From f2af57c6d7b67a3a8f0f74f68b77f51f3d1fecb2 Mon Sep 17 00:00:00 2001 From: Alexander Alekhin Date: Tue, 22 Nov 2016 02:05:56 +0300 Subject: [PATCH 1/3] 3rdparty: remove protobuf sources --- modules/dnn/3rdparty/protobuf/CHANGES.txt | 528 -- .../dnn/3rdparty/protobuf/CONTRIBUTORS.txt | 90 - modules/dnn/3rdparty/protobuf/COPYING.txt | 33 - modules/dnn/3rdparty/protobuf/README.txt | 152 - .../dnn/3rdparty/protobuf/cmake/.gitignore | 2 - .../protobuf/cmake/CheckCxxHashmap.cmake | 55 - .../protobuf/cmake/CheckCxxHashset.cmake | 54 - modules/dnn/3rdparty/protobuf/cmake/LICENSE | 31 - .../dnn/3rdparty/protobuf/cmake/config.h.in | 62 - .../protobuf/compiler/code_generator.cc | 80 - .../google/protobuf/compiler/code_generator.h | 142 - .../compiler/command_line_interface.cc | 1437 --- .../compiler/command_line_interface.h | 353 - .../command_line_interface_unittest.cc | 1560 ---- .../compiler/cpp/cpp_bootstrap_unittest.cc | 158 - .../google/protobuf/compiler/cpp/cpp_enum.cc | 258 - .../google/protobuf/compiler/cpp/cpp_enum.h | 101 - .../protobuf/compiler/cpp/cpp_enum_field.cc | 366 - .../protobuf/compiler/cpp/cpp_enum_field.h | 105 - .../protobuf/compiler/cpp/cpp_extension.cc | 210 - .../protobuf/compiler/cpp/cpp_extension.h | 86 - .../google/protobuf/compiler/cpp/cpp_field.cc | 142 - .../google/protobuf/compiler/cpp/cpp_field.h | 177 - .../google/protobuf/compiler/cpp/cpp_file.cc | 652 -- .../google/protobuf/compiler/cpp/cpp_file.h | 99 - .../protobuf/compiler/cpp/cpp_generator.cc | 124 - .../protobuf/compiler/cpp/cpp_generator.h | 72 - .../protobuf/compiler/cpp/cpp_helpers.cc | 438 - .../protobuf/compiler/cpp/cpp_helpers.h | 186 - .../protobuf/compiler/cpp/cpp_message.cc | 2020 ---- .../protobuf/compiler/cpp/cpp_message.h | 171 - .../compiler/cpp/cpp_message_field.cc | 298 - .../protobuf/compiler/cpp/cpp_message_field.h | 104 - .../protobuf/compiler/cpp/cpp_options.h | 58 - .../compiler/cpp/cpp_plugin_unittest.cc | 121 - .../compiler/cpp/cpp_primitive_field.cc | 387 - .../compiler/cpp/cpp_primitive_field.h | 105 - .../protobuf/compiler/cpp/cpp_service.cc | 334 - .../protobuf/compiler/cpp/cpp_service.h | 119 - .../protobuf/compiler/cpp/cpp_string_field.cc | 491 - .../protobuf/compiler/cpp/cpp_string_field.h | 108 - .../cpp/cpp_test_bad_identifiers.proto | 123 - .../protobuf/compiler/cpp/cpp_unittest.cc | 1354 --- .../protobuf/compiler/cpp/cpp_unittest.h | 51 - .../src/google/protobuf/compiler/importer.cc | 459 - .../src/google/protobuf/compiler/importer.h | 304 - .../protobuf/compiler/importer_unittest.cc | 600 -- .../compiler/java/java_doc_comment.cc | 236 - .../protobuf/compiler/java/java_doc_comment.h | 69 - .../java/java_doc_comment_unittest.cc | 66 - .../protobuf/compiler/java/java_enum.cc | 271 - .../google/protobuf/compiler/java/java_enum.h | 86 - .../protobuf/compiler/java/java_enum_field.cc | 603 -- .../protobuf/compiler/java/java_enum_field.h | 123 - .../protobuf/compiler/java/java_extension.cc | 218 - .../protobuf/compiler/java/java_extension.h | 77 - .../protobuf/compiler/java/java_field.cc | 137 - .../protobuf/compiler/java/java_field.h | 109 - .../protobuf/compiler/java/java_file.cc | 490 - .../google/protobuf/compiler/java/java_file.h | 101 - .../protobuf/compiler/java/java_generator.cc | 128 - .../protobuf/compiler/java/java_generator.h | 72 - .../protobuf/compiler/java/java_helpers.cc | 500 - .../protobuf/compiler/java/java_helpers.h | 220 - .../protobuf/compiler/java/java_message.cc | 1435 --- .../protobuf/compiler/java/java_message.h | 112 - .../compiler/java/java_message_field.cc | 974 -- .../compiler/java/java_message_field.h | 136 - .../compiler/java/java_plugin_unittest.cc | 122 - .../compiler/java/java_primitive_field.cc | 787 -- .../compiler/java/java_primitive_field.h | 123 - .../protobuf/compiler/java/java_service.cc | 453 - .../protobuf/compiler/java/java_service.h | 113 - .../compiler/java/java_string_field.cc | 726 -- .../compiler/java/java_string_field.h | 122 - .../src/google/protobuf/compiler/main.cc | 61 - .../protobuf/compiler/mock_code_generator.cc | 241 - .../protobuf/compiler/mock_code_generator.h | 117 - .../google/protobuf/compiler/package_info.h | 64 - .../src/google/protobuf/compiler/parser.cc | 1611 ---- .../src/google/protobuf/compiler/parser.h | 477 - .../protobuf/compiler/parser_unittest.cc | 2374 ----- .../src/google/protobuf/compiler/plugin.cc | 163 - .../src/google/protobuf/compiler/plugin.h | 72 - .../src/google/protobuf/compiler/plugin.pb.cc | 1090 --- .../src/google/protobuf/compiler/plugin.pb.h | 856 -- .../src/google/protobuf/compiler/plugin.proto | 147 - .../compiler/python/python_generator.cc | 1157 --- .../compiler/python/python_generator.h | 161 - .../compiler/python/python_plugin_unittest.cc | 116 - .../google/protobuf/compiler/subprocess.cc | 463 - .../src/google/protobuf/compiler/subprocess.h | 108 - .../google/protobuf/compiler/test_plugin.cc | 51 - .../protobuf/compiler/zip_output_unittest.sh | 91 - .../google/protobuf/compiler/zip_writer.cc | 218 - .../src/google/protobuf/compiler/zip_writer.h | 93 - .../src/google/protobuf/descriptor.cc | 4948 ---------- .../protobuf/src/google/protobuf/descriptor.h | 1521 --- .../src/google/protobuf/descriptor.pb.cc | 8146 ----------------- .../src/google/protobuf/descriptor.pb.h | 5992 ------------ .../src/google/protobuf/descriptor.proto | 620 -- .../google/protobuf/descriptor_database.cc | 541 -- .../src/google/protobuf/descriptor_database.h | 367 - .../protobuf/descriptor_database_unittest.cc | 748 -- .../google/protobuf/descriptor_unittest.cc | 4656 ---------- .../src/google/protobuf/dynamic_message.cc | 571 -- .../src/google/protobuf/dynamic_message.h | 136 - .../protobuf/dynamic_message_unittest.cc | 166 - .../src/google/protobuf/extension_set.cc | 1461 --- .../src/google/protobuf/extension_set.h | 1007 -- .../google/protobuf/extension_set_heavy.cc | 711 -- .../google/protobuf/extension_set_unittest.cc | 726 -- .../protobuf/generated_enum_reflection.h | 85 - .../protobuf/generated_message_reflection.cc | 1293 --- .../protobuf/generated_message_reflection.h | 419 - .../generated_message_reflection_unittest.cc | 484 - .../google/protobuf/generated_message_util.cc | 54 - .../google/protobuf/generated_message_util.h | 77 - .../src/google/protobuf/io/coded_stream.cc | 857 -- .../src/google/protobuf/io/coded_stream.h | 1136 --- .../src/google/protobuf/io/coded_stream_inl.h | 68 - .../protobuf/io/coded_stream_unittest.cc | 1191 --- .../src/google/protobuf/io/gzip_stream.cc | 326 - .../src/google/protobuf/io/gzip_stream.h | 209 - .../protobuf/io/gzip_stream_unittest.sh | 44 - .../src/google/protobuf/io/package_info.h | 54 - .../src/google/protobuf/io/printer.cc | 198 - .../protobuf/src/google/protobuf/io/printer.h | 136 - .../google/protobuf/io/printer_unittest.cc | 285 - .../src/google/protobuf/io/tokenizer.cc | 1091 --- .../src/google/protobuf/io/tokenizer.h | 384 - .../google/protobuf/io/tokenizer_unittest.cc | 1001 -- .../google/protobuf/io/zero_copy_stream.cc | 48 - .../src/google/protobuf/io/zero_copy_stream.h | 238 - .../protobuf/io/zero_copy_stream_impl.cc | 471 - .../protobuf/io/zero_copy_stream_impl.h | 357 - .../protobuf/io/zero_copy_stream_impl_lite.cc | 394 - .../protobuf/io/zero_copy_stream_impl_lite.h | 340 - .../protobuf/io/zero_copy_stream_unittest.cc | 944 -- .../src/google/protobuf/lite_unittest.cc | 185 - .../protobuf/src/google/protobuf/message.cc | 358 - .../protobuf/src/google/protobuf/message.h | 837 -- .../src/google/protobuf/message_lite.cc | 334 - .../src/google/protobuf/message_lite.h | 246 - .../src/google/protobuf/message_unittest.cc | 354 - .../src/google/protobuf/package_info.h | 64 - .../src/google/protobuf/reflection_ops.cc | 267 - .../src/google/protobuf/reflection_ops.h | 81 - .../protobuf/reflection_ops_unittest.cc | 405 - .../src/google/protobuf/repeated_field.cc | 87 - .../src/google/protobuf/repeated_field.h | 1519 --- .../repeated_field_reflection_unittest.cc | 195 - .../protobuf/repeated_field_unittest.cc | 1357 --- .../protobuf/src/google/protobuf/service.cc | 46 - .../protobuf/src/google/protobuf/service.h | 291 - .../src/google/protobuf/stubs/atomicops.h | 206 - .../stubs/atomicops_internals_arm_gcc.h | 151 - .../stubs/atomicops_internals_arm_qnx.h | 146 - .../atomicops_internals_atomicword_compat.h | 122 - .../stubs/atomicops_internals_macosx.h | 225 - .../stubs/atomicops_internals_mips_gcc.h | 187 - .../stubs/atomicops_internals_pnacl.h | 73 - .../stubs/atomicops_internals_x86_gcc.cc | 137 - .../stubs/atomicops_internals_x86_gcc.h | 293 - .../stubs/atomicops_internals_x86_msvc.cc | 112 - .../stubs/atomicops_internals_x86_msvc.h | 150 - .../src/google/protobuf/stubs/common.cc | 395 - .../src/google/protobuf/stubs/common.h | 1223 --- .../google/protobuf/stubs/common_unittest.cc | 357 - .../protobuf/src/google/protobuf/stubs/hash.h | 232 - .../src/google/protobuf/stubs/map-util.h | 143 - .../src/google/protobuf/stubs/once.cc | 99 - .../protobuf/src/google/protobuf/stubs/once.h | 148 - .../google/protobuf/stubs/once_unittest.cc | 253 - .../google/protobuf/stubs/platform_macros.h | 70 - .../src/google/protobuf/stubs/stl_util.h | 121 - .../src/google/protobuf/stubs/stringprintf.cc | 175 - .../src/google/protobuf/stubs/stringprintf.h | 76 - .../protobuf/stubs/stringprintf_unittest.cc | 152 - .../protobuf/stubs/structurally_valid.cc | 536 -- .../stubs/structurally_valid_unittest.cc | 40 - .../src/google/protobuf/stubs/strutil.cc | 1204 --- .../src/google/protobuf/stubs/strutil.h | 467 - .../google/protobuf/stubs/strutil_unittest.cc | 83 - .../src/google/protobuf/stubs/substitute.cc | 134 - .../src/google/protobuf/stubs/substitute.h | 170 - .../src/google/protobuf/stubs/template_util.h | 138 - .../protobuf/stubs/template_util_unittest.cc | 130 - .../src/google/protobuf/stubs/type_traits.h | 336 - .../protobuf/stubs/type_traits_unittest.cc | 628 -- .../protobuf/src/google/protobuf/test_util.cc | 3047 ------ .../protobuf/src/google/protobuf/test_util.h | 193 - .../src/google/protobuf/test_util_lite.cc | 1548 ---- .../src/google/protobuf/test_util_lite.h | 101 - .../src/google/protobuf/testing/file.cc | 176 - .../src/google/protobuf/testing/file.h | 83 - .../src/google/protobuf/testing/googletest.cc | 255 - .../src/google/protobuf/testing/googletest.h | 102 - .../src/google/protobuf/testing/zcgunzip.cc | 73 - .../src/google/protobuf/testing/zcgzip.cc | 79 - .../src/google/protobuf/text_format.cc | 1521 --- .../src/google/protobuf/text_format.h | 369 - .../google/protobuf/text_format_unittest.cc | 1248 --- .../src/google/protobuf/unknown_field_set.cc | 266 - .../src/google/protobuf/unknown_field_set.h | 311 - .../protobuf/unknown_field_set_unittest.cc | 594 -- .../src/google/protobuf/wire_format.cc | 1054 --- .../src/google/protobuf/wire_format.h | 308 - .../src/google/protobuf/wire_format_lite.cc | 361 - .../src/google/protobuf/wire_format_lite.h | 622 -- .../google/protobuf/wire_format_lite_inl.h | 776 -- .../google/protobuf/wire_format_unittest.cc | 978 -- 212 files changed, 107604 deletions(-) delete mode 100644 modules/dnn/3rdparty/protobuf/CHANGES.txt delete mode 100644 modules/dnn/3rdparty/protobuf/CONTRIBUTORS.txt delete mode 100644 modules/dnn/3rdparty/protobuf/COPYING.txt delete mode 100644 modules/dnn/3rdparty/protobuf/README.txt delete mode 100644 modules/dnn/3rdparty/protobuf/cmake/.gitignore delete mode 100644 modules/dnn/3rdparty/protobuf/cmake/CheckCxxHashmap.cmake delete mode 100644 modules/dnn/3rdparty/protobuf/cmake/CheckCxxHashset.cmake delete mode 100644 modules/dnn/3rdparty/protobuf/cmake/LICENSE delete mode 100644 modules/dnn/3rdparty/protobuf/cmake/config.h.in delete mode 100644 modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/code_generator.cc delete mode 100644 modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/code_generator.h delete mode 100644 modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/command_line_interface.cc delete mode 100644 modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/command_line_interface.h delete mode 100644 modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/command_line_interface_unittest.cc delete mode 100644 modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/cpp/cpp_bootstrap_unittest.cc delete mode 100644 modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/cpp/cpp_enum.cc delete mode 100644 modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/cpp/cpp_enum.h delete mode 100644 modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/cpp/cpp_enum_field.cc delete mode 100644 modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/cpp/cpp_enum_field.h delete mode 100644 modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/cpp/cpp_extension.cc delete mode 100644 modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/cpp/cpp_extension.h delete mode 100644 modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/cpp/cpp_field.cc delete mode 100644 modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/cpp/cpp_field.h delete mode 100644 modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/cpp/cpp_file.cc delete mode 100644 modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/cpp/cpp_file.h delete mode 100644 modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/cpp/cpp_generator.cc delete mode 100644 modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/cpp/cpp_generator.h delete mode 100644 modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/cpp/cpp_helpers.cc delete mode 100644 modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/cpp/cpp_helpers.h delete mode 100644 modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/cpp/cpp_message.cc delete mode 100644 modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/cpp/cpp_message.h delete mode 100644 modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/cpp/cpp_message_field.cc delete mode 100644 modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/cpp/cpp_message_field.h delete mode 100644 modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/cpp/cpp_options.h delete mode 100644 modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/cpp/cpp_plugin_unittest.cc delete mode 100644 modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/cpp/cpp_primitive_field.cc delete mode 100644 modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/cpp/cpp_primitive_field.h delete mode 100644 modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/cpp/cpp_service.cc delete mode 100644 modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/cpp/cpp_service.h delete mode 100644 modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/cpp/cpp_string_field.cc delete mode 100644 modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/cpp/cpp_string_field.h delete mode 100644 modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/cpp/cpp_test_bad_identifiers.proto delete mode 100644 modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/cpp/cpp_unittest.cc delete mode 100644 modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/cpp/cpp_unittest.h delete mode 100644 modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/importer.cc delete mode 100644 modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/importer.h delete mode 100644 modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/importer_unittest.cc delete mode 100644 modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/java/java_doc_comment.cc delete mode 100644 modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/java/java_doc_comment.h delete mode 100644 modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/java/java_doc_comment_unittest.cc delete mode 100644 modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/java/java_enum.cc delete mode 100644 modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/java/java_enum.h delete mode 100644 modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/java/java_enum_field.cc delete mode 100644 modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/java/java_enum_field.h delete mode 100644 modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/java/java_extension.cc delete mode 100644 modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/java/java_extension.h delete mode 100644 modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/java/java_field.cc delete mode 100644 modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/java/java_field.h delete mode 100644 modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/java/java_file.cc delete mode 100644 modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/java/java_file.h delete mode 100644 modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/java/java_generator.cc delete mode 100644 modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/java/java_generator.h delete mode 100644 modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/java/java_helpers.cc delete mode 100644 modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/java/java_helpers.h delete mode 100644 modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/java/java_message.cc delete mode 100644 modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/java/java_message.h delete mode 100644 modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/java/java_message_field.cc delete mode 100644 modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/java/java_message_field.h delete mode 100644 modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/java/java_plugin_unittest.cc delete mode 100644 modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/java/java_primitive_field.cc delete mode 100644 modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/java/java_primitive_field.h delete mode 100644 modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/java/java_service.cc delete mode 100644 modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/java/java_service.h delete mode 100644 modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/java/java_string_field.cc delete mode 100644 modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/java/java_string_field.h delete mode 100644 modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/main.cc delete mode 100644 modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/mock_code_generator.cc delete mode 100644 modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/mock_code_generator.h delete mode 100644 modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/package_info.h delete mode 100644 modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/parser.cc delete mode 100644 modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/parser.h delete mode 100644 modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/parser_unittest.cc delete mode 100644 modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/plugin.cc delete mode 100644 modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/plugin.h delete mode 100644 modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/plugin.pb.cc delete mode 100644 modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/plugin.pb.h delete mode 100644 modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/plugin.proto delete mode 100644 modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/python/python_generator.cc delete mode 100644 modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/python/python_generator.h delete mode 100644 modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/python/python_plugin_unittest.cc delete mode 100644 modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/subprocess.cc delete mode 100644 modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/subprocess.h delete mode 100644 modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/test_plugin.cc delete mode 100644 modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/zip_output_unittest.sh delete mode 100644 modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/zip_writer.cc delete mode 100644 modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/zip_writer.h delete mode 100644 modules/dnn/3rdparty/protobuf/src/google/protobuf/descriptor.cc delete mode 100644 modules/dnn/3rdparty/protobuf/src/google/protobuf/descriptor.h delete mode 100644 modules/dnn/3rdparty/protobuf/src/google/protobuf/descriptor.pb.cc delete mode 100644 modules/dnn/3rdparty/protobuf/src/google/protobuf/descriptor.pb.h delete mode 100644 modules/dnn/3rdparty/protobuf/src/google/protobuf/descriptor.proto delete mode 100644 modules/dnn/3rdparty/protobuf/src/google/protobuf/descriptor_database.cc delete mode 100644 modules/dnn/3rdparty/protobuf/src/google/protobuf/descriptor_database.h delete mode 100644 modules/dnn/3rdparty/protobuf/src/google/protobuf/descriptor_database_unittest.cc delete mode 100644 modules/dnn/3rdparty/protobuf/src/google/protobuf/descriptor_unittest.cc delete mode 100644 modules/dnn/3rdparty/protobuf/src/google/protobuf/dynamic_message.cc delete mode 100644 modules/dnn/3rdparty/protobuf/src/google/protobuf/dynamic_message.h delete mode 100644 modules/dnn/3rdparty/protobuf/src/google/protobuf/dynamic_message_unittest.cc delete mode 100644 modules/dnn/3rdparty/protobuf/src/google/protobuf/extension_set.cc delete mode 100644 modules/dnn/3rdparty/protobuf/src/google/protobuf/extension_set.h delete mode 100644 modules/dnn/3rdparty/protobuf/src/google/protobuf/extension_set_heavy.cc delete mode 100644 modules/dnn/3rdparty/protobuf/src/google/protobuf/extension_set_unittest.cc delete mode 100644 modules/dnn/3rdparty/protobuf/src/google/protobuf/generated_enum_reflection.h delete mode 100644 modules/dnn/3rdparty/protobuf/src/google/protobuf/generated_message_reflection.cc delete mode 100644 modules/dnn/3rdparty/protobuf/src/google/protobuf/generated_message_reflection.h delete mode 100644 modules/dnn/3rdparty/protobuf/src/google/protobuf/generated_message_reflection_unittest.cc delete mode 100644 modules/dnn/3rdparty/protobuf/src/google/protobuf/generated_message_util.cc delete mode 100644 modules/dnn/3rdparty/protobuf/src/google/protobuf/generated_message_util.h delete mode 100644 modules/dnn/3rdparty/protobuf/src/google/protobuf/io/coded_stream.cc delete mode 100644 modules/dnn/3rdparty/protobuf/src/google/protobuf/io/coded_stream.h delete mode 100644 modules/dnn/3rdparty/protobuf/src/google/protobuf/io/coded_stream_inl.h delete mode 100644 modules/dnn/3rdparty/protobuf/src/google/protobuf/io/coded_stream_unittest.cc delete mode 100644 modules/dnn/3rdparty/protobuf/src/google/protobuf/io/gzip_stream.cc delete mode 100644 modules/dnn/3rdparty/protobuf/src/google/protobuf/io/gzip_stream.h delete mode 100644 modules/dnn/3rdparty/protobuf/src/google/protobuf/io/gzip_stream_unittest.sh delete mode 100644 modules/dnn/3rdparty/protobuf/src/google/protobuf/io/package_info.h delete mode 100644 modules/dnn/3rdparty/protobuf/src/google/protobuf/io/printer.cc delete mode 100644 modules/dnn/3rdparty/protobuf/src/google/protobuf/io/printer.h delete mode 100644 modules/dnn/3rdparty/protobuf/src/google/protobuf/io/printer_unittest.cc delete mode 100644 modules/dnn/3rdparty/protobuf/src/google/protobuf/io/tokenizer.cc delete mode 100644 modules/dnn/3rdparty/protobuf/src/google/protobuf/io/tokenizer.h delete mode 100644 modules/dnn/3rdparty/protobuf/src/google/protobuf/io/tokenizer_unittest.cc delete mode 100644 modules/dnn/3rdparty/protobuf/src/google/protobuf/io/zero_copy_stream.cc delete mode 100644 modules/dnn/3rdparty/protobuf/src/google/protobuf/io/zero_copy_stream.h delete mode 100644 modules/dnn/3rdparty/protobuf/src/google/protobuf/io/zero_copy_stream_impl.cc delete mode 100644 modules/dnn/3rdparty/protobuf/src/google/protobuf/io/zero_copy_stream_impl.h delete mode 100644 modules/dnn/3rdparty/protobuf/src/google/protobuf/io/zero_copy_stream_impl_lite.cc delete mode 100644 modules/dnn/3rdparty/protobuf/src/google/protobuf/io/zero_copy_stream_impl_lite.h delete mode 100644 modules/dnn/3rdparty/protobuf/src/google/protobuf/io/zero_copy_stream_unittest.cc delete mode 100644 modules/dnn/3rdparty/protobuf/src/google/protobuf/lite_unittest.cc delete mode 100644 modules/dnn/3rdparty/protobuf/src/google/protobuf/message.cc delete mode 100644 modules/dnn/3rdparty/protobuf/src/google/protobuf/message.h delete mode 100644 modules/dnn/3rdparty/protobuf/src/google/protobuf/message_lite.cc delete mode 100644 modules/dnn/3rdparty/protobuf/src/google/protobuf/message_lite.h delete mode 100644 modules/dnn/3rdparty/protobuf/src/google/protobuf/message_unittest.cc delete mode 100644 modules/dnn/3rdparty/protobuf/src/google/protobuf/package_info.h delete mode 100644 modules/dnn/3rdparty/protobuf/src/google/protobuf/reflection_ops.cc delete mode 100644 modules/dnn/3rdparty/protobuf/src/google/protobuf/reflection_ops.h delete mode 100644 modules/dnn/3rdparty/protobuf/src/google/protobuf/reflection_ops_unittest.cc delete mode 100644 modules/dnn/3rdparty/protobuf/src/google/protobuf/repeated_field.cc delete mode 100644 modules/dnn/3rdparty/protobuf/src/google/protobuf/repeated_field.h delete mode 100644 modules/dnn/3rdparty/protobuf/src/google/protobuf/repeated_field_reflection_unittest.cc delete mode 100644 modules/dnn/3rdparty/protobuf/src/google/protobuf/repeated_field_unittest.cc delete mode 100644 modules/dnn/3rdparty/protobuf/src/google/protobuf/service.cc delete mode 100644 modules/dnn/3rdparty/protobuf/src/google/protobuf/service.h delete mode 100644 modules/dnn/3rdparty/protobuf/src/google/protobuf/stubs/atomicops.h delete mode 100644 modules/dnn/3rdparty/protobuf/src/google/protobuf/stubs/atomicops_internals_arm_gcc.h delete mode 100644 modules/dnn/3rdparty/protobuf/src/google/protobuf/stubs/atomicops_internals_arm_qnx.h delete mode 100644 modules/dnn/3rdparty/protobuf/src/google/protobuf/stubs/atomicops_internals_atomicword_compat.h delete mode 100644 modules/dnn/3rdparty/protobuf/src/google/protobuf/stubs/atomicops_internals_macosx.h delete mode 100644 modules/dnn/3rdparty/protobuf/src/google/protobuf/stubs/atomicops_internals_mips_gcc.h delete mode 100644 modules/dnn/3rdparty/protobuf/src/google/protobuf/stubs/atomicops_internals_pnacl.h delete mode 100644 modules/dnn/3rdparty/protobuf/src/google/protobuf/stubs/atomicops_internals_x86_gcc.cc delete mode 100644 modules/dnn/3rdparty/protobuf/src/google/protobuf/stubs/atomicops_internals_x86_gcc.h delete mode 100644 modules/dnn/3rdparty/protobuf/src/google/protobuf/stubs/atomicops_internals_x86_msvc.cc delete mode 100644 modules/dnn/3rdparty/protobuf/src/google/protobuf/stubs/atomicops_internals_x86_msvc.h delete mode 100644 modules/dnn/3rdparty/protobuf/src/google/protobuf/stubs/common.cc delete mode 100644 modules/dnn/3rdparty/protobuf/src/google/protobuf/stubs/common.h delete mode 100644 modules/dnn/3rdparty/protobuf/src/google/protobuf/stubs/common_unittest.cc delete mode 100644 modules/dnn/3rdparty/protobuf/src/google/protobuf/stubs/hash.h delete mode 100644 modules/dnn/3rdparty/protobuf/src/google/protobuf/stubs/map-util.h delete mode 100644 modules/dnn/3rdparty/protobuf/src/google/protobuf/stubs/once.cc delete mode 100644 modules/dnn/3rdparty/protobuf/src/google/protobuf/stubs/once.h delete mode 100644 modules/dnn/3rdparty/protobuf/src/google/protobuf/stubs/once_unittest.cc delete mode 100644 modules/dnn/3rdparty/protobuf/src/google/protobuf/stubs/platform_macros.h delete mode 100644 modules/dnn/3rdparty/protobuf/src/google/protobuf/stubs/stl_util.h delete mode 100644 modules/dnn/3rdparty/protobuf/src/google/protobuf/stubs/stringprintf.cc delete mode 100644 modules/dnn/3rdparty/protobuf/src/google/protobuf/stubs/stringprintf.h delete mode 100644 modules/dnn/3rdparty/protobuf/src/google/protobuf/stubs/stringprintf_unittest.cc delete mode 100644 modules/dnn/3rdparty/protobuf/src/google/protobuf/stubs/structurally_valid.cc delete mode 100644 modules/dnn/3rdparty/protobuf/src/google/protobuf/stubs/structurally_valid_unittest.cc delete mode 100644 modules/dnn/3rdparty/protobuf/src/google/protobuf/stubs/strutil.cc delete mode 100644 modules/dnn/3rdparty/protobuf/src/google/protobuf/stubs/strutil.h delete mode 100644 modules/dnn/3rdparty/protobuf/src/google/protobuf/stubs/strutil_unittest.cc delete mode 100644 modules/dnn/3rdparty/protobuf/src/google/protobuf/stubs/substitute.cc delete mode 100644 modules/dnn/3rdparty/protobuf/src/google/protobuf/stubs/substitute.h delete mode 100644 modules/dnn/3rdparty/protobuf/src/google/protobuf/stubs/template_util.h delete mode 100644 modules/dnn/3rdparty/protobuf/src/google/protobuf/stubs/template_util_unittest.cc delete mode 100644 modules/dnn/3rdparty/protobuf/src/google/protobuf/stubs/type_traits.h delete mode 100644 modules/dnn/3rdparty/protobuf/src/google/protobuf/stubs/type_traits_unittest.cc delete mode 100644 modules/dnn/3rdparty/protobuf/src/google/protobuf/test_util.cc delete mode 100644 modules/dnn/3rdparty/protobuf/src/google/protobuf/test_util.h delete mode 100644 modules/dnn/3rdparty/protobuf/src/google/protobuf/test_util_lite.cc delete mode 100644 modules/dnn/3rdparty/protobuf/src/google/protobuf/test_util_lite.h delete mode 100644 modules/dnn/3rdparty/protobuf/src/google/protobuf/testing/file.cc delete mode 100644 modules/dnn/3rdparty/protobuf/src/google/protobuf/testing/file.h delete mode 100644 modules/dnn/3rdparty/protobuf/src/google/protobuf/testing/googletest.cc delete mode 100644 modules/dnn/3rdparty/protobuf/src/google/protobuf/testing/googletest.h delete mode 100644 modules/dnn/3rdparty/protobuf/src/google/protobuf/testing/zcgunzip.cc delete mode 100644 modules/dnn/3rdparty/protobuf/src/google/protobuf/testing/zcgzip.cc delete mode 100644 modules/dnn/3rdparty/protobuf/src/google/protobuf/text_format.cc delete mode 100644 modules/dnn/3rdparty/protobuf/src/google/protobuf/text_format.h delete mode 100644 modules/dnn/3rdparty/protobuf/src/google/protobuf/text_format_unittest.cc delete mode 100644 modules/dnn/3rdparty/protobuf/src/google/protobuf/unknown_field_set.cc delete mode 100644 modules/dnn/3rdparty/protobuf/src/google/protobuf/unknown_field_set.h delete mode 100644 modules/dnn/3rdparty/protobuf/src/google/protobuf/unknown_field_set_unittest.cc delete mode 100644 modules/dnn/3rdparty/protobuf/src/google/protobuf/wire_format.cc delete mode 100644 modules/dnn/3rdparty/protobuf/src/google/protobuf/wire_format.h delete mode 100644 modules/dnn/3rdparty/protobuf/src/google/protobuf/wire_format_lite.cc delete mode 100644 modules/dnn/3rdparty/protobuf/src/google/protobuf/wire_format_lite.h delete mode 100644 modules/dnn/3rdparty/protobuf/src/google/protobuf/wire_format_lite_inl.h delete mode 100644 modules/dnn/3rdparty/protobuf/src/google/protobuf/wire_format_unittest.cc diff --git a/modules/dnn/3rdparty/protobuf/CHANGES.txt b/modules/dnn/3rdparty/protobuf/CHANGES.txt deleted file mode 100644 index 5eefe9a81..000000000 --- a/modules/dnn/3rdparty/protobuf/CHANGES.txt +++ /dev/null @@ -1,528 +0,0 @@ -2013-02-27 version 2.5.0: - - General - * New notion "import public" that allows a proto file to forward the content - it imports to its importers. For example, - // foo.proto - import public "bar.proto"; - import "baz.proto"; - - // qux.proto - import "foo.proto"; - // Stuff defined in bar.proto may be used in this file, but stuff from - // baz.proto may NOT be used without importing it explicitly. - This is useful for moving proto files. To move a proto file, just leave - a single "import public" in the old proto file. - * New enum option "allow_alias" that specifies whether different symbols can - be assigned the same numeric value. Default value is "true". Setting it to - false causes the compiler to reject enum definitions where multiple symbols - have the same numeric value. - - C++ - * New generated method set_allocated_foo(Type* foo) for message and string - fields. This method allows you to set the field to a pre-allocated object - and the containing message takes the ownership of that object. - * Added SetAllocatedExtension() and ReleaseExtension() to extensions API. - * Custom options are now formatted correctly when descriptors are printed in - text format. - * Various speed optimizations. - - Java - * Comments in proto files are now collected and put into generated code as - comments for corresponding classes and data members. - * Added Parser to parse directly into messages without a Builder. For - example, - Foo foo = Foo.PARSER.ParseFrom(input); - Using Parser is ~25% faster than using Builder to parse messages. - * Added getters/setters to access the underlying ByteString of a string field - directly. - * ByteString now supports more operations: substring(), prepend(), and - append(). The implementation of ByteString uses a binary tree structure - to support these operations efficiently. - * New method findInitializationErrors() that lists all missing required - fields. - * Various code size and speed optimizations. - - Python - * Added support for dynamic message creation. DescriptorDatabase, - DescriptorPool, and MessageFactory work like their C++ couterparts to - simplify Descriptor construction from *DescriptorProtos, and MessageFactory - provides a message instance from a Descriptor. - * Added pickle support for protobuf messages. - * Unknown fields are now preserved after parsing. - * Fixed bug where custom options were not correctly populated. Custom - options can be accessed now. - * Added EnumTypeWrapper that provides better accessibility to enum types. - * Added ParseMessage(descriptor, bytes) to generate a new Message instance - from a descriptor and a byte string. - -2011-05-01 version 2.4.1: - - C++ - * Fixed the frendship problem for old compilers to make the library now gcc 3 - compatible again. - * Fixed vcprojects/extract_includes.bat to extract compiler/plugin.h. - - Java - * Removed usages of JDK 1.6 only features to make the library now JDK 1.5 - compatible again. - * Fixed a bug about negative enum values. - * serialVersionUID is now defined in generated messages for java serializing. - * Fixed protoc to use java.lang.Object, which makes "Object" now a valid - message name again. - - Python - * Experimental C++ implementation now requires C++ protobuf library installed. - See the README.txt in the python directory for details. - -2011-02-02 version 2.4.0: - - General - * The RPC (cc|java|py)_generic_services default value is now false instead of - true. - * Custom options can have aggregate types. For example, - message MyOption { - optional string comment = 1; - optional string author = 2; - } - extend google.protobuf.FieldOptions { - optional MyOption myoption = 12345; - } - This option can now be set as follows: - message SomeType { - optional int32 field = 1 [(myoption) = { comment:'x' author:'y' }]; - } - - C++ - * Various speed and code size optimizations. - * Added a release_foo() method on string and message fields. - * Fixed gzip_output_stream sub-stream handling. - - Java - * Builders now maintain sub-builders for sub-messages. Use getFooBuilder() to - get the builder for the sub-message "foo". This allows you to repeatedly - modify deeply-nested sub-messages without rebuilding them. - * Builder.build() no longer invalidates the Builder for generated messages - (You may continue to modify it and then build another message). - * Code generator will generate efficient equals() and hashCode() - implementations if new option java_generate_equals_and_hash is enabled. - (Otherwise, reflection-based implementations are used.) - * Generated messages now implement Serializable. - * Fields with [deprecated=true] will be marked with @Deprecated in Java. - * Added lazy conversion of UTF-8 encoded strings to String objects to improve - performance. - * Various optimizations. - * Enum value can be accessed directly, instead of calling getNumber() on the - enum member. - * For each enum value, an integer constant is also generated with the suffix - _VALUE. - - Python - * Added an experimental C++ implementation for Python messages via a Python - extension. Implementation type is controlled by an environment variable - PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION (valid values: "cpp" and "python") - The default value is currently "python" but will be changed to "cpp" in - future release. - * Improved performance on message instantiation significantly. - Most of the work on message instantiation is done just once per message - class, instead of once per message instance. - * Improved performance on text message parsing. - * Allow add() to forward keyword arguments to the concrete class. - E.g. instead of - item = repeated_field.add() - item.foo = bar - item.baz = quux - You can do: - repeated_field.add(foo=bar, baz=quux) - * Added a sort() interface to the BaseContainer. - * Added an extend() method to repeated composite fields. - * Added UTF8 debug string support. - -2010-01-08 version 2.3.0: - - General - * Parsers for repeated numeric fields now always accept both packed and - unpacked input. The [packed=true] option only affects serializers. - Therefore, it is possible to switch a field to packed format without - breaking backwards-compatibility -- as long as all parties are using - protobuf 2.3.0 or above, at least. - * The generic RPC service code generated by the C++, Java, and Python - generators can be disabled via file options: - option cc_generic_services = false; - option java_generic_services = false; - option py_generic_services = false; - This allows plugins to generate alternative code, possibly specific to some - particular RPC implementation. - - protoc - * Now supports a plugin system for code generators. Plugins can generate - code for new languages or inject additional code into the output of other - code generators. Plugins are just binaries which accept a protocol buffer - on stdin and write a protocol buffer to stdout, so they may be written in - any language. See src/google/protobuf/compiler/plugin.proto. - **WARNING**: Plugins are experimental. The interface may change in a - future version. - * If the output location ends in .zip or .jar, protoc will write its output - to a zip/jar archive instead of a directory. For example: - protoc --java_out=myproto_srcs.jar --python_out=myproto.zip myproto.proto - Currently the archive contents are not compressed, though this could change - in the future. - * inf, -inf, and nan can now be used as default values for float and double - fields. - - C++ - * Various speed and code size optimizations. - * DynamicMessageFactory is now fully thread-safe. - * Message::Utf8DebugString() method is like DebugString() but avoids escaping - UTF-8 bytes. - * Compiled-in message types can now contain dynamic extensions, through use - of CodedInputStream::SetExtensionRegistry(). - * Now compiles shared libraries (DLLs) by default on Cygwin and MinGW, to - match other platforms. Use --disable-shared to avoid this. - - Java - * parseDelimitedFrom() and mergeDelimitedFrom() now detect EOF and return - false/null instead of throwing an exception. - * Fixed some initialization ordering bugs. - * Fixes for OpenJDK 7. - - Python - * 10-25 times faster than 2.2.0, still pure-Python. - * Calling a mutating method on a sub-message always instantiates the message - in its parent even if the mutating method doesn't actually mutate anything - (e.g. parsing from an empty string). - * Expanded descriptors a bit. - -2009-08-11 version 2.2.0: - - C++ - * Lite mode: The "optimize_for = LITE_RUNTIME" option causes the compiler - to generate code which only depends libprotobuf-lite, which is much smaller - than libprotobuf but lacks descriptors, reflection, and some other features. - * Fixed bug where Message.Swap(Message) was only implemented for - optimize_for_speed. Swap now properly implemented in both modes - (Issue 91). - * Added RemoveLast and SwapElements(index1, index2) to Reflection - interface for repeated elements. - * Added Swap(Message) to Reflection interface. - * Floating-point literals in generated code that are intended to be - single-precision now explicitly have 'f' suffix to avoid pedantic warnings - produced by some compilers. - * The [deprecated=true] option now causes the C++ code generator to generate - a GCC-style deprecation annotation (no-op on other compilers). - * google::protobuf::GetEnumDescriptor() returns the - EnumDescriptor for that type -- useful for templates which cannot call - SomeGeneratedEnumType_descriptor(). - * Various optimizations and obscure bug fixes. - - Java - * Lite mode: The "optimize_for = LITE_RUNTIME" option causes the compiler - to generate code which only depends libprotobuf-lite, which is much smaller - than libprotobuf but lacks descriptors, reflection, and some other features. - * Lots of style cleanups. - - Python - * Fixed endianness bug with floats and doubles. - * Text format parsing support. - * Fix bug with parsing packed repeated fields in embedded messages. - * Ability to initialize fields by passing keyword args to constructor. - * Support iterators in extend and __setslice__ for containers. - -2009-05-13 version 2.1.0: - - General - * Repeated fields of primitive types (types other that string, group, and - nested messages) may now use the option [packed = true] to get a more - efficient encoding. In the new encoding, the entire list is written - as a single byte blob using the "length-delimited" wire type. Within - this blob, the individual values are encoded the same way they would - be normally except without a tag before each value (thus, they are - tightly "packed"). - * For each field, the generated code contains an integer constant assigned - to the field number. For example, the .proto file: - message Foo { optional int bar_baz = 123; } - would generate the following constants, all with the integer value 123: - C++: Foo::kBarBazFieldNumber - Java: Foo.BAR_BAZ_FIELD_NUMBER - Python: Foo.BAR_BAZ_FIELD_NUMBER - Constants are also generated for extensions, with the same naming scheme. - These constants may be used as switch cases. - * Updated bundled Google Test to version 1.3.0. Google Test is now bundled - in its verbatim form as a nested autoconf package, so you can drop in any - other version of Google Test if needed. - * optimize_for = SPEED is now the default, by popular demand. Use - optimize_for = CODE_SIZE if code size is more important in your app. - * It is now an error to define a default value for a repeated field. - Previously, this was silently ignored (it had no effect on the generated - code). - * Fields can now be marked deprecated like: - optional int32 foo = 1 [deprecated = true]; - Currently this does not have any actual effect, but in the future the code - generators may generate deprecation annotations in each language. - * Cross-compiling should now be possible using the --with-protoc option to - configure. See README.txt for more info. - - protoc - * --error_format=msvs option causes errors to be printed in Visual Studio - format, which should allow them to be clicked on in the build log to go - directly to the error location. - * The type name resolver will no longer resolve type names to fields. For - example, this now works: - message Foo {} - message Bar { - optional int32 Foo = 1; - optional Foo baz = 2; - } - Previously, the type of "baz" would resolve to "Bar.Foo", and you'd get - an error because Bar.Foo is a field, not a type. Now the type of "baz" - resolves to the message type Foo. This change is unlikely to make a - difference to anyone who follows the Protocol Buffers style guide. - - C++ - * Several optimizations, including but not limited to: - - Serialization, especially to flat arrays, is 10%-50% faster, possibly - more for small objects. - - Several descriptor operations which previously required locking no longer - do. - - Descriptors are now constructed lazily on first use, rather than at - process startup time. This should save memory in programs which do not - use descriptors or reflection. - - UnknownFieldSet completely redesigned to be more efficient (especially in - terms of memory usage). - - Various optimizations to reduce code size (though the serialization speed - optimizations increased code size). - * Message interface has method ParseFromBoundedZeroCopyStream() which parses - a limited number of bytes from an input stream rather than parsing until - EOF. - * GzipInputStream and GzipOutputStream support reading/writing gzip- or - zlib-compressed streams if zlib is available. - (google/protobuf/io/gzip_stream.h) - * DescriptorPool::FindAllExtensions() and corresponding - DescriptorDatabase::FindAllExtensions() can be used to enumerate all - extensions of a given type. - * For each enum type Foo, protoc will generate functions: - const string& Foo_Name(Foo value); - bool Foo_Parse(const string& name, Foo* result); - The former returns the name of the enum constant corresponding to the given - value while the latter finds the value corresponding to a name. - * RepeatedField and RepeatedPtrField now have back-insertion iterators. - * String fields now have setters that take a char* and a size, in addition - to the existing ones that took char* or const string&. - * DescriptorPool::AllowUnknownDependencies() may be used to tell - DescriptorPool to create placeholder descriptors for unknown entities - referenced in a FileDescriptorProto. This can allow you to parse a .proto - file without having access to other .proto files that it imports, for - example. - * Updated gtest to latest version. The gtest package is now included as a - nested autoconf package, so it should be able to drop new versions into the - "gtest" subdirectory without modification. - - Java - * Fixed bug where Message.mergeFrom(Message) failed to merge extensions. - * Message interface has new method toBuilder() which is equivalent to - newBuilderForType().mergeFrom(this). - * All enums now implement the ProtocolMessageEnum interface. - * Setting a field to null now throws NullPointerException. - * Fixed tendency for TextFormat's parsing to overflow the stack when - parsing large string values. The underlying problem is with Java's - regex implementation (which unfortunately uses recursive backtracking - rather than building an NFA). Worked around by making use of possesive - quantifiers. - * Generated service classes now also generate pure interfaces. For a service - Foo, Foo.Interface is a pure interface containing all of the service's - defined methods. Foo.newReflectiveService() can be called to wrap an - instance of this interface in a class that implements the generic - RpcService interface, which provides reflection support that is usually - needed by RPC server implementations. - * RPC interfaces now support blocking operation in addition to non-blocking. - The protocol compiler generates separate blocking and non-blocking stubs - which operate against separate blocking and non-blocking RPC interfaces. - RPC implementations will have to implement the new interfaces in order to - support blocking mode. - * New I/O methods parseDelimitedFrom(), mergeDelimitedFrom(), and - writeDelimitedTo() read and write "delemited" messages from/to a stream, - meaning that the message size precedes the data. This way, you can write - multiple messages to a stream without having to worry about delimiting - them yourself. - * Throw a more descriptive exception when build() is double-called. - * Add a method to query whether CodedInputStream is at the end of the input - stream. - * Add a method to reset a CodedInputStream's size counter; useful when - reading many messages with the same stream. - * equals() and hashCode() now account for unknown fields. - - Python - * Added slicing support for repeated scalar fields. Added slice retrieval and - removal of repeated composite fields. - * Updated RPC interfaces to allow for blocking operation. A client may - now pass None for a callback when making an RPC, in which case the - call will block until the response is received, and the response - object will be returned directly to the caller. This interface change - cannot be used in practice until RPC implementations are updated to - implement it. - * Changes to input_stream.py should make protobuf compatible with appengine. - -2008-11-25 version 2.0.3: - - protoc - * Enum values may now have custom options, using syntax similar to field - options. - * Fixed bug where .proto files which use custom options but don't actually - define them (i.e. they import another .proto file defining the options) - had to explicitly import descriptor.proto. - * Adjacent string literals in .proto files will now be concatenated, like in - C. - * If an input file is a Windows absolute path (e.g. "C:\foo\bar.proto") and - the import path only contains "." (or contains "." but does not contain - the file), protoc incorrectly thought that the file was under ".", because - it thought that the path was relative (since it didn't start with a slash). - This has been fixed. - - C++ - * Generated message classes now have a Swap() method which efficiently swaps - the contents of two objects. - * All message classes now have a SpaceUsed() method which returns an estimate - of the number of bytes of allocated memory currently owned by the object. - This is particularly useful when you are reusing a single message object - to improve performance but want to make sure it doesn't bloat up too large. - * New method Message::SerializeAsString() returns a string containing the - serialized data. May be more convenient than calling - SerializeToString(string*). - * In debug mode, log error messages when string-type fields are found to - contain bytes that are not valid UTF-8. - * Fixed bug where a message with multiple extension ranges couldn't parse - extensions. - * Fixed bug where MergeFrom(const Message&) didn't do anything if invoked on - a message that contained no fields (but possibly contained extensions). - * Fixed ShortDebugString() to not be O(n^2). Durr. - * Fixed crash in TextFormat parsing if the first token in the input caused a - tokenization error. - * Fixed obscure bugs in zero_copy_stream_impl.cc. - * Added support for HP C++ on Tru64. - * Only build tests on "make check", not "make". - * Fixed alignment issue that caused crashes when using DynamicMessage on - 64-bit Sparc machines. - * Simplify template usage to work with MSVC 2003. - * Work around GCC 4.3.x x86_64 compiler bug that caused crashes on startup. - (This affected Fedora 9 in particular.) - * Now works on "Solaris 10 using recent Sun Studio". - - Java - * New overload of mergeFrom() which parses a slice of a byte array instead - of the whole thing. - * New method ByteString.asReadOnlyByteBuffer() does what it sounds like. - * Improved performance of isInitialized() when optimizing for code size. - - Python - * Corrected ListFields() signature in Message base class to match what - subclasses actually implement. - * Some minor refactoring. - * Don't pass self as first argument to superclass constructor (no longer - allowed in Python 2.6). - -2008-09-29 version 2.0.2: - - General - * License changed from Apache 2.0 to New BSD. - * It is now possible to define custom "options", which are basically - annotations which may be placed on definitions in a .proto file. - For example, you might define a field option called "foo" like so: - import "google/protobuf/descriptor.proto" - extend google.protobuf.FieldOptions { - optional string foo = 12345; - } - Then you annotate a field using the "foo" option: - message MyMessage { - optional int32 some_field = 1 [(foo) = "bar"] - } - The value of this option is then visible via the message's - Descriptor: - const FieldDescriptor* field = - MyMessage::descriptor()->FindFieldByName("some_field"); - assert(field->options().GetExtension(foo) == "bar"); - This feature has been implemented and tested in C++ and Java. - Other languages may or may not need to do extra work to support - custom options, depending on how they construct descriptors. - - C++ - * Fixed some GCC warnings that only occur when using -pedantic. - * Improved static initialization code, making ordering more - predictable among other things. - * TextFormat will no longer accept messages which contain multiple - instances of a singular field. Previously, the latter instance - would overwrite the former. - * Now works on systems that don't have hash_map. - - Java - * Print @Override annotation in generated code where appropriate. - - Python - * Strings now use the "unicode" type rather than the "str" type. - String fields may still be assigned ASCII "str" values; they will - automatically be converted. - * Adding a property to an object representing a repeated field now - raises an exception. For example: - # No longer works (and never should have). - message.some_repeated_field.foo = 1 - - Windows - * We now build static libraries rather than DLLs by default on MSVC. - See vsprojects/readme.txt for more information. - -2008-08-15 version 2.0.1: - - protoc - * New flags --encode and --decode can be used to convert between protobuf text - format and binary format from the command-line. - * New flag --descriptor_set_out can be used to write FileDescriptorProtos for - all parsed files directly into a single output file. This is particularly - useful if you wish to parse .proto files from programs written in languages - other than C++: just run protoc as a background process and have it output - a FileDescriptorList, then parse that natively. - * Improved error message when an enum value's name conflicts with another - symbol defined in the enum type's scope, e.g. if two enum types declared - in the same scope have values with the same name. This is disallowed for - compatibility with C++, but this wasn't clear from the error. - * Fixed absolute output paths on Windows. - * Allow trailing slashes in --proto_path mappings. - - C++ - * Reflection objects are now per-class rather than per-instance. To make this - possible, the Reflection interface had to be changed such that all methods - take the Message instance as a parameter. This change improves performance - significantly in memory-bandwidth-limited use cases, since it makes the - message objects smaller. Note that source-incompatible interface changes - like this will not be made again after the library leaves beta. - * Heuristically detect sub-messages when printing unknown fields. - * Fix static initialization ordering bug that caused crashes at startup when - compiling on Mac with static linking. - * Fixed TokenizerTest when compiling with -DNDEBUG on Linux. - * Fixed incorrect definition of kint32min. - * Fix bytes type setter to work with byte sequences with embedded NULLs. - * Other irrelevant tweaks. - - Java - * Fixed UnknownFieldSet's parsing of varints larger than 32 bits. - * Fixed TextFormat's parsing of "inf" and "nan". - * Fixed TextFormat's parsing of comments. - * Added info to Java POM that will be required when we upload the - package to a Maven repo. - - Python - * MergeFrom(message) and CopyFrom(message) are now implemented. - * SerializeToString() raises an exception if the message is missing required - fields. - * Code organization improvements. - * Fixed doc comments for RpcController and RpcChannel, which had somehow been - swapped. - * Fixed text_format_test on Windows where floating-point exponents sometimes - contain extra zeros. - * Fix Python service CallMethod() implementation. - - Other - * Improved readmes. - * VIM syntax highlighting improvements. - -2008-07-07 version 2.0.0: - - * First public release. diff --git a/modules/dnn/3rdparty/protobuf/CONTRIBUTORS.txt b/modules/dnn/3rdparty/protobuf/CONTRIBUTORS.txt deleted file mode 100644 index b39ec308b..000000000 --- a/modules/dnn/3rdparty/protobuf/CONTRIBUTORS.txt +++ /dev/null @@ -1,90 +0,0 @@ -This file contains a list of people who have made large contributions -to the public version of Protocol Buffers. - -Original Protocol Buffers design and implementation: - Sanjay Ghemawat - Jeff Dean - Daniel Dulitz - Craig Silverstein - Paul Haahr - Corey Anderson - (and many others) - -Proto2 C++ and Java primary author: - Kenton Varda - -Proto2 Python primary authors: - Will Robinson - Petar Petrov - -Large code contributions: - Jason Hsueh - Joseph Schorr - Wenbo Zhu - -Large quantity of code reviews: - Scott Bruce - Frank Yellin - Neal Norwitz - Jeffrey Yasskin - Ambrose Feinstein - -Documentation: - Lisa Carey - -Maven packaging: - Gregory Kick - -Patch contributors: - Kevin Ko - * Small patch to handle trailing slashes in --proto_path flag. - Johan Euphrosine - * Small patch to fix Python CallMethod(). - Ulrich Kunitz - * Small optimizations to Python serialization. - Leandro Lucarella - * VI syntax highlighting tweaks. - * Fix compiler to not make output executable. - Dilip Joseph - * Heuristic detection of sub-messages when printing unknown fields in - text format. - Brian Atkinson - * Added @Override annotation to generated Java code where appropriate. - Vincent Choinière - * Tru64 support. - Monty Taylor - * Solaris 10 + Sun Studio fixes. - Alek Storm - * Slicing support for repeated scalar fields for the Python API. - Oleg Smolsky - * MS Visual Studio error format option. - * Detect unordered_map in stl_hash.m4. - Brian Olson - * gzip/zlib I/O support. - Michael Poole - * Fixed warnings about generated constructors not explicitly initializing - all fields (only present with certain compiler settings). - * Added generation of field number constants. - Wink Saville - * Fixed initialization ordering problem in logging code. - Will Pierce - * Small patch improving performance of in Python serialization. - Alexandre Vassalotti - * Emacs mode for Protocol Buffers (editors/protobuf-mode.el). - Scott Stafford - * Added Swap(), SwapElements(), and RemoveLast() to Reflection interface. - Alexander Melnikov - * HPUX support. - Oliver Jowett - * Detect whether zlib is new enough in configure script. - * Fixes for Solaris 10 32/64-bit confusion. - Evan Jones - * Optimize Java serialization code when writing a small message to a stream. - * Optimize Java serialization of strings so that UTF-8 encoding happens only - once per string per serialization call. - * Clean up some Java warnings. - * Fix bug with permanent callbacks that delete themselves when run. - Michael Kucharski - * Added CodedInputStream.getTotalBytesRead(). - Kacper Kowalik - * Fixed m4/acx_pthread.m4 problem for some Linux distributions. diff --git a/modules/dnn/3rdparty/protobuf/COPYING.txt b/modules/dnn/3rdparty/protobuf/COPYING.txt deleted file mode 100644 index 705db579c..000000000 --- a/modules/dnn/3rdparty/protobuf/COPYING.txt +++ /dev/null @@ -1,33 +0,0 @@ -Copyright 2008, Google Inc. -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met: - - * Redistributions of source code must retain the above copyright -notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above -copyright notice, this list of conditions and the following disclaimer -in the documentation and/or other materials provided with the -distribution. - * Neither the name of Google Inc. nor the names of its -contributors may be used to endorse or promote products derived from -this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -Code generated by the Protocol Buffer compiler is owned by the owner -of the input file used when generating it. This code is not -standalone and requires a support library to be linked with it. This -support library is itself covered by the above license. diff --git a/modules/dnn/3rdparty/protobuf/README.txt b/modules/dnn/3rdparty/protobuf/README.txt deleted file mode 100644 index 17551a5a0..000000000 --- a/modules/dnn/3rdparty/protobuf/README.txt +++ /dev/null @@ -1,152 +0,0 @@ -Protocol Buffers - Google's data interchange format -Copyright 2008 Google Inc. -http://code.google.com/apis/protocolbuffers/ - -C++ Installation - Unix -======================= - -To build and install the C++ Protocol Buffer runtime and the Protocol -Buffer compiler (protoc) execute the following: - - $ ./configure - $ make - $ make check - $ make install - -If "make check" fails, you can still install, but it is likely that -some features of this library will not work correctly on your system. -Proceed at your own risk. - -"make install" may require superuser privileges. - -For advanced usage information on configure and make, see INSTALL.txt. - -** Hint on install location ** - - By default, the package will be installed to /usr/local. However, - on many platforms, /usr/local/lib is not part of LD_LIBRARY_PATH. - You can add it, but it may be easier to just install to /usr - instead. To do this, invoke configure as follows: - - ./configure --prefix=/usr - - If you already built the package with a different prefix, make sure - to run "make clean" before building again. - -** Compiling dependent packages ** - - To compile a package that uses Protocol Buffers, you need to pass - various flags to your compiler and linker. As of version 2.2.0, - Protocol Buffers integrates with pkg-config to manage this. If you - have pkg-config installed, then you can invoke it to get a list of - flags like so: - - pkg-config --cflags protobuf # print compiler flags - pkg-config --libs protobuf # print linker flags - pkg-config --cflags --libs protobuf # print both - - For example: - - c++ my_program.cc my_proto.pb.cc `pkg-config --cflags --libs protobuf` - - Note that packages written prior to the 2.2.0 release of Protocol - Buffers may not yet integrate with pkg-config to get flags, and may - not pass the correct set of flags to correctly link against - libprotobuf. If the package in question uses autoconf, you can - often fix the problem by invoking its configure script like: - - configure CXXFLAGS="$(pkg-config --cflags protobuf)" \ - LIBS="$(pkg-config --libs protobuf)" - - This will force it to use the correct flags. - - If you are writing an autoconf-based package that uses Protocol - Buffers, you should probably use the PKG_CHECK_MODULES macro in your - configure script like: - - PKG_CHECK_MODULES([protobuf], [protobuf]) - - See the pkg-config man page for more info. - - If you only want protobuf-lite, substitute "protobuf-lite" in place - of "protobuf" in these examples. - -** Note for cross-compiling ** - - The makefiles normally invoke the protoc executable that they just - built in order to build tests. When cross-compiling, the protoc - executable may not be executable on the host machine. In this case, - you must build a copy of protoc for the host machine first, then use - the --with-protoc option to tell configure to use it instead. For - example: - - ./configure --with-protoc=protoc - - This will use the installed protoc (found in your $PATH) instead of - trying to execute the one built during the build process. You can - also use an executable that hasn't been installed. For example, if - you built the protobuf package for your host machine in ../host, - you might do: - - ./configure --with-protoc=../host/src/protoc - - Either way, you must make sure that the protoc executable you use - has the same version as the protobuf source code you are trying to - use it with. - -** Note for Solaris users ** - - Solaris 10 x86 has a bug that will make linking fail, complaining - about libstdc++.la being invalid. We have included a work-around - in this package. To use the work-around, run configure as follows: - - ./configure LDFLAGS=-L$PWD/src/solaris - - See src/solaris/libstdc++.la for more info on this bug. - -** Note for HP C++ Tru64 users ** - - To compile invoke configure as follows: - - ./configure CXXFLAGS="-O -std ansi -ieee -D__USE_STD_IOSTREAM" - - Also, you will need to use gmake instead of make. - -C++ Installation - Windows -========================== - -If you are using Microsoft Visual C++, see vsprojects/readme.txt. - -If you are using Cygwin or MinGW, follow the Unix installation -instructions, above. - -Binary Compatibility Warning -============================ - -Due to the nature of C++, it is unlikely that any two versions of the -Protocol Buffers C++ runtime libraries will have compatible ABIs. -That is, if you linked an executable against an older version of -libprotobuf, it is unlikely to work with a newer version without -re-compiling. This problem, when it occurs, will normally be detected -immediately on startup of your app. Still, you may want to consider -using static linkage. You can configure this package to install -static libraries only using: - - ./configure --disable-shared - -Java and Python Installation -============================ - -The Java and Python runtime libraries for Protocol Buffers are located -in the java and python directories. See the README file in each -directory for more information on how to compile and install them. -Note that both of them require you to first install the Protocol -Buffer compiler (protoc), which is part of the C++ package. - -Usage -===== - -The complete documentation for Protocol Buffers is available via the -web at: - - http://code.google.com/apis/protocolbuffers/ diff --git a/modules/dnn/3rdparty/protobuf/cmake/.gitignore b/modules/dnn/3rdparty/protobuf/cmake/.gitignore deleted file mode 100644 index fe06a514f..000000000 --- a/modules/dnn/3rdparty/protobuf/cmake/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -build -build-* diff --git a/modules/dnn/3rdparty/protobuf/cmake/CheckCxxHashmap.cmake b/modules/dnn/3rdparty/protobuf/cmake/CheckCxxHashmap.cmake deleted file mode 100644 index 122c512b4..000000000 --- a/modules/dnn/3rdparty/protobuf/cmake/CheckCxxHashmap.cmake +++ /dev/null @@ -1,55 +0,0 @@ -# From LLVM - -# - Check if for hash_map. -# CHECK_HASHMAP () -# - -include(CheckCXXSourceCompiles) - -macro(CHECK_HASHMAP) - message(STATUS "Checking for C++ hash_map implementation...") - check_cxx_source_compiles(" - #include - int main() { - __gnu_cxx::hash_map t; - } -" - HAVE_GNU_EXT_HASH_MAP - ) - if(HAVE_GNU_EXT_HASH_MAP) - message(STATUS "C++ hash_map found in 'ext' dir in namespace __gnu_cxx::") - endif(HAVE_GNU_EXT_HASH_MAP) - - check_cxx_source_compiles(" - #include - int main() { - std::hash_map t; - } -" - HAVE_STD_EXT_HASH_MAP - ) - if(HAVE_STD_EXT_HASH_MAP) - message(STATUS "C++ hash_map found in 'ext' dir in namespace std::") - endif(HAVE_STD_EXT_HASH_MAP) - - check_cxx_source_compiles(" - #include - int main() { - hash_map t; - } -" - HAVE_GLOBAL_HASH_MAP - ) - if(HAVE_GLOBAL_HASH_MAP) - message(STATUS "C++ hash_map found in global namespace") - endif(HAVE_GLOBAL_HASH_MAP) - - if(NOT HAVE_GNU_EXT_HASH_MAP) - if(NOT HAVE_STD_EXT_HASH_MAP) - if(NOT HAVE_GLOBAL_HASH_MAP) - message(STATUS "C++ hash_map not found") - endif(NOT HAVE_GLOBAL_HASH_MAP) - endif(NOT HAVE_STD_EXT_HASH_MAP) - endif(NOT HAVE_GNU_EXT_HASH_MAP) - -endmacro(CHECK_HASHMAP) diff --git a/modules/dnn/3rdparty/protobuf/cmake/CheckCxxHashset.cmake b/modules/dnn/3rdparty/protobuf/cmake/CheckCxxHashset.cmake deleted file mode 100644 index 495b174c2..000000000 --- a/modules/dnn/3rdparty/protobuf/cmake/CheckCxxHashset.cmake +++ /dev/null @@ -1,54 +0,0 @@ -# From LLVM - -# - Check if for hash_set. -# CHECK_HASHSET () -# - -include(CheckCXXSourceCompiles) - -macro(CHECK_HASHSET) - message(STATUS "Checking for C++ hash_set implementation...") - check_cxx_source_compiles(" - #include - int main() { - __gnu_cxx::hash_set t; - } -" - HAVE_GNU_EXT_HASH_SET - ) - if(HAVE_GNU_EXT_HASH_SET) - message(STATUS "C++ hash_set found in 'ext' dir in namespace __gnu_cxx::") - endif(HAVE_GNU_EXT_HASH_SET) - - check_cxx_source_compiles(" - #include - int main() { - std::hash_set t; - } -" - HAVE_STD_EXT_HASH_SET - ) - if(HAVE_STD_EXT_HASH_SET) - message(STATUS "C++ hash_set found in 'ext' dir in namespace std::") - endif(HAVE_STD_EXT_HASH_SET) - - check_cxx_source_compiles(" - #include - int main() { - hash_set t; - } -" - HAVE_GLOBAL_HASH_SET - ) - if(HAVE_GLOBAL_HASH_SET) - message(STATUS "C++ hash_set found in global namespace") - endif(HAVE_GLOBAL_HASH_SET) - - if(NOT HAVE_GNU_EXT_HASH_SET) - if(NOT HAVE_STD_EXT_HASH_SET) - if(NOT HAVE_GLOBAL_HASH_SET) - message(STATUS "C++ hash_set not found") - endif(NOT HAVE_GLOBAL_HASH_SET) - endif(NOT HAVE_STD_EXT_HASH_SET) - endif(NOT HAVE_GNU_EXT_HASH_SET) -endmacro(CHECK_HASHSET) diff --git a/modules/dnn/3rdparty/protobuf/cmake/LICENSE b/modules/dnn/3rdparty/protobuf/cmake/LICENSE deleted file mode 100644 index b97fb748e..000000000 --- a/modules/dnn/3rdparty/protobuf/cmake/LICENSE +++ /dev/null @@ -1,31 +0,0 @@ -New BSD license: http://opensource.org/licenses/BSD-3-Clause - -Copyright (c) 2014, Jesper Eskilson and others -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met: - -1. Redistributions of source code must retain the above copyright -notice, this list of conditions and the following disclaimer. - -2. Redistributions in binary form must reproduce the above copyright -notice, this list of conditions and the following disclaimer in the -documentation and/or other materials provided with the distribution. - -3. Neither the name of the copyright holder nor the names of its -contributors may be used to endorse or promote products derived from -this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. \ No newline at end of file diff --git a/modules/dnn/3rdparty/protobuf/cmake/config.h.in b/modules/dnn/3rdparty/protobuf/cmake/config.h.in deleted file mode 100644 index 96d4d9ae9..000000000 --- a/modules/dnn/3rdparty/protobuf/cmake/config.h.in +++ /dev/null @@ -1,62 +0,0 @@ - -#ifndef _CONFIG_H_ -#define _CONFIG_H_ - -/* the name of */ -#define HASH_MAP_CLASS ${HASH_MAP_CLASS} - -/* the location of or */ -#define HASH_MAP_H ${HASH_MAP_H} - -/* the namespace of hash_map/hash_set */ -#define HASH_NAMESPACE ${HASH_NAMESPACE} - -/* the name of */ -#define HASH_SET_CLASS ${HASH_SET_CLASS} - -/* the location of or */ -#define HASH_SET_H ${HASH_SET_H} - -/* define if the compiler has hash_map */ -#cmakedefine HAVE_HASH_MAP - -/* define if the compiler has hash_set */ -#cmakedefine HAVE_HASH_SET - -/* Define if you have POSIX threads libraries and header files. */ -#cmakedefine HAVE_PTHREAD - -/* Enable classes using zlib compression. */ -#undef HAVE_ZLIB - -/* Enable extensions on AIX 3, Interix. */ -#ifndef _ALL_SOURCE -# undef _ALL_SOURCE -#endif -/* Enable GNU extensions on systems that have them. */ -#ifndef _GNU_SOURCE -# undef _GNU_SOURCE -#endif -/* Enable threading extensions on Solaris. */ -#ifndef _POSIX_PTHREAD_SEMANTICS -# undef _POSIX_PTHREAD_SEMANTICS -#endif -/* Enable extensions on HP NonStop. */ -#ifndef _TANDEM_SOURCE -# undef _TANDEM_SOURCE -#endif -/* Enable general extensions on Solaris. */ -#ifndef __EXTENSIONS__ -# undef __EXTENSIONS__ -#endif - - -/* Define to 2 if the system does not provide POSIX.1 features except with - this defined. */ -#undef _POSIX_1_SOURCE - -/* Define to 1 if you need to in order for `stat' and other things to work. */ -#undef _POSIX_SOURCE - -#endif /* _CONFIG_H_ */ - diff --git a/modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/code_generator.cc b/modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/code_generator.cc deleted file mode 100644 index 455c239a9..000000000 --- a/modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/code_generator.cc +++ /dev/null @@ -1,80 +0,0 @@ -// Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// http://code.google.com/p/protobuf/ -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -// Author: kenton@google.com (Kenton Varda) -// Based on original Protocol Buffers design by -// Sanjay Ghemawat, Jeff Dean, and others. - -#include - -#include -#include - -namespace google { -namespace protobuf { -namespace compiler { - -CodeGenerator::~CodeGenerator() {} -GeneratorContext::~GeneratorContext() {} - -io::ZeroCopyOutputStream* GeneratorContext::OpenForInsert( - const string& filename, const string& insertion_point) { - GOOGLE_LOG(FATAL) << "This GeneratorContext does not support insertion."; - return NULL; // make compiler happy -} - -void GeneratorContext::ListParsedFiles( - vector* output) { - GOOGLE_LOG(FATAL) << "This GeneratorContext does not support ListParsedFiles"; -} - -// Parses a set of comma-delimited name/value pairs. -void ParseGeneratorParameter(const string& text, - vector >* output) { - vector parts; - SplitStringUsing(text, ",", &parts); - - for (int i = 0; i < parts.size(); i++) { - string::size_type equals_pos = parts[i].find_first_of('='); - pair value; - if (equals_pos == string::npos) { - value.first = parts[i]; - value.second = ""; - } else { - value.first = parts[i].substr(0, equals_pos); - value.second = parts[i].substr(equals_pos + 1); - } - output->push_back(value); - } -} - -} // namespace compiler -} // namespace protobuf -} // namespace google diff --git a/modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/code_generator.h b/modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/code_generator.h deleted file mode 100644 index 252f68d1d..000000000 --- a/modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/code_generator.h +++ /dev/null @@ -1,142 +0,0 @@ -// Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// http://code.google.com/p/protobuf/ -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -// Author: kenton@google.com (Kenton Varda) -// Based on original Protocol Buffers design by -// Sanjay Ghemawat, Jeff Dean, and others. -// -// Defines the abstract interface implemented by each of the language-specific -// code generators. - -#ifndef GOOGLE_PROTOBUF_COMPILER_CODE_GENERATOR_H__ -#define GOOGLE_PROTOBUF_COMPILER_CODE_GENERATOR_H__ - -#include -#include -#include -#include - -namespace google { -namespace protobuf { - -namespace io { class ZeroCopyOutputStream; } -class FileDescriptor; - -namespace compiler { - -// Defined in this file. -class CodeGenerator; -class GeneratorContext; - -// The abstract interface to a class which generates code implementing a -// particular proto file in a particular language. A number of these may -// be registered with CommandLineInterface to support various languages. -class LIBPROTOC_EXPORT CodeGenerator { - public: - inline CodeGenerator() {} - virtual ~CodeGenerator(); - - // Generates code for the given proto file, generating one or more files in - // the given output directory. - // - // A parameter to be passed to the generator can be specified on the - // command line. This is intended to be used by Java and similar languages - // to specify which specific class from the proto file is to be generated, - // though it could have other uses as well. It is empty if no parameter was - // given. - // - // Returns true if successful. Otherwise, sets *error to a description of - // the problem (e.g. "invalid parameter") and returns false. - virtual bool Generate(const FileDescriptor* file, - const string& parameter, - GeneratorContext* generator_context, - string* error) const = 0; - - private: - GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(CodeGenerator); -}; - -// CodeGenerators generate one or more files in a given directory. This -// abstract interface represents the directory to which the CodeGenerator is -// to write and other information about the context in which the Generator -// runs. -class LIBPROTOC_EXPORT GeneratorContext { - public: - inline GeneratorContext() {} - virtual ~GeneratorContext(); - - // Opens the given file, truncating it if it exists, and returns a - // ZeroCopyOutputStream that writes to the file. The caller takes ownership - // of the returned object. This method never fails (a dummy stream will be - // returned instead). - // - // The filename given should be relative to the root of the source tree. - // E.g. the C++ generator, when generating code for "foo/bar.proto", will - // generate the files "foo/bar.pb.h" and "foo/bar.pb.cc"; note that - // "foo/" is included in these filenames. The filename is not allowed to - // contain "." or ".." components. - virtual io::ZeroCopyOutputStream* Open(const string& filename) = 0; - - // Creates a ZeroCopyOutputStream which will insert code into the given file - // at the given insertion point. See plugin.proto (plugin.pb.h) for more - // information on insertion points. The default implementation - // assert-fails -- it exists only for backwards-compatibility. - // - // WARNING: This feature is currently EXPERIMENTAL and is subject to change. - virtual io::ZeroCopyOutputStream* OpenForInsert( - const string& filename, const string& insertion_point); - - // Returns a vector of FileDescriptors for all the files being compiled - // in this run. Useful for languages, such as Go, that treat files - // differently when compiled as a set rather than individually. - virtual void ListParsedFiles(vector* output); - - private: - GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(GeneratorContext); -}; - -// The type GeneratorContext was once called OutputDirectory. This typedef -// provides backward compatibility. -typedef GeneratorContext OutputDirectory; - -// Several code generators treat the parameter argument as holding a -// list of options separated by commas. This helper function parses -// a set of comma-delimited name/value pairs: e.g., -// "foo=bar,baz,qux=corge" -// parses to the pairs: -// ("foo", "bar"), ("baz", ""), ("qux", "corge") -extern void ParseGeneratorParameter(const string&, - vector >*); - -} // namespace compiler -} // namespace protobuf - -} // namespace google -#endif // GOOGLE_PROTOBUF_COMPILER_CODE_GENERATOR_H__ diff --git a/modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/command_line_interface.cc b/modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/command_line_interface.cc deleted file mode 100644 index b9293c97d..000000000 --- a/modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/command_line_interface.cc +++ /dev/null @@ -1,1437 +0,0 @@ -// Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// http://code.google.com/p/protobuf/ -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -// Author: kenton@google.com (Kenton Varda) -// Based on original Protocol Buffers design by -// Sanjay Ghemawat, Jeff Dean, and others. - -#include - -#include -#include -#include -#include -#ifdef _MSC_VER -#include -#include -#else -#include -#endif -#include -#include -#include - -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - - -namespace google { -namespace protobuf { -namespace compiler { - -#if defined(_WIN32) -#define mkdir(name, mode) mkdir(name) -#ifndef W_OK -#define W_OK 02 // not defined by MSVC for whatever reason -#endif -#ifndef F_OK -#define F_OK 00 // not defined by MSVC for whatever reason -#endif -#ifndef STDIN_FILENO -#define STDIN_FILENO 0 -#endif -#ifndef STDOUT_FILENO -#define STDOUT_FILENO 1 -#endif -#endif - -#ifndef O_BINARY -#ifdef _O_BINARY -#define O_BINARY _O_BINARY -#else -#define O_BINARY 0 // If this isn't defined, the platform doesn't need it. -#endif -#endif - -namespace { -#if defined(_WIN32) && !defined(__CYGWIN__) -static const char* kPathSeparator = ";"; -#else -static const char* kPathSeparator = ":"; -#endif - -// Returns true if the text looks like a Windows-style absolute path, starting -// with a drive letter. Example: "C:\foo". TODO(kenton): Share this with -// copy in importer.cc? -static bool IsWindowsAbsolutePath(const string& text) { -#if defined(_WIN32) || defined(__CYGWIN__) - return text.size() >= 3 && text[1] == ':' && - isalpha(text[0]) && - (text[2] == '/' || text[2] == '\\') && - text.find_last_of(':') == 1; -#else - return false; -#endif -} - -void SetFdToTextMode(int fd) { -#ifdef _WIN32 - if (_setmode(fd, _O_TEXT) == -1) { - // This should never happen, I think. - GOOGLE_LOG(WARNING) << "_setmode(" << fd << ", _O_TEXT): " << strerror(errno); - } -#endif - // (Text and binary are the same on non-Windows platforms.) -} - -void SetFdToBinaryMode(int fd) { -#ifdef _WIN32 - if (_setmode(fd, _O_BINARY) == -1) { - // This should never happen, I think. - GOOGLE_LOG(WARNING) << "_setmode(" << fd << ", _O_BINARY): " << strerror(errno); - } -#endif - // (Text and binary are the same on non-Windows platforms.) -} - -void AddTrailingSlash(string* path) { - if (!path->empty() && path->at(path->size() - 1) != '/') { - path->push_back('/'); - } -} - -bool VerifyDirectoryExists(const string& path) { - if (path.empty()) return true; - - if (access(path.c_str(), F_OK) == -1) { - cerr << path << ": " << strerror(errno) << endl; - return false; - } else { - return true; - } -} - -// Try to create the parent directory of the given file, creating the parent's -// parent if necessary, and so on. The full file name is actually -// (prefix + filename), but we assume |prefix| already exists and only create -// directories listed in |filename|. -bool TryCreateParentDirectory(const string& prefix, const string& filename) { - // Recursively create parent directories to the output file. - vector parts; - SplitStringUsing(filename, "/", &parts); - string path_so_far = prefix; - for (int i = 0; i < parts.size() - 1; i++) { - path_so_far += parts[i]; - if (mkdir(path_so_far.c_str(), 0777) != 0) { - if (errno != EEXIST) { - cerr << filename << ": while trying to create directory " - << path_so_far << ": " << strerror(errno) << endl; - return false; - } - } - path_so_far += '/'; - } - - return true; -} - -} // namespace - -// A MultiFileErrorCollector that prints errors to stderr. -class CommandLineInterface::ErrorPrinter : public MultiFileErrorCollector, - public io::ErrorCollector { - public: - ErrorPrinter(ErrorFormat format, DiskSourceTree *tree = NULL) - : format_(format), tree_(tree) {} - ~ErrorPrinter() {} - - // implements MultiFileErrorCollector ------------------------------ - void AddError(const string& filename, int line, int column, - const string& message) { - - // Print full path when running under MSVS - string dfile; - if (format_ == CommandLineInterface::ERROR_FORMAT_MSVS && - tree_ != NULL && - tree_->VirtualFileToDiskFile(filename, &dfile)) { - cerr << dfile; - } else { - cerr << filename; - } - - // Users typically expect 1-based line/column numbers, so we add 1 - // to each here. - if (line != -1) { - // Allow for both GCC- and Visual-Studio-compatible output. - switch (format_) { - case CommandLineInterface::ERROR_FORMAT_GCC: - cerr << ":" << (line + 1) << ":" << (column + 1); - break; - case CommandLineInterface::ERROR_FORMAT_MSVS: - cerr << "(" << (line + 1) << ") : error in column=" << (column + 1); - break; - } - } - - cerr << ": " << message << endl; - } - - // implements io::ErrorCollector ----------------------------------- - void AddError(int line, int column, const string& message) { - AddError("input", line, column, message); - } - - private: - const ErrorFormat format_; - DiskSourceTree *tree_; -}; - -// ------------------------------------------------------------------- - -// A GeneratorContext implementation that buffers files in memory, then dumps -// them all to disk on demand. -class CommandLineInterface::GeneratorContextImpl : public GeneratorContext { - public: - GeneratorContextImpl(const vector& parsed_files); - ~GeneratorContextImpl(); - - // Write all files in the directory to disk at the given output location, - // which must end in a '/'. - bool WriteAllToDisk(const string& prefix); - - // Write the contents of this directory to a ZIP-format archive with the - // given name. - bool WriteAllToZip(const string& filename); - - // Add a boilerplate META-INF/MANIFEST.MF file as required by the Java JAR - // format, unless one has already been written. - void AddJarManifest(); - - // implements GeneratorContext -------------------------------------- - io::ZeroCopyOutputStream* Open(const string& filename); - io::ZeroCopyOutputStream* OpenForInsert( - const string& filename, const string& insertion_point); - void ListParsedFiles(vector* output) { - *output = parsed_files_; - } - - private: - friend class MemoryOutputStream; - - // map instead of hash_map so that files are written in order (good when - // writing zips). - map files_; - const vector& parsed_files_; - bool had_error_; -}; - -class CommandLineInterface::MemoryOutputStream - : public io::ZeroCopyOutputStream { - public: - MemoryOutputStream(GeneratorContextImpl* directory, const string& filename); - MemoryOutputStream(GeneratorContextImpl* directory, const string& filename, - const string& insertion_point); - virtual ~MemoryOutputStream(); - - // implements ZeroCopyOutputStream --------------------------------- - virtual bool Next(void** data, int* size) { return inner_->Next(data, size); } - virtual void BackUp(int count) { inner_->BackUp(count); } - virtual int64 ByteCount() const { return inner_->ByteCount(); } - - private: - // Where to insert the string when it's done. - GeneratorContextImpl* directory_; - string filename_; - string insertion_point_; - - // The string we're building. - string data_; - - // StringOutputStream writing to data_. - scoped_ptr inner_; -}; - -// ------------------------------------------------------------------- - -CommandLineInterface::GeneratorContextImpl::GeneratorContextImpl( - const vector& parsed_files) - : parsed_files_(parsed_files), - had_error_(false) { -} - -CommandLineInterface::GeneratorContextImpl::~GeneratorContextImpl() { - STLDeleteValues(&files_); -} - -bool CommandLineInterface::GeneratorContextImpl::WriteAllToDisk( - const string& prefix) { - if (had_error_) { - return false; - } - - if (!VerifyDirectoryExists(prefix)) { - return false; - } - - for (map::const_iterator iter = files_.begin(); - iter != files_.end(); ++iter) { - const string& relative_filename = iter->first; - const char* data = iter->second->data(); - int size = iter->second->size(); - - if (!TryCreateParentDirectory(prefix, relative_filename)) { - return false; - } - string filename = prefix + relative_filename; - - // Create the output file. - int file_descriptor; - do { - file_descriptor = - open(filename.c_str(), O_WRONLY | O_CREAT | O_TRUNC | O_BINARY, 0666); - } while (file_descriptor < 0 && errno == EINTR); - - if (file_descriptor < 0) { - int error = errno; - cerr << filename << ": " << strerror(error); - return false; - } - - // Write the file. - while (size > 0) { - int write_result; - do { - write_result = write(file_descriptor, data, size); - } while (write_result < 0 && errno == EINTR); - - if (write_result <= 0) { - // Write error. - - // FIXME(kenton): According to the man page, if write() returns zero, - // there was no error; write() simply did not write anything. It's - // unclear under what circumstances this might happen, but presumably - // errno won't be set in this case. I am confused as to how such an - // event should be handled. For now I'm treating it as an error, - // since retrying seems like it could lead to an infinite loop. I - // suspect this never actually happens anyway. - - if (write_result < 0) { - int error = errno; - cerr << filename << ": write: " << strerror(error); - } else { - cerr << filename << ": write() returned zero?" << endl; - } - return false; - } - - data += write_result; - size -= write_result; - } - - if (close(file_descriptor) != 0) { - int error = errno; - cerr << filename << ": close: " << strerror(error); - return false; - } - } - - return true; -} - -bool CommandLineInterface::GeneratorContextImpl::WriteAllToZip( - const string& filename) { - if (had_error_) { - return false; - } - - // Create the output file. - int file_descriptor; - do { - file_descriptor = - open(filename.c_str(), O_WRONLY | O_CREAT | O_TRUNC | O_BINARY, 0666); - } while (file_descriptor < 0 && errno == EINTR); - - if (file_descriptor < 0) { - int error = errno; - cerr << filename << ": " << strerror(error); - return false; - } - - // Create the ZipWriter - io::FileOutputStream stream(file_descriptor); - ZipWriter zip_writer(&stream); - - for (map::const_iterator iter = files_.begin(); - iter != files_.end(); ++iter) { - zip_writer.Write(iter->first, *iter->second); - } - - zip_writer.WriteDirectory(); - - if (stream.GetErrno() != 0) { - cerr << filename << ": " << strerror(stream.GetErrno()) << endl; - } - - if (!stream.Close()) { - cerr << filename << ": " << strerror(stream.GetErrno()) << endl; - } - - return true; -} - -void CommandLineInterface::GeneratorContextImpl::AddJarManifest() { - string** map_slot = &files_["META-INF/MANIFEST.MF"]; - if (*map_slot == NULL) { - *map_slot = new string( - "Manifest-Version: 1.0\n" - "Created-By: 1.6.0 (protoc)\n" - "\n"); - } -} - -io::ZeroCopyOutputStream* CommandLineInterface::GeneratorContextImpl::Open( - const string& filename) { - return new MemoryOutputStream(this, filename); -} - -io::ZeroCopyOutputStream* -CommandLineInterface::GeneratorContextImpl::OpenForInsert( - const string& filename, const string& insertion_point) { - return new MemoryOutputStream(this, filename, insertion_point); -} - -// ------------------------------------------------------------------- - -CommandLineInterface::MemoryOutputStream::MemoryOutputStream( - GeneratorContextImpl* directory, const string& filename) - : directory_(directory), - filename_(filename), - inner_(new io::StringOutputStream(&data_)) { -} - -CommandLineInterface::MemoryOutputStream::MemoryOutputStream( - GeneratorContextImpl* directory, const string& filename, - const string& insertion_point) - : directory_(directory), - filename_(filename), - insertion_point_(insertion_point), - inner_(new io::StringOutputStream(&data_)) { -} - -CommandLineInterface::MemoryOutputStream::~MemoryOutputStream() { - // Make sure all data has been written. - inner_.reset(); - - // Insert into the directory. - string** map_slot = &directory_->files_[filename_]; - - if (insertion_point_.empty()) { - // This was just a regular Open(). - if (*map_slot != NULL) { - cerr << filename_ << ": Tried to write the same file twice." << endl; - directory_->had_error_ = true; - return; - } - - *map_slot = new string; - (*map_slot)->swap(data_); - } else { - // This was an OpenForInsert(). - - // If the data doens't end with a clean line break, add one. - if (!data_.empty() && data_[data_.size() - 1] != '\n') { - data_.push_back('\n'); - } - - // Find the file we are going to insert into. - if (*map_slot == NULL) { - cerr << filename_ << ": Tried to insert into file that doesn't exist." - << endl; - directory_->had_error_ = true; - return; - } - string* target = *map_slot; - - // Find the insertion point. - string magic_string = strings::Substitute( - "@@protoc_insertion_point($0)", insertion_point_); - string::size_type pos = target->find(magic_string); - - if (pos == string::npos) { - cerr << filename_ << ": insertion point \"" << insertion_point_ - << "\" not found." << endl; - directory_->had_error_ = true; - return; - } - - // Seek backwards to the beginning of the line, which is where we will - // insert the data. Note that this has the effect of pushing the insertion - // point down, so the data is inserted before it. This is intentional - // because it means that multiple insertions at the same point will end - // up in the expected order in the final output. - pos = target->find_last_of('\n', pos); - if (pos == string::npos) { - // Insertion point is on the first line. - pos = 0; - } else { - // Advance to character after '\n'. - ++pos; - } - - // Extract indent. - string indent_(*target, pos, target->find_first_not_of(" \t", pos) - pos); - - if (indent_.empty()) { - // No indent. This makes things easier. - target->insert(pos, data_); - } else { - // Calculate how much space we need. - int indent_size = 0; - for (int i = 0; i < data_.size(); i++) { - if (data_[i] == '\n') indent_size += indent_.size(); - } - - // Make a hole for it. - target->insert(pos, data_.size() + indent_size, '\0'); - - // Now copy in the data. - string::size_type data_pos = 0; - char* target_ptr = string_as_array(target) + pos; - while (data_pos < data_.size()) { - // Copy indent. - memcpy(target_ptr, indent_.data(), indent_.size()); - target_ptr += indent_.size(); - - // Copy line from data_. - // We already guaranteed that data_ ends with a newline (above), so this - // search can't fail. - string::size_type line_length = - data_.find_first_of('\n', data_pos) + 1 - data_pos; - memcpy(target_ptr, data_.data() + data_pos, line_length); - target_ptr += line_length; - data_pos += line_length; - } - - GOOGLE_CHECK_EQ(target_ptr, - string_as_array(target) + pos + data_.size() + indent_size); - } - } -} - -// =================================================================== - -CommandLineInterface::CommandLineInterface() - : mode_(MODE_COMPILE), - error_format_(ERROR_FORMAT_GCC), - imports_in_descriptor_set_(false), - source_info_in_descriptor_set_(false), - disallow_services_(false), - inputs_are_proto_path_relative_(false) {} -CommandLineInterface::~CommandLineInterface() {} - -void CommandLineInterface::RegisterGenerator(const string& flag_name, - CodeGenerator* generator, - const string& help_text) { - GeneratorInfo info; - info.flag_name = flag_name; - info.generator = generator; - info.help_text = help_text; - generators_by_flag_name_[flag_name] = info; -} - -void CommandLineInterface::RegisterGenerator(const string& flag_name, - const string& option_flag_name, - CodeGenerator* generator, - const string& help_text) { - GeneratorInfo info; - info.flag_name = flag_name; - info.option_flag_name = option_flag_name; - info.generator = generator; - info.help_text = help_text; - generators_by_flag_name_[flag_name] = info; - generators_by_option_name_[option_flag_name] = info; -} - -void CommandLineInterface::AllowPlugins(const string& exe_name_prefix) { - plugin_prefix_ = exe_name_prefix; -} - -int CommandLineInterface::Run(int argc, const char* const argv[]) { - Clear(); - switch (ParseArguments(argc, argv)) { - case PARSE_ARGUMENT_DONE_AND_EXIT: - return 0; - case PARSE_ARGUMENT_FAIL: - return 1; - case PARSE_ARGUMENT_DONE_AND_CONTINUE: - break; - } - - // Set up the source tree. - DiskSourceTree source_tree; - for (int i = 0; i < proto_path_.size(); i++) { - source_tree.MapPath(proto_path_[i].first, proto_path_[i].second); - } - - // Map input files to virtual paths if necessary. - if (!inputs_are_proto_path_relative_) { - if (!MakeInputsBeProtoPathRelative(&source_tree)) { - return 1; - } - } - - // Allocate the Importer. - ErrorPrinter error_collector(error_format_, &source_tree); - Importer importer(&source_tree, &error_collector); - - vector parsed_files; - - // Parse each file. - for (int i = 0; i < input_files_.size(); i++) { - // Import the file. - const FileDescriptor* parsed_file = importer.Import(input_files_[i]); - if (parsed_file == NULL) return 1; - parsed_files.push_back(parsed_file); - - // Enforce --disallow_services. - if (disallow_services_ && parsed_file->service_count() > 0) { - cerr << parsed_file->name() << ": This file contains services, but " - "--disallow_services was used." << endl; - return 1; - } - } - - // We construct a separate GeneratorContext for each output location. Note - // that two code generators may output to the same location, in which case - // they should share a single GeneratorContext so that OpenForInsert() works. - typedef hash_map GeneratorContextMap; - GeneratorContextMap output_directories; - - // Generate output. - if (mode_ == MODE_COMPILE) { - for (int i = 0; i < output_directives_.size(); i++) { - string output_location = output_directives_[i].output_location; - if (!HasSuffixString(output_location, ".zip") && - !HasSuffixString(output_location, ".jar")) { - AddTrailingSlash(&output_location); - } - GeneratorContextImpl** map_slot = &output_directories[output_location]; - - if (*map_slot == NULL) { - // First time we've seen this output location. - *map_slot = new GeneratorContextImpl(parsed_files); - } - - if (!GenerateOutput(parsed_files, output_directives_[i], *map_slot)) { - STLDeleteValues(&output_directories); - return 1; - } - } - } - - // Write all output to disk. - for (GeneratorContextMap::iterator iter = output_directories.begin(); - iter != output_directories.end(); ++iter) { - const string& location = iter->first; - GeneratorContextImpl* directory = iter->second; - if (HasSuffixString(location, "/")) { - if (!directory->WriteAllToDisk(location)) { - STLDeleteValues(&output_directories); - return 1; - } - } else { - if (HasSuffixString(location, ".jar")) { - directory->AddJarManifest(); - } - - if (!directory->WriteAllToZip(location)) { - STLDeleteValues(&output_directories); - return 1; - } - } - } - - STLDeleteValues(&output_directories); - - if (!descriptor_set_name_.empty()) { - if (!WriteDescriptorSet(parsed_files)) { - return 1; - } - } - - if (mode_ == MODE_ENCODE || mode_ == MODE_DECODE) { - if (codec_type_.empty()) { - // HACK: Define an EmptyMessage type to use for decoding. - DescriptorPool pool; - FileDescriptorProto file; - file.set_name("empty_message.proto"); - file.add_message_type()->set_name("EmptyMessage"); - GOOGLE_CHECK(pool.BuildFile(file) != NULL); - codec_type_ = "EmptyMessage"; - if (!EncodeOrDecode(&pool)) { - return 1; - } - } else { - if (!EncodeOrDecode(importer.pool())) { - return 1; - } - } - } - - return 0; -} - -void CommandLineInterface::Clear() { - // Clear all members that are set by Run(). Note that we must not clear - // members which are set by other methods before Run() is called. - executable_name_.clear(); - proto_path_.clear(); - input_files_.clear(); - output_directives_.clear(); - codec_type_.clear(); - descriptor_set_name_.clear(); - - mode_ = MODE_COMPILE; - imports_in_descriptor_set_ = false; - source_info_in_descriptor_set_ = false; - disallow_services_ = false; -} - -bool CommandLineInterface::MakeInputsBeProtoPathRelative( - DiskSourceTree* source_tree) { - for (int i = 0; i < input_files_.size(); i++) { - string virtual_file, shadowing_disk_file; - switch (source_tree->DiskFileToVirtualFile( - input_files_[i], &virtual_file, &shadowing_disk_file)) { - case DiskSourceTree::SUCCESS: - input_files_[i] = virtual_file; - break; - case DiskSourceTree::SHADOWED: - cerr << input_files_[i] << ": Input is shadowed in the --proto_path " - "by \"" << shadowing_disk_file << "\". Either use the latter " - "file as your input or reorder the --proto_path so that the " - "former file's location comes first." << endl; - return false; - case DiskSourceTree::CANNOT_OPEN: - cerr << input_files_[i] << ": " << strerror(errno) << endl; - return false; - case DiskSourceTree::NO_MAPPING: - // First check if the file exists at all. - if (access(input_files_[i].c_str(), F_OK) < 0) { - // File does not even exist. - cerr << input_files_[i] << ": " << strerror(ENOENT) << endl; - } else { - cerr << input_files_[i] << ": File does not reside within any path " - "specified using --proto_path (or -I). You must specify a " - "--proto_path which encompasses this file. Note that the " - "proto_path must be an exact prefix of the .proto file " - "names -- protoc is too dumb to figure out when two paths " - "(e.g. absolute and relative) are equivalent (it's harder " - "than you think)." << endl; - } - return false; - } - } - - return true; -} - -CommandLineInterface::ParseArgumentStatus -CommandLineInterface::ParseArguments(int argc, const char* const argv[]) { - executable_name_ = argv[0]; - - // Iterate through all arguments and parse them. - for (int i = 1; i < argc; i++) { - string name, value; - - if (ParseArgument(argv[i], &name, &value)) { - // Returned true => Use the next argument as the flag value. - if (i + 1 == argc || argv[i+1][0] == '-') { - cerr << "Missing value for flag: " << name << endl; - if (name == "--decode") { - cerr << "To decode an unknown message, use --decode_raw." << endl; - } - return PARSE_ARGUMENT_FAIL; - } else { - ++i; - value = argv[i]; - } - } - - ParseArgumentStatus status = InterpretArgument(name, value); - if (status != PARSE_ARGUMENT_DONE_AND_CONTINUE) - return status; - } - - // If no --proto_path was given, use the current working directory. - if (proto_path_.empty()) { - // Don't use make_pair as the old/default standard library on Solaris - // doesn't support it without explicit template parameters, which are - // incompatible with C++0x's make_pair. - proto_path_.push_back(pair("", ".")); - } - - // Check some errror cases. - bool decoding_raw = (mode_ == MODE_DECODE) && codec_type_.empty(); - if (decoding_raw && !input_files_.empty()) { - cerr << "When using --decode_raw, no input files should be given." << endl; - return PARSE_ARGUMENT_FAIL; - } else if (!decoding_raw && input_files_.empty()) { - cerr << "Missing input file." << endl; - return PARSE_ARGUMENT_FAIL; - } - if (mode_ == MODE_COMPILE && output_directives_.empty() && - descriptor_set_name_.empty()) { - cerr << "Missing output directives." << endl; - return PARSE_ARGUMENT_FAIL; - } - if (imports_in_descriptor_set_ && descriptor_set_name_.empty()) { - cerr << "--include_imports only makes sense when combined with " - "--descriptor_set_out." << endl; - } - if (source_info_in_descriptor_set_ && descriptor_set_name_.empty()) { - cerr << "--include_source_info only makes sense when combined with " - "--descriptor_set_out." << endl; - } - - return PARSE_ARGUMENT_DONE_AND_CONTINUE; -} - -bool CommandLineInterface::ParseArgument(const char* arg, - string* name, string* value) { - bool parsed_value = false; - - if (arg[0] != '-') { - // Not a flag. - name->clear(); - parsed_value = true; - *value = arg; - } else if (arg[1] == '-') { - // Two dashes: Multi-character name, with '=' separating name and - // value. - const char* equals_pos = strchr(arg, '='); - if (equals_pos != NULL) { - *name = string(arg, equals_pos - arg); - *value = equals_pos + 1; - parsed_value = true; - } else { - *name = arg; - } - } else { - // One dash: One-character name, all subsequent characters are the - // value. - if (arg[1] == '\0') { - // arg is just "-". We treat this as an input file, except that at - // present this will just lead to a "file not found" error. - name->clear(); - *value = arg; - parsed_value = true; - } else { - *name = string(arg, 2); - *value = arg + 2; - parsed_value = !value->empty(); - } - } - - // Need to return true iff the next arg should be used as the value for this - // one, false otherwise. - - if (parsed_value) { - // We already parsed a value for this flag. - return false; - } - - if (*name == "-h" || *name == "--help" || - *name == "--disallow_services" || - *name == "--include_imports" || - *name == "--include_source_info" || - *name == "--version" || - *name == "--decode_raw") { - // HACK: These are the only flags that don't take a value. - // They probably should not be hard-coded like this but for now it's - // not worth doing better. - return false; - } - - // Next argument is the flag value. - return true; -} - -CommandLineInterface::ParseArgumentStatus -CommandLineInterface::InterpretArgument(const string& name, - const string& value) { - if (name.empty()) { - // Not a flag. Just a filename. - if (value.empty()) { - cerr << "You seem to have passed an empty string as one of the " - "arguments to " << executable_name_ << ". This is actually " - "sort of hard to do. Congrats. Unfortunately it is not valid " - "input so the program is going to die now." << endl; - return PARSE_ARGUMENT_FAIL; - } - - input_files_.push_back(value); - - } else if (name == "-I" || name == "--proto_path") { - // Java's -classpath (and some other languages) delimits path components - // with colons. Let's accept that syntax too just to make things more - // intuitive. - vector parts; - SplitStringUsing(value, kPathSeparator, &parts); - - for (int i = 0; i < parts.size(); i++) { - string virtual_path; - string disk_path; - - string::size_type equals_pos = parts[i].find_first_of('='); - if (equals_pos == string::npos) { - virtual_path = ""; - disk_path = parts[i]; - } else { - virtual_path = parts[i].substr(0, equals_pos); - disk_path = parts[i].substr(equals_pos + 1); - } - - if (disk_path.empty()) { - cerr << "--proto_path passed empty directory name. (Use \".\" for " - "current directory.)" << endl; - return PARSE_ARGUMENT_FAIL; - } - - // Make sure disk path exists, warn otherwise. - if (access(disk_path.c_str(), F_OK) < 0) { - cerr << disk_path << ": warning: directory does not exist." << endl; - } - - // Don't use make_pair as the old/default standard library on Solaris - // doesn't support it without explicit template parameters, which are - // incompatible with C++0x's make_pair. - proto_path_.push_back(pair(virtual_path, disk_path)); - } - - } else if (name == "-o" || name == "--descriptor_set_out") { - if (!descriptor_set_name_.empty()) { - cerr << name << " may only be passed once." << endl; - return PARSE_ARGUMENT_FAIL; - } - if (value.empty()) { - cerr << name << " requires a non-empty value." << endl; - return PARSE_ARGUMENT_FAIL; - } - if (mode_ != MODE_COMPILE) { - cerr << "Cannot use --encode or --decode and generate descriptors at the " - "same time." << endl; - return PARSE_ARGUMENT_FAIL; - } - descriptor_set_name_ = value; - - } else if (name == "--include_imports") { - if (imports_in_descriptor_set_) { - cerr << name << " may only be passed once." << endl; - return PARSE_ARGUMENT_FAIL; - } - imports_in_descriptor_set_ = true; - - } else if (name == "--include_source_info") { - if (source_info_in_descriptor_set_) { - cerr << name << " may only be passed once." << endl; - return PARSE_ARGUMENT_FAIL; - } - source_info_in_descriptor_set_ = true; - - } else if (name == "-h" || name == "--help") { - PrintHelpText(); - return PARSE_ARGUMENT_DONE_AND_EXIT; // Exit without running compiler. - - } else if (name == "--version") { - if (!version_info_.empty()) { - cout << version_info_ << endl; - } - cout << "libprotoc " - << protobuf::internal::VersionString(GOOGLE_PROTOBUF_VERSION) - << endl; - return PARSE_ARGUMENT_DONE_AND_EXIT; // Exit without running compiler. - - } else if (name == "--disallow_services") { - disallow_services_ = true; - - } else if (name == "--encode" || name == "--decode" || - name == "--decode_raw") { - if (mode_ != MODE_COMPILE) { - cerr << "Only one of --encode and --decode can be specified." << endl; - return PARSE_ARGUMENT_FAIL; - } - if (!output_directives_.empty() || !descriptor_set_name_.empty()) { - cerr << "Cannot use " << name - << " and generate code or descriptors at the same time." << endl; - return PARSE_ARGUMENT_FAIL; - } - - mode_ = (name == "--encode") ? MODE_ENCODE : MODE_DECODE; - - if (value.empty() && name != "--decode_raw") { - cerr << "Type name for " << name << " cannot be blank." << endl; - if (name == "--decode") { - cerr << "To decode an unknown message, use --decode_raw." << endl; - } - return PARSE_ARGUMENT_FAIL; - } else if (!value.empty() && name == "--decode_raw") { - cerr << "--decode_raw does not take a parameter." << endl; - return PARSE_ARGUMENT_FAIL; - } - - codec_type_ = value; - - } else if (name == "--error_format") { - if (value == "gcc") { - error_format_ = ERROR_FORMAT_GCC; - } else if (value == "msvs") { - error_format_ = ERROR_FORMAT_MSVS; - } else { - cerr << "Unknown error format: " << value << endl; - return PARSE_ARGUMENT_FAIL; - } - - } else if (name == "--plugin") { - if (plugin_prefix_.empty()) { - cerr << "This compiler does not support plugins." << endl; - return PARSE_ARGUMENT_FAIL; - } - - string plugin_name; - string path; - - string::size_type equals_pos = value.find_first_of('='); - if (equals_pos == string::npos) { - // Use the basename of the file. - string::size_type slash_pos = value.find_last_of('/'); - if (slash_pos == string::npos) { - plugin_name = value; - } else { - plugin_name = value.substr(slash_pos + 1); - } - path = value; - } else { - plugin_name = value.substr(0, equals_pos); - path = value.substr(equals_pos + 1); - } - - plugins_[plugin_name] = path; - - } else { - // Some other flag. Look it up in the generators list. - const GeneratorInfo* generator_info = - FindOrNull(generators_by_flag_name_, name); - if (generator_info == NULL && - (plugin_prefix_.empty() || !HasSuffixString(name, "_out"))) { - // Check if it's a generator option flag. - generator_info = FindOrNull(generators_by_option_name_, name); - if (generator_info == NULL) { - cerr << "Unknown flag: " << name << endl; - return PARSE_ARGUMENT_FAIL; - } else { - string* parameters = &generator_parameters_[generator_info->flag_name]; - if (!parameters->empty()) { - parameters->append(","); - } - parameters->append(value); - } - } else { - // It's an output flag. Add it to the output directives. - if (mode_ != MODE_COMPILE) { - cerr << "Cannot use --encode or --decode and generate code at the " - "same time." << endl; - return PARSE_ARGUMENT_FAIL; - } - - OutputDirective directive; - directive.name = name; - if (generator_info == NULL) { - directive.generator = NULL; - } else { - directive.generator = generator_info->generator; - } - - // Split value at ':' to separate the generator parameter from the - // filename. However, avoid doing this if the colon is part of a valid - // Windows-style absolute path. - string::size_type colon_pos = value.find_first_of(':'); - if (colon_pos == string::npos || IsWindowsAbsolutePath(value)) { - directive.output_location = value; - } else { - directive.parameter = value.substr(0, colon_pos); - directive.output_location = value.substr(colon_pos + 1); - } - - output_directives_.push_back(directive); - } - } - - return PARSE_ARGUMENT_DONE_AND_CONTINUE; -} - -void CommandLineInterface::PrintHelpText() { - // Sorry for indentation here; line wrapping would be uglier. - cerr << -"Usage: " << executable_name_ << " [OPTION] PROTO_FILES\n" -"Parse PROTO_FILES and generate output based on the options given:\n" -" -IPATH, --proto_path=PATH Specify the directory in which to search for\n" -" imports. May be specified multiple times;\n" -" directories will be searched in order. If not\n" -" given, the current working directory is used.\n" -" --version Show version info and exit.\n" -" -h, --help Show this text and exit.\n" -" --encode=MESSAGE_TYPE Read a text-format message of the given type\n" -" from standard input and write it in binary\n" -" to standard output. The message type must\n" -" be defined in PROTO_FILES or their imports.\n" -" --decode=MESSAGE_TYPE Read a binary message of the given type from\n" -" standard input and write it in text format\n" -" to standard output. The message type must\n" -" be defined in PROTO_FILES or their imports.\n" -" --decode_raw Read an arbitrary protocol message from\n" -" standard input and write the raw tag/value\n" -" pairs in text format to standard output. No\n" -" PROTO_FILES should be given when using this\n" -" flag.\n" -" -oFILE, Writes a FileDescriptorSet (a protocol buffer,\n" -" --descriptor_set_out=FILE defined in descriptor.proto) containing all of\n" -" the input files to FILE.\n" -" --include_imports When using --descriptor_set_out, also include\n" -" all dependencies of the input files in the\n" -" set, so that the set is self-contained.\n" -" --include_source_info When using --descriptor_set_out, do not strip\n" -" SourceCodeInfo from the FileDescriptorProto.\n" -" This results in vastly larger descriptors that\n" -" include information about the original\n" -" location of each decl in the source file as\n" -" well as surrounding comments.\n" -" --error_format=FORMAT Set the format in which to print errors.\n" -" FORMAT may be 'gcc' (the default) or 'msvs'\n" -" (Microsoft Visual Studio format)." << endl; - if (!plugin_prefix_.empty()) { - cerr << -" --plugin=EXECUTABLE Specifies a plugin executable to use.\n" -" Normally, protoc searches the PATH for\n" -" plugins, but you may specify additional\n" -" executables not in the path using this flag.\n" -" Additionally, EXECUTABLE may be of the form\n" -" NAME=PATH, in which case the given plugin name\n" -" is mapped to the given executable even if\n" -" the executable's own name differs." << endl; - } - - for (GeneratorMap::iterator iter = generators_by_flag_name_.begin(); - iter != generators_by_flag_name_.end(); ++iter) { - // FIXME(kenton): If the text is long enough it will wrap, which is ugly, - // but fixing this nicely (e.g. splitting on spaces) is probably more - // trouble than it's worth. - cerr << " " << iter->first << "=OUT_DIR " - << string(19 - iter->first.size(), ' ') // Spaces for alignment. - << iter->second.help_text << endl; - } -} - -bool CommandLineInterface::GenerateOutput( - const vector& parsed_files, - const OutputDirective& output_directive, - GeneratorContext* generator_context) { - // Call the generator. - string error; - if (output_directive.generator == NULL) { - // This is a plugin. - GOOGLE_CHECK(HasPrefixString(output_directive.name, "--") && - HasSuffixString(output_directive.name, "_out")) - << "Bad name for plugin generator: " << output_directive.name; - - // Strip the "--" and "_out" and add the plugin prefix. - string plugin_name = plugin_prefix_ + "gen-" + - output_directive.name.substr(2, output_directive.name.size() - 6); - - if (!GeneratePluginOutput(parsed_files, plugin_name, - output_directive.parameter, - generator_context, &error)) { - cerr << output_directive.name << ": " << error << endl; - return false; - } - } else { - // Regular generator. - string parameters = output_directive.parameter; - if (!generator_parameters_[output_directive.name].empty()) { - if (!parameters.empty()) { - parameters.append(","); - } - parameters.append(generator_parameters_[output_directive.name]); - } - for (int i = 0; i < parsed_files.size(); i++) { - if (!output_directive.generator->Generate(parsed_files[i], parameters, - generator_context, &error)) { - // Generator returned an error. - cerr << output_directive.name << ": " << parsed_files[i]->name() << ": " - << error << endl; - return false; - } - } - } - - return true; -} - -bool CommandLineInterface::GeneratePluginOutput( - const vector& parsed_files, - const string& plugin_name, - const string& parameter, - GeneratorContext* generator_context, - string* error) { - CodeGeneratorRequest request; - CodeGeneratorResponse response; - - // Build the request. - if (!parameter.empty()) { - request.set_parameter(parameter); - } - - set already_seen; - for (int i = 0; i < parsed_files.size(); i++) { - request.add_file_to_generate(parsed_files[i]->name()); - GetTransitiveDependencies(parsed_files[i], - true, // Include source code info. - &already_seen, request.mutable_proto_file()); - } - - // Invoke the plugin. - Subprocess subprocess; - - if (plugins_.count(plugin_name) > 0) { - subprocess.Start(plugins_[plugin_name], Subprocess::EXACT_NAME); - } else { - subprocess.Start(plugin_name, Subprocess::SEARCH_PATH); - } - - string communicate_error; - if (!subprocess.Communicate(request, &response, &communicate_error)) { - *error = strings::Substitute("$0: $1", plugin_name, communicate_error); - return false; - } - - // Write the files. We do this even if there was a generator error in order - // to match the behavior of a compiled-in generator. - scoped_ptr current_output; - for (int i = 0; i < response.file_size(); i++) { - const CodeGeneratorResponse::File& output_file = response.file(i); - - if (!output_file.insertion_point().empty()) { - // Open a file for insert. - // We reset current_output to NULL first so that the old file is closed - // before the new one is opened. - current_output.reset(); - current_output.reset(generator_context->OpenForInsert( - output_file.name(), output_file.insertion_point())); - } else if (!output_file.name().empty()) { - // Starting a new file. Open it. - // We reset current_output to NULL first so that the old file is closed - // before the new one is opened. - current_output.reset(); - current_output.reset(generator_context->Open(output_file.name())); - } else if (current_output == NULL) { - *error = strings::Substitute( - "$0: First file chunk returned by plugin did not specify a file name.", - plugin_name); - return false; - } - - // Use CodedOutputStream for convenience; otherwise we'd need to provide - // our own buffer-copying loop. - io::CodedOutputStream writer(current_output.get()); - writer.WriteString(output_file.content()); - } - - // Check for errors. - if (!response.error().empty()) { - // Generator returned an error. - *error = response.error(); - return false; - } - - return true; -} - -bool CommandLineInterface::EncodeOrDecode(const DescriptorPool* pool) { - // Look up the type. - const Descriptor* type = pool->FindMessageTypeByName(codec_type_); - if (type == NULL) { - cerr << "Type not defined: " << codec_type_ << endl; - return false; - } - - DynamicMessageFactory dynamic_factory(pool); - scoped_ptr message(dynamic_factory.GetPrototype(type)->New()); - - if (mode_ == MODE_ENCODE) { - SetFdToTextMode(STDIN_FILENO); - SetFdToBinaryMode(STDOUT_FILENO); - } else { - SetFdToBinaryMode(STDIN_FILENO); - SetFdToTextMode(STDOUT_FILENO); - } - - io::FileInputStream in(STDIN_FILENO); - io::FileOutputStream out(STDOUT_FILENO); - - if (mode_ == MODE_ENCODE) { - // Input is text. - ErrorPrinter error_collector(error_format_); - TextFormat::Parser parser; - parser.RecordErrorsTo(&error_collector); - parser.AllowPartialMessage(true); - - if (!parser.Parse(&in, message.get())) { - cerr << "Failed to parse input." << endl; - return false; - } - } else { - // Input is binary. - if (!message->ParsePartialFromZeroCopyStream(&in)) { - cerr << "Failed to parse input." << endl; - return false; - } - } - - if (!message->IsInitialized()) { - cerr << "warning: Input message is missing required fields: " - << message->InitializationErrorString() << endl; - } - - if (mode_ == MODE_ENCODE) { - // Output is binary. - if (!message->SerializePartialToZeroCopyStream(&out)) { - cerr << "output: I/O error." << endl; - return false; - } - } else { - // Output is text. - if (!TextFormat::Print(*message, &out)) { - cerr << "output: I/O error." << endl; - return false; - } - } - - return true; -} - -bool CommandLineInterface::WriteDescriptorSet( - const vector parsed_files) { - FileDescriptorSet file_set; - - if (imports_in_descriptor_set_) { - set already_seen; - for (int i = 0; i < parsed_files.size(); i++) { - GetTransitiveDependencies(parsed_files[i], - source_info_in_descriptor_set_, - &already_seen, file_set.mutable_file()); - } - } else { - for (int i = 0; i < parsed_files.size(); i++) { - FileDescriptorProto* file_proto = file_set.add_file(); - parsed_files[i]->CopyTo(file_proto); - if (source_info_in_descriptor_set_) { - parsed_files[i]->CopySourceCodeInfoTo(file_proto); - } - } - } - - int fd; - do { - fd = open(descriptor_set_name_.c_str(), - O_WRONLY | O_CREAT | O_TRUNC | O_BINARY, 0666); - } while (fd < 0 && errno == EINTR); - - if (fd < 0) { - perror(descriptor_set_name_.c_str()); - return false; - } - - io::FileOutputStream out(fd); - if (!file_set.SerializeToZeroCopyStream(&out)) { - cerr << descriptor_set_name_ << ": " << strerror(out.GetErrno()) << endl; - out.Close(); - return false; - } - if (!out.Close()) { - cerr << descriptor_set_name_ << ": " << strerror(out.GetErrno()) << endl; - return false; - } - - return true; -} - -void CommandLineInterface::GetTransitiveDependencies( - const FileDescriptor* file, bool include_source_code_info, - set* already_seen, - RepeatedPtrField* output) { - if (!already_seen->insert(file).second) { - // Already saw this file. Skip. - return; - } - - // Add all dependencies. - for (int i = 0; i < file->dependency_count(); i++) { - GetTransitiveDependencies(file->dependency(i), include_source_code_info, - already_seen, output); - } - - // Add this file. - FileDescriptorProto* new_descriptor = output->Add(); - file->CopyTo(new_descriptor); - if (include_source_code_info) { - file->CopySourceCodeInfoTo(new_descriptor); - } -} - - -} // namespace compiler -} // namespace protobuf -} // namespace google diff --git a/modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/command_line_interface.h b/modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/command_line_interface.h deleted file mode 100644 index 86ea9bde2..000000000 --- a/modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/command_line_interface.h +++ /dev/null @@ -1,353 +0,0 @@ -// Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// http://code.google.com/p/protobuf/ -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -// Author: kenton@google.com (Kenton Varda) -// Based on original Protocol Buffers design by -// Sanjay Ghemawat, Jeff Dean, and others. -// -// Implements the Protocol Compiler front-end such that it may be reused by -// custom compilers written to support other languages. - -#ifndef GOOGLE_PROTOBUF_COMPILER_COMMAND_LINE_INTERFACE_H__ -#define GOOGLE_PROTOBUF_COMPILER_COMMAND_LINE_INTERFACE_H__ - -#include -#include -#include -#include -#include -#include - -namespace google { -namespace protobuf { - -class FileDescriptor; // descriptor.h -class DescriptorPool; // descriptor.h -class FileDescriptorProto; // descriptor.pb.h -template class RepeatedPtrField; // repeated_field.h - -namespace compiler { - -class CodeGenerator; // code_generator.h -class GeneratorContext; // code_generator.h -class DiskSourceTree; // importer.h - -// This class implements the command-line interface to the protocol compiler. -// It is designed to make it very easy to create a custom protocol compiler -// supporting the languages of your choice. For example, if you wanted to -// create a custom protocol compiler binary which includes both the regular -// C++ support plus support for your own custom output "Foo", you would -// write a class "FooGenerator" which implements the CodeGenerator interface, -// then write a main() procedure like this: -// -// int main(int argc, char* argv[]) { -// google::protobuf::compiler::CommandLineInterface cli; -// -// // Support generation of C++ source and headers. -// google::protobuf::compiler::cpp::CppGenerator cpp_generator; -// cli.RegisterGenerator("--cpp_out", &cpp_generator, -// "Generate C++ source and header."); -// -// // Support generation of Foo code. -// FooGenerator foo_generator; -// cli.RegisterGenerator("--foo_out", &foo_generator, -// "Generate Foo file."); -// -// return cli.Run(argc, argv); -// } -// -// The compiler is invoked with syntax like: -// protoc --cpp_out=outdir --foo_out=outdir --proto_path=src src/foo.proto -// -// For a full description of the command-line syntax, invoke it with --help. -class LIBPROTOC_EXPORT CommandLineInterface { - public: - CommandLineInterface(); - ~CommandLineInterface(); - - // Register a code generator for a language. - // - // Parameters: - // * flag_name: The command-line flag used to specify an output file of - // this type. The name must start with a '-'. If the name is longer - // than one letter, it must start with two '-'s. - // * generator: The CodeGenerator which will be called to generate files - // of this type. - // * help_text: Text describing this flag in the --help output. - // - // Some generators accept extra parameters. You can specify this parameter - // on the command-line by placing it before the output directory, separated - // by a colon: - // protoc --foo_out=enable_bar:outdir - // The text before the colon is passed to CodeGenerator::Generate() as the - // "parameter". - void RegisterGenerator(const string& flag_name, - CodeGenerator* generator, - const string& help_text); - - // Register a code generator for a language. - // Besides flag_name you can specify another option_flag_name that could be - // used to pass extra parameters to the registered code generator. - // Suppose you have registered a generator by calling: - // command_line_interface.RegisterGenerator("--foo_out", "--foo_opt", ...) - // Then you could invoke the compiler with a command like: - // protoc --foo_out=enable_bar:outdir --foo_opt=enable_baz - // This will pass "enable_bar,enable_baz" as the parameter to the generator. - void RegisterGenerator(const string& flag_name, - const string& option_flag_name, - CodeGenerator* generator, - const string& help_text); - - // Enables "plugins". In this mode, if a command-line flag ends with "_out" - // but does not match any registered generator, the compiler will attempt to - // find a "plugin" to implement the generator. Plugins are just executables. - // They should live somewhere in the PATH. - // - // The compiler determines the executable name to search for by concatenating - // exe_name_prefix with the unrecognized flag name, removing "_out". So, for - // example, if exe_name_prefix is "protoc-" and you pass the flag --foo_out, - // the compiler will try to run the program "protoc-foo". - // - // The plugin program should implement the following usage: - // plugin [--out=OUTDIR] [--parameter=PARAMETER] PROTO_FILES < DESCRIPTORS - // --out indicates the output directory (as passed to the --foo_out - // parameter); if omitted, the current directory should be used. --parameter - // gives the generator parameter, if any was provided. The PROTO_FILES list - // the .proto files which were given on the compiler command-line; these are - // the files for which the plugin is expected to generate output code. - // Finally, DESCRIPTORS is an encoded FileDescriptorSet (as defined in - // descriptor.proto). This is piped to the plugin's stdin. The set will - // include descriptors for all the files listed in PROTO_FILES as well as - // all files that they import. The plugin MUST NOT attempt to read the - // PROTO_FILES directly -- it must use the FileDescriptorSet. - // - // The plugin should generate whatever files are necessary, as code generators - // normally do. It should write the names of all files it generates to - // stdout. The names should be relative to the output directory, NOT absolute - // names or relative to the current directory. If any errors occur, error - // messages should be written to stderr. If an error is fatal, the plugin - // should exit with a non-zero exit code. - void AllowPlugins(const string& exe_name_prefix); - - // Run the Protocol Compiler with the given command-line parameters. - // Returns the error code which should be returned by main(). - // - // It may not be safe to call Run() in a multi-threaded environment because - // it calls strerror(). I'm not sure why you'd want to do this anyway. - int Run(int argc, const char* const argv[]); - - // Call SetInputsAreCwdRelative(true) if the input files given on the command - // line should be interpreted relative to the proto import path specified - // using --proto_path or -I flags. Otherwise, input file names will be - // interpreted relative to the current working directory (or as absolute - // paths if they start with '/'), though they must still reside inside - // a directory given by --proto_path or the compiler will fail. The latter - // mode is generally more intuitive and easier to use, especially e.g. when - // defining implicit rules in Makefiles. - void SetInputsAreProtoPathRelative(bool enable) { - inputs_are_proto_path_relative_ = enable; - } - - // Provides some text which will be printed when the --version flag is - // used. The version of libprotoc will also be printed on the next line - // after this text. - void SetVersionInfo(const string& text) { - version_info_ = text; - } - - - private: - // ----------------------------------------------------------------- - - class ErrorPrinter; - class GeneratorContextImpl; - class MemoryOutputStream; - - // Clear state from previous Run(). - void Clear(); - - // Remaps each file in input_files_ so that it is relative to one of the - // directories in proto_path_. Returns false if an error occurred. This - // is only used if inputs_are_proto_path_relative_ is false. - bool MakeInputsBeProtoPathRelative( - DiskSourceTree* source_tree); - - // Return status for ParseArguments() and InterpretArgument(). - enum ParseArgumentStatus { - PARSE_ARGUMENT_DONE_AND_CONTINUE, - PARSE_ARGUMENT_DONE_AND_EXIT, - PARSE_ARGUMENT_FAIL - }; - - // Parse all command-line arguments. - ParseArgumentStatus ParseArguments(int argc, const char* const argv[]); - - // Parses a command-line argument into a name/value pair. Returns - // true if the next argument in the argv should be used as the value, - // false otherwise. - // - // Exmaples: - // "-Isrc/protos" -> - // name = "-I", value = "src/protos" - // "--cpp_out=src/foo.pb2.cc" -> - // name = "--cpp_out", value = "src/foo.pb2.cc" - // "foo.proto" -> - // name = "", value = "foo.proto" - bool ParseArgument(const char* arg, string* name, string* value); - - // Interprets arguments parsed with ParseArgument. - ParseArgumentStatus InterpretArgument(const string& name, - const string& value); - - // Print the --help text to stderr. - void PrintHelpText(); - - // Generate the given output file from the given input. - struct OutputDirective; // see below - bool GenerateOutput(const vector& parsed_files, - const OutputDirective& output_directive, - GeneratorContext* generator_context); - bool GeneratePluginOutput(const vector& parsed_files, - const string& plugin_name, - const string& parameter, - GeneratorContext* generator_context, - string* error); - - // Implements --encode and --decode. - bool EncodeOrDecode(const DescriptorPool* pool); - - // Implements the --descriptor_set_out option. - bool WriteDescriptorSet(const vector parsed_files); - - // Get all transitive dependencies of the given file (including the file - // itself), adding them to the given list of FileDescriptorProtos. The - // protos will be ordered such that every file is listed before any file that - // depends on it, so that you can call DescriptorPool::BuildFile() on them - // in order. Any files in *already_seen will not be added, and each file - // added will be inserted into *already_seen. If include_source_code_info is - // true then include the source code information in the FileDescriptorProtos. - static void GetTransitiveDependencies( - const FileDescriptor* file, - bool include_source_code_info, - set* already_seen, - RepeatedPtrField* output); - - // ----------------------------------------------------------------- - - // The name of the executable as invoked (i.e. argv[0]). - string executable_name_; - - // Version info set with SetVersionInfo(). - string version_info_; - - // Registered generators. - struct GeneratorInfo { - string flag_name; - string option_flag_name; - CodeGenerator* generator; - string help_text; - }; - typedef map GeneratorMap; - GeneratorMap generators_by_flag_name_; - GeneratorMap generators_by_option_name_; - // A map from generator names to the parameters specified using the option - // flag. For example, if the user invokes the compiler with: - // protoc --foo_out=outputdir --foo_opt=enable_bar ... - // Then there will be an entry ("--foo_out", "enable_bar") in this map. - map generator_parameters_; - - // See AllowPlugins(). If this is empty, plugins aren't allowed. - string plugin_prefix_; - - // Maps specific plugin names to files. When executing a plugin, this map - // is searched first to find the plugin executable. If not found here, the - // PATH (or other OS-specific search strategy) is searched. - map plugins_; - - // Stuff parsed from command line. - enum Mode { - MODE_COMPILE, // Normal mode: parse .proto files and compile them. - MODE_ENCODE, // --encode: read text from stdin, write binary to stdout. - MODE_DECODE // --decode: read binary from stdin, write text to stdout. - }; - - Mode mode_; - - enum ErrorFormat { - ERROR_FORMAT_GCC, // GCC error output format (default). - ERROR_FORMAT_MSVS // Visual Studio output (--error_format=msvs). - }; - - ErrorFormat error_format_; - - vector > proto_path_; // Search path for proto files. - vector input_files_; // Names of the input proto files. - - // output_directives_ lists all the files we are supposed to output and what - // generator to use for each. - struct OutputDirective { - string name; // E.g. "--foo_out" - CodeGenerator* generator; // NULL for plugins - string parameter; - string output_location; - }; - vector output_directives_; - - // When using --encode or --decode, this names the type we are encoding or - // decoding. (Empty string indicates --decode_raw.) - string codec_type_; - - // If --descriptor_set_out was given, this is the filename to which the - // FileDescriptorSet should be written. Otherwise, empty. - string descriptor_set_name_; - - // True if --include_imports was given, meaning that we should - // write all transitive dependencies to the DescriptorSet. Otherwise, only - // the .proto files listed on the command-line are added. - bool imports_in_descriptor_set_; - - // True if --include_source_info was given, meaning that we should not strip - // SourceCodeInfo from the DescriptorSet. - bool source_info_in_descriptor_set_; - - // Was the --disallow_services flag used? - bool disallow_services_; - - // See SetInputsAreProtoPathRelative(). - bool inputs_are_proto_path_relative_; - - GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(CommandLineInterface); -}; - -} // namespace compiler -} // namespace protobuf - -} // namespace google -#endif // GOOGLE_PROTOBUF_COMPILER_COMMAND_LINE_INTERFACE_H__ diff --git a/modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/command_line_interface_unittest.cc b/modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/command_line_interface_unittest.cc deleted file mode 100644 index 165599231..000000000 --- a/modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/command_line_interface_unittest.cc +++ /dev/null @@ -1,1560 +0,0 @@ -// Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// http://code.google.com/p/protobuf/ -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -// Author: kenton@google.com (Kenton Varda) -// Based on original Protocol Buffers design by -// Sanjay Ghemawat, Jeff Dean, and others. - -#include -#include -#include -#ifdef _MSC_VER -#include -#else -#include -#endif -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -namespace google { -namespace protobuf { -namespace compiler { - -#if defined(_WIN32) -#ifndef STDIN_FILENO -#define STDIN_FILENO 0 -#endif -#ifndef STDOUT_FILENO -#define STDOUT_FILENO 1 -#endif -#ifndef F_OK -#define F_OK 00 // not defined by MSVC for whatever reason -#endif -#endif - -namespace { - -class CommandLineInterfaceTest : public testing::Test { - protected: - virtual void SetUp(); - virtual void TearDown(); - - // Runs the CommandLineInterface with the given command line. The - // command is automatically split on spaces, and the string "$tmpdir" - // is replaced with TestTempDir(). - void Run(const string& command); - - // ----------------------------------------------------------------- - // Methods to set up the test (called before Run()). - - class NullCodeGenerator; - - // Normally plugins are allowed for all tests. Call this to explicitly - // disable them. - void DisallowPlugins() { disallow_plugins_ = true; } - - // Create a temp file within temp_directory_ with the given name. - // The containing directory is also created if necessary. - void CreateTempFile(const string& name, const string& contents); - - // Create a subdirectory within temp_directory_. - void CreateTempDir(const string& name); - - void SetInputsAreProtoPathRelative(bool enable) { - cli_.SetInputsAreProtoPathRelative(enable); - } - - // ----------------------------------------------------------------- - // Methods to check the test results (called after Run()). - - // Checks that no text was written to stderr during Run(), and Run() - // returned 0. - void ExpectNoErrors(); - - // Checks that Run() returned non-zero and the stderr output is exactly - // the text given. expected_test may contain references to "$tmpdir", - // which will be replaced by the temporary directory path. - void ExpectErrorText(const string& expected_text); - - // Checks that Run() returned non-zero and the stderr contains the given - // substring. - void ExpectErrorSubstring(const string& expected_substring); - - // Like ExpectErrorSubstring, but checks that Run() returned zero. - void ExpectErrorSubstringWithZeroReturnCode( - const string& expected_substring); - - // Returns true if ExpectErrorSubstring(expected_substring) would pass, but - // does not fail otherwise. - bool HasAlternateErrorSubstring(const string& expected_substring); - - // Checks that MockCodeGenerator::Generate() was called in the given - // context (or the generator in test_plugin.cc, which produces the same - // output). That is, this tests if the generator with the given name - // was called with the given parameter and proto file and produced the - // given output file. This is checked by reading the output file and - // checking that it contains the content that MockCodeGenerator would - // generate given these inputs. message_name is the name of the first - // message that appeared in the proto file; this is just to make extra - // sure that the correct file was parsed. - void ExpectGenerated(const string& generator_name, - const string& parameter, - const string& proto_name, - const string& message_name); - void ExpectGenerated(const string& generator_name, - const string& parameter, - const string& proto_name, - const string& message_name, - const string& output_directory); - void ExpectGeneratedWithMultipleInputs(const string& generator_name, - const string& all_proto_names, - const string& proto_name, - const string& message_name); - void ExpectGeneratedWithInsertions(const string& generator_name, - const string& parameter, - const string& insertions, - const string& proto_name, - const string& message_name); - - void ExpectNullCodeGeneratorCalled(const string& parameter); - - void ReadDescriptorSet(const string& filename, - FileDescriptorSet* descriptor_set); - - private: - // The object we are testing. - CommandLineInterface cli_; - - // Was DisallowPlugins() called? - bool disallow_plugins_; - - // We create a directory within TestTempDir() in order to add extra - // protection against accidentally deleting user files (since we recursively - // delete this directory during the test). This is the full path of that - // directory. - string temp_directory_; - - // The result of Run(). - int return_code_; - - // The captured stderr output. - string error_text_; - - // Pointers which need to be deleted later. - vector mock_generators_to_delete_; - - NullCodeGenerator* null_generator_; -}; - -class CommandLineInterfaceTest::NullCodeGenerator : public CodeGenerator { - public: - NullCodeGenerator() : called_(false) {} - ~NullCodeGenerator() {} - - mutable bool called_; - mutable string parameter_; - - // implements CodeGenerator ---------------------------------------- - bool Generate(const FileDescriptor* file, - const string& parameter, - GeneratorContext* context, - string* error) const { - called_ = true; - parameter_ = parameter; - return true; - } -}; - -// =================================================================== - -void CommandLineInterfaceTest::SetUp() { - // Most of these tests were written before this option was added, so we - // run with the option on (which used to be the only way) except in certain - // tests where we turn it off. - cli_.SetInputsAreProtoPathRelative(true); - - temp_directory_ = TestTempDir() + "/proto2_cli_test_temp"; - - // If the temp directory already exists, it must be left over from a - // previous run. Delete it. - if (File::Exists(temp_directory_)) { - File::DeleteRecursively(temp_directory_, NULL, NULL); - } - - // Create the temp directory. - GOOGLE_CHECK(File::CreateDir(temp_directory_.c_str(), DEFAULT_FILE_MODE)); - - // Register generators. - CodeGenerator* generator = new MockCodeGenerator("test_generator"); - mock_generators_to_delete_.push_back(generator); - cli_.RegisterGenerator("--test_out", "--test_opt", generator, "Test output."); - cli_.RegisterGenerator("-t", generator, "Test output."); - - generator = new MockCodeGenerator("alt_generator"); - mock_generators_to_delete_.push_back(generator); - cli_.RegisterGenerator("--alt_out", generator, "Alt output."); - - generator = null_generator_ = new NullCodeGenerator(); - mock_generators_to_delete_.push_back(generator); - cli_.RegisterGenerator("--null_out", generator, "Null output."); - - disallow_plugins_ = false; -} - -void CommandLineInterfaceTest::TearDown() { - // Delete the temp directory. - File::DeleteRecursively(temp_directory_, NULL, NULL); - - // Delete all the MockCodeGenerators. - for (int i = 0; i < mock_generators_to_delete_.size(); i++) { - delete mock_generators_to_delete_[i]; - } - mock_generators_to_delete_.clear(); -} - -void CommandLineInterfaceTest::Run(const string& command) { - vector args; - SplitStringUsing(command, " ", &args); - - if (!disallow_plugins_) { - cli_.AllowPlugins("prefix-"); - const char* possible_paths[] = { - // When building with shared libraries, libtool hides the real executable - // in .libs and puts a fake wrapper in the current directory. - // Unfortunately, due to an apparent bug on Cygwin/MinGW, if one program - // wrapped in this way (e.g. protobuf-tests.exe) tries to execute another - // program wrapped in this way (e.g. test_plugin.exe), the latter fails - // with error code 127 and no explanation message. Presumably the problem - // is that the wrapper for protobuf-tests.exe set some environment - // variables that confuse the wrapper for test_plugin.exe. Luckily, it - // turns out that if we simply invoke the wrapped test_plugin.exe - // directly, it works -- I guess the environment variables set by the - // protobuf-tests.exe wrapper happen to be correct for it too. So we do - // that. - ".libs/test_plugin.exe", // Win32 w/autotool (Cygwin / MinGW) - "test_plugin.exe", // Other Win32 (MSVC) - "test_plugin", // Unix - }; - - string plugin_path; - - for (int i = 0; i < GOOGLE_ARRAYSIZE(possible_paths); i++) { - if (access(possible_paths[i], F_OK) == 0) { - plugin_path = possible_paths[i]; - break; - } - } - - if (plugin_path.empty()) { - GOOGLE_LOG(ERROR) - << "Plugin executable not found. Plugin tests are likely to fail."; - } else { - args.push_back("--plugin=prefix-gen-plug=" + plugin_path); - } - } - - scoped_array argv(new const char*[args.size()]); - - for (int i = 0; i < args.size(); i++) { - args[i] = StringReplace(args[i], "$tmpdir", temp_directory_, true); - argv[i] = args[i].c_str(); - } - - CaptureTestStderr(); - - return_code_ = cli_.Run(args.size(), argv.get()); - - error_text_ = GetCapturedTestStderr(); -} - -// ------------------------------------------------------------------- - -void CommandLineInterfaceTest::CreateTempFile( - const string& name, - const string& contents) { - // Create parent directory, if necessary. - string::size_type slash_pos = name.find_last_of('/'); - if (slash_pos != string::npos) { - string dir = name.substr(0, slash_pos); - File::RecursivelyCreateDir(temp_directory_ + "/" + dir, 0777); - } - - // Write file. - string full_name = temp_directory_ + "/" + name; - File::WriteStringToFileOrDie(contents, full_name); -} - -void CommandLineInterfaceTest::CreateTempDir(const string& name) { - File::RecursivelyCreateDir(temp_directory_ + "/" + name, 0777); -} - -// ------------------------------------------------------------------- - -void CommandLineInterfaceTest::ExpectNoErrors() { - EXPECT_EQ(0, return_code_); - EXPECT_EQ("", error_text_); -} - -void CommandLineInterfaceTest::ExpectErrorText(const string& expected_text) { - EXPECT_NE(0, return_code_); - EXPECT_EQ(StringReplace(expected_text, "$tmpdir", temp_directory_, true), - error_text_); -} - -void CommandLineInterfaceTest::ExpectErrorSubstring( - const string& expected_substring) { - EXPECT_NE(0, return_code_); - EXPECT_PRED_FORMAT2(testing::IsSubstring, expected_substring, error_text_); -} - -void CommandLineInterfaceTest::ExpectErrorSubstringWithZeroReturnCode( - const string& expected_substring) { - EXPECT_EQ(0, return_code_); - EXPECT_PRED_FORMAT2(testing::IsSubstring, expected_substring, error_text_); -} - -bool CommandLineInterfaceTest::HasAlternateErrorSubstring( - const string& expected_substring) { - EXPECT_NE(0, return_code_); - return error_text_.find(expected_substring) != string::npos; -} - -void CommandLineInterfaceTest::ExpectGenerated( - const string& generator_name, - const string& parameter, - const string& proto_name, - const string& message_name) { - MockCodeGenerator::ExpectGenerated( - generator_name, parameter, "", proto_name, message_name, proto_name, - temp_directory_); -} - -void CommandLineInterfaceTest::ExpectGenerated( - const string& generator_name, - const string& parameter, - const string& proto_name, - const string& message_name, - const string& output_directory) { - MockCodeGenerator::ExpectGenerated( - generator_name, parameter, "", proto_name, message_name, proto_name, - temp_directory_ + "/" + output_directory); -} - -void CommandLineInterfaceTest::ExpectGeneratedWithMultipleInputs( - const string& generator_name, - const string& all_proto_names, - const string& proto_name, - const string& message_name) { - MockCodeGenerator::ExpectGenerated( - generator_name, "", "", proto_name, message_name, - all_proto_names, - temp_directory_); -} - -void CommandLineInterfaceTest::ExpectGeneratedWithInsertions( - const string& generator_name, - const string& parameter, - const string& insertions, - const string& proto_name, - const string& message_name) { - MockCodeGenerator::ExpectGenerated( - generator_name, parameter, insertions, proto_name, message_name, - proto_name, temp_directory_); -} - -void CommandLineInterfaceTest::ExpectNullCodeGeneratorCalled( - const string& parameter) { - EXPECT_TRUE(null_generator_->called_); - EXPECT_EQ(parameter, null_generator_->parameter_); -} - -void CommandLineInterfaceTest::ReadDescriptorSet( - const string& filename, FileDescriptorSet* descriptor_set) { - string path = temp_directory_ + "/" + filename; - string file_contents; - if (!File::ReadFileToString(path, &file_contents)) { - FAIL() << "File not found: " << path; - } - if (!descriptor_set->ParseFromString(file_contents)) { - FAIL() << "Could not parse file contents: " << path; - } -} - -// =================================================================== - -TEST_F(CommandLineInterfaceTest, BasicOutput) { - // Test that the common case works. - - CreateTempFile("foo.proto", - "syntax = \"proto2\";\n" - "message Foo {}\n"); - - Run("protocol_compiler --test_out=$tmpdir " - "--proto_path=$tmpdir foo.proto"); - - ExpectNoErrors(); - ExpectGenerated("test_generator", "", "foo.proto", "Foo"); -} - -TEST_F(CommandLineInterfaceTest, BasicPlugin) { - // Test that basic plugins work. - - CreateTempFile("foo.proto", - "syntax = \"proto2\";\n" - "message Foo {}\n"); - - Run("protocol_compiler --plug_out=$tmpdir " - "--proto_path=$tmpdir foo.proto"); - - ExpectNoErrors(); - ExpectGenerated("test_plugin", "", "foo.proto", "Foo"); -} - -TEST_F(CommandLineInterfaceTest, GeneratorAndPlugin) { - // Invoke a generator and a plugin at the same time. - - CreateTempFile("foo.proto", - "syntax = \"proto2\";\n" - "message Foo {}\n"); - - Run("protocol_compiler --test_out=$tmpdir --plug_out=$tmpdir " - "--proto_path=$tmpdir foo.proto"); - - ExpectNoErrors(); - ExpectGenerated("test_generator", "", "foo.proto", "Foo"); - ExpectGenerated("test_plugin", "", "foo.proto", "Foo"); -} - -TEST_F(CommandLineInterfaceTest, MultipleInputs) { - // Test parsing multiple input files. - - CreateTempFile("foo.proto", - "syntax = \"proto2\";\n" - "message Foo {}\n"); - CreateTempFile("bar.proto", - "syntax = \"proto2\";\n" - "message Bar {}\n"); - - Run("protocol_compiler --test_out=$tmpdir --plug_out=$tmpdir " - "--proto_path=$tmpdir foo.proto bar.proto"); - - ExpectNoErrors(); - ExpectGeneratedWithMultipleInputs("test_generator", "foo.proto,bar.proto", - "foo.proto", "Foo"); - ExpectGeneratedWithMultipleInputs("test_generator", "foo.proto,bar.proto", - "bar.proto", "Bar"); - ExpectGeneratedWithMultipleInputs("test_plugin", "foo.proto,bar.proto", - "foo.proto", "Foo"); - ExpectGeneratedWithMultipleInputs("test_plugin", "foo.proto,bar.proto", - "bar.proto", "Bar"); -} - -TEST_F(CommandLineInterfaceTest, MultipleInputsWithImport) { - // Test parsing multiple input files with an import of a separate file. - - CreateTempFile("foo.proto", - "syntax = \"proto2\";\n" - "message Foo {}\n"); - CreateTempFile("bar.proto", - "syntax = \"proto2\";\n" - "import \"baz.proto\";\n" - "message Bar {\n" - " optional Baz a = 1;\n" - "}\n"); - CreateTempFile("baz.proto", - "syntax = \"proto2\";\n" - "message Baz {}\n"); - - Run("protocol_compiler --test_out=$tmpdir --plug_out=$tmpdir " - "--proto_path=$tmpdir foo.proto bar.proto"); - - ExpectNoErrors(); - ExpectGeneratedWithMultipleInputs("test_generator", "foo.proto,bar.proto", - "foo.proto", "Foo"); - ExpectGeneratedWithMultipleInputs("test_generator", "foo.proto,bar.proto", - "bar.proto", "Bar"); - ExpectGeneratedWithMultipleInputs("test_plugin", "foo.proto,bar.proto", - "foo.proto", "Foo"); - ExpectGeneratedWithMultipleInputs("test_plugin", "foo.proto,bar.proto", - "bar.proto", "Bar"); -} - -TEST_F(CommandLineInterfaceTest, CreateDirectory) { - // Test that when we output to a sub-directory, it is created. - - CreateTempFile("bar/baz/foo.proto", - "syntax = \"proto2\";\n" - "message Foo {}\n"); - CreateTempDir("out"); - CreateTempDir("plugout"); - - Run("protocol_compiler --test_out=$tmpdir/out --plug_out=$tmpdir/plugout " - "--proto_path=$tmpdir bar/baz/foo.proto"); - - ExpectNoErrors(); - ExpectGenerated("test_generator", "", "bar/baz/foo.proto", "Foo", "out"); - ExpectGenerated("test_plugin", "", "bar/baz/foo.proto", "Foo", "plugout"); -} - -TEST_F(CommandLineInterfaceTest, GeneratorParameters) { - // Test that generator parameters are correctly parsed from the command line. - - CreateTempFile("foo.proto", - "syntax = \"proto2\";\n" - "message Foo {}\n"); - - Run("protocol_compiler --test_out=TestParameter:$tmpdir " - "--plug_out=TestPluginParameter:$tmpdir " - "--proto_path=$tmpdir foo.proto"); - - ExpectNoErrors(); - ExpectGenerated("test_generator", "TestParameter", "foo.proto", "Foo"); - ExpectGenerated("test_plugin", "TestPluginParameter", "foo.proto", "Foo"); -} - -TEST_F(CommandLineInterfaceTest, ExtraGeneratorParameters) { - // Test that generator parameters specified with the option flag are - // correctly passed to the code generator. - - CreateTempFile("foo.proto", - "syntax = \"proto2\";\n" - "message Foo {}\n"); - // Create the "a" and "b" sub-directories. - CreateTempDir("a"); - CreateTempDir("b"); - - Run("protocol_compiler " - "--test_opt=foo1 " - "--test_out=bar:$tmpdir/a " - "--test_opt=foo2 " - "--test_out=baz:$tmpdir/b " - "--test_opt=foo3 " - "--proto_path=$tmpdir foo.proto"); - - ExpectNoErrors(); - ExpectGenerated( - "test_generator", "bar,foo1,foo2,foo3", "foo.proto", "Foo", "a"); - ExpectGenerated( - "test_generator", "baz,foo1,foo2,foo3", "foo.proto", "Foo", "b"); -} - -TEST_F(CommandLineInterfaceTest, Insert) { - // Test running a generator that inserts code into another's output. - - CreateTempFile("foo.proto", - "syntax = \"proto2\";\n" - "message Foo {}\n"); - - Run("protocol_compiler " - "--test_out=TestParameter:$tmpdir " - "--plug_out=TestPluginParameter:$tmpdir " - "--test_out=insert=test_generator,test_plugin:$tmpdir " - "--plug_out=insert=test_generator,test_plugin:$tmpdir " - "--proto_path=$tmpdir foo.proto"); - - ExpectNoErrors(); - ExpectGeneratedWithInsertions( - "test_generator", "TestParameter", "test_generator,test_plugin", - "foo.proto", "Foo"); - ExpectGeneratedWithInsertions( - "test_plugin", "TestPluginParameter", "test_generator,test_plugin", - "foo.proto", "Foo"); -} - -#if defined(_WIN32) - -TEST_F(CommandLineInterfaceTest, WindowsOutputPath) { - // Test that the output path can be a Windows-style path. - - CreateTempFile("foo.proto", - "syntax = \"proto2\";\n"); - - Run("protocol_compiler --null_out=C:\\ " - "--proto_path=$tmpdir foo.proto"); - - ExpectNoErrors(); - ExpectNullCodeGeneratorCalled(""); -} - -TEST_F(CommandLineInterfaceTest, WindowsOutputPathAndParameter) { - // Test that we can have a windows-style output path and a parameter. - - CreateTempFile("foo.proto", - "syntax = \"proto2\";\n"); - - Run("protocol_compiler --null_out=bar:C:\\ " - "--proto_path=$tmpdir foo.proto"); - - ExpectNoErrors(); - ExpectNullCodeGeneratorCalled("bar"); -} - -TEST_F(CommandLineInterfaceTest, TrailingBackslash) { - // Test that the directories can end in backslashes. Some users claim this - // doesn't work on their system. - - CreateTempFile("foo.proto", - "syntax = \"proto2\";\n" - "message Foo {}\n"); - - Run("protocol_compiler --test_out=$tmpdir\\ " - "--proto_path=$tmpdir\\ foo.proto"); - - ExpectNoErrors(); - ExpectGenerated("test_generator", "", "foo.proto", "Foo"); -} - -#endif // defined(_WIN32) || defined(__CYGWIN__) - -TEST_F(CommandLineInterfaceTest, PathLookup) { - // Test that specifying multiple directories in the proto search path works. - - CreateTempFile("b/bar.proto", - "syntax = \"proto2\";\n" - "message Bar {}\n"); - CreateTempFile("a/foo.proto", - "syntax = \"proto2\";\n" - "import \"bar.proto\";\n" - "message Foo {\n" - " optional Bar a = 1;\n" - "}\n"); - CreateTempFile("b/foo.proto", "this should not be parsed\n"); - - Run("protocol_compiler --test_out=$tmpdir " - "--proto_path=$tmpdir/a --proto_path=$tmpdir/b foo.proto"); - - ExpectNoErrors(); - ExpectGenerated("test_generator", "", "foo.proto", "Foo"); -} - -TEST_F(CommandLineInterfaceTest, ColonDelimitedPath) { - // Same as PathLookup, but we provide the proto_path in a single flag. - - CreateTempFile("b/bar.proto", - "syntax = \"proto2\";\n" - "message Bar {}\n"); - CreateTempFile("a/foo.proto", - "syntax = \"proto2\";\n" - "import \"bar.proto\";\n" - "message Foo {\n" - " optional Bar a = 1;\n" - "}\n"); - CreateTempFile("b/foo.proto", "this should not be parsed\n"); - -#undef PATH_SEPARATOR -#if defined(_WIN32) -#define PATH_SEPARATOR ";" -#else -#define PATH_SEPARATOR ":" -#endif - - Run("protocol_compiler --test_out=$tmpdir " - "--proto_path=$tmpdir/a"PATH_SEPARATOR"$tmpdir/b foo.proto"); - -#undef PATH_SEPARATOR - - ExpectNoErrors(); - ExpectGenerated("test_generator", "", "foo.proto", "Foo"); -} - -TEST_F(CommandLineInterfaceTest, NonRootMapping) { - // Test setting up a search path mapping a directory to a non-root location. - - CreateTempFile("foo.proto", - "syntax = \"proto2\";\n" - "message Foo {}\n"); - - Run("protocol_compiler --test_out=$tmpdir " - "--proto_path=bar=$tmpdir bar/foo.proto"); - - ExpectNoErrors(); - ExpectGenerated("test_generator", "", "bar/foo.proto", "Foo"); -} - -TEST_F(CommandLineInterfaceTest, MultipleGenerators) { - // Test that we can have multiple generators and use both in one invocation, - // each with a different output directory. - - CreateTempFile("foo.proto", - "syntax = \"proto2\";\n" - "message Foo {}\n"); - // Create the "a" and "b" sub-directories. - CreateTempDir("a"); - CreateTempDir("b"); - - Run("protocol_compiler " - "--test_out=$tmpdir/a " - "--alt_out=$tmpdir/b " - "--proto_path=$tmpdir foo.proto"); - - ExpectNoErrors(); - ExpectGenerated("test_generator", "", "foo.proto", "Foo", "a"); - ExpectGenerated("alt_generator", "", "foo.proto", "Foo", "b"); -} - -TEST_F(CommandLineInterfaceTest, DisallowServicesNoServices) { - // Test that --disallow_services doesn't cause a problem when there are no - // services. - - CreateTempFile("foo.proto", - "syntax = \"proto2\";\n" - "message Foo {}\n"); - - Run("protocol_compiler --disallow_services --test_out=$tmpdir " - "--proto_path=$tmpdir foo.proto"); - - ExpectNoErrors(); - ExpectGenerated("test_generator", "", "foo.proto", "Foo"); -} - -TEST_F(CommandLineInterfaceTest, DisallowServicesHasService) { - // Test that --disallow_services produces an error when there are services. - - CreateTempFile("foo.proto", - "syntax = \"proto2\";\n" - "message Foo {}\n" - "service Bar {}\n"); - - Run("protocol_compiler --disallow_services --test_out=$tmpdir " - "--proto_path=$tmpdir foo.proto"); - - ExpectErrorSubstring("foo.proto: This file contains services"); -} - -TEST_F(CommandLineInterfaceTest, AllowServicesHasService) { - // Test that services work fine as long as --disallow_services is not used. - - CreateTempFile("foo.proto", - "syntax = \"proto2\";\n" - "message Foo {}\n" - "service Bar {}\n"); - - Run("protocol_compiler --test_out=$tmpdir " - "--proto_path=$tmpdir foo.proto"); - - ExpectNoErrors(); - ExpectGenerated("test_generator", "", "foo.proto", "Foo"); -} - -TEST_F(CommandLineInterfaceTest, CwdRelativeInputs) { - // Test that we can accept working-directory-relative input files. - - SetInputsAreProtoPathRelative(false); - - CreateTempFile("foo.proto", - "syntax = \"proto2\";\n" - "message Foo {}\n"); - - Run("protocol_compiler --test_out=$tmpdir " - "--proto_path=$tmpdir $tmpdir/foo.proto"); - - ExpectNoErrors(); - ExpectGenerated("test_generator", "", "foo.proto", "Foo"); -} - -TEST_F(CommandLineInterfaceTest, WriteDescriptorSet) { - CreateTempFile("foo.proto", - "syntax = \"proto2\";\n" - "message Foo {}\n"); - CreateTempFile("bar.proto", - "syntax = \"proto2\";\n" - "import \"foo.proto\";\n" - "message Bar {\n" - " optional Foo foo = 1;\n" - "}\n"); - - Run("protocol_compiler --descriptor_set_out=$tmpdir/descriptor_set " - "--proto_path=$tmpdir bar.proto"); - - ExpectNoErrors(); - - FileDescriptorSet descriptor_set; - ReadDescriptorSet("descriptor_set", &descriptor_set); - if (HasFatalFailure()) return; - ASSERT_EQ(1, descriptor_set.file_size()); - EXPECT_EQ("bar.proto", descriptor_set.file(0).name()); - // Descriptor set should not have source code info. - EXPECT_FALSE(descriptor_set.file(0).has_source_code_info()); -} - -TEST_F(CommandLineInterfaceTest, WriteDescriptorSetWithSourceInfo) { - CreateTempFile("foo.proto", - "syntax = \"proto2\";\n" - "message Foo {}\n"); - CreateTempFile("bar.proto", - "syntax = \"proto2\";\n" - "import \"foo.proto\";\n" - "message Bar {\n" - " optional Foo foo = 1;\n" - "}\n"); - - Run("protocol_compiler --descriptor_set_out=$tmpdir/descriptor_set " - "--include_source_info --proto_path=$tmpdir bar.proto"); - - ExpectNoErrors(); - - FileDescriptorSet descriptor_set; - ReadDescriptorSet("descriptor_set", &descriptor_set); - if (HasFatalFailure()) return; - ASSERT_EQ(1, descriptor_set.file_size()); - EXPECT_EQ("bar.proto", descriptor_set.file(0).name()); - // Source code info included. - EXPECT_TRUE(descriptor_set.file(0).has_source_code_info()); -} - -TEST_F(CommandLineInterfaceTest, WriteTransitiveDescriptorSet) { - CreateTempFile("foo.proto", - "syntax = \"proto2\";\n" - "message Foo {}\n"); - CreateTempFile("bar.proto", - "syntax = \"proto2\";\n" - "import \"foo.proto\";\n" - "message Bar {\n" - " optional Foo foo = 1;\n" - "}\n"); - - Run("protocol_compiler --descriptor_set_out=$tmpdir/descriptor_set " - "--include_imports --proto_path=$tmpdir bar.proto"); - - ExpectNoErrors(); - - FileDescriptorSet descriptor_set; - ReadDescriptorSet("descriptor_set", &descriptor_set); - if (HasFatalFailure()) return; - ASSERT_EQ(2, descriptor_set.file_size()); - if (descriptor_set.file(0).name() == "bar.proto") { - std::swap(descriptor_set.mutable_file()->mutable_data()[0], - descriptor_set.mutable_file()->mutable_data()[1]); - } - EXPECT_EQ("foo.proto", descriptor_set.file(0).name()); - EXPECT_EQ("bar.proto", descriptor_set.file(1).name()); - // Descriptor set should not have source code info. - EXPECT_FALSE(descriptor_set.file(0).has_source_code_info()); - EXPECT_FALSE(descriptor_set.file(1).has_source_code_info()); -} - -TEST_F(CommandLineInterfaceTest, WriteTransitiveDescriptorSetWithSourceInfo) { - CreateTempFile("foo.proto", - "syntax = \"proto2\";\n" - "message Foo {}\n"); - CreateTempFile("bar.proto", - "syntax = \"proto2\";\n" - "import \"foo.proto\";\n" - "message Bar {\n" - " optional Foo foo = 1;\n" - "}\n"); - - Run("protocol_compiler --descriptor_set_out=$tmpdir/descriptor_set " - "--include_imports --include_source_info --proto_path=$tmpdir bar.proto"); - - ExpectNoErrors(); - - FileDescriptorSet descriptor_set; - ReadDescriptorSet("descriptor_set", &descriptor_set); - if (HasFatalFailure()) return; - ASSERT_EQ(2, descriptor_set.file_size()); - if (descriptor_set.file(0).name() == "bar.proto") { - std::swap(descriptor_set.mutable_file()->mutable_data()[0], - descriptor_set.mutable_file()->mutable_data()[1]); - } - EXPECT_EQ("foo.proto", descriptor_set.file(0).name()); - EXPECT_EQ("bar.proto", descriptor_set.file(1).name()); - // Source code info included. - EXPECT_TRUE(descriptor_set.file(0).has_source_code_info()); - EXPECT_TRUE(descriptor_set.file(1).has_source_code_info()); -} - -// ------------------------------------------------------------------- - -TEST_F(CommandLineInterfaceTest, ParseErrors) { - // Test that parse errors are reported. - - CreateTempFile("foo.proto", - "syntax = \"proto2\";\n" - "badsyntax\n"); - - Run("protocol_compiler --test_out=$tmpdir " - "--proto_path=$tmpdir foo.proto"); - - ExpectErrorText( - "foo.proto:2:1: Expected top-level statement (e.g. \"message\").\n"); -} - -TEST_F(CommandLineInterfaceTest, ParseErrorsMultipleFiles) { - // Test that parse errors are reported from multiple files. - - // We set up files such that foo.proto actually depends on bar.proto in - // two ways: Directly and through baz.proto. bar.proto's errors should - // only be reported once. - CreateTempFile("bar.proto", - "syntax = \"proto2\";\n" - "badsyntax\n"); - CreateTempFile("baz.proto", - "syntax = \"proto2\";\n" - "import \"bar.proto\";\n"); - CreateTempFile("foo.proto", - "syntax = \"proto2\";\n" - "import \"bar.proto\";\n" - "import \"baz.proto\";\n"); - - Run("protocol_compiler --test_out=$tmpdir " - "--proto_path=$tmpdir foo.proto"); - - ExpectErrorText( - "bar.proto:2:1: Expected top-level statement (e.g. \"message\").\n" - "baz.proto: Import \"bar.proto\" was not found or had errors.\n" - "foo.proto: Import \"bar.proto\" was not found or had errors.\n" - "foo.proto: Import \"baz.proto\" was not found or had errors.\n"); -} - -TEST_F(CommandLineInterfaceTest, InputNotFoundError) { - // Test what happens if the input file is not found. - - Run("protocol_compiler --test_out=$tmpdir " - "--proto_path=$tmpdir foo.proto"); - - ExpectErrorText( - "foo.proto: File not found.\n"); -} - -TEST_F(CommandLineInterfaceTest, CwdRelativeInputNotFoundError) { - // Test what happens when a working-directory-relative input file is not - // found. - - SetInputsAreProtoPathRelative(false); - - Run("protocol_compiler --test_out=$tmpdir " - "--proto_path=$tmpdir $tmpdir/foo.proto"); - - ExpectErrorText( - "$tmpdir/foo.proto: No such file or directory\n"); -} - -TEST_F(CommandLineInterfaceTest, CwdRelativeInputNotMappedError) { - // Test what happens when a working-directory-relative input file is not - // mapped to a virtual path. - - SetInputsAreProtoPathRelative(false); - - CreateTempFile("foo.proto", - "syntax = \"proto2\";\n" - "message Foo {}\n"); - - // Create a directory called "bar" so that we can point --proto_path at it. - CreateTempFile("bar/dummy", ""); - - Run("protocol_compiler --test_out=$tmpdir " - "--proto_path=$tmpdir/bar $tmpdir/foo.proto"); - - ExpectErrorText( - "$tmpdir/foo.proto: File does not reside within any path " - "specified using --proto_path (or -I). You must specify a " - "--proto_path which encompasses this file. Note that the " - "proto_path must be an exact prefix of the .proto file " - "names -- protoc is too dumb to figure out when two paths " - "(e.g. absolute and relative) are equivalent (it's harder " - "than you think).\n"); -} - -TEST_F(CommandLineInterfaceTest, CwdRelativeInputNotFoundAndNotMappedError) { - // Check what happens if the input file is not found *and* is not mapped - // in the proto_path. - - SetInputsAreProtoPathRelative(false); - - // Create a directory called "bar" so that we can point --proto_path at it. - CreateTempFile("bar/dummy", ""); - - Run("protocol_compiler --test_out=$tmpdir " - "--proto_path=$tmpdir/bar $tmpdir/foo.proto"); - - ExpectErrorText( - "$tmpdir/foo.proto: No such file or directory\n"); -} - -TEST_F(CommandLineInterfaceTest, CwdRelativeInputShadowedError) { - // Test what happens when a working-directory-relative input file is shadowed - // by another file in the virtual path. - - SetInputsAreProtoPathRelative(false); - - CreateTempFile("foo/foo.proto", - "syntax = \"proto2\";\n" - "message Foo {}\n"); - CreateTempFile("bar/foo.proto", - "syntax = \"proto2\";\n" - "message Bar {}\n"); - - Run("protocol_compiler --test_out=$tmpdir " - "--proto_path=$tmpdir/foo --proto_path=$tmpdir/bar " - "$tmpdir/bar/foo.proto"); - - ExpectErrorText( - "$tmpdir/bar/foo.proto: Input is shadowed in the --proto_path " - "by \"$tmpdir/foo/foo.proto\". Either use the latter " - "file as your input or reorder the --proto_path so that the " - "former file's location comes first.\n"); -} - -TEST_F(CommandLineInterfaceTest, ProtoPathNotFoundError) { - // Test what happens if the input file is not found. - - Run("protocol_compiler --test_out=$tmpdir " - "--proto_path=$tmpdir/foo foo.proto"); - - ExpectErrorText( - "$tmpdir/foo: warning: directory does not exist.\n" - "foo.proto: File not found.\n"); -} - -TEST_F(CommandLineInterfaceTest, MissingInputError) { - // Test that we get an error if no inputs are given. - - Run("protocol_compiler --test_out=$tmpdir " - "--proto_path=$tmpdir"); - - ExpectErrorText("Missing input file.\n"); -} - -TEST_F(CommandLineInterfaceTest, MissingOutputError) { - CreateTempFile("foo.proto", - "syntax = \"proto2\";\n" - "message Foo {}\n"); - - Run("protocol_compiler --proto_path=$tmpdir foo.proto"); - - ExpectErrorText("Missing output directives.\n"); -} - -TEST_F(CommandLineInterfaceTest, OutputWriteError) { - CreateTempFile("foo.proto", - "syntax = \"proto2\";\n" - "message Foo {}\n"); - - string output_file = - MockCodeGenerator::GetOutputFileName("test_generator", "foo.proto"); - - // Create a directory blocking our output location. - CreateTempDir(output_file); - - Run("protocol_compiler --test_out=$tmpdir " - "--proto_path=$tmpdir foo.proto"); - - // MockCodeGenerator no longer detects an error because we actually write to - // an in-memory location first, then dump to disk at the end. This is no - // big deal. - // ExpectErrorSubstring("MockCodeGenerator detected write error."); - -#if defined(_WIN32) && !defined(__CYGWIN__) - // Windows with MSVCRT.dll produces EPERM instead of EISDIR. - if (HasAlternateErrorSubstring(output_file + ": Permission denied")) { - return; - } -#endif - - ExpectErrorSubstring(output_file + ": Is a directory"); -} - -TEST_F(CommandLineInterfaceTest, PluginOutputWriteError) { - CreateTempFile("foo.proto", - "syntax = \"proto2\";\n" - "message Foo {}\n"); - - string output_file = - MockCodeGenerator::GetOutputFileName("test_plugin", "foo.proto"); - - // Create a directory blocking our output location. - CreateTempDir(output_file); - - Run("protocol_compiler --plug_out=$tmpdir " - "--proto_path=$tmpdir foo.proto"); - -#if defined(_WIN32) && !defined(__CYGWIN__) - // Windows with MSVCRT.dll produces EPERM instead of EISDIR. - if (HasAlternateErrorSubstring(output_file + ": Permission denied")) { - return; - } -#endif - - ExpectErrorSubstring(output_file + ": Is a directory"); -} - -TEST_F(CommandLineInterfaceTest, OutputDirectoryNotFoundError) { - CreateTempFile("foo.proto", - "syntax = \"proto2\";\n" - "message Foo {}\n"); - - Run("protocol_compiler --test_out=$tmpdir/nosuchdir " - "--proto_path=$tmpdir foo.proto"); - - ExpectErrorSubstring("nosuchdir/: No such file or directory"); -} - -TEST_F(CommandLineInterfaceTest, PluginOutputDirectoryNotFoundError) { - CreateTempFile("foo.proto", - "syntax = \"proto2\";\n" - "message Foo {}\n"); - - Run("protocol_compiler --plug_out=$tmpdir/nosuchdir " - "--proto_path=$tmpdir foo.proto"); - - ExpectErrorSubstring("nosuchdir/: No such file or directory"); -} - -TEST_F(CommandLineInterfaceTest, OutputDirectoryIsFileError) { - CreateTempFile("foo.proto", - "syntax = \"proto2\";\n" - "message Foo {}\n"); - - Run("protocol_compiler --test_out=$tmpdir/foo.proto " - "--proto_path=$tmpdir foo.proto"); - -#if defined(_WIN32) && !defined(__CYGWIN__) - // Windows with MSVCRT.dll produces EINVAL instead of ENOTDIR. - if (HasAlternateErrorSubstring("foo.proto/: Invalid argument")) { - return; - } -#endif - - ExpectErrorSubstring("foo.proto/: Not a directory"); -} - -TEST_F(CommandLineInterfaceTest, GeneratorError) { - CreateTempFile("foo.proto", - "syntax = \"proto2\";\n" - "message MockCodeGenerator_Error {}\n"); - - Run("protocol_compiler --test_out=$tmpdir " - "--proto_path=$tmpdir foo.proto"); - - ExpectErrorSubstring( - "--test_out: foo.proto: Saw message type MockCodeGenerator_Error."); -} - -TEST_F(CommandLineInterfaceTest, GeneratorPluginError) { - // Test a generator plugin that returns an error. - - CreateTempFile("foo.proto", - "syntax = \"proto2\";\n" - "message MockCodeGenerator_Error {}\n"); - - Run("protocol_compiler --plug_out=TestParameter:$tmpdir " - "--proto_path=$tmpdir foo.proto"); - - ExpectErrorSubstring( - "--plug_out: foo.proto: Saw message type MockCodeGenerator_Error."); -} - -TEST_F(CommandLineInterfaceTest, GeneratorPluginFail) { - // Test a generator plugin that exits with an error code. - - CreateTempFile("foo.proto", - "syntax = \"proto2\";\n" - "message MockCodeGenerator_Exit {}\n"); - - Run("protocol_compiler --plug_out=TestParameter:$tmpdir " - "--proto_path=$tmpdir foo.proto"); - - ExpectErrorSubstring("Saw message type MockCodeGenerator_Exit."); - ExpectErrorSubstring( - "--plug_out: prefix-gen-plug: Plugin failed with status code 123."); -} - -TEST_F(CommandLineInterfaceTest, GeneratorPluginCrash) { - // Test a generator plugin that crashes. - - CreateTempFile("foo.proto", - "syntax = \"proto2\";\n" - "message MockCodeGenerator_Abort {}\n"); - - Run("protocol_compiler --plug_out=TestParameter:$tmpdir " - "--proto_path=$tmpdir foo.proto"); - - ExpectErrorSubstring("Saw message type MockCodeGenerator_Abort."); - -#ifdef _WIN32 - // Windows doesn't have signals. It looks like abort()ing causes the process - // to exit with status code 3, but let's not depend on the exact number here. - ExpectErrorSubstring( - "--plug_out: prefix-gen-plug: Plugin failed with status code"); -#else - // Don't depend on the exact signal number. - ExpectErrorSubstring( - "--plug_out: prefix-gen-plug: Plugin killed by signal"); -#endif -} - -TEST_F(CommandLineInterfaceTest, PluginReceivesSourceCodeInfo) { - CreateTempFile("foo.proto", - "syntax = \"proto2\";\n" - "message MockCodeGenerator_HasSourceCodeInfo {}\n"); - - Run("protocol_compiler --plug_out=$tmpdir --proto_path=$tmpdir foo.proto"); - - ExpectErrorSubstring( - "Saw message type MockCodeGenerator_HasSourceCodeInfo: 1."); -} - -TEST_F(CommandLineInterfaceTest, GeneratorPluginNotFound) { - // Test what happens if the plugin isn't found. - - CreateTempFile("error.proto", - "syntax = \"proto2\";\n" - "message Foo {}\n"); - - Run("protocol_compiler --badplug_out=TestParameter:$tmpdir " - "--plugin=prefix-gen-badplug=no_such_file " - "--proto_path=$tmpdir error.proto"); - -#ifdef _WIN32 - ExpectErrorSubstring("--badplug_out: prefix-gen-badplug: " + - Subprocess::Win32ErrorMessage(ERROR_FILE_NOT_FOUND)); -#else - // Error written to stdout by child process after exec() fails. - ExpectErrorSubstring( - "no_such_file: program not found or is not executable"); - - // Error written by parent process when child fails. - ExpectErrorSubstring( - "--badplug_out: prefix-gen-badplug: Plugin failed with status code 1."); -#endif -} - -TEST_F(CommandLineInterfaceTest, GeneratorPluginNotAllowed) { - // Test what happens if plugins aren't allowed. - - CreateTempFile("error.proto", - "syntax = \"proto2\";\n" - "message Foo {}\n"); - - DisallowPlugins(); - Run("protocol_compiler --plug_out=TestParameter:$tmpdir " - "--proto_path=$tmpdir error.proto"); - - ExpectErrorSubstring("Unknown flag: --plug_out"); -} - -TEST_F(CommandLineInterfaceTest, HelpText) { - Run("test_exec_name --help"); - - ExpectErrorSubstringWithZeroReturnCode("Usage: test_exec_name "); - ExpectErrorSubstringWithZeroReturnCode("--test_out=OUT_DIR"); - ExpectErrorSubstringWithZeroReturnCode("Test output."); - ExpectErrorSubstringWithZeroReturnCode("--alt_out=OUT_DIR"); - ExpectErrorSubstringWithZeroReturnCode("Alt output."); -} - -TEST_F(CommandLineInterfaceTest, GccFormatErrors) { - // Test --error_format=gcc (which is the default, but we want to verify - // that it can be set explicitly). - - CreateTempFile("foo.proto", - "syntax = \"proto2\";\n" - "badsyntax\n"); - - Run("protocol_compiler --test_out=$tmpdir " - "--proto_path=$tmpdir --error_format=gcc foo.proto"); - - ExpectErrorText( - "foo.proto:2:1: Expected top-level statement (e.g. \"message\").\n"); -} - -TEST_F(CommandLineInterfaceTest, MsvsFormatErrors) { - // Test --error_format=msvs - - CreateTempFile("foo.proto", - "syntax = \"proto2\";\n" - "badsyntax\n"); - - Run("protocol_compiler --test_out=$tmpdir " - "--proto_path=$tmpdir --error_format=msvs foo.proto"); - - ExpectErrorText( - "$tmpdir/foo.proto(2) : error in column=1: Expected top-level statement " - "(e.g. \"message\").\n"); -} - -TEST_F(CommandLineInterfaceTest, InvalidErrorFormat) { - // Test --error_format=msvs - - CreateTempFile("foo.proto", - "syntax = \"proto2\";\n" - "badsyntax\n"); - - Run("protocol_compiler --test_out=$tmpdir " - "--proto_path=$tmpdir --error_format=invalid foo.proto"); - - ExpectErrorText( - "Unknown error format: invalid\n"); -} - -// ------------------------------------------------------------------- -// Flag parsing tests - -TEST_F(CommandLineInterfaceTest, ParseSingleCharacterFlag) { - // Test that a single-character flag works. - - CreateTempFile("foo.proto", - "syntax = \"proto2\";\n" - "message Foo {}\n"); - - Run("protocol_compiler -t$tmpdir " - "--proto_path=$tmpdir foo.proto"); - - ExpectNoErrors(); - ExpectGenerated("test_generator", "", "foo.proto", "Foo"); -} - -TEST_F(CommandLineInterfaceTest, ParseSpaceDelimitedValue) { - // Test that separating the flag value with a space works. - - CreateTempFile("foo.proto", - "syntax = \"proto2\";\n" - "message Foo {}\n"); - - Run("protocol_compiler --test_out $tmpdir " - "--proto_path=$tmpdir foo.proto"); - - ExpectNoErrors(); - ExpectGenerated("test_generator", "", "foo.proto", "Foo"); -} - -TEST_F(CommandLineInterfaceTest, ParseSingleCharacterSpaceDelimitedValue) { - // Test that separating the flag value with a space works for - // single-character flags. - - CreateTempFile("foo.proto", - "syntax = \"proto2\";\n" - "message Foo {}\n"); - - Run("protocol_compiler -t $tmpdir " - "--proto_path=$tmpdir foo.proto"); - - ExpectNoErrors(); - ExpectGenerated("test_generator", "", "foo.proto", "Foo"); -} - -TEST_F(CommandLineInterfaceTest, MissingValueError) { - // Test that we get an error if a flag is missing its value. - - Run("protocol_compiler --test_out --proto_path=$tmpdir foo.proto"); - - ExpectErrorText("Missing value for flag: --test_out\n"); -} - -TEST_F(CommandLineInterfaceTest, MissingValueAtEndError) { - // Test that we get an error if the last argument is a flag requiring a - // value. - - Run("protocol_compiler --test_out"); - - ExpectErrorText("Missing value for flag: --test_out\n"); -} - -// =================================================================== - -// Test for --encode and --decode. Note that it would be easier to do this -// test as a shell script, but we'd like to be able to run the test on -// platforms that don't have a Bourne-compatible shell available (especially -// Windows/MSVC). -class EncodeDecodeTest : public testing::Test { - protected: - virtual void SetUp() { - duped_stdin_ = dup(STDIN_FILENO); - } - - virtual void TearDown() { - dup2(duped_stdin_, STDIN_FILENO); - close(duped_stdin_); - } - - void RedirectStdinFromText(const string& input) { - string filename = TestTempDir() + "/test_stdin"; - File::WriteStringToFileOrDie(input, filename); - GOOGLE_CHECK(RedirectStdinFromFile(filename)); - } - - bool RedirectStdinFromFile(const string& filename) { - int fd = open(filename.c_str(), O_RDONLY); - if (fd < 0) return false; - dup2(fd, STDIN_FILENO); - close(fd); - return true; - } - - // Remove '\r' characters from text. - string StripCR(const string& text) { - string result; - - for (int i = 0; i < text.size(); i++) { - if (text[i] != '\r') { - result.push_back(text[i]); - } - } - - return result; - } - - enum Type { TEXT, BINARY }; - enum ReturnCode { SUCCESS, ERROR }; - - bool Run(const string& command) { - vector args; - args.push_back("protoc"); - SplitStringUsing(command, " ", &args); - args.push_back("--proto_path=" + TestSourceDir()); - - scoped_array argv(new const char*[args.size()]); - for (int i = 0; i < args.size(); i++) { - argv[i] = args[i].c_str(); - } - - CommandLineInterface cli; - cli.SetInputsAreProtoPathRelative(true); - - CaptureTestStdout(); - CaptureTestStderr(); - - int result = cli.Run(args.size(), argv.get()); - - captured_stdout_ = GetCapturedTestStdout(); - captured_stderr_ = GetCapturedTestStderr(); - - return result == 0; - } - - void ExpectStdoutMatchesBinaryFile(const string& filename) { - string expected_output; - ASSERT_TRUE(File::ReadFileToString(filename, &expected_output)); - - // Don't use EXPECT_EQ because we don't want to print raw binary data to - // stdout on failure. - EXPECT_TRUE(captured_stdout_ == expected_output); - } - - void ExpectStdoutMatchesTextFile(const string& filename) { - string expected_output; - ASSERT_TRUE(File::ReadFileToString(filename, &expected_output)); - - ExpectStdoutMatchesText(expected_output); - } - - void ExpectStdoutMatchesText(const string& expected_text) { - EXPECT_EQ(StripCR(expected_text), StripCR(captured_stdout_)); - } - - void ExpectStderrMatchesText(const string& expected_text) { - EXPECT_EQ(StripCR(expected_text), StripCR(captured_stderr_)); - } - - private: - int duped_stdin_; - string captured_stdout_; - string captured_stderr_; -}; - -TEST_F(EncodeDecodeTest, Encode) { - RedirectStdinFromFile(TestSourceDir() + - "/google/protobuf/testdata/text_format_unittest_data.txt"); - EXPECT_TRUE(Run("google/protobuf/unittest.proto " - "--encode=protobuf_unittest.TestAllTypes")); - ExpectStdoutMatchesBinaryFile(TestSourceDir() + - "/google/protobuf/testdata/golden_message"); - ExpectStderrMatchesText(""); -} - -TEST_F(EncodeDecodeTest, Decode) { - RedirectStdinFromFile(TestSourceDir() + - "/google/protobuf/testdata/golden_message"); - EXPECT_TRUE(Run("google/protobuf/unittest.proto " - "--decode=protobuf_unittest.TestAllTypes")); - ExpectStdoutMatchesTextFile(TestSourceDir() + - "/google/protobuf/testdata/text_format_unittest_data.txt"); - ExpectStderrMatchesText(""); -} - -TEST_F(EncodeDecodeTest, Partial) { - RedirectStdinFromText(""); - EXPECT_TRUE(Run("google/protobuf/unittest.proto " - "--encode=protobuf_unittest.TestRequired")); - ExpectStdoutMatchesText(""); - ExpectStderrMatchesText( - "warning: Input message is missing required fields: a, b, c\n"); -} - -TEST_F(EncodeDecodeTest, DecodeRaw) { - protobuf_unittest::TestAllTypes message; - message.set_optional_int32(123); - message.set_optional_string("foo"); - string data; - message.SerializeToString(&data); - - RedirectStdinFromText(data); - EXPECT_TRUE(Run("--decode_raw")); - ExpectStdoutMatchesText("1: 123\n" - "14: \"foo\"\n"); - ExpectStderrMatchesText(""); -} - -TEST_F(EncodeDecodeTest, UnknownType) { - EXPECT_FALSE(Run("google/protobuf/unittest.proto " - "--encode=NoSuchType")); - ExpectStdoutMatchesText(""); - ExpectStderrMatchesText("Type not defined: NoSuchType\n"); -} - -TEST_F(EncodeDecodeTest, ProtoParseError) { - EXPECT_FALSE(Run("google/protobuf/no_such_file.proto " - "--encode=NoSuchType")); - ExpectStdoutMatchesText(""); - ExpectStderrMatchesText( - "google/protobuf/no_such_file.proto: File not found.\n"); -} - -} // anonymous namespace - -} // namespace compiler -} // namespace protobuf -} // namespace google diff --git a/modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/cpp/cpp_bootstrap_unittest.cc b/modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/cpp/cpp_bootstrap_unittest.cc deleted file mode 100644 index b7c1766bf..000000000 --- a/modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/cpp/cpp_bootstrap_unittest.cc +++ /dev/null @@ -1,158 +0,0 @@ -// Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// http://code.google.com/p/protobuf/ -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -// Author: kenton@google.com (Kenton Varda) -// Based on original Protocol Buffers design by -// Sanjay Ghemawat, Jeff Dean, and others. -// -// This test insures that google/protobuf/descriptor.pb.{h,cc} match exactly -// what would be generated by the protocol compiler. These files are not -// generated automatically at build time because they are compiled into the -// protocol compiler itself. So, if they were auto-generated, you'd have a -// chicken-and-egg problem. -// -// If this test fails, run the script -// "generate_descriptor_proto.sh" and add -// descriptor.pb.{h,cc} to your changelist. - -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -namespace google { -namespace protobuf { -namespace compiler { -namespace cpp { - -namespace { - -class MockErrorCollector : public MultiFileErrorCollector { - public: - MockErrorCollector() {} - ~MockErrorCollector() {} - - string text_; - - // implements ErrorCollector --------------------------------------- - void AddError(const string& filename, int line, int column, - const string& message) { - strings::SubstituteAndAppend(&text_, "$0:$1:$2: $3\n", - filename, line, column, message); - } -}; - -class MockGeneratorContext : public GeneratorContext { - public: - MockGeneratorContext() {} - ~MockGeneratorContext() { - STLDeleteValues(&files_); - } - - void ExpectFileMatches(const string& virtual_filename, - const string& physical_filename) { - string* expected_contents = FindPtrOrNull(files_, virtual_filename); - ASSERT_TRUE(expected_contents != NULL) - << "Generator failed to generate file: " << virtual_filename; - - string actual_contents; - File::ReadFileToStringOrDie( - TestSourceDir() + "/" + physical_filename, - &actual_contents); - EXPECT_TRUE(actual_contents == *expected_contents) - << physical_filename << " needs to be regenerated. Please run " - "generate_descriptor_proto.sh and add this file " - "to your CL."; - } - - // implements GeneratorContext -------------------------------------- - - virtual io::ZeroCopyOutputStream* Open(const string& filename) { - string** map_slot = &files_[filename]; - if (*map_slot != NULL) delete *map_slot; - *map_slot = new string; - - return new io::StringOutputStream(*map_slot); - } - - private: - map files_; -}; - -TEST(BootstrapTest, GeneratedDescriptorMatches) { - MockErrorCollector error_collector; - DiskSourceTree source_tree; - source_tree.MapPath("", TestSourceDir()); - Importer importer(&source_tree, &error_collector); - const FileDescriptor* proto_file = - importer.Import("google/protobuf/descriptor.proto"); - const FileDescriptor* plugin_proto_file = - importer.Import("google/protobuf/compiler/plugin.proto"); - EXPECT_EQ("", error_collector.text_); - ASSERT_TRUE(proto_file != NULL); - ASSERT_TRUE(plugin_proto_file != NULL); - - CppGenerator generator; - MockGeneratorContext context; - string error; - string parameter; - parameter = "dllexport_decl=LIBPROTOBUF_EXPORT"; - ASSERT_TRUE(generator.Generate(proto_file, parameter, - &context, &error)); - parameter = "dllexport_decl=LIBPROTOC_EXPORT"; - ASSERT_TRUE(generator.Generate(plugin_proto_file, parameter, - &context, &error)); - - context.ExpectFileMatches("google/protobuf/descriptor.pb.h", - "google/protobuf/descriptor.pb.h"); - context.ExpectFileMatches("google/protobuf/descriptor.pb.cc", - "google/protobuf/descriptor.pb.cc"); - context.ExpectFileMatches("google/protobuf/compiler/plugin.pb.h", - "google/protobuf/compiler/plugin.pb.h"); - context.ExpectFileMatches("google/protobuf/compiler/plugin.pb.cc", - "google/protobuf/compiler/plugin.pb.cc"); -} - -} // namespace - -} // namespace cpp -} // namespace compiler -} // namespace protobuf -} // namespace google diff --git a/modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/cpp/cpp_enum.cc b/modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/cpp/cpp_enum.cc deleted file mode 100644 index 67c12d7ab..000000000 --- a/modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/cpp/cpp_enum.cc +++ /dev/null @@ -1,258 +0,0 @@ -// Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// http://code.google.com/p/protobuf/ -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -// Author: kenton@google.com (Kenton Varda) -// Based on original Protocol Buffers design by -// Sanjay Ghemawat, Jeff Dean, and others. - -#include -#include - -#include -#include -#include -#include - -namespace google { -namespace protobuf { -namespace compiler { -namespace cpp { - -EnumGenerator::EnumGenerator(const EnumDescriptor* descriptor, - const Options& options) - : descriptor_(descriptor), - classname_(ClassName(descriptor, false)), - options_(options) { -} - -EnumGenerator::~EnumGenerator() {} - -void EnumGenerator::GenerateDefinition(io::Printer* printer) { - map vars; - vars["classname"] = classname_; - vars["short_name"] = descriptor_->name(); - - printer->Print(vars, "enum $classname$ {\n"); - printer->Indent(); - - const EnumValueDescriptor* min_value = descriptor_->value(0); - const EnumValueDescriptor* max_value = descriptor_->value(0); - - for (int i = 0; i < descriptor_->value_count(); i++) { - vars["name"] = descriptor_->value(i)->name(); - vars["number"] = SimpleItoa(descriptor_->value(i)->number()); - vars["prefix"] = (descriptor_->containing_type() == NULL) ? - "" : classname_ + "_"; - - if (i > 0) printer->Print(",\n"); - printer->Print(vars, "$prefix$$name$ = $number$"); - - if (descriptor_->value(i)->number() < min_value->number()) { - min_value = descriptor_->value(i); - } - if (descriptor_->value(i)->number() > max_value->number()) { - max_value = descriptor_->value(i); - } - } - - printer->Outdent(); - printer->Print("\n};\n"); - - vars["min_name"] = min_value->name(); - vars["max_name"] = max_value->name(); - - if (options_.dllexport_decl.empty()) { - vars["dllexport"] = ""; - } else { - vars["dllexport"] = options_.dllexport_decl + " "; - } - - printer->Print(vars, - "$dllexport$bool $classname$_IsValid(int value);\n" - "const $classname$ $prefix$$short_name$_MIN = $prefix$$min_name$;\n" - "const $classname$ $prefix$$short_name$_MAX = $prefix$$max_name$;\n" - "const int $prefix$$short_name$_ARRAYSIZE = $prefix$$short_name$_MAX + 1;\n" - "\n"); - - if (HasDescriptorMethods(descriptor_->file())) { - printer->Print(vars, - "$dllexport$const ::google::protobuf::EnumDescriptor* $classname$_descriptor();\n"); - // The _Name and _Parse methods - printer->Print(vars, - "inline const ::std::string& $classname$_Name($classname$ value) {\n" - " return ::google::protobuf::internal::NameOfEnum(\n" - " $classname$_descriptor(), value);\n" - "}\n"); - printer->Print(vars, - "inline bool $classname$_Parse(\n" - " const ::std::string& name, $classname$* value) {\n" - " return ::google::protobuf::internal::ParseNamedEnum<$classname$>(\n" - " $classname$_descriptor(), name, value);\n" - "}\n"); - } -} - -void EnumGenerator:: -GenerateGetEnumDescriptorSpecializations(io::Printer* printer) { - if (HasDescriptorMethods(descriptor_->file())) { - printer->Print( - "template <>\n" - "inline const EnumDescriptor* GetEnumDescriptor< $classname$>() {\n" - " return $classname$_descriptor();\n" - "}\n", - "classname", ClassName(descriptor_, true)); - } -} - -void EnumGenerator::GenerateSymbolImports(io::Printer* printer) { - map vars; - vars["nested_name"] = descriptor_->name(); - vars["classname"] = classname_; - printer->Print(vars, "typedef $classname$ $nested_name$;\n"); - - for (int j = 0; j < descriptor_->value_count(); j++) { - vars["tag"] = descriptor_->value(j)->name(); - printer->Print(vars, - "static const $nested_name$ $tag$ = $classname$_$tag$;\n"); - } - - printer->Print(vars, - "static inline bool $nested_name$_IsValid(int value) {\n" - " return $classname$_IsValid(value);\n" - "}\n" - "static const $nested_name$ $nested_name$_MIN =\n" - " $classname$_$nested_name$_MIN;\n" - "static const $nested_name$ $nested_name$_MAX =\n" - " $classname$_$nested_name$_MAX;\n" - "static const int $nested_name$_ARRAYSIZE =\n" - " $classname$_$nested_name$_ARRAYSIZE;\n"); - - if (HasDescriptorMethods(descriptor_->file())) { - printer->Print(vars, - "static inline const ::google::protobuf::EnumDescriptor*\n" - "$nested_name$_descriptor() {\n" - " return $classname$_descriptor();\n" - "}\n"); - printer->Print(vars, - "static inline const ::std::string& $nested_name$_Name($nested_name$ value) {\n" - " return $classname$_Name(value);\n" - "}\n"); - printer->Print(vars, - "static inline bool $nested_name$_Parse(const ::std::string& name,\n" - " $nested_name$* value) {\n" - " return $classname$_Parse(name, value);\n" - "}\n"); - } -} - -void EnumGenerator::GenerateDescriptorInitializer( - io::Printer* printer, int index) { - map vars; - vars["classname"] = classname_; - vars["index"] = SimpleItoa(index); - - if (descriptor_->containing_type() == NULL) { - printer->Print(vars, - "$classname$_descriptor_ = file->enum_type($index$);\n"); - } else { - vars["parent"] = ClassName(descriptor_->containing_type(), false); - printer->Print(vars, - "$classname$_descriptor_ = $parent$_descriptor_->enum_type($index$);\n"); - } -} - -void EnumGenerator::GenerateMethods(io::Printer* printer) { - map vars; - vars["classname"] = classname_; - - if (HasDescriptorMethods(descriptor_->file())) { - printer->Print(vars, - "const ::google::protobuf::EnumDescriptor* $classname$_descriptor() {\n" - " protobuf_AssignDescriptorsOnce();\n" - " return $classname$_descriptor_;\n" - "}\n"); - } - - printer->Print(vars, - "bool $classname$_IsValid(int value) {\n" - " switch(value) {\n"); - - // Multiple values may have the same number. Make sure we only cover - // each number once by first constructing a set containing all valid - // numbers, then printing a case statement for each element. - - set numbers; - for (int j = 0; j < descriptor_->value_count(); j++) { - const EnumValueDescriptor* value = descriptor_->value(j); - numbers.insert(value->number()); - } - - for (set::iterator iter = numbers.begin(); - iter != numbers.end(); ++iter) { - printer->Print( - " case $number$:\n", - "number", SimpleItoa(*iter)); - } - - printer->Print(vars, - " return true;\n" - " default:\n" - " return false;\n" - " }\n" - "}\n" - "\n"); - - if (descriptor_->containing_type() != NULL) { - // We need to "define" the static constants which were declared in the - // header, to give the linker a place to put them. Or at least the C++ - // standard says we have to. MSVC actually insists tha we do _not_ define - // them again in the .cc file. - printer->Print("#ifndef _MSC_VER\n"); - - vars["parent"] = ClassName(descriptor_->containing_type(), false); - vars["nested_name"] = descriptor_->name(); - for (int i = 0; i < descriptor_->value_count(); i++) { - vars["value"] = descriptor_->value(i)->name(); - printer->Print(vars, - "const $classname$ $parent$::$value$;\n"); - } - printer->Print(vars, - "const $classname$ $parent$::$nested_name$_MIN;\n" - "const $classname$ $parent$::$nested_name$_MAX;\n" - "const int $parent$::$nested_name$_ARRAYSIZE;\n"); - - printer->Print("#endif // _MSC_VER\n"); - } -} - -} // namespace cpp -} // namespace compiler -} // namespace protobuf -} // namespace google diff --git a/modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/cpp/cpp_enum.h b/modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/cpp/cpp_enum.h deleted file mode 100644 index 2e85a0bd3..000000000 --- a/modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/cpp/cpp_enum.h +++ /dev/null @@ -1,101 +0,0 @@ -// Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// http://code.google.com/p/protobuf/ -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -// Author: kenton@google.com (Kenton Varda) -// Based on original Protocol Buffers design by -// Sanjay Ghemawat, Jeff Dean, and others. - -#ifndef GOOGLE_PROTOBUF_COMPILER_CPP_ENUM_H__ -#define GOOGLE_PROTOBUF_COMPILER_CPP_ENUM_H__ - -#include -#include -#include - - -namespace google { -namespace protobuf { - namespace io { - class Printer; // printer.h - } -} - -namespace protobuf { -namespace compiler { -namespace cpp { - -class EnumGenerator { - public: - // See generator.cc for the meaning of dllexport_decl. - explicit EnumGenerator(const EnumDescriptor* descriptor, - const Options& options); - ~EnumGenerator(); - - // Header stuff. - - // Generate header code defining the enum. This code should be placed - // within the enum's package namespace, but NOT within any class, even for - // nested enums. - void GenerateDefinition(io::Printer* printer); - - // Generate specialization of GetEnumDescriptor(). - // Precondition: in ::google::protobuf namespace. - void GenerateGetEnumDescriptorSpecializations(io::Printer* printer); - - // For enums nested within a message, generate code to import all the enum's - // symbols (e.g. the enum type name, all its values, etc.) into the class's - // namespace. This should be placed inside the class definition in the - // header. - void GenerateSymbolImports(io::Printer* printer); - - // Source file stuff. - - // Generate code that initializes the global variable storing the enum's - // descriptor. - void GenerateDescriptorInitializer(io::Printer* printer, int index); - - // Generate non-inline methods related to the enum, such as IsValidValue(). - // Goes in the .cc file. - void GenerateMethods(io::Printer* printer); - - private: - const EnumDescriptor* descriptor_; - string classname_; - Options options_; - - GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(EnumGenerator); -}; - -} // namespace cpp -} // namespace compiler -} // namespace protobuf - -} // namespace google -#endif // GOOGLE_PROTOBUF_COMPILER_CPP_ENUM_H__ diff --git a/modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/cpp/cpp_enum_field.cc b/modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/cpp/cpp_enum_field.cc deleted file mode 100644 index 6e1620d4d..000000000 --- a/modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/cpp/cpp_enum_field.cc +++ /dev/null @@ -1,366 +0,0 @@ -// Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// http://code.google.com/p/protobuf/ -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -// Author: kenton@google.com (Kenton Varda) -// Based on original Protocol Buffers design by -// Sanjay Ghemawat, Jeff Dean, and others. - -#include -#include -#include -#include -#include - -namespace google { -namespace protobuf { -namespace compiler { -namespace cpp { - -namespace { - -void SetEnumVariables(const FieldDescriptor* descriptor, - map* variables, - const Options& options) { - SetCommonFieldVariables(descriptor, variables, options); - const EnumValueDescriptor* default_value = descriptor->default_value_enum(); - (*variables)["type"] = ClassName(descriptor->enum_type(), true); - (*variables)["default"] = SimpleItoa(default_value->number()); -} - -} // namespace - -// =================================================================== - -EnumFieldGenerator:: -EnumFieldGenerator(const FieldDescriptor* descriptor, - const Options& options) - : descriptor_(descriptor) { - SetEnumVariables(descriptor, &variables_, options); -} - -EnumFieldGenerator::~EnumFieldGenerator() {} - -void EnumFieldGenerator:: -GeneratePrivateMembers(io::Printer* printer) const { - printer->Print(variables_, "int $name$_;\n"); -} - -void EnumFieldGenerator:: -GenerateAccessorDeclarations(io::Printer* printer) const { - printer->Print(variables_, - "inline $type$ $name$() const$deprecation$;\n" - "inline void set_$name$($type$ value)$deprecation$;\n"); -} - -void EnumFieldGenerator:: -GenerateInlineAccessorDefinitions(io::Printer* printer) const { - printer->Print(variables_, - "inline $type$ $classname$::$name$() const {\n" - " return static_cast< $type$ >($name$_);\n" - "}\n" - "inline void $classname$::set_$name$($type$ value) {\n" - " assert($type$_IsValid(value));\n" - " set_has_$name$();\n" - " $name$_ = value;\n" - "}\n"); -} - -void EnumFieldGenerator:: -GenerateClearingCode(io::Printer* printer) const { - printer->Print(variables_, "$name$_ = $default$;\n"); -} - -void EnumFieldGenerator:: -GenerateMergingCode(io::Printer* printer) const { - printer->Print(variables_, "set_$name$(from.$name$());\n"); -} - -void EnumFieldGenerator:: -GenerateSwappingCode(io::Printer* printer) const { - printer->Print(variables_, "std::swap($name$_, other->$name$_);\n"); -} - -void EnumFieldGenerator:: -GenerateConstructorCode(io::Printer* printer) const { - printer->Print(variables_, "$name$_ = $default$;\n"); -} - -void EnumFieldGenerator:: -GenerateMergeFromCodedStream(io::Printer* printer) const { - printer->Print(variables_, - "int value;\n" - "DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<\n" - " int, ::google::protobuf::internal::WireFormatLite::TYPE_ENUM>(\n" - " input, &value)));\n" - "if ($type$_IsValid(value)) {\n" - " set_$name$(static_cast< $type$ >(value));\n"); - if (HasUnknownFields(descriptor_->file())) { - printer->Print(variables_, - "} else {\n" - " mutable_unknown_fields()->AddVarint($number$, value);\n"); - } - printer->Print(variables_, - "}\n"); -} - -void EnumFieldGenerator:: -GenerateSerializeWithCachedSizes(io::Printer* printer) const { - printer->Print(variables_, - "::google::protobuf::internal::WireFormatLite::WriteEnum(\n" - " $number$, this->$name$(), output);\n"); -} - -void EnumFieldGenerator:: -GenerateSerializeWithCachedSizesToArray(io::Printer* printer) const { - printer->Print(variables_, - "target = ::google::protobuf::internal::WireFormatLite::WriteEnumToArray(\n" - " $number$, this->$name$(), target);\n"); -} - -void EnumFieldGenerator:: -GenerateByteSize(io::Printer* printer) const { - printer->Print(variables_, - "total_size += $tag_size$ +\n" - " ::google::protobuf::internal::WireFormatLite::EnumSize(this->$name$());\n"); -} - -// =================================================================== - -RepeatedEnumFieldGenerator:: -RepeatedEnumFieldGenerator(const FieldDescriptor* descriptor, - const Options& options) - : descriptor_(descriptor) { - SetEnumVariables(descriptor, &variables_, options); -} - -RepeatedEnumFieldGenerator::~RepeatedEnumFieldGenerator() {} - -void RepeatedEnumFieldGenerator:: -GeneratePrivateMembers(io::Printer* printer) const { - printer->Print(variables_, - "::google::protobuf::RepeatedField $name$_;\n"); - if (descriptor_->options().packed() && HasGeneratedMethods(descriptor_->file())) { - printer->Print(variables_, - "mutable int _$name$_cached_byte_size_;\n"); - } -} - -void RepeatedEnumFieldGenerator:: -GenerateAccessorDeclarations(io::Printer* printer) const { - printer->Print(variables_, - "inline $type$ $name$(int index) const$deprecation$;\n" - "inline void set_$name$(int index, $type$ value)$deprecation$;\n" - "inline void add_$name$($type$ value)$deprecation$;\n"); - printer->Print(variables_, - "inline const ::google::protobuf::RepeatedField& $name$() const$deprecation$;\n" - "inline ::google::protobuf::RepeatedField* mutable_$name$()$deprecation$;\n"); -} - -void RepeatedEnumFieldGenerator:: -GenerateInlineAccessorDefinitions(io::Printer* printer) const { - printer->Print(variables_, - "inline $type$ $classname$::$name$(int index) const {\n" - " return static_cast< $type$ >($name$_.Get(index));\n" - "}\n" - "inline void $classname$::set_$name$(int index, $type$ value) {\n" - " assert($type$_IsValid(value));\n" - " $name$_.Set(index, value);\n" - "}\n" - "inline void $classname$::add_$name$($type$ value) {\n" - " assert($type$_IsValid(value));\n" - " $name$_.Add(value);\n" - "}\n"); - printer->Print(variables_, - "inline const ::google::protobuf::RepeatedField&\n" - "$classname$::$name$() const {\n" - " return $name$_;\n" - "}\n" - "inline ::google::protobuf::RepeatedField*\n" - "$classname$::mutable_$name$() {\n" - " return &$name$_;\n" - "}\n"); -} - -void RepeatedEnumFieldGenerator:: -GenerateClearingCode(io::Printer* printer) const { - printer->Print(variables_, "$name$_.Clear();\n"); -} - -void RepeatedEnumFieldGenerator:: -GenerateMergingCode(io::Printer* printer) const { - printer->Print(variables_, "$name$_.MergeFrom(from.$name$_);\n"); -} - -void RepeatedEnumFieldGenerator:: -GenerateSwappingCode(io::Printer* printer) const { - printer->Print(variables_, "$name$_.Swap(&other->$name$_);\n"); -} - -void RepeatedEnumFieldGenerator:: -GenerateConstructorCode(io::Printer* printer) const { - // Not needed for repeated fields. -} - -void RepeatedEnumFieldGenerator:: -GenerateMergeFromCodedStream(io::Printer* printer) const { - // Don't use ReadRepeatedPrimitive here so that the enum can be validated. - printer->Print(variables_, - "int value;\n" - "DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<\n" - " int, ::google::protobuf::internal::WireFormatLite::TYPE_ENUM>(\n" - " input, &value)));\n" - "if ($type$_IsValid(value)) {\n" - " add_$name$(static_cast< $type$ >(value));\n"); - if (HasUnknownFields(descriptor_->file())) { - printer->Print(variables_, - "} else {\n" - " mutable_unknown_fields()->AddVarint($number$, value);\n"); - } - printer->Print("}\n"); -} - -void RepeatedEnumFieldGenerator:: -GenerateMergeFromCodedStreamWithPacking(io::Printer* printer) const { - if (!descriptor_->options().packed()) { - // We use a non-inlined implementation in this case, since this path will - // rarely be executed. - printer->Print(variables_, - "DO_((::google::protobuf::internal::WireFormatLite::ReadPackedEnumNoInline(\n" - " input,\n" - " &$type$_IsValid,\n" - " this->mutable_$name$())));\n"); - } else { - printer->Print(variables_, - "::google::protobuf::uint32 length;\n" - "DO_(input->ReadVarint32(&length));\n" - "::google::protobuf::io::CodedInputStream::Limit limit = " - "input->PushLimit(length);\n" - "while (input->BytesUntilLimit() > 0) {\n" - " int value;\n" - " DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<\n" - " int, ::google::protobuf::internal::WireFormatLite::TYPE_ENUM>(\n" - " input, &value)));\n" - " if ($type$_IsValid(value)) {\n" - " add_$name$(static_cast< $type$ >(value));\n" - " }\n" - "}\n" - "input->PopLimit(limit);\n"); - } -} - -void RepeatedEnumFieldGenerator:: -GenerateSerializeWithCachedSizes(io::Printer* printer) const { - if (descriptor_->options().packed()) { - // Write the tag and the size. - printer->Print(variables_, - "if (this->$name$_size() > 0) {\n" - " ::google::protobuf::internal::WireFormatLite::WriteTag(\n" - " $number$,\n" - " ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED,\n" - " output);\n" - " output->WriteVarint32(_$name$_cached_byte_size_);\n" - "}\n"); - } - printer->Print(variables_, - "for (int i = 0; i < this->$name$_size(); i++) {\n"); - if (descriptor_->options().packed()) { - printer->Print(variables_, - " ::google::protobuf::internal::WireFormatLite::WriteEnumNoTag(\n" - " this->$name$(i), output);\n"); - } else { - printer->Print(variables_, - " ::google::protobuf::internal::WireFormatLite::WriteEnum(\n" - " $number$, this->$name$(i), output);\n"); - } - printer->Print("}\n"); -} - -void RepeatedEnumFieldGenerator:: -GenerateSerializeWithCachedSizesToArray(io::Printer* printer) const { - if (descriptor_->options().packed()) { - // Write the tag and the size. - printer->Print(variables_, - "if (this->$name$_size() > 0) {\n" - " target = ::google::protobuf::internal::WireFormatLite::WriteTagToArray(\n" - " $number$,\n" - " ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED,\n" - " target);\n" - " target = ::google::protobuf::io::CodedOutputStream::WriteVarint32ToArray(" - " _$name$_cached_byte_size_, target);\n" - "}\n"); - } - printer->Print(variables_, - "for (int i = 0; i < this->$name$_size(); i++) {\n"); - if (descriptor_->options().packed()) { - printer->Print(variables_, - " target = ::google::protobuf::internal::WireFormatLite::WriteEnumNoTagToArray(\n" - " this->$name$(i), target);\n"); - } else { - printer->Print(variables_, - " target = ::google::protobuf::internal::WireFormatLite::WriteEnumToArray(\n" - " $number$, this->$name$(i), target);\n"); - } - printer->Print("}\n"); -} - -void RepeatedEnumFieldGenerator:: -GenerateByteSize(io::Printer* printer) const { - printer->Print(variables_, - "{\n" - " int data_size = 0;\n"); - printer->Indent(); - printer->Print(variables_, - "for (int i = 0; i < this->$name$_size(); i++) {\n" - " data_size += ::google::protobuf::internal::WireFormatLite::EnumSize(\n" - " this->$name$(i));\n" - "}\n"); - - if (descriptor_->options().packed()) { - printer->Print(variables_, - "if (data_size > 0) {\n" - " total_size += $tag_size$ +\n" - " ::google::protobuf::internal::WireFormatLite::Int32Size(data_size);\n" - "}\n" - "GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();\n" - "_$name$_cached_byte_size_ = data_size;\n" - "GOOGLE_SAFE_CONCURRENT_WRITES_END();\n" - "total_size += data_size;\n"); - } else { - printer->Print(variables_, - "total_size += $tag_size$ * this->$name$_size() + data_size;\n"); - } - printer->Outdent(); - printer->Print("}\n"); -} - -} // namespace cpp -} // namespace compiler -} // namespace protobuf -} // namespace google diff --git a/modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/cpp/cpp_enum_field.h b/modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/cpp/cpp_enum_field.h deleted file mode 100644 index 65770083b..000000000 --- a/modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/cpp/cpp_enum_field.h +++ /dev/null @@ -1,105 +0,0 @@ -// Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// http://code.google.com/p/protobuf/ -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -// Author: kenton@google.com (Kenton Varda) -// Based on original Protocol Buffers design by -// Sanjay Ghemawat, Jeff Dean, and others. - -#ifndef GOOGLE_PROTOBUF_COMPILER_CPP_ENUM_FIELD_H__ -#define GOOGLE_PROTOBUF_COMPILER_CPP_ENUM_FIELD_H__ - -#include -#include -#include - -namespace google { -namespace protobuf { -namespace compiler { -namespace cpp { - -class EnumFieldGenerator : public FieldGenerator { - public: - explicit EnumFieldGenerator(const FieldDescriptor* descriptor, - const Options& options); - ~EnumFieldGenerator(); - - // implements FieldGenerator --------------------------------------- - void GeneratePrivateMembers(io::Printer* printer) const; - void GenerateAccessorDeclarations(io::Printer* printer) const; - void GenerateInlineAccessorDefinitions(io::Printer* printer) const; - void GenerateClearingCode(io::Printer* printer) const; - void GenerateMergingCode(io::Printer* printer) const; - void GenerateSwappingCode(io::Printer* printer) const; - void GenerateConstructorCode(io::Printer* printer) const; - void GenerateMergeFromCodedStream(io::Printer* printer) const; - void GenerateSerializeWithCachedSizes(io::Printer* printer) const; - void GenerateSerializeWithCachedSizesToArray(io::Printer* printer) const; - void GenerateByteSize(io::Printer* printer) const; - - private: - const FieldDescriptor* descriptor_; - map variables_; - - GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(EnumFieldGenerator); -}; - -class RepeatedEnumFieldGenerator : public FieldGenerator { - public: - explicit RepeatedEnumFieldGenerator(const FieldDescriptor* descriptor, - const Options& options); - ~RepeatedEnumFieldGenerator(); - - // implements FieldGenerator --------------------------------------- - void GeneratePrivateMembers(io::Printer* printer) const; - void GenerateAccessorDeclarations(io::Printer* printer) const; - void GenerateInlineAccessorDefinitions(io::Printer* printer) const; - void GenerateClearingCode(io::Printer* printer) const; - void GenerateMergingCode(io::Printer* printer) const; - void GenerateSwappingCode(io::Printer* printer) const; - void GenerateConstructorCode(io::Printer* printer) const; - void GenerateMergeFromCodedStream(io::Printer* printer) const; - void GenerateMergeFromCodedStreamWithPacking(io::Printer* printer) const; - void GenerateSerializeWithCachedSizes(io::Printer* printer) const; - void GenerateSerializeWithCachedSizesToArray(io::Printer* printer) const; - void GenerateByteSize(io::Printer* printer) const; - - private: - const FieldDescriptor* descriptor_; - map variables_; - - GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(RepeatedEnumFieldGenerator); -}; - -} // namespace cpp -} // namespace compiler -} // namespace protobuf - -} // namespace google -#endif // GOOGLE_PROTOBUF_COMPILER_CPP_ENUM_FIELD_H__ diff --git a/modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/cpp/cpp_extension.cc b/modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/cpp/cpp_extension.cc deleted file mode 100644 index ef56b5e54..000000000 --- a/modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/cpp/cpp_extension.cc +++ /dev/null @@ -1,210 +0,0 @@ -// Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// http://code.google.com/p/protobuf/ -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -// Author: kenton@google.com (Kenton Varda) -// Based on original Protocol Buffers design by -// Sanjay Ghemawat, Jeff Dean, and others. - -#include -#include -#include -#include -#include -#include - -namespace google { -namespace protobuf { -namespace compiler { -namespace cpp { - -namespace { - -// Returns the fully-qualified class name of the message that this field -// extends. This function is used in the Google-internal code to handle some -// legacy cases. -string ExtendeeClassName(const FieldDescriptor* descriptor) { - const Descriptor* extendee = descriptor->containing_type(); - return ClassName(extendee, true); -} - -} // anonymous namespace - -ExtensionGenerator::ExtensionGenerator(const FieldDescriptor* descriptor, - const Options& options) - : descriptor_(descriptor), - options_(options) { - // Construct type_traits_. - if (descriptor_->is_repeated()) { - type_traits_ = "Repeated"; - } - - switch (descriptor_->cpp_type()) { - case FieldDescriptor::CPPTYPE_ENUM: - type_traits_.append("EnumTypeTraits< "); - type_traits_.append(ClassName(descriptor_->enum_type(), true)); - type_traits_.append(", "); - type_traits_.append(ClassName(descriptor_->enum_type(), true)); - type_traits_.append("_IsValid>"); - break; - case FieldDescriptor::CPPTYPE_STRING: - type_traits_.append("StringTypeTraits"); - break; - case FieldDescriptor::CPPTYPE_MESSAGE: - type_traits_.append("MessageTypeTraits< "); - type_traits_.append(ClassName(descriptor_->message_type(), true)); - type_traits_.append(" >"); - break; - default: - type_traits_.append("PrimitiveTypeTraits< "); - type_traits_.append(PrimitiveTypeName(descriptor_->cpp_type())); - type_traits_.append(" >"); - break; - } -} - -ExtensionGenerator::~ExtensionGenerator() {} - -void ExtensionGenerator::GenerateDeclaration(io::Printer* printer) { - map vars; - vars["extendee" ] = ExtendeeClassName(descriptor_); - vars["number" ] = SimpleItoa(descriptor_->number()); - vars["type_traits" ] = type_traits_; - vars["name" ] = descriptor_->name(); - vars["field_type" ] = SimpleItoa(static_cast(descriptor_->type())); - vars["packed" ] = descriptor_->options().packed() ? "true" : "false"; - vars["constant_name"] = FieldConstantName(descriptor_); - - // If this is a class member, it needs to be declared "static". Otherwise, - // it needs to be "extern". In the latter case, it also needs the DLL - // export/import specifier. - if (descriptor_->extension_scope() == NULL) { - vars["qualifier"] = "extern"; - if (!options_.dllexport_decl.empty()) { - vars["qualifier"] = options_.dllexport_decl + " " + vars["qualifier"]; - } - } else { - vars["qualifier"] = "static"; - } - - printer->Print(vars, - "static const int $constant_name$ = $number$;\n" - "$qualifier$ ::google::protobuf::internal::ExtensionIdentifier< $extendee$,\n" - " ::google::protobuf::internal::$type_traits$, $field_type$, $packed$ >\n" - " $name$;\n" - ); - -} - -void ExtensionGenerator::GenerateDefinition(io::Printer* printer) { - // If this is a class member, it needs to be declared in its class scope. - string scope = (descriptor_->extension_scope() == NULL) ? "" : - ClassName(descriptor_->extension_scope(), false) + "::"; - string name = scope + descriptor_->name(); - - map vars; - vars["extendee" ] = ExtendeeClassName(descriptor_); - vars["type_traits" ] = type_traits_; - vars["name" ] = name; - vars["constant_name"] = FieldConstantName(descriptor_); - vars["default" ] = DefaultValue(descriptor_); - vars["field_type" ] = SimpleItoa(static_cast(descriptor_->type())); - vars["packed" ] = descriptor_->options().packed() ? "true" : "false"; - vars["scope" ] = scope; - - if (descriptor_->cpp_type() == FieldDescriptor::CPPTYPE_STRING) { - // We need to declare a global string which will contain the default value. - // We cannot declare it at class scope because that would require exposing - // it in the header which would be annoying for other reasons. So we - // replace :: with _ in the name and declare it as a global. - string global_name = StringReplace(name, "::", "_", true); - vars["global_name"] = global_name; - printer->Print(vars, - "const ::std::string $global_name$_default($default$);\n"); - - // Update the default to refer to the string global. - vars["default"] = global_name + "_default"; - } - - // Likewise, class members need to declare the field constant variable. - if (descriptor_->extension_scope() != NULL) { - printer->Print(vars, - "#ifndef _MSC_VER\n" - "const int $scope$$constant_name$;\n" - "#endif\n"); - } - - printer->Print(vars, - "::google::protobuf::internal::ExtensionIdentifier< $extendee$,\n" - " ::google::protobuf::internal::$type_traits$, $field_type$, $packed$ >\n" - " $name$($constant_name$, $default$);\n"); -} - -void ExtensionGenerator::GenerateRegistration(io::Printer* printer) { - map vars; - vars["extendee" ] = ExtendeeClassName(descriptor_); - vars["number" ] = SimpleItoa(descriptor_->number()); - vars["field_type" ] = SimpleItoa(static_cast(descriptor_->type())); - vars["is_repeated"] = descriptor_->is_repeated() ? "true" : "false"; - vars["is_packed" ] = (descriptor_->is_repeated() && - descriptor_->options().packed()) - ? "true" : "false"; - - switch (descriptor_->cpp_type()) { - case FieldDescriptor::CPPTYPE_ENUM: - printer->Print(vars, - "::google::protobuf::internal::ExtensionSet::RegisterEnumExtension(\n" - " &$extendee$::default_instance(),\n" - " $number$, $field_type$, $is_repeated$, $is_packed$,\n"); - printer->Print( - " &$type$_IsValid);\n", - "type", ClassName(descriptor_->enum_type(), true)); - break; - case FieldDescriptor::CPPTYPE_MESSAGE: - printer->Print(vars, - "::google::protobuf::internal::ExtensionSet::RegisterMessageExtension(\n" - " &$extendee$::default_instance(),\n" - " $number$, $field_type$, $is_repeated$, $is_packed$,\n"); - printer->Print( - " &$type$::default_instance());\n", - "type", ClassName(descriptor_->message_type(), true)); - break; - default: - printer->Print(vars, - "::google::protobuf::internal::ExtensionSet::RegisterExtension(\n" - " &$extendee$::default_instance(),\n" - " $number$, $field_type$, $is_repeated$, $is_packed$);\n"); - break; - } -} - -} // namespace cpp -} // namespace compiler -} // namespace protobuf -} // namespace google diff --git a/modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/cpp/cpp_extension.h b/modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/cpp/cpp_extension.h deleted file mode 100644 index 50ad035ba..000000000 --- a/modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/cpp/cpp_extension.h +++ /dev/null @@ -1,86 +0,0 @@ -// Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// http://code.google.com/p/protobuf/ -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -// Author: kenton@google.com (Kenton Varda) -// Based on original Protocol Buffers design by -// Sanjay Ghemawat, Jeff Dean, and others. - -#ifndef GOOGLE_PROTOBUF_COMPILER_CPP_EXTENSION_H__ -#define GOOGLE_PROTOBUF_COMPILER_CPP_EXTENSION_H__ - -#include -#include -#include - -namespace google { -namespace protobuf { - class FieldDescriptor; // descriptor.h - namespace io { - class Printer; // printer.h - } -} - -namespace protobuf { -namespace compiler { -namespace cpp { - -// Generates code for an extension, which may be within the scope of some -// message or may be at file scope. This is much simpler than FieldGenerator -// since extensions are just simple identifiers with interesting types. -class ExtensionGenerator { - public: - // See generator.cc for the meaning of dllexport_decl. - explicit ExtensionGenerator(const FieldDescriptor* desycriptor, - const Options& options); - ~ExtensionGenerator(); - - // Header stuff. - void GenerateDeclaration(io::Printer* printer); - - // Source file stuff. - void GenerateDefinition(io::Printer* printer); - - // Generate code to register the extension. - void GenerateRegistration(io::Printer* printer); - - private: - const FieldDescriptor* descriptor_; - string type_traits_; - Options options_; - - GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ExtensionGenerator); -}; - -} // namespace cpp -} // namespace compiler -} // namespace protobuf - -} // namespace google -#endif // GOOGLE_PROTOBUF_COMPILER_CPP_MESSAGE_H__ diff --git a/modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/cpp/cpp_field.cc b/modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/cpp/cpp_field.cc deleted file mode 100644 index 0786176ba..000000000 --- a/modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/cpp/cpp_field.cc +++ /dev/null @@ -1,142 +0,0 @@ -// Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// http://code.google.com/p/protobuf/ -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -// Author: kenton@google.com (Kenton Varda) -// Based on original Protocol Buffers design by -// Sanjay Ghemawat, Jeff Dean, and others. - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -namespace google { -namespace protobuf { -namespace compiler { -namespace cpp { - -using internal::WireFormat; - -void SetCommonFieldVariables(const FieldDescriptor* descriptor, - map* variables, - const Options& options) { - (*variables)["name"] = FieldName(descriptor); - (*variables)["index"] = SimpleItoa(descriptor->index()); - (*variables)["number"] = SimpleItoa(descriptor->number()); - (*variables)["classname"] = ClassName(FieldScope(descriptor), false); - (*variables)["declared_type"] = DeclaredTypeMethodName(descriptor->type()); - - (*variables)["tag_size"] = SimpleItoa( - WireFormat::TagSize(descriptor->number(), descriptor->type())); - (*variables)["deprecation"] = descriptor->options().deprecated() - ? " PROTOBUF_DEPRECATED" : ""; - - (*variables)["cppget"] = "Get"; -} - -FieldGenerator::~FieldGenerator() {} - -void FieldGenerator:: -GenerateMergeFromCodedStreamWithPacking(io::Printer* printer) const { - // Reaching here indicates a bug. Cases are: - // - This FieldGenerator should support packing, but this method should be - // overridden. - // - This FieldGenerator doesn't support packing, and this method should - // never have been called. - GOOGLE_LOG(FATAL) << "GenerateMergeFromCodedStreamWithPacking() " - << "called on field generator that does not support packing."; - -} - -FieldGeneratorMap::FieldGeneratorMap(const Descriptor* descriptor, - const Options& options) - : descriptor_(descriptor), - field_generators_(new scoped_ptr[descriptor->field_count()]) { - // Construct all the FieldGenerators. - for (int i = 0; i < descriptor->field_count(); i++) { - field_generators_[i].reset(MakeGenerator(descriptor->field(i), options)); - } -} - -FieldGenerator* FieldGeneratorMap::MakeGenerator(const FieldDescriptor* field, - const Options& options) { - if (field->is_repeated()) { - switch (field->cpp_type()) { - case FieldDescriptor::CPPTYPE_MESSAGE: - return new RepeatedMessageFieldGenerator(field, options); - case FieldDescriptor::CPPTYPE_STRING: - switch (field->options().ctype()) { - default: // RepeatedStringFieldGenerator handles unknown ctypes. - case FieldOptions::STRING: - return new RepeatedStringFieldGenerator(field, options); - } - case FieldDescriptor::CPPTYPE_ENUM: - return new RepeatedEnumFieldGenerator(field, options); - default: - return new RepeatedPrimitiveFieldGenerator(field, options); - } - } else { - switch (field->cpp_type()) { - case FieldDescriptor::CPPTYPE_MESSAGE: - return new MessageFieldGenerator(field, options); - case FieldDescriptor::CPPTYPE_STRING: - switch (field->options().ctype()) { - default: // StringFieldGenerator handles unknown ctypes. - case FieldOptions::STRING: - return new StringFieldGenerator(field, options); - } - case FieldDescriptor::CPPTYPE_ENUM: - return new EnumFieldGenerator(field, options); - default: - return new PrimitiveFieldGenerator(field, options); - } - } -} - -FieldGeneratorMap::~FieldGeneratorMap() {} - -const FieldGenerator& FieldGeneratorMap::get( - const FieldDescriptor* field) const { - GOOGLE_CHECK_EQ(field->containing_type(), descriptor_); - return *field_generators_[field->index()]; -} - - -} // namespace cpp -} // namespace compiler -} // namespace protobuf -} // namespace google diff --git a/modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/cpp/cpp_field.h b/modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/cpp/cpp_field.h deleted file mode 100644 index f7d99b154..000000000 --- a/modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/cpp/cpp_field.h +++ /dev/null @@ -1,177 +0,0 @@ -// Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// http://code.google.com/p/protobuf/ -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -// Author: kenton@google.com (Kenton Varda) -// Based on original Protocol Buffers design by -// Sanjay Ghemawat, Jeff Dean, and others. - -#ifndef GOOGLE_PROTOBUF_COMPILER_CPP_FIELD_H__ -#define GOOGLE_PROTOBUF_COMPILER_CPP_FIELD_H__ - -#include -#include - -#include -#include -#include - -namespace google { -namespace protobuf { - namespace io { - class Printer; // printer.h - } -} - -namespace protobuf { -namespace compiler { -namespace cpp { - -// Helper function: set variables in the map that are the same for all -// field code generators. -// ['name', 'index', 'number', 'classname', 'declared_type', 'tag_size', -// 'deprecation']. -void SetCommonFieldVariables(const FieldDescriptor* descriptor, - map* variables, - const Options& options); - -class FieldGenerator { - public: - FieldGenerator() {} - virtual ~FieldGenerator(); - - // Generate lines of code declaring members fields of the message class - // needed to represent this field. These are placed inside the message - // class. - virtual void GeneratePrivateMembers(io::Printer* printer) const = 0; - - // Generate prototypes for all of the accessor functions related to this - // field. These are placed inside the class definition. - virtual void GenerateAccessorDeclarations(io::Printer* printer) const = 0; - - // Generate inline definitions of accessor functions for this field. - // These are placed inside the header after all class definitions. - virtual void GenerateInlineAccessorDefinitions( - io::Printer* printer) const = 0; - - // Generate definitions of accessors that aren't inlined. These are - // placed somewhere in the .cc file. - // Most field types don't need this, so the default implementation is empty. - virtual void GenerateNonInlineAccessorDefinitions( - io::Printer* printer) const {} - - // Generate lines of code (statements, not declarations) which clear the - // field. This is used to define the clear_$name$() method as well as - // the Clear() method for the whole message. - virtual void GenerateClearingCode(io::Printer* printer) const = 0; - - // Generate lines of code (statements, not declarations) which merges the - // contents of the field from the current message to the target message, - // which is stored in the generated code variable "from". - // This is used to fill in the MergeFrom method for the whole message. - // Details of this usage can be found in message.cc under the - // GenerateMergeFrom method. - virtual void GenerateMergingCode(io::Printer* printer) const = 0; - - // Generate lines of code (statements, not declarations) which swaps - // this field and the corresponding field of another message, which - // is stored in the generated code variable "other". This is used to - // define the Swap method. Details of usage can be found in - // message.cc under the GenerateSwap method. - virtual void GenerateSwappingCode(io::Printer* printer) const = 0; - - // Generate initialization code for private members declared by - // GeneratePrivateMembers(). These go into the message class's SharedCtor() - // method, invoked by each of the generated constructors. - virtual void GenerateConstructorCode(io::Printer* printer) const = 0; - - // Generate any code that needs to go in the class's SharedDtor() method, - // invoked by the destructor. - // Most field types don't need this, so the default implementation is empty. - virtual void GenerateDestructorCode(io::Printer* printer) const {} - - // Generate code that allocates the fields's default instance. - virtual void GenerateDefaultInstanceAllocator(io::Printer* printer) const {} - - // Generate code that should be run when ShutdownProtobufLibrary() is called, - // to delete all dynamically-allocated objects. - virtual void GenerateShutdownCode(io::Printer* printer) const {} - - // Generate lines to decode this field, which will be placed inside the - // message's MergeFromCodedStream() method. - virtual void GenerateMergeFromCodedStream(io::Printer* printer) const = 0; - - // Generate lines to decode this field from a packed value, which will be - // placed inside the message's MergeFromCodedStream() method. - virtual void GenerateMergeFromCodedStreamWithPacking(io::Printer* printer) - const; - - // Generate lines to serialize this field, which are placed within the - // message's SerializeWithCachedSizes() method. - virtual void GenerateSerializeWithCachedSizes(io::Printer* printer) const = 0; - - // Generate lines to serialize this field directly to the array "target", - // which are placed within the message's SerializeWithCachedSizesToArray() - // method. This must also advance "target" past the written bytes. - virtual void GenerateSerializeWithCachedSizesToArray( - io::Printer* printer) const = 0; - - // Generate lines to compute the serialized size of this field, which - // are placed in the message's ByteSize() method. - virtual void GenerateByteSize(io::Printer* printer) const = 0; - - private: - GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(FieldGenerator); -}; - -// Convenience class which constructs FieldGenerators for a Descriptor. -class FieldGeneratorMap { - public: - explicit FieldGeneratorMap(const Descriptor* descriptor, const Options& options); - ~FieldGeneratorMap(); - - const FieldGenerator& get(const FieldDescriptor* field) const; - - private: - const Descriptor* descriptor_; - scoped_array > field_generators_; - - static FieldGenerator* MakeGenerator(const FieldDescriptor* field, - const Options& options); - - GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(FieldGeneratorMap); -}; - - -} // namespace cpp -} // namespace compiler -} // namespace protobuf - -} // namespace google -#endif // GOOGLE_PROTOBUF_COMPILER_CPP_FIELD_H__ diff --git a/modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/cpp/cpp_file.cc b/modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/cpp/cpp_file.cc deleted file mode 100644 index cfe96c8a7..000000000 --- a/modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/cpp/cpp_file.cc +++ /dev/null @@ -1,652 +0,0 @@ -// Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// http://code.google.com/p/protobuf/ -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -// Author: kenton@google.com (Kenton Varda) -// Based on original Protocol Buffers design by -// Sanjay Ghemawat, Jeff Dean, and others. - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -namespace google { -namespace protobuf { -namespace compiler { -namespace cpp { - -// =================================================================== - -FileGenerator::FileGenerator(const FileDescriptor* file, - const Options& options) - : file_(file), - message_generators_( - new scoped_ptr[file->message_type_count()]), - enum_generators_( - new scoped_ptr[file->enum_type_count()]), - service_generators_( - new scoped_ptr[file->service_count()]), - extension_generators_( - new scoped_ptr[file->extension_count()]), - options_(options) { - - for (int i = 0; i < file->message_type_count(); i++) { - message_generators_[i].reset( - new MessageGenerator(file->message_type(i), options)); - } - - for (int i = 0; i < file->enum_type_count(); i++) { - enum_generators_[i].reset( - new EnumGenerator(file->enum_type(i), options)); - } - - for (int i = 0; i < file->service_count(); i++) { - service_generators_[i].reset( - new ServiceGenerator(file->service(i), options)); - } - - for (int i = 0; i < file->extension_count(); i++) { - extension_generators_[i].reset( - new ExtensionGenerator(file->extension(i), options)); - } - - SplitStringUsing(file_->package(), ".", &package_parts_); -} - -FileGenerator::~FileGenerator() {} - -void FileGenerator::GenerateHeader(io::Printer* printer) { - string filename_identifier = FilenameIdentifier(file_->name()); - - // Generate top of header. - printer->Print( - "// Generated by the protocol buffer compiler. DO NOT EDIT!\n" - "// source: $filename$\n" - "\n" - "#ifndef PROTOBUF_$filename_identifier$__INCLUDED\n" - "#define PROTOBUF_$filename_identifier$__INCLUDED\n" - "\n" - "#include \n" - "\n", - "filename", file_->name(), - "filename_identifier", filename_identifier); - - - printer->Print( - "#include \n" - "\n"); - - // Verify the protobuf library header version is compatible with the protoc - // version before going any further. - printer->Print( - "#if GOOGLE_PROTOBUF_VERSION < $min_header_version$\n" - "#error This file was generated by a newer version of protoc which is\n" - "#error incompatible with your Protocol Buffer headers. Please update\n" - "#error your headers.\n" - "#endif\n" - "#if $protoc_version$ < GOOGLE_PROTOBUF_MIN_PROTOC_VERSION\n" - "#error This file was generated by an older version of protoc which is\n" - "#error incompatible with your Protocol Buffer headers. Please\n" - "#error regenerate this file with a newer version of protoc.\n" - "#endif\n" - "\n", - "min_header_version", - SimpleItoa(protobuf::internal::kMinHeaderVersionForProtoc), - "protoc_version", SimpleItoa(GOOGLE_PROTOBUF_VERSION)); - - // OK, it's now safe to #include other files. - printer->Print( - "#include \n"); - if (file_->message_type_count() > 0) { - if (HasDescriptorMethods(file_)) { - printer->Print( - "#include \n"); - } else { - printer->Print( - "#include \n"); - } - } - printer->Print( - "#include \n" - "#include \n"); - - if (HasDescriptorMethods(file_) && HasEnumDefinitions(file_)) { - printer->Print( - "#include \n"); - } - - if (HasGenericServices(file_)) { - printer->Print( - "#include \n"); - } - - if (HasUnknownFields(file_) && file_->message_type_count() > 0) { - printer->Print( - "#include \n"); - } - - - for (int i = 0; i < file_->dependency_count(); i++) { - printer->Print( - "#include \"$dependency$.pb.h\"\n", - "dependency", StripProto(file_->dependency(i)->name())); - } - - - printer->Print( - "// @@protoc_insertion_point(includes)\n"); - - - // Open namespace. - GenerateNamespaceOpeners(printer); - - // Forward-declare the AddDescriptors, AssignDescriptors, and ShutdownFile - // functions, so that we can declare them to be friends of each class. - printer->Print( - "\n" - "// Internal implementation detail -- do not call these.\n" - "void $dllexport_decl$ $adddescriptorsname$();\n", - "adddescriptorsname", GlobalAddDescriptorsName(file_->name()), - "dllexport_decl", options_.dllexport_decl); - - printer->Print( - // Note that we don't put dllexport_decl on these because they are only - // called by the .pb.cc file in which they are defined. - "void $assigndescriptorsname$();\n" - "void $shutdownfilename$();\n" - "\n", - "assigndescriptorsname", GlobalAssignDescriptorsName(file_->name()), - "shutdownfilename", GlobalShutdownFileName(file_->name())); - - // Generate forward declarations of classes. - for (int i = 0; i < file_->message_type_count(); i++) { - message_generators_[i]->GenerateForwardDeclaration(printer); - } - - printer->Print("\n"); - - // Generate enum definitions. - for (int i = 0; i < file_->message_type_count(); i++) { - message_generators_[i]->GenerateEnumDefinitions(printer); - } - for (int i = 0; i < file_->enum_type_count(); i++) { - enum_generators_[i]->GenerateDefinition(printer); - } - - printer->Print(kThickSeparator); - printer->Print("\n"); - - // Generate class definitions. - for (int i = 0; i < file_->message_type_count(); i++) { - if (i > 0) { - printer->Print("\n"); - printer->Print(kThinSeparator); - printer->Print("\n"); - } - message_generators_[i]->GenerateClassDefinition(printer); - } - - printer->Print("\n"); - printer->Print(kThickSeparator); - printer->Print("\n"); - - if (HasGenericServices(file_)) { - // Generate service definitions. - for (int i = 0; i < file_->service_count(); i++) { - if (i > 0) { - printer->Print("\n"); - printer->Print(kThinSeparator); - printer->Print("\n"); - } - service_generators_[i]->GenerateDeclarations(printer); - } - - printer->Print("\n"); - printer->Print(kThickSeparator); - printer->Print("\n"); - } - - // Declare extension identifiers. - for (int i = 0; i < file_->extension_count(); i++) { - extension_generators_[i]->GenerateDeclaration(printer); - } - - printer->Print("\n"); - printer->Print(kThickSeparator); - printer->Print("\n"); - - // Generate class inline methods. - for (int i = 0; i < file_->message_type_count(); i++) { - if (i > 0) { - printer->Print(kThinSeparator); - printer->Print("\n"); - } - message_generators_[i]->GenerateInlineMethods(printer); - } - - printer->Print( - "\n" - "// @@protoc_insertion_point(namespace_scope)\n"); - - // Close up namespace. - GenerateNamespaceClosers(printer); - - // Emit GetEnumDescriptor specializations into google::protobuf namespace: - if (HasDescriptorMethods(file_)) { - // The SWIG conditional is to avoid a null-pointer dereference - // (bug 1984964) in swig-1.3.21 resulting from the following syntax: - // namespace X { void Y(); } - // which appears in GetEnumDescriptor() specializations. - printer->Print( - "\n" - "#ifndef SWIG\n" - "namespace google {\nnamespace protobuf {\n" - "\n"); - for (int i = 0; i < file_->message_type_count(); i++) { - message_generators_[i]->GenerateGetEnumDescriptorSpecializations(printer); - } - for (int i = 0; i < file_->enum_type_count(); i++) { - enum_generators_[i]->GenerateGetEnumDescriptorSpecializations(printer); - } - printer->Print( - "\n" - "} // namespace google\n} // namespace protobuf\n" - "#endif // SWIG\n"); - } - - printer->Print( - "\n" - "// @@protoc_insertion_point(global_scope)\n" - "\n"); - - printer->Print( - "#endif // PROTOBUF_$filename_identifier$__INCLUDED\n", - "filename_identifier", filename_identifier); -} - -void FileGenerator::GenerateSource(io::Printer* printer) { - printer->Print( - "// Generated by the protocol buffer compiler. DO NOT EDIT!\n" - "// source: $filename$\n" - "\n" - - // The generated code calls accessors that might be deprecated. We don't - // want the compiler to warn in generated code. - "#define INTERNAL_SUPPRESS_PROTOBUF_FIELD_DEPRECATION\n" - "#include \"$basename$.pb.h\"\n" - "\n" - "#include \n" // for swap() - "\n" - "#include \n" - "#include \n" - "#include \n" - "#include \n", - "filename", file_->name(), - "basename", StripProto(file_->name())); - - if (HasDescriptorMethods(file_)) { - printer->Print( - "#include \n" - "#include \n" - "#include \n" - "#include \n"); - } - - printer->Print( - "// @@protoc_insertion_point(includes)\n"); - - GenerateNamespaceOpeners(printer); - - if (HasDescriptorMethods(file_)) { - printer->Print( - "\n" - "namespace {\n" - "\n"); - for (int i = 0; i < file_->message_type_count(); i++) { - message_generators_[i]->GenerateDescriptorDeclarations(printer); - } - for (int i = 0; i < file_->enum_type_count(); i++) { - printer->Print( - "const ::google::protobuf::EnumDescriptor* $name$_descriptor_ = NULL;\n", - "name", ClassName(file_->enum_type(i), false)); - } - - if (HasGenericServices(file_)) { - for (int i = 0; i < file_->service_count(); i++) { - printer->Print( - "const ::google::protobuf::ServiceDescriptor* $name$_descriptor_ = NULL;\n", - "name", file_->service(i)->name()); - } - } - - printer->Print( - "\n" - "} // namespace\n" - "\n"); - } - - // Define our externally-visible BuildDescriptors() function. (For the lite - // library, all this does is initialize default instances.) - GenerateBuildDescriptors(printer); - - // Generate enums. - for (int i = 0; i < file_->enum_type_count(); i++) { - enum_generators_[i]->GenerateMethods(printer); - } - - // Generate classes. - for (int i = 0; i < file_->message_type_count(); i++) { - printer->Print("\n"); - printer->Print(kThickSeparator); - printer->Print("\n"); - message_generators_[i]->GenerateClassMethods(printer); - } - - if (HasGenericServices(file_)) { - // Generate services. - for (int i = 0; i < file_->service_count(); i++) { - if (i == 0) printer->Print("\n"); - printer->Print(kThickSeparator); - printer->Print("\n"); - service_generators_[i]->GenerateImplementation(printer); - } - } - - // Define extensions. - for (int i = 0; i < file_->extension_count(); i++) { - extension_generators_[i]->GenerateDefinition(printer); - } - - printer->Print( - "\n" - "// @@protoc_insertion_point(namespace_scope)\n"); - - GenerateNamespaceClosers(printer); - - printer->Print( - "\n" - "// @@protoc_insertion_point(global_scope)\n"); -} - -void FileGenerator::GenerateBuildDescriptors(io::Printer* printer) { - // AddDescriptors() is a file-level procedure which adds the encoded - // FileDescriptorProto for this .proto file to the global DescriptorPool for - // generated files (DescriptorPool::generated_pool()). It either runs at - // static initialization time (by default) or when default_instance() is - // called for the first time (in LITE_RUNTIME mode with - // GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER flag enabled). This procedure also - // constructs default instances and registers extensions. - // - // Its sibling, AssignDescriptors(), actually pulls the compiled - // FileDescriptor from the DescriptorPool and uses it to populate all of - // the global variables which store pointers to the descriptor objects. - // It also constructs the reflection objects. It is called the first time - // anyone calls descriptor() or GetReflection() on one of the types defined - // in the file. - - // In optimize_for = LITE_RUNTIME mode, we don't generate AssignDescriptors() - // and we only use AddDescriptors() to allocate default instances. - if (HasDescriptorMethods(file_)) { - printer->Print( - "\n" - "void $assigndescriptorsname$() {\n", - "assigndescriptorsname", GlobalAssignDescriptorsName(file_->name())); - printer->Indent(); - - // Make sure the file has found its way into the pool. If a descriptor - // is requested *during* static init then AddDescriptors() may not have - // been called yet, so we call it manually. Note that it's fine if - // AddDescriptors() is called multiple times. - printer->Print( - "$adddescriptorsname$();\n", - "adddescriptorsname", GlobalAddDescriptorsName(file_->name())); - - // Get the file's descriptor from the pool. - printer->Print( - "const ::google::protobuf::FileDescriptor* file =\n" - " ::google::protobuf::DescriptorPool::generated_pool()->FindFileByName(\n" - " \"$filename$\");\n" - // Note that this GOOGLE_CHECK is necessary to prevent a warning about "file" - // being unused when compiling an empty .proto file. - "GOOGLE_CHECK(file != NULL);\n", - "filename", file_->name()); - - // Go through all the stuff defined in this file and generated code to - // assign the global descriptor pointers based on the file descriptor. - for (int i = 0; i < file_->message_type_count(); i++) { - message_generators_[i]->GenerateDescriptorInitializer(printer, i); - } - for (int i = 0; i < file_->enum_type_count(); i++) { - enum_generators_[i]->GenerateDescriptorInitializer(printer, i); - } - if (HasGenericServices(file_)) { - for (int i = 0; i < file_->service_count(); i++) { - service_generators_[i]->GenerateDescriptorInitializer(printer, i); - } - } - - printer->Outdent(); - printer->Print( - "}\n" - "\n"); - - // --------------------------------------------------------------- - - // protobuf_AssignDescriptorsOnce(): The first time it is called, calls - // AssignDescriptors(). All later times, waits for the first call to - // complete and then returns. - printer->Print( - "namespace {\n" - "\n" - "GOOGLE_PROTOBUF_DECLARE_ONCE(protobuf_AssignDescriptors_once_);\n" - "inline void protobuf_AssignDescriptorsOnce() {\n" - " ::google::protobuf::GoogleOnceInit(&protobuf_AssignDescriptors_once_,\n" - " &$assigndescriptorsname$);\n" - "}\n" - "\n", - "assigndescriptorsname", GlobalAssignDescriptorsName(file_->name())); - - // protobuf_RegisterTypes(): Calls - // MessageFactory::InternalRegisterGeneratedType() for each message type. - printer->Print( - "void protobuf_RegisterTypes(const ::std::string&) {\n" - " protobuf_AssignDescriptorsOnce();\n"); - printer->Indent(); - - for (int i = 0; i < file_->message_type_count(); i++) { - message_generators_[i]->GenerateTypeRegistrations(printer); - } - - printer->Outdent(); - printer->Print( - "}\n" - "\n" - "} // namespace\n"); - } - - // ----------------------------------------------------------------- - - // ShutdownFile(): Deletes descriptors, default instances, etc. on shutdown. - printer->Print( - "\n" - "void $shutdownfilename$() {\n", - "shutdownfilename", GlobalShutdownFileName(file_->name())); - printer->Indent(); - - for (int i = 0; i < file_->message_type_count(); i++) { - message_generators_[i]->GenerateShutdownCode(printer); - } - - printer->Outdent(); - printer->Print( - "}\n\n"); - - // ----------------------------------------------------------------- - - // Now generate the AddDescriptors() function. - PrintHandlingOptionalStaticInitializers( - file_, printer, - // With static initializers. - // Note that we don't need any special synchronization in the following code - // because it is called at static init time before any threads exist. - "void $adddescriptorsname$() {\n" - " static bool already_here = false;\n" - " if (already_here) return;\n" - " already_here = true;\n" - " GOOGLE_PROTOBUF_VERIFY_VERSION;\n" - "\n", - // Without. - "void $adddescriptorsname$_impl() {\n" - " GOOGLE_PROTOBUF_VERIFY_VERSION;\n" - "\n", - // Vars. - "adddescriptorsname", GlobalAddDescriptorsName(file_->name())); - - printer->Indent(); - - // Call the AddDescriptors() methods for all of our dependencies, to make - // sure they get added first. - for (int i = 0; i < file_->dependency_count(); i++) { - const FileDescriptor* dependency = file_->dependency(i); - // Print the namespace prefix for the dependency. - vector dependency_package_parts; - SplitStringUsing(dependency->package(), ".", &dependency_package_parts); - printer->Print("::"); - for (int j = 0; j < dependency_package_parts.size(); j++) { - printer->Print("$name$::", - "name", dependency_package_parts[j]); - } - // Call its AddDescriptors function. - printer->Print( - "$name$();\n", - "name", GlobalAddDescriptorsName(dependency->name())); - } - - if (HasDescriptorMethods(file_)) { - // Embed the descriptor. We simply serialize the entire FileDescriptorProto - // and embed it as a string literal, which is parsed and built into real - // descriptors at initialization time. - FileDescriptorProto file_proto; - file_->CopyTo(&file_proto); - string file_data; - file_proto.SerializeToString(&file_data); - - printer->Print( - "::google::protobuf::DescriptorPool::InternalAddGeneratedFile("); - - // Only write 40 bytes per line. - static const int kBytesPerLine = 40; - for (int i = 0; i < file_data.size(); i += kBytesPerLine) { - printer->Print("\n \"$data$\"", - "data", - EscapeTrigraphs( - CEscape(file_data.substr(i, kBytesPerLine)))); - } - printer->Print( - ", $size$);\n", - "size", SimpleItoa(file_data.size())); - - // Call MessageFactory::InternalRegisterGeneratedFile(). - printer->Print( - "::google::protobuf::MessageFactory::InternalRegisterGeneratedFile(\n" - " \"$filename$\", &protobuf_RegisterTypes);\n", - "filename", file_->name()); - } - - // Allocate and initialize default instances. This can't be done lazily - // since default instances are returned by simple accessors and are used with - // extensions. Speaking of which, we also register extensions at this time. - for (int i = 0; i < file_->message_type_count(); i++) { - message_generators_[i]->GenerateDefaultInstanceAllocator(printer); - } - for (int i = 0; i < file_->extension_count(); i++) { - extension_generators_[i]->GenerateRegistration(printer); - } - for (int i = 0; i < file_->message_type_count(); i++) { - message_generators_[i]->GenerateDefaultInstanceInitializer(printer); - } - - printer->Print( - "::google::protobuf::internal::OnShutdown(&$shutdownfilename$);\n", - "shutdownfilename", GlobalShutdownFileName(file_->name())); - - printer->Outdent(); - printer->Print( - "}\n" - "\n"); - - PrintHandlingOptionalStaticInitializers( - file_, printer, - // With static initializers. - "// Force AddDescriptors() to be called at static initialization time.\n" - "struct StaticDescriptorInitializer_$filename$ {\n" - " StaticDescriptorInitializer_$filename$() {\n" - " $adddescriptorsname$();\n" - " }\n" - "} static_descriptor_initializer_$filename$_;\n", - // Without. - "GOOGLE_PROTOBUF_DECLARE_ONCE($adddescriptorsname$_once_);\n" - "void $adddescriptorsname$() {\n" - " ::google::protobuf::::google::protobuf::GoogleOnceInit(&$adddescriptorsname$_once_,\n" - " &$adddescriptorsname$_impl);\n" - "}\n", - // Vars. - "adddescriptorsname", GlobalAddDescriptorsName(file_->name()), - "filename", FilenameIdentifier(file_->name())); -} - -void FileGenerator::GenerateNamespaceOpeners(io::Printer* printer) { - if (package_parts_.size() > 0) printer->Print("\n"); - - for (int i = 0; i < package_parts_.size(); i++) { - printer->Print("namespace $part$ {\n", - "part", package_parts_[i]); - } -} - -void FileGenerator::GenerateNamespaceClosers(io::Printer* printer) { - if (package_parts_.size() > 0) printer->Print("\n"); - - for (int i = package_parts_.size() - 1; i >= 0; i--) { - printer->Print("} // namespace $part$\n", - "part", package_parts_[i]); - } -} - -} // namespace cpp -} // namespace compiler -} // namespace protobuf -} // namespace google diff --git a/modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/cpp/cpp_file.h b/modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/cpp/cpp_file.h deleted file mode 100644 index 2deefaa86..000000000 --- a/modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/cpp/cpp_file.h +++ /dev/null @@ -1,99 +0,0 @@ -// Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// http://code.google.com/p/protobuf/ -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -// Author: kenton@google.com (Kenton Varda) -// Based on original Protocol Buffers design by -// Sanjay Ghemawat, Jeff Dean, and others. - -#ifndef GOOGLE_PROTOBUF_COMPILER_CPP_FILE_H__ -#define GOOGLE_PROTOBUF_COMPILER_CPP_FILE_H__ - -#include -#include -#include -#include -#include - -namespace google { -namespace protobuf { - class FileDescriptor; // descriptor.h - namespace io { - class Printer; // printer.h - } -} - -namespace protobuf { -namespace compiler { -namespace cpp { - -class EnumGenerator; // enum.h -class MessageGenerator; // message.h -class ServiceGenerator; // service.h -class ExtensionGenerator; // extension.h - -class FileGenerator { - public: - // See generator.cc for the meaning of dllexport_decl. - explicit FileGenerator(const FileDescriptor* file, - const Options& options); - ~FileGenerator(); - - void GenerateHeader(io::Printer* printer); - void GenerateSource(io::Printer* printer); - - private: - // Generate the BuildDescriptors() procedure, which builds all descriptors - // for types defined in the file. - void GenerateBuildDescriptors(io::Printer* printer); - - void GenerateNamespaceOpeners(io::Printer* printer); - void GenerateNamespaceClosers(io::Printer* printer); - - const FileDescriptor* file_; - - scoped_array > message_generators_; - scoped_array > enum_generators_; - scoped_array > service_generators_; - scoped_array > extension_generators_; - - // E.g. if the package is foo.bar, package_parts_ is {"foo", "bar"}. - vector package_parts_; - - const Options options_; - - GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(FileGenerator); -}; - -} // namespace cpp -} // namespace compiler -} // namespace protobuf - -} // namespace google -#endif // GOOGLE_PROTOBUF_COMPILER_CPP_FILE_H__ diff --git a/modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/cpp/cpp_generator.cc b/modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/cpp/cpp_generator.cc deleted file mode 100644 index 1813510b6..000000000 --- a/modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/cpp/cpp_generator.cc +++ /dev/null @@ -1,124 +0,0 @@ -// Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// http://code.google.com/p/protobuf/ -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -// Author: kenton@google.com (Kenton Varda) -// Based on original Protocol Buffers design by -// Sanjay Ghemawat, Jeff Dean, and others. - -#include - -#include -#include - -#include -#include -#include -#include -#include - -namespace google { -namespace protobuf { -namespace compiler { -namespace cpp { - -CppGenerator::CppGenerator() {} -CppGenerator::~CppGenerator() {} - -bool CppGenerator::Generate(const FileDescriptor* file, - const string& parameter, - GeneratorContext* generator_context, - string* error) const { - vector > options; - ParseGeneratorParameter(parameter, &options); - - // ----------------------------------------------------------------- - // parse generator options - - // TODO(kenton): If we ever have more options, we may want to create a - // class that encapsulates them which we can pass down to all the - // generator classes. Currently we pass dllexport_decl down to all of - // them via the constructors, but we don't want to have to add another - // constructor parameter for every option. - - // If the dllexport_decl option is passed to the compiler, we need to write - // it in front of every symbol that should be exported if this .proto is - // compiled into a Windows DLL. E.g., if the user invokes the protocol - // compiler as: - // protoc --cpp_out=dllexport_decl=FOO_EXPORT:outdir foo.proto - // then we'll define classes like this: - // class FOO_EXPORT Foo { - // ... - // } - // FOO_EXPORT is a macro which should expand to __declspec(dllexport) or - // __declspec(dllimport) depending on what is being compiled. - Options file_options; - - for (int i = 0; i < options.size(); i++) { - if (options[i].first == "dllexport_decl") { - file_options.dllexport_decl = options[i].second; - } else if (options[i].first == "safe_boundary_check") { - file_options.safe_boundary_check = true; - } else { - *error = "Unknown generator option: " + options[i].first; - return false; - } - } - - // ----------------------------------------------------------------- - - - string basename = StripProto(file->name()); - basename.append(".pb"); - - FileGenerator file_generator(file, file_options); - - // Generate header. - { - scoped_ptr output( - generator_context->Open(basename + ".h")); - io::Printer printer(output.get(), '$'); - file_generator.GenerateHeader(&printer); - } - - // Generate cc file. - { - scoped_ptr output( - generator_context->Open(basename + ".cc")); - io::Printer printer(output.get(), '$'); - file_generator.GenerateSource(&printer); - } - - return true; -} - -} // namespace cpp -} // namespace compiler -} // namespace protobuf -} // namespace google diff --git a/modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/cpp/cpp_generator.h b/modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/cpp/cpp_generator.h deleted file mode 100644 index a90e84d7b..000000000 --- a/modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/cpp/cpp_generator.h +++ /dev/null @@ -1,72 +0,0 @@ -// Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// http://code.google.com/p/protobuf/ -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -// Author: kenton@google.com (Kenton Varda) -// Based on original Protocol Buffers design by -// Sanjay Ghemawat, Jeff Dean, and others. -// -// Generates C++ code for a given .proto file. - -#ifndef GOOGLE_PROTOBUF_COMPILER_CPP_GENERATOR_H__ -#define GOOGLE_PROTOBUF_COMPILER_CPP_GENERATOR_H__ - -#include -#include - -namespace google { -namespace protobuf { -namespace compiler { -namespace cpp { - -// CodeGenerator implementation which generates a C++ source file and -// header. If you create your own protocol compiler binary and you want -// it to support C++ output, you can do so by registering an instance of this -// CodeGenerator with the CommandLineInterface in your main() function. -class LIBPROTOC_EXPORT CppGenerator : public CodeGenerator { - public: - CppGenerator(); - ~CppGenerator(); - - // implements CodeGenerator ---------------------------------------- - bool Generate(const FileDescriptor* file, - const string& parameter, - GeneratorContext* generator_context, - string* error) const; - - private: - GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(CppGenerator); -}; - -} // namespace cpp -} // namespace compiler -} // namespace protobuf - -} // namespace google -#endif // GOOGLE_PROTOBUF_COMPILER_CPP_GENERATOR_H__ diff --git a/modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/cpp/cpp_helpers.cc b/modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/cpp/cpp_helpers.cc deleted file mode 100644 index 28911ab00..000000000 --- a/modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/cpp/cpp_helpers.cc +++ /dev/null @@ -1,438 +0,0 @@ -// Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// http://code.google.com/p/protobuf/ -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -// Author: kenton@google.com (Kenton Varda) -// Based on original Protocol Buffers design by -// Sanjay Ghemawat, Jeff Dean, and others. - -#include -#include -#include -#include - -#include -#include -#include -#include -#include - - -namespace google { -namespace protobuf { -namespace compiler { -namespace cpp { - -namespace { - -string DotsToUnderscores(const string& name) { - return StringReplace(name, ".", "_", true); -} - -string DotsToColons(const string& name) { - return StringReplace(name, ".", "::", true); -} - -const char* const kKeywordList[] = { - "and", "and_eq", "asm", "auto", "bitand", "bitor", "bool", "break", "case", - "catch", "char", "class", "compl", "const", "const_cast", "continue", - "default", "delete", "do", "double", "dynamic_cast", "else", "enum", - "explicit", "extern", "false", "float", "for", "friend", "goto", "if", - "inline", "int", "long", "mutable", "namespace", "new", "not", "not_eq", - "operator", "or", "or_eq", "private", "protected", "public", "register", - "reinterpret_cast", "return", "short", "signed", "sizeof", "static", - "static_cast", "struct", "switch", "template", "this", "throw", "true", "try", - "typedef", "typeid", "typename", "union", "unsigned", "using", "virtual", - "void", "volatile", "wchar_t", "while", "xor", "xor_eq" -}; - -hash_set MakeKeywordsMap() { - hash_set result; - for (int i = 0; i < GOOGLE_ARRAYSIZE(kKeywordList); i++) { - result.insert(kKeywordList[i]); - } - return result; -} - -hash_set kKeywords = MakeKeywordsMap(); - -string UnderscoresToCamelCase(const string& input, bool cap_next_letter) { - string result; - // Note: I distrust ctype.h due to locales. - for (int i = 0; i < input.size(); i++) { - if ('a' <= input[i] && input[i] <= 'z') { - if (cap_next_letter) { - result += input[i] + ('A' - 'a'); - } else { - result += input[i]; - } - cap_next_letter = false; - } else if ('A' <= input[i] && input[i] <= 'Z') { - // Capital letters are left as-is. - result += input[i]; - cap_next_letter = false; - } else if ('0' <= input[i] && input[i] <= '9') { - result += input[i]; - cap_next_letter = true; - } else { - cap_next_letter = true; - } - } - return result; -} - -// Returns whether the provided descriptor has an extension. This includes its -// nested types. -bool HasExtension(const Descriptor* descriptor) { - if (descriptor->extension_count() > 0) { - return true; - } - for (int i = 0; i < descriptor->nested_type_count(); ++i) { - if (HasExtension(descriptor->nested_type(i))) { - return true; - } - } - return false; -} - -} // namespace - -const char kThickSeparator[] = - "// ===================================================================\n"; -const char kThinSeparator[] = - "// -------------------------------------------------------------------\n"; - -string ClassName(const Descriptor* descriptor, bool qualified) { - - // Find "outer", the descriptor of the top-level message in which - // "descriptor" is embedded. - const Descriptor* outer = descriptor; - while (outer->containing_type() != NULL) outer = outer->containing_type(); - - const string& outer_name = outer->full_name(); - string inner_name = descriptor->full_name().substr(outer_name.size()); - - if (qualified) { - return "::" + DotsToColons(outer_name) + DotsToUnderscores(inner_name); - } else { - return outer->name() + DotsToUnderscores(inner_name); - } -} - -string ClassName(const EnumDescriptor* enum_descriptor, bool qualified) { - if (enum_descriptor->containing_type() == NULL) { - if (qualified) { - return "::" + DotsToColons(enum_descriptor->full_name()); - } else { - return enum_descriptor->name(); - } - } else { - string result = ClassName(enum_descriptor->containing_type(), qualified); - result += '_'; - result += enum_descriptor->name(); - return result; - } -} - - -string SuperClassName(const Descriptor* descriptor) { - return HasDescriptorMethods(descriptor->file()) ? - "::google::protobuf::Message" : "::google::protobuf::MessageLite"; -} - -string FieldName(const FieldDescriptor* field) { - string result = field->name(); - LowerString(&result); - if (kKeywords.count(result) > 0) { - result.append("_"); - } - return result; -} - -string FieldConstantName(const FieldDescriptor *field) { - string field_name = UnderscoresToCamelCase(field->name(), true); - string result = "k" + field_name + "FieldNumber"; - - if (!field->is_extension() && - field->containing_type()->FindFieldByCamelcaseName( - field->camelcase_name()) != field) { - // This field's camelcase name is not unique. As a hack, add the field - // number to the constant name. This makes the constant rather useless, - // but what can we do? - result += "_" + SimpleItoa(field->number()); - } - - return result; -} - -string FieldMessageTypeName(const FieldDescriptor* field) { - // Note: The Google-internal version of Protocol Buffers uses this function - // as a hook point for hacks to support legacy code. - return ClassName(field->message_type(), true); -} - -string StripProto(const string& filename) { - if (HasSuffixString(filename, ".protodevel")) { - return StripSuffixString(filename, ".protodevel"); - } else { - return StripSuffixString(filename, ".proto"); - } -} - -const char* PrimitiveTypeName(FieldDescriptor::CppType type) { - switch (type) { - case FieldDescriptor::CPPTYPE_INT32 : return "::google::protobuf::int32"; - case FieldDescriptor::CPPTYPE_INT64 : return "::google::protobuf::int64"; - case FieldDescriptor::CPPTYPE_UINT32 : return "::google::protobuf::uint32"; - case FieldDescriptor::CPPTYPE_UINT64 : return "::google::protobuf::uint64"; - case FieldDescriptor::CPPTYPE_DOUBLE : return "double"; - case FieldDescriptor::CPPTYPE_FLOAT : return "float"; - case FieldDescriptor::CPPTYPE_BOOL : return "bool"; - case FieldDescriptor::CPPTYPE_ENUM : return "int"; - case FieldDescriptor::CPPTYPE_STRING : return "::std::string"; - case FieldDescriptor::CPPTYPE_MESSAGE: return NULL; - - // No default because we want the compiler to complain if any new - // CppTypes are added. - } - - GOOGLE_LOG(FATAL) << "Can't get here."; - return NULL; -} - -const char* DeclaredTypeMethodName(FieldDescriptor::Type type) { - switch (type) { - case FieldDescriptor::TYPE_INT32 : return "Int32"; - case FieldDescriptor::TYPE_INT64 : return "Int64"; - case FieldDescriptor::TYPE_UINT32 : return "UInt32"; - case FieldDescriptor::TYPE_UINT64 : return "UInt64"; - case FieldDescriptor::TYPE_SINT32 : return "SInt32"; - case FieldDescriptor::TYPE_SINT64 : return "SInt64"; - case FieldDescriptor::TYPE_FIXED32 : return "Fixed32"; - case FieldDescriptor::TYPE_FIXED64 : return "Fixed64"; - case FieldDescriptor::TYPE_SFIXED32: return "SFixed32"; - case FieldDescriptor::TYPE_SFIXED64: return "SFixed64"; - case FieldDescriptor::TYPE_FLOAT : return "Float"; - case FieldDescriptor::TYPE_DOUBLE : return "Double"; - - case FieldDescriptor::TYPE_BOOL : return "Bool"; - case FieldDescriptor::TYPE_ENUM : return "Enum"; - - case FieldDescriptor::TYPE_STRING : return "String"; - case FieldDescriptor::TYPE_BYTES : return "Bytes"; - case FieldDescriptor::TYPE_GROUP : return "Group"; - case FieldDescriptor::TYPE_MESSAGE : return "Message"; - - // No default because we want the compiler to complain if any new - // types are added. - } - GOOGLE_LOG(FATAL) << "Can't get here."; - return ""; -} - -string DefaultValue(const FieldDescriptor* field) { - switch (field->cpp_type()) { - case FieldDescriptor::CPPTYPE_INT32: - // gcc rejects the decimal form of kint32min and kint64min. - if (field->default_value_int32() == kint32min) { - // Make sure we are in a 2's complement system. - GOOGLE_COMPILE_ASSERT(kint32min == -0x80000000, kint32min_value_error); - return "-0x80000000"; - } - return SimpleItoa(field->default_value_int32()); - case FieldDescriptor::CPPTYPE_UINT32: - return SimpleItoa(field->default_value_uint32()) + "u"; - case FieldDescriptor::CPPTYPE_INT64: - // See the comments for CPPTYPE_INT32. - if (field->default_value_int64() == kint64min) { - // Make sure we are in a 2's complement system. - GOOGLE_COMPILE_ASSERT(kint64min == GOOGLE_LONGLONG(-0x8000000000000000), - kint64min_value_error); - return "GOOGLE_LONGLONG(-0x8000000000000000)"; - } - return "GOOGLE_LONGLONG(" + SimpleItoa(field->default_value_int64()) + ")"; - case FieldDescriptor::CPPTYPE_UINT64: - return "GOOGLE_ULONGLONG(" + SimpleItoa(field->default_value_uint64())+ ")"; - case FieldDescriptor::CPPTYPE_DOUBLE: { - double value = field->default_value_double(); - if (value == numeric_limits::infinity()) { - return "::google::protobuf::internal::Infinity()"; - } else if (value == -numeric_limits::infinity()) { - return "-::google::protobuf::internal::Infinity()"; - } else if (value != value) { - return "::google::protobuf::internal::NaN()"; - } else { - return SimpleDtoa(value); - } - } - case FieldDescriptor::CPPTYPE_FLOAT: - { - float value = field->default_value_float(); - if (value == numeric_limits::infinity()) { - return "static_cast(::google::protobuf::internal::Infinity())"; - } else if (value == -numeric_limits::infinity()) { - return "static_cast(-::google::protobuf::internal::Infinity())"; - } else if (value != value) { - return "static_cast(::google::protobuf::internal::NaN())"; - } else { - string float_value = SimpleFtoa(value); - // If floating point value contains a period (.) or an exponent - // (either E or e), then append suffix 'f' to make it a float - // literal. - if (float_value.find_first_of(".eE") != string::npos) { - float_value.push_back('f'); - } - return float_value; - } - } - case FieldDescriptor::CPPTYPE_BOOL: - return field->default_value_bool() ? "true" : "false"; - case FieldDescriptor::CPPTYPE_ENUM: - // Lazy: Generate a static_cast because we don't have a helper function - // that constructs the full name of an enum value. - return strings::Substitute( - "static_cast< $0 >($1)", - ClassName(field->enum_type(), true), - field->default_value_enum()->number()); - case FieldDescriptor::CPPTYPE_STRING: - return "\"" + EscapeTrigraphs( - CEscape(field->default_value_string())) + - "\""; - case FieldDescriptor::CPPTYPE_MESSAGE: - return FieldMessageTypeName(field) + "::default_instance()"; - } - // Can't actually get here; make compiler happy. (We could add a default - // case above but then we wouldn't get the nice compiler warning when a - // new type is added.) - GOOGLE_LOG(FATAL) << "Can't get here."; - return ""; -} - -// Convert a file name into a valid identifier. -string FilenameIdentifier(const string& filename) { - string result; - for (int i = 0; i < filename.size(); i++) { - if (ascii_isalnum(filename[i])) { - result.push_back(filename[i]); - } else { - // Not alphanumeric. To avoid any possibility of name conflicts we - // use the hex code for the character. - result.push_back('_'); - char buffer[kFastToBufferSize]; - result.append(FastHexToBuffer(static_cast(filename[i]), buffer)); - } - } - return result; -} - -// Return the name of the AddDescriptors() function for a given file. -string GlobalAddDescriptorsName(const string& filename) { - return "protobuf_AddDesc_" + FilenameIdentifier(filename); -} - -// Return the name of the AssignDescriptors() function for a given file. -string GlobalAssignDescriptorsName(const string& filename) { - return "protobuf_AssignDesc_" + FilenameIdentifier(filename); -} - -// Return the name of the ShutdownFile() function for a given file. -string GlobalShutdownFileName(const string& filename) { - return "protobuf_ShutdownFile_" + FilenameIdentifier(filename); -} - -// Escape C++ trigraphs by escaping question marks to \? -string EscapeTrigraphs(const string& to_escape) { - return StringReplace(to_escape, "?", "\\?", true); -} - -bool StaticInitializersForced(const FileDescriptor* file) { - if (HasDescriptorMethods(file) || file->extension_count() > 0) { - return true; - } - for (int i = 0; i < file->message_type_count(); ++i) { - if (HasExtension(file->message_type(i))) { - return true; - } - } - return false; -} - -void PrintHandlingOptionalStaticInitializers( - const FileDescriptor* file, io::Printer* printer, - const char* with_static_init, const char* without_static_init, - const char* var1, const string& val1, - const char* var2, const string& val2) { - map vars; - if (var1) { - vars[var1] = val1; - } - if (var2) { - vars[var2] = val2; - } - PrintHandlingOptionalStaticInitializers( - vars, file, printer, with_static_init, without_static_init); -} - -void PrintHandlingOptionalStaticInitializers( - const map& vars, const FileDescriptor* file, - io::Printer* printer, const char* with_static_init, - const char* without_static_init) { - if (StaticInitializersForced(file)) { - printer->Print(vars, with_static_init); - } else { - printer->Print(vars, (string( - "#ifdef GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER\n") + - without_static_init + - "#else\n" + - with_static_init + - "#endif\n").c_str()); - } -} - - -static bool HasEnumDefinitions(const Descriptor* message_type) { - if (message_type->enum_type_count() > 0) return true; - for (int i = 0; i < message_type->nested_type_count(); ++i) { - if (HasEnumDefinitions(message_type->nested_type(i))) return true; - } - return false; -} - -bool HasEnumDefinitions(const FileDescriptor* file) { - if (file->enum_type_count() > 0) return true; - for (int i = 0; i < file->message_type_count(); ++i) { - if (HasEnumDefinitions(file->message_type(i))) return true; - } - return false; -} - -} // namespace cpp -} // namespace compiler -} // namespace protobuf -} // namespace google diff --git a/modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/cpp/cpp_helpers.h b/modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/cpp/cpp_helpers.h deleted file mode 100644 index 526e19cc7..000000000 --- a/modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/cpp/cpp_helpers.h +++ /dev/null @@ -1,186 +0,0 @@ -// Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// http://code.google.com/p/protobuf/ -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -// Author: kenton@google.com (Kenton Varda) -// Based on original Protocol Buffers design by -// Sanjay Ghemawat, Jeff Dean, and others. - -#ifndef GOOGLE_PROTOBUF_COMPILER_CPP_HELPERS_H__ -#define GOOGLE_PROTOBUF_COMPILER_CPP_HELPERS_H__ - -#include -#include -#include -#include - -namespace google { -namespace protobuf { - -namespace io { -class Printer; -} - -namespace compiler { -namespace cpp { - -// Commonly-used separator comments. Thick is a line of '=', thin is a line -// of '-'. -extern const char kThickSeparator[]; -extern const char kThinSeparator[]; - -// Returns the non-nested type name for the given type. If "qualified" is -// true, prefix the type with the full namespace. For example, if you had: -// package foo.bar; -// message Baz { message Qux {} } -// Then the qualified ClassName for Qux would be: -// ::foo::bar::Baz_Qux -// While the non-qualified version would be: -// Baz_Qux -string ClassName(const Descriptor* descriptor, bool qualified); -string ClassName(const EnumDescriptor* enum_descriptor, bool qualified); - -string SuperClassName(const Descriptor* descriptor); - -// Get the (unqualified) name that should be used for this field in C++ code. -// The name is coerced to lower-case to emulate proto1 behavior. People -// should be using lowercase-with-underscores style for proto field names -// anyway, so normally this just returns field->name(). -string FieldName(const FieldDescriptor* field); - -// Get the unqualified name that should be used for a field's field -// number constant. -string FieldConstantName(const FieldDescriptor *field); - -// Returns the scope where the field was defined (for extensions, this is -// different from the message type to which the field applies). -inline const Descriptor* FieldScope(const FieldDescriptor* field) { - return field->is_extension() ? - field->extension_scope() : field->containing_type(); -} - -// Returns the fully-qualified type name field->message_type(). Usually this -// is just ClassName(field->message_type(), true); -string FieldMessageTypeName(const FieldDescriptor* field); - -// Strips ".proto" or ".protodevel" from the end of a filename. -string StripProto(const string& filename); - -// Get the C++ type name for a primitive type (e.g. "double", "::google::protobuf::int32", etc.). -// Note: non-built-in type names will be qualified, meaning they will start -// with a ::. If you are using the type as a template parameter, you will -// need to insure there is a space between the < and the ::, because the -// ridiculous C++ standard defines "<:" to be a synonym for "[". -const char* PrimitiveTypeName(FieldDescriptor::CppType type); - -// Get the declared type name in CamelCase format, as is used e.g. for the -// methods of WireFormat. For example, TYPE_INT32 becomes "Int32". -const char* DeclaredTypeMethodName(FieldDescriptor::Type type); - -// Get code that evaluates to the field's default value. -string DefaultValue(const FieldDescriptor* field); - -// Convert a file name into a valid identifier. -string FilenameIdentifier(const string& filename); - -// Return the name of the AddDescriptors() function for a given file. -string GlobalAddDescriptorsName(const string& filename); - -// Return the name of the AssignDescriptors() function for a given file. -string GlobalAssignDescriptorsName(const string& filename); - -// Return the name of the ShutdownFile() function for a given file. -string GlobalShutdownFileName(const string& filename); - -// Escape C++ trigraphs by escaping question marks to \? -string EscapeTrigraphs(const string& to_escape); - -// Do message classes in this file keep track of unknown fields? -inline bool HasUnknownFields(const FileDescriptor* file) { - return file->options().optimize_for() != FileOptions::LITE_RUNTIME; -} - - -// Does this file have any enum type definitions? -bool HasEnumDefinitions(const FileDescriptor* file); - -// Does this file have generated parsing, serialization, and other -// standard methods for which reflection-based fallback implementations exist? -inline bool HasGeneratedMethods(const FileDescriptor* file) { - return file->options().optimize_for() != FileOptions::CODE_SIZE; -} - -// Do message classes in this file have descriptor and reflection methods? -inline bool HasDescriptorMethods(const FileDescriptor* file) { - return file->options().optimize_for() != FileOptions::LITE_RUNTIME; -} - -// Should we generate generic services for this file? -inline bool HasGenericServices(const FileDescriptor* file) { - return file->service_count() > 0 && - file->options().optimize_for() != FileOptions::LITE_RUNTIME && - file->options().cc_generic_services(); -} - -// Should string fields in this file verify that their contents are UTF-8? -inline bool HasUtf8Verification(const FileDescriptor* file) { - return file->options().optimize_for() != FileOptions::LITE_RUNTIME; -} - -// Should we generate a separate, super-optimized code path for serializing to -// flat arrays? We don't do this in Lite mode because we'd rather reduce code -// size. -inline bool HasFastArraySerialization(const FileDescriptor* file) { - return file->options().optimize_for() == FileOptions::SPEED; -} - -// Returns whether we have to generate code with static initializers. -bool StaticInitializersForced(const FileDescriptor* file); - -// Prints 'with_static_init' if static initializers have to be used for the -// provided file. Otherwise emits both 'with_static_init' and -// 'without_static_init' using #ifdef. -void PrintHandlingOptionalStaticInitializers( - const FileDescriptor* file, io::Printer* printer, - const char* with_static_init, const char* without_static_init, - const char* var1 = NULL, const string& val1 = "", - const char* var2 = NULL, const string& val2 = ""); - -void PrintHandlingOptionalStaticInitializers( - const map& vars, const FileDescriptor* file, - io::Printer* printer, const char* with_static_init, - const char* without_static_init); - - -} // namespace cpp -} // namespace compiler -} // namespace protobuf - -} // namespace google -#endif // GOOGLE_PROTOBUF_COMPILER_CPP_HELPERS_H__ diff --git a/modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/cpp/cpp_message.cc b/modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/cpp/cpp_message.cc deleted file mode 100644 index 1ea4f13d1..000000000 --- a/modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/cpp/cpp_message.cc +++ /dev/null @@ -1,2020 +0,0 @@ -// Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// http://code.google.com/p/protobuf/ -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -// Author: kenton@google.com (Kenton Varda) -// Based on original Protocol Buffers design by -// Sanjay Ghemawat, Jeff Dean, and others. - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - - -namespace google { -namespace protobuf { -namespace compiler { -namespace cpp { - -using internal::WireFormat; -using internal::WireFormatLite; - -namespace { - -void PrintFieldComment(io::Printer* printer, const FieldDescriptor* field) { - // Print the field's proto-syntax definition as a comment. We don't want to - // print group bodies so we cut off after the first line. - string def = field->DebugString(); - printer->Print("// $def$\n", - "def", def.substr(0, def.find_first_of('\n'))); -} - -struct FieldOrderingByNumber { - inline bool operator()(const FieldDescriptor* a, - const FieldDescriptor* b) const { - return a->number() < b->number(); - } -}; - -const char* kWireTypeNames[] = { - "VARINT", - "FIXED64", - "LENGTH_DELIMITED", - "START_GROUP", - "END_GROUP", - "FIXED32", -}; - -// Sort the fields of the given Descriptor by number into a new[]'d array -// and return it. -const FieldDescriptor** SortFieldsByNumber(const Descriptor* descriptor) { - const FieldDescriptor** fields = - new const FieldDescriptor*[descriptor->field_count()]; - for (int i = 0; i < descriptor->field_count(); i++) { - fields[i] = descriptor->field(i); - } - sort(fields, fields + descriptor->field_count(), - FieldOrderingByNumber()); - return fields; -} - -// Functor for sorting extension ranges by their "start" field number. -struct ExtensionRangeSorter { - bool operator()(const Descriptor::ExtensionRange* left, - const Descriptor::ExtensionRange* right) const { - return left->start < right->start; - } -}; - -// Returns true if the "required" restriction check should be ignored for the -// given field. -inline static bool ShouldIgnoreRequiredFieldCheck( - const FieldDescriptor* field) { - return false; -} - -// Returns true if the message type has any required fields. If it doesn't, -// we can optimize out calls to its IsInitialized() method. -// -// already_seen is used to avoid checking the same type multiple times -// (and also to protect against recursion). -static bool HasRequiredFields( - const Descriptor* type, - hash_set* already_seen) { - if (already_seen->count(type) > 0) { - // Since the first occurrence of a required field causes the whole - // function to return true, we can assume that if the type is already - // in the cache it didn't have any required fields. - return false; - } - already_seen->insert(type); - - // If the type has extensions, an extension with message type could contain - // required fields, so we have to be conservative and assume such an - // extension exists. - if (type->extension_range_count() > 0) return true; - - for (int i = 0; i < type->field_count(); i++) { - const FieldDescriptor* field = type->field(i); - if (field->is_required()) { - return true; - } - if (field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE && - !ShouldIgnoreRequiredFieldCheck(field)) { - if (HasRequiredFields(field->message_type(), already_seen)) { - return true; - } - } - } - - return false; -} - -static bool HasRequiredFields(const Descriptor* type) { - hash_set already_seen; - return HasRequiredFields(type, &already_seen); -} - -// This returns an estimate of the compiler's alignment for the field. This -// can't guarantee to be correct because the generated code could be compiled on -// different systems with different alignment rules. The estimates below assume -// 64-bit pointers. -int EstimateAlignmentSize(const FieldDescriptor* field) { - if (field == NULL) return 0; - if (field->is_repeated()) return 8; - switch (field->cpp_type()) { - case FieldDescriptor::CPPTYPE_BOOL: - return 1; - - case FieldDescriptor::CPPTYPE_INT32: - case FieldDescriptor::CPPTYPE_UINT32: - case FieldDescriptor::CPPTYPE_ENUM: - case FieldDescriptor::CPPTYPE_FLOAT: - return 4; - - case FieldDescriptor::CPPTYPE_INT64: - case FieldDescriptor::CPPTYPE_UINT64: - case FieldDescriptor::CPPTYPE_DOUBLE: - case FieldDescriptor::CPPTYPE_STRING: - case FieldDescriptor::CPPTYPE_MESSAGE: - return 8; - } - GOOGLE_LOG(FATAL) << "Can't get here."; - return -1; // Make compiler happy. -} - -// FieldGroup is just a helper for OptimizePadding below. It holds a vector of -// fields that are grouped together because they have compatible alignment, and -// a preferred location in the final field ordering. -class FieldGroup { - public: - FieldGroup() - : preferred_location_(0) {} - - // A group with a single field. - FieldGroup(float preferred_location, const FieldDescriptor* field) - : preferred_location_(preferred_location), - fields_(1, field) {} - - // Append the fields in 'other' to this group. - void Append(const FieldGroup& other) { - if (other.fields_.empty()) { - return; - } - // Preferred location is the average among all the fields, so we weight by - // the number of fields on each FieldGroup object. - preferred_location_ = - (preferred_location_ * fields_.size() + - (other.preferred_location_ * other.fields_.size())) / - (fields_.size() + other.fields_.size()); - fields_.insert(fields_.end(), other.fields_.begin(), other.fields_.end()); - } - - void SetPreferredLocation(float location) { preferred_location_ = location; } - const vector& fields() const { return fields_; } - - // FieldGroup objects sort by their preferred location. - bool operator<(const FieldGroup& other) const { - return preferred_location_ < other.preferred_location_; - } - - private: - // "preferred_location_" is an estimate of where this group should go in the - // final list of fields. We compute this by taking the average index of each - // field in this group in the original ordering of fields. This is very - // approximate, but should put this group close to where its member fields - // originally went. - float preferred_location_; - vector fields_; - // We rely on the default copy constructor and operator= so this type can be - // used in a vector. -}; - -// Reorder 'fields' so that if the fields are output into a c++ class in the new -// order, the alignment padding is minimized. We try to do this while keeping -// each field as close as possible to its original position so that we don't -// reduce cache locality much for function that access each field in order. -void OptimizePadding(vector* fields) { - // First divide fields into those that align to 1 byte, 4 bytes or 8 bytes. - vector aligned_to_1, aligned_to_4, aligned_to_8; - for (int i = 0; i < fields->size(); ++i) { - switch (EstimateAlignmentSize((*fields)[i])) { - case 1: aligned_to_1.push_back(FieldGroup(i, (*fields)[i])); break; - case 4: aligned_to_4.push_back(FieldGroup(i, (*fields)[i])); break; - case 8: aligned_to_8.push_back(FieldGroup(i, (*fields)[i])); break; - default: - GOOGLE_LOG(FATAL) << "Unknown alignment size."; - } - } - - // Now group fields aligned to 1 byte into sets of 4, and treat those like a - // single field aligned to 4 bytes. - for (int i = 0; i < aligned_to_1.size(); i += 4) { - FieldGroup field_group; - for (int j = i; j < aligned_to_1.size() && j < i + 4; ++j) { - field_group.Append(aligned_to_1[j]); - } - aligned_to_4.push_back(field_group); - } - // Sort by preferred location to keep fields as close to their original - // location as possible. - sort(aligned_to_4.begin(), aligned_to_4.end()); - - // Now group fields aligned to 4 bytes (or the 4-field groups created above) - // into pairs, and treat those like a single field aligned to 8 bytes. - for (int i = 0; i < aligned_to_4.size(); i += 2) { - FieldGroup field_group; - for (int j = i; j < aligned_to_4.size() && j < i + 2; ++j) { - field_group.Append(aligned_to_4[j]); - } - if (i == aligned_to_4.size() - 1) { - // Move incomplete 4-byte block to the end. - field_group.SetPreferredLocation(fields->size() + 1); - } - aligned_to_8.push_back(field_group); - } - // Sort by preferred location to keep fields as close to their original - // location as possible. - sort(aligned_to_8.begin(), aligned_to_8.end()); - - // Now pull out all the FieldDescriptors in order. - fields->clear(); - for (int i = 0; i < aligned_to_8.size(); ++i) { - fields->insert(fields->end(), - aligned_to_8[i].fields().begin(), - aligned_to_8[i].fields().end()); - } -} - -} - -// =================================================================== - -MessageGenerator::MessageGenerator(const Descriptor* descriptor, - const Options& options) - : descriptor_(descriptor), - classname_(ClassName(descriptor, false)), - options_(options), - field_generators_(descriptor, options), - nested_generators_(new scoped_ptr[ - descriptor->nested_type_count()]), - enum_generators_(new scoped_ptr[ - descriptor->enum_type_count()]), - extension_generators_(new scoped_ptr[ - descriptor->extension_count()]) { - - for (int i = 0; i < descriptor->nested_type_count(); i++) { - nested_generators_[i].reset( - new MessageGenerator(descriptor->nested_type(i), options)); - } - - for (int i = 0; i < descriptor->enum_type_count(); i++) { - enum_generators_[i].reset( - new EnumGenerator(descriptor->enum_type(i), options)); - } - - for (int i = 0; i < descriptor->extension_count(); i++) { - extension_generators_[i].reset( - new ExtensionGenerator(descriptor->extension(i), options)); - } -} - -MessageGenerator::~MessageGenerator() {} - -void MessageGenerator:: -GenerateForwardDeclaration(io::Printer* printer) { - printer->Print("class $classname$;\n", - "classname", classname_); - - for (int i = 0; i < descriptor_->nested_type_count(); i++) { - nested_generators_[i]->GenerateForwardDeclaration(printer); - } -} - -void MessageGenerator:: -GenerateEnumDefinitions(io::Printer* printer) { - for (int i = 0; i < descriptor_->nested_type_count(); i++) { - nested_generators_[i]->GenerateEnumDefinitions(printer); - } - - for (int i = 0; i < descriptor_->enum_type_count(); i++) { - enum_generators_[i]->GenerateDefinition(printer); - } -} - -void MessageGenerator:: -GenerateGetEnumDescriptorSpecializations(io::Printer* printer) { - for (int i = 0; i < descriptor_->nested_type_count(); i++) { - nested_generators_[i]->GenerateGetEnumDescriptorSpecializations(printer); - } - for (int i = 0; i < descriptor_->enum_type_count(); i++) { - enum_generators_[i]->GenerateGetEnumDescriptorSpecializations(printer); - } -} - -void MessageGenerator:: -GenerateFieldAccessorDeclarations(io::Printer* printer) { - for (int i = 0; i < descriptor_->field_count(); i++) { - const FieldDescriptor* field = descriptor_->field(i); - - PrintFieldComment(printer, field); - - map vars; - SetCommonFieldVariables(field, &vars, options_); - vars["constant_name"] = FieldConstantName(field); - - if (field->is_repeated()) { - printer->Print(vars, "inline int $name$_size() const$deprecation$;\n"); - } else { - printer->Print(vars, "inline bool has_$name$() const$deprecation$;\n"); - } - - printer->Print(vars, "inline void clear_$name$()$deprecation$;\n"); - printer->Print(vars, "static const int $constant_name$ = $number$;\n"); - - // Generate type-specific accessor declarations. - field_generators_.get(field).GenerateAccessorDeclarations(printer); - - printer->Print("\n"); - } - - if (descriptor_->extension_range_count() > 0) { - // Generate accessors for extensions. We just call a macro located in - // extension_set.h since the accessors about 80 lines of static code. - printer->Print( - "GOOGLE_PROTOBUF_EXTENSION_ACCESSORS($classname$)\n", - "classname", classname_); - } -} - -void MessageGenerator:: -GenerateFieldAccessorDefinitions(io::Printer* printer) { - printer->Print("// $classname$\n\n", "classname", classname_); - - for (int i = 0; i < descriptor_->field_count(); i++) { - const FieldDescriptor* field = descriptor_->field(i); - - PrintFieldComment(printer, field); - - map vars; - SetCommonFieldVariables(field, &vars, options_); - - // Generate has_$name$() or $name$_size(). - if (field->is_repeated()) { - printer->Print(vars, - "inline int $classname$::$name$_size() const {\n" - " return $name$_.size();\n" - "}\n"); - } else { - // Singular field. - char buffer[kFastToBufferSize]; - vars["has_array_index"] = SimpleItoa(field->index() / 32); - vars["has_mask"] = FastHex32ToBuffer(1u << (field->index() % 32), buffer); - printer->Print(vars, - "inline bool $classname$::has_$name$() const {\n" - " return (_has_bits_[$has_array_index$] & 0x$has_mask$u) != 0;\n" - "}\n" - "inline void $classname$::set_has_$name$() {\n" - " _has_bits_[$has_array_index$] |= 0x$has_mask$u;\n" - "}\n" - "inline void $classname$::clear_has_$name$() {\n" - " _has_bits_[$has_array_index$] &= ~0x$has_mask$u;\n" - "}\n" - ); - } - - // Generate clear_$name$() - printer->Print(vars, - "inline void $classname$::clear_$name$() {\n"); - - printer->Indent(); - field_generators_.get(field).GenerateClearingCode(printer); - printer->Outdent(); - - if (!field->is_repeated()) { - printer->Print(vars, - " clear_has_$name$();\n"); - } - - printer->Print("}\n"); - - // Generate type-specific accessors. - field_generators_.get(field).GenerateInlineAccessorDefinitions(printer); - - printer->Print("\n"); - } -} - -void MessageGenerator:: -GenerateClassDefinition(io::Printer* printer) { - for (int i = 0; i < descriptor_->nested_type_count(); i++) { - nested_generators_[i]->GenerateClassDefinition(printer); - printer->Print("\n"); - printer->Print(kThinSeparator); - printer->Print("\n"); - } - - map vars; - vars["classname"] = classname_; - vars["field_count"] = SimpleItoa(descriptor_->field_count()); - if (options_.dllexport_decl.empty()) { - vars["dllexport"] = ""; - } else { - vars["dllexport"] = options_.dllexport_decl + " "; - } - vars["superclass"] = SuperClassName(descriptor_); - - printer->Print(vars, - "class $dllexport$$classname$ : public $superclass$ {\n" - " public:\n"); - printer->Indent(); - - printer->Print(vars, - "$classname$();\n" - "virtual ~$classname$();\n" - "\n" - "$classname$(const $classname$& from);\n" - "\n" - "inline $classname$& operator=(const $classname$& from) {\n" - " CopyFrom(from);\n" - " return *this;\n" - "}\n" - "\n"); - - if (HasUnknownFields(descriptor_->file())) { - printer->Print( - "inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const {\n" - " return _unknown_fields_;\n" - "}\n" - "\n" - "inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() {\n" - " return &_unknown_fields_;\n" - "}\n" - "\n"); - } - - // Only generate this member if it's not disabled. - if (HasDescriptorMethods(descriptor_->file()) && - !descriptor_->options().no_standard_descriptor_accessor()) { - printer->Print(vars, - "static const ::google::protobuf::Descriptor* descriptor();\n"); - } - - printer->Print(vars, - "static const $classname$& default_instance();\n" - "\n"); - - if (!StaticInitializersForced(descriptor_->file())) { - printer->Print(vars, - "#ifdef GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER\n" - "// Returns the internal default instance pointer. This function can\n" - "// return NULL thus should not be used by the user. This is intended\n" - "// for Protobuf internal code. Please use default_instance() declared\n" - "// above instead.\n" - "static inline const $classname$* internal_default_instance() {\n" - " return default_instance_;\n" - "}\n" - "#endif\n" - "\n"); - } - - - printer->Print(vars, - "void Swap($classname$* other);\n" - "\n" - "// implements Message ----------------------------------------------\n" - "\n" - "$classname$* New() const;\n"); - - if (HasGeneratedMethods(descriptor_->file())) { - if (HasDescriptorMethods(descriptor_->file())) { - printer->Print(vars, - "void CopyFrom(const ::google::protobuf::Message& from);\n" - "void MergeFrom(const ::google::protobuf::Message& from);\n"); - } else { - printer->Print(vars, - "void CheckTypeAndMergeFrom(const ::google::protobuf::MessageLite& from);\n"); - } - - printer->Print(vars, - "void CopyFrom(const $classname$& from);\n" - "void MergeFrom(const $classname$& from);\n" - "void Clear();\n" - "bool IsInitialized() const;\n" - "\n" - "int ByteSize() const;\n" - "bool MergePartialFromCodedStream(\n" - " ::google::protobuf::io::CodedInputStream* input);\n" - "void SerializeWithCachedSizes(\n" - " ::google::protobuf::io::CodedOutputStream* output) const;\n"); - if (HasFastArraySerialization(descriptor_->file())) { - printer->Print( - "::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const;\n"); - } - } - - printer->Print(vars, - "int GetCachedSize() const { return _cached_size_; }\n" - "private:\n" - "void SharedCtor();\n" - "void SharedDtor();\n" - "void SetCachedSize(int size) const;\n" - "public:\n" - "\n"); - - if (HasDescriptorMethods(descriptor_->file())) { - printer->Print( - "::google::protobuf::Metadata GetMetadata() const;\n" - "\n"); - } else { - printer->Print( - "::std::string GetTypeName() const;\n" - "\n"); - } - - printer->Print( - "// nested types ----------------------------------------------------\n" - "\n"); - - // Import all nested message classes into this class's scope with typedefs. - for (int i = 0; i < descriptor_->nested_type_count(); i++) { - const Descriptor* nested_type = descriptor_->nested_type(i); - printer->Print("typedef $nested_full_name$ $nested_name$;\n", - "nested_name", nested_type->name(), - "nested_full_name", ClassName(nested_type, false)); - } - - if (descriptor_->nested_type_count() > 0) { - printer->Print("\n"); - } - - // Import all nested enums and their values into this class's scope with - // typedefs and constants. - for (int i = 0; i < descriptor_->enum_type_count(); i++) { - enum_generators_[i]->GenerateSymbolImports(printer); - printer->Print("\n"); - } - - printer->Print( - "// accessors -------------------------------------------------------\n" - "\n"); - - // Generate accessor methods for all fields. - GenerateFieldAccessorDeclarations(printer); - - // Declare extension identifiers. - for (int i = 0; i < descriptor_->extension_count(); i++) { - extension_generators_[i]->GenerateDeclaration(printer); - } - - - printer->Print( - "// @@protoc_insertion_point(class_scope:$full_name$)\n", - "full_name", descriptor_->full_name()); - - // Generate private members. - printer->Outdent(); - printer->Print(" private:\n"); - printer->Indent(); - - - for (int i = 0; i < descriptor_->field_count(); i++) { - if (!descriptor_->field(i)->is_repeated()) { - printer->Print( - "inline void set_has_$name$();\n", - "name", FieldName(descriptor_->field(i))); - printer->Print( - "inline void clear_has_$name$();\n", - "name", FieldName(descriptor_->field(i))); - } - } - printer->Print("\n"); - - // To minimize padding, data members are divided into three sections: - // (1) members assumed to align to 8 bytes - // (2) members corresponding to message fields, re-ordered to optimize - // alignment. - // (3) members assumed to align to 4 bytes. - - // Members assumed to align to 8 bytes: - - if (descriptor_->extension_range_count() > 0) { - printer->Print( - "::google::protobuf::internal::ExtensionSet _extensions_;\n" - "\n"); - } - - if (HasUnknownFields(descriptor_->file())) { - printer->Print( - "::google::protobuf::UnknownFieldSet _unknown_fields_;\n" - "\n"); - } - - // Field members: - - vector fields; - for (int i = 0; i < descriptor_->field_count(); i++) { - fields.push_back(descriptor_->field(i)); - } - OptimizePadding(&fields); - for (int i = 0; i < fields.size(); ++i) { - field_generators_.get(fields[i]).GeneratePrivateMembers(printer); - } - - // Members assumed to align to 4 bytes: - - // TODO(kenton): Make _cached_size_ an atomic when C++ supports it. - printer->Print( - "\n" - "mutable int _cached_size_;\n"); - - // Generate _has_bits_. - if (descriptor_->field_count() > 0) { - printer->Print(vars, - "::google::protobuf::uint32 _has_bits_[($field_count$ + 31) / 32];\n" - "\n"); - } else { - // Zero-size arrays aren't technically allowed, and MSVC in particular - // doesn't like them. We still need to declare these arrays to make - // other code compile. Since this is an uncommon case, we'll just declare - // them with size 1 and waste some space. Oh well. - printer->Print( - "::google::protobuf::uint32 _has_bits_[1];\n" - "\n"); - } - - // Declare AddDescriptors(), BuildDescriptors(), and ShutdownFile() as - // friends so that they can access private static variables like - // default_instance_ and reflection_. - PrintHandlingOptionalStaticInitializers( - descriptor_->file(), printer, - // With static initializers. - "friend void $dllexport_decl$ $adddescriptorsname$();\n", - // Without. - "friend void $dllexport_decl$ $adddescriptorsname$_impl();\n", - // Vars. - "dllexport_decl", options_.dllexport_decl, - "adddescriptorsname", - GlobalAddDescriptorsName(descriptor_->file()->name())); - - printer->Print( - "friend void $assigndescriptorsname$();\n" - "friend void $shutdownfilename$();\n" - "\n", - "assigndescriptorsname", - GlobalAssignDescriptorsName(descriptor_->file()->name()), - "shutdownfilename", GlobalShutdownFileName(descriptor_->file()->name())); - - printer->Print( - "void InitAsDefaultInstance();\n" - "static $classname$* default_instance_;\n", - "classname", classname_); - - printer->Outdent(); - printer->Print(vars, "};"); -} - -void MessageGenerator:: -GenerateInlineMethods(io::Printer* printer) { - for (int i = 0; i < descriptor_->nested_type_count(); i++) { - nested_generators_[i]->GenerateInlineMethods(printer); - printer->Print(kThinSeparator); - printer->Print("\n"); - } - - GenerateFieldAccessorDefinitions(printer); -} - -void MessageGenerator:: -GenerateDescriptorDeclarations(io::Printer* printer) { - printer->Print( - "const ::google::protobuf::Descriptor* $name$_descriptor_ = NULL;\n" - "const ::google::protobuf::internal::GeneratedMessageReflection*\n" - " $name$_reflection_ = NULL;\n", - "name", classname_); - - for (int i = 0; i < descriptor_->nested_type_count(); i++) { - nested_generators_[i]->GenerateDescriptorDeclarations(printer); - } - - for (int i = 0; i < descriptor_->enum_type_count(); i++) { - printer->Print( - "const ::google::protobuf::EnumDescriptor* $name$_descriptor_ = NULL;\n", - "name", ClassName(descriptor_->enum_type(i), false)); - } -} - -void MessageGenerator:: -GenerateDescriptorInitializer(io::Printer* printer, int index) { - // TODO(kenton): Passing the index to this method is redundant; just use - // descriptor_->index() instead. - map vars; - vars["classname"] = classname_; - vars["index"] = SimpleItoa(index); - - // Obtain the descriptor from the parent's descriptor. - if (descriptor_->containing_type() == NULL) { - printer->Print(vars, - "$classname$_descriptor_ = file->message_type($index$);\n"); - } else { - vars["parent"] = ClassName(descriptor_->containing_type(), false); - printer->Print(vars, - "$classname$_descriptor_ = " - "$parent$_descriptor_->nested_type($index$);\n"); - } - - // Generate the offsets. - GenerateOffsets(printer); - - // Construct the reflection object. - printer->Print(vars, - "$classname$_reflection_ =\n" - " new ::google::protobuf::internal::GeneratedMessageReflection(\n" - " $classname$_descriptor_,\n" - " $classname$::default_instance_,\n" - " $classname$_offsets_,\n" - " GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET($classname$, _has_bits_[0]),\n" - " GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(" - "$classname$, _unknown_fields_),\n"); - if (descriptor_->extension_range_count() > 0) { - printer->Print(vars, - " GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(" - "$classname$, _extensions_),\n"); - } else { - // No extensions. - printer->Print(vars, - " -1,\n"); - } - printer->Print( - " ::google::protobuf::DescriptorPool::generated_pool(),\n"); - printer->Print(vars, - " ::google::protobuf::MessageFactory::generated_factory(),\n"); - printer->Print(vars, - " sizeof($classname$));\n"); - - // Handle nested types. - for (int i = 0; i < descriptor_->nested_type_count(); i++) { - nested_generators_[i]->GenerateDescriptorInitializer(printer, i); - } - - for (int i = 0; i < descriptor_->enum_type_count(); i++) { - enum_generators_[i]->GenerateDescriptorInitializer(printer, i); - } -} - -void MessageGenerator:: -GenerateTypeRegistrations(io::Printer* printer) { - // Register this message type with the message factory. - printer->Print( - "::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(\n" - " $classname$_descriptor_, &$classname$::default_instance());\n", - "classname", classname_); - - // Handle nested types. - for (int i = 0; i < descriptor_->nested_type_count(); i++) { - nested_generators_[i]->GenerateTypeRegistrations(printer); - } -} - -void MessageGenerator:: -GenerateDefaultInstanceAllocator(io::Printer* printer) { - // Construct the default instances of all fields, as they will be used - // when creating the default instance of the entire message. - for (int i = 0; i < descriptor_->field_count(); i++) { - field_generators_.get(descriptor_->field(i)) - .GenerateDefaultInstanceAllocator(printer); - } - - // Construct the default instance. We can't call InitAsDefaultInstance() yet - // because we need to make sure all default instances that this one might - // depend on are constructed first. - printer->Print( - "$classname$::default_instance_ = new $classname$();\n", - "classname", classname_); - - // Handle nested types. - for (int i = 0; i < descriptor_->nested_type_count(); i++) { - nested_generators_[i]->GenerateDefaultInstanceAllocator(printer); - } - -} - -void MessageGenerator:: -GenerateDefaultInstanceInitializer(io::Printer* printer) { - printer->Print( - "$classname$::default_instance_->InitAsDefaultInstance();\n", - "classname", classname_); - - // Register extensions. - for (int i = 0; i < descriptor_->extension_count(); i++) { - extension_generators_[i]->GenerateRegistration(printer); - } - - // Handle nested types. - for (int i = 0; i < descriptor_->nested_type_count(); i++) { - nested_generators_[i]->GenerateDefaultInstanceInitializer(printer); - } -} - -void MessageGenerator:: -GenerateShutdownCode(io::Printer* printer) { - printer->Print( - "delete $classname$::default_instance_;\n", - "classname", classname_); - - if (HasDescriptorMethods(descriptor_->file())) { - printer->Print( - "delete $classname$_reflection_;\n", - "classname", classname_); - } - - // Handle default instances of fields. - for (int i = 0; i < descriptor_->field_count(); i++) { - field_generators_.get(descriptor_->field(i)) - .GenerateShutdownCode(printer); - } - - // Handle nested types. - for (int i = 0; i < descriptor_->nested_type_count(); i++) { - nested_generators_[i]->GenerateShutdownCode(printer); - } -} - -void MessageGenerator:: -GenerateClassMethods(io::Printer* printer) { - for (int i = 0; i < descriptor_->enum_type_count(); i++) { - enum_generators_[i]->GenerateMethods(printer); - } - - for (int i = 0; i < descriptor_->nested_type_count(); i++) { - nested_generators_[i]->GenerateClassMethods(printer); - printer->Print("\n"); - printer->Print(kThinSeparator); - printer->Print("\n"); - } - - // Generate non-inline field definitions. - for (int i = 0; i < descriptor_->field_count(); i++) { - field_generators_.get(descriptor_->field(i)) - .GenerateNonInlineAccessorDefinitions(printer); - } - - // Generate field number constants. - printer->Print("#ifndef _MSC_VER\n"); - for (int i = 0; i < descriptor_->field_count(); i++) { - const FieldDescriptor *field = descriptor_->field(i); - printer->Print( - "const int $classname$::$constant_name$;\n", - "classname", ClassName(FieldScope(field), false), - "constant_name", FieldConstantName(field)); - } - printer->Print( - "#endif // !_MSC_VER\n" - "\n"); - - // Define extension identifiers. - for (int i = 0; i < descriptor_->extension_count(); i++) { - extension_generators_[i]->GenerateDefinition(printer); - } - - GenerateStructors(printer); - printer->Print("\n"); - - if (HasGeneratedMethods(descriptor_->file())) { - GenerateClear(printer); - printer->Print("\n"); - - GenerateMergeFromCodedStream(printer); - printer->Print("\n"); - - GenerateSerializeWithCachedSizes(printer); - printer->Print("\n"); - - if (HasFastArraySerialization(descriptor_->file())) { - GenerateSerializeWithCachedSizesToArray(printer); - printer->Print("\n"); - } - - GenerateByteSize(printer); - printer->Print("\n"); - - GenerateMergeFrom(printer); - printer->Print("\n"); - - GenerateCopyFrom(printer); - printer->Print("\n"); - - GenerateIsInitialized(printer); - printer->Print("\n"); - } - - GenerateSwap(printer); - printer->Print("\n"); - - if (HasDescriptorMethods(descriptor_->file())) { - printer->Print( - "::google::protobuf::Metadata $classname$::GetMetadata() const {\n" - " protobuf_AssignDescriptorsOnce();\n" - " ::google::protobuf::Metadata metadata;\n" - " metadata.descriptor = $classname$_descriptor_;\n" - " metadata.reflection = $classname$_reflection_;\n" - " return metadata;\n" - "}\n" - "\n", - "classname", classname_); - } else { - printer->Print( - "::std::string $classname$::GetTypeName() const {\n" - " return \"$type_name$\";\n" - "}\n" - "\n", - "classname", classname_, - "type_name", descriptor_->full_name()); - } - -} - -void MessageGenerator:: -GenerateOffsets(io::Printer* printer) { - printer->Print( - "static const int $classname$_offsets_[$field_count$] = {\n", - "classname", classname_, - "field_count", SimpleItoa(max(1, descriptor_->field_count()))); - printer->Indent(); - - for (int i = 0; i < descriptor_->field_count(); i++) { - const FieldDescriptor* field = descriptor_->field(i); - printer->Print( - "GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET($classname$, $name$_),\n", - "classname", classname_, - "name", FieldName(field)); - } - - printer->Outdent(); - printer->Print("};\n"); -} - -void MessageGenerator:: -GenerateSharedConstructorCode(io::Printer* printer) { - printer->Print( - "void $classname$::SharedCtor() {\n", - "classname", classname_); - printer->Indent(); - - printer->Print( - "_cached_size_ = 0;\n"); - - for (int i = 0; i < descriptor_->field_count(); i++) { - field_generators_.get(descriptor_->field(i)) - .GenerateConstructorCode(printer); - } - - printer->Print( - "::memset(_has_bits_, 0, sizeof(_has_bits_));\n"); - - printer->Outdent(); - printer->Print("}\n\n"); -} - -void MessageGenerator:: -GenerateSharedDestructorCode(io::Printer* printer) { - printer->Print( - "void $classname$::SharedDtor() {\n", - "classname", classname_); - printer->Indent(); - // Write the destructors for each field. - for (int i = 0; i < descriptor_->field_count(); i++) { - field_generators_.get(descriptor_->field(i)) - .GenerateDestructorCode(printer); - } - - PrintHandlingOptionalStaticInitializers( - descriptor_->file(), printer, - // With static initializers. - "if (this != default_instance_) {\n", - // Without. - "if (this != &default_instance()) {\n"); - - // We need to delete all embedded messages. - // TODO(kenton): If we make unset messages point at default instances - // instead of NULL, then it would make sense to move this code into - // MessageFieldGenerator::GenerateDestructorCode(). - for (int i = 0; i < descriptor_->field_count(); i++) { - const FieldDescriptor* field = descriptor_->field(i); - - if (!field->is_repeated() && - field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE) { - printer->Print(" delete $name$_;\n", - "name", FieldName(field)); - } - } - - printer->Outdent(); - printer->Print( - " }\n" - "}\n" - "\n"); -} - -void MessageGenerator:: -GenerateStructors(io::Printer* printer) { - string superclass = SuperClassName(descriptor_); - - // Generate the default constructor. - printer->Print( - "$classname$::$classname$()\n" - " : $superclass$() {\n" - " SharedCtor();\n" - "}\n", - "classname", classname_, - "superclass", superclass); - - printer->Print( - "\n" - "void $classname$::InitAsDefaultInstance() {\n", - "classname", classname_); - - // The default instance needs all of its embedded message pointers - // cross-linked to other default instances. We can't do this initialization - // in the constructor because some other default instances may not have been - // constructed yet at that time. - // TODO(kenton): Maybe all message fields (even for non-default messages) - // should be initialized to point at default instances rather than NULL? - for (int i = 0; i < descriptor_->field_count(); i++) { - const FieldDescriptor* field = descriptor_->field(i); - - if (!field->is_repeated() && - field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE) { - PrintHandlingOptionalStaticInitializers( - descriptor_->file(), printer, - // With static initializers. - " $name$_ = const_cast< $type$*>(&$type$::default_instance());\n", - // Without. - " $name$_ = const_cast< $type$*>(\n" - " $type$::internal_default_instance());\n", - // Vars. - "name", FieldName(field), - "type", FieldMessageTypeName(field)); - } - } - printer->Print( - "}\n" - "\n"); - - // Generate the copy constructor. - printer->Print( - "$classname$::$classname$(const $classname$& from)\n" - " : $superclass$() {\n" - " SharedCtor();\n" - " MergeFrom(from);\n" - "}\n" - "\n", - "classname", classname_, - "superclass", superclass); - - // Generate the shared constructor code. - GenerateSharedConstructorCode(printer); - - // Generate the destructor. - printer->Print( - "$classname$::~$classname$() {\n" - " SharedDtor();\n" - "}\n" - "\n", - "classname", classname_); - - // Generate the shared destructor code. - GenerateSharedDestructorCode(printer); - - // Generate SetCachedSize. - printer->Print( - "void $classname$::SetCachedSize(int size) const {\n" - " GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();\n" - " _cached_size_ = size;\n" - " GOOGLE_SAFE_CONCURRENT_WRITES_END();\n" - "}\n", - "classname", classname_); - - // Only generate this member if it's not disabled. - if (HasDescriptorMethods(descriptor_->file()) && - !descriptor_->options().no_standard_descriptor_accessor()) { - printer->Print( - "const ::google::protobuf::Descriptor* $classname$::descriptor() {\n" - " protobuf_AssignDescriptorsOnce();\n" - " return $classname$_descriptor_;\n" - "}\n" - "\n", - "classname", classname_, - "adddescriptorsname", - GlobalAddDescriptorsName(descriptor_->file()->name())); - } - - printer->Print( - "const $classname$& $classname$::default_instance() {\n", - "classname", classname_); - - PrintHandlingOptionalStaticInitializers( - descriptor_->file(), printer, - // With static initializers. - " if (default_instance_ == NULL) $adddescriptorsname$();\n", - // Without. - " $adddescriptorsname$();\n", - // Vars. - "adddescriptorsname", - GlobalAddDescriptorsName(descriptor_->file()->name())); - - printer->Print( - " return *default_instance_;\n" - "}\n" - "\n" - "$classname$* $classname$::default_instance_ = NULL;\n" - "\n" - "$classname$* $classname$::New() const {\n" - " return new $classname$;\n" - "}\n", - "classname", classname_, - "adddescriptorsname", - GlobalAddDescriptorsName(descriptor_->file()->name())); -} - -void MessageGenerator:: -GenerateClear(io::Printer* printer) { - printer->Print("void $classname$::Clear() {\n", - "classname", classname_); - printer->Indent(); - - int last_index = -1; - - if (descriptor_->extension_range_count() > 0) { - printer->Print("_extensions_.Clear();\n"); - } - - for (int i = 0; i < descriptor_->field_count(); i++) { - const FieldDescriptor* field = descriptor_->field(i); - - if (!field->is_repeated()) { - // We can use the fact that _has_bits_ is a giant bitfield to our - // advantage: We can check up to 32 bits at a time for equality to - // zero, and skip the whole range if so. This can improve the speed - // of Clear() for messages which contain a very large number of - // optional fields of which only a few are used at a time. Here, - // we've chosen to check 8 bits at a time rather than 32. - if (i / 8 != last_index / 8 || last_index < 0) { - if (last_index >= 0) { - printer->Outdent(); - printer->Print("}\n"); - } - printer->Print( - "if (_has_bits_[$index$ / 32] & (0xffu << ($index$ % 32))) {\n", - "index", SimpleItoa(field->index())); - printer->Indent(); - } - last_index = i; - - // It's faster to just overwrite primitive types, but we should - // only clear strings and messages if they were set. - // TODO(kenton): Let the CppFieldGenerator decide this somehow. - bool should_check_bit = - field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE || - field->cpp_type() == FieldDescriptor::CPPTYPE_STRING; - - if (should_check_bit) { - printer->Print( - "if (has_$name$()) {\n", - "name", FieldName(field)); - printer->Indent(); - } - - field_generators_.get(field).GenerateClearingCode(printer); - - if (should_check_bit) { - printer->Outdent(); - printer->Print("}\n"); - } - } - } - - if (last_index >= 0) { - printer->Outdent(); - printer->Print("}\n"); - } - - // Repeated fields don't use _has_bits_ so we clear them in a separate - // pass. - for (int i = 0; i < descriptor_->field_count(); i++) { - const FieldDescriptor* field = descriptor_->field(i); - - if (field->is_repeated()) { - field_generators_.get(field).GenerateClearingCode(printer); - } - } - - printer->Print( - "::memset(_has_bits_, 0, sizeof(_has_bits_));\n"); - - if (HasUnknownFields(descriptor_->file())) { - printer->Print( - "mutable_unknown_fields()->Clear();\n"); - } - - printer->Outdent(); - printer->Print("}\n"); -} - -void MessageGenerator:: -GenerateSwap(io::Printer* printer) { - // Generate the Swap member function. - printer->Print("void $classname$::Swap($classname$* other) {\n", - "classname", classname_); - printer->Indent(); - printer->Print("if (other != this) {\n"); - printer->Indent(); - - if (HasGeneratedMethods(descriptor_->file())) { - for (int i = 0; i < descriptor_->field_count(); i++) { - const FieldDescriptor* field = descriptor_->field(i); - field_generators_.get(field).GenerateSwappingCode(printer); - } - - for (int i = 0; i < (descriptor_->field_count() + 31) / 32; ++i) { - printer->Print("std::swap(_has_bits_[$i$], other->_has_bits_[$i$]);\n", - "i", SimpleItoa(i)); - } - - if (HasUnknownFields(descriptor_->file())) { - printer->Print("_unknown_fields_.Swap(&other->_unknown_fields_);\n"); - } - printer->Print("std::swap(_cached_size_, other->_cached_size_);\n"); - if (descriptor_->extension_range_count() > 0) { - printer->Print("_extensions_.Swap(&other->_extensions_);\n"); - } - } else { - printer->Print("GetReflection()->Swap(this, other);"); - } - - printer->Outdent(); - printer->Print("}\n"); - printer->Outdent(); - printer->Print("}\n"); -} - -void MessageGenerator:: -GenerateMergeFrom(io::Printer* printer) { - if (HasDescriptorMethods(descriptor_->file())) { - // Generate the generalized MergeFrom (aka that which takes in the Message - // base class as a parameter). - printer->Print( - "void $classname$::MergeFrom(const ::google::protobuf::Message& from) {\n" - " GOOGLE_CHECK_NE(&from, this);\n", - "classname", classname_); - printer->Indent(); - - // Cast the message to the proper type. If we find that the message is - // *not* of the proper type, we can still call Merge via the reflection - // system, as the GOOGLE_CHECK above ensured that we have the same descriptor - // for each message. - printer->Print( - "const $classname$* source =\n" - " ::google::protobuf::internal::dynamic_cast_if_available(\n" - " &from);\n" - "if (source == NULL) {\n" - " ::google::protobuf::internal::ReflectionOps::Merge(from, this);\n" - "} else {\n" - " MergeFrom(*source);\n" - "}\n", - "classname", classname_); - - printer->Outdent(); - printer->Print("}\n\n"); - } else { - // Generate CheckTypeAndMergeFrom(). - printer->Print( - "void $classname$::CheckTypeAndMergeFrom(\n" - " const ::google::protobuf::MessageLite& from) {\n" - " MergeFrom(*::google::protobuf::down_cast(&from));\n" - "}\n" - "\n", - "classname", classname_); - } - - // Generate the class-specific MergeFrom, which avoids the GOOGLE_CHECK and cast. - printer->Print( - "void $classname$::MergeFrom(const $classname$& from) {\n" - " GOOGLE_CHECK_NE(&from, this);\n", - "classname", classname_); - printer->Indent(); - - // Merge Repeated fields. These fields do not require a - // check as we can simply iterate over them. - for (int i = 0; i < descriptor_->field_count(); ++i) { - const FieldDescriptor* field = descriptor_->field(i); - - if (field->is_repeated()) { - field_generators_.get(field).GenerateMergingCode(printer); - } - } - - // Merge Optional and Required fields (after a _has_bit check). - int last_index = -1; - - for (int i = 0; i < descriptor_->field_count(); ++i) { - const FieldDescriptor* field = descriptor_->field(i); - - if (!field->is_repeated()) { - // See above in GenerateClear for an explanation of this. - if (i / 8 != last_index / 8 || last_index < 0) { - if (last_index >= 0) { - printer->Outdent(); - printer->Print("}\n"); - } - printer->Print( - "if (from._has_bits_[$index$ / 32] & (0xffu << ($index$ % 32))) {\n", - "index", SimpleItoa(field->index())); - printer->Indent(); - } - - last_index = i; - - printer->Print( - "if (from.has_$name$()) {\n", - "name", FieldName(field)); - printer->Indent(); - - field_generators_.get(field).GenerateMergingCode(printer); - - printer->Outdent(); - printer->Print("}\n"); - } - } - - if (last_index >= 0) { - printer->Outdent(); - printer->Print("}\n"); - } - - if (descriptor_->extension_range_count() > 0) { - printer->Print("_extensions_.MergeFrom(from._extensions_);\n"); - } - - if (HasUnknownFields(descriptor_->file())) { - printer->Print( - "mutable_unknown_fields()->MergeFrom(from.unknown_fields());\n"); - } - - printer->Outdent(); - printer->Print("}\n"); -} - -void MessageGenerator:: -GenerateCopyFrom(io::Printer* printer) { - if (HasDescriptorMethods(descriptor_->file())) { - // Generate the generalized CopyFrom (aka that which takes in the Message - // base class as a parameter). - printer->Print( - "void $classname$::CopyFrom(const ::google::protobuf::Message& from) {\n", - "classname", classname_); - printer->Indent(); - - printer->Print( - "if (&from == this) return;\n" - "Clear();\n" - "MergeFrom(from);\n"); - - printer->Outdent(); - printer->Print("}\n\n"); - } - - // Generate the class-specific CopyFrom. - printer->Print( - "void $classname$::CopyFrom(const $classname$& from) {\n", - "classname", classname_); - printer->Indent(); - - printer->Print( - "if (&from == this) return;\n" - "Clear();\n" - "MergeFrom(from);\n"); - - printer->Outdent(); - printer->Print("}\n"); -} - -void MessageGenerator:: -GenerateMergeFromCodedStream(io::Printer* printer) { - if (descriptor_->options().message_set_wire_format()) { - // Special-case MessageSet. - printer->Print( - "bool $classname$::MergePartialFromCodedStream(\n" - " ::google::protobuf::io::CodedInputStream* input) {\n", - "classname", classname_); - - PrintHandlingOptionalStaticInitializers( - descriptor_->file(), printer, - // With static initializers. - " return _extensions_.ParseMessageSet(input, default_instance_,\n" - " mutable_unknown_fields());\n", - // Without. - " return _extensions_.ParseMessageSet(input, &default_instance(),\n" - " mutable_unknown_fields());\n", - // Vars. - "classname", classname_); - - printer->Print( - "}\n"); - return; - } - - printer->Print( - "bool $classname$::MergePartialFromCodedStream(\n" - " ::google::protobuf::io::CodedInputStream* input) {\n" - "#define DO_(EXPRESSION) if (!(EXPRESSION)) return false\n" - " ::google::protobuf::uint32 tag;\n" - " while ((tag = input->ReadTag()) != 0) {\n", - "classname", classname_); - - printer->Indent(); - printer->Indent(); - - if (descriptor_->field_count() > 0) { - // We don't even want to print the switch() if we have no fields because - // MSVC dislikes switch() statements that contain only a default value. - - // Note: If we just switched on the tag rather than the field number, we - // could avoid the need for the if() to check the wire type at the beginning - // of each case. However, this is actually a bit slower in practice as it - // creates a jump table that is 8x larger and sparser, and meanwhile the - // if()s are highly predictable. - printer->Print( - "switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {\n"); - - printer->Indent(); - - scoped_array ordered_fields( - SortFieldsByNumber(descriptor_)); - - for (int i = 0; i < descriptor_->field_count(); i++) { - const FieldDescriptor* field = ordered_fields[i]; - - PrintFieldComment(printer, field); - - printer->Print( - "case $number$: {\n", - "number", SimpleItoa(field->number())); - printer->Indent(); - const FieldGenerator& field_generator = field_generators_.get(field); - - // Emit code to parse the common, expected case. - printer->Print( - "if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==\n" - " ::google::protobuf::internal::WireFormatLite::WIRETYPE_$wiretype$) {\n", - "wiretype", kWireTypeNames[WireFormat::WireTypeForField(field)]); - - if (i > 0 || (field->is_repeated() && !field->options().packed())) { - printer->Print( - " parse_$name$:\n", - "name", field->name()); - } - - printer->Indent(); - if (field->options().packed()) { - field_generator.GenerateMergeFromCodedStreamWithPacking(printer); - } else { - field_generator.GenerateMergeFromCodedStream(printer); - } - printer->Outdent(); - - // Emit code to parse unexpectedly packed or unpacked values. - if (field->is_packable() && field->options().packed()) { - printer->Print( - "} else if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag)\n" - " == ::google::protobuf::internal::WireFormatLite::\n" - " WIRETYPE_$wiretype$) {\n", - "wiretype", - kWireTypeNames[WireFormat::WireTypeForFieldType(field->type())]); - printer->Indent(); - field_generator.GenerateMergeFromCodedStream(printer); - printer->Outdent(); - } else if (field->is_packable() && !field->options().packed()) { - printer->Print( - "} else if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag)\n" - " == ::google::protobuf::internal::WireFormatLite::\n" - " WIRETYPE_LENGTH_DELIMITED) {\n"); - printer->Indent(); - field_generator.GenerateMergeFromCodedStreamWithPacking(printer); - printer->Outdent(); - } - - printer->Print( - "} else {\n" - " goto handle_uninterpreted;\n" - "}\n"); - - // switch() is slow since it can't be predicted well. Insert some if()s - // here that attempt to predict the next tag. - if (field->is_repeated() && !field->options().packed()) { - // Expect repeats of this field. - printer->Print( - "if (input->ExpectTag($tag$)) goto parse_$name$;\n", - "tag", SimpleItoa(WireFormat::MakeTag(field)), - "name", field->name()); - } - - if (i + 1 < descriptor_->field_count()) { - // Expect the next field in order. - const FieldDescriptor* next_field = ordered_fields[i + 1]; - printer->Print( - "if (input->ExpectTag($next_tag$)) goto parse_$next_name$;\n", - "next_tag", SimpleItoa(WireFormat::MakeTag(next_field)), - "next_name", next_field->name()); - } else { - // Expect EOF. - // TODO(kenton): Expect group end-tag? - printer->Print( - "if (input->ExpectAtEnd()) return true;\n"); - } - - printer->Print( - "break;\n"); - - printer->Outdent(); - printer->Print("}\n\n"); - } - - printer->Print( - "default: {\n" - "handle_uninterpreted:\n"); - printer->Indent(); - } - - // Is this an end-group tag? If so, this must be the end of the message. - printer->Print( - "if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==\n" - " ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) {\n" - " return true;\n" - "}\n"); - - // Handle extension ranges. - if (descriptor_->extension_range_count() > 0) { - printer->Print( - "if ("); - for (int i = 0; i < descriptor_->extension_range_count(); i++) { - const Descriptor::ExtensionRange* range = - descriptor_->extension_range(i); - if (i > 0) printer->Print(" ||\n "); - - uint32 start_tag = WireFormatLite::MakeTag( - range->start, static_cast(0)); - uint32 end_tag = WireFormatLite::MakeTag( - range->end, static_cast(0)); - - if (range->end > FieldDescriptor::kMaxNumber) { - printer->Print( - "($start$u <= tag)", - "start", SimpleItoa(start_tag)); - } else { - printer->Print( - "($start$u <= tag && tag < $end$u)", - "start", SimpleItoa(start_tag), - "end", SimpleItoa(end_tag)); - } - } - printer->Print(") {\n"); - if (HasUnknownFields(descriptor_->file())) { - PrintHandlingOptionalStaticInitializers( - descriptor_->file(), printer, - // With static initializers. - " DO_(_extensions_.ParseField(tag, input, default_instance_,\n" - " mutable_unknown_fields()));\n", - // Without. - " DO_(_extensions_.ParseField(tag, input, &default_instance(),\n" - " mutable_unknown_fields()));\n"); - } else { - PrintHandlingOptionalStaticInitializers( - descriptor_->file(), printer, - // With static initializers. - " DO_(_extensions_.ParseField(tag, input, default_instance_));\n", - // Without. - " DO_(_extensions_.ParseField(tag, input, &default_instance()));\n"); - } - printer->Print( - " continue;\n" - "}\n"); - } - - // We really don't recognize this tag. Skip it. - if (HasUnknownFields(descriptor_->file())) { - printer->Print( - "DO_(::google::protobuf::internal::WireFormat::SkipField(\n" - " input, tag, mutable_unknown_fields()));\n"); - } else { - printer->Print( - "DO_(::google::protobuf::internal::WireFormatLite::SkipField(input, tag));\n"); - } - - if (descriptor_->field_count() > 0) { - printer->Print("break;\n"); - printer->Outdent(); - printer->Print("}\n"); // default: - printer->Outdent(); - printer->Print("}\n"); // switch - } - - printer->Outdent(); - printer->Outdent(); - printer->Print( - " }\n" // while - " return true;\n" - "#undef DO_\n" - "}\n"); -} - -void MessageGenerator::GenerateSerializeOneField( - io::Printer* printer, const FieldDescriptor* field, bool to_array) { - PrintFieldComment(printer, field); - - if (!field->is_repeated()) { - printer->Print( - "if (has_$name$()) {\n", - "name", FieldName(field)); - printer->Indent(); - } - - if (to_array) { - field_generators_.get(field).GenerateSerializeWithCachedSizesToArray( - printer); - } else { - field_generators_.get(field).GenerateSerializeWithCachedSizes(printer); - } - - if (!field->is_repeated()) { - printer->Outdent(); - printer->Print("}\n"); - } - printer->Print("\n"); -} - -void MessageGenerator::GenerateSerializeOneExtensionRange( - io::Printer* printer, const Descriptor::ExtensionRange* range, - bool to_array) { - map vars; - vars["start"] = SimpleItoa(range->start); - vars["end"] = SimpleItoa(range->end); - printer->Print(vars, - "// Extension range [$start$, $end$)\n"); - if (to_array) { - printer->Print(vars, - "target = _extensions_.SerializeWithCachedSizesToArray(\n" - " $start$, $end$, target);\n\n"); - } else { - printer->Print(vars, - "_extensions_.SerializeWithCachedSizes(\n" - " $start$, $end$, output);\n\n"); - } -} - -void MessageGenerator:: -GenerateSerializeWithCachedSizes(io::Printer* printer) { - if (descriptor_->options().message_set_wire_format()) { - // Special-case MessageSet. - printer->Print( - "void $classname$::SerializeWithCachedSizes(\n" - " ::google::protobuf::io::CodedOutputStream* output) const {\n" - " _extensions_.SerializeMessageSetWithCachedSizes(output);\n", - "classname", classname_); - if (HasUnknownFields(descriptor_->file())) { - printer->Print( - " ::google::protobuf::internal::WireFormat::SerializeUnknownMessageSetItems(\n" - " unknown_fields(), output);\n"); - } - printer->Print( - "}\n"); - return; - } - - printer->Print( - "void $classname$::SerializeWithCachedSizes(\n" - " ::google::protobuf::io::CodedOutputStream* output) const {\n", - "classname", classname_); - printer->Indent(); - - GenerateSerializeWithCachedSizesBody(printer, false); - - printer->Outdent(); - printer->Print( - "}\n"); -} - -void MessageGenerator:: -GenerateSerializeWithCachedSizesToArray(io::Printer* printer) { - if (descriptor_->options().message_set_wire_format()) { - // Special-case MessageSet. - printer->Print( - "::google::protobuf::uint8* $classname$::SerializeWithCachedSizesToArray(\n" - " ::google::protobuf::uint8* target) const {\n" - " target =\n" - " _extensions_.SerializeMessageSetWithCachedSizesToArray(target);\n", - "classname", classname_); - if (HasUnknownFields(descriptor_->file())) { - printer->Print( - " target = ::google::protobuf::internal::WireFormat::\n" - " SerializeUnknownMessageSetItemsToArray(\n" - " unknown_fields(), target);\n"); - } - printer->Print( - " return target;\n" - "}\n"); - return; - } - - printer->Print( - "::google::protobuf::uint8* $classname$::SerializeWithCachedSizesToArray(\n" - " ::google::protobuf::uint8* target) const {\n", - "classname", classname_); - printer->Indent(); - - GenerateSerializeWithCachedSizesBody(printer, true); - - printer->Outdent(); - printer->Print( - " return target;\n" - "}\n"); -} - -void MessageGenerator:: -GenerateSerializeWithCachedSizesBody(io::Printer* printer, bool to_array) { - scoped_array ordered_fields( - SortFieldsByNumber(descriptor_)); - - vector sorted_extensions; - for (int i = 0; i < descriptor_->extension_range_count(); ++i) { - sorted_extensions.push_back(descriptor_->extension_range(i)); - } - sort(sorted_extensions.begin(), sorted_extensions.end(), - ExtensionRangeSorter()); - - // Merge the fields and the extension ranges, both sorted by field number. - int i, j; - for (i = 0, j = 0; - i < descriptor_->field_count() || j < sorted_extensions.size(); - ) { - if (i == descriptor_->field_count()) { - GenerateSerializeOneExtensionRange(printer, - sorted_extensions[j++], - to_array); - } else if (j == sorted_extensions.size()) { - GenerateSerializeOneField(printer, ordered_fields[i++], to_array); - } else if (ordered_fields[i]->number() < sorted_extensions[j]->start) { - GenerateSerializeOneField(printer, ordered_fields[i++], to_array); - } else { - GenerateSerializeOneExtensionRange(printer, - sorted_extensions[j++], - to_array); - } - } - - if (HasUnknownFields(descriptor_->file())) { - printer->Print("if (!unknown_fields().empty()) {\n"); - printer->Indent(); - if (to_array) { - printer->Print( - "target = " - "::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray(\n" - " unknown_fields(), target);\n"); - } else { - printer->Print( - "::google::protobuf::internal::WireFormat::SerializeUnknownFields(\n" - " unknown_fields(), output);\n"); - } - printer->Outdent(); - - printer->Print( - "}\n"); - } -} - -void MessageGenerator:: -GenerateByteSize(io::Printer* printer) { - if (descriptor_->options().message_set_wire_format()) { - // Special-case MessageSet. - printer->Print( - "int $classname$::ByteSize() const {\n" - " int total_size = _extensions_.MessageSetByteSize();\n", - "classname", classname_); - if (HasUnknownFields(descriptor_->file())) { - printer->Print( - " total_size += ::google::protobuf::internal::WireFormat::\n" - " ComputeUnknownMessageSetItemsSize(unknown_fields());\n"); - } - printer->Print( - " GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();\n" - " _cached_size_ = total_size;\n" - " GOOGLE_SAFE_CONCURRENT_WRITES_END();\n" - " return total_size;\n" - "}\n"); - return; - } - - printer->Print( - "int $classname$::ByteSize() const {\n", - "classname", classname_); - printer->Indent(); - printer->Print( - "int total_size = 0;\n" - "\n"); - - int last_index = -1; - - for (int i = 0; i < descriptor_->field_count(); i++) { - const FieldDescriptor* field = descriptor_->field(i); - - if (!field->is_repeated()) { - // See above in GenerateClear for an explanation of this. - // TODO(kenton): Share code? Unclear how to do so without - // over-engineering. - if ((i / 8) != (last_index / 8) || - last_index < 0) { - if (last_index >= 0) { - printer->Outdent(); - printer->Print("}\n"); - } - printer->Print( - "if (_has_bits_[$index$ / 32] & (0xffu << ($index$ % 32))) {\n", - "index", SimpleItoa(field->index())); - printer->Indent(); - } - last_index = i; - - PrintFieldComment(printer, field); - - printer->Print( - "if (has_$name$()) {\n", - "name", FieldName(field)); - printer->Indent(); - - field_generators_.get(field).GenerateByteSize(printer); - - printer->Outdent(); - printer->Print( - "}\n" - "\n"); - } - } - - if (last_index >= 0) { - printer->Outdent(); - printer->Print("}\n"); - } - - // Repeated fields don't use _has_bits_ so we count them in a separate - // pass. - for (int i = 0; i < descriptor_->field_count(); i++) { - const FieldDescriptor* field = descriptor_->field(i); - - if (field->is_repeated()) { - PrintFieldComment(printer, field); - field_generators_.get(field).GenerateByteSize(printer); - printer->Print("\n"); - } - } - - if (descriptor_->extension_range_count() > 0) { - printer->Print( - "total_size += _extensions_.ByteSize();\n" - "\n"); - } - - if (HasUnknownFields(descriptor_->file())) { - printer->Print("if (!unknown_fields().empty()) {\n"); - printer->Indent(); - printer->Print( - "total_size +=\n" - " ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(\n" - " unknown_fields());\n"); - printer->Outdent(); - printer->Print("}\n"); - } - - // We update _cached_size_ even though this is a const method. In theory, - // this is not thread-compatible, because concurrent writes have undefined - // results. In practice, since any concurrent writes will be writing the - // exact same value, it works on all common processors. In a future version - // of C++, _cached_size_ should be made into an atomic. - printer->Print( - "GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();\n" - "_cached_size_ = total_size;\n" - "GOOGLE_SAFE_CONCURRENT_WRITES_END();\n" - "return total_size;\n"); - - printer->Outdent(); - printer->Print("}\n"); -} - -void MessageGenerator:: -GenerateIsInitialized(io::Printer* printer) { - printer->Print( - "bool $classname$::IsInitialized() const {\n", - "classname", classname_); - printer->Indent(); - - // Check that all required fields in this message are set. We can do this - // most efficiently by checking 32 "has bits" at a time. - int has_bits_array_size = (descriptor_->field_count() + 31) / 32; - for (int i = 0; i < has_bits_array_size; i++) { - uint32 mask = 0; - for (int bit = 0; bit < 32; bit++) { - int index = i * 32 + bit; - if (index >= descriptor_->field_count()) break; - const FieldDescriptor* field = descriptor_->field(index); - - if (field->is_required()) { - mask |= 1 << bit; - } - } - - if (mask != 0) { - char buffer[kFastToBufferSize]; - printer->Print( - "if ((_has_bits_[$i$] & 0x$mask$) != 0x$mask$) return false;\n", - "i", SimpleItoa(i), - "mask", FastHex32ToBuffer(mask, buffer)); - } - } - - // Now check that all embedded messages are initialized. - printer->Print("\n"); - for (int i = 0; i < descriptor_->field_count(); i++) { - const FieldDescriptor* field = descriptor_->field(i); - if (field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE && - !ShouldIgnoreRequiredFieldCheck(field) && - HasRequiredFields(field->message_type())) { - if (field->is_repeated()) { - printer->Print( - "for (int i = 0; i < $name$_size(); i++) {\n" - " if (!this->$name$(i).IsInitialized()) return false;\n" - "}\n", - "name", FieldName(field)); - } else { - printer->Print( - "if (has_$name$()) {\n" - " if (!this->$name$().IsInitialized()) return false;\n" - "}\n", - "name", FieldName(field)); - } - } - } - - if (descriptor_->extension_range_count() > 0) { - printer->Print( - "\n" - "if (!_extensions_.IsInitialized()) return false;"); - } - - printer->Outdent(); - printer->Print( - " return true;\n" - "}\n"); -} - - -} // namespace cpp -} // namespace compiler -} // namespace protobuf -} // namespace google diff --git a/modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/cpp/cpp_message.h b/modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/cpp/cpp_message.h deleted file mode 100644 index a7e43d9c9..000000000 --- a/modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/cpp/cpp_message.h +++ /dev/null @@ -1,171 +0,0 @@ -// Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// http://code.google.com/p/protobuf/ -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -// Author: kenton@google.com (Kenton Varda) -// Based on original Protocol Buffers design by -// Sanjay Ghemawat, Jeff Dean, and others. - -#ifndef GOOGLE_PROTOBUF_COMPILER_CPP_MESSAGE_H__ -#define GOOGLE_PROTOBUF_COMPILER_CPP_MESSAGE_H__ - -#include -#include -#include -#include - -namespace google { -namespace protobuf { - namespace io { - class Printer; // printer.h - } -} - -namespace protobuf { -namespace compiler { -namespace cpp { - -class EnumGenerator; // enum.h -class ExtensionGenerator; // extension.h - -class MessageGenerator { - public: - // See generator.cc for the meaning of dllexport_decl. - explicit MessageGenerator(const Descriptor* descriptor, - const Options& options); - ~MessageGenerator(); - - // Header stuff. - - // Generate foward declarations for this class and all its nested types. - void GenerateForwardDeclaration(io::Printer* printer); - - // Generate definitions of all nested enums (must come before class - // definitions because those classes use the enums definitions). - void GenerateEnumDefinitions(io::Printer* printer); - - // Generate specializations of GetEnumDescriptor(). - // Precondition: in ::google::protobuf namespace. - void GenerateGetEnumDescriptorSpecializations(io::Printer* printer); - - // Generate definitions for this class and all its nested types. - void GenerateClassDefinition(io::Printer* printer); - - // Generate definitions of inline methods (placed at the end of the header - // file). - void GenerateInlineMethods(io::Printer* printer); - - // Source file stuff. - - // Generate code which declares all the global descriptor pointers which - // will be initialized by the methods below. - void GenerateDescriptorDeclarations(io::Printer* printer); - - // Generate code that initializes the global variable storing the message's - // descriptor. - void GenerateDescriptorInitializer(io::Printer* printer, int index); - - // Generate code that calls MessageFactory::InternalRegisterGeneratedMessage() - // for all types. - void GenerateTypeRegistrations(io::Printer* printer); - - // Generates code that allocates the message's default instance. - void GenerateDefaultInstanceAllocator(io::Printer* printer); - - // Generates code that initializes the message's default instance. This - // is separate from allocating because all default instances must be - // allocated before any can be initialized. - void GenerateDefaultInstanceInitializer(io::Printer* printer); - - // Generates code that should be run when ShutdownProtobufLibrary() is called, - // to delete all dynamically-allocated objects. - void GenerateShutdownCode(io::Printer* printer); - - // Generate all non-inline methods for this class. - void GenerateClassMethods(io::Printer* printer); - - private: - // Generate declarations and definitions of accessors for fields. - void GenerateFieldAccessorDeclarations(io::Printer* printer); - void GenerateFieldAccessorDefinitions(io::Printer* printer); - - // Generate the field offsets array. - void GenerateOffsets(io::Printer* printer); - - // Generate constructors and destructor. - void GenerateStructors(io::Printer* printer); - - // The compiler typically generates multiple copies of each constructor and - // destructor: http://gcc.gnu.org/bugs.html#nonbugs_cxx - // Placing common code in a separate method reduces the generated code size. - // - // Generate the shared constructor code. - void GenerateSharedConstructorCode(io::Printer* printer); - // Generate the shared destructor code. - void GenerateSharedDestructorCode(io::Printer* printer); - - // Generate standard Message methods. - void GenerateClear(io::Printer* printer); - void GenerateMergeFromCodedStream(io::Printer* printer); - void GenerateSerializeWithCachedSizes(io::Printer* printer); - void GenerateSerializeWithCachedSizesToArray(io::Printer* printer); - void GenerateSerializeWithCachedSizesBody(io::Printer* printer, - bool to_array); - void GenerateByteSize(io::Printer* printer); - void GenerateMergeFrom(io::Printer* printer); - void GenerateCopyFrom(io::Printer* printer); - void GenerateSwap(io::Printer* printer); - void GenerateIsInitialized(io::Printer* printer); - - // Helpers for GenerateSerializeWithCachedSizes(). - void GenerateSerializeOneField(io::Printer* printer, - const FieldDescriptor* field, - bool unbounded); - void GenerateSerializeOneExtensionRange( - io::Printer* printer, const Descriptor::ExtensionRange* range, - bool unbounded); - - - const Descriptor* descriptor_; - string classname_; - Options options_; - FieldGeneratorMap field_generators_; - scoped_array > nested_generators_; - scoped_array > enum_generators_; - scoped_array > extension_generators_; - - GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(MessageGenerator); -}; - -} // namespace cpp -} // namespace compiler -} // namespace protobuf - -} // namespace google -#endif // GOOGLE_PROTOBUF_COMPILER_CPP_MESSAGE_H__ diff --git a/modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/cpp/cpp_message_field.cc b/modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/cpp/cpp_message_field.cc deleted file mode 100644 index 447f975f8..000000000 --- a/modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/cpp/cpp_message_field.cc +++ /dev/null @@ -1,298 +0,0 @@ -// Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// http://code.google.com/p/protobuf/ -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -// Author: kenton@google.com (Kenton Varda) -// Based on original Protocol Buffers design by -// Sanjay Ghemawat, Jeff Dean, and others. - -#include -#include -#include -#include - -namespace google { -namespace protobuf { -namespace compiler { -namespace cpp { - -namespace { - -void SetMessageVariables(const FieldDescriptor* descriptor, - map* variables, - const Options& options) { - SetCommonFieldVariables(descriptor, variables, options); - (*variables)["type"] = FieldMessageTypeName(descriptor); - (*variables)["stream_writer"] = (*variables)["declared_type"] + - (HasFastArraySerialization(descriptor->message_type()->file()) ? - "MaybeToArray" : - ""); -} - -} // namespace - -// =================================================================== - -MessageFieldGenerator:: -MessageFieldGenerator(const FieldDescriptor* descriptor, - const Options& options) - : descriptor_(descriptor) { - SetMessageVariables(descriptor, &variables_, options); -} - -MessageFieldGenerator::~MessageFieldGenerator() {} - -void MessageFieldGenerator:: -GeneratePrivateMembers(io::Printer* printer) const { - printer->Print(variables_, "$type$* $name$_;\n"); -} - -void MessageFieldGenerator:: -GenerateAccessorDeclarations(io::Printer* printer) const { - printer->Print(variables_, - "inline const $type$& $name$() const$deprecation$;\n" - "inline $type$* mutable_$name$()$deprecation$;\n" - "inline $type$* release_$name$()$deprecation$;\n" - "inline void set_allocated_$name$($type$* $name$)$deprecation$;\n"); -} - -void MessageFieldGenerator:: -GenerateInlineAccessorDefinitions(io::Printer* printer) const { - printer->Print(variables_, - "inline const $type$& $classname$::$name$() const {\n"); - - PrintHandlingOptionalStaticInitializers( - variables_, descriptor_->file(), printer, - // With static initializers. - " return $name$_ != NULL ? *$name$_ : *default_instance_->$name$_;\n", - // Without. - " return $name$_ != NULL ? *$name$_ : *default_instance().$name$_;\n"); - - printer->Print(variables_, - "}\n" - "inline $type$* $classname$::mutable_$name$() {\n" - " set_has_$name$();\n" - " if ($name$_ == NULL) $name$_ = new $type$;\n" - " return $name$_;\n" - "}\n" - "inline $type$* $classname$::release_$name$() {\n" - " clear_has_$name$();\n" - " $type$* temp = $name$_;\n" - " $name$_ = NULL;\n" - " return temp;\n" - "}\n" - "inline void $classname$::set_allocated_$name$($type$* $name$) {\n" - " delete $name$_;\n" - " $name$_ = $name$;\n" - " if ($name$) {\n" - " set_has_$name$();\n" - " } else {\n" - " clear_has_$name$();\n" - " }\n" - "}\n"); -} - -void MessageFieldGenerator:: -GenerateClearingCode(io::Printer* printer) const { - printer->Print(variables_, - "if ($name$_ != NULL) $name$_->$type$::Clear();\n"); -} - -void MessageFieldGenerator:: -GenerateMergingCode(io::Printer* printer) const { - printer->Print(variables_, - "mutable_$name$()->$type$::MergeFrom(from.$name$());\n"); -} - -void MessageFieldGenerator:: -GenerateSwappingCode(io::Printer* printer) const { - printer->Print(variables_, "std::swap($name$_, other->$name$_);\n"); -} - -void MessageFieldGenerator:: -GenerateConstructorCode(io::Printer* printer) const { - printer->Print(variables_, "$name$_ = NULL;\n"); -} - -void MessageFieldGenerator:: -GenerateMergeFromCodedStream(io::Printer* printer) const { - if (descriptor_->type() == FieldDescriptor::TYPE_MESSAGE) { - printer->Print(variables_, - "DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(\n" - " input, mutable_$name$()));\n"); - } else { - printer->Print(variables_, - "DO_(::google::protobuf::internal::WireFormatLite::ReadGroupNoVirtual(\n" - " $number$, input, mutable_$name$()));\n"); - } -} - -void MessageFieldGenerator:: -GenerateSerializeWithCachedSizes(io::Printer* printer) const { - printer->Print(variables_, - "::google::protobuf::internal::WireFormatLite::Write$stream_writer$(\n" - " $number$, this->$name$(), output);\n"); -} - -void MessageFieldGenerator:: -GenerateSerializeWithCachedSizesToArray(io::Printer* printer) const { - printer->Print(variables_, - "target = ::google::protobuf::internal::WireFormatLite::\n" - " Write$declared_type$NoVirtualToArray(\n" - " $number$, this->$name$(), target);\n"); -} - -void MessageFieldGenerator:: -GenerateByteSize(io::Printer* printer) const { - printer->Print(variables_, - "total_size += $tag_size$ +\n" - " ::google::protobuf::internal::WireFormatLite::$declared_type$SizeNoVirtual(\n" - " this->$name$());\n"); -} - -// =================================================================== - -RepeatedMessageFieldGenerator:: -RepeatedMessageFieldGenerator(const FieldDescriptor* descriptor, - const Options& options) - : descriptor_(descriptor) { - SetMessageVariables(descriptor, &variables_, options); -} - -RepeatedMessageFieldGenerator::~RepeatedMessageFieldGenerator() {} - -void RepeatedMessageFieldGenerator:: -GeneratePrivateMembers(io::Printer* printer) const { - printer->Print(variables_, - "::google::protobuf::RepeatedPtrField< $type$ > $name$_;\n"); -} - -void RepeatedMessageFieldGenerator:: -GenerateAccessorDeclarations(io::Printer* printer) const { - printer->Print(variables_, - "inline const $type$& $name$(int index) const$deprecation$;\n" - "inline $type$* mutable_$name$(int index)$deprecation$;\n" - "inline $type$* add_$name$()$deprecation$;\n"); - printer->Print(variables_, - "inline const ::google::protobuf::RepeatedPtrField< $type$ >&\n" - " $name$() const$deprecation$;\n" - "inline ::google::protobuf::RepeatedPtrField< $type$ >*\n" - " mutable_$name$()$deprecation$;\n"); -} - -void RepeatedMessageFieldGenerator:: -GenerateInlineAccessorDefinitions(io::Printer* printer) const { - printer->Print(variables_, - "inline const $type$& $classname$::$name$(int index) const {\n" - " return $name$_.$cppget$(index);\n" - "}\n" - "inline $type$* $classname$::mutable_$name$(int index) {\n" - " return $name$_.Mutable(index);\n" - "}\n" - "inline $type$* $classname$::add_$name$() {\n" - " return $name$_.Add();\n" - "}\n"); - printer->Print(variables_, - "inline const ::google::protobuf::RepeatedPtrField< $type$ >&\n" - "$classname$::$name$() const {\n" - " return $name$_;\n" - "}\n" - "inline ::google::protobuf::RepeatedPtrField< $type$ >*\n" - "$classname$::mutable_$name$() {\n" - " return &$name$_;\n" - "}\n"); -} - -void RepeatedMessageFieldGenerator:: -GenerateClearingCode(io::Printer* printer) const { - printer->Print(variables_, "$name$_.Clear();\n"); -} - -void RepeatedMessageFieldGenerator:: -GenerateMergingCode(io::Printer* printer) const { - printer->Print(variables_, "$name$_.MergeFrom(from.$name$_);\n"); -} - -void RepeatedMessageFieldGenerator:: -GenerateSwappingCode(io::Printer* printer) const { - printer->Print(variables_, "$name$_.Swap(&other->$name$_);\n"); -} - -void RepeatedMessageFieldGenerator:: -GenerateConstructorCode(io::Printer* printer) const { - // Not needed for repeated fields. -} - -void RepeatedMessageFieldGenerator:: -GenerateMergeFromCodedStream(io::Printer* printer) const { - if (descriptor_->type() == FieldDescriptor::TYPE_MESSAGE) { - printer->Print(variables_, - "DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(\n" - " input, add_$name$()));\n"); - } else { - printer->Print(variables_, - "DO_(::google::protobuf::internal::WireFormatLite::ReadGroupNoVirtual(\n" - " $number$, input, add_$name$()));\n"); - } -} - -void RepeatedMessageFieldGenerator:: -GenerateSerializeWithCachedSizes(io::Printer* printer) const { - printer->Print(variables_, - "for (int i = 0; i < this->$name$_size(); i++) {\n" - " ::google::protobuf::internal::WireFormatLite::Write$stream_writer$(\n" - " $number$, this->$name$(i), output);\n" - "}\n"); -} - -void RepeatedMessageFieldGenerator:: -GenerateSerializeWithCachedSizesToArray(io::Printer* printer) const { - printer->Print(variables_, - "for (int i = 0; i < this->$name$_size(); i++) {\n" - " target = ::google::protobuf::internal::WireFormatLite::\n" - " Write$declared_type$NoVirtualToArray(\n" - " $number$, this->$name$(i), target);\n" - "}\n"); -} - -void RepeatedMessageFieldGenerator:: -GenerateByteSize(io::Printer* printer) const { - printer->Print(variables_, - "total_size += $tag_size$ * this->$name$_size();\n" - "for (int i = 0; i < this->$name$_size(); i++) {\n" - " total_size +=\n" - " ::google::protobuf::internal::WireFormatLite::$declared_type$SizeNoVirtual(\n" - " this->$name$(i));\n" - "}\n"); -} - -} // namespace cpp -} // namespace compiler -} // namespace protobuf -} // namespace google diff --git a/modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/cpp/cpp_message_field.h b/modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/cpp/cpp_message_field.h deleted file mode 100644 index a5ed68a5c..000000000 --- a/modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/cpp/cpp_message_field.h +++ /dev/null @@ -1,104 +0,0 @@ -// Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// http://code.google.com/p/protobuf/ -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -// Author: kenton@google.com (Kenton Varda) -// Based on original Protocol Buffers design by -// Sanjay Ghemawat, Jeff Dean, and others. - -#ifndef GOOGLE_PROTOBUF_COMPILER_CPP_MESSAGE_FIELD_H__ -#define GOOGLE_PROTOBUF_COMPILER_CPP_MESSAGE_FIELD_H__ - -#include -#include -#include - -namespace google { -namespace protobuf { -namespace compiler { -namespace cpp { - -class MessageFieldGenerator : public FieldGenerator { - public: - explicit MessageFieldGenerator(const FieldDescriptor* descriptor, - const Options& options); - ~MessageFieldGenerator(); - - // implements FieldGenerator --------------------------------------- - void GeneratePrivateMembers(io::Printer* printer) const; - void GenerateAccessorDeclarations(io::Printer* printer) const; - void GenerateInlineAccessorDefinitions(io::Printer* printer) const; - void GenerateClearingCode(io::Printer* printer) const; - void GenerateMergingCode(io::Printer* printer) const; - void GenerateSwappingCode(io::Printer* printer) const; - void GenerateConstructorCode(io::Printer* printer) const; - void GenerateMergeFromCodedStream(io::Printer* printer) const; - void GenerateSerializeWithCachedSizes(io::Printer* printer) const; - void GenerateSerializeWithCachedSizesToArray(io::Printer* printer) const; - void GenerateByteSize(io::Printer* printer) const; - - private: - const FieldDescriptor* descriptor_; - map variables_; - - GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(MessageFieldGenerator); -}; - -class RepeatedMessageFieldGenerator : public FieldGenerator { - public: - explicit RepeatedMessageFieldGenerator(const FieldDescriptor* descriptor, - const Options& options); - ~RepeatedMessageFieldGenerator(); - - // implements FieldGenerator --------------------------------------- - void GeneratePrivateMembers(io::Printer* printer) const; - void GenerateAccessorDeclarations(io::Printer* printer) const; - void GenerateInlineAccessorDefinitions(io::Printer* printer) const; - void GenerateClearingCode(io::Printer* printer) const; - void GenerateMergingCode(io::Printer* printer) const; - void GenerateSwappingCode(io::Printer* printer) const; - void GenerateConstructorCode(io::Printer* printer) const; - void GenerateMergeFromCodedStream(io::Printer* printer) const; - void GenerateSerializeWithCachedSizes(io::Printer* printer) const; - void GenerateSerializeWithCachedSizesToArray(io::Printer* printer) const; - void GenerateByteSize(io::Printer* printer) const; - - private: - const FieldDescriptor* descriptor_; - map variables_; - - GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(RepeatedMessageFieldGenerator); -}; - -} // namespace cpp -} // namespace compiler -} // namespace protobuf - -} // namespace google -#endif // GOOGLE_PROTOBUF_COMPILER_CPP_MESSAGE_FIELD_H__ diff --git a/modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/cpp/cpp_options.h b/modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/cpp/cpp_options.h deleted file mode 100644 index 787706629..000000000 --- a/modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/cpp/cpp_options.h +++ /dev/null @@ -1,58 +0,0 @@ -// Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// http://code.google.com/p/protobuf/ -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -// Author: rennie@google.com (Jeffrey Rennie) - -#ifndef GOOGLE_PROTOBUF_COMPILER_CPP_OPTIONS_H__ -#define GOOGLE_PROTOBUF_COMPILER_CPP_OPTIONS_H__ - -#include - -#include -namespace google { -namespace protobuf { -namespace compiler { -namespace cpp { - -// Generator options: -struct Options { - Options() : safe_boundary_check(false) { - } - string dllexport_decl; - bool safe_boundary_check; -}; - -} // namespace cpp -} // namespace compiler -} // namespace protobuf - - -} // namespace google -#endif // GOOGLE_PROTOBUF_COMPILER_CPP_OPTIONS_H__ diff --git a/modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/cpp/cpp_plugin_unittest.cc b/modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/cpp/cpp_plugin_unittest.cc deleted file mode 100644 index 5c4aa4fbc..000000000 --- a/modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/cpp/cpp_plugin_unittest.cc +++ /dev/null @@ -1,121 +0,0 @@ -// Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// http://code.google.com/p/protobuf/ -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -// Author: kenton@google.com (Kenton Varda) -// -// TODO(kenton): Share code with the versions of this test in other languages? -// It seemed like parameterizing it would add more complexity than it is -// worth. - -#include -#include -#include -#include - -#include -#include -#include - -namespace google { -namespace protobuf { -namespace compiler { -namespace cpp { -namespace { - -class TestGenerator : public CodeGenerator { - public: - TestGenerator() {} - ~TestGenerator() {} - - virtual bool Generate(const FileDescriptor* file, - const string& parameter, - GeneratorContext* context, - string* error) const { - TryInsert("test.pb.h", "includes", context); - TryInsert("test.pb.h", "namespace_scope", context); - TryInsert("test.pb.h", "global_scope", context); - TryInsert("test.pb.h", "class_scope:foo.Bar", context); - TryInsert("test.pb.h", "class_scope:foo.Bar.Baz", context); - - TryInsert("test.pb.cc", "includes", context); - TryInsert("test.pb.cc", "namespace_scope", context); - TryInsert("test.pb.cc", "global_scope", context); - return true; - } - - void TryInsert(const string& filename, const string& insertion_point, - GeneratorContext* context) const { - scoped_ptr output( - context->OpenForInsert(filename, insertion_point)); - io::Printer printer(output.get(), '$'); - printer.Print("// inserted $name$\n", "name", insertion_point); - } -}; - -// This test verifies that all the expected insertion points exist. It does -// not verify that they are correctly-placed; that would require actually -// compiling the output which is a bit more than I care to do for this test. -TEST(CppPluginTest, PluginTest) { - File::WriteStringToFileOrDie( - "syntax = \"proto2\";\n" - "package foo;\n" - "message Bar {\n" - " message Baz {}\n" - "}\n", - TestTempDir() + "/test.proto"); - - google::protobuf::compiler::CommandLineInterface cli; - cli.SetInputsAreProtoPathRelative(true); - - CppGenerator cpp_generator; - TestGenerator test_generator; - cli.RegisterGenerator("--cpp_out", &cpp_generator, ""); - cli.RegisterGenerator("--test_out", &test_generator, ""); - - string proto_path = "-I" + TestTempDir(); - string cpp_out = "--cpp_out=" + TestTempDir(); - string test_out = "--test_out=" + TestTempDir(); - - const char* argv[] = { - "protoc", - proto_path.c_str(), - cpp_out.c_str(), - test_out.c_str(), - "test.proto" - }; - - EXPECT_EQ(0, cli.Run(5, argv)); -} - -} // namespace -} // namespace cpp -} // namespace compiler -} // namespace protobuf -} // namespace google diff --git a/modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/cpp/cpp_primitive_field.cc b/modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/cpp/cpp_primitive_field.cc deleted file mode 100644 index 1c35fefa1..000000000 --- a/modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/cpp/cpp_primitive_field.cc +++ /dev/null @@ -1,387 +0,0 @@ -// Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// http://code.google.com/p/protobuf/ -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -// Author: kenton@google.com (Kenton Varda) -// Based on original Protocol Buffers design by -// Sanjay Ghemawat, Jeff Dean, and others. - -#include -#include -#include -#include -#include - -namespace google { -namespace protobuf { -namespace compiler { -namespace cpp { - -using internal::WireFormatLite; - -namespace { - -// For encodings with fixed sizes, returns that size in bytes. Otherwise -// returns -1. -int FixedSize(FieldDescriptor::Type type) { - switch (type) { - case FieldDescriptor::TYPE_INT32 : return -1; - case FieldDescriptor::TYPE_INT64 : return -1; - case FieldDescriptor::TYPE_UINT32 : return -1; - case FieldDescriptor::TYPE_UINT64 : return -1; - case FieldDescriptor::TYPE_SINT32 : return -1; - case FieldDescriptor::TYPE_SINT64 : return -1; - case FieldDescriptor::TYPE_FIXED32 : return WireFormatLite::kFixed32Size; - case FieldDescriptor::TYPE_FIXED64 : return WireFormatLite::kFixed64Size; - case FieldDescriptor::TYPE_SFIXED32: return WireFormatLite::kSFixed32Size; - case FieldDescriptor::TYPE_SFIXED64: return WireFormatLite::kSFixed64Size; - case FieldDescriptor::TYPE_FLOAT : return WireFormatLite::kFloatSize; - case FieldDescriptor::TYPE_DOUBLE : return WireFormatLite::kDoubleSize; - - case FieldDescriptor::TYPE_BOOL : return WireFormatLite::kBoolSize; - case FieldDescriptor::TYPE_ENUM : return -1; - - case FieldDescriptor::TYPE_STRING : return -1; - case FieldDescriptor::TYPE_BYTES : return -1; - case FieldDescriptor::TYPE_GROUP : return -1; - case FieldDescriptor::TYPE_MESSAGE : return -1; - - // No default because we want the compiler to complain if any new - // types are added. - } - GOOGLE_LOG(FATAL) << "Can't get here."; - return -1; -} - -void SetPrimitiveVariables(const FieldDescriptor* descriptor, - map* variables, - const Options& options) { - SetCommonFieldVariables(descriptor, variables, options); - (*variables)["type"] = PrimitiveTypeName(descriptor->cpp_type()); - (*variables)["default"] = DefaultValue(descriptor); - (*variables)["tag"] = SimpleItoa(internal::WireFormat::MakeTag(descriptor)); - int fixed_size = FixedSize(descriptor->type()); - if (fixed_size != -1) { - (*variables)["fixed_size"] = SimpleItoa(fixed_size); - } - (*variables)["wire_format_field_type"] = - "::google::protobuf::internal::WireFormatLite::" + FieldDescriptorProto_Type_Name( - static_cast(descriptor->type())); -} - -} // namespace - -// =================================================================== - -PrimitiveFieldGenerator:: -PrimitiveFieldGenerator(const FieldDescriptor* descriptor, - const Options& options) - : descriptor_(descriptor) { - SetPrimitiveVariables(descriptor, &variables_, options); -} - -PrimitiveFieldGenerator::~PrimitiveFieldGenerator() {} - -void PrimitiveFieldGenerator:: -GeneratePrivateMembers(io::Printer* printer) const { - printer->Print(variables_, "$type$ $name$_;\n"); -} - -void PrimitiveFieldGenerator:: -GenerateAccessorDeclarations(io::Printer* printer) const { - printer->Print(variables_, - "inline $type$ $name$() const$deprecation$;\n" - "inline void set_$name$($type$ value)$deprecation$;\n"); -} - -void PrimitiveFieldGenerator:: -GenerateInlineAccessorDefinitions(io::Printer* printer) const { - printer->Print(variables_, - "inline $type$ $classname$::$name$() const {\n" - " return $name$_;\n" - "}\n" - "inline void $classname$::set_$name$($type$ value) {\n" - " set_has_$name$();\n" - " $name$_ = value;\n" - "}\n"); -} - -void PrimitiveFieldGenerator:: -GenerateClearingCode(io::Printer* printer) const { - printer->Print(variables_, "$name$_ = $default$;\n"); -} - -void PrimitiveFieldGenerator:: -GenerateMergingCode(io::Printer* printer) const { - printer->Print(variables_, "set_$name$(from.$name$());\n"); -} - -void PrimitiveFieldGenerator:: -GenerateSwappingCode(io::Printer* printer) const { - printer->Print(variables_, "std::swap($name$_, other->$name$_);\n"); -} - -void PrimitiveFieldGenerator:: -GenerateConstructorCode(io::Printer* printer) const { - printer->Print(variables_, "$name$_ = $default$;\n"); -} - -void PrimitiveFieldGenerator:: -GenerateMergeFromCodedStream(io::Printer* printer) const { - printer->Print(variables_, - "DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<\n" - " $type$, $wire_format_field_type$>(\n" - " input, &$name$_)));\n" - "set_has_$name$();\n"); -} - -void PrimitiveFieldGenerator:: -GenerateSerializeWithCachedSizes(io::Printer* printer) const { - printer->Print(variables_, - "::google::protobuf::internal::WireFormatLite::Write$declared_type$(" - "$number$, this->$name$(), output);\n"); -} - -void PrimitiveFieldGenerator:: -GenerateSerializeWithCachedSizesToArray(io::Printer* printer) const { - printer->Print(variables_, - "target = ::google::protobuf::internal::WireFormatLite::Write$declared_type$ToArray(" - "$number$, this->$name$(), target);\n"); -} - -void PrimitiveFieldGenerator:: -GenerateByteSize(io::Printer* printer) const { - int fixed_size = FixedSize(descriptor_->type()); - if (fixed_size == -1) { - printer->Print(variables_, - "total_size += $tag_size$ +\n" - " ::google::protobuf::internal::WireFormatLite::$declared_type$Size(\n" - " this->$name$());\n"); - } else { - printer->Print(variables_, - "total_size += $tag_size$ + $fixed_size$;\n"); - } -} - -// =================================================================== - -RepeatedPrimitiveFieldGenerator:: -RepeatedPrimitiveFieldGenerator(const FieldDescriptor* descriptor, - const Options& options) - : descriptor_(descriptor) { - SetPrimitiveVariables(descriptor, &variables_, options); - - if (descriptor->options().packed()) { - variables_["packed_reader"] = "ReadPackedPrimitive"; - variables_["repeated_reader"] = "ReadRepeatedPrimitiveNoInline"; - } else { - variables_["packed_reader"] = "ReadPackedPrimitiveNoInline"; - variables_["repeated_reader"] = "ReadRepeatedPrimitive"; - } -} - -RepeatedPrimitiveFieldGenerator::~RepeatedPrimitiveFieldGenerator() {} - -void RepeatedPrimitiveFieldGenerator:: -GeneratePrivateMembers(io::Printer* printer) const { - printer->Print(variables_, - "::google::protobuf::RepeatedField< $type$ > $name$_;\n"); - if (descriptor_->options().packed() && HasGeneratedMethods(descriptor_->file())) { - printer->Print(variables_, - "mutable int _$name$_cached_byte_size_;\n"); - } -} - -void RepeatedPrimitiveFieldGenerator:: -GenerateAccessorDeclarations(io::Printer* printer) const { - printer->Print(variables_, - "inline $type$ $name$(int index) const$deprecation$;\n" - "inline void set_$name$(int index, $type$ value)$deprecation$;\n" - "inline void add_$name$($type$ value)$deprecation$;\n"); - printer->Print(variables_, - "inline const ::google::protobuf::RepeatedField< $type$ >&\n" - " $name$() const$deprecation$;\n" - "inline ::google::protobuf::RepeatedField< $type$ >*\n" - " mutable_$name$()$deprecation$;\n"); -} - -void RepeatedPrimitiveFieldGenerator:: -GenerateInlineAccessorDefinitions(io::Printer* printer) const { - printer->Print(variables_, - "inline $type$ $classname$::$name$(int index) const {\n" - " return $name$_.Get(index);\n" - "}\n" - "inline void $classname$::set_$name$(int index, $type$ value) {\n" - " $name$_.Set(index, value);\n" - "}\n" - "inline void $classname$::add_$name$($type$ value) {\n" - " $name$_.Add(value);\n" - "}\n"); - printer->Print(variables_, - "inline const ::google::protobuf::RepeatedField< $type$ >&\n" - "$classname$::$name$() const {\n" - " return $name$_;\n" - "}\n" - "inline ::google::protobuf::RepeatedField< $type$ >*\n" - "$classname$::mutable_$name$() {\n" - " return &$name$_;\n" - "}\n"); -} - -void RepeatedPrimitiveFieldGenerator:: -GenerateClearingCode(io::Printer* printer) const { - printer->Print(variables_, "$name$_.Clear();\n"); -} - -void RepeatedPrimitiveFieldGenerator:: -GenerateMergingCode(io::Printer* printer) const { - printer->Print(variables_, "$name$_.MergeFrom(from.$name$_);\n"); -} - -void RepeatedPrimitiveFieldGenerator:: -GenerateSwappingCode(io::Printer* printer) const { - printer->Print(variables_, "$name$_.Swap(&other->$name$_);\n"); -} - -void RepeatedPrimitiveFieldGenerator:: -GenerateConstructorCode(io::Printer* printer) const { - // Not needed for repeated fields. -} - -void RepeatedPrimitiveFieldGenerator:: -GenerateMergeFromCodedStream(io::Printer* printer) const { - printer->Print(variables_, - "DO_((::google::protobuf::internal::WireFormatLite::$repeated_reader$<\n" - " $type$, $wire_format_field_type$>(\n" - " $tag_size$, $tag$, input, this->mutable_$name$())));\n"); -} - -void RepeatedPrimitiveFieldGenerator:: -GenerateMergeFromCodedStreamWithPacking(io::Printer* printer) const { - printer->Print(variables_, - "DO_((::google::protobuf::internal::WireFormatLite::$packed_reader$<\n" - " $type$, $wire_format_field_type$>(\n" - " input, this->mutable_$name$())));\n"); -} - -void RepeatedPrimitiveFieldGenerator:: -GenerateSerializeWithCachedSizes(io::Printer* printer) const { - if (descriptor_->options().packed()) { - // Write the tag and the size. - printer->Print(variables_, - "if (this->$name$_size() > 0) {\n" - " ::google::protobuf::internal::WireFormatLite::WriteTag(" - "$number$, " - "::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED, " - "output);\n" - " output->WriteVarint32(_$name$_cached_byte_size_);\n" - "}\n"); - } - printer->Print(variables_, - "for (int i = 0; i < this->$name$_size(); i++) {\n"); - if (descriptor_->options().packed()) { - printer->Print(variables_, - " ::google::protobuf::internal::WireFormatLite::Write$declared_type$NoTag(\n" - " this->$name$(i), output);\n"); - } else { - printer->Print(variables_, - " ::google::protobuf::internal::WireFormatLite::Write$declared_type$(\n" - " $number$, this->$name$(i), output);\n"); - } - printer->Print("}\n"); -} - -void RepeatedPrimitiveFieldGenerator:: -GenerateSerializeWithCachedSizesToArray(io::Printer* printer) const { - if (descriptor_->options().packed()) { - // Write the tag and the size. - printer->Print(variables_, - "if (this->$name$_size() > 0) {\n" - " target = ::google::protobuf::internal::WireFormatLite::WriteTagToArray(\n" - " $number$,\n" - " ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED,\n" - " target);\n" - " target = ::google::protobuf::io::CodedOutputStream::WriteVarint32ToArray(\n" - " _$name$_cached_byte_size_, target);\n" - "}\n"); - } - printer->Print(variables_, - "for (int i = 0; i < this->$name$_size(); i++) {\n"); - if (descriptor_->options().packed()) { - printer->Print(variables_, - " target = ::google::protobuf::internal::WireFormatLite::\n" - " Write$declared_type$NoTagToArray(this->$name$(i), target);\n"); - } else { - printer->Print(variables_, - " target = ::google::protobuf::internal::WireFormatLite::\n" - " Write$declared_type$ToArray($number$, this->$name$(i), target);\n"); - } - printer->Print("}\n"); -} - -void RepeatedPrimitiveFieldGenerator:: -GenerateByteSize(io::Printer* printer) const { - printer->Print(variables_, - "{\n" - " int data_size = 0;\n"); - printer->Indent(); - int fixed_size = FixedSize(descriptor_->type()); - if (fixed_size == -1) { - printer->Print(variables_, - "for (int i = 0; i < this->$name$_size(); i++) {\n" - " data_size += ::google::protobuf::internal::WireFormatLite::\n" - " $declared_type$Size(this->$name$(i));\n" - "}\n"); - } else { - printer->Print(variables_, - "data_size = $fixed_size$ * this->$name$_size();\n"); - } - - if (descriptor_->options().packed()) { - printer->Print(variables_, - "if (data_size > 0) {\n" - " total_size += $tag_size$ +\n" - " ::google::protobuf::internal::WireFormatLite::Int32Size(data_size);\n" - "}\n" - "GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();\n" - "_$name$_cached_byte_size_ = data_size;\n" - "GOOGLE_SAFE_CONCURRENT_WRITES_END();\n" - "total_size += data_size;\n"); - } else { - printer->Print(variables_, - "total_size += $tag_size$ * this->$name$_size() + data_size;\n"); - } - printer->Outdent(); - printer->Print("}\n"); -} - -} // namespace cpp -} // namespace compiler -} // namespace protobuf -} // namespace google diff --git a/modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/cpp/cpp_primitive_field.h b/modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/cpp/cpp_primitive_field.h deleted file mode 100644 index 48249c407..000000000 --- a/modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/cpp/cpp_primitive_field.h +++ /dev/null @@ -1,105 +0,0 @@ -// Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// http://code.google.com/p/protobuf/ -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -// Author: kenton@google.com (Kenton Varda) -// Based on original Protocol Buffers design by -// Sanjay Ghemawat, Jeff Dean, and others. - -#ifndef GOOGLE_PROTOBUF_COMPILER_CPP_PRIMITIVE_FIELD_H__ -#define GOOGLE_PROTOBUF_COMPILER_CPP_PRIMITIVE_FIELD_H__ - -#include -#include -#include - -namespace google { -namespace protobuf { -namespace compiler { -namespace cpp { - -class PrimitiveFieldGenerator : public FieldGenerator { - public: - explicit PrimitiveFieldGenerator(const FieldDescriptor* descriptor, - const Options& options); - ~PrimitiveFieldGenerator(); - - // implements FieldGenerator --------------------------------------- - void GeneratePrivateMembers(io::Printer* printer) const; - void GenerateAccessorDeclarations(io::Printer* printer) const; - void GenerateInlineAccessorDefinitions(io::Printer* printer) const; - void GenerateClearingCode(io::Printer* printer) const; - void GenerateMergingCode(io::Printer* printer) const; - void GenerateSwappingCode(io::Printer* printer) const; - void GenerateConstructorCode(io::Printer* printer) const; - void GenerateMergeFromCodedStream(io::Printer* printer) const; - void GenerateSerializeWithCachedSizes(io::Printer* printer) const; - void GenerateSerializeWithCachedSizesToArray(io::Printer* printer) const; - void GenerateByteSize(io::Printer* printer) const; - - private: - const FieldDescriptor* descriptor_; - map variables_; - - GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(PrimitiveFieldGenerator); -}; - -class RepeatedPrimitiveFieldGenerator : public FieldGenerator { - public: - explicit RepeatedPrimitiveFieldGenerator(const FieldDescriptor* descriptor, - const Options& options); - ~RepeatedPrimitiveFieldGenerator(); - - // implements FieldGenerator --------------------------------------- - void GeneratePrivateMembers(io::Printer* printer) const; - void GenerateAccessorDeclarations(io::Printer* printer) const; - void GenerateInlineAccessorDefinitions(io::Printer* printer) const; - void GenerateClearingCode(io::Printer* printer) const; - void GenerateMergingCode(io::Printer* printer) const; - void GenerateSwappingCode(io::Printer* printer) const; - void GenerateConstructorCode(io::Printer* printer) const; - void GenerateMergeFromCodedStream(io::Printer* printer) const; - void GenerateMergeFromCodedStreamWithPacking(io::Printer* printer) const; - void GenerateSerializeWithCachedSizes(io::Printer* printer) const; - void GenerateSerializeWithCachedSizesToArray(io::Printer* printer) const; - void GenerateByteSize(io::Printer* printer) const; - - private: - const FieldDescriptor* descriptor_; - map variables_; - - GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(RepeatedPrimitiveFieldGenerator); -}; - -} // namespace cpp -} // namespace compiler -} // namespace protobuf - -} // namespace google -#endif // GOOGLE_PROTOBUF_COMPILER_CPP_PRIMITIVE_FIELD_H__ diff --git a/modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/cpp/cpp_service.cc b/modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/cpp/cpp_service.cc deleted file mode 100644 index d20018ea2..000000000 --- a/modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/cpp/cpp_service.cc +++ /dev/null @@ -1,334 +0,0 @@ -// Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// http://code.google.com/p/protobuf/ -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -// Author: kenton@google.com (Kenton Varda) -// Based on original Protocol Buffers design by -// Sanjay Ghemawat, Jeff Dean, and others. - -#include -#include -#include -#include - -namespace google { -namespace protobuf { -namespace compiler { -namespace cpp { - -ServiceGenerator::ServiceGenerator(const ServiceDescriptor* descriptor, - const Options& options) - : descriptor_(descriptor) { - vars_["classname"] = descriptor_->name(); - vars_["full_name"] = descriptor_->full_name(); - if (options.dllexport_decl.empty()) { - vars_["dllexport"] = ""; - } else { - vars_["dllexport"] = options.dllexport_decl + " "; - } -} - -ServiceGenerator::~ServiceGenerator() {} - -void ServiceGenerator::GenerateDeclarations(io::Printer* printer) { - // Forward-declare the stub type. - printer->Print(vars_, - "class $classname$_Stub;\n" - "\n"); - - GenerateInterface(printer); - GenerateStubDefinition(printer); -} - -void ServiceGenerator::GenerateInterface(io::Printer* printer) { - printer->Print(vars_, - "class $dllexport$$classname$ : public ::google::protobuf::Service {\n" - " protected:\n" - " // This class should be treated as an abstract interface.\n" - " inline $classname$() {};\n" - " public:\n" - " virtual ~$classname$();\n"); - printer->Indent(); - - printer->Print(vars_, - "\n" - "typedef $classname$_Stub Stub;\n" - "\n" - "static const ::google::protobuf::ServiceDescriptor* descriptor();\n" - "\n"); - - GenerateMethodSignatures(VIRTUAL, printer); - - printer->Print( - "\n" - "// implements Service ----------------------------------------------\n" - "\n" - "const ::google::protobuf::ServiceDescriptor* GetDescriptor();\n" - "void CallMethod(const ::google::protobuf::MethodDescriptor* method,\n" - " ::google::protobuf::RpcController* controller,\n" - " const ::google::protobuf::Message* request,\n" - " ::google::protobuf::Message* response,\n" - " ::google::protobuf::Closure* done);\n" - "const ::google::protobuf::Message& GetRequestPrototype(\n" - " const ::google::protobuf::MethodDescriptor* method) const;\n" - "const ::google::protobuf::Message& GetResponsePrototype(\n" - " const ::google::protobuf::MethodDescriptor* method) const;\n"); - - printer->Outdent(); - printer->Print(vars_, - "\n" - " private:\n" - " GOOGLE_DISALLOW_EVIL_CONSTRUCTORS($classname$);\n" - "};\n" - "\n"); -} - -void ServiceGenerator::GenerateStubDefinition(io::Printer* printer) { - printer->Print(vars_, - "class $dllexport$$classname$_Stub : public $classname$ {\n" - " public:\n"); - - printer->Indent(); - - printer->Print(vars_, - "$classname$_Stub(::google::protobuf::RpcChannel* channel);\n" - "$classname$_Stub(::google::protobuf::RpcChannel* channel,\n" - " ::google::protobuf::Service::ChannelOwnership ownership);\n" - "~$classname$_Stub();\n" - "\n" - "inline ::google::protobuf::RpcChannel* channel() { return channel_; }\n" - "\n" - "// implements $classname$ ------------------------------------------\n" - "\n"); - - GenerateMethodSignatures(NON_VIRTUAL, printer); - - printer->Outdent(); - printer->Print(vars_, - " private:\n" - " ::google::protobuf::RpcChannel* channel_;\n" - " bool owns_channel_;\n" - " GOOGLE_DISALLOW_EVIL_CONSTRUCTORS($classname$_Stub);\n" - "};\n" - "\n"); -} - -void ServiceGenerator::GenerateMethodSignatures( - VirtualOrNon virtual_or_non, io::Printer* printer) { - for (int i = 0; i < descriptor_->method_count(); i++) { - const MethodDescriptor* method = descriptor_->method(i); - map sub_vars; - sub_vars["name"] = method->name(); - sub_vars["input_type"] = ClassName(method->input_type(), true); - sub_vars["output_type"] = ClassName(method->output_type(), true); - sub_vars["virtual"] = virtual_or_non == VIRTUAL ? "virtual " : ""; - - printer->Print(sub_vars, - "$virtual$void $name$(::google::protobuf::RpcController* controller,\n" - " const $input_type$* request,\n" - " $output_type$* response,\n" - " ::google::protobuf::Closure* done);\n"); - } -} - -// =================================================================== - -void ServiceGenerator::GenerateDescriptorInitializer( - io::Printer* printer, int index) { - map vars; - vars["classname"] = descriptor_->name(); - vars["index"] = SimpleItoa(index); - - printer->Print(vars, - "$classname$_descriptor_ = file->service($index$);\n"); -} - -// =================================================================== - -void ServiceGenerator::GenerateImplementation(io::Printer* printer) { - printer->Print(vars_, - "$classname$::~$classname$() {}\n" - "\n" - "const ::google::protobuf::ServiceDescriptor* $classname$::descriptor() {\n" - " protobuf_AssignDescriptorsOnce();\n" - " return $classname$_descriptor_;\n" - "}\n" - "\n" - "const ::google::protobuf::ServiceDescriptor* $classname$::GetDescriptor() {\n" - " protobuf_AssignDescriptorsOnce();\n" - " return $classname$_descriptor_;\n" - "}\n" - "\n"); - - // Generate methods of the interface. - GenerateNotImplementedMethods(printer); - GenerateCallMethod(printer); - GenerateGetPrototype(REQUEST, printer); - GenerateGetPrototype(RESPONSE, printer); - - // Generate stub implementation. - printer->Print(vars_, - "$classname$_Stub::$classname$_Stub(::google::protobuf::RpcChannel* channel)\n" - " : channel_(channel), owns_channel_(false) {}\n" - "$classname$_Stub::$classname$_Stub(\n" - " ::google::protobuf::RpcChannel* channel,\n" - " ::google::protobuf::Service::ChannelOwnership ownership)\n" - " : channel_(channel),\n" - " owns_channel_(ownership == ::google::protobuf::Service::STUB_OWNS_CHANNEL) {}\n" - "$classname$_Stub::~$classname$_Stub() {\n" - " if (owns_channel_) delete channel_;\n" - "}\n" - "\n"); - - GenerateStubMethods(printer); -} - -void ServiceGenerator::GenerateNotImplementedMethods(io::Printer* printer) { - for (int i = 0; i < descriptor_->method_count(); i++) { - const MethodDescriptor* method = descriptor_->method(i); - map sub_vars; - sub_vars["classname"] = descriptor_->name(); - sub_vars["name"] = method->name(); - sub_vars["index"] = SimpleItoa(i); - sub_vars["input_type"] = ClassName(method->input_type(), true); - sub_vars["output_type"] = ClassName(method->output_type(), true); - - printer->Print(sub_vars, - "void $classname$::$name$(::google::protobuf::RpcController* controller,\n" - " const $input_type$*,\n" - " $output_type$*,\n" - " ::google::protobuf::Closure* done) {\n" - " controller->SetFailed(\"Method $name$() not implemented.\");\n" - " done->Run();\n" - "}\n" - "\n"); - } -} - -void ServiceGenerator::GenerateCallMethod(io::Printer* printer) { - printer->Print(vars_, - "void $classname$::CallMethod(const ::google::protobuf::MethodDescriptor* method,\n" - " ::google::protobuf::RpcController* controller,\n" - " const ::google::protobuf::Message* request,\n" - " ::google::protobuf::Message* response,\n" - " ::google::protobuf::Closure* done) {\n" - " GOOGLE_DCHECK_EQ(method->service(), $classname$_descriptor_);\n" - " switch(method->index()) {\n"); - - for (int i = 0; i < descriptor_->method_count(); i++) { - const MethodDescriptor* method = descriptor_->method(i); - map sub_vars; - sub_vars["name"] = method->name(); - sub_vars["index"] = SimpleItoa(i); - sub_vars["input_type"] = ClassName(method->input_type(), true); - sub_vars["output_type"] = ClassName(method->output_type(), true); - - // Note: down_cast does not work here because it only works on pointers, - // not references. - printer->Print(sub_vars, - " case $index$:\n" - " $name$(controller,\n" - " ::google::protobuf::down_cast(request),\n" - " ::google::protobuf::down_cast< $output_type$*>(response),\n" - " done);\n" - " break;\n"); - } - - printer->Print(vars_, - " default:\n" - " GOOGLE_LOG(FATAL) << \"Bad method index; this should never happen.\";\n" - " break;\n" - " }\n" - "}\n" - "\n"); -} - -void ServiceGenerator::GenerateGetPrototype(RequestOrResponse which, - io::Printer* printer) { - if (which == REQUEST) { - printer->Print(vars_, - "const ::google::protobuf::Message& $classname$::GetRequestPrototype(\n"); - } else { - printer->Print(vars_, - "const ::google::protobuf::Message& $classname$::GetResponsePrototype(\n"); - } - - printer->Print(vars_, - " const ::google::protobuf::MethodDescriptor* method) const {\n" - " GOOGLE_DCHECK_EQ(method->service(), descriptor());\n" - " switch(method->index()) {\n"); - - for (int i = 0; i < descriptor_->method_count(); i++) { - const MethodDescriptor* method = descriptor_->method(i); - const Descriptor* type = - (which == REQUEST) ? method->input_type() : method->output_type(); - - map sub_vars; - sub_vars["index"] = SimpleItoa(i); - sub_vars["type"] = ClassName(type, true); - - printer->Print(sub_vars, - " case $index$:\n" - " return $type$::default_instance();\n"); - } - - printer->Print(vars_, - " default:\n" - " GOOGLE_LOG(FATAL) << \"Bad method index; this should never happen.\";\n" - " return *reinterpret_cast< ::google::protobuf::Message*>(NULL);\n" - " }\n" - "}\n" - "\n"); -} - -void ServiceGenerator::GenerateStubMethods(io::Printer* printer) { - for (int i = 0; i < descriptor_->method_count(); i++) { - const MethodDescriptor* method = descriptor_->method(i); - map sub_vars; - sub_vars["classname"] = descriptor_->name(); - sub_vars["name"] = method->name(); - sub_vars["index"] = SimpleItoa(i); - sub_vars["input_type"] = ClassName(method->input_type(), true); - sub_vars["output_type"] = ClassName(method->output_type(), true); - - printer->Print(sub_vars, - "void $classname$_Stub::$name$(::google::protobuf::RpcController* controller,\n" - " const $input_type$* request,\n" - " $output_type$* response,\n" - " ::google::protobuf::Closure* done) {\n" - " channel_->CallMethod(descriptor()->method($index$),\n" - " controller, request, response, done);\n" - "}\n"); - } -} - -} // namespace cpp -} // namespace compiler -} // namespace protobuf -} // namespace google diff --git a/modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/cpp/cpp_service.h b/modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/cpp/cpp_service.h deleted file mode 100644 index 820f9f5f7..000000000 --- a/modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/cpp/cpp_service.h +++ /dev/null @@ -1,119 +0,0 @@ -// Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// http://code.google.com/p/protobuf/ -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -// Author: kenton@google.com (Kenton Varda) -// Based on original Protocol Buffers design by -// Sanjay Ghemawat, Jeff Dean, and others. - -#ifndef GOOGLE_PROTOBUF_COMPILER_CPP_SERVICE_H__ -#define GOOGLE_PROTOBUF_COMPILER_CPP_SERVICE_H__ - -#include -#include -#include -#include -#include - -namespace google { -namespace protobuf { - namespace io { - class Printer; // printer.h - } -} - -namespace protobuf { -namespace compiler { -namespace cpp { - -class ServiceGenerator { - public: - // See generator.cc for the meaning of dllexport_decl. - explicit ServiceGenerator(const ServiceDescriptor* descriptor, - const Options& options); - ~ServiceGenerator(); - - // Header stuff. - - // Generate the class definitions for the service's interface and the - // stub implementation. - void GenerateDeclarations(io::Printer* printer); - - // Source file stuff. - - // Generate code that initializes the global variable storing the service's - // descriptor. - void GenerateDescriptorInitializer(io::Printer* printer, int index); - - // Generate implementations of everything declared by GenerateDeclarations(). - void GenerateImplementation(io::Printer* printer); - - private: - enum RequestOrResponse { REQUEST, RESPONSE }; - enum VirtualOrNon { VIRTUAL, NON_VIRTUAL }; - - // Header stuff. - - // Generate the service abstract interface. - void GenerateInterface(io::Printer* printer); - - // Generate the stub class definition. - void GenerateStubDefinition(io::Printer* printer); - - // Prints signatures for all methods in the - void GenerateMethodSignatures(VirtualOrNon virtual_or_non, - io::Printer* printer); - - // Source file stuff. - - // Generate the default implementations of the service methods, which - // produce a "not implemented" error. - void GenerateNotImplementedMethods(io::Printer* printer); - - // Generate the CallMethod() method of the service. - void GenerateCallMethod(io::Printer* printer); - - // Generate the Get{Request,Response}Prototype() methods. - void GenerateGetPrototype(RequestOrResponse which, io::Printer* printer); - - // Generate the stub's implementations of the service methods. - void GenerateStubMethods(io::Printer* printer); - - const ServiceDescriptor* descriptor_; - map vars_; - - GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ServiceGenerator); -}; - -} // namespace cpp -} // namespace compiler -} // namespace protobuf - -} // namespace google -#endif // GOOGLE_PROTOBUF_COMPILER_CPP_SERVICE_H__ diff --git a/modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/cpp/cpp_string_field.cc b/modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/cpp/cpp_string_field.cc deleted file mode 100644 index 9c0911ac9..000000000 --- a/modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/cpp/cpp_string_field.cc +++ /dev/null @@ -1,491 +0,0 @@ -// Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// http://code.google.com/p/protobuf/ -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -// Author: kenton@google.com (Kenton Varda) -// Based on original Protocol Buffers design by -// Sanjay Ghemawat, Jeff Dean, and others. - -#include -#include -#include -#include -#include - -namespace google { -namespace protobuf { -namespace compiler { -namespace cpp { - -namespace { - -void SetStringVariables(const FieldDescriptor* descriptor, - map* variables, - const Options& options) { - SetCommonFieldVariables(descriptor, variables, options); - (*variables)["default"] = DefaultValue(descriptor); - (*variables)["default_length"] = - SimpleItoa(descriptor->default_value_string().length()); - (*variables)["default_variable"] = descriptor->default_value_string().empty() - ? "&::google::protobuf::internal::kEmptyString" - : "_default_" + FieldName(descriptor) + "_"; - (*variables)["pointer_type"] = - descriptor->type() == FieldDescriptor::TYPE_BYTES ? "void" : "char"; -} - -} // namespace - -// =================================================================== - -StringFieldGenerator:: -StringFieldGenerator(const FieldDescriptor* descriptor, - const Options& options) - : descriptor_(descriptor) { - SetStringVariables(descriptor, &variables_, options); -} - -StringFieldGenerator::~StringFieldGenerator() {} - -void StringFieldGenerator:: -GeneratePrivateMembers(io::Printer* printer) const { - printer->Print(variables_, "::std::string* $name$_;\n"); - if (!descriptor_->default_value_string().empty()) { - printer->Print(variables_, "static ::std::string* $default_variable$;\n"); - } -} - -void StringFieldGenerator:: -GenerateAccessorDeclarations(io::Printer* printer) const { - // If we're using StringFieldGenerator for a field with a ctype, it's - // because that ctype isn't actually implemented. In particular, this is - // true of ctype=CORD and ctype=STRING_PIECE in the open source release. - // We aren't releasing Cord because it has too many Google-specific - // dependencies and we aren't releasing StringPiece because it's hardly - // useful outside of Google and because it would get confusing to have - // multiple instances of the StringPiece class in different libraries (PCRE - // already includes it for their C++ bindings, which came from Google). - // - // In any case, we make all the accessors private while still actually - // using a string to represent the field internally. This way, we can - // guarantee that if we do ever implement the ctype, it won't break any - // existing users who might be -- for whatever reason -- already using .proto - // files that applied the ctype. The field can still be accessed via the - // reflection interface since the reflection interface is independent of - // the string's underlying representation. - if (descriptor_->options().ctype() != FieldOptions::STRING) { - printer->Outdent(); - printer->Print( - " private:\n" - " // Hidden due to unknown ctype option.\n"); - printer->Indent(); - } - - printer->Print(variables_, - "inline const ::std::string& $name$() const$deprecation$;\n" - "inline void set_$name$(const ::std::string& value)$deprecation$;\n" - "inline void set_$name$(const char* value)$deprecation$;\n" - "inline void set_$name$(const $pointer_type$* value, size_t size)" - "$deprecation$;\n" - "inline ::std::string* mutable_$name$()$deprecation$;\n" - "inline ::std::string* release_$name$()$deprecation$;\n" - "inline void set_allocated_$name$(::std::string* $name$)$deprecation$;\n"); - - - if (descriptor_->options().ctype() != FieldOptions::STRING) { - printer->Outdent(); - printer->Print(" public:\n"); - printer->Indent(); - } -} - -void StringFieldGenerator:: -GenerateInlineAccessorDefinitions(io::Printer* printer) const { - printer->Print(variables_, - "inline const ::std::string& $classname$::$name$() const {\n" - " return *$name$_;\n" - "}\n" - "inline void $classname$::set_$name$(const ::std::string& value) {\n" - " set_has_$name$();\n" - " if ($name$_ == $default_variable$) {\n" - " $name$_ = new ::std::string;\n" - " }\n" - " $name$_->assign(value);\n" - "}\n" - "inline void $classname$::set_$name$(const char* value) {\n" - " set_has_$name$();\n" - " if ($name$_ == $default_variable$) {\n" - " $name$_ = new ::std::string;\n" - " }\n" - " $name$_->assign(value);\n" - "}\n" - "inline " - "void $classname$::set_$name$(const $pointer_type$* value, size_t size) {\n" - " set_has_$name$();\n" - " if ($name$_ == $default_variable$) {\n" - " $name$_ = new ::std::string;\n" - " }\n" - " $name$_->assign(reinterpret_cast(value), size);\n" - "}\n" - "inline ::std::string* $classname$::mutable_$name$() {\n" - " set_has_$name$();\n" - " if ($name$_ == $default_variable$) {\n"); - if (descriptor_->default_value_string().empty()) { - printer->Print(variables_, - " $name$_ = new ::std::string;\n"); - } else { - printer->Print(variables_, - " $name$_ = new ::std::string(*$default_variable$);\n"); - } - printer->Print(variables_, - " }\n" - " return $name$_;\n" - "}\n" - "inline ::std::string* $classname$::release_$name$() {\n" - " clear_has_$name$();\n" - " if ($name$_ == $default_variable$) {\n" - " return NULL;\n" - " } else {\n" - " ::std::string* temp = $name$_;\n" - " $name$_ = const_cast< ::std::string*>($default_variable$);\n" - " return temp;\n" - " }\n" - "}\n" - "inline void $classname$::set_allocated_$name$(::std::string* $name$) {\n" - " if ($name$_ != $default_variable$) {\n" - " delete $name$_;\n" - " }\n" - " if ($name$) {\n" - " set_has_$name$();\n" - " $name$_ = $name$;\n" - " } else {\n" - " clear_has_$name$();\n" - " $name$_ = const_cast< ::std::string*>($default_variable$);\n" - " }\n" - "}\n"); -} - -void StringFieldGenerator:: -GenerateNonInlineAccessorDefinitions(io::Printer* printer) const { - if (!descriptor_->default_value_string().empty()) { - // Initialized in GenerateDefaultInstanceAllocator. - printer->Print(variables_, - "::std::string* $classname$::$default_variable$ = NULL;\n"); - } -} - -void StringFieldGenerator:: -GenerateClearingCode(io::Printer* printer) const { - if (descriptor_->default_value_string().empty()) { - printer->Print(variables_, - "if ($name$_ != $default_variable$) {\n" - " $name$_->clear();\n" - "}\n"); - } else { - printer->Print(variables_, - "if ($name$_ != $default_variable$) {\n" - " $name$_->assign(*$default_variable$);\n" - "}\n"); - } -} - -void StringFieldGenerator:: -GenerateMergingCode(io::Printer* printer) const { - printer->Print(variables_, "set_$name$(from.$name$());\n"); -} - -void StringFieldGenerator:: -GenerateSwappingCode(io::Printer* printer) const { - printer->Print(variables_, "std::swap($name$_, other->$name$_);\n"); -} - -void StringFieldGenerator:: -GenerateConstructorCode(io::Printer* printer) const { - printer->Print(variables_, - "$name$_ = const_cast< ::std::string*>($default_variable$);\n"); -} - -void StringFieldGenerator:: -GenerateDestructorCode(io::Printer* printer) const { - printer->Print(variables_, - "if ($name$_ != $default_variable$) {\n" - " delete $name$_;\n" - "}\n"); -} - -void StringFieldGenerator:: -GenerateDefaultInstanceAllocator(io::Printer* printer) const { - if (!descriptor_->default_value_string().empty()) { - printer->Print(variables_, - "$classname$::$default_variable$ =\n" - " new ::std::string($default$, $default_length$);\n"); - } -} - -void StringFieldGenerator:: -GenerateShutdownCode(io::Printer* printer) const { - if (!descriptor_->default_value_string().empty()) { - printer->Print(variables_, - "delete $classname$::$default_variable$;\n"); - } -} - -void StringFieldGenerator:: -GenerateMergeFromCodedStream(io::Printer* printer) const { - printer->Print(variables_, - "DO_(::google::protobuf::internal::WireFormatLite::Read$declared_type$(\n" - " input, this->mutable_$name$()));\n"); - if (HasUtf8Verification(descriptor_->file()) && - descriptor_->type() == FieldDescriptor::TYPE_STRING) { - printer->Print(variables_, - "::google::protobuf::internal::WireFormat::VerifyUTF8String(\n" - " this->$name$().data(), this->$name$().length(),\n" - " ::google::protobuf::internal::WireFormat::PARSE);\n"); - } -} - -void StringFieldGenerator:: -GenerateSerializeWithCachedSizes(io::Printer* printer) const { - if (HasUtf8Verification(descriptor_->file()) && - descriptor_->type() == FieldDescriptor::TYPE_STRING) { - printer->Print(variables_, - "::google::protobuf::internal::WireFormat::VerifyUTF8String(\n" - " this->$name$().data(), this->$name$().length(),\n" - " ::google::protobuf::internal::WireFormat::SERIALIZE);\n"); - } - printer->Print(variables_, - "::google::protobuf::internal::WireFormatLite::Write$declared_type$(\n" - " $number$, this->$name$(), output);\n"); -} - -void StringFieldGenerator:: -GenerateSerializeWithCachedSizesToArray(io::Printer* printer) const { - if (HasUtf8Verification(descriptor_->file()) && - descriptor_->type() == FieldDescriptor::TYPE_STRING) { - printer->Print(variables_, - "::google::protobuf::internal::WireFormat::VerifyUTF8String(\n" - " this->$name$().data(), this->$name$().length(),\n" - " ::google::protobuf::internal::WireFormat::SERIALIZE);\n"); - } - printer->Print(variables_, - "target =\n" - " ::google::protobuf::internal::WireFormatLite::Write$declared_type$ToArray(\n" - " $number$, this->$name$(), target);\n"); -} - -void StringFieldGenerator:: -GenerateByteSize(io::Printer* printer) const { - printer->Print(variables_, - "total_size += $tag_size$ +\n" - " ::google::protobuf::internal::WireFormatLite::$declared_type$Size(\n" - " this->$name$());\n"); -} - -// =================================================================== - -RepeatedStringFieldGenerator:: -RepeatedStringFieldGenerator(const FieldDescriptor* descriptor, - const Options& options) - : descriptor_(descriptor) { - SetStringVariables(descriptor, &variables_, options); -} - -RepeatedStringFieldGenerator::~RepeatedStringFieldGenerator() {} - -void RepeatedStringFieldGenerator:: -GeneratePrivateMembers(io::Printer* printer) const { - printer->Print(variables_, - "::google::protobuf::RepeatedPtrField< ::std::string> $name$_;\n"); -} - -void RepeatedStringFieldGenerator:: -GenerateAccessorDeclarations(io::Printer* printer) const { - // See comment above about unknown ctypes. - if (descriptor_->options().ctype() != FieldOptions::STRING) { - printer->Outdent(); - printer->Print( - " private:\n" - " // Hidden due to unknown ctype option.\n"); - printer->Indent(); - } - - printer->Print(variables_, - "inline const ::std::string& $name$(int index) const$deprecation$;\n" - "inline ::std::string* mutable_$name$(int index)$deprecation$;\n" - "inline void set_$name$(int index, const ::std::string& value)$deprecation$;\n" - "inline void set_$name$(int index, const char* value)$deprecation$;\n" - "inline " - "void set_$name$(int index, const $pointer_type$* value, size_t size)" - "$deprecation$;\n" - "inline ::std::string* add_$name$()$deprecation$;\n" - "inline void add_$name$(const ::std::string& value)$deprecation$;\n" - "inline void add_$name$(const char* value)$deprecation$;\n" - "inline void add_$name$(const $pointer_type$* value, size_t size)" - "$deprecation$;\n"); - - printer->Print(variables_, - "inline const ::google::protobuf::RepeatedPtrField< ::std::string>& $name$() const" - "$deprecation$;\n" - "inline ::google::protobuf::RepeatedPtrField< ::std::string>* mutable_$name$()" - "$deprecation$;\n"); - - if (descriptor_->options().ctype() != FieldOptions::STRING) { - printer->Outdent(); - printer->Print(" public:\n"); - printer->Indent(); - } -} - -void RepeatedStringFieldGenerator:: -GenerateInlineAccessorDefinitions(io::Printer* printer) const { - printer->Print(variables_, - "inline const ::std::string& $classname$::$name$(int index) const {\n" - " return $name$_.$cppget$(index);\n" - "}\n" - "inline ::std::string* $classname$::mutable_$name$(int index) {\n" - " return $name$_.Mutable(index);\n" - "}\n" - "inline void $classname$::set_$name$(int index, const ::std::string& value) {\n" - " $name$_.Mutable(index)->assign(value);\n" - "}\n" - "inline void $classname$::set_$name$(int index, const char* value) {\n" - " $name$_.Mutable(index)->assign(value);\n" - "}\n" - "inline void " - "$classname$::set_$name$" - "(int index, const $pointer_type$* value, size_t size) {\n" - " $name$_.Mutable(index)->assign(\n" - " reinterpret_cast(value), size);\n" - "}\n" - "inline ::std::string* $classname$::add_$name$() {\n" - " return $name$_.Add();\n" - "}\n" - "inline void $classname$::add_$name$(const ::std::string& value) {\n" - " $name$_.Add()->assign(value);\n" - "}\n" - "inline void $classname$::add_$name$(const char* value) {\n" - " $name$_.Add()->assign(value);\n" - "}\n" - "inline void " - "$classname$::add_$name$(const $pointer_type$* value, size_t size) {\n" - " $name$_.Add()->assign(reinterpret_cast(value), size);\n" - "}\n"); - printer->Print(variables_, - "inline const ::google::protobuf::RepeatedPtrField< ::std::string>&\n" - "$classname$::$name$() const {\n" - " return $name$_;\n" - "}\n" - "inline ::google::protobuf::RepeatedPtrField< ::std::string>*\n" - "$classname$::mutable_$name$() {\n" - " return &$name$_;\n" - "}\n"); -} - -void RepeatedStringFieldGenerator:: -GenerateClearingCode(io::Printer* printer) const { - printer->Print(variables_, "$name$_.Clear();\n"); -} - -void RepeatedStringFieldGenerator:: -GenerateMergingCode(io::Printer* printer) const { - printer->Print(variables_, "$name$_.MergeFrom(from.$name$_);\n"); -} - -void RepeatedStringFieldGenerator:: -GenerateSwappingCode(io::Printer* printer) const { - printer->Print(variables_, "$name$_.Swap(&other->$name$_);\n"); -} - -void RepeatedStringFieldGenerator:: -GenerateConstructorCode(io::Printer* printer) const { - // Not needed for repeated fields. -} - -void RepeatedStringFieldGenerator:: -GenerateMergeFromCodedStream(io::Printer* printer) const { - printer->Print(variables_, - "DO_(::google::protobuf::internal::WireFormatLite::Read$declared_type$(\n" - " input, this->add_$name$()));\n"); - if (HasUtf8Verification(descriptor_->file()) && - descriptor_->type() == FieldDescriptor::TYPE_STRING) { - printer->Print(variables_, - "::google::protobuf::internal::WireFormat::VerifyUTF8String(\n" - " this->$name$(this->$name$_size() - 1).data(),\n" - " this->$name$(this->$name$_size() - 1).length(),\n" - " ::google::protobuf::internal::WireFormat::PARSE);\n"); - } -} - -void RepeatedStringFieldGenerator:: -GenerateSerializeWithCachedSizes(io::Printer* printer) const { - printer->Print(variables_, - "for (int i = 0; i < this->$name$_size(); i++) {\n"); - if (HasUtf8Verification(descriptor_->file()) && - descriptor_->type() == FieldDescriptor::TYPE_STRING) { - printer->Print(variables_, - "::google::protobuf::internal::WireFormat::VerifyUTF8String(\n" - " this->$name$(i).data(), this->$name$(i).length(),\n" - " ::google::protobuf::internal::WireFormat::SERIALIZE);\n"); - } - printer->Print(variables_, - " ::google::protobuf::internal::WireFormatLite::Write$declared_type$(\n" - " $number$, this->$name$(i), output);\n" - "}\n"); -} - -void RepeatedStringFieldGenerator:: -GenerateSerializeWithCachedSizesToArray(io::Printer* printer) const { - printer->Print(variables_, - "for (int i = 0; i < this->$name$_size(); i++) {\n"); - if (HasUtf8Verification(descriptor_->file()) && - descriptor_->type() == FieldDescriptor::TYPE_STRING) { - printer->Print(variables_, - " ::google::protobuf::internal::WireFormat::VerifyUTF8String(\n" - " this->$name$(i).data(), this->$name$(i).length(),\n" - " ::google::protobuf::internal::WireFormat::SERIALIZE);\n"); - } - printer->Print(variables_, - " target = ::google::protobuf::internal::WireFormatLite::\n" - " Write$declared_type$ToArray($number$, this->$name$(i), target);\n" - "}\n"); -} - -void RepeatedStringFieldGenerator:: -GenerateByteSize(io::Printer* printer) const { - printer->Print(variables_, - "total_size += $tag_size$ * this->$name$_size();\n" - "for (int i = 0; i < this->$name$_size(); i++) {\n" - " total_size += ::google::protobuf::internal::WireFormatLite::$declared_type$Size(\n" - " this->$name$(i));\n" - "}\n"); -} - -} // namespace cpp -} // namespace compiler -} // namespace protobuf -} // namespace google diff --git a/modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/cpp/cpp_string_field.h b/modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/cpp/cpp_string_field.h deleted file mode 100644 index 3264134aa..000000000 --- a/modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/cpp/cpp_string_field.h +++ /dev/null @@ -1,108 +0,0 @@ -// Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// http://code.google.com/p/protobuf/ -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -// Author: kenton@google.com (Kenton Varda) -// Based on original Protocol Buffers design by -// Sanjay Ghemawat, Jeff Dean, and others. - -#ifndef GOOGLE_PROTOBUF_COMPILER_CPP_STRING_FIELD_H__ -#define GOOGLE_PROTOBUF_COMPILER_CPP_STRING_FIELD_H__ - -#include -#include -#include - -namespace google { -namespace protobuf { -namespace compiler { -namespace cpp { - -class StringFieldGenerator : public FieldGenerator { - public: - explicit StringFieldGenerator(const FieldDescriptor* descriptor, - const Options& options); - ~StringFieldGenerator(); - - // implements FieldGenerator --------------------------------------- - void GeneratePrivateMembers(io::Printer* printer) const; - void GenerateAccessorDeclarations(io::Printer* printer) const; - void GenerateInlineAccessorDefinitions(io::Printer* printer) const; - void GenerateNonInlineAccessorDefinitions(io::Printer* printer) const; - void GenerateClearingCode(io::Printer* printer) const; - void GenerateMergingCode(io::Printer* printer) const; - void GenerateSwappingCode(io::Printer* printer) const; - void GenerateConstructorCode(io::Printer* printer) const; - void GenerateDestructorCode(io::Printer* printer) const; - void GenerateDefaultInstanceAllocator(io::Printer* printer) const; - void GenerateShutdownCode(io::Printer* printer) const; - void GenerateMergeFromCodedStream(io::Printer* printer) const; - void GenerateSerializeWithCachedSizes(io::Printer* printer) const; - void GenerateSerializeWithCachedSizesToArray(io::Printer* printer) const; - void GenerateByteSize(io::Printer* printer) const; - - private: - const FieldDescriptor* descriptor_; - map variables_; - - GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(StringFieldGenerator); -}; - -class RepeatedStringFieldGenerator : public FieldGenerator { - public: - explicit RepeatedStringFieldGenerator(const FieldDescriptor* descriptor, - const Options& options); - ~RepeatedStringFieldGenerator(); - - // implements FieldGenerator --------------------------------------- - void GeneratePrivateMembers(io::Printer* printer) const; - void GenerateAccessorDeclarations(io::Printer* printer) const; - void GenerateInlineAccessorDefinitions(io::Printer* printer) const; - void GenerateClearingCode(io::Printer* printer) const; - void GenerateMergingCode(io::Printer* printer) const; - void GenerateSwappingCode(io::Printer* printer) const; - void GenerateConstructorCode(io::Printer* printer) const; - void GenerateMergeFromCodedStream(io::Printer* printer) const; - void GenerateSerializeWithCachedSizes(io::Printer* printer) const; - void GenerateSerializeWithCachedSizesToArray(io::Printer* printer) const; - void GenerateByteSize(io::Printer* printer) const; - - private: - const FieldDescriptor* descriptor_; - map variables_; - - GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(RepeatedStringFieldGenerator); -}; - -} // namespace cpp -} // namespace compiler -} // namespace protobuf - -} // namespace google -#endif // GOOGLE_PROTOBUF_COMPILER_CPP_STRING_FIELD_H__ diff --git a/modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/cpp/cpp_test_bad_identifiers.proto b/modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/cpp/cpp_test_bad_identifiers.proto deleted file mode 100644 index e14a818c9..000000000 --- a/modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/cpp/cpp_test_bad_identifiers.proto +++ /dev/null @@ -1,123 +0,0 @@ -// Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// http://code.google.com/p/protobuf/ -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -// Author: kenton@google.com (Kenton Varda) -// Based on original Protocol Buffers design by -// Sanjay Ghemawat, Jeff Dean, and others. -// -// This file tests that various identifiers work as field and type names even -// though the same identifiers are used internally by the C++ code generator. - - -// Some generic_services option(s) added automatically. -// See: http://go/proto2-generic-services-default -option cc_generic_services = true; // auto-added - -// We don't put this in a package within proto2 because we need to make sure -// that the generated code doesn't depend on being in the proto2 namespace. -package protobuf_unittest; - -// Test that fields can have names like "input" and "i" which are also used -// internally by the code generator for local variables. -message TestConflictingSymbolNames { - message BuildDescriptors {} - message TypeTraits {} - - optional int32 input = 1; - optional int32 output = 2; - optional string length = 3; - repeated int32 i = 4; - repeated string new_element = 5 [ctype=STRING_PIECE]; - optional int32 total_size = 6; - optional int32 tag = 7; - - enum TestEnum { FOO = 1; } - message Data1 { repeated int32 data = 1; } - message Data2 { repeated TestEnum data = 1; } - message Data3 { repeated string data = 1; } - message Data4 { repeated Data4 data = 1; } - message Data5 { repeated string data = 1 [ctype=STRING_PIECE]; } - message Data6 { repeated string data = 1 [ctype=CORD]; } - - optional int32 source = 8; - optional int32 value = 9; - optional int32 file = 10; - optional int32 from = 11; - optional int32 handle_uninterpreted = 12; - repeated int32 index = 13; - optional int32 controller = 14; - optional int32 already_here = 15; - - optional uint32 uint32 = 16; - optional uint64 uint64 = 17; - optional string string = 18; - optional int32 memset = 19; - optional int32 int32 = 20; - optional int64 int64 = 21; - - optional uint32 cached_size = 22; - optional uint32 extensions = 23; - optional uint32 bit = 24; - optional uint32 bits = 25; - optional uint32 offsets = 26; - optional uint32 reflection = 27; - - message Cord {} - optional string some_cord = 28 [ctype=CORD]; - - message StringPiece {} - optional string some_string_piece = 29 [ctype=STRING_PIECE]; - - // Some keywords. - optional uint32 int = 30; - optional uint32 friend = 31; - - // The generator used to #define a macro called "DO" inside the .cc file. - message DO {} - optional DO do = 32; - - // Some template parameter names for extensions. - optional int32 field_type = 33; - optional bool is_packed = 34; - - extensions 1000 to max; -} - -message TestConflictingSymbolNamesExtension { - extend TestConflictingSymbolNames { - repeated int32 repeated_int32_ext = 20423638 [packed=true]; - } -} - -message DummyMessage {} - -service TestConflictingMethodNames { - rpc Closure(DummyMessage) returns (DummyMessage); -} diff --git a/modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/cpp/cpp_unittest.cc b/modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/cpp/cpp_unittest.cc deleted file mode 100644 index 1eae29b53..000000000 --- a/modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/cpp/cpp_unittest.cc +++ /dev/null @@ -1,1354 +0,0 @@ -// Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// http://code.google.com/p/protobuf/ -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -// Author: kenton@google.com (Kenton Varda) -// Based on original Protocol Buffers design by -// Sanjay Ghemawat, Jeff Dean, and others. -// -// To test the code generator, we actually use it to generate code for -// google/protobuf/unittest.proto, then test that. This means that we -// are actually testing the parser and other parts of the system at the same -// time, and that problems in the generator may show up as compile-time errors -// rather than unittest failures, which may be surprising. However, testing -// the output of the C++ generator directly would be very hard. We can't very -// well just check it against golden files since those files would have to be -// updated for any small change; such a test would be very brittle and probably -// not very helpful. What we really want to test is that the code compiles -// correctly and produces the interfaces we expect, which is why this test -// is written this way. - -#include - -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include - -namespace google { -namespace protobuf { -namespace compiler { -namespace cpp { - -// Can't use an anonymous namespace here due to brokenness of Tru64 compiler. -namespace cpp_unittest { - -namespace protobuf_unittest = ::protobuf_unittest; - - -class MockErrorCollector : public MultiFileErrorCollector { - public: - MockErrorCollector() {} - ~MockErrorCollector() {} - - string text_; - - // implements ErrorCollector --------------------------------------- - void AddError(const string& filename, int line, int column, - const string& message) { - strings::SubstituteAndAppend(&text_, "$0:$1:$2: $3\n", - filename, line, column, message); - } -}; - -#ifndef PROTOBUF_TEST_NO_DESCRIPTORS - -// Test that generated code has proper descriptors: -// Parse a descriptor directly (using google::protobuf::compiler::Importer) and -// compare it to the one that was produced by generated code. -TEST(GeneratedDescriptorTest, IdenticalDescriptors) { - const FileDescriptor* generated_descriptor = - unittest::TestAllTypes::descriptor()->file(); - - // Set up the Importer. - MockErrorCollector error_collector; - DiskSourceTree source_tree; - source_tree.MapPath("", TestSourceDir()); - Importer importer(&source_tree, &error_collector); - - // Import (parse) unittest.proto. - const FileDescriptor* parsed_descriptor = - importer.Import("google/protobuf/unittest.proto"); - EXPECT_EQ("", error_collector.text_); - ASSERT_TRUE(parsed_descriptor != NULL); - - // Test that descriptors are generated correctly by converting them to - // FileDescriptorProtos and comparing. - FileDescriptorProto generated_decsriptor_proto, parsed_descriptor_proto; - generated_descriptor->CopyTo(&generated_decsriptor_proto); - parsed_descriptor->CopyTo(&parsed_descriptor_proto); - - EXPECT_EQ(parsed_descriptor_proto.DebugString(), - generated_decsriptor_proto.DebugString()); -} - -#endif // !PROTOBUF_TEST_NO_DESCRIPTORS - -// =================================================================== - -TEST(GeneratedMessageTest, Defaults) { - // Check that all default values are set correctly in the initial message. - unittest::TestAllTypes message; - - TestUtil::ExpectClear(message); - - // Messages should return pointers to default instances until first use. - // (This is not checked by ExpectClear() since it is not actually true after - // the fields have been set and then cleared.) - EXPECT_EQ(&unittest::TestAllTypes::OptionalGroup::default_instance(), - &message.optionalgroup()); - EXPECT_EQ(&unittest::TestAllTypes::NestedMessage::default_instance(), - &message.optional_nested_message()); - EXPECT_EQ(&unittest::ForeignMessage::default_instance(), - &message.optional_foreign_message()); - EXPECT_EQ(&unittest_import::ImportMessage::default_instance(), - &message.optional_import_message()); -} - -TEST(GeneratedMessageTest, FloatingPointDefaults) { - const unittest::TestExtremeDefaultValues& extreme_default = - unittest::TestExtremeDefaultValues::default_instance(); - - EXPECT_EQ(0.0f, extreme_default.zero_float()); - EXPECT_EQ(1.0f, extreme_default.one_float()); - EXPECT_EQ(1.5f, extreme_default.small_float()); - EXPECT_EQ(-1.0f, extreme_default.negative_one_float()); - EXPECT_EQ(-1.5f, extreme_default.negative_float()); - EXPECT_EQ(2.0e8f, extreme_default.large_float()); - EXPECT_EQ(-8e-28f, extreme_default.small_negative_float()); - EXPECT_EQ(numeric_limits::infinity(), - extreme_default.inf_double()); - EXPECT_EQ(-numeric_limits::infinity(), - extreme_default.neg_inf_double()); - EXPECT_TRUE(extreme_default.nan_double() != extreme_default.nan_double()); - EXPECT_EQ(numeric_limits::infinity(), - extreme_default.inf_float()); - EXPECT_EQ(-numeric_limits::infinity(), - extreme_default.neg_inf_float()); - EXPECT_TRUE(extreme_default.nan_float() != extreme_default.nan_float()); -} - -TEST(GeneratedMessageTest, Trigraph) { - const unittest::TestExtremeDefaultValues& extreme_default = - unittest::TestExtremeDefaultValues::default_instance(); - - EXPECT_EQ("? ? ?? ?? ??? ?\?/ ?\?-", extreme_default.cpp_trigraph()); -} - -TEST(GeneratedMessageTest, ExtremeSmallIntegerDefault) { - const unittest::TestExtremeDefaultValues& extreme_default = - unittest::TestExtremeDefaultValues::default_instance(); - EXPECT_EQ(-0x80000000, kint32min); - EXPECT_EQ(GOOGLE_LONGLONG(-0x8000000000000000), kint64min); - EXPECT_EQ(kint32min, extreme_default.really_small_int32()); - EXPECT_EQ(kint64min, extreme_default.really_small_int64()); -} - -TEST(GeneratedMessageTest, Accessors) { - // Set every field to a unique value then go back and check all those - // values. - unittest::TestAllTypes message; - - TestUtil::SetAllFields(&message); - TestUtil::ExpectAllFieldsSet(message); - - TestUtil::ModifyRepeatedFields(&message); - TestUtil::ExpectRepeatedFieldsModified(message); -} - -TEST(GeneratedMessageTest, MutableStringDefault) { - // mutable_foo() for a string should return a string initialized to its - // default value. - unittest::TestAllTypes message; - - EXPECT_EQ("hello", *message.mutable_default_string()); - - // Note that the first time we call mutable_foo(), we get a newly-allocated - // string, but if we clear it and call it again, we get the same object again. - // We should verify that it has its default value in both cases. - message.set_default_string("blah"); - message.Clear(); - - EXPECT_EQ("hello", *message.mutable_default_string()); -} - -TEST(GeneratedMessageTest, StringDefaults) { - unittest::TestExtremeDefaultValues message; - // Check if '\000' can be used in default string value. - EXPECT_EQ(string("hel\000lo", 6), message.string_with_zero()); - EXPECT_EQ(string("wor\000ld", 6), message.bytes_with_zero()); -} - -TEST(GeneratedMessageTest, ReleaseString) { - // Check that release_foo() starts out NULL, and gives us a value - // that we can delete after it's been set. - unittest::TestAllTypes message; - - EXPECT_EQ(NULL, message.release_default_string()); - EXPECT_FALSE(message.has_default_string()); - EXPECT_EQ("hello", message.default_string()); - - message.set_default_string("blah"); - EXPECT_TRUE(message.has_default_string()); - string* str = message.release_default_string(); - EXPECT_FALSE(message.has_default_string()); - ASSERT_TRUE(str != NULL); - EXPECT_EQ("blah", *str); - delete str; - - EXPECT_EQ(NULL, message.release_default_string()); - EXPECT_FALSE(message.has_default_string()); - EXPECT_EQ("hello", message.default_string()); -} - -TEST(GeneratedMessageTest, ReleaseMessage) { - // Check that release_foo() starts out NULL, and gives us a value - // that we can delete after it's been set. - unittest::TestAllTypes message; - - EXPECT_EQ(NULL, message.release_optional_nested_message()); - EXPECT_FALSE(message.has_optional_nested_message()); - - message.mutable_optional_nested_message()->set_bb(1); - unittest::TestAllTypes::NestedMessage* nest = - message.release_optional_nested_message(); - EXPECT_FALSE(message.has_optional_nested_message()); - ASSERT_TRUE(nest != NULL); - EXPECT_EQ(1, nest->bb()); - delete nest; - - EXPECT_EQ(NULL, message.release_optional_nested_message()); - EXPECT_FALSE(message.has_optional_nested_message()); -} - -TEST(GeneratedMessageTest, SetAllocatedString) { - // Check that set_allocated_foo() works for strings. - unittest::TestAllTypes message; - - EXPECT_FALSE(message.has_optional_string()); - const string kHello("hello"); - message.set_optional_string(kHello); - EXPECT_TRUE(message.has_optional_string()); - - message.set_allocated_optional_string(NULL); - EXPECT_FALSE(message.has_optional_string()); - EXPECT_EQ("", message.optional_string()); - - message.set_allocated_optional_string(new string(kHello)); - EXPECT_TRUE(message.has_optional_string()); - EXPECT_EQ(kHello, message.optional_string()); -} - -TEST(GeneratedMessageTest, SetAllocatedMessage) { - // Check that set_allocated_foo() can be called in all cases. - unittest::TestAllTypes message; - - EXPECT_FALSE(message.has_optional_nested_message()); - - message.mutable_optional_nested_message()->set_bb(1); - EXPECT_TRUE(message.has_optional_nested_message()); - - message.set_allocated_optional_nested_message(NULL); - EXPECT_FALSE(message.has_optional_nested_message()); - EXPECT_EQ(&unittest::TestAllTypes::NestedMessage::default_instance(), - &message.optional_nested_message()); - - message.mutable_optional_nested_message()->set_bb(1); - unittest::TestAllTypes::NestedMessage* nest = - message.release_optional_nested_message(); - ASSERT_TRUE(nest != NULL); - EXPECT_FALSE(message.has_optional_nested_message()); - - message.set_allocated_optional_nested_message(nest); - EXPECT_TRUE(message.has_optional_nested_message()); - EXPECT_EQ(1, message.optional_nested_message().bb()); -} - -TEST(GeneratedMessageTest, Clear) { - // Set every field to a unique value, clear the message, then check that - // it is cleared. - unittest::TestAllTypes message; - - TestUtil::SetAllFields(&message); - message.Clear(); - TestUtil::ExpectClear(message); - - // Unlike with the defaults test, we do NOT expect that requesting embedded - // messages will return a pointer to the default instance. Instead, they - // should return the objects that were created when mutable_blah() was - // called. - EXPECT_NE(&unittest::TestAllTypes::OptionalGroup::default_instance(), - &message.optionalgroup()); - EXPECT_NE(&unittest::TestAllTypes::NestedMessage::default_instance(), - &message.optional_nested_message()); - EXPECT_NE(&unittest::ForeignMessage::default_instance(), - &message.optional_foreign_message()); - EXPECT_NE(&unittest_import::ImportMessage::default_instance(), - &message.optional_import_message()); -} - -TEST(GeneratedMessageTest, EmbeddedNullsInBytesCharStar) { - unittest::TestAllTypes message; - - const char* value = "\0lalala\0\0"; - message.set_optional_bytes(value, 9); - ASSERT_EQ(9, message.optional_bytes().size()); - EXPECT_EQ(0, memcmp(value, message.optional_bytes().data(), 9)); - - message.add_repeated_bytes(value, 9); - ASSERT_EQ(9, message.repeated_bytes(0).size()); - EXPECT_EQ(0, memcmp(value, message.repeated_bytes(0).data(), 9)); -} - -TEST(GeneratedMessageTest, ClearOneField) { - // Set every field to a unique value, then clear one value and insure that - // only that one value is cleared. - unittest::TestAllTypes message; - - TestUtil::SetAllFields(&message); - int64 original_value = message.optional_int64(); - - // Clear the field and make sure it shows up as cleared. - message.clear_optional_int64(); - EXPECT_FALSE(message.has_optional_int64()); - EXPECT_EQ(0, message.optional_int64()); - - // Other adjacent fields should not be cleared. - EXPECT_TRUE(message.has_optional_int32()); - EXPECT_TRUE(message.has_optional_uint32()); - - // Make sure if we set it again, then all fields are set. - message.set_optional_int64(original_value); - TestUtil::ExpectAllFieldsSet(message); -} - -TEST(GeneratedMessageTest, StringCharStarLength) { - // Verify that we can use a char*,length to set one of the string fields. - unittest::TestAllTypes message; - message.set_optional_string("abcdef", 3); - EXPECT_EQ("abc", message.optional_string()); - - // Verify that we can use a char*,length to add to a repeated string field. - message.add_repeated_string("abcdef", 3); - EXPECT_EQ(1, message.repeated_string_size()); - EXPECT_EQ("abc", message.repeated_string(0)); - - // Verify that we can use a char*,length to set a repeated string field. - message.set_repeated_string(0, "wxyz", 2); - EXPECT_EQ("wx", message.repeated_string(0)); -} - -TEST(GeneratedMessageTest, CopyFrom) { - unittest::TestAllTypes message1, message2; - - TestUtil::SetAllFields(&message1); - message2.CopyFrom(message1); - TestUtil::ExpectAllFieldsSet(message2); - - // Copying from self should be a no-op. - message2.CopyFrom(message2); - TestUtil::ExpectAllFieldsSet(message2); -} - -TEST(GeneratedMessageTest, SwapWithEmpty) { - unittest::TestAllTypes message1, message2; - TestUtil::SetAllFields(&message1); - - TestUtil::ExpectAllFieldsSet(message1); - TestUtil::ExpectClear(message2); - message1.Swap(&message2); - TestUtil::ExpectAllFieldsSet(message2); - TestUtil::ExpectClear(message1); -} - -TEST(GeneratedMessageTest, SwapWithSelf) { - unittest::TestAllTypes message; - TestUtil::SetAllFields(&message); - TestUtil::ExpectAllFieldsSet(message); - message.Swap(&message); - TestUtil::ExpectAllFieldsSet(message); -} - -TEST(GeneratedMessageTest, SwapWithOther) { - unittest::TestAllTypes message1, message2; - - message1.set_optional_int32(123); - message1.set_optional_string("abc"); - message1.mutable_optional_nested_message()->set_bb(1); - message1.set_optional_nested_enum(unittest::TestAllTypes::FOO); - message1.add_repeated_int32(1); - message1.add_repeated_int32(2); - message1.add_repeated_string("a"); - message1.add_repeated_string("b"); - message1.add_repeated_nested_message()->set_bb(7); - message1.add_repeated_nested_message()->set_bb(8); - message1.add_repeated_nested_enum(unittest::TestAllTypes::FOO); - message1.add_repeated_nested_enum(unittest::TestAllTypes::BAR); - - message2.set_optional_int32(456); - message2.set_optional_string("def"); - message2.mutable_optional_nested_message()->set_bb(2); - message2.set_optional_nested_enum(unittest::TestAllTypes::BAR); - message2.add_repeated_int32(3); - message2.add_repeated_string("c"); - message2.add_repeated_nested_message()->set_bb(9); - message2.add_repeated_nested_enum(unittest::TestAllTypes::BAZ); - - message1.Swap(&message2); - - EXPECT_EQ(456, message1.optional_int32()); - EXPECT_EQ("def", message1.optional_string()); - EXPECT_EQ(2, message1.optional_nested_message().bb()); - EXPECT_EQ(unittest::TestAllTypes::BAR, message1.optional_nested_enum()); - ASSERT_EQ(1, message1.repeated_int32_size()); - EXPECT_EQ(3, message1.repeated_int32(0)); - ASSERT_EQ(1, message1.repeated_string_size()); - EXPECT_EQ("c", message1.repeated_string(0)); - ASSERT_EQ(1, message1.repeated_nested_message_size()); - EXPECT_EQ(9, message1.repeated_nested_message(0).bb()); - ASSERT_EQ(1, message1.repeated_nested_enum_size()); - EXPECT_EQ(unittest::TestAllTypes::BAZ, message1.repeated_nested_enum(0)); - - EXPECT_EQ(123, message2.optional_int32()); - EXPECT_EQ("abc", message2.optional_string()); - EXPECT_EQ(1, message2.optional_nested_message().bb()); - EXPECT_EQ(unittest::TestAllTypes::FOO, message2.optional_nested_enum()); - ASSERT_EQ(2, message2.repeated_int32_size()); - EXPECT_EQ(1, message2.repeated_int32(0)); - EXPECT_EQ(2, message2.repeated_int32(1)); - ASSERT_EQ(2, message2.repeated_string_size()); - EXPECT_EQ("a", message2.repeated_string(0)); - EXPECT_EQ("b", message2.repeated_string(1)); - ASSERT_EQ(2, message2.repeated_nested_message_size()); - EXPECT_EQ(7, message2.repeated_nested_message(0).bb()); - EXPECT_EQ(8, message2.repeated_nested_message(1).bb()); - ASSERT_EQ(2, message2.repeated_nested_enum_size()); - EXPECT_EQ(unittest::TestAllTypes::FOO, message2.repeated_nested_enum(0)); - EXPECT_EQ(unittest::TestAllTypes::BAR, message2.repeated_nested_enum(1)); -} - -TEST(GeneratedMessageTest, CopyConstructor) { - unittest::TestAllTypes message1; - TestUtil::SetAllFields(&message1); - - unittest::TestAllTypes message2(message1); - TestUtil::ExpectAllFieldsSet(message2); -} - -TEST(GeneratedMessageTest, CopyAssignmentOperator) { - unittest::TestAllTypes message1; - TestUtil::SetAllFields(&message1); - - unittest::TestAllTypes message2; - message2 = message1; - TestUtil::ExpectAllFieldsSet(message2); - - // Make sure that self-assignment does something sane. - message2.operator=(message2); - TestUtil::ExpectAllFieldsSet(message2); -} - -#if !defined(PROTOBUF_TEST_NO_DESCRIPTORS) || \ - !defined(GOOGLE_PROTOBUF_NO_RTTI) -TEST(GeneratedMessageTest, UpcastCopyFrom) { - // Test the CopyFrom method that takes in the generic const Message& - // parameter. - unittest::TestAllTypes message1, message2; - - TestUtil::SetAllFields(&message1); - - const Message* source = implicit_cast(&message1); - message2.CopyFrom(*source); - - TestUtil::ExpectAllFieldsSet(message2); -} -#endif - -#ifndef PROTOBUF_TEST_NO_DESCRIPTORS - -TEST(GeneratedMessageTest, DynamicMessageCopyFrom) { - // Test copying from a DynamicMessage, which must fall back to using - // reflection. - unittest::TestAllTypes message2; - - // Construct a new version of the dynamic message via the factory. - DynamicMessageFactory factory; - scoped_ptr message1; - message1.reset(factory.GetPrototype( - unittest::TestAllTypes::descriptor())->New()); - - TestUtil::ReflectionTester reflection_tester( - unittest::TestAllTypes::descriptor()); - reflection_tester.SetAllFieldsViaReflection(message1.get()); - - message2.CopyFrom(*message1); - - TestUtil::ExpectAllFieldsSet(message2); -} - -#endif // !PROTOBUF_TEST_NO_DESCRIPTORS - -TEST(GeneratedMessageTest, NonEmptyMergeFrom) { - // Test merging with a non-empty message. Code is a modified form - // of that found in google/protobuf/reflection_ops_unittest.cc. - unittest::TestAllTypes message1, message2; - - TestUtil::SetAllFields(&message1); - - // This field will test merging into an empty spot. - message2.set_optional_int32(message1.optional_int32()); - message1.clear_optional_int32(); - - // This tests overwriting. - message2.set_optional_string(message1.optional_string()); - message1.set_optional_string("something else"); - - // This tests concatenating. - message2.add_repeated_int32(message1.repeated_int32(1)); - int32 i = message1.repeated_int32(0); - message1.clear_repeated_int32(); - message1.add_repeated_int32(i); - - message1.MergeFrom(message2); - - TestUtil::ExpectAllFieldsSet(message1); -} - -#if !defined(PROTOBUF_TEST_NO_DESCRIPTORS) || \ - !defined(GOOGLE_PROTOBUF_NO_RTTI) -#ifdef PROTOBUF_HAS_DEATH_TEST - -TEST(GeneratedMessageTest, MergeFromSelf) { - unittest::TestAllTypes message; - EXPECT_DEATH(message.MergeFrom(message), "&from"); - EXPECT_DEATH(message.MergeFrom(implicit_cast(message)), - "&from"); -} - -#endif // PROTOBUF_HAS_DEATH_TEST -#endif // !PROTOBUF_TEST_NO_DESCRIPTORS || !GOOGLE_PROTOBUF_NO_RTTI - -// Test the generated SerializeWithCachedSizesToArray(), -TEST(GeneratedMessageTest, SerializationToArray) { - unittest::TestAllTypes message1, message2; - string data; - TestUtil::SetAllFields(&message1); - int size = message1.ByteSize(); - data.resize(size); - uint8* start = reinterpret_cast(string_as_array(&data)); - uint8* end = message1.SerializeWithCachedSizesToArray(start); - EXPECT_EQ(size, end - start); - EXPECT_TRUE(message2.ParseFromString(data)); - TestUtil::ExpectAllFieldsSet(message2); - -} - -TEST(GeneratedMessageTest, PackedFieldsSerializationToArray) { - unittest::TestPackedTypes packed_message1, packed_message2; - string packed_data; - TestUtil::SetPackedFields(&packed_message1); - int packed_size = packed_message1.ByteSize(); - packed_data.resize(packed_size); - uint8* start = reinterpret_cast(string_as_array(&packed_data)); - uint8* end = packed_message1.SerializeWithCachedSizesToArray(start); - EXPECT_EQ(packed_size, end - start); - EXPECT_TRUE(packed_message2.ParseFromString(packed_data)); - TestUtil::ExpectPackedFieldsSet(packed_message2); -} - -// Test the generated SerializeWithCachedSizes() by forcing the buffer to write -// one byte at a time. -TEST(GeneratedMessageTest, SerializationToStream) { - unittest::TestAllTypes message1, message2; - TestUtil::SetAllFields(&message1); - int size = message1.ByteSize(); - string data; - data.resize(size); - { - // Allow the output stream to buffer only one byte at a time. - io::ArrayOutputStream array_stream(string_as_array(&data), size, 1); - io::CodedOutputStream output_stream(&array_stream); - message1.SerializeWithCachedSizes(&output_stream); - EXPECT_FALSE(output_stream.HadError()); - EXPECT_EQ(size, output_stream.ByteCount()); - } - EXPECT_TRUE(message2.ParseFromString(data)); - TestUtil::ExpectAllFieldsSet(message2); - -} - -TEST(GeneratedMessageTest, PackedFieldsSerializationToStream) { - unittest::TestPackedTypes message1, message2; - TestUtil::SetPackedFields(&message1); - int size = message1.ByteSize(); - string data; - data.resize(size); - { - // Allow the output stream to buffer only one byte at a time. - io::ArrayOutputStream array_stream(string_as_array(&data), size, 1); - io::CodedOutputStream output_stream(&array_stream); - message1.SerializeWithCachedSizes(&output_stream); - EXPECT_FALSE(output_stream.HadError()); - EXPECT_EQ(size, output_stream.ByteCount()); - } - EXPECT_TRUE(message2.ParseFromString(data)); - TestUtil::ExpectPackedFieldsSet(message2); -} - - -TEST(GeneratedMessageTest, Required) { - // Test that IsInitialized() returns false if required fields are missing. - unittest::TestRequired message; - - EXPECT_FALSE(message.IsInitialized()); - message.set_a(1); - EXPECT_FALSE(message.IsInitialized()); - message.set_b(2); - EXPECT_FALSE(message.IsInitialized()); - message.set_c(3); - EXPECT_TRUE(message.IsInitialized()); -} - -TEST(GeneratedMessageTest, RequiredForeign) { - // Test that IsInitialized() returns false if required fields in nested - // messages are missing. - unittest::TestRequiredForeign message; - - EXPECT_TRUE(message.IsInitialized()); - - message.mutable_optional_message(); - EXPECT_FALSE(message.IsInitialized()); - - message.mutable_optional_message()->set_a(1); - message.mutable_optional_message()->set_b(2); - message.mutable_optional_message()->set_c(3); - EXPECT_TRUE(message.IsInitialized()); - - message.add_repeated_message(); - EXPECT_FALSE(message.IsInitialized()); - - message.mutable_repeated_message(0)->set_a(1); - message.mutable_repeated_message(0)->set_b(2); - message.mutable_repeated_message(0)->set_c(3); - EXPECT_TRUE(message.IsInitialized()); -} - -TEST(GeneratedMessageTest, ForeignNested) { - // Test that TestAllTypes::NestedMessage can be embedded directly into - // another message. - unittest::TestForeignNested message; - - // If this compiles and runs without crashing, it must work. We have - // nothing more to test. - unittest::TestAllTypes::NestedMessage* nested = - message.mutable_foreign_nested(); - nested->set_bb(1); -} - -TEST(GeneratedMessageTest, ReallyLargeTagNumber) { - // Test that really large tag numbers don't break anything. - unittest::TestReallyLargeTagNumber message1, message2; - string data; - - // For the most part, if this compiles and runs then we're probably good. - // (The most likely cause for failure would be if something were attempting - // to allocate a lookup table of some sort using tag numbers as the index.) - // We'll try serializing just for fun. - message1.set_a(1234); - message1.set_bb(5678); - message1.SerializeToString(&data); - EXPECT_TRUE(message2.ParseFromString(data)); - EXPECT_EQ(1234, message2.a()); - EXPECT_EQ(5678, message2.bb()); -} - -TEST(GeneratedMessageTest, MutualRecursion) { - // Test that mutually-recursive message types work. - unittest::TestMutualRecursionA message; - unittest::TestMutualRecursionA* nested = message.mutable_bb()->mutable_a(); - unittest::TestMutualRecursionA* nested2 = nested->mutable_bb()->mutable_a(); - - // Again, if the above compiles and runs, that's all we really have to - // test, but just for run we'll check that the system didn't somehow come - // up with a pointer loop... - EXPECT_NE(&message, nested); - EXPECT_NE(&message, nested2); - EXPECT_NE(nested, nested2); -} - -TEST(GeneratedMessageTest, CamelCaseFieldNames) { - // This test is mainly checking that the following compiles, which verifies - // that the field names were coerced to lower-case. - // - // Protocol buffers standard style is to use lowercase-with-underscores for - // field names. Some old proto1 .protos unfortunately used camel-case field - // names. In proto1, these names were forced to lower-case. So, we do the - // same thing in proto2. - - unittest::TestCamelCaseFieldNames message; - - message.set_primitivefield(2); - message.set_stringfield("foo"); - message.set_enumfield(unittest::FOREIGN_FOO); - message.mutable_messagefield()->set_c(6); - - message.add_repeatedprimitivefield(8); - message.add_repeatedstringfield("qux"); - message.add_repeatedenumfield(unittest::FOREIGN_BAR); - message.add_repeatedmessagefield()->set_c(15); - - EXPECT_EQ(2, message.primitivefield()); - EXPECT_EQ("foo", message.stringfield()); - EXPECT_EQ(unittest::FOREIGN_FOO, message.enumfield()); - EXPECT_EQ(6, message.messagefield().c()); - - EXPECT_EQ(8, message.repeatedprimitivefield(0)); - EXPECT_EQ("qux", message.repeatedstringfield(0)); - EXPECT_EQ(unittest::FOREIGN_BAR, message.repeatedenumfield(0)); - EXPECT_EQ(15, message.repeatedmessagefield(0).c()); -} - -TEST(GeneratedMessageTest, TestConflictingSymbolNames) { - // test_bad_identifiers.proto successfully compiled, then it works. The - // following is just a token usage to insure that the code is, in fact, - // being compiled and linked. - - protobuf_unittest::TestConflictingSymbolNames message; - message.set_uint32(1); - EXPECT_EQ(3, message.ByteSize()); - - message.set_friend_(5); - EXPECT_EQ(5, message.friend_()); - - // Instantiate extension template functions to test conflicting template - // parameter names. - typedef protobuf_unittest::TestConflictingSymbolNamesExtension ExtensionMessage; - message.AddExtension(ExtensionMessage::repeated_int32_ext, 123); - EXPECT_EQ(123, - message.GetExtension(ExtensionMessage::repeated_int32_ext, 0)); -} - -#ifndef PROTOBUF_TEST_NO_DESCRIPTORS - -TEST(GeneratedMessageTest, TestOptimizedForSize) { - // We rely on the tests in reflection_ops_unittest and wire_format_unittest - // to really test that reflection-based methods work. Here we are mostly - // just making sure that TestOptimizedForSize actually builds and seems to - // function. - - protobuf_unittest::TestOptimizedForSize message, message2; - message.set_i(1); - message.mutable_msg()->set_c(2); - message2.CopyFrom(message); - EXPECT_EQ(1, message2.i()); - EXPECT_EQ(2, message2.msg().c()); -} - -TEST(GeneratedMessageTest, TestEmbedOptimizedForSize) { - // Verifies that something optimized for speed can contain something optimized - // for size. - - protobuf_unittest::TestEmbedOptimizedForSize message, message2; - message.mutable_optional_message()->set_i(1); - message.add_repeated_message()->mutable_msg()->set_c(2); - string data; - message.SerializeToString(&data); - ASSERT_TRUE(message2.ParseFromString(data)); - EXPECT_EQ(1, message2.optional_message().i()); - EXPECT_EQ(2, message2.repeated_message(0).msg().c()); -} - -TEST(GeneratedMessageTest, TestSpaceUsed) { - unittest::TestAllTypes message1; - // sizeof provides a lower bound on SpaceUsed(). - EXPECT_LE(sizeof(unittest::TestAllTypes), message1.SpaceUsed()); - const int empty_message_size = message1.SpaceUsed(); - - // Setting primitive types shouldn't affect the space used. - message1.set_optional_int32(123); - message1.set_optional_int64(12345); - message1.set_optional_uint32(123); - message1.set_optional_uint64(12345); - EXPECT_EQ(empty_message_size, message1.SpaceUsed()); - - // On some STL implementations, setting the string to a small value should - // only increase SpaceUsed() by the size of a string object, though this is - // not true everywhere. - message1.set_optional_string("abc"); - EXPECT_LE(empty_message_size + sizeof(string), message1.SpaceUsed()); - - // Setting a string to a value larger than the string object itself should - // increase SpaceUsed(), because it cannot store the value internally. - message1.set_optional_string(string(sizeof(string) + 1, 'x')); - int min_expected_increase = message1.optional_string().capacity() + - sizeof(string); - EXPECT_LE(empty_message_size + min_expected_increase, - message1.SpaceUsed()); - - int previous_size = message1.SpaceUsed(); - // Adding an optional message should increase the size by the size of the - // nested message type. NestedMessage is simple enough (1 int field) that it - // is equal to sizeof(NestedMessage) - message1.mutable_optional_nested_message(); - ASSERT_EQ(sizeof(unittest::TestAllTypes::NestedMessage), - message1.optional_nested_message().SpaceUsed()); - EXPECT_EQ(previous_size + - sizeof(unittest::TestAllTypes::NestedMessage), - message1.SpaceUsed()); -} - -#endif // !PROTOBUF_TEST_NO_DESCRIPTORS - - -TEST(GeneratedMessageTest, FieldConstantValues) { - unittest::TestRequired message; - EXPECT_EQ(unittest::TestAllTypes_NestedMessage::kBbFieldNumber, 1); - EXPECT_EQ(unittest::TestAllTypes::kOptionalInt32FieldNumber, 1); - EXPECT_EQ(unittest::TestAllTypes::kOptionalgroupFieldNumber, 16); - EXPECT_EQ(unittest::TestAllTypes::kOptionalNestedMessageFieldNumber, 18); - EXPECT_EQ(unittest::TestAllTypes::kOptionalNestedEnumFieldNumber, 21); - EXPECT_EQ(unittest::TestAllTypes::kRepeatedInt32FieldNumber, 31); - EXPECT_EQ(unittest::TestAllTypes::kRepeatedgroupFieldNumber, 46); - EXPECT_EQ(unittest::TestAllTypes::kRepeatedNestedMessageFieldNumber, 48); - EXPECT_EQ(unittest::TestAllTypes::kRepeatedNestedEnumFieldNumber, 51); -} - -TEST(GeneratedMessageTest, ExtensionConstantValues) { - EXPECT_EQ(unittest::TestRequired::kSingleFieldNumber, 1000); - EXPECT_EQ(unittest::TestRequired::kMultiFieldNumber, 1001); - EXPECT_EQ(unittest::kOptionalInt32ExtensionFieldNumber, 1); - EXPECT_EQ(unittest::kOptionalgroupExtensionFieldNumber, 16); - EXPECT_EQ(unittest::kOptionalNestedMessageExtensionFieldNumber, 18); - EXPECT_EQ(unittest::kOptionalNestedEnumExtensionFieldNumber, 21); - EXPECT_EQ(unittest::kRepeatedInt32ExtensionFieldNumber, 31); - EXPECT_EQ(unittest::kRepeatedgroupExtensionFieldNumber, 46); - EXPECT_EQ(unittest::kRepeatedNestedMessageExtensionFieldNumber, 48); - EXPECT_EQ(unittest::kRepeatedNestedEnumExtensionFieldNumber, 51); -} - -// =================================================================== - -TEST(GeneratedEnumTest, EnumValuesAsSwitchCases) { - // Test that our nested enum values can be used as switch cases. This test - // doesn't actually do anything, the proof that it works is that it - // compiles. - int i =0; - unittest::TestAllTypes::NestedEnum a = unittest::TestAllTypes::BAR; - switch (a) { - case unittest::TestAllTypes::FOO: - i = 1; - break; - case unittest::TestAllTypes::BAR: - i = 2; - break; - case unittest::TestAllTypes::BAZ: - i = 3; - break; - // no default case: We want to make sure the compiler recognizes that - // all cases are covered. (GCC warns if you do not cover all cases of - // an enum in a switch.) - } - - // Token check just for fun. - EXPECT_EQ(2, i); -} - -TEST(GeneratedEnumTest, IsValidValue) { - // Test enum IsValidValue. - EXPECT_TRUE(unittest::TestAllTypes::NestedEnum_IsValid(1)); - EXPECT_TRUE(unittest::TestAllTypes::NestedEnum_IsValid(2)); - EXPECT_TRUE(unittest::TestAllTypes::NestedEnum_IsValid(3)); - - EXPECT_FALSE(unittest::TestAllTypes::NestedEnum_IsValid(0)); - EXPECT_FALSE(unittest::TestAllTypes::NestedEnum_IsValid(4)); - - // Make sure it also works when there are dups. - EXPECT_TRUE(unittest::TestEnumWithDupValue_IsValid(1)); - EXPECT_TRUE(unittest::TestEnumWithDupValue_IsValid(2)); - EXPECT_TRUE(unittest::TestEnumWithDupValue_IsValid(3)); - - EXPECT_FALSE(unittest::TestEnumWithDupValue_IsValid(0)); - EXPECT_FALSE(unittest::TestEnumWithDupValue_IsValid(4)); -} - -TEST(GeneratedEnumTest, MinAndMax) { - EXPECT_EQ(unittest::TestAllTypes::FOO, - unittest::TestAllTypes::NestedEnum_MIN); - EXPECT_EQ(unittest::TestAllTypes::BAZ, - unittest::TestAllTypes::NestedEnum_MAX); - EXPECT_EQ(4, unittest::TestAllTypes::NestedEnum_ARRAYSIZE); - - EXPECT_EQ(unittest::FOREIGN_FOO, unittest::ForeignEnum_MIN); - EXPECT_EQ(unittest::FOREIGN_BAZ, unittest::ForeignEnum_MAX); - EXPECT_EQ(7, unittest::ForeignEnum_ARRAYSIZE); - - EXPECT_EQ(1, unittest::TestEnumWithDupValue_MIN); - EXPECT_EQ(3, unittest::TestEnumWithDupValue_MAX); - EXPECT_EQ(4, unittest::TestEnumWithDupValue_ARRAYSIZE); - - EXPECT_EQ(unittest::SPARSE_E, unittest::TestSparseEnum_MIN); - EXPECT_EQ(unittest::SPARSE_C, unittest::TestSparseEnum_MAX); - EXPECT_EQ(12589235, unittest::TestSparseEnum_ARRAYSIZE); - - // Make sure we can take the address of _MIN, _MAX and _ARRAYSIZE. - void* null_pointer = 0; // NULL may be integer-type, not pointer-type. - EXPECT_NE(null_pointer, &unittest::TestAllTypes::NestedEnum_MIN); - EXPECT_NE(null_pointer, &unittest::TestAllTypes::NestedEnum_MAX); - EXPECT_NE(null_pointer, &unittest::TestAllTypes::NestedEnum_ARRAYSIZE); - - EXPECT_NE(null_pointer, &unittest::ForeignEnum_MIN); - EXPECT_NE(null_pointer, &unittest::ForeignEnum_MAX); - EXPECT_NE(null_pointer, &unittest::ForeignEnum_ARRAYSIZE); - - // Make sure we can use _MIN and _MAX as switch cases. - switch (unittest::SPARSE_A) { - case unittest::TestSparseEnum_MIN: - case unittest::TestSparseEnum_MAX: - break; - default: - break; - } -} - -#ifndef PROTOBUF_TEST_NO_DESCRIPTORS - -TEST(GeneratedEnumTest, Name) { - // "Names" in the presence of dup values are a bit arbitrary. - EXPECT_EQ("FOO1", unittest::TestEnumWithDupValue_Name(unittest::FOO1)); - EXPECT_EQ("FOO1", unittest::TestEnumWithDupValue_Name(unittest::FOO2)); - - EXPECT_EQ("SPARSE_A", unittest::TestSparseEnum_Name(unittest::SPARSE_A)); - EXPECT_EQ("SPARSE_B", unittest::TestSparseEnum_Name(unittest::SPARSE_B)); - EXPECT_EQ("SPARSE_C", unittest::TestSparseEnum_Name(unittest::SPARSE_C)); - EXPECT_EQ("SPARSE_D", unittest::TestSparseEnum_Name(unittest::SPARSE_D)); - EXPECT_EQ("SPARSE_E", unittest::TestSparseEnum_Name(unittest::SPARSE_E)); - EXPECT_EQ("SPARSE_F", unittest::TestSparseEnum_Name(unittest::SPARSE_F)); - EXPECT_EQ("SPARSE_G", unittest::TestSparseEnum_Name(unittest::SPARSE_G)); -} - -TEST(GeneratedEnumTest, Parse) { - unittest::TestEnumWithDupValue dup_value = unittest::FOO1; - EXPECT_TRUE(unittest::TestEnumWithDupValue_Parse("FOO1", &dup_value)); - EXPECT_EQ(unittest::FOO1, dup_value); - EXPECT_TRUE(unittest::TestEnumWithDupValue_Parse("FOO2", &dup_value)); - EXPECT_EQ(unittest::FOO2, dup_value); - EXPECT_FALSE(unittest::TestEnumWithDupValue_Parse("FOO", &dup_value)); -} - -TEST(GeneratedEnumTest, GetEnumDescriptor) { - EXPECT_EQ(unittest::TestAllTypes::NestedEnum_descriptor(), - GetEnumDescriptor()); - EXPECT_EQ(unittest::ForeignEnum_descriptor(), - GetEnumDescriptor()); - EXPECT_EQ(unittest::TestEnumWithDupValue_descriptor(), - GetEnumDescriptor()); - EXPECT_EQ(unittest::TestSparseEnum_descriptor(), - GetEnumDescriptor()); -} - -#endif // PROTOBUF_TEST_NO_DESCRIPTORS - -// =================================================================== - -#ifndef PROTOBUF_TEST_NO_DESCRIPTORS - -// Support code for testing services. -class GeneratedServiceTest : public testing::Test { - protected: - class MockTestService : public unittest::TestService { - public: - MockTestService() - : called_(false), - method_(""), - controller_(NULL), - request_(NULL), - response_(NULL), - done_(NULL) {} - - ~MockTestService() {} - - void Reset() { called_ = false; } - - // implements TestService ---------------------------------------- - - void Foo(RpcController* controller, - const unittest::FooRequest* request, - unittest::FooResponse* response, - Closure* done) { - ASSERT_FALSE(called_); - called_ = true; - method_ = "Foo"; - controller_ = controller; - request_ = request; - response_ = response; - done_ = done; - } - - void Bar(RpcController* controller, - const unittest::BarRequest* request, - unittest::BarResponse* response, - Closure* done) { - ASSERT_FALSE(called_); - called_ = true; - method_ = "Bar"; - controller_ = controller; - request_ = request; - response_ = response; - done_ = done; - } - - // --------------------------------------------------------------- - - bool called_; - string method_; - RpcController* controller_; - const Message* request_; - Message* response_; - Closure* done_; - }; - - class MockRpcChannel : public RpcChannel { - public: - MockRpcChannel() - : called_(false), - method_(NULL), - controller_(NULL), - request_(NULL), - response_(NULL), - done_(NULL), - destroyed_(NULL) {} - - ~MockRpcChannel() { - if (destroyed_ != NULL) *destroyed_ = true; - } - - void Reset() { called_ = false; } - - // implements TestService ---------------------------------------- - - void CallMethod(const MethodDescriptor* method, - RpcController* controller, - const Message* request, - Message* response, - Closure* done) { - ASSERT_FALSE(called_); - called_ = true; - method_ = method; - controller_ = controller; - request_ = request; - response_ = response; - done_ = done; - } - - // --------------------------------------------------------------- - - bool called_; - const MethodDescriptor* method_; - RpcController* controller_; - const Message* request_; - Message* response_; - Closure* done_; - bool* destroyed_; - }; - - class MockController : public RpcController { - public: - void Reset() { - ADD_FAILURE() << "Reset() not expected during this test."; - } - bool Failed() const { - ADD_FAILURE() << "Failed() not expected during this test."; - return false; - } - string ErrorText() const { - ADD_FAILURE() << "ErrorText() not expected during this test."; - return ""; - } - void StartCancel() { - ADD_FAILURE() << "StartCancel() not expected during this test."; - } - void SetFailed(const string& reason) { - ADD_FAILURE() << "SetFailed() not expected during this test."; - } - bool IsCanceled() const { - ADD_FAILURE() << "IsCanceled() not expected during this test."; - return false; - } - void NotifyOnCancel(Closure* callback) { - ADD_FAILURE() << "NotifyOnCancel() not expected during this test."; - } - }; - - GeneratedServiceTest() - : descriptor_(unittest::TestService::descriptor()), - foo_(descriptor_->FindMethodByName("Foo")), - bar_(descriptor_->FindMethodByName("Bar")), - stub_(&mock_channel_), - done_(NewPermanentCallback(&DoNothing)) {} - - virtual void SetUp() { - ASSERT_TRUE(foo_ != NULL); - ASSERT_TRUE(bar_ != NULL); - } - - const ServiceDescriptor* descriptor_; - const MethodDescriptor* foo_; - const MethodDescriptor* bar_; - - MockTestService mock_service_; - MockController mock_controller_; - - MockRpcChannel mock_channel_; - unittest::TestService::Stub stub_; - - // Just so we don't have to re-define these with every test. - unittest::FooRequest foo_request_; - unittest::FooResponse foo_response_; - unittest::BarRequest bar_request_; - unittest::BarResponse bar_response_; - scoped_ptr done_; -}; - -TEST_F(GeneratedServiceTest, GetDescriptor) { - // Test that GetDescriptor() works. - - EXPECT_EQ(descriptor_, mock_service_.GetDescriptor()); -} - -TEST_F(GeneratedServiceTest, GetChannel) { - EXPECT_EQ(&mock_channel_, stub_.channel()); -} - -TEST_F(GeneratedServiceTest, OwnsChannel) { - MockRpcChannel* channel = new MockRpcChannel; - bool destroyed = false; - channel->destroyed_ = &destroyed; - - { - unittest::TestService::Stub owning_stub(channel, - Service::STUB_OWNS_CHANNEL); - EXPECT_FALSE(destroyed); - } - - EXPECT_TRUE(destroyed); -} - -TEST_F(GeneratedServiceTest, CallMethod) { - // Test that CallMethod() works. - - // Call Foo() via CallMethod(). - mock_service_.CallMethod(foo_, &mock_controller_, - &foo_request_, &foo_response_, done_.get()); - - ASSERT_TRUE(mock_service_.called_); - - EXPECT_EQ("Foo" , mock_service_.method_ ); - EXPECT_EQ(&mock_controller_, mock_service_.controller_); - EXPECT_EQ(&foo_request_ , mock_service_.request_ ); - EXPECT_EQ(&foo_response_ , mock_service_.response_ ); - EXPECT_EQ(done_.get() , mock_service_.done_ ); - - // Try again, but call Bar() instead. - mock_service_.Reset(); - mock_service_.CallMethod(bar_, &mock_controller_, - &bar_request_, &bar_response_, done_.get()); - - ASSERT_TRUE(mock_service_.called_); - EXPECT_EQ("Bar", mock_service_.method_); -} - -TEST_F(GeneratedServiceTest, CallMethodTypeFailure) { - // Verify death if we call Foo() with Bar's message types. - -#ifdef PROTOBUF_HAS_DEATH_TEST // death tests do not work on Windows yet - EXPECT_DEBUG_DEATH( - mock_service_.CallMethod(foo_, &mock_controller_, - &foo_request_, &bar_response_, done_.get()), - "dynamic_cast"); - - mock_service_.Reset(); - EXPECT_DEBUG_DEATH( - mock_service_.CallMethod(foo_, &mock_controller_, - &bar_request_, &foo_response_, done_.get()), - "dynamic_cast"); -#endif // PROTOBUF_HAS_DEATH_TEST -} - -TEST_F(GeneratedServiceTest, GetPrototypes) { - // Test Get{Request,Response}Prototype() methods. - - EXPECT_EQ(&unittest::FooRequest::default_instance(), - &mock_service_.GetRequestPrototype(foo_)); - EXPECT_EQ(&unittest::BarRequest::default_instance(), - &mock_service_.GetRequestPrototype(bar_)); - - EXPECT_EQ(&unittest::FooResponse::default_instance(), - &mock_service_.GetResponsePrototype(foo_)); - EXPECT_EQ(&unittest::BarResponse::default_instance(), - &mock_service_.GetResponsePrototype(bar_)); -} - -TEST_F(GeneratedServiceTest, Stub) { - // Test that the stub class works. - - // Call Foo() via the stub. - stub_.Foo(&mock_controller_, &foo_request_, &foo_response_, done_.get()); - - ASSERT_TRUE(mock_channel_.called_); - - EXPECT_EQ(foo_ , mock_channel_.method_ ); - EXPECT_EQ(&mock_controller_, mock_channel_.controller_); - EXPECT_EQ(&foo_request_ , mock_channel_.request_ ); - EXPECT_EQ(&foo_response_ , mock_channel_.response_ ); - EXPECT_EQ(done_.get() , mock_channel_.done_ ); - - // Call Bar() via the stub. - mock_channel_.Reset(); - stub_.Bar(&mock_controller_, &bar_request_, &bar_response_, done_.get()); - - ASSERT_TRUE(mock_channel_.called_); - EXPECT_EQ(bar_, mock_channel_.method_); -} - -TEST_F(GeneratedServiceTest, NotImplemented) { - // Test that failing to implement a method of a service causes it to fail - // with a "not implemented" error message. - - // A service which doesn't implement any methods. - class UnimplementedService : public unittest::TestService { - public: - UnimplementedService() {} - }; - - UnimplementedService unimplemented_service; - - // And a controller which expects to get a "not implemented" error. - class ExpectUnimplementedController : public MockController { - public: - ExpectUnimplementedController() : called_(false) {} - - void SetFailed(const string& reason) { - EXPECT_FALSE(called_); - called_ = true; - EXPECT_EQ("Method Foo() not implemented.", reason); - } - - bool called_; - }; - - ExpectUnimplementedController controller; - - // Call Foo. - unimplemented_service.Foo(&controller, &foo_request_, &foo_response_, - done_.get()); - - EXPECT_TRUE(controller.called_); -} - -} // namespace cpp_unittest -} // namespace cpp -} // namespace compiler - -namespace no_generic_services_test { - // Verify that no class called "TestService" was defined in - // unittest_no_generic_services.pb.h by defining a different type by the same - // name. If such a service was generated, this will not compile. - struct TestService { - int i; - }; -} - -namespace compiler { -namespace cpp { -namespace cpp_unittest { - -TEST_F(GeneratedServiceTest, NoGenericServices) { - // Verify that non-services in unittest_no_generic_services.proto were - // generated. - no_generic_services_test::TestMessage message; - message.set_a(1); - message.SetExtension(no_generic_services_test::test_extension, 123); - no_generic_services_test::TestEnum e = no_generic_services_test::FOO; - EXPECT_EQ(e, 1); - - // Verify that a ServiceDescriptor is generated for the service even if the - // class itself is not. - const FileDescriptor* file = - no_generic_services_test::TestMessage::descriptor()->file(); - - ASSERT_EQ(1, file->service_count()); - EXPECT_EQ("TestService", file->service(0)->name()); - ASSERT_EQ(1, file->service(0)->method_count()); - EXPECT_EQ("Foo", file->service(0)->method(0)->name()); -} - -#endif // !PROTOBUF_TEST_NO_DESCRIPTORS - -// =================================================================== - -// This test must run last. It verifies that descriptors were or were not -// initialized depending on whether PROTOBUF_TEST_NO_DESCRIPTORS was defined. -// When this is defined, we skip all tests which are expected to trigger -// descriptor initialization. This verifies that everything else still works -// if descriptors are not initialized. -TEST(DescriptorInitializationTest, Initialized) { -#ifdef PROTOBUF_TEST_NO_DESCRIPTORS - bool should_have_descriptors = false; -#else - bool should_have_descriptors = true; -#endif - - EXPECT_EQ(should_have_descriptors, - DescriptorPool::generated_pool()->InternalIsFileLoaded( - "google/protobuf/unittest.proto")); -} - -} // namespace cpp_unittest - -} // namespace cpp -} // namespace compiler -} // namespace protobuf -} // namespace google diff --git a/modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/cpp/cpp_unittest.h b/modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/cpp/cpp_unittest.h deleted file mode 100644 index a3a1d1baa..000000000 --- a/modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/cpp/cpp_unittest.h +++ /dev/null @@ -1,51 +0,0 @@ -// Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// http://code.google.com/p/protobuf/ -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -// This header declares the namespace google::protobuf::protobuf_unittest in order to expose -// any problems with the generated class names. We use this header to ensure -// unittest.cc will declare the namespace prior to other includes, while obeying -// normal include ordering. -// -// When generating a class name of "foo.Bar" we must ensure we prefix the class -// name with "::", in case the namespace google::protobuf::foo exists. We intentionally -// trigger that case here by declaring google::protobuf::protobuf_unittest. -// -// See ClassName in helpers.h for more details. - -#ifndef GOOGLE_PROTOBUF_COMPILER_CPP_UNITTEST_H__ -#define GOOGLE_PROTOBUF_COMPILER_CPP_UNITTEST_H__ - -namespace google { -namespace protobuf { -namespace protobuf_unittest {} -} // namespace protobuf - -} // namespace google -#endif // GOOGLE_PROTOBUF_COMPILER_CPP_UNITTEST_H__ diff --git a/modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/importer.cc b/modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/importer.cc deleted file mode 100644 index 422f759f2..000000000 --- a/modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/importer.cc +++ /dev/null @@ -1,459 +0,0 @@ -// Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// http://code.google.com/p/protobuf/ -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -// Author: kenton@google.com (Kenton Varda) -// Based on original Protocol Buffers design by -// Sanjay Ghemawat, Jeff Dean, and others. - -#ifdef _MSC_VER -#include -#else -#include -#endif -#include -#include -#include -#include - -#include - -#include - -#include -#include -#include -#include - -namespace google { -namespace protobuf { -namespace compiler { - -#ifdef _WIN32 -#ifndef F_OK -#define F_OK 00 // not defined by MSVC for whatever reason -#endif -#include -#endif - -// Returns true if the text looks like a Windows-style absolute path, starting -// with a drive letter. Example: "C:\foo". TODO(kenton): Share this with -// copy in command_line_interface.cc? -static bool IsWindowsAbsolutePath(const string& text) { -#if defined(_WIN32) || defined(__CYGWIN__) - return text.size() >= 3 && text[1] == ':' && - isalpha(text[0]) && - (text[2] == '/' || text[2] == '\\') && - text.find_last_of(':') == 1; -#else - return false; -#endif -} - -MultiFileErrorCollector::~MultiFileErrorCollector() {} - -// This class serves two purposes: -// - It implements the ErrorCollector interface (used by Tokenizer and Parser) -// in terms of MultiFileErrorCollector, using a particular filename. -// - It lets us check if any errors have occurred. -class SourceTreeDescriptorDatabase::SingleFileErrorCollector - : public io::ErrorCollector { - public: - SingleFileErrorCollector(const string& filename, - MultiFileErrorCollector* multi_file_error_collector) - : filename_(filename), - multi_file_error_collector_(multi_file_error_collector), - had_errors_(false) {} - ~SingleFileErrorCollector() {} - - bool had_errors() { return had_errors_; } - - // implements ErrorCollector --------------------------------------- - void AddError(int line, int column, const string& message) { - if (multi_file_error_collector_ != NULL) { - multi_file_error_collector_->AddError(filename_, line, column, message); - } - had_errors_ = true; - } - - private: - string filename_; - MultiFileErrorCollector* multi_file_error_collector_; - bool had_errors_; -}; - -// =================================================================== - -SourceTreeDescriptorDatabase::SourceTreeDescriptorDatabase( - SourceTree* source_tree) - : source_tree_(source_tree), - error_collector_(NULL), - using_validation_error_collector_(false), - validation_error_collector_(this) {} - -SourceTreeDescriptorDatabase::~SourceTreeDescriptorDatabase() {} - -bool SourceTreeDescriptorDatabase::FindFileByName( - const string& filename, FileDescriptorProto* output) { - scoped_ptr input(source_tree_->Open(filename)); - if (input == NULL) { - if (error_collector_ != NULL) { - error_collector_->AddError(filename, -1, 0, "File not found."); - } - return false; - } - - // Set up the tokenizer and parser. - SingleFileErrorCollector file_error_collector(filename, error_collector_); - io::Tokenizer tokenizer(input.get(), &file_error_collector); - - Parser parser; - if (error_collector_ != NULL) { - parser.RecordErrorsTo(&file_error_collector); - } - if (using_validation_error_collector_) { - parser.RecordSourceLocationsTo(&source_locations_); - } - - // Parse it. - output->set_name(filename); - return parser.Parse(&tokenizer, output) && - !file_error_collector.had_errors(); -} - -bool SourceTreeDescriptorDatabase::FindFileContainingSymbol( - const string& symbol_name, FileDescriptorProto* output) { - return false; -} - -bool SourceTreeDescriptorDatabase::FindFileContainingExtension( - const string& containing_type, int field_number, - FileDescriptorProto* output) { - return false; -} - -// ------------------------------------------------------------------- - -SourceTreeDescriptorDatabase::ValidationErrorCollector:: -ValidationErrorCollector(SourceTreeDescriptorDatabase* owner) - : owner_(owner) {} - -SourceTreeDescriptorDatabase::ValidationErrorCollector:: -~ValidationErrorCollector() {} - -void SourceTreeDescriptorDatabase::ValidationErrorCollector::AddError( - const string& filename, - const string& element_name, - const Message* descriptor, - ErrorLocation location, - const string& message) { - if (owner_->error_collector_ == NULL) return; - - int line, column; - owner_->source_locations_.Find(descriptor, location, &line, &column); - owner_->error_collector_->AddError(filename, line, column, message); -} - -// =================================================================== - -Importer::Importer(SourceTree* source_tree, - MultiFileErrorCollector* error_collector) - : database_(source_tree), - pool_(&database_, database_.GetValidationErrorCollector()) { - database_.RecordErrorsTo(error_collector); -} - -Importer::~Importer() {} - -const FileDescriptor* Importer::Import(const string& filename) { - return pool_.FindFileByName(filename); -} - -// =================================================================== - -SourceTree::~SourceTree() {} - -DiskSourceTree::DiskSourceTree() {} - -DiskSourceTree::~DiskSourceTree() {} - -static inline char LastChar(const string& str) { - return str[str.size() - 1]; -} - -// Given a path, returns an equivalent path with these changes: -// - On Windows, any backslashes are replaced with forward slashes. -// - Any instances of the directory "." are removed. -// - Any consecutive '/'s are collapsed into a single slash. -// Note that the resulting string may be empty. -// -// TODO(kenton): It would be nice to handle "..", e.g. so that we can figure -// out that "foo/bar.proto" is inside "baz/../foo". However, if baz is a -// symlink or doesn't exist, then things get complicated, and we can't -// actually determine this without investigating the filesystem, probably -// in non-portable ways. So, we punt. -// -// TODO(kenton): It would be nice to use realpath() here except that it -// resolves symbolic links. This could cause problems if people place -// symbolic links in their source tree. For example, if you executed: -// protoc --proto_path=foo foo/bar/baz.proto -// then if foo/bar is a symbolic link, foo/bar/baz.proto will canonicalize -// to a path which does not appear to be under foo, and thus the compiler -// will complain that baz.proto is not inside the --proto_path. -static string CanonicalizePath(string path) { -#ifdef _WIN32 - // The Win32 API accepts forward slashes as a path delimiter even though - // backslashes are standard. Let's avoid confusion and use only forward - // slashes. - if (HasPrefixString(path, "\\\\")) { - // Avoid converting two leading backslashes. - path = "\\\\" + StringReplace(path.substr(2), "\\", "/", true); - } else { - path = StringReplace(path, "\\", "/", true); - } -#endif - - vector parts; - vector canonical_parts; - SplitStringUsing(path, "/", &parts); // Note: Removes empty parts. - for (int i = 0; i < parts.size(); i++) { - if (parts[i] == ".") { - // Ignore. - } else { - canonical_parts.push_back(parts[i]); - } - } - string result = JoinStrings(canonical_parts, "/"); - if (!path.empty() && path[0] == '/') { - // Restore leading slash. - result = '/' + result; - } - if (!path.empty() && LastChar(path) == '/' && - !result.empty() && LastChar(result) != '/') { - // Restore trailing slash. - result += '/'; - } - return result; -} - -static inline bool ContainsParentReference(const string& path) { - return path == ".." || - HasPrefixString(path, "../") || - HasSuffixString(path, "/..") || - path.find("/../") != string::npos; -} - -// Maps a file from an old location to a new one. Typically, old_prefix is -// a virtual path and new_prefix is its corresponding disk path. Returns -// false if the filename did not start with old_prefix, otherwise replaces -// old_prefix with new_prefix and stores the result in *result. Examples: -// string result; -// assert(ApplyMapping("foo/bar", "", "baz", &result)); -// assert(result == "baz/foo/bar"); -// -// assert(ApplyMapping("foo/bar", "foo", "baz", &result)); -// assert(result == "baz/bar"); -// -// assert(ApplyMapping("foo", "foo", "bar", &result)); -// assert(result == "bar"); -// -// assert(!ApplyMapping("foo/bar", "baz", "qux", &result)); -// assert(!ApplyMapping("foo/bar", "baz", "qux", &result)); -// assert(!ApplyMapping("foobar", "foo", "baz", &result)); -static bool ApplyMapping(const string& filename, - const string& old_prefix, - const string& new_prefix, - string* result) { - if (old_prefix.empty()) { - // old_prefix matches any relative path. - if (ContainsParentReference(filename)) { - // We do not allow the file name to use "..". - return false; - } - if (HasPrefixString(filename, "/") || - IsWindowsAbsolutePath(filename)) { - // This is an absolute path, so it isn't matched by the empty string. - return false; - } - result->assign(new_prefix); - if (!result->empty()) result->push_back('/'); - result->append(filename); - return true; - } else if (HasPrefixString(filename, old_prefix)) { - // old_prefix is a prefix of the filename. Is it the whole filename? - if (filename.size() == old_prefix.size()) { - // Yep, it's an exact match. - *result = new_prefix; - return true; - } else { - // Not an exact match. Is the next character a '/'? Otherwise, - // this isn't actually a match at all. E.g. the prefix "foo/bar" - // does not match the filename "foo/barbaz". - int after_prefix_start = -1; - if (filename[old_prefix.size()] == '/') { - after_prefix_start = old_prefix.size() + 1; - } else if (filename[old_prefix.size() - 1] == '/') { - // old_prefix is never empty, and canonicalized paths never have - // consecutive '/' characters. - after_prefix_start = old_prefix.size(); - } - if (after_prefix_start != -1) { - // Yep. So the prefixes are directories and the filename is a file - // inside them. - string after_prefix = filename.substr(after_prefix_start); - if (ContainsParentReference(after_prefix)) { - // We do not allow the file name to use "..". - return false; - } - result->assign(new_prefix); - if (!result->empty()) result->push_back('/'); - result->append(after_prefix); - return true; - } - } - } - - return false; -} - -void DiskSourceTree::MapPath(const string& virtual_path, - const string& disk_path) { - mappings_.push_back(Mapping(virtual_path, CanonicalizePath(disk_path))); -} - -DiskSourceTree::DiskFileToVirtualFileResult -DiskSourceTree::DiskFileToVirtualFile( - const string& disk_file, - string* virtual_file, - string* shadowing_disk_file) { - int mapping_index = -1; - string canonical_disk_file = CanonicalizePath(disk_file); - - for (int i = 0; i < mappings_.size(); i++) { - // Apply the mapping in reverse. - if (ApplyMapping(canonical_disk_file, mappings_[i].disk_path, - mappings_[i].virtual_path, virtual_file)) { - // Success. - mapping_index = i; - break; - } - } - - if (mapping_index == -1) { - return NO_MAPPING; - } - - // Iterate through all mappings with higher precedence and verify that none - // of them map this file to some other existing file. - for (int i = 0; i < mapping_index; i++) { - if (ApplyMapping(*virtual_file, mappings_[i].virtual_path, - mappings_[i].disk_path, shadowing_disk_file)) { - if (access(shadowing_disk_file->c_str(), F_OK) >= 0) { - // File exists. - return SHADOWED; - } - } - } - shadowing_disk_file->clear(); - - // Verify that we can open the file. Note that this also has the side-effect - // of verifying that we are not canonicalizing away any non-existent - // directories. - scoped_ptr stream(OpenDiskFile(disk_file)); - if (stream == NULL) { - return CANNOT_OPEN; - } - - return SUCCESS; -} - -bool DiskSourceTree::VirtualFileToDiskFile(const string& virtual_file, - string* disk_file) { - scoped_ptr stream(OpenVirtualFile(virtual_file, - disk_file)); - return stream != NULL; -} - -io::ZeroCopyInputStream* DiskSourceTree::Open(const string& filename) { - return OpenVirtualFile(filename, NULL); -} - -io::ZeroCopyInputStream* DiskSourceTree::OpenVirtualFile( - const string& virtual_file, - string* disk_file) { - if (virtual_file != CanonicalizePath(virtual_file) || - ContainsParentReference(virtual_file)) { - // We do not allow importing of paths containing things like ".." or - // consecutive slashes since the compiler expects files to be uniquely - // identified by file name. - return NULL; - } - - for (int i = 0; i < mappings_.size(); i++) { - string temp_disk_file; - if (ApplyMapping(virtual_file, mappings_[i].virtual_path, - mappings_[i].disk_path, &temp_disk_file)) { - io::ZeroCopyInputStream* stream = OpenDiskFile(temp_disk_file); - if (stream != NULL) { - if (disk_file != NULL) { - *disk_file = temp_disk_file; - } - return stream; - } - - if (errno == EACCES) { - // The file exists but is not readable. - // TODO(kenton): Find a way to report this more nicely. - GOOGLE_LOG(WARNING) << "Read access is denied for file: " << temp_disk_file; - return NULL; - } - } - } - - return NULL; -} - -io::ZeroCopyInputStream* DiskSourceTree::OpenDiskFile( - const string& filename) { - int file_descriptor; - do { - file_descriptor = open(filename.c_str(), O_RDONLY); - } while (file_descriptor < 0 && errno == EINTR); - if (file_descriptor >= 0) { - io::FileInputStream* result = new io::FileInputStream(file_descriptor); - result->SetCloseOnDelete(true); - return result; - } else { - return NULL; - } -} - -} // namespace compiler -} // namespace protobuf -} // namespace google diff --git a/modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/importer.h b/modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/importer.h deleted file mode 100644 index 7a62fa0e6..000000000 --- a/modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/importer.h +++ /dev/null @@ -1,304 +0,0 @@ -// Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// http://code.google.com/p/protobuf/ -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -// Author: kenton@google.com (Kenton Varda) -// Based on original Protocol Buffers design by -// Sanjay Ghemawat, Jeff Dean, and others. -// -// This file is the public interface to the .proto file parser. - -#ifndef GOOGLE_PROTOBUF_COMPILER_IMPORTER_H__ -#define GOOGLE_PROTOBUF_COMPILER_IMPORTER_H__ - -#include -#include -#include -#include -#include -#include -#include - -namespace google { -namespace protobuf { - -namespace io { class ZeroCopyInputStream; } - -namespace compiler { - -// Defined in this file. -class Importer; -class MultiFileErrorCollector; -class SourceTree; -class DiskSourceTree; - -// TODO(kenton): Move all SourceTree stuff to a separate file? - -// An implementation of DescriptorDatabase which loads files from a SourceTree -// and parses them. -// -// Note: This class is not thread-safe since it maintains a table of source -// code locations for error reporting. However, when a DescriptorPool wraps -// a DescriptorDatabase, it uses mutex locking to make sure only one method -// of the database is called at a time, even if the DescriptorPool is used -// from multiple threads. Therefore, there is only a problem if you create -// multiple DescriptorPools wrapping the same SourceTreeDescriptorDatabase -// and use them from multiple threads. -// -// Note: This class does not implement FindFileContainingSymbol() or -// FindFileContainingExtension(); these will always return false. -class LIBPROTOBUF_EXPORT SourceTreeDescriptorDatabase : public DescriptorDatabase { - public: - SourceTreeDescriptorDatabase(SourceTree* source_tree); - ~SourceTreeDescriptorDatabase(); - - // Instructs the SourceTreeDescriptorDatabase to report any parse errors - // to the given MultiFileErrorCollector. This should be called before - // parsing. error_collector must remain valid until either this method - // is called again or the SourceTreeDescriptorDatabase is destroyed. - void RecordErrorsTo(MultiFileErrorCollector* error_collector) { - error_collector_ = error_collector; - } - - // Gets a DescriptorPool::ErrorCollector which records errors to the - // MultiFileErrorCollector specified with RecordErrorsTo(). This collector - // has the ability to determine exact line and column numbers of errors - // from the information given to it by the DescriptorPool. - DescriptorPool::ErrorCollector* GetValidationErrorCollector() { - using_validation_error_collector_ = true; - return &validation_error_collector_; - } - - // implements DescriptorDatabase ----------------------------------- - bool FindFileByName(const string& filename, FileDescriptorProto* output); - bool FindFileContainingSymbol(const string& symbol_name, - FileDescriptorProto* output); - bool FindFileContainingExtension(const string& containing_type, - int field_number, - FileDescriptorProto* output); - - private: - class SingleFileErrorCollector; - - SourceTree* source_tree_; - MultiFileErrorCollector* error_collector_; - - class LIBPROTOBUF_EXPORT ValidationErrorCollector : public DescriptorPool::ErrorCollector { - public: - ValidationErrorCollector(SourceTreeDescriptorDatabase* owner); - ~ValidationErrorCollector(); - - // implements ErrorCollector --------------------------------------- - void AddError(const string& filename, - const string& element_name, - const Message* descriptor, - ErrorLocation location, - const string& message); - - private: - SourceTreeDescriptorDatabase* owner_; - }; - friend class ValidationErrorCollector; - - bool using_validation_error_collector_; - SourceLocationTable source_locations_; - ValidationErrorCollector validation_error_collector_; -}; - -// Simple interface for parsing .proto files. This wraps the process -// of opening the file, parsing it with a Parser, recursively parsing all its -// imports, and then cross-linking the results to produce a FileDescriptor. -// -// This is really just a thin wrapper around SourceTreeDescriptorDatabase. -// You may find that SourceTreeDescriptorDatabase is more flexible. -// -// TODO(kenton): I feel like this class is not well-named. -class LIBPROTOBUF_EXPORT Importer { - public: - Importer(SourceTree* source_tree, - MultiFileErrorCollector* error_collector); - ~Importer(); - - // Import the given file and build a FileDescriptor representing it. If - // the file is already in the DescriptorPool, the existing FileDescriptor - // will be returned. The FileDescriptor is property of the DescriptorPool, - // and will remain valid until it is destroyed. If any errors occur, they - // will be reported using the error collector and Import() will return NULL. - // - // A particular Importer object will only report errors for a particular - // file once. All future attempts to import the same file will return NULL - // without reporting any errors. The idea is that you might want to import - // a lot of files without seeing the same errors over and over again. If - // you want to see errors for the same files repeatedly, you can use a - // separate Importer object to import each one (but use the same - // DescriptorPool so that they can be cross-linked). - const FileDescriptor* Import(const string& filename); - - // The DescriptorPool in which all imported FileDescriptors and their - // contents are stored. - inline const DescriptorPool* pool() const { - return &pool_; - } - - private: - SourceTreeDescriptorDatabase database_; - DescriptorPool pool_; - - GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(Importer); -}; - -// If the importer encounters problems while trying to import the proto files, -// it reports them to a MultiFileErrorCollector. -class LIBPROTOBUF_EXPORT MultiFileErrorCollector { - public: - inline MultiFileErrorCollector() {} - virtual ~MultiFileErrorCollector(); - - // Line and column numbers are zero-based. A line number of -1 indicates - // an error with the entire file (e.g. "not found"). - virtual void AddError(const string& filename, int line, int column, - const string& message) = 0; - - private: - GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(MultiFileErrorCollector); -}; - -// Abstract interface which represents a directory tree containing proto files. -// Used by the default implementation of Importer to resolve import statements -// Most users will probably want to use the DiskSourceTree implementation, -// below. -class LIBPROTOBUF_EXPORT SourceTree { - public: - inline SourceTree() {} - virtual ~SourceTree(); - - // Open the given file and return a stream that reads it, or NULL if not - // found. The caller takes ownership of the returned object. The filename - // must be a path relative to the root of the source tree and must not - // contain "." or ".." components. - virtual io::ZeroCopyInputStream* Open(const string& filename) = 0; - - private: - GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(SourceTree); -}; - -// An implementation of SourceTree which loads files from locations on disk. -// Multiple mappings can be set up to map locations in the DiskSourceTree to -// locations in the physical filesystem. -class LIBPROTOBUF_EXPORT DiskSourceTree : public SourceTree { - public: - DiskSourceTree(); - ~DiskSourceTree(); - - // Map a path on disk to a location in the SourceTree. The path may be - // either a file or a directory. If it is a directory, the entire tree - // under it will be mapped to the given virtual location. To map a directory - // to the root of the source tree, pass an empty string for virtual_path. - // - // If multiple mapped paths apply when opening a file, they will be searched - // in order. For example, if you do: - // MapPath("bar", "foo/bar"); - // MapPath("", "baz"); - // and then you do: - // Open("bar/qux"); - // the DiskSourceTree will first try to open foo/bar/qux, then baz/bar/qux, - // returning the first one that opens successfuly. - // - // disk_path may be an absolute path or relative to the current directory, - // just like a path you'd pass to open(). - void MapPath(const string& virtual_path, const string& disk_path); - - // Return type for DiskFileToVirtualFile(). - enum DiskFileToVirtualFileResult { - SUCCESS, - SHADOWED, - CANNOT_OPEN, - NO_MAPPING - }; - - // Given a path to a file on disk, find a virtual path mapping to that - // file. The first mapping created with MapPath() whose disk_path contains - // the filename is used. However, that virtual path may not actually be - // usable to open the given file. Possible return values are: - // * SUCCESS: The mapping was found. *virtual_file is filled in so that - // calling Open(*virtual_file) will open the file named by disk_file. - // * SHADOWED: A mapping was found, but using Open() to open this virtual - // path will end up returning some different file. This is because some - // other mapping with a higher precedence also matches this virtual path - // and maps it to a different file that exists on disk. *virtual_file - // is filled in as it would be in the SUCCESS case. *shadowing_disk_file - // is filled in with the disk path of the file which would be opened if - // you were to call Open(*virtual_file). - // * CANNOT_OPEN: The mapping was found and was not shadowed, but the - // file specified cannot be opened. When this value is returned, - // errno will indicate the reason the file cannot be opened. *virtual_file - // will be set to the virtual path as in the SUCCESS case, even though - // it is not useful. - // * NO_MAPPING: Indicates that no mapping was found which contains this - // file. - DiskFileToVirtualFileResult - DiskFileToVirtualFile(const string& disk_file, - string* virtual_file, - string* shadowing_disk_file); - - // Given a virtual path, find the path to the file on disk. - // Return true and update disk_file with the on-disk path if the file exists. - // Return false and leave disk_file untouched if the file doesn't exist. - bool VirtualFileToDiskFile(const string& virtual_file, string* disk_file); - - // implements SourceTree ------------------------------------------- - io::ZeroCopyInputStream* Open(const string& filename); - - private: - struct Mapping { - string virtual_path; - string disk_path; - - inline Mapping(const string& virtual_path_param, - const string& disk_path_param) - : virtual_path(virtual_path_param), disk_path(disk_path_param) {} - }; - vector mappings_; - - // Like Open(), but returns the on-disk path in disk_file if disk_file is - // non-NULL and the file could be successfully opened. - io::ZeroCopyInputStream* OpenVirtualFile(const string& virtual_file, - string* disk_file); - - // Like Open() but given the actual on-disk path. - io::ZeroCopyInputStream* OpenDiskFile(const string& filename); - - GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(DiskSourceTree); -}; - -} // namespace compiler -} // namespace protobuf - -} // namespace google -#endif // GOOGLE_PROTOBUF_COMPILER_IMPORTER_H__ diff --git a/modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/importer_unittest.cc b/modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/importer_unittest.cc deleted file mode 100644 index 56fad56ed..000000000 --- a/modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/importer_unittest.cc +++ /dev/null @@ -1,600 +0,0 @@ -// Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// http://code.google.com/p/protobuf/ -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -// Author: kenton@google.com (Kenton Varda) -// Based on original Protocol Buffers design by -// Sanjay Ghemawat, Jeff Dean, and others. - -#include - -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include - -namespace google { -namespace protobuf { -namespace compiler { - -namespace { - -#define EXPECT_SUBSTRING(needle, haystack) \ - EXPECT_PRED_FORMAT2(testing::IsSubstring, (needle), (haystack)) - -class MockErrorCollector : public MultiFileErrorCollector { - public: - MockErrorCollector() {} - ~MockErrorCollector() {} - - string text_; - - // implements ErrorCollector --------------------------------------- - void AddError(const string& filename, int line, int column, - const string& message) { - strings::SubstituteAndAppend(&text_, "$0:$1:$2: $3\n", - filename, line, column, message); - } -}; - -// ------------------------------------------------------------------- - -// A dummy implementation of SourceTree backed by a simple map. -class MockSourceTree : public SourceTree { - public: - MockSourceTree() {} - ~MockSourceTree() {} - - void AddFile(const string& name, const char* contents) { - files_[name] = contents; - } - - // implements SourceTree ------------------------------------------- - io::ZeroCopyInputStream* Open(const string& filename) { - const char* contents = FindPtrOrNull(files_, filename); - if (contents == NULL) { - return NULL; - } else { - return new io::ArrayInputStream(contents, strlen(contents)); - } - } - - private: - hash_map files_; -}; - -// =================================================================== - -class ImporterTest : public testing::Test { - protected: - ImporterTest() - : importer_(&source_tree_, &error_collector_) {} - - void AddFile(const string& filename, const char* text) { - source_tree_.AddFile(filename, text); - } - - // Return the collected error text - string error() const { return error_collector_.text_; } - - MockErrorCollector error_collector_; - MockSourceTree source_tree_; - Importer importer_; -}; - -TEST_F(ImporterTest, Import) { - // Test normal importing. - AddFile("foo.proto", - "syntax = \"proto2\";\n" - "message Foo {}\n"); - - const FileDescriptor* file = importer_.Import("foo.proto"); - EXPECT_EQ("", error_collector_.text_); - ASSERT_TRUE(file != NULL); - - ASSERT_EQ(1, file->message_type_count()); - EXPECT_EQ("Foo", file->message_type(0)->name()); - - // Importing again should return same object. - EXPECT_EQ(file, importer_.Import("foo.proto")); -} - -TEST_F(ImporterTest, ImportNested) { - // Test that importing a file which imports another file works. - AddFile("foo.proto", - "syntax = \"proto2\";\n" - "import \"bar.proto\";\n" - "message Foo {\n" - " optional Bar bar = 1;\n" - "}\n"); - AddFile("bar.proto", - "syntax = \"proto2\";\n" - "message Bar {}\n"); - - // Note that both files are actually parsed by the first call to Import() - // here, since foo.proto imports bar.proto. The second call just returns - // the same ProtoFile for bar.proto which was constructed while importing - // foo.proto. We test that this is the case below by checking that bar - // is among foo's dependencies (by pointer). - const FileDescriptor* foo = importer_.Import("foo.proto"); - const FileDescriptor* bar = importer_.Import("bar.proto"); - EXPECT_EQ("", error_collector_.text_); - ASSERT_TRUE(foo != NULL); - ASSERT_TRUE(bar != NULL); - - // Check that foo's dependency is the same object as bar. - ASSERT_EQ(1, foo->dependency_count()); - EXPECT_EQ(bar, foo->dependency(0)); - - // Check that foo properly cross-links bar. - ASSERT_EQ(1, foo->message_type_count()); - ASSERT_EQ(1, bar->message_type_count()); - ASSERT_EQ(1, foo->message_type(0)->field_count()); - ASSERT_EQ(FieldDescriptor::TYPE_MESSAGE, - foo->message_type(0)->field(0)->type()); - EXPECT_EQ(bar->message_type(0), - foo->message_type(0)->field(0)->message_type()); -} - -TEST_F(ImporterTest, FileNotFound) { - // Error: Parsing a file that doesn't exist. - EXPECT_TRUE(importer_.Import("foo.proto") == NULL); - EXPECT_EQ( - "foo.proto:-1:0: File not found.\n", - error_collector_.text_); -} - -TEST_F(ImporterTest, ImportNotFound) { - // Error: Importing a file that doesn't exist. - AddFile("foo.proto", - "syntax = \"proto2\";\n" - "import \"bar.proto\";\n"); - - EXPECT_TRUE(importer_.Import("foo.proto") == NULL); - EXPECT_EQ( - "bar.proto:-1:0: File not found.\n" - "foo.proto:-1:0: Import \"bar.proto\" was not found or had errors.\n", - error_collector_.text_); -} - -TEST_F(ImporterTest, RecursiveImport) { - // Error: Recursive import. - AddFile("recursive1.proto", - "syntax = \"proto2\";\n" - "import \"recursive2.proto\";\n"); - AddFile("recursive2.proto", - "syntax = \"proto2\";\n" - "import \"recursive1.proto\";\n"); - - EXPECT_TRUE(importer_.Import("recursive1.proto") == NULL); - EXPECT_EQ( - "recursive1.proto:-1:0: File recursively imports itself: recursive1.proto " - "-> recursive2.proto -> recursive1.proto\n" - "recursive2.proto:-1:0: Import \"recursive1.proto\" was not found " - "or had errors.\n" - "recursive1.proto:-1:0: Import \"recursive2.proto\" was not found " - "or had errors.\n", - error_collector_.text_); -} - -// TODO(sanjay): The MapField tests below more properly belong in -// descriptor_unittest, but are more convenient to test here. -TEST_F(ImporterTest, MapFieldValid) { - AddFile( - "map.proto", - "syntax = \"proto2\";\n" - "message Item {\n" - " required string key = 1;\n" - "}\n" - "message Map {\n" - " repeated Item items = 1 [experimental_map_key = \"key\"];\n" - "}\n" - ); - const FileDescriptor* file = importer_.Import("map.proto"); - ASSERT_TRUE(file != NULL) << error_collector_.text_; - EXPECT_EQ("", error_collector_.text_); - - // Check that Map::items points to Item::key - const Descriptor* item_type = file->FindMessageTypeByName("Item"); - ASSERT_TRUE(item_type != NULL); - const Descriptor* map_type = file->FindMessageTypeByName("Map"); - ASSERT_TRUE(map_type != NULL); - const FieldDescriptor* key_field = item_type->FindFieldByName("key"); - ASSERT_TRUE(key_field != NULL); - const FieldDescriptor* items_field = map_type->FindFieldByName("items"); - ASSERT_TRUE(items_field != NULL); - EXPECT_EQ(items_field->experimental_map_key(), key_field); -} - -TEST_F(ImporterTest, MapFieldNotRepeated) { - AddFile( - "map.proto", - "syntax = \"proto2\";\n" - "message Item {\n" - " required string key = 1;\n" - "}\n" - "message Map {\n" - " required Item items = 1 [experimental_map_key = \"key\"];\n" - "}\n" - ); - EXPECT_TRUE(importer_.Import("map.proto") == NULL); - EXPECT_SUBSTRING("only allowed for repeated fields", error()); -} - -TEST_F(ImporterTest, MapFieldNotMessageType) { - AddFile( - "map.proto", - "syntax = \"proto2\";\n" - "message Map {\n" - " repeated int32 items = 1 [experimental_map_key = \"key\"];\n" - "}\n" - ); - EXPECT_TRUE(importer_.Import("map.proto") == NULL); - EXPECT_SUBSTRING("only allowed for fields with a message type", error()); -} - -TEST_F(ImporterTest, MapFieldTypeNotFound) { - AddFile( - "map.proto", - "syntax = \"proto2\";\n" - "message Map {\n" - " repeated Unknown items = 1 [experimental_map_key = \"key\"];\n" - "}\n" - ); - EXPECT_TRUE(importer_.Import("map.proto") == NULL); - EXPECT_SUBSTRING("not defined", error()); -} - -TEST_F(ImporterTest, MapFieldKeyNotFound) { - AddFile( - "map.proto", - "syntax = \"proto2\";\n" - "message Item {\n" - " required string key = 1;\n" - "}\n" - "message Map {\n" - " repeated Item items = 1 [experimental_map_key = \"badkey\"];\n" - "}\n" - ); - EXPECT_TRUE(importer_.Import("map.proto") == NULL); - EXPECT_SUBSTRING("Could not find field", error()); -} - -TEST_F(ImporterTest, MapFieldKeyRepeated) { - AddFile( - "map.proto", - "syntax = \"proto2\";\n" - "message Item {\n" - " repeated string key = 1;\n" - "}\n" - "message Map {\n" - " repeated Item items = 1 [experimental_map_key = \"key\"];\n" - "}\n" - ); - EXPECT_TRUE(importer_.Import("map.proto") == NULL); - EXPECT_SUBSTRING("must not name a repeated field", error()); -} - -TEST_F(ImporterTest, MapFieldKeyNotScalar) { - AddFile( - "map.proto", - "syntax = \"proto2\";\n" - "message ItemKey { }\n" - "message Item {\n" - " required ItemKey key = 1;\n" - "}\n" - "message Map {\n" - " repeated Item items = 1 [experimental_map_key = \"key\"];\n" - "}\n" - ); - EXPECT_TRUE(importer_.Import("map.proto") == NULL); - EXPECT_SUBSTRING("must name a scalar or string", error()); -} - -// =================================================================== - -class DiskSourceTreeTest : public testing::Test { - protected: - virtual void SetUp() { - dirnames_.push_back(TestTempDir() + "/test_proto2_import_path_1"); - dirnames_.push_back(TestTempDir() + "/test_proto2_import_path_2"); - - for (int i = 0; i < dirnames_.size(); i++) { - if (File::Exists(dirnames_[i])) { - File::DeleteRecursively(dirnames_[i], NULL, NULL); - } - GOOGLE_CHECK(File::CreateDir(dirnames_[i].c_str(), DEFAULT_FILE_MODE)); - } - } - - virtual void TearDown() { - for (int i = 0; i < dirnames_.size(); i++) { - File::DeleteRecursively(dirnames_[i], NULL, NULL); - } - } - - void AddFile(const string& filename, const char* contents) { - File::WriteStringToFileOrDie(contents, filename); - } - - void AddSubdir(const string& dirname) { - GOOGLE_CHECK(File::CreateDir(dirname.c_str(), DEFAULT_FILE_MODE)); - } - - void ExpectFileContents(const string& filename, - const char* expected_contents) { - scoped_ptr input(source_tree_.Open(filename)); - - ASSERT_FALSE(input == NULL); - - // Read all the data from the file. - string file_contents; - const void* data; - int size; - while (input->Next(&data, &size)) { - file_contents.append(reinterpret_cast(data), size); - } - - EXPECT_EQ(expected_contents, file_contents); - } - - void ExpectFileNotFound(const string& filename) { - scoped_ptr input(source_tree_.Open(filename)); - EXPECT_TRUE(input == NULL); - } - - DiskSourceTree source_tree_; - - // Paths of two on-disk directories to use during the test. - vector dirnames_; -}; - -TEST_F(DiskSourceTreeTest, MapRoot) { - // Test opening a file in a directory that is mapped to the root of the - // source tree. - AddFile(dirnames_[0] + "/foo", "Hello World!"); - source_tree_.MapPath("", dirnames_[0]); - - ExpectFileContents("foo", "Hello World!"); - ExpectFileNotFound("bar"); -} - -TEST_F(DiskSourceTreeTest, MapDirectory) { - // Test opening a file in a directory that is mapped to somewhere other - // than the root of the source tree. - - AddFile(dirnames_[0] + "/foo", "Hello World!"); - source_tree_.MapPath("baz", dirnames_[0]); - - ExpectFileContents("baz/foo", "Hello World!"); - ExpectFileNotFound("baz/bar"); - ExpectFileNotFound("foo"); - ExpectFileNotFound("bar"); - - // Non-canonical file names should not work. - ExpectFileNotFound("baz//foo"); - ExpectFileNotFound("baz/../baz/foo"); - ExpectFileNotFound("baz/./foo"); - ExpectFileNotFound("baz/foo/"); -} - -TEST_F(DiskSourceTreeTest, NoParent) { - // Test that we cannot open files in a parent of a mapped directory. - - AddFile(dirnames_[0] + "/foo", "Hello World!"); - AddSubdir(dirnames_[0] + "/bar"); - AddFile(dirnames_[0] + "/bar/baz", "Blah."); - source_tree_.MapPath("", dirnames_[0] + "/bar"); - - ExpectFileContents("baz", "Blah."); - ExpectFileNotFound("../foo"); - ExpectFileNotFound("../bar/baz"); -} - -TEST_F(DiskSourceTreeTest, MapFile) { - // Test opening a file that is mapped directly into the source tree. - - AddFile(dirnames_[0] + "/foo", "Hello World!"); - source_tree_.MapPath("foo", dirnames_[0] + "/foo"); - - ExpectFileContents("foo", "Hello World!"); - ExpectFileNotFound("bar"); -} - -TEST_F(DiskSourceTreeTest, SearchMultipleDirectories) { - // Test mapping and searching multiple directories. - - AddFile(dirnames_[0] + "/foo", "Hello World!"); - AddFile(dirnames_[1] + "/foo", "This file should be hidden."); - AddFile(dirnames_[1] + "/bar", "Goodbye World!"); - source_tree_.MapPath("", dirnames_[0]); - source_tree_.MapPath("", dirnames_[1]); - - ExpectFileContents("foo", "Hello World!"); - ExpectFileContents("bar", "Goodbye World!"); - ExpectFileNotFound("baz"); -} - -TEST_F(DiskSourceTreeTest, OrderingTrumpsSpecificity) { - // Test that directories are always searched in order, even when a latter - // directory is more-specific than a former one. - - // Create the "bar" directory so we can put a file in it. - ASSERT_TRUE(File::CreateDir((dirnames_[0] + "/bar").c_str(), - DEFAULT_FILE_MODE)); - - // Add files and map paths. - AddFile(dirnames_[0] + "/bar/foo", "Hello World!"); - AddFile(dirnames_[1] + "/foo", "This file should be hidden."); - source_tree_.MapPath("", dirnames_[0]); - source_tree_.MapPath("bar", dirnames_[1]); - - // Check. - ExpectFileContents("bar/foo", "Hello World!"); -} - -TEST_F(DiskSourceTreeTest, DiskFileToVirtualFile) { - // Test DiskFileToVirtualFile. - - AddFile(dirnames_[0] + "/foo", "Hello World!"); - AddFile(dirnames_[1] + "/foo", "This file should be hidden."); - source_tree_.MapPath("bar", dirnames_[0]); - source_tree_.MapPath("bar", dirnames_[1]); - - string virtual_file; - string shadowing_disk_file; - - EXPECT_EQ(DiskSourceTree::NO_MAPPING, - source_tree_.DiskFileToVirtualFile( - "/foo", &virtual_file, &shadowing_disk_file)); - - EXPECT_EQ(DiskSourceTree::SHADOWED, - source_tree_.DiskFileToVirtualFile( - dirnames_[1] + "/foo", &virtual_file, &shadowing_disk_file)); - EXPECT_EQ("bar/foo", virtual_file); - EXPECT_EQ(dirnames_[0] + "/foo", shadowing_disk_file); - - EXPECT_EQ(DiskSourceTree::CANNOT_OPEN, - source_tree_.DiskFileToVirtualFile( - dirnames_[1] + "/baz", &virtual_file, &shadowing_disk_file)); - EXPECT_EQ("bar/baz", virtual_file); - - EXPECT_EQ(DiskSourceTree::SUCCESS, - source_tree_.DiskFileToVirtualFile( - dirnames_[0] + "/foo", &virtual_file, &shadowing_disk_file)); - EXPECT_EQ("bar/foo", virtual_file); -} - -TEST_F(DiskSourceTreeTest, DiskFileToVirtualFileCanonicalization) { - // Test handling of "..", ".", etc. in DiskFileToVirtualFile(). - - source_tree_.MapPath("dir1", ".."); - source_tree_.MapPath("dir2", "../../foo"); - source_tree_.MapPath("dir3", "./foo/bar/."); - source_tree_.MapPath("dir4", "."); - source_tree_.MapPath("", "/qux"); - source_tree_.MapPath("dir5", "/quux/"); - - string virtual_file; - string shadowing_disk_file; - - // "../.." should not be considered to be under "..". - EXPECT_EQ(DiskSourceTree::NO_MAPPING, - source_tree_.DiskFileToVirtualFile( - "../../baz", &virtual_file, &shadowing_disk_file)); - - // "/foo" is not mapped (it should not be misintepreted as being under "."). - EXPECT_EQ(DiskSourceTree::NO_MAPPING, - source_tree_.DiskFileToVirtualFile( - "/foo", &virtual_file, &shadowing_disk_file)); - -#ifdef WIN32 - // "C:\foo" is not mapped (it should not be misintepreted as being under "."). - EXPECT_EQ(DiskSourceTree::NO_MAPPING, - source_tree_.DiskFileToVirtualFile( - "C:\\foo", &virtual_file, &shadowing_disk_file)); -#endif // WIN32 - - // But "../baz" should be. - EXPECT_EQ(DiskSourceTree::CANNOT_OPEN, - source_tree_.DiskFileToVirtualFile( - "../baz", &virtual_file, &shadowing_disk_file)); - EXPECT_EQ("dir1/baz", virtual_file); - - // "../../foo/baz" is under "../../foo". - EXPECT_EQ(DiskSourceTree::CANNOT_OPEN, - source_tree_.DiskFileToVirtualFile( - "../../foo/baz", &virtual_file, &shadowing_disk_file)); - EXPECT_EQ("dir2/baz", virtual_file); - - // "foo/./bar/baz" is under "./foo/bar/.". - EXPECT_EQ(DiskSourceTree::CANNOT_OPEN, - source_tree_.DiskFileToVirtualFile( - "foo/bar/baz", &virtual_file, &shadowing_disk_file)); - EXPECT_EQ("dir3/baz", virtual_file); - - // "bar" is under ".". - EXPECT_EQ(DiskSourceTree::CANNOT_OPEN, - source_tree_.DiskFileToVirtualFile( - "bar", &virtual_file, &shadowing_disk_file)); - EXPECT_EQ("dir4/bar", virtual_file); - - // "/qux/baz" is under "/qux". - EXPECT_EQ(DiskSourceTree::CANNOT_OPEN, - source_tree_.DiskFileToVirtualFile( - "/qux/baz", &virtual_file, &shadowing_disk_file)); - EXPECT_EQ("baz", virtual_file); - - // "/quux/bar" is under "/quux". - EXPECT_EQ(DiskSourceTree::CANNOT_OPEN, - source_tree_.DiskFileToVirtualFile( - "/quux/bar", &virtual_file, &shadowing_disk_file)); - EXPECT_EQ("dir5/bar", virtual_file); -} - -TEST_F(DiskSourceTreeTest, VirtualFileToDiskFile) { - // Test VirtualFileToDiskFile. - - AddFile(dirnames_[0] + "/foo", "Hello World!"); - AddFile(dirnames_[1] + "/foo", "This file should be hidden."); - AddFile(dirnames_[1] + "/quux", "This file should not be hidden."); - source_tree_.MapPath("bar", dirnames_[0]); - source_tree_.MapPath("bar", dirnames_[1]); - - // Existent files, shadowed and non-shadowed case. - string disk_file; - EXPECT_TRUE(source_tree_.VirtualFileToDiskFile("bar/foo", &disk_file)); - EXPECT_EQ(dirnames_[0] + "/foo", disk_file); - EXPECT_TRUE(source_tree_.VirtualFileToDiskFile("bar/quux", &disk_file)); - EXPECT_EQ(dirnames_[1] + "/quux", disk_file); - - // Nonexistent file in existent directory and vice versa. - string not_touched = "not touched"; - EXPECT_FALSE(source_tree_.VirtualFileToDiskFile("bar/baz", ¬_touched)); - EXPECT_EQ("not touched", not_touched); - EXPECT_FALSE(source_tree_.VirtualFileToDiskFile("baz/foo", ¬_touched)); - EXPECT_EQ("not touched", not_touched); - - // Accept NULL as output parameter. - EXPECT_TRUE(source_tree_.VirtualFileToDiskFile("bar/foo", NULL)); - EXPECT_FALSE(source_tree_.VirtualFileToDiskFile("baz/foo", NULL)); -} - -} // namespace - -} // namespace compiler -} // namespace protobuf -} // namespace google diff --git a/modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/java/java_doc_comment.cc b/modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/java/java_doc_comment.cc deleted file mode 100644 index 60b4f2ac6..000000000 --- a/modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/java/java_doc_comment.cc +++ /dev/null @@ -1,236 +0,0 @@ -// Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// http://code.google.com/p/protobuf/ -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -// Author: kenton@google.com (Kenton Varda) -// Based on original Protocol Buffers design by -// Sanjay Ghemawat, Jeff Dean, and others. - -#include - -#include - -#include -#include - -namespace google { -namespace protobuf { -namespace compiler { -namespace java { - -string EscapeJavadoc(const string& input) { - string result; - result.reserve(input.size() * 2); - - char prev = '*'; - - for (string::size_type i = 0; i < input.size(); i++) { - char c = input[i]; - switch (c) { - case '*': - // Avoid "/*". - if (prev == '/') { - result.append("*"); - } else { - result.push_back(c); - } - break; - case '/': - // Avoid "*/". - if (prev == '*') { - result.append("/"); - } else { - result.push_back(c); - } - break; - case '@': - // "{@" starts Javadoc markup. - if (prev == '{') { - result.append("@"); - } else { - result.push_back(c); - } - break; - case '<': - // Avoid interpretation as HTML. - result.append("<"); - break; - case '>': - // Avoid interpretation as HTML. - result.append(">"); - break; - case '&': - // Avoid interpretation as HTML. - result.append("&"); - break; - case '\\': - // Java interprets Unicode escape sequences anywhere! - result.append("\"); - break; - default: - result.push_back(c); - break; - } - - prev = c; - } - - return result; -} - -static void WriteDocCommentBodyForLocation( - io::Printer* printer, const SourceLocation& location) { - string comments = location.leading_comments.empty() ? - location.trailing_comments : location.leading_comments; - if (!comments.empty()) { - // TODO(kenton): Ideally we should parse the comment text as Markdown and - // write it back as HTML, but this requires a Markdown parser. For now - // we just use
 to get fixed-width text formatting.
-
-    // If the comment itself contains block comment start or end markers,
-    // HTML-escape them so that they don't accidentally close the doc comment.
-    comments = EscapeJavadoc(comments);
-
-    vector lines;
-    SplitStringAllowEmpty(comments, "\n", &lines);
-    while (!lines.empty() && lines.back().empty()) {
-      lines.pop_back();
-    }
-
-    printer->Print(
-        " *\n"
-        " * 
\n");
-    for (int i = 0; i < lines.size(); i++) {
-      // Most lines should start with a space.  Watch out for lines that start
-      // with a /, since putting that right after the leading asterisk will
-      // close the comment.
-      if (!lines[i].empty() && lines[i][0] == '/') {
-        printer->Print(" * $line$\n", "line", lines[i]);
-      } else {
-        printer->Print(" *$line$\n", "line", lines[i]);
-      }
-    }
-    printer->Print(" * 
\n"); - } -} - -template -static void WriteDocCommentBody( - io::Printer* printer, const DescriptorType* descriptor) { - SourceLocation location; - if (descriptor->GetSourceLocation(&location)) { - WriteDocCommentBodyForLocation(printer, location); - } -} - -static string FirstLineOf(const string& value) { - string result = value; - - string::size_type pos = result.find_first_of('\n'); - if (pos != string::npos) { - result.erase(pos); - } - - // If line ends in an opening brace, make it "{ ... }" so it looks nice. - if (!result.empty() && result[result.size() - 1] == '{') { - result.append(" ... }"); - } - - return result; -} - -void WriteMessageDocComment(io::Printer* printer, const Descriptor* message) { - printer->Print( - "/**\n" - " * Protobuf type {@code $fullname$}\n", - "fullname", EscapeJavadoc(message->full_name())); - WriteDocCommentBody(printer, message); - printer->Print(" */\n"); -} - -void WriteFieldDocComment(io::Printer* printer, const FieldDescriptor* field) { - // In theory we should have slightly different comments for setters, getters, - // etc., but in practice everyone already knows the difference between these - // so it's redundant information. - - // We use the field declaration as the first line of the comment, e.g.: - // optional string foo = 5; - // This communicates a lot of information about the field in a small space. - // If the field is a group, the debug string might end with {. - printer->Print( - "/**\n" - " * $def$\n", - "def", EscapeJavadoc(FirstLineOf(field->DebugString()))); - WriteDocCommentBody(printer, field); - printer->Print(" */\n"); -} - -void WriteEnumDocComment(io::Printer* printer, const EnumDescriptor* enum_) { - printer->Print( - "/**\n" - " * Protobuf enum {@code $fullname$}\n", - "fullname", EscapeJavadoc(enum_->full_name())); - WriteDocCommentBody(printer, enum_); - printer->Print(" */\n"); -} - -void WriteEnumValueDocComment(io::Printer* printer, - const EnumValueDescriptor* value) { - printer->Print( - "/**\n" - " * $def$\n", - "def", EscapeJavadoc(FirstLineOf(value->DebugString()))); - WriteDocCommentBody(printer, value); - printer->Print(" */\n"); -} - -void WriteServiceDocComment(io::Printer* printer, - const ServiceDescriptor* service) { - printer->Print( - "/**\n" - " * Protobuf service {@code $fullname$}\n", - "fullname", EscapeJavadoc(service->full_name())); - WriteDocCommentBody(printer, service); - printer->Print(" */\n"); -} - -void WriteMethodDocComment(io::Printer* printer, - const MethodDescriptor* method) { - printer->Print( - "/**\n" - " * $def$\n", - "def", EscapeJavadoc(FirstLineOf(method->DebugString()))); - WriteDocCommentBody(printer, method); - printer->Print(" */\n"); -} - -} // namespace java -} // namespace compiler -} // namespace protobuf -} // namespace google diff --git a/modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/java/java_doc_comment.h b/modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/java/java_doc_comment.h deleted file mode 100644 index 7244d9bac..000000000 --- a/modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/java/java_doc_comment.h +++ /dev/null @@ -1,69 +0,0 @@ -// Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// http://code.google.com/p/protobuf/ -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -// Author: kenton@google.com (Kenton Varda) -// Based on original Protocol Buffers design by -// Sanjay Ghemawat, Jeff Dean, and others. - -#ifndef GOOGLE_PROTOBUF_COMPILER_JAVA_DOC_COMMENT_H__ -#define GOOGLE_PROTOBUF_COMPILER_JAVA_DOC_COMMENT_H__ - -#include - -namespace google { -namespace protobuf { - namespace io { - class Printer; // printer.h - } -} - -namespace protobuf { -namespace compiler { -namespace java { - -void WriteMessageDocComment(io::Printer* printer, const Descriptor* message); -void WriteFieldDocComment(io::Printer* printer, const FieldDescriptor* field); -void WriteEnumDocComment(io::Printer* printer, const EnumDescriptor* enum_); -void WriteEnumValueDocComment(io::Printer* printer, - const EnumValueDescriptor* value); -void WriteServiceDocComment(io::Printer* printer, - const ServiceDescriptor* service); -void WriteMethodDocComment(io::Printer* printer, - const MethodDescriptor* method); - -// Exposed for testing only. -LIBPROTOC_EXPORT string EscapeJavadoc(const string& input); - -} // namespace java -} // namespace compiler -} // namespace protobuf - -} // namespace google -#endif // GOOGLE_PROTOBUF_COMPILER_JAVA_DOC_COMMENT_H__ diff --git a/modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/java/java_doc_comment_unittest.cc b/modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/java/java_doc_comment_unittest.cc deleted file mode 100644 index 28b6d8b49..000000000 --- a/modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/java/java_doc_comment_unittest.cc +++ /dev/null @@ -1,66 +0,0 @@ -// Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// http://code.google.com/p/protobuf/ -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -// Author: kenton@google.com (Kenton Varda) - -#include - -#include - -namespace google { -namespace protobuf { -namespace compiler { -namespace java { -namespace { - -TEST(JavaDocCommentTest, Escaping) { - EXPECT_EQ("foo /* bar */ baz", EscapeJavadoc("foo /* bar */ baz")); - EXPECT_EQ("foo /*/ baz", EscapeJavadoc("foo /*/ baz")); - EXPECT_EQ("{@foo}", EscapeJavadoc("{@foo}")); - EXPECT_EQ("<i>&</i>", EscapeJavadoc("&")); - EXPECT_EQ("foo\u1234bar", EscapeJavadoc("foo\\u1234bar")); -} - -// TODO(kenton): It's hard to write a robust test of the doc comments -- we -// can only really compare the output against a golden value, which is a -// fairly tedious and fragile testing strategy. If we want to go that route, -// it probably makes sense to bite the bullet and write a test that compares -// the whole generated output for unittest.proto against a golden value, with -// a very simple script that can be run to regenerate it with the latest code. -// This would mean that updates to the golden file would have to be included -// in any change to the code generator, which would actually be fairly useful -// as it allows the reviewer to see clearly how the generated code is -// changing. - -} // namespace -} // namespace java -} // namespace compiler -} // namespace protobuf -} // namespace google diff --git a/modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/java/java_enum.cc b/modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/java/java_enum.cc deleted file mode 100644 index cfed815f8..000000000 --- a/modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/java/java_enum.cc +++ /dev/null @@ -1,271 +0,0 @@ -// Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// http://code.google.com/p/protobuf/ -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -// Author: kenton@google.com (Kenton Varda) -// Based on original Protocol Buffers design by -// Sanjay Ghemawat, Jeff Dean, and others. - -#include -#include - -#include -#include -#include -#include -#include -#include - -namespace google { -namespace protobuf { -namespace compiler { -namespace java { - -EnumGenerator::EnumGenerator(const EnumDescriptor* descriptor) - : descriptor_(descriptor) { - for (int i = 0; i < descriptor_->value_count(); i++) { - const EnumValueDescriptor* value = descriptor_->value(i); - const EnumValueDescriptor* canonical_value = - descriptor_->FindValueByNumber(value->number()); - - if (value == canonical_value) { - canonical_values_.push_back(value); - } else { - Alias alias; - alias.value = value; - alias.canonical_value = canonical_value; - aliases_.push_back(alias); - } - } -} - -EnumGenerator::~EnumGenerator() {} - -void EnumGenerator::Generate(io::Printer* printer) { - WriteEnumDocComment(printer, descriptor_); - if (HasDescriptorMethods(descriptor_)) { - printer->Print( - "public enum $classname$\n" - " implements com.google.protobuf.ProtocolMessageEnum {\n", - "classname", descriptor_->name()); - } else { - printer->Print( - "public enum $classname$\n" - " implements com.google.protobuf.Internal.EnumLite {\n", - "classname", descriptor_->name()); - } - printer->Indent(); - - for (int i = 0; i < canonical_values_.size(); i++) { - map vars; - vars["name"] = canonical_values_[i]->name(); - vars["index"] = SimpleItoa(canonical_values_[i]->index()); - vars["number"] = SimpleItoa(canonical_values_[i]->number()); - WriteEnumValueDocComment(printer, canonical_values_[i]); - printer->Print(vars, - "$name$($index$, $number$),\n"); - } - - printer->Print( - ";\n" - "\n"); - - // ----------------------------------------------------------------- - - for (int i = 0; i < aliases_.size(); i++) { - map vars; - vars["classname"] = descriptor_->name(); - vars["name"] = aliases_[i].value->name(); - vars["canonical_name"] = aliases_[i].canonical_value->name(); - WriteEnumValueDocComment(printer, aliases_[i].value); - printer->Print(vars, - "public static final $classname$ $name$ = $canonical_name$;\n"); - } - - for (int i = 0; i < descriptor_->value_count(); i++) { - map vars; - vars["name"] = descriptor_->value(i)->name(); - vars["number"] = SimpleItoa(descriptor_->value(i)->number()); - WriteEnumValueDocComment(printer, descriptor_->value(i)); - printer->Print(vars, - "public static final int $name$_VALUE = $number$;\n"); - } - printer->Print("\n"); - - // ----------------------------------------------------------------- - - printer->Print( - "\n" - "public final int getNumber() { return value; }\n" - "\n" - "public static $classname$ valueOf(int value) {\n" - " switch (value) {\n", - "classname", descriptor_->name()); - printer->Indent(); - printer->Indent(); - - for (int i = 0; i < canonical_values_.size(); i++) { - printer->Print( - "case $number$: return $name$;\n", - "name", canonical_values_[i]->name(), - "number", SimpleItoa(canonical_values_[i]->number())); - } - - printer->Outdent(); - printer->Outdent(); - printer->Print( - " default: return null;\n" - " }\n" - "}\n" - "\n" - "public static com.google.protobuf.Internal.EnumLiteMap<$classname$>\n" - " internalGetValueMap() {\n" - " return internalValueMap;\n" - "}\n" - "private static com.google.protobuf.Internal.EnumLiteMap<$classname$>\n" - " internalValueMap =\n" - " new com.google.protobuf.Internal.EnumLiteMap<$classname$>() {\n" - " public $classname$ findValueByNumber(int number) {\n" - " return $classname$.valueOf(number);\n" - " }\n" - " };\n" - "\n", - "classname", descriptor_->name()); - - // ----------------------------------------------------------------- - // Reflection - - if (HasDescriptorMethods(descriptor_)) { - printer->Print( - "public final com.google.protobuf.Descriptors.EnumValueDescriptor\n" - " getValueDescriptor() {\n" - " return getDescriptor().getValues().get(index);\n" - "}\n" - "public final com.google.protobuf.Descriptors.EnumDescriptor\n" - " getDescriptorForType() {\n" - " return getDescriptor();\n" - "}\n" - "public static final com.google.protobuf.Descriptors.EnumDescriptor\n" - " getDescriptor() {\n"); - - // TODO(kenton): Cache statically? Note that we can't access descriptors - // at module init time because it wouldn't work with descriptor.proto, but - // we can cache the value the first time getDescriptor() is called. - if (descriptor_->containing_type() == NULL) { - printer->Print( - " return $file$.getDescriptor().getEnumTypes().get($index$);\n", - "file", ClassName(descriptor_->file()), - "index", SimpleItoa(descriptor_->index())); - } else { - printer->Print( - " return $parent$.getDescriptor().getEnumTypes().get($index$);\n", - "parent", ClassName(descriptor_->containing_type()), - "index", SimpleItoa(descriptor_->index())); - } - - printer->Print( - "}\n" - "\n" - "private static final $classname$[] VALUES = ", - "classname", descriptor_->name()); - - if (CanUseEnumValues()) { - // If the constants we are going to output are exactly the ones we - // have declared in the Java enum in the same order, then we can use - // the values() method that the Java compiler automatically generates - // for every enum. - printer->Print("values();\n"); - } else { - printer->Print( - "{\n" - " "); - for (int i = 0; i < descriptor_->value_count(); i++) { - printer->Print("$name$, ", - "name", descriptor_->value(i)->name()); - } - printer->Print( - "\n" - "};\n"); - } - - printer->Print( - "\n" - "public static $classname$ valueOf(\n" - " com.google.protobuf.Descriptors.EnumValueDescriptor desc) {\n" - " if (desc.getType() != getDescriptor()) {\n" - " throw new java.lang.IllegalArgumentException(\n" - " \"EnumValueDescriptor is not for this type.\");\n" - " }\n" - " return VALUES[desc.getIndex()];\n" - "}\n" - "\n", - "classname", descriptor_->name()); - - // index is only used for reflection; lite implementation does not need it - printer->Print("private final int index;\n"); - } - - // ----------------------------------------------------------------- - - printer->Print( - "private final int value;\n\n" - "private $classname$(int index, int value) {\n", - "classname", descriptor_->name()); - if (HasDescriptorMethods(descriptor_)) { - printer->Print(" this.index = index;\n"); - } - printer->Print( - " this.value = value;\n" - "}\n"); - - printer->Print( - "\n" - "// @@protoc_insertion_point(enum_scope:$full_name$)\n", - "full_name", descriptor_->full_name()); - - printer->Outdent(); - printer->Print("}\n\n"); -} - -bool EnumGenerator::CanUseEnumValues() { - if (canonical_values_.size() != descriptor_->value_count()) { - return false; - } - for (int i = 0; i < descriptor_->value_count(); i++) { - if (descriptor_->value(i)->name() != canonical_values_[i]->name()) { - return false; - } - } - return true; -} - -} // namespace java -} // namespace compiler -} // namespace protobuf -} // namespace google diff --git a/modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/java/java_enum.h b/modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/java/java_enum.h deleted file mode 100644 index 9a9e5742a..000000000 --- a/modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/java/java_enum.h +++ /dev/null @@ -1,86 +0,0 @@ -// Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// http://code.google.com/p/protobuf/ -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -// Author: kenton@google.com (Kenton Varda) -// Based on original Protocol Buffers design by -// Sanjay Ghemawat, Jeff Dean, and others. - -#ifndef GOOGLE_PROTOBUF_COMPILER_JAVA_ENUM_H__ -#define GOOGLE_PROTOBUF_COMPILER_JAVA_ENUM_H__ - -#include -#include -#include - -namespace google { -namespace protobuf { - namespace io { - class Printer; // printer.h - } -} - -namespace protobuf { -namespace compiler { -namespace java { - -class EnumGenerator { - public: - explicit EnumGenerator(const EnumDescriptor* descriptor); - ~EnumGenerator(); - - void Generate(io::Printer* printer); - - private: - const EnumDescriptor* descriptor_; - - // The proto language allows multiple enum constants to have the same numeric - // value. Java, however, does not allow multiple enum constants to be - // considered equivalent. We treat the first defined constant for any - // given numeric value as "canonical" and the rest as aliases of that - // canonical value. - vector canonical_values_; - - struct Alias { - const EnumValueDescriptor* value; - const EnumValueDescriptor* canonical_value; - }; - vector aliases_; - - bool CanUseEnumValues(); - - GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(EnumGenerator); -}; - -} // namespace java -} // namespace compiler -} // namespace protobuf - -} // namespace google -#endif // GOOGLE_PROTOBUF_COMPILER_JAVA_ENUM_H__ diff --git a/modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/java/java_enum_field.cc b/modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/java/java_enum_field.cc deleted file mode 100644 index ec0b067ee..000000000 --- a/modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/java/java_enum_field.cc +++ /dev/null @@ -1,603 +0,0 @@ -// Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// http://code.google.com/p/protobuf/ -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -// Author: kenton@google.com (Kenton Varda) -// Based on original Protocol Buffers design by -// Sanjay Ghemawat, Jeff Dean, and others. - -#include -#include - -#include -#include -#include -#include -#include -#include -#include - -namespace google { -namespace protobuf { -namespace compiler { -namespace java { - -namespace { - -// TODO(kenton): Factor out a "SetCommonFieldVariables()" to get rid of -// repeat code between this and the other field types. -void SetEnumVariables(const FieldDescriptor* descriptor, - int messageBitIndex, - int builderBitIndex, - map* variables) { - (*variables)["name"] = - UnderscoresToCamelCase(descriptor); - (*variables)["capitalized_name"] = - UnderscoresToCapitalizedCamelCase(descriptor); - (*variables)["constant_name"] = FieldConstantName(descriptor); - (*variables)["number"] = SimpleItoa(descriptor->number()); - (*variables)["type"] = ClassName(descriptor->enum_type()); - (*variables)["default"] = DefaultValue(descriptor); - (*variables)["tag"] = SimpleItoa(internal::WireFormat::MakeTag(descriptor)); - (*variables)["tag_size"] = SimpleItoa( - internal::WireFormat::TagSize(descriptor->number(), GetType(descriptor))); - // TODO(birdo): Add @deprecated javadoc when generating javadoc is supported - // by the proto compiler - (*variables)["deprecation"] = descriptor->options().deprecated() - ? "@java.lang.Deprecated " : ""; - (*variables)["on_changed"] = - HasDescriptorMethods(descriptor->containing_type()) ? "onChanged();" : ""; - - // For singular messages and builders, one bit is used for the hasField bit. - (*variables)["get_has_field_bit_message"] = GenerateGetBit(messageBitIndex); - (*variables)["set_has_field_bit_message"] = GenerateSetBit(messageBitIndex); - - (*variables)["get_has_field_bit_builder"] = GenerateGetBit(builderBitIndex); - (*variables)["set_has_field_bit_builder"] = GenerateSetBit(builderBitIndex); - (*variables)["clear_has_field_bit_builder"] = - GenerateClearBit(builderBitIndex); - - // For repated builders, one bit is used for whether the array is immutable. - (*variables)["get_mutable_bit_builder"] = GenerateGetBit(builderBitIndex); - (*variables)["set_mutable_bit_builder"] = GenerateSetBit(builderBitIndex); - (*variables)["clear_mutable_bit_builder"] = GenerateClearBit(builderBitIndex); - - // For repeated fields, one bit is used for whether the array is immutable - // in the parsing constructor. - (*variables)["get_mutable_bit_parser"] = - GenerateGetBitMutableLocal(builderBitIndex); - (*variables)["set_mutable_bit_parser"] = - GenerateSetBitMutableLocal(builderBitIndex); - - (*variables)["get_has_field_bit_from_local"] = - GenerateGetBitFromLocal(builderBitIndex); - (*variables)["set_has_field_bit_to_local"] = - GenerateSetBitToLocal(messageBitIndex); -} - -} // namespace - -// =================================================================== - -EnumFieldGenerator:: -EnumFieldGenerator(const FieldDescriptor* descriptor, - int messageBitIndex, - int builderBitIndex) - : descriptor_(descriptor), messageBitIndex_(messageBitIndex), - builderBitIndex_(builderBitIndex) { - SetEnumVariables(descriptor, messageBitIndex, builderBitIndex, &variables_); -} - -EnumFieldGenerator::~EnumFieldGenerator() {} - -int EnumFieldGenerator::GetNumBitsForMessage() const { - return 1; -} - -int EnumFieldGenerator::GetNumBitsForBuilder() const { - return 1; -} - -void EnumFieldGenerator:: -GenerateInterfaceMembers(io::Printer* printer) const { - WriteFieldDocComment(printer, descriptor_); - printer->Print(variables_, - "$deprecation$boolean has$capitalized_name$();\n"); - WriteFieldDocComment(printer, descriptor_); - printer->Print(variables_, - "$deprecation$$type$ get$capitalized_name$();\n"); -} - -void EnumFieldGenerator:: -GenerateMembers(io::Printer* printer) const { - printer->Print(variables_, - "private $type$ $name$_;\n"); - WriteFieldDocComment(printer, descriptor_); - printer->Print(variables_, - "$deprecation$public boolean has$capitalized_name$() {\n" - " return $get_has_field_bit_message$;\n" - "}\n"); - WriteFieldDocComment(printer, descriptor_); - printer->Print(variables_, - "$deprecation$public $type$ get$capitalized_name$() {\n" - " return $name$_;\n" - "}\n"); -} - -void EnumFieldGenerator:: -GenerateBuilderMembers(io::Printer* printer) const { - printer->Print(variables_, - "private $type$ $name$_ = $default$;\n"); - WriteFieldDocComment(printer, descriptor_); - printer->Print(variables_, - "$deprecation$public boolean has$capitalized_name$() {\n" - " return $get_has_field_bit_builder$;\n" - "}\n"); - WriteFieldDocComment(printer, descriptor_); - printer->Print(variables_, - "$deprecation$public $type$ get$capitalized_name$() {\n" - " return $name$_;\n" - "}\n"); - WriteFieldDocComment(printer, descriptor_); - printer->Print(variables_, - "$deprecation$public Builder set$capitalized_name$($type$ value) {\n" - " if (value == null) {\n" - " throw new NullPointerException();\n" - " }\n" - " $set_has_field_bit_builder$;\n" - " $name$_ = value;\n" - " $on_changed$\n" - " return this;\n" - "}\n"); - WriteFieldDocComment(printer, descriptor_); - printer->Print(variables_, - "$deprecation$public Builder clear$capitalized_name$() {\n" - " $clear_has_field_bit_builder$;\n" - " $name$_ = $default$;\n" - " $on_changed$\n" - " return this;\n" - "}\n"); -} - -void EnumFieldGenerator:: -GenerateFieldBuilderInitializationCode(io::Printer* printer) const { - // noop for enums -} - -void EnumFieldGenerator:: -GenerateInitializationCode(io::Printer* printer) const { - printer->Print(variables_, "$name$_ = $default$;\n"); -} - -void EnumFieldGenerator:: -GenerateBuilderClearCode(io::Printer* printer) const { - printer->Print(variables_, - "$name$_ = $default$;\n" - "$clear_has_field_bit_builder$;\n"); -} - -void EnumFieldGenerator:: -GenerateMergingCode(io::Printer* printer) const { - printer->Print(variables_, - "if (other.has$capitalized_name$()) {\n" - " set$capitalized_name$(other.get$capitalized_name$());\n" - "}\n"); -} - -void EnumFieldGenerator:: -GenerateBuildingCode(io::Printer* printer) const { - printer->Print(variables_, - "if ($get_has_field_bit_from_local$) {\n" - " $set_has_field_bit_to_local$;\n" - "}\n" - "result.$name$_ = $name$_;\n"); -} - -void EnumFieldGenerator:: -GenerateParsingCode(io::Printer* printer) const { - printer->Print(variables_, - "int rawValue = input.readEnum();\n" - "$type$ value = $type$.valueOf(rawValue);\n"); - if (HasUnknownFields(descriptor_->containing_type())) { - printer->Print(variables_, - "if (value == null) {\n" - " unknownFields.mergeVarintField($number$, rawValue);\n" - "} else {\n"); - } else { - printer->Print(variables_, - "if (value != null) {\n"); - } - printer->Print(variables_, - " $set_has_field_bit_message$;\n" - " $name$_ = value;\n" - "}\n"); -} - -void EnumFieldGenerator:: -GenerateParsingDoneCode(io::Printer* printer) const { - // noop for enums -} - -void EnumFieldGenerator:: -GenerateSerializationCode(io::Printer* printer) const { - printer->Print(variables_, - "if ($get_has_field_bit_message$) {\n" - " output.writeEnum($number$, $name$_.getNumber());\n" - "}\n"); -} - -void EnumFieldGenerator:: -GenerateSerializedSizeCode(io::Printer* printer) const { - printer->Print(variables_, - "if ($get_has_field_bit_message$) {\n" - " size += com.google.protobuf.CodedOutputStream\n" - " .computeEnumSize($number$, $name$_.getNumber());\n" - "}\n"); -} - -void EnumFieldGenerator:: -GenerateEqualsCode(io::Printer* printer) const { - printer->Print(variables_, - "result = result &&\n" - " (get$capitalized_name$() == other.get$capitalized_name$());\n"); -} - -void EnumFieldGenerator:: -GenerateHashCode(io::Printer* printer) const { - printer->Print(variables_, - "hash = (37 * hash) + $constant_name$;\n" - "hash = (53 * hash) + hashEnum(get$capitalized_name$());\n"); -} - -string EnumFieldGenerator::GetBoxedType() const { - return ClassName(descriptor_->enum_type()); -} - -// =================================================================== - -RepeatedEnumFieldGenerator:: -RepeatedEnumFieldGenerator(const FieldDescriptor* descriptor, - int messageBitIndex, - int builderBitIndex) - : descriptor_(descriptor), messageBitIndex_(messageBitIndex), - builderBitIndex_(builderBitIndex) { - SetEnumVariables(descriptor, messageBitIndex, builderBitIndex, &variables_); -} - -RepeatedEnumFieldGenerator::~RepeatedEnumFieldGenerator() {} - -int RepeatedEnumFieldGenerator::GetNumBitsForMessage() const { - return 0; -} - -int RepeatedEnumFieldGenerator::GetNumBitsForBuilder() const { - return 1; -} - -void RepeatedEnumFieldGenerator:: -GenerateInterfaceMembers(io::Printer* printer) const { - WriteFieldDocComment(printer, descriptor_); - printer->Print(variables_, - "$deprecation$java.util.List<$type$> get$capitalized_name$List();\n"); - WriteFieldDocComment(printer, descriptor_); - printer->Print(variables_, - "$deprecation$int get$capitalized_name$Count();\n"); - WriteFieldDocComment(printer, descriptor_); - printer->Print(variables_, - "$deprecation$$type$ get$capitalized_name$(int index);\n"); -} - -void RepeatedEnumFieldGenerator:: -GenerateMembers(io::Printer* printer) const { - printer->Print(variables_, - "private java.util.List<$type$> $name$_;\n"); - WriteFieldDocComment(printer, descriptor_); - printer->Print(variables_, - "$deprecation$public java.util.List<$type$> get$capitalized_name$List() {\n" - " return $name$_;\n" // note: unmodifiable list - "}\n"); - WriteFieldDocComment(printer, descriptor_); - printer->Print(variables_, - "$deprecation$public int get$capitalized_name$Count() {\n" - " return $name$_.size();\n" - "}\n"); - WriteFieldDocComment(printer, descriptor_); - printer->Print(variables_, - "$deprecation$public $type$ get$capitalized_name$(int index) {\n" - " return $name$_.get(index);\n" - "}\n"); - - if (descriptor_->options().packed() && - HasGeneratedMethods(descriptor_->containing_type())) { - printer->Print(variables_, - "private int $name$MemoizedSerializedSize;\n"); - } -} - -void RepeatedEnumFieldGenerator:: -GenerateBuilderMembers(io::Printer* printer) const { - printer->Print(variables_, - // One field is the list and the other field keeps track of whether the - // list is immutable. If it's immutable, the invariant is that it must - // either an instance of Collections.emptyList() or it's an ArrayList - // wrapped in a Collections.unmodifiableList() wrapper and nobody else has - // a refererence to the underlying ArrayList. This invariant allows us to - // share instances of lists between protocol buffers avoiding expensive - // memory allocations. Note, immutable is a strong guarantee here -- not - // just that the list cannot be modified via the reference but that the - // list can never be modified. - "private java.util.List<$type$> $name$_ =\n" - " java.util.Collections.emptyList();\n" - - "private void ensure$capitalized_name$IsMutable() {\n" - " if (!$get_mutable_bit_builder$) {\n" - " $name$_ = new java.util.ArrayList<$type$>($name$_);\n" - " $set_mutable_bit_builder$;\n" - " }\n" - "}\n"); - - WriteFieldDocComment(printer, descriptor_); - printer->Print(variables_, - // Note: We return an unmodifiable list because otherwise the caller - // could hold on to the returned list and modify it after the message - // has been built, thus mutating the message which is supposed to be - // immutable. - "$deprecation$public java.util.List<$type$> get$capitalized_name$List() {\n" - " return java.util.Collections.unmodifiableList($name$_);\n" - "}\n"); - WriteFieldDocComment(printer, descriptor_); - printer->Print(variables_, - "$deprecation$public int get$capitalized_name$Count() {\n" - " return $name$_.size();\n" - "}\n"); - WriteFieldDocComment(printer, descriptor_); - printer->Print(variables_, - "$deprecation$public $type$ get$capitalized_name$(int index) {\n" - " return $name$_.get(index);\n" - "}\n"); - WriteFieldDocComment(printer, descriptor_); - printer->Print(variables_, - "$deprecation$public Builder set$capitalized_name$(\n" - " int index, $type$ value) {\n" - " if (value == null) {\n" - " throw new NullPointerException();\n" - " }\n" - " ensure$capitalized_name$IsMutable();\n" - " $name$_.set(index, value);\n" - " $on_changed$\n" - " return this;\n" - "}\n"); - WriteFieldDocComment(printer, descriptor_); - printer->Print(variables_, - "$deprecation$public Builder add$capitalized_name$($type$ value) {\n" - " if (value == null) {\n" - " throw new NullPointerException();\n" - " }\n" - " ensure$capitalized_name$IsMutable();\n" - " $name$_.add(value);\n" - " $on_changed$\n" - " return this;\n" - "}\n"); - WriteFieldDocComment(printer, descriptor_); - printer->Print(variables_, - "$deprecation$public Builder addAll$capitalized_name$(\n" - " java.lang.Iterable values) {\n" - " ensure$capitalized_name$IsMutable();\n" - " super.addAll(values, $name$_);\n" - " $on_changed$\n" - " return this;\n" - "}\n"); - WriteFieldDocComment(printer, descriptor_); - printer->Print(variables_, - "$deprecation$public Builder clear$capitalized_name$() {\n" - " $name$_ = java.util.Collections.emptyList();\n" - " $clear_mutable_bit_builder$;\n" - " $on_changed$\n" - " return this;\n" - "}\n"); -} - -void RepeatedEnumFieldGenerator:: -GenerateFieldBuilderInitializationCode(io::Printer* printer) const { - // noop for enums -} - -void RepeatedEnumFieldGenerator:: -GenerateInitializationCode(io::Printer* printer) const { - printer->Print(variables_, "$name$_ = java.util.Collections.emptyList();\n"); -} - -void RepeatedEnumFieldGenerator:: -GenerateBuilderClearCode(io::Printer* printer) const { - printer->Print(variables_, - "$name$_ = java.util.Collections.emptyList();\n" - "$clear_mutable_bit_builder$;\n"); -} - -void RepeatedEnumFieldGenerator:: -GenerateMergingCode(io::Printer* printer) const { - // The code below does two optimizations: - // 1. If the other list is empty, there's nothing to do. This ensures we - // don't allocate a new array if we already have an immutable one. - // 2. If the other list is non-empty and our current list is empty, we can - // reuse the other list which is guaranteed to be immutable. - printer->Print(variables_, - "if (!other.$name$_.isEmpty()) {\n" - " if ($name$_.isEmpty()) {\n" - " $name$_ = other.$name$_;\n" - " $clear_mutable_bit_builder$;\n" - " } else {\n" - " ensure$capitalized_name$IsMutable();\n" - " $name$_.addAll(other.$name$_);\n" - " }\n" - " $on_changed$\n" - "}\n"); -} - -void RepeatedEnumFieldGenerator:: -GenerateBuildingCode(io::Printer* printer) const { - // The code below ensures that the result has an immutable list. If our - // list is immutable, we can just reuse it. If not, we make it immutable. - printer->Print(variables_, - "if ($get_mutable_bit_builder$) {\n" - " $name$_ = java.util.Collections.unmodifiableList($name$_);\n" - " $clear_mutable_bit_builder$;\n" - "}\n" - "result.$name$_ = $name$_;\n"); -} - -void RepeatedEnumFieldGenerator:: -GenerateParsingCode(io::Printer* printer) const { - // Read and store the enum - printer->Print(variables_, - "int rawValue = input.readEnum();\n" - "$type$ value = $type$.valueOf(rawValue);\n"); - if (HasUnknownFields(descriptor_->containing_type())) { - printer->Print(variables_, - "if (value == null) {\n" - " unknownFields.mergeVarintField($number$, rawValue);\n" - "} else {\n"); - } else { - printer->Print(variables_, - "if (value != null) {\n"); - } - printer->Print(variables_, - " if (!$get_mutable_bit_parser$) {\n" - " $name$_ = new java.util.ArrayList<$type$>();\n" - " $set_mutable_bit_parser$;\n" - " }\n" - " $name$_.add(value);\n" - "}\n"); -} - -void RepeatedEnumFieldGenerator:: -GenerateParsingCodeFromPacked(io::Printer* printer) const { - // Wrap GenerateParsingCode's contents with a while loop. - - printer->Print(variables_, - "int length = input.readRawVarint32();\n" - "int oldLimit = input.pushLimit(length);\n" - "while(input.getBytesUntilLimit() > 0) {\n"); - printer->Indent(); - - GenerateParsingCode(printer); - - printer->Outdent(); - printer->Print(variables_, - "}\n" - "input.popLimit(oldLimit);\n"); -} - -void RepeatedEnumFieldGenerator:: -GenerateParsingDoneCode(io::Printer* printer) const { - printer->Print(variables_, - "if ($get_mutable_bit_parser$) {\n" - " $name$_ = java.util.Collections.unmodifiableList($name$_);\n" - "}\n"); -} - -void RepeatedEnumFieldGenerator:: -GenerateSerializationCode(io::Printer* printer) const { - if (descriptor_->options().packed()) { - printer->Print(variables_, - "if (get$capitalized_name$List().size() > 0) {\n" - " output.writeRawVarint32($tag$);\n" - " output.writeRawVarint32($name$MemoizedSerializedSize);\n" - "}\n" - "for (int i = 0; i < $name$_.size(); i++) {\n" - " output.writeEnumNoTag($name$_.get(i).getNumber());\n" - "}\n"); - } else { - printer->Print(variables_, - "for (int i = 0; i < $name$_.size(); i++) {\n" - " output.writeEnum($number$, $name$_.get(i).getNumber());\n" - "}\n"); - } -} - -void RepeatedEnumFieldGenerator:: -GenerateSerializedSizeCode(io::Printer* printer) const { - printer->Print(variables_, - "{\n" - " int dataSize = 0;\n"); - printer->Indent(); - - printer->Print(variables_, - "for (int i = 0; i < $name$_.size(); i++) {\n" - " dataSize += com.google.protobuf.CodedOutputStream\n" - " .computeEnumSizeNoTag($name$_.get(i).getNumber());\n" - "}\n"); - printer->Print( - "size += dataSize;\n"); - if (descriptor_->options().packed()) { - printer->Print(variables_, - "if (!get$capitalized_name$List().isEmpty()) {" - " size += $tag_size$;\n" - " size += com.google.protobuf.CodedOutputStream\n" - " .computeRawVarint32Size(dataSize);\n" - "}"); - } else { - printer->Print(variables_, - "size += $tag_size$ * $name$_.size();\n"); - } - - // cache the data size for packed fields. - if (descriptor_->options().packed()) { - printer->Print(variables_, - "$name$MemoizedSerializedSize = dataSize;\n"); - } - - printer->Outdent(); - printer->Print("}\n"); -} - -void RepeatedEnumFieldGenerator:: -GenerateEqualsCode(io::Printer* printer) const { - printer->Print(variables_, - "result = result && get$capitalized_name$List()\n" - " .equals(other.get$capitalized_name$List());\n"); -} - -void RepeatedEnumFieldGenerator:: -GenerateHashCode(io::Printer* printer) const { - printer->Print(variables_, - "if (get$capitalized_name$Count() > 0) {\n" - " hash = (37 * hash) + $constant_name$;\n" - " hash = (53 * hash) + hashEnumList(get$capitalized_name$List());\n" - "}\n"); -} - -string RepeatedEnumFieldGenerator::GetBoxedType() const { - return ClassName(descriptor_->enum_type()); -} - -} // namespace java -} // namespace compiler -} // namespace protobuf -} // namespace google diff --git a/modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/java/java_enum_field.h b/modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/java/java_enum_field.h deleted file mode 100644 index 90fae6394..000000000 --- a/modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/java/java_enum_field.h +++ /dev/null @@ -1,123 +0,0 @@ -// Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// http://code.google.com/p/protobuf/ -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -// Author: kenton@google.com (Kenton Varda) -// Based on original Protocol Buffers design by -// Sanjay Ghemawat, Jeff Dean, and others. - -#ifndef GOOGLE_PROTOBUF_COMPILER_JAVA_ENUM_FIELD_H__ -#define GOOGLE_PROTOBUF_COMPILER_JAVA_ENUM_FIELD_H__ - -#include -#include -#include - -namespace google { -namespace protobuf { -namespace compiler { -namespace java { - -class EnumFieldGenerator : public FieldGenerator { - public: - explicit EnumFieldGenerator(const FieldDescriptor* descriptor, - int messageBitIndex, int builderBitIndex); - ~EnumFieldGenerator(); - - // implements FieldGenerator --------------------------------------- - int GetNumBitsForMessage() const; - int GetNumBitsForBuilder() const; - void GenerateInterfaceMembers(io::Printer* printer) const; - void GenerateMembers(io::Printer* printer) const; - void GenerateBuilderMembers(io::Printer* printer) const; - void GenerateInitializationCode(io::Printer* printer) const; - void GenerateBuilderClearCode(io::Printer* printer) const; - void GenerateMergingCode(io::Printer* printer) const; - void GenerateBuildingCode(io::Printer* printer) const; - void GenerateParsingCode(io::Printer* printer) const; - void GenerateParsingDoneCode(io::Printer* printer) const; - void GenerateSerializationCode(io::Printer* printer) const; - void GenerateSerializedSizeCode(io::Printer* printer) const; - void GenerateFieldBuilderInitializationCode(io::Printer* printer) const; - void GenerateEqualsCode(io::Printer* printer) const; - void GenerateHashCode(io::Printer* printer) const; - - string GetBoxedType() const; - - private: - const FieldDescriptor* descriptor_; - map variables_; - const int messageBitIndex_; - const int builderBitIndex_; - - GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(EnumFieldGenerator); -}; - -class RepeatedEnumFieldGenerator : public FieldGenerator { - public: - explicit RepeatedEnumFieldGenerator(const FieldDescriptor* descriptor, - int messageBitIndex, int builderBitIndex); - ~RepeatedEnumFieldGenerator(); - - // implements FieldGenerator --------------------------------------- - int GetNumBitsForMessage() const; - int GetNumBitsForBuilder() const; - void GenerateInterfaceMembers(io::Printer* printer) const; - void GenerateMembers(io::Printer* printer) const; - void GenerateBuilderMembers(io::Printer* printer) const; - void GenerateInitializationCode(io::Printer* printer) const; - void GenerateBuilderClearCode(io::Printer* printer) const; - void GenerateMergingCode(io::Printer* printer) const; - void GenerateBuildingCode(io::Printer* printer) const; - void GenerateParsingCode(io::Printer* printer) const; - void GenerateParsingCodeFromPacked(io::Printer* printer) const; - void GenerateParsingDoneCode(io::Printer* printer) const; - void GenerateSerializationCode(io::Printer* printer) const; - void GenerateSerializedSizeCode(io::Printer* printer) const; - void GenerateFieldBuilderInitializationCode(io::Printer* printer) const; - void GenerateEqualsCode(io::Printer* printer) const; - void GenerateHashCode(io::Printer* printer) const; - - string GetBoxedType() const; - - private: - const FieldDescriptor* descriptor_; - map variables_; - const int messageBitIndex_; - const int builderBitIndex_; - - GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(RepeatedEnumFieldGenerator); -}; - -} // namespace java -} // namespace compiler -} // namespace protobuf - -} // namespace google -#endif // GOOGLE_PROTOBUF_COMPILER_JAVA_ENUM_FIELD_H__ diff --git a/modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/java/java_extension.cc b/modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/java/java_extension.cc deleted file mode 100644 index 921fe6589..000000000 --- a/modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/java/java_extension.cc +++ /dev/null @@ -1,218 +0,0 @@ -// Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// http://code.google.com/p/protobuf/ -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -// Author: kenton@google.com (Kenton Varda) -// Based on original Protocol Buffers design by -// Sanjay Ghemawat, Jeff Dean, and others. - -#include -#include -#include -#include -#include - -namespace google { -namespace protobuf { -namespace compiler { -namespace java { - -namespace { - -const char* TypeName(FieldDescriptor::Type field_type) { - switch (field_type) { - case FieldDescriptor::TYPE_INT32 : return "INT32"; - case FieldDescriptor::TYPE_UINT32 : return "UINT32"; - case FieldDescriptor::TYPE_SINT32 : return "SINT32"; - case FieldDescriptor::TYPE_FIXED32 : return "FIXED32"; - case FieldDescriptor::TYPE_SFIXED32: return "SFIXED32"; - case FieldDescriptor::TYPE_INT64 : return "INT64"; - case FieldDescriptor::TYPE_UINT64 : return "UINT64"; - case FieldDescriptor::TYPE_SINT64 : return "SINT64"; - case FieldDescriptor::TYPE_FIXED64 : return "FIXED64"; - case FieldDescriptor::TYPE_SFIXED64: return "SFIXED64"; - case FieldDescriptor::TYPE_FLOAT : return "FLOAT"; - case FieldDescriptor::TYPE_DOUBLE : return "DOUBLE"; - case FieldDescriptor::TYPE_BOOL : return "BOOL"; - case FieldDescriptor::TYPE_STRING : return "STRING"; - case FieldDescriptor::TYPE_BYTES : return "BYTES"; - case FieldDescriptor::TYPE_ENUM : return "ENUM"; - case FieldDescriptor::TYPE_GROUP : return "GROUP"; - case FieldDescriptor::TYPE_MESSAGE : return "MESSAGE"; - - // No default because we want the compiler to complain if any new - // types are added. - } - - GOOGLE_LOG(FATAL) << "Can't get here."; - return NULL; -} - -} - -ExtensionGenerator::ExtensionGenerator(const FieldDescriptor* descriptor) - : descriptor_(descriptor) { - if (descriptor_->extension_scope() != NULL) { - scope_ = ClassName(descriptor_->extension_scope()); - } else { - scope_ = ClassName(descriptor_->file()); - } -} - -ExtensionGenerator::~ExtensionGenerator() {} - -// Initializes the vars referenced in the generated code templates. -void InitTemplateVars(const FieldDescriptor* descriptor, - const string& scope, - map* vars_pointer) { - map &vars = *vars_pointer; - vars["scope"] = scope; - vars["name"] = UnderscoresToCamelCase(descriptor); - vars["containing_type"] = ClassName(descriptor->containing_type()); - vars["number"] = SimpleItoa(descriptor->number()); - vars["constant_name"] = FieldConstantName(descriptor); - vars["index"] = SimpleItoa(descriptor->index()); - vars["default"] = - descriptor->is_repeated() ? "" : DefaultValue(descriptor); - vars["type_constant"] = TypeName(GetType(descriptor)); - vars["packed"] = descriptor->options().packed() ? "true" : "false"; - vars["enum_map"] = "null"; - vars["prototype"] = "null"; - - JavaType java_type = GetJavaType(descriptor); - string singular_type; - switch (java_type) { - case JAVATYPE_MESSAGE: - singular_type = ClassName(descriptor->message_type()); - vars["prototype"] = singular_type + ".getDefaultInstance()"; - break; - case JAVATYPE_ENUM: - singular_type = ClassName(descriptor->enum_type()); - vars["enum_map"] = singular_type + ".internalGetValueMap()"; - break; - default: - singular_type = BoxedPrimitiveTypeName(java_type); - break; - } - vars["type"] = descriptor->is_repeated() ? - "java.util.List<" + singular_type + ">" : singular_type; - vars["singular_type"] = singular_type; -} - -void ExtensionGenerator::Generate(io::Printer* printer) { - map vars; - InitTemplateVars(descriptor_, scope_, &vars); - printer->Print(vars, - "public static final int $constant_name$ = $number$;\n"); - - WriteFieldDocComment(printer, descriptor_); - if (HasDescriptorMethods(descriptor_->file())) { - // Non-lite extensions - if (descriptor_->extension_scope() == NULL) { - // Non-nested - printer->Print( - vars, - "public static final\n" - " com.google.protobuf.GeneratedMessage.GeneratedExtension<\n" - " $containing_type$,\n" - " $type$> $name$ = com.google.protobuf.GeneratedMessage\n" - " .newFileScopedGeneratedExtension(\n" - " $singular_type$.class,\n" - " $prototype$);\n"); - } else { - // Nested - printer->Print( - vars, - "public static final\n" - " com.google.protobuf.GeneratedMessage.GeneratedExtension<\n" - " $containing_type$,\n" - " $type$> $name$ = com.google.protobuf.GeneratedMessage\n" - " .newMessageScopedGeneratedExtension(\n" - " $scope$.getDefaultInstance(),\n" - " $index$,\n" - " $singular_type$.class,\n" - " $prototype$);\n"); - } - } else { - // Lite extensions - if (descriptor_->is_repeated()) { - printer->Print( - vars, - "public static final\n" - " com.google.protobuf.GeneratedMessageLite.GeneratedExtension<\n" - " $containing_type$,\n" - " $type$> $name$ = com.google.protobuf.GeneratedMessageLite\n" - " .newRepeatedGeneratedExtension(\n" - " $containing_type$.getDefaultInstance(),\n" - " $prototype$,\n" - " $enum_map$,\n" - " $number$,\n" - " com.google.protobuf.WireFormat.FieldType.$type_constant$,\n" - " $packed$);\n"); - } else { - printer->Print( - vars, - "public static final\n" - " com.google.protobuf.GeneratedMessageLite.GeneratedExtension<\n" - " $containing_type$,\n" - " $type$> $name$ = com.google.protobuf.GeneratedMessageLite\n" - " .newSingularGeneratedExtension(\n" - " $containing_type$.getDefaultInstance(),\n" - " $default$,\n" - " $prototype$,\n" - " $enum_map$,\n" - " $number$,\n" - " com.google.protobuf.WireFormat.FieldType.$type_constant$);\n"); - } - } -} - -void ExtensionGenerator::GenerateNonNestedInitializationCode( - io::Printer* printer) { - if (descriptor_->extension_scope() == NULL && - HasDescriptorMethods(descriptor_->file())) { - // Only applies to non-nested, non-lite extensions. - printer->Print( - "$name$.internalInit(descriptor.getExtensions().get($index$));\n", - "name", UnderscoresToCamelCase(descriptor_), - "index", SimpleItoa(descriptor_->index())); - } -} - -void ExtensionGenerator::GenerateRegistrationCode(io::Printer* printer) { - printer->Print( - "registry.add($scope$.$name$);\n", - "scope", scope_, - "name", UnderscoresToCamelCase(descriptor_)); -} - -} // namespace java -} // namespace compiler -} // namespace protobuf -} // namespace google diff --git a/modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/java/java_extension.h b/modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/java/java_extension.h deleted file mode 100644 index 009ed9ffa..000000000 --- a/modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/java/java_extension.h +++ /dev/null @@ -1,77 +0,0 @@ -// Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// http://code.google.com/p/protobuf/ -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -// Author: kenton@google.com (Kenton Varda) -// Based on original Protocol Buffers design by -// Sanjay Ghemawat, Jeff Dean, and others. - -#ifndef GOOGLE_PROTOBUF_COMPILER_JAVA_EXTENSION_H__ -#define GOOGLE_PROTOBUF_COMPILER_JAVA_EXTENSION_H__ - -#include - -#include - -namespace google { -namespace protobuf { - class FieldDescriptor; // descriptor.h - namespace io { - class Printer; // printer.h - } -} - -namespace protobuf { -namespace compiler { -namespace java { - -// Generates code for an extension, which may be within the scope of some -// message or may be at file scope. This is much simpler than FieldGenerator -// since extensions are just simple identifiers with interesting types. -class ExtensionGenerator { - public: - explicit ExtensionGenerator(const FieldDescriptor* descriptor); - ~ExtensionGenerator(); - - void Generate(io::Printer* printer); - void GenerateNonNestedInitializationCode(io::Printer* printer); - void GenerateRegistrationCode(io::Printer* printer); - - private: - const FieldDescriptor* descriptor_; - string scope_; - GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ExtensionGenerator); -}; - -} // namespace java -} // namespace compiler -} // namespace protobuf - -} // namespace google -#endif // GOOGLE_PROTOBUF_COMPILER_JAVA_MESSAGE_H__ diff --git a/modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/java/java_field.cc b/modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/java/java_field.cc deleted file mode 100644 index c7d433c8e..000000000 --- a/modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/java/java_field.cc +++ /dev/null @@ -1,137 +0,0 @@ -// Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// http://code.google.com/p/protobuf/ -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -// Author: kenton@google.com (Kenton Varda) -// Based on original Protocol Buffers design by -// Sanjay Ghemawat, Jeff Dean, and others. - -#include -#include -#include -#include -#include -#include -#include - -namespace google { -namespace protobuf { -namespace compiler { -namespace java { - -FieldGenerator::~FieldGenerator() {} - -void FieldGenerator::GenerateParsingCodeFromPacked(io::Printer* printer) const { - // Reaching here indicates a bug. Cases are: - // - This FieldGenerator should support packing, but this method should be - // overridden. - // - This FieldGenerator doesn't support packing, and this method should - // never have been called. - GOOGLE_LOG(FATAL) << "GenerateParsingCodeFromPacked() " - << "called on field generator that does not support packing."; -} - -FieldGeneratorMap::FieldGeneratorMap(const Descriptor* descriptor) - : descriptor_(descriptor), - field_generators_( - new scoped_ptr[descriptor->field_count()]), - extension_generators_( - new scoped_ptr[descriptor->extension_count()]) { - - // Construct all the FieldGenerators and assign them bit indices for their - // bit fields. - int messageBitIndex = 0; - int builderBitIndex = 0; - for (int i = 0; i < descriptor->field_count(); i++) { - FieldGenerator* generator = MakeGenerator(descriptor->field(i), - messageBitIndex, builderBitIndex); - field_generators_[i].reset(generator); - messageBitIndex += generator->GetNumBitsForMessage(); - builderBitIndex += generator->GetNumBitsForBuilder(); - } - for (int i = 0; i < descriptor->extension_count(); i++) { - FieldGenerator* generator = MakeGenerator(descriptor->extension(i), - messageBitIndex, builderBitIndex); - extension_generators_[i].reset(generator); - messageBitIndex += generator->GetNumBitsForMessage(); - builderBitIndex += generator->GetNumBitsForBuilder(); - } -} - -FieldGenerator* FieldGeneratorMap::MakeGenerator( - const FieldDescriptor* field, int messageBitIndex, int builderBitIndex) { - if (field->is_repeated()) { - switch (GetJavaType(field)) { - case JAVATYPE_MESSAGE: - return new RepeatedMessageFieldGenerator( - field, messageBitIndex, builderBitIndex); - case JAVATYPE_ENUM: - return new RepeatedEnumFieldGenerator( - field, messageBitIndex, builderBitIndex); - case JAVATYPE_STRING: - return new RepeatedStringFieldGenerator( - field, messageBitIndex, builderBitIndex); - default: - return new RepeatedPrimitiveFieldGenerator( - field, messageBitIndex, builderBitIndex); - } - } else { - switch (GetJavaType(field)) { - case JAVATYPE_MESSAGE: - return new MessageFieldGenerator( - field, messageBitIndex, builderBitIndex); - case JAVATYPE_ENUM: - return new EnumFieldGenerator( - field, messageBitIndex, builderBitIndex); - case JAVATYPE_STRING: - return new StringFieldGenerator( - field, messageBitIndex, builderBitIndex); - default: - return new PrimitiveFieldGenerator( - field, messageBitIndex, builderBitIndex); - } - } -} - -FieldGeneratorMap::~FieldGeneratorMap() {} - -const FieldGenerator& FieldGeneratorMap::get( - const FieldDescriptor* field) const { - GOOGLE_CHECK_EQ(field->containing_type(), descriptor_); - return *field_generators_[field->index()]; -} - -const FieldGenerator& FieldGeneratorMap::get_extension(int index) const { - return *extension_generators_[index]; -} - -} // namespace java -} // namespace compiler -} // namespace protobuf -} // namespace google diff --git a/modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/java/java_field.h b/modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/java/java_field.h deleted file mode 100644 index 4dd0efd60..000000000 --- a/modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/java/java_field.h +++ /dev/null @@ -1,109 +0,0 @@ -// Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// http://code.google.com/p/protobuf/ -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -// Author: kenton@google.com (Kenton Varda) -// Based on original Protocol Buffers design by -// Sanjay Ghemawat, Jeff Dean, and others. - -#ifndef GOOGLE_PROTOBUF_COMPILER_JAVA_FIELD_H__ -#define GOOGLE_PROTOBUF_COMPILER_JAVA_FIELD_H__ - -#include -#include -#include - -namespace google { -namespace protobuf { - namespace io { - class Printer; // printer.h - } -} - -namespace protobuf { -namespace compiler { -namespace java { - -class FieldGenerator { - public: - FieldGenerator() {} - virtual ~FieldGenerator(); - - virtual int GetNumBitsForMessage() const = 0; - virtual int GetNumBitsForBuilder() const = 0; - virtual void GenerateInterfaceMembers(io::Printer* printer) const = 0; - virtual void GenerateMembers(io::Printer* printer) const = 0; - virtual void GenerateBuilderMembers(io::Printer* printer) const = 0; - virtual void GenerateInitializationCode(io::Printer* printer) const = 0; - virtual void GenerateBuilderClearCode(io::Printer* printer) const = 0; - virtual void GenerateMergingCode(io::Printer* printer) const = 0; - virtual void GenerateBuildingCode(io::Printer* printer) const = 0; - virtual void GenerateParsingCode(io::Printer* printer) const = 0; - virtual void GenerateParsingCodeFromPacked(io::Printer* printer) const; - virtual void GenerateParsingDoneCode(io::Printer* printer) const = 0; - virtual void GenerateSerializationCode(io::Printer* printer) const = 0; - virtual void GenerateSerializedSizeCode(io::Printer* printer) const = 0; - virtual void GenerateFieldBuilderInitializationCode(io::Printer* printer) - const = 0; - - virtual void GenerateEqualsCode(io::Printer* printer) const = 0; - virtual void GenerateHashCode(io::Printer* printer) const = 0; - - virtual string GetBoxedType() const = 0; - - private: - GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(FieldGenerator); -}; - -// Convenience class which constructs FieldGenerators for a Descriptor. -class FieldGeneratorMap { - public: - explicit FieldGeneratorMap(const Descriptor* descriptor); - ~FieldGeneratorMap(); - - const FieldGenerator& get(const FieldDescriptor* field) const; - const FieldGenerator& get_extension(int index) const; - - private: - const Descriptor* descriptor_; - scoped_array > field_generators_; - scoped_array > extension_generators_; - - static FieldGenerator* MakeGenerator(const FieldDescriptor* field, - int messageBitIndex, int builderBitIndex); - - GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(FieldGeneratorMap); -}; - -} // namespace java -} // namespace compiler -} // namespace protobuf - -} // namespace google -#endif // GOOGLE_PROTOBUF_COMPILER_JAVA_FIELD_H__ diff --git a/modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/java/java_file.cc b/modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/java/java_file.cc deleted file mode 100644 index f43e55001..000000000 --- a/modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/java/java_file.cc +++ /dev/null @@ -1,490 +0,0 @@ -// Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// http://code.google.com/p/protobuf/ -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -// Author: kenton@google.com (Kenton Varda) -// Based on original Protocol Buffers design by -// Sanjay Ghemawat, Jeff Dean, and others. - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -namespace google { -namespace protobuf { -namespace compiler { -namespace java { - -namespace { - - -// Recursively searches the given message to collect extensions. -// Returns true if all the extensions can be recognized. The extensions will be -// appended in to the extensions parameter. -// Returns false when there are unknown fields, in which case the data in the -// extensions output parameter is not reliable and should be discarded. -bool CollectExtensions(const Message& message, - vector* extensions) { - const Reflection* reflection = message.GetReflection(); - - // There are unknown fields that could be extensions, thus this call fails. - if (reflection->GetUnknownFields(message).field_count() > 0) return false; - - vector fields; - reflection->ListFields(message, &fields); - - for (int i = 0; i < fields.size(); i++) { - if (fields[i]->is_extension()) extensions->push_back(fields[i]); - - if (GetJavaType(fields[i]) == JAVATYPE_MESSAGE) { - if (fields[i]->is_repeated()) { - int size = reflection->FieldSize(message, fields[i]); - for (int j = 0; j < size; j++) { - const Message& sub_message = - reflection->GetRepeatedMessage(message, fields[i], j); - if (!CollectExtensions(sub_message, extensions)) return false; - } - } else { - const Message& sub_message = reflection->GetMessage(message, fields[i]); - if (!CollectExtensions(sub_message, extensions)) return false; - } - } - } - - return true; -} - -// Finds all extensions in the given message and its sub-messages. If the -// message contains unknown fields (which could be extensions), then those -// extensions are defined in alternate_pool. -// The message will be converted to a DynamicMessage backed by alternate_pool -// in order to handle this case. -void CollectExtensions(const FileDescriptorProto& file_proto, - const DescriptorPool& alternate_pool, - vector* extensions, - const string& file_data) { - if (!CollectExtensions(file_proto, extensions)) { - // There are unknown fields in the file_proto, which are probably - // extensions. We need to parse the data into a dynamic message based on the - // builder-pool to find out all extensions. - const Descriptor* file_proto_desc = alternate_pool.FindMessageTypeByName( - file_proto.GetDescriptor()->full_name()); - GOOGLE_CHECK(file_proto_desc) - << "Find unknown fields in FileDescriptorProto when building " - << file_proto.name() - << ". It's likely that those fields are custom options, however, " - "descriptor.proto is not in the transitive dependencies. " - "This normally should not happen. Please report a bug."; - DynamicMessageFactory factory; - scoped_ptr dynamic_file_proto( - factory.GetPrototype(file_proto_desc)->New()); - GOOGLE_CHECK(dynamic_file_proto.get() != NULL); - GOOGLE_CHECK(dynamic_file_proto->ParseFromString(file_data)); - - // Collect the extensions again from the dynamic message. There should be no - // more unknown fields this time, i.e. all the custom options should be - // parsed as extensions now. - extensions->clear(); - GOOGLE_CHECK(CollectExtensions(*dynamic_file_proto, extensions)) - << "Find unknown fields in FileDescriptorProto when building " - << file_proto.name() - << ". It's likely that those fields are custom options, however, " - "those options cannot be recognized in the builder pool. " - "This normally should not happen. Please report a bug."; - } -} - - -} // namespace - -FileGenerator::FileGenerator(const FileDescriptor* file) - : file_(file), - java_package_(FileJavaPackage(file)), - classname_(FileClassName(file)) { -} - -FileGenerator::~FileGenerator() {} - -bool FileGenerator::Validate(string* error) { - // Check that no class name matches the file's class name. This is a common - // problem that leads to Java compile errors that can be hard to understand. - // It's especially bad when using the java_multiple_files, since we would - // end up overwriting the outer class with one of the inner ones. - - bool found_conflict = false; - for (int i = 0; i < file_->enum_type_count() && !found_conflict; i++) { - if (file_->enum_type(i)->name() == classname_) { - found_conflict = true; - } - } - for (int i = 0; i < file_->message_type_count() && !found_conflict; i++) { - if (file_->message_type(i)->name() == classname_) { - found_conflict = true; - } - } - for (int i = 0; i < file_->service_count() && !found_conflict; i++) { - if (file_->service(i)->name() == classname_) { - found_conflict = true; - } - } - - if (found_conflict) { - error->assign(file_->name()); - error->append( - ": Cannot generate Java output because the file's outer class name, \""); - error->append(classname_); - error->append( - "\", matches the name of one of the types declared inside it. " - "Please either rename the type or use the java_outer_classname " - "option to specify a different outer class name for the .proto file."); - return false; - } - - return true; -} - -void FileGenerator::Generate(io::Printer* printer) { - // We don't import anything because we refer to all classes by their - // fully-qualified names in the generated source. - printer->Print( - "// Generated by the protocol buffer compiler. DO NOT EDIT!\n" - "// source: $filename$\n" - "\n", - "filename", file_->name()); - if (!java_package_.empty()) { - printer->Print( - "package $package$;\n" - "\n", - "package", java_package_); - } - printer->Print( - "public final class $classname$ {\n" - " private $classname$() {}\n", - "classname", classname_); - printer->Indent(); - - // ----------------------------------------------------------------- - - printer->Print( - "public static void registerAllExtensions(\n" - " com.google.protobuf.ExtensionRegistry$lite$ registry) {\n", - "lite", HasDescriptorMethods(file_) ? "" : "Lite"); - - printer->Indent(); - - for (int i = 0; i < file_->extension_count(); i++) { - ExtensionGenerator(file_->extension(i)).GenerateRegistrationCode(printer); - } - - for (int i = 0; i < file_->message_type_count(); i++) { - MessageGenerator(file_->message_type(i)) - .GenerateExtensionRegistrationCode(printer); - } - - printer->Outdent(); - printer->Print( - "}\n"); - - // ----------------------------------------------------------------- - - if (!file_->options().java_multiple_files()) { - for (int i = 0; i < file_->enum_type_count(); i++) { - EnumGenerator(file_->enum_type(i)).Generate(printer); - } - for (int i = 0; i < file_->message_type_count(); i++) { - MessageGenerator messageGenerator(file_->message_type(i)); - messageGenerator.GenerateInterface(printer); - messageGenerator.Generate(printer); - } - if (HasGenericServices(file_)) { - for (int i = 0; i < file_->service_count(); i++) { - ServiceGenerator(file_->service(i)).Generate(printer); - } - } - } - - // Extensions must be generated in the outer class since they are values, - // not classes. - for (int i = 0; i < file_->extension_count(); i++) { - ExtensionGenerator(file_->extension(i)).Generate(printer); - } - - // Static variables. - for (int i = 0; i < file_->message_type_count(); i++) { - // TODO(kenton): Reuse MessageGenerator objects? - MessageGenerator(file_->message_type(i)).GenerateStaticVariables(printer); - } - - printer->Print("\n"); - - if (HasDescriptorMethods(file_)) { - GenerateEmbeddedDescriptor(printer); - } else { - printer->Print( - "static {\n"); - printer->Indent(); - - for (int i = 0; i < file_->message_type_count(); i++) { - // TODO(kenton): Reuse MessageGenerator objects? - MessageGenerator(file_->message_type(i)) - .GenerateStaticVariableInitializers(printer); - } - - printer->Outdent(); - printer->Print( - "}\n"); - } - - printer->Print( - "\n" - "// @@protoc_insertion_point(outer_class_scope)\n"); - - printer->Outdent(); - printer->Print("}\n"); -} - -void FileGenerator::GenerateEmbeddedDescriptor(io::Printer* printer) { - // Embed the descriptor. We simply serialize the entire FileDescriptorProto - // and embed it as a string literal, which is parsed and built into real - // descriptors at initialization time. We unfortunately have to put it in - // a string literal, not a byte array, because apparently using a literal - // byte array causes the Java compiler to generate *instructions* to - // initialize each and every byte of the array, e.g. as if you typed: - // b[0] = 123; b[1] = 456; b[2] = 789; - // This makes huge bytecode files and can easily hit the compiler's internal - // code size limits (error "code to large"). String literals are apparently - // embedded raw, which is what we want. - FileDescriptorProto file_proto; - file_->CopyTo(&file_proto); - - string file_data; - file_proto.SerializeToString(&file_data); - - printer->Print( - "public static com.google.protobuf.Descriptors.FileDescriptor\n" - " getDescriptor() {\n" - " return descriptor;\n" - "}\n" - "private static com.google.protobuf.Descriptors.FileDescriptor\n" - " descriptor;\n" - "static {\n" - " java.lang.String[] descriptorData = {\n"); - printer->Indent(); - printer->Indent(); - - // Only write 40 bytes per line. - static const int kBytesPerLine = 40; - for (int i = 0; i < file_data.size(); i += kBytesPerLine) { - if (i > 0) { - // Every 400 lines, start a new string literal, in order to avoid the - // 64k length limit. - if (i % 400 == 0) { - printer->Print(",\n"); - } else { - printer->Print(" +\n"); - } - } - printer->Print("\"$data$\"", - "data", CEscape(file_data.substr(i, kBytesPerLine))); - } - - printer->Outdent(); - printer->Print("\n};\n"); - - // ----------------------------------------------------------------- - // Create the InternalDescriptorAssigner. - - printer->Print( - "com.google.protobuf.Descriptors.FileDescriptor." - "InternalDescriptorAssigner assigner =\n" - " new com.google.protobuf.Descriptors.FileDescriptor." - "InternalDescriptorAssigner() {\n" - " public com.google.protobuf.ExtensionRegistry assignDescriptors(\n" - " com.google.protobuf.Descriptors.FileDescriptor root) {\n" - " descriptor = root;\n"); - - printer->Indent(); - printer->Indent(); - printer->Indent(); - - for (int i = 0; i < file_->message_type_count(); i++) { - // TODO(kenton): Reuse MessageGenerator objects? - MessageGenerator(file_->message_type(i)) - .GenerateStaticVariableInitializers(printer); - } - for (int i = 0; i < file_->extension_count(); i++) { - // TODO(kenton): Reuse ExtensionGenerator objects? - ExtensionGenerator(file_->extension(i)) - .GenerateNonNestedInitializationCode(printer); - } - - // Proto compiler builds a DescriptorPool, which holds all the descriptors to - // generate, when processing the ".proto" files. We call this DescriptorPool - // the parsed pool (a.k.a. file_->pool()). - // - // Note that when users try to extend the (.*)DescriptorProto in their - // ".proto" files, it does not affect the pre-built FileDescriptorProto class - // in proto compiler. When we put the descriptor data in the file_proto, those - // extensions become unknown fields. - // - // Now we need to find out all the extension value to the (.*)DescriptorProto - // in the file_proto message, and prepare an ExtensionRegistry to return. - // - // To find those extensions, we need to parse the data into a dynamic message - // of the FileDescriptor based on the builder-pool, then we can use - // reflections to find all extension fields - vector extensions; - CollectExtensions(file_proto, *file_->pool(), &extensions, file_data); - - if (extensions.size() > 0) { - // Must construct an ExtensionRegistry containing all existing extensions - // and return it. - printer->Print( - "com.google.protobuf.ExtensionRegistry registry =\n" - " com.google.protobuf.ExtensionRegistry.newInstance();\n"); - for (int i = 0; i < extensions.size(); i++) { - ExtensionGenerator(extensions[i]).GenerateRegistrationCode(printer); - } - printer->Print( - "return registry;\n"); - } else { - printer->Print( - "return null;\n"); - } - - printer->Outdent(); - printer->Outdent(); - printer->Outdent(); - - printer->Print( - " }\n" - " };\n"); - - // ----------------------------------------------------------------- - // Invoke internalBuildGeneratedFileFrom() to build the file. - - printer->Print( - "com.google.protobuf.Descriptors.FileDescriptor\n" - " .internalBuildGeneratedFileFrom(descriptorData,\n" - " new com.google.protobuf.Descriptors.FileDescriptor[] {\n"); - - for (int i = 0; i < file_->dependency_count(); i++) { - if (ShouldIncludeDependency(file_->dependency(i))) { - printer->Print( - " $dependency$.getDescriptor(),\n", - "dependency", ClassName(file_->dependency(i))); - } - } - - printer->Print( - " }, assigner);\n"); - - printer->Outdent(); - printer->Print( - "}\n"); -} - -template -static void GenerateSibling(const string& package_dir, - const string& java_package, - const DescriptorClass* descriptor, - GeneratorContext* context, - vector* file_list, - const string& name_suffix, - void (GeneratorClass::*pfn)(io::Printer* printer)) { - string filename = package_dir + descriptor->name() + name_suffix + ".java"; - file_list->push_back(filename); - - scoped_ptr output(context->Open(filename)); - io::Printer printer(output.get(), '$'); - - printer.Print( - "// Generated by the protocol buffer compiler. DO NOT EDIT!\n" - "// source: $filename$\n" - "\n", - "filename", descriptor->file()->name()); - if (!java_package.empty()) { - printer.Print( - "package $package$;\n" - "\n", - "package", java_package); - } - - GeneratorClass generator(descriptor); - (generator.*pfn)(&printer); -} - -void FileGenerator::GenerateSiblings(const string& package_dir, - GeneratorContext* context, - vector* file_list) { - if (file_->options().java_multiple_files()) { - for (int i = 0; i < file_->enum_type_count(); i++) { - GenerateSibling(package_dir, java_package_, - file_->enum_type(i), - context, file_list, "", - &EnumGenerator::Generate); - } - for (int i = 0; i < file_->message_type_count(); i++) { - GenerateSibling(package_dir, java_package_, - file_->message_type(i), - context, file_list, "OrBuilder", - &MessageGenerator::GenerateInterface); - GenerateSibling(package_dir, java_package_, - file_->message_type(i), - context, file_list, "", - &MessageGenerator::Generate); - } - if (HasGenericServices(file_)) { - for (int i = 0; i < file_->service_count(); i++) { - GenerateSibling(package_dir, java_package_, - file_->service(i), - context, file_list, "", - &ServiceGenerator::Generate); - } - } - } -} - -bool FileGenerator::ShouldIncludeDependency(const FileDescriptor* descriptor) { - return true; -} - -} // namespace java -} // namespace compiler -} // namespace protobuf -} // namespace google diff --git a/modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/java/java_file.h b/modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/java/java_file.h deleted file mode 100644 index 599114626..000000000 --- a/modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/java/java_file.h +++ /dev/null @@ -1,101 +0,0 @@ -// Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// http://code.google.com/p/protobuf/ -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -// Author: kenton@google.com (Kenton Varda) -// Based on original Protocol Buffers design by -// Sanjay Ghemawat, Jeff Dean, and others. - -#ifndef GOOGLE_PROTOBUF_COMPILER_JAVA_FILE_H__ -#define GOOGLE_PROTOBUF_COMPILER_JAVA_FILE_H__ - -#include -#include -#include - -namespace google { -namespace protobuf { - class FileDescriptor; // descriptor.h - namespace io { - class Printer; // printer.h - } - namespace compiler { - class GeneratorContext; // code_generator.h - } -} - -namespace protobuf { -namespace compiler { -namespace java { - -class FileGenerator { - public: - explicit FileGenerator(const FileDescriptor* file); - ~FileGenerator(); - - // Checks for problems that would otherwise lead to cryptic compile errors. - // Returns true if there are no problems, or writes an error description to - // the given string and returns false otherwise. - bool Validate(string* error); - - void Generate(io::Printer* printer); - - // If we aren't putting everything into one file, this will write all the - // files other than the outer file (i.e. one for each message, enum, and - // service type). - void GenerateSiblings(const string& package_dir, - GeneratorContext* generator_context, - vector* file_list); - - const string& java_package() { return java_package_; } - const string& classname() { return classname_; } - - - private: - // Returns whether the dependency should be included in the output file. - // Always returns true for opensource, but used internally at Google to help - // improve compatibility with version 1 of protocol buffers. - bool ShouldIncludeDependency(const FileDescriptor* descriptor); - - const FileDescriptor* file_; - string java_package_; - string classname_; - - - void GenerateEmbeddedDescriptor(io::Printer* printer); - - GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(FileGenerator); -}; - -} // namespace java -} // namespace compiler -} // namespace protobuf - -} // namespace google -#endif // GOOGLE_PROTOBUF_COMPILER_JAVA_FILE_H__ diff --git a/modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/java/java_generator.cc b/modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/java/java_generator.cc deleted file mode 100644 index e6c79abcd..000000000 --- a/modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/java/java_generator.cc +++ /dev/null @@ -1,128 +0,0 @@ -// Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// http://code.google.com/p/protobuf/ -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -// Author: kenton@google.com (Kenton Varda) -// Based on original Protocol Buffers design by -// Sanjay Ghemawat, Jeff Dean, and others. - -#include -#include -#include -#include -#include -#include -#include - -namespace google { -namespace protobuf { -namespace compiler { -namespace java { - - -JavaGenerator::JavaGenerator() {} -JavaGenerator::~JavaGenerator() {} - -bool JavaGenerator::Generate(const FileDescriptor* file, - const string& parameter, - GeneratorContext* context, - string* error) const { - // ----------------------------------------------------------------- - // parse generator options - - // Name a file where we will write a list of generated file names, one - // per line. - string output_list_file; - - - vector > options; - ParseGeneratorParameter(parameter, &options); - - for (int i = 0; i < options.size(); i++) { - if (options[i].first == "output_list_file") { - output_list_file = options[i].second; - } else { - *error = "Unknown generator option: " + options[i].first; - return false; - } - } - - // ----------------------------------------------------------------- - - - if (file->options().optimize_for() == FileOptions::LITE_RUNTIME && - file->options().java_generate_equals_and_hash()) { - *error = "The \"java_generate_equals_and_hash\" option is incompatible " - "with \"optimize_for = LITE_RUNTIME\". You must optimize for " - "SPEED or CODE_SIZE if you want to use this option."; - return false; - } - - FileGenerator file_generator(file); - if (!file_generator.Validate(error)) { - return false; - } - - string package_dir = JavaPackageToDir(file_generator.java_package()); - - vector all_files; - - string java_filename = package_dir; - java_filename += file_generator.classname(); - java_filename += ".java"; - all_files.push_back(java_filename); - - // Generate main java file. - scoped_ptr output( - context->Open(java_filename)); - io::Printer printer(output.get(), '$'); - file_generator.Generate(&printer); - - // Generate sibling files. - file_generator.GenerateSiblings(package_dir, context, &all_files); - - // Generate output list if requested. - if (!output_list_file.empty()) { - // Generate output list. This is just a simple text file placed in a - // deterministic location which lists the .java files being generated. - scoped_ptr srclist_raw_output( - context->Open(output_list_file)); - io::Printer srclist_printer(srclist_raw_output.get(), '$'); - for (int i = 0; i < all_files.size(); i++) { - srclist_printer.Print("$filename$\n", "filename", all_files[i]); - } - } - - return true; -} - -} // namespace java -} // namespace compiler -} // namespace protobuf -} // namespace google diff --git a/modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/java/java_generator.h b/modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/java/java_generator.h deleted file mode 100644 index 888b8d85e..000000000 --- a/modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/java/java_generator.h +++ /dev/null @@ -1,72 +0,0 @@ -// Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// http://code.google.com/p/protobuf/ -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -// Author: kenton@google.com (Kenton Varda) -// Based on original Protocol Buffers design by -// Sanjay Ghemawat, Jeff Dean, and others. -// -// Generates Java code for a given .proto file. - -#ifndef GOOGLE_PROTOBUF_COMPILER_JAVA_GENERATOR_H__ -#define GOOGLE_PROTOBUF_COMPILER_JAVA_GENERATOR_H__ - -#include -#include - -namespace google { -namespace protobuf { -namespace compiler { -namespace java { - -// CodeGenerator implementation which generates Java code. If you create your -// own protocol compiler binary and you want it to support Java output, you -// can do so by registering an instance of this CodeGenerator with the -// CommandLineInterface in your main() function. -class LIBPROTOC_EXPORT JavaGenerator : public CodeGenerator { - public: - JavaGenerator(); - ~JavaGenerator(); - - // implements CodeGenerator ---------------------------------------- - bool Generate(const FileDescriptor* file, - const string& parameter, - GeneratorContext* context, - string* error) const; - - private: - GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(JavaGenerator); -}; - -} // namespace java -} // namespace compiler -} // namespace protobuf - -} // namespace google -#endif // GOOGLE_PROTOBUF_COMPILER_JAVA_GENERATOR_H__ diff --git a/modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/java/java_helpers.cc b/modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/java/java_helpers.cc deleted file mode 100644 index cf241b8a5..000000000 --- a/modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/java/java_helpers.cc +++ /dev/null @@ -1,500 +0,0 @@ -// Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// http://code.google.com/p/protobuf/ -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -// Author: kenton@google.com (Kenton Varda) -// Based on original Protocol Buffers design by -// Sanjay Ghemawat, Jeff Dean, and others. - -#include -#include - -#include -#include -#include -#include - -namespace google { -namespace protobuf { -namespace compiler { -namespace java { - -const char kThickSeparator[] = - "// ===================================================================\n"; -const char kThinSeparator[] = - "// -------------------------------------------------------------------\n"; - -namespace { - -const char* kDefaultPackage = ""; - -const string& FieldName(const FieldDescriptor* field) { - // Groups are hacky: The name of the field is just the lower-cased name - // of the group type. In Java, though, we would like to retain the original - // capitalization of the type name. - if (GetType(field) == FieldDescriptor::TYPE_GROUP) { - return field->message_type()->name(); - } else { - return field->name(); - } -} - -string UnderscoresToCamelCaseImpl(const string& input, bool cap_next_letter) { - string result; - // Note: I distrust ctype.h due to locales. - for (int i = 0; i < input.size(); i++) { - if ('a' <= input[i] && input[i] <= 'z') { - if (cap_next_letter) { - result += input[i] + ('A' - 'a'); - } else { - result += input[i]; - } - cap_next_letter = false; - } else if ('A' <= input[i] && input[i] <= 'Z') { - if (i == 0 && !cap_next_letter) { - // Force first letter to lower-case unless explicitly told to - // capitalize it. - result += input[i] + ('a' - 'A'); - } else { - // Capital letters after the first are left as-is. - result += input[i]; - } - cap_next_letter = false; - } else if ('0' <= input[i] && input[i] <= '9') { - result += input[i]; - cap_next_letter = true; - } else { - cap_next_letter = true; - } - } - return result; -} - -} // namespace - -string UnderscoresToCamelCase(const FieldDescriptor* field) { - return UnderscoresToCamelCaseImpl(FieldName(field), false); -} - -string UnderscoresToCapitalizedCamelCase(const FieldDescriptor* field) { - return UnderscoresToCamelCaseImpl(FieldName(field), true); -} - -string UnderscoresToCamelCase(const MethodDescriptor* method) { - return UnderscoresToCamelCaseImpl(method->name(), false); -} - -string StripProto(const string& filename) { - if (HasSuffixString(filename, ".protodevel")) { - return StripSuffixString(filename, ".protodevel"); - } else { - return StripSuffixString(filename, ".proto"); - } -} - -string FileClassName(const FileDescriptor* file) { - if (file->options().has_java_outer_classname()) { - return file->options().java_outer_classname(); - } else { - string basename; - string::size_type last_slash = file->name().find_last_of('/'); - if (last_slash == string::npos) { - basename = file->name(); - } else { - basename = file->name().substr(last_slash + 1); - } - return UnderscoresToCamelCaseImpl(StripProto(basename), true); - } -} - -string FileJavaPackage(const FileDescriptor* file) { - string result; - - if (file->options().has_java_package()) { - result = file->options().java_package(); - } else { - result = kDefaultPackage; - if (!file->package().empty()) { - if (!result.empty()) result += '.'; - result += file->package(); - } - } - - - return result; -} - -string JavaPackageToDir(string package_name) { - string package_dir = - StringReplace(package_name, ".", "/", true); - if (!package_dir.empty()) package_dir += "/"; - return package_dir; -} - -string ToJavaName(const string& full_name, const FileDescriptor* file) { - string result; - if (file->options().java_multiple_files()) { - result = FileJavaPackage(file); - } else { - result = ClassName(file); - } - if (!result.empty()) { - result += '.'; - } - if (file->package().empty()) { - result += full_name; - } else { - // Strip the proto package from full_name since we've replaced it with - // the Java package. - result += full_name.substr(file->package().size() + 1); - } - return result; -} - -string ClassName(const Descriptor* descriptor) { - return ToJavaName(descriptor->full_name(), descriptor->file()); -} - -string ClassName(const EnumDescriptor* descriptor) { - return ToJavaName(descriptor->full_name(), descriptor->file()); -} - -string ClassName(const ServiceDescriptor* descriptor) { - return ToJavaName(descriptor->full_name(), descriptor->file()); -} - -string ClassName(const FileDescriptor* descriptor) { - string result = FileJavaPackage(descriptor); - if (!result.empty()) result += '.'; - result += FileClassName(descriptor); - return result; -} - -string FieldConstantName(const FieldDescriptor *field) { - string name = field->name() + "_FIELD_NUMBER"; - UpperString(&name); - return name; -} - -FieldDescriptor::Type GetType(const FieldDescriptor* field) { - return field->type(); -} - -JavaType GetJavaType(const FieldDescriptor* field) { - switch (GetType(field)) { - case FieldDescriptor::TYPE_INT32: - case FieldDescriptor::TYPE_UINT32: - case FieldDescriptor::TYPE_SINT32: - case FieldDescriptor::TYPE_FIXED32: - case FieldDescriptor::TYPE_SFIXED32: - return JAVATYPE_INT; - - case FieldDescriptor::TYPE_INT64: - case FieldDescriptor::TYPE_UINT64: - case FieldDescriptor::TYPE_SINT64: - case FieldDescriptor::TYPE_FIXED64: - case FieldDescriptor::TYPE_SFIXED64: - return JAVATYPE_LONG; - - case FieldDescriptor::TYPE_FLOAT: - return JAVATYPE_FLOAT; - - case FieldDescriptor::TYPE_DOUBLE: - return JAVATYPE_DOUBLE; - - case FieldDescriptor::TYPE_BOOL: - return JAVATYPE_BOOLEAN; - - case FieldDescriptor::TYPE_STRING: - return JAVATYPE_STRING; - - case FieldDescriptor::TYPE_BYTES: - return JAVATYPE_BYTES; - - case FieldDescriptor::TYPE_ENUM: - return JAVATYPE_ENUM; - - case FieldDescriptor::TYPE_GROUP: - case FieldDescriptor::TYPE_MESSAGE: - return JAVATYPE_MESSAGE; - - // No default because we want the compiler to complain if any new - // types are added. - } - - GOOGLE_LOG(FATAL) << "Can't get here."; - return JAVATYPE_INT; -} - -const char* BoxedPrimitiveTypeName(JavaType type) { - switch (type) { - case JAVATYPE_INT : return "java.lang.Integer"; - case JAVATYPE_LONG : return "java.lang.Long"; - case JAVATYPE_FLOAT : return "java.lang.Float"; - case JAVATYPE_DOUBLE : return "java.lang.Double"; - case JAVATYPE_BOOLEAN: return "java.lang.Boolean"; - case JAVATYPE_STRING : return "java.lang.String"; - case JAVATYPE_BYTES : return "com.google.protobuf.ByteString"; - case JAVATYPE_ENUM : return NULL; - case JAVATYPE_MESSAGE: return NULL; - - // No default because we want the compiler to complain if any new - // JavaTypes are added. - } - - GOOGLE_LOG(FATAL) << "Can't get here."; - return NULL; -} - -bool AllAscii(const string& text) { - for (int i = 0; i < text.size(); i++) { - if ((text[i] & 0x80) != 0) { - return false; - } - } - return true; -} - -string DefaultValue(const FieldDescriptor* field) { - // Switch on CppType since we need to know which default_value_* method - // of FieldDescriptor to call. - switch (field->cpp_type()) { - case FieldDescriptor::CPPTYPE_INT32: - return SimpleItoa(field->default_value_int32()); - case FieldDescriptor::CPPTYPE_UINT32: - // Need to print as a signed int since Java has no unsigned. - return SimpleItoa(static_cast(field->default_value_uint32())); - case FieldDescriptor::CPPTYPE_INT64: - return SimpleItoa(field->default_value_int64()) + "L"; - case FieldDescriptor::CPPTYPE_UINT64: - return SimpleItoa(static_cast(field->default_value_uint64())) + - "L"; - case FieldDescriptor::CPPTYPE_DOUBLE: { - double value = field->default_value_double(); - if (value == numeric_limits::infinity()) { - return "Double.POSITIVE_INFINITY"; - } else if (value == -numeric_limits::infinity()) { - return "Double.NEGATIVE_INFINITY"; - } else if (value != value) { - return "Double.NaN"; - } else { - return SimpleDtoa(value) + "D"; - } - } - case FieldDescriptor::CPPTYPE_FLOAT: { - float value = field->default_value_float(); - if (value == numeric_limits::infinity()) { - return "Float.POSITIVE_INFINITY"; - } else if (value == -numeric_limits::infinity()) { - return "Float.NEGATIVE_INFINITY"; - } else if (value != value) { - return "Float.NaN"; - } else { - return SimpleFtoa(value) + "F"; - } - } - case FieldDescriptor::CPPTYPE_BOOL: - return field->default_value_bool() ? "true" : "false"; - case FieldDescriptor::CPPTYPE_STRING: - if (GetType(field) == FieldDescriptor::TYPE_BYTES) { - if (field->has_default_value()) { - // See comments in Internal.java for gory details. - return strings::Substitute( - "com.google.protobuf.Internal.bytesDefaultValue(\"$0\")", - CEscape(field->default_value_string())); - } else { - return "com.google.protobuf.ByteString.EMPTY"; - } - } else { - if (AllAscii(field->default_value_string())) { - // All chars are ASCII. In this case CEscape() works fine. - return "\"" + CEscape(field->default_value_string()) + "\""; - } else { - // See comments in Internal.java for gory details. - return strings::Substitute( - "com.google.protobuf.Internal.stringDefaultValue(\"$0\")", - CEscape(field->default_value_string())); - } - } - - case FieldDescriptor::CPPTYPE_ENUM: - return ClassName(field->enum_type()) + "." + - field->default_value_enum()->name(); - - case FieldDescriptor::CPPTYPE_MESSAGE: - return ClassName(field->message_type()) + ".getDefaultInstance()"; - - // No default because we want the compiler to complain if any new - // types are added. - } - - GOOGLE_LOG(FATAL) << "Can't get here."; - return ""; -} - -bool IsDefaultValueJavaDefault(const FieldDescriptor* field) { - // Switch on CppType since we need to know which default_value_* method - // of FieldDescriptor to call. - switch (field->cpp_type()) { - case FieldDescriptor::CPPTYPE_INT32: - return field->default_value_int32() == 0; - case FieldDescriptor::CPPTYPE_UINT32: - return field->default_value_uint32() == 0; - case FieldDescriptor::CPPTYPE_INT64: - return field->default_value_int64() == 0L; - case FieldDescriptor::CPPTYPE_UINT64: - return field->default_value_uint64() == 0L; - case FieldDescriptor::CPPTYPE_DOUBLE: - return field->default_value_double() == 0.0; - case FieldDescriptor::CPPTYPE_FLOAT: - return field->default_value_float() == 0.0; - case FieldDescriptor::CPPTYPE_BOOL: - return field->default_value_bool() == false; - - case FieldDescriptor::CPPTYPE_STRING: - case FieldDescriptor::CPPTYPE_ENUM: - case FieldDescriptor::CPPTYPE_MESSAGE: - return false; - - // No default because we want the compiler to complain if any new - // types are added. - } - - GOOGLE_LOG(FATAL) << "Can't get here."; - return false; -} - -const char* bit_masks[] = { - "0x00000001", - "0x00000002", - "0x00000004", - "0x00000008", - "0x00000010", - "0x00000020", - "0x00000040", - "0x00000080", - - "0x00000100", - "0x00000200", - "0x00000400", - "0x00000800", - "0x00001000", - "0x00002000", - "0x00004000", - "0x00008000", - - "0x00010000", - "0x00020000", - "0x00040000", - "0x00080000", - "0x00100000", - "0x00200000", - "0x00400000", - "0x00800000", - - "0x01000000", - "0x02000000", - "0x04000000", - "0x08000000", - "0x10000000", - "0x20000000", - "0x40000000", - "0x80000000", -}; - -string GetBitFieldName(int index) { - string varName = "bitField"; - varName += SimpleItoa(index); - varName += "_"; - return varName; -} - -string GetBitFieldNameForBit(int bitIndex) { - return GetBitFieldName(bitIndex / 32); -} - -namespace { - -string GenerateGetBitInternal(const string& prefix, int bitIndex) { - string varName = prefix + GetBitFieldNameForBit(bitIndex); - int bitInVarIndex = bitIndex % 32; - - string mask = bit_masks[bitInVarIndex]; - string result = "((" + varName + " & " + mask + ") == " + mask + ")"; - return result; -} - -string GenerateSetBitInternal(const string& prefix, int bitIndex) { - string varName = prefix + GetBitFieldNameForBit(bitIndex); - int bitInVarIndex = bitIndex % 32; - - string mask = bit_masks[bitInVarIndex]; - string result = varName + " |= " + mask; - return result; -} - -} // namespace - -string GenerateGetBit(int bitIndex) { - return GenerateGetBitInternal("", bitIndex); -} - -string GenerateSetBit(int bitIndex) { - return GenerateSetBitInternal("", bitIndex); -} - -string GenerateClearBit(int bitIndex) { - string varName = GetBitFieldNameForBit(bitIndex); - int bitInVarIndex = bitIndex % 32; - - string mask = bit_masks[bitInVarIndex]; - string result = varName + " = (" + varName + " & ~" + mask + ")"; - return result; -} - -string GenerateGetBitFromLocal(int bitIndex) { - return GenerateGetBitInternal("from_", bitIndex); -} - -string GenerateSetBitToLocal(int bitIndex) { - return GenerateSetBitInternal("to_", bitIndex); -} - -string GenerateGetBitMutableLocal(int bitIndex) { - return GenerateGetBitInternal("mutable_", bitIndex); -} - -string GenerateSetBitMutableLocal(int bitIndex) { - return GenerateSetBitInternal("mutable_", bitIndex); -} - -} // namespace java -} // namespace compiler -} // namespace protobuf -} // namespace google diff --git a/modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/java/java_helpers.h b/modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/java/java_helpers.h deleted file mode 100644 index 3937f069b..000000000 --- a/modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/java/java_helpers.h +++ /dev/null @@ -1,220 +0,0 @@ -// Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// http://code.google.com/p/protobuf/ -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -// Author: kenton@google.com (Kenton Varda) -// Based on original Protocol Buffers design by -// Sanjay Ghemawat, Jeff Dean, and others. - -#ifndef GOOGLE_PROTOBUF_COMPILER_JAVA_HELPERS_H__ -#define GOOGLE_PROTOBUF_COMPILER_JAVA_HELPERS_H__ - -#include -#include -#include - -namespace google { -namespace protobuf { -namespace compiler { -namespace java { - -// Commonly-used separator comments. Thick is a line of '=', thin is a line -// of '-'. -extern const char kThickSeparator[]; -extern const char kThinSeparator[]; - -// Converts the field's name to camel-case, e.g. "foo_bar_baz" becomes -// "fooBarBaz" or "FooBarBaz", respectively. -string UnderscoresToCamelCase(const FieldDescriptor* field); -string UnderscoresToCapitalizedCamelCase(const FieldDescriptor* field); - -// Similar, but for method names. (Typically, this merely has the effect -// of lower-casing the first letter of the name.) -string UnderscoresToCamelCase(const MethodDescriptor* method); - -// Strips ".proto" or ".protodevel" from the end of a filename. -string StripProto(const string& filename); - -// Gets the unqualified class name for the file. Each .proto file becomes a -// single Java class, with all its contents nested in that class. -string FileClassName(const FileDescriptor* file); - -// Returns the file's Java package name. -string FileJavaPackage(const FileDescriptor* file); - -// Returns output directory for the given package name. -string JavaPackageToDir(string package_name); - -// Converts the given fully-qualified name in the proto namespace to its -// fully-qualified name in the Java namespace, given that it is in the given -// file. -string ToJavaName(const string& full_name, const FileDescriptor* file); - -// These return the fully-qualified class name corresponding to the given -// descriptor. -string ClassName(const Descriptor* descriptor); -string ClassName(const EnumDescriptor* descriptor); -string ClassName(const ServiceDescriptor* descriptor); -string ClassName(const FileDescriptor* descriptor); - -inline string ExtensionIdentifierName(const FieldDescriptor* descriptor) { - return ToJavaName(descriptor->full_name(), descriptor->file()); -} - -// Get the unqualified name that should be used for a field's field -// number constant. -string FieldConstantName(const FieldDescriptor *field); - -// Returns the type of the FieldDescriptor. -// This does nothing interesting for the open source release, but is used for -// hacks that improve compatability with version 1 protocol buffers at Google. -FieldDescriptor::Type GetType(const FieldDescriptor* field); - -enum JavaType { - JAVATYPE_INT, - JAVATYPE_LONG, - JAVATYPE_FLOAT, - JAVATYPE_DOUBLE, - JAVATYPE_BOOLEAN, - JAVATYPE_STRING, - JAVATYPE_BYTES, - JAVATYPE_ENUM, - JAVATYPE_MESSAGE -}; - -JavaType GetJavaType(const FieldDescriptor* field); - -// Get the fully-qualified class name for a boxed primitive type, e.g. -// "java.lang.Integer" for JAVATYPE_INT. Returns NULL for enum and message -// types. -const char* BoxedPrimitiveTypeName(JavaType type); - -string DefaultValue(const FieldDescriptor* field); -bool IsDefaultValueJavaDefault(const FieldDescriptor* field); - -// Does this message class keep track of unknown fields? -inline bool HasUnknownFields(const Descriptor* descriptor) { - return descriptor->file()->options().optimize_for() != - FileOptions::LITE_RUNTIME; -} - -// Does this message class have generated parsing, serialization, and other -// standard methods for which reflection-based fallback implementations exist? -inline bool HasGeneratedMethods(const Descriptor* descriptor) { - return descriptor->file()->options().optimize_for() != - FileOptions::CODE_SIZE; -} - -// Does this message have specialized equals() and hashCode() methods? -inline bool HasEqualsAndHashCode(const Descriptor* descriptor) { - return descriptor->file()->options().java_generate_equals_and_hash(); -} - -// Does this message class have descriptor and reflection methods? -inline bool HasDescriptorMethods(const Descriptor* descriptor) { - return descriptor->file()->options().optimize_for() != - FileOptions::LITE_RUNTIME; -} -inline bool HasDescriptorMethods(const EnumDescriptor* descriptor) { - return descriptor->file()->options().optimize_for() != - FileOptions::LITE_RUNTIME; -} -inline bool HasDescriptorMethods(const FileDescriptor* descriptor) { - return descriptor->options().optimize_for() != - FileOptions::LITE_RUNTIME; -} - -inline bool HasNestedBuilders(const Descriptor* descriptor) { - // The proto-lite version doesn't support nested builders. - return descriptor->file()->options().optimize_for() != - FileOptions::LITE_RUNTIME; -} - -// Should we generate generic services for this file? -inline bool HasGenericServices(const FileDescriptor *file) { - return file->service_count() > 0 && - file->options().optimize_for() != FileOptions::LITE_RUNTIME && - file->options().java_generic_services(); -} - - -// Methods for shared bitfields. - -// Gets the name of the shared bitfield for the given index. -string GetBitFieldName(int index); - -// Gets the name of the shared bitfield for the given bit index. -// Effectively, GetBitFieldName(bitIndex / 32) -string GetBitFieldNameForBit(int bitIndex); - -// Generates the java code for the expression that returns the boolean value -// of the bit of the shared bitfields for the given bit index. -// Example: "((bitField1_ & 0x04) == 0x04)" -string GenerateGetBit(int bitIndex); - -// Generates the java code for the expression that sets the bit of the shared -// bitfields for the given bit index. -// Example: "bitField1_ = (bitField1_ | 0x04)" -string GenerateSetBit(int bitIndex); - -// Generates the java code for the expression that clears the bit of the shared -// bitfields for the given bit index. -// Example: "bitField1_ = (bitField1_ & ~0x04)" -string GenerateClearBit(int bitIndex); - -// Does the same as GenerateGetBit but operates on the bit field on a local -// variable. This is used by the builder to copy the value in the builder to -// the message. -// Example: "((from_bitField1_ & 0x04) == 0x04)" -string GenerateGetBitFromLocal(int bitIndex); - -// Does the same as GenerateSetBit but operates on the bit field on a local -// variable. This is used by the builder to copy the value in the builder to -// the message. -// Example: "to_bitField1_ = (to_bitField1_ | 0x04)" -string GenerateSetBitToLocal(int bitIndex); - -// Does the same as GenerateGetBit but operates on the bit field on a local -// variable. This is used by the parsing constructor to record if a repeated -// field is mutable. -// Example: "((mutable_bitField1_ & 0x04) == 0x04)" -string GenerateGetBitMutableLocal(int bitIndex); - -// Does the same as GenerateSetBit but operates on the bit field on a local -// variable. This is used by the parsing constructor to record if a repeated -// field is mutable. -// Example: "mutable_bitField1_ = (mutable_bitField1_ | 0x04)" -string GenerateSetBitMutableLocal(int bitIndex); - -} // namespace java -} // namespace compiler -} // namespace protobuf - -} // namespace google -#endif // GOOGLE_PROTOBUF_COMPILER_JAVA_HELPERS_H__ diff --git a/modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/java/java_message.cc b/modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/java/java_message.cc deleted file mode 100644 index 9322e242b..000000000 --- a/modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/java/java_message.cc +++ /dev/null @@ -1,1435 +0,0 @@ -// Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// http://code.google.com/p/protobuf/ -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -// Author: kenton@google.com (Kenton Varda) -// Based on original Protocol Buffers design by -// Sanjay Ghemawat, Jeff Dean, and others. - -#include - -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -namespace google { -namespace protobuf { -namespace compiler { -namespace java { - -using internal::WireFormat; -using internal::WireFormatLite; - -namespace { - -void PrintFieldComment(io::Printer* printer, const FieldDescriptor* field) { - // Print the field's proto-syntax definition as a comment. We don't want to - // print group bodies so we cut off after the first line. - string def = field->DebugString(); - printer->Print("// $def$\n", - "def", def.substr(0, def.find_first_of('\n'))); -} - -struct FieldOrderingByNumber { - inline bool operator()(const FieldDescriptor* a, - const FieldDescriptor* b) const { - return a->number() < b->number(); - } -}; - -struct ExtensionRangeOrdering { - bool operator()(const Descriptor::ExtensionRange* a, - const Descriptor::ExtensionRange* b) const { - return a->start < b->start; - } -}; - -// Sort the fields of the given Descriptor by number into a new[]'d array -// and return it. -const FieldDescriptor** SortFieldsByNumber(const Descriptor* descriptor) { - const FieldDescriptor** fields = - new const FieldDescriptor*[descriptor->field_count()]; - for (int i = 0; i < descriptor->field_count(); i++) { - fields[i] = descriptor->field(i); - } - sort(fields, fields + descriptor->field_count(), - FieldOrderingByNumber()); - return fields; -} - -// Get an identifier that uniquely identifies this type within the file. -// This is used to declare static variables related to this type at the -// outermost file scope. -string UniqueFileScopeIdentifier(const Descriptor* descriptor) { - return "static_" + StringReplace(descriptor->full_name(), ".", "_", true); -} - -// Returns true if the message type has any required fields. If it doesn't, -// we can optimize out calls to its isInitialized() method. -// -// already_seen is used to avoid checking the same type multiple times -// (and also to protect against recursion). -static bool HasRequiredFields( - const Descriptor* type, - hash_set* already_seen) { - if (already_seen->count(type) > 0) { - // The type is already in cache. This means that either: - // a. The type has no required fields. - // b. We are in the midst of checking if the type has required fields, - // somewhere up the stack. In this case, we know that if the type - // has any required fields, they'll be found when we return to it, - // and the whole call to HasRequiredFields() will return true. - // Therefore, we don't have to check if this type has required fields - // here. - return false; - } - already_seen->insert(type); - - // If the type has extensions, an extension with message type could contain - // required fields, so we have to be conservative and assume such an - // extension exists. - if (type->extension_range_count() > 0) return true; - - for (int i = 0; i < type->field_count(); i++) { - const FieldDescriptor* field = type->field(i); - if (field->is_required()) { - return true; - } - if (GetJavaType(field) == JAVATYPE_MESSAGE) { - if (HasRequiredFields(field->message_type(), already_seen)) { - return true; - } - } - } - - return false; -} - -static bool HasRequiredFields(const Descriptor* type) { - hash_set already_seen; - return HasRequiredFields(type, &already_seen); -} - -} // namespace - -// =================================================================== - -MessageGenerator::MessageGenerator(const Descriptor* descriptor) - : descriptor_(descriptor), - field_generators_(descriptor) { -} - -MessageGenerator::~MessageGenerator() {} - -void MessageGenerator::GenerateStaticVariables(io::Printer* printer) { - if (HasDescriptorMethods(descriptor_)) { - // Because descriptor.proto (com.google.protobuf.DescriptorProtos) is - // used in the construction of descriptors, we have a tricky bootstrapping - // problem. To help control static initialization order, we make sure all - // descriptors and other static data that depends on them are members of - // the outermost class in the file. This way, they will be initialized in - // a deterministic order. - - map vars; - vars["identifier"] = UniqueFileScopeIdentifier(descriptor_); - vars["index"] = SimpleItoa(descriptor_->index()); - vars["classname"] = ClassName(descriptor_); - if (descriptor_->containing_type() != NULL) { - vars["parent"] = UniqueFileScopeIdentifier( - descriptor_->containing_type()); - } - if (descriptor_->file()->options().java_multiple_files()) { - // We can only make these package-private since the classes that use them - // are in separate files. - vars["private"] = ""; - } else { - vars["private"] = "private "; - } - - // The descriptor for this type. - printer->Print(vars, - "$private$static com.google.protobuf.Descriptors.Descriptor\n" - " internal_$identifier$_descriptor;\n"); - - // And the FieldAccessorTable. - printer->Print(vars, - "$private$static\n" - " com.google.protobuf.GeneratedMessage.FieldAccessorTable\n" - " internal_$identifier$_fieldAccessorTable;\n"); - } - - // Generate static members for all nested types. - for (int i = 0; i < descriptor_->nested_type_count(); i++) { - // TODO(kenton): Reuse MessageGenerator objects? - MessageGenerator(descriptor_->nested_type(i)) - .GenerateStaticVariables(printer); - } -} - -void MessageGenerator::GenerateStaticVariableInitializers( - io::Printer* printer) { - if (HasDescriptorMethods(descriptor_)) { - map vars; - vars["identifier"] = UniqueFileScopeIdentifier(descriptor_); - vars["index"] = SimpleItoa(descriptor_->index()); - vars["classname"] = ClassName(descriptor_); - if (descriptor_->containing_type() != NULL) { - vars["parent"] = UniqueFileScopeIdentifier( - descriptor_->containing_type()); - } - - // The descriptor for this type. - if (descriptor_->containing_type() == NULL) { - printer->Print(vars, - "internal_$identifier$_descriptor =\n" - " getDescriptor().getMessageTypes().get($index$);\n"); - } else { - printer->Print(vars, - "internal_$identifier$_descriptor =\n" - " internal_$parent$_descriptor.getNestedTypes().get($index$);\n"); - } - - // And the FieldAccessorTable. - printer->Print(vars, - "internal_$identifier$_fieldAccessorTable = new\n" - " com.google.protobuf.GeneratedMessage.FieldAccessorTable(\n" - " internal_$identifier$_descriptor,\n" - " new java.lang.String[] { "); - for (int i = 0; i < descriptor_->field_count(); i++) { - printer->Print( - "\"$field_name$\", ", - "field_name", - UnderscoresToCapitalizedCamelCase(descriptor_->field(i))); - } - printer->Print( - "});\n"); - } - - // Generate static member initializers for all nested types. - for (int i = 0; i < descriptor_->nested_type_count(); i++) { - // TODO(kenton): Reuse MessageGenerator objects? - MessageGenerator(descriptor_->nested_type(i)) - .GenerateStaticVariableInitializers(printer); - } -} - -// =================================================================== - -void MessageGenerator::GenerateInterface(io::Printer* printer) { - if (descriptor_->extension_range_count() > 0) { - if (HasDescriptorMethods(descriptor_)) { - printer->Print( - "public interface $classname$OrBuilder extends\n" - " com.google.protobuf.GeneratedMessage.\n" - " ExtendableMessageOrBuilder<$classname$> {\n", - "classname", descriptor_->name()); - } else { - printer->Print( - "public interface $classname$OrBuilder extends \n" - " com.google.protobuf.GeneratedMessageLite.\n" - " ExtendableMessageOrBuilder<$classname$> {\n", - "classname", descriptor_->name()); - } - } else { - if (HasDescriptorMethods(descriptor_)) { - printer->Print( - "public interface $classname$OrBuilder\n" - " extends com.google.protobuf.MessageOrBuilder {\n", - "classname", descriptor_->name()); - } else { - printer->Print( - "public interface $classname$OrBuilder\n" - " extends com.google.protobuf.MessageLiteOrBuilder {\n", - "classname", descriptor_->name()); - } - } - - printer->Indent(); - for (int i = 0; i < descriptor_->field_count(); i++) { - printer->Print("\n"); - PrintFieldComment(printer, descriptor_->field(i)); - field_generators_.get(descriptor_->field(i)) - .GenerateInterfaceMembers(printer); - } - printer->Outdent(); - - printer->Print("}\n"); -} - -// =================================================================== - -void MessageGenerator::Generate(io::Printer* printer) { - bool is_own_file = - descriptor_->containing_type() == NULL && - descriptor_->file()->options().java_multiple_files(); - - WriteMessageDocComment(printer, descriptor_); - - // The builder_type stores the super type name of the nested Builder class. - string builder_type; - if (descriptor_->extension_range_count() > 0) { - if (HasDescriptorMethods(descriptor_)) { - printer->Print( - "public $static$ final class $classname$ extends\n" - " com.google.protobuf.GeneratedMessage.ExtendableMessage<\n" - " $classname$> implements $classname$OrBuilder {\n", - "static", is_own_file ? "" : "static", - "classname", descriptor_->name()); - builder_type = strings::Substitute( - "com.google.protobuf.GeneratedMessage.ExtendableBuilder<$0, ?>", - ClassName(descriptor_)); - } else { - printer->Print( - "public $static$ final class $classname$ extends\n" - " com.google.protobuf.GeneratedMessageLite.ExtendableMessage<\n" - " $classname$> implements $classname$OrBuilder {\n", - "static", is_own_file ? "" : "static", - "classname", descriptor_->name()); - builder_type = strings::Substitute( - "com.google.protobuf.GeneratedMessageLite.ExtendableBuilder<$0, ?>", - ClassName(descriptor_)); - } - } else { - if (HasDescriptorMethods(descriptor_)) { - printer->Print( - "public $static$ final class $classname$ extends\n" - " com.google.protobuf.GeneratedMessage\n" - " implements $classname$OrBuilder {\n", - "static", is_own_file ? "" : "static", - "classname", descriptor_->name()); - builder_type = "com.google.protobuf.GeneratedMessage.Builder"; - } else { - printer->Print( - "public $static$ final class $classname$ extends\n" - " com.google.protobuf.GeneratedMessageLite\n" - " implements $classname$OrBuilder {\n", - "static", is_own_file ? "" : "static", - "classname", descriptor_->name()); - builder_type = "com.google.protobuf.GeneratedMessageLite.Builder"; - } - } - printer->Indent(); - // Using builder_type, instead of Builder, prevents the Builder class from - // being loaded into PermGen space when the default instance is created. - // This optimizes the PermGen space usage for clients that do not modify - // messages. - printer->Print( - "// Use $classname$.newBuilder() to construct.\n" - "private $classname$($buildertype$ builder) {\n" - " super(builder);\n" - "$set_unknown_fields$\n" - "}\n", - "classname", descriptor_->name(), - "buildertype", builder_type, - "set_unknown_fields", HasUnknownFields(descriptor_) - ? " this.unknownFields = builder.getUnknownFields();" : ""); - printer->Print( - // Used when constructing the default instance, which cannot be initialized - // immediately because it may cyclically refer to other default instances. - "private $classname$(boolean noInit) {$set_default_unknown_fields$}\n" - "\n" - "private static final $classname$ defaultInstance;\n" - "public static $classname$ getDefaultInstance() {\n" - " return defaultInstance;\n" - "}\n" - "\n" - "public $classname$ getDefaultInstanceForType() {\n" - " return defaultInstance;\n" - "}\n" - "\n", - "classname", descriptor_->name(), - "set_default_unknown_fields", HasUnknownFields(descriptor_) - ? " this.unknownFields =" - " com.google.protobuf.UnknownFieldSet.getDefaultInstance(); " : ""); - - if (HasUnknownFields(descriptor_)) { - printer->Print( - "private final com.google.protobuf.UnknownFieldSet unknownFields;\n" - "" - "@java.lang.Override\n" - "public final com.google.protobuf.UnknownFieldSet\n" - " getUnknownFields() {\n" - " return this.unknownFields;\n" - "}\n"); - } - - if (HasGeneratedMethods(descriptor_)) { - GenerateParsingConstructor(printer); - } - - GenerateDescriptorMethods(printer); - GenerateParser(printer); - - // Nested types - for (int i = 0; i < descriptor_->enum_type_count(); i++) { - EnumGenerator(descriptor_->enum_type(i)).Generate(printer); - } - - for (int i = 0; i < descriptor_->nested_type_count(); i++) { - MessageGenerator messageGenerator(descriptor_->nested_type(i)); - messageGenerator.GenerateInterface(printer); - messageGenerator.Generate(printer); - } - - // Integers for bit fields. - int totalBits = 0; - for (int i = 0; i < descriptor_->field_count(); i++) { - totalBits += field_generators_.get(descriptor_->field(i)) - .GetNumBitsForMessage(); - } - int totalInts = (totalBits + 31) / 32; - for (int i = 0; i < totalInts; i++) { - printer->Print("private int $bit_field_name$;\n", - "bit_field_name", GetBitFieldName(i)); - } - - // Fields - for (int i = 0; i < descriptor_->field_count(); i++) { - PrintFieldComment(printer, descriptor_->field(i)); - printer->Print("public static final int $constant_name$ = $number$;\n", - "constant_name", FieldConstantName(descriptor_->field(i)), - "number", SimpleItoa(descriptor_->field(i)->number())); - field_generators_.get(descriptor_->field(i)).GenerateMembers(printer); - printer->Print("\n"); - } - - // Called by the constructor, except in the case of the default instance, - // in which case this is called by static init code later on. - printer->Print("private void initFields() {\n"); - printer->Indent(); - for (int i = 0; i < descriptor_->field_count(); i++) { - field_generators_.get(descriptor_->field(i)) - .GenerateInitializationCode(printer); - } - printer->Outdent(); - printer->Print("}\n"); - - if (HasGeneratedMethods(descriptor_)) { - GenerateIsInitialized(printer, MEMOIZE); - GenerateMessageSerializationMethods(printer); - } - - if (HasEqualsAndHashCode(descriptor_)) { - GenerateEqualsAndHashCode(printer); - } - - GenerateParseFromMethods(printer); - GenerateBuilder(printer); - - // Carefully initialize the default instance in such a way that it doesn't - // conflict with other initialization. - printer->Print( - "\n" - "static {\n" - " defaultInstance = new $classname$(true);\n" - " defaultInstance.initFields();\n" - "}\n" - "\n" - "// @@protoc_insertion_point(class_scope:$full_name$)\n", - "classname", descriptor_->name(), - "full_name", descriptor_->full_name()); - - // Extensions must be declared after the defaultInstance is initialized - // because the defaultInstance is used by the extension to lazily retrieve - // the outer class's FileDescriptor. - for (int i = 0; i < descriptor_->extension_count(); i++) { - ExtensionGenerator(descriptor_->extension(i)).Generate(printer); - } - - printer->Outdent(); - printer->Print("}\n\n"); -} - - -// =================================================================== - -void MessageGenerator:: -GenerateMessageSerializationMethods(io::Printer* printer) { - scoped_array sorted_fields( - SortFieldsByNumber(descriptor_)); - - vector sorted_extensions; - for (int i = 0; i < descriptor_->extension_range_count(); ++i) { - sorted_extensions.push_back(descriptor_->extension_range(i)); - } - sort(sorted_extensions.begin(), sorted_extensions.end(), - ExtensionRangeOrdering()); - - printer->Print( - "public void writeTo(com.google.protobuf.CodedOutputStream output)\n" - " throws java.io.IOException {\n"); - printer->Indent(); - // writeTo(CodedOutputStream output) might be invoked without - // getSerializedSize() ever being called, but we need the memoized - // sizes in case this message has packed fields. Rather than emit checks for - // each packed field, just call getSerializedSize() up front for all messages. - // In most cases, getSerializedSize() will have already been called anyway by - // one of the wrapper writeTo() methods, making this call cheap. - printer->Print( - "getSerializedSize();\n"); - - if (descriptor_->extension_range_count() > 0) { - if (descriptor_->options().message_set_wire_format()) { - printer->Print( - "com.google.protobuf.GeneratedMessage$lite$\n" - " .ExtendableMessage<$classname$>.ExtensionWriter extensionWriter =\n" - " newMessageSetExtensionWriter();\n", - "lite", HasDescriptorMethods(descriptor_) ? "" : "Lite", - "classname", ClassName(descriptor_)); - } else { - printer->Print( - "com.google.protobuf.GeneratedMessage$lite$\n" - " .ExtendableMessage<$classname$>.ExtensionWriter extensionWriter =\n" - " newExtensionWriter();\n", - "lite", HasDescriptorMethods(descriptor_) ? "" : "Lite", - "classname", ClassName(descriptor_)); - } - } - - // Merge the fields and the extension ranges, both sorted by field number. - for (int i = 0, j = 0; - i < descriptor_->field_count() || j < sorted_extensions.size(); - ) { - if (i == descriptor_->field_count()) { - GenerateSerializeOneExtensionRange(printer, sorted_extensions[j++]); - } else if (j == sorted_extensions.size()) { - GenerateSerializeOneField(printer, sorted_fields[i++]); - } else if (sorted_fields[i]->number() < sorted_extensions[j]->start) { - GenerateSerializeOneField(printer, sorted_fields[i++]); - } else { - GenerateSerializeOneExtensionRange(printer, sorted_extensions[j++]); - } - } - - if (HasUnknownFields(descriptor_)) { - if (descriptor_->options().message_set_wire_format()) { - printer->Print( - "getUnknownFields().writeAsMessageSetTo(output);\n"); - } else { - printer->Print( - "getUnknownFields().writeTo(output);\n"); - } - } - - printer->Outdent(); - printer->Print( - "}\n" - "\n" - "private int memoizedSerializedSize = -1;\n" - "public int getSerializedSize() {\n" - " int size = memoizedSerializedSize;\n" - " if (size != -1) return size;\n" - "\n" - " size = 0;\n"); - printer->Indent(); - - for (int i = 0; i < descriptor_->field_count(); i++) { - field_generators_.get(sorted_fields[i]).GenerateSerializedSizeCode(printer); - } - - if (descriptor_->extension_range_count() > 0) { - if (descriptor_->options().message_set_wire_format()) { - printer->Print( - "size += extensionsSerializedSizeAsMessageSet();\n"); - } else { - printer->Print( - "size += extensionsSerializedSize();\n"); - } - } - - if (HasUnknownFields(descriptor_)) { - if (descriptor_->options().message_set_wire_format()) { - printer->Print( - "size += getUnknownFields().getSerializedSizeAsMessageSet();\n"); - } else { - printer->Print( - "size += getUnknownFields().getSerializedSize();\n"); - } - } - - printer->Outdent(); - printer->Print( - " memoizedSerializedSize = size;\n" - " return size;\n" - "}\n" - "\n"); - - printer->Print( - "private static final long serialVersionUID = 0L;\n" - "@java.lang.Override\n" - "protected java.lang.Object writeReplace()\n" - " throws java.io.ObjectStreamException {\n" - " return super.writeReplace();\n" - "}\n" - "\n"); -} - -void MessageGenerator:: -GenerateParseFromMethods(io::Printer* printer) { - // Note: These are separate from GenerateMessageSerializationMethods() - // because they need to be generated even for messages that are optimized - // for code size. - printer->Print( - "public static $classname$ parseFrom(\n" - " com.google.protobuf.ByteString data)\n" - " throws com.google.protobuf.InvalidProtocolBufferException {\n" - " return PARSER.parseFrom(data);\n" - "}\n" - "public static $classname$ parseFrom(\n" - " com.google.protobuf.ByteString data,\n" - " com.google.protobuf.ExtensionRegistryLite extensionRegistry)\n" - " throws com.google.protobuf.InvalidProtocolBufferException {\n" - " return PARSER.parseFrom(data, extensionRegistry);\n" - "}\n" - "public static $classname$ parseFrom(byte[] data)\n" - " throws com.google.protobuf.InvalidProtocolBufferException {\n" - " return PARSER.parseFrom(data);\n" - "}\n" - "public static $classname$ parseFrom(\n" - " byte[] data,\n" - " com.google.protobuf.ExtensionRegistryLite extensionRegistry)\n" - " throws com.google.protobuf.InvalidProtocolBufferException {\n" - " return PARSER.parseFrom(data, extensionRegistry);\n" - "}\n" - "public static $classname$ parseFrom(java.io.InputStream input)\n" - " throws java.io.IOException {\n" - " return PARSER.parseFrom(input);\n" - "}\n" - "public static $classname$ parseFrom(\n" - " java.io.InputStream input,\n" - " com.google.protobuf.ExtensionRegistryLite extensionRegistry)\n" - " throws java.io.IOException {\n" - " return PARSER.parseFrom(input, extensionRegistry);\n" - "}\n" - "public static $classname$ parseDelimitedFrom(java.io.InputStream input)\n" - " throws java.io.IOException {\n" - " return PARSER.parseDelimitedFrom(input);\n" - "}\n" - "public static $classname$ parseDelimitedFrom(\n" - " java.io.InputStream input,\n" - " com.google.protobuf.ExtensionRegistryLite extensionRegistry)\n" - " throws java.io.IOException {\n" - " return PARSER.parseDelimitedFrom(input, extensionRegistry);\n" - "}\n" - "public static $classname$ parseFrom(\n" - " com.google.protobuf.CodedInputStream input)\n" - " throws java.io.IOException {\n" - " return PARSER.parseFrom(input);\n" - "}\n" - "public static $classname$ parseFrom(\n" - " com.google.protobuf.CodedInputStream input,\n" - " com.google.protobuf.ExtensionRegistryLite extensionRegistry)\n" - " throws java.io.IOException {\n" - " return PARSER.parseFrom(input, extensionRegistry);\n" - "}\n" - "\n", - "classname", ClassName(descriptor_)); -} - -void MessageGenerator::GenerateSerializeOneField( - io::Printer* printer, const FieldDescriptor* field) { - field_generators_.get(field).GenerateSerializationCode(printer); -} - -void MessageGenerator::GenerateSerializeOneExtensionRange( - io::Printer* printer, const Descriptor::ExtensionRange* range) { - printer->Print( - "extensionWriter.writeUntil($end$, output);\n", - "end", SimpleItoa(range->end)); -} - -// =================================================================== - -void MessageGenerator::GenerateBuilder(io::Printer* printer) { - printer->Print( - "public static Builder newBuilder() { return Builder.create(); }\n" - "public Builder newBuilderForType() { return newBuilder(); }\n" - "public static Builder newBuilder($classname$ prototype) {\n" - " return newBuilder().mergeFrom(prototype);\n" - "}\n" - "public Builder toBuilder() { return newBuilder(this); }\n" - "\n", - "classname", ClassName(descriptor_)); - - if (HasNestedBuilders(descriptor_)) { - printer->Print( - "@java.lang.Override\n" - "protected Builder newBuilderForType(\n" - " com.google.protobuf.GeneratedMessage.BuilderParent parent) {\n" - " Builder builder = new Builder(parent);\n" - " return builder;\n" - "}\n"); - } - - WriteMessageDocComment(printer, descriptor_); - - if (descriptor_->extension_range_count() > 0) { - if (HasDescriptorMethods(descriptor_)) { - printer->Print( - "public static final class Builder extends\n" - " com.google.protobuf.GeneratedMessage.ExtendableBuilder<\n" - " $classname$, Builder> implements $classname$OrBuilder {\n", - "classname", ClassName(descriptor_)); - } else { - printer->Print( - "public static final class Builder extends\n" - " com.google.protobuf.GeneratedMessageLite.ExtendableBuilder<\n" - " $classname$, Builder> implements $classname$OrBuilder {\n", - "classname", ClassName(descriptor_)); - } - } else { - if (HasDescriptorMethods(descriptor_)) { - printer->Print( - "public static final class Builder extends\n" - " com.google.protobuf.GeneratedMessage.Builder\n" - " implements $classname$OrBuilder {\n", - "classname", ClassName(descriptor_)); - } else { - printer->Print( - "public static final class Builder extends\n" - " com.google.protobuf.GeneratedMessageLite.Builder<\n" - " $classname$, Builder>\n" - " implements $classname$OrBuilder {\n", - "classname", ClassName(descriptor_)); - } - } - printer->Indent(); - - GenerateDescriptorMethods(printer); - GenerateCommonBuilderMethods(printer); - - if (HasGeneratedMethods(descriptor_)) { - GenerateIsInitialized(printer, DONT_MEMOIZE); - GenerateBuilderParsingMethods(printer); - } - - // Integers for bit fields. - int totalBits = 0; - for (int i = 0; i < descriptor_->field_count(); i++) { - totalBits += field_generators_.get(descriptor_->field(i)) - .GetNumBitsForBuilder(); - } - int totalInts = (totalBits + 31) / 32; - for (int i = 0; i < totalInts; i++) { - printer->Print("private int $bit_field_name$;\n", - "bit_field_name", GetBitFieldName(i)); - } - - for (int i = 0; i < descriptor_->field_count(); i++) { - printer->Print("\n"); - PrintFieldComment(printer, descriptor_->field(i)); - field_generators_.get(descriptor_->field(i)) - .GenerateBuilderMembers(printer); - } - - printer->Print( - "\n" - "// @@protoc_insertion_point(builder_scope:$full_name$)\n", - "full_name", descriptor_->full_name()); - - printer->Outdent(); - printer->Print("}\n"); -} - -void MessageGenerator::GenerateDescriptorMethods(io::Printer* printer) { - if (HasDescriptorMethods(descriptor_)) { - if (!descriptor_->options().no_standard_descriptor_accessor()) { - printer->Print( - "public static final com.google.protobuf.Descriptors.Descriptor\n" - " getDescriptor() {\n" - " return $fileclass$.internal_$identifier$_descriptor;\n" - "}\n" - "\n", - "fileclass", ClassName(descriptor_->file()), - "identifier", UniqueFileScopeIdentifier(descriptor_)); - } - printer->Print( - "protected com.google.protobuf.GeneratedMessage.FieldAccessorTable\n" - " internalGetFieldAccessorTable() {\n" - " return $fileclass$.internal_$identifier$_fieldAccessorTable\n" - " .ensureFieldAccessorsInitialized(\n" - " $classname$.class, $classname$.Builder.class);\n" - "}\n" - "\n", - "classname", ClassName(descriptor_), - "fileclass", ClassName(descriptor_->file()), - "identifier", UniqueFileScopeIdentifier(descriptor_)); - } -} - -// =================================================================== - -void MessageGenerator::GenerateCommonBuilderMethods(io::Printer* printer) { - printer->Print( - "// Construct using $classname$.newBuilder()\n" - "private Builder() {\n" - " maybeForceBuilderInitialization();\n" - "}\n" - "\n", - "classname", ClassName(descriptor_)); - - if (HasDescriptorMethods(descriptor_)) { - printer->Print( - "private Builder(\n" - " com.google.protobuf.GeneratedMessage.BuilderParent parent) {\n" - " super(parent);\n" - " maybeForceBuilderInitialization();\n" - "}\n", - "classname", ClassName(descriptor_)); - } - - - if (HasNestedBuilders(descriptor_)) { - printer->Print( - "private void maybeForceBuilderInitialization() {\n" - " if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) {\n"); - - printer->Indent(); - printer->Indent(); - for (int i = 0; i < descriptor_->field_count(); i++) { - field_generators_.get(descriptor_->field(i)) - .GenerateFieldBuilderInitializationCode(printer); - } - printer->Outdent(); - printer->Outdent(); - - printer->Print( - " }\n" - "}\n"); - } else { - printer->Print( - "private void maybeForceBuilderInitialization() {\n" - "}\n"); - } - - printer->Print( - "private static Builder create() {\n" - " return new Builder();\n" - "}\n" - "\n" - "public Builder clear() {\n" - " super.clear();\n", - "classname", ClassName(descriptor_)); - - printer->Indent(); - - for (int i = 0; i < descriptor_->field_count(); i++) { - field_generators_.get(descriptor_->field(i)) - .GenerateBuilderClearCode(printer); - } - - printer->Outdent(); - - printer->Print( - " return this;\n" - "}\n" - "\n" - "public Builder clone() {\n" - " return create().mergeFrom(buildPartial());\n" - "}\n" - "\n", - "classname", ClassName(descriptor_)); - if (HasDescriptorMethods(descriptor_)) { - printer->Print( - "public com.google.protobuf.Descriptors.Descriptor\n" - " getDescriptorForType() {\n" - " return $fileclass$.internal_$identifier$_descriptor;\n" - "}\n" - "\n", - "fileclass", ClassName(descriptor_->file()), - "identifier", UniqueFileScopeIdentifier(descriptor_)); - } - printer->Print( - "public $classname$ getDefaultInstanceForType() {\n" - " return $classname$.getDefaultInstance();\n" - "}\n" - "\n", - "classname", ClassName(descriptor_)); - - // ----------------------------------------------------------------- - - printer->Print( - "public $classname$ build() {\n" - " $classname$ result = buildPartial();\n" - " if (!result.isInitialized()) {\n" - " throw newUninitializedMessageException(result);\n" - " }\n" - " return result;\n" - "}\n" - "\n" - "public $classname$ buildPartial() {\n" - " $classname$ result = new $classname$(this);\n", - "classname", ClassName(descriptor_)); - - printer->Indent(); - - // Local vars for from and to bit fields to avoid accessing the builder and - // message over and over for these fields. Seems to provide a slight - // perforamance improvement in micro benchmark and this is also what proto1 - // code does. - int totalBuilderBits = 0; - int totalMessageBits = 0; - for (int i = 0; i < descriptor_->field_count(); i++) { - const FieldGenerator& field = field_generators_.get(descriptor_->field(i)); - totalBuilderBits += field.GetNumBitsForBuilder(); - totalMessageBits += field.GetNumBitsForMessage(); - } - int totalBuilderInts = (totalBuilderBits + 31) / 32; - int totalMessageInts = (totalMessageBits + 31) / 32; - for (int i = 0; i < totalBuilderInts; i++) { - printer->Print("int from_$bit_field_name$ = $bit_field_name$;\n", - "bit_field_name", GetBitFieldName(i)); - } - for (int i = 0; i < totalMessageInts; i++) { - printer->Print("int to_$bit_field_name$ = 0;\n", - "bit_field_name", GetBitFieldName(i)); - } - - // Output generation code for each field. - for (int i = 0; i < descriptor_->field_count(); i++) { - field_generators_.get(descriptor_->field(i)).GenerateBuildingCode(printer); - } - - // Copy the bit field results to the generated message - for (int i = 0; i < totalMessageInts; i++) { - printer->Print("result.$bit_field_name$ = to_$bit_field_name$;\n", - "bit_field_name", GetBitFieldName(i)); - } - - printer->Outdent(); - - if (HasDescriptorMethods(descriptor_)) { - printer->Print( - " onBuilt();\n"); - } - - printer->Print( - " return result;\n" - "}\n" - "\n", - "classname", ClassName(descriptor_)); - - // ----------------------------------------------------------------- - - if (HasGeneratedMethods(descriptor_)) { - // MergeFrom(Message other) requires the ability to distinguish the other - // messages type by its descriptor. - if (HasDescriptorMethods(descriptor_)) { - printer->Print( - "public Builder mergeFrom(com.google.protobuf.Message other) {\n" - " if (other instanceof $classname$) {\n" - " return mergeFrom(($classname$)other);\n" - " } else {\n" - " super.mergeFrom(other);\n" - " return this;\n" - " }\n" - "}\n" - "\n", - "classname", ClassName(descriptor_)); - } - - printer->Print( - "public Builder mergeFrom($classname$ other) {\n" - // Optimization: If other is the default instance, we know none of its - // fields are set so we can skip the merge. - " if (other == $classname$.getDefaultInstance()) return this;\n", - "classname", ClassName(descriptor_)); - printer->Indent(); - - for (int i = 0; i < descriptor_->field_count(); i++) { - field_generators_.get(descriptor_->field(i)).GenerateMergingCode(printer); - } - - printer->Outdent(); - - // if message type has extensions - if (descriptor_->extension_range_count() > 0) { - printer->Print( - " this.mergeExtensionFields(other);\n"); - } - - if (HasUnknownFields(descriptor_)) { - printer->Print( - " this.mergeUnknownFields(other.getUnknownFields());\n"); - } - - printer->Print( - " return this;\n" - "}\n" - "\n"); - } -} - -// =================================================================== - -void MessageGenerator::GenerateBuilderParsingMethods(io::Printer* printer) { - printer->Print( - "public Builder mergeFrom(\n" - " com.google.protobuf.CodedInputStream input,\n" - " com.google.protobuf.ExtensionRegistryLite extensionRegistry)\n" - " throws java.io.IOException {\n" - " $classname$ parsedMessage = null;\n" - " try {\n" - " parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry);\n" - " } catch (com.google.protobuf.InvalidProtocolBufferException e) {\n" - " parsedMessage = ($classname$) e.getUnfinishedMessage();\n" - " throw e;\n" - " } finally {\n" - " if (parsedMessage != null) {\n" - " mergeFrom(parsedMessage);\n" - " }\n" - " }\n" - " return this;\n" - "}\n", - "classname", ClassName(descriptor_)); -} - -// =================================================================== - -void MessageGenerator::GenerateIsInitialized( - io::Printer* printer, UseMemoization useMemoization) { - bool memoization = useMemoization == MEMOIZE; - if (memoization) { - // Memoizes whether the protocol buffer is fully initialized (has all - // required fields). -1 means not yet computed. 0 means false and 1 means - // true. - printer->Print( - "private byte memoizedIsInitialized = -1;\n"); - } - printer->Print( - "public final boolean isInitialized() {\n"); - printer->Indent(); - - if (memoization) { - printer->Print( - "byte isInitialized = memoizedIsInitialized;\n" - "if (isInitialized != -1) return isInitialized == 1;\n" - "\n"); - } - - // Check that all required fields in this message are set. - // TODO(kenton): We can optimize this when we switch to putting all the - // "has" fields into a single bitfield. - for (int i = 0; i < descriptor_->field_count(); i++) { - const FieldDescriptor* field = descriptor_->field(i); - - if (field->is_required()) { - printer->Print( - "if (!has$name$()) {\n" - " $memoize$\n" - " return false;\n" - "}\n", - "name", UnderscoresToCapitalizedCamelCase(field), - "memoize", memoization ? "memoizedIsInitialized = 0;" : ""); - } - } - - // Now check that all embedded messages are initialized. - for (int i = 0; i < descriptor_->field_count(); i++) { - const FieldDescriptor* field = descriptor_->field(i); - if (GetJavaType(field) == JAVATYPE_MESSAGE && - HasRequiredFields(field->message_type())) { - switch (field->label()) { - case FieldDescriptor::LABEL_REQUIRED: - printer->Print( - "if (!get$name$().isInitialized()) {\n" - " $memoize$\n" - " return false;\n" - "}\n", - "type", ClassName(field->message_type()), - "name", UnderscoresToCapitalizedCamelCase(field), - "memoize", memoization ? "memoizedIsInitialized = 0;" : ""); - break; - case FieldDescriptor::LABEL_OPTIONAL: - printer->Print( - "if (has$name$()) {\n" - " if (!get$name$().isInitialized()) {\n" - " $memoize$\n" - " return false;\n" - " }\n" - "}\n", - "type", ClassName(field->message_type()), - "name", UnderscoresToCapitalizedCamelCase(field), - "memoize", memoization ? "memoizedIsInitialized = 0;" : ""); - break; - case FieldDescriptor::LABEL_REPEATED: - printer->Print( - "for (int i = 0; i < get$name$Count(); i++) {\n" - " if (!get$name$(i).isInitialized()) {\n" - " $memoize$\n" - " return false;\n" - " }\n" - "}\n", - "type", ClassName(field->message_type()), - "name", UnderscoresToCapitalizedCamelCase(field), - "memoize", memoization ? "memoizedIsInitialized = 0;" : ""); - break; - } - } - } - - if (descriptor_->extension_range_count() > 0) { - printer->Print( - "if (!extensionsAreInitialized()) {\n" - " $memoize$\n" - " return false;\n" - "}\n", - "memoize", memoization ? "memoizedIsInitialized = 0;" : ""); - } - - printer->Outdent(); - - if (memoization) { - printer->Print( - " memoizedIsInitialized = 1;\n"); - } - - printer->Print( - " return true;\n" - "}\n" - "\n"); -} - -// =================================================================== - -void MessageGenerator::GenerateEqualsAndHashCode(io::Printer* printer) { - printer->Print( - "@java.lang.Override\n" - "public boolean equals(final java.lang.Object obj) {\n"); - printer->Indent(); - printer->Print( - "if (obj == this) {\n" - " return true;\n" - "}\n" - "if (!(obj instanceof $classname$)) {\n" - " return super.equals(obj);\n" - "}\n" - "$classname$ other = ($classname$) obj;\n" - "\n", - "classname", ClassName(descriptor_)); - - printer->Print("boolean result = true;\n"); - for (int i = 0; i < descriptor_->field_count(); i++) { - const FieldDescriptor* field = descriptor_->field(i); - if (!field->is_repeated()) { - printer->Print( - "result = result && (has$name$() == other.has$name$());\n" - "if (has$name$()) {\n", - "name", UnderscoresToCapitalizedCamelCase(field)); - printer->Indent(); - } - field_generators_.get(field).GenerateEqualsCode(printer); - if (!field->is_repeated()) { - printer->Outdent(); - printer->Print( - "}\n"); - } - } - if (HasDescriptorMethods(descriptor_)) { - printer->Print( - "result = result &&\n" - " getUnknownFields().equals(other.getUnknownFields());\n"); - if (descriptor_->extension_range_count() > 0) { - printer->Print( - "result = result &&\n" - " getExtensionFields().equals(other.getExtensionFields());\n"); - } - } - printer->Print( - "return result;\n"); - printer->Outdent(); - printer->Print( - "}\n" - "\n"); - - printer->Print( - "private int memoizedHashCode = 0;\n"); - printer->Print( - "@java.lang.Override\n" - "public int hashCode() {\n"); - printer->Indent(); - printer->Print( - "if (memoizedHashCode != 0) {\n"); - printer->Indent(); - printer->Print( - "return memoizedHashCode;\n"); - printer->Outdent(); - printer->Print( - "}\n" - "int hash = 41;\n" - "hash = (19 * hash) + getDescriptorForType().hashCode();\n"); - for (int i = 0; i < descriptor_->field_count(); i++) { - const FieldDescriptor* field = descriptor_->field(i); - if (!field->is_repeated()) { - printer->Print( - "if (has$name$()) {\n", - "name", UnderscoresToCapitalizedCamelCase(field)); - printer->Indent(); - } - field_generators_.get(field).GenerateHashCode(printer); - if (!field->is_repeated()) { - printer->Outdent(); - printer->Print("}\n"); - } - } - if (HasDescriptorMethods(descriptor_)) { - if (descriptor_->extension_range_count() > 0) { - printer->Print( - "hash = hashFields(hash, getExtensionFields());\n"); - } - } - printer->Print( - "hash = (29 * hash) + getUnknownFields().hashCode();\n" - "memoizedHashCode = hash;\n" - "return hash;\n"); - printer->Outdent(); - printer->Print( - "}\n" - "\n"); -} - -// =================================================================== - -void MessageGenerator::GenerateExtensionRegistrationCode(io::Printer* printer) { - for (int i = 0; i < descriptor_->extension_count(); i++) { - ExtensionGenerator(descriptor_->extension(i)) - .GenerateRegistrationCode(printer); - } - - for (int i = 0; i < descriptor_->nested_type_count(); i++) { - MessageGenerator(descriptor_->nested_type(i)) - .GenerateExtensionRegistrationCode(printer); - } -} - -// =================================================================== -void MessageGenerator::GenerateParsingConstructor(io::Printer* printer) { - scoped_array sorted_fields( - SortFieldsByNumber(descriptor_)); - - printer->Print( - "private $classname$(\n" - " com.google.protobuf.CodedInputStream input,\n" - " com.google.protobuf.ExtensionRegistryLite extensionRegistry)\n" - " throws com.google.protobuf.InvalidProtocolBufferException {\n", - "classname", descriptor_->name()); - printer->Indent(); - - // Initialize all fields to default. - printer->Print( - "initFields();\n"); - - // Use builder bits to track mutable repeated fields. - int totalBuilderBits = 0; - for (int i = 0; i < descriptor_->field_count(); i++) { - const FieldGenerator& field = field_generators_.get(descriptor_->field(i)); - totalBuilderBits += field.GetNumBitsForBuilder(); - } - int totalBuilderInts = (totalBuilderBits + 31) / 32; - for (int i = 0; i < totalBuilderInts; i++) { - printer->Print("int mutable_$bit_field_name$ = 0;\n", - "bit_field_name", GetBitFieldName(i)); - } - - if (HasUnknownFields(descriptor_)) { - printer->Print( - "com.google.protobuf.UnknownFieldSet.Builder unknownFields =\n" - " com.google.protobuf.UnknownFieldSet.newBuilder();\n"); - } - - printer->Print( - "try {\n"); - printer->Indent(); - - printer->Print( - "boolean done = false;\n" - "while (!done) {\n"); - printer->Indent(); - - printer->Print( - "int tag = input.readTag();\n" - "switch (tag) {\n"); - printer->Indent(); - - printer->Print( - "case 0:\n" // zero signals EOF / limit reached - " done = true;\n" - " break;\n" - "default: {\n" - " if (!parseUnknownField(input,$unknown_fields$\n" - " extensionRegistry, tag)) {\n" - " done = true;\n" // it's an endgroup tag - " }\n" - " break;\n" - "}\n", - "unknown_fields", HasUnknownFields(descriptor_) - ? " unknownFields," : ""); - - for (int i = 0; i < descriptor_->field_count(); i++) { - const FieldDescriptor* field = sorted_fields[i]; - uint32 tag = WireFormatLite::MakeTag(field->number(), - WireFormat::WireTypeForFieldType(field->type())); - - printer->Print( - "case $tag$: {\n", - "tag", SimpleItoa(tag)); - printer->Indent(); - - field_generators_.get(field).GenerateParsingCode(printer); - - printer->Outdent(); - printer->Print( - " break;\n" - "}\n"); - - if (field->is_packable()) { - // To make packed = true wire compatible, we generate parsing code from a - // packed version of this field regardless of field->options().packed(). - uint32 packed_tag = WireFormatLite::MakeTag(field->number(), - WireFormatLite::WIRETYPE_LENGTH_DELIMITED); - printer->Print( - "case $tag$: {\n", - "tag", SimpleItoa(packed_tag)); - printer->Indent(); - - field_generators_.get(field).GenerateParsingCodeFromPacked(printer); - - printer->Outdent(); - printer->Print( - " break;\n" - "}\n"); - } - } - - printer->Outdent(); - printer->Outdent(); - printer->Print( - " }\n" // switch (tag) - "}\n"); // while (!done) - - printer->Outdent(); - printer->Print( - "} catch (com.google.protobuf.InvalidProtocolBufferException e) {\n" - " throw e.setUnfinishedMessage(this);\n" - "} catch (java.io.IOException e) {\n" - " throw new com.google.protobuf.InvalidProtocolBufferException(\n" - " e.getMessage()).setUnfinishedMessage(this);\n" - "} finally {\n"); - printer->Indent(); - - // Make repeated field list immutable. - for (int i = 0; i < descriptor_->field_count(); i++) { - const FieldDescriptor* field = sorted_fields[i]; - field_generators_.get(field).GenerateParsingDoneCode(printer); - } - - // Make unknown fields immutable. - if (HasUnknownFields(descriptor_)) { - printer->Print( - "this.unknownFields = unknownFields.build();\n"); - } - - // Make extensions immutable. - printer->Print( - "makeExtensionsImmutable();\n"); - - printer->Outdent(); - printer->Outdent(); - printer->Print( - " }\n" // finally - "}\n"); -} - -// =================================================================== -void MessageGenerator::GenerateParser(io::Printer* printer) { - printer->Print( - "public static com.google.protobuf.Parser<$classname$> PARSER =\n" - " new com.google.protobuf.AbstractParser<$classname$>() {\n", - "classname", descriptor_->name()); - printer->Indent(); - printer->Print( - "public $classname$ parsePartialFrom(\n" - " com.google.protobuf.CodedInputStream input,\n" - " com.google.protobuf.ExtensionRegistryLite extensionRegistry)\n" - " throws com.google.protobuf.InvalidProtocolBufferException {\n", - "classname", descriptor_->name()); - if (HasGeneratedMethods(descriptor_)) { - printer->Print( - " return new $classname$(input, extensionRegistry);\n", - "classname", descriptor_->name()); - } else { - // When parsing constructor isn't generated, use builder to parse messages. - // Note, will fallback to use reflection based mergeFieldFrom() in - // AbstractMessage.Builder. - printer->Indent(); - printer->Print( - "Builder builder = newBuilder();\n" - "try {\n" - " builder.mergeFrom(input, extensionRegistry);\n" - "} catch (com.google.protobuf.InvalidProtocolBufferException e) {\n" - " throw e.setUnfinishedMessage(builder.buildPartial());\n" - "} catch (java.io.IOException e) {\n" - " throw new com.google.protobuf.InvalidProtocolBufferException(\n" - " e.getMessage()).setUnfinishedMessage(builder.buildPartial());\n" - "}\n" - "return builder.buildPartial();\n"); - printer->Outdent(); - } - printer->Print( - "}\n"); - printer->Outdent(); - printer->Print( - "};\n" - "\n"); - - printer->Print( - "@java.lang.Override\n" - "public com.google.protobuf.Parser<$classname$> getParserForType() {\n" - " return PARSER;\n" - "}\n" - "\n", - "classname", descriptor_->name()); -} - -} // namespace java -} // namespace compiler -} // namespace protobuf -} // namespace google diff --git a/modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/java/java_message.h b/modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/java/java_message.h deleted file mode 100644 index a30f02026..000000000 --- a/modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/java/java_message.h +++ /dev/null @@ -1,112 +0,0 @@ -// Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// http://code.google.com/p/protobuf/ -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -// Author: kenton@google.com (Kenton Varda) -// Based on original Protocol Buffers design by -// Sanjay Ghemawat, Jeff Dean, and others. - -#ifndef GOOGLE_PROTOBUF_COMPILER_JAVA_MESSAGE_H__ -#define GOOGLE_PROTOBUF_COMPILER_JAVA_MESSAGE_H__ - -#include -#include -#include - -namespace google { -namespace protobuf { - namespace io { - class Printer; // printer.h - } -} - -namespace protobuf { -namespace compiler { -namespace java { - -class MessageGenerator { - public: - explicit MessageGenerator(const Descriptor* descriptor); - ~MessageGenerator(); - - // All static variables have to be declared at the top-level of the file - // so that we can control initialization order, which is important for - // DescriptorProto bootstrapping to work. - void GenerateStaticVariables(io::Printer* printer); - - // Output code which initializes the static variables generated by - // GenerateStaticVariables(). - void GenerateStaticVariableInitializers(io::Printer* printer); - - // Generate the class itself. - void Generate(io::Printer* printer); - - // Generates the base interface that both the class and its builder implement - void GenerateInterface(io::Printer* printer); - - // Generate code to register all contained extensions with an - // ExtensionRegistry. - void GenerateExtensionRegistrationCode(io::Printer* printer); - - private: - enum UseMemoization { - MEMOIZE, - DONT_MEMOIZE - }; - - void GenerateMessageSerializationMethods(io::Printer* printer); - void GenerateParseFromMethods(io::Printer* printer); - void GenerateSerializeOneField(io::Printer* printer, - const FieldDescriptor* field); - void GenerateSerializeOneExtensionRange( - io::Printer* printer, const Descriptor::ExtensionRange* range); - - void GenerateBuilder(io::Printer* printer); - void GenerateCommonBuilderMethods(io::Printer* printer); - void GenerateDescriptorMethods(io::Printer* printer); - void GenerateBuilderParsingMethods(io::Printer* printer); - void GenerateIsInitialized(io::Printer* printer, - UseMemoization useMemoization); - void GenerateEqualsAndHashCode(io::Printer* printer); - - void GenerateParser(io::Printer* printer); - void GenerateParsingConstructor(io::Printer* printer); - - const Descriptor* descriptor_; - FieldGeneratorMap field_generators_; - - GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(MessageGenerator); -}; - -} // namespace java -} // namespace compiler -} // namespace protobuf - -} // namespace google -#endif // GOOGLE_PROTOBUF_COMPILER_JAVA_MESSAGE_H__ diff --git a/modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/java/java_message_field.cc b/modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/java/java_message_field.cc deleted file mode 100644 index b0b284f76..000000000 --- a/modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/java/java_message_field.cc +++ /dev/null @@ -1,974 +0,0 @@ -// Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// http://code.google.com/p/protobuf/ -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -// Author: kenton@google.com (Kenton Varda) -// Based on original Protocol Buffers design by -// Sanjay Ghemawat, Jeff Dean, and others. - -#include -#include - -#include -#include -#include -#include -#include -#include - -namespace google { -namespace protobuf { -namespace compiler { -namespace java { - -namespace { - -// TODO(kenton): Factor out a "SetCommonFieldVariables()" to get rid of -// repeat code between this and the other field types. -void SetMessageVariables(const FieldDescriptor* descriptor, - int messageBitIndex, - int builderBitIndex, - map* variables) { - (*variables)["name"] = - UnderscoresToCamelCase(descriptor); - (*variables)["capitalized_name"] = - UnderscoresToCapitalizedCamelCase(descriptor); - (*variables)["constant_name"] = FieldConstantName(descriptor); - (*variables)["number"] = SimpleItoa(descriptor->number()); - (*variables)["type"] = ClassName(descriptor->message_type()); - (*variables)["group_or_message"] = - (GetType(descriptor) == FieldDescriptor::TYPE_GROUP) ? - "Group" : "Message"; - // TODO(birdo): Add @deprecated javadoc when generating javadoc is supported - // by the proto compiler - (*variables)["deprecation"] = descriptor->options().deprecated() - ? "@java.lang.Deprecated " : ""; - (*variables)["on_changed"] = - HasDescriptorMethods(descriptor->containing_type()) ? "onChanged();" : ""; - - // For singular messages and builders, one bit is used for the hasField bit. - (*variables)["get_has_field_bit_message"] = GenerateGetBit(messageBitIndex); - (*variables)["set_has_field_bit_message"] = GenerateSetBit(messageBitIndex); - - (*variables)["get_has_field_bit_builder"] = GenerateGetBit(builderBitIndex); - (*variables)["set_has_field_bit_builder"] = GenerateSetBit(builderBitIndex); - (*variables)["clear_has_field_bit_builder"] = - GenerateClearBit(builderBitIndex); - - // For repated builders, one bit is used for whether the array is immutable. - (*variables)["get_mutable_bit_builder"] = GenerateGetBit(builderBitIndex); - (*variables)["set_mutable_bit_builder"] = GenerateSetBit(builderBitIndex); - (*variables)["clear_mutable_bit_builder"] = GenerateClearBit(builderBitIndex); - - // For repeated fields, one bit is used for whether the array is immutable - // in the parsing constructor. - (*variables)["get_mutable_bit_parser"] = - GenerateGetBitMutableLocal(builderBitIndex); - (*variables)["set_mutable_bit_parser"] = - GenerateSetBitMutableLocal(builderBitIndex); - - (*variables)["get_has_field_bit_from_local"] = - GenerateGetBitFromLocal(builderBitIndex); - (*variables)["set_has_field_bit_to_local"] = - GenerateSetBitToLocal(messageBitIndex); -} - -} // namespace - -// =================================================================== - -MessageFieldGenerator:: -MessageFieldGenerator(const FieldDescriptor* descriptor, - int messageBitIndex, - int builderBitIndex) - : descriptor_(descriptor), messageBitIndex_(messageBitIndex), - builderBitIndex_(builderBitIndex) { - SetMessageVariables(descriptor, messageBitIndex, builderBitIndex, - &variables_); -} - -MessageFieldGenerator::~MessageFieldGenerator() {} - -int MessageFieldGenerator::GetNumBitsForMessage() const { - return 1; -} - -int MessageFieldGenerator::GetNumBitsForBuilder() const { - return 1; -} - -void MessageFieldGenerator:: -GenerateInterfaceMembers(io::Printer* printer) const { - // TODO(jonp): In the future, consider having a method specific to the - // interface so that builders can choose dynamically to either return a - // message or a nested builder, so that asking for the interface doesn't - // cause a message to ever be built. - WriteFieldDocComment(printer, descriptor_); - printer->Print(variables_, - "$deprecation$boolean has$capitalized_name$();\n"); - WriteFieldDocComment(printer, descriptor_); - printer->Print(variables_, - "$deprecation$$type$ get$capitalized_name$();\n"); - - if (HasNestedBuilders(descriptor_->containing_type())) { - WriteFieldDocComment(printer, descriptor_); - printer->Print(variables_, - "$deprecation$$type$OrBuilder get$capitalized_name$OrBuilder();\n"); - } -} - -void MessageFieldGenerator:: -GenerateMembers(io::Printer* printer) const { - printer->Print(variables_, - "private $type$ $name$_;\n"); - WriteFieldDocComment(printer, descriptor_); - printer->Print(variables_, - "$deprecation$public boolean has$capitalized_name$() {\n" - " return $get_has_field_bit_message$;\n" - "}\n"); - WriteFieldDocComment(printer, descriptor_); - printer->Print(variables_, - "$deprecation$public $type$ get$capitalized_name$() {\n" - " return $name$_;\n" - "}\n"); - - if (HasNestedBuilders(descriptor_->containing_type())) { - WriteFieldDocComment(printer, descriptor_); - printer->Print(variables_, - "$deprecation$public $type$OrBuilder get$capitalized_name$OrBuilder() {\n" - " return $name$_;\n" - "}\n"); - } -} - -void MessageFieldGenerator::PrintNestedBuilderCondition( - io::Printer* printer, - const char* regular_case, - const char* nested_builder_case) const { - if (HasNestedBuilders(descriptor_->containing_type())) { - printer->Print(variables_, "if ($name$Builder_ == null) {\n"); - printer->Indent(); - printer->Print(variables_, regular_case); - printer->Outdent(); - printer->Print("} else {\n"); - printer->Indent(); - printer->Print(variables_, nested_builder_case); - printer->Outdent(); - printer->Print("}\n"); - } else { - printer->Print(variables_, regular_case); - } -} - -void MessageFieldGenerator::PrintNestedBuilderFunction( - io::Printer* printer, - const char* method_prototype, - const char* regular_case, - const char* nested_builder_case, - const char* trailing_code) const { - printer->Print(variables_, method_prototype); - printer->Print(" {\n"); - printer->Indent(); - PrintNestedBuilderCondition(printer, regular_case, nested_builder_case); - if (trailing_code != NULL) { - printer->Print(variables_, trailing_code); - } - printer->Outdent(); - printer->Print("}\n"); -} - -void MessageFieldGenerator:: -GenerateBuilderMembers(io::Printer* printer) const { - // When using nested-builders, the code initially works just like the - // non-nested builder case. It only creates a nested builder lazily on - // demand and then forever delegates to it after creation. - - printer->Print(variables_, - // Used when the builder is null. - "private $type$ $name$_ = $type$.getDefaultInstance();\n"); - - if (HasNestedBuilders(descriptor_->containing_type())) { - printer->Print(variables_, - // If this builder is non-null, it is used and the other fields are - // ignored. - "private com.google.protobuf.SingleFieldBuilder<\n" - " $type$, $type$.Builder, $type$OrBuilder> $name$Builder_;" - "\n"); - } - - // The comments above the methods below are based on a hypothetical - // field of type "Field" called "Field". - - // boolean hasField() - WriteFieldDocComment(printer, descriptor_); - printer->Print(variables_, - "$deprecation$public boolean has$capitalized_name$() {\n" - " return $get_has_field_bit_builder$;\n" - "}\n"); - - // Field getField() - WriteFieldDocComment(printer, descriptor_); - PrintNestedBuilderFunction(printer, - "$deprecation$public $type$ get$capitalized_name$()", - - "return $name$_;\n", - - "return $name$Builder_.getMessage();\n", - - NULL); - - // Field.Builder setField(Field value) - WriteFieldDocComment(printer, descriptor_); - PrintNestedBuilderFunction(printer, - "$deprecation$public Builder set$capitalized_name$($type$ value)", - - "if (value == null) {\n" - " throw new NullPointerException();\n" - "}\n" - "$name$_ = value;\n" - "$on_changed$\n", - - "$name$Builder_.setMessage(value);\n", - - "$set_has_field_bit_builder$;\n" - "return this;\n"); - - // Field.Builder setField(Field.Builder builderForValue) - WriteFieldDocComment(printer, descriptor_); - PrintNestedBuilderFunction(printer, - "$deprecation$public Builder set$capitalized_name$(\n" - " $type$.Builder builderForValue)", - - "$name$_ = builderForValue.build();\n" - "$on_changed$\n", - - "$name$Builder_.setMessage(builderForValue.build());\n", - - "$set_has_field_bit_builder$;\n" - "return this;\n"); - - // Field.Builder mergeField(Field value) - WriteFieldDocComment(printer, descriptor_); - PrintNestedBuilderFunction(printer, - "$deprecation$public Builder merge$capitalized_name$($type$ value)", - - "if ($get_has_field_bit_builder$ &&\n" - " $name$_ != $type$.getDefaultInstance()) {\n" - " $name$_ =\n" - " $type$.newBuilder($name$_).mergeFrom(value).buildPartial();\n" - "} else {\n" - " $name$_ = value;\n" - "}\n" - "$on_changed$\n", - - "$name$Builder_.mergeFrom(value);\n", - - "$set_has_field_bit_builder$;\n" - "return this;\n"); - - // Field.Builder clearField() - WriteFieldDocComment(printer, descriptor_); - PrintNestedBuilderFunction(printer, - "$deprecation$public Builder clear$capitalized_name$()", - - "$name$_ = $type$.getDefaultInstance();\n" - "$on_changed$\n", - - "$name$Builder_.clear();\n", - - "$clear_has_field_bit_builder$;\n" - "return this;\n"); - - if (HasNestedBuilders(descriptor_->containing_type())) { - WriteFieldDocComment(printer, descriptor_); - printer->Print(variables_, - "$deprecation$public $type$.Builder get$capitalized_name$Builder() {\n" - " $set_has_field_bit_builder$;\n" - " $on_changed$\n" - " return get$capitalized_name$FieldBuilder().getBuilder();\n" - "}\n"); - WriteFieldDocComment(printer, descriptor_); - printer->Print(variables_, - "$deprecation$public $type$OrBuilder get$capitalized_name$OrBuilder() {\n" - " if ($name$Builder_ != null) {\n" - " return $name$Builder_.getMessageOrBuilder();\n" - " } else {\n" - " return $name$_;\n" - " }\n" - "}\n"); - WriteFieldDocComment(printer, descriptor_); - printer->Print(variables_, - "private com.google.protobuf.SingleFieldBuilder<\n" - " $type$, $type$.Builder, $type$OrBuilder> \n" - " get$capitalized_name$FieldBuilder() {\n" - " if ($name$Builder_ == null) {\n" - " $name$Builder_ = new com.google.protobuf.SingleFieldBuilder<\n" - " $type$, $type$.Builder, $type$OrBuilder>(\n" - " $name$_,\n" - " getParentForChildren(),\n" - " isClean());\n" - " $name$_ = null;\n" - " }\n" - " return $name$Builder_;\n" - "}\n"); - } -} - -void MessageFieldGenerator:: -GenerateFieldBuilderInitializationCode(io::Printer* printer) const { - printer->Print(variables_, - "get$capitalized_name$FieldBuilder();\n"); -} - - -void MessageFieldGenerator:: -GenerateInitializationCode(io::Printer* printer) const { - printer->Print(variables_, "$name$_ = $type$.getDefaultInstance();\n"); -} - -void MessageFieldGenerator:: -GenerateBuilderClearCode(io::Printer* printer) const { - PrintNestedBuilderCondition(printer, - "$name$_ = $type$.getDefaultInstance();\n", - - "$name$Builder_.clear();\n"); - printer->Print(variables_, "$clear_has_field_bit_builder$;\n"); -} - -void MessageFieldGenerator:: -GenerateMergingCode(io::Printer* printer) const { - printer->Print(variables_, - "if (other.has$capitalized_name$()) {\n" - " merge$capitalized_name$(other.get$capitalized_name$());\n" - "}\n"); -} - -void MessageFieldGenerator:: -GenerateBuildingCode(io::Printer* printer) const { - - printer->Print(variables_, - "if ($get_has_field_bit_from_local$) {\n" - " $set_has_field_bit_to_local$;\n" - "}\n"); - - PrintNestedBuilderCondition(printer, - "result.$name$_ = $name$_;\n", - - "result.$name$_ = $name$Builder_.build();\n"); -} - -void MessageFieldGenerator:: -GenerateParsingCode(io::Printer* printer) const { - printer->Print(variables_, - "$type$.Builder subBuilder = null;\n" - "if ($get_has_field_bit_message$) {\n" - " subBuilder = $name$_.toBuilder();\n" - "}\n"); - - if (GetType(descriptor_) == FieldDescriptor::TYPE_GROUP) { - printer->Print(variables_, - "$name$_ = input.readGroup($number$, $type$.PARSER,\n" - " extensionRegistry);\n"); - } else { - printer->Print(variables_, - "$name$_ = input.readMessage($type$.PARSER, extensionRegistry);\n"); - } - - printer->Print(variables_, - "if (subBuilder != null) {\n" - " subBuilder.mergeFrom($name$_);\n" - " $name$_ = subBuilder.buildPartial();\n" - "}\n"); - printer->Print(variables_, - "$set_has_field_bit_message$;\n"); -} - -void MessageFieldGenerator:: -GenerateParsingDoneCode(io::Printer* printer) const { - // noop for messages. -} - -void MessageFieldGenerator:: -GenerateSerializationCode(io::Printer* printer) const { - printer->Print(variables_, - "if ($get_has_field_bit_message$) {\n" - " output.write$group_or_message$($number$, $name$_);\n" - "}\n"); -} - -void MessageFieldGenerator:: -GenerateSerializedSizeCode(io::Printer* printer) const { - printer->Print(variables_, - "if ($get_has_field_bit_message$) {\n" - " size += com.google.protobuf.CodedOutputStream\n" - " .compute$group_or_message$Size($number$, $name$_);\n" - "}\n"); -} - -void MessageFieldGenerator:: -GenerateEqualsCode(io::Printer* printer) const { - printer->Print(variables_, - "result = result && get$capitalized_name$()\n" - " .equals(other.get$capitalized_name$());\n"); -} - -void MessageFieldGenerator:: -GenerateHashCode(io::Printer* printer) const { - printer->Print(variables_, - "hash = (37 * hash) + $constant_name$;\n" - "hash = (53 * hash) + get$capitalized_name$().hashCode();\n"); -} - -string MessageFieldGenerator::GetBoxedType() const { - return ClassName(descriptor_->message_type()); -} - -// =================================================================== - -RepeatedMessageFieldGenerator:: -RepeatedMessageFieldGenerator(const FieldDescriptor* descriptor, - int messageBitIndex, - int builderBitIndex) - : descriptor_(descriptor), messageBitIndex_(messageBitIndex), - builderBitIndex_(builderBitIndex) { - SetMessageVariables(descriptor, messageBitIndex, builderBitIndex, - &variables_); -} - -RepeatedMessageFieldGenerator::~RepeatedMessageFieldGenerator() {} - -int RepeatedMessageFieldGenerator::GetNumBitsForMessage() const { - return 0; -} - -int RepeatedMessageFieldGenerator::GetNumBitsForBuilder() const { - return 1; -} - -void RepeatedMessageFieldGenerator:: -GenerateInterfaceMembers(io::Printer* printer) const { - // TODO(jonp): In the future, consider having methods specific to the - // interface so that builders can choose dynamically to either return a - // message or a nested builder, so that asking for the interface doesn't - // cause a message to ever be built. - WriteFieldDocComment(printer, descriptor_); - printer->Print(variables_, - "$deprecation$java.util.List<$type$> \n" - " get$capitalized_name$List();\n"); - WriteFieldDocComment(printer, descriptor_); - printer->Print(variables_, - "$deprecation$$type$ get$capitalized_name$(int index);\n"); - WriteFieldDocComment(printer, descriptor_); - printer->Print(variables_, - "$deprecation$int get$capitalized_name$Count();\n"); - if (HasNestedBuilders(descriptor_->containing_type())) { - WriteFieldDocComment(printer, descriptor_); - printer->Print(variables_, - "$deprecation$java.util.List \n" - " get$capitalized_name$OrBuilderList();\n"); - WriteFieldDocComment(printer, descriptor_); - printer->Print(variables_, - "$deprecation$$type$OrBuilder get$capitalized_name$OrBuilder(\n" - " int index);\n"); - } -} - -void RepeatedMessageFieldGenerator:: -GenerateMembers(io::Printer* printer) const { - printer->Print(variables_, - "private java.util.List<$type$> $name$_;\n"); - WriteFieldDocComment(printer, descriptor_); - printer->Print(variables_, - "$deprecation$public java.util.List<$type$> get$capitalized_name$List() {\n" - " return $name$_;\n" // note: unmodifiable list - "}\n"); - WriteFieldDocComment(printer, descriptor_); - printer->Print(variables_, - "$deprecation$public java.util.List \n" - " get$capitalized_name$OrBuilderList() {\n" - " return $name$_;\n" - "}\n"); - WriteFieldDocComment(printer, descriptor_); - printer->Print(variables_, - "$deprecation$public int get$capitalized_name$Count() {\n" - " return $name$_.size();\n" - "}\n"); - WriteFieldDocComment(printer, descriptor_); - printer->Print(variables_, - "$deprecation$public $type$ get$capitalized_name$(int index) {\n" - " return $name$_.get(index);\n" - "}\n"); - WriteFieldDocComment(printer, descriptor_); - printer->Print(variables_, - "$deprecation$public $type$OrBuilder get$capitalized_name$OrBuilder(\n" - " int index) {\n" - " return $name$_.get(index);\n" - "}\n"); - -} - -void RepeatedMessageFieldGenerator::PrintNestedBuilderCondition( - io::Printer* printer, - const char* regular_case, - const char* nested_builder_case) const { - if (HasNestedBuilders(descriptor_->containing_type())) { - printer->Print(variables_, "if ($name$Builder_ == null) {\n"); - printer->Indent(); - printer->Print(variables_, regular_case); - printer->Outdent(); - printer->Print("} else {\n"); - printer->Indent(); - printer->Print(variables_, nested_builder_case); - printer->Outdent(); - printer->Print("}\n"); - } else { - printer->Print(variables_, regular_case); - } -} - -void RepeatedMessageFieldGenerator::PrintNestedBuilderFunction( - io::Printer* printer, - const char* method_prototype, - const char* regular_case, - const char* nested_builder_case, - const char* trailing_code) const { - printer->Print(variables_, method_prototype); - printer->Print(" {\n"); - printer->Indent(); - PrintNestedBuilderCondition(printer, regular_case, nested_builder_case); - if (trailing_code != NULL) { - printer->Print(variables_, trailing_code); - } - printer->Outdent(); - printer->Print("}\n"); -} - -void RepeatedMessageFieldGenerator:: -GenerateBuilderMembers(io::Printer* printer) const { - // When using nested-builders, the code initially works just like the - // non-nested builder case. It only creates a nested builder lazily on - // demand and then forever delegates to it after creation. - - printer->Print(variables_, - // Used when the builder is null. - // One field is the list and the other field keeps track of whether the - // list is immutable. If it's immutable, the invariant is that it must - // either an instance of Collections.emptyList() or it's an ArrayList - // wrapped in a Collections.unmodifiableList() wrapper and nobody else has - // a refererence to the underlying ArrayList. This invariant allows us to - // share instances of lists between protocol buffers avoiding expensive - // memory allocations. Note, immutable is a strong guarantee here -- not - // just that the list cannot be modified via the reference but that the - // list can never be modified. - "private java.util.List<$type$> $name$_ =\n" - " java.util.Collections.emptyList();\n" - - "private void ensure$capitalized_name$IsMutable() {\n" - " if (!$get_mutable_bit_builder$) {\n" - " $name$_ = new java.util.ArrayList<$type$>($name$_);\n" - " $set_mutable_bit_builder$;\n" - " }\n" - "}\n" - "\n"); - - if (HasNestedBuilders(descriptor_->containing_type())) { - printer->Print(variables_, - // If this builder is non-null, it is used and the other fields are - // ignored. - "private com.google.protobuf.RepeatedFieldBuilder<\n" - " $type$, $type$.Builder, $type$OrBuilder> $name$Builder_;\n" - "\n"); - } - - // The comments above the methods below are based on a hypothetical - // repeated field of type "Field" called "RepeatedField". - - // List getRepeatedFieldList() - WriteFieldDocComment(printer, descriptor_); - PrintNestedBuilderFunction(printer, - "$deprecation$public java.util.List<$type$> get$capitalized_name$List()", - - "return java.util.Collections.unmodifiableList($name$_);\n", - "return $name$Builder_.getMessageList();\n", - - NULL); - - // int getRepeatedFieldCount() - WriteFieldDocComment(printer, descriptor_); - PrintNestedBuilderFunction(printer, - "$deprecation$public int get$capitalized_name$Count()", - - "return $name$_.size();\n", - "return $name$Builder_.getCount();\n", - - NULL); - - // Field getRepeatedField(int index) - WriteFieldDocComment(printer, descriptor_); - PrintNestedBuilderFunction(printer, - "$deprecation$public $type$ get$capitalized_name$(int index)", - - "return $name$_.get(index);\n", - - "return $name$Builder_.getMessage(index);\n", - - NULL); - - // Builder setRepeatedField(int index, Field value) - WriteFieldDocComment(printer, descriptor_); - PrintNestedBuilderFunction(printer, - "$deprecation$public Builder set$capitalized_name$(\n" - " int index, $type$ value)", - "if (value == null) {\n" - " throw new NullPointerException();\n" - "}\n" - "ensure$capitalized_name$IsMutable();\n" - "$name$_.set(index, value);\n" - "$on_changed$\n", - "$name$Builder_.setMessage(index, value);\n", - "return this;\n"); - - // Builder setRepeatedField(int index, Field.Builder builderForValue) - WriteFieldDocComment(printer, descriptor_); - PrintNestedBuilderFunction(printer, - "$deprecation$public Builder set$capitalized_name$(\n" - " int index, $type$.Builder builderForValue)", - - "ensure$capitalized_name$IsMutable();\n" - "$name$_.set(index, builderForValue.build());\n" - "$on_changed$\n", - - "$name$Builder_.setMessage(index, builderForValue.build());\n", - - "return this;\n"); - - // Builder addRepeatedField(Field value) - WriteFieldDocComment(printer, descriptor_); - PrintNestedBuilderFunction(printer, - "$deprecation$public Builder add$capitalized_name$($type$ value)", - - "if (value == null) {\n" - " throw new NullPointerException();\n" - "}\n" - "ensure$capitalized_name$IsMutable();\n" - "$name$_.add(value);\n" - - "$on_changed$\n", - - "$name$Builder_.addMessage(value);\n", - - "return this;\n"); - - // Builder addRepeatedField(int index, Field value) - WriteFieldDocComment(printer, descriptor_); - PrintNestedBuilderFunction(printer, - "$deprecation$public Builder add$capitalized_name$(\n" - " int index, $type$ value)", - - "if (value == null) {\n" - " throw new NullPointerException();\n" - "}\n" - "ensure$capitalized_name$IsMutable();\n" - "$name$_.add(index, value);\n" - "$on_changed$\n", - - "$name$Builder_.addMessage(index, value);\n", - - "return this;\n"); - - // Builder addRepeatedField(Field.Builder builderForValue) - WriteFieldDocComment(printer, descriptor_); - PrintNestedBuilderFunction(printer, - "$deprecation$public Builder add$capitalized_name$(\n" - " $type$.Builder builderForValue)", - - "ensure$capitalized_name$IsMutable();\n" - "$name$_.add(builderForValue.build());\n" - "$on_changed$\n", - - "$name$Builder_.addMessage(builderForValue.build());\n", - - "return this;\n"); - - // Builder addRepeatedField(int index, Field.Builder builderForValue) - WriteFieldDocComment(printer, descriptor_); - PrintNestedBuilderFunction(printer, - "$deprecation$public Builder add$capitalized_name$(\n" - " int index, $type$.Builder builderForValue)", - - "ensure$capitalized_name$IsMutable();\n" - "$name$_.add(index, builderForValue.build());\n" - "$on_changed$\n", - - "$name$Builder_.addMessage(index, builderForValue.build());\n", - - "return this;\n"); - - // Builder addAllRepeatedField(Iterable values) - WriteFieldDocComment(printer, descriptor_); - PrintNestedBuilderFunction(printer, - "$deprecation$public Builder addAll$capitalized_name$(\n" - " java.lang.Iterable values)", - - "ensure$capitalized_name$IsMutable();\n" - "super.addAll(values, $name$_);\n" - "$on_changed$\n", - - "$name$Builder_.addAllMessages(values);\n", - - "return this;\n"); - - // Builder clearAllRepeatedField() - WriteFieldDocComment(printer, descriptor_); - PrintNestedBuilderFunction(printer, - "$deprecation$public Builder clear$capitalized_name$()", - - "$name$_ = java.util.Collections.emptyList();\n" - "$clear_mutable_bit_builder$;\n" - "$on_changed$\n", - - "$name$Builder_.clear();\n", - - "return this;\n"); - - // Builder removeRepeatedField(int index) - WriteFieldDocComment(printer, descriptor_); - PrintNestedBuilderFunction(printer, - "$deprecation$public Builder remove$capitalized_name$(int index)", - - "ensure$capitalized_name$IsMutable();\n" - "$name$_.remove(index);\n" - "$on_changed$\n", - - "$name$Builder_.remove(index);\n", - - "return this;\n"); - - if (HasNestedBuilders(descriptor_->containing_type())) { - WriteFieldDocComment(printer, descriptor_); - printer->Print(variables_, - "$deprecation$public $type$.Builder get$capitalized_name$Builder(\n" - " int index) {\n" - " return get$capitalized_name$FieldBuilder().getBuilder(index);\n" - "}\n"); - - WriteFieldDocComment(printer, descriptor_); - printer->Print(variables_, - "$deprecation$public $type$OrBuilder get$capitalized_name$OrBuilder(\n" - " int index) {\n" - " if ($name$Builder_ == null) {\n" - " return $name$_.get(index);" - " } else {\n" - " return $name$Builder_.getMessageOrBuilder(index);\n" - " }\n" - "}\n"); - - WriteFieldDocComment(printer, descriptor_); - printer->Print(variables_, - "$deprecation$public java.util.List \n" - " get$capitalized_name$OrBuilderList() {\n" - " if ($name$Builder_ != null) {\n" - " return $name$Builder_.getMessageOrBuilderList();\n" - " } else {\n" - " return java.util.Collections.unmodifiableList($name$_);\n" - " }\n" - "}\n"); - - WriteFieldDocComment(printer, descriptor_); - printer->Print(variables_, - "$deprecation$public $type$.Builder add$capitalized_name$Builder() {\n" - " return get$capitalized_name$FieldBuilder().addBuilder(\n" - " $type$.getDefaultInstance());\n" - "}\n"); - WriteFieldDocComment(printer, descriptor_); - printer->Print(variables_, - "$deprecation$public $type$.Builder add$capitalized_name$Builder(\n" - " int index) {\n" - " return get$capitalized_name$FieldBuilder().addBuilder(\n" - " index, $type$.getDefaultInstance());\n" - "}\n"); - WriteFieldDocComment(printer, descriptor_); - printer->Print(variables_, - "$deprecation$public java.util.List<$type$.Builder> \n" - " get$capitalized_name$BuilderList() {\n" - " return get$capitalized_name$FieldBuilder().getBuilderList();\n" - "}\n" - "private com.google.protobuf.RepeatedFieldBuilder<\n" - " $type$, $type$.Builder, $type$OrBuilder> \n" - " get$capitalized_name$FieldBuilder() {\n" - " if ($name$Builder_ == null) {\n" - " $name$Builder_ = new com.google.protobuf.RepeatedFieldBuilder<\n" - " $type$, $type$.Builder, $type$OrBuilder>(\n" - " $name$_,\n" - " $get_mutable_bit_builder$,\n" - " getParentForChildren(),\n" - " isClean());\n" - " $name$_ = null;\n" - " }\n" - " return $name$Builder_;\n" - "}\n"); - } -} - -void RepeatedMessageFieldGenerator:: -GenerateFieldBuilderInitializationCode(io::Printer* printer) const { - printer->Print(variables_, - "get$capitalized_name$FieldBuilder();\n"); -} - -void RepeatedMessageFieldGenerator:: -GenerateInitializationCode(io::Printer* printer) const { - printer->Print(variables_, "$name$_ = java.util.Collections.emptyList();\n"); -} - -void RepeatedMessageFieldGenerator:: -GenerateBuilderClearCode(io::Printer* printer) const { - PrintNestedBuilderCondition(printer, - "$name$_ = java.util.Collections.emptyList();\n" - "$clear_mutable_bit_builder$;\n", - - "$name$Builder_.clear();\n"); -} - -void RepeatedMessageFieldGenerator:: -GenerateMergingCode(io::Printer* printer) const { - // The code below does two optimizations (non-nested builder case): - // 1. If the other list is empty, there's nothing to do. This ensures we - // don't allocate a new array if we already have an immutable one. - // 2. If the other list is non-empty and our current list is empty, we can - // reuse the other list which is guaranteed to be immutable. - PrintNestedBuilderCondition(printer, - "if (!other.$name$_.isEmpty()) {\n" - " if ($name$_.isEmpty()) {\n" - " $name$_ = other.$name$_;\n" - " $clear_mutable_bit_builder$;\n" - " } else {\n" - " ensure$capitalized_name$IsMutable();\n" - " $name$_.addAll(other.$name$_);\n" - " }\n" - " $on_changed$\n" - "}\n", - - "if (!other.$name$_.isEmpty()) {\n" - " if ($name$Builder_.isEmpty()) {\n" - " $name$Builder_.dispose();\n" - " $name$Builder_ = null;\n" - " $name$_ = other.$name$_;\n" - " $clear_mutable_bit_builder$;\n" - " $name$Builder_ = \n" - " com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders ?\n" - " get$capitalized_name$FieldBuilder() : null;\n" - " } else {\n" - " $name$Builder_.addAllMessages(other.$name$_);\n" - " }\n" - "}\n"); -} - -void RepeatedMessageFieldGenerator:: -GenerateBuildingCode(io::Printer* printer) const { - // The code below (non-nested builder case) ensures that the result has an - // immutable list. If our list is immutable, we can just reuse it. If not, - // we make it immutable. - PrintNestedBuilderCondition(printer, - "if ($get_mutable_bit_builder$) {\n" - " $name$_ = java.util.Collections.unmodifiableList($name$_);\n" - " $clear_mutable_bit_builder$;\n" - "}\n" - "result.$name$_ = $name$_;\n", - - "result.$name$_ = $name$Builder_.build();\n"); -} - -void RepeatedMessageFieldGenerator:: -GenerateParsingCode(io::Printer* printer) const { - printer->Print(variables_, - "if (!$get_mutable_bit_parser$) {\n" - " $name$_ = new java.util.ArrayList<$type$>();\n" - " $set_mutable_bit_parser$;\n" - "}\n"); - - if (GetType(descriptor_) == FieldDescriptor::TYPE_GROUP) { - printer->Print(variables_, - "$name$_.add(input.readGroup($number$, $type$.PARSER,\n" - " extensionRegistry));\n"); - } else { - printer->Print(variables_, - "$name$_.add(input.readMessage($type$.PARSER, extensionRegistry));\n"); - } -} - -void RepeatedMessageFieldGenerator:: -GenerateParsingDoneCode(io::Printer* printer) const { - printer->Print(variables_, - "if ($get_mutable_bit_parser$) {\n" - " $name$_ = java.util.Collections.unmodifiableList($name$_);\n" - "}\n"); -} - -void RepeatedMessageFieldGenerator:: -GenerateSerializationCode(io::Printer* printer) const { - printer->Print(variables_, - "for (int i = 0; i < $name$_.size(); i++) {\n" - " output.write$group_or_message$($number$, $name$_.get(i));\n" - "}\n"); -} - -void RepeatedMessageFieldGenerator:: -GenerateSerializedSizeCode(io::Printer* printer) const { - printer->Print(variables_, - "for (int i = 0; i < $name$_.size(); i++) {\n" - " size += com.google.protobuf.CodedOutputStream\n" - " .compute$group_or_message$Size($number$, $name$_.get(i));\n" - "}\n"); -} - -void RepeatedMessageFieldGenerator:: -GenerateEqualsCode(io::Printer* printer) const { - printer->Print(variables_, - "result = result && get$capitalized_name$List()\n" - " .equals(other.get$capitalized_name$List());\n"); -} - -void RepeatedMessageFieldGenerator:: -GenerateHashCode(io::Printer* printer) const { - printer->Print(variables_, - "if (get$capitalized_name$Count() > 0) {\n" - " hash = (37 * hash) + $constant_name$;\n" - " hash = (53 * hash) + get$capitalized_name$List().hashCode();\n" - "}\n"); -} - -string RepeatedMessageFieldGenerator::GetBoxedType() const { - return ClassName(descriptor_->message_type()); -} - -} // namespace java -} // namespace compiler -} // namespace protobuf -} // namespace google diff --git a/modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/java/java_message_field.h b/modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/java/java_message_field.h deleted file mode 100644 index 5c8078a15..000000000 --- a/modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/java/java_message_field.h +++ /dev/null @@ -1,136 +0,0 @@ -// Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// http://code.google.com/p/protobuf/ -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -// Author: kenton@google.com (Kenton Varda) -// Based on original Protocol Buffers design by -// Sanjay Ghemawat, Jeff Dean, and others. - -#ifndef GOOGLE_PROTOBUF_COMPILER_JAVA_MESSAGE_FIELD_H__ -#define GOOGLE_PROTOBUF_COMPILER_JAVA_MESSAGE_FIELD_H__ - -#include -#include -#include - -namespace google { -namespace protobuf { -namespace compiler { -namespace java { - -class MessageFieldGenerator : public FieldGenerator { - public: - explicit MessageFieldGenerator(const FieldDescriptor* descriptor, - int messageBitIndex, int builderBitIndex); - ~MessageFieldGenerator(); - - // implements FieldGenerator --------------------------------------- - int GetNumBitsForMessage() const; - int GetNumBitsForBuilder() const; - void GenerateInterfaceMembers(io::Printer* printer) const; - void GenerateMembers(io::Printer* printer) const; - void GenerateBuilderMembers(io::Printer* printer) const; - void GenerateInitializationCode(io::Printer* printer) const; - void GenerateBuilderClearCode(io::Printer* printer) const; - void GenerateMergingCode(io::Printer* printer) const; - void GenerateBuildingCode(io::Printer* printer) const; - void GenerateParsingCode(io::Printer* printer) const; - void GenerateParsingDoneCode(io::Printer* printer) const; - void GenerateSerializationCode(io::Printer* printer) const; - void GenerateSerializedSizeCode(io::Printer* printer) const; - void GenerateFieldBuilderInitializationCode(io::Printer* printer) const; - void GenerateEqualsCode(io::Printer* printer) const; - void GenerateHashCode(io::Printer* printer) const; - - string GetBoxedType() const; - - private: - const FieldDescriptor* descriptor_; - map variables_; - const int messageBitIndex_; - const int builderBitIndex_; - - GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(MessageFieldGenerator); - - void PrintNestedBuilderCondition(io::Printer* printer, - const char* regular_case, const char* nested_builder_case) const; - void PrintNestedBuilderFunction(io::Printer* printer, - const char* method_prototype, const char* regular_case, - const char* nested_builder_case, - const char* trailing_code) const; -}; - -class RepeatedMessageFieldGenerator : public FieldGenerator { - public: - explicit RepeatedMessageFieldGenerator(const FieldDescriptor* descriptor, - int messageBitIndex, int builderBitIndex); - ~RepeatedMessageFieldGenerator(); - - // implements FieldGenerator --------------------------------------- - int GetNumBitsForMessage() const; - int GetNumBitsForBuilder() const; - void GenerateInterfaceMembers(io::Printer* printer) const; - void GenerateMembers(io::Printer* printer) const; - void GenerateBuilderMembers(io::Printer* printer) const; - void GenerateInitializationCode(io::Printer* printer) const; - void GenerateBuilderClearCode(io::Printer* printer) const; - void GenerateMergingCode(io::Printer* printer) const; - void GenerateBuildingCode(io::Printer* printer) const; - void GenerateParsingCode(io::Printer* printer) const; - void GenerateParsingDoneCode(io::Printer* printer) const; - void GenerateSerializationCode(io::Printer* printer) const; - void GenerateSerializedSizeCode(io::Printer* printer) const; - void GenerateFieldBuilderInitializationCode(io::Printer* printer) const; - void GenerateEqualsCode(io::Printer* printer) const; - void GenerateHashCode(io::Printer* printer) const; - - string GetBoxedType() const; - - private: - const FieldDescriptor* descriptor_; - map variables_; - const int messageBitIndex_; - const int builderBitIndex_; - - GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(RepeatedMessageFieldGenerator); - - void PrintNestedBuilderCondition(io::Printer* printer, - const char* regular_case, const char* nested_builder_case) const; - void PrintNestedBuilderFunction(io::Printer* printer, - const char* method_prototype, const char* regular_case, - const char* nested_builder_case, - const char* trailing_code) const; -}; - -} // namespace java -} // namespace compiler -} // namespace protobuf - -} // namespace google -#endif // GOOGLE_PROTOBUF_COMPILER_JAVA_MESSAGE_FIELD_H__ diff --git a/modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/java/java_plugin_unittest.cc b/modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/java/java_plugin_unittest.cc deleted file mode 100644 index ccc94c9df..000000000 --- a/modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/java/java_plugin_unittest.cc +++ /dev/null @@ -1,122 +0,0 @@ -// Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// http://code.google.com/p/protobuf/ -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -// Author: kenton@google.com (Kenton Varda) -// -// TODO(kenton): Share code with the versions of this test in other languages? -// It seemed like parameterizing it would add more complexity than it is -// worth. - -#include -#include -#include -#include - -#include -#include -#include - -namespace google { -namespace protobuf { -namespace compiler { -namespace java { -namespace { - -class TestGenerator : public CodeGenerator { - public: - TestGenerator() {} - ~TestGenerator() {} - - virtual bool Generate(const FileDescriptor* file, - const string& parameter, - GeneratorContext* context, - string* error) const { - string filename = "Test.java"; - TryInsert(filename, "outer_class_scope", context); - TryInsert(filename, "class_scope:foo.Bar", context); - TryInsert(filename, "class_scope:foo.Bar.Baz", context); - TryInsert(filename, "builder_scope:foo.Bar", context); - TryInsert(filename, "builder_scope:foo.Bar.Baz", context); - TryInsert(filename, "enum_scope:foo.Qux", context); - return true; - } - - void TryInsert(const string& filename, const string& insertion_point, - GeneratorContext* context) const { - scoped_ptr output( - context->OpenForInsert(filename, insertion_point)); - io::Printer printer(output.get(), '$'); - printer.Print("// inserted $name$\n", "name", insertion_point); - } -}; - -// This test verifies that all the expected insertion points exist. It does -// not verify that they are correctly-placed; that would require actually -// compiling the output which is a bit more than I care to do for this test. -TEST(JavaPluginTest, PluginTest) { - File::WriteStringToFileOrDie( - "syntax = \"proto2\";\n" - "package foo;\n" - "option java_package = \"\";\n" - "option java_outer_classname = \"Test\";\n" - "message Bar {\n" - " message Baz {}\n" - "}\n" - "enum Qux { BLAH = 1; }\n", - TestTempDir() + "/test.proto"); - - google::protobuf::compiler::CommandLineInterface cli; - cli.SetInputsAreProtoPathRelative(true); - - JavaGenerator java_generator; - TestGenerator test_generator; - cli.RegisterGenerator("--java_out", &java_generator, ""); - cli.RegisterGenerator("--test_out", &test_generator, ""); - - string proto_path = "-I" + TestTempDir(); - string java_out = "--java_out=" + TestTempDir(); - string test_out = "--test_out=" + TestTempDir(); - - const char* argv[] = { - "protoc", - proto_path.c_str(), - java_out.c_str(), - test_out.c_str(), - "test.proto" - }; - - EXPECT_EQ(0, cli.Run(5, argv)); -} - -} // namespace -} // namespace java -} // namespace compiler -} // namespace protobuf -} // namespace google diff --git a/modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/java/java_primitive_field.cc b/modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/java/java_primitive_field.cc deleted file mode 100644 index 0140e23f8..000000000 --- a/modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/java/java_primitive_field.cc +++ /dev/null @@ -1,787 +0,0 @@ -// Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// http://code.google.com/p/protobuf/ -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -// Author: kenton@google.com (Kenton Varda) -// Based on original Protocol Buffers design by -// Sanjay Ghemawat, Jeff Dean, and others. - -#include -#include - -#include -#include -#include -#include -#include -#include -#include - -namespace google { -namespace protobuf { -namespace compiler { -namespace java { - -using internal::WireFormat; -using internal::WireFormatLite; - -namespace { - -const char* PrimitiveTypeName(JavaType type) { - switch (type) { - case JAVATYPE_INT : return "int"; - case JAVATYPE_LONG : return "long"; - case JAVATYPE_FLOAT : return "float"; - case JAVATYPE_DOUBLE : return "double"; - case JAVATYPE_BOOLEAN: return "boolean"; - case JAVATYPE_STRING : return "java.lang.String"; - case JAVATYPE_BYTES : return "com.google.protobuf.ByteString"; - case JAVATYPE_ENUM : return NULL; - case JAVATYPE_MESSAGE: return NULL; - - // No default because we want the compiler to complain if any new - // JavaTypes are added. - } - - GOOGLE_LOG(FATAL) << "Can't get here."; - return NULL; -} - -bool IsReferenceType(JavaType type) { - switch (type) { - case JAVATYPE_INT : return false; - case JAVATYPE_LONG : return false; - case JAVATYPE_FLOAT : return false; - case JAVATYPE_DOUBLE : return false; - case JAVATYPE_BOOLEAN: return false; - case JAVATYPE_STRING : return true; - case JAVATYPE_BYTES : return true; - case JAVATYPE_ENUM : return true; - case JAVATYPE_MESSAGE: return true; - - // No default because we want the compiler to complain if any new - // JavaTypes are added. - } - - GOOGLE_LOG(FATAL) << "Can't get here."; - return false; -} - -const char* GetCapitalizedType(const FieldDescriptor* field) { - switch (GetType(field)) { - case FieldDescriptor::TYPE_INT32 : return "Int32" ; - case FieldDescriptor::TYPE_UINT32 : return "UInt32" ; - case FieldDescriptor::TYPE_SINT32 : return "SInt32" ; - case FieldDescriptor::TYPE_FIXED32 : return "Fixed32" ; - case FieldDescriptor::TYPE_SFIXED32: return "SFixed32"; - case FieldDescriptor::TYPE_INT64 : return "Int64" ; - case FieldDescriptor::TYPE_UINT64 : return "UInt64" ; - case FieldDescriptor::TYPE_SINT64 : return "SInt64" ; - case FieldDescriptor::TYPE_FIXED64 : return "Fixed64" ; - case FieldDescriptor::TYPE_SFIXED64: return "SFixed64"; - case FieldDescriptor::TYPE_FLOAT : return "Float" ; - case FieldDescriptor::TYPE_DOUBLE : return "Double" ; - case FieldDescriptor::TYPE_BOOL : return "Bool" ; - case FieldDescriptor::TYPE_STRING : return "String" ; - case FieldDescriptor::TYPE_BYTES : return "Bytes" ; - case FieldDescriptor::TYPE_ENUM : return "Enum" ; - case FieldDescriptor::TYPE_GROUP : return "Group" ; - case FieldDescriptor::TYPE_MESSAGE : return "Message" ; - - // No default because we want the compiler to complain if any new - // types are added. - } - - GOOGLE_LOG(FATAL) << "Can't get here."; - return NULL; -} - -// For encodings with fixed sizes, returns that size in bytes. Otherwise -// returns -1. -int FixedSize(FieldDescriptor::Type type) { - switch (type) { - case FieldDescriptor::TYPE_INT32 : return -1; - case FieldDescriptor::TYPE_INT64 : return -1; - case FieldDescriptor::TYPE_UINT32 : return -1; - case FieldDescriptor::TYPE_UINT64 : return -1; - case FieldDescriptor::TYPE_SINT32 : return -1; - case FieldDescriptor::TYPE_SINT64 : return -1; - case FieldDescriptor::TYPE_FIXED32 : return WireFormatLite::kFixed32Size; - case FieldDescriptor::TYPE_FIXED64 : return WireFormatLite::kFixed64Size; - case FieldDescriptor::TYPE_SFIXED32: return WireFormatLite::kSFixed32Size; - case FieldDescriptor::TYPE_SFIXED64: return WireFormatLite::kSFixed64Size; - case FieldDescriptor::TYPE_FLOAT : return WireFormatLite::kFloatSize; - case FieldDescriptor::TYPE_DOUBLE : return WireFormatLite::kDoubleSize; - - case FieldDescriptor::TYPE_BOOL : return WireFormatLite::kBoolSize; - case FieldDescriptor::TYPE_ENUM : return -1; - - case FieldDescriptor::TYPE_STRING : return -1; - case FieldDescriptor::TYPE_BYTES : return -1; - case FieldDescriptor::TYPE_GROUP : return -1; - case FieldDescriptor::TYPE_MESSAGE : return -1; - - // No default because we want the compiler to complain if any new - // types are added. - } - GOOGLE_LOG(FATAL) << "Can't get here."; - return -1; -} - -void SetPrimitiveVariables(const FieldDescriptor* descriptor, - int messageBitIndex, - int builderBitIndex, - map* variables) { - (*variables)["name"] = - UnderscoresToCamelCase(descriptor); - (*variables)["capitalized_name"] = - UnderscoresToCapitalizedCamelCase(descriptor); - (*variables)["constant_name"] = FieldConstantName(descriptor); - (*variables)["number"] = SimpleItoa(descriptor->number()); - (*variables)["type"] = PrimitiveTypeName(GetJavaType(descriptor)); - (*variables)["boxed_type"] = BoxedPrimitiveTypeName(GetJavaType(descriptor)); - (*variables)["field_type"] = (*variables)["type"]; - (*variables)["field_list_type"] = "java.util.List<" + - (*variables)["boxed_type"] + ">"; - (*variables)["empty_list"] = "java.util.Collections.emptyList()"; - (*variables)["default"] = DefaultValue(descriptor); - (*variables)["default_init"] = IsDefaultValueJavaDefault(descriptor) ? - "" : ("= " + DefaultValue(descriptor)); - (*variables)["capitalized_type"] = GetCapitalizedType(descriptor); - (*variables)["tag"] = SimpleItoa(WireFormat::MakeTag(descriptor)); - (*variables)["tag_size"] = SimpleItoa( - WireFormat::TagSize(descriptor->number(), GetType(descriptor))); - if (IsReferenceType(GetJavaType(descriptor))) { - (*variables)["null_check"] = - " if (value == null) {\n" - " throw new NullPointerException();\n" - " }\n"; - } else { - (*variables)["null_check"] = ""; - } - // TODO(birdo): Add @deprecated javadoc when generating javadoc is supported - // by the proto compiler - (*variables)["deprecation"] = descriptor->options().deprecated() - ? "@java.lang.Deprecated " : ""; - int fixed_size = FixedSize(GetType(descriptor)); - if (fixed_size != -1) { - (*variables)["fixed_size"] = SimpleItoa(fixed_size); - } - (*variables)["on_changed"] = - HasDescriptorMethods(descriptor->containing_type()) ? "onChanged();" : ""; - - // For singular messages and builders, one bit is used for the hasField bit. - (*variables)["get_has_field_bit_message"] = GenerateGetBit(messageBitIndex); - (*variables)["set_has_field_bit_message"] = GenerateSetBit(messageBitIndex); - - (*variables)["get_has_field_bit_builder"] = GenerateGetBit(builderBitIndex); - (*variables)["set_has_field_bit_builder"] = GenerateSetBit(builderBitIndex); - (*variables)["clear_has_field_bit_builder"] = - GenerateClearBit(builderBitIndex); - - // For repated builders, one bit is used for whether the array is immutable. - (*variables)["get_mutable_bit_builder"] = GenerateGetBit(builderBitIndex); - (*variables)["set_mutable_bit_builder"] = GenerateSetBit(builderBitIndex); - (*variables)["clear_mutable_bit_builder"] = GenerateClearBit(builderBitIndex); - - // For repeated fields, one bit is used for whether the array is immutable - // in the parsing constructor. - (*variables)["get_mutable_bit_parser"] = - GenerateGetBitMutableLocal(builderBitIndex); - (*variables)["set_mutable_bit_parser"] = - GenerateSetBitMutableLocal(builderBitIndex); - - (*variables)["get_has_field_bit_from_local"] = - GenerateGetBitFromLocal(builderBitIndex); - (*variables)["set_has_field_bit_to_local"] = - GenerateSetBitToLocal(messageBitIndex); -} - -} // namespace - -// =================================================================== - -PrimitiveFieldGenerator:: -PrimitiveFieldGenerator(const FieldDescriptor* descriptor, - int messageBitIndex, - int builderBitIndex) - : descriptor_(descriptor), messageBitIndex_(messageBitIndex), - builderBitIndex_(builderBitIndex) { - SetPrimitiveVariables(descriptor, messageBitIndex, builderBitIndex, - &variables_); -} - -PrimitiveFieldGenerator::~PrimitiveFieldGenerator() {} - -int PrimitiveFieldGenerator::GetNumBitsForMessage() const { - return 1; -} - -int PrimitiveFieldGenerator::GetNumBitsForBuilder() const { - return 1; -} - -void PrimitiveFieldGenerator:: -GenerateInterfaceMembers(io::Printer* printer) const { - WriteFieldDocComment(printer, descriptor_); - printer->Print(variables_, - "$deprecation$boolean has$capitalized_name$();\n"); - WriteFieldDocComment(printer, descriptor_); - printer->Print(variables_, - "$deprecation$$type$ get$capitalized_name$();\n"); -} - -void PrimitiveFieldGenerator:: -GenerateMembers(io::Printer* printer) const { - printer->Print(variables_, - "private $field_type$ $name$_;\n"); - - WriteFieldDocComment(printer, descriptor_); - printer->Print(variables_, - "$deprecation$public boolean has$capitalized_name$() {\n" - " return $get_has_field_bit_message$;\n" - "}\n"); - - WriteFieldDocComment(printer, descriptor_); - printer->Print(variables_, - "$deprecation$public $type$ get$capitalized_name$() {\n" - " return $name$_;\n" - "}\n"); -} - -void PrimitiveFieldGenerator:: -GenerateBuilderMembers(io::Printer* printer) const { - printer->Print(variables_, - "private $field_type$ $name$_ $default_init$;\n"); - - WriteFieldDocComment(printer, descriptor_); - printer->Print(variables_, - "$deprecation$public boolean has$capitalized_name$() {\n" - " return $get_has_field_bit_builder$;\n" - "}\n"); - - WriteFieldDocComment(printer, descriptor_); - printer->Print(variables_, - "$deprecation$public $type$ get$capitalized_name$() {\n" - " return $name$_;\n" - "}\n"); - - WriteFieldDocComment(printer, descriptor_); - printer->Print(variables_, - "$deprecation$public Builder set$capitalized_name$($type$ value) {\n" - "$null_check$" - " $set_has_field_bit_builder$;\n" - " $name$_ = value;\n" - " $on_changed$\n" - " return this;\n" - "}\n"); - - WriteFieldDocComment(printer, descriptor_); - printer->Print(variables_, - "$deprecation$public Builder clear$capitalized_name$() {\n" - " $clear_has_field_bit_builder$;\n"); - JavaType type = GetJavaType(descriptor_); - if (type == JAVATYPE_STRING || type == JAVATYPE_BYTES) { - // The default value is not a simple literal so we want to avoid executing - // it multiple times. Instead, get the default out of the default instance. - printer->Print(variables_, - " $name$_ = getDefaultInstance().get$capitalized_name$();\n"); - } else { - printer->Print(variables_, - " $name$_ = $default$;\n"); - } - printer->Print(variables_, - " $on_changed$\n" - " return this;\n" - "}\n"); -} - -void PrimitiveFieldGenerator:: -GenerateFieldBuilderInitializationCode(io::Printer* printer) const { - // noop for primitives -} - -void PrimitiveFieldGenerator:: -GenerateInitializationCode(io::Printer* printer) const { - printer->Print(variables_, "$name$_ = $default$;\n"); -} - -void PrimitiveFieldGenerator:: -GenerateBuilderClearCode(io::Printer* printer) const { - printer->Print(variables_, - "$name$_ = $default$;\n" - "$clear_has_field_bit_builder$;\n"); -} - -void PrimitiveFieldGenerator:: -GenerateMergingCode(io::Printer* printer) const { - printer->Print(variables_, - "if (other.has$capitalized_name$()) {\n" - " set$capitalized_name$(other.get$capitalized_name$());\n" - "}\n"); -} - -void PrimitiveFieldGenerator:: -GenerateBuildingCode(io::Printer* printer) const { - printer->Print(variables_, - "if ($get_has_field_bit_from_local$) {\n" - " $set_has_field_bit_to_local$;\n" - "}\n" - "result.$name$_ = $name$_;\n"); -} - -void PrimitiveFieldGenerator:: -GenerateParsingCode(io::Printer* printer) const { - printer->Print(variables_, - "$set_has_field_bit_message$;\n" - "$name$_ = input.read$capitalized_type$();\n"); -} - -void PrimitiveFieldGenerator:: -GenerateParsingDoneCode(io::Printer* printer) const { - // noop for primitives. -} - -void PrimitiveFieldGenerator:: -GenerateSerializationCode(io::Printer* printer) const { - printer->Print(variables_, - "if ($get_has_field_bit_message$) {\n" - " output.write$capitalized_type$($number$, $name$_);\n" - "}\n"); -} - -void PrimitiveFieldGenerator:: -GenerateSerializedSizeCode(io::Printer* printer) const { - printer->Print(variables_, - "if ($get_has_field_bit_message$) {\n" - " size += com.google.protobuf.CodedOutputStream\n" - " .compute$capitalized_type$Size($number$, $name$_);\n" - "}\n"); -} - -void PrimitiveFieldGenerator:: -GenerateEqualsCode(io::Printer* printer) const { - switch (GetJavaType(descriptor_)) { - case JAVATYPE_INT: - case JAVATYPE_LONG: - case JAVATYPE_BOOLEAN: - printer->Print(variables_, - "result = result && (get$capitalized_name$()\n" - " == other.get$capitalized_name$());\n"); - break; - - case JAVATYPE_FLOAT: - printer->Print(variables_, - "result = result && (Float.floatToIntBits(get$capitalized_name$())" - " == Float.floatToIntBits(other.get$capitalized_name$()));\n"); - break; - - case JAVATYPE_DOUBLE: - printer->Print(variables_, - "result = result && (Double.doubleToLongBits(get$capitalized_name$())" - " == Double.doubleToLongBits(other.get$capitalized_name$()));\n"); - break; - - case JAVATYPE_STRING: - case JAVATYPE_BYTES: - printer->Print(variables_, - "result = result && get$capitalized_name$()\n" - " .equals(other.get$capitalized_name$());\n"); - break; - - case JAVATYPE_ENUM: - case JAVATYPE_MESSAGE: - default: - GOOGLE_LOG(FATAL) << "Can't get here."; - break; - } -} - -void PrimitiveFieldGenerator:: -GenerateHashCode(io::Printer* printer) const { - printer->Print(variables_, - "hash = (37 * hash) + $constant_name$;\n"); - switch (GetJavaType(descriptor_)) { - case JAVATYPE_INT: - printer->Print(variables_, - "hash = (53 * hash) + get$capitalized_name$();\n"); - break; - - case JAVATYPE_LONG: - printer->Print(variables_, - "hash = (53 * hash) + hashLong(get$capitalized_name$());\n"); - break; - - case JAVATYPE_BOOLEAN: - printer->Print(variables_, - "hash = (53 * hash) + hashBoolean(get$capitalized_name$());\n"); - break; - - case JAVATYPE_FLOAT: - printer->Print(variables_, - "hash = (53 * hash) + Float.floatToIntBits(\n" - " get$capitalized_name$());\n"); - break; - - case JAVATYPE_DOUBLE: - printer->Print(variables_, - "hash = (53 * hash) + hashLong(\n" - " Double.doubleToLongBits(get$capitalized_name$()));\n"); - break; - - case JAVATYPE_STRING: - case JAVATYPE_BYTES: - printer->Print(variables_, - "hash = (53 * hash) + get$capitalized_name$().hashCode();\n"); - break; - - case JAVATYPE_ENUM: - case JAVATYPE_MESSAGE: - default: - GOOGLE_LOG(FATAL) << "Can't get here."; - break; - } -} - -string PrimitiveFieldGenerator::GetBoxedType() const { - return BoxedPrimitiveTypeName(GetJavaType(descriptor_)); -} - -// =================================================================== - -RepeatedPrimitiveFieldGenerator:: -RepeatedPrimitiveFieldGenerator(const FieldDescriptor* descriptor, - int messageBitIndex, - int builderBitIndex) - : descriptor_(descriptor), messageBitIndex_(messageBitIndex), - builderBitIndex_(builderBitIndex) { - SetPrimitiveVariables(descriptor, messageBitIndex, builderBitIndex, - &variables_); -} - -RepeatedPrimitiveFieldGenerator::~RepeatedPrimitiveFieldGenerator() {} - -int RepeatedPrimitiveFieldGenerator::GetNumBitsForMessage() const { - return 0; -} - -int RepeatedPrimitiveFieldGenerator::GetNumBitsForBuilder() const { - return 1; -} - -void RepeatedPrimitiveFieldGenerator:: -GenerateInterfaceMembers(io::Printer* printer) const { - WriteFieldDocComment(printer, descriptor_); - printer->Print(variables_, - "$deprecation$java.util.List<$boxed_type$> get$capitalized_name$List();\n"); - WriteFieldDocComment(printer, descriptor_); - printer->Print(variables_, - "$deprecation$int get$capitalized_name$Count();\n"); - WriteFieldDocComment(printer, descriptor_); - printer->Print(variables_, - "$deprecation$$type$ get$capitalized_name$(int index);\n"); -} - - -void RepeatedPrimitiveFieldGenerator:: -GenerateMembers(io::Printer* printer) const { - printer->Print(variables_, - "private $field_list_type$ $name$_;\n"); - WriteFieldDocComment(printer, descriptor_); - printer->Print(variables_, - "$deprecation$public java.util.List<$boxed_type$>\n" - " get$capitalized_name$List() {\n" - " return $name$_;\n" // note: unmodifiable list - "}\n"); - WriteFieldDocComment(printer, descriptor_); - printer->Print(variables_, - "$deprecation$public int get$capitalized_name$Count() {\n" - " return $name$_.size();\n" - "}\n"); - WriteFieldDocComment(printer, descriptor_); - printer->Print(variables_, - "$deprecation$public $type$ get$capitalized_name$(int index) {\n" - " return $name$_.get(index);\n" - "}\n"); - - if (descriptor_->options().packed() && - HasGeneratedMethods(descriptor_->containing_type())) { - printer->Print(variables_, - "private int $name$MemoizedSerializedSize = -1;\n"); - } -} - -void RepeatedPrimitiveFieldGenerator:: -GenerateBuilderMembers(io::Printer* printer) const { - // One field is the list and the bit field keeps track of whether the - // list is immutable. If it's immutable, the invariant is that it must - // either an instance of Collections.emptyList() or it's an ArrayList - // wrapped in a Collections.unmodifiableList() wrapper and nobody else has - // a refererence to the underlying ArrayList. This invariant allows us to - // share instances of lists between protocol buffers avoiding expensive - // memory allocations. Note, immutable is a strong guarantee here -- not - // just that the list cannot be modified via the reference but that the - // list can never be modified. - printer->Print(variables_, - "private $field_list_type$ $name$_ = $empty_list$;\n"); - - printer->Print(variables_, - "private void ensure$capitalized_name$IsMutable() {\n" - " if (!$get_mutable_bit_builder$) {\n" - " $name$_ = new java.util.ArrayList<$boxed_type$>($name$_);\n" - " $set_mutable_bit_builder$;\n" - " }\n" - "}\n"); - - // Note: We return an unmodifiable list because otherwise the caller - // could hold on to the returned list and modify it after the message - // has been built, thus mutating the message which is supposed to be - // immutable. - WriteFieldDocComment(printer, descriptor_); - printer->Print(variables_, - "$deprecation$public java.util.List<$boxed_type$>\n" - " get$capitalized_name$List() {\n" - " return java.util.Collections.unmodifiableList($name$_);\n" - "}\n"); - WriteFieldDocComment(printer, descriptor_); - printer->Print(variables_, - "$deprecation$public int get$capitalized_name$Count() {\n" - " return $name$_.size();\n" - "}\n"); - WriteFieldDocComment(printer, descriptor_); - printer->Print(variables_, - "$deprecation$public $type$ get$capitalized_name$(int index) {\n" - " return $name$_.get(index);\n" - "}\n"); - WriteFieldDocComment(printer, descriptor_); - printer->Print(variables_, - "$deprecation$public Builder set$capitalized_name$(\n" - " int index, $type$ value) {\n" - "$null_check$" - " ensure$capitalized_name$IsMutable();\n" - " $name$_.set(index, value);\n" - " $on_changed$\n" - " return this;\n" - "}\n"); - WriteFieldDocComment(printer, descriptor_); - printer->Print(variables_, - "$deprecation$public Builder add$capitalized_name$($type$ value) {\n" - "$null_check$" - " ensure$capitalized_name$IsMutable();\n" - " $name$_.add(value);\n" - " $on_changed$\n" - " return this;\n" - "}\n"); - WriteFieldDocComment(printer, descriptor_); - printer->Print(variables_, - "$deprecation$public Builder addAll$capitalized_name$(\n" - " java.lang.Iterable values) {\n" - " ensure$capitalized_name$IsMutable();\n" - " super.addAll(values, $name$_);\n" - " $on_changed$\n" - " return this;\n" - "}\n"); - WriteFieldDocComment(printer, descriptor_); - printer->Print(variables_, - "$deprecation$public Builder clear$capitalized_name$() {\n" - " $name$_ = $empty_list$;\n" - " $clear_mutable_bit_builder$;\n" - " $on_changed$\n" - " return this;\n" - "}\n"); -} - -void RepeatedPrimitiveFieldGenerator:: -GenerateFieldBuilderInitializationCode(io::Printer* printer) const { - // noop for primitives -} - -void RepeatedPrimitiveFieldGenerator:: -GenerateInitializationCode(io::Printer* printer) const { - printer->Print(variables_, "$name$_ = $empty_list$;\n"); -} - -void RepeatedPrimitiveFieldGenerator:: -GenerateBuilderClearCode(io::Printer* printer) const { - printer->Print(variables_, - "$name$_ = $empty_list$;\n" - "$clear_mutable_bit_builder$;\n"); -} - -void RepeatedPrimitiveFieldGenerator:: -GenerateMergingCode(io::Printer* printer) const { - // The code below does two optimizations: - // 1. If the other list is empty, there's nothing to do. This ensures we - // don't allocate a new array if we already have an immutable one. - // 2. If the other list is non-empty and our current list is empty, we can - // reuse the other list which is guaranteed to be immutable. - printer->Print(variables_, - "if (!other.$name$_.isEmpty()) {\n" - " if ($name$_.isEmpty()) {\n" - " $name$_ = other.$name$_;\n" - " $clear_mutable_bit_builder$;\n" - " } else {\n" - " ensure$capitalized_name$IsMutable();\n" - " $name$_.addAll(other.$name$_);\n" - " }\n" - " $on_changed$\n" - "}\n"); -} - -void RepeatedPrimitiveFieldGenerator:: -GenerateBuildingCode(io::Printer* printer) const { - // The code below ensures that the result has an immutable list. If our - // list is immutable, we can just reuse it. If not, we make it immutable. - printer->Print(variables_, - "if ($get_mutable_bit_builder$) {\n" - " $name$_ = java.util.Collections.unmodifiableList($name$_);\n" - " $clear_mutable_bit_builder$;\n" - "}\n" - "result.$name$_ = $name$_;\n"); -} - -void RepeatedPrimitiveFieldGenerator:: -GenerateParsingCode(io::Printer* printer) const { - printer->Print(variables_, - "if (!$get_mutable_bit_parser$) {\n" - " $name$_ = new java.util.ArrayList<$boxed_type$>();\n" - " $set_mutable_bit_parser$;\n" - "}\n" - "$name$_.add(input.read$capitalized_type$());\n"); -} - -void RepeatedPrimitiveFieldGenerator:: -GenerateParsingCodeFromPacked(io::Printer* printer) const { - printer->Print(variables_, - "int length = input.readRawVarint32();\n" - "int limit = input.pushLimit(length);\n" - "if (!$get_mutable_bit_parser$ && input.getBytesUntilLimit() > 0) {\n" - " $name$_ = new java.util.ArrayList<$boxed_type$>();\n" - " $set_mutable_bit_parser$;\n" - "}\n" - "while (input.getBytesUntilLimit() > 0) {\n" - " $name$_.add(input.read$capitalized_type$());\n" - "}\n" - "input.popLimit(limit);\n"); -} - -void RepeatedPrimitiveFieldGenerator:: -GenerateParsingDoneCode(io::Printer* printer) const { - printer->Print(variables_, - "if ($get_mutable_bit_parser$) {\n" - " $name$_ = java.util.Collections.unmodifiableList($name$_);\n" - "}\n"); -} - -void RepeatedPrimitiveFieldGenerator:: -GenerateSerializationCode(io::Printer* printer) const { - if (descriptor_->options().packed()) { - printer->Print(variables_, - "if (get$capitalized_name$List().size() > 0) {\n" - " output.writeRawVarint32($tag$);\n" - " output.writeRawVarint32($name$MemoizedSerializedSize);\n" - "}\n" - "for (int i = 0; i < $name$_.size(); i++) {\n" - " output.write$capitalized_type$NoTag($name$_.get(i));\n" - "}\n"); - } else { - printer->Print(variables_, - "for (int i = 0; i < $name$_.size(); i++) {\n" - " output.write$capitalized_type$($number$, $name$_.get(i));\n" - "}\n"); - } -} - -void RepeatedPrimitiveFieldGenerator:: -GenerateSerializedSizeCode(io::Printer* printer) const { - printer->Print(variables_, - "{\n" - " int dataSize = 0;\n"); - printer->Indent(); - - if (FixedSize(GetType(descriptor_)) == -1) { - printer->Print(variables_, - "for (int i = 0; i < $name$_.size(); i++) {\n" - " dataSize += com.google.protobuf.CodedOutputStream\n" - " .compute$capitalized_type$SizeNoTag($name$_.get(i));\n" - "}\n"); - } else { - printer->Print(variables_, - "dataSize = $fixed_size$ * get$capitalized_name$List().size();\n"); - } - - printer->Print( - "size += dataSize;\n"); - - if (descriptor_->options().packed()) { - printer->Print(variables_, - "if (!get$capitalized_name$List().isEmpty()) {\n" - " size += $tag_size$;\n" - " size += com.google.protobuf.CodedOutputStream\n" - " .computeInt32SizeNoTag(dataSize);\n" - "}\n"); - } else { - printer->Print(variables_, - "size += $tag_size$ * get$capitalized_name$List().size();\n"); - } - - // cache the data size for packed fields. - if (descriptor_->options().packed()) { - printer->Print(variables_, - "$name$MemoizedSerializedSize = dataSize;\n"); - } - - printer->Outdent(); - printer->Print("}\n"); -} - -void RepeatedPrimitiveFieldGenerator:: -GenerateEqualsCode(io::Printer* printer) const { - printer->Print(variables_, - "result = result && get$capitalized_name$List()\n" - " .equals(other.get$capitalized_name$List());\n"); -} - -void RepeatedPrimitiveFieldGenerator:: -GenerateHashCode(io::Printer* printer) const { - printer->Print(variables_, - "if (get$capitalized_name$Count() > 0) {\n" - " hash = (37 * hash) + $constant_name$;\n" - " hash = (53 * hash) + get$capitalized_name$List().hashCode();\n" - "}\n"); -} - -string RepeatedPrimitiveFieldGenerator::GetBoxedType() const { - return BoxedPrimitiveTypeName(GetJavaType(descriptor_)); -} - -} // namespace java -} // namespace compiler -} // namespace protobuf -} // namespace google diff --git a/modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/java/java_primitive_field.h b/modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/java/java_primitive_field.h deleted file mode 100644 index 1b5b6d95d..000000000 --- a/modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/java/java_primitive_field.h +++ /dev/null @@ -1,123 +0,0 @@ -// Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// http://code.google.com/p/protobuf/ -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -// Author: kenton@google.com (Kenton Varda) -// Based on original Protocol Buffers design by -// Sanjay Ghemawat, Jeff Dean, and others. - -#ifndef GOOGLE_PROTOBUF_COMPILER_JAVA_PRIMITIVE_FIELD_H__ -#define GOOGLE_PROTOBUF_COMPILER_JAVA_PRIMITIVE_FIELD_H__ - -#include -#include -#include - -namespace google { -namespace protobuf { -namespace compiler { -namespace java { - -class PrimitiveFieldGenerator : public FieldGenerator { - public: - explicit PrimitiveFieldGenerator(const FieldDescriptor* descriptor, - int messageBitIndex, int builderBitIndex); - ~PrimitiveFieldGenerator(); - - // implements FieldGenerator --------------------------------------- - int GetNumBitsForMessage() const; - int GetNumBitsForBuilder() const; - void GenerateInterfaceMembers(io::Printer* printer) const; - void GenerateMembers(io::Printer* printer) const; - void GenerateBuilderMembers(io::Printer* printer) const; - void GenerateInitializationCode(io::Printer* printer) const; - void GenerateBuilderClearCode(io::Printer* printer) const; - void GenerateMergingCode(io::Printer* printer) const; - void GenerateBuildingCode(io::Printer* printer) const; - void GenerateParsingCode(io::Printer* printer) const; - void GenerateParsingDoneCode(io::Printer* printer) const; - void GenerateSerializationCode(io::Printer* printer) const; - void GenerateSerializedSizeCode(io::Printer* printer) const; - void GenerateFieldBuilderInitializationCode(io::Printer* printer) const; - void GenerateEqualsCode(io::Printer* printer) const; - void GenerateHashCode(io::Printer* printer) const; - - string GetBoxedType() const; - - private: - const FieldDescriptor* descriptor_; - map variables_; - const int messageBitIndex_; - const int builderBitIndex_; - - GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(PrimitiveFieldGenerator); -}; - -class RepeatedPrimitiveFieldGenerator : public FieldGenerator { - public: - explicit RepeatedPrimitiveFieldGenerator(const FieldDescriptor* descriptor, - int messageBitIndex, int builderBitIndex); - ~RepeatedPrimitiveFieldGenerator(); - - // implements FieldGenerator --------------------------------------- - int GetNumBitsForMessage() const; - int GetNumBitsForBuilder() const; - void GenerateInterfaceMembers(io::Printer* printer) const; - void GenerateMembers(io::Printer* printer) const; - void GenerateBuilderMembers(io::Printer* printer) const; - void GenerateInitializationCode(io::Printer* printer) const; - void GenerateBuilderClearCode(io::Printer* printer) const; - void GenerateMergingCode(io::Printer* printer) const; - void GenerateBuildingCode(io::Printer* printer) const; - void GenerateParsingCode(io::Printer* printer) const; - void GenerateParsingCodeFromPacked(io::Printer* printer) const; - void GenerateParsingDoneCode(io::Printer* printer) const; - void GenerateSerializationCode(io::Printer* printer) const; - void GenerateSerializedSizeCode(io::Printer* printer) const; - void GenerateFieldBuilderInitializationCode(io::Printer* printer) const; - void GenerateEqualsCode(io::Printer* printer) const; - void GenerateHashCode(io::Printer* printer) const; - - string GetBoxedType() const; - - private: - const FieldDescriptor* descriptor_; - map variables_; - const int messageBitIndex_; - const int builderBitIndex_; - - GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(RepeatedPrimitiveFieldGenerator); -}; - -} // namespace java -} // namespace compiler -} // namespace protobuf - -} // namespace google -#endif // GOOGLE_PROTOBUF_COMPILER_JAVA_PRIMITIVE_FIELD_H__ diff --git a/modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/java/java_service.cc b/modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/java/java_service.cc deleted file mode 100644 index bcd803590..000000000 --- a/modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/java/java_service.cc +++ /dev/null @@ -1,453 +0,0 @@ -// Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// http://code.google.com/p/protobuf/ -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -// Author: kenton@google.com (Kenton Varda) -// Based on original Protocol Buffers design by -// Sanjay Ghemawat, Jeff Dean, and others. - -#include -#include -#include -#include -#include -#include - -namespace google { -namespace protobuf { -namespace compiler { -namespace java { - -ServiceGenerator::ServiceGenerator(const ServiceDescriptor* descriptor) - : descriptor_(descriptor) {} - -ServiceGenerator::~ServiceGenerator() {} - -void ServiceGenerator::Generate(io::Printer* printer) { - bool is_own_file = descriptor_->file()->options().java_multiple_files(); - WriteServiceDocComment(printer, descriptor_); - printer->Print( - "public $static$ abstract class $classname$\n" - " implements com.google.protobuf.Service {\n", - "static", is_own_file ? "" : "static", - "classname", descriptor_->name()); - printer->Indent(); - - printer->Print( - "protected $classname$() {}\n\n", - "classname", descriptor_->name()); - - GenerateInterface(printer); - - GenerateNewReflectiveServiceMethod(printer); - GenerateNewReflectiveBlockingServiceMethod(printer); - - GenerateAbstractMethods(printer); - - // Generate getDescriptor() and getDescriptorForType(). - printer->Print( - "public static final\n" - " com.google.protobuf.Descriptors.ServiceDescriptor\n" - " getDescriptor() {\n" - " return $file$.getDescriptor().getServices().get($index$);\n" - "}\n", - "file", ClassName(descriptor_->file()), - "index", SimpleItoa(descriptor_->index())); - GenerateGetDescriptorForType(printer); - - // Generate more stuff. - GenerateCallMethod(printer); - GenerateGetPrototype(REQUEST, printer); - GenerateGetPrototype(RESPONSE, printer); - GenerateStub(printer); - GenerateBlockingStub(printer); - - // Add an insertion point. - printer->Print( - "\n" - "// @@protoc_insertion_point(class_scope:$full_name$)\n", - "full_name", descriptor_->full_name()); - - printer->Outdent(); - printer->Print("}\n\n"); -} - -void ServiceGenerator::GenerateGetDescriptorForType(io::Printer* printer) { - printer->Print( - "public final com.google.protobuf.Descriptors.ServiceDescriptor\n" - " getDescriptorForType() {\n" - " return getDescriptor();\n" - "}\n"); -} - -void ServiceGenerator::GenerateInterface(io::Printer* printer) { - printer->Print("public interface Interface {\n"); - printer->Indent(); - GenerateAbstractMethods(printer); - printer->Outdent(); - printer->Print("}\n\n"); -} - -void ServiceGenerator::GenerateNewReflectiveServiceMethod( - io::Printer* printer) { - printer->Print( - "public static com.google.protobuf.Service newReflectiveService(\n" - " final Interface impl) {\n" - " return new $classname$() {\n", - "classname", descriptor_->name()); - printer->Indent(); - printer->Indent(); - - for (int i = 0; i < descriptor_->method_count(); i++) { - const MethodDescriptor* method = descriptor_->method(i); - printer->Print("@java.lang.Override\n"); - GenerateMethodSignature(printer, method, IS_CONCRETE); - printer->Print( - " {\n" - " impl.$method$(controller, request, done);\n" - "}\n\n", - "method", UnderscoresToCamelCase(method)); - } - - printer->Outdent(); - printer->Print("};\n"); - printer->Outdent(); - printer->Print("}\n\n"); -} - -void ServiceGenerator::GenerateNewReflectiveBlockingServiceMethod( - io::Printer* printer) { - printer->Print( - "public static com.google.protobuf.BlockingService\n" - " newReflectiveBlockingService(final BlockingInterface impl) {\n" - " return new com.google.protobuf.BlockingService() {\n"); - printer->Indent(); - printer->Indent(); - - GenerateGetDescriptorForType(printer); - - GenerateCallBlockingMethod(printer); - GenerateGetPrototype(REQUEST, printer); - GenerateGetPrototype(RESPONSE, printer); - - printer->Outdent(); - printer->Print("};\n"); - printer->Outdent(); - printer->Print("}\n\n"); -} - -void ServiceGenerator::GenerateAbstractMethods(io::Printer* printer) { - for (int i = 0; i < descriptor_->method_count(); i++) { - const MethodDescriptor* method = descriptor_->method(i); - WriteMethodDocComment(printer, method); - GenerateMethodSignature(printer, method, IS_ABSTRACT); - printer->Print(";\n\n"); - } -} - -void ServiceGenerator::GenerateCallMethod(io::Printer* printer) { - printer->Print( - "\n" - "public final void callMethod(\n" - " com.google.protobuf.Descriptors.MethodDescriptor method,\n" - " com.google.protobuf.RpcController controller,\n" - " com.google.protobuf.Message request,\n" - " com.google.protobuf.RpcCallback<\n" - " com.google.protobuf.Message> done) {\n" - " if (method.getService() != getDescriptor()) {\n" - " throw new java.lang.IllegalArgumentException(\n" - " \"Service.callMethod() given method descriptor for wrong \" +\n" - " \"service type.\");\n" - " }\n" - " switch(method.getIndex()) {\n"); - printer->Indent(); - printer->Indent(); - - for (int i = 0; i < descriptor_->method_count(); i++) { - const MethodDescriptor* method = descriptor_->method(i); - map vars; - vars["index"] = SimpleItoa(i); - vars["method"] = UnderscoresToCamelCase(method); - vars["input"] = ClassName(method->input_type()); - vars["output"] = ClassName(method->output_type()); - printer->Print(vars, - "case $index$:\n" - " this.$method$(controller, ($input$)request,\n" - " com.google.protobuf.RpcUtil.<$output$>specializeCallback(\n" - " done));\n" - " return;\n"); - } - - printer->Print( - "default:\n" - " throw new java.lang.AssertionError(\"Can't get here.\");\n"); - - printer->Outdent(); - printer->Outdent(); - - printer->Print( - " }\n" - "}\n" - "\n"); -} - -void ServiceGenerator::GenerateCallBlockingMethod(io::Printer* printer) { - printer->Print( - "\n" - "public final com.google.protobuf.Message callBlockingMethod(\n" - " com.google.protobuf.Descriptors.MethodDescriptor method,\n" - " com.google.protobuf.RpcController controller,\n" - " com.google.protobuf.Message request)\n" - " throws com.google.protobuf.ServiceException {\n" - " if (method.getService() != getDescriptor()) {\n" - " throw new java.lang.IllegalArgumentException(\n" - " \"Service.callBlockingMethod() given method descriptor for \" +\n" - " \"wrong service type.\");\n" - " }\n" - " switch(method.getIndex()) {\n"); - printer->Indent(); - printer->Indent(); - - for (int i = 0; i < descriptor_->method_count(); i++) { - const MethodDescriptor* method = descriptor_->method(i); - map vars; - vars["index"] = SimpleItoa(i); - vars["method"] = UnderscoresToCamelCase(method); - vars["input"] = ClassName(method->input_type()); - vars["output"] = ClassName(method->output_type()); - printer->Print(vars, - "case $index$:\n" - " return impl.$method$(controller, ($input$)request);\n"); - } - - printer->Print( - "default:\n" - " throw new java.lang.AssertionError(\"Can't get here.\");\n"); - - printer->Outdent(); - printer->Outdent(); - - printer->Print( - " }\n" - "}\n" - "\n"); -} - -void ServiceGenerator::GenerateGetPrototype(RequestOrResponse which, - io::Printer* printer) { - /* - * TODO(cpovirk): The exception message says "Service.foo" when it may be - * "BlockingService.foo." Consider fixing. - */ - printer->Print( - "public final com.google.protobuf.Message\n" - " get$request_or_response$Prototype(\n" - " com.google.protobuf.Descriptors.MethodDescriptor method) {\n" - " if (method.getService() != getDescriptor()) {\n" - " throw new java.lang.IllegalArgumentException(\n" - " \"Service.get$request_or_response$Prototype() given method \" +\n" - " \"descriptor for wrong service type.\");\n" - " }\n" - " switch(method.getIndex()) {\n", - "request_or_response", (which == REQUEST) ? "Request" : "Response"); - printer->Indent(); - printer->Indent(); - - for (int i = 0; i < descriptor_->method_count(); i++) { - const MethodDescriptor* method = descriptor_->method(i); - map vars; - vars["index"] = SimpleItoa(i); - vars["type"] = ClassName( - (which == REQUEST) ? method->input_type() : method->output_type()); - printer->Print(vars, - "case $index$:\n" - " return $type$.getDefaultInstance();\n"); - } - - printer->Print( - "default:\n" - " throw new java.lang.AssertionError(\"Can't get here.\");\n"); - - printer->Outdent(); - printer->Outdent(); - - printer->Print( - " }\n" - "}\n" - "\n"); -} - -void ServiceGenerator::GenerateStub(io::Printer* printer) { - printer->Print( - "public static Stub newStub(\n" - " com.google.protobuf.RpcChannel channel) {\n" - " return new Stub(channel);\n" - "}\n" - "\n" - "public static final class Stub extends $classname$ implements Interface {" - "\n", - "classname", ClassName(descriptor_)); - printer->Indent(); - - printer->Print( - "private Stub(com.google.protobuf.RpcChannel channel) {\n" - " this.channel = channel;\n" - "}\n" - "\n" - "private final com.google.protobuf.RpcChannel channel;\n" - "\n" - "public com.google.protobuf.RpcChannel getChannel() {\n" - " return channel;\n" - "}\n"); - - for (int i = 0; i < descriptor_->method_count(); i++) { - const MethodDescriptor* method = descriptor_->method(i); - printer->Print("\n"); - GenerateMethodSignature(printer, method, IS_CONCRETE); - printer->Print(" {\n"); - printer->Indent(); - - map vars; - vars["index"] = SimpleItoa(i); - vars["output"] = ClassName(method->output_type()); - printer->Print(vars, - "channel.callMethod(\n" - " getDescriptor().getMethods().get($index$),\n" - " controller,\n" - " request,\n" - " $output$.getDefaultInstance(),\n" - " com.google.protobuf.RpcUtil.generalizeCallback(\n" - " done,\n" - " $output$.class,\n" - " $output$.getDefaultInstance()));\n"); - - printer->Outdent(); - printer->Print("}\n"); - } - - printer->Outdent(); - printer->Print( - "}\n" - "\n"); -} - -void ServiceGenerator::GenerateBlockingStub(io::Printer* printer) { - printer->Print( - "public static BlockingInterface newBlockingStub(\n" - " com.google.protobuf.BlockingRpcChannel channel) {\n" - " return new BlockingStub(channel);\n" - "}\n" - "\n"); - - printer->Print( - "public interface BlockingInterface {"); - printer->Indent(); - - for (int i = 0; i < descriptor_->method_count(); i++) { - const MethodDescriptor* method = descriptor_->method(i); - GenerateBlockingMethodSignature(printer, method); - printer->Print(";\n"); - } - - printer->Outdent(); - printer->Print( - "}\n" - "\n"); - - printer->Print( - "private static final class BlockingStub implements BlockingInterface {\n"); - printer->Indent(); - - printer->Print( - "private BlockingStub(com.google.protobuf.BlockingRpcChannel channel) {\n" - " this.channel = channel;\n" - "}\n" - "\n" - "private final com.google.protobuf.BlockingRpcChannel channel;\n"); - - for (int i = 0; i < descriptor_->method_count(); i++) { - const MethodDescriptor* method = descriptor_->method(i); - GenerateBlockingMethodSignature(printer, method); - printer->Print(" {\n"); - printer->Indent(); - - map vars; - vars["index"] = SimpleItoa(i); - vars["output"] = ClassName(method->output_type()); - printer->Print(vars, - "return ($output$) channel.callBlockingMethod(\n" - " getDescriptor().getMethods().get($index$),\n" - " controller,\n" - " request,\n" - " $output$.getDefaultInstance());\n"); - - printer->Outdent(); - printer->Print( - "}\n" - "\n"); - } - - printer->Outdent(); - printer->Print("}\n"); -} - -void ServiceGenerator::GenerateMethodSignature(io::Printer* printer, - const MethodDescriptor* method, - IsAbstract is_abstract) { - map vars; - vars["name"] = UnderscoresToCamelCase(method); - vars["input"] = ClassName(method->input_type()); - vars["output"] = ClassName(method->output_type()); - vars["abstract"] = (is_abstract == IS_ABSTRACT) ? "abstract" : ""; - printer->Print(vars, - "public $abstract$ void $name$(\n" - " com.google.protobuf.RpcController controller,\n" - " $input$ request,\n" - " com.google.protobuf.RpcCallback<$output$> done)"); -} - -void ServiceGenerator::GenerateBlockingMethodSignature( - io::Printer* printer, - const MethodDescriptor* method) { - map vars; - vars["method"] = UnderscoresToCamelCase(method); - vars["input"] = ClassName(method->input_type()); - vars["output"] = ClassName(method->output_type()); - printer->Print(vars, - "\n" - "public $output$ $method$(\n" - " com.google.protobuf.RpcController controller,\n" - " $input$ request)\n" - " throws com.google.protobuf.ServiceException"); -} - -} // namespace java -} // namespace compiler -} // namespace protobuf -} // namespace google diff --git a/modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/java/java_service.h b/modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/java/java_service.h deleted file mode 100644 index e07eebf75..000000000 --- a/modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/java/java_service.h +++ /dev/null @@ -1,113 +0,0 @@ -// Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// http://code.google.com/p/protobuf/ -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -// Author: kenton@google.com (Kenton Varda) -// Based on original Protocol Buffers design by -// Sanjay Ghemawat, Jeff Dean, and others. - -#ifndef GOOGLE_PROTOBUF_COMPILER_JAVA_SERVICE_H__ -#define GOOGLE_PROTOBUF_COMPILER_JAVA_SERVICE_H__ - -#include -#include - -namespace google { -namespace protobuf { - namespace io { - class Printer; // printer.h - } -} - -namespace protobuf { -namespace compiler { -namespace java { - -class ServiceGenerator { - public: - explicit ServiceGenerator(const ServiceDescriptor* descriptor); - ~ServiceGenerator(); - - void Generate(io::Printer* printer); - - private: - - // Generate the getDescriptorForType() method. - void GenerateGetDescriptorForType(io::Printer* printer); - - // Generate a Java interface for the service. - void GenerateInterface(io::Printer* printer); - - // Generate newReflectiveService() method. - void GenerateNewReflectiveServiceMethod(io::Printer* printer); - - // Generate newReflectiveBlockingService() method. - void GenerateNewReflectiveBlockingServiceMethod(io::Printer* printer); - - // Generate abstract method declarations for all methods. - void GenerateAbstractMethods(io::Printer* printer); - - // Generate the implementation of Service.callMethod(). - void GenerateCallMethod(io::Printer* printer); - - // Generate the implementation of BlockingService.callBlockingMethod(). - void GenerateCallBlockingMethod(io::Printer* printer); - - // Generate the implementations of Service.get{Request,Response}Prototype(). - enum RequestOrResponse { REQUEST, RESPONSE }; - void GenerateGetPrototype(RequestOrResponse which, io::Printer* printer); - - // Generate a stub implementation of the service. - void GenerateStub(io::Printer* printer); - - // Generate a method signature, possibly abstract, without body or trailing - // semicolon. - enum IsAbstract { IS_ABSTRACT, IS_CONCRETE }; - void GenerateMethodSignature(io::Printer* printer, - const MethodDescriptor* method, - IsAbstract is_abstract); - - // Generate a blocking stub interface and implementation of the service. - void GenerateBlockingStub(io::Printer* printer); - - // Generate the method signature for one method of a blocking stub. - void GenerateBlockingMethodSignature(io::Printer* printer, - const MethodDescriptor* method); - - const ServiceDescriptor* descriptor_; - - GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ServiceGenerator); -}; - -} // namespace java -} // namespace compiler -} // namespace protobuf - -#endif // NET_PROTO2_COMPILER_JAVA_SERVICE_H__ -} // namespace google diff --git a/modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/java/java_string_field.cc b/modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/java/java_string_field.cc deleted file mode 100644 index 4815663b1..000000000 --- a/modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/java/java_string_field.cc +++ /dev/null @@ -1,726 +0,0 @@ -// Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// http://code.google.com/p/protobuf/ -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -// Author: kenton@google.com (Kenton Varda) -// Author: jonp@google.com (Jon Perlow) -// Based on original Protocol Buffers design by -// Sanjay Ghemawat, Jeff Dean, and others. - -#include -#include - -#include -#include -#include -#include -#include -#include -#include - -namespace google { -namespace protobuf { -namespace compiler { -namespace java { - -using internal::WireFormat; -using internal::WireFormatLite; - -namespace { - -void SetPrimitiveVariables(const FieldDescriptor* descriptor, - int messageBitIndex, - int builderBitIndex, - map* variables) { - (*variables)["name"] = - UnderscoresToCamelCase(descriptor); - (*variables)["capitalized_name"] = - UnderscoresToCapitalizedCamelCase(descriptor); - (*variables)["constant_name"] = FieldConstantName(descriptor); - (*variables)["number"] = SimpleItoa(descriptor->number()); - (*variables)["empty_list"] = "com.google.protobuf.LazyStringArrayList.EMPTY"; - - (*variables)["default"] = DefaultValue(descriptor); - (*variables)["default_init"] = ("= " + DefaultValue(descriptor)); - (*variables)["capitalized_type"] = "String"; - (*variables)["tag"] = SimpleItoa(WireFormat::MakeTag(descriptor)); - (*variables)["tag_size"] = SimpleItoa( - WireFormat::TagSize(descriptor->number(), GetType(descriptor))); - (*variables)["null_check"] = - " if (value == null) {\n" - " throw new NullPointerException();\n" - " }\n"; - - // TODO(birdo): Add @deprecated javadoc when generating javadoc is supported - // by the proto compiler - (*variables)["deprecation"] = descriptor->options().deprecated() - ? "@java.lang.Deprecated " : ""; - (*variables)["on_changed"] = - HasDescriptorMethods(descriptor->containing_type()) ? "onChanged();" : ""; - - // For singular messages and builders, one bit is used for the hasField bit. - (*variables)["get_has_field_bit_message"] = GenerateGetBit(messageBitIndex); - (*variables)["set_has_field_bit_message"] = GenerateSetBit(messageBitIndex); - - (*variables)["get_has_field_bit_builder"] = GenerateGetBit(builderBitIndex); - (*variables)["set_has_field_bit_builder"] = GenerateSetBit(builderBitIndex); - (*variables)["clear_has_field_bit_builder"] = - GenerateClearBit(builderBitIndex); - - // For repated builders, one bit is used for whether the array is immutable. - (*variables)["get_mutable_bit_builder"] = GenerateGetBit(builderBitIndex); - (*variables)["set_mutable_bit_builder"] = GenerateSetBit(builderBitIndex); - (*variables)["clear_mutable_bit_builder"] = GenerateClearBit(builderBitIndex); - - // For repeated fields, one bit is used for whether the array is immutable - // in the parsing constructor. - (*variables)["get_mutable_bit_parser"] = - GenerateGetBitMutableLocal(builderBitIndex); - (*variables)["set_mutable_bit_parser"] = - GenerateSetBitMutableLocal(builderBitIndex); - - (*variables)["get_has_field_bit_from_local"] = - GenerateGetBitFromLocal(builderBitIndex); - (*variables)["set_has_field_bit_to_local"] = - GenerateSetBitToLocal(messageBitIndex); -} - -} // namespace - -// =================================================================== - -StringFieldGenerator:: -StringFieldGenerator(const FieldDescriptor* descriptor, - int messageBitIndex, - int builderBitIndex) - : descriptor_(descriptor), messageBitIndex_(messageBitIndex), - builderBitIndex_(builderBitIndex) { - SetPrimitiveVariables(descriptor, messageBitIndex, builderBitIndex, - &variables_); -} - -StringFieldGenerator::~StringFieldGenerator() {} - -int StringFieldGenerator::GetNumBitsForMessage() const { - return 1; -} - -int StringFieldGenerator::GetNumBitsForBuilder() const { - return 1; -} - -// A note about how strings are handled. This code used to just store a String -// in the Message. This had two issues: -// -// 1. It wouldn't roundtrip byte arrays that were not vaid UTF-8 encoded -// strings, but rather fields that were raw bytes incorrectly marked -// as strings in the proto file. This is common because in the proto1 -// syntax, string was the way to indicate bytes and C++ engineers can -// easily make this mistake without affecting the C++ API. By converting to -// strings immediately, some java code might corrupt these byte arrays as -// it passes through a java server even if the field was never accessed by -// application code. -// -// 2. There's a performance hit to converting between bytes and strings and -// it many cases, the field is never even read by the application code. This -// avoids unnecessary conversions in the common use cases. -// -// So now, the field for String is maintained as an Object reference which can -// either store a String or a ByteString. The code uses an instanceof check -// to see which one it has and converts to the other one if needed. It remembers -// the last value requested (in a thread safe manner) as this is most likely -// the one needed next. The thread safety is such that if two threads both -// convert the field because the changes made by each thread were not visible to -// the other, they may cause a conversion to happen more times than would -// otherwise be necessary. This was deemed better than adding synchronization -// overhead. It will not cause any corruption issues or affect the behavior of -// the API. The instanceof check is also highly optimized in the JVM and we -// decided it was better to reduce the memory overhead by not having two -// separate fields but rather use dynamic type checking. -// -// For single fields, the logic for this is done inside the generated code. For -// repeated fields, the logic is done in LazyStringArrayList and -// UnmodifiableLazyStringList. -void StringFieldGenerator:: -GenerateInterfaceMembers(io::Printer* printer) const { - WriteFieldDocComment(printer, descriptor_); - printer->Print(variables_, - "$deprecation$boolean has$capitalized_name$();\n"); - WriteFieldDocComment(printer, descriptor_); - printer->Print(variables_, - "$deprecation$java.lang.String get$capitalized_name$();\n"); - WriteFieldDocComment(printer, descriptor_); - printer->Print(variables_, - "$deprecation$com.google.protobuf.ByteString\n" - " get$capitalized_name$Bytes();\n"); -} - -void StringFieldGenerator:: -GenerateMembers(io::Printer* printer) const { - printer->Print(variables_, - "private java.lang.Object $name$_;\n"); - WriteFieldDocComment(printer, descriptor_); - printer->Print(variables_, - "$deprecation$public boolean has$capitalized_name$() {\n" - " return $get_has_field_bit_message$;\n" - "}\n"); - - WriteFieldDocComment(printer, descriptor_); - printer->Print(variables_, - "$deprecation$public java.lang.String get$capitalized_name$() {\n" - " java.lang.Object ref = $name$_;\n" - " if (ref instanceof java.lang.String) {\n" - " return (java.lang.String) ref;\n" - " } else {\n" - " com.google.protobuf.ByteString bs = \n" - " (com.google.protobuf.ByteString) ref;\n" - " java.lang.String s = bs.toStringUtf8();\n" - " if (bs.isValidUtf8()) {\n" - " $name$_ = s;\n" - " }\n" - " return s;\n" - " }\n" - "}\n"); - WriteFieldDocComment(printer, descriptor_); - printer->Print(variables_, - "$deprecation$public com.google.protobuf.ByteString\n" - " get$capitalized_name$Bytes() {\n" - " java.lang.Object ref = $name$_;\n" - " if (ref instanceof java.lang.String) {\n" - " com.google.protobuf.ByteString b = \n" - " com.google.protobuf.ByteString.copyFromUtf8(\n" - " (java.lang.String) ref);\n" - " $name$_ = b;\n" - " return b;\n" - " } else {\n" - " return (com.google.protobuf.ByteString) ref;\n" - " }\n" - "}\n"); -} - -void StringFieldGenerator:: -GenerateBuilderMembers(io::Printer* printer) const { - printer->Print(variables_, - "private java.lang.Object $name$_ $default_init$;\n"); - WriteFieldDocComment(printer, descriptor_); - printer->Print(variables_, - "$deprecation$public boolean has$capitalized_name$() {\n" - " return $get_has_field_bit_builder$;\n" - "}\n"); - - WriteFieldDocComment(printer, descriptor_); - printer->Print(variables_, - "$deprecation$public java.lang.String get$capitalized_name$() {\n" - " java.lang.Object ref = $name$_;\n" - " if (!(ref instanceof java.lang.String)) {\n" - " java.lang.String s = ((com.google.protobuf.ByteString) ref)\n" - " .toStringUtf8();\n" - " $name$_ = s;\n" - " return s;\n" - " } else {\n" - " return (java.lang.String) ref;\n" - " }\n" - "}\n"); - - WriteFieldDocComment(printer, descriptor_); - printer->Print(variables_, - "$deprecation$public com.google.protobuf.ByteString\n" - " get$capitalized_name$Bytes() {\n" - " java.lang.Object ref = $name$_;\n" - " if (ref instanceof String) {\n" - " com.google.protobuf.ByteString b = \n" - " com.google.protobuf.ByteString.copyFromUtf8(\n" - " (java.lang.String) ref);\n" - " $name$_ = b;\n" - " return b;\n" - " } else {\n" - " return (com.google.protobuf.ByteString) ref;\n" - " }\n" - "}\n"); - - WriteFieldDocComment(printer, descriptor_); - printer->Print(variables_, - "$deprecation$public Builder set$capitalized_name$(\n" - " java.lang.String value) {\n" - "$null_check$" - " $set_has_field_bit_builder$;\n" - " $name$_ = value;\n" - " $on_changed$\n" - " return this;\n" - "}\n"); - WriteFieldDocComment(printer, descriptor_); - printer->Print(variables_, - "$deprecation$public Builder clear$capitalized_name$() {\n" - " $clear_has_field_bit_builder$;\n"); - // The default value is not a simple literal so we want to avoid executing - // it multiple times. Instead, get the default out of the default instance. - printer->Print(variables_, - " $name$_ = getDefaultInstance().get$capitalized_name$();\n"); - printer->Print(variables_, - " $on_changed$\n" - " return this;\n" - "}\n"); - - WriteFieldDocComment(printer, descriptor_); - printer->Print(variables_, - "$deprecation$public Builder set$capitalized_name$Bytes(\n" - " com.google.protobuf.ByteString value) {\n" - "$null_check$" - " $set_has_field_bit_builder$;\n" - " $name$_ = value;\n" - " $on_changed$\n" - " return this;\n" - "}\n"); -} - -void StringFieldGenerator:: -GenerateFieldBuilderInitializationCode(io::Printer* printer) const { - // noop for primitives -} - -void StringFieldGenerator:: -GenerateInitializationCode(io::Printer* printer) const { - printer->Print(variables_, "$name$_ = $default$;\n"); -} - -void StringFieldGenerator:: -GenerateBuilderClearCode(io::Printer* printer) const { - printer->Print(variables_, - "$name$_ = $default$;\n" - "$clear_has_field_bit_builder$;\n"); -} - -void StringFieldGenerator:: -GenerateMergingCode(io::Printer* printer) const { - // Allow a slight breach of abstraction here in order to avoid forcing - // all string fields to Strings when copying fields from a Message. - printer->Print(variables_, - "if (other.has$capitalized_name$()) {\n" - " $set_has_field_bit_builder$;\n" - " $name$_ = other.$name$_;\n" - " $on_changed$\n" - "}\n"); -} - -void StringFieldGenerator:: -GenerateBuildingCode(io::Printer* printer) const { - printer->Print(variables_, - "if ($get_has_field_bit_from_local$) {\n" - " $set_has_field_bit_to_local$;\n" - "}\n" - "result.$name$_ = $name$_;\n"); -} - -void StringFieldGenerator:: -GenerateParsingCode(io::Printer* printer) const { - printer->Print(variables_, - "$set_has_field_bit_message$;\n" - "$name$_ = input.readBytes();\n"); -} - -void StringFieldGenerator:: -GenerateParsingDoneCode(io::Printer* printer) const { - // noop for strings. -} - -void StringFieldGenerator:: -GenerateSerializationCode(io::Printer* printer) const { - printer->Print(variables_, - "if ($get_has_field_bit_message$) {\n" - " output.writeBytes($number$, get$capitalized_name$Bytes());\n" - "}\n"); -} - -void StringFieldGenerator:: -GenerateSerializedSizeCode(io::Printer* printer) const { - printer->Print(variables_, - "if ($get_has_field_bit_message$) {\n" - " size += com.google.protobuf.CodedOutputStream\n" - " .computeBytesSize($number$, get$capitalized_name$Bytes());\n" - "}\n"); -} - -void StringFieldGenerator:: -GenerateEqualsCode(io::Printer* printer) const { - printer->Print(variables_, - "result = result && get$capitalized_name$()\n" - " .equals(other.get$capitalized_name$());\n"); -} - -void StringFieldGenerator:: -GenerateHashCode(io::Printer* printer) const { - printer->Print(variables_, - "hash = (37 * hash) + $constant_name$;\n"); - printer->Print(variables_, - "hash = (53 * hash) + get$capitalized_name$().hashCode();\n"); -} - -string StringFieldGenerator::GetBoxedType() const { - return "java.lang.String"; -} - - -// =================================================================== - -RepeatedStringFieldGenerator:: -RepeatedStringFieldGenerator(const FieldDescriptor* descriptor, - int messageBitIndex, - int builderBitIndex) - : descriptor_(descriptor), messageBitIndex_(messageBitIndex), - builderBitIndex_(builderBitIndex) { - SetPrimitiveVariables(descriptor, messageBitIndex, builderBitIndex, - &variables_); -} - -RepeatedStringFieldGenerator::~RepeatedStringFieldGenerator() {} - -int RepeatedStringFieldGenerator::GetNumBitsForMessage() const { - return 0; -} - -int RepeatedStringFieldGenerator::GetNumBitsForBuilder() const { - return 1; -} - -void RepeatedStringFieldGenerator:: -GenerateInterfaceMembers(io::Printer* printer) const { - WriteFieldDocComment(printer, descriptor_); - printer->Print(variables_, - "$deprecation$java.util.List\n" - "get$capitalized_name$List();\n"); - WriteFieldDocComment(printer, descriptor_); - printer->Print(variables_, - "$deprecation$int get$capitalized_name$Count();\n"); - WriteFieldDocComment(printer, descriptor_); - printer->Print(variables_, - "$deprecation$java.lang.String get$capitalized_name$(int index);\n"); - WriteFieldDocComment(printer, descriptor_); - printer->Print(variables_, - "$deprecation$com.google.protobuf.ByteString\n" - " get$capitalized_name$Bytes(int index);\n"); -} - - -void RepeatedStringFieldGenerator:: -GenerateMembers(io::Printer* printer) const { - printer->Print(variables_, - "private com.google.protobuf.LazyStringList $name$_;\n"); - WriteFieldDocComment(printer, descriptor_); - printer->Print(variables_, - "$deprecation$public java.util.List\n" - " get$capitalized_name$List() {\n" - " return $name$_;\n" // note: unmodifiable list - "}\n"); - WriteFieldDocComment(printer, descriptor_); - printer->Print(variables_, - "$deprecation$public int get$capitalized_name$Count() {\n" - " return $name$_.size();\n" - "}\n"); - WriteFieldDocComment(printer, descriptor_); - printer->Print(variables_, - "$deprecation$public java.lang.String get$capitalized_name$(int index) {\n" - " return $name$_.get(index);\n" - "}\n"); - WriteFieldDocComment(printer, descriptor_); - printer->Print(variables_, - "$deprecation$public com.google.protobuf.ByteString\n" - " get$capitalized_name$Bytes(int index) {\n" - " return $name$_.getByteString(index);\n" - "}\n"); - - if (descriptor_->options().packed() && - HasGeneratedMethods(descriptor_->containing_type())) { - printer->Print(variables_, - "private int $name$MemoizedSerializedSize = -1;\n"); - } -} - -void RepeatedStringFieldGenerator:: -GenerateBuilderMembers(io::Printer* printer) const { - // One field is the list and the bit field keeps track of whether the - // list is immutable. If it's immutable, the invariant is that it must - // either an instance of Collections.emptyList() or it's an ArrayList - // wrapped in a Collections.unmodifiableList() wrapper and nobody else has - // a refererence to the underlying ArrayList. This invariant allows us to - // share instances of lists between protocol buffers avoiding expensive - // memory allocations. Note, immutable is a strong guarantee here -- not - // just that the list cannot be modified via the reference but that the - // list can never be modified. - printer->Print(variables_, - "private com.google.protobuf.LazyStringList $name$_ = $empty_list$;\n"); - - printer->Print(variables_, - "private void ensure$capitalized_name$IsMutable() {\n" - " if (!$get_mutable_bit_builder$) {\n" - " $name$_ = new com.google.protobuf.LazyStringArrayList($name$_);\n" - " $set_mutable_bit_builder$;\n" - " }\n" - "}\n"); - - // Note: We return an unmodifiable list because otherwise the caller - // could hold on to the returned list and modify it after the message - // has been built, thus mutating the message which is supposed to be - // immutable. - WriteFieldDocComment(printer, descriptor_); - printer->Print(variables_, - "$deprecation$public java.util.List\n" - " get$capitalized_name$List() {\n" - " return java.util.Collections.unmodifiableList($name$_);\n" - "}\n"); - WriteFieldDocComment(printer, descriptor_); - printer->Print(variables_, - "$deprecation$public int get$capitalized_name$Count() {\n" - " return $name$_.size();\n" - "}\n"); - WriteFieldDocComment(printer, descriptor_); - printer->Print(variables_, - "$deprecation$public java.lang.String get$capitalized_name$(int index) {\n" - " return $name$_.get(index);\n" - "}\n"); - WriteFieldDocComment(printer, descriptor_); - printer->Print(variables_, - "$deprecation$public com.google.protobuf.ByteString\n" - " get$capitalized_name$Bytes(int index) {\n" - " return $name$_.getByteString(index);\n" - "}\n"); - WriteFieldDocComment(printer, descriptor_); - printer->Print(variables_, - "$deprecation$public Builder set$capitalized_name$(\n" - " int index, java.lang.String value) {\n" - "$null_check$" - " ensure$capitalized_name$IsMutable();\n" - " $name$_.set(index, value);\n" - " $on_changed$\n" - " return this;\n" - "}\n"); - WriteFieldDocComment(printer, descriptor_); - printer->Print(variables_, - "$deprecation$public Builder add$capitalized_name$(\n" - " java.lang.String value) {\n" - "$null_check$" - " ensure$capitalized_name$IsMutable();\n" - " $name$_.add(value);\n" - " $on_changed$\n" - " return this;\n" - "}\n"); - WriteFieldDocComment(printer, descriptor_); - printer->Print(variables_, - "$deprecation$public Builder addAll$capitalized_name$(\n" - " java.lang.Iterable values) {\n" - " ensure$capitalized_name$IsMutable();\n" - " super.addAll(values, $name$_);\n" - " $on_changed$\n" - " return this;\n" - "}\n"); - WriteFieldDocComment(printer, descriptor_); - printer->Print(variables_, - "$deprecation$public Builder clear$capitalized_name$() {\n" - " $name$_ = $empty_list$;\n" - " $clear_mutable_bit_builder$;\n" - " $on_changed$\n" - " return this;\n" - "}\n"); - - WriteFieldDocComment(printer, descriptor_); - printer->Print(variables_, - "$deprecation$public Builder add$capitalized_name$Bytes(\n" - " com.google.protobuf.ByteString value) {\n" - "$null_check$" - " ensure$capitalized_name$IsMutable();\n" - " $name$_.add(value);\n" - " $on_changed$\n" - " return this;\n" - "}\n"); -} - -void RepeatedStringFieldGenerator:: -GenerateFieldBuilderInitializationCode(io::Printer* printer) const { - // noop for primitives -} - -void RepeatedStringFieldGenerator:: -GenerateInitializationCode(io::Printer* printer) const { - printer->Print(variables_, "$name$_ = $empty_list$;\n"); -} - -void RepeatedStringFieldGenerator:: -GenerateBuilderClearCode(io::Printer* printer) const { - printer->Print(variables_, - "$name$_ = $empty_list$;\n" - "$clear_mutable_bit_builder$;\n"); -} - -void RepeatedStringFieldGenerator:: -GenerateMergingCode(io::Printer* printer) const { - // The code below does two optimizations: - // 1. If the other list is empty, there's nothing to do. This ensures we - // don't allocate a new array if we already have an immutable one. - // 2. If the other list is non-empty and our current list is empty, we can - // reuse the other list which is guaranteed to be immutable. - printer->Print(variables_, - "if (!other.$name$_.isEmpty()) {\n" - " if ($name$_.isEmpty()) {\n" - " $name$_ = other.$name$_;\n" - " $clear_mutable_bit_builder$;\n" - " } else {\n" - " ensure$capitalized_name$IsMutable();\n" - " $name$_.addAll(other.$name$_);\n" - " }\n" - " $on_changed$\n" - "}\n"); -} - -void RepeatedStringFieldGenerator:: -GenerateBuildingCode(io::Printer* printer) const { - // The code below ensures that the result has an immutable list. If our - // list is immutable, we can just reuse it. If not, we make it immutable. - - printer->Print(variables_, - "if ($get_mutable_bit_builder$) {\n" - " $name$_ = new com.google.protobuf.UnmodifiableLazyStringList(\n" - " $name$_);\n" - " $clear_mutable_bit_builder$;\n" - "}\n" - "result.$name$_ = $name$_;\n"); -} - -void RepeatedStringFieldGenerator:: -GenerateParsingCode(io::Printer* printer) const { - printer->Print(variables_, - "if (!$get_mutable_bit_parser$) {\n" - " $name$_ = new com.google.protobuf.LazyStringArrayList();\n" - " $set_mutable_bit_parser$;\n" - "}\n" - "$name$_.add(input.readBytes());\n"); -} - -void RepeatedStringFieldGenerator:: -GenerateParsingCodeFromPacked(io::Printer* printer) const { - printer->Print(variables_, - "int length = input.readRawVarint32();\n" - "int limit = input.pushLimit(length);\n" - "if (!$get_mutable_bit_parser$ && input.getBytesUntilLimit() > 0) {\n" - " $name$_ = new com.google.protobuf.LazyStringArrayList();\n" - " $set_mutable_bit_parser$;\n" - "}\n" - "while (input.getBytesUntilLimit() > 0) {\n" - " $name$.add(input.read$capitalized_type$());\n" - "}\n" - "input.popLimit(limit);\n"); -} - -void RepeatedStringFieldGenerator:: -GenerateParsingDoneCode(io::Printer* printer) const { - printer->Print(variables_, - "if ($get_mutable_bit_parser$) {\n" - " $name$_ = new com.google.protobuf.UnmodifiableLazyStringList($name$_);\n" - "}\n"); -} - -void RepeatedStringFieldGenerator:: -GenerateSerializationCode(io::Printer* printer) const { - if (descriptor_->options().packed()) { - printer->Print(variables_, - "if (get$capitalized_name$List().size() > 0) {\n" - " output.writeRawVarint32($tag$);\n" - " output.writeRawVarint32($name$MemoizedSerializedSize);\n" - "}\n" - "for (int i = 0; i < $name$_.size(); i++) {\n" - " output.write$capitalized_type$NoTag($name$_.get(i));\n" - "}\n"); - } else { - printer->Print(variables_, - "for (int i = 0; i < $name$_.size(); i++) {\n" - " output.writeBytes($number$, $name$_.getByteString(i));\n" - "}\n"); - } -} - -void RepeatedStringFieldGenerator:: -GenerateSerializedSizeCode(io::Printer* printer) const { - printer->Print(variables_, - "{\n" - " int dataSize = 0;\n"); - printer->Indent(); - - printer->Print(variables_, - "for (int i = 0; i < $name$_.size(); i++) {\n" - " dataSize += com.google.protobuf.CodedOutputStream\n" - " .computeBytesSizeNoTag($name$_.getByteString(i));\n" - "}\n"); - - printer->Print( - "size += dataSize;\n"); - - if (descriptor_->options().packed()) { - printer->Print(variables_, - "if (!get$capitalized_name$List().isEmpty()) {\n" - " size += $tag_size$;\n" - " size += com.google.protobuf.CodedOutputStream\n" - " .computeInt32SizeNoTag(dataSize);\n" - "}\n"); - } else { - printer->Print(variables_, - "size += $tag_size$ * get$capitalized_name$List().size();\n"); - } - - // cache the data size for packed fields. - if (descriptor_->options().packed()) { - printer->Print(variables_, - "$name$MemoizedSerializedSize = dataSize;\n"); - } - - printer->Outdent(); - printer->Print("}\n"); -} - -void RepeatedStringFieldGenerator:: -GenerateEqualsCode(io::Printer* printer) const { - printer->Print(variables_, - "result = result && get$capitalized_name$List()\n" - " .equals(other.get$capitalized_name$List());\n"); -} - -void RepeatedStringFieldGenerator:: -GenerateHashCode(io::Printer* printer) const { - printer->Print(variables_, - "if (get$capitalized_name$Count() > 0) {\n" - " hash = (37 * hash) + $constant_name$;\n" - " hash = (53 * hash) + get$capitalized_name$List().hashCode();\n" - "}\n"); -} - -string RepeatedStringFieldGenerator::GetBoxedType() const { - return "String"; -} - -} // namespace java -} // namespace compiler -} // namespace protobuf -} // namespace google diff --git a/modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/java/java_string_field.h b/modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/java/java_string_field.h deleted file mode 100644 index 4f7532f44..000000000 --- a/modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/java/java_string_field.h +++ /dev/null @@ -1,122 +0,0 @@ -// Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// http://code.google.com/p/protobuf/ -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -// Author: kenton@google.com (Kenton Varda) -// Author: jonp@google.com (Jon Perlow) -// Based on original Protocol Buffers design by -// Sanjay Ghemawat, Jeff Dean, and others. - -#ifndef GOOGLE_PROTOBUF_COMPILER_JAVA_STRING_FIELD_H__ -#define GOOGLE_PROTOBUF_COMPILER_JAVA_STRING_FIELD_H__ - -#include -#include -#include - -namespace google { -namespace protobuf { -namespace compiler { -namespace java { - -class StringFieldGenerator : public FieldGenerator { - public: - explicit StringFieldGenerator(const FieldDescriptor* descriptor, - int messageBitIndex, int builderBitIndex); - ~StringFieldGenerator(); - - // implements FieldGenerator --------------------------------------- - int GetNumBitsForMessage() const; - int GetNumBitsForBuilder() const; - void GenerateInterfaceMembers(io::Printer* printer) const; - void GenerateMembers(io::Printer* printer) const; - void GenerateBuilderMembers(io::Printer* printer) const; - void GenerateInitializationCode(io::Printer* printer) const; - void GenerateBuilderClearCode(io::Printer* printer) const; - void GenerateMergingCode(io::Printer* printer) const; - void GenerateBuildingCode(io::Printer* printer) const; - void GenerateParsingCode(io::Printer* printer) const; - void GenerateParsingDoneCode(io::Printer* printer) const; - void GenerateSerializationCode(io::Printer* printer) const; - void GenerateSerializedSizeCode(io::Printer* printer) const; - void GenerateFieldBuilderInitializationCode(io::Printer* printer) const; - void GenerateEqualsCode(io::Printer* printer) const; - void GenerateHashCode(io::Printer* printer) const; - string GetBoxedType() const; - - private: - const FieldDescriptor* descriptor_; - map variables_; - const int messageBitIndex_; - const int builderBitIndex_; - - GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(StringFieldGenerator); -}; - -class RepeatedStringFieldGenerator : public FieldGenerator { - public: - explicit RepeatedStringFieldGenerator(const FieldDescriptor* descriptor, - int messageBitIndex, int builderBitIndex); - ~RepeatedStringFieldGenerator(); - - // implements FieldGenerator --------------------------------------- - int GetNumBitsForMessage() const; - int GetNumBitsForBuilder() const; - void GenerateInterfaceMembers(io::Printer* printer) const; - void GenerateMembers(io::Printer* printer) const; - void GenerateBuilderMembers(io::Printer* printer) const; - void GenerateInitializationCode(io::Printer* printer) const; - void GenerateBuilderClearCode(io::Printer* printer) const; - void GenerateMergingCode(io::Printer* printer) const; - void GenerateBuildingCode(io::Printer* printer) const; - void GenerateParsingCode(io::Printer* printer) const; - void GenerateParsingCodeFromPacked(io::Printer* printer) const; - void GenerateParsingDoneCode(io::Printer* printer) const; - void GenerateSerializationCode(io::Printer* printer) const; - void GenerateSerializedSizeCode(io::Printer* printer) const; - void GenerateFieldBuilderInitializationCode(io::Printer* printer) const; - void GenerateEqualsCode(io::Printer* printer) const; - void GenerateHashCode(io::Printer* printer) const; - string GetBoxedType() const; - - private: - const FieldDescriptor* descriptor_; - map variables_; - const int messageBitIndex_; - const int builderBitIndex_; - - GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(RepeatedStringFieldGenerator); -}; - -} // namespace java -} // namespace compiler -} // namespace protobuf - -} // namespace google -#endif // GOOGLE_PROTOBUF_COMPILER_JAVA_STRING_FIELD_H__ diff --git a/modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/main.cc b/modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/main.cc deleted file mode 100644 index 1afc5d611..000000000 --- a/modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/main.cc +++ /dev/null @@ -1,61 +0,0 @@ -// Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// http://code.google.com/p/protobuf/ -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -// Author: kenton@google.com (Kenton Varda) - -#include -#include -#include -#include - - -int main(int argc, char* argv[]) { - - google::protobuf::compiler::CommandLineInterface cli; - cli.AllowPlugins("protoc-"); - - // Proto2 C++ - google::protobuf::compiler::cpp::CppGenerator cpp_generator; - cli.RegisterGenerator("--cpp_out", "--cpp_opt", &cpp_generator, - "Generate C++ header and source."); - - // Proto2 Java - google::protobuf::compiler::java::JavaGenerator java_generator; - cli.RegisterGenerator("--java_out", &java_generator, - "Generate Java source file."); - - - // Proto2 Python - google::protobuf::compiler::python::Generator py_generator; - cli.RegisterGenerator("--python_out", &py_generator, - "Generate Python source file."); - - return cli.Run(argc, argv); -} diff --git a/modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/mock_code_generator.cc b/modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/mock_code_generator.cc deleted file mode 100644 index 0e35ed19c..000000000 --- a/modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/mock_code_generator.cc +++ /dev/null @@ -1,241 +0,0 @@ -// Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// http://code.google.com/p/protobuf/ -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -// Author: kenton@google.com (Kenton Varda) - -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -namespace google { -namespace protobuf { -namespace compiler { - -// Returns the list of the names of files in all_files in the form of a -// comma-separated string. -string CommaSeparatedList(const vector all_files) { - vector names; - for (int i = 0; i < all_files.size(); i++) { - names.push_back(all_files[i]->name()); - } - return JoinStrings(names, ","); -} - -static const char* kFirstInsertionPointName = "first_mock_insertion_point"; -static const char* kSecondInsertionPointName = "second_mock_insertion_point"; -static const char* kFirstInsertionPoint = - "# @@protoc_insertion_point(first_mock_insertion_point) is here\n"; -static const char* kSecondInsertionPoint = - " # @@protoc_insertion_point(second_mock_insertion_point) is here\n"; - -MockCodeGenerator::MockCodeGenerator(const string& name) - : name_(name) {} - -MockCodeGenerator::~MockCodeGenerator() {} - -void MockCodeGenerator::ExpectGenerated( - const string& name, - const string& parameter, - const string& insertions, - const string& file, - const string& first_message_name, - const string& first_parsed_file_name, - const string& output_directory) { - string content; - ASSERT_TRUE(File::ReadFileToString( - output_directory + "/" + GetOutputFileName(name, file), &content)); - - vector lines; - SplitStringUsing(content, "\n", &lines); - - while (!lines.empty() && lines.back().empty()) { - lines.pop_back(); - } - for (int i = 0; i < lines.size(); i++) { - lines[i] += "\n"; - } - - vector insertion_list; - if (!insertions.empty()) { - SplitStringUsing(insertions, ",", &insertion_list); - } - - ASSERT_EQ(lines.size(), 3 + insertion_list.size() * 2); - EXPECT_EQ(GetOutputFileContent(name, parameter, file, - first_parsed_file_name, first_message_name), - lines[0]); - - EXPECT_EQ(kFirstInsertionPoint, lines[1 + insertion_list.size()]); - EXPECT_EQ(kSecondInsertionPoint, lines[2 + insertion_list.size() * 2]); - - for (int i = 0; i < insertion_list.size(); i++) { - EXPECT_EQ(GetOutputFileContent(insertion_list[i], "first_insert", - file, file, first_message_name), - lines[1 + i]); - // Second insertion point is indented, so the inserted text should - // automatically be indented too. - EXPECT_EQ(" " + GetOutputFileContent(insertion_list[i], "second_insert", - file, file, first_message_name), - lines[2 + insertion_list.size() + i]); - } -} - -bool MockCodeGenerator::Generate( - const FileDescriptor* file, - const string& parameter, - GeneratorContext* context, - string* error) const { - for (int i = 0; i < file->message_type_count(); i++) { - if (HasPrefixString(file->message_type(i)->name(), "MockCodeGenerator_")) { - string command = StripPrefixString(file->message_type(i)->name(), - "MockCodeGenerator_"); - if (command == "Error") { - *error = "Saw message type MockCodeGenerator_Error."; - return false; - } else if (command == "Exit") { - cerr << "Saw message type MockCodeGenerator_Exit." << endl; - exit(123); - } else if (command == "Abort") { - cerr << "Saw message type MockCodeGenerator_Abort." << endl; - abort(); - } else if (command == "HasSourceCodeInfo") { - FileDescriptorProto file_descriptor_proto; - file->CopySourceCodeInfoTo(&file_descriptor_proto); - bool has_source_code_info = - file_descriptor_proto.has_source_code_info() && - file_descriptor_proto.source_code_info().location_size() > 0; - cerr << "Saw message type MockCodeGenerator_HasSourceCodeInfo: " - << has_source_code_info << "." << endl; - abort(); - } else { - GOOGLE_LOG(FATAL) << "Unknown MockCodeGenerator command: " << command; - } - } - } - - if (HasPrefixString(parameter, "insert=")) { - vector insert_into; - SplitStringUsing(StripPrefixString(parameter, "insert="), - ",", &insert_into); - - for (int i = 0; i < insert_into.size(); i++) { - { - scoped_ptr output( - context->OpenForInsert( - GetOutputFileName(insert_into[i], file), - kFirstInsertionPointName)); - io::Printer printer(output.get(), '$'); - printer.PrintRaw(GetOutputFileContent(name_, "first_insert", - file, context)); - if (printer.failed()) { - *error = "MockCodeGenerator detected write error."; - return false; - } - } - - { - scoped_ptr output( - context->OpenForInsert( - GetOutputFileName(insert_into[i], file), - kSecondInsertionPointName)); - io::Printer printer(output.get(), '$'); - printer.PrintRaw(GetOutputFileContent(name_, "second_insert", - file, context)); - if (printer.failed()) { - *error = "MockCodeGenerator detected write error."; - return false; - } - } - } - } else { - scoped_ptr output( - context->Open(GetOutputFileName(name_, file))); - - io::Printer printer(output.get(), '$'); - printer.PrintRaw(GetOutputFileContent(name_, parameter, - file, context)); - printer.PrintRaw(kFirstInsertionPoint); - printer.PrintRaw(kSecondInsertionPoint); - - if (printer.failed()) { - *error = "MockCodeGenerator detected write error."; - return false; - } - } - - return true; -} - -string MockCodeGenerator::GetOutputFileName(const string& generator_name, - const FileDescriptor* file) { - return GetOutputFileName(generator_name, file->name()); -} - -string MockCodeGenerator::GetOutputFileName(const string& generator_name, - const string& file) { - return file + ".MockCodeGenerator." + generator_name; -} - -string MockCodeGenerator::GetOutputFileContent( - const string& generator_name, - const string& parameter, - const FileDescriptor* file, - GeneratorContext *context) { - vector all_files; - context->ListParsedFiles(&all_files); - return GetOutputFileContent( - generator_name, parameter, file->name(), - CommaSeparatedList(all_files), - file->message_type_count() > 0 ? - file->message_type(0)->name() : "(none)"); -} - -string MockCodeGenerator::GetOutputFileContent( - const string& generator_name, - const string& parameter, - const string& file, - const string& parsed_file_list, - const string& first_message_name) { - return strings::Substitute("$0: $1, $2, $3, $4\n", - generator_name, parameter, file, - first_message_name, parsed_file_list); -} - -} // namespace compiler -} // namespace protobuf -} // namespace google diff --git a/modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/mock_code_generator.h b/modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/mock_code_generator.h deleted file mode 100644 index 506fd2070..000000000 --- a/modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/mock_code_generator.h +++ /dev/null @@ -1,117 +0,0 @@ -// Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// http://code.google.com/p/protobuf/ -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -// Author: kenton@google.com (Kenton Varda) - -#ifndef GOOGLE_PROTOBUF_COMPILER_MOCK_CODE_GENERATOR_H__ -#define GOOGLE_PROTOBUF_COMPILER_MOCK_CODE_GENERATOR_H__ - -#include -#include - -namespace google { -namespace protobuf { -namespace compiler { - -// A mock CodeGenerator, used by command_line_interface_unittest. This is in -// its own file so that it can be used both directly and as a plugin. -// -// Generate() produces some output which can be checked by ExpectCalled(). The -// generator can run in a different process (e.g. a plugin). -// -// If the parameter is "insert=NAMES", the MockCodeGenerator will insert lines -// into the files generated by other MockCodeGenerators instead of creating -// its own file. NAMES is a comma-separated list of the names of those other -// MockCodeGenerators. -// -// MockCodeGenerator will also modify its behavior slightly if the input file -// contains a message type with one of the following names: -// MockCodeGenerator_Error: Causes Generate() to return false and set the -// error message to "Saw message type MockCodeGenerator_Error." -// MockCodeGenerator_Exit: Generate() prints "Saw message type -// MockCodeGenerator_Exit." to stderr and then calls exit(123). -// MockCodeGenerator_Abort: Generate() prints "Saw message type -// MockCodeGenerator_Abort." to stderr and then calls abort(). -// MockCodeGenerator_HasSourceCodeInfo: Causes Generate() to abort after -// printing "Saw message type MockCodeGenerator_HasSourceCodeInfo: FOO." to -// stderr, where FOO is "1" if the supplied FileDescriptorProto has source -// code info, and "0" otherwise. -class MockCodeGenerator : public CodeGenerator { - public: - MockCodeGenerator(const string& name); - virtual ~MockCodeGenerator(); - - // Expect (via gTest) that a MockCodeGenerator with the given name was called - // with the given parameters by inspecting the output location. - // - // |insertions| is a comma-separated list of names of MockCodeGenerators which - // should have inserted lines into this file. - // |parsed_file_list| is a comma-separated list of names of the files - // that are being compiled together in this run. - static void ExpectGenerated(const string& name, - const string& parameter, - const string& insertions, - const string& file, - const string& first_message_name, - const string& parsed_file_list, - const string& output_directory); - - // Get the name of the file which would be written by the given generator. - static string GetOutputFileName(const string& generator_name, - const FileDescriptor* file); - static string GetOutputFileName(const string& generator_name, - const string& file); - - // implements CodeGenerator ---------------------------------------- - - virtual bool Generate(const FileDescriptor* file, - const string& parameter, - GeneratorContext* context, - string* error) const; - - private: - string name_; - - static string GetOutputFileContent(const string& generator_name, - const string& parameter, - const FileDescriptor* file, - GeneratorContext *context); - static string GetOutputFileContent(const string& generator_name, - const string& parameter, - const string& file, - const string& parsed_file_list, - const string& first_message_name); -}; - -} // namespace compiler -} // namespace protobuf - -} // namespace google -#endif // GOOGLE_PROTOBUF_COMPILER_MOCK_CODE_GENERATOR_H__ diff --git a/modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/package_info.h b/modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/package_info.h deleted file mode 100644 index b89712674..000000000 --- a/modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/package_info.h +++ /dev/null @@ -1,64 +0,0 @@ -// Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// http://code.google.com/p/protobuf/ -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -// Author: kenton@google.com (Kenton Varda) -// Based on original Protocol Buffers design by -// Sanjay Ghemawat, Jeff Dean, and others. -// -// This file exists solely to document the google::protobuf::compiler namespace. -// It is not compiled into anything, but it may be read by an automated -// documentation generator. - -namespace google { - -namespace protobuf { - -// Implementation of the Protocol Buffer compiler. -// -// This package contains code for parsing .proto files and generating code -// based on them. There are two reasons you might be interested in this -// package: -// - You want to parse .proto files at runtime. In this case, you should -// look at importer.h. Since this functionality is widely useful, it is -// included in the libprotobuf base library; you do not have to link against -// libprotoc. -// - You want to write a custom protocol compiler which generates different -// kinds of code, e.g. code in a different language which is not supported -// by the official compiler. For this purpose, command_line_interface.h -// provides you with a complete compiler front-end, so all you need to do -// is write a custom implementation of CodeGenerator and a trivial main() -// function. You can even make your compiler support the official languages -// in addition to your own. Since this functionality is only useful to those -// writing custom compilers, it is in a separate library called "libprotoc" -// which you will have to link against. -namespace compiler {} - -} // namespace protobuf -} // namespace google diff --git a/modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/parser.cc b/modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/parser.cc deleted file mode 100644 index 23aa01ced..000000000 --- a/modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/parser.cc +++ /dev/null @@ -1,1611 +0,0 @@ -// Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// http://code.google.com/p/protobuf/ -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -// Author: kenton@google.com (Kenton Varda) -// Based on original Protocol Buffers design by -// Sanjay Ghemawat, Jeff Dean, and others. -// -// Recursive descent FTW. - -#include -#include -#include - - -#include -#include -#include -#include -#include -#include -#include -#include - -namespace google { -namespace protobuf { -namespace compiler { - -using internal::WireFormat; - -namespace { - -typedef hash_map TypeNameMap; - -TypeNameMap MakeTypeNameTable() { - TypeNameMap result; - - result["double" ] = FieldDescriptorProto::TYPE_DOUBLE; - result["float" ] = FieldDescriptorProto::TYPE_FLOAT; - result["uint64" ] = FieldDescriptorProto::TYPE_UINT64; - result["fixed64" ] = FieldDescriptorProto::TYPE_FIXED64; - result["fixed32" ] = FieldDescriptorProto::TYPE_FIXED32; - result["bool" ] = FieldDescriptorProto::TYPE_BOOL; - result["string" ] = FieldDescriptorProto::TYPE_STRING; - result["group" ] = FieldDescriptorProto::TYPE_GROUP; - - result["bytes" ] = FieldDescriptorProto::TYPE_BYTES; - result["uint32" ] = FieldDescriptorProto::TYPE_UINT32; - result["sfixed32"] = FieldDescriptorProto::TYPE_SFIXED32; - result["sfixed64"] = FieldDescriptorProto::TYPE_SFIXED64; - result["int32" ] = FieldDescriptorProto::TYPE_INT32; - result["int64" ] = FieldDescriptorProto::TYPE_INT64; - result["sint32" ] = FieldDescriptorProto::TYPE_SINT32; - result["sint64" ] = FieldDescriptorProto::TYPE_SINT64; - - return result; -} - -const TypeNameMap kTypeNames = MakeTypeNameTable(); - -} // anonymous namespace - -// Makes code slightly more readable. The meaning of "DO(foo)" is -// "Execute foo and fail if it fails.", where failure is indicated by -// returning false. -#define DO(STATEMENT) if (STATEMENT) {} else return false - -// =================================================================== - -Parser::Parser() - : input_(NULL), - error_collector_(NULL), - source_location_table_(NULL), - had_errors_(false), - require_syntax_identifier_(false), - stop_after_syntax_identifier_(false) { -} - -Parser::~Parser() { -} - -// =================================================================== - -inline bool Parser::LookingAt(const char* text) { - return input_->current().text == text; -} - -inline bool Parser::LookingAtType(io::Tokenizer::TokenType token_type) { - return input_->current().type == token_type; -} - -inline bool Parser::AtEnd() { - return LookingAtType(io::Tokenizer::TYPE_END); -} - -bool Parser::TryConsume(const char* text) { - if (LookingAt(text)) { - input_->Next(); - return true; - } else { - return false; - } -} - -bool Parser::Consume(const char* text, const char* error) { - if (TryConsume(text)) { - return true; - } else { - AddError(error); - return false; - } -} - -bool Parser::Consume(const char* text) { - if (TryConsume(text)) { - return true; - } else { - AddError("Expected \"" + string(text) + "\"."); - return false; - } -} - -bool Parser::ConsumeIdentifier(string* output, const char* error) { - if (LookingAtType(io::Tokenizer::TYPE_IDENTIFIER)) { - *output = input_->current().text; - input_->Next(); - return true; - } else { - AddError(error); - return false; - } -} - -bool Parser::ConsumeInteger(int* output, const char* error) { - if (LookingAtType(io::Tokenizer::TYPE_INTEGER)) { - uint64 value = 0; - if (!io::Tokenizer::ParseInteger(input_->current().text, - kint32max, &value)) { - AddError("Integer out of range."); - // We still return true because we did, in fact, parse an integer. - } - *output = value; - input_->Next(); - return true; - } else { - AddError(error); - return false; - } -} - -bool Parser::ConsumeSignedInteger(int* output, const char* error) { - bool is_negative = false; - uint64 max_value = kint32max; - if (TryConsume("-")) { - is_negative = true; - max_value += 1; - } - uint64 value = 0; - DO(ConsumeInteger64(max_value, &value, error)); - if (is_negative) value *= -1; - *output = value; - return true; -} - -bool Parser::ConsumeInteger64(uint64 max_value, uint64* output, - const char* error) { - if (LookingAtType(io::Tokenizer::TYPE_INTEGER)) { - if (!io::Tokenizer::ParseInteger(input_->current().text, max_value, - output)) { - AddError("Integer out of range."); - // We still return true because we did, in fact, parse an integer. - *output = 0; - } - input_->Next(); - return true; - } else { - AddError(error); - return false; - } -} - -bool Parser::ConsumeNumber(double* output, const char* error) { - if (LookingAtType(io::Tokenizer::TYPE_FLOAT)) { - *output = io::Tokenizer::ParseFloat(input_->current().text); - input_->Next(); - return true; - } else if (LookingAtType(io::Tokenizer::TYPE_INTEGER)) { - // Also accept integers. - uint64 value = 0; - if (!io::Tokenizer::ParseInteger(input_->current().text, - kuint64max, &value)) { - AddError("Integer out of range."); - // We still return true because we did, in fact, parse a number. - } - *output = value; - input_->Next(); - return true; - } else if (LookingAt("inf")) { - *output = numeric_limits::infinity(); - input_->Next(); - return true; - } else if (LookingAt("nan")) { - *output = numeric_limits::quiet_NaN(); - input_->Next(); - return true; - } else { - AddError(error); - return false; - } -} - -bool Parser::ConsumeString(string* output, const char* error) { - if (LookingAtType(io::Tokenizer::TYPE_STRING)) { - io::Tokenizer::ParseString(input_->current().text, output); - input_->Next(); - // Allow C++ like concatenation of adjacent string tokens. - while (LookingAtType(io::Tokenizer::TYPE_STRING)) { - io::Tokenizer::ParseStringAppend(input_->current().text, output); - input_->Next(); - } - return true; - } else { - AddError(error); - return false; - } -} - -bool Parser::TryConsumeEndOfDeclaration(const char* text, - const LocationRecorder* location) { - if (LookingAt(text)) { - string leading, trailing; - input_->NextWithComments(&trailing, NULL, &leading); - - // Save the leading comments for next time, and recall the leading comments - // from last time. - leading.swap(upcoming_doc_comments_); - - if (location != NULL) { - location->AttachComments(&leading, &trailing); - } - return true; - } else { - return false; - } -} - -bool Parser::ConsumeEndOfDeclaration(const char* text, - const LocationRecorder* location) { - if (TryConsumeEndOfDeclaration(text, location)) { - return true; - } else { - AddError("Expected \"" + string(text) + "\"."); - return false; - } -} - -// ------------------------------------------------------------------- - -void Parser::AddError(int line, int column, const string& error) { - if (error_collector_ != NULL) { - error_collector_->AddError(line, column, error); - } - had_errors_ = true; -} - -void Parser::AddError(const string& error) { - AddError(input_->current().line, input_->current().column, error); -} - -// ------------------------------------------------------------------- - -Parser::LocationRecorder::LocationRecorder(Parser* parser) - : parser_(parser), - location_(parser_->source_code_info_->add_location()) { - location_->add_span(parser_->input_->current().line); - location_->add_span(parser_->input_->current().column); -} - -Parser::LocationRecorder::LocationRecorder(const LocationRecorder& parent) { - Init(parent); -} - -Parser::LocationRecorder::LocationRecorder(const LocationRecorder& parent, - int path1) { - Init(parent); - AddPath(path1); -} - -Parser::LocationRecorder::LocationRecorder(const LocationRecorder& parent, - int path1, int path2) { - Init(parent); - AddPath(path1); - AddPath(path2); -} - -void Parser::LocationRecorder::Init(const LocationRecorder& parent) { - parser_ = parent.parser_; - location_ = parser_->source_code_info_->add_location(); - location_->mutable_path()->CopyFrom(parent.location_->path()); - - location_->add_span(parser_->input_->current().line); - location_->add_span(parser_->input_->current().column); -} - -Parser::LocationRecorder::~LocationRecorder() { - if (location_->span_size() <= 2) { - EndAt(parser_->input_->previous()); - } -} - -void Parser::LocationRecorder::AddPath(int path_component) { - location_->add_path(path_component); -} - -void Parser::LocationRecorder::StartAt(const io::Tokenizer::Token& token) { - location_->set_span(0, token.line); - location_->set_span(1, token.column); -} - -void Parser::LocationRecorder::EndAt(const io::Tokenizer::Token& token) { - if (token.line != location_->span(0)) { - location_->add_span(token.line); - } - location_->add_span(token.end_column); -} - -void Parser::LocationRecorder::RecordLegacyLocation(const Message* descriptor, - DescriptorPool::ErrorCollector::ErrorLocation location) { - if (parser_->source_location_table_ != NULL) { - parser_->source_location_table_->Add( - descriptor, location, location_->span(0), location_->span(1)); - } -} - -void Parser::LocationRecorder::AttachComments( - string* leading, string* trailing) const { - GOOGLE_CHECK(!location_->has_leading_comments()); - GOOGLE_CHECK(!location_->has_trailing_comments()); - - if (!leading->empty()) { - location_->mutable_leading_comments()->swap(*leading); - } - if (!trailing->empty()) { - location_->mutable_trailing_comments()->swap(*trailing); - } -} - -// ------------------------------------------------------------------- - -void Parser::SkipStatement() { - while (true) { - if (AtEnd()) { - return; - } else if (LookingAtType(io::Tokenizer::TYPE_SYMBOL)) { - if (TryConsumeEndOfDeclaration(";", NULL)) { - return; - } else if (TryConsume("{")) { - SkipRestOfBlock(); - return; - } else if (LookingAt("}")) { - return; - } - } - input_->Next(); - } -} - -void Parser::SkipRestOfBlock() { - while (true) { - if (AtEnd()) { - return; - } else if (LookingAtType(io::Tokenizer::TYPE_SYMBOL)) { - if (TryConsumeEndOfDeclaration("}", NULL)) { - return; - } else if (TryConsume("{")) { - SkipRestOfBlock(); - } - } - input_->Next(); - } -} - -// =================================================================== - -bool Parser::Parse(io::Tokenizer* input, FileDescriptorProto* file) { - input_ = input; - had_errors_ = false; - syntax_identifier_.clear(); - - // Note that |file| could be NULL at this point if - // stop_after_syntax_identifier_ is true. So, we conservatively allocate - // SourceCodeInfo on the stack, then swap it into the FileDescriptorProto - // later on. - SourceCodeInfo source_code_info; - source_code_info_ = &source_code_info; - - if (LookingAtType(io::Tokenizer::TYPE_START)) { - // Advance to first token. - input_->NextWithComments(NULL, NULL, &upcoming_doc_comments_); - } - - { - LocationRecorder root_location(this); - - if (require_syntax_identifier_ || LookingAt("syntax")) { - if (!ParseSyntaxIdentifier()) { - // Don't attempt to parse the file if we didn't recognize the syntax - // identifier. - return false; - } - } else if (!stop_after_syntax_identifier_) { - syntax_identifier_ = "proto2"; - } - - if (stop_after_syntax_identifier_) return !had_errors_; - - // Repeatedly parse statements until we reach the end of the file. - while (!AtEnd()) { - if (!ParseTopLevelStatement(file, root_location)) { - // This statement failed to parse. Skip it, but keep looping to parse - // other statements. - SkipStatement(); - - if (LookingAt("}")) { - AddError("Unmatched \"}\"."); - input_->NextWithComments(NULL, NULL, &upcoming_doc_comments_); - } - } - } - } - - input_ = NULL; - source_code_info_ = NULL; - source_code_info.Swap(file->mutable_source_code_info()); - return !had_errors_; -} - -bool Parser::ParseSyntaxIdentifier() { - DO(Consume("syntax", "File must begin with 'syntax = \"proto2\";'.")); - DO(Consume("=")); - io::Tokenizer::Token syntax_token = input_->current(); - string syntax; - DO(ConsumeString(&syntax, "Expected syntax identifier.")); - DO(ConsumeEndOfDeclaration(";", NULL)); - - syntax_identifier_ = syntax; - - if (syntax != "proto2" && !stop_after_syntax_identifier_) { - AddError(syntax_token.line, syntax_token.column, - "Unrecognized syntax identifier \"" + syntax + "\". This parser " - "only recognizes \"proto2\"."); - return false; - } - - return true; -} - -bool Parser::ParseTopLevelStatement(FileDescriptorProto* file, - const LocationRecorder& root_location) { - if (TryConsumeEndOfDeclaration(";", NULL)) { - // empty statement; ignore - return true; - } else if (LookingAt("message")) { - LocationRecorder location(root_location, - FileDescriptorProto::kMessageTypeFieldNumber, file->message_type_size()); - return ParseMessageDefinition(file->add_message_type(), location); - } else if (LookingAt("enum")) { - LocationRecorder location(root_location, - FileDescriptorProto::kEnumTypeFieldNumber, file->enum_type_size()); - return ParseEnumDefinition(file->add_enum_type(), location); - } else if (LookingAt("service")) { - LocationRecorder location(root_location, - FileDescriptorProto::kServiceFieldNumber, file->service_size()); - return ParseServiceDefinition(file->add_service(), location); - } else if (LookingAt("extend")) { - LocationRecorder location(root_location, - FileDescriptorProto::kExtensionFieldNumber); - return ParseExtend(file->mutable_extension(), - file->mutable_message_type(), - root_location, - FileDescriptorProto::kMessageTypeFieldNumber, - location); - } else if (LookingAt("import")) { - return ParseImport(file->mutable_dependency(), - file->mutable_public_dependency(), - file->mutable_weak_dependency(), - root_location); - } else if (LookingAt("package")) { - return ParsePackage(file, root_location); - } else if (LookingAt("option")) { - LocationRecorder location(root_location, - FileDescriptorProto::kOptionsFieldNumber); - return ParseOption(file->mutable_options(), location, OPTION_STATEMENT); - } else { - AddError("Expected top-level statement (e.g. \"message\")."); - return false; - } -} - -// ------------------------------------------------------------------- -// Messages - -bool Parser::ParseMessageDefinition(DescriptorProto* message, - const LocationRecorder& message_location) { - DO(Consume("message")); - { - LocationRecorder location(message_location, - DescriptorProto::kNameFieldNumber); - location.RecordLegacyLocation( - message, DescriptorPool::ErrorCollector::NAME); - DO(ConsumeIdentifier(message->mutable_name(), "Expected message name.")); - } - DO(ParseMessageBlock(message, message_location)); - return true; -} - -namespace { - -const int kMaxExtensionRangeSentinel = -1; - -bool IsMessageSetWireFormatMessage(const DescriptorProto& message) { - const MessageOptions& options = message.options(); - for (int i = 0; i < options.uninterpreted_option_size(); ++i) { - const UninterpretedOption& uninterpreted = options.uninterpreted_option(i); - if (uninterpreted.name_size() == 1 && - uninterpreted.name(0).name_part() == "message_set_wire_format" && - uninterpreted.identifier_value() == "true") { - return true; - } - } - return false; -} - -// Modifies any extension ranges that specified 'max' as the end of the -// extension range, and sets them to the type-specific maximum. The actual max -// tag number can only be determined after all options have been parsed. -void AdjustExtensionRangesWithMaxEndNumber(DescriptorProto* message) { - const bool is_message_set = IsMessageSetWireFormatMessage(*message); - const int max_extension_number = is_message_set ? - kint32max : - FieldDescriptor::kMaxNumber + 1; - for (int i = 0; i < message->extension_range_size(); ++i) { - if (message->extension_range(i).end() == kMaxExtensionRangeSentinel) { - message->mutable_extension_range(i)->set_end(max_extension_number); - } - } -} - -} // namespace - -bool Parser::ParseMessageBlock(DescriptorProto* message, - const LocationRecorder& message_location) { - DO(ConsumeEndOfDeclaration("{", &message_location)); - - while (!TryConsumeEndOfDeclaration("}", NULL)) { - if (AtEnd()) { - AddError("Reached end of input in message definition (missing '}')."); - return false; - } - - if (!ParseMessageStatement(message, message_location)) { - // This statement failed to parse. Skip it, but keep looping to parse - // other statements. - SkipStatement(); - } - } - - if (message->extension_range_size() > 0) { - AdjustExtensionRangesWithMaxEndNumber(message); - } - return true; -} - -bool Parser::ParseMessageStatement(DescriptorProto* message, - const LocationRecorder& message_location) { - if (TryConsumeEndOfDeclaration(";", NULL)) { - // empty statement; ignore - return true; - } else if (LookingAt("message")) { - LocationRecorder location(message_location, - DescriptorProto::kNestedTypeFieldNumber, - message->nested_type_size()); - return ParseMessageDefinition(message->add_nested_type(), location); - } else if (LookingAt("enum")) { - LocationRecorder location(message_location, - DescriptorProto::kEnumTypeFieldNumber, - message->enum_type_size()); - return ParseEnumDefinition(message->add_enum_type(), location); - } else if (LookingAt("extensions")) { - LocationRecorder location(message_location, - DescriptorProto::kExtensionRangeFieldNumber); - return ParseExtensions(message, location); - } else if (LookingAt("extend")) { - LocationRecorder location(message_location, - DescriptorProto::kExtensionFieldNumber); - return ParseExtend(message->mutable_extension(), - message->mutable_nested_type(), - message_location, - DescriptorProto::kNestedTypeFieldNumber, - location); - } else if (LookingAt("option")) { - LocationRecorder location(message_location, - DescriptorProto::kOptionsFieldNumber); - return ParseOption(message->mutable_options(), location, OPTION_STATEMENT); - } else { - LocationRecorder location(message_location, - DescriptorProto::kFieldFieldNumber, - message->field_size()); - return ParseMessageField(message->add_field(), - message->mutable_nested_type(), - message_location, - DescriptorProto::kNestedTypeFieldNumber, - location); - } -} - -bool Parser::ParseMessageField(FieldDescriptorProto* field, - RepeatedPtrField* messages, - const LocationRecorder& parent_location, - int location_field_number_for_nested_type, - const LocationRecorder& field_location) { - // Parse label and type. - io::Tokenizer::Token label_token = input_->current(); - { - LocationRecorder location(field_location, - FieldDescriptorProto::kLabelFieldNumber); - FieldDescriptorProto::Label label; - DO(ParseLabel(&label)); - field->set_label(label); - } - - { - LocationRecorder location(field_location); // add path later - location.RecordLegacyLocation(field, DescriptorPool::ErrorCollector::TYPE); - - FieldDescriptorProto::Type type = FieldDescriptorProto::TYPE_INT32; - string type_name; - DO(ParseType(&type, &type_name)); - if (type_name.empty()) { - location.AddPath(FieldDescriptorProto::kTypeFieldNumber); - field->set_type(type); - } else { - location.AddPath(FieldDescriptorProto::kTypeNameFieldNumber); - field->set_type_name(type_name); - } - } - - // Parse name and '='. - io::Tokenizer::Token name_token = input_->current(); - { - LocationRecorder location(field_location, - FieldDescriptorProto::kNameFieldNumber); - location.RecordLegacyLocation(field, DescriptorPool::ErrorCollector::NAME); - DO(ConsumeIdentifier(field->mutable_name(), "Expected field name.")); - } - DO(Consume("=", "Missing field number.")); - - // Parse field number. - { - LocationRecorder location(field_location, - FieldDescriptorProto::kNumberFieldNumber); - location.RecordLegacyLocation( - field, DescriptorPool::ErrorCollector::NUMBER); - int number; - DO(ConsumeInteger(&number, "Expected field number.")); - field->set_number(number); - } - - // Parse options. - DO(ParseFieldOptions(field, field_location)); - - // Deal with groups. - if (field->has_type() && field->type() == FieldDescriptorProto::TYPE_GROUP) { - // Awkward: Since a group declares both a message type and a field, we - // have to create overlapping locations. - LocationRecorder group_location(parent_location); - group_location.StartAt(label_token); - group_location.AddPath(location_field_number_for_nested_type); - group_location.AddPath(messages->size()); - - DescriptorProto* group = messages->Add(); - group->set_name(field->name()); - - // Record name location to match the field name's location. - { - LocationRecorder location(group_location, - DescriptorProto::kNameFieldNumber); - location.StartAt(name_token); - location.EndAt(name_token); - location.RecordLegacyLocation( - group, DescriptorPool::ErrorCollector::NAME); - } - - // The field's type_name also comes from the name. Confusing! - { - LocationRecorder location(field_location, - FieldDescriptorProto::kTypeNameFieldNumber); - location.StartAt(name_token); - location.EndAt(name_token); - } - - // As a hack for backwards-compatibility, we force the group name to start - // with a capital letter and lower-case the field name. New code should - // not use groups; it should use nested messages. - if (group->name()[0] < 'A' || 'Z' < group->name()[0]) { - AddError(name_token.line, name_token.column, - "Group names must start with a capital letter."); - } - LowerString(field->mutable_name()); - - field->set_type_name(group->name()); - if (LookingAt("{")) { - DO(ParseMessageBlock(group, group_location)); - } else { - AddError("Missing group body."); - return false; - } - } else { - DO(ConsumeEndOfDeclaration(";", &field_location)); - } - - return true; -} - -bool Parser::ParseFieldOptions(FieldDescriptorProto* field, - const LocationRecorder& field_location) { - if (!LookingAt("[")) return true; - - LocationRecorder location(field_location, - FieldDescriptorProto::kOptionsFieldNumber); - - DO(Consume("[")); - - // Parse field options. - do { - if (LookingAt("default")) { - // We intentionally pass field_location rather than location here, since - // the default value is not actually an option. - DO(ParseDefaultAssignment(field, field_location)); - } else { - DO(ParseOption(field->mutable_options(), location, OPTION_ASSIGNMENT)); - } - } while (TryConsume(",")); - - DO(Consume("]")); - return true; -} - -bool Parser::ParseDefaultAssignment(FieldDescriptorProto* field, - const LocationRecorder& field_location) { - if (field->has_default_value()) { - AddError("Already set option \"default\"."); - field->clear_default_value(); - } - - DO(Consume("default")); - DO(Consume("=")); - - LocationRecorder location(field_location, - FieldDescriptorProto::kDefaultValueFieldNumber); - location.RecordLegacyLocation( - field, DescriptorPool::ErrorCollector::DEFAULT_VALUE); - string* default_value = field->mutable_default_value(); - - if (!field->has_type()) { - // The field has a type name, but we don't know if it is a message or an - // enum yet. Assume an enum for now. - DO(ConsumeIdentifier(default_value, "Expected identifier.")); - return true; - } - - switch (field->type()) { - case FieldDescriptorProto::TYPE_INT32: - case FieldDescriptorProto::TYPE_INT64: - case FieldDescriptorProto::TYPE_SINT32: - case FieldDescriptorProto::TYPE_SINT64: - case FieldDescriptorProto::TYPE_SFIXED32: - case FieldDescriptorProto::TYPE_SFIXED64: { - uint64 max_value = kint64max; - if (field->type() == FieldDescriptorProto::TYPE_INT32 || - field->type() == FieldDescriptorProto::TYPE_SINT32 || - field->type() == FieldDescriptorProto::TYPE_SFIXED32) { - max_value = kint32max; - } - - // These types can be negative. - if (TryConsume("-")) { - default_value->append("-"); - // Two's complement always has one more negative value than positive. - ++max_value; - } - // Parse the integer to verify that it is not out-of-range. - uint64 value; - DO(ConsumeInteger64(max_value, &value, "Expected integer.")); - // And stringify it again. - default_value->append(SimpleItoa(value)); - break; - } - - case FieldDescriptorProto::TYPE_UINT32: - case FieldDescriptorProto::TYPE_UINT64: - case FieldDescriptorProto::TYPE_FIXED32: - case FieldDescriptorProto::TYPE_FIXED64: { - uint64 max_value = kuint64max; - if (field->type() == FieldDescriptorProto::TYPE_UINT32 || - field->type() == FieldDescriptorProto::TYPE_FIXED32) { - max_value = kuint32max; - } - - // Numeric, not negative. - if (TryConsume("-")) { - AddError("Unsigned field can't have negative default value."); - } - // Parse the integer to verify that it is not out-of-range. - uint64 value; - DO(ConsumeInteger64(max_value, &value, "Expected integer.")); - // And stringify it again. - default_value->append(SimpleItoa(value)); - break; - } - - case FieldDescriptorProto::TYPE_FLOAT: - case FieldDescriptorProto::TYPE_DOUBLE: - // These types can be negative. - if (TryConsume("-")) { - default_value->append("-"); - } - // Parse the integer because we have to convert hex integers to decimal - // floats. - double value; - DO(ConsumeNumber(&value, "Expected number.")); - // And stringify it again. - default_value->append(SimpleDtoa(value)); - break; - - case FieldDescriptorProto::TYPE_BOOL: - if (TryConsume("true")) { - default_value->assign("true"); - } else if (TryConsume("false")) { - default_value->assign("false"); - } else { - AddError("Expected \"true\" or \"false\"."); - return false; - } - break; - - case FieldDescriptorProto::TYPE_STRING: - DO(ConsumeString(default_value, "Expected string.")); - break; - - case FieldDescriptorProto::TYPE_BYTES: - DO(ConsumeString(default_value, "Expected string.")); - *default_value = CEscape(*default_value); - break; - - case FieldDescriptorProto::TYPE_ENUM: - DO(ConsumeIdentifier(default_value, "Expected identifier.")); - break; - - case FieldDescriptorProto::TYPE_MESSAGE: - case FieldDescriptorProto::TYPE_GROUP: - AddError("Messages can't have default values."); - return false; - } - - return true; -} - -bool Parser::ParseOptionNamePart(UninterpretedOption* uninterpreted_option, - const LocationRecorder& part_location) { - UninterpretedOption::NamePart* name = uninterpreted_option->add_name(); - string identifier; // We parse identifiers into this string. - if (LookingAt("(")) { // This is an extension. - DO(Consume("(")); - - { - LocationRecorder location( - part_location, UninterpretedOption::NamePart::kNamePartFieldNumber); - // An extension name consists of dot-separated identifiers, and may begin - // with a dot. - if (LookingAtType(io::Tokenizer::TYPE_IDENTIFIER)) { - DO(ConsumeIdentifier(&identifier, "Expected identifier.")); - name->mutable_name_part()->append(identifier); - } - while (LookingAt(".")) { - DO(Consume(".")); - name->mutable_name_part()->append("."); - DO(ConsumeIdentifier(&identifier, "Expected identifier.")); - name->mutable_name_part()->append(identifier); - } - } - - DO(Consume(")")); - name->set_is_extension(true); - } else { // This is a regular field. - LocationRecorder location( - part_location, UninterpretedOption::NamePart::kNamePartFieldNumber); - DO(ConsumeIdentifier(&identifier, "Expected identifier.")); - name->mutable_name_part()->append(identifier); - name->set_is_extension(false); - } - return true; -} - -bool Parser::ParseUninterpretedBlock(string* value) { - // Note that enclosing braces are not added to *value. - // We do NOT use ConsumeEndOfStatement for this brace because it's delimiting - // an expression, not a block of statements. - DO(Consume("{")); - int brace_depth = 1; - while (!AtEnd()) { - if (LookingAt("{")) { - brace_depth++; - } else if (LookingAt("}")) { - brace_depth--; - if (brace_depth == 0) { - input_->Next(); - return true; - } - } - // TODO(sanjay): Interpret line/column numbers to preserve formatting - if (!value->empty()) value->push_back(' '); - value->append(input_->current().text); - input_->Next(); - } - AddError("Unexpected end of stream while parsing aggregate value."); - return false; -} - -// We don't interpret the option here. Instead we store it in an -// UninterpretedOption, to be interpreted later. -bool Parser::ParseOption(Message* options, - const LocationRecorder& options_location, - OptionStyle style) { - // Create an entry in the uninterpreted_option field. - const FieldDescriptor* uninterpreted_option_field = options->GetDescriptor()-> - FindFieldByName("uninterpreted_option"); - GOOGLE_CHECK(uninterpreted_option_field != NULL) - << "No field named \"uninterpreted_option\" in the Options proto."; - - const Reflection* reflection = options->GetReflection(); - - LocationRecorder location( - options_location, uninterpreted_option_field->number(), - reflection->FieldSize(*options, uninterpreted_option_field)); - - if (style == OPTION_STATEMENT) { - DO(Consume("option")); - } - - UninterpretedOption* uninterpreted_option = down_cast( - options->GetReflection()->AddMessage(options, - uninterpreted_option_field)); - - // Parse dot-separated name. - { - LocationRecorder name_location(location, - UninterpretedOption::kNameFieldNumber); - name_location.RecordLegacyLocation( - uninterpreted_option, DescriptorPool::ErrorCollector::OPTION_NAME); - - { - LocationRecorder part_location(name_location, - uninterpreted_option->name_size()); - DO(ParseOptionNamePart(uninterpreted_option, part_location)); - } - - while (LookingAt(".")) { - DO(Consume(".")); - LocationRecorder part_location(name_location, - uninterpreted_option->name_size()); - DO(ParseOptionNamePart(uninterpreted_option, part_location)); - } - } - - DO(Consume("=")); - - { - LocationRecorder value_location(location); - value_location.RecordLegacyLocation( - uninterpreted_option, DescriptorPool::ErrorCollector::OPTION_VALUE); - - // All values are a single token, except for negative numbers, which consist - // of a single '-' symbol, followed by a positive number. - bool is_negative = TryConsume("-"); - - switch (input_->current().type) { - case io::Tokenizer::TYPE_START: - GOOGLE_LOG(FATAL) << "Trying to read value before any tokens have been read."; - return false; - - case io::Tokenizer::TYPE_END: - AddError("Unexpected end of stream while parsing option value."); - return false; - - case io::Tokenizer::TYPE_IDENTIFIER: { - value_location.AddPath( - UninterpretedOption::kIdentifierValueFieldNumber); - if (is_negative) { - AddError("Invalid '-' symbol before identifier."); - return false; - } - string value; - DO(ConsumeIdentifier(&value, "Expected identifier.")); - uninterpreted_option->set_identifier_value(value); - break; - } - - case io::Tokenizer::TYPE_INTEGER: { - uint64 value; - uint64 max_value = - is_negative ? static_cast(kint64max) + 1 : kuint64max; - DO(ConsumeInteger64(max_value, &value, "Expected integer.")); - if (is_negative) { - value_location.AddPath( - UninterpretedOption::kNegativeIntValueFieldNumber); - uninterpreted_option->set_negative_int_value( - -static_cast(value)); - } else { - value_location.AddPath( - UninterpretedOption::kPositiveIntValueFieldNumber); - uninterpreted_option->set_positive_int_value(value); - } - break; - } - - case io::Tokenizer::TYPE_FLOAT: { - value_location.AddPath(UninterpretedOption::kDoubleValueFieldNumber); - double value; - DO(ConsumeNumber(&value, "Expected number.")); - uninterpreted_option->set_double_value(is_negative ? -value : value); - break; - } - - case io::Tokenizer::TYPE_STRING: { - value_location.AddPath(UninterpretedOption::kStringValueFieldNumber); - if (is_negative) { - AddError("Invalid '-' symbol before string."); - return false; - } - string value; - DO(ConsumeString(&value, "Expected string.")); - uninterpreted_option->set_string_value(value); - break; - } - - case io::Tokenizer::TYPE_SYMBOL: - if (LookingAt("{")) { - value_location.AddPath( - UninterpretedOption::kAggregateValueFieldNumber); - DO(ParseUninterpretedBlock( - uninterpreted_option->mutable_aggregate_value())); - } else { - AddError("Expected option value."); - return false; - } - break; - } - } - - if (style == OPTION_STATEMENT) { - DO(ConsumeEndOfDeclaration(";", &location)); - } - - return true; -} - -bool Parser::ParseExtensions(DescriptorProto* message, - const LocationRecorder& extensions_location) { - // Parse the declaration. - DO(Consume("extensions")); - - do { - // Note that kExtensionRangeFieldNumber was already pushed by the parent. - LocationRecorder location(extensions_location, - message->extension_range_size()); - - DescriptorProto::ExtensionRange* range = message->add_extension_range(); - location.RecordLegacyLocation( - range, DescriptorPool::ErrorCollector::NUMBER); - - int start, end; - io::Tokenizer::Token start_token; - - { - LocationRecorder start_location( - location, DescriptorProto::ExtensionRange::kStartFieldNumber); - start_token = input_->current(); - DO(ConsumeInteger(&start, "Expected field number range.")); - } - - if (TryConsume("to")) { - LocationRecorder end_location( - location, DescriptorProto::ExtensionRange::kEndFieldNumber); - if (TryConsume("max")) { - // Set to the sentinel value - 1 since we increment the value below. - // The actual value of the end of the range should be set with - // AdjustExtensionRangesWithMaxEndNumber. - end = kMaxExtensionRangeSentinel - 1; - } else { - DO(ConsumeInteger(&end, "Expected integer.")); - } - } else { - LocationRecorder end_location( - location, DescriptorProto::ExtensionRange::kEndFieldNumber); - end_location.StartAt(start_token); - end_location.EndAt(start_token); - end = start; - } - - // Users like to specify inclusive ranges, but in code we like the end - // number to be exclusive. - ++end; - - range->set_start(start); - range->set_end(end); - } while (TryConsume(",")); - - DO(ConsumeEndOfDeclaration(";", &extensions_location)); - return true; -} - -bool Parser::ParseExtend(RepeatedPtrField* extensions, - RepeatedPtrField* messages, - const LocationRecorder& parent_location, - int location_field_number_for_nested_type, - const LocationRecorder& extend_location) { - DO(Consume("extend")); - - // Parse the extendee type. - io::Tokenizer::Token extendee_start = input_->current(); - string extendee; - DO(ParseUserDefinedType(&extendee)); - io::Tokenizer::Token extendee_end = input_->previous(); - - // Parse the block. - DO(ConsumeEndOfDeclaration("{", &extend_location)); - - bool is_first = true; - - do { - if (AtEnd()) { - AddError("Reached end of input in extend definition (missing '}')."); - return false; - } - - // Note that kExtensionFieldNumber was already pushed by the parent. - LocationRecorder location(extend_location, extensions->size()); - - FieldDescriptorProto* field = extensions->Add(); - - { - LocationRecorder extendee_location( - location, FieldDescriptorProto::kExtendeeFieldNumber); - extendee_location.StartAt(extendee_start); - extendee_location.EndAt(extendee_end); - - if (is_first) { - extendee_location.RecordLegacyLocation( - field, DescriptorPool::ErrorCollector::EXTENDEE); - is_first = false; - } - } - - field->set_extendee(extendee); - - if (!ParseMessageField(field, messages, parent_location, - location_field_number_for_nested_type, - location)) { - // This statement failed to parse. Skip it, but keep looping to parse - // other statements. - SkipStatement(); - } - } while (!TryConsumeEndOfDeclaration("}", NULL)); - - return true; -} - -// ------------------------------------------------------------------- -// Enums - -bool Parser::ParseEnumDefinition(EnumDescriptorProto* enum_type, - const LocationRecorder& enum_location) { - DO(Consume("enum")); - - { - LocationRecorder location(enum_location, - EnumDescriptorProto::kNameFieldNumber); - location.RecordLegacyLocation( - enum_type, DescriptorPool::ErrorCollector::NAME); - DO(ConsumeIdentifier(enum_type->mutable_name(), "Expected enum name.")); - } - - DO(ParseEnumBlock(enum_type, enum_location)); - return true; -} - -bool Parser::ParseEnumBlock(EnumDescriptorProto* enum_type, - const LocationRecorder& enum_location) { - DO(ConsumeEndOfDeclaration("{", &enum_location)); - - while (!TryConsumeEndOfDeclaration("}", NULL)) { - if (AtEnd()) { - AddError("Reached end of input in enum definition (missing '}')."); - return false; - } - - if (!ParseEnumStatement(enum_type, enum_location)) { - // This statement failed to parse. Skip it, but keep looping to parse - // other statements. - SkipStatement(); - } - } - - return true; -} - -bool Parser::ParseEnumStatement(EnumDescriptorProto* enum_type, - const LocationRecorder& enum_location) { - if (TryConsumeEndOfDeclaration(";", NULL)) { - // empty statement; ignore - return true; - } else if (LookingAt("option")) { - LocationRecorder location(enum_location, - EnumDescriptorProto::kOptionsFieldNumber); - return ParseOption(enum_type->mutable_options(), location, - OPTION_STATEMENT); - } else { - LocationRecorder location(enum_location, - EnumDescriptorProto::kValueFieldNumber, enum_type->value_size()); - return ParseEnumConstant(enum_type->add_value(), location); - } -} - -bool Parser::ParseEnumConstant(EnumValueDescriptorProto* enum_value, - const LocationRecorder& enum_value_location) { - // Parse name. - { - LocationRecorder location(enum_value_location, - EnumValueDescriptorProto::kNameFieldNumber); - location.RecordLegacyLocation( - enum_value, DescriptorPool::ErrorCollector::NAME); - DO(ConsumeIdentifier(enum_value->mutable_name(), - "Expected enum constant name.")); - } - - DO(Consume("=", "Missing numeric value for enum constant.")); - - // Parse value. - { - LocationRecorder location( - enum_value_location, EnumValueDescriptorProto::kNumberFieldNumber); - location.RecordLegacyLocation( - enum_value, DescriptorPool::ErrorCollector::NUMBER); - - int number; - DO(ConsumeSignedInteger(&number, "Expected integer.")); - enum_value->set_number(number); - } - - DO(ParseEnumConstantOptions(enum_value, enum_value_location)); - - DO(ConsumeEndOfDeclaration(";", &enum_value_location)); - - return true; -} - -bool Parser::ParseEnumConstantOptions( - EnumValueDescriptorProto* value, - const LocationRecorder& enum_value_location) { - if (!LookingAt("[")) return true; - - LocationRecorder location( - enum_value_location, EnumValueDescriptorProto::kOptionsFieldNumber); - - DO(Consume("[")); - - do { - DO(ParseOption(value->mutable_options(), location, OPTION_ASSIGNMENT)); - } while (TryConsume(",")); - - DO(Consume("]")); - return true; -} - -// ------------------------------------------------------------------- -// Services - -bool Parser::ParseServiceDefinition(ServiceDescriptorProto* service, - const LocationRecorder& service_location) { - DO(Consume("service")); - - { - LocationRecorder location(service_location, - ServiceDescriptorProto::kNameFieldNumber); - location.RecordLegacyLocation( - service, DescriptorPool::ErrorCollector::NAME); - DO(ConsumeIdentifier(service->mutable_name(), "Expected service name.")); - } - - DO(ParseServiceBlock(service, service_location)); - return true; -} - -bool Parser::ParseServiceBlock(ServiceDescriptorProto* service, - const LocationRecorder& service_location) { - DO(ConsumeEndOfDeclaration("{", &service_location)); - - while (!TryConsumeEndOfDeclaration("}", NULL)) { - if (AtEnd()) { - AddError("Reached end of input in service definition (missing '}')."); - return false; - } - - if (!ParseServiceStatement(service, service_location)) { - // This statement failed to parse. Skip it, but keep looping to parse - // other statements. - SkipStatement(); - } - } - - return true; -} - -bool Parser::ParseServiceStatement(ServiceDescriptorProto* service, - const LocationRecorder& service_location) { - if (TryConsumeEndOfDeclaration(";", NULL)) { - // empty statement; ignore - return true; - } else if (LookingAt("option")) { - LocationRecorder location( - service_location, ServiceDescriptorProto::kOptionsFieldNumber); - return ParseOption(service->mutable_options(), location, OPTION_STATEMENT); - } else { - LocationRecorder location(service_location, - ServiceDescriptorProto::kMethodFieldNumber, service->method_size()); - return ParseServiceMethod(service->add_method(), location); - } -} - -bool Parser::ParseServiceMethod(MethodDescriptorProto* method, - const LocationRecorder& method_location) { - DO(Consume("rpc")); - - { - LocationRecorder location(method_location, - MethodDescriptorProto::kNameFieldNumber); - location.RecordLegacyLocation( - method, DescriptorPool::ErrorCollector::NAME); - DO(ConsumeIdentifier(method->mutable_name(), "Expected method name.")); - } - - // Parse input type. - DO(Consume("(")); - { - LocationRecorder location(method_location, - MethodDescriptorProto::kInputTypeFieldNumber); - location.RecordLegacyLocation( - method, DescriptorPool::ErrorCollector::INPUT_TYPE); - DO(ParseUserDefinedType(method->mutable_input_type())); - } - DO(Consume(")")); - - // Parse output type. - DO(Consume("returns")); - DO(Consume("(")); - { - LocationRecorder location(method_location, - MethodDescriptorProto::kOutputTypeFieldNumber); - location.RecordLegacyLocation( - method, DescriptorPool::ErrorCollector::OUTPUT_TYPE); - DO(ParseUserDefinedType(method->mutable_output_type())); - } - DO(Consume(")")); - - if (LookingAt("{")) { - // Options! - DO(ParseOptions(method_location, - MethodDescriptorProto::kOptionsFieldNumber, - method->mutable_options())); - } else { - DO(ConsumeEndOfDeclaration(";", &method_location)); - } - - return true; -} - - -bool Parser::ParseOptions(const LocationRecorder& parent_location, - const int optionsFieldNumber, - Message* mutable_options) { - // Options! - ConsumeEndOfDeclaration("{", &parent_location); - while (!TryConsumeEndOfDeclaration("}", NULL)) { - if (AtEnd()) { - AddError("Reached end of input in method options (missing '}')."); - return false; - } - - if (TryConsumeEndOfDeclaration(";", NULL)) { - // empty statement; ignore - } else { - LocationRecorder location(parent_location, - optionsFieldNumber); - if (!ParseOption(mutable_options, location, OPTION_STATEMENT)) { - // This statement failed to parse. Skip it, but keep looping to - // parse other statements. - SkipStatement(); - } - } - } - - return true; -} - -// ------------------------------------------------------------------- - -bool Parser::ParseLabel(FieldDescriptorProto::Label* label) { - if (TryConsume("optional")) { - *label = FieldDescriptorProto::LABEL_OPTIONAL; - return true; - } else if (TryConsume("repeated")) { - *label = FieldDescriptorProto::LABEL_REPEATED; - return true; - } else if (TryConsume("required")) { - *label = FieldDescriptorProto::LABEL_REQUIRED; - return true; - } else { - AddError("Expected \"required\", \"optional\", or \"repeated\"."); - // We can actually reasonably recover here by just assuming the user - // forgot the label altogether. - *label = FieldDescriptorProto::LABEL_OPTIONAL; - return true; - } -} - -bool Parser::ParseType(FieldDescriptorProto::Type* type, - string* type_name) { - TypeNameMap::const_iterator iter = kTypeNames.find(input_->current().text); - if (iter != kTypeNames.end()) { - *type = iter->second; - input_->Next(); - } else { - DO(ParseUserDefinedType(type_name)); - } - return true; -} - -bool Parser::ParseUserDefinedType(string* type_name) { - type_name->clear(); - - TypeNameMap::const_iterator iter = kTypeNames.find(input_->current().text); - if (iter != kTypeNames.end()) { - // Note: The only place enum types are allowed is for field types, but - // if we are parsing a field type then we would not get here because - // primitives are allowed there as well. So this error message doesn't - // need to account for enums. - AddError("Expected message type."); - - // Pretend to accept this type so that we can go on parsing. - *type_name = input_->current().text; - input_->Next(); - return true; - } - - // A leading "." means the name is fully-qualified. - if (TryConsume(".")) type_name->append("."); - - // Consume the first part of the name. - string identifier; - DO(ConsumeIdentifier(&identifier, "Expected type name.")); - type_name->append(identifier); - - // Consume more parts. - while (TryConsume(".")) { - type_name->append("."); - DO(ConsumeIdentifier(&identifier, "Expected identifier.")); - type_name->append(identifier); - } - - return true; -} - -// =================================================================== - -bool Parser::ParsePackage(FileDescriptorProto* file, - const LocationRecorder& root_location) { - if (file->has_package()) { - AddError("Multiple package definitions."); - // Don't append the new package to the old one. Just replace it. Not - // that it really matters since this is an error anyway. - file->clear_package(); - } - - DO(Consume("package")); - - { - LocationRecorder location(root_location, - FileDescriptorProto::kPackageFieldNumber); - location.RecordLegacyLocation(file, DescriptorPool::ErrorCollector::NAME); - - while (true) { - string identifier; - DO(ConsumeIdentifier(&identifier, "Expected identifier.")); - file->mutable_package()->append(identifier); - if (!TryConsume(".")) break; - file->mutable_package()->append("."); - } - - location.EndAt(input_->previous()); - - DO(ConsumeEndOfDeclaration(";", &location)); - } - - return true; -} - -bool Parser::ParseImport(RepeatedPtrField* dependency, - RepeatedField* public_dependency, - RepeatedField* weak_dependency, - const LocationRecorder& root_location) { - DO(Consume("import")); - if (LookingAt("public")) { - LocationRecorder location( - root_location, FileDescriptorProto::kPublicDependencyFieldNumber, - public_dependency->size()); - DO(Consume("public")); - *public_dependency->Add() = dependency->size(); - } else if (LookingAt("weak")) { - LocationRecorder location( - root_location, FileDescriptorProto::kWeakDependencyFieldNumber, - weak_dependency->size()); - DO(Consume("weak")); - *weak_dependency->Add() = dependency->size(); - } - { - LocationRecorder location(root_location, - FileDescriptorProto::kDependencyFieldNumber, - dependency->size()); - DO(ConsumeString(dependency->Add(), - "Expected a string naming the file to import.")); - - location.EndAt(input_->previous()); - - DO(ConsumeEndOfDeclaration(";", &location)); - } - return true; -} - -// =================================================================== - -SourceLocationTable::SourceLocationTable() {} -SourceLocationTable::~SourceLocationTable() {} - -bool SourceLocationTable::Find( - const Message* descriptor, - DescriptorPool::ErrorCollector::ErrorLocation location, - int* line, int* column) const { - const pair* result = - FindOrNull(location_map_, make_pair(descriptor, location)); - if (result == NULL) { - *line = -1; - *column = 0; - return false; - } else { - *line = result->first; - *column = result->second; - return true; - } -} - -void SourceLocationTable::Add( - const Message* descriptor, - DescriptorPool::ErrorCollector::ErrorLocation location, - int line, int column) { - location_map_[make_pair(descriptor, location)] = make_pair(line, column); -} - -void SourceLocationTable::Clear() { - location_map_.clear(); -} - -} // namespace compiler -} // namespace protobuf -} // namespace google diff --git a/modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/parser.h b/modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/parser.h deleted file mode 100644 index cfd3649be..000000000 --- a/modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/parser.h +++ /dev/null @@ -1,477 +0,0 @@ -// Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// http://code.google.com/p/protobuf/ -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -// Author: kenton@google.com (Kenton Varda) -// Based on original Protocol Buffers design by -// Sanjay Ghemawat, Jeff Dean, and others. -// -// Implements parsing of .proto files to FileDescriptorProtos. - -#ifndef GOOGLE_PROTOBUF_COMPILER_PARSER_H__ -#define GOOGLE_PROTOBUF_COMPILER_PARSER_H__ - -#include -#include -#include -#include -#include -#include -#include -#include - -namespace google { -namespace protobuf { class Message; } - -namespace protobuf { -namespace compiler { - -// Defined in this file. -class Parser; -class SourceLocationTable; - -// Implements parsing of protocol definitions (such as .proto files). -// -// Note that most users will be more interested in the Importer class. -// Parser is a lower-level class which simply converts a single .proto file -// to a FileDescriptorProto. It does not resolve import directives or perform -// many other kinds of validation needed to construct a complete -// FileDescriptor. -class LIBPROTOBUF_EXPORT Parser { - public: - Parser(); - ~Parser(); - - // Parse the entire input and construct a FileDescriptorProto representing - // it. Returns true if no errors occurred, false otherwise. - bool Parse(io::Tokenizer* input, FileDescriptorProto* file); - - // Optional fetaures: - - // DEPRECATED: New code should use the SourceCodeInfo embedded in the - // FileDescriptorProto. - // - // Requests that locations of certain definitions be recorded to the given - // SourceLocationTable while parsing. This can be used to look up exact line - // and column numbers for errors reported by DescriptorPool during validation. - // Set to NULL (the default) to discard source location information. - void RecordSourceLocationsTo(SourceLocationTable* location_table) { - source_location_table_ = location_table; - } - - // Requests that errors be recorded to the given ErrorCollector while - // parsing. Set to NULL (the default) to discard error messages. - void RecordErrorsTo(io::ErrorCollector* error_collector) { - error_collector_ = error_collector; - } - - // Returns the identifier used in the "syntax = " declaration, if one was - // seen during the last call to Parse(), or the empty string otherwise. - const string& GetSyntaxIdentifier() { return syntax_identifier_; } - - // If set true, input files will be required to begin with a syntax - // identifier. Otherwise, files may omit this. If a syntax identifier - // is provided, it must be 'syntax = "proto2";' and must appear at the - // top of this file regardless of whether or not it was required. - void SetRequireSyntaxIdentifier(bool value) { - require_syntax_identifier_ = value; - } - - // Call SetStopAfterSyntaxIdentifier(true) to tell the parser to stop - // parsing as soon as it has seen the syntax identifier, or lack thereof. - // This is useful for quickly identifying the syntax of the file without - // parsing the whole thing. If this is enabled, no error will be recorded - // if the syntax identifier is something other than "proto2" (since - // presumably the caller intends to deal with that), but other kinds of - // errors (e.g. parse errors) will still be reported. When this is enabled, - // you may pass a NULL FileDescriptorProto to Parse(). - void SetStopAfterSyntaxIdentifier(bool value) { - stop_after_syntax_identifier_ = value; - } - - private: - class LocationRecorder; - - // ================================================================= - // Error recovery helpers - - // Consume the rest of the current statement. This consumes tokens - // until it sees one of: - // ';' Consumes the token and returns. - // '{' Consumes the brace then calls SkipRestOfBlock(). - // '}' Returns without consuming. - // EOF Returns (can't consume). - // The Parser often calls SkipStatement() after encountering a syntax - // error. This allows it to go on parsing the following lines, allowing - // it to report more than just one error in the file. - void SkipStatement(); - - // Consume the rest of the current block, including nested blocks, - // ending after the closing '}' is encountered and consumed, or at EOF. - void SkipRestOfBlock(); - - // ----------------------------------------------------------------- - // Single-token consuming helpers - // - // These make parsing code more readable. - - // True if the current token is TYPE_END. - inline bool AtEnd(); - - // True if the next token matches the given text. - inline bool LookingAt(const char* text); - // True if the next token is of the given type. - inline bool LookingAtType(io::Tokenizer::TokenType token_type); - - // If the next token exactly matches the text given, consume it and return - // true. Otherwise, return false without logging an error. - bool TryConsume(const char* text); - - // These attempt to read some kind of token from the input. If successful, - // they return true. Otherwise they return false and add the given error - // to the error list. - - // Consume a token with the exact text given. - bool Consume(const char* text, const char* error); - // Same as above, but automatically generates the error "Expected \"text\".", - // where "text" is the expected token text. - bool Consume(const char* text); - // Consume a token of type IDENTIFIER and store its text in "output". - bool ConsumeIdentifier(string* output, const char* error); - // Consume an integer and store its value in "output". - bool ConsumeInteger(int* output, const char* error); - // Consume a signed integer and store its value in "output". - bool ConsumeSignedInteger(int* output, const char* error); - // Consume a 64-bit integer and store its value in "output". If the value - // is greater than max_value, an error will be reported. - bool ConsumeInteger64(uint64 max_value, uint64* output, const char* error); - // Consume a number and store its value in "output". This will accept - // tokens of either INTEGER or FLOAT type. - bool ConsumeNumber(double* output, const char* error); - // Consume a string literal and store its (unescaped) value in "output". - bool ConsumeString(string* output, const char* error); - - // Consume a token representing the end of the statement. Comments between - // this token and the next will be harvested for documentation. The given - // LocationRecorder should refer to the declaration that was just parsed; - // it will be populated with these comments. - // - // TODO(kenton): The LocationRecorder is const because historically locations - // have been passed around by const reference, for no particularly good - // reason. We should probably go through and change them all to mutable - // pointer to make this more intuitive. - bool TryConsumeEndOfDeclaration(const char* text, - const LocationRecorder* location); - bool ConsumeEndOfDeclaration(const char* text, - const LocationRecorder* location); - - // ----------------------------------------------------------------- - // Error logging helpers - - // Invokes error_collector_->AddError(), if error_collector_ is not NULL. - void AddError(int line, int column, const string& error); - - // Invokes error_collector_->AddError() with the line and column number - // of the current token. - void AddError(const string& error); - - // Records a location in the SourceCodeInfo.location table (see - // descriptor.proto). We use RAII to ensure that the start and end locations - // are recorded -- the constructor records the start location and the - // destructor records the end location. Since the parser is - // recursive-descent, this works out beautifully. - class LIBPROTOBUF_EXPORT LocationRecorder { - public: - // Construct the file's "root" location. - LocationRecorder(Parser* parser); - - // Construct a location that represents a declaration nested within the - // given parent. E.g. a field's location is nested within the location - // for a message type. The parent's path will be copied, so you should - // call AddPath() only to add the path components leading from the parent - // to the child (as opposed to leading from the root to the child). - LocationRecorder(const LocationRecorder& parent); - - // Convenience constructors that call AddPath() one or two times. - LocationRecorder(const LocationRecorder& parent, int path1); - LocationRecorder(const LocationRecorder& parent, int path1, int path2); - - ~LocationRecorder(); - - // Add a path component. See SourceCodeInfo.Location.path in - // descriptor.proto. - void AddPath(int path_component); - - // By default the location is considered to start at the current token at - // the time the LocationRecorder is created. StartAt() sets the start - // location to the given token instead. - void StartAt(const io::Tokenizer::Token& token); - - // By default the location is considered to end at the previous token at - // the time the LocationRecorder is destroyed. EndAt() sets the end - // location to the given token instead. - void EndAt(const io::Tokenizer::Token& token); - - // Records the start point of this location to the SourceLocationTable that - // was passed to RecordSourceLocationsTo(), if any. SourceLocationTable - // is an older way of keeping track of source locations which is still - // used in some places. - void RecordLegacyLocation(const Message* descriptor, - DescriptorPool::ErrorCollector::ErrorLocation location); - - // Attaches leading and trailing comments to the location. The two strings - // will be swapped into place, so after this is called *leading and - // *trailing will be empty. - // - // TODO(kenton): See comment on TryConsumeEndOfDeclaration(), above, for - // why this is const. - void AttachComments(string* leading, string* trailing) const; - - private: - Parser* parser_; - SourceCodeInfo::Location* location_; - - void Init(const LocationRecorder& parent); - }; - - // ================================================================= - // Parsers for various language constructs - - // Parses the "syntax = \"proto2\";" line at the top of the file. Returns - // false if it failed to parse or if the syntax identifier was not - // recognized. - bool ParseSyntaxIdentifier(); - - // These methods parse various individual bits of code. They return - // false if they completely fail to parse the construct. In this case, - // it is probably necessary to skip the rest of the statement to recover. - // However, if these methods return true, it does NOT mean that there - // were no errors; only that there were no *syntax* errors. For instance, - // if a service method is defined using proper syntax but uses a primitive - // type as its input or output, ParseMethodField() still returns true - // and only reports the error by calling AddError(). In practice, this - // makes logic much simpler for the caller. - - // Parse a top-level message, enum, service, etc. - bool ParseTopLevelStatement(FileDescriptorProto* file, - const LocationRecorder& root_location); - - // Parse various language high-level language construrcts. - bool ParseMessageDefinition(DescriptorProto* message, - const LocationRecorder& message_location); - bool ParseEnumDefinition(EnumDescriptorProto* enum_type, - const LocationRecorder& enum_location); - bool ParseServiceDefinition(ServiceDescriptorProto* service, - const LocationRecorder& service_location); - bool ParsePackage(FileDescriptorProto* file, - const LocationRecorder& root_location); - bool ParseImport(RepeatedPtrField* dependency, - RepeatedField* public_dependency, - RepeatedField* weak_dependency, - const LocationRecorder& root_location); - bool ParseOption(Message* options, - const LocationRecorder& options_location); - - // These methods parse the contents of a message, enum, or service type and - // add them to the given object. They consume the entire block including - // the beginning and ending brace. - bool ParseMessageBlock(DescriptorProto* message, - const LocationRecorder& message_location); - bool ParseEnumBlock(EnumDescriptorProto* enum_type, - const LocationRecorder& enum_location); - bool ParseServiceBlock(ServiceDescriptorProto* service, - const LocationRecorder& service_location); - - // Parse one statement within a message, enum, or service block, inclunding - // final semicolon. - bool ParseMessageStatement(DescriptorProto* message, - const LocationRecorder& message_location); - bool ParseEnumStatement(EnumDescriptorProto* message, - const LocationRecorder& enum_location); - bool ParseServiceStatement(ServiceDescriptorProto* message, - const LocationRecorder& service_location); - - // Parse a field of a message. If the field is a group, its type will be - // added to "messages". - // - // parent_location and location_field_number_for_nested_type are needed when - // parsing groups -- we need to generate a nested message type within the - // parent and record its location accordingly. Since the parent could be - // either a FileDescriptorProto or a DescriptorProto, we must pass in the - // correct field number to use. - bool ParseMessageField(FieldDescriptorProto* field, - RepeatedPtrField* messages, - const LocationRecorder& parent_location, - int location_field_number_for_nested_type, - const LocationRecorder& field_location); - - // Parse an "extensions" declaration. - bool ParseExtensions(DescriptorProto* message, - const LocationRecorder& extensions_location); - - // Parse an "extend" declaration. (See also comments for - // ParseMessageField().) - bool ParseExtend(RepeatedPtrField* extensions, - RepeatedPtrField* messages, - const LocationRecorder& parent_location, - int location_field_number_for_nested_type, - const LocationRecorder& extend_location); - - // Parse a single enum value within an enum block. - bool ParseEnumConstant(EnumValueDescriptorProto* enum_value, - const LocationRecorder& enum_value_location); - - // Parse enum constant options, i.e. the list in square brackets at the end - // of the enum constant value definition. - bool ParseEnumConstantOptions(EnumValueDescriptorProto* value, - const LocationRecorder& enum_value_location); - - // Parse a single method within a service definition. - bool ParseServiceMethod(MethodDescriptorProto* method, - const LocationRecorder& method_location); - - - // Parse options of a single method or stream. - bool ParseOptions(const LocationRecorder& parent_location, - const int optionsFieldNumber, - Message* mutable_options); - - // Parse "required", "optional", or "repeated" and fill in "label" - // with the value. - bool ParseLabel(FieldDescriptorProto::Label* label); - - // Parse a type name and fill in "type" (if it is a primitive) or - // "type_name" (if it is not) with the type parsed. - bool ParseType(FieldDescriptorProto::Type* type, - string* type_name); - // Parse a user-defined type and fill in "type_name" with the name. - // If a primitive type is named, it is treated as an error. - bool ParseUserDefinedType(string* type_name); - - // Parses field options, i.e. the stuff in square brackets at the end - // of a field definition. Also parses default value. - bool ParseFieldOptions(FieldDescriptorProto* field, - const LocationRecorder& field_location); - - // Parse the "default" option. This needs special handling because its - // type is the field's type. - bool ParseDefaultAssignment(FieldDescriptorProto* field, - const LocationRecorder& field_location); - - enum OptionStyle { - OPTION_ASSIGNMENT, // just "name = value" - OPTION_STATEMENT // "option name = value;" - }; - - // Parse a single option name/value pair, e.g. "ctype = CORD". The name - // identifies a field of the given Message, and the value of that field - // is set to the parsed value. - bool ParseOption(Message* options, - const LocationRecorder& options_location, - OptionStyle style); - - // Parses a single part of a multipart option name. A multipart name consists - // of names separated by dots. Each name is either an identifier or a series - // of identifiers separated by dots and enclosed in parentheses. E.g., - // "foo.(bar.baz).qux". - bool ParseOptionNamePart(UninterpretedOption* uninterpreted_option, - const LocationRecorder& part_location); - - // Parses a string surrounded by balanced braces. Strips off the outer - // braces and stores the enclosed string in *value. - // E.g., - // { foo } *value gets 'foo' - // { foo { bar: box } } *value gets 'foo { bar: box }' - // {} *value gets '' - // - // REQUIRES: LookingAt("{") - // When finished successfully, we are looking at the first token past - // the ending brace. - bool ParseUninterpretedBlock(string* value); - - // ================================================================= - - io::Tokenizer* input_; - io::ErrorCollector* error_collector_; - SourceCodeInfo* source_code_info_; - SourceLocationTable* source_location_table_; // legacy - bool had_errors_; - bool require_syntax_identifier_; - bool stop_after_syntax_identifier_; - string syntax_identifier_; - - // Leading doc comments for the next declaration. These are not complete - // yet; use ConsumeEndOfDeclaration() to get the complete comments. - string upcoming_doc_comments_; - - GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(Parser); -}; - -// A table mapping (descriptor, ErrorLocation) pairs -- as reported by -// DescriptorPool when validating descriptors -- to line and column numbers -// within the original source code. -// -// This is semi-obsolete: FileDescriptorProto.source_code_info now contains -// far more complete information about source locations. However, as of this -// writing you still need to use SourceLocationTable when integrating with -// DescriptorPool. -class LIBPROTOBUF_EXPORT SourceLocationTable { - public: - SourceLocationTable(); - ~SourceLocationTable(); - - // Finds the precise location of the given error and fills in *line and - // *column with the line and column numbers. If not found, sets *line to - // -1 and *column to 0 (since line = -1 is used to mean "error has no exact - // location" in the ErrorCollector interface). Returns true if found, false - // otherwise. - bool Find(const Message* descriptor, - DescriptorPool::ErrorCollector::ErrorLocation location, - int* line, int* column) const; - - // Adds a location to the table. - void Add(const Message* descriptor, - DescriptorPool::ErrorCollector::ErrorLocation location, - int line, int column); - - // Clears the contents of the table. - void Clear(); - - private: - typedef map< - pair, - pair > LocationMap; - LocationMap location_map_; -}; - -} // namespace compiler -} // namespace protobuf - -} // namespace google -#endif // GOOGLE_PROTOBUF_COMPILER_PARSER_H__ diff --git a/modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/parser_unittest.cc b/modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/parser_unittest.cc deleted file mode 100644 index c61ac60ec..000000000 --- a/modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/parser_unittest.cc +++ /dev/null @@ -1,2374 +0,0 @@ -// Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// http://code.google.com/p/protobuf/ -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -// Author: kenton@google.com (Kenton Varda) -// Based on original Protocol Buffers design by -// Sanjay Ghemawat, Jeff Dean, and others. - -#include -#include -#include - -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -namespace google { -namespace protobuf { -namespace compiler { - -namespace { - -class MockErrorCollector : public io::ErrorCollector { - public: - MockErrorCollector() {} - ~MockErrorCollector() {} - - string text_; - - // implements ErrorCollector --------------------------------------- - void AddError(int line, int column, const string& message) { - strings::SubstituteAndAppend(&text_, "$0:$1: $2\n", - line, column, message); - } -}; - -class MockValidationErrorCollector : public DescriptorPool::ErrorCollector { - public: - MockValidationErrorCollector(const SourceLocationTable& source_locations, - io::ErrorCollector* wrapped_collector) - : source_locations_(source_locations), - wrapped_collector_(wrapped_collector) {} - ~MockValidationErrorCollector() {} - - // implements ErrorCollector --------------------------------------- - void AddError(const string& filename, - const string& element_name, - const Message* descriptor, - ErrorLocation location, - const string& message) { - int line, column; - source_locations_.Find(descriptor, location, &line, &column); - wrapped_collector_->AddError(line, column, message); - } - - private: - const SourceLocationTable& source_locations_; - io::ErrorCollector* wrapped_collector_; -}; - -class ParserTest : public testing::Test { - protected: - ParserTest() - : require_syntax_identifier_(false) {} - - // Set up the parser to parse the given text. - void SetupParser(const char* text) { - raw_input_.reset(new io::ArrayInputStream(text, strlen(text))); - input_.reset(new io::Tokenizer(raw_input_.get(), &error_collector_)); - parser_.reset(new Parser()); - parser_->RecordErrorsTo(&error_collector_); - parser_->SetRequireSyntaxIdentifier(require_syntax_identifier_); - } - - // Parse the input and expect that the resulting FileDescriptorProto matches - // the given output. The output is a FileDescriptorProto in protocol buffer - // text format. - void ExpectParsesTo(const char* input, const char* output) { - SetupParser(input); - FileDescriptorProto actual, expected; - - parser_->Parse(input_.get(), &actual); - EXPECT_EQ(io::Tokenizer::TYPE_END, input_->current().type); - ASSERT_EQ("", error_collector_.text_); - - // We don't cover SourceCodeInfo in these tests. - actual.clear_source_code_info(); - - // Parse the ASCII representation in order to canonicalize it. We could - // just compare directly to actual.DebugString(), but that would require - // that the caller precisely match the formatting that DebugString() - // produces. - ASSERT_TRUE(TextFormat::ParseFromString(output, &expected)); - - // Compare by comparing debug strings. - // TODO(kenton): Use differencer, once it is available. - EXPECT_EQ(expected.DebugString(), actual.DebugString()); - } - - // Parse the text and expect that the given errors are reported. - void ExpectHasErrors(const char* text, const char* expected_errors) { - ExpectHasEarlyExitErrors(text, expected_errors); - EXPECT_EQ(io::Tokenizer::TYPE_END, input_->current().type); - } - - // Same as above but does not expect that the parser parses the complete - // input. - void ExpectHasEarlyExitErrors(const char* text, const char* expected_errors) { - SetupParser(text); - FileDescriptorProto file; - parser_->Parse(input_.get(), &file); - EXPECT_EQ(expected_errors, error_collector_.text_); - } - - // Parse the text as a file and validate it (with a DescriptorPool), and - // expect that the validation step reports the given errors. - void ExpectHasValidationErrors(const char* text, - const char* expected_errors) { - SetupParser(text); - SourceLocationTable source_locations; - parser_->RecordSourceLocationsTo(&source_locations); - - FileDescriptorProto file; - file.set_name("foo.proto"); - parser_->Parse(input_.get(), &file); - EXPECT_EQ(io::Tokenizer::TYPE_END, input_->current().type); - ASSERT_EQ("", error_collector_.text_); - - MockValidationErrorCollector validation_error_collector( - source_locations, &error_collector_); - EXPECT_TRUE(pool_.BuildFileCollectingErrors( - file, &validation_error_collector) == NULL); - EXPECT_EQ(expected_errors, error_collector_.text_); - } - - MockErrorCollector error_collector_; - DescriptorPool pool_; - - scoped_ptr raw_input_; - scoped_ptr input_; - scoped_ptr parser_; - bool require_syntax_identifier_; -}; - -// =================================================================== - -TEST_F(ParserTest, StopAfterSyntaxIdentifier) { - SetupParser( - "// blah\n" - "syntax = \"foobar\";\n" - "this line will not be parsed\n"); - parser_->SetStopAfterSyntaxIdentifier(true); - EXPECT_TRUE(parser_->Parse(input_.get(), NULL)); - EXPECT_EQ("", error_collector_.text_); - EXPECT_EQ("foobar", parser_->GetSyntaxIdentifier()); -} - -TEST_F(ParserTest, StopAfterOmittedSyntaxIdentifier) { - SetupParser( - "// blah\n" - "this line will not be parsed\n"); - parser_->SetStopAfterSyntaxIdentifier(true); - EXPECT_TRUE(parser_->Parse(input_.get(), NULL)); - EXPECT_EQ("", error_collector_.text_); - EXPECT_EQ("", parser_->GetSyntaxIdentifier()); -} - -TEST_F(ParserTest, StopAfterSyntaxIdentifierWithErrors) { - SetupParser( - "// blah\n" - "syntax = error;\n"); - parser_->SetStopAfterSyntaxIdentifier(true); - EXPECT_FALSE(parser_->Parse(input_.get(), NULL)); - EXPECT_EQ("1:9: Expected syntax identifier.\n", error_collector_.text_); -} - -// =================================================================== - -typedef ParserTest ParseMessageTest; - -TEST_F(ParseMessageTest, SimpleMessage) { - ExpectParsesTo( - "message TestMessage {\n" - " required int32 foo = 1;\n" - "}\n", - - "message_type {" - " name: \"TestMessage\"" - " field { name:\"foo\" label:LABEL_REQUIRED type:TYPE_INT32 number:1 }" - "}"); -} - -TEST_F(ParseMessageTest, ImplicitSyntaxIdentifier) { - require_syntax_identifier_ = false; - ExpectParsesTo( - "message TestMessage {\n" - " required int32 foo = 1;\n" - "}\n", - - "message_type {" - " name: \"TestMessage\"" - " field { name:\"foo\" label:LABEL_REQUIRED type:TYPE_INT32 number:1 }" - "}"); - EXPECT_EQ("proto2", parser_->GetSyntaxIdentifier()); -} - -TEST_F(ParseMessageTest, ExplicitSyntaxIdentifier) { - ExpectParsesTo( - "syntax = \"proto2\";\n" - "message TestMessage {\n" - " required int32 foo = 1;\n" - "}\n", - - "message_type {" - " name: \"TestMessage\"" - " field { name:\"foo\" label:LABEL_REQUIRED type:TYPE_INT32 number:1 }" - "}"); - EXPECT_EQ("proto2", parser_->GetSyntaxIdentifier()); -} - -TEST_F(ParseMessageTest, ExplicitRequiredSyntaxIdentifier) { - require_syntax_identifier_ = true; - ExpectParsesTo( - "syntax = \"proto2\";\n" - "message TestMessage {\n" - " required int32 foo = 1;\n" - "}\n", - - "message_type {" - " name: \"TestMessage\"" - " field { name:\"foo\" label:LABEL_REQUIRED type:TYPE_INT32 number:1 }" - "}"); - EXPECT_EQ("proto2", parser_->GetSyntaxIdentifier()); -} - -TEST_F(ParseMessageTest, SimpleFields) { - ExpectParsesTo( - "message TestMessage {\n" - " required int32 foo = 15;\n" - " optional int32 bar = 34;\n" - " repeated int32 baz = 3;\n" - "}\n", - - "message_type {" - " name: \"TestMessage\"" - " field { name:\"foo\" label:LABEL_REQUIRED type:TYPE_INT32 number:15 }" - " field { name:\"bar\" label:LABEL_OPTIONAL type:TYPE_INT32 number:34 }" - " field { name:\"baz\" label:LABEL_REPEATED type:TYPE_INT32 number:3 }" - "}"); -} - -TEST_F(ParseMessageTest, PrimitiveFieldTypes) { - ExpectParsesTo( - "message TestMessage {\n" - " required int32 foo = 1;\n" - " required int64 foo = 1;\n" - " required uint32 foo = 1;\n" - " required uint64 foo = 1;\n" - " required sint32 foo = 1;\n" - " required sint64 foo = 1;\n" - " required fixed32 foo = 1;\n" - " required fixed64 foo = 1;\n" - " required sfixed32 foo = 1;\n" - " required sfixed64 foo = 1;\n" - " required float foo = 1;\n" - " required double foo = 1;\n" - " required string foo = 1;\n" - " required bytes foo = 1;\n" - " required bool foo = 1;\n" - "}\n", - - "message_type {" - " name: \"TestMessage\"" - " field { name:\"foo\" label:LABEL_REQUIRED type:TYPE_INT32 number:1 }" - " field { name:\"foo\" label:LABEL_REQUIRED type:TYPE_INT64 number:1 }" - " field { name:\"foo\" label:LABEL_REQUIRED type:TYPE_UINT32 number:1 }" - " field { name:\"foo\" label:LABEL_REQUIRED type:TYPE_UINT64 number:1 }" - " field { name:\"foo\" label:LABEL_REQUIRED type:TYPE_SINT32 number:1 }" - " field { name:\"foo\" label:LABEL_REQUIRED type:TYPE_SINT64 number:1 }" - " field { name:\"foo\" label:LABEL_REQUIRED type:TYPE_FIXED32 number:1 }" - " field { name:\"foo\" label:LABEL_REQUIRED type:TYPE_FIXED64 number:1 }" - " field { name:\"foo\" label:LABEL_REQUIRED type:TYPE_SFIXED32 number:1 }" - " field { name:\"foo\" label:LABEL_REQUIRED type:TYPE_SFIXED64 number:1 }" - " field { name:\"foo\" label:LABEL_REQUIRED type:TYPE_FLOAT number:1 }" - " field { name:\"foo\" label:LABEL_REQUIRED type:TYPE_DOUBLE number:1 }" - " field { name:\"foo\" label:LABEL_REQUIRED type:TYPE_STRING number:1 }" - " field { name:\"foo\" label:LABEL_REQUIRED type:TYPE_BYTES number:1 }" - " field { name:\"foo\" label:LABEL_REQUIRED type:TYPE_BOOL number:1 }" - "}"); -} - -TEST_F(ParseMessageTest, FieldDefaults) { - ExpectParsesTo( - "message TestMessage {\n" - " required int32 foo = 1 [default= 1 ];\n" - " required int32 foo = 1 [default= -2 ];\n" - " required int64 foo = 1 [default= 3 ];\n" - " required int64 foo = 1 [default= -4 ];\n" - " required uint32 foo = 1 [default= 5 ];\n" - " required uint64 foo = 1 [default= 6 ];\n" - " required float foo = 1 [default= 7.5];\n" - " required float foo = 1 [default= -8.5];\n" - " required float foo = 1 [default= 9 ];\n" - " required double foo = 1 [default= 10.5];\n" - " required double foo = 1 [default=-11.5];\n" - " required double foo = 1 [default= 12 ];\n" - " required double foo = 1 [default= inf ];\n" - " required double foo = 1 [default=-inf ];\n" - " required double foo = 1 [default= nan ];\n" - " required string foo = 1 [default='13\\001'];\n" - " required string foo = 1 [default='a' \"b\" \n \"c\"];\n" - " required bytes foo = 1 [default='14\\002'];\n" - " required bytes foo = 1 [default='a' \"b\" \n 'c'];\n" - " required bool foo = 1 [default=true ];\n" - " required Foo foo = 1 [default=FOO ];\n" - - " required int32 foo = 1 [default= 0x7FFFFFFF];\n" - " required int32 foo = 1 [default=-0x80000000];\n" - " required uint32 foo = 1 [default= 0xFFFFFFFF];\n" - " required int64 foo = 1 [default= 0x7FFFFFFFFFFFFFFF];\n" - " required int64 foo = 1 [default=-0x8000000000000000];\n" - " required uint64 foo = 1 [default= 0xFFFFFFFFFFFFFFFF];\n" - " required double foo = 1 [default= 0xabcd];\n" - "}\n", - -#define ETC "name:\"foo\" label:LABEL_REQUIRED number:1" - "message_type {" - " name: \"TestMessage\"" - " field { type:TYPE_INT32 default_value:\"1\" "ETC" }" - " field { type:TYPE_INT32 default_value:\"-2\" "ETC" }" - " field { type:TYPE_INT64 default_value:\"3\" "ETC" }" - " field { type:TYPE_INT64 default_value:\"-4\" "ETC" }" - " field { type:TYPE_UINT32 default_value:\"5\" "ETC" }" - " field { type:TYPE_UINT64 default_value:\"6\" "ETC" }" - " field { type:TYPE_FLOAT default_value:\"7.5\" "ETC" }" - " field { type:TYPE_FLOAT default_value:\"-8.5\" "ETC" }" - " field { type:TYPE_FLOAT default_value:\"9\" "ETC" }" - " field { type:TYPE_DOUBLE default_value:\"10.5\" "ETC" }" - " field { type:TYPE_DOUBLE default_value:\"-11.5\" "ETC" }" - " field { type:TYPE_DOUBLE default_value:\"12\" "ETC" }" - " field { type:TYPE_DOUBLE default_value:\"inf\" "ETC" }" - " field { type:TYPE_DOUBLE default_value:\"-inf\" "ETC" }" - " field { type:TYPE_DOUBLE default_value:\"nan\" "ETC" }" - " field { type:TYPE_STRING default_value:\"13\\001\" "ETC" }" - " field { type:TYPE_STRING default_value:\"abc\" "ETC" }" - " field { type:TYPE_BYTES default_value:\"14\\\\002\" "ETC" }" - " field { type:TYPE_BYTES default_value:\"abc\" "ETC" }" - " field { type:TYPE_BOOL default_value:\"true\" "ETC" }" - " field { type_name:\"Foo\" default_value:\"FOO\" "ETC" }" - - " field { type:TYPE_INT32 default_value:\"2147483647\" "ETC" }" - " field { type:TYPE_INT32 default_value:\"-2147483648\" "ETC" }" - " field { type:TYPE_UINT32 default_value:\"4294967295\" "ETC" }" - " field { type:TYPE_INT64 default_value:\"9223372036854775807\" "ETC" }" - " field { type:TYPE_INT64 default_value:\"-9223372036854775808\" "ETC" }" - " field { type:TYPE_UINT64 default_value:\"18446744073709551615\" "ETC" }" - " field { type:TYPE_DOUBLE default_value:\"43981\" "ETC" }" - "}"); -#undef ETC -} - -TEST_F(ParseMessageTest, FieldOptions) { - ExpectParsesTo( - "message TestMessage {\n" - " optional string foo = 1\n" - " [ctype=CORD, (foo)=7, foo.(.bar.baz).qux.quux.(corge)=-33, \n" - " (quux)=\"x\040y\", (baz.qux)=hey];\n" - "}\n", - - "message_type {" - " name: \"TestMessage\"" - " field { name: \"foo\" label: LABEL_OPTIONAL type: TYPE_STRING number: 1" - " options { uninterpreted_option: { name { name_part: \"ctype\" " - " is_extension: false } " - " identifier_value: \"CORD\" }" - " uninterpreted_option: { name { name_part: \"foo\" " - " is_extension: true } " - " positive_int_value: 7 }" - " uninterpreted_option: { name { name_part: \"foo\" " - " is_extension: false } " - " name { name_part: \".bar.baz\"" - " is_extension: true } " - " name { name_part: \"qux\" " - " is_extension: false } " - " name { name_part: \"quux\" " - " is_extension: false } " - " name { name_part: \"corge\" " - " is_extension: true } " - " negative_int_value: -33 }" - " uninterpreted_option: { name { name_part: \"quux\" " - " is_extension: true } " - " string_value: \"x y\" }" - " uninterpreted_option: { name { name_part: \"baz.qux\" " - " is_extension: true } " - " identifier_value: \"hey\" }" - " }" - " }" - "}"); -} - -TEST_F(ParseMessageTest, Group) { - ExpectParsesTo( - "message TestMessage {\n" - " optional group TestGroup = 1 {};\n" - "}\n", - - "message_type {" - " name: \"TestMessage\"" - " nested_type { name: \"TestGroup\" }" - " field { name:\"testgroup\" label:LABEL_OPTIONAL number:1" - " type:TYPE_GROUP type_name: \"TestGroup\" }" - "}"); -} - -TEST_F(ParseMessageTest, NestedMessage) { - ExpectParsesTo( - "message TestMessage {\n" - " message Nested {}\n" - " optional Nested test_nested = 1;\n" - "}\n", - - "message_type {" - " name: \"TestMessage\"" - " nested_type { name: \"Nested\" }" - " field { name:\"test_nested\" label:LABEL_OPTIONAL number:1" - " type_name: \"Nested\" }" - "}"); -} - -TEST_F(ParseMessageTest, NestedEnum) { - ExpectParsesTo( - "message TestMessage {\n" - " enum NestedEnum {}\n" - " optional NestedEnum test_enum = 1;\n" - "}\n", - - "message_type {" - " name: \"TestMessage\"" - " enum_type { name: \"NestedEnum\" }" - " field { name:\"test_enum\" label:LABEL_OPTIONAL number:1" - " type_name: \"NestedEnum\" }" - "}"); -} - -TEST_F(ParseMessageTest, ExtensionRange) { - ExpectParsesTo( - "message TestMessage {\n" - " extensions 10 to 19;\n" - " extensions 30 to max;\n" - "}\n", - - "message_type {" - " name: \"TestMessage\"" - " extension_range { start:10 end:20 }" - " extension_range { start:30 end:536870912 }" - "}"); -} - -TEST_F(ParseMessageTest, CompoundExtensionRange) { - ExpectParsesTo( - "message TestMessage {\n" - " extensions 2, 15, 9 to 11, 100 to max, 3;\n" - "}\n", - - "message_type {" - " name: \"TestMessage\"" - " extension_range { start:2 end:3 }" - " extension_range { start:15 end:16 }" - " extension_range { start:9 end:12 }" - " extension_range { start:100 end:536870912 }" - " extension_range { start:3 end:4 }" - "}"); -} - -TEST_F(ParseMessageTest, LargerMaxForMessageSetWireFormatMessages) { - // Messages using the message_set_wire_format option can accept larger - // extension numbers, as the numbers are not encoded as int32 field values - // rather than tags. - ExpectParsesTo( - "message TestMessage {\n" - " extensions 4 to max;\n" - " option message_set_wire_format = true;\n" - "}\n", - - "message_type {" - " name: \"TestMessage\"" - " extension_range { start:4 end: 0x7fffffff }" - " options {\n" - " uninterpreted_option { \n" - " name {\n" - " name_part: \"message_set_wire_format\"\n" - " is_extension: false\n" - " }\n" - " identifier_value: \"true\"\n" - " }\n" - " }\n" - "}"); -} - -TEST_F(ParseMessageTest, Extensions) { - ExpectParsesTo( - "extend Extendee1 { optional int32 foo = 12; }\n" - "extend Extendee2 { repeated TestMessage bar = 22; }\n", - - "extension { name:\"foo\" label:LABEL_OPTIONAL type:TYPE_INT32 number:12" - " extendee: \"Extendee1\" } " - "extension { name:\"bar\" label:LABEL_REPEATED number:22" - " type_name:\"TestMessage\" extendee: \"Extendee2\" }"); -} - -TEST_F(ParseMessageTest, ExtensionsInMessageScope) { - ExpectParsesTo( - "message TestMessage {\n" - " extend Extendee1 { optional int32 foo = 12; }\n" - " extend Extendee2 { repeated TestMessage bar = 22; }\n" - "}\n", - - "message_type {" - " name: \"TestMessage\"" - " extension { name:\"foo\" label:LABEL_OPTIONAL type:TYPE_INT32 number:12" - " extendee: \"Extendee1\" }" - " extension { name:\"bar\" label:LABEL_REPEATED number:22" - " type_name:\"TestMessage\" extendee: \"Extendee2\" }" - "}"); -} - -TEST_F(ParseMessageTest, MultipleExtensionsOneExtendee) { - ExpectParsesTo( - "extend Extendee1 {\n" - " optional int32 foo = 12;\n" - " repeated TestMessage bar = 22;\n" - "}\n", - - "extension { name:\"foo\" label:LABEL_OPTIONAL type:TYPE_INT32 number:12" - " extendee: \"Extendee1\" } " - "extension { name:\"bar\" label:LABEL_REPEATED number:22" - " type_name:\"TestMessage\" extendee: \"Extendee1\" }"); -} - -// =================================================================== - -typedef ParserTest ParseEnumTest; - -TEST_F(ParseEnumTest, SimpleEnum) { - ExpectParsesTo( - "enum TestEnum {\n" - " FOO = 0;\n" - "}\n", - - "enum_type {" - " name: \"TestEnum\"" - " value { name:\"FOO\" number:0 }" - "}"); -} - -TEST_F(ParseEnumTest, Values) { - ExpectParsesTo( - "enum TestEnum {\n" - " FOO = 13;\n" - " BAR = -10;\n" - " BAZ = 500;\n" - " HEX_MAX = 0x7FFFFFFF;\n" - " HEX_MIN = -0x80000000;\n" - " INT_MAX = 2147483647;\n" - " INT_MIN = -2147483648;\n" - "}\n", - - "enum_type {" - " name: \"TestEnum\"" - " value { name:\"FOO\" number:13 }" - " value { name:\"BAR\" number:-10 }" - " value { name:\"BAZ\" number:500 }" - " value { name:\"HEX_MAX\" number:2147483647 }" - " value { name:\"HEX_MIN\" number:-2147483648 }" - " value { name:\"INT_MAX\" number:2147483647 }" - " value { name:\"INT_MIN\" number:-2147483648 }" - "}"); -} - -TEST_F(ParseEnumTest, ValueOptions) { - ExpectParsesTo( - "enum TestEnum {\n" - " FOO = 13;\n" - " BAR = -10 [ (something.text) = 'abc' ];\n" - " BAZ = 500 [ (something.text) = 'def', other = 1 ];\n" - "}\n", - - "enum_type {" - " name: \"TestEnum\"" - " value { name: \"FOO\" number: 13 }" - " value { name: \"BAR\" number: -10 " - " options { " - " uninterpreted_option { " - " name { name_part: \"something.text\" is_extension: true } " - " string_value: \"abc\" " - " } " - " } " - " } " - " value { name: \"BAZ\" number: 500 " - " options { " - " uninterpreted_option { " - " name { name_part: \"something.text\" is_extension: true } " - " string_value: \"def\" " - " } " - " uninterpreted_option { " - " name { name_part: \"other\" is_extension: false } " - " positive_int_value: 1 " - " } " - " } " - " } " - "}"); -} - -// =================================================================== - -typedef ParserTest ParseServiceTest; - -TEST_F(ParseServiceTest, SimpleService) { - ExpectParsesTo( - "service TestService {\n" - " rpc Foo(In) returns (Out);\n" - "}\n", - - "service {" - " name: \"TestService\"" - " method { name:\"Foo\" input_type:\"In\" output_type:\"Out\" }" - "}"); -} - -TEST_F(ParseServiceTest, MethodsAndStreams) { - ExpectParsesTo( - "service TestService {\n" - " rpc Foo(In1) returns (Out1);\n" - " rpc Bar(In2) returns (Out2);\n" - " rpc Baz(In3) returns (Out3);\n" - "}\n", - - "service {" - " name: \"TestService\"" - " method { name:\"Foo\" input_type:\"In1\" output_type:\"Out1\" }" - " method { name:\"Bar\" input_type:\"In2\" output_type:\"Out2\" }" - " method { name:\"Baz\" input_type:\"In3\" output_type:\"Out3\" }" - "}"); -} - -// =================================================================== -// imports and packages - -typedef ParserTest ParseMiscTest; - -TEST_F(ParseMiscTest, ParseImport) { - ExpectParsesTo( - "import \"foo/bar/baz.proto\";\n", - "dependency: \"foo/bar/baz.proto\""); -} - -TEST_F(ParseMiscTest, ParseMultipleImports) { - ExpectParsesTo( - "import \"foo.proto\";\n" - "import \"bar.proto\";\n" - "import \"baz.proto\";\n", - "dependency: \"foo.proto\"" - "dependency: \"bar.proto\"" - "dependency: \"baz.proto\""); -} - -TEST_F(ParseMiscTest, ParsePublicImports) { - ExpectParsesTo( - "import \"foo.proto\";\n" - "import public \"bar.proto\";\n" - "import \"baz.proto\";\n" - "import public \"qux.proto\";\n", - "dependency: \"foo.proto\"" - "dependency: \"bar.proto\"" - "dependency: \"baz.proto\"" - "dependency: \"qux.proto\"" - "public_dependency: 1 " - "public_dependency: 3 "); -} - -TEST_F(ParseMiscTest, ParsePackage) { - ExpectParsesTo( - "package foo.bar.baz;\n", - "package: \"foo.bar.baz\""); -} - -TEST_F(ParseMiscTest, ParsePackageWithSpaces) { - ExpectParsesTo( - "package foo . bar. \n" - " baz;\n", - "package: \"foo.bar.baz\""); -} - -// =================================================================== -// options - -TEST_F(ParseMiscTest, ParseFileOptions) { - ExpectParsesTo( - "option java_package = \"com.google.foo\";\n" - "option optimize_for = CODE_SIZE;", - - "options {" - "uninterpreted_option { name { name_part: \"java_package\" " - " is_extension: false }" - " string_value: \"com.google.foo\"} " - "uninterpreted_option { name { name_part: \"optimize_for\" " - " is_extension: false }" - " identifier_value: \"CODE_SIZE\" } " - "}"); -} - -// =================================================================== -// Error tests -// -// There are a very large number of possible errors that the parser could -// report, so it's infeasible to test every single one of them. Instead, -// we test each unique call to AddError() in parser.h. This does not mean -// we are testing every possible error that Parser can generate because -// each variant of the Consume() helper only counts as one unique call to -// AddError(). - -typedef ParserTest ParseErrorTest; - -TEST_F(ParseErrorTest, MissingSyntaxIdentifier) { - require_syntax_identifier_ = true; - ExpectHasEarlyExitErrors( - "message TestMessage {}", - "0:0: File must begin with 'syntax = \"proto2\";'.\n"); - EXPECT_EQ("", parser_->GetSyntaxIdentifier()); -} - -TEST_F(ParseErrorTest, UnknownSyntaxIdentifier) { - ExpectHasEarlyExitErrors( - "syntax = \"no_such_syntax\";", - "0:9: Unrecognized syntax identifier \"no_such_syntax\". This parser " - "only recognizes \"proto2\".\n"); - EXPECT_EQ("no_such_syntax", parser_->GetSyntaxIdentifier()); -} - -TEST_F(ParseErrorTest, SimpleSyntaxError) { - ExpectHasErrors( - "message TestMessage @#$ { blah }", - "0:20: Expected \"{\".\n"); - EXPECT_EQ("proto2", parser_->GetSyntaxIdentifier()); -} - -TEST_F(ParseErrorTest, ExpectedTopLevel) { - ExpectHasErrors( - "blah;", - "0:0: Expected top-level statement (e.g. \"message\").\n"); -} - -TEST_F(ParseErrorTest, UnmatchedCloseBrace) { - // This used to cause an infinite loop. Doh. - ExpectHasErrors( - "}", - "0:0: Expected top-level statement (e.g. \"message\").\n" - "0:0: Unmatched \"}\".\n"); -} - -// ------------------------------------------------------------------- -// Message errors - -TEST_F(ParseErrorTest, MessageMissingName) { - ExpectHasErrors( - "message {}", - "0:8: Expected message name.\n"); -} - -TEST_F(ParseErrorTest, MessageMissingBody) { - ExpectHasErrors( - "message TestMessage;", - "0:19: Expected \"{\".\n"); -} - -TEST_F(ParseErrorTest, EofInMessage) { - ExpectHasErrors( - "message TestMessage {", - "0:21: Reached end of input in message definition (missing '}').\n"); -} - -TEST_F(ParseErrorTest, MissingFieldNumber) { - ExpectHasErrors( - "message TestMessage {\n" - " optional int32 foo;\n" - "}\n", - "1:20: Missing field number.\n"); -} - -TEST_F(ParseErrorTest, ExpectedFieldNumber) { - ExpectHasErrors( - "message TestMessage {\n" - " optional int32 foo = ;\n" - "}\n", - "1:23: Expected field number.\n"); -} - -TEST_F(ParseErrorTest, FieldNumberOutOfRange) { - ExpectHasErrors( - "message TestMessage {\n" - " optional int32 foo = 0x100000000;\n" - "}\n", - "1:23: Integer out of range.\n"); -} - -TEST_F(ParseErrorTest, MissingLabel) { - ExpectHasErrors( - "message TestMessage {\n" - " int32 foo = 1;\n" - "}\n", - "1:2: Expected \"required\", \"optional\", or \"repeated\".\n"); -} - -TEST_F(ParseErrorTest, ExpectedOptionName) { - ExpectHasErrors( - "message TestMessage {\n" - " optional uint32 foo = 1 [];\n" - "}\n", - "1:27: Expected identifier.\n"); -} - -TEST_F(ParseErrorTest, NonExtensionOptionNameBeginningWithDot) { - ExpectHasErrors( - "message TestMessage {\n" - " optional uint32 foo = 1 [.foo=1];\n" - "}\n", - "1:27: Expected identifier.\n"); -} - -TEST_F(ParseErrorTest, DefaultValueTypeMismatch) { - ExpectHasErrors( - "message TestMessage {\n" - " optional uint32 foo = 1 [default=true];\n" - "}\n", - "1:35: Expected integer.\n"); -} - -TEST_F(ParseErrorTest, DefaultValueNotBoolean) { - ExpectHasErrors( - "message TestMessage {\n" - " optional bool foo = 1 [default=blah];\n" - "}\n", - "1:33: Expected \"true\" or \"false\".\n"); -} - -TEST_F(ParseErrorTest, DefaultValueNotString) { - ExpectHasErrors( - "message TestMessage {\n" - " optional string foo = 1 [default=1];\n" - "}\n", - "1:35: Expected string.\n"); -} - -TEST_F(ParseErrorTest, DefaultValueUnsignedNegative) { - ExpectHasErrors( - "message TestMessage {\n" - " optional uint32 foo = 1 [default=-1];\n" - "}\n", - "1:36: Unsigned field can't have negative default value.\n"); -} - -TEST_F(ParseErrorTest, DefaultValueTooLarge) { - ExpectHasErrors( - "message TestMessage {\n" - " optional int32 foo = 1 [default= 0x80000000];\n" - " optional int32 foo = 1 [default=-0x80000001];\n" - " optional uint32 foo = 1 [default= 0x100000000];\n" - " optional int64 foo = 1 [default= 0x80000000000000000];\n" - " optional int64 foo = 1 [default=-0x80000000000000001];\n" - " optional uint64 foo = 1 [default= 0x100000000000000000];\n" - "}\n", - "1:36: Integer out of range.\n" - "2:36: Integer out of range.\n" - "3:36: Integer out of range.\n" - "4:36: Integer out of range.\n" - "5:36: Integer out of range.\n" - "6:36: Integer out of range.\n"); -} - -TEST_F(ParseErrorTest, EnumValueOutOfRange) { - ExpectHasErrors( - "enum TestEnum {\n" - " HEX_TOO_BIG = 0x80000000;\n" - " HEX_TOO_SMALL = -0x80000001;\n" - " INT_TOO_BIG = 2147483648;\n" - " INT_TOO_SMALL = -2147483649;\n" - "}\n", - "1:19: Integer out of range.\n" - "2:19: Integer out of range.\n" - "3:19: Integer out of range.\n" - "4:19: Integer out of range.\n"); -} - -TEST_F(ParseErrorTest, DefaultValueMissing) { - ExpectHasErrors( - "message TestMessage {\n" - " optional uint32 foo = 1 [default=];\n" - "}\n", - "1:35: Expected integer.\n"); -} - -TEST_F(ParseErrorTest, DefaultValueForGroup) { - ExpectHasErrors( - "message TestMessage {\n" - " optional group Foo = 1 [default=blah] {}\n" - "}\n", - "1:34: Messages can't have default values.\n"); -} - -TEST_F(ParseErrorTest, DuplicateDefaultValue) { - ExpectHasErrors( - "message TestMessage {\n" - " optional uint32 foo = 1 [default=1,default=2];\n" - "}\n", - "1:37: Already set option \"default\".\n"); -} - -TEST_F(ParseErrorTest, GroupNotCapitalized) { - ExpectHasErrors( - "message TestMessage {\n" - " optional group foo = 1 {}\n" - "}\n", - "1:17: Group names must start with a capital letter.\n"); -} - -TEST_F(ParseErrorTest, GroupMissingBody) { - ExpectHasErrors( - "message TestMessage {\n" - " optional group Foo = 1;\n" - "}\n", - "1:24: Missing group body.\n"); -} - -TEST_F(ParseErrorTest, ExtendingPrimitive) { - ExpectHasErrors( - "extend int32 { optional string foo = 4; }\n", - "0:7: Expected message type.\n"); -} - -TEST_F(ParseErrorTest, ErrorInExtension) { - ExpectHasErrors( - "message Foo { extensions 100 to 199; }\n" - "extend Foo { optional string foo; }\n", - "1:32: Missing field number.\n"); -} - -TEST_F(ParseErrorTest, MultipleParseErrors) { - // When a statement has a parse error, the parser should be able to continue - // parsing at the next statement. - ExpectHasErrors( - "message TestMessage {\n" - " optional int32 foo;\n" - " !invalid statement ending in a block { blah blah { blah } blah }\n" - " optional int32 bar = 3 {}\n" - "}\n", - "1:20: Missing field number.\n" - "2:2: Expected \"required\", \"optional\", or \"repeated\".\n" - "2:2: Expected type name.\n" - "3:25: Expected \";\".\n"); -} - -TEST_F(ParseErrorTest, EofInAggregateValue) { - ExpectHasErrors( - "option (fileopt) = { i:100\n", - "1:0: Unexpected end of stream while parsing aggregate value.\n"); -} - -// ------------------------------------------------------------------- -// Enum errors - -TEST_F(ParseErrorTest, EofInEnum) { - ExpectHasErrors( - "enum TestEnum {", - "0:15: Reached end of input in enum definition (missing '}').\n"); -} - -TEST_F(ParseErrorTest, EnumValueMissingNumber) { - ExpectHasErrors( - "enum TestEnum {\n" - " FOO;\n" - "}\n", - "1:5: Missing numeric value for enum constant.\n"); -} - -// ------------------------------------------------------------------- -// Service errors - -TEST_F(ParseErrorTest, EofInService) { - ExpectHasErrors( - "service TestService {", - "0:21: Reached end of input in service definition (missing '}').\n"); -} - -TEST_F(ParseErrorTest, ServiceMethodPrimitiveParams) { - ExpectHasErrors( - "service TestService {\n" - " rpc Foo(int32) returns (string);\n" - "}\n", - "1:10: Expected message type.\n" - "1:26: Expected message type.\n"); -} - - -TEST_F(ParseErrorTest, EofInMethodOptions) { - ExpectHasErrors( - "service TestService {\n" - " rpc Foo(Bar) returns(Bar) {", - "1:29: Reached end of input in method options (missing '}').\n" - "1:29: Reached end of input in service definition (missing '}').\n"); -} - - -TEST_F(ParseErrorTest, PrimitiveMethodInput) { - ExpectHasErrors( - "service TestService {\n" - " rpc Foo(int32) returns(Bar);\n" - "}\n", - "1:10: Expected message type.\n"); -} - - -TEST_F(ParseErrorTest, MethodOptionTypeError) { - // This used to cause an infinite loop. - ExpectHasErrors( - "message Baz {}\n" - "service Foo {\n" - " rpc Bar(Baz) returns(Baz) { option invalid syntax; }\n" - "}\n", - "2:45: Expected \"=\".\n"); -} - - -// ------------------------------------------------------------------- -// Import and package errors - -TEST_F(ParseErrorTest, ImportNotQuoted) { - ExpectHasErrors( - "import foo;\n", - "0:7: Expected a string naming the file to import.\n"); -} - -TEST_F(ParseErrorTest, MultiplePackagesInFile) { - ExpectHasErrors( - "package foo;\n" - "package bar;\n", - "1:0: Multiple package definitions.\n"); -} - -// =================================================================== -// Test that errors detected by DescriptorPool correctly report line and -// column numbers. We have one test for every call to RecordLocation() in -// parser.cc. - -typedef ParserTest ParserValidationErrorTest; - -TEST_F(ParserValidationErrorTest, PackageNameError) { - // Create another file which defines symbol "foo". - FileDescriptorProto other_file; - other_file.set_name("bar.proto"); - other_file.add_message_type()->set_name("foo"); - EXPECT_TRUE(pool_.BuildFile(other_file) != NULL); - - // Now try to define it as a package. - ExpectHasValidationErrors( - "package foo.bar;", - "0:8: \"foo\" is already defined (as something other than a package) " - "in file \"bar.proto\".\n"); -} - -TEST_F(ParserValidationErrorTest, MessageNameError) { - ExpectHasValidationErrors( - "message Foo {}\n" - "message Foo {}\n", - "1:8: \"Foo\" is already defined.\n"); -} - -TEST_F(ParserValidationErrorTest, FieldNameError) { - ExpectHasValidationErrors( - "message Foo {\n" - " optional int32 bar = 1;\n" - " optional int32 bar = 2;\n" - "}\n", - "2:17: \"bar\" is already defined in \"Foo\".\n"); -} - -TEST_F(ParserValidationErrorTest, FieldTypeError) { - ExpectHasValidationErrors( - "message Foo {\n" - " optional Baz bar = 1;\n" - "}\n", - "1:11: \"Baz\" is not defined.\n"); -} - -TEST_F(ParserValidationErrorTest, FieldNumberError) { - ExpectHasValidationErrors( - "message Foo {\n" - " optional int32 bar = 0;\n" - "}\n", - "1:23: Field numbers must be positive integers.\n"); -} - -TEST_F(ParserValidationErrorTest, FieldExtendeeError) { - ExpectHasValidationErrors( - "extend Baz { optional int32 bar = 1; }\n", - "0:7: \"Baz\" is not defined.\n"); -} - -TEST_F(ParserValidationErrorTest, FieldDefaultValueError) { - ExpectHasValidationErrors( - "enum Baz { QUX = 1; }\n" - "message Foo {\n" - " optional Baz bar = 1 [default=NO_SUCH_VALUE];\n" - "}\n", - "2:32: Enum type \"Baz\" has no value named \"NO_SUCH_VALUE\".\n"); -} - -TEST_F(ParserValidationErrorTest, FileOptionNameError) { - ExpectHasValidationErrors( - "option foo = 5;", - "0:7: Option \"foo\" unknown.\n"); -} - -TEST_F(ParserValidationErrorTest, FileOptionValueError) { - ExpectHasValidationErrors( - "option java_outer_classname = 5;", - "0:30: Value must be quoted string for string option " - "\"google.protobuf.FileOptions.java_outer_classname\".\n"); -} - -TEST_F(ParserValidationErrorTest, FieldOptionNameError) { - ExpectHasValidationErrors( - "message Foo {\n" - " optional bool bar = 1 [foo=1];\n" - "}\n", - "1:25: Option \"foo\" unknown.\n"); -} - -TEST_F(ParserValidationErrorTest, FieldOptionValueError) { - ExpectHasValidationErrors( - "message Foo {\n" - " optional int32 bar = 1 [ctype=1];\n" - "}\n", - "1:32: Value must be identifier for enum-valued option " - "\"google.protobuf.FieldOptions.ctype\".\n"); -} - -TEST_F(ParserValidationErrorTest, ExtensionRangeNumberError) { - ExpectHasValidationErrors( - "message Foo {\n" - " extensions 0;\n" - "}\n", - "1:13: Extension numbers must be positive integers.\n"); -} - -TEST_F(ParserValidationErrorTest, EnumNameError) { - ExpectHasValidationErrors( - "enum Foo {A = 1;}\n" - "enum Foo {B = 1;}\n", - "1:5: \"Foo\" is already defined.\n"); -} - -TEST_F(ParserValidationErrorTest, EnumValueNameError) { - ExpectHasValidationErrors( - "enum Foo {\n" - " BAR = 1;\n" - " BAR = 1;\n" - "}\n", - "2:2: \"BAR\" is already defined.\n"); -} - -TEST_F(ParserValidationErrorTest, ServiceNameError) { - ExpectHasValidationErrors( - "service Foo {}\n" - "service Foo {}\n", - "1:8: \"Foo\" is already defined.\n"); -} - -TEST_F(ParserValidationErrorTest, MethodNameError) { - ExpectHasValidationErrors( - "message Baz {}\n" - "service Foo {\n" - " rpc Bar(Baz) returns(Baz);\n" - " rpc Bar(Baz) returns(Baz);\n" - "}\n", - "3:6: \"Bar\" is already defined in \"Foo\".\n"); -} - - -TEST_F(ParserValidationErrorTest, MethodInputTypeError) { - ExpectHasValidationErrors( - "message Baz {}\n" - "service Foo {\n" - " rpc Bar(Qux) returns(Baz);\n" - "}\n", - "2:10: \"Qux\" is not defined.\n"); -} - - -TEST_F(ParserValidationErrorTest, MethodOutputTypeError) { - ExpectHasValidationErrors( - "message Baz {}\n" - "service Foo {\n" - " rpc Bar(Baz) returns(Qux);\n" - "}\n", - "2:23: \"Qux\" is not defined.\n"); -} - - -// =================================================================== -// Test that the output from FileDescriptor::DebugString() (and all other -// descriptor types) is parseable, and results in the same Descriptor -// definitions again afoter parsing (not, however, that the order of messages -// cannot be guaranteed to be the same) - -typedef ParserTest ParseDecriptorDebugTest; - -class CompareDescriptorNames { - public: - bool operator()(const DescriptorProto* left, const DescriptorProto* right) { - return left->name() < right->name(); - } -}; - -// Sorts nested DescriptorProtos of a DescriptoProto, by name. -void SortMessages(DescriptorProto *descriptor_proto) { - int size = descriptor_proto->nested_type_size(); - // recursively sort; we can't guarantee the order of nested messages either - for (int i = 0; i < size; ++i) { - SortMessages(descriptor_proto->mutable_nested_type(i)); - } - DescriptorProto **data = - descriptor_proto->mutable_nested_type()->mutable_data(); - sort(data, data + size, CompareDescriptorNames()); -} - -// Sorts DescriptorProtos belonging to a FileDescriptorProto, by name. -void SortMessages(FileDescriptorProto *file_descriptor_proto) { - int size = file_descriptor_proto->message_type_size(); - // recursively sort; we can't guarantee the order of nested messages either - for (int i = 0; i < size; ++i) { - SortMessages(file_descriptor_proto->mutable_message_type(i)); - } - DescriptorProto **data = - file_descriptor_proto->mutable_message_type()->mutable_data(); - sort(data, data + size, CompareDescriptorNames()); -} - -TEST_F(ParseDecriptorDebugTest, TestAllDescriptorTypes) { - const FileDescriptor* original_file = - protobuf_unittest::TestAllTypes::descriptor()->file(); - FileDescriptorProto expected; - original_file->CopyTo(&expected); - - // Get the DebugString of the unittest.proto FileDecriptor, which includes - // all other descriptor types - string debug_string = original_file->DebugString(); - - // Parse the debug string - SetupParser(debug_string.c_str()); - FileDescriptorProto parsed; - parser_->Parse(input_.get(), &parsed); - EXPECT_EQ(io::Tokenizer::TYPE_END, input_->current().type); - ASSERT_EQ("", error_collector_.text_); - - // We now have a FileDescriptorProto, but to compare with the expected we - // need to link to a FileDecriptor, then output back to a proto. We'll - // also need to give it the same name as the original. - parsed.set_name("google/protobuf/unittest.proto"); - // We need the imported dependency before we can build our parsed proto - const FileDescriptor* public_import = - protobuf_unittest_import::PublicImportMessage::descriptor()->file(); - FileDescriptorProto public_import_proto; - public_import->CopyTo(&public_import_proto); - ASSERT_TRUE(pool_.BuildFile(public_import_proto) != NULL); - const FileDescriptor* import = - protobuf_unittest_import::ImportMessage::descriptor()->file(); - FileDescriptorProto import_proto; - import->CopyTo(&import_proto); - ASSERT_TRUE(pool_.BuildFile(import_proto) != NULL); - const FileDescriptor* actual = pool_.BuildFile(parsed); - parsed.Clear(); - actual->CopyTo(&parsed); - ASSERT_TRUE(actual != NULL); - - // The messages might be in different orders, making them hard to compare. - // So, sort the messages in the descriptor protos (including nested messages, - // recursively). - SortMessages(&expected); - SortMessages(&parsed); - - // I really wanted to use StringDiff here for the debug output on fail, - // but the strings are too long for it, and if I increase its max size, - // we get a memory allocation failure :( - EXPECT_EQ(expected.DebugString(), parsed.DebugString()); -} - -TEST_F(ParseDecriptorDebugTest, TestCustomOptions) { - const FileDescriptor* original_file = - protobuf_unittest::AggregateMessage::descriptor()->file(); - FileDescriptorProto expected; - original_file->CopyTo(&expected); - - string debug_string = original_file->DebugString(); - - // Parse the debug string - SetupParser(debug_string.c_str()); - FileDescriptorProto parsed; - parser_->Parse(input_.get(), &parsed); - EXPECT_EQ(io::Tokenizer::TYPE_END, input_->current().type); - ASSERT_EQ("", error_collector_.text_); - - // We now have a FileDescriptorProto, but to compare with the expected we - // need to link to a FileDecriptor, then output back to a proto. We'll - // also need to give it the same name as the original. - parsed.set_name(original_file->name()); - - // unittest_custom_options.proto depends on descriptor.proto. - const FileDescriptor* import = FileDescriptorProto::descriptor()->file(); - FileDescriptorProto import_proto; - import->CopyTo(&import_proto); - ASSERT_TRUE(pool_.BuildFile(import_proto) != NULL); - const FileDescriptor* actual = pool_.BuildFile(parsed); - ASSERT_TRUE(actual != NULL); - parsed.Clear(); - actual->CopyTo(&parsed); - - // The messages might be in different orders, making them hard to compare. - // So, sort the messages in the descriptor protos (including nested messages, - // recursively). - SortMessages(&expected); - SortMessages(&parsed); - - EXPECT_EQ(expected.DebugString(), parsed.DebugString()); -} - -// =================================================================== -// SourceCodeInfo tests. - -// Follows a path -- as defined by SourceCodeInfo.Location.path -- from a -// message to a particular sub-field. -// * If the target is itself a message, sets *output_message to point at it, -// *output_field to NULL, and *output_index to -1. -// * Otherwise, if the target is an element of a repeated field, sets -// *output_message to the containing message, *output_field to the descriptor -// of the field, and *output_index to the index of the element. -// * Otherwise, the target is a field (possibly a repeated field, but not any -// one element). Sets *output_message to the containing message, -// *output_field to the descriptor of the field, and *output_index to -1. -// Returns true if the path was valid, false otherwise. A gTest failure is -// recorded before returning false. -bool FollowPath(const Message& root, - const int* path_begin, const int* path_end, - const Message** output_message, - const FieldDescriptor** output_field, - int* output_index) { - if (path_begin == path_end) { - // Path refers to this whole message. - *output_message = &root; - *output_field = NULL; - *output_index = -1; - return true; - } - - const Descriptor* descriptor = root.GetDescriptor(); - const Reflection* reflection = root.GetReflection(); - - const FieldDescriptor* field = descriptor->FindFieldByNumber(*path_begin); - - if (field == NULL) { - ADD_FAILURE() << descriptor->name() << " has no field number: " - << *path_begin; - return false; - } - - ++path_begin; - - if (field->is_repeated()) { - if (path_begin == path_end) { - // Path refers to the whole repeated field. - *output_message = &root; - *output_field = field; - *output_index = -1; - return true; - } - - int index = *path_begin++; - int size = reflection->FieldSize(root, field); - - if (index >= size) { - ADD_FAILURE() << descriptor->name() << "." << field->name() - << " has size " << size << ", but path contained index: " - << index; - return false; - } - - if (field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE) { - // Descend into child message. - const Message& child = reflection->GetRepeatedMessage(root, field, index); - return FollowPath(child, path_begin, path_end, - output_message, output_field, output_index); - } else if (path_begin == path_end) { - // Path refers to this element. - *output_message = &root; - *output_field = field; - *output_index = index; - return true; - } else { - ADD_FAILURE() << descriptor->name() << "." << field->name() - << " is not a message; cannot descend into it."; - return false; - } - } else { - if (field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE) { - const Message& child = reflection->GetMessage(root, field); - return FollowPath(child, path_begin, path_end, - output_message, output_field, output_index); - } else if (path_begin == path_end) { - // Path refers to this field. - *output_message = &root; - *output_field = field; - *output_index = -1; - return true; - } else { - ADD_FAILURE() << descriptor->name() << "." << field->name() - << " is not a message; cannot descend into it."; - return false; - } - } -} - -// Check if two spans are equal. -bool CompareSpans(const RepeatedField& span1, - const RepeatedField& span2) { - if (span1.size() != span2.size()) return false; - for (int i = 0; i < span1.size(); i++) { - if (span1.Get(i) != span2.Get(i)) return false; - } - return true; -} - -// Test fixture for source info tests, which check that source locations are -// recorded correctly in FileDescriptorProto.source_code_info.location. -class SourceInfoTest : public ParserTest { - protected: - // The parsed file (initialized by Parse()). - FileDescriptorProto file_; - - // Parse the given text as a .proto file and populate the spans_ map with - // all the source location spans in its SourceCodeInfo table. - bool Parse(const char* text) { - ExtractMarkers(text); - SetupParser(text_without_markers_.c_str()); - if (!parser_->Parse(input_.get(), &file_)) { - return false; - } - - const SourceCodeInfo& source_info = file_.source_code_info(); - for (int i = 0; i < source_info.location_size(); i++) { - const SourceCodeInfo::Location& location = source_info.location(i); - const Message* descriptor_proto = NULL; - const FieldDescriptor* field = NULL; - int index = 0; - if (!FollowPath(file_, location.path().begin(), location.path().end(), - &descriptor_proto, &field, &index)) { - return false; - } - - spans_.insert(make_pair(SpanKey(*descriptor_proto, field, index), - &location)); - } - - return true; - } - - virtual void TearDown() { - EXPECT_TRUE(spans_.empty()) - << "Forgot to call HasSpan() for:\n" - << spans_.begin()->second->DebugString(); - } - - // ----------------------------------------------------------------- - // HasSpan() checks that the span of source code delimited by the given - // tags (comments) correspond via the SourceCodeInfo table to the given - // part of the FileDescriptorProto. (If unclear, look at the actual tests; - // it should quickly become obvious.) - - bool HasSpan(char start_marker, char end_marker, - const Message& descriptor_proto) { - return HasSpanWithComment( - start_marker, end_marker, descriptor_proto, NULL, -1, NULL, NULL); - } - - bool HasSpanWithComment(char start_marker, char end_marker, - const Message& descriptor_proto, - const char* expected_leading_comments, - const char* expected_trailing_comments) { - return HasSpanWithComment( - start_marker, end_marker, descriptor_proto, NULL, -1, - expected_leading_comments, expected_trailing_comments); - } - - bool HasSpan(char start_marker, char end_marker, - const Message& descriptor_proto, const string& field_name) { - return HasSpan(start_marker, end_marker, descriptor_proto, field_name, -1); - } - - bool HasSpan(char start_marker, char end_marker, - const Message& descriptor_proto, const string& field_name, - int index) { - return HasSpan(start_marker, end_marker, descriptor_proto, - field_name, index, NULL, NULL); - } - - bool HasSpan(char start_marker, char end_marker, - const Message& descriptor_proto, - const string& field_name, int index, - const char* expected_leading_comments, - const char* expected_trailing_comments) { - const FieldDescriptor* field = - descriptor_proto.GetDescriptor()->FindFieldByName(field_name); - if (field == NULL) { - ADD_FAILURE() << descriptor_proto.GetDescriptor()->name() - << " has no such field: " << field_name; - return false; - } - - return HasSpanWithComment( - start_marker, end_marker, descriptor_proto, field, index, - expected_leading_comments, expected_trailing_comments); - } - - bool HasSpan(const Message& descriptor_proto) { - return HasSpanWithComment( - '\0', '\0', descriptor_proto, NULL, -1, NULL, NULL); - } - - bool HasSpan(const Message& descriptor_proto, const string& field_name) { - return HasSpan('\0', '\0', descriptor_proto, field_name, -1); - } - - bool HasSpan(const Message& descriptor_proto, const string& field_name, - int index) { - return HasSpan('\0', '\0', descriptor_proto, field_name, index); - } - - bool HasSpanWithComment(char start_marker, char end_marker, - const Message& descriptor_proto, - const FieldDescriptor* field, int index, - const char* expected_leading_comments, - const char* expected_trailing_comments) { - pair range = - spans_.equal_range(SpanKey(descriptor_proto, field, index)); - - if (start_marker == '\0') { - if (range.first == range.second) { - return false; - } else { - spans_.erase(range.first); - return true; - } - } else { - pair start_pos = FindOrDie(markers_, start_marker); - pair end_pos = FindOrDie(markers_, end_marker); - - RepeatedField expected_span; - expected_span.Add(start_pos.first); - expected_span.Add(start_pos.second); - if (end_pos.first != start_pos.first) { - expected_span.Add(end_pos.first); - } - expected_span.Add(end_pos.second); - - for (SpanMap::iterator iter = range.first; iter != range.second; ++iter) { - if (CompareSpans(expected_span, iter->second->span())) { - if (expected_leading_comments == NULL) { - EXPECT_FALSE(iter->second->has_leading_comments()); - } else { - EXPECT_TRUE(iter->second->has_leading_comments()); - EXPECT_EQ(expected_leading_comments, - iter->second->leading_comments()); - } - if (expected_trailing_comments == NULL) { - EXPECT_FALSE(iter->second->has_trailing_comments()); - } else { - EXPECT_TRUE(iter->second->has_trailing_comments()); - EXPECT_EQ(expected_trailing_comments, - iter->second->trailing_comments()); - } - - spans_.erase(iter); - return true; - } - } - - return false; - } - } - - private: - struct SpanKey { - const Message* descriptor_proto; - const FieldDescriptor* field; - int index; - - inline SpanKey() {} - inline SpanKey(const Message& descriptor_proto_param, - const FieldDescriptor* field_param, - int index_param) - : descriptor_proto(&descriptor_proto_param), field(field_param), - index(index_param) {} - - inline bool operator<(const SpanKey& other) const { - if (descriptor_proto < other.descriptor_proto) return true; - if (descriptor_proto > other.descriptor_proto) return false; - if (field < other.field) return true; - if (field > other.field) return false; - return index < other.index; - } - }; - - typedef multimap SpanMap; - SpanMap spans_; - map > markers_; - string text_without_markers_; - - void ExtractMarkers(const char* text) { - markers_.clear(); - text_without_markers_.clear(); - int line = 0; - int column = 0; - while (*text != '\0') { - if (*text == '$') { - ++text; - GOOGLE_CHECK_NE('\0', *text); - if (*text == '$') { - text_without_markers_ += '$'; - ++column; - } else { - markers_[*text] = make_pair(line, column); - ++text; - GOOGLE_CHECK_EQ('$', *text); - } - } else if (*text == '\n') { - ++line; - column = 0; - text_without_markers_ += *text; - } else { - text_without_markers_ += *text; - ++column; - } - ++text; - } - } -}; - -TEST_F(SourceInfoTest, BasicFileDecls) { - EXPECT_TRUE(Parse( - "$a$syntax = \"proto2\";\n" - "package $b$foo.bar$c$;\n" - "import $d$\"baz.proto\"$e$;\n" - "import $f$\"qux.proto\"$g$;$h$\n" - "\n" - "// comment ignored\n")); - - EXPECT_TRUE(HasSpan('a', 'h', file_)); - EXPECT_TRUE(HasSpan('b', 'c', file_, "package")); - EXPECT_TRUE(HasSpan('d', 'e', file_, "dependency", 0)); - EXPECT_TRUE(HasSpan('f', 'g', file_, "dependency", 1)); -} - -TEST_F(SourceInfoTest, Messages) { - EXPECT_TRUE(Parse( - "$a$message $b$Foo$c$ {}$d$\n" - "$e$message $f$Bar$g$ {}$h$\n")); - - EXPECT_TRUE(HasSpan('a', 'd', file_.message_type(0))); - EXPECT_TRUE(HasSpan('b', 'c', file_.message_type(0), "name")); - EXPECT_TRUE(HasSpan('e', 'h', file_.message_type(1))); - EXPECT_TRUE(HasSpan('f', 'g', file_.message_type(1), "name")); - - // Ignore these. - EXPECT_TRUE(HasSpan(file_)); -} - -TEST_F(SourceInfoTest, Fields) { - EXPECT_TRUE(Parse( - "message Foo {\n" - " $a$optional$b$ $c$int32$d$ $e$bar$f$ = $g$1$h$;$i$\n" - " $j$repeated$k$ $l$X.Y$m$ $n$baz$o$ = $p$2$q$;$r$\n" - "}\n")); - - const FieldDescriptorProto& field1 = file_.message_type(0).field(0); - const FieldDescriptorProto& field2 = file_.message_type(0).field(1); - - EXPECT_TRUE(HasSpan('a', 'i', field1)); - EXPECT_TRUE(HasSpan('a', 'b', field1, "label")); - EXPECT_TRUE(HasSpan('c', 'd', field1, "type")); - EXPECT_TRUE(HasSpan('e', 'f', field1, "name")); - EXPECT_TRUE(HasSpan('g', 'h', field1, "number")); - - EXPECT_TRUE(HasSpan('j', 'r', field2)); - EXPECT_TRUE(HasSpan('j', 'k', field2, "label")); - EXPECT_TRUE(HasSpan('l', 'm', field2, "type_name")); - EXPECT_TRUE(HasSpan('n', 'o', field2, "name")); - EXPECT_TRUE(HasSpan('p', 'q', field2, "number")); - - // Ignore these. - EXPECT_TRUE(HasSpan(file_)); - EXPECT_TRUE(HasSpan(file_.message_type(0))); - EXPECT_TRUE(HasSpan(file_.message_type(0), "name")); -} - -TEST_F(SourceInfoTest, Extensions) { - EXPECT_TRUE(Parse( - "$a$extend $b$Foo$c$ {\n" - " $d$optional$e$ int32 bar = 1;$f$\n" - " $g$repeated$h$ X.Y baz = 2;$i$\n" - "}$j$\n" - "$k$extend $l$Bar$m$ {\n" - " $n$optional int32 qux = 1;$o$\n" - "}$p$\n")); - - const FieldDescriptorProto& field1 = file_.extension(0); - const FieldDescriptorProto& field2 = file_.extension(1); - const FieldDescriptorProto& field3 = file_.extension(2); - - EXPECT_TRUE(HasSpan('a', 'j', file_, "extension")); - EXPECT_TRUE(HasSpan('k', 'p', file_, "extension")); - - EXPECT_TRUE(HasSpan('d', 'f', field1)); - EXPECT_TRUE(HasSpan('d', 'e', field1, "label")); - EXPECT_TRUE(HasSpan('b', 'c', field1, "extendee")); - - EXPECT_TRUE(HasSpan('g', 'i', field2)); - EXPECT_TRUE(HasSpan('g', 'h', field2, "label")); - EXPECT_TRUE(HasSpan('b', 'c', field2, "extendee")); - - EXPECT_TRUE(HasSpan('n', 'o', field3)); - EXPECT_TRUE(HasSpan('l', 'm', field3, "extendee")); - - // Ignore these. - EXPECT_TRUE(HasSpan(file_)); - EXPECT_TRUE(HasSpan(field1, "type")); - EXPECT_TRUE(HasSpan(field1, "name")); - EXPECT_TRUE(HasSpan(field1, "number")); - EXPECT_TRUE(HasSpan(field2, "type_name")); - EXPECT_TRUE(HasSpan(field2, "name")); - EXPECT_TRUE(HasSpan(field2, "number")); - EXPECT_TRUE(HasSpan(field3, "label")); - EXPECT_TRUE(HasSpan(field3, "type")); - EXPECT_TRUE(HasSpan(field3, "name")); - EXPECT_TRUE(HasSpan(field3, "number")); -} - -TEST_F(SourceInfoTest, NestedExtensions) { - EXPECT_TRUE(Parse( - "message Message {\n" - " $a$extend $b$Foo$c$ {\n" - " $d$optional$e$ int32 bar = 1;$f$\n" - " $g$repeated$h$ X.Y baz = 2;$i$\n" - " }$j$\n" - " $k$extend $l$Bar$m$ {\n" - " $n$optional int32 qux = 1;$o$\n" - " }$p$\n" - "}\n")); - - const FieldDescriptorProto& field1 = file_.message_type(0).extension(0); - const FieldDescriptorProto& field2 = file_.message_type(0).extension(1); - const FieldDescriptorProto& field3 = file_.message_type(0).extension(2); - - EXPECT_TRUE(HasSpan('a', 'j', file_.message_type(0), "extension")); - EXPECT_TRUE(HasSpan('k', 'p', file_.message_type(0), "extension")); - - EXPECT_TRUE(HasSpan('d', 'f', field1)); - EXPECT_TRUE(HasSpan('d', 'e', field1, "label")); - EXPECT_TRUE(HasSpan('b', 'c', field1, "extendee")); - - EXPECT_TRUE(HasSpan('g', 'i', field2)); - EXPECT_TRUE(HasSpan('g', 'h', field2, "label")); - EXPECT_TRUE(HasSpan('b', 'c', field2, "extendee")); - - EXPECT_TRUE(HasSpan('n', 'o', field3)); - EXPECT_TRUE(HasSpan('l', 'm', field3, "extendee")); - - // Ignore these. - EXPECT_TRUE(HasSpan(file_)); - EXPECT_TRUE(HasSpan(file_.message_type(0))); - EXPECT_TRUE(HasSpan(file_.message_type(0), "name")); - EXPECT_TRUE(HasSpan(field1, "type")); - EXPECT_TRUE(HasSpan(field1, "name")); - EXPECT_TRUE(HasSpan(field1, "number")); - EXPECT_TRUE(HasSpan(field2, "type_name")); - EXPECT_TRUE(HasSpan(field2, "name")); - EXPECT_TRUE(HasSpan(field2, "number")); - EXPECT_TRUE(HasSpan(field3, "label")); - EXPECT_TRUE(HasSpan(field3, "type")); - EXPECT_TRUE(HasSpan(field3, "name")); - EXPECT_TRUE(HasSpan(field3, "number")); -} - -TEST_F(SourceInfoTest, ExtensionRanges) { - EXPECT_TRUE(Parse( - "message Message {\n" - " $a$extensions $b$1$c$ to $d$4$e$, $f$6$g$;$h$\n" - " $i$extensions $j$8$k$ to $l$max$m$;$n$\n" - "}\n")); - - const DescriptorProto::ExtensionRange& range1 = - file_.message_type(0).extension_range(0); - const DescriptorProto::ExtensionRange& range2 = - file_.message_type(0).extension_range(1); - const DescriptorProto::ExtensionRange& range3 = - file_.message_type(0).extension_range(2); - - EXPECT_TRUE(HasSpan('a', 'h', file_.message_type(0), "extension_range")); - EXPECT_TRUE(HasSpan('i', 'n', file_.message_type(0), "extension_range")); - - EXPECT_TRUE(HasSpan('b', 'e', range1)); - EXPECT_TRUE(HasSpan('b', 'c', range1, "start")); - EXPECT_TRUE(HasSpan('d', 'e', range1, "end")); - - EXPECT_TRUE(HasSpan('f', 'g', range2)); - EXPECT_TRUE(HasSpan('f', 'g', range2, "start")); - EXPECT_TRUE(HasSpan('f', 'g', range2, "end")); - - EXPECT_TRUE(HasSpan('j', 'm', range3)); - EXPECT_TRUE(HasSpan('j', 'k', range3, "start")); - EXPECT_TRUE(HasSpan('l', 'm', range3, "end")); - - // Ignore these. - EXPECT_TRUE(HasSpan(file_)); - EXPECT_TRUE(HasSpan(file_.message_type(0))); - EXPECT_TRUE(HasSpan(file_.message_type(0), "name")); -} - -TEST_F(SourceInfoTest, NestedMessages) { - EXPECT_TRUE(Parse( - "message Foo {\n" - " $a$message $b$Bar$c$ {\n" - " $d$message $e$Baz$f$ {}$g$\n" - " }$h$\n" - " $i$message $j$Qux$k$ {}$l$\n" - "}\n")); - - const DescriptorProto& bar = file_.message_type(0).nested_type(0); - const DescriptorProto& baz = bar.nested_type(0); - const DescriptorProto& qux = file_.message_type(0).nested_type(1); - - EXPECT_TRUE(HasSpan('a', 'h', bar)); - EXPECT_TRUE(HasSpan('b', 'c', bar, "name")); - EXPECT_TRUE(HasSpan('d', 'g', baz)); - EXPECT_TRUE(HasSpan('e', 'f', baz, "name")); - EXPECT_TRUE(HasSpan('i', 'l', qux)); - EXPECT_TRUE(HasSpan('j', 'k', qux, "name")); - - // Ignore these. - EXPECT_TRUE(HasSpan(file_)); - EXPECT_TRUE(HasSpan(file_.message_type(0))); - EXPECT_TRUE(HasSpan(file_.message_type(0), "name")); -} - -TEST_F(SourceInfoTest, Groups) { - EXPECT_TRUE(Parse( - "message Foo {\n" - " message Bar {}\n" - " $a$optional$b$ $c$group$d$ $e$Baz$f$ = $g$1$h$ {\n" - " $i$message Qux {}$j$\n" - " }$k$\n" - "}\n")); - - const DescriptorProto& bar = file_.message_type(0).nested_type(0); - const DescriptorProto& baz = file_.message_type(0).nested_type(1); - const DescriptorProto& qux = baz.nested_type(0); - const FieldDescriptorProto& field = file_.message_type(0).field(0); - - EXPECT_TRUE(HasSpan('a', 'k', field)); - EXPECT_TRUE(HasSpan('a', 'b', field, "label")); - EXPECT_TRUE(HasSpan('c', 'd', field, "type")); - EXPECT_TRUE(HasSpan('e', 'f', field, "name")); - EXPECT_TRUE(HasSpan('e', 'f', field, "type_name")); - EXPECT_TRUE(HasSpan('g', 'h', field, "number")); - - EXPECT_TRUE(HasSpan('a', 'k', baz)); - EXPECT_TRUE(HasSpan('e', 'f', baz, "name")); - EXPECT_TRUE(HasSpan('i', 'j', qux)); - - // Ignore these. - EXPECT_TRUE(HasSpan(file_)); - EXPECT_TRUE(HasSpan(file_.message_type(0))); - EXPECT_TRUE(HasSpan(file_.message_type(0), "name")); - EXPECT_TRUE(HasSpan(bar)); - EXPECT_TRUE(HasSpan(bar, "name")); - EXPECT_TRUE(HasSpan(qux, "name")); -} - -TEST_F(SourceInfoTest, Enums) { - EXPECT_TRUE(Parse( - "$a$enum $b$Foo$c$ {}$d$\n" - "$e$enum $f$Bar$g$ {}$h$\n")); - - EXPECT_TRUE(HasSpan('a', 'd', file_.enum_type(0))); - EXPECT_TRUE(HasSpan('b', 'c', file_.enum_type(0), "name")); - EXPECT_TRUE(HasSpan('e', 'h', file_.enum_type(1))); - EXPECT_TRUE(HasSpan('f', 'g', file_.enum_type(1), "name")); - - // Ignore these. - EXPECT_TRUE(HasSpan(file_)); -} - -TEST_F(SourceInfoTest, EnumValues) { - EXPECT_TRUE(Parse( - "enum Foo {\n" - " $a$BAR$b$ = $c$1$d$;$e$\n" - " $f$BAZ$g$ = $h$2$i$;$j$\n" - "}")); - - const EnumValueDescriptorProto& bar = file_.enum_type(0).value(0); - const EnumValueDescriptorProto& baz = file_.enum_type(0).value(1); - - EXPECT_TRUE(HasSpan('a', 'e', bar)); - EXPECT_TRUE(HasSpan('a', 'b', bar, "name")); - EXPECT_TRUE(HasSpan('c', 'd', bar, "number")); - EXPECT_TRUE(HasSpan('f', 'j', baz)); - EXPECT_TRUE(HasSpan('f', 'g', baz, "name")); - EXPECT_TRUE(HasSpan('h', 'i', baz, "number")); - - // Ignore these. - EXPECT_TRUE(HasSpan(file_)); - EXPECT_TRUE(HasSpan(file_.enum_type(0))); - EXPECT_TRUE(HasSpan(file_.enum_type(0), "name")); -} - -TEST_F(SourceInfoTest, NestedEnums) { - EXPECT_TRUE(Parse( - "message Foo {\n" - " $a$enum $b$Bar$c$ {}$d$\n" - " $e$enum $f$Baz$g$ {}$h$\n" - "}\n")); - - const EnumDescriptorProto& bar = file_.message_type(0).enum_type(0); - const EnumDescriptorProto& baz = file_.message_type(0).enum_type(1); - - EXPECT_TRUE(HasSpan('a', 'd', bar)); - EXPECT_TRUE(HasSpan('b', 'c', bar, "name")); - EXPECT_TRUE(HasSpan('e', 'h', baz)); - EXPECT_TRUE(HasSpan('f', 'g', baz, "name")); - - // Ignore these. - EXPECT_TRUE(HasSpan(file_)); - EXPECT_TRUE(HasSpan(file_.message_type(0))); - EXPECT_TRUE(HasSpan(file_.message_type(0), "name")); -} - -TEST_F(SourceInfoTest, Services) { - EXPECT_TRUE(Parse( - "$a$service $b$Foo$c$ {}$d$\n" - "$e$service $f$Bar$g$ {}$h$\n")); - - EXPECT_TRUE(HasSpan('a', 'd', file_.service(0))); - EXPECT_TRUE(HasSpan('b', 'c', file_.service(0), "name")); - EXPECT_TRUE(HasSpan('e', 'h', file_.service(1))); - EXPECT_TRUE(HasSpan('f', 'g', file_.service(1), "name")); - - // Ignore these. - EXPECT_TRUE(HasSpan(file_)); -} - -TEST_F(SourceInfoTest, MethodsAndStreams) { - EXPECT_TRUE(Parse( - "service Foo {\n" - " $a$rpc $b$Bar$c$($d$X$e$) returns($f$Y$g$);$h$" - " $i$rpc $j$Baz$k$($l$Z$m$) returns($n$W$o$);$p$" - "}")); - - const MethodDescriptorProto& bar = file_.service(0).method(0); - const MethodDescriptorProto& baz = file_.service(0).method(1); - - EXPECT_TRUE(HasSpan('a', 'h', bar)); - EXPECT_TRUE(HasSpan('b', 'c', bar, "name")); - EXPECT_TRUE(HasSpan('d', 'e', bar, "input_type")); - EXPECT_TRUE(HasSpan('f', 'g', bar, "output_type")); - - EXPECT_TRUE(HasSpan('i', 'p', baz)); - EXPECT_TRUE(HasSpan('j', 'k', baz, "name")); - EXPECT_TRUE(HasSpan('l', 'm', baz, "input_type")); - EXPECT_TRUE(HasSpan('n', 'o', baz, "output_type")); - - // Ignore these. - EXPECT_TRUE(HasSpan(file_)); - EXPECT_TRUE(HasSpan(file_.service(0))); - EXPECT_TRUE(HasSpan(file_.service(0), "name")); -} - -TEST_F(SourceInfoTest, Options) { - EXPECT_TRUE(Parse( - "$a$option $b$foo$c$.$d$($e$bar.baz$f$)$g$ = " - "$h$123$i$;$j$\n" - "$k$option qux = $l$-123$m$;$n$\n" - "$o$option corge = $p$abc$q$;$r$\n" - "$s$option grault = $t$'blah'$u$;$v$\n" - "$w$option garply = $x${ yadda yadda }$y$;$z$\n" - "$0$option waldo = $1$123.0$2$;$3$\n" - )); - - const UninterpretedOption& option1 = file_.options().uninterpreted_option(0); - const UninterpretedOption& option2 = file_.options().uninterpreted_option(1); - const UninterpretedOption& option3 = file_.options().uninterpreted_option(2); - const UninterpretedOption& option4 = file_.options().uninterpreted_option(3); - const UninterpretedOption& option5 = file_.options().uninterpreted_option(4); - const UninterpretedOption& option6 = file_.options().uninterpreted_option(5); - - EXPECT_TRUE(HasSpan('a', 'j', file_.options())); - EXPECT_TRUE(HasSpan('a', 'j', option1)); - EXPECT_TRUE(HasSpan('b', 'g', option1, "name")); - EXPECT_TRUE(HasSpan('b', 'c', option1.name(0))); - EXPECT_TRUE(HasSpan('b', 'c', option1.name(0), "name_part")); - EXPECT_TRUE(HasSpan('d', 'g', option1.name(1))); - EXPECT_TRUE(HasSpan('e', 'f', option1.name(1), "name_part")); - EXPECT_TRUE(HasSpan('h', 'i', option1, "positive_int_value")); - - EXPECT_TRUE(HasSpan('k', 'n', file_.options())); - EXPECT_TRUE(HasSpan('l', 'm', option2, "negative_int_value")); - - EXPECT_TRUE(HasSpan('o', 'r', file_.options())); - EXPECT_TRUE(HasSpan('p', 'q', option3, "identifier_value")); - - EXPECT_TRUE(HasSpan('s', 'v', file_.options())); - EXPECT_TRUE(HasSpan('t', 'u', option4, "string_value")); - - EXPECT_TRUE(HasSpan('w', 'z', file_.options())); - EXPECT_TRUE(HasSpan('x', 'y', option5, "aggregate_value")); - - EXPECT_TRUE(HasSpan('0', '3', file_.options())); - EXPECT_TRUE(HasSpan('1', '2', option6, "double_value")); - - // Ignore these. - EXPECT_TRUE(HasSpan(file_)); - EXPECT_TRUE(HasSpan(option2)); - EXPECT_TRUE(HasSpan(option3)); - EXPECT_TRUE(HasSpan(option4)); - EXPECT_TRUE(HasSpan(option5)); - EXPECT_TRUE(HasSpan(option6)); - EXPECT_TRUE(HasSpan(option2, "name")); - EXPECT_TRUE(HasSpan(option3, "name")); - EXPECT_TRUE(HasSpan(option4, "name")); - EXPECT_TRUE(HasSpan(option5, "name")); - EXPECT_TRUE(HasSpan(option6, "name")); - EXPECT_TRUE(HasSpan(option2.name(0))); - EXPECT_TRUE(HasSpan(option3.name(0))); - EXPECT_TRUE(HasSpan(option4.name(0))); - EXPECT_TRUE(HasSpan(option5.name(0))); - EXPECT_TRUE(HasSpan(option6.name(0))); - EXPECT_TRUE(HasSpan(option2.name(0), "name_part")); - EXPECT_TRUE(HasSpan(option3.name(0), "name_part")); - EXPECT_TRUE(HasSpan(option4.name(0), "name_part")); - EXPECT_TRUE(HasSpan(option5.name(0), "name_part")); - EXPECT_TRUE(HasSpan(option6.name(0), "name_part")); -} - -TEST_F(SourceInfoTest, ScopedOptions) { - EXPECT_TRUE(Parse( - "message Foo {\n" - " $a$option mopt = 1;$b$\n" - "}\n" - "enum Bar {\n" - " $c$option eopt = 1;$d$\n" - "}\n" - "service Baz {\n" - " $e$option sopt = 1;$f$\n" - " rpc M(X) returns(Y) {\n" - " $g$option mopt = 1;$h$\n" - " }\n" - "}\n")); - - EXPECT_TRUE(HasSpan('a', 'b', file_.message_type(0).options())); - EXPECT_TRUE(HasSpan('c', 'd', file_.enum_type(0).options())); - EXPECT_TRUE(HasSpan('e', 'f', file_.service(0).options())); - EXPECT_TRUE(HasSpan('g', 'h', file_.service(0).method(0).options())); - - // Ignore these. - EXPECT_TRUE(HasSpan(file_)); - EXPECT_TRUE(HasSpan(file_.message_type(0))); - EXPECT_TRUE(HasSpan(file_.message_type(0), "name")); - EXPECT_TRUE(HasSpan(file_.message_type(0).options() - .uninterpreted_option(0))); - EXPECT_TRUE(HasSpan(file_.message_type(0).options() - .uninterpreted_option(0), "name")); - EXPECT_TRUE(HasSpan(file_.message_type(0).options() - .uninterpreted_option(0).name(0))); - EXPECT_TRUE(HasSpan(file_.message_type(0).options() - .uninterpreted_option(0).name(0), "name_part")); - EXPECT_TRUE(HasSpan(file_.message_type(0).options() - .uninterpreted_option(0), "positive_int_value")); - EXPECT_TRUE(HasSpan(file_.enum_type(0))); - EXPECT_TRUE(HasSpan(file_.enum_type(0), "name")); - EXPECT_TRUE(HasSpan(file_.enum_type(0).options() - .uninterpreted_option(0))); - EXPECT_TRUE(HasSpan(file_.enum_type(0).options() - .uninterpreted_option(0), "name")); - EXPECT_TRUE(HasSpan(file_.enum_type(0).options() - .uninterpreted_option(0).name(0))); - EXPECT_TRUE(HasSpan(file_.enum_type(0).options() - .uninterpreted_option(0).name(0), "name_part")); - EXPECT_TRUE(HasSpan(file_.enum_type(0).options() - .uninterpreted_option(0), "positive_int_value")); - EXPECT_TRUE(HasSpan(file_.service(0))); - EXPECT_TRUE(HasSpan(file_.service(0), "name")); - EXPECT_TRUE(HasSpan(file_.service(0).method(0))); - EXPECT_TRUE(HasSpan(file_.service(0).options() - .uninterpreted_option(0))); - EXPECT_TRUE(HasSpan(file_.service(0).options() - .uninterpreted_option(0), "name")); - EXPECT_TRUE(HasSpan(file_.service(0).options() - .uninterpreted_option(0).name(0))); - EXPECT_TRUE(HasSpan(file_.service(0).options() - .uninterpreted_option(0).name(0), "name_part")); - EXPECT_TRUE(HasSpan(file_.service(0).options() - .uninterpreted_option(0), "positive_int_value")); - EXPECT_TRUE(HasSpan(file_.service(0).method(0), "name")); - EXPECT_TRUE(HasSpan(file_.service(0).method(0), "input_type")); - EXPECT_TRUE(HasSpan(file_.service(0).method(0), "output_type")); - EXPECT_TRUE(HasSpan(file_.service(0).method(0).options() - .uninterpreted_option(0))); - EXPECT_TRUE(HasSpan(file_.service(0).method(0).options() - .uninterpreted_option(0), "name")); - EXPECT_TRUE(HasSpan(file_.service(0).method(0).options() - .uninterpreted_option(0).name(0))); - EXPECT_TRUE(HasSpan(file_.service(0).method(0).options() - .uninterpreted_option(0).name(0), "name_part")); - EXPECT_TRUE(HasSpan(file_.service(0).method(0).options() - .uninterpreted_option(0), "positive_int_value")); -} - -TEST_F(SourceInfoTest, FieldOptions) { - // The actual "name = value" pairs are parsed by the same code as for - // top-level options so we won't re-test that -- just make sure that the - // syntax used for field options is understood. - EXPECT_TRUE(Parse( - "message Foo {" - " optional int32 bar = 1 " - "$a$[default=$b$123$c$,$d$opt1=123$e$," - "$f$opt2='hi'$g$]$h$;" - "}\n" - )); - - const FieldDescriptorProto& field = file_.message_type(0).field(0); - const UninterpretedOption& option1 = field.options().uninterpreted_option(0); - const UninterpretedOption& option2 = field.options().uninterpreted_option(1); - - EXPECT_TRUE(HasSpan('a', 'h', field.options())); - EXPECT_TRUE(HasSpan('b', 'c', field, "default_value")); - EXPECT_TRUE(HasSpan('d', 'e', option1)); - EXPECT_TRUE(HasSpan('f', 'g', option2)); - - // Ignore these. - EXPECT_TRUE(HasSpan(file_)); - EXPECT_TRUE(HasSpan(file_.message_type(0))); - EXPECT_TRUE(HasSpan(file_.message_type(0), "name")); - EXPECT_TRUE(HasSpan(field)); - EXPECT_TRUE(HasSpan(field, "label")); - EXPECT_TRUE(HasSpan(field, "type")); - EXPECT_TRUE(HasSpan(field, "name")); - EXPECT_TRUE(HasSpan(field, "number")); - EXPECT_TRUE(HasSpan(option1, "name")); - EXPECT_TRUE(HasSpan(option2, "name")); - EXPECT_TRUE(HasSpan(option1.name(0))); - EXPECT_TRUE(HasSpan(option2.name(0))); - EXPECT_TRUE(HasSpan(option1.name(0), "name_part")); - EXPECT_TRUE(HasSpan(option2.name(0), "name_part")); - EXPECT_TRUE(HasSpan(option1, "positive_int_value")); - EXPECT_TRUE(HasSpan(option2, "string_value")); -} - -TEST_F(SourceInfoTest, EnumValueOptions) { - // The actual "name = value" pairs are parsed by the same code as for - // top-level options so we won't re-test that -- just make sure that the - // syntax used for enum options is understood. - EXPECT_TRUE(Parse( - "enum Foo {" - " BAR = 1 $a$[$b$opt1=123$c$,$d$opt2='hi'$e$]$f$;" - "}\n" - )); - - const EnumValueDescriptorProto& value = file_.enum_type(0).value(0); - const UninterpretedOption& option1 = value.options().uninterpreted_option(0); - const UninterpretedOption& option2 = value.options().uninterpreted_option(1); - - EXPECT_TRUE(HasSpan('a', 'f', value.options())); - EXPECT_TRUE(HasSpan('b', 'c', option1)); - EXPECT_TRUE(HasSpan('d', 'e', option2)); - - // Ignore these. - EXPECT_TRUE(HasSpan(file_)); - EXPECT_TRUE(HasSpan(file_.enum_type(0))); - EXPECT_TRUE(HasSpan(file_.enum_type(0), "name")); - EXPECT_TRUE(HasSpan(value)); - EXPECT_TRUE(HasSpan(value, "name")); - EXPECT_TRUE(HasSpan(value, "number")); - EXPECT_TRUE(HasSpan(option1, "name")); - EXPECT_TRUE(HasSpan(option2, "name")); - EXPECT_TRUE(HasSpan(option1.name(0))); - EXPECT_TRUE(HasSpan(option2.name(0))); - EXPECT_TRUE(HasSpan(option1.name(0), "name_part")); - EXPECT_TRUE(HasSpan(option2.name(0), "name_part")); - EXPECT_TRUE(HasSpan(option1, "positive_int_value")); - EXPECT_TRUE(HasSpan(option2, "string_value")); -} - -TEST_F(SourceInfoTest, DocComments) { - EXPECT_TRUE(Parse( - "// Foo leading\n" - "// line 2\n" - "$a$message Foo {\n" - " // Foo trailing\n" - " // line 2\n" - "\n" - " // ignored\n" - "\n" - " // bar leading\n" - " $b$optional int32 bar = 1;$c$\n" - " // bar trailing\n" - "}$d$\n" - "// ignored\n" - )); - - const DescriptorProto& foo = file_.message_type(0); - const FieldDescriptorProto& bar = foo.field(0); - - EXPECT_TRUE(HasSpanWithComment('a', 'd', foo, - " Foo leading\n line 2\n", - " Foo trailing\n line 2\n")); - EXPECT_TRUE(HasSpanWithComment('b', 'c', bar, - " bar leading\n", - " bar trailing\n")); - - // Ignore these. - EXPECT_TRUE(HasSpan(file_)); - EXPECT_TRUE(HasSpan(foo, "name")); - EXPECT_TRUE(HasSpan(bar, "label")); - EXPECT_TRUE(HasSpan(bar, "type")); - EXPECT_TRUE(HasSpan(bar, "name")); - EXPECT_TRUE(HasSpan(bar, "number")); -} - -TEST_F(SourceInfoTest, DocComments2) { - EXPECT_TRUE(Parse( - "// ignored\n" - "syntax = \"proto2\";\n" - "// Foo leading\n" - "// line 2\n" - "$a$message Foo {\n" - " /* Foo trailing\n" - " * line 2 */\n" - " // ignored\n" - " /* bar leading\n" - " */" - " $b$optional int32 bar = 1;$c$ // bar trailing\n" - " // ignored\n" - "}$d$\n" - "// ignored\n" - "\n" - "// option leading\n" - "$e$option baz = 123;$f$\n" - "// option trailing\n" - )); - - const DescriptorProto& foo = file_.message_type(0); - const FieldDescriptorProto& bar = foo.field(0); - const UninterpretedOption& baz = file_.options().uninterpreted_option(0); - - EXPECT_TRUE(HasSpanWithComment('a', 'd', foo, - " Foo leading\n line 2\n", - " Foo trailing\n line 2 ")); - EXPECT_TRUE(HasSpanWithComment('b', 'c', bar, - " bar leading\n", - " bar trailing\n")); - EXPECT_TRUE(HasSpanWithComment('e', 'f', baz, - " option leading\n", - " option trailing\n")); - - // Ignore these. - EXPECT_TRUE(HasSpan(file_)); - EXPECT_TRUE(HasSpan(foo, "name")); - EXPECT_TRUE(HasSpan(bar, "label")); - EXPECT_TRUE(HasSpan(bar, "type")); - EXPECT_TRUE(HasSpan(bar, "name")); - EXPECT_TRUE(HasSpan(bar, "number")); - EXPECT_TRUE(HasSpan(file_.options())); - EXPECT_TRUE(HasSpan(baz, "name")); - EXPECT_TRUE(HasSpan(baz.name(0))); - EXPECT_TRUE(HasSpan(baz.name(0), "name_part")); - EXPECT_TRUE(HasSpan(baz, "positive_int_value")); -} - -TEST_F(SourceInfoTest, DocComments3) { - EXPECT_TRUE(Parse( - "$a$message Foo {\n" - " // bar leading\n" - " $b$optional int32 bar = 1 [(baz.qux) = {}];$c$\n" - " // bar trailing\n" - "}$d$\n" - "// ignored\n" - )); - - const DescriptorProto& foo = file_.message_type(0); - const FieldDescriptorProto& bar = foo.field(0); - - EXPECT_TRUE(HasSpanWithComment('b', 'c', bar, - " bar leading\n", - " bar trailing\n")); - - // Ignore these. - EXPECT_TRUE(HasSpan(file_)); - EXPECT_TRUE(HasSpan(foo)); - EXPECT_TRUE(HasSpan(foo, "name")); - EXPECT_TRUE(HasSpan(bar, "label")); - EXPECT_TRUE(HasSpan(bar, "type")); - EXPECT_TRUE(HasSpan(bar, "name")); - EXPECT_TRUE(HasSpan(bar, "number")); - EXPECT_TRUE(HasSpan(bar.options())); - EXPECT_TRUE(HasSpan(bar.options().uninterpreted_option(0))); - EXPECT_TRUE(HasSpan(bar.options().uninterpreted_option(0), "name")); - EXPECT_TRUE(HasSpan(bar.options().uninterpreted_option(0).name(0))); - EXPECT_TRUE(HasSpan( - bar.options().uninterpreted_option(0).name(0), "name_part")); - EXPECT_TRUE(HasSpan( - bar.options().uninterpreted_option(0), "aggregate_value")); -} - -// =================================================================== - -} // anonymous namespace - -} // namespace compiler -} // namespace protobuf -} // namespace google diff --git a/modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/plugin.cc b/modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/plugin.cc deleted file mode 100644 index 727f94216..000000000 --- a/modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/plugin.cc +++ /dev/null @@ -1,163 +0,0 @@ -// Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// http://code.google.com/p/protobuf/ -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -// Author: kenton@google.com (Kenton Varda) - -#include - -#include -#include - -#ifdef _WIN32 -#include -#include -#ifndef STDIN_FILENO -#define STDIN_FILENO 0 -#endif -#ifndef STDOUT_FILENO -#define STDOUT_FILENO 1 -#endif -#else -#include -#endif - -#include -#include -#include -#include -#include - - -namespace google { -namespace protobuf { -namespace compiler { - -class GeneratorResponseContext : public GeneratorContext { - public: - GeneratorResponseContext(CodeGeneratorResponse* response, - const vector& parsed_files) - : response_(response), - parsed_files_(parsed_files) {} - virtual ~GeneratorResponseContext() {} - - // implements GeneratorContext -------------------------------------- - - virtual io::ZeroCopyOutputStream* Open(const string& filename) { - CodeGeneratorResponse::File* file = response_->add_file(); - file->set_name(filename); - return new io::StringOutputStream(file->mutable_content()); - } - - virtual io::ZeroCopyOutputStream* OpenForInsert( - const string& filename, const string& insertion_point) { - CodeGeneratorResponse::File* file = response_->add_file(); - file->set_name(filename); - file->set_insertion_point(insertion_point); - return new io::StringOutputStream(file->mutable_content()); - } - - void ListParsedFiles(vector* output) { - *output = parsed_files_; - } - - private: - CodeGeneratorResponse* response_; - const vector& parsed_files_; -}; - -int PluginMain(int argc, char* argv[], const CodeGenerator* generator) { - - if (argc > 1) { - cerr << argv[0] << ": Unknown option: " << argv[1] << endl; - return 1; - } - -#ifdef _WIN32 - _setmode(STDIN_FILENO, _O_BINARY); - _setmode(STDOUT_FILENO, _O_BINARY); -#endif - - CodeGeneratorRequest request; - if (!request.ParseFromFileDescriptor(STDIN_FILENO)) { - cerr << argv[0] << ": protoc sent unparseable request to plugin." << endl; - return 1; - } - - DescriptorPool pool; - for (int i = 0; i < request.proto_file_size(); i++) { - const FileDescriptor* file = pool.BuildFile(request.proto_file(i)); - if (file == NULL) { - // BuildFile() already wrote an error message. - return 1; - } - } - - vector parsed_files; - for (int i = 0; i < request.file_to_generate_size(); i++) { - parsed_files.push_back(pool.FindFileByName(request.file_to_generate(i))); - if (parsed_files.back() == NULL) { - cerr << argv[0] << ": protoc asked plugin to generate a file but " - "did not provide a descriptor for the file: " - << request.file_to_generate(i) << endl; - return 1; - } - } - - CodeGeneratorResponse response; - GeneratorResponseContext context(&response, parsed_files); - - for (int i = 0; i < parsed_files.size(); i++) { - const FileDescriptor* file = parsed_files[i]; - - string error; - bool succeeded = generator->Generate( - file, request.parameter(), &context, &error); - - if (!succeeded && error.empty()) { - error = "Code generator returned false but provided no error " - "description."; - } - if (!error.empty()) { - response.set_error(file->name() + ": " + error); - break; - } - } - - if (!response.SerializeToFileDescriptor(STDOUT_FILENO)) { - cerr << argv[0] << ": Error writing to stdout." << endl; - return 1; - } - - return 0; -} - -} // namespace compiler -} // namespace protobuf -} // namespace google diff --git a/modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/plugin.h b/modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/plugin.h deleted file mode 100644 index 6fa2de127..000000000 --- a/modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/plugin.h +++ /dev/null @@ -1,72 +0,0 @@ -// Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// http://code.google.com/p/protobuf/ -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -// Author: kenton@google.com (Kenton Varda) -// -// Front-end for protoc code generator plugins written in C++. -// -// To implement a protoc plugin in C++, simply write an implementation of -// CodeGenerator, then create a main() function like: -// int main(int argc, char* argv[]) { -// MyCodeGenerator generator; -// return google::protobuf::compiler::PluginMain(argc, argv, &generator); -// } -// You must link your plugin against libprotobuf and libprotoc. -// -// To get protoc to use the plugin, do one of the following: -// * Place the plugin binary somewhere in the PATH and give it the name -// "protoc-gen-NAME" (replacing "NAME" with the name of your plugin). If you -// then invoke protoc with the parameter --NAME_out=OUT_DIR (again, replace -// "NAME" with your plugin's name), protoc will invoke your plugin to generate -// the output, which will be placed in OUT_DIR. -// * Place the plugin binary anywhere, with any name, and pass the --plugin -// parameter to protoc to direct it to your plugin like so: -// protoc --plugin=protoc-gen-NAME=path/to/mybinary --NAME_out=OUT_DIR -// On Windows, make sure to include the .exe suffix: -// protoc --plugin=protoc-gen-NAME=path/to/mybinary.exe --NAME_out=OUT_DIR - -#ifndef GOOGLE_PROTOBUF_COMPILER_PLUGIN_H__ -#define GOOGLE_PROTOBUF_COMPILER_PLUGIN_H__ - -#include -namespace google { -namespace protobuf { -namespace compiler { - -class CodeGenerator; // code_generator.h - -// Implements main() for a protoc plugin exposing the given code generator. -LIBPROTOC_EXPORT int PluginMain(int argc, char* argv[], const CodeGenerator* generator); - -} // namespace compiler -} // namespace protobuf - -} // namespace google -#endif // GOOGLE_PROTOBUF_COMPILER_PLUGIN_H__ diff --git a/modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/plugin.pb.cc b/modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/plugin.pb.cc deleted file mode 100644 index ee14dcf72..000000000 --- a/modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/plugin.pb.cc +++ /dev/null @@ -1,1090 +0,0 @@ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: google/protobuf/compiler/plugin.proto - -#define INTERNAL_SUPPRESS_PROTOBUF_FIELD_DEPRECATION -#include "google/protobuf/compiler/plugin.pb.h" - -#include - -#include -#include -#include -#include -#include -#include -#include -#include -// @@protoc_insertion_point(includes) - -namespace google { -namespace protobuf { -namespace compiler { - -namespace { - -const ::google::protobuf::Descriptor* CodeGeneratorRequest_descriptor_ = NULL; -const ::google::protobuf::internal::GeneratedMessageReflection* - CodeGeneratorRequest_reflection_ = NULL; -const ::google::protobuf::Descriptor* CodeGeneratorResponse_descriptor_ = NULL; -const ::google::protobuf::internal::GeneratedMessageReflection* - CodeGeneratorResponse_reflection_ = NULL; -const ::google::protobuf::Descriptor* CodeGeneratorResponse_File_descriptor_ = NULL; -const ::google::protobuf::internal::GeneratedMessageReflection* - CodeGeneratorResponse_File_reflection_ = NULL; - -} // namespace - - -void protobuf_AssignDesc_google_2fprotobuf_2fcompiler_2fplugin_2eproto() { - protobuf_AddDesc_google_2fprotobuf_2fcompiler_2fplugin_2eproto(); - const ::google::protobuf::FileDescriptor* file = - ::google::protobuf::DescriptorPool::generated_pool()->FindFileByName( - "google/protobuf/compiler/plugin.proto"); - GOOGLE_CHECK(file != NULL); - CodeGeneratorRequest_descriptor_ = file->message_type(0); - static const int CodeGeneratorRequest_offsets_[3] = { - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(CodeGeneratorRequest, file_to_generate_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(CodeGeneratorRequest, parameter_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(CodeGeneratorRequest, proto_file_), - }; - CodeGeneratorRequest_reflection_ = - new ::google::protobuf::internal::GeneratedMessageReflection( - CodeGeneratorRequest_descriptor_, - CodeGeneratorRequest::default_instance_, - CodeGeneratorRequest_offsets_, - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(CodeGeneratorRequest, _has_bits_[0]), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(CodeGeneratorRequest, _unknown_fields_), - -1, - ::google::protobuf::DescriptorPool::generated_pool(), - ::google::protobuf::MessageFactory::generated_factory(), - sizeof(CodeGeneratorRequest)); - CodeGeneratorResponse_descriptor_ = file->message_type(1); - static const int CodeGeneratorResponse_offsets_[2] = { - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(CodeGeneratorResponse, error_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(CodeGeneratorResponse, file_), - }; - CodeGeneratorResponse_reflection_ = - new ::google::protobuf::internal::GeneratedMessageReflection( - CodeGeneratorResponse_descriptor_, - CodeGeneratorResponse::default_instance_, - CodeGeneratorResponse_offsets_, - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(CodeGeneratorResponse, _has_bits_[0]), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(CodeGeneratorResponse, _unknown_fields_), - -1, - ::google::protobuf::DescriptorPool::generated_pool(), - ::google::protobuf::MessageFactory::generated_factory(), - sizeof(CodeGeneratorResponse)); - CodeGeneratorResponse_File_descriptor_ = CodeGeneratorResponse_descriptor_->nested_type(0); - static const int CodeGeneratorResponse_File_offsets_[3] = { - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(CodeGeneratorResponse_File, name_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(CodeGeneratorResponse_File, insertion_point_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(CodeGeneratorResponse_File, content_), - }; - CodeGeneratorResponse_File_reflection_ = - new ::google::protobuf::internal::GeneratedMessageReflection( - CodeGeneratorResponse_File_descriptor_, - CodeGeneratorResponse_File::default_instance_, - CodeGeneratorResponse_File_offsets_, - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(CodeGeneratorResponse_File, _has_bits_[0]), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(CodeGeneratorResponse_File, _unknown_fields_), - -1, - ::google::protobuf::DescriptorPool::generated_pool(), - ::google::protobuf::MessageFactory::generated_factory(), - sizeof(CodeGeneratorResponse_File)); -} - -namespace { - -GOOGLE_PROTOBUF_DECLARE_ONCE(protobuf_AssignDescriptors_once_); -inline void protobuf_AssignDescriptorsOnce() { - ::google::protobuf::GoogleOnceInit(&protobuf_AssignDescriptors_once_, - &protobuf_AssignDesc_google_2fprotobuf_2fcompiler_2fplugin_2eproto); -} - -void protobuf_RegisterTypes(const ::std::string&) { - protobuf_AssignDescriptorsOnce(); - ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - CodeGeneratorRequest_descriptor_, &CodeGeneratorRequest::default_instance()); - ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - CodeGeneratorResponse_descriptor_, &CodeGeneratorResponse::default_instance()); - ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - CodeGeneratorResponse_File_descriptor_, &CodeGeneratorResponse_File::default_instance()); -} - -} // namespace - -void protobuf_ShutdownFile_google_2fprotobuf_2fcompiler_2fplugin_2eproto() { - delete CodeGeneratorRequest::default_instance_; - delete CodeGeneratorRequest_reflection_; - delete CodeGeneratorResponse::default_instance_; - delete CodeGeneratorResponse_reflection_; - delete CodeGeneratorResponse_File::default_instance_; - delete CodeGeneratorResponse_File_reflection_; -} - -void protobuf_AddDesc_google_2fprotobuf_2fcompiler_2fplugin_2eproto() { - static bool already_here = false; - if (already_here) return; - already_here = true; - GOOGLE_PROTOBUF_VERIFY_VERSION; - - ::google::protobuf::protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto(); - ::google::protobuf::DescriptorPool::InternalAddGeneratedFile( - "\n%google/protobuf/compiler/plugin.proto\022" - "\030google.protobuf.compiler\032 google/protob" - "uf/descriptor.proto\"}\n\024CodeGeneratorRequ" - "est\022\030\n\020file_to_generate\030\001 \003(\t\022\021\n\tparamet" - "er\030\002 \001(\t\0228\n\nproto_file\030\017 \003(\0132$.google.pr" - "otobuf.FileDescriptorProto\"\252\001\n\025CodeGener" - "atorResponse\022\r\n\005error\030\001 \001(\t\022B\n\004file\030\017 \003(" - "\01324.google.protobuf.compiler.CodeGenerat" - "orResponse.File\032>\n\004File\022\014\n\004name\030\001 \001(\t\022\027\n" - "\017insertion_point\030\002 \001(\t\022\017\n\007content\030\017 \001(\tB" - ",\n\034com.google.protobuf.compilerB\014PluginP" - "rotos", 445); - ::google::protobuf::MessageFactory::InternalRegisterGeneratedFile( - "google/protobuf/compiler/plugin.proto", &protobuf_RegisterTypes); - CodeGeneratorRequest::default_instance_ = new CodeGeneratorRequest(); - CodeGeneratorResponse::default_instance_ = new CodeGeneratorResponse(); - CodeGeneratorResponse_File::default_instance_ = new CodeGeneratorResponse_File(); - CodeGeneratorRequest::default_instance_->InitAsDefaultInstance(); - CodeGeneratorResponse::default_instance_->InitAsDefaultInstance(); - CodeGeneratorResponse_File::default_instance_->InitAsDefaultInstance(); - ::google::protobuf::internal::OnShutdown(&protobuf_ShutdownFile_google_2fprotobuf_2fcompiler_2fplugin_2eproto); -} - -// Force AddDescriptors() to be called at static initialization time. -struct StaticDescriptorInitializer_google_2fprotobuf_2fcompiler_2fplugin_2eproto { - StaticDescriptorInitializer_google_2fprotobuf_2fcompiler_2fplugin_2eproto() { - protobuf_AddDesc_google_2fprotobuf_2fcompiler_2fplugin_2eproto(); - } -} static_descriptor_initializer_google_2fprotobuf_2fcompiler_2fplugin_2eproto_; - -// =================================================================== - -#ifndef _MSC_VER -const int CodeGeneratorRequest::kFileToGenerateFieldNumber; -const int CodeGeneratorRequest::kParameterFieldNumber; -const int CodeGeneratorRequest::kProtoFileFieldNumber; -#endif // !_MSC_VER - -CodeGeneratorRequest::CodeGeneratorRequest() - : ::google::protobuf::Message() { - SharedCtor(); -} - -void CodeGeneratorRequest::InitAsDefaultInstance() { -} - -CodeGeneratorRequest::CodeGeneratorRequest(const CodeGeneratorRequest& from) - : ::google::protobuf::Message() { - SharedCtor(); - MergeFrom(from); -} - -void CodeGeneratorRequest::SharedCtor() { - _cached_size_ = 0; - parameter_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); - ::memset(_has_bits_, 0, sizeof(_has_bits_)); -} - -CodeGeneratorRequest::~CodeGeneratorRequest() { - SharedDtor(); -} - -void CodeGeneratorRequest::SharedDtor() { - if (parameter_ != &::google::protobuf::internal::kEmptyString) { - delete parameter_; - } - if (this != default_instance_) { - } -} - -void CodeGeneratorRequest::SetCachedSize(int size) const { - GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); - _cached_size_ = size; - GOOGLE_SAFE_CONCURRENT_WRITES_END(); -} -const ::google::protobuf::Descriptor* CodeGeneratorRequest::descriptor() { - protobuf_AssignDescriptorsOnce(); - return CodeGeneratorRequest_descriptor_; -} - -const CodeGeneratorRequest& CodeGeneratorRequest::default_instance() { - if (default_instance_ == NULL) protobuf_AddDesc_google_2fprotobuf_2fcompiler_2fplugin_2eproto(); - return *default_instance_; -} - -CodeGeneratorRequest* CodeGeneratorRequest::default_instance_ = NULL; - -CodeGeneratorRequest* CodeGeneratorRequest::New() const { - return new CodeGeneratorRequest; -} - -void CodeGeneratorRequest::Clear() { - if (_has_bits_[1 / 32] & (0xffu << (1 % 32))) { - if (has_parameter()) { - if (parameter_ != &::google::protobuf::internal::kEmptyString) { - parameter_->clear(); - } - } - } - file_to_generate_.Clear(); - proto_file_.Clear(); - ::memset(_has_bits_, 0, sizeof(_has_bits_)); - mutable_unknown_fields()->Clear(); -} - -bool CodeGeneratorRequest::MergePartialFromCodedStream( - ::google::protobuf::io::CodedInputStream* input) { -#define DO_(EXPRESSION) if (!(EXPRESSION)) return false - ::google::protobuf::uint32 tag; - while ((tag = input->ReadTag()) != 0) { - switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { - // repeated string file_to_generate = 1; - case 1: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) { - parse_file_to_generate: - DO_(::google::protobuf::internal::WireFormatLite::ReadString( - input, this->add_file_to_generate())); - ::google::protobuf::internal::WireFormat::VerifyUTF8String( - this->file_to_generate(this->file_to_generate_size() - 1).data(), - this->file_to_generate(this->file_to_generate_size() - 1).length(), - ::google::protobuf::internal::WireFormat::PARSE); - } else { - goto handle_uninterpreted; - } - if (input->ExpectTag(10)) goto parse_file_to_generate; - if (input->ExpectTag(18)) goto parse_parameter; - break; - } - - // optional string parameter = 2; - case 2: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) { - parse_parameter: - DO_(::google::protobuf::internal::WireFormatLite::ReadString( - input, this->mutable_parameter())); - ::google::protobuf::internal::WireFormat::VerifyUTF8String( - this->parameter().data(), this->parameter().length(), - ::google::protobuf::internal::WireFormat::PARSE); - } else { - goto handle_uninterpreted; - } - if (input->ExpectTag(122)) goto parse_proto_file; - break; - } - - // repeated .google.protobuf.FileDescriptorProto proto_file = 15; - case 15: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) { - parse_proto_file: - DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual( - input, add_proto_file())); - } else { - goto handle_uninterpreted; - } - if (input->ExpectTag(122)) goto parse_proto_file; - if (input->ExpectAtEnd()) return true; - break; - } - - default: { - handle_uninterpreted: - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) { - return true; - } - DO_(::google::protobuf::internal::WireFormat::SkipField( - input, tag, mutable_unknown_fields())); - break; - } - } - } - return true; -#undef DO_ -} - -void CodeGeneratorRequest::SerializeWithCachedSizes( - ::google::protobuf::io::CodedOutputStream* output) const { - // repeated string file_to_generate = 1; - for (int i = 0; i < this->file_to_generate_size(); i++) { - ::google::protobuf::internal::WireFormat::VerifyUTF8String( - this->file_to_generate(i).data(), this->file_to_generate(i).length(), - ::google::protobuf::internal::WireFormat::SERIALIZE); - ::google::protobuf::internal::WireFormatLite::WriteString( - 1, this->file_to_generate(i), output); - } - - // optional string parameter = 2; - if (has_parameter()) { - ::google::protobuf::internal::WireFormat::VerifyUTF8String( - this->parameter().data(), this->parameter().length(), - ::google::protobuf::internal::WireFormat::SERIALIZE); - ::google::protobuf::internal::WireFormatLite::WriteString( - 2, this->parameter(), output); - } - - // repeated .google.protobuf.FileDescriptorProto proto_file = 15; - for (int i = 0; i < this->proto_file_size(); i++) { - ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( - 15, this->proto_file(i), output); - } - - if (!unknown_fields().empty()) { - ::google::protobuf::internal::WireFormat::SerializeUnknownFields( - unknown_fields(), output); - } -} - -::google::protobuf::uint8* CodeGeneratorRequest::SerializeWithCachedSizesToArray( - ::google::protobuf::uint8* target) const { - // repeated string file_to_generate = 1; - for (int i = 0; i < this->file_to_generate_size(); i++) { - ::google::protobuf::internal::WireFormat::VerifyUTF8String( - this->file_to_generate(i).data(), this->file_to_generate(i).length(), - ::google::protobuf::internal::WireFormat::SERIALIZE); - target = ::google::protobuf::internal::WireFormatLite:: - WriteStringToArray(1, this->file_to_generate(i), target); - } - - // optional string parameter = 2; - if (has_parameter()) { - ::google::protobuf::internal::WireFormat::VerifyUTF8String( - this->parameter().data(), this->parameter().length(), - ::google::protobuf::internal::WireFormat::SERIALIZE); - target = - ::google::protobuf::internal::WireFormatLite::WriteStringToArray( - 2, this->parameter(), target); - } - - // repeated .google.protobuf.FileDescriptorProto proto_file = 15; - for (int i = 0; i < this->proto_file_size(); i++) { - target = ::google::protobuf::internal::WireFormatLite:: - WriteMessageNoVirtualToArray( - 15, this->proto_file(i), target); - } - - if (!unknown_fields().empty()) { - target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray( - unknown_fields(), target); - } - return target; -} - -int CodeGeneratorRequest::ByteSize() const { - int total_size = 0; - - if (_has_bits_[1 / 32] & (0xffu << (1 % 32))) { - // optional string parameter = 2; - if (has_parameter()) { - total_size += 1 + - ::google::protobuf::internal::WireFormatLite::StringSize( - this->parameter()); - } - - } - // repeated string file_to_generate = 1; - total_size += 1 * this->file_to_generate_size(); - for (int i = 0; i < this->file_to_generate_size(); i++) { - total_size += ::google::protobuf::internal::WireFormatLite::StringSize( - this->file_to_generate(i)); - } - - // repeated .google.protobuf.FileDescriptorProto proto_file = 15; - total_size += 1 * this->proto_file_size(); - for (int i = 0; i < this->proto_file_size(); i++) { - total_size += - ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( - this->proto_file(i)); - } - - if (!unknown_fields().empty()) { - total_size += - ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( - unknown_fields()); - } - GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); - _cached_size_ = total_size; - GOOGLE_SAFE_CONCURRENT_WRITES_END(); - return total_size; -} - -void CodeGeneratorRequest::MergeFrom(const ::google::protobuf::Message& from) { - GOOGLE_CHECK_NE(&from, this); - const CodeGeneratorRequest* source = - ::google::protobuf::internal::dynamic_cast_if_available( - &from); - if (source == NULL) { - ::google::protobuf::internal::ReflectionOps::Merge(from, this); - } else { - MergeFrom(*source); - } -} - -void CodeGeneratorRequest::MergeFrom(const CodeGeneratorRequest& from) { - GOOGLE_CHECK_NE(&from, this); - file_to_generate_.MergeFrom(from.file_to_generate_); - proto_file_.MergeFrom(from.proto_file_); - if (from._has_bits_[1 / 32] & (0xffu << (1 % 32))) { - if (from.has_parameter()) { - set_parameter(from.parameter()); - } - } - mutable_unknown_fields()->MergeFrom(from.unknown_fields()); -} - -void CodeGeneratorRequest::CopyFrom(const ::google::protobuf::Message& from) { - if (&from == this) return; - Clear(); - MergeFrom(from); -} - -void CodeGeneratorRequest::CopyFrom(const CodeGeneratorRequest& from) { - if (&from == this) return; - Clear(); - MergeFrom(from); -} - -bool CodeGeneratorRequest::IsInitialized() const { - - for (int i = 0; i < proto_file_size(); i++) { - if (!this->proto_file(i).IsInitialized()) return false; - } - return true; -} - -void CodeGeneratorRequest::Swap(CodeGeneratorRequest* other) { - if (other != this) { - file_to_generate_.Swap(&other->file_to_generate_); - std::swap(parameter_, other->parameter_); - proto_file_.Swap(&other->proto_file_); - std::swap(_has_bits_[0], other->_has_bits_[0]); - _unknown_fields_.Swap(&other->_unknown_fields_); - std::swap(_cached_size_, other->_cached_size_); - } -} - -::google::protobuf::Metadata CodeGeneratorRequest::GetMetadata() const { - protobuf_AssignDescriptorsOnce(); - ::google::protobuf::Metadata metadata; - metadata.descriptor = CodeGeneratorRequest_descriptor_; - metadata.reflection = CodeGeneratorRequest_reflection_; - return metadata; -} - - -// =================================================================== - -#ifndef _MSC_VER -const int CodeGeneratorResponse_File::kNameFieldNumber; -const int CodeGeneratorResponse_File::kInsertionPointFieldNumber; -const int CodeGeneratorResponse_File::kContentFieldNumber; -#endif // !_MSC_VER - -CodeGeneratorResponse_File::CodeGeneratorResponse_File() - : ::google::protobuf::Message() { - SharedCtor(); -} - -void CodeGeneratorResponse_File::InitAsDefaultInstance() { -} - -CodeGeneratorResponse_File::CodeGeneratorResponse_File(const CodeGeneratorResponse_File& from) - : ::google::protobuf::Message() { - SharedCtor(); - MergeFrom(from); -} - -void CodeGeneratorResponse_File::SharedCtor() { - _cached_size_ = 0; - name_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); - insertion_point_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); - content_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); - ::memset(_has_bits_, 0, sizeof(_has_bits_)); -} - -CodeGeneratorResponse_File::~CodeGeneratorResponse_File() { - SharedDtor(); -} - -void CodeGeneratorResponse_File::SharedDtor() { - if (name_ != &::google::protobuf::internal::kEmptyString) { - delete name_; - } - if (insertion_point_ != &::google::protobuf::internal::kEmptyString) { - delete insertion_point_; - } - if (content_ != &::google::protobuf::internal::kEmptyString) { - delete content_; - } - if (this != default_instance_) { - } -} - -void CodeGeneratorResponse_File::SetCachedSize(int size) const { - GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); - _cached_size_ = size; - GOOGLE_SAFE_CONCURRENT_WRITES_END(); -} -const ::google::protobuf::Descriptor* CodeGeneratorResponse_File::descriptor() { - protobuf_AssignDescriptorsOnce(); - return CodeGeneratorResponse_File_descriptor_; -} - -const CodeGeneratorResponse_File& CodeGeneratorResponse_File::default_instance() { - if (default_instance_ == NULL) protobuf_AddDesc_google_2fprotobuf_2fcompiler_2fplugin_2eproto(); - return *default_instance_; -} - -CodeGeneratorResponse_File* CodeGeneratorResponse_File::default_instance_ = NULL; - -CodeGeneratorResponse_File* CodeGeneratorResponse_File::New() const { - return new CodeGeneratorResponse_File; -} - -void CodeGeneratorResponse_File::Clear() { - if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) { - if (has_name()) { - if (name_ != &::google::protobuf::internal::kEmptyString) { - name_->clear(); - } - } - if (has_insertion_point()) { - if (insertion_point_ != &::google::protobuf::internal::kEmptyString) { - insertion_point_->clear(); - } - } - if (has_content()) { - if (content_ != &::google::protobuf::internal::kEmptyString) { - content_->clear(); - } - } - } - ::memset(_has_bits_, 0, sizeof(_has_bits_)); - mutable_unknown_fields()->Clear(); -} - -bool CodeGeneratorResponse_File::MergePartialFromCodedStream( - ::google::protobuf::io::CodedInputStream* input) { -#define DO_(EXPRESSION) if (!(EXPRESSION)) return false - ::google::protobuf::uint32 tag; - while ((tag = input->ReadTag()) != 0) { - switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { - // optional string name = 1; - case 1: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) { - DO_(::google::protobuf::internal::WireFormatLite::ReadString( - input, this->mutable_name())); - ::google::protobuf::internal::WireFormat::VerifyUTF8String( - this->name().data(), this->name().length(), - ::google::protobuf::internal::WireFormat::PARSE); - } else { - goto handle_uninterpreted; - } - if (input->ExpectTag(18)) goto parse_insertion_point; - break; - } - - // optional string insertion_point = 2; - case 2: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) { - parse_insertion_point: - DO_(::google::protobuf::internal::WireFormatLite::ReadString( - input, this->mutable_insertion_point())); - ::google::protobuf::internal::WireFormat::VerifyUTF8String( - this->insertion_point().data(), this->insertion_point().length(), - ::google::protobuf::internal::WireFormat::PARSE); - } else { - goto handle_uninterpreted; - } - if (input->ExpectTag(122)) goto parse_content; - break; - } - - // optional string content = 15; - case 15: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) { - parse_content: - DO_(::google::protobuf::internal::WireFormatLite::ReadString( - input, this->mutable_content())); - ::google::protobuf::internal::WireFormat::VerifyUTF8String( - this->content().data(), this->content().length(), - ::google::protobuf::internal::WireFormat::PARSE); - } else { - goto handle_uninterpreted; - } - if (input->ExpectAtEnd()) return true; - break; - } - - default: { - handle_uninterpreted: - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) { - return true; - } - DO_(::google::protobuf::internal::WireFormat::SkipField( - input, tag, mutable_unknown_fields())); - break; - } - } - } - return true; -#undef DO_ -} - -void CodeGeneratorResponse_File::SerializeWithCachedSizes( - ::google::protobuf::io::CodedOutputStream* output) const { - // optional string name = 1; - if (has_name()) { - ::google::protobuf::internal::WireFormat::VerifyUTF8String( - this->name().data(), this->name().length(), - ::google::protobuf::internal::WireFormat::SERIALIZE); - ::google::protobuf::internal::WireFormatLite::WriteString( - 1, this->name(), output); - } - - // optional string insertion_point = 2; - if (has_insertion_point()) { - ::google::protobuf::internal::WireFormat::VerifyUTF8String( - this->insertion_point().data(), this->insertion_point().length(), - ::google::protobuf::internal::WireFormat::SERIALIZE); - ::google::protobuf::internal::WireFormatLite::WriteString( - 2, this->insertion_point(), output); - } - - // optional string content = 15; - if (has_content()) { - ::google::protobuf::internal::WireFormat::VerifyUTF8String( - this->content().data(), this->content().length(), - ::google::protobuf::internal::WireFormat::SERIALIZE); - ::google::protobuf::internal::WireFormatLite::WriteString( - 15, this->content(), output); - } - - if (!unknown_fields().empty()) { - ::google::protobuf::internal::WireFormat::SerializeUnknownFields( - unknown_fields(), output); - } -} - -::google::protobuf::uint8* CodeGeneratorResponse_File::SerializeWithCachedSizesToArray( - ::google::protobuf::uint8* target) const { - // optional string name = 1; - if (has_name()) { - ::google::protobuf::internal::WireFormat::VerifyUTF8String( - this->name().data(), this->name().length(), - ::google::protobuf::internal::WireFormat::SERIALIZE); - target = - ::google::protobuf::internal::WireFormatLite::WriteStringToArray( - 1, this->name(), target); - } - - // optional string insertion_point = 2; - if (has_insertion_point()) { - ::google::protobuf::internal::WireFormat::VerifyUTF8String( - this->insertion_point().data(), this->insertion_point().length(), - ::google::protobuf::internal::WireFormat::SERIALIZE); - target = - ::google::protobuf::internal::WireFormatLite::WriteStringToArray( - 2, this->insertion_point(), target); - } - - // optional string content = 15; - if (has_content()) { - ::google::protobuf::internal::WireFormat::VerifyUTF8String( - this->content().data(), this->content().length(), - ::google::protobuf::internal::WireFormat::SERIALIZE); - target = - ::google::protobuf::internal::WireFormatLite::WriteStringToArray( - 15, this->content(), target); - } - - if (!unknown_fields().empty()) { - target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray( - unknown_fields(), target); - } - return target; -} - -int CodeGeneratorResponse_File::ByteSize() const { - int total_size = 0; - - if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) { - // optional string name = 1; - if (has_name()) { - total_size += 1 + - ::google::protobuf::internal::WireFormatLite::StringSize( - this->name()); - } - - // optional string insertion_point = 2; - if (has_insertion_point()) { - total_size += 1 + - ::google::protobuf::internal::WireFormatLite::StringSize( - this->insertion_point()); - } - - // optional string content = 15; - if (has_content()) { - total_size += 1 + - ::google::protobuf::internal::WireFormatLite::StringSize( - this->content()); - } - - } - if (!unknown_fields().empty()) { - total_size += - ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( - unknown_fields()); - } - GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); - _cached_size_ = total_size; - GOOGLE_SAFE_CONCURRENT_WRITES_END(); - return total_size; -} - -void CodeGeneratorResponse_File::MergeFrom(const ::google::protobuf::Message& from) { - GOOGLE_CHECK_NE(&from, this); - const CodeGeneratorResponse_File* source = - ::google::protobuf::internal::dynamic_cast_if_available( - &from); - if (source == NULL) { - ::google::protobuf::internal::ReflectionOps::Merge(from, this); - } else { - MergeFrom(*source); - } -} - -void CodeGeneratorResponse_File::MergeFrom(const CodeGeneratorResponse_File& from) { - GOOGLE_CHECK_NE(&from, this); - if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) { - if (from.has_name()) { - set_name(from.name()); - } - if (from.has_insertion_point()) { - set_insertion_point(from.insertion_point()); - } - if (from.has_content()) { - set_content(from.content()); - } - } - mutable_unknown_fields()->MergeFrom(from.unknown_fields()); -} - -void CodeGeneratorResponse_File::CopyFrom(const ::google::protobuf::Message& from) { - if (&from == this) return; - Clear(); - MergeFrom(from); -} - -void CodeGeneratorResponse_File::CopyFrom(const CodeGeneratorResponse_File& from) { - if (&from == this) return; - Clear(); - MergeFrom(from); -} - -bool CodeGeneratorResponse_File::IsInitialized() const { - - return true; -} - -void CodeGeneratorResponse_File::Swap(CodeGeneratorResponse_File* other) { - if (other != this) { - std::swap(name_, other->name_); - std::swap(insertion_point_, other->insertion_point_); - std::swap(content_, other->content_); - std::swap(_has_bits_[0], other->_has_bits_[0]); - _unknown_fields_.Swap(&other->_unknown_fields_); - std::swap(_cached_size_, other->_cached_size_); - } -} - -::google::protobuf::Metadata CodeGeneratorResponse_File::GetMetadata() const { - protobuf_AssignDescriptorsOnce(); - ::google::protobuf::Metadata metadata; - metadata.descriptor = CodeGeneratorResponse_File_descriptor_; - metadata.reflection = CodeGeneratorResponse_File_reflection_; - return metadata; -} - - -// ------------------------------------------------------------------- - -#ifndef _MSC_VER -const int CodeGeneratorResponse::kErrorFieldNumber; -const int CodeGeneratorResponse::kFileFieldNumber; -#endif // !_MSC_VER - -CodeGeneratorResponse::CodeGeneratorResponse() - : ::google::protobuf::Message() { - SharedCtor(); -} - -void CodeGeneratorResponse::InitAsDefaultInstance() { -} - -CodeGeneratorResponse::CodeGeneratorResponse(const CodeGeneratorResponse& from) - : ::google::protobuf::Message() { - SharedCtor(); - MergeFrom(from); -} - -void CodeGeneratorResponse::SharedCtor() { - _cached_size_ = 0; - error_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); - ::memset(_has_bits_, 0, sizeof(_has_bits_)); -} - -CodeGeneratorResponse::~CodeGeneratorResponse() { - SharedDtor(); -} - -void CodeGeneratorResponse::SharedDtor() { - if (error_ != &::google::protobuf::internal::kEmptyString) { - delete error_; - } - if (this != default_instance_) { - } -} - -void CodeGeneratorResponse::SetCachedSize(int size) const { - GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); - _cached_size_ = size; - GOOGLE_SAFE_CONCURRENT_WRITES_END(); -} -const ::google::protobuf::Descriptor* CodeGeneratorResponse::descriptor() { - protobuf_AssignDescriptorsOnce(); - return CodeGeneratorResponse_descriptor_; -} - -const CodeGeneratorResponse& CodeGeneratorResponse::default_instance() { - if (default_instance_ == NULL) protobuf_AddDesc_google_2fprotobuf_2fcompiler_2fplugin_2eproto(); - return *default_instance_; -} - -CodeGeneratorResponse* CodeGeneratorResponse::default_instance_ = NULL; - -CodeGeneratorResponse* CodeGeneratorResponse::New() const { - return new CodeGeneratorResponse; -} - -void CodeGeneratorResponse::Clear() { - if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) { - if (has_error()) { - if (error_ != &::google::protobuf::internal::kEmptyString) { - error_->clear(); - } - } - } - file_.Clear(); - ::memset(_has_bits_, 0, sizeof(_has_bits_)); - mutable_unknown_fields()->Clear(); -} - -bool CodeGeneratorResponse::MergePartialFromCodedStream( - ::google::protobuf::io::CodedInputStream* input) { -#define DO_(EXPRESSION) if (!(EXPRESSION)) return false - ::google::protobuf::uint32 tag; - while ((tag = input->ReadTag()) != 0) { - switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { - // optional string error = 1; - case 1: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) { - DO_(::google::protobuf::internal::WireFormatLite::ReadString( - input, this->mutable_error())); - ::google::protobuf::internal::WireFormat::VerifyUTF8String( - this->error().data(), this->error().length(), - ::google::protobuf::internal::WireFormat::PARSE); - } else { - goto handle_uninterpreted; - } - if (input->ExpectTag(122)) goto parse_file; - break; - } - - // repeated .google.protobuf.compiler.CodeGeneratorResponse.File file = 15; - case 15: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) { - parse_file: - DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual( - input, add_file())); - } else { - goto handle_uninterpreted; - } - if (input->ExpectTag(122)) goto parse_file; - if (input->ExpectAtEnd()) return true; - break; - } - - default: { - handle_uninterpreted: - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) { - return true; - } - DO_(::google::protobuf::internal::WireFormat::SkipField( - input, tag, mutable_unknown_fields())); - break; - } - } - } - return true; -#undef DO_ -} - -void CodeGeneratorResponse::SerializeWithCachedSizes( - ::google::protobuf::io::CodedOutputStream* output) const { - // optional string error = 1; - if (has_error()) { - ::google::protobuf::internal::WireFormat::VerifyUTF8String( - this->error().data(), this->error().length(), - ::google::protobuf::internal::WireFormat::SERIALIZE); - ::google::protobuf::internal::WireFormatLite::WriteString( - 1, this->error(), output); - } - - // repeated .google.protobuf.compiler.CodeGeneratorResponse.File file = 15; - for (int i = 0; i < this->file_size(); i++) { - ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( - 15, this->file(i), output); - } - - if (!unknown_fields().empty()) { - ::google::protobuf::internal::WireFormat::SerializeUnknownFields( - unknown_fields(), output); - } -} - -::google::protobuf::uint8* CodeGeneratorResponse::SerializeWithCachedSizesToArray( - ::google::protobuf::uint8* target) const { - // optional string error = 1; - if (has_error()) { - ::google::protobuf::internal::WireFormat::VerifyUTF8String( - this->error().data(), this->error().length(), - ::google::protobuf::internal::WireFormat::SERIALIZE); - target = - ::google::protobuf::internal::WireFormatLite::WriteStringToArray( - 1, this->error(), target); - } - - // repeated .google.protobuf.compiler.CodeGeneratorResponse.File file = 15; - for (int i = 0; i < this->file_size(); i++) { - target = ::google::protobuf::internal::WireFormatLite:: - WriteMessageNoVirtualToArray( - 15, this->file(i), target); - } - - if (!unknown_fields().empty()) { - target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray( - unknown_fields(), target); - } - return target; -} - -int CodeGeneratorResponse::ByteSize() const { - int total_size = 0; - - if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) { - // optional string error = 1; - if (has_error()) { - total_size += 1 + - ::google::protobuf::internal::WireFormatLite::StringSize( - this->error()); - } - - } - // repeated .google.protobuf.compiler.CodeGeneratorResponse.File file = 15; - total_size += 1 * this->file_size(); - for (int i = 0; i < this->file_size(); i++) { - total_size += - ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( - this->file(i)); - } - - if (!unknown_fields().empty()) { - total_size += - ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( - unknown_fields()); - } - GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); - _cached_size_ = total_size; - GOOGLE_SAFE_CONCURRENT_WRITES_END(); - return total_size; -} - -void CodeGeneratorResponse::MergeFrom(const ::google::protobuf::Message& from) { - GOOGLE_CHECK_NE(&from, this); - const CodeGeneratorResponse* source = - ::google::protobuf::internal::dynamic_cast_if_available( - &from); - if (source == NULL) { - ::google::protobuf::internal::ReflectionOps::Merge(from, this); - } else { - MergeFrom(*source); - } -} - -void CodeGeneratorResponse::MergeFrom(const CodeGeneratorResponse& from) { - GOOGLE_CHECK_NE(&from, this); - file_.MergeFrom(from.file_); - if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) { - if (from.has_error()) { - set_error(from.error()); - } - } - mutable_unknown_fields()->MergeFrom(from.unknown_fields()); -} - -void CodeGeneratorResponse::CopyFrom(const ::google::protobuf::Message& from) { - if (&from == this) return; - Clear(); - MergeFrom(from); -} - -void CodeGeneratorResponse::CopyFrom(const CodeGeneratorResponse& from) { - if (&from == this) return; - Clear(); - MergeFrom(from); -} - -bool CodeGeneratorResponse::IsInitialized() const { - - return true; -} - -void CodeGeneratorResponse::Swap(CodeGeneratorResponse* other) { - if (other != this) { - std::swap(error_, other->error_); - file_.Swap(&other->file_); - std::swap(_has_bits_[0], other->_has_bits_[0]); - _unknown_fields_.Swap(&other->_unknown_fields_); - std::swap(_cached_size_, other->_cached_size_); - } -} - -::google::protobuf::Metadata CodeGeneratorResponse::GetMetadata() const { - protobuf_AssignDescriptorsOnce(); - ::google::protobuf::Metadata metadata; - metadata.descriptor = CodeGeneratorResponse_descriptor_; - metadata.reflection = CodeGeneratorResponse_reflection_; - return metadata; -} - - -// @@protoc_insertion_point(namespace_scope) - -} // namespace compiler -} // namespace protobuf -} // namespace google - -// @@protoc_insertion_point(global_scope) diff --git a/modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/plugin.pb.h b/modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/plugin.pb.h deleted file mode 100644 index 68cc21c7f..000000000 --- a/modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/plugin.pb.h +++ /dev/null @@ -1,856 +0,0 @@ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: google/protobuf/compiler/plugin.proto - -#ifndef PROTOBUF_google_2fprotobuf_2fcompiler_2fplugin_2eproto__INCLUDED -#define PROTOBUF_google_2fprotobuf_2fcompiler_2fplugin_2eproto__INCLUDED - -#include - -#include - -#if GOOGLE_PROTOBUF_VERSION < 2005000 -#error This file was generated by a newer version of protoc which is -#error incompatible with your Protocol Buffer headers. Please update -#error your headers. -#endif -#if 2005000 < GOOGLE_PROTOBUF_MIN_PROTOC_VERSION -#error This file was generated by an older version of protoc which is -#error incompatible with your Protocol Buffer headers. Please -#error regenerate this file with a newer version of protoc. -#endif - -#include -#include -#include -#include -#include -#include "google/protobuf/descriptor.pb.h" -// @@protoc_insertion_point(includes) - -namespace google { -namespace protobuf { -namespace compiler { - -// Internal implementation detail -- do not call these. -void LIBPROTOC_EXPORT protobuf_AddDesc_google_2fprotobuf_2fcompiler_2fplugin_2eproto(); -void protobuf_AssignDesc_google_2fprotobuf_2fcompiler_2fplugin_2eproto(); -void protobuf_ShutdownFile_google_2fprotobuf_2fcompiler_2fplugin_2eproto(); - -class CodeGeneratorRequest; -class CodeGeneratorResponse; -class CodeGeneratorResponse_File; - -// =================================================================== - -class LIBPROTOC_EXPORT CodeGeneratorRequest : public ::google::protobuf::Message { - public: - CodeGeneratorRequest(); - virtual ~CodeGeneratorRequest(); - - CodeGeneratorRequest(const CodeGeneratorRequest& from); - - inline CodeGeneratorRequest& operator=(const CodeGeneratorRequest& from) { - CopyFrom(from); - return *this; - } - - inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const { - return _unknown_fields_; - } - - inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() { - return &_unknown_fields_; - } - - static const ::google::protobuf::Descriptor* descriptor(); - static const CodeGeneratorRequest& default_instance(); - - void Swap(CodeGeneratorRequest* other); - - // implements Message ---------------------------------------------- - - CodeGeneratorRequest* New() const; - void CopyFrom(const ::google::protobuf::Message& from); - void MergeFrom(const ::google::protobuf::Message& from); - void CopyFrom(const CodeGeneratorRequest& from); - void MergeFrom(const CodeGeneratorRequest& from); - void Clear(); - bool IsInitialized() const; - - int ByteSize() const; - bool MergePartialFromCodedStream( - ::google::protobuf::io::CodedInputStream* input); - void SerializeWithCachedSizes( - ::google::protobuf::io::CodedOutputStream* output) const; - ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const; - int GetCachedSize() const { return _cached_size_; } - private: - void SharedCtor(); - void SharedDtor(); - void SetCachedSize(int size) const; - public: - - ::google::protobuf::Metadata GetMetadata() const; - - // nested types ---------------------------------------------------- - - // accessors ------------------------------------------------------- - - // repeated string file_to_generate = 1; - inline int file_to_generate_size() const; - inline void clear_file_to_generate(); - static const int kFileToGenerateFieldNumber = 1; - inline const ::std::string& file_to_generate(int index) const; - inline ::std::string* mutable_file_to_generate(int index); - inline void set_file_to_generate(int index, const ::std::string& value); - inline void set_file_to_generate(int index, const char* value); - inline void set_file_to_generate(int index, const char* value, size_t size); - inline ::std::string* add_file_to_generate(); - inline void add_file_to_generate(const ::std::string& value); - inline void add_file_to_generate(const char* value); - inline void add_file_to_generate(const char* value, size_t size); - inline const ::google::protobuf::RepeatedPtrField< ::std::string>& file_to_generate() const; - inline ::google::protobuf::RepeatedPtrField< ::std::string>* mutable_file_to_generate(); - - // optional string parameter = 2; - inline bool has_parameter() const; - inline void clear_parameter(); - static const int kParameterFieldNumber = 2; - inline const ::std::string& parameter() const; - inline void set_parameter(const ::std::string& value); - inline void set_parameter(const char* value); - inline void set_parameter(const char* value, size_t size); - inline ::std::string* mutable_parameter(); - inline ::std::string* release_parameter(); - inline void set_allocated_parameter(::std::string* parameter); - - // repeated .google.protobuf.FileDescriptorProto proto_file = 15; - inline int proto_file_size() const; - inline void clear_proto_file(); - static const int kProtoFileFieldNumber = 15; - inline const ::google::protobuf::FileDescriptorProto& proto_file(int index) const; - inline ::google::protobuf::FileDescriptorProto* mutable_proto_file(int index); - inline ::google::protobuf::FileDescriptorProto* add_proto_file(); - inline const ::google::protobuf::RepeatedPtrField< ::google::protobuf::FileDescriptorProto >& - proto_file() const; - inline ::google::protobuf::RepeatedPtrField< ::google::protobuf::FileDescriptorProto >* - mutable_proto_file(); - - // @@protoc_insertion_point(class_scope:google.protobuf.compiler.CodeGeneratorRequest) - private: - inline void set_has_parameter(); - inline void clear_has_parameter(); - - ::google::protobuf::UnknownFieldSet _unknown_fields_; - - ::google::protobuf::RepeatedPtrField< ::std::string> file_to_generate_; - ::std::string* parameter_; - ::google::protobuf::RepeatedPtrField< ::google::protobuf::FileDescriptorProto > proto_file_; - - mutable int _cached_size_; - ::google::protobuf::uint32 _has_bits_[(3 + 31) / 32]; - - friend void LIBPROTOC_EXPORT protobuf_AddDesc_google_2fprotobuf_2fcompiler_2fplugin_2eproto(); - friend void protobuf_AssignDesc_google_2fprotobuf_2fcompiler_2fplugin_2eproto(); - friend void protobuf_ShutdownFile_google_2fprotobuf_2fcompiler_2fplugin_2eproto(); - - void InitAsDefaultInstance(); - static CodeGeneratorRequest* default_instance_; -}; -// ------------------------------------------------------------------- - -class LIBPROTOC_EXPORT CodeGeneratorResponse_File : public ::google::protobuf::Message { - public: - CodeGeneratorResponse_File(); - virtual ~CodeGeneratorResponse_File(); - - CodeGeneratorResponse_File(const CodeGeneratorResponse_File& from); - - inline CodeGeneratorResponse_File& operator=(const CodeGeneratorResponse_File& from) { - CopyFrom(from); - return *this; - } - - inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const { - return _unknown_fields_; - } - - inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() { - return &_unknown_fields_; - } - - static const ::google::protobuf::Descriptor* descriptor(); - static const CodeGeneratorResponse_File& default_instance(); - - void Swap(CodeGeneratorResponse_File* other); - - // implements Message ---------------------------------------------- - - CodeGeneratorResponse_File* New() const; - void CopyFrom(const ::google::protobuf::Message& from); - void MergeFrom(const ::google::protobuf::Message& from); - void CopyFrom(const CodeGeneratorResponse_File& from); - void MergeFrom(const CodeGeneratorResponse_File& from); - void Clear(); - bool IsInitialized() const; - - int ByteSize() const; - bool MergePartialFromCodedStream( - ::google::protobuf::io::CodedInputStream* input); - void SerializeWithCachedSizes( - ::google::protobuf::io::CodedOutputStream* output) const; - ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const; - int GetCachedSize() const { return _cached_size_; } - private: - void SharedCtor(); - void SharedDtor(); - void SetCachedSize(int size) const; - public: - - ::google::protobuf::Metadata GetMetadata() const; - - // nested types ---------------------------------------------------- - - // accessors ------------------------------------------------------- - - // optional string name = 1; - inline bool has_name() const; - inline void clear_name(); - static const int kNameFieldNumber = 1; - inline const ::std::string& name() const; - inline void set_name(const ::std::string& value); - inline void set_name(const char* value); - inline void set_name(const char* value, size_t size); - inline ::std::string* mutable_name(); - inline ::std::string* release_name(); - inline void set_allocated_name(::std::string* name); - - // optional string insertion_point = 2; - inline bool has_insertion_point() const; - inline void clear_insertion_point(); - static const int kInsertionPointFieldNumber = 2; - inline const ::std::string& insertion_point() const; - inline void set_insertion_point(const ::std::string& value); - inline void set_insertion_point(const char* value); - inline void set_insertion_point(const char* value, size_t size); - inline ::std::string* mutable_insertion_point(); - inline ::std::string* release_insertion_point(); - inline void set_allocated_insertion_point(::std::string* insertion_point); - - // optional string content = 15; - inline bool has_content() const; - inline void clear_content(); - static const int kContentFieldNumber = 15; - inline const ::std::string& content() const; - inline void set_content(const ::std::string& value); - inline void set_content(const char* value); - inline void set_content(const char* value, size_t size); - inline ::std::string* mutable_content(); - inline ::std::string* release_content(); - inline void set_allocated_content(::std::string* content); - - // @@protoc_insertion_point(class_scope:google.protobuf.compiler.CodeGeneratorResponse.File) - private: - inline void set_has_name(); - inline void clear_has_name(); - inline void set_has_insertion_point(); - inline void clear_has_insertion_point(); - inline void set_has_content(); - inline void clear_has_content(); - - ::google::protobuf::UnknownFieldSet _unknown_fields_; - - ::std::string* name_; - ::std::string* insertion_point_; - ::std::string* content_; - - mutable int _cached_size_; - ::google::protobuf::uint32 _has_bits_[(3 + 31) / 32]; - - friend void LIBPROTOC_EXPORT protobuf_AddDesc_google_2fprotobuf_2fcompiler_2fplugin_2eproto(); - friend void protobuf_AssignDesc_google_2fprotobuf_2fcompiler_2fplugin_2eproto(); - friend void protobuf_ShutdownFile_google_2fprotobuf_2fcompiler_2fplugin_2eproto(); - - void InitAsDefaultInstance(); - static CodeGeneratorResponse_File* default_instance_; -}; -// ------------------------------------------------------------------- - -class LIBPROTOC_EXPORT CodeGeneratorResponse : public ::google::protobuf::Message { - public: - CodeGeneratorResponse(); - virtual ~CodeGeneratorResponse(); - - CodeGeneratorResponse(const CodeGeneratorResponse& from); - - inline CodeGeneratorResponse& operator=(const CodeGeneratorResponse& from) { - CopyFrom(from); - return *this; - } - - inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const { - return _unknown_fields_; - } - - inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() { - return &_unknown_fields_; - } - - static const ::google::protobuf::Descriptor* descriptor(); - static const CodeGeneratorResponse& default_instance(); - - void Swap(CodeGeneratorResponse* other); - - // implements Message ---------------------------------------------- - - CodeGeneratorResponse* New() const; - void CopyFrom(const ::google::protobuf::Message& from); - void MergeFrom(const ::google::protobuf::Message& from); - void CopyFrom(const CodeGeneratorResponse& from); - void MergeFrom(const CodeGeneratorResponse& from); - void Clear(); - bool IsInitialized() const; - - int ByteSize() const; - bool MergePartialFromCodedStream( - ::google::protobuf::io::CodedInputStream* input); - void SerializeWithCachedSizes( - ::google::protobuf::io::CodedOutputStream* output) const; - ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const; - int GetCachedSize() const { return _cached_size_; } - private: - void SharedCtor(); - void SharedDtor(); - void SetCachedSize(int size) const; - public: - - ::google::protobuf::Metadata GetMetadata() const; - - // nested types ---------------------------------------------------- - - typedef CodeGeneratorResponse_File File; - - // accessors ------------------------------------------------------- - - // optional string error = 1; - inline bool has_error() const; - inline void clear_error(); - static const int kErrorFieldNumber = 1; - inline const ::std::string& error() const; - inline void set_error(const ::std::string& value); - inline void set_error(const char* value); - inline void set_error(const char* value, size_t size); - inline ::std::string* mutable_error(); - inline ::std::string* release_error(); - inline void set_allocated_error(::std::string* error); - - // repeated .google.protobuf.compiler.CodeGeneratorResponse.File file = 15; - inline int file_size() const; - inline void clear_file(); - static const int kFileFieldNumber = 15; - inline const ::google::protobuf::compiler::CodeGeneratorResponse_File& file(int index) const; - inline ::google::protobuf::compiler::CodeGeneratorResponse_File* mutable_file(int index); - inline ::google::protobuf::compiler::CodeGeneratorResponse_File* add_file(); - inline const ::google::protobuf::RepeatedPtrField< ::google::protobuf::compiler::CodeGeneratorResponse_File >& - file() const; - inline ::google::protobuf::RepeatedPtrField< ::google::protobuf::compiler::CodeGeneratorResponse_File >* - mutable_file(); - - // @@protoc_insertion_point(class_scope:google.protobuf.compiler.CodeGeneratorResponse) - private: - inline void set_has_error(); - inline void clear_has_error(); - - ::google::protobuf::UnknownFieldSet _unknown_fields_; - - ::std::string* error_; - ::google::protobuf::RepeatedPtrField< ::google::protobuf::compiler::CodeGeneratorResponse_File > file_; - - mutable int _cached_size_; - ::google::protobuf::uint32 _has_bits_[(2 + 31) / 32]; - - friend void LIBPROTOC_EXPORT protobuf_AddDesc_google_2fprotobuf_2fcompiler_2fplugin_2eproto(); - friend void protobuf_AssignDesc_google_2fprotobuf_2fcompiler_2fplugin_2eproto(); - friend void protobuf_ShutdownFile_google_2fprotobuf_2fcompiler_2fplugin_2eproto(); - - void InitAsDefaultInstance(); - static CodeGeneratorResponse* default_instance_; -}; -// =================================================================== - - -// =================================================================== - -// CodeGeneratorRequest - -// repeated string file_to_generate = 1; -inline int CodeGeneratorRequest::file_to_generate_size() const { - return file_to_generate_.size(); -} -inline void CodeGeneratorRequest::clear_file_to_generate() { - file_to_generate_.Clear(); -} -inline const ::std::string& CodeGeneratorRequest::file_to_generate(int index) const { - return file_to_generate_.Get(index); -} -inline ::std::string* CodeGeneratorRequest::mutable_file_to_generate(int index) { - return file_to_generate_.Mutable(index); -} -inline void CodeGeneratorRequest::set_file_to_generate(int index, const ::std::string& value) { - file_to_generate_.Mutable(index)->assign(value); -} -inline void CodeGeneratorRequest::set_file_to_generate(int index, const char* value) { - file_to_generate_.Mutable(index)->assign(value); -} -inline void CodeGeneratorRequest::set_file_to_generate(int index, const char* value, size_t size) { - file_to_generate_.Mutable(index)->assign( - reinterpret_cast(value), size); -} -inline ::std::string* CodeGeneratorRequest::add_file_to_generate() { - return file_to_generate_.Add(); -} -inline void CodeGeneratorRequest::add_file_to_generate(const ::std::string& value) { - file_to_generate_.Add()->assign(value); -} -inline void CodeGeneratorRequest::add_file_to_generate(const char* value) { - file_to_generate_.Add()->assign(value); -} -inline void CodeGeneratorRequest::add_file_to_generate(const char* value, size_t size) { - file_to_generate_.Add()->assign(reinterpret_cast(value), size); -} -inline const ::google::protobuf::RepeatedPtrField< ::std::string>& -CodeGeneratorRequest::file_to_generate() const { - return file_to_generate_; -} -inline ::google::protobuf::RepeatedPtrField< ::std::string>* -CodeGeneratorRequest::mutable_file_to_generate() { - return &file_to_generate_; -} - -// optional string parameter = 2; -inline bool CodeGeneratorRequest::has_parameter() const { - return (_has_bits_[0] & 0x00000002u) != 0; -} -inline void CodeGeneratorRequest::set_has_parameter() { - _has_bits_[0] |= 0x00000002u; -} -inline void CodeGeneratorRequest::clear_has_parameter() { - _has_bits_[0] &= ~0x00000002u; -} -inline void CodeGeneratorRequest::clear_parameter() { - if (parameter_ != &::google::protobuf::internal::kEmptyString) { - parameter_->clear(); - } - clear_has_parameter(); -} -inline const ::std::string& CodeGeneratorRequest::parameter() const { - return *parameter_; -} -inline void CodeGeneratorRequest::set_parameter(const ::std::string& value) { - set_has_parameter(); - if (parameter_ == &::google::protobuf::internal::kEmptyString) { - parameter_ = new ::std::string; - } - parameter_->assign(value); -} -inline void CodeGeneratorRequest::set_parameter(const char* value) { - set_has_parameter(); - if (parameter_ == &::google::protobuf::internal::kEmptyString) { - parameter_ = new ::std::string; - } - parameter_->assign(value); -} -inline void CodeGeneratorRequest::set_parameter(const char* value, size_t size) { - set_has_parameter(); - if (parameter_ == &::google::protobuf::internal::kEmptyString) { - parameter_ = new ::std::string; - } - parameter_->assign(reinterpret_cast(value), size); -} -inline ::std::string* CodeGeneratorRequest::mutable_parameter() { - set_has_parameter(); - if (parameter_ == &::google::protobuf::internal::kEmptyString) { - parameter_ = new ::std::string; - } - return parameter_; -} -inline ::std::string* CodeGeneratorRequest::release_parameter() { - clear_has_parameter(); - if (parameter_ == &::google::protobuf::internal::kEmptyString) { - return NULL; - } else { - ::std::string* temp = parameter_; - parameter_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); - return temp; - } -} -inline void CodeGeneratorRequest::set_allocated_parameter(::std::string* parameter) { - if (parameter_ != &::google::protobuf::internal::kEmptyString) { - delete parameter_; - } - if (parameter) { - set_has_parameter(); - parameter_ = parameter; - } else { - clear_has_parameter(); - parameter_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); - } -} - -// repeated .google.protobuf.FileDescriptorProto proto_file = 15; -inline int CodeGeneratorRequest::proto_file_size() const { - return proto_file_.size(); -} -inline void CodeGeneratorRequest::clear_proto_file() { - proto_file_.Clear(); -} -inline const ::google::protobuf::FileDescriptorProto& CodeGeneratorRequest::proto_file(int index) const { - return proto_file_.Get(index); -} -inline ::google::protobuf::FileDescriptorProto* CodeGeneratorRequest::mutable_proto_file(int index) { - return proto_file_.Mutable(index); -} -inline ::google::protobuf::FileDescriptorProto* CodeGeneratorRequest::add_proto_file() { - return proto_file_.Add(); -} -inline const ::google::protobuf::RepeatedPtrField< ::google::protobuf::FileDescriptorProto >& -CodeGeneratorRequest::proto_file() const { - return proto_file_; -} -inline ::google::protobuf::RepeatedPtrField< ::google::protobuf::FileDescriptorProto >* -CodeGeneratorRequest::mutable_proto_file() { - return &proto_file_; -} - -// ------------------------------------------------------------------- - -// CodeGeneratorResponse_File - -// optional string name = 1; -inline bool CodeGeneratorResponse_File::has_name() const { - return (_has_bits_[0] & 0x00000001u) != 0; -} -inline void CodeGeneratorResponse_File::set_has_name() { - _has_bits_[0] |= 0x00000001u; -} -inline void CodeGeneratorResponse_File::clear_has_name() { - _has_bits_[0] &= ~0x00000001u; -} -inline void CodeGeneratorResponse_File::clear_name() { - if (name_ != &::google::protobuf::internal::kEmptyString) { - name_->clear(); - } - clear_has_name(); -} -inline const ::std::string& CodeGeneratorResponse_File::name() const { - return *name_; -} -inline void CodeGeneratorResponse_File::set_name(const ::std::string& value) { - set_has_name(); - if (name_ == &::google::protobuf::internal::kEmptyString) { - name_ = new ::std::string; - } - name_->assign(value); -} -inline void CodeGeneratorResponse_File::set_name(const char* value) { - set_has_name(); - if (name_ == &::google::protobuf::internal::kEmptyString) { - name_ = new ::std::string; - } - name_->assign(value); -} -inline void CodeGeneratorResponse_File::set_name(const char* value, size_t size) { - set_has_name(); - if (name_ == &::google::protobuf::internal::kEmptyString) { - name_ = new ::std::string; - } - name_->assign(reinterpret_cast(value), size); -} -inline ::std::string* CodeGeneratorResponse_File::mutable_name() { - set_has_name(); - if (name_ == &::google::protobuf::internal::kEmptyString) { - name_ = new ::std::string; - } - return name_; -} -inline ::std::string* CodeGeneratorResponse_File::release_name() { - clear_has_name(); - if (name_ == &::google::protobuf::internal::kEmptyString) { - return NULL; - } else { - ::std::string* temp = name_; - name_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); - return temp; - } -} -inline void CodeGeneratorResponse_File::set_allocated_name(::std::string* name) { - if (name_ != &::google::protobuf::internal::kEmptyString) { - delete name_; - } - if (name) { - set_has_name(); - name_ = name; - } else { - clear_has_name(); - name_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); - } -} - -// optional string insertion_point = 2; -inline bool CodeGeneratorResponse_File::has_insertion_point() const { - return (_has_bits_[0] & 0x00000002u) != 0; -} -inline void CodeGeneratorResponse_File::set_has_insertion_point() { - _has_bits_[0] |= 0x00000002u; -} -inline void CodeGeneratorResponse_File::clear_has_insertion_point() { - _has_bits_[0] &= ~0x00000002u; -} -inline void CodeGeneratorResponse_File::clear_insertion_point() { - if (insertion_point_ != &::google::protobuf::internal::kEmptyString) { - insertion_point_->clear(); - } - clear_has_insertion_point(); -} -inline const ::std::string& CodeGeneratorResponse_File::insertion_point() const { - return *insertion_point_; -} -inline void CodeGeneratorResponse_File::set_insertion_point(const ::std::string& value) { - set_has_insertion_point(); - if (insertion_point_ == &::google::protobuf::internal::kEmptyString) { - insertion_point_ = new ::std::string; - } - insertion_point_->assign(value); -} -inline void CodeGeneratorResponse_File::set_insertion_point(const char* value) { - set_has_insertion_point(); - if (insertion_point_ == &::google::protobuf::internal::kEmptyString) { - insertion_point_ = new ::std::string; - } - insertion_point_->assign(value); -} -inline void CodeGeneratorResponse_File::set_insertion_point(const char* value, size_t size) { - set_has_insertion_point(); - if (insertion_point_ == &::google::protobuf::internal::kEmptyString) { - insertion_point_ = new ::std::string; - } - insertion_point_->assign(reinterpret_cast(value), size); -} -inline ::std::string* CodeGeneratorResponse_File::mutable_insertion_point() { - set_has_insertion_point(); - if (insertion_point_ == &::google::protobuf::internal::kEmptyString) { - insertion_point_ = new ::std::string; - } - return insertion_point_; -} -inline ::std::string* CodeGeneratorResponse_File::release_insertion_point() { - clear_has_insertion_point(); - if (insertion_point_ == &::google::protobuf::internal::kEmptyString) { - return NULL; - } else { - ::std::string* temp = insertion_point_; - insertion_point_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); - return temp; - } -} -inline void CodeGeneratorResponse_File::set_allocated_insertion_point(::std::string* insertion_point) { - if (insertion_point_ != &::google::protobuf::internal::kEmptyString) { - delete insertion_point_; - } - if (insertion_point) { - set_has_insertion_point(); - insertion_point_ = insertion_point; - } else { - clear_has_insertion_point(); - insertion_point_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); - } -} - -// optional string content = 15; -inline bool CodeGeneratorResponse_File::has_content() const { - return (_has_bits_[0] & 0x00000004u) != 0; -} -inline void CodeGeneratorResponse_File::set_has_content() { - _has_bits_[0] |= 0x00000004u; -} -inline void CodeGeneratorResponse_File::clear_has_content() { - _has_bits_[0] &= ~0x00000004u; -} -inline void CodeGeneratorResponse_File::clear_content() { - if (content_ != &::google::protobuf::internal::kEmptyString) { - content_->clear(); - } - clear_has_content(); -} -inline const ::std::string& CodeGeneratorResponse_File::content() const { - return *content_; -} -inline void CodeGeneratorResponse_File::set_content(const ::std::string& value) { - set_has_content(); - if (content_ == &::google::protobuf::internal::kEmptyString) { - content_ = new ::std::string; - } - content_->assign(value); -} -inline void CodeGeneratorResponse_File::set_content(const char* value) { - set_has_content(); - if (content_ == &::google::protobuf::internal::kEmptyString) { - content_ = new ::std::string; - } - content_->assign(value); -} -inline void CodeGeneratorResponse_File::set_content(const char* value, size_t size) { - set_has_content(); - if (content_ == &::google::protobuf::internal::kEmptyString) { - content_ = new ::std::string; - } - content_->assign(reinterpret_cast(value), size); -} -inline ::std::string* CodeGeneratorResponse_File::mutable_content() { - set_has_content(); - if (content_ == &::google::protobuf::internal::kEmptyString) { - content_ = new ::std::string; - } - return content_; -} -inline ::std::string* CodeGeneratorResponse_File::release_content() { - clear_has_content(); - if (content_ == &::google::protobuf::internal::kEmptyString) { - return NULL; - } else { - ::std::string* temp = content_; - content_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); - return temp; - } -} -inline void CodeGeneratorResponse_File::set_allocated_content(::std::string* content) { - if (content_ != &::google::protobuf::internal::kEmptyString) { - delete content_; - } - if (content) { - set_has_content(); - content_ = content; - } else { - clear_has_content(); - content_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); - } -} - -// ------------------------------------------------------------------- - -// CodeGeneratorResponse - -// optional string error = 1; -inline bool CodeGeneratorResponse::has_error() const { - return (_has_bits_[0] & 0x00000001u) != 0; -} -inline void CodeGeneratorResponse::set_has_error() { - _has_bits_[0] |= 0x00000001u; -} -inline void CodeGeneratorResponse::clear_has_error() { - _has_bits_[0] &= ~0x00000001u; -} -inline void CodeGeneratorResponse::clear_error() { - if (error_ != &::google::protobuf::internal::kEmptyString) { - error_->clear(); - } - clear_has_error(); -} -inline const ::std::string& CodeGeneratorResponse::error() const { - return *error_; -} -inline void CodeGeneratorResponse::set_error(const ::std::string& value) { - set_has_error(); - if (error_ == &::google::protobuf::internal::kEmptyString) { - error_ = new ::std::string; - } - error_->assign(value); -} -inline void CodeGeneratorResponse::set_error(const char* value) { - set_has_error(); - if (error_ == &::google::protobuf::internal::kEmptyString) { - error_ = new ::std::string; - } - error_->assign(value); -} -inline void CodeGeneratorResponse::set_error(const char* value, size_t size) { - set_has_error(); - if (error_ == &::google::protobuf::internal::kEmptyString) { - error_ = new ::std::string; - } - error_->assign(reinterpret_cast(value), size); -} -inline ::std::string* CodeGeneratorResponse::mutable_error() { - set_has_error(); - if (error_ == &::google::protobuf::internal::kEmptyString) { - error_ = new ::std::string; - } - return error_; -} -inline ::std::string* CodeGeneratorResponse::release_error() { - clear_has_error(); - if (error_ == &::google::protobuf::internal::kEmptyString) { - return NULL; - } else { - ::std::string* temp = error_; - error_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); - return temp; - } -} -inline void CodeGeneratorResponse::set_allocated_error(::std::string* error) { - if (error_ != &::google::protobuf::internal::kEmptyString) { - delete error_; - } - if (error) { - set_has_error(); - error_ = error; - } else { - clear_has_error(); - error_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); - } -} - -// repeated .google.protobuf.compiler.CodeGeneratorResponse.File file = 15; -inline int CodeGeneratorResponse::file_size() const { - return file_.size(); -} -inline void CodeGeneratorResponse::clear_file() { - file_.Clear(); -} -inline const ::google::protobuf::compiler::CodeGeneratorResponse_File& CodeGeneratorResponse::file(int index) const { - return file_.Get(index); -} -inline ::google::protobuf::compiler::CodeGeneratorResponse_File* CodeGeneratorResponse::mutable_file(int index) { - return file_.Mutable(index); -} -inline ::google::protobuf::compiler::CodeGeneratorResponse_File* CodeGeneratorResponse::add_file() { - return file_.Add(); -} -inline const ::google::protobuf::RepeatedPtrField< ::google::protobuf::compiler::CodeGeneratorResponse_File >& -CodeGeneratorResponse::file() const { - return file_; -} -inline ::google::protobuf::RepeatedPtrField< ::google::protobuf::compiler::CodeGeneratorResponse_File >* -CodeGeneratorResponse::mutable_file() { - return &file_; -} - - -// @@protoc_insertion_point(namespace_scope) - -} // namespace compiler -} // namespace protobuf -} // namespace google - -#ifndef SWIG -namespace google { -namespace protobuf { - - -} // namespace google -} // namespace protobuf -#endif // SWIG - -// @@protoc_insertion_point(global_scope) - -#endif // PROTOBUF_google_2fprotobuf_2fcompiler_2fplugin_2eproto__INCLUDED diff --git a/modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/plugin.proto b/modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/plugin.proto deleted file mode 100644 index 77b888f37..000000000 --- a/modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/plugin.proto +++ /dev/null @@ -1,147 +0,0 @@ -// Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// http://code.google.com/p/protobuf/ -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -// Author: kenton@google.com (Kenton Varda) -// -// WARNING: The plugin interface is currently EXPERIMENTAL and is subject to -// change. -// -// protoc (aka the Protocol Compiler) can be extended via plugins. A plugin is -// just a program that reads a CodeGeneratorRequest from stdin and writes a -// CodeGeneratorResponse to stdout. -// -// Plugins written using C++ can use google/protobuf/compiler/plugin.h instead -// of dealing with the raw protocol defined here. -// -// A plugin executable needs only to be placed somewhere in the path. The -// plugin should be named "protoc-gen-$NAME", and will then be used when the -// flag "--${NAME}_out" is passed to protoc. - -package google.protobuf.compiler; -option java_package = "com.google.protobuf.compiler"; -option java_outer_classname = "PluginProtos"; - -import "google/protobuf/descriptor.proto"; - -// An encoded CodeGeneratorRequest is written to the plugin's stdin. -message CodeGeneratorRequest { - // The .proto files that were explicitly listed on the command-line. The - // code generator should generate code only for these files. Each file's - // descriptor will be included in proto_file, below. - repeated string file_to_generate = 1; - - // The generator parameter passed on the command-line. - optional string parameter = 2; - - // FileDescriptorProtos for all files in files_to_generate and everything - // they import. The files will appear in topological order, so each file - // appears before any file that imports it. - // - // protoc guarantees that all proto_files will be written after - // the fields above, even though this is not technically guaranteed by the - // protobuf wire format. This theoretically could allow a plugin to stream - // in the FileDescriptorProtos and handle them one by one rather than read - // the entire set into memory at once. However, as of this writing, this - // is not similarly optimized on protoc's end -- it will store all fields in - // memory at once before sending them to the plugin. - repeated FileDescriptorProto proto_file = 15; -} - -// The plugin writes an encoded CodeGeneratorResponse to stdout. -message CodeGeneratorResponse { - // Error message. If non-empty, code generation failed. The plugin process - // should exit with status code zero even if it reports an error in this way. - // - // This should be used to indicate errors in .proto files which prevent the - // code generator from generating correct code. Errors which indicate a - // problem in protoc itself -- such as the input CodeGeneratorRequest being - // unparseable -- should be reported by writing a message to stderr and - // exiting with a non-zero status code. - optional string error = 1; - - // Represents a single generated file. - message File { - // The file name, relative to the output directory. The name must not - // contain "." or ".." components and must be relative, not be absolute (so, - // the file cannot lie outside the output directory). "/" must be used as - // the path separator, not "\". - // - // If the name is omitted, the content will be appended to the previous - // file. This allows the generator to break large files into small chunks, - // and allows the generated text to be streamed back to protoc so that large - // files need not reside completely in memory at one time. Note that as of - // this writing protoc does not optimize for this -- it will read the entire - // CodeGeneratorResponse before writing files to disk. - optional string name = 1; - - // If non-empty, indicates that the named file should already exist, and the - // content here is to be inserted into that file at a defined insertion - // point. This feature allows a code generator to extend the output - // produced by another code generator. The original generator may provide - // insertion points by placing special annotations in the file that look - // like: - // @@protoc_insertion_point(NAME) - // The annotation can have arbitrary text before and after it on the line, - // which allows it to be placed in a comment. NAME should be replaced with - // an identifier naming the point -- this is what other generators will use - // as the insertion_point. Code inserted at this point will be placed - // immediately above the line containing the insertion point (thus multiple - // insertions to the same point will come out in the order they were added). - // The double-@ is intended to make it unlikely that the generated code - // could contain things that look like insertion points by accident. - // - // For example, the C++ code generator places the following line in the - // .pb.h files that it generates: - // // @@protoc_insertion_point(namespace_scope) - // This line appears within the scope of the file's package namespace, but - // outside of any particular class. Another plugin can then specify the - // insertion_point "namespace_scope" to generate additional classes or - // other declarations that should be placed in this scope. - // - // Note that if the line containing the insertion point begins with - // whitespace, the same whitespace will be added to every line of the - // inserted text. This is useful for languages like Python, where - // indentation matters. In these languages, the insertion point comment - // should be indented the same amount as any inserted code will need to be - // in order to work correctly in that context. - // - // The code generator that generates the initial file and the one which - // inserts into it must both run as part of a single invocation of protoc. - // Code generators are executed in the order in which they appear on the - // command line. - // - // If |insertion_point| is present, |name| must also be present. - optional string insertion_point = 2; - - // The file contents. - optional string content = 15; - } - repeated File file = 15; -} diff --git a/modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/python/python_generator.cc b/modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/python/python_generator.cc deleted file mode 100644 index 211ac70c0..000000000 --- a/modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/python/python_generator.cc +++ /dev/null @@ -1,1157 +0,0 @@ -// Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// http://code.google.com/p/protobuf/ -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -// Author: robinson@google.com (Will Robinson) -// -// This module outputs pure-Python protocol message classes that will -// largely be constructed at runtime via the metaclass in reflection.py. -// In other words, our job is basically to output a Python equivalent -// of the C++ *Descriptor objects, and fix up all circular references -// within these objects. -// -// Note that the runtime performance of protocol message classes created in -// this way is expected to be lousy. The plan is to create an alternate -// generator that outputs a Python/C extension module that lets -// performance-minded Python code leverage the fast C++ implementation -// directly. - -#include -#include -#include -#include -#include - -#include -#include - -#include -#include -#include -#include -#include -#include -#include - -namespace google { -namespace protobuf { -namespace compiler { -namespace python { - -namespace { - -// Returns a copy of |filename| with any trailing ".protodevel" or ".proto -// suffix stripped. -// TODO(robinson): Unify with copy in compiler/cpp/internal/helpers.cc. -string StripProto(const string& filename) { - const char* suffix = HasSuffixString(filename, ".protodevel") - ? ".protodevel" : ".proto"; - return StripSuffixString(filename, suffix); -} - - -// Returns the Python module name expected for a given .proto filename. -string ModuleName(const string& filename) { - string basename = StripProto(filename); - StripString(&basename, "-", '_'); - StripString(&basename, "/", '.'); - return basename + "_pb2"; -} - - -// Returns the name of all containing types for descriptor, -// in order from outermost to innermost, followed by descriptor's -// own name. Each name is separated by |separator|. -template -string NamePrefixedWithNestedTypes(const DescriptorT& descriptor, - const string& separator) { - string name = descriptor.name(); - for (const Descriptor* current = descriptor.containing_type(); - current != NULL; current = current->containing_type()) { - name = current->name() + separator + name; - } - return name; -} - - -// Name of the class attribute where we store the Python -// descriptor.Descriptor instance for the generated class. -// Must stay consistent with the _DESCRIPTOR_KEY constant -// in proto2/public/reflection.py. -const char kDescriptorKey[] = "DESCRIPTOR"; - - -// Does the file have top-level enums? -inline bool HasTopLevelEnums(const FileDescriptor *file) { - return file->enum_type_count() > 0; -} - - -// Should we generate generic services for this file? -inline bool HasGenericServices(const FileDescriptor *file) { - return file->service_count() > 0 && - file->options().py_generic_services(); -} - - -// Prints the common boilerplate needed at the top of every .py -// file output by this generator. -void PrintTopBoilerplate( - io::Printer* printer, const FileDescriptor* file, bool descriptor_proto) { - // TODO(robinson): Allow parameterization of Python version? - printer->Print( - "# Generated by the protocol buffer compiler. DO NOT EDIT!\n" - "# source: $filename$\n" - "\n", - "filename", file->name()); - if (HasTopLevelEnums(file)) { - printer->Print( - "from google.protobuf.internal import enum_type_wrapper\n"); - } - printer->Print( - "from google.protobuf import descriptor as _descriptor\n" - "from google.protobuf import message as _message\n" - "from google.protobuf import reflection as _reflection\n" - ); - if (HasGenericServices(file)) { - printer->Print( - "from google.protobuf import service as _service\n" - "from google.protobuf import service_reflection\n"); - } - - // Avoid circular imports if this module is descriptor_pb2. - if (!descriptor_proto) { - printer->Print( - "from google.protobuf import descriptor_pb2\n"); - } - printer->Print( - "# @@protoc_insertion_point(imports)\n"); - printer->Print("\n\n"); -} - - -// Returns a Python literal giving the default value for a field. -// If the field specifies no explicit default value, we'll return -// the default default value for the field type (zero for numbers, -// empty string for strings, empty list for repeated fields, and -// None for non-repeated, composite fields). -// -// TODO(robinson): Unify with code from -// //compiler/cpp/internal/primitive_field.cc -// //compiler/cpp/internal/enum_field.cc -// //compiler/cpp/internal/string_field.cc -string StringifyDefaultValue(const FieldDescriptor& field) { - if (field.is_repeated()) { - return "[]"; - } - - switch (field.cpp_type()) { - case FieldDescriptor::CPPTYPE_INT32: - return SimpleItoa(field.default_value_int32()); - case FieldDescriptor::CPPTYPE_UINT32: - return SimpleItoa(field.default_value_uint32()); - case FieldDescriptor::CPPTYPE_INT64: - return SimpleItoa(field.default_value_int64()); - case FieldDescriptor::CPPTYPE_UINT64: - return SimpleItoa(field.default_value_uint64()); - case FieldDescriptor::CPPTYPE_DOUBLE: { - double value = field.default_value_double(); - if (value == numeric_limits::infinity()) { - // Python pre-2.6 on Windows does not parse "inf" correctly. However, - // a numeric literal that is too big for a double will become infinity. - return "1e10000"; - } else if (value == -numeric_limits::infinity()) { - // See above. - return "-1e10000"; - } else if (value != value) { - // infinity * 0 = nan - return "(1e10000 * 0)"; - } else { - return SimpleDtoa(value); - } - } - case FieldDescriptor::CPPTYPE_FLOAT: { - float value = field.default_value_float(); - if (value == numeric_limits::infinity()) { - // Python pre-2.6 on Windows does not parse "inf" correctly. However, - // a numeric literal that is too big for a double will become infinity. - return "1e10000"; - } else if (value == -numeric_limits::infinity()) { - // See above. - return "-1e10000"; - } else if (value != value) { - // infinity - infinity = nan - return "(1e10000 * 0)"; - } else { - return SimpleFtoa(value); - } - } - case FieldDescriptor::CPPTYPE_BOOL: - return field.default_value_bool() ? "True" : "False"; - case FieldDescriptor::CPPTYPE_ENUM: - return SimpleItoa(field.default_value_enum()->number()); - case FieldDescriptor::CPPTYPE_STRING: - if (field.type() == FieldDescriptor::TYPE_STRING) { - return "unicode(\"" + CEscape(field.default_value_string()) + - "\", \"utf-8\")"; - } else { - return "\"" + CEscape(field.default_value_string()) + "\""; - } - case FieldDescriptor::CPPTYPE_MESSAGE: - return "None"; - } - // (We could add a default case above but then we wouldn't get the nice - // compiler warning when a new type is added.) - GOOGLE_LOG(FATAL) << "Not reached."; - return ""; -} - - - -} // namespace - - -Generator::Generator() : file_(NULL) { -} - -Generator::~Generator() { -} - -bool Generator::Generate(const FileDescriptor* file, - const string& parameter, - GeneratorContext* context, - string* error) const { - - // Completely serialize all Generate() calls on this instance. The - // thread-safety constraints of the CodeGenerator interface aren't clear so - // just be as conservative as possible. It's easier to relax this later if - // we need to, but I doubt it will be an issue. - // TODO(kenton): The proper thing to do would be to allocate any state on - // the stack and use that, so that the Generator class itself does not need - // to have any mutable members. Then it is implicitly thread-safe. - MutexLock lock(&mutex_); - file_ = file; - string module_name = ModuleName(file->name()); - string filename = module_name; - StripString(&filename, ".", '/'); - filename += ".py"; - - FileDescriptorProto fdp; - file_->CopyTo(&fdp); - fdp.SerializeToString(&file_descriptor_serialized_); - - - scoped_ptr output(context->Open(filename)); - GOOGLE_CHECK(output.get()); - io::Printer printer(output.get(), '$'); - printer_ = &printer; - - PrintTopBoilerplate(printer_, file_, GeneratingDescriptorProto()); - PrintImports(); - PrintFileDescriptor(); - PrintTopLevelEnums(); - PrintTopLevelExtensions(); - PrintAllNestedEnumsInFile(); - PrintMessageDescriptors(); - FixForeignFieldsInDescriptors(); - PrintMessages(); - // We have to fix up the extensions after the message classes themselves, - // since they need to call static RegisterExtension() methods on these - // classes. - FixForeignFieldsInExtensions(); - // Descriptor options may have custom extensions. These custom options - // can only be successfully parsed after we register corresponding - // extensions. Therefore we parse all options again here to recognize - // custom options that may be unknown when we define the descriptors. - FixAllDescriptorOptions(); - if (HasGenericServices(file)) { - PrintServices(); - } - - printer.Print( - "# @@protoc_insertion_point(module_scope)\n"); - - return !printer.failed(); -} - -// Prints Python imports for all modules imported by |file|. -void Generator::PrintImports() const { - for (int i = 0; i < file_->dependency_count(); ++i) { - string module_name = ModuleName(file_->dependency(i)->name()); - printer_->Print("import $module$\n", "module", - module_name); - } - printer_->Print("\n"); - - // Print public imports. - for (int i = 0; i < file_->public_dependency_count(); ++i) { - string module_name = ModuleName(file_->public_dependency(i)->name()); - printer_->Print("from $module$ import *\n", "module", module_name); - } - printer_->Print("\n"); -} - -// Prints the single file descriptor for this file. -void Generator::PrintFileDescriptor() const { - map m; - m["descriptor_name"] = kDescriptorKey; - m["name"] = file_->name(); - m["package"] = file_->package(); - const char file_descriptor_template[] = - "$descriptor_name$ = _descriptor.FileDescriptor(\n" - " name='$name$',\n" - " package='$package$',\n"; - printer_->Print(m, file_descriptor_template); - printer_->Indent(); - printer_->Print( - "serialized_pb='$value$'", - "value", strings::CHexEscape(file_descriptor_serialized_)); - - // TODO(falk): Also print options and fix the message_type, enum_type, - // service and extension later in the generation. - - printer_->Outdent(); - printer_->Print(")\n"); - printer_->Print("\n"); -} - -// Prints descriptors and module-level constants for all top-level -// enums defined in |file|. -void Generator::PrintTopLevelEnums() const { - vector > top_level_enum_values; - for (int i = 0; i < file_->enum_type_count(); ++i) { - const EnumDescriptor& enum_descriptor = *file_->enum_type(i); - PrintEnum(enum_descriptor); - printer_->Print("$name$ = " - "enum_type_wrapper.EnumTypeWrapper($descriptor_name$)", - "name", enum_descriptor.name(), - "descriptor_name", - ModuleLevelDescriptorName(enum_descriptor)); - printer_->Print("\n"); - - for (int j = 0; j < enum_descriptor.value_count(); ++j) { - const EnumValueDescriptor& value_descriptor = *enum_descriptor.value(j); - top_level_enum_values.push_back( - make_pair(value_descriptor.name(), value_descriptor.number())); - } - } - - for (int i = 0; i < top_level_enum_values.size(); ++i) { - printer_->Print("$name$ = $value$\n", - "name", top_level_enum_values[i].first, - "value", SimpleItoa(top_level_enum_values[i].second)); - } - printer_->Print("\n"); -} - -// Prints all enums contained in all message types in |file|. -void Generator::PrintAllNestedEnumsInFile() const { - for (int i = 0; i < file_->message_type_count(); ++i) { - PrintNestedEnums(*file_->message_type(i)); - } -} - -// Prints a Python statement assigning the appropriate module-level -// enum name to a Python EnumDescriptor object equivalent to -// enum_descriptor. -void Generator::PrintEnum(const EnumDescriptor& enum_descriptor) const { - map m; - m["descriptor_name"] = ModuleLevelDescriptorName(enum_descriptor); - m["name"] = enum_descriptor.name(); - m["full_name"] = enum_descriptor.full_name(); - m["file"] = kDescriptorKey; - const char enum_descriptor_template[] = - "$descriptor_name$ = _descriptor.EnumDescriptor(\n" - " name='$name$',\n" - " full_name='$full_name$',\n" - " filename=None,\n" - " file=$file$,\n" - " values=[\n"; - string options_string; - enum_descriptor.options().SerializeToString(&options_string); - printer_->Print(m, enum_descriptor_template); - printer_->Indent(); - printer_->Indent(); - for (int i = 0; i < enum_descriptor.value_count(); ++i) { - PrintEnumValueDescriptor(*enum_descriptor.value(i)); - printer_->Print(",\n"); - } - printer_->Outdent(); - printer_->Print("],\n"); - printer_->Print("containing_type=None,\n"); - printer_->Print("options=$options_value$,\n", - "options_value", - OptionsValue("EnumOptions", options_string)); - EnumDescriptorProto edp; - PrintSerializedPbInterval(enum_descriptor, edp); - printer_->Outdent(); - printer_->Print(")\n"); - printer_->Print("\n"); -} - -// Recursively prints enums in nested types within descriptor, then -// prints enums contained at the top level in descriptor. -void Generator::PrintNestedEnums(const Descriptor& descriptor) const { - for (int i = 0; i < descriptor.nested_type_count(); ++i) { - PrintNestedEnums(*descriptor.nested_type(i)); - } - - for (int i = 0; i < descriptor.enum_type_count(); ++i) { - PrintEnum(*descriptor.enum_type(i)); - } -} - -void Generator::PrintTopLevelExtensions() const { - const bool is_extension = true; - for (int i = 0; i < file_->extension_count(); ++i) { - const FieldDescriptor& extension_field = *file_->extension(i); - string constant_name = extension_field.name() + "_FIELD_NUMBER"; - UpperString(&constant_name); - printer_->Print("$constant_name$ = $number$\n", - "constant_name", constant_name, - "number", SimpleItoa(extension_field.number())); - printer_->Print("$name$ = ", "name", extension_field.name()); - PrintFieldDescriptor(extension_field, is_extension); - printer_->Print("\n"); - } - printer_->Print("\n"); -} - -// Prints Python equivalents of all Descriptors in |file|. -void Generator::PrintMessageDescriptors() const { - for (int i = 0; i < file_->message_type_count(); ++i) { - PrintDescriptor(*file_->message_type(i)); - printer_->Print("\n"); - } -} - -void Generator::PrintServices() const { - for (int i = 0; i < file_->service_count(); ++i) { - PrintServiceDescriptor(*file_->service(i)); - PrintServiceClass(*file_->service(i)); - PrintServiceStub(*file_->service(i)); - printer_->Print("\n"); - } -} - -void Generator::PrintServiceDescriptor( - const ServiceDescriptor& descriptor) const { - printer_->Print("\n"); - string service_name = ModuleLevelServiceDescriptorName(descriptor); - string options_string; - descriptor.options().SerializeToString(&options_string); - - printer_->Print( - "$service_name$ = _descriptor.ServiceDescriptor(\n", - "service_name", service_name); - printer_->Indent(); - map m; - m["name"] = descriptor.name(); - m["full_name"] = descriptor.full_name(); - m["file"] = kDescriptorKey; - m["index"] = SimpleItoa(descriptor.index()); - m["options_value"] = OptionsValue("ServiceOptions", options_string); - const char required_function_arguments[] = - "name='$name$',\n" - "full_name='$full_name$',\n" - "file=$file$,\n" - "index=$index$,\n" - "options=$options_value$,\n"; - printer_->Print(m, required_function_arguments); - - ServiceDescriptorProto sdp; - PrintSerializedPbInterval(descriptor, sdp); - - printer_->Print("methods=[\n"); - for (int i = 0; i < descriptor.method_count(); ++i) { - const MethodDescriptor* method = descriptor.method(i); - method->options().SerializeToString(&options_string); - - m.clear(); - m["name"] = method->name(); - m["full_name"] = method->full_name(); - m["index"] = SimpleItoa(method->index()); - m["serialized_options"] = CEscape(options_string); - m["input_type"] = ModuleLevelDescriptorName(*(method->input_type())); - m["output_type"] = ModuleLevelDescriptorName(*(method->output_type())); - m["options_value"] = OptionsValue("MethodOptions", options_string); - printer_->Print("_descriptor.MethodDescriptor(\n"); - printer_->Indent(); - printer_->Print( - m, - "name='$name$',\n" - "full_name='$full_name$',\n" - "index=$index$,\n" - "containing_service=None,\n" - "input_type=$input_type$,\n" - "output_type=$output_type$,\n" - "options=$options_value$,\n"); - printer_->Outdent(); - printer_->Print("),\n"); - } - - printer_->Outdent(); - printer_->Print("])\n\n"); -} - -void Generator::PrintServiceClass(const ServiceDescriptor& descriptor) const { - // Print the service. - printer_->Print("class $class_name$(_service.Service):\n", - "class_name", descriptor.name()); - printer_->Indent(); - printer_->Print( - "__metaclass__ = service_reflection.GeneratedServiceType\n" - "$descriptor_key$ = $descriptor_name$\n", - "descriptor_key", kDescriptorKey, - "descriptor_name", ModuleLevelServiceDescriptorName(descriptor)); - printer_->Outdent(); -} - -void Generator::PrintServiceStub(const ServiceDescriptor& descriptor) const { - // Print the service stub. - printer_->Print("class $class_name$_Stub($class_name$):\n", - "class_name", descriptor.name()); - printer_->Indent(); - printer_->Print( - "__metaclass__ = service_reflection.GeneratedServiceStubType\n" - "$descriptor_key$ = $descriptor_name$\n", - "descriptor_key", kDescriptorKey, - "descriptor_name", ModuleLevelServiceDescriptorName(descriptor)); - printer_->Outdent(); -} - -// Prints statement assigning ModuleLevelDescriptorName(message_descriptor) -// to a Python Descriptor object for message_descriptor. -// -// Mutually recursive with PrintNestedDescriptors(). -void Generator::PrintDescriptor(const Descriptor& message_descriptor) const { - PrintNestedDescriptors(message_descriptor); - - printer_->Print("\n"); - printer_->Print("$descriptor_name$ = _descriptor.Descriptor(\n", - "descriptor_name", - ModuleLevelDescriptorName(message_descriptor)); - printer_->Indent(); - map m; - m["name"] = message_descriptor.name(); - m["full_name"] = message_descriptor.full_name(); - m["file"] = kDescriptorKey; - const char required_function_arguments[] = - "name='$name$',\n" - "full_name='$full_name$',\n" - "filename=None,\n" - "file=$file$,\n" - "containing_type=None,\n"; - printer_->Print(m, required_function_arguments); - PrintFieldsInDescriptor(message_descriptor); - PrintExtensionsInDescriptor(message_descriptor); - - // Nested types - printer_->Print("nested_types=["); - for (int i = 0; i < message_descriptor.nested_type_count(); ++i) { - const string nested_name = ModuleLevelDescriptorName( - *message_descriptor.nested_type(i)); - printer_->Print("$name$, ", "name", nested_name); - } - printer_->Print("],\n"); - - // Enum types - printer_->Print("enum_types=[\n"); - printer_->Indent(); - for (int i = 0; i < message_descriptor.enum_type_count(); ++i) { - const string descriptor_name = ModuleLevelDescriptorName( - *message_descriptor.enum_type(i)); - printer_->Print(descriptor_name.c_str()); - printer_->Print(",\n"); - } - printer_->Outdent(); - printer_->Print("],\n"); - string options_string; - message_descriptor.options().SerializeToString(&options_string); - printer_->Print( - "options=$options_value$,\n" - "is_extendable=$extendable$", - "options_value", OptionsValue("MessageOptions", options_string), - "extendable", message_descriptor.extension_range_count() > 0 ? - "True" : "False"); - printer_->Print(",\n"); - - // Extension ranges - printer_->Print("extension_ranges=["); - for (int i = 0; i < message_descriptor.extension_range_count(); ++i) { - const Descriptor::ExtensionRange* range = - message_descriptor.extension_range(i); - printer_->Print("($start$, $end$), ", - "start", SimpleItoa(range->start), - "end", SimpleItoa(range->end)); - } - printer_->Print("],\n"); - - // Serialization of proto - DescriptorProto edp; - PrintSerializedPbInterval(message_descriptor, edp); - - printer_->Outdent(); - printer_->Print(")\n"); -} - -// Prints Python Descriptor objects for all nested types contained in -// message_descriptor. -// -// Mutually recursive with PrintDescriptor(). -void Generator::PrintNestedDescriptors( - const Descriptor& containing_descriptor) const { - for (int i = 0; i < containing_descriptor.nested_type_count(); ++i) { - PrintDescriptor(*containing_descriptor.nested_type(i)); - } -} - -// Prints all messages in |file|. -void Generator::PrintMessages() const { - for (int i = 0; i < file_->message_type_count(); ++i) { - PrintMessage(*file_->message_type(i)); - printer_->Print("\n"); - } -} - -// Prints a Python class for the given message descriptor. We defer to the -// metaclass to do almost all of the work of actually creating a useful class. -// The purpose of this function and its many helper functions above is merely -// to output a Python version of the descriptors, which the metaclass in -// reflection.py will use to construct the meat of the class itself. -// -// Mutually recursive with PrintNestedMessages(). -void Generator::PrintMessage( - const Descriptor& message_descriptor) const { - printer_->Print("class $name$(_message.Message):\n", "name", - message_descriptor.name()); - printer_->Indent(); - printer_->Print("__metaclass__ = _reflection.GeneratedProtocolMessageType\n"); - PrintNestedMessages(message_descriptor); - map m; - m["descriptor_key"] = kDescriptorKey; - m["descriptor_name"] = ModuleLevelDescriptorName(message_descriptor); - printer_->Print(m, "$descriptor_key$ = $descriptor_name$\n"); - - printer_->Print( - "\n" - "# @@protoc_insertion_point(class_scope:$full_name$)\n", - "full_name", message_descriptor.full_name()); - - printer_->Outdent(); -} - -// Prints all nested messages within |containing_descriptor|. -// Mutually recursive with PrintMessage(). -void Generator::PrintNestedMessages( - const Descriptor& containing_descriptor) const { - for (int i = 0; i < containing_descriptor.nested_type_count(); ++i) { - printer_->Print("\n"); - PrintMessage(*containing_descriptor.nested_type(i)); - } -} - -// Recursively fixes foreign fields in all nested types in |descriptor|, then -// sets the message_type and enum_type of all message and enum fields to point -// to their respective descriptors. -// Args: -// descriptor: descriptor to print fields for. -// containing_descriptor: if descriptor is a nested type, this is its -// containing type, or NULL if this is a root/top-level type. -void Generator::FixForeignFieldsInDescriptor( - const Descriptor& descriptor, - const Descriptor* containing_descriptor) const { - for (int i = 0; i < descriptor.nested_type_count(); ++i) { - FixForeignFieldsInDescriptor(*descriptor.nested_type(i), &descriptor); - } - - for (int i = 0; i < descriptor.field_count(); ++i) { - const FieldDescriptor& field_descriptor = *descriptor.field(i); - FixForeignFieldsInField(&descriptor, field_descriptor, "fields_by_name"); - } - - FixContainingTypeInDescriptor(descriptor, containing_descriptor); - for (int i = 0; i < descriptor.enum_type_count(); ++i) { - const EnumDescriptor& enum_descriptor = *descriptor.enum_type(i); - FixContainingTypeInDescriptor(enum_descriptor, &descriptor); - } -} - -void Generator::AddMessageToFileDescriptor(const Descriptor& descriptor) const { - map m; - m["descriptor_name"] = kDescriptorKey; - m["message_name"] = descriptor.name(); - m["message_descriptor_name"] = ModuleLevelDescriptorName(descriptor); - const char file_descriptor_template[] = - "$descriptor_name$.message_types_by_name['$message_name$'] = " - "$message_descriptor_name$\n"; - printer_->Print(m, file_descriptor_template); -} - -// Sets any necessary message_type and enum_type attributes -// for the Python version of |field|. -// -// containing_type may be NULL, in which case this is a module-level field. -// -// python_dict_name is the name of the Python dict where we should -// look the field up in the containing type. (e.g., fields_by_name -// or extensions_by_name). We ignore python_dict_name if containing_type -// is NULL. -void Generator::FixForeignFieldsInField(const Descriptor* containing_type, - const FieldDescriptor& field, - const string& python_dict_name) const { - const string field_referencing_expression = FieldReferencingExpression( - containing_type, field, python_dict_name); - map m; - m["field_ref"] = field_referencing_expression; - const Descriptor* foreign_message_type = field.message_type(); - if (foreign_message_type) { - m["foreign_type"] = ModuleLevelDescriptorName(*foreign_message_type); - printer_->Print(m, "$field_ref$.message_type = $foreign_type$\n"); - } - const EnumDescriptor* enum_type = field.enum_type(); - if (enum_type) { - m["enum_type"] = ModuleLevelDescriptorName(*enum_type); - printer_->Print(m, "$field_ref$.enum_type = $enum_type$\n"); - } -} - -// Returns the module-level expression for the given FieldDescriptor. -// Only works for fields in the .proto file this Generator is generating for. -// -// containing_type may be NULL, in which case this is a module-level field. -// -// python_dict_name is the name of the Python dict where we should -// look the field up in the containing type. (e.g., fields_by_name -// or extensions_by_name). We ignore python_dict_name if containing_type -// is NULL. -string Generator::FieldReferencingExpression( - const Descriptor* containing_type, - const FieldDescriptor& field, - const string& python_dict_name) const { - // We should only ever be looking up fields in the current file. - // The only things we refer to from other files are message descriptors. - GOOGLE_CHECK_EQ(field.file(), file_) << field.file()->name() << " vs. " - << file_->name(); - if (!containing_type) { - return field.name(); - } - return strings::Substitute( - "$0.$1['$2']", - ModuleLevelDescriptorName(*containing_type), - python_dict_name, field.name()); -} - -// Prints containing_type for nested descriptors or enum descriptors. -template -void Generator::FixContainingTypeInDescriptor( - const DescriptorT& descriptor, - const Descriptor* containing_descriptor) const { - if (containing_descriptor != NULL) { - const string nested_name = ModuleLevelDescriptorName(descriptor); - const string parent_name = ModuleLevelDescriptorName( - *containing_descriptor); - printer_->Print( - "$nested_name$.containing_type = $parent_name$;\n", - "nested_name", nested_name, - "parent_name", parent_name); - } -} - -// Prints statements setting the message_type and enum_type fields in the -// Python descriptor objects we've already output in ths file. We must -// do this in a separate step due to circular references (otherwise, we'd -// just set everything in the initial assignment statements). -void Generator::FixForeignFieldsInDescriptors() const { - for (int i = 0; i < file_->message_type_count(); ++i) { - FixForeignFieldsInDescriptor(*file_->message_type(i), NULL); - } - for (int i = 0; i < file_->message_type_count(); ++i) { - AddMessageToFileDescriptor(*file_->message_type(i)); - } - printer_->Print("\n"); -} - -// We need to not only set any necessary message_type fields, but -// also need to call RegisterExtension() on each message we're -// extending. -void Generator::FixForeignFieldsInExtensions() const { - // Top-level extensions. - for (int i = 0; i < file_->extension_count(); ++i) { - FixForeignFieldsInExtension(*file_->extension(i)); - } - // Nested extensions. - for (int i = 0; i < file_->message_type_count(); ++i) { - FixForeignFieldsInNestedExtensions(*file_->message_type(i)); - } - printer_->Print("\n"); -} - -void Generator::FixForeignFieldsInExtension( - const FieldDescriptor& extension_field) const { - GOOGLE_CHECK(extension_field.is_extension()); - // extension_scope() will be NULL for top-level extensions, which is - // exactly what FixForeignFieldsInField() wants. - FixForeignFieldsInField(extension_field.extension_scope(), extension_field, - "extensions_by_name"); - - map m; - // Confusingly, for FieldDescriptors that happen to be extensions, - // containing_type() means "extended type." - // On the other hand, extension_scope() will give us what we normally - // mean by containing_type(). - m["extended_message_class"] = ModuleLevelMessageName( - *extension_field.containing_type()); - m["field"] = FieldReferencingExpression(extension_field.extension_scope(), - extension_field, - "extensions_by_name"); - printer_->Print(m, "$extended_message_class$.RegisterExtension($field$)\n"); -} - -void Generator::FixForeignFieldsInNestedExtensions( - const Descriptor& descriptor) const { - // Recursively fix up extensions in all nested types. - for (int i = 0; i < descriptor.nested_type_count(); ++i) { - FixForeignFieldsInNestedExtensions(*descriptor.nested_type(i)); - } - // Fix up extensions directly contained within this type. - for (int i = 0; i < descriptor.extension_count(); ++i) { - FixForeignFieldsInExtension(*descriptor.extension(i)); - } -} - -// Returns a Python expression that instantiates a Python EnumValueDescriptor -// object for the given C++ descriptor. -void Generator::PrintEnumValueDescriptor( - const EnumValueDescriptor& descriptor) const { - // TODO(robinson): Fix up EnumValueDescriptor "type" fields. - // More circular references. ::sigh:: - string options_string; - descriptor.options().SerializeToString(&options_string); - map m; - m["name"] = descriptor.name(); - m["index"] = SimpleItoa(descriptor.index()); - m["number"] = SimpleItoa(descriptor.number()); - m["options"] = OptionsValue("EnumValueOptions", options_string); - printer_->Print( - m, - "_descriptor.EnumValueDescriptor(\n" - " name='$name$', index=$index$, number=$number$,\n" - " options=$options$,\n" - " type=None)"); -} - -// Returns a Python expression that calls descriptor._ParseOptions using -// the given descriptor class name and serialized options protobuf string. -string Generator::OptionsValue( - const string& class_name, const string& serialized_options) const { - if (serialized_options.length() == 0 || GeneratingDescriptorProto()) { - return "None"; - } else { - string full_class_name = "descriptor_pb2." + class_name; - return "_descriptor._ParseOptions(" + full_class_name + "(), '" - + CEscape(serialized_options)+ "')"; - } -} - -// Prints an expression for a Python FieldDescriptor for |field|. -void Generator::PrintFieldDescriptor( - const FieldDescriptor& field, bool is_extension) const { - string options_string; - field.options().SerializeToString(&options_string); - map m; - m["name"] = field.name(); - m["full_name"] = field.full_name(); - m["index"] = SimpleItoa(field.index()); - m["number"] = SimpleItoa(field.number()); - m["type"] = SimpleItoa(field.type()); - m["cpp_type"] = SimpleItoa(field.cpp_type()); - m["label"] = SimpleItoa(field.label()); - m["has_default_value"] = field.has_default_value() ? "True" : "False"; - m["default_value"] = StringifyDefaultValue(field); - m["is_extension"] = is_extension ? "True" : "False"; - m["options"] = OptionsValue("FieldOptions", options_string); - // We always set message_type and enum_type to None at this point, and then - // these fields in correctly after all referenced descriptors have been - // defined and/or imported (see FixForeignFieldsInDescriptors()). - const char field_descriptor_decl[] = - "_descriptor.FieldDescriptor(\n" - " name='$name$', full_name='$full_name$', index=$index$,\n" - " number=$number$, type=$type$, cpp_type=$cpp_type$, label=$label$,\n" - " has_default_value=$has_default_value$, default_value=$default_value$,\n" - " message_type=None, enum_type=None, containing_type=None,\n" - " is_extension=$is_extension$, extension_scope=None,\n" - " options=$options$)"; - printer_->Print(m, field_descriptor_decl); -} - -// Helper for Print{Fields,Extensions}InDescriptor(). -void Generator::PrintFieldDescriptorsInDescriptor( - const Descriptor& message_descriptor, - bool is_extension, - const string& list_variable_name, - int (Descriptor::*CountFn)() const, - const FieldDescriptor* (Descriptor::*GetterFn)(int) const) const { - printer_->Print("$list$=[\n", "list", list_variable_name); - printer_->Indent(); - for (int i = 0; i < (message_descriptor.*CountFn)(); ++i) { - PrintFieldDescriptor(*(message_descriptor.*GetterFn)(i), - is_extension); - printer_->Print(",\n"); - } - printer_->Outdent(); - printer_->Print("],\n"); -} - -// Prints a statement assigning "fields" to a list of Python FieldDescriptors, -// one for each field present in message_descriptor. -void Generator::PrintFieldsInDescriptor( - const Descriptor& message_descriptor) const { - const bool is_extension = false; - PrintFieldDescriptorsInDescriptor( - message_descriptor, is_extension, "fields", - &Descriptor::field_count, &Descriptor::field); -} - -// Prints a statement assigning "extensions" to a list of Python -// FieldDescriptors, one for each extension present in message_descriptor. -void Generator::PrintExtensionsInDescriptor( - const Descriptor& message_descriptor) const { - const bool is_extension = true; - PrintFieldDescriptorsInDescriptor( - message_descriptor, is_extension, "extensions", - &Descriptor::extension_count, &Descriptor::extension); -} - -bool Generator::GeneratingDescriptorProto() const { - return file_->name() == "google/protobuf/descriptor.proto"; -} - -// Returns the unique Python module-level identifier given to a descriptor. -// This name is module-qualified iff the given descriptor describes an -// entity that doesn't come from the current file. -template -string Generator::ModuleLevelDescriptorName( - const DescriptorT& descriptor) const { - // FIXME(robinson): - // We currently don't worry about collisions with underscores in the type - // names, so these would collide in nasty ways if found in the same file: - // OuterProto.ProtoA.ProtoB - // OuterProto_ProtoA.ProtoB # Underscore instead of period. - // As would these: - // OuterProto.ProtoA_.ProtoB - // OuterProto.ProtoA._ProtoB # Leading vs. trailing underscore. - // (Contrived, but certainly possible). - // - // The C++ implementation doesn't guard against this either. Leaving - // it for now... - string name = NamePrefixedWithNestedTypes(descriptor, "_"); - UpperString(&name); - // Module-private for now. Easy to make public later; almost impossible - // to make private later. - name = "_" + name; - // We now have the name relative to its own module. Also qualify with - // the module name iff this descriptor is from a different .proto file. - if (descriptor.file() != file_) { - name = ModuleName(descriptor.file()->name()) + "." + name; - } - return name; -} - -// Returns the name of the message class itself, not the descriptor. -// Like ModuleLevelDescriptorName(), module-qualifies the name iff -// the given descriptor describes an entity that doesn't come from -// the current file. -string Generator::ModuleLevelMessageName(const Descriptor& descriptor) const { - string name = NamePrefixedWithNestedTypes(descriptor, "."); - if (descriptor.file() != file_) { - name = ModuleName(descriptor.file()->name()) + "." + name; - } - return name; -} - -// Returns the unique Python module-level identifier given to a service -// descriptor. -string Generator::ModuleLevelServiceDescriptorName( - const ServiceDescriptor& descriptor) const { - string name = descriptor.name(); - UpperString(&name); - name = "_" + name; - if (descriptor.file() != file_) { - name = ModuleName(descriptor.file()->name()) + "." + name; - } - return name; -} - -// Prints standard constructor arguments serialized_start and serialized_end. -// Args: -// descriptor: The cpp descriptor to have a serialized reference. -// proto: A proto -// Example printer output: -// serialized_start=41, -// serialized_end=43, -// -template -void Generator::PrintSerializedPbInterval( - const DescriptorT& descriptor, DescriptorProtoT& proto) const { - descriptor.CopyTo(&proto); - string sp; - proto.SerializeToString(&sp); - int offset = file_descriptor_serialized_.find(sp); - GOOGLE_CHECK_GE(offset, 0); - - printer_->Print("serialized_start=$serialized_start$,\n" - "serialized_end=$serialized_end$,\n", - "serialized_start", SimpleItoa(offset), - "serialized_end", SimpleItoa(offset + sp.size())); -} - -namespace { -void PrintDescriptorOptionsFixingCode(const string& descriptor, - const string& options, - io::Printer* printer) { - // TODO(xiaofeng): I have added a method _SetOptions() to DescriptorBase - // in proto2 python runtime but it couldn't be used here because appengine - // uses a snapshot version of the library in which the new method is not - // yet present. After appengine has synced their runtime library, the code - // below should be cleaned up to use _SetOptions(). - printer->Print( - "$descriptor$.has_options = True\n" - "$descriptor$._options = $options$\n", - "descriptor", descriptor, "options", options); -} -} // namespace - -// Prints expressions that set the options field of all descriptors. -void Generator::FixAllDescriptorOptions() const { - // Prints an expression that sets the file descriptor's options. - string file_options = OptionsValue( - "FileOptions", file_->options().SerializeAsString()); - if (file_options != "None") { - PrintDescriptorOptionsFixingCode(kDescriptorKey, file_options, printer_); - } - // Prints expressions that set the options for all top level enums. - for (int i = 0; i < file_->enum_type_count(); ++i) { - const EnumDescriptor& enum_descriptor = *file_->enum_type(i); - FixOptionsForEnum(enum_descriptor); - } - // Prints expressions that set the options for all top level extensions. - for (int i = 0; i < file_->extension_count(); ++i) { - const FieldDescriptor& field = *file_->extension(i); - FixOptionsForField(field); - } - // Prints expressions that set the options for all messages, nested enums, - // nested extensions and message fields. - for (int i = 0; i < file_->message_type_count(); ++i) { - FixOptionsForMessage(*file_->message_type(i)); - } -} - -// Prints expressions that set the options for an enum descriptor and its -// value descriptors. -void Generator::FixOptionsForEnum(const EnumDescriptor& enum_descriptor) const { - string descriptor_name = ModuleLevelDescriptorName(enum_descriptor); - string enum_options = OptionsValue( - "EnumOptions", enum_descriptor.options().SerializeAsString()); - if (enum_options != "None") { - PrintDescriptorOptionsFixingCode(descriptor_name, enum_options, printer_); - } - for (int i = 0; i < enum_descriptor.value_count(); ++i) { - const EnumValueDescriptor& value_descriptor = *enum_descriptor.value(i); - string value_options = OptionsValue( - "EnumValueOptions", value_descriptor.options().SerializeAsString()); - if (value_options != "None") { - PrintDescriptorOptionsFixingCode( - StringPrintf("%s.values_by_name[\"%s\"]", descriptor_name.c_str(), - value_descriptor.name().c_str()), - value_options, printer_); - } - } -} - -// Prints expressions that set the options for field descriptors (including -// extensions). -void Generator::FixOptionsForField( - const FieldDescriptor& field) const { - string field_options = OptionsValue( - "FieldOptions", field.options().SerializeAsString()); - if (field_options != "None") { - string field_name; - if (field.is_extension()) { - if (field.extension_scope() == NULL) { - // Top level extensions. - field_name = field.name(); - } else { - field_name = FieldReferencingExpression( - field.extension_scope(), field, "extensions_by_name"); - } - } else { - field_name = FieldReferencingExpression( - field.containing_type(), field, "fields_by_name"); - } - PrintDescriptorOptionsFixingCode(field_name, field_options, printer_); - } -} - -// Prints expressions that set the options for a message and all its inner -// types (nested messages, nested enums, extensions, fields). -void Generator::FixOptionsForMessage(const Descriptor& descriptor) const { - // Nested messages. - for (int i = 0; i < descriptor.nested_type_count(); ++i) { - FixOptionsForMessage(*descriptor.nested_type(i)); - } - // Enums. - for (int i = 0; i < descriptor.enum_type_count(); ++i) { - FixOptionsForEnum(*descriptor.enum_type(i)); - } - // Fields. - for (int i = 0; i < descriptor.field_count(); ++i) { - const FieldDescriptor& field = *descriptor.field(i); - FixOptionsForField(field); - } - // Extensions. - for (int i = 0; i < descriptor.extension_count(); ++i) { - const FieldDescriptor& field = *descriptor.extension(i); - FixOptionsForField(field); - } - // Message option for this message. - string message_options = OptionsValue( - "MessageOptions", descriptor.options().SerializeAsString()); - if (message_options != "None") { - string descriptor_name = ModuleLevelDescriptorName(descriptor); - PrintDescriptorOptionsFixingCode(descriptor_name, - message_options, - printer_); - } -} - -} // namespace python -} // namespace compiler -} // namespace protobuf -} // namespace google diff --git a/modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/python/python_generator.h b/modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/python/python_generator.h deleted file mode 100644 index a3f22cee6..000000000 --- a/modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/python/python_generator.h +++ /dev/null @@ -1,161 +0,0 @@ -// Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// http://code.google.com/p/protobuf/ -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -// Author: robinson@google.com (Will Robinson) -// -// Generates Python code for a given .proto file. - -#ifndef GOOGLE_PROTOBUF_COMPILER_PYTHON_GENERATOR_H__ -#define GOOGLE_PROTOBUF_COMPILER_PYTHON_GENERATOR_H__ - -#include - -#include -#include - -namespace google { -namespace protobuf { - -class Descriptor; -class EnumDescriptor; -class EnumValueDescriptor; -class FieldDescriptor; -class ServiceDescriptor; - -namespace io { class Printer; } - -namespace compiler { -namespace python { - -// CodeGenerator implementation for generated Python protocol buffer classes. -// If you create your own protocol compiler binary and you want it to support -// Python output, you can do so by registering an instance of this -// CodeGenerator with the CommandLineInterface in your main() function. -class LIBPROTOC_EXPORT Generator : public CodeGenerator { - public: - Generator(); - virtual ~Generator(); - - // CodeGenerator methods. - virtual bool Generate(const FileDescriptor* file, - const string& parameter, - GeneratorContext* generator_context, - string* error) const; - - private: - void PrintImports() const; - void PrintFileDescriptor() const; - void PrintTopLevelEnums() const; - void PrintAllNestedEnumsInFile() const; - void PrintNestedEnums(const Descriptor& descriptor) const; - void PrintEnum(const EnumDescriptor& enum_descriptor) const; - - void PrintTopLevelExtensions() const; - - void PrintFieldDescriptor( - const FieldDescriptor& field, bool is_extension) const; - void PrintFieldDescriptorsInDescriptor( - const Descriptor& message_descriptor, - bool is_extension, - const string& list_variable_name, - int (Descriptor::*CountFn)() const, - const FieldDescriptor* (Descriptor::*GetterFn)(int) const) const; - void PrintFieldsInDescriptor(const Descriptor& message_descriptor) const; - void PrintExtensionsInDescriptor(const Descriptor& message_descriptor) const; - void PrintMessageDescriptors() const; - void PrintDescriptor(const Descriptor& message_descriptor) const; - void PrintNestedDescriptors(const Descriptor& containing_descriptor) const; - - void PrintMessages() const; - void PrintMessage(const Descriptor& message_descriptor) const; - void PrintNestedMessages(const Descriptor& containing_descriptor) const; - - void FixForeignFieldsInDescriptors() const; - void FixForeignFieldsInDescriptor( - const Descriptor& descriptor, - const Descriptor* containing_descriptor) const; - void FixForeignFieldsInField(const Descriptor* containing_type, - const FieldDescriptor& field, - const string& python_dict_name) const; - void AddMessageToFileDescriptor(const Descriptor& descriptor) const; - string FieldReferencingExpression(const Descriptor* containing_type, - const FieldDescriptor& field, - const string& python_dict_name) const; - template - void FixContainingTypeInDescriptor( - const DescriptorT& descriptor, - const Descriptor* containing_descriptor) const; - - void FixForeignFieldsInExtensions() const; - void FixForeignFieldsInExtension( - const FieldDescriptor& extension_field) const; - void FixForeignFieldsInNestedExtensions(const Descriptor& descriptor) const; - - void PrintServices() const; - void PrintServiceDescriptor(const ServiceDescriptor& descriptor) const; - void PrintServiceClass(const ServiceDescriptor& descriptor) const; - void PrintServiceStub(const ServiceDescriptor& descriptor) const; - - void PrintEnumValueDescriptor(const EnumValueDescriptor& descriptor) const; - string OptionsValue(const string& class_name, - const string& serialized_options) const; - bool GeneratingDescriptorProto() const; - - template - string ModuleLevelDescriptorName(const DescriptorT& descriptor) const; - string ModuleLevelMessageName(const Descriptor& descriptor) const; - string ModuleLevelServiceDescriptorName( - const ServiceDescriptor& descriptor) const; - - template - void PrintSerializedPbInterval( - const DescriptorT& descriptor, DescriptorProtoT& proto) const; - - void FixAllDescriptorOptions() const; - void FixOptionsForField(const FieldDescriptor& field) const; - void FixOptionsForEnum(const EnumDescriptor& descriptor) const; - void FixOptionsForMessage(const Descriptor& descriptor) const; - - // Very coarse-grained lock to ensure that Generate() is reentrant. - // Guards file_, printer_ and file_descriptor_serialized_. - mutable Mutex mutex_; - mutable const FileDescriptor* file_; // Set in Generate(). Under mutex_. - mutable string file_descriptor_serialized_; - mutable io::Printer* printer_; // Set in Generate(). Under mutex_. - - GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(Generator); -}; - -} // namespace python -} // namespace compiler -} // namespace protobuf - -} // namespace google -#endif // GOOGLE_PROTOBUF_COMPILER_PYTHON_GENERATOR_H__ diff --git a/modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/python/python_plugin_unittest.cc b/modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/python/python_plugin_unittest.cc deleted file mode 100644 index da619ad3e..000000000 --- a/modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/python/python_plugin_unittest.cc +++ /dev/null @@ -1,116 +0,0 @@ -// Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// http://code.google.com/p/protobuf/ -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -// Author: kenton@google.com (Kenton Varda) -// -// TODO(kenton): Share code with the versions of this test in other languages? -// It seemed like parameterizing it would add more complexity than it is -// worth. - -#include -#include -#include -#include - -#include -#include -#include - -namespace google { -namespace protobuf { -namespace compiler { -namespace python { -namespace { - -class TestGenerator : public CodeGenerator { - public: - TestGenerator() {} - ~TestGenerator() {} - - virtual bool Generate(const FileDescriptor* file, - const string& parameter, - GeneratorContext* context, - string* error) const { - TryInsert("test_pb2.py", "imports", context); - TryInsert("test_pb2.py", "module_scope", context); - TryInsert("test_pb2.py", "class_scope:foo.Bar", context); - TryInsert("test_pb2.py", "class_scope:foo.Bar.Baz", context); - return true; - } - - void TryInsert(const string& filename, const string& insertion_point, - GeneratorContext* context) const { - scoped_ptr output( - context->OpenForInsert(filename, insertion_point)); - io::Printer printer(output.get(), '$'); - printer.Print("// inserted $name$\n", "name", insertion_point); - } -}; - -// This test verifies that all the expected insertion points exist. It does -// not verify that they are correctly-placed; that would require actually -// compiling the output which is a bit more than I care to do for this test. -TEST(PythonPluginTest, PluginTest) { - File::WriteStringToFileOrDie( - "syntax = \"proto2\";\n" - "package foo;\n" - "message Bar {\n" - " message Baz {}\n" - "}\n", - TestTempDir() + "/test.proto"); - - google::protobuf::compiler::CommandLineInterface cli; - cli.SetInputsAreProtoPathRelative(true); - - python::Generator python_generator; - TestGenerator test_generator; - cli.RegisterGenerator("--python_out", &python_generator, ""); - cli.RegisterGenerator("--test_out", &test_generator, ""); - - string proto_path = "-I" + TestTempDir(); - string python_out = "--python_out=" + TestTempDir(); - string test_out = "--test_out=" + TestTempDir(); - - const char* argv[] = { - "protoc", - proto_path.c_str(), - python_out.c_str(), - test_out.c_str(), - "test.proto" - }; - - EXPECT_EQ(0, cli.Run(5, argv)); -} - -} // namespace -} // namespace python -} // namespace compiler -} // namespace protobuf -} // namespace google diff --git a/modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/subprocess.cc b/modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/subprocess.cc deleted file mode 100644 index 67da120d6..000000000 --- a/modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/subprocess.cc +++ /dev/null @@ -1,463 +0,0 @@ -// Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// http://code.google.com/p/protobuf/ -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -// Author: kenton@google.com (Kenton Varda) - -#include - -#include -#include - -#ifndef _WIN32 -#include -#include -#include -#include -#endif - -#include -#include -#include - -namespace google { -namespace protobuf { -namespace compiler { - -#ifdef _WIN32 - -static void CloseHandleOrDie(HANDLE handle) { - if (!CloseHandle(handle)) { - GOOGLE_LOG(FATAL) << "CloseHandle: " - << Subprocess::Win32ErrorMessage(GetLastError()); - } -} - -Subprocess::Subprocess() - : process_start_error_(ERROR_SUCCESS), - child_handle_(NULL), child_stdin_(NULL), child_stdout_(NULL) {} - -Subprocess::~Subprocess() { - if (child_stdin_ != NULL) { - CloseHandleOrDie(child_stdin_); - } - if (child_stdout_ != NULL) { - CloseHandleOrDie(child_stdout_); - } -} - -void Subprocess::Start(const string& program, SearchMode search_mode) { - // Create the pipes. - HANDLE stdin_pipe_read; - HANDLE stdin_pipe_write; - HANDLE stdout_pipe_read; - HANDLE stdout_pipe_write; - - if (!CreatePipe(&stdin_pipe_read, &stdin_pipe_write, NULL, 0)) { - GOOGLE_LOG(FATAL) << "CreatePipe: " << Win32ErrorMessage(GetLastError()); - } - if (!CreatePipe(&stdout_pipe_read, &stdout_pipe_write, NULL, 0)) { - GOOGLE_LOG(FATAL) << "CreatePipe: " << Win32ErrorMessage(GetLastError()); - } - - // Make child side of the pipes inheritable. - if (!SetHandleInformation(stdin_pipe_read, - HANDLE_FLAG_INHERIT, HANDLE_FLAG_INHERIT)) { - GOOGLE_LOG(FATAL) << "SetHandleInformation: " - << Win32ErrorMessage(GetLastError()); - } - if (!SetHandleInformation(stdout_pipe_write, - HANDLE_FLAG_INHERIT, HANDLE_FLAG_INHERIT)) { - GOOGLE_LOG(FATAL) << "SetHandleInformation: " - << Win32ErrorMessage(GetLastError()); - } - - // Setup STARTUPINFO to redirect handles. - STARTUPINFOA startup_info; - ZeroMemory(&startup_info, sizeof(startup_info)); - startup_info.cb = sizeof(startup_info); - startup_info.dwFlags = STARTF_USESTDHANDLES; - startup_info.hStdInput = stdin_pipe_read; - startup_info.hStdOutput = stdout_pipe_write; - startup_info.hStdError = GetStdHandle(STD_ERROR_HANDLE); - - if (startup_info.hStdError == INVALID_HANDLE_VALUE) { - GOOGLE_LOG(FATAL) << "GetStdHandle: " - << Win32ErrorMessage(GetLastError()); - } - - // CreateProcess() mutates its second parameter. WTF? - char* name_copy = strdup(program.c_str()); - - // Create the process. - PROCESS_INFORMATION process_info; - - if (CreateProcessA((search_mode == SEARCH_PATH) ? NULL : program.c_str(), - (search_mode == SEARCH_PATH) ? name_copy : NULL, - NULL, // process security attributes - NULL, // thread security attributes - TRUE, // inherit handles? - 0, // obscure creation flags - NULL, // environment (inherit from parent) - NULL, // current directory (inherit from parent) - &startup_info, - &process_info)) { - child_handle_ = process_info.hProcess; - CloseHandleOrDie(process_info.hThread); - child_stdin_ = stdin_pipe_write; - child_stdout_ = stdout_pipe_read; - } else { - process_start_error_ = GetLastError(); - CloseHandleOrDie(stdin_pipe_write); - CloseHandleOrDie(stdout_pipe_read); - } - - CloseHandleOrDie(stdin_pipe_read); - CloseHandleOrDie(stdout_pipe_write); - free(name_copy); -} - -bool Subprocess::Communicate(const Message& input, Message* output, - string* error) { - if (process_start_error_ != ERROR_SUCCESS) { - *error = Win32ErrorMessage(process_start_error_); - return false; - } - - GOOGLE_CHECK(child_handle_ != NULL) << "Must call Start() first."; - - string input_data = input.SerializeAsString(); - string output_data; - - int input_pos = 0; - - while (child_stdout_ != NULL) { - HANDLE handles[2]; - int handle_count = 0; - - if (child_stdin_ != NULL) { - handles[handle_count++] = child_stdin_; - } - if (child_stdout_ != NULL) { - handles[handle_count++] = child_stdout_; - } - - DWORD wait_result = - WaitForMultipleObjects(handle_count, handles, FALSE, INFINITE); - - HANDLE signaled_handle; - if (wait_result >= WAIT_OBJECT_0 && - wait_result < WAIT_OBJECT_0 + handle_count) { - signaled_handle = handles[wait_result - WAIT_OBJECT_0]; - } else if (wait_result == WAIT_FAILED) { - GOOGLE_LOG(FATAL) << "WaitForMultipleObjects: " - << Win32ErrorMessage(GetLastError()); - } else { - GOOGLE_LOG(FATAL) << "WaitForMultipleObjects: Unexpected return code: " - << wait_result; - } - - if (signaled_handle == child_stdin_) { - DWORD n; - if (!WriteFile(child_stdin_, - input_data.data() + input_pos, - input_data.size() - input_pos, - &n, NULL)) { - // Child closed pipe. Presumably it will report an error later. - // Pretend we're done for now. - input_pos = input_data.size(); - } else { - input_pos += n; - } - - if (input_pos == input_data.size()) { - // We're done writing. Close. - CloseHandleOrDie(child_stdin_); - child_stdin_ = NULL; - } - } else if (signaled_handle == child_stdout_) { - char buffer[4096]; - DWORD n; - - if (!ReadFile(child_stdout_, buffer, sizeof(buffer), &n, NULL)) { - // We're done reading. Close. - CloseHandleOrDie(child_stdout_); - child_stdout_ = NULL; - } else { - output_data.append(buffer, n); - } - } - } - - if (child_stdin_ != NULL) { - // Child did not finish reading input before it closed the output. - // Presumably it exited with an error. - CloseHandleOrDie(child_stdin_); - child_stdin_ = NULL; - } - - DWORD wait_result = WaitForSingleObject(child_handle_, INFINITE); - - if (wait_result == WAIT_FAILED) { - GOOGLE_LOG(FATAL) << "WaitForSingleObject: " - << Win32ErrorMessage(GetLastError()); - } else if (wait_result != WAIT_OBJECT_0) { - GOOGLE_LOG(FATAL) << "WaitForSingleObject: Unexpected return code: " - << wait_result; - } - - DWORD exit_code; - if (!GetExitCodeProcess(child_handle_, &exit_code)) { - GOOGLE_LOG(FATAL) << "GetExitCodeProcess: " - << Win32ErrorMessage(GetLastError()); - } - - CloseHandleOrDie(child_handle_); - child_handle_ = NULL; - - if (exit_code != 0) { - *error = strings::Substitute( - "Plugin failed with status code $0.", exit_code); - return false; - } - - if (!output->ParseFromString(output_data)) { - *error = "Plugin output is unparseable: " + CEscape(output_data); - return false; - } - - return true; -} - -string Subprocess::Win32ErrorMessage(DWORD error_code) { - char* message; - - // WTF? - FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | - FORMAT_MESSAGE_FROM_SYSTEM | - FORMAT_MESSAGE_IGNORE_INSERTS, - NULL, error_code, 0, - (LPTSTR)&message, // NOT A BUG! - 0, NULL); - - string result = message; - LocalFree(message); - return result; -} - -// =================================================================== - -#else // _WIN32 - -Subprocess::Subprocess() - : child_pid_(-1), child_stdin_(-1), child_stdout_(-1) {} - -Subprocess::~Subprocess() { - if (child_stdin_ != -1) { - close(child_stdin_); - } - if (child_stdout_ != -1) { - close(child_stdout_); - } -} - -void Subprocess::Start(const string& program, SearchMode search_mode) { - // Note that we assume that there are no other threads, thus we don't have to - // do crazy stuff like using socket pairs or avoiding libc locks. - - // [0] is read end, [1] is write end. - int stdin_pipe[2]; - int stdout_pipe[2]; - - GOOGLE_CHECK(pipe(stdin_pipe) != -1); - GOOGLE_CHECK(pipe(stdout_pipe) != -1); - - char* argv[2] = { strdup(program.c_str()), NULL }; - - child_pid_ = fork(); - if (child_pid_ == -1) { - GOOGLE_LOG(FATAL) << "fork: " << strerror(errno); - } else if (child_pid_ == 0) { - // We are the child. - dup2(stdin_pipe[0], STDIN_FILENO); - dup2(stdout_pipe[1], STDOUT_FILENO); - - close(stdin_pipe[0]); - close(stdin_pipe[1]); - close(stdout_pipe[0]); - close(stdout_pipe[1]); - - switch (search_mode) { - case SEARCH_PATH: - execvp(argv[0], argv); - break; - case EXACT_NAME: - execv(argv[0], argv); - break; - } - - // Write directly to STDERR_FILENO to avoid stdio code paths that may do - // stuff that is unsafe here. - int ignored; - ignored = write(STDERR_FILENO, argv[0], strlen(argv[0])); - const char* message = ": program not found or is not executable\n"; - ignored = write(STDERR_FILENO, message, strlen(message)); - (void) ignored; - - // Must use _exit() rather than exit() to avoid flushing output buffers - // that will also be flushed by the parent. - _exit(1); - } else { - free(argv[0]); - - close(stdin_pipe[0]); - close(stdout_pipe[1]); - - child_stdin_ = stdin_pipe[1]; - child_stdout_ = stdout_pipe[0]; - } -} - -bool Subprocess::Communicate(const Message& input, Message* output, - string* error) { - - GOOGLE_CHECK_NE(child_stdin_, -1) << "Must call Start() first."; - - // The "sighandler_t" typedef is GNU-specific, so define our own. - typedef void SignalHandler(int); - - // Make sure SIGPIPE is disabled so that if the child dies it doesn't kill us. - SignalHandler* old_pipe_handler = signal(SIGPIPE, SIG_IGN); - - string input_data = input.SerializeAsString(); - string output_data; - - int input_pos = 0; - int max_fd = max(child_stdin_, child_stdout_); - - while (child_stdout_ != -1) { - fd_set read_fds; - fd_set write_fds; - FD_ZERO(&read_fds); - FD_ZERO(&write_fds); - if (child_stdout_ != -1) { - FD_SET(child_stdout_, &read_fds); - } - if (child_stdin_ != -1) { - FD_SET(child_stdin_, &write_fds); - } - - if (select(max_fd + 1, &read_fds, &write_fds, NULL, NULL) < 0) { - if (errno == EINTR) { - // Interrupted by signal. Try again. - continue; - } else { - GOOGLE_LOG(FATAL) << "select: " << strerror(errno); - } - } - - if (child_stdin_ != -1 && FD_ISSET(child_stdin_, &write_fds)) { - int n = write(child_stdin_, input_data.data() + input_pos, - input_data.size() - input_pos); - if (n < 0) { - // Child closed pipe. Presumably it will report an error later. - // Pretend we're done for now. - input_pos = input_data.size(); - } else { - input_pos += n; - } - - if (input_pos == input_data.size()) { - // We're done writing. Close. - close(child_stdin_); - child_stdin_ = -1; - } - } - - if (child_stdout_ != -1 && FD_ISSET(child_stdout_, &read_fds)) { - char buffer[4096]; - int n = read(child_stdout_, buffer, sizeof(buffer)); - - if (n > 0) { - output_data.append(buffer, n); - } else { - // We're done reading. Close. - close(child_stdout_); - child_stdout_ = -1; - } - } - } - - if (child_stdin_ != -1) { - // Child did not finish reading input before it closed the output. - // Presumably it exited with an error. - close(child_stdin_); - child_stdin_ = -1; - } - - int status; - while (waitpid(child_pid_, &status, 0) == -1) { - if (errno != EINTR) { - GOOGLE_LOG(FATAL) << "waitpid: " << strerror(errno); - } - } - - // Restore SIGPIPE handling. - signal(SIGPIPE, old_pipe_handler); - - if (WIFEXITED(status)) { - if (WEXITSTATUS(status) != 0) { - int error_code = WEXITSTATUS(status); - *error = strings::Substitute( - "Plugin failed with status code $0.", error_code); - return false; - } - } else if (WIFSIGNALED(status)) { - int signal = WTERMSIG(status); - *error = strings::Substitute( - "Plugin killed by signal $0.", signal); - return false; - } else { - *error = "Neither WEXITSTATUS nor WTERMSIG is true?"; - return false; - } - - if (!output->ParseFromString(output_data)) { - *error = "Plugin output is unparseable."; - return false; - } - - return true; -} - -#endif // !_WIN32 - -} // namespace compiler -} // namespace protobuf -} // namespace google diff --git a/modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/subprocess.h b/modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/subprocess.h deleted file mode 100644 index 005649640..000000000 --- a/modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/subprocess.h +++ /dev/null @@ -1,108 +0,0 @@ -// Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// http://code.google.com/p/protobuf/ -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -// Author: kenton@google.com (Kenton Varda) - -#ifndef GOOGLE_PROTOBUF_COMPILER_SUBPROCESS_H__ -#define GOOGLE_PROTOBUF_COMPILER_SUBPROCESS_H__ - -#ifdef _WIN32 -#define WIN32_LEAN_AND_MEAN // right... -#include -#else // _WIN32 -#include -#include -#endif // !_WIN32 -#include - -#include - - -namespace google { -namespace protobuf { - -class Message; - -namespace compiler { - -// Utility class for launching sub-processes. -class LIBPROTOC_EXPORT Subprocess { - public: - Subprocess(); - ~Subprocess(); - - enum SearchMode { - SEARCH_PATH, // Use PATH environment variable. - EXACT_NAME // Program is an exact file name; don't use the PATH. - }; - - // Start the subprocess. Currently we don't provide a way to specify - // arguments as protoc plugins don't have any. - void Start(const string& program, SearchMode search_mode); - - // Serialize the input message and pipe it to the subprocess's stdin, then - // close the pipe. Meanwhile, read from the subprocess's stdout and parse - // the data into *output. All this is done carefully to avoid deadlocks. - // Returns true if successful. On any sort of error, returns false and sets - // *error to a description of the problem. - bool Communicate(const Message& input, Message* output, string* error); - -#ifdef _WIN32 - // Given an error code, returns a human-readable error message. This is - // defined here so that CommandLineInterface can share it. - static string Win32ErrorMessage(DWORD error_code); -#endif - - private: -#ifdef _WIN32 - DWORD process_start_error_; - HANDLE child_handle_; - - // The file handles for our end of the child's pipes. We close each and - // set it to NULL when no longer needed. - HANDLE child_stdin_; - HANDLE child_stdout_; - -#else // _WIN32 - pid_t child_pid_; - - // The file descriptors for our end of the child's pipes. We close each and - // set it to -1 when no longer needed. - int child_stdin_; - int child_stdout_; - -#endif // !_WIN32 -}; - -} // namespace compiler -} // namespace protobuf - -} // namespace google -#endif // GOOGLE_PROTOBUF_COMPILER_SUBPROCESS_H__ diff --git a/modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/test_plugin.cc b/modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/test_plugin.cc deleted file mode 100644 index 5cbbf3d9d..000000000 --- a/modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/test_plugin.cc +++ /dev/null @@ -1,51 +0,0 @@ -// Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// http://code.google.com/p/protobuf/ -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -// Author: kenton@google.com (Kenton Varda) -// -// This is a dummy code generator plugin used by -// command_line_interface_unittest. - -#include -#include -#include -#include -#include - -int main(int argc, char* argv[]) { -#ifdef _MSC_VER - // Don't print a silly message or stick a modal dialog box in my face, - // please. - _set_abort_behavior(0, ~0); -#endif // !_MSC_VER - - google::protobuf::compiler::MockCodeGenerator generator("test_plugin"); - return google::protobuf::compiler::PluginMain(argc, argv, &generator); -} diff --git a/modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/zip_output_unittest.sh b/modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/zip_output_unittest.sh deleted file mode 100644 index 3a024364d..000000000 --- a/modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/zip_output_unittest.sh +++ /dev/null @@ -1,91 +0,0 @@ -#!/bin/sh -# -# Protocol Buffers - Google's data interchange format -# Copyright 2009 Google Inc. All rights reserved. -# http://code.google.com/p/protobuf/ -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are -# met: -# -# * Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# * Redistributions in binary form must reproduce the above -# copyright notice, this list of conditions and the following disclaimer -# in the documentation and/or other materials provided with the -# distribution. -# * Neither the name of Google Inc. nor the names of its -# contributors may be used to endorse or promote products derived from -# this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -# Author: kenton@google.com (Kenton Varda) -# -# Test protoc's zip output mode. - -fail() { - echo "$@" >&2 - exit 1 -} - -TEST_TMPDIR=. -PROTOC=./protoc - -echo ' - syntax = "proto2"; - option java_multiple_files = true; - option java_package = "test.jar"; - option java_outer_classname = "Outer"; - message Foo {} - message Bar {} -' > $TEST_TMPDIR/testzip.proto - -$PROTOC \ - --cpp_out=$TEST_TMPDIR/testzip.zip --python_out=$TEST_TMPDIR/testzip.zip \ - --java_out=$TEST_TMPDIR/testzip.jar -I$TEST_TMPDIR testzip.proto \ - || fail 'protoc failed.' - -echo "Testing output to zip..." -if unzip -h > /dev/null; then - unzip -t $TEST_TMPDIR/testzip.zip > $TEST_TMPDIR/testzip.list || fail 'unzip failed.' - - grep 'testing: testzip\.pb\.cc *OK$' $TEST_TMPDIR/testzip.list > /dev/null \ - || fail 'testzip.pb.cc not found in output zip.' - grep 'testing: testzip\.pb\.h *OK$' $TEST_TMPDIR/testzip.list > /dev/null \ - || fail 'testzip.pb.h not found in output zip.' - grep 'testing: testzip_pb2\.py *OK$' $TEST_TMPDIR/testzip.list > /dev/null \ - || fail 'testzip_pb2.py not found in output zip.' - grep -i 'manifest' $TEST_TMPDIR/testzip.list > /dev/null \ - && fail 'Zip file contained manifest.' -else - echo "Warning: 'unzip' command not available. Skipping test." -fi - -echo "Testing output to jar..." -if jar c $TEST_TMPDIR/testzip.proto > /dev/null; then - jar tf $TEST_TMPDIR/testzip.jar > $TEST_TMPDIR/testzip.list || fail 'jar failed.' - - grep '^test/jar/Foo\.java$' $TEST_TMPDIR/testzip.list > /dev/null \ - || fail 'Foo.java not found in output jar.' - grep '^test/jar/Bar\.java$' $TEST_TMPDIR/testzip.list > /dev/null \ - || fail 'Bar.java not found in output jar.' - grep '^test/jar/Outer\.java$' $TEST_TMPDIR/testzip.list > /dev/null \ - || fail 'Outer.java not found in output jar.' - grep '^META-INF/MANIFEST\.MF$' $TEST_TMPDIR/testzip.list > /dev/null \ - || fail 'Manifest not found in output jar.' -else - echo "Warning: 'jar' command not available. Skipping test." -fi - -echo PASS diff --git a/modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/zip_writer.cc b/modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/zip_writer.cc deleted file mode 100644 index 65d735270..000000000 --- a/modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/zip_writer.cc +++ /dev/null @@ -1,218 +0,0 @@ -// Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// http://code.google.com/p/protobuf/ -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -// Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// http://code.google.com/p/protobuf/ -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -// Author: ambrose@google.com (Ambrose Feinstein), -// kenton@google.com (Kenton Varda) -// -// Based on http://www.pkware.com/documents/casestudies/APPNOTE.TXT - -#include -#include - -namespace google { -namespace protobuf { -namespace compiler { - -static const uint32 kCRC32Table[256] = { - 0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419, 0x706af48f, - 0xe963a535, 0x9e6495a3, 0x0edb8832, 0x79dcb8a4, 0xe0d5e91e, 0x97d2d988, - 0x09b64c2b, 0x7eb17cbd, 0xe7b82d07, 0x90bf1d91, 0x1db71064, 0x6ab020f2, - 0xf3b97148, 0x84be41de, 0x1adad47d, 0x6ddde4eb, 0xf4d4b551, 0x83d385c7, - 0x136c9856, 0x646ba8c0, 0xfd62f97a, 0x8a65c9ec, 0x14015c4f, 0x63066cd9, - 0xfa0f3d63, 0x8d080df5, 0x3b6e20c8, 0x4c69105e, 0xd56041e4, 0xa2677172, - 0x3c03e4d1, 0x4b04d447, 0xd20d85fd, 0xa50ab56b, 0x35b5a8fa, 0x42b2986c, - 0xdbbbc9d6, 0xacbcf940, 0x32d86ce3, 0x45df5c75, 0xdcd60dcf, 0xabd13d59, - 0x26d930ac, 0x51de003a, 0xc8d75180, 0xbfd06116, 0x21b4f4b5, 0x56b3c423, - 0xcfba9599, 0xb8bda50f, 0x2802b89e, 0x5f058808, 0xc60cd9b2, 0xb10be924, - 0x2f6f7c87, 0x58684c11, 0xc1611dab, 0xb6662d3d, 0x76dc4190, 0x01db7106, - 0x98d220bc, 0xefd5102a, 0x71b18589, 0x06b6b51f, 0x9fbfe4a5, 0xe8b8d433, - 0x7807c9a2, 0x0f00f934, 0x9609a88e, 0xe10e9818, 0x7f6a0dbb, 0x086d3d2d, - 0x91646c97, 0xe6635c01, 0x6b6b51f4, 0x1c6c6162, 0x856530d8, 0xf262004e, - 0x6c0695ed, 0x1b01a57b, 0x8208f4c1, 0xf50fc457, 0x65b0d9c6, 0x12b7e950, - 0x8bbeb8ea, 0xfcb9887c, 0x62dd1ddf, 0x15da2d49, 0x8cd37cf3, 0xfbd44c65, - 0x4db26158, 0x3ab551ce, 0xa3bc0074, 0xd4bb30e2, 0x4adfa541, 0x3dd895d7, - 0xa4d1c46d, 0xd3d6f4fb, 0x4369e96a, 0x346ed9fc, 0xad678846, 0xda60b8d0, - 0x44042d73, 0x33031de5, 0xaa0a4c5f, 0xdd0d7cc9, 0x5005713c, 0x270241aa, - 0xbe0b1010, 0xc90c2086, 0x5768b525, 0x206f85b3, 0xb966d409, 0xce61e49f, - 0x5edef90e, 0x29d9c998, 0xb0d09822, 0xc7d7a8b4, 0x59b33d17, 0x2eb40d81, - 0xb7bd5c3b, 0xc0ba6cad, 0xedb88320, 0x9abfb3b6, 0x03b6e20c, 0x74b1d29a, - 0xead54739, 0x9dd277af, 0x04db2615, 0x73dc1683, 0xe3630b12, 0x94643b84, - 0x0d6d6a3e, 0x7a6a5aa8, 0xe40ecf0b, 0x9309ff9d, 0x0a00ae27, 0x7d079eb1, - 0xf00f9344, 0x8708a3d2, 0x1e01f268, 0x6906c2fe, 0xf762575d, 0x806567cb, - 0x196c3671, 0x6e6b06e7, 0xfed41b76, 0x89d32be0, 0x10da7a5a, 0x67dd4acc, - 0xf9b9df6f, 0x8ebeeff9, 0x17b7be43, 0x60b08ed5, 0xd6d6a3e8, 0xa1d1937e, - 0x38d8c2c4, 0x4fdff252, 0xd1bb67f1, 0xa6bc5767, 0x3fb506dd, 0x48b2364b, - 0xd80d2bda, 0xaf0a1b4c, 0x36034af6, 0x41047a60, 0xdf60efc3, 0xa867df55, - 0x316e8eef, 0x4669be79, 0xcb61b38c, 0xbc66831a, 0x256fd2a0, 0x5268e236, - 0xcc0c7795, 0xbb0b4703, 0x220216b9, 0x5505262f, 0xc5ba3bbe, 0xb2bd0b28, - 0x2bb45a92, 0x5cb36a04, 0xc2d7ffa7, 0xb5d0cf31, 0x2cd99e8b, 0x5bdeae1d, - 0x9b64c2b0, 0xec63f226, 0x756aa39c, 0x026d930a, 0x9c0906a9, 0xeb0e363f, - 0x72076785, 0x05005713, 0x95bf4a82, 0xe2b87a14, 0x7bb12bae, 0x0cb61b38, - 0x92d28e9b, 0xe5d5be0d, 0x7cdcefb7, 0x0bdbdf21, 0x86d3d2d4, 0xf1d4e242, - 0x68ddb3f8, 0x1fda836e, 0x81be16cd, 0xf6b9265b, 0x6fb077e1, 0x18b74777, - 0x88085ae6, 0xff0f6a70, 0x66063bca, 0x11010b5c, 0x8f659eff, 0xf862ae69, - 0x616bffd3, 0x166ccf45, 0xa00ae278, 0xd70dd2ee, 0x4e048354, 0x3903b3c2, - 0xa7672661, 0xd06016f7, 0x4969474d, 0x3e6e77db, 0xaed16a4a, 0xd9d65adc, - 0x40df0b66, 0x37d83bf0, 0xa9bcae53, 0xdebb9ec5, 0x47b2cf7f, 0x30b5ffe9, - 0xbdbdf21c, 0xcabac28a, 0x53b39330, 0x24b4a3a6, 0xbad03605, 0xcdd70693, - 0x54de5729, 0x23d967bf, 0xb3667a2e, 0xc4614ab8, 0x5d681b02, 0x2a6f2b94, - 0xb40bbe37, 0xc30c8ea1, 0x5a05df1b, 0x2d02ef8d -}; - -static uint32 ComputeCRC32(const string &buf) { - uint32 x = ~0U; - for (int i = 0; i < buf.size(); ++i) { - unsigned char c = buf[i]; - x = kCRC32Table[(x ^ c) & 0xff] ^ (x >> 8); - } - return ~x; -} - -static void WriteShort(io::CodedOutputStream *out, uint16 val) { - uint8 p[2]; - p[0] = static_cast(val); - p[1] = static_cast(val >> 8); - out->WriteRaw(p, 2); -} - -ZipWriter::ZipWriter(io::ZeroCopyOutputStream* raw_output) - : raw_output_(raw_output) {} -ZipWriter::~ZipWriter() {} - -bool ZipWriter::Write(const string& filename, const string& contents) { - FileInfo info; - - info.name = filename; - uint16 filename_size = filename.size(); - info.offset = raw_output_->ByteCount(); - info.size = contents.size(); - info.crc32 = ComputeCRC32(contents); - - files_.push_back(info); - - // write file header - io::CodedOutputStream output(raw_output_); - output.WriteLittleEndian32(0x04034b50); // magic - WriteShort(&output, 10); // version needed to extract - WriteShort(&output, 0); // flags - WriteShort(&output, 0); // compression method: stored - WriteShort(&output, 0); // last modified time - WriteShort(&output, 0); // last modified date - output.WriteLittleEndian32(info.crc32); // crc-32 - output.WriteLittleEndian32(info.size); // compressed size - output.WriteLittleEndian32(info.size); // uncompressed size - WriteShort(&output, filename_size); // file name length - WriteShort(&output, 0); // extra field length - output.WriteString(filename); // file name - output.WriteString(contents); // file data - - return !output.HadError(); -} - -bool ZipWriter::WriteDirectory() { - uint16 num_entries = files_.size(); - uint32 dir_ofs = raw_output_->ByteCount(); - - // write central directory - io::CodedOutputStream output(raw_output_); - for (int i = 0; i < num_entries; ++i) { - const string &filename = files_[i].name; - uint16 filename_size = filename.size(); - uint32 crc32 = files_[i].crc32; - uint32 size = files_[i].size; - uint32 offset = files_[i].offset; - - output.WriteLittleEndian32(0x02014b50); // magic - WriteShort(&output, 10); // version made by - WriteShort(&output, 10); // version needed to extract - WriteShort(&output, 0); // flags - WriteShort(&output, 0); // compression method: stored - WriteShort(&output, 0); // last modified time - WriteShort(&output, 0); // last modified date - output.WriteLittleEndian32(crc32); // crc-32 - output.WriteLittleEndian32(size); // compressed size - output.WriteLittleEndian32(size); // uncompressed size - WriteShort(&output, filename_size); // file name length - WriteShort(&output, 0); // extra field length - WriteShort(&output, 0); // file comment length - WriteShort(&output, 0); // starting disk number - WriteShort(&output, 0); // internal file attributes - output.WriteLittleEndian32(0); // external file attributes - output.WriteLittleEndian32(offset); // local header offset - output.WriteString(filename); // file name - } - uint32 dir_len = output.ByteCount(); - - // write end of central directory marker - output.WriteLittleEndian32(0x06054b50); // magic - WriteShort(&output, 0); // disk number - WriteShort(&output, 0); // disk with start of central directory - WriteShort(&output, num_entries); // central directory entries (this disk) - WriteShort(&output, num_entries); // central directory entries (total) - output.WriteLittleEndian32(dir_len); // central directory byte size - output.WriteLittleEndian32(dir_ofs); // central directory offset - WriteShort(&output, 0); // comment length - - return output.HadError(); -} - -} // namespace compiler -} // namespace protobuf -} // namespace google diff --git a/modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/zip_writer.h b/modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/zip_writer.h deleted file mode 100644 index be73972a6..000000000 --- a/modules/dnn/3rdparty/protobuf/src/google/protobuf/compiler/zip_writer.h +++ /dev/null @@ -1,93 +0,0 @@ -// Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// http://code.google.com/p/protobuf/ -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -// Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// http://code.google.com/p/protobuf/ -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -// Author: kenton@google.com (Kenton Varda) - -#include -#include -#include - -namespace google { -namespace protobuf { -namespace compiler { - -class ZipWriter { - public: - ZipWriter(io::ZeroCopyOutputStream* raw_output); - ~ZipWriter(); - - bool Write(const string& filename, const string& contents); - bool WriteDirectory(); - - private: - struct FileInfo { - string name; - uint32 offset; - uint32 size; - uint32 crc32; - }; - - io::ZeroCopyOutputStream* raw_output_; - vector files_; -}; - -} // namespace compiler -} // namespace protobuf -} // namespace google diff --git a/modules/dnn/3rdparty/protobuf/src/google/protobuf/descriptor.cc b/modules/dnn/3rdparty/protobuf/src/google/protobuf/descriptor.cc deleted file mode 100644 index 3516f64a8..000000000 --- a/modules/dnn/3rdparty/protobuf/src/google/protobuf/descriptor.cc +++ /dev/null @@ -1,4948 +0,0 @@ -// Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// http://code.google.com/p/protobuf/ -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -// Author: kenton@google.com (Kenton Varda) -// Based on original Protocol Buffers design by -// Sanjay Ghemawat, Jeff Dean, and others. - -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#undef PACKAGE // autoheader #defines this. :( - -namespace google { -namespace protobuf { - -const FieldDescriptor::CppType -FieldDescriptor::kTypeToCppTypeMap[MAX_TYPE + 1] = { - static_cast(0), // 0 is reserved for errors - - CPPTYPE_DOUBLE, // TYPE_DOUBLE - CPPTYPE_FLOAT, // TYPE_FLOAT - CPPTYPE_INT64, // TYPE_INT64 - CPPTYPE_UINT64, // TYPE_UINT64 - CPPTYPE_INT32, // TYPE_INT32 - CPPTYPE_UINT64, // TYPE_FIXED64 - CPPTYPE_UINT32, // TYPE_FIXED32 - CPPTYPE_BOOL, // TYPE_BOOL - CPPTYPE_STRING, // TYPE_STRING - CPPTYPE_MESSAGE, // TYPE_GROUP - CPPTYPE_MESSAGE, // TYPE_MESSAGE - CPPTYPE_STRING, // TYPE_BYTES - CPPTYPE_UINT32, // TYPE_UINT32 - CPPTYPE_ENUM, // TYPE_ENUM - CPPTYPE_INT32, // TYPE_SFIXED32 - CPPTYPE_INT64, // TYPE_SFIXED64 - CPPTYPE_INT32, // TYPE_SINT32 - CPPTYPE_INT64, // TYPE_SINT64 -}; - -const char * const FieldDescriptor::kTypeToName[MAX_TYPE + 1] = { - "ERROR", // 0 is reserved for errors - - "double", // TYPE_DOUBLE - "float", // TYPE_FLOAT - "int64", // TYPE_INT64 - "uint64", // TYPE_UINT64 - "int32", // TYPE_INT32 - "fixed64", // TYPE_FIXED64 - "fixed32", // TYPE_FIXED32 - "bool", // TYPE_BOOL - "string", // TYPE_STRING - "group", // TYPE_GROUP - "message", // TYPE_MESSAGE - "bytes", // TYPE_BYTES - "uint32", // TYPE_UINT32 - "enum", // TYPE_ENUM - "sfixed32", // TYPE_SFIXED32 - "sfixed64", // TYPE_SFIXED64 - "sint32", // TYPE_SINT32 - "sint64", // TYPE_SINT64 -}; - -const char * const FieldDescriptor::kCppTypeToName[MAX_CPPTYPE + 1] = { - "ERROR", // 0 is reserved for errors - - "int32", // CPPTYPE_INT32 - "int64", // CPPTYPE_INT64 - "uint32", // CPPTYPE_UINT32 - "uint64", // CPPTYPE_UINT64 - "double", // CPPTYPE_DOUBLE - "float", // CPPTYPE_FLOAT - "bool", // CPPTYPE_BOOL - "enum", // CPPTYPE_ENUM - "string", // CPPTYPE_STRING - "message", // CPPTYPE_MESSAGE -}; - -const char * const FieldDescriptor::kLabelToName[MAX_LABEL + 1] = { - "ERROR", // 0 is reserved for errors - - "optional", // LABEL_OPTIONAL - "required", // LABEL_REQUIRED - "repeated", // LABEL_REPEATED -}; - -#ifndef _MSC_VER // MSVC doesn't need these and won't even accept them. -const int FieldDescriptor::kMaxNumber; -const int FieldDescriptor::kFirstReservedNumber; -const int FieldDescriptor::kLastReservedNumber; -#endif - -namespace { - -const string kEmptyString; - -string ToCamelCase(const string& input) { - bool capitalize_next = false; - string result; - result.reserve(input.size()); - - for (int i = 0; i < input.size(); i++) { - if (input[i] == '_') { - capitalize_next = true; - } else if (capitalize_next) { - // Note: I distrust ctype.h due to locales. - if ('a' <= input[i] && input[i] <= 'z') { - result.push_back(input[i] - 'a' + 'A'); - } else { - result.push_back(input[i]); - } - capitalize_next = false; - } else { - result.push_back(input[i]); - } - } - - // Lower-case the first letter. - if (!result.empty() && 'A' <= result[0] && result[0] <= 'Z') { - result[0] = result[0] - 'A' + 'a'; - } - - return result; -} - -// A DescriptorPool contains a bunch of hash_maps to implement the -// various Find*By*() methods. Since hashtable lookups are O(1), it's -// most efficient to construct a fixed set of large hash_maps used by -// all objects in the pool rather than construct one or more small -// hash_maps for each object. -// -// The keys to these hash_maps are (parent, name) or (parent, number) -// pairs. Unfortunately STL doesn't provide hash functions for pair<>, -// so we must invent our own. -// -// TODO(kenton): Use StringPiece rather than const char* in keys? It would -// be a lot cleaner but we'd just have to convert it back to const char* -// for the open source release. - -typedef pair PointerStringPair; - -struct PointerStringPairEqual { - inline bool operator()(const PointerStringPair& a, - const PointerStringPair& b) const { - return a.first == b.first && strcmp(a.second, b.second) == 0; - } -}; - -template -struct PointerIntegerPairHash { - size_t operator()(const PairType& p) const { - // FIXME(kenton): What is the best way to compute this hash? I have - // no idea! This seems a bit better than an XOR. - return reinterpret_cast(p.first) * ((1 << 16) - 1) + p.second; - } - - // Used only by MSVC and platforms where hash_map is not available. - static const size_t bucket_size = 4; - static const size_t min_buckets = 8; - inline bool operator()(const PairType& a, const PairType& b) const { - return a.first < b.first || - (a.first == b.first && a.second < b.second); - } -}; - -typedef pair DescriptorIntPair; -typedef pair EnumIntPair; - -struct PointerStringPairHash { - size_t operator()(const PointerStringPair& p) const { - // FIXME(kenton): What is the best way to compute this hash? I have - // no idea! This seems a bit better than an XOR. - hash cstring_hash; - return reinterpret_cast(p.first) * ((1 << 16) - 1) + - cstring_hash(p.second); - } - - // Used only by MSVC and platforms where hash_map is not available. - enum { bucket_size = 4, min_buckets = 8 }; - inline bool operator()(const PointerStringPair& a, - const PointerStringPair& b) const { - if (a.first < b.first) return true; - if (a.first > b.first) return false; - return strcmp(a.second, b.second) < 0; - } -}; - - -struct Symbol { - enum Type { - NULL_SYMBOL, MESSAGE, FIELD, ENUM, ENUM_VALUE, SERVICE, METHOD, - PACKAGE - }; - Type type; - union { - const Descriptor* descriptor; - const FieldDescriptor* field_descriptor; - const EnumDescriptor* enum_descriptor; - const EnumValueDescriptor* enum_value_descriptor; - const ServiceDescriptor* service_descriptor; - const MethodDescriptor* method_descriptor; - const FileDescriptor* package_file_descriptor; - }; - - inline Symbol() : type(NULL_SYMBOL) { descriptor = NULL; } - inline bool IsNull() const { return type == NULL_SYMBOL; } - inline bool IsType() const { - return type == MESSAGE || type == ENUM; - } - inline bool IsAggregate() const { - return type == MESSAGE || type == PACKAGE - || type == ENUM || type == SERVICE; - } - -#define CONSTRUCTOR(TYPE, TYPE_CONSTANT, FIELD) \ - inline explicit Symbol(const TYPE* value) { \ - type = TYPE_CONSTANT; \ - this->FIELD = value; \ - } - - CONSTRUCTOR(Descriptor , MESSAGE , descriptor ) - CONSTRUCTOR(FieldDescriptor , FIELD , field_descriptor ) - CONSTRUCTOR(EnumDescriptor , ENUM , enum_descriptor ) - CONSTRUCTOR(EnumValueDescriptor, ENUM_VALUE, enum_value_descriptor ) - CONSTRUCTOR(ServiceDescriptor , SERVICE , service_descriptor ) - CONSTRUCTOR(MethodDescriptor , METHOD , method_descriptor ) - CONSTRUCTOR(FileDescriptor , PACKAGE , package_file_descriptor) -#undef CONSTRUCTOR - - const FileDescriptor* GetFile() const { - switch (type) { - case NULL_SYMBOL: return NULL; - case MESSAGE : return descriptor ->file(); - case FIELD : return field_descriptor ->file(); - case ENUM : return enum_descriptor ->file(); - case ENUM_VALUE : return enum_value_descriptor->type()->file(); - case SERVICE : return service_descriptor ->file(); - case METHOD : return method_descriptor ->service()->file(); - case PACKAGE : return package_file_descriptor; - } - return NULL; - } -}; - -const Symbol kNullSymbol; - -typedef hash_map, streq> - SymbolsByNameMap; -typedef hash_map - SymbolsByParentMap; -typedef hash_map, streq> - FilesByNameMap; -typedef hash_map - FieldsByNameMap; -typedef hash_map > - FieldsByNumberMap; -typedef hash_map > - EnumValuesByNumberMap; -// This is a map rather than a hash_map, since we use it to iterate -// through all the extensions that extend a given Descriptor, and an -// ordered data structure that implements lower_bound is convenient -// for that. -typedef map - ExtensionsGroupedByDescriptorMap; - -} // anonymous namespace - -// =================================================================== -// DescriptorPool::Tables - -class DescriptorPool::Tables { - public: - Tables(); - ~Tables(); - - // Record the current state of the tables to the stack of checkpoints. - // Each call to AddCheckpoint() must be paired with exactly one call to either - // ClearLastCheckpoint() or RollbackToLastCheckpoint(). - // - // This is used when building files, since some kinds of validation errors - // cannot be detected until the file's descriptors have already been added to - // the tables. - // - // This supports recursive checkpoints, since building a file may trigger - // recursive building of other files. Note that recursive checkpoints are not - // normally necessary; explicit dependencies are built prior to checkpointing. - // So although we recursively build transitive imports, there is at most one - // checkpoint in the stack during dependency building. - // - // Recursive checkpoints only arise during cross-linking of the descriptors. - // Symbol references must be resolved, via DescriptorBuilder::FindSymbol and - // friends. If the pending file references an unknown symbol - // (e.g., it is not defined in the pending file's explicit dependencies), and - // the pool is using a fallback database, and that database contains a file - // defining that symbol, and that file has not yet been built by the pool, - // the pool builds the file during cross-linking, leading to another - // checkpoint. - void AddCheckpoint(); - - // Mark the last checkpoint as having cleared successfully, removing it from - // the stack. If the stack is empty, all pending symbols will be committed. - // - // Note that this does not guarantee that the symbols added since the last - // checkpoint won't be rolled back: if a checkpoint gets rolled back, - // everything past that point gets rolled back, including symbols added after - // checkpoints that were pushed onto the stack after it and marked as cleared. - void ClearLastCheckpoint(); - - // Roll back the Tables to the state of the checkpoint at the top of the - // stack, removing everything that was added after that point. - void RollbackToLastCheckpoint(); - - // The stack of files which are currently being built. Used to detect - // cyclic dependencies when loading files from a DescriptorDatabase. Not - // used when fallback_database_ == NULL. - vector pending_files_; - - // A set of files which we have tried to load from the fallback database - // and encountered errors. We will not attempt to load them again. - // Not used when fallback_database_ == NULL. - hash_set known_bad_files_; - - // The set of descriptors for which we've already loaded the full - // set of extensions numbers from fallback_database_. - hash_set extensions_loaded_from_db_; - - // ----------------------------------------------------------------- - // Finding items. - - // Find symbols. This returns a null Symbol (symbol.IsNull() is true) - // if not found. - inline Symbol FindSymbol(const string& key) const; - - // This implements the body of DescriptorPool::Find*ByName(). It should - // really be a private method of DescriptorPool, but that would require - // declaring Symbol in descriptor.h, which would drag all kinds of other - // stuff into the header. Yay C++. - Symbol FindByNameHelper( - const DescriptorPool* pool, const string& name) const; - - // These return NULL if not found. - inline const FileDescriptor* FindFile(const string& key) const; - inline const FieldDescriptor* FindExtension(const Descriptor* extendee, - int number); - inline void FindAllExtensions(const Descriptor* extendee, - vector* out) const; - - // ----------------------------------------------------------------- - // Adding items. - - // These add items to the corresponding tables. They return false if - // the key already exists in the table. For AddSymbol(), the string passed - // in must be one that was constructed using AllocateString(), as it will - // be used as a key in the symbols_by_name_ map without copying. - bool AddSymbol(const string& full_name, Symbol symbol); - bool AddFile(const FileDescriptor* file); - bool AddExtension(const FieldDescriptor* field); - - // ----------------------------------------------------------------- - // Allocating memory. - - // Allocate an object which will be reclaimed when the pool is - // destroyed. Note that the object's destructor will never be called, - // so its fields must be plain old data (primitive data types and - // pointers). All of the descriptor types are such objects. - template Type* Allocate(); - - // Allocate an array of objects which will be reclaimed when the - // pool in destroyed. Again, destructors are never called. - template Type* AllocateArray(int count); - - // Allocate a string which will be destroyed when the pool is destroyed. - // The string is initialized to the given value for convenience. - string* AllocateString(const string& value); - - // Allocate a protocol message object. Some older versions of GCC have - // trouble understanding explicit template instantiations in some cases, so - // in those cases we have to pass a dummy pointer of the right type as the - // parameter instead of specifying the type explicitly. - template Type* AllocateMessage(Type* dummy = NULL); - - // Allocate a FileDescriptorTables object. - FileDescriptorTables* AllocateFileTables(); - - private: - vector strings_; // All strings in the pool. - vector messages_; // All messages in the pool. - vector file_tables_; // All file tables in the pool. - vector allocations_; // All other memory allocated in the pool. - - SymbolsByNameMap symbols_by_name_; - FilesByNameMap files_by_name_; - ExtensionsGroupedByDescriptorMap extensions_; - - struct CheckPoint { - explicit CheckPoint(const Tables* tables) - : strings_before_checkpoint(tables->strings_.size()), - messages_before_checkpoint(tables->messages_.size()), - file_tables_before_checkpoint(tables->file_tables_.size()), - allocations_before_checkpoint(tables->allocations_.size()), - pending_symbols_before_checkpoint( - tables->symbols_after_checkpoint_.size()), - pending_files_before_checkpoint( - tables->files_after_checkpoint_.size()), - pending_extensions_before_checkpoint( - tables->extensions_after_checkpoint_.size()) { - } - int strings_before_checkpoint; - int messages_before_checkpoint; - int file_tables_before_checkpoint; - int allocations_before_checkpoint; - int pending_symbols_before_checkpoint; - int pending_files_before_checkpoint; - int pending_extensions_before_checkpoint; - }; - vector checkpoints_; - vector symbols_after_checkpoint_; - vector files_after_checkpoint_; - vector extensions_after_checkpoint_; - - // Allocate some bytes which will be reclaimed when the pool is - // destroyed. - void* AllocateBytes(int size); -}; - -// Contains tables specific to a particular file. These tables are not -// modified once the file has been constructed, so they need not be -// protected by a mutex. This makes operations that depend only on the -// contents of a single file -- e.g. Descriptor::FindFieldByName() -- -// lock-free. -// -// For historical reasons, the definitions of the methods of -// FileDescriptorTables and DescriptorPool::Tables are interleaved below. -// These used to be a single class. -class FileDescriptorTables { - public: - FileDescriptorTables(); - ~FileDescriptorTables(); - - // Empty table, used with placeholder files. - static const FileDescriptorTables kEmpty; - - // ----------------------------------------------------------------- - // Finding items. - - // Find symbols. These return a null Symbol (symbol.IsNull() is true) - // if not found. - inline Symbol FindNestedSymbol(const void* parent, - const string& name) const; - inline Symbol FindNestedSymbolOfType(const void* parent, - const string& name, - const Symbol::Type type) const; - - // These return NULL if not found. - inline const FieldDescriptor* FindFieldByNumber( - const Descriptor* parent, int number) const; - inline const FieldDescriptor* FindFieldByLowercaseName( - const void* parent, const string& lowercase_name) const; - inline const FieldDescriptor* FindFieldByCamelcaseName( - const void* parent, const string& camelcase_name) const; - inline const EnumValueDescriptor* FindEnumValueByNumber( - const EnumDescriptor* parent, int number) const; - - // ----------------------------------------------------------------- - // Adding items. - - // These add items to the corresponding tables. They return false if - // the key already exists in the table. For AddAliasUnderParent(), the - // string passed in must be one that was constructed using AllocateString(), - // as it will be used as a key in the symbols_by_parent_ map without copying. - bool AddAliasUnderParent(const void* parent, const string& name, - Symbol symbol); - bool AddFieldByNumber(const FieldDescriptor* field); - bool AddEnumValueByNumber(const EnumValueDescriptor* value); - - // Adds the field to the lowercase_name and camelcase_name maps. Never - // fails because we allow duplicates; the first field by the name wins. - void AddFieldByStylizedNames(const FieldDescriptor* field); - - private: - SymbolsByParentMap symbols_by_parent_; - FieldsByNameMap fields_by_lowercase_name_; - FieldsByNameMap fields_by_camelcase_name_; - FieldsByNumberMap fields_by_number_; // Not including extensions. - EnumValuesByNumberMap enum_values_by_number_; -}; - -DescriptorPool::Tables::Tables() - // Start some hash_map and hash_set objects with a small # of buckets - : known_bad_files_(3), - extensions_loaded_from_db_(3), - symbols_by_name_(3), - files_by_name_(3) {} - - -DescriptorPool::Tables::~Tables() { - GOOGLE_DCHECK(checkpoints_.empty()); - // Note that the deletion order is important, since the destructors of some - // messages may refer to objects in allocations_. - STLDeleteElements(&messages_); - for (int i = 0; i < allocations_.size(); i++) { - operator delete(allocations_[i]); - } - STLDeleteElements(&strings_); - STLDeleteElements(&file_tables_); -} - -FileDescriptorTables::FileDescriptorTables() - // Initialize all the hash tables to start out with a small # of buckets - : symbols_by_parent_(3), - fields_by_lowercase_name_(3), - fields_by_camelcase_name_(3), - fields_by_number_(3), - enum_values_by_number_(3) { -} - -FileDescriptorTables::~FileDescriptorTables() {} - -const FileDescriptorTables FileDescriptorTables::kEmpty; - -void DescriptorPool::Tables::AddCheckpoint() { - checkpoints_.push_back(CheckPoint(this)); -} - -void DescriptorPool::Tables::ClearLastCheckpoint() { - GOOGLE_DCHECK(!checkpoints_.empty()); - checkpoints_.pop_back(); - if (checkpoints_.empty()) { - // All checkpoints have been cleared: we can now commit all of the pending - // data. - symbols_after_checkpoint_.clear(); - files_after_checkpoint_.clear(); - extensions_after_checkpoint_.clear(); - } -} - -void DescriptorPool::Tables::RollbackToLastCheckpoint() { - GOOGLE_DCHECK(!checkpoints_.empty()); - const CheckPoint& checkpoint = checkpoints_.back(); - - for (int i = checkpoint.pending_symbols_before_checkpoint; - i < symbols_after_checkpoint_.size(); - i++) { - symbols_by_name_.erase(symbols_after_checkpoint_[i]); - } - for (int i = checkpoint.pending_files_before_checkpoint; - i < files_after_checkpoint_.size(); - i++) { - files_by_name_.erase(files_after_checkpoint_[i]); - } - for (int i = checkpoint.pending_extensions_before_checkpoint; - i < extensions_after_checkpoint_.size(); - i++) { - extensions_.erase(extensions_after_checkpoint_[i]); - } - - symbols_after_checkpoint_.resize( - checkpoint.pending_symbols_before_checkpoint); - files_after_checkpoint_.resize(checkpoint.pending_files_before_checkpoint); - extensions_after_checkpoint_.resize( - checkpoint.pending_extensions_before_checkpoint); - - STLDeleteContainerPointers( - strings_.begin() + checkpoint.strings_before_checkpoint, strings_.end()); - STLDeleteContainerPointers( - messages_.begin() + checkpoint.messages_before_checkpoint, - messages_.end()); - STLDeleteContainerPointers( - file_tables_.begin() + checkpoint.file_tables_before_checkpoint, - file_tables_.end()); - for (int i = checkpoint.allocations_before_checkpoint; - i < allocations_.size(); - i++) { - operator delete(allocations_[i]); - } - - strings_.resize(checkpoint.strings_before_checkpoint); - messages_.resize(checkpoint.messages_before_checkpoint); - file_tables_.resize(checkpoint.file_tables_before_checkpoint); - allocations_.resize(checkpoint.allocations_before_checkpoint); - checkpoints_.pop_back(); -} - -// ------------------------------------------------------------------- - -inline Symbol DescriptorPool::Tables::FindSymbol(const string& key) const { - const Symbol* result = FindOrNull(symbols_by_name_, key.c_str()); - if (result == NULL) { - return kNullSymbol; - } else { - return *result; - } -} - -inline Symbol FileDescriptorTables::FindNestedSymbol( - const void* parent, const string& name) const { - const Symbol* result = - FindOrNull(symbols_by_parent_, PointerStringPair(parent, name.c_str())); - if (result == NULL) { - return kNullSymbol; - } else { - return *result; - } -} - -inline Symbol FileDescriptorTables::FindNestedSymbolOfType( - const void* parent, const string& name, const Symbol::Type type) const { - Symbol result = FindNestedSymbol(parent, name); - if (result.type != type) return kNullSymbol; - return result; -} - -Symbol DescriptorPool::Tables::FindByNameHelper( - const DescriptorPool* pool, const string& name) const { - MutexLockMaybe lock(pool->mutex_); - Symbol result = FindSymbol(name); - - if (result.IsNull() && pool->underlay_ != NULL) { - // Symbol not found; check the underlay. - result = - pool->underlay_->tables_->FindByNameHelper(pool->underlay_, name); - } - - if (result.IsNull()) { - // Symbol still not found, so check fallback database. - if (pool->TryFindSymbolInFallbackDatabase(name)) { - result = FindSymbol(name); - } - } - - return result; -} - -inline const FileDescriptor* DescriptorPool::Tables::FindFile( - const string& key) const { - return FindPtrOrNull(files_by_name_, key.c_str()); -} - -inline const FieldDescriptor* FileDescriptorTables::FindFieldByNumber( - const Descriptor* parent, int number) const { - return FindPtrOrNull(fields_by_number_, make_pair(parent, number)); -} - -inline const FieldDescriptor* FileDescriptorTables::FindFieldByLowercaseName( - const void* parent, const string& lowercase_name) const { - return FindPtrOrNull(fields_by_lowercase_name_, - PointerStringPair(parent, lowercase_name.c_str())); -} - -inline const FieldDescriptor* FileDescriptorTables::FindFieldByCamelcaseName( - const void* parent, const string& camelcase_name) const { - return FindPtrOrNull(fields_by_camelcase_name_, - PointerStringPair(parent, camelcase_name.c_str())); -} - -inline const EnumValueDescriptor* FileDescriptorTables::FindEnumValueByNumber( - const EnumDescriptor* parent, int number) const { - return FindPtrOrNull(enum_values_by_number_, make_pair(parent, number)); -} - -inline const FieldDescriptor* DescriptorPool::Tables::FindExtension( - const Descriptor* extendee, int number) { - return FindPtrOrNull(extensions_, make_pair(extendee, number)); -} - -inline void DescriptorPool::Tables::FindAllExtensions( - const Descriptor* extendee, vector* out) const { - ExtensionsGroupedByDescriptorMap::const_iterator it = - extensions_.lower_bound(make_pair(extendee, 0)); - for (; it != extensions_.end() && it->first.first == extendee; ++it) { - out->push_back(it->second); - } -} - -// ------------------------------------------------------------------- - -bool DescriptorPool::Tables::AddSymbol( - const string& full_name, Symbol symbol) { - if (InsertIfNotPresent(&symbols_by_name_, full_name.c_str(), symbol)) { - symbols_after_checkpoint_.push_back(full_name.c_str()); - return true; - } else { - return false; - } -} - -bool FileDescriptorTables::AddAliasUnderParent( - const void* parent, const string& name, Symbol symbol) { - PointerStringPair by_parent_key(parent, name.c_str()); - return InsertIfNotPresent(&symbols_by_parent_, by_parent_key, symbol); -} - -bool DescriptorPool::Tables::AddFile(const FileDescriptor* file) { - if (InsertIfNotPresent(&files_by_name_, file->name().c_str(), file)) { - files_after_checkpoint_.push_back(file->name().c_str()); - return true; - } else { - return false; - } -} - -void FileDescriptorTables::AddFieldByStylizedNames( - const FieldDescriptor* field) { - const void* parent; - if (field->is_extension()) { - if (field->extension_scope() == NULL) { - parent = field->file(); - } else { - parent = field->extension_scope(); - } - } else { - parent = field->containing_type(); - } - - PointerStringPair lowercase_key(parent, field->lowercase_name().c_str()); - InsertIfNotPresent(&fields_by_lowercase_name_, lowercase_key, field); - - PointerStringPair camelcase_key(parent, field->camelcase_name().c_str()); - InsertIfNotPresent(&fields_by_camelcase_name_, camelcase_key, field); -} - -bool FileDescriptorTables::AddFieldByNumber(const FieldDescriptor* field) { - DescriptorIntPair key(field->containing_type(), field->number()); - return InsertIfNotPresent(&fields_by_number_, key, field); -} - -bool FileDescriptorTables::AddEnumValueByNumber( - const EnumValueDescriptor* value) { - EnumIntPair key(value->type(), value->number()); - return InsertIfNotPresent(&enum_values_by_number_, key, value); -} - -bool DescriptorPool::Tables::AddExtension(const FieldDescriptor* field) { - DescriptorIntPair key(field->containing_type(), field->number()); - if (InsertIfNotPresent(&extensions_, key, field)) { - extensions_after_checkpoint_.push_back(key); - return true; - } else { - return false; - } -} - -// ------------------------------------------------------------------- - -template -Type* DescriptorPool::Tables::Allocate() { - return reinterpret_cast(AllocateBytes(sizeof(Type))); -} - -template -Type* DescriptorPool::Tables::AllocateArray(int count) { - return reinterpret_cast(AllocateBytes(sizeof(Type) * count)); -} - -string* DescriptorPool::Tables::AllocateString(const string& value) { - string* result = new string(value); - strings_.push_back(result); - return result; -} - -template -Type* DescriptorPool::Tables::AllocateMessage(Type* dummy) { - Type* result = new Type; - messages_.push_back(result); - return result; -} - -FileDescriptorTables* DescriptorPool::Tables::AllocateFileTables() { - FileDescriptorTables* result = new FileDescriptorTables; - file_tables_.push_back(result); - return result; -} - -void* DescriptorPool::Tables::AllocateBytes(int size) { - // TODO(kenton): Would it be worthwhile to implement this in some more - // sophisticated way? Probably not for the open source release, but for - // internal use we could easily plug in one of our existing memory pool - // allocators... - if (size == 0) return NULL; - - void* result = operator new(size); - allocations_.push_back(result); - return result; -} - -// =================================================================== -// DescriptorPool - -DescriptorPool::ErrorCollector::~ErrorCollector() {} - -DescriptorPool::DescriptorPool() - : mutex_(NULL), - fallback_database_(NULL), - default_error_collector_(NULL), - underlay_(NULL), - tables_(new Tables), - enforce_dependencies_(true), - allow_unknown_(false) {} - -DescriptorPool::DescriptorPool(DescriptorDatabase* fallback_database, - ErrorCollector* error_collector) - : mutex_(new Mutex), - fallback_database_(fallback_database), - default_error_collector_(error_collector), - underlay_(NULL), - tables_(new Tables), - enforce_dependencies_(true), - allow_unknown_(false) { -} - -DescriptorPool::DescriptorPool(const DescriptorPool* underlay) - : mutex_(NULL), - fallback_database_(NULL), - default_error_collector_(NULL), - underlay_(underlay), - tables_(new Tables), - enforce_dependencies_(true), - allow_unknown_(false) {} - -DescriptorPool::~DescriptorPool() { - if (mutex_ != NULL) delete mutex_; -} - -// DescriptorPool::BuildFile() defined later. -// DescriptorPool::BuildFileCollectingErrors() defined later. - -void DescriptorPool::InternalDontEnforceDependencies() { - enforce_dependencies_ = false; -} - -bool DescriptorPool::InternalIsFileLoaded(const string& filename) const { - MutexLockMaybe lock(mutex_); - return tables_->FindFile(filename) != NULL; -} - -// generated_pool ==================================================== - -namespace { - - -EncodedDescriptorDatabase* generated_database_ = NULL; -DescriptorPool* generated_pool_ = NULL; -GOOGLE_PROTOBUF_DECLARE_ONCE(generated_pool_init_); - -void DeleteGeneratedPool() { - delete generated_database_; - generated_database_ = NULL; - delete generated_pool_; - generated_pool_ = NULL; -} - -static void InitGeneratedPool() { - generated_database_ = new EncodedDescriptorDatabase; - generated_pool_ = new DescriptorPool(generated_database_); - - internal::OnShutdown(&DeleteGeneratedPool); -} - -inline void InitGeneratedPoolOnce() { - ::google::protobuf::GoogleOnceInit(&generated_pool_init_, &InitGeneratedPool); -} - -} // anonymous namespace - -const DescriptorPool* DescriptorPool::generated_pool() { - InitGeneratedPoolOnce(); - return generated_pool_; -} - -DescriptorPool* DescriptorPool::internal_generated_pool() { - InitGeneratedPoolOnce(); - return generated_pool_; -} - -void DescriptorPool::InternalAddGeneratedFile( - const void* encoded_file_descriptor, int size) { - // So, this function is called in the process of initializing the - // descriptors for generated proto classes. Each generated .pb.cc file - // has an internal procedure called AddDescriptors() which is called at - // process startup, and that function calls this one in order to register - // the raw bytes of the FileDescriptorProto representing the file. - // - // We do not actually construct the descriptor objects right away. We just - // hang on to the bytes until they are actually needed. We actually construct - // the descriptor the first time one of the following things happens: - // * Someone calls a method like descriptor(), GetDescriptor(), or - // GetReflection() on the generated types, which requires returning the - // descriptor or an object based on it. - // * Someone looks up the descriptor in DescriptorPool::generated_pool(). - // - // Once one of these happens, the DescriptorPool actually parses the - // FileDescriptorProto and generates a FileDescriptor (and all its children) - // based on it. - // - // Note that FileDescriptorProto is itself a generated protocol message. - // Therefore, when we parse one, we have to be very careful to avoid using - // any descriptor-based operations, since this might cause infinite recursion - // or deadlock. - InitGeneratedPoolOnce(); - GOOGLE_CHECK(generated_database_->Add(encoded_file_descriptor, size)); -} - - -// Find*By* methods ================================================== - -// TODO(kenton): There's a lot of repeated code here, but I'm not sure if -// there's any good way to factor it out. Think about this some time when -// there's nothing more important to do (read: never). - -const FileDescriptor* DescriptorPool::FindFileByName(const string& name) const { - MutexLockMaybe lock(mutex_); - const FileDescriptor* result = tables_->FindFile(name); - if (result != NULL) return result; - if (underlay_ != NULL) { - result = underlay_->FindFileByName(name); - if (result != NULL) return result; - } - if (TryFindFileInFallbackDatabase(name)) { - result = tables_->FindFile(name); - if (result != NULL) return result; - } - return NULL; -} - -const FileDescriptor* DescriptorPool::FindFileContainingSymbol( - const string& symbol_name) const { - MutexLockMaybe lock(mutex_); - Symbol result = tables_->FindSymbol(symbol_name); - if (!result.IsNull()) return result.GetFile(); - if (underlay_ != NULL) { - const FileDescriptor* file_result = - underlay_->FindFileContainingSymbol(symbol_name); - if (file_result != NULL) return file_result; - } - if (TryFindSymbolInFallbackDatabase(symbol_name)) { - result = tables_->FindSymbol(symbol_name); - if (!result.IsNull()) return result.GetFile(); - } - return NULL; -} - -const Descriptor* DescriptorPool::FindMessageTypeByName( - const string& name) const { - Symbol result = tables_->FindByNameHelper(this, name); - return (result.type == Symbol::MESSAGE) ? result.descriptor : NULL; -} - -const FieldDescriptor* DescriptorPool::FindFieldByName( - const string& name) const { - Symbol result = tables_->FindByNameHelper(this, name); - if (result.type == Symbol::FIELD && - !result.field_descriptor->is_extension()) { - return result.field_descriptor; - } else { - return NULL; - } -} - -const FieldDescriptor* DescriptorPool::FindExtensionByName( - const string& name) const { - Symbol result = tables_->FindByNameHelper(this, name); - if (result.type == Symbol::FIELD && - result.field_descriptor->is_extension()) { - return result.field_descriptor; - } else { - return NULL; - } -} - -const EnumDescriptor* DescriptorPool::FindEnumTypeByName( - const string& name) const { - Symbol result = tables_->FindByNameHelper(this, name); - return (result.type == Symbol::ENUM) ? result.enum_descriptor : NULL; -} - -const EnumValueDescriptor* DescriptorPool::FindEnumValueByName( - const string& name) const { - Symbol result = tables_->FindByNameHelper(this, name); - return (result.type == Symbol::ENUM_VALUE) ? - result.enum_value_descriptor : NULL; -} - -const ServiceDescriptor* DescriptorPool::FindServiceByName( - const string& name) const { - Symbol result = tables_->FindByNameHelper(this, name); - return (result.type == Symbol::SERVICE) ? result.service_descriptor : NULL; -} - -const MethodDescriptor* DescriptorPool::FindMethodByName( - const string& name) const { - Symbol result = tables_->FindByNameHelper(this, name); - return (result.type == Symbol::METHOD) ? result.method_descriptor : NULL; -} - -const FieldDescriptor* DescriptorPool::FindExtensionByNumber( - const Descriptor* extendee, int number) const { - MutexLockMaybe lock(mutex_); - const FieldDescriptor* result = tables_->FindExtension(extendee, number); - if (result != NULL) { - return result; - } - if (underlay_ != NULL) { - result = underlay_->FindExtensionByNumber(extendee, number); - if (result != NULL) return result; - } - if (TryFindExtensionInFallbackDatabase(extendee, number)) { - result = tables_->FindExtension(extendee, number); - if (result != NULL) { - return result; - } - } - return NULL; -} - -void DescriptorPool::FindAllExtensions( - const Descriptor* extendee, vector* out) const { - MutexLockMaybe lock(mutex_); - - // Initialize tables_->extensions_ from the fallback database first - // (but do this only once per descriptor). - if (fallback_database_ != NULL && - tables_->extensions_loaded_from_db_.count(extendee) == 0) { - vector numbers; - if (fallback_database_->FindAllExtensionNumbers(extendee->full_name(), - &numbers)) { - for (int i = 0; i < numbers.size(); ++i) { - int number = numbers[i]; - if (tables_->FindExtension(extendee, number) == NULL) { - TryFindExtensionInFallbackDatabase(extendee, number); - } - } - tables_->extensions_loaded_from_db_.insert(extendee); - } - } - - tables_->FindAllExtensions(extendee, out); - if (underlay_ != NULL) { - underlay_->FindAllExtensions(extendee, out); - } -} - -// ------------------------------------------------------------------- - -const FieldDescriptor* -Descriptor::FindFieldByNumber(int key) const { - const FieldDescriptor* result = - file()->tables_->FindFieldByNumber(this, key); - if (result == NULL || result->is_extension()) { - return NULL; - } else { - return result; - } -} - -const FieldDescriptor* -Descriptor::FindFieldByLowercaseName(const string& key) const { - const FieldDescriptor* result = - file()->tables_->FindFieldByLowercaseName(this, key); - if (result == NULL || result->is_extension()) { - return NULL; - } else { - return result; - } -} - -const FieldDescriptor* -Descriptor::FindFieldByCamelcaseName(const string& key) const { - const FieldDescriptor* result = - file()->tables_->FindFieldByCamelcaseName(this, key); - if (result == NULL || result->is_extension()) { - return NULL; - } else { - return result; - } -} - -const FieldDescriptor* -Descriptor::FindFieldByName(const string& key) const { - Symbol result = - file()->tables_->FindNestedSymbolOfType(this, key, Symbol::FIELD); - if (!result.IsNull() && !result.field_descriptor->is_extension()) { - return result.field_descriptor; - } else { - return NULL; - } -} - -const FieldDescriptor* -Descriptor::FindExtensionByName(const string& key) const { - Symbol result = - file()->tables_->FindNestedSymbolOfType(this, key, Symbol::FIELD); - if (!result.IsNull() && result.field_descriptor->is_extension()) { - return result.field_descriptor; - } else { - return NULL; - } -} - -const FieldDescriptor* -Descriptor::FindExtensionByLowercaseName(const string& key) const { - const FieldDescriptor* result = - file()->tables_->FindFieldByLowercaseName(this, key); - if (result == NULL || !result->is_extension()) { - return NULL; - } else { - return result; - } -} - -const FieldDescriptor* -Descriptor::FindExtensionByCamelcaseName(const string& key) const { - const FieldDescriptor* result = - file()->tables_->FindFieldByCamelcaseName(this, key); - if (result == NULL || !result->is_extension()) { - return NULL; - } else { - return result; - } -} - -const Descriptor* -Descriptor::FindNestedTypeByName(const string& key) const { - Symbol result = - file()->tables_->FindNestedSymbolOfType(this, key, Symbol::MESSAGE); - if (!result.IsNull()) { - return result.descriptor; - } else { - return NULL; - } -} - -const EnumDescriptor* -Descriptor::FindEnumTypeByName(const string& key) const { - Symbol result = - file()->tables_->FindNestedSymbolOfType(this, key, Symbol::ENUM); - if (!result.IsNull()) { - return result.enum_descriptor; - } else { - return NULL; - } -} - -const EnumValueDescriptor* -Descriptor::FindEnumValueByName(const string& key) const { - Symbol result = - file()->tables_->FindNestedSymbolOfType(this, key, Symbol::ENUM_VALUE); - if (!result.IsNull()) { - return result.enum_value_descriptor; - } else { - return NULL; - } -} - -const EnumValueDescriptor* -EnumDescriptor::FindValueByName(const string& key) const { - Symbol result = - file()->tables_->FindNestedSymbolOfType(this, key, Symbol::ENUM_VALUE); - if (!result.IsNull()) { - return result.enum_value_descriptor; - } else { - return NULL; - } -} - -const EnumValueDescriptor* -EnumDescriptor::FindValueByNumber(int key) const { - return file()->tables_->FindEnumValueByNumber(this, key); -} - -const MethodDescriptor* -ServiceDescriptor::FindMethodByName(const string& key) const { - Symbol result = - file()->tables_->FindNestedSymbolOfType(this, key, Symbol::METHOD); - if (!result.IsNull()) { - return result.method_descriptor; - } else { - return NULL; - } -} - -const Descriptor* -FileDescriptor::FindMessageTypeByName(const string& key) const { - Symbol result = tables_->FindNestedSymbolOfType(this, key, Symbol::MESSAGE); - if (!result.IsNull()) { - return result.descriptor; - } else { - return NULL; - } -} - -const EnumDescriptor* -FileDescriptor::FindEnumTypeByName(const string& key) const { - Symbol result = tables_->FindNestedSymbolOfType(this, key, Symbol::ENUM); - if (!result.IsNull()) { - return result.enum_descriptor; - } else { - return NULL; - } -} - -const EnumValueDescriptor* -FileDescriptor::FindEnumValueByName(const string& key) const { - Symbol result = - tables_->FindNestedSymbolOfType(this, key, Symbol::ENUM_VALUE); - if (!result.IsNull()) { - return result.enum_value_descriptor; - } else { - return NULL; - } -} - -const ServiceDescriptor* -FileDescriptor::FindServiceByName(const string& key) const { - Symbol result = tables_->FindNestedSymbolOfType(this, key, Symbol::SERVICE); - if (!result.IsNull()) { - return result.service_descriptor; - } else { - return NULL; - } -} - -const FieldDescriptor* -FileDescriptor::FindExtensionByName(const string& key) const { - Symbol result = tables_->FindNestedSymbolOfType(this, key, Symbol::FIELD); - if (!result.IsNull() && result.field_descriptor->is_extension()) { - return result.field_descriptor; - } else { - return NULL; - } -} - -const FieldDescriptor* -FileDescriptor::FindExtensionByLowercaseName(const string& key) const { - const FieldDescriptor* result = tables_->FindFieldByLowercaseName(this, key); - if (result == NULL || !result->is_extension()) { - return NULL; - } else { - return result; - } -} - -const FieldDescriptor* -FileDescriptor::FindExtensionByCamelcaseName(const string& key) const { - const FieldDescriptor* result = tables_->FindFieldByCamelcaseName(this, key); - if (result == NULL || !result->is_extension()) { - return NULL; - } else { - return result; - } -} - -bool Descriptor::IsExtensionNumber(int number) const { - // Linear search should be fine because we don't expect a message to have - // more than a couple extension ranges. - for (int i = 0; i < extension_range_count(); i++) { - if (number >= extension_range(i)->start && - number < extension_range(i)->end) { - return true; - } - } - return false; -} - -// ------------------------------------------------------------------- - -bool DescriptorPool::TryFindFileInFallbackDatabase(const string& name) const { - if (fallback_database_ == NULL) return false; - - if (tables_->known_bad_files_.count(name) > 0) return false; - - FileDescriptorProto file_proto; - if (!fallback_database_->FindFileByName(name, &file_proto) || - BuildFileFromDatabase(file_proto) == NULL) { - tables_->known_bad_files_.insert(name); - return false; - } - - return true; -} - -bool DescriptorPool::IsSubSymbolOfBuiltType(const string& name) const { - string prefix = name; - for (;;) { - string::size_type dot_pos = prefix.find_last_of('.'); - if (dot_pos == string::npos) { - break; - } - prefix = prefix.substr(0, dot_pos); - Symbol symbol = tables_->FindSymbol(prefix); - // If the symbol type is anything other than PACKAGE, then its complete - // definition is already known. - if (!symbol.IsNull() && symbol.type != Symbol::PACKAGE) { - return true; - } - } - if (underlay_ != NULL) { - // Check to see if any prefix of this symbol exists in the underlay. - return underlay_->IsSubSymbolOfBuiltType(name); - } - return false; -} - -bool DescriptorPool::TryFindSymbolInFallbackDatabase(const string& name) const { - if (fallback_database_ == NULL) return false; - - // We skip looking in the fallback database if the name is a sub-symbol of - // any descriptor that already exists in the descriptor pool (except for - // package descriptors). This is valid because all symbols except for - // packages are defined in a single file, so if the symbol exists then we - // should already have its definition. - // - // The other reason to do this is to support "overriding" type definitions - // by merging two databases that define the same type. (Yes, people do - // this.) The main difficulty with making this work is that - // FindFileContainingSymbol() is allowed to return both false positives - // (e.g., SimpleDescriptorDatabase, UpgradedDescriptorDatabase) and false - // negatives (e.g. ProtoFileParser, SourceTreeDescriptorDatabase). When two - // such databases are merged, looking up a non-existent sub-symbol of a type - // that already exists in the descriptor pool can result in an attempt to - // load multiple definitions of the same type. The check below avoids this. - if (IsSubSymbolOfBuiltType(name)) return false; - - FileDescriptorProto file_proto; - if (!fallback_database_->FindFileContainingSymbol(name, &file_proto)) { - return false; - } - - if (tables_->FindFile(file_proto.name()) != NULL) { - // We've already loaded this file, and it apparently doesn't contain the - // symbol we're looking for. Some DescriptorDatabases return false - // positives. - return false; - } - - if (BuildFileFromDatabase(file_proto) == NULL) { - return false; - } - - return true; -} - -bool DescriptorPool::TryFindExtensionInFallbackDatabase( - const Descriptor* containing_type, int field_number) const { - if (fallback_database_ == NULL) return false; - - FileDescriptorProto file_proto; - if (!fallback_database_->FindFileContainingExtension( - containing_type->full_name(), field_number, &file_proto)) { - return false; - } - - if (tables_->FindFile(file_proto.name()) != NULL) { - // We've already loaded this file, and it apparently doesn't contain the - // extension we're looking for. Some DescriptorDatabases return false - // positives. - return false; - } - - if (BuildFileFromDatabase(file_proto) == NULL) { - return false; - } - - return true; -} - -// =================================================================== - -string FieldDescriptor::DefaultValueAsString(bool quote_string_type) const { - GOOGLE_CHECK(has_default_value()) << "No default value"; - switch (cpp_type()) { - case CPPTYPE_INT32: - return SimpleItoa(default_value_int32()); - break; - case CPPTYPE_INT64: - return SimpleItoa(default_value_int64()); - break; - case CPPTYPE_UINT32: - return SimpleItoa(default_value_uint32()); - break; - case CPPTYPE_UINT64: - return SimpleItoa(default_value_uint64()); - break; - case CPPTYPE_FLOAT: - return SimpleFtoa(default_value_float()); - break; - case CPPTYPE_DOUBLE: - return SimpleDtoa(default_value_double()); - break; - case CPPTYPE_BOOL: - return default_value_bool() ? "true" : "false"; - break; - case CPPTYPE_STRING: - if (quote_string_type) { - return "\"" + CEscape(default_value_string()) + "\""; - } else { - if (type() == TYPE_BYTES) { - return CEscape(default_value_string()); - } else { - return default_value_string(); - } - } - break; - case CPPTYPE_ENUM: - return default_value_enum()->name(); - break; - case CPPTYPE_MESSAGE: - GOOGLE_LOG(DFATAL) << "Messages can't have default values!"; - break; - } - GOOGLE_LOG(FATAL) << "Can't get here: failed to get default value as string"; - return ""; -} - -// CopyTo methods ==================================================== - -void FileDescriptor::CopyTo(FileDescriptorProto* proto) const { - proto->set_name(name()); - if (!package().empty()) proto->set_package(package()); - - for (int i = 0; i < dependency_count(); i++) { - proto->add_dependency(dependency(i)->name()); - } - - for (int i = 0; i < public_dependency_count(); i++) { - proto->add_public_dependency(public_dependencies_[i]); - } - - for (int i = 0; i < weak_dependency_count(); i++) { - proto->add_weak_dependency(weak_dependencies_[i]); - } - - for (int i = 0; i < message_type_count(); i++) { - message_type(i)->CopyTo(proto->add_message_type()); - } - for (int i = 0; i < enum_type_count(); i++) { - enum_type(i)->CopyTo(proto->add_enum_type()); - } - for (int i = 0; i < service_count(); i++) { - service(i)->CopyTo(proto->add_service()); - } - for (int i = 0; i < extension_count(); i++) { - extension(i)->CopyTo(proto->add_extension()); - } - - if (&options() != &FileOptions::default_instance()) { - proto->mutable_options()->CopyFrom(options()); - } -} - -void FileDescriptor::CopySourceCodeInfoTo(FileDescriptorProto* proto) const { - if (source_code_info_ != &SourceCodeInfo::default_instance()) { - proto->mutable_source_code_info()->CopyFrom(*source_code_info_); - } -} - -void Descriptor::CopyTo(DescriptorProto* proto) const { - proto->set_name(name()); - - for (int i = 0; i < field_count(); i++) { - field(i)->CopyTo(proto->add_field()); - } - for (int i = 0; i < nested_type_count(); i++) { - nested_type(i)->CopyTo(proto->add_nested_type()); - } - for (int i = 0; i < enum_type_count(); i++) { - enum_type(i)->CopyTo(proto->add_enum_type()); - } - for (int i = 0; i < extension_range_count(); i++) { - DescriptorProto::ExtensionRange* range = proto->add_extension_range(); - range->set_start(extension_range(i)->start); - range->set_end(extension_range(i)->end); - } - for (int i = 0; i < extension_count(); i++) { - extension(i)->CopyTo(proto->add_extension()); - } - - if (&options() != &MessageOptions::default_instance()) { - proto->mutable_options()->CopyFrom(options()); - } -} - -void FieldDescriptor::CopyTo(FieldDescriptorProto* proto) const { - proto->set_name(name()); - proto->set_number(number()); - - // Some compilers do not allow static_cast directly between two enum types, - // so we must cast to int first. - proto->set_label(static_cast( - implicit_cast(label()))); - proto->set_type(static_cast( - implicit_cast(type()))); - - if (is_extension()) { - if (!containing_type()->is_unqualified_placeholder_) { - proto->set_extendee("."); - } - proto->mutable_extendee()->append(containing_type()->full_name()); - } - - if (cpp_type() == CPPTYPE_MESSAGE) { - if (message_type()->is_placeholder_) { - // We don't actually know if the type is a message type. It could be - // an enum. - proto->clear_type(); - } - - if (!message_type()->is_unqualified_placeholder_) { - proto->set_type_name("."); - } - proto->mutable_type_name()->append(message_type()->full_name()); - } else if (cpp_type() == CPPTYPE_ENUM) { - if (!enum_type()->is_unqualified_placeholder_) { - proto->set_type_name("."); - } - proto->mutable_type_name()->append(enum_type()->full_name()); - } - - if (has_default_value()) { - proto->set_default_value(DefaultValueAsString(false)); - } - - if (&options() != &FieldOptions::default_instance()) { - proto->mutable_options()->CopyFrom(options()); - } -} - -void EnumDescriptor::CopyTo(EnumDescriptorProto* proto) const { - proto->set_name(name()); - - for (int i = 0; i < value_count(); i++) { - value(i)->CopyTo(proto->add_value()); - } - - if (&options() != &EnumOptions::default_instance()) { - proto->mutable_options()->CopyFrom(options()); - } -} - -void EnumValueDescriptor::CopyTo(EnumValueDescriptorProto* proto) const { - proto->set_name(name()); - proto->set_number(number()); - - if (&options() != &EnumValueOptions::default_instance()) { - proto->mutable_options()->CopyFrom(options()); - } -} - -void ServiceDescriptor::CopyTo(ServiceDescriptorProto* proto) const { - proto->set_name(name()); - - for (int i = 0; i < method_count(); i++) { - method(i)->CopyTo(proto->add_method()); - } - - if (&options() != &ServiceOptions::default_instance()) { - proto->mutable_options()->CopyFrom(options()); - } -} - -void MethodDescriptor::CopyTo(MethodDescriptorProto* proto) const { - proto->set_name(name()); - - if (!input_type()->is_unqualified_placeholder_) { - proto->set_input_type("."); - } - proto->mutable_input_type()->append(input_type()->full_name()); - - if (!output_type()->is_unqualified_placeholder_) { - proto->set_output_type("."); - } - proto->mutable_output_type()->append(output_type()->full_name()); - - if (&options() != &MethodOptions::default_instance()) { - proto->mutable_options()->CopyFrom(options()); - } -} - -// DebugString methods =============================================== - -namespace { - -// Used by each of the option formatters. -bool RetrieveOptions(int depth, - const Message &options, - vector *option_entries) { - option_entries->clear(); - const Reflection* reflection = options.GetReflection(); - vector fields; - reflection->ListFields(options, &fields); - for (int i = 0; i < fields.size(); i++) { - int count = 1; - bool repeated = false; - if (fields[i]->is_repeated()) { - count = reflection->FieldSize(options, fields[i]); - repeated = true; - } - for (int j = 0; j < count; j++) { - string fieldval; - if (fields[i]->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE) { - string tmp; - TextFormat::Printer printer; - printer.SetInitialIndentLevel(depth + 1); - printer.PrintFieldValueToString(options, fields[i], - repeated ? j : -1, &tmp); - fieldval.append("{\n"); - fieldval.append(tmp); - fieldval.append(depth * 2, ' '); - fieldval.append("}"); - } else { - TextFormat::PrintFieldValueToString(options, fields[i], - repeated ? j : -1, &fieldval); - } - string name; - if (fields[i]->is_extension()) { - name = "(." + fields[i]->full_name() + ")"; - } else { - name = fields[i]->name(); - } - option_entries->push_back(name + " = " + fieldval); - } - } - return !option_entries->empty(); -} - -// Formats options that all appear together in brackets. Does not include -// brackets. -bool FormatBracketedOptions(int depth, const Message &options, string *output) { - vector all_options; - if (RetrieveOptions(depth, options, &all_options)) { - output->append(JoinStrings(all_options, ", ")); - } - return !all_options.empty(); -} - -// Formats options one per line -bool FormatLineOptions(int depth, const Message &options, string *output) { - string prefix(depth * 2, ' '); - vector all_options; - if (RetrieveOptions(depth, options, &all_options)) { - for (int i = 0; i < all_options.size(); i++) { - strings::SubstituteAndAppend(output, "$0option $1;\n", - prefix, all_options[i]); - } - } - return !all_options.empty(); -} - -} // anonymous namespace - -string FileDescriptor::DebugString() const { - string contents = "syntax = \"proto2\";\n\n"; - - set public_dependencies; - set weak_dependencies; - public_dependencies.insert(public_dependencies_, - public_dependencies_ + public_dependency_count_); - weak_dependencies.insert(weak_dependencies_, - weak_dependencies_ + weak_dependency_count_); - - for (int i = 0; i < dependency_count(); i++) { - if (public_dependencies.count(i) > 0) { - strings::SubstituteAndAppend(&contents, "import public \"$0\";\n", - dependency(i)->name()); - } else if (weak_dependencies.count(i) > 0) { - strings::SubstituteAndAppend(&contents, "import weak \"$0\";\n", - dependency(i)->name()); - } else { - strings::SubstituteAndAppend(&contents, "import \"$0\";\n", - dependency(i)->name()); - } - } - - if (!package().empty()) { - strings::SubstituteAndAppend(&contents, "package $0;\n\n", package()); - } - - if (FormatLineOptions(0, options(), &contents)) { - contents.append("\n"); // add some space if we had options - } - - for (int i = 0; i < enum_type_count(); i++) { - enum_type(i)->DebugString(0, &contents); - contents.append("\n"); - } - - // Find all the 'group' type extensions; we will not output their nested - // definitions (those will be done with their group field descriptor). - set groups; - for (int i = 0; i < extension_count(); i++) { - if (extension(i)->type() == FieldDescriptor::TYPE_GROUP) { - groups.insert(extension(i)->message_type()); - } - } - - for (int i = 0; i < message_type_count(); i++) { - if (groups.count(message_type(i)) == 0) { - strings::SubstituteAndAppend(&contents, "message $0", - message_type(i)->name()); - message_type(i)->DebugString(0, &contents); - contents.append("\n"); - } - } - - for (int i = 0; i < service_count(); i++) { - service(i)->DebugString(&contents); - contents.append("\n"); - } - - const Descriptor* containing_type = NULL; - for (int i = 0; i < extension_count(); i++) { - if (extension(i)->containing_type() != containing_type) { - if (i > 0) contents.append("}\n\n"); - containing_type = extension(i)->containing_type(); - strings::SubstituteAndAppend(&contents, "extend .$0 {\n", - containing_type->full_name()); - } - extension(i)->DebugString(1, &contents); - } - if (extension_count() > 0) contents.append("}\n\n"); - - return contents; -} - -string Descriptor::DebugString() const { - string contents; - strings::SubstituteAndAppend(&contents, "message $0", name()); - DebugString(0, &contents); - return contents; -} - -void Descriptor::DebugString(int depth, string *contents) const { - string prefix(depth * 2, ' '); - ++depth; - contents->append(" {\n"); - - FormatLineOptions(depth, options(), contents); - - // Find all the 'group' types for fields and extensions; we will not output - // their nested definitions (those will be done with their group field - // descriptor). - set groups; - for (int i = 0; i < field_count(); i++) { - if (field(i)->type() == FieldDescriptor::TYPE_GROUP) { - groups.insert(field(i)->message_type()); - } - } - for (int i = 0; i < extension_count(); i++) { - if (extension(i)->type() == FieldDescriptor::TYPE_GROUP) { - groups.insert(extension(i)->message_type()); - } - } - - for (int i = 0; i < nested_type_count(); i++) { - if (groups.count(nested_type(i)) == 0) { - strings::SubstituteAndAppend(contents, "$0 message $1", - prefix, nested_type(i)->name()); - nested_type(i)->DebugString(depth, contents); - } - } - for (int i = 0; i < enum_type_count(); i++) { - enum_type(i)->DebugString(depth, contents); - } - for (int i = 0; i < field_count(); i++) { - field(i)->DebugString(depth, contents); - } - - for (int i = 0; i < extension_range_count(); i++) { - strings::SubstituteAndAppend(contents, "$0 extensions $1 to $2;\n", - prefix, - extension_range(i)->start, - extension_range(i)->end - 1); - } - - // Group extensions by what they extend, so they can be printed out together. - const Descriptor* containing_type = NULL; - for (int i = 0; i < extension_count(); i++) { - if (extension(i)->containing_type() != containing_type) { - if (i > 0) strings::SubstituteAndAppend(contents, "$0 }\n", prefix); - containing_type = extension(i)->containing_type(); - strings::SubstituteAndAppend(contents, "$0 extend .$1 {\n", - prefix, containing_type->full_name()); - } - extension(i)->DebugString(depth + 1, contents); - } - if (extension_count() > 0) - strings::SubstituteAndAppend(contents, "$0 }\n", prefix); - - strings::SubstituteAndAppend(contents, "$0}\n", prefix); -} - -string FieldDescriptor::DebugString() const { - string contents; - int depth = 0; - if (is_extension()) { - strings::SubstituteAndAppend(&contents, "extend .$0 {\n", - containing_type()->full_name()); - depth = 1; - } - DebugString(depth, &contents); - if (is_extension()) { - contents.append("}\n"); - } - return contents; -} - -void FieldDescriptor::DebugString(int depth, string *contents) const { - string prefix(depth * 2, ' '); - string field_type; - switch (type()) { - case TYPE_MESSAGE: - field_type = "." + message_type()->full_name(); - break; - case TYPE_ENUM: - field_type = "." + enum_type()->full_name(); - break; - default: - field_type = kTypeToName[type()]; - } - - strings::SubstituteAndAppend(contents, "$0$1 $2 $3 = $4", - prefix, - kLabelToName[label()], - field_type, - type() == TYPE_GROUP ? message_type()->name() : - name(), - number()); - - bool bracketed = false; - if (has_default_value()) { - bracketed = true; - strings::SubstituteAndAppend(contents, " [default = $0", - DefaultValueAsString(true)); - } - - string formatted_options; - if (FormatBracketedOptions(depth, options(), &formatted_options)) { - contents->append(bracketed ? ", " : " ["); - bracketed = true; - contents->append(formatted_options); - } - - if (bracketed) { - contents->append("]"); - } - - if (type() == TYPE_GROUP) { - message_type()->DebugString(depth, contents); - } else { - contents->append(";\n"); - } -} - -string EnumDescriptor::DebugString() const { - string contents; - DebugString(0, &contents); - return contents; -} - -void EnumDescriptor::DebugString(int depth, string *contents) const { - string prefix(depth * 2, ' '); - ++depth; - strings::SubstituteAndAppend(contents, "$0enum $1 {\n", - prefix, name()); - - FormatLineOptions(depth, options(), contents); - - for (int i = 0; i < value_count(); i++) { - value(i)->DebugString(depth, contents); - } - strings::SubstituteAndAppend(contents, "$0}\n", prefix); -} - -string EnumValueDescriptor::DebugString() const { - string contents; - DebugString(0, &contents); - return contents; -} - -void EnumValueDescriptor::DebugString(int depth, string *contents) const { - string prefix(depth * 2, ' '); - strings::SubstituteAndAppend(contents, "$0$1 = $2", - prefix, name(), number()); - - string formatted_options; - if (FormatBracketedOptions(depth, options(), &formatted_options)) { - strings::SubstituteAndAppend(contents, " [$0]", formatted_options); - } - contents->append(";\n"); -} - -string ServiceDescriptor::DebugString() const { - string contents; - DebugString(&contents); - return contents; -} - -void ServiceDescriptor::DebugString(string *contents) const { - strings::SubstituteAndAppend(contents, "service $0 {\n", name()); - - FormatLineOptions(1, options(), contents); - - for (int i = 0; i < method_count(); i++) { - method(i)->DebugString(1, contents); - } - - contents->append("}\n"); -} - -string MethodDescriptor::DebugString() const { - string contents; - DebugString(0, &contents); - return contents; -} - -void MethodDescriptor::DebugString(int depth, string *contents) const { - string prefix(depth * 2, ' '); - ++depth; - strings::SubstituteAndAppend(contents, "$0rpc $1(.$2) returns (.$3)", - prefix, name(), - input_type()->full_name(), - output_type()->full_name()); - - string formatted_options; - if (FormatLineOptions(depth, options(), &formatted_options)) { - strings::SubstituteAndAppend(contents, " {\n$0$1}\n", - formatted_options, prefix); - } else { - contents->append(";\n"); - } -} - - -// Location methods =============================================== - -static bool PathsEqual(const vector& x, const RepeatedField& y) { - if (x.size() != y.size()) return false; - for (int i = 0; i < x.size(); ++i) { - if (x[i] != y.Get(i)) return false; - } - return true; -} - -bool FileDescriptor::GetSourceLocation(const vector& path, - SourceLocation* out_location) const { - GOOGLE_CHECK_NOTNULL(out_location); - const SourceCodeInfo* info = source_code_info_; - for (int i = 0; info && i < info->location_size(); ++i) { - if (PathsEqual(path, info->location(i).path())) { - const RepeatedField& span = info->location(i).span(); - if (span.size() == 3 || span.size() == 4) { - out_location->start_line = span.Get(0); - out_location->start_column = span.Get(1); - out_location->end_line = span.Get(span.size() == 3 ? 0 : 2); - out_location->end_column = span.Get(span.size() - 1); - - out_location->leading_comments = info->location(i).leading_comments(); - out_location->trailing_comments = info->location(i).trailing_comments(); - return true; - } - } - } - return false; -} - -bool FieldDescriptor::is_packed() const { - return is_packable() && (options_ != NULL) && options_->packed(); -} - -bool Descriptor::GetSourceLocation(SourceLocation* out_location) const { - vector path; - GetLocationPath(&path); - return file()->GetSourceLocation(path, out_location); -} - -bool FieldDescriptor::GetSourceLocation(SourceLocation* out_location) const { - vector path; - GetLocationPath(&path); - return file()->GetSourceLocation(path, out_location); -} - -bool EnumDescriptor::GetSourceLocation(SourceLocation* out_location) const { - vector path; - GetLocationPath(&path); - return file()->GetSourceLocation(path, out_location); -} - -bool MethodDescriptor::GetSourceLocation(SourceLocation* out_location) const { - vector path; - GetLocationPath(&path); - return service()->file()->GetSourceLocation(path, out_location); -} - -bool ServiceDescriptor::GetSourceLocation(SourceLocation* out_location) const { - vector path; - GetLocationPath(&path); - return file()->GetSourceLocation(path, out_location); -} - -bool EnumValueDescriptor::GetSourceLocation( - SourceLocation* out_location) const { - vector path; - GetLocationPath(&path); - return type()->file()->GetSourceLocation(path, out_location); -} - -void Descriptor::GetLocationPath(vector* output) const { - if (containing_type()) { - containing_type()->GetLocationPath(output); - output->push_back(DescriptorProto::kNestedTypeFieldNumber); - output->push_back(index()); - } else { - output->push_back(FileDescriptorProto::kMessageTypeFieldNumber); - output->push_back(index()); - } -} - -void FieldDescriptor::GetLocationPath(vector* output) const { - containing_type()->GetLocationPath(output); - output->push_back(DescriptorProto::kFieldFieldNumber); - output->push_back(index()); -} - -void EnumDescriptor::GetLocationPath(vector* output) const { - if (containing_type()) { - containing_type()->GetLocationPath(output); - output->push_back(DescriptorProto::kEnumTypeFieldNumber); - output->push_back(index()); - } else { - output->push_back(FileDescriptorProto::kEnumTypeFieldNumber); - output->push_back(index()); - } -} - -void EnumValueDescriptor::GetLocationPath(vector* output) const { - type()->GetLocationPath(output); - output->push_back(EnumDescriptorProto::kValueFieldNumber); - output->push_back(index()); -} - -void ServiceDescriptor::GetLocationPath(vector* output) const { - output->push_back(FileDescriptorProto::kServiceFieldNumber); - output->push_back(index()); -} - -void MethodDescriptor::GetLocationPath(vector* output) const { - service()->GetLocationPath(output); - output->push_back(ServiceDescriptorProto::kMethodFieldNumber); - output->push_back(index()); -} - -// =================================================================== - -namespace { - -// Represents an options message to interpret. Extension names in the option -// name are respolved relative to name_scope. element_name and orig_opt are -// used only for error reporting (since the parser records locations against -// pointers in the original options, not the mutable copy). The Message must be -// one of the Options messages in descriptor.proto. -struct OptionsToInterpret { - OptionsToInterpret(const string& ns, - const string& el, - const Message* orig_opt, - Message* opt) - : name_scope(ns), - element_name(el), - original_options(orig_opt), - options(opt) { - } - string name_scope; - string element_name; - const Message* original_options; - Message* options; -}; - -} // namespace - -class DescriptorBuilder { - public: - DescriptorBuilder(const DescriptorPool* pool, - DescriptorPool::Tables* tables, - DescriptorPool::ErrorCollector* error_collector); - ~DescriptorBuilder(); - - const FileDescriptor* BuildFile(const FileDescriptorProto& proto); - - private: - friend class OptionInterpreter; - - const DescriptorPool* pool_; - DescriptorPool::Tables* tables_; // for convenience - DescriptorPool::ErrorCollector* error_collector_; - - // As we build descriptors we store copies of the options messages in - // them. We put pointers to those copies in this vector, as we build, so we - // can later (after cross-linking) interpret those options. - vector options_to_interpret_; - - bool had_errors_; - string filename_; - FileDescriptor* file_; - FileDescriptorTables* file_tables_; - set dependencies_; - - // If LookupSymbol() finds a symbol that is in a file which is not a declared - // dependency of this file, it will fail, but will set - // possible_undeclared_dependency_ to point at that file. This is only used - // by AddNotDefinedError() to report a more useful error message. - // possible_undeclared_dependency_name_ is the name of the symbol that was - // actually found in possible_undeclared_dependency_, which may be a parent - // of the symbol actually looked for. - const FileDescriptor* possible_undeclared_dependency_; - string possible_undeclared_dependency_name_; - - void AddError(const string& element_name, - const Message& descriptor, - DescriptorPool::ErrorCollector::ErrorLocation location, - const string& error); - - // Adds an error indicating that undefined_symbol was not defined. Must - // only be called after LookupSymbol() fails. - void AddNotDefinedError( - const string& element_name, - const Message& descriptor, - DescriptorPool::ErrorCollector::ErrorLocation location, - const string& undefined_symbol); - - // Silly helper which determines if the given file is in the given package. - // I.e., either file->package() == package_name or file->package() is a - // nested package within package_name. - bool IsInPackage(const FileDescriptor* file, const string& package_name); - - // Helper function which finds all public dependencies of the given file, and - // stores the them in the dependencies_ set in the builder. - void RecordPublicDependencies(const FileDescriptor* file); - - // Like tables_->FindSymbol(), but additionally: - // - Search the pool's underlay if not found in tables_. - // - Insure that the resulting Symbol is from one of the file's declared - // dependencies. - Symbol FindSymbol(const string& name); - - // Like FindSymbol() but does not require that the symbol is in one of the - // file's declared dependencies. - Symbol FindSymbolNotEnforcingDeps(const string& name); - - // This implements the body of FindSymbolNotEnforcingDeps(). - Symbol FindSymbolNotEnforcingDepsHelper(const DescriptorPool* pool, - const string& name); - - // Like FindSymbol(), but looks up the name relative to some other symbol - // name. This first searches siblings of relative_to, then siblings of its - // parents, etc. For example, LookupSymbol("foo.bar", "baz.qux.corge") makes - // the following calls, returning the first non-null result: - // FindSymbol("baz.qux.foo.bar"), FindSymbol("baz.foo.bar"), - // FindSymbol("foo.bar"). If AllowUnknownDependencies() has been called - // on the DescriptorPool, this will generate a placeholder type if - // the name is not found (unless the name itself is malformed). The - // placeholder_type parameter indicates what kind of placeholder should be - // constructed in this case. The resolve_mode parameter determines whether - // any symbol is returned, or only symbols that are types. Note, however, - // that LookupSymbol may still return a non-type symbol in LOOKUP_TYPES mode, - // if it believes that's all it could refer to. The caller should always - // check that it receives the type of symbol it was expecting. - enum PlaceholderType { - PLACEHOLDER_MESSAGE, - PLACEHOLDER_ENUM, - PLACEHOLDER_EXTENDABLE_MESSAGE - }; - enum ResolveMode { - LOOKUP_ALL, LOOKUP_TYPES - }; - Symbol LookupSymbol(const string& name, const string& relative_to, - PlaceholderType placeholder_type = PLACEHOLDER_MESSAGE, - ResolveMode resolve_mode = LOOKUP_ALL); - - // Like LookupSymbol() but will not return a placeholder even if - // AllowUnknownDependencies() has been used. - Symbol LookupSymbolNoPlaceholder(const string& name, - const string& relative_to, - ResolveMode resolve_mode = LOOKUP_ALL); - - // Creates a placeholder type suitable for return from LookupSymbol(). May - // return kNullSymbol if the name is not a valid type name. - Symbol NewPlaceholder(const string& name, PlaceholderType placeholder_type); - - // Creates a placeholder file. Never returns NULL. This is used when an - // import is not found and AllowUnknownDependencies() is enabled. - const FileDescriptor* NewPlaceholderFile(const string& name); - - // Calls tables_->AddSymbol() and records an error if it fails. Returns - // true if successful or false if failed, though most callers can ignore - // the return value since an error has already been recorded. - bool AddSymbol(const string& full_name, - const void* parent, const string& name, - const Message& proto, Symbol symbol); - - // Like AddSymbol(), but succeeds if the symbol is already defined as long - // as the existing definition is also a package (because it's OK to define - // the same package in two different files). Also adds all parents of the - // packgae to the symbol table (e.g. AddPackage("foo.bar", ...) will add - // "foo.bar" and "foo" to the table). - void AddPackage(const string& name, const Message& proto, - const FileDescriptor* file); - - // Checks that the symbol name contains only alphanumeric characters and - // underscores. Records an error otherwise. - void ValidateSymbolName(const string& name, const string& full_name, - const Message& proto); - - // Like ValidateSymbolName(), but the name is allowed to contain periods and - // an error is indicated by returning false (not recording the error). - bool ValidateQualifiedName(const string& name); - - // Used by BUILD_ARRAY macro (below) to avoid having to have the type - // specified as a macro parameter. - template - inline void AllocateArray(int size, Type** output) { - *output = tables_->AllocateArray(size); - } - - // Allocates a copy of orig_options in tables_ and stores it in the - // descriptor. Remembers its uninterpreted options, to be interpreted - // later. DescriptorT must be one of the Descriptor messages from - // descriptor.proto. - template void AllocateOptions( - const typename DescriptorT::OptionsType& orig_options, - DescriptorT* descriptor); - // Specialization for FileOptions. - void AllocateOptions(const FileOptions& orig_options, - FileDescriptor* descriptor); - - // Implementation for AllocateOptions(). Don't call this directly. - template void AllocateOptionsImpl( - const string& name_scope, - const string& element_name, - const typename DescriptorT::OptionsType& orig_options, - DescriptorT* descriptor); - - // These methods all have the same signature for the sake of the BUILD_ARRAY - // macro, below. - void BuildMessage(const DescriptorProto& proto, - const Descriptor* parent, - Descriptor* result); - void BuildFieldOrExtension(const FieldDescriptorProto& proto, - const Descriptor* parent, - FieldDescriptor* result, - bool is_extension); - void BuildField(const FieldDescriptorProto& proto, - const Descriptor* parent, - FieldDescriptor* result) { - BuildFieldOrExtension(proto, parent, result, false); - } - void BuildExtension(const FieldDescriptorProto& proto, - const Descriptor* parent, - FieldDescriptor* result) { - BuildFieldOrExtension(proto, parent, result, true); - } - void BuildExtensionRange(const DescriptorProto::ExtensionRange& proto, - const Descriptor* parent, - Descriptor::ExtensionRange* result); - void BuildEnum(const EnumDescriptorProto& proto, - const Descriptor* parent, - EnumDescriptor* result); - void BuildEnumValue(const EnumValueDescriptorProto& proto, - const EnumDescriptor* parent, - EnumValueDescriptor* result); - void BuildService(const ServiceDescriptorProto& proto, - const void* dummy, - ServiceDescriptor* result); - void BuildMethod(const MethodDescriptorProto& proto, - const ServiceDescriptor* parent, - MethodDescriptor* result); - - // Must be run only after building. - // - // NOTE: Options will not be available during cross-linking, as they - // have not yet been interpreted. Defer any handling of options to the - // Validate*Options methods. - void CrossLinkFile(FileDescriptor* file, const FileDescriptorProto& proto); - void CrossLinkMessage(Descriptor* message, const DescriptorProto& proto); - void CrossLinkField(FieldDescriptor* field, - const FieldDescriptorProto& proto); - void CrossLinkEnum(EnumDescriptor* enum_type, - const EnumDescriptorProto& proto); - void CrossLinkEnumValue(EnumValueDescriptor* enum_value, - const EnumValueDescriptorProto& proto); - void CrossLinkService(ServiceDescriptor* service, - const ServiceDescriptorProto& proto); - void CrossLinkMethod(MethodDescriptor* method, - const MethodDescriptorProto& proto); - - // Must be run only after cross-linking. - void InterpretOptions(); - - // A helper class for interpreting options. - class OptionInterpreter { - public: - // Creates an interpreter that operates in the context of the pool of the - // specified builder, which must not be NULL. We don't take ownership of the - // builder. - explicit OptionInterpreter(DescriptorBuilder* builder); - - ~OptionInterpreter(); - - // Interprets the uninterpreted options in the specified Options message. - // On error, calls AddError() on the underlying builder and returns false. - // Otherwise returns true. - bool InterpretOptions(OptionsToInterpret* options_to_interpret); - - class AggregateOptionFinder; - - private: - // Interprets uninterpreted_option_ on the specified message, which - // must be the mutable copy of the original options message to which - // uninterpreted_option_ belongs. - bool InterpretSingleOption(Message* options); - - // Adds the uninterpreted_option to the given options message verbatim. - // Used when AllowUnknownDependencies() is in effect and we can't find - // the option's definition. - void AddWithoutInterpreting(const UninterpretedOption& uninterpreted_option, - Message* options); - - // A recursive helper function that drills into the intermediate fields - // in unknown_fields to check if field innermost_field is set on the - // innermost message. Returns false and sets an error if so. - bool ExamineIfOptionIsSet( - vector::const_iterator intermediate_fields_iter, - vector::const_iterator intermediate_fields_end, - const FieldDescriptor* innermost_field, const string& debug_msg_name, - const UnknownFieldSet& unknown_fields); - - // Validates the value for the option field of the currently interpreted - // option and then sets it on the unknown_field. - bool SetOptionValue(const FieldDescriptor* option_field, - UnknownFieldSet* unknown_fields); - - // Parses an aggregate value for a CPPTYPE_MESSAGE option and - // saves it into *unknown_fields. - bool SetAggregateOption(const FieldDescriptor* option_field, - UnknownFieldSet* unknown_fields); - - // Convenience functions to set an int field the right way, depending on - // its wire type (a single int CppType can represent multiple wire types). - void SetInt32(int number, int32 value, FieldDescriptor::Type type, - UnknownFieldSet* unknown_fields); - void SetInt64(int number, int64 value, FieldDescriptor::Type type, - UnknownFieldSet* unknown_fields); - void SetUInt32(int number, uint32 value, FieldDescriptor::Type type, - UnknownFieldSet* unknown_fields); - void SetUInt64(int number, uint64 value, FieldDescriptor::Type type, - UnknownFieldSet* unknown_fields); - - // A helper function that adds an error at the specified location of the - // option we're currently interpreting, and returns false. - bool AddOptionError(DescriptorPool::ErrorCollector::ErrorLocation location, - const string& msg) { - builder_->AddError(options_to_interpret_->element_name, - *uninterpreted_option_, location, msg); - return false; - } - - // A helper function that adds an error at the location of the option name - // and returns false. - bool AddNameError(const string& msg) { - return AddOptionError(DescriptorPool::ErrorCollector::OPTION_NAME, msg); - } - - // A helper function that adds an error at the location of the option name - // and returns false. - bool AddValueError(const string& msg) { - return AddOptionError(DescriptorPool::ErrorCollector::OPTION_VALUE, msg); - } - - // We interpret against this builder's pool. Is never NULL. We don't own - // this pointer. - DescriptorBuilder* builder_; - - // The options we're currently interpreting, or NULL if we're not in a call - // to InterpretOptions. - const OptionsToInterpret* options_to_interpret_; - - // The option we're currently interpreting within options_to_interpret_, or - // NULL if we're not in a call to InterpretOptions(). This points to a - // submessage of the original option, not the mutable copy. Therefore we - // can use it to find locations recorded by the parser. - const UninterpretedOption* uninterpreted_option_; - - // Factory used to create the dynamic messages we need to parse - // any aggregate option values we encounter. - DynamicMessageFactory dynamic_factory_; - - GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(OptionInterpreter); - }; - - // Work-around for broken compilers: According to the C++ standard, - // OptionInterpreter should have access to the private members of any class - // which has declared DescriptorBuilder as a friend. Unfortunately some old - // versions of GCC and other compilers do not implement this correctly. So, - // we have to have these intermediate methods to provide access. We also - // redundantly declare OptionInterpreter a friend just to make things extra - // clear for these bad compilers. - friend class OptionInterpreter; - friend class OptionInterpreter::AggregateOptionFinder; - - static inline bool get_allow_unknown(const DescriptorPool* pool) { - return pool->allow_unknown_; - } - static inline bool get_is_placeholder(const Descriptor* descriptor) { - return descriptor->is_placeholder_; - } - static inline void assert_mutex_held(const DescriptorPool* pool) { - if (pool->mutex_ != NULL) { - pool->mutex_->AssertHeld(); - } - } - - // Must be run only after options have been interpreted. - // - // NOTE: Validation code must only reference the options in the mutable - // descriptors, which are the ones that have been interpreted. The const - // proto references are passed in only so they can be provided to calls to - // AddError(). Do not look at their options, which have not been interpreted. - void ValidateFileOptions(FileDescriptor* file, - const FileDescriptorProto& proto); - void ValidateMessageOptions(Descriptor* message, - const DescriptorProto& proto); - void ValidateFieldOptions(FieldDescriptor* field, - const FieldDescriptorProto& proto); - void ValidateEnumOptions(EnumDescriptor* enm, - const EnumDescriptorProto& proto); - void ValidateEnumValueOptions(EnumValueDescriptor* enum_value, - const EnumValueDescriptorProto& proto); - void ValidateServiceOptions(ServiceDescriptor* service, - const ServiceDescriptorProto& proto); - void ValidateMethodOptions(MethodDescriptor* method, - const MethodDescriptorProto& proto); - - void ValidateMapKey(FieldDescriptor* field, - const FieldDescriptorProto& proto); - -}; - -const FileDescriptor* DescriptorPool::BuildFile( - const FileDescriptorProto& proto) { - GOOGLE_CHECK(fallback_database_ == NULL) - << "Cannot call BuildFile on a DescriptorPool that uses a " - "DescriptorDatabase. You must instead find a way to get your file " - "into the underlying database."; - GOOGLE_CHECK(mutex_ == NULL); // Implied by the above GOOGLE_CHECK. - return DescriptorBuilder(this, tables_.get(), NULL).BuildFile(proto); -} - -const FileDescriptor* DescriptorPool::BuildFileCollectingErrors( - const FileDescriptorProto& proto, - ErrorCollector* error_collector) { - GOOGLE_CHECK(fallback_database_ == NULL) - << "Cannot call BuildFile on a DescriptorPool that uses a " - "DescriptorDatabase. You must instead find a way to get your file " - "into the underlying database."; - GOOGLE_CHECK(mutex_ == NULL); // Implied by the above GOOGLE_CHECK. - return DescriptorBuilder(this, tables_.get(), - error_collector).BuildFile(proto); -} - -const FileDescriptor* DescriptorPool::BuildFileFromDatabase( - const FileDescriptorProto& proto) const { - mutex_->AssertHeld(); - return DescriptorBuilder(this, tables_.get(), - default_error_collector_).BuildFile(proto); -} - -DescriptorBuilder::DescriptorBuilder( - const DescriptorPool* pool, - DescriptorPool::Tables* tables, - DescriptorPool::ErrorCollector* error_collector) - : pool_(pool), - tables_(tables), - error_collector_(error_collector), - had_errors_(false), - possible_undeclared_dependency_(NULL) {} - -DescriptorBuilder::~DescriptorBuilder() {} - -void DescriptorBuilder::AddError( - const string& element_name, - const Message& descriptor, - DescriptorPool::ErrorCollector::ErrorLocation location, - const string& error) { - if (error_collector_ == NULL) { - if (!had_errors_) { - GOOGLE_LOG(ERROR) << "Invalid proto descriptor for file \"" << filename_ - << "\":"; - } - GOOGLE_LOG(ERROR) << " " << element_name << ": " << error; - } else { - error_collector_->AddError(filename_, element_name, - &descriptor, location, error); - } - had_errors_ = true; -} - -void DescriptorBuilder::AddNotDefinedError( - const string& element_name, - const Message& descriptor, - DescriptorPool::ErrorCollector::ErrorLocation location, - const string& undefined_symbol) { - if (possible_undeclared_dependency_ == NULL) { - AddError(element_name, descriptor, location, - "\"" + undefined_symbol + "\" is not defined."); - } else { - AddError(element_name, descriptor, location, - "\"" + possible_undeclared_dependency_name_ + - "\" seems to be defined in \"" + - possible_undeclared_dependency_->name() + "\", which is not " - "imported by \"" + filename_ + "\". To use it here, please " - "add the necessary import."); - } -} - -bool DescriptorBuilder::IsInPackage(const FileDescriptor* file, - const string& package_name) { - return HasPrefixString(file->package(), package_name) && - (file->package().size() == package_name.size() || - file->package()[package_name.size()] == '.'); -} - -void DescriptorBuilder::RecordPublicDependencies(const FileDescriptor* file) { - if (file == NULL || !dependencies_.insert(file).second) return; - for (int i = 0; file != NULL && i < file->public_dependency_count(); i++) { - RecordPublicDependencies(file->public_dependency(i)); - } -} - -Symbol DescriptorBuilder::FindSymbolNotEnforcingDepsHelper( - const DescriptorPool* pool, const string& name) { - // If we are looking at an underlay, we must lock its mutex_, since we are - // accessing the underlay's tables_ directly. - MutexLockMaybe lock((pool == pool_) ? NULL : pool->mutex_); - - Symbol result = pool->tables_->FindSymbol(name); - if (result.IsNull() && pool->underlay_ != NULL) { - // Symbol not found; check the underlay. - result = FindSymbolNotEnforcingDepsHelper(pool->underlay_, name); - } - - if (result.IsNull()) { - // In theory, we shouldn't need to check fallback_database_ because the - // symbol should be in one of its file's direct dependencies, and we have - // already loaded those by the time we get here. But we check anyway so - // that we can generate better error message when dependencies are missing - // (i.e., "missing dependency" rather than "type is not defined"). - if (pool->TryFindSymbolInFallbackDatabase(name)) { - result = pool->tables_->FindSymbol(name); - } - } - - return result; -} - -Symbol DescriptorBuilder::FindSymbolNotEnforcingDeps(const string& name) { - return FindSymbolNotEnforcingDepsHelper(pool_, name); -} - -Symbol DescriptorBuilder::FindSymbol(const string& name) { - Symbol result = FindSymbolNotEnforcingDeps(name); - - if (result.IsNull()) return result; - - if (!pool_->enforce_dependencies_) { - // Hack for CompilerUpgrader. - return result; - } - - // Only find symbols which were defined in this file or one of its - // dependencies. - const FileDescriptor* file = result.GetFile(); - if (file == file_ || dependencies_.count(file) > 0) return result; - - if (result.type == Symbol::PACKAGE) { - // Arg, this is overcomplicated. The symbol is a package name. It could - // be that the package was defined in multiple files. result.GetFile() - // returns the first file we saw that used this package. We've determined - // that that file is not a direct dependency of the file we are currently - // building, but it could be that some other file which *is* a direct - // dependency also defines the same package. We can't really rule out this - // symbol unless none of the dependencies define it. - if (IsInPackage(file_, name)) return result; - for (set::const_iterator it = dependencies_.begin(); - it != dependencies_.end(); ++it) { - // Note: A dependency may be NULL if it was not found or had errors. - if (*it != NULL && IsInPackage(*it, name)) return result; - } - } - - possible_undeclared_dependency_ = file; - possible_undeclared_dependency_name_ = name; - return kNullSymbol; -} - -Symbol DescriptorBuilder::LookupSymbolNoPlaceholder( - const string& name, const string& relative_to, ResolveMode resolve_mode) { - possible_undeclared_dependency_ = NULL; - - if (name.size() > 0 && name[0] == '.') { - // Fully-qualified name. - return FindSymbol(name.substr(1)); - } - - // If name is something like "Foo.Bar.baz", and symbols named "Foo" are - // defined in multiple parent scopes, we only want to find "Bar.baz" in the - // innermost one. E.g., the following should produce an error: - // message Bar { message Baz {} } - // message Foo { - // message Bar { - // } - // optional Bar.Baz baz = 1; - // } - // So, we look for just "Foo" first, then look for "Bar.baz" within it if - // found. - string::size_type name_dot_pos = name.find_first_of('.'); - string first_part_of_name; - if (name_dot_pos == string::npos) { - first_part_of_name = name; - } else { - first_part_of_name = name.substr(0, name_dot_pos); - } - - string scope_to_try(relative_to); - - while (true) { - // Chop off the last component of the scope. - string::size_type dot_pos = scope_to_try.find_last_of('.'); - if (dot_pos == string::npos) { - return FindSymbol(name); - } else { - scope_to_try.erase(dot_pos); - } - - // Append ".first_part_of_name" and try to find. - string::size_type old_size = scope_to_try.size(); - scope_to_try.append(1, '.'); - scope_to_try.append(first_part_of_name); - Symbol result = FindSymbol(scope_to_try); - if (!result.IsNull()) { - if (first_part_of_name.size() < name.size()) { - // name is a compound symbol, of which we only found the first part. - // Now try to look up the rest of it. - if (result.IsAggregate()) { - scope_to_try.append(name, first_part_of_name.size(), - name.size() - first_part_of_name.size()); - return FindSymbol(scope_to_try); - } else { - // We found a symbol but it's not an aggregate. Continue the loop. - } - } else { - if (resolve_mode == LOOKUP_TYPES && !result.IsType()) { - // We found a symbol but it's not a type. Continue the loop. - } else { - return result; - } - } - } - - // Not found. Remove the name so we can try again. - scope_to_try.erase(old_size); - } -} - -Symbol DescriptorBuilder::LookupSymbol( - const string& name, const string& relative_to, - PlaceholderType placeholder_type, ResolveMode resolve_mode) { - Symbol result = LookupSymbolNoPlaceholder( - name, relative_to, resolve_mode); - if (result.IsNull() && pool_->allow_unknown_) { - // Not found, but AllowUnknownDependencies() is enabled. Return a - // placeholder instead. - result = NewPlaceholder(name, placeholder_type); - } - return result; -} - -Symbol DescriptorBuilder::NewPlaceholder(const string& name, - PlaceholderType placeholder_type) { - // Compute names. - const string* placeholder_full_name; - const string* placeholder_name; - const string* placeholder_package; - - if (!ValidateQualifiedName(name)) return kNullSymbol; - if (name[0] == '.') { - // Fully-qualified. - placeholder_full_name = tables_->AllocateString(name.substr(1)); - } else { - placeholder_full_name = tables_->AllocateString(name); - } - - string::size_type dotpos = placeholder_full_name->find_last_of('.'); - if (dotpos != string::npos) { - placeholder_package = tables_->AllocateString( - placeholder_full_name->substr(0, dotpos)); - placeholder_name = tables_->AllocateString( - placeholder_full_name->substr(dotpos + 1)); - } else { - placeholder_package = &kEmptyString; - placeholder_name = placeholder_full_name; - } - - // Create the placeholders. - FileDescriptor* placeholder_file = tables_->Allocate(); - memset(placeholder_file, 0, sizeof(*placeholder_file)); - - placeholder_file->source_code_info_ = &SourceCodeInfo::default_instance(); - - placeholder_file->name_ = - tables_->AllocateString(*placeholder_full_name + ".placeholder.proto"); - placeholder_file->package_ = placeholder_package; - placeholder_file->pool_ = pool_; - placeholder_file->options_ = &FileOptions::default_instance(); - placeholder_file->tables_ = &FileDescriptorTables::kEmpty; - // All other fields are zero or NULL. - - if (placeholder_type == PLACEHOLDER_ENUM) { - placeholder_file->enum_type_count_ = 1; - placeholder_file->enum_types_ = - tables_->AllocateArray(1); - - EnumDescriptor* placeholder_enum = &placeholder_file->enum_types_[0]; - memset(placeholder_enum, 0, sizeof(*placeholder_enum)); - - placeholder_enum->full_name_ = placeholder_full_name; - placeholder_enum->name_ = placeholder_name; - placeholder_enum->file_ = placeholder_file; - placeholder_enum->options_ = &EnumOptions::default_instance(); - placeholder_enum->is_placeholder_ = true; - placeholder_enum->is_unqualified_placeholder_ = (name[0] != '.'); - - // Enums must have at least one value. - placeholder_enum->value_count_ = 1; - placeholder_enum->values_ = tables_->AllocateArray(1); - - EnumValueDescriptor* placeholder_value = &placeholder_enum->values_[0]; - memset(placeholder_value, 0, sizeof(*placeholder_value)); - - placeholder_value->name_ = tables_->AllocateString("PLACEHOLDER_VALUE"); - // Note that enum value names are siblings of their type, not children. - placeholder_value->full_name_ = - placeholder_package->empty() ? placeholder_value->name_ : - tables_->AllocateString(*placeholder_package + ".PLACEHOLDER_VALUE"); - - placeholder_value->number_ = 0; - placeholder_value->type_ = placeholder_enum; - placeholder_value->options_ = &EnumValueOptions::default_instance(); - - return Symbol(placeholder_enum); - } else { - placeholder_file->message_type_count_ = 1; - placeholder_file->message_types_ = - tables_->AllocateArray(1); - - Descriptor* placeholder_message = &placeholder_file->message_types_[0]; - memset(placeholder_message, 0, sizeof(*placeholder_message)); - - placeholder_message->full_name_ = placeholder_full_name; - placeholder_message->name_ = placeholder_name; - placeholder_message->file_ = placeholder_file; - placeholder_message->options_ = &MessageOptions::default_instance(); - placeholder_message->is_placeholder_ = true; - placeholder_message->is_unqualified_placeholder_ = (name[0] != '.'); - - if (placeholder_type == PLACEHOLDER_EXTENDABLE_MESSAGE) { - placeholder_message->extension_range_count_ = 1; - placeholder_message->extension_ranges_ = - tables_->AllocateArray(1); - placeholder_message->extension_ranges_->start = 1; - // kMaxNumber + 1 because ExtensionRange::end is exclusive. - placeholder_message->extension_ranges_->end = - FieldDescriptor::kMaxNumber + 1; - } - - return Symbol(placeholder_message); - } -} - -const FileDescriptor* DescriptorBuilder::NewPlaceholderFile( - const string& name) { - FileDescriptor* placeholder = tables_->Allocate(); - memset(placeholder, 0, sizeof(*placeholder)); - - placeholder->name_ = tables_->AllocateString(name); - placeholder->package_ = &kEmptyString; - placeholder->pool_ = pool_; - placeholder->options_ = &FileOptions::default_instance(); - placeholder->tables_ = &FileDescriptorTables::kEmpty; - // All other fields are zero or NULL. - - return placeholder; -} - -bool DescriptorBuilder::AddSymbol( - const string& full_name, const void* parent, const string& name, - const Message& proto, Symbol symbol) { - // If the caller passed NULL for the parent, the symbol is at file scope. - // Use its file as the parent instead. - if (parent == NULL) parent = file_; - - if (tables_->AddSymbol(full_name, symbol)) { - if (!file_tables_->AddAliasUnderParent(parent, name, symbol)) { - GOOGLE_LOG(DFATAL) << "\"" << full_name << "\" not previously defined in " - "symbols_by_name_, but was defined in symbols_by_parent_; " - "this shouldn't be possible."; - return false; - } - return true; - } else { - const FileDescriptor* other_file = tables_->FindSymbol(full_name).GetFile(); - if (other_file == file_) { - string::size_type dot_pos = full_name.find_last_of('.'); - if (dot_pos == string::npos) { - AddError(full_name, proto, DescriptorPool::ErrorCollector::NAME, - "\"" + full_name + "\" is already defined."); - } else { - AddError(full_name, proto, DescriptorPool::ErrorCollector::NAME, - "\"" + full_name.substr(dot_pos + 1) + - "\" is already defined in \"" + - full_name.substr(0, dot_pos) + "\"."); - } - } else { - // Symbol seems to have been defined in a different file. - AddError(full_name, proto, DescriptorPool::ErrorCollector::NAME, - "\"" + full_name + "\" is already defined in file \"" + - other_file->name() + "\"."); - } - return false; - } -} - -void DescriptorBuilder::AddPackage( - const string& name, const Message& proto, const FileDescriptor* file) { - if (tables_->AddSymbol(name, Symbol(file))) { - // Success. Also add parent package, if any. - string::size_type dot_pos = name.find_last_of('.'); - if (dot_pos == string::npos) { - // No parents. - ValidateSymbolName(name, name, proto); - } else { - // Has parent. - string* parent_name = tables_->AllocateString(name.substr(0, dot_pos)); - AddPackage(*parent_name, proto, file); - ValidateSymbolName(name.substr(dot_pos + 1), name, proto); - } - } else { - Symbol existing_symbol = tables_->FindSymbol(name); - // It's OK to redefine a package. - if (existing_symbol.type != Symbol::PACKAGE) { - // Symbol seems to have been defined in a different file. - AddError(name, proto, DescriptorPool::ErrorCollector::NAME, - "\"" + name + "\" is already defined (as something other than " - "a package) in file \"" + existing_symbol.GetFile()->name() + - "\"."); - } - } -} - -void DescriptorBuilder::ValidateSymbolName( - const string& name, const string& full_name, const Message& proto) { - if (name.empty()) { - AddError(full_name, proto, DescriptorPool::ErrorCollector::NAME, - "Missing name."); - } else { - for (int i = 0; i < name.size(); i++) { - // I don't trust isalnum() due to locales. :( - if ((name[i] < 'a' || 'z' < name[i]) && - (name[i] < 'A' || 'Z' < name[i]) && - (name[i] < '0' || '9' < name[i]) && - (name[i] != '_')) { - AddError(full_name, proto, DescriptorPool::ErrorCollector::NAME, - "\"" + name + "\" is not a valid identifier."); - } - } - } -} - -bool DescriptorBuilder::ValidateQualifiedName(const string& name) { - bool last_was_period = false; - - for (int i = 0; i < name.size(); i++) { - // I don't trust isalnum() due to locales. :( - if (('a' <= name[i] && name[i] <= 'z') || - ('A' <= name[i] && name[i] <= 'Z') || - ('0' <= name[i] && name[i] <= '9') || - (name[i] == '_')) { - last_was_period = false; - } else if (name[i] == '.') { - if (last_was_period) return false; - last_was_period = true; - } else { - return false; - } - } - - return !name.empty() && !last_was_period; -} - -// ------------------------------------------------------------------- - -// This generic implementation is good for all descriptors except -// FileDescriptor. -template void DescriptorBuilder::AllocateOptions( - const typename DescriptorT::OptionsType& orig_options, - DescriptorT* descriptor) { - AllocateOptionsImpl(descriptor->full_name(), descriptor->full_name(), - orig_options, descriptor); -} - -// We specialize for FileDescriptor. -void DescriptorBuilder::AllocateOptions(const FileOptions& orig_options, - FileDescriptor* descriptor) { - // We add the dummy token so that LookupSymbol does the right thing. - AllocateOptionsImpl(descriptor->package() + ".dummy", descriptor->name(), - orig_options, descriptor); -} - -template void DescriptorBuilder::AllocateOptionsImpl( - const string& name_scope, - const string& element_name, - const typename DescriptorT::OptionsType& orig_options, - DescriptorT* descriptor) { - // We need to use a dummy pointer to work around a bug in older versions of - // GCC. Otherwise, the following two lines could be replaced with: - // typename DescriptorT::OptionsType* options = - // tables_->AllocateMessage(); - typename DescriptorT::OptionsType* const dummy = NULL; - typename DescriptorT::OptionsType* options = tables_->AllocateMessage(dummy); - // Avoid using MergeFrom()/CopyFrom() in this class to make it -fno-rtti - // friendly. Without RTTI, MergeFrom() and CopyFrom() will fallback to the - // reflection based method, which requires the Descriptor. However, we are in - // the middle of building the descriptors, thus the deadlock. - options->ParseFromString(orig_options.SerializeAsString()); - descriptor->options_ = options; - - // Don't add to options_to_interpret_ unless there were uninterpreted - // options. This not only avoids unnecessary work, but prevents a - // bootstrapping problem when building descriptors for descriptor.proto. - // descriptor.proto does not contain any uninterpreted options, but - // attempting to interpret options anyway will cause - // OptionsType::GetDescriptor() to be called which may then deadlock since - // we're still trying to build it. - if (options->uninterpreted_option_size() > 0) { - options_to_interpret_.push_back( - OptionsToInterpret(name_scope, element_name, &orig_options, options)); - } -} - - -// A common pattern: We want to convert a repeated field in the descriptor -// to an array of values, calling some method to build each value. -#define BUILD_ARRAY(INPUT, OUTPUT, NAME, METHOD, PARENT) \ - OUTPUT->NAME##_count_ = INPUT.NAME##_size(); \ - AllocateArray(INPUT.NAME##_size(), &OUTPUT->NAME##s_); \ - for (int i = 0; i < INPUT.NAME##_size(); i++) { \ - METHOD(INPUT.NAME(i), PARENT, OUTPUT->NAME##s_ + i); \ - } - -const FileDescriptor* DescriptorBuilder::BuildFile( - const FileDescriptorProto& proto) { - filename_ = proto.name(); - - // Check if the file already exists and is identical to the one being built. - // Note: This only works if the input is canonical -- that is, it - // fully-qualifies all type names, has no UninterpretedOptions, etc. - // This is fine, because this idempotency "feature" really only exists to - // accomodate one hack in the proto1->proto2 migration layer. - const FileDescriptor* existing_file = tables_->FindFile(filename_); - if (existing_file != NULL) { - // File already in pool. Compare the existing one to the input. - FileDescriptorProto existing_proto; - existing_file->CopyTo(&existing_proto); - if (existing_proto.SerializeAsString() == proto.SerializeAsString()) { - // They're identical. Return the existing descriptor. - return existing_file; - } - - // Not a match. The error will be detected and handled later. - } - - // Check to see if this file is already on the pending files list. - // TODO(kenton): Allow recursive imports? It may not work with some - // (most?) programming languages. E.g., in C++, a forward declaration - // of a type is not sufficient to allow it to be used even in a - // generated header file due to inlining. This could perhaps be - // worked around using tricks involving inserting #include statements - // mid-file, but that's pretty ugly, and I'm pretty sure there are - // some languages out there that do not allow recursive dependencies - // at all. - for (int i = 0; i < tables_->pending_files_.size(); i++) { - if (tables_->pending_files_[i] == proto.name()) { - string error_message("File recursively imports itself: "); - for (; i < tables_->pending_files_.size(); i++) { - error_message.append(tables_->pending_files_[i]); - error_message.append(" -> "); - } - error_message.append(proto.name()); - - AddError(proto.name(), proto, DescriptorPool::ErrorCollector::OTHER, - error_message); - return NULL; - } - } - - // If we have a fallback_database_, attempt to load all dependencies now, - // before checkpointing tables_. This avoids confusion with recursive - // checkpoints. - if (pool_->fallback_database_ != NULL) { - tables_->pending_files_.push_back(proto.name()); - for (int i = 0; i < proto.dependency_size(); i++) { - if (tables_->FindFile(proto.dependency(i)) == NULL && - (pool_->underlay_ == NULL || - pool_->underlay_->FindFileByName(proto.dependency(i)) == NULL)) { - // We don't care what this returns since we'll find out below anyway. - pool_->TryFindFileInFallbackDatabase(proto.dependency(i)); - } - } - tables_->pending_files_.pop_back(); - } - - // Checkpoint the tables so that we can roll back if something goes wrong. - tables_->AddCheckpoint(); - - FileDescriptor* result = tables_->Allocate(); - file_ = result; - - if (proto.has_source_code_info()) { - SourceCodeInfo *info = tables_->AllocateMessage(); - info->CopyFrom(proto.source_code_info()); - result->source_code_info_ = info; - } else { - result->source_code_info_ = &SourceCodeInfo::default_instance(); - } - - file_tables_ = tables_->AllocateFileTables(); - file_->tables_ = file_tables_; - - if (!proto.has_name()) { - AddError("", proto, DescriptorPool::ErrorCollector::OTHER, - "Missing field: FileDescriptorProto.name."); - } - - result->name_ = tables_->AllocateString(proto.name()); - if (proto.has_package()) { - result->package_ = tables_->AllocateString(proto.package()); - } else { - // We cannot rely on proto.package() returning a valid string if - // proto.has_package() is false, because we might be running at static - // initialization time, in which case default values have not yet been - // initialized. - result->package_ = tables_->AllocateString(""); - } - result->pool_ = pool_; - - // Add to tables. - if (!tables_->AddFile(result)) { - AddError(proto.name(), proto, DescriptorPool::ErrorCollector::OTHER, - "A file with this name is already in the pool."); - // Bail out early so that if this is actually the exact same file, we - // don't end up reporting that every single symbol is already defined. - tables_->RollbackToLastCheckpoint(); - return NULL; - } - if (!result->package().empty()) { - AddPackage(result->package(), proto, result); - } - - // Make sure all dependencies are loaded. - set seen_dependencies; - result->dependency_count_ = proto.dependency_size(); - result->dependencies_ = - tables_->AllocateArray(proto.dependency_size()); - for (int i = 0; i < proto.dependency_size(); i++) { - if (!seen_dependencies.insert(proto.dependency(i)).second) { - AddError(proto.name(), proto, - DescriptorPool::ErrorCollector::OTHER, - "Import \"" + proto.dependency(i) + "\" was listed twice."); - } - - const FileDescriptor* dependency = tables_->FindFile(proto.dependency(i)); - if (dependency == NULL && pool_->underlay_ != NULL) { - dependency = pool_->underlay_->FindFileByName(proto.dependency(i)); - } - - if (dependency == NULL) { - if (pool_->allow_unknown_) { - dependency = NewPlaceholderFile(proto.dependency(i)); - } else { - string message; - if (pool_->fallback_database_ == NULL) { - message = "Import \"" + proto.dependency(i) + - "\" has not been loaded."; - } else { - message = "Import \"" + proto.dependency(i) + - "\" was not found or had errors."; - } - AddError(proto.name(), proto, - DescriptorPool::ErrorCollector::OTHER, - message); - } - } - - result->dependencies_[i] = dependency; - } - - // Check public dependencies. - int public_dependency_count = 0; - result->public_dependencies_ = tables_->AllocateArray( - proto.public_dependency_size()); - for (int i = 0; i < proto.public_dependency_size(); i++) { - // Only put valid public dependency indexes. - int index = proto.public_dependency(i); - if (index >= 0 && index < proto.dependency_size()) { - result->public_dependencies_[public_dependency_count++] = index; - } else { - AddError(proto.name(), proto, - DescriptorPool::ErrorCollector::OTHER, - "Invalid public dependency index."); - } - } - result->public_dependency_count_ = public_dependency_count; - - // Build dependency set - dependencies_.clear(); - for (int i = 0; i < result->dependency_count(); i++) { - RecordPublicDependencies(result->dependency(i)); - } - - // Check weak dependencies. - int weak_dependency_count = 0; - result->weak_dependencies_ = tables_->AllocateArray( - proto.weak_dependency_size()); - for (int i = 0; i < proto.weak_dependency_size(); i++) { - int index = proto.weak_dependency(i); - if (index >= 0 && index < proto.dependency_size()) { - result->weak_dependencies_[weak_dependency_count++] = index; - } else { - AddError(proto.name(), proto, - DescriptorPool::ErrorCollector::OTHER, - "Invalid weak dependency index."); - } - } - result->weak_dependency_count_ = weak_dependency_count; - - // Convert children. - BUILD_ARRAY(proto, result, message_type, BuildMessage , NULL); - BUILD_ARRAY(proto, result, enum_type , BuildEnum , NULL); - BUILD_ARRAY(proto, result, service , BuildService , NULL); - BUILD_ARRAY(proto, result, extension , BuildExtension, NULL); - - // Copy options. - if (!proto.has_options()) { - result->options_ = NULL; // Will set to default_instance later. - } else { - AllocateOptions(proto.options(), result); - } - - // Note that the following steps must occur in exactly the specified order. - - // Cross-link. - CrossLinkFile(result, proto); - - // Interpret any remaining uninterpreted options gathered into - // options_to_interpret_ during descriptor building. Cross-linking has made - // extension options known, so all interpretations should now succeed. - if (!had_errors_) { - OptionInterpreter option_interpreter(this); - for (vector::iterator iter = - options_to_interpret_.begin(); - iter != options_to_interpret_.end(); ++iter) { - option_interpreter.InterpretOptions(&(*iter)); - } - options_to_interpret_.clear(); - } - - // Validate options. - if (!had_errors_) { - ValidateFileOptions(result, proto); - } - - if (had_errors_) { - tables_->RollbackToLastCheckpoint(); - return NULL; - } else { - tables_->ClearLastCheckpoint(); - return result; - } -} - -void DescriptorBuilder::BuildMessage(const DescriptorProto& proto, - const Descriptor* parent, - Descriptor* result) { - const string& scope = (parent == NULL) ? - file_->package() : parent->full_name(); - string* full_name = tables_->AllocateString(scope); - if (!full_name->empty()) full_name->append(1, '.'); - full_name->append(proto.name()); - - ValidateSymbolName(proto.name(), *full_name, proto); - - result->name_ = tables_->AllocateString(proto.name()); - result->full_name_ = full_name; - result->file_ = file_; - result->containing_type_ = parent; - result->is_placeholder_ = false; - result->is_unqualified_placeholder_ = false; - - BUILD_ARRAY(proto, result, field , BuildField , result); - BUILD_ARRAY(proto, result, nested_type , BuildMessage , result); - BUILD_ARRAY(proto, result, enum_type , BuildEnum , result); - BUILD_ARRAY(proto, result, extension_range, BuildExtensionRange, result); - BUILD_ARRAY(proto, result, extension , BuildExtension , result); - - // Copy options. - if (!proto.has_options()) { - result->options_ = NULL; // Will set to default_instance later. - } else { - AllocateOptions(proto.options(), result); - } - - AddSymbol(result->full_name(), parent, result->name(), - proto, Symbol(result)); - - // Check that no fields have numbers in extension ranges. - for (int i = 0; i < result->field_count(); i++) { - const FieldDescriptor* field = result->field(i); - for (int j = 0; j < result->extension_range_count(); j++) { - const Descriptor::ExtensionRange* range = result->extension_range(j); - if (range->start <= field->number() && field->number() < range->end) { - AddError(field->full_name(), proto.extension_range(j), - DescriptorPool::ErrorCollector::NUMBER, - strings::Substitute( - "Extension range $0 to $1 includes field \"$2\" ($3).", - range->start, range->end - 1, - field->name(), field->number())); - } - } - } - - // Check that extension ranges don't overlap. - for (int i = 0; i < result->extension_range_count(); i++) { - const Descriptor::ExtensionRange* range1 = result->extension_range(i); - for (int j = i + 1; j < result->extension_range_count(); j++) { - const Descriptor::ExtensionRange* range2 = result->extension_range(j); - if (range1->end > range2->start && range2->end > range1->start) { - AddError(result->full_name(), proto.extension_range(j), - DescriptorPool::ErrorCollector::NUMBER, - strings::Substitute("Extension range $0 to $1 overlaps with " - "already-defined range $2 to $3.", - range2->start, range2->end - 1, - range1->start, range1->end - 1)); - } - } - } -} - -void DescriptorBuilder::BuildFieldOrExtension(const FieldDescriptorProto& proto, - const Descriptor* parent, - FieldDescriptor* result, - bool is_extension) { - const string& scope = (parent == NULL) ? - file_->package() : parent->full_name(); - string* full_name = tables_->AllocateString(scope); - if (!full_name->empty()) full_name->append(1, '.'); - full_name->append(proto.name()); - - ValidateSymbolName(proto.name(), *full_name, proto); - - result->name_ = tables_->AllocateString(proto.name()); - result->full_name_ = full_name; - result->file_ = file_; - result->number_ = proto.number(); - result->is_extension_ = is_extension; - - // If .proto files follow the style guide then the name should already be - // lower-cased. If that's the case we can just reuse the string we already - // allocated rather than allocate a new one. - string lowercase_name(proto.name()); - LowerString(&lowercase_name); - if (lowercase_name == proto.name()) { - result->lowercase_name_ = result->name_; - } else { - result->lowercase_name_ = tables_->AllocateString(lowercase_name); - } - - // Don't bother with the above optimization for camel-case names since - // .proto files that follow the guide shouldn't be using names in this - // format, so the optimization wouldn't help much. - result->camelcase_name_ = tables_->AllocateString(ToCamelCase(proto.name())); - - // Some compilers do not allow static_cast directly between two enum types, - // so we must cast to int first. - result->type_ = static_cast( - implicit_cast(proto.type())); - result->label_ = static_cast( - implicit_cast(proto.label())); - - // Some of these may be filled in when cross-linking. - result->containing_type_ = NULL; - result->extension_scope_ = NULL; - result->experimental_map_key_ = NULL; - result->message_type_ = NULL; - result->enum_type_ = NULL; - - result->has_default_value_ = proto.has_default_value(); - if (proto.has_default_value() && result->is_repeated()) { - AddError(result->full_name(), proto, - DescriptorPool::ErrorCollector::DEFAULT_VALUE, - "Repeated fields can't have default values."); - } - - if (proto.has_type()) { - if (proto.has_default_value()) { - char* end_pos = NULL; - switch (result->cpp_type()) { - case FieldDescriptor::CPPTYPE_INT32: - result->default_value_int32_ = - strtol(proto.default_value().c_str(), &end_pos, 0); - break; - case FieldDescriptor::CPPTYPE_INT64: - result->default_value_int64_ = - strto64(proto.default_value().c_str(), &end_pos, 0); - break; - case FieldDescriptor::CPPTYPE_UINT32: - result->default_value_uint32_ = - strtoul(proto.default_value().c_str(), &end_pos, 0); - break; - case FieldDescriptor::CPPTYPE_UINT64: - result->default_value_uint64_ = - strtou64(proto.default_value().c_str(), &end_pos, 0); - break; - case FieldDescriptor::CPPTYPE_FLOAT: - if (proto.default_value() == "inf") { - result->default_value_float_ = numeric_limits::infinity(); - } else if (proto.default_value() == "-inf") { - result->default_value_float_ = -numeric_limits::infinity(); - } else if (proto.default_value() == "nan") { - result->default_value_float_ = numeric_limits::quiet_NaN(); - } else { - result->default_value_float_ = - NoLocaleStrtod(proto.default_value().c_str(), &end_pos); - } - break; - case FieldDescriptor::CPPTYPE_DOUBLE: - if (proto.default_value() == "inf") { - result->default_value_double_ = numeric_limits::infinity(); - } else if (proto.default_value() == "-inf") { - result->default_value_double_ = -numeric_limits::infinity(); - } else if (proto.default_value() == "nan") { - result->default_value_double_ = numeric_limits::quiet_NaN(); - } else { - result->default_value_double_ = - NoLocaleStrtod(proto.default_value().c_str(), &end_pos); - } - break; - case FieldDescriptor::CPPTYPE_BOOL: - if (proto.default_value() == "true") { - result->default_value_bool_ = true; - } else if (proto.default_value() == "false") { - result->default_value_bool_ = false; - } else { - AddError(result->full_name(), proto, - DescriptorPool::ErrorCollector::DEFAULT_VALUE, - "Boolean default must be true or false."); - } - break; - case FieldDescriptor::CPPTYPE_ENUM: - // This will be filled in when cross-linking. - result->default_value_enum_ = NULL; - break; - case FieldDescriptor::CPPTYPE_STRING: - if (result->type() == FieldDescriptor::TYPE_BYTES) { - result->default_value_string_ = tables_->AllocateString( - UnescapeCEscapeString(proto.default_value())); - } else { - result->default_value_string_ = - tables_->AllocateString(proto.default_value()); - } - break; - case FieldDescriptor::CPPTYPE_MESSAGE: - AddError(result->full_name(), proto, - DescriptorPool::ErrorCollector::DEFAULT_VALUE, - "Messages can't have default values."); - result->has_default_value_ = false; - break; - } - - if (end_pos != NULL) { - // end_pos is only set non-NULL by the parsers for numeric types, above. - // This checks that the default was non-empty and had no extra junk - // after the end of the number. - if (proto.default_value().empty() || *end_pos != '\0') { - AddError(result->full_name(), proto, - DescriptorPool::ErrorCollector::DEFAULT_VALUE, - "Couldn't parse default value."); - } - } - } else { - // No explicit default value - switch (result->cpp_type()) { - case FieldDescriptor::CPPTYPE_INT32: - result->default_value_int32_ = 0; - break; - case FieldDescriptor::CPPTYPE_INT64: - result->default_value_int64_ = 0; - break; - case FieldDescriptor::CPPTYPE_UINT32: - result->default_value_uint32_ = 0; - break; - case FieldDescriptor::CPPTYPE_UINT64: - result->default_value_uint64_ = 0; - break; - case FieldDescriptor::CPPTYPE_FLOAT: - result->default_value_float_ = 0.0f; - break; - case FieldDescriptor::CPPTYPE_DOUBLE: - result->default_value_double_ = 0.0; - break; - case FieldDescriptor::CPPTYPE_BOOL: - result->default_value_bool_ = false; - break; - case FieldDescriptor::CPPTYPE_ENUM: - // This will be filled in when cross-linking. - result->default_value_enum_ = NULL; - break; - case FieldDescriptor::CPPTYPE_STRING: - result->default_value_string_ = &kEmptyString; - break; - case FieldDescriptor::CPPTYPE_MESSAGE: - break; - } - } - } - - if (result->number() <= 0) { - AddError(result->full_name(), proto, DescriptorPool::ErrorCollector::NUMBER, - "Field numbers must be positive integers."); - } else if (!is_extension && result->number() > FieldDescriptor::kMaxNumber) { - // Only validate that the number is within the valid field range if it is - // not an extension. Since extension numbers are validated with the - // extendee's valid set of extension numbers, and those are in turn - // validated against the max allowed number, the check is unnecessary for - // extension fields. - // This avoids cross-linking issues that arise when attempting to check if - // the extendee is a message_set_wire_format message, which has a higher max - // on extension numbers. - AddError(result->full_name(), proto, DescriptorPool::ErrorCollector::NUMBER, - strings::Substitute("Field numbers cannot be greater than $0.", - FieldDescriptor::kMaxNumber)); - } else if (result->number() >= FieldDescriptor::kFirstReservedNumber && - result->number() <= FieldDescriptor::kLastReservedNumber) { - AddError(result->full_name(), proto, DescriptorPool::ErrorCollector::NUMBER, - strings::Substitute( - "Field numbers $0 through $1 are reserved for the protocol " - "buffer library implementation.", - FieldDescriptor::kFirstReservedNumber, - FieldDescriptor::kLastReservedNumber)); - } - - if (is_extension) { - if (!proto.has_extendee()) { - AddError(result->full_name(), proto, - DescriptorPool::ErrorCollector::EXTENDEE, - "FieldDescriptorProto.extendee not set for extension field."); - } - - result->extension_scope_ = parent; - } else { - if (proto.has_extendee()) { - AddError(result->full_name(), proto, - DescriptorPool::ErrorCollector::EXTENDEE, - "FieldDescriptorProto.extendee set for non-extension field."); - } - - result->containing_type_ = parent; - } - - // Copy options. - if (!proto.has_options()) { - result->options_ = NULL; // Will set to default_instance later. - } else { - AllocateOptions(proto.options(), result); - } - - AddSymbol(result->full_name(), parent, result->name(), - proto, Symbol(result)); -} - -void DescriptorBuilder::BuildExtensionRange( - const DescriptorProto::ExtensionRange& proto, - const Descriptor* parent, - Descriptor::ExtensionRange* result) { - result->start = proto.start(); - result->end = proto.end(); - if (result->start <= 0) { - AddError(parent->full_name(), proto, - DescriptorPool::ErrorCollector::NUMBER, - "Extension numbers must be positive integers."); - } - - // Checking of the upper bound of the extension range is deferred until after - // options interpreting. This allows messages with message_set_wire_format to - // have extensions beyond FieldDescriptor::kMaxNumber, since the extension - // numbers are actually used as int32s in the message_set_wire_format. - - if (result->start >= result->end) { - AddError(parent->full_name(), proto, - DescriptorPool::ErrorCollector::NUMBER, - "Extension range end number must be greater than start number."); - } -} - -void DescriptorBuilder::BuildEnum(const EnumDescriptorProto& proto, - const Descriptor* parent, - EnumDescriptor* result) { - const string& scope = (parent == NULL) ? - file_->package() : parent->full_name(); - string* full_name = tables_->AllocateString(scope); - if (!full_name->empty()) full_name->append(1, '.'); - full_name->append(proto.name()); - - ValidateSymbolName(proto.name(), *full_name, proto); - - result->name_ = tables_->AllocateString(proto.name()); - result->full_name_ = full_name; - result->file_ = file_; - result->containing_type_ = parent; - result->is_placeholder_ = false; - result->is_unqualified_placeholder_ = false; - - if (proto.value_size() == 0) { - // We cannot allow enums with no values because this would mean there - // would be no valid default value for fields of this type. - AddError(result->full_name(), proto, - DescriptorPool::ErrorCollector::NAME, - "Enums must contain at least one value."); - } - - BUILD_ARRAY(proto, result, value, BuildEnumValue, result); - - // Copy options. - if (!proto.has_options()) { - result->options_ = NULL; // Will set to default_instance later. - } else { - AllocateOptions(proto.options(), result); - } - - AddSymbol(result->full_name(), parent, result->name(), - proto, Symbol(result)); -} - -void DescriptorBuilder::BuildEnumValue(const EnumValueDescriptorProto& proto, - const EnumDescriptor* parent, - EnumValueDescriptor* result) { - result->name_ = tables_->AllocateString(proto.name()); - result->number_ = proto.number(); - result->type_ = parent; - - // Note: full_name for enum values is a sibling to the parent's name, not a - // child of it. - string* full_name = tables_->AllocateString(*parent->full_name_); - full_name->resize(full_name->size() - parent->name_->size()); - full_name->append(*result->name_); - result->full_name_ = full_name; - - ValidateSymbolName(proto.name(), *full_name, proto); - - // Copy options. - if (!proto.has_options()) { - result->options_ = NULL; // Will set to default_instance later. - } else { - AllocateOptions(proto.options(), result); - } - - // Again, enum values are weird because we makes them appear as siblings - // of the enum type instead of children of it. So, we use - // parent->containing_type() as the value's parent. - bool added_to_outer_scope = - AddSymbol(result->full_name(), parent->containing_type(), result->name(), - proto, Symbol(result)); - - // However, we also want to be able to search for values within a single - // enum type, so we add it as a child of the enum type itself, too. - // Note: This could fail, but if it does, the error has already been - // reported by the above AddSymbol() call, so we ignore the return code. - bool added_to_inner_scope = - file_tables_->AddAliasUnderParent(parent, result->name(), Symbol(result)); - - if (added_to_inner_scope && !added_to_outer_scope) { - // This value did not conflict with any values defined in the same enum, - // but it did conflict with some other symbol defined in the enum type's - // scope. Let's print an additional error to explain this. - string outer_scope; - if (parent->containing_type() == NULL) { - outer_scope = file_->package(); - } else { - outer_scope = parent->containing_type()->full_name(); - } - - if (outer_scope.empty()) { - outer_scope = "the global scope"; - } else { - outer_scope = "\"" + outer_scope + "\""; - } - - AddError(result->full_name(), proto, - DescriptorPool::ErrorCollector::NAME, - "Note that enum values use C++ scoping rules, meaning that " - "enum values are siblings of their type, not children of it. " - "Therefore, \"" + result->name() + "\" must be unique within " - + outer_scope + ", not just within \"" + parent->name() + "\"."); - } - - // An enum is allowed to define two numbers that refer to the same value. - // FindValueByNumber() should return the first such value, so we simply - // ignore AddEnumValueByNumber()'s return code. - file_tables_->AddEnumValueByNumber(result); -} - -void DescriptorBuilder::BuildService(const ServiceDescriptorProto& proto, - const void* dummy, - ServiceDescriptor* result) { - string* full_name = tables_->AllocateString(file_->package()); - if (!full_name->empty()) full_name->append(1, '.'); - full_name->append(proto.name()); - - ValidateSymbolName(proto.name(), *full_name, proto); - - result->name_ = tables_->AllocateString(proto.name()); - result->full_name_ = full_name; - result->file_ = file_; - - BUILD_ARRAY(proto, result, method, BuildMethod, result); - - // Copy options. - if (!proto.has_options()) { - result->options_ = NULL; // Will set to default_instance later. - } else { - AllocateOptions(proto.options(), result); - } - - AddSymbol(result->full_name(), NULL, result->name(), - proto, Symbol(result)); -} - -void DescriptorBuilder::BuildMethod(const MethodDescriptorProto& proto, - const ServiceDescriptor* parent, - MethodDescriptor* result) { - result->name_ = tables_->AllocateString(proto.name()); - result->service_ = parent; - - string* full_name = tables_->AllocateString(parent->full_name()); - full_name->append(1, '.'); - full_name->append(*result->name_); - result->full_name_ = full_name; - - ValidateSymbolName(proto.name(), *full_name, proto); - - // These will be filled in when cross-linking. - result->input_type_ = NULL; - result->output_type_ = NULL; - - // Copy options. - if (!proto.has_options()) { - result->options_ = NULL; // Will set to default_instance later. - } else { - AllocateOptions(proto.options(), result); - } - - AddSymbol(result->full_name(), parent, result->name(), - proto, Symbol(result)); -} - -#undef BUILD_ARRAY - -// ------------------------------------------------------------------- - -void DescriptorBuilder::CrossLinkFile( - FileDescriptor* file, const FileDescriptorProto& proto) { - if (file->options_ == NULL) { - file->options_ = &FileOptions::default_instance(); - } - - for (int i = 0; i < file->message_type_count(); i++) { - CrossLinkMessage(&file->message_types_[i], proto.message_type(i)); - } - - for (int i = 0; i < file->extension_count(); i++) { - CrossLinkField(&file->extensions_[i], proto.extension(i)); - } - - for (int i = 0; i < file->enum_type_count(); i++) { - CrossLinkEnum(&file->enum_types_[i], proto.enum_type(i)); - } - - for (int i = 0; i < file->service_count(); i++) { - CrossLinkService(&file->services_[i], proto.service(i)); - } -} - -void DescriptorBuilder::CrossLinkMessage( - Descriptor* message, const DescriptorProto& proto) { - if (message->options_ == NULL) { - message->options_ = &MessageOptions::default_instance(); - } - - for (int i = 0; i < message->nested_type_count(); i++) { - CrossLinkMessage(&message->nested_types_[i], proto.nested_type(i)); - } - - for (int i = 0; i < message->enum_type_count(); i++) { - CrossLinkEnum(&message->enum_types_[i], proto.enum_type(i)); - } - - for (int i = 0; i < message->field_count(); i++) { - CrossLinkField(&message->fields_[i], proto.field(i)); - } - - for (int i = 0; i < message->extension_count(); i++) { - CrossLinkField(&message->extensions_[i], proto.extension(i)); - } -} - -void DescriptorBuilder::CrossLinkField( - FieldDescriptor* field, const FieldDescriptorProto& proto) { - if (field->options_ == NULL) { - field->options_ = &FieldOptions::default_instance(); - } - - if (proto.has_extendee()) { - Symbol extendee = LookupSymbol(proto.extendee(), field->full_name(), - PLACEHOLDER_EXTENDABLE_MESSAGE); - if (extendee.IsNull()) { - AddNotDefinedError(field->full_name(), proto, - DescriptorPool::ErrorCollector::EXTENDEE, - proto.extendee()); - return; - } else if (extendee.type != Symbol::MESSAGE) { - AddError(field->full_name(), proto, - DescriptorPool::ErrorCollector::EXTENDEE, - "\"" + proto.extendee() + "\" is not a message type."); - return; - } - field->containing_type_ = extendee.descriptor; - - if (!field->containing_type()->IsExtensionNumber(field->number())) { - AddError(field->full_name(), proto, - DescriptorPool::ErrorCollector::NUMBER, - strings::Substitute("\"$0\" does not declare $1 as an " - "extension number.", - field->containing_type()->full_name(), - field->number())); - } - } - - if (proto.has_type_name()) { - // Assume we are expecting a message type unless the proto contains some - // evidence that it expects an enum type. This only makes a difference if - // we end up creating a placeholder. - bool expecting_enum = (proto.type() == FieldDescriptorProto::TYPE_ENUM) || - proto.has_default_value(); - - Symbol type = - LookupSymbol(proto.type_name(), field->full_name(), - expecting_enum ? PLACEHOLDER_ENUM : PLACEHOLDER_MESSAGE, - LOOKUP_TYPES); - - if (type.IsNull()) { - AddNotDefinedError(field->full_name(), proto, - DescriptorPool::ErrorCollector::TYPE, - proto.type_name()); - return; - } - - if (!proto.has_type()) { - // Choose field type based on symbol. - if (type.type == Symbol::MESSAGE) { - field->type_ = FieldDescriptor::TYPE_MESSAGE; - } else if (type.type == Symbol::ENUM) { - field->type_ = FieldDescriptor::TYPE_ENUM; - } else { - AddError(field->full_name(), proto, - DescriptorPool::ErrorCollector::TYPE, - "\"" + proto.type_name() + "\" is not a type."); - return; - } - } - - if (field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE) { - if (type.type != Symbol::MESSAGE) { - AddError(field->full_name(), proto, - DescriptorPool::ErrorCollector::TYPE, - "\"" + proto.type_name() + "\" is not a message type."); - return; - } - field->message_type_ = type.descriptor; - - if (field->has_default_value()) { - AddError(field->full_name(), proto, - DescriptorPool::ErrorCollector::DEFAULT_VALUE, - "Messages can't have default values."); - } - } else if (field->cpp_type() == FieldDescriptor::CPPTYPE_ENUM) { - if (type.type != Symbol::ENUM) { - AddError(field->full_name(), proto, - DescriptorPool::ErrorCollector::TYPE, - "\"" + proto.type_name() + "\" is not an enum type."); - return; - } - field->enum_type_ = type.enum_descriptor; - - if (field->enum_type()->is_placeholder_) { - // We can't look up default values for placeholder types. We'll have - // to just drop them. - field->has_default_value_ = false; - } - - if (field->has_default_value()) { - // We can't just use field->enum_type()->FindValueByName() here - // because that locks the pool's mutex, which we have already locked - // at this point. - Symbol default_value = - LookupSymbolNoPlaceholder(proto.default_value(), - field->enum_type()->full_name()); - - if (default_value.type == Symbol::ENUM_VALUE && - default_value.enum_value_descriptor->type() == field->enum_type()) { - field->default_value_enum_ = default_value.enum_value_descriptor; - } else { - AddError(field->full_name(), proto, - DescriptorPool::ErrorCollector::DEFAULT_VALUE, - "Enum type \"" + field->enum_type()->full_name() + - "\" has no value named \"" + proto.default_value() + "\"."); - } - } else if (field->enum_type()->value_count() > 0) { - // All enums must have at least one value, or we would have reported - // an error elsewhere. We use the first defined value as the default - // if a default is not explicitly defined. - field->default_value_enum_ = field->enum_type()->value(0); - } - } else { - AddError(field->full_name(), proto, DescriptorPool::ErrorCollector::TYPE, - "Field with primitive type has type_name."); - } - } else { - if (field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE || - field->cpp_type() == FieldDescriptor::CPPTYPE_ENUM) { - AddError(field->full_name(), proto, DescriptorPool::ErrorCollector::TYPE, - "Field with message or enum type missing type_name."); - } - } - - // Add the field to the fields-by-number table. - // Note: We have to do this *after* cross-linking because extensions do not - // know their containing type until now. - if (!file_tables_->AddFieldByNumber(field)) { - const FieldDescriptor* conflicting_field = - file_tables_->FindFieldByNumber(field->containing_type(), - field->number()); - if (field->is_extension()) { - AddError(field->full_name(), proto, - DescriptorPool::ErrorCollector::NUMBER, - strings::Substitute("Extension number $0 has already been used " - "in \"$1\" by extension \"$2\".", - field->number(), - field->containing_type()->full_name(), - conflicting_field->full_name())); - } else { - AddError(field->full_name(), proto, - DescriptorPool::ErrorCollector::NUMBER, - strings::Substitute("Field number $0 has already been used in " - "\"$1\" by field \"$2\".", - field->number(), - field->containing_type()->full_name(), - conflicting_field->name())); - } - } - - if (field->is_extension()) { - // No need for error checking: if the extension number collided, - // we've already been informed of it by the if() above. - tables_->AddExtension(field); - } - - // Add the field to the lowercase-name and camelcase-name tables. - file_tables_->AddFieldByStylizedNames(field); -} - -void DescriptorBuilder::CrossLinkEnum( - EnumDescriptor* enum_type, const EnumDescriptorProto& proto) { - if (enum_type->options_ == NULL) { - enum_type->options_ = &EnumOptions::default_instance(); - } - - for (int i = 0; i < enum_type->value_count(); i++) { - CrossLinkEnumValue(&enum_type->values_[i], proto.value(i)); - } -} - -void DescriptorBuilder::CrossLinkEnumValue( - EnumValueDescriptor* enum_value, const EnumValueDescriptorProto& proto) { - if (enum_value->options_ == NULL) { - enum_value->options_ = &EnumValueOptions::default_instance(); - } -} - -void DescriptorBuilder::CrossLinkService( - ServiceDescriptor* service, const ServiceDescriptorProto& proto) { - if (service->options_ == NULL) { - service->options_ = &ServiceOptions::default_instance(); - } - - for (int i = 0; i < service->method_count(); i++) { - CrossLinkMethod(&service->methods_[i], proto.method(i)); - } -} - -void DescriptorBuilder::CrossLinkMethod( - MethodDescriptor* method, const MethodDescriptorProto& proto) { - if (method->options_ == NULL) { - method->options_ = &MethodOptions::default_instance(); - } - - Symbol input_type = LookupSymbol(proto.input_type(), method->full_name()); - if (input_type.IsNull()) { - AddNotDefinedError(method->full_name(), proto, - DescriptorPool::ErrorCollector::INPUT_TYPE, - proto.input_type()); - } else if (input_type.type != Symbol::MESSAGE) { - AddError(method->full_name(), proto, - DescriptorPool::ErrorCollector::INPUT_TYPE, - "\"" + proto.input_type() + "\" is not a message type."); - } else { - method->input_type_ = input_type.descriptor; - } - - Symbol output_type = LookupSymbol(proto.output_type(), method->full_name()); - if (output_type.IsNull()) { - AddNotDefinedError(method->full_name(), proto, - DescriptorPool::ErrorCollector::OUTPUT_TYPE, - proto.output_type()); - } else if (output_type.type != Symbol::MESSAGE) { - AddError(method->full_name(), proto, - DescriptorPool::ErrorCollector::OUTPUT_TYPE, - "\"" + proto.output_type() + "\" is not a message type."); - } else { - method->output_type_ = output_type.descriptor; - } -} - -// ------------------------------------------------------------------- - -#define VALIDATE_OPTIONS_FROM_ARRAY(descriptor, array_name, type) \ - for (int i = 0; i < descriptor->array_name##_count(); ++i) { \ - Validate##type##Options(descriptor->array_name##s_ + i, \ - proto.array_name(i)); \ - } - -// Determine if the file uses optimize_for = LITE_RUNTIME, being careful to -// avoid problems that exist at init time. -static bool IsLite(const FileDescriptor* file) { - // TODO(kenton): I don't even remember how many of these conditions are - // actually possible. I'm just being super-safe. - return file != NULL && - &file->options() != NULL && - &file->options() != &FileOptions::default_instance() && - file->options().optimize_for() == FileOptions::LITE_RUNTIME; -} - -void DescriptorBuilder::ValidateFileOptions(FileDescriptor* file, - const FileDescriptorProto& proto) { - VALIDATE_OPTIONS_FROM_ARRAY(file, message_type, Message); - VALIDATE_OPTIONS_FROM_ARRAY(file, enum_type, Enum); - VALIDATE_OPTIONS_FROM_ARRAY(file, service, Service); - VALIDATE_OPTIONS_FROM_ARRAY(file, extension, Field); - - // Lite files can only be imported by other Lite files. - if (!IsLite(file)) { - for (int i = 0; i < file->dependency_count(); i++) { - if (IsLite(file->dependency(i))) { - AddError( - file->name(), proto, - DescriptorPool::ErrorCollector::OTHER, - "Files that do not use optimize_for = LITE_RUNTIME cannot import " - "files which do use this option. This file is not lite, but it " - "imports \"" + file->dependency(i)->name() + "\" which is."); - break; - } - } - } -} - -void DescriptorBuilder::ValidateMessageOptions(Descriptor* message, - const DescriptorProto& proto) { - VALIDATE_OPTIONS_FROM_ARRAY(message, field, Field); - VALIDATE_OPTIONS_FROM_ARRAY(message, nested_type, Message); - VALIDATE_OPTIONS_FROM_ARRAY(message, enum_type, Enum); - VALIDATE_OPTIONS_FROM_ARRAY(message, extension, Field); - - const int64 max_extension_range = - static_cast(message->options().message_set_wire_format() ? - kint32max : - FieldDescriptor::kMaxNumber); - for (int i = 0; i < message->extension_range_count(); ++i) { - if (message->extension_range(i)->end > max_extension_range + 1) { - AddError( - message->full_name(), proto.extension_range(i), - DescriptorPool::ErrorCollector::NUMBER, - strings::Substitute("Extension numbers cannot be greater than $0.", - max_extension_range)); - } - } -} - -void DescriptorBuilder::ValidateFieldOptions(FieldDescriptor* field, - const FieldDescriptorProto& proto) { - if (field->options().has_experimental_map_key()) { - ValidateMapKey(field, proto); - } - - // Only message type fields may be lazy. - if (field->options().lazy()) { - if (field->type() != FieldDescriptor::TYPE_MESSAGE) { - AddError(field->full_name(), proto, - DescriptorPool::ErrorCollector::TYPE, - "[lazy = true] can only be specified for submessage fields."); - } - } - - // Only repeated primitive fields may be packed. - if (field->options().packed() && !field->is_packable()) { - AddError( - field->full_name(), proto, - DescriptorPool::ErrorCollector::TYPE, - "[packed = true] can only be specified for repeated primitive fields."); - } - - // Note: Default instance may not yet be initialized here, so we have to - // avoid reading from it. - if (field->containing_type_ != NULL && - &field->containing_type()->options() != - &MessageOptions::default_instance() && - field->containing_type()->options().message_set_wire_format()) { - if (field->is_extension()) { - if (!field->is_optional() || - field->type() != FieldDescriptor::TYPE_MESSAGE) { - AddError(field->full_name(), proto, - DescriptorPool::ErrorCollector::TYPE, - "Extensions of MessageSets must be optional messages."); - } - } else { - AddError(field->full_name(), proto, - DescriptorPool::ErrorCollector::NAME, - "MessageSets cannot have fields, only extensions."); - } - } - - // Lite extensions can only be of Lite types. - if (IsLite(field->file()) && - field->containing_type_ != NULL && - !IsLite(field->containing_type()->file())) { - AddError(field->full_name(), proto, - DescriptorPool::ErrorCollector::EXTENDEE, - "Extensions to non-lite types can only be declared in non-lite " - "files. Note that you cannot extend a non-lite type to contain " - "a lite type, but the reverse is allowed."); - } - -} - -void DescriptorBuilder::ValidateEnumOptions(EnumDescriptor* enm, - const EnumDescriptorProto& proto) { - VALIDATE_OPTIONS_FROM_ARRAY(enm, value, EnumValue); - if (!enm->options().has_allow_alias() || !enm->options().allow_alias()) { - map used_values; - for (int i = 0; i < enm->value_count(); ++i) { - const EnumValueDescriptor* enum_value = enm->value(i); - if (used_values.find(enum_value->number()) != used_values.end()) { - string error = - "\"" + enum_value->full_name() + - "\" uses the same enum value as \"" + - used_values[enum_value->number()] + "\". If this is intended, set " - "'option allow_alias = true;' to the enum definition."; - if (!enm->options().allow_alias()) { - // Generate error if duplicated enum values are explicitly disallowed. - AddError(enm->full_name(), proto, - DescriptorPool::ErrorCollector::NUMBER, - error); - } else { - // Generate warning if duplicated values are found but the option - // isn't set. - GOOGLE_LOG(ERROR) << error; - } - } else { - used_values[enum_value->number()] = enum_value->full_name(); - } - } - } -} - -void DescriptorBuilder::ValidateEnumValueOptions( - EnumValueDescriptor* enum_value, const EnumValueDescriptorProto& proto) { - // Nothing to do so far. -} -void DescriptorBuilder::ValidateServiceOptions(ServiceDescriptor* service, - const ServiceDescriptorProto& proto) { - if (IsLite(service->file()) && - (service->file()->options().cc_generic_services() || - service->file()->options().java_generic_services())) { - AddError(service->full_name(), proto, - DescriptorPool::ErrorCollector::NAME, - "Files with optimize_for = LITE_RUNTIME cannot define services " - "unless you set both options cc_generic_services and " - "java_generic_sevices to false."); - } - - VALIDATE_OPTIONS_FROM_ARRAY(service, method, Method); -} - -void DescriptorBuilder::ValidateMethodOptions(MethodDescriptor* method, - const MethodDescriptorProto& proto) { - // Nothing to do so far. -} - -void DescriptorBuilder::ValidateMapKey(FieldDescriptor* field, - const FieldDescriptorProto& proto) { - if (!field->is_repeated()) { - AddError(field->full_name(), proto, DescriptorPool::ErrorCollector::TYPE, - "map type is only allowed for repeated fields."); - return; - } - - if (field->cpp_type() != FieldDescriptor::CPPTYPE_MESSAGE) { - AddError(field->full_name(), proto, DescriptorPool::ErrorCollector::TYPE, - "map type is only allowed for fields with a message type."); - return; - } - - const Descriptor* item_type = field->message_type(); - if (item_type == NULL) { - AddError(field->full_name(), proto, DescriptorPool::ErrorCollector::TYPE, - "Could not find field type."); - return; - } - - // Find the field in item_type named by "experimental_map_key" - const string& key_name = field->options().experimental_map_key(); - const Symbol key_symbol = LookupSymbol( - key_name, - // We append ".key_name" to the containing type's name since - // LookupSymbol() searches for peers of the supplied name, not - // children of the supplied name. - item_type->full_name() + "." + key_name); - - if (key_symbol.IsNull() || key_symbol.field_descriptor->is_extension()) { - AddError(field->full_name(), proto, DescriptorPool::ErrorCollector::TYPE, - "Could not find field named \"" + key_name + "\" in type \"" + - item_type->full_name() + "\"."); - return; - } - const FieldDescriptor* key_field = key_symbol.field_descriptor; - - if (key_field->is_repeated()) { - AddError(field->full_name(), proto, DescriptorPool::ErrorCollector::TYPE, - "map_key must not name a repeated field."); - return; - } - - if (key_field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE) { - AddError(field->full_name(), proto, DescriptorPool::ErrorCollector::TYPE, - "map key must name a scalar or string field."); - return; - } - - field->experimental_map_key_ = key_field; -} - - -#undef VALIDATE_OPTIONS_FROM_ARRAY - -// ------------------------------------------------------------------- - -DescriptorBuilder::OptionInterpreter::OptionInterpreter( - DescriptorBuilder* builder) : builder_(builder) { - GOOGLE_CHECK(builder_); -} - -DescriptorBuilder::OptionInterpreter::~OptionInterpreter() { -} - -bool DescriptorBuilder::OptionInterpreter::InterpretOptions( - OptionsToInterpret* options_to_interpret) { - // Note that these may be in different pools, so we can't use the same - // descriptor and reflection objects on both. - Message* options = options_to_interpret->options; - const Message* original_options = options_to_interpret->original_options; - - bool failed = false; - options_to_interpret_ = options_to_interpret; - - // Find the uninterpreted_option field in the mutable copy of the options - // and clear them, since we're about to interpret them. - const FieldDescriptor* uninterpreted_options_field = - options->GetDescriptor()->FindFieldByName("uninterpreted_option"); - GOOGLE_CHECK(uninterpreted_options_field != NULL) - << "No field named \"uninterpreted_option\" in the Options proto."; - options->GetReflection()->ClearField(options, uninterpreted_options_field); - - // Find the uninterpreted_option field in the original options. - const FieldDescriptor* original_uninterpreted_options_field = - original_options->GetDescriptor()-> - FindFieldByName("uninterpreted_option"); - GOOGLE_CHECK(original_uninterpreted_options_field != NULL) - << "No field named \"uninterpreted_option\" in the Options proto."; - - const int num_uninterpreted_options = original_options->GetReflection()-> - FieldSize(*original_options, original_uninterpreted_options_field); - for (int i = 0; i < num_uninterpreted_options; ++i) { - uninterpreted_option_ = down_cast( - &original_options->GetReflection()->GetRepeatedMessage( - *original_options, original_uninterpreted_options_field, i)); - if (!InterpretSingleOption(options)) { - // Error already added by InterpretSingleOption(). - failed = true; - break; - } - } - // Reset these, so we don't have any dangling pointers. - uninterpreted_option_ = NULL; - options_to_interpret_ = NULL; - - if (!failed) { - // InterpretSingleOption() added the interpreted options in the - // UnknownFieldSet, in case the option isn't yet known to us. Now we - // serialize the options message and deserialize it back. That way, any - // option fields that we do happen to know about will get moved from the - // UnknownFieldSet into the real fields, and thus be available right away. - // If they are not known, that's OK too. They will get reparsed into the - // UnknownFieldSet and wait there until the message is parsed by something - // that does know about the options. - string buf; - options->AppendToString(&buf); - GOOGLE_CHECK(options->ParseFromString(buf)) - << "Protocol message serialized itself in invalid fashion."; - } - - return !failed; -} - -bool DescriptorBuilder::OptionInterpreter::InterpretSingleOption( - Message* options) { - // First do some basic validation. - if (uninterpreted_option_->name_size() == 0) { - // This should never happen unless the parser has gone seriously awry or - // someone has manually created the uninterpreted option badly. - return AddNameError("Option must have a name."); - } - if (uninterpreted_option_->name(0).name_part() == "uninterpreted_option") { - return AddNameError("Option must not use reserved name " - "\"uninterpreted_option\"."); - } - - const Descriptor* options_descriptor = NULL; - // Get the options message's descriptor from the builder's pool, so that we - // get the version that knows about any extension options declared in the - // file we're currently building. The descriptor should be there as long as - // the file we're building imported "google/protobuf/descriptors.proto". - - // Note that we use DescriptorBuilder::FindSymbolNotEnforcingDeps(), not - // DescriptorPool::FindMessageTypeByName() because we're already holding the - // pool's mutex, and the latter method locks it again. We don't use - // FindSymbol() because files that use custom options only need to depend on - // the file that defines the option, not descriptor.proto itself. - Symbol symbol = builder_->FindSymbolNotEnforcingDeps( - options->GetDescriptor()->full_name()); - if (!symbol.IsNull() && symbol.type == Symbol::MESSAGE) { - options_descriptor = symbol.descriptor; - } else { - // The options message's descriptor was not in the builder's pool, so use - // the standard version from the generated pool. We're not holding the - // generated pool's mutex, so we can search it the straightforward way. - options_descriptor = options->GetDescriptor(); - } - GOOGLE_CHECK(options_descriptor); - - // We iterate over the name parts to drill into the submessages until we find - // the leaf field for the option. As we drill down we remember the current - // submessage's descriptor in |descriptor| and the next field in that - // submessage in |field|. We also track the fields we're drilling down - // through in |intermediate_fields|. As we go, we reconstruct the full option - // name in |debug_msg_name|, for use in error messages. - const Descriptor* descriptor = options_descriptor; - const FieldDescriptor* field = NULL; - vector intermediate_fields; - string debug_msg_name = ""; - - for (int i = 0; i < uninterpreted_option_->name_size(); ++i) { - const string& name_part = uninterpreted_option_->name(i).name_part(); - if (debug_msg_name.size() > 0) { - debug_msg_name += "."; - } - if (uninterpreted_option_->name(i).is_extension()) { - debug_msg_name += "(" + name_part + ")"; - // Search for the extension's descriptor as an extension in the builder's - // pool. Note that we use DescriptorBuilder::LookupSymbol(), not - // DescriptorPool::FindExtensionByName(), for two reasons: 1) It allows - // relative lookups, and 2) because we're already holding the pool's - // mutex, and the latter method locks it again. - symbol = builder_->LookupSymbol(name_part, - options_to_interpret_->name_scope); - if (!symbol.IsNull() && symbol.type == Symbol::FIELD) { - field = symbol.field_descriptor; - } - // If we don't find the field then the field's descriptor was not in the - // builder's pool, but there's no point in looking in the generated - // pool. We require that you import the file that defines any extensions - // you use, so they must be present in the builder's pool. - } else { - debug_msg_name += name_part; - // Search for the field's descriptor as a regular field. - field = descriptor->FindFieldByName(name_part); - } - - if (field == NULL) { - if (get_allow_unknown(builder_->pool_)) { - // We can't find the option, but AllowUnknownDependencies() is enabled, - // so we will just leave it as uninterpreted. - AddWithoutInterpreting(*uninterpreted_option_, options); - return true; - } else { - return AddNameError("Option \"" + debug_msg_name + "\" unknown."); - } - } else if (field->containing_type() != descriptor) { - if (get_is_placeholder(field->containing_type())) { - // The field is an extension of a placeholder type, so we can't - // reliably verify whether it is a valid extension to use here (e.g. - // we don't know if it is an extension of the correct *Options message, - // or if it has a valid field number, etc.). Just leave it as - // uninterpreted instead. - AddWithoutInterpreting(*uninterpreted_option_, options); - return true; - } else { - // This can only happen if, due to some insane misconfiguration of the - // pools, we find the options message in one pool but the field in - // another. This would probably imply a hefty bug somewhere. - return AddNameError("Option field \"" + debug_msg_name + - "\" is not a field or extension of message \"" + - descriptor->name() + "\"."); - } - } else if (field->is_repeated()) { - return AddNameError("Option field \"" + debug_msg_name + - "\" is repeated. Repeated options are not " - "supported."); - } else if (i < uninterpreted_option_->name_size() - 1) { - if (field->cpp_type() != FieldDescriptor::CPPTYPE_MESSAGE) { - return AddNameError("Option \"" + debug_msg_name + - "\" is an atomic type, not a message."); - } else { - // Drill down into the submessage. - intermediate_fields.push_back(field); - descriptor = field->message_type(); - } - } - } - - // We've found the leaf field. Now we use UnknownFieldSets to set its value - // on the options message. We do so because the message may not yet know - // about its extension fields, so we may not be able to set the fields - // directly. But the UnknownFieldSets will serialize to the same wire-format - // message, so reading that message back in once the extension fields are - // known will populate them correctly. - - // First see if the option is already set. - if (!ExamineIfOptionIsSet( - intermediate_fields.begin(), - intermediate_fields.end(), - field, debug_msg_name, - options->GetReflection()->GetUnknownFields(*options))) { - return false; // ExamineIfOptionIsSet() already added the error. - } - - - // First set the value on the UnknownFieldSet corresponding to the - // innermost message. - scoped_ptr unknown_fields(new UnknownFieldSet()); - if (!SetOptionValue(field, unknown_fields.get())) { - return false; // SetOptionValue() already added the error. - } - - // Now wrap the UnknownFieldSet with UnknownFieldSets corresponding to all - // the intermediate messages. - for (vector::reverse_iterator iter = - intermediate_fields.rbegin(); - iter != intermediate_fields.rend(); ++iter) { - scoped_ptr parent_unknown_fields(new UnknownFieldSet()); - switch ((*iter)->type()) { - case FieldDescriptor::TYPE_MESSAGE: { - io::StringOutputStream outstr( - parent_unknown_fields->AddLengthDelimited((*iter)->number())); - io::CodedOutputStream out(&outstr); - internal::WireFormat::SerializeUnknownFields(*unknown_fields, &out); - GOOGLE_CHECK(!out.HadError()) - << "Unexpected failure while serializing option submessage " - << debug_msg_name << "\"."; - break; - } - - case FieldDescriptor::TYPE_GROUP: { - parent_unknown_fields->AddGroup((*iter)->number()) - ->MergeFrom(*unknown_fields); - break; - } - - default: - GOOGLE_LOG(FATAL) << "Invalid wire type for CPPTYPE_MESSAGE: " - << (*iter)->type(); - return false; - } - unknown_fields.reset(parent_unknown_fields.release()); - } - - // Now merge the UnknownFieldSet corresponding to the top-level message into - // the options message. - options->GetReflection()->MutableUnknownFields(options)->MergeFrom( - *unknown_fields); - - return true; -} - -void DescriptorBuilder::OptionInterpreter::AddWithoutInterpreting( - const UninterpretedOption& uninterpreted_option, Message* options) { - const FieldDescriptor* field = - options->GetDescriptor()->FindFieldByName("uninterpreted_option"); - GOOGLE_CHECK(field != NULL); - - options->GetReflection()->AddMessage(options, field) - ->CopyFrom(uninterpreted_option); -} - -bool DescriptorBuilder::OptionInterpreter::ExamineIfOptionIsSet( - vector::const_iterator intermediate_fields_iter, - vector::const_iterator intermediate_fields_end, - const FieldDescriptor* innermost_field, const string& debug_msg_name, - const UnknownFieldSet& unknown_fields) { - // We do linear searches of the UnknownFieldSet and its sub-groups. This - // should be fine since it's unlikely that any one options structure will - // contain more than a handful of options. - - if (intermediate_fields_iter == intermediate_fields_end) { - // We're at the innermost submessage. - for (int i = 0; i < unknown_fields.field_count(); i++) { - if (unknown_fields.field(i).number() == innermost_field->number()) { - return AddNameError("Option \"" + debug_msg_name + - "\" was already set."); - } - } - return true; - } - - for (int i = 0; i < unknown_fields.field_count(); i++) { - if (unknown_fields.field(i).number() == - (*intermediate_fields_iter)->number()) { - const UnknownField* unknown_field = &unknown_fields.field(i); - FieldDescriptor::Type type = (*intermediate_fields_iter)->type(); - // Recurse into the next submessage. - switch (type) { - case FieldDescriptor::TYPE_MESSAGE: - if (unknown_field->type() == UnknownField::TYPE_LENGTH_DELIMITED) { - UnknownFieldSet intermediate_unknown_fields; - if (intermediate_unknown_fields.ParseFromString( - unknown_field->length_delimited()) && - !ExamineIfOptionIsSet(intermediate_fields_iter + 1, - intermediate_fields_end, - innermost_field, debug_msg_name, - intermediate_unknown_fields)) { - return false; // Error already added. - } - } - break; - - case FieldDescriptor::TYPE_GROUP: - if (unknown_field->type() == UnknownField::TYPE_GROUP) { - if (!ExamineIfOptionIsSet(intermediate_fields_iter + 1, - intermediate_fields_end, - innermost_field, debug_msg_name, - unknown_field->group())) { - return false; // Error already added. - } - } - break; - - default: - GOOGLE_LOG(FATAL) << "Invalid wire type for CPPTYPE_MESSAGE: " << type; - return false; - } - } - } - return true; -} - -bool DescriptorBuilder::OptionInterpreter::SetOptionValue( - const FieldDescriptor* option_field, - UnknownFieldSet* unknown_fields) { - // We switch on the CppType to validate. - switch (option_field->cpp_type()) { - - case FieldDescriptor::CPPTYPE_INT32: - if (uninterpreted_option_->has_positive_int_value()) { - if (uninterpreted_option_->positive_int_value() > - static_cast(kint32max)) { - return AddValueError("Value out of range for int32 option \"" + - option_field->full_name() + "\"."); - } else { - SetInt32(option_field->number(), - uninterpreted_option_->positive_int_value(), - option_field->type(), unknown_fields); - } - } else if (uninterpreted_option_->has_negative_int_value()) { - if (uninterpreted_option_->negative_int_value() < - static_cast(kint32min)) { - return AddValueError("Value out of range for int32 option \"" + - option_field->full_name() + "\"."); - } else { - SetInt32(option_field->number(), - uninterpreted_option_->negative_int_value(), - option_field->type(), unknown_fields); - } - } else { - return AddValueError("Value must be integer for int32 option \"" + - option_field->full_name() + "\"."); - } - break; - - case FieldDescriptor::CPPTYPE_INT64: - if (uninterpreted_option_->has_positive_int_value()) { - if (uninterpreted_option_->positive_int_value() > - static_cast(kint64max)) { - return AddValueError("Value out of range for int64 option \"" + - option_field->full_name() + "\"."); - } else { - SetInt64(option_field->number(), - uninterpreted_option_->positive_int_value(), - option_field->type(), unknown_fields); - } - } else if (uninterpreted_option_->has_negative_int_value()) { - SetInt64(option_field->number(), - uninterpreted_option_->negative_int_value(), - option_field->type(), unknown_fields); - } else { - return AddValueError("Value must be integer for int64 option \"" + - option_field->full_name() + "\"."); - } - break; - - case FieldDescriptor::CPPTYPE_UINT32: - if (uninterpreted_option_->has_positive_int_value()) { - if (uninterpreted_option_->positive_int_value() > kuint32max) { - return AddValueError("Value out of range for uint32 option \"" + - option_field->name() + "\"."); - } else { - SetUInt32(option_field->number(), - uninterpreted_option_->positive_int_value(), - option_field->type(), unknown_fields); - } - } else { - return AddValueError("Value must be non-negative integer for uint32 " - "option \"" + option_field->full_name() + "\"."); - } - break; - - case FieldDescriptor::CPPTYPE_UINT64: - if (uninterpreted_option_->has_positive_int_value()) { - SetUInt64(option_field->number(), - uninterpreted_option_->positive_int_value(), - option_field->type(), unknown_fields); - } else { - return AddValueError("Value must be non-negative integer for uint64 " - "option \"" + option_field->full_name() + "\"."); - } - break; - - case FieldDescriptor::CPPTYPE_FLOAT: { - float value; - if (uninterpreted_option_->has_double_value()) { - value = uninterpreted_option_->double_value(); - } else if (uninterpreted_option_->has_positive_int_value()) { - value = uninterpreted_option_->positive_int_value(); - } else if (uninterpreted_option_->has_negative_int_value()) { - value = uninterpreted_option_->negative_int_value(); - } else { - return AddValueError("Value must be number for float option \"" + - option_field->full_name() + "\"."); - } - unknown_fields->AddFixed32(option_field->number(), - google::protobuf::internal::WireFormatLite::EncodeFloat(value)); - break; - } - - case FieldDescriptor::CPPTYPE_DOUBLE: { - double value; - if (uninterpreted_option_->has_double_value()) { - value = uninterpreted_option_->double_value(); - } else if (uninterpreted_option_->has_positive_int_value()) { - value = uninterpreted_option_->positive_int_value(); - } else if (uninterpreted_option_->has_negative_int_value()) { - value = uninterpreted_option_->negative_int_value(); - } else { - return AddValueError("Value must be number for double option \"" + - option_field->full_name() + "\"."); - } - unknown_fields->AddFixed64(option_field->number(), - google::protobuf::internal::WireFormatLite::EncodeDouble(value)); - break; - } - - case FieldDescriptor::CPPTYPE_BOOL: - uint64 value; - if (!uninterpreted_option_->has_identifier_value()) { - return AddValueError("Value must be identifier for boolean option " - "\"" + option_field->full_name() + "\"."); - } - if (uninterpreted_option_->identifier_value() == "true") { - value = 1; - } else if (uninterpreted_option_->identifier_value() == "false") { - value = 0; - } else { - return AddValueError("Value must be \"true\" or \"false\" for boolean " - "option \"" + option_field->full_name() + "\"."); - } - unknown_fields->AddVarint(option_field->number(), value); - break; - - case FieldDescriptor::CPPTYPE_ENUM: { - if (!uninterpreted_option_->has_identifier_value()) { - return AddValueError("Value must be identifier for enum-valued option " - "\"" + option_field->full_name() + "\"."); - } - const EnumDescriptor* enum_type = option_field->enum_type(); - const string& value_name = uninterpreted_option_->identifier_value(); - const EnumValueDescriptor* enum_value = NULL; - - if (enum_type->file()->pool() != DescriptorPool::generated_pool()) { - // Note that the enum value's fully-qualified name is a sibling of the - // enum's name, not a child of it. - string fully_qualified_name = enum_type->full_name(); - fully_qualified_name.resize(fully_qualified_name.size() - - enum_type->name().size()); - fully_qualified_name += value_name; - - // Search for the enum value's descriptor in the builder's pool. Note - // that we use DescriptorBuilder::FindSymbolNotEnforcingDeps(), not - // DescriptorPool::FindEnumValueByName() because we're already holding - // the pool's mutex, and the latter method locks it again. - Symbol symbol = - builder_->FindSymbolNotEnforcingDeps(fully_qualified_name); - if (!symbol.IsNull() && symbol.type == Symbol::ENUM_VALUE) { - if (symbol.enum_value_descriptor->type() != enum_type) { - return AddValueError("Enum type \"" + enum_type->full_name() + - "\" has no value named \"" + value_name + "\" for option \"" + - option_field->full_name() + - "\". This appears to be a value from a sibling type."); - } else { - enum_value = symbol.enum_value_descriptor; - } - } - } else { - // The enum type is in the generated pool, so we can search for the - // value there. - enum_value = enum_type->FindValueByName(value_name); - } - - if (enum_value == NULL) { - return AddValueError("Enum type \"" + - option_field->enum_type()->full_name() + - "\" has no value named \"" + value_name + "\" for " - "option \"" + option_field->full_name() + "\"."); - } else { - // Sign-extension is not a problem, since we cast directly from int32 to - // uint64, without first going through uint32. - unknown_fields->AddVarint(option_field->number(), - static_cast(static_cast(enum_value->number()))); - } - break; - } - - case FieldDescriptor::CPPTYPE_STRING: - if (!uninterpreted_option_->has_string_value()) { - return AddValueError("Value must be quoted string for string option " - "\"" + option_field->full_name() + "\"."); - } - // The string has already been unquoted and unescaped by the parser. - unknown_fields->AddLengthDelimited(option_field->number(), - uninterpreted_option_->string_value()); - break; - - case FieldDescriptor::CPPTYPE_MESSAGE: - if (!SetAggregateOption(option_field, unknown_fields)) { - return false; - } - break; - } - - return true; -} - -class DescriptorBuilder::OptionInterpreter::AggregateOptionFinder - : public TextFormat::Finder { - public: - DescriptorBuilder* builder_; - - virtual const FieldDescriptor* FindExtension( - Message* message, const string& name) const { - assert_mutex_held(builder_->pool_); - const Descriptor* descriptor = message->GetDescriptor(); - Symbol result = builder_->LookupSymbolNoPlaceholder( - name, descriptor->full_name()); - if (result.type == Symbol::FIELD && - result.field_descriptor->is_extension()) { - return result.field_descriptor; - } else if (result.type == Symbol::MESSAGE && - descriptor->options().message_set_wire_format()) { - const Descriptor* foreign_type = result.descriptor; - // The text format allows MessageSet items to be specified using - // the type name, rather than the extension identifier. If the symbol - // lookup returned a Message, and the enclosing Message has - // message_set_wire_format = true, then return the message set - // extension, if one exists. - for (int i = 0; i < foreign_type->extension_count(); i++) { - const FieldDescriptor* extension = foreign_type->extension(i); - if (extension->containing_type() == descriptor && - extension->type() == FieldDescriptor::TYPE_MESSAGE && - extension->is_optional() && - extension->message_type() == foreign_type) { - // Found it. - return extension; - } - } - } - return NULL; - } -}; - -// A custom error collector to record any text-format parsing errors -namespace { -class AggregateErrorCollector : public io::ErrorCollector { - public: - string error_; - - virtual void AddError(int line, int column, const string& message) { - if (!error_.empty()) { - error_ += "; "; - } - error_ += message; - } - - virtual void AddWarning(int line, int column, const string& message) { - // Ignore warnings - } -}; -} - -// We construct a dynamic message of the type corresponding to -// option_field, parse the supplied text-format string into this -// message, and serialize the resulting message to produce the value. -bool DescriptorBuilder::OptionInterpreter::SetAggregateOption( - const FieldDescriptor* option_field, - UnknownFieldSet* unknown_fields) { - if (!uninterpreted_option_->has_aggregate_value()) { - return AddValueError("Option \"" + option_field->full_name() + - "\" is a message. To set the entire message, use " - "syntax like \"" + option_field->name() + - " = { }\". " - "To set fields within it, use " - "syntax like \"" + option_field->name() + - ".foo = value\"."); - } - - const Descriptor* type = option_field->message_type(); - scoped_ptr dynamic(dynamic_factory_.GetPrototype(type)->New()); - GOOGLE_CHECK(dynamic.get() != NULL) - << "Could not create an instance of " << option_field->DebugString(); - - AggregateErrorCollector collector; - AggregateOptionFinder finder; - finder.builder_ = builder_; - TextFormat::Parser parser; - parser.RecordErrorsTo(&collector); - parser.SetFinder(&finder); - if (!parser.ParseFromString(uninterpreted_option_->aggregate_value(), - dynamic.get())) { - AddValueError("Error while parsing option value for \"" + - option_field->name() + "\": " + collector.error_); - return false; - } else { - string serial; - dynamic->SerializeToString(&serial); // Never fails - if (option_field->type() == FieldDescriptor::TYPE_MESSAGE) { - unknown_fields->AddLengthDelimited(option_field->number(), serial); - } else { - GOOGLE_CHECK_EQ(option_field->type(), FieldDescriptor::TYPE_GROUP); - UnknownFieldSet* group = unknown_fields->AddGroup(option_field->number()); - group->ParseFromString(serial); - } - return true; - } -} - -void DescriptorBuilder::OptionInterpreter::SetInt32(int number, int32 value, - FieldDescriptor::Type type, UnknownFieldSet* unknown_fields) { - switch (type) { - case FieldDescriptor::TYPE_INT32: - unknown_fields->AddVarint(number, - static_cast(static_cast(value))); - break; - - case FieldDescriptor::TYPE_SFIXED32: - unknown_fields->AddFixed32(number, static_cast(value)); - break; - - case FieldDescriptor::TYPE_SINT32: - unknown_fields->AddVarint(number, - google::protobuf::internal::WireFormatLite::ZigZagEncode32(value)); - break; - - default: - GOOGLE_LOG(FATAL) << "Invalid wire type for CPPTYPE_INT32: " << type; - break; - } -} - -void DescriptorBuilder::OptionInterpreter::SetInt64(int number, int64 value, - FieldDescriptor::Type type, UnknownFieldSet* unknown_fields) { - switch (type) { - case FieldDescriptor::TYPE_INT64: - unknown_fields->AddVarint(number, static_cast(value)); - break; - - case FieldDescriptor::TYPE_SFIXED64: - unknown_fields->AddFixed64(number, static_cast(value)); - break; - - case FieldDescriptor::TYPE_SINT64: - unknown_fields->AddVarint(number, - google::protobuf::internal::WireFormatLite::ZigZagEncode64(value)); - break; - - default: - GOOGLE_LOG(FATAL) << "Invalid wire type for CPPTYPE_INT64: " << type; - break; - } -} - -void DescriptorBuilder::OptionInterpreter::SetUInt32(int number, uint32 value, - FieldDescriptor::Type type, UnknownFieldSet* unknown_fields) { - switch (type) { - case FieldDescriptor::TYPE_UINT32: - unknown_fields->AddVarint(number, static_cast(value)); - break; - - case FieldDescriptor::TYPE_FIXED32: - unknown_fields->AddFixed32(number, static_cast(value)); - break; - - default: - GOOGLE_LOG(FATAL) << "Invalid wire type for CPPTYPE_UINT32: " << type; - break; - } -} - -void DescriptorBuilder::OptionInterpreter::SetUInt64(int number, uint64 value, - FieldDescriptor::Type type, UnknownFieldSet* unknown_fields) { - switch (type) { - case FieldDescriptor::TYPE_UINT64: - unknown_fields->AddVarint(number, value); - break; - - case FieldDescriptor::TYPE_FIXED64: - unknown_fields->AddFixed64(number, value); - break; - - default: - GOOGLE_LOG(FATAL) << "Invalid wire type for CPPTYPE_UINT64: " << type; - break; - } -} - -} // namespace protobuf -} // namespace google diff --git a/modules/dnn/3rdparty/protobuf/src/google/protobuf/descriptor.h b/modules/dnn/3rdparty/protobuf/src/google/protobuf/descriptor.h deleted file mode 100644 index 33e3af724..000000000 --- a/modules/dnn/3rdparty/protobuf/src/google/protobuf/descriptor.h +++ /dev/null @@ -1,1521 +0,0 @@ -// Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// http://code.google.com/p/protobuf/ -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -// Author: kenton@google.com (Kenton Varda) -// Based on original Protocol Buffers design by -// Sanjay Ghemawat, Jeff Dean, and others. -// -// This file contains classes which describe a type of protocol message. -// You can use a message's descriptor to learn at runtime what fields -// it contains and what the types of those fields are. The Message -// interface also allows you to dynamically access and modify individual -// fields by passing the FieldDescriptor of the field you are interested -// in. -// -// Most users will not care about descriptors, because they will write -// code specific to certain protocol types and will simply use the classes -// generated by the protocol compiler directly. Advanced users who want -// to operate on arbitrary types (not known at compile time) may want to -// read descriptors in order to learn about the contents of a message. -// A very small number of users will want to construct their own -// Descriptors, either because they are implementing Message manually or -// because they are writing something like the protocol compiler. -// -// For an example of how you might use descriptors, see the code example -// at the top of message.h. - -#ifndef GOOGLE_PROTOBUF_DESCRIPTOR_H__ -#define GOOGLE_PROTOBUF_DESCRIPTOR_H__ - -#include -#include -#include - -// TYPE_BOOL is defined in the MacOS's ConditionalMacros.h. -#ifdef TYPE_BOOL -#undef TYPE_BOOL -#endif // TYPE_BOOL - -namespace google { -namespace protobuf { - -// Defined in this file. -class Descriptor; -class FieldDescriptor; -class EnumDescriptor; -class EnumValueDescriptor; -class ServiceDescriptor; -class MethodDescriptor; -class FileDescriptor; -class DescriptorDatabase; -class DescriptorPool; - -// Defined in descriptor.proto -class DescriptorProto; -class FieldDescriptorProto; -class EnumDescriptorProto; -class EnumValueDescriptorProto; -class ServiceDescriptorProto; -class MethodDescriptorProto; -class FileDescriptorProto; -class MessageOptions; -class FieldOptions; -class EnumOptions; -class EnumValueOptions; -class ServiceOptions; -class MethodOptions; -class FileOptions; -class UninterpretedOption; -class SourceCodeInfo; - -// Defined in message.h -class Message; - -// Defined in descriptor.cc -class DescriptorBuilder; -class FileDescriptorTables; - -// Defined in unknown_field_set.h. -class UnknownField; - -// NB, all indices are zero-based. -struct SourceLocation { - int start_line; - int end_line; - int start_column; - int end_column; - - // Doc comments found at the source location. - // TODO(kenton): Maybe this struct should have been named SourceInfo or - // something instead. Oh well. - string leading_comments; - string trailing_comments; -}; - -// Describes a type of protocol message, or a particular group within a -// message. To obtain the Descriptor for a given message object, call -// Message::GetDescriptor(). Generated message classes also have a -// static method called descriptor() which returns the type's descriptor. -// Use DescriptorPool to construct your own descriptors. -class LIBPROTOBUF_EXPORT Descriptor { - public: - // The name of the message type, not including its scope. - const string& name() const; - - // The fully-qualified name of the message type, scope delimited by - // periods. For example, message type "Foo" which is declared in package - // "bar" has full name "bar.Foo". If a type "Baz" is nested within - // Foo, Baz's full_name is "bar.Foo.Baz". To get only the part that - // comes after the last '.', use name(). - const string& full_name() const; - - // Index of this descriptor within the file or containing type's message - // type array. - int index() const; - - // The .proto file in which this message type was defined. Never NULL. - const FileDescriptor* file() const; - - // If this Descriptor describes a nested type, this returns the type - // in which it is nested. Otherwise, returns NULL. - const Descriptor* containing_type() const; - - // Get options for this message type. These are specified in the .proto file - // by placing lines like "option foo = 1234;" in the message definition. - // Allowed options are defined by MessageOptions in - // google/protobuf/descriptor.proto, and any available extensions of that - // message. - const MessageOptions& options() const; - - // Write the contents of this Descriptor into the given DescriptorProto. - // The target DescriptorProto must be clear before calling this; if it - // isn't, the result may be garbage. - void CopyTo(DescriptorProto* proto) const; - - // Write the contents of this decriptor in a human-readable form. Output - // will be suitable for re-parsing. - string DebugString() const; - - // Field stuff ----------------------------------------------------- - - // The number of fields in this message type. - int field_count() const; - // Gets a field by index, where 0 <= index < field_count(). - // These are returned in the order they were defined in the .proto file. - const FieldDescriptor* field(int index) const; - - // Looks up a field by declared tag number. Returns NULL if no such field - // exists. - const FieldDescriptor* FindFieldByNumber(int number) const; - // Looks up a field by name. Returns NULL if no such field exists. - const FieldDescriptor* FindFieldByName(const string& name) const; - - // Looks up a field by lowercased name (as returned by lowercase_name()). - // This lookup may be ambiguous if multiple field names differ only by case, - // in which case the field returned is chosen arbitrarily from the matches. - const FieldDescriptor* FindFieldByLowercaseName( - const string& lowercase_name) const; - - // Looks up a field by camel-case name (as returned by camelcase_name()). - // This lookup may be ambiguous if multiple field names differ in a way that - // leads them to have identical camel-case names, in which case the field - // returned is chosen arbitrarily from the matches. - const FieldDescriptor* FindFieldByCamelcaseName( - const string& camelcase_name) const; - - // Nested type stuff ----------------------------------------------- - - // The number of nested types in this message type. - int nested_type_count() const; - // Gets a nested type by index, where 0 <= index < nested_type_count(). - // These are returned in the order they were defined in the .proto file. - const Descriptor* nested_type(int index) const; - - // Looks up a nested type by name. Returns NULL if no such nested type - // exists. - const Descriptor* FindNestedTypeByName(const string& name) const; - - // Enum stuff ------------------------------------------------------ - - // The number of enum types in this message type. - int enum_type_count() const; - // Gets an enum type by index, where 0 <= index < enum_type_count(). - // These are returned in the order they were defined in the .proto file. - const EnumDescriptor* enum_type(int index) const; - - // Looks up an enum type by name. Returns NULL if no such enum type exists. - const EnumDescriptor* FindEnumTypeByName(const string& name) const; - - // Looks up an enum value by name, among all enum types in this message. - // Returns NULL if no such value exists. - const EnumValueDescriptor* FindEnumValueByName(const string& name) const; - - // Extensions ------------------------------------------------------ - - // A range of field numbers which are designated for third-party - // extensions. - struct ExtensionRange { - int start; // inclusive - int end; // exclusive - }; - - // The number of extension ranges in this message type. - int extension_range_count() const; - // Gets an extension range by index, where 0 <= index < - // extension_range_count(). These are returned in the order they were defined - // in the .proto file. - const ExtensionRange* extension_range(int index) const; - - // Returns true if the number is in one of the extension ranges. - bool IsExtensionNumber(int number) const; - - // The number of extensions -- extending *other* messages -- that were - // defined nested within this message type's scope. - int extension_count() const; - // Get an extension by index, where 0 <= index < extension_count(). - // These are returned in the order they were defined in the .proto file. - const FieldDescriptor* extension(int index) const; - - // Looks up a named extension (which extends some *other* message type) - // defined within this message type's scope. - const FieldDescriptor* FindExtensionByName(const string& name) const; - - // Similar to FindFieldByLowercaseName(), but finds extensions defined within - // this message type's scope. - const FieldDescriptor* FindExtensionByLowercaseName(const string& name) const; - - // Similar to FindFieldByCamelcaseName(), but finds extensions defined within - // this message type's scope. - const FieldDescriptor* FindExtensionByCamelcaseName(const string& name) const; - - // Source Location --------------------------------------------------- - - // Updates |*out_location| to the source location of the complete - // extent of this message declaration. Returns false and leaves - // |*out_location| unchanged iff location information was not available. - bool GetSourceLocation(SourceLocation* out_location) const; - - private: - typedef MessageOptions OptionsType; - - // Internal version of DebugString; controls the level of indenting for - // correct depth - void DebugString(int depth, string *contents) const; - - // Walks up the descriptor tree to generate the source location path - // to this descriptor from the file root. - void GetLocationPath(vector* output) const; - - const string* name_; - const string* full_name_; - const FileDescriptor* file_; - const Descriptor* containing_type_; - const MessageOptions* options_; - - // True if this is a placeholder for an unknown type. - bool is_placeholder_; - // True if this is a placeholder and the type name wasn't fully-qualified. - bool is_unqualified_placeholder_; - - int field_count_; - FieldDescriptor* fields_; - int nested_type_count_; - Descriptor* nested_types_; - int enum_type_count_; - EnumDescriptor* enum_types_; - int extension_range_count_; - ExtensionRange* extension_ranges_; - int extension_count_; - FieldDescriptor* extensions_; - // IMPORTANT: If you add a new field, make sure to search for all instances - // of Allocate() and AllocateArray() in descriptor.cc - // and update them to initialize the field. - - // Must be constructed using DescriptorPool. - Descriptor() {} - friend class DescriptorBuilder; - friend class EnumDescriptor; - friend class FieldDescriptor; - friend class MethodDescriptor; - friend class FileDescriptor; - GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(Descriptor); -}; - -// Describes a single field of a message. To get the descriptor for a given -// field, first get the Descriptor for the message in which it is defined, -// then call Descriptor::FindFieldByName(). To get a FieldDescriptor for -// an extension, do one of the following: -// - Get the Descriptor or FileDescriptor for its containing scope, then -// call Descriptor::FindExtensionByName() or -// FileDescriptor::FindExtensionByName(). -// - Given a DescriptorPool, call DescriptorPool::FindExtensionByNumber(). -// - Given a Reflection for a message object, call -// Reflection::FindKnownExtensionByName() or -// Reflection::FindKnownExtensionByNumber(). -// Use DescriptorPool to construct your own descriptors. -class LIBPROTOBUF_EXPORT FieldDescriptor { - public: - // Identifies a field type. 0 is reserved for errors. The order is weird - // for historical reasons. Types 12 and up are new in proto2. - enum Type { - TYPE_DOUBLE = 1, // double, exactly eight bytes on the wire. - TYPE_FLOAT = 2, // float, exactly four bytes on the wire. - TYPE_INT64 = 3, // int64, varint on the wire. Negative numbers - // take 10 bytes. Use TYPE_SINT64 if negative - // values are likely. - TYPE_UINT64 = 4, // uint64, varint on the wire. - TYPE_INT32 = 5, // int32, varint on the wire. Negative numbers - // take 10 bytes. Use TYPE_SINT32 if negative - // values are likely. - TYPE_FIXED64 = 6, // uint64, exactly eight bytes on the wire. - TYPE_FIXED32 = 7, // uint32, exactly four bytes on the wire. - TYPE_BOOL = 8, // bool, varint on the wire. - TYPE_STRING = 9, // UTF-8 text. - TYPE_GROUP = 10, // Tag-delimited message. Deprecated. - TYPE_MESSAGE = 11, // Length-delimited message. - - TYPE_BYTES = 12, // Arbitrary byte array. - TYPE_UINT32 = 13, // uint32, varint on the wire - TYPE_ENUM = 14, // Enum, varint on the wire - TYPE_SFIXED32 = 15, // int32, exactly four bytes on the wire - TYPE_SFIXED64 = 16, // int64, exactly eight bytes on the wire - TYPE_SINT32 = 17, // int32, ZigZag-encoded varint on the wire - TYPE_SINT64 = 18, // int64, ZigZag-encoded varint on the wire - - MAX_TYPE = 18, // Constant useful for defining lookup tables - // indexed by Type. - }; - - // Specifies the C++ data type used to represent the field. There is a - // fixed mapping from Type to CppType where each Type maps to exactly one - // CppType. 0 is reserved for errors. - enum CppType { - CPPTYPE_INT32 = 1, // TYPE_INT32, TYPE_SINT32, TYPE_SFIXED32 - CPPTYPE_INT64 = 2, // TYPE_INT64, TYPE_SINT64, TYPE_SFIXED64 - CPPTYPE_UINT32 = 3, // TYPE_UINT32, TYPE_FIXED32 - CPPTYPE_UINT64 = 4, // TYPE_UINT64, TYPE_FIXED64 - CPPTYPE_DOUBLE = 5, // TYPE_DOUBLE - CPPTYPE_FLOAT = 6, // TYPE_FLOAT - CPPTYPE_BOOL = 7, // TYPE_BOOL - CPPTYPE_ENUM = 8, // TYPE_ENUM - CPPTYPE_STRING = 9, // TYPE_STRING, TYPE_BYTES - CPPTYPE_MESSAGE = 10, // TYPE_MESSAGE, TYPE_GROUP - - MAX_CPPTYPE = 10, // Constant useful for defining lookup tables - // indexed by CppType. - }; - - // Identifies whether the field is optional, required, or repeated. 0 is - // reserved for errors. - enum Label { - LABEL_OPTIONAL = 1, // optional - LABEL_REQUIRED = 2, // required - LABEL_REPEATED = 3, // repeated - - MAX_LABEL = 3, // Constant useful for defining lookup tables - // indexed by Label. - }; - - // Valid field numbers are positive integers up to kMaxNumber. - static const int kMaxNumber = (1 << 29) - 1; - - // First field number reserved for the protocol buffer library implementation. - // Users may not declare fields that use reserved numbers. - static const int kFirstReservedNumber = 19000; - // Last field number reserved for the protocol buffer library implementation. - // Users may not declare fields that use reserved numbers. - static const int kLastReservedNumber = 19999; - - const string& name() const; // Name of this field within the message. - const string& full_name() const; // Fully-qualified name of the field. - const FileDescriptor* file() const;// File in which this field was defined. - bool is_extension() const; // Is this an extension field? - int number() const; // Declared tag number. - - // Same as name() except converted to lower-case. This (and especially the - // FindFieldByLowercaseName() method) can be useful when parsing formats - // which prefer to use lowercase naming style. (Although, technically - // field names should be lowercased anyway according to the protobuf style - // guide, so this only makes a difference when dealing with old .proto files - // which do not follow the guide.) - const string& lowercase_name() const; - - // Same as name() except converted to camel-case. In this conversion, any - // time an underscore appears in the name, it is removed and the next - // letter is capitalized. Furthermore, the first letter of the name is - // lower-cased. Examples: - // FooBar -> fooBar - // foo_bar -> fooBar - // fooBar -> fooBar - // This (and especially the FindFieldByCamelcaseName() method) can be useful - // when parsing formats which prefer to use camel-case naming style. - const string& camelcase_name() const; - - Type type() const; // Declared type of this field. - const char* type_name() const; // Name of the declared type. - CppType cpp_type() const; // C++ type of this field. - const char* cpp_type_name() const; // Name of the C++ type. - Label label() const; // optional/required/repeated - - bool is_required() const; // shorthand for label() == LABEL_REQUIRED - bool is_optional() const; // shorthand for label() == LABEL_OPTIONAL - bool is_repeated() const; // shorthand for label() == LABEL_REPEATED - bool is_packable() const; // shorthand for is_repeated() && - // IsTypePackable(type()) - bool is_packed() const; // shorthand for is_packable() && - // options().packed() - - // Index of this field within the message's field array, or the file or - // extension scope's extensions array. - int index() const; - - // Does this field have an explicitly-declared default value? - bool has_default_value() const; - - // Get the field default value if cpp_type() == CPPTYPE_INT32. If no - // explicit default was defined, the default is 0. - int32 default_value_int32() const; - // Get the field default value if cpp_type() == CPPTYPE_INT64. If no - // explicit default was defined, the default is 0. - int64 default_value_int64() const; - // Get the field default value if cpp_type() == CPPTYPE_UINT32. If no - // explicit default was defined, the default is 0. - uint32 default_value_uint32() const; - // Get the field default value if cpp_type() == CPPTYPE_UINT64. If no - // explicit default was defined, the default is 0. - uint64 default_value_uint64() const; - // Get the field default value if cpp_type() == CPPTYPE_FLOAT. If no - // explicit default was defined, the default is 0.0. - float default_value_float() const; - // Get the field default value if cpp_type() == CPPTYPE_DOUBLE. If no - // explicit default was defined, the default is 0.0. - double default_value_double() const; - // Get the field default value if cpp_type() == CPPTYPE_BOOL. If no - // explicit default was defined, the default is false. - bool default_value_bool() const; - // Get the field default value if cpp_type() == CPPTYPE_ENUM. If no - // explicit default was defined, the default is the first value defined - // in the enum type (all enum types are required to have at least one value). - // This never returns NULL. - const EnumValueDescriptor* default_value_enum() const; - // Get the field default value if cpp_type() == CPPTYPE_STRING. If no - // explicit default was defined, the default is the empty string. - const string& default_value_string() const; - - // The Descriptor for the message of which this is a field. For extensions, - // this is the extended type. Never NULL. - const Descriptor* containing_type() const; - - // An extension may be declared within the scope of another message. If this - // field is an extension (is_extension() is true), then extension_scope() - // returns that message, or NULL if the extension was declared at global - // scope. If this is not an extension, extension_scope() is undefined (may - // assert-fail). - const Descriptor* extension_scope() const; - - // If type is TYPE_MESSAGE or TYPE_GROUP, returns a descriptor for the - // message or the group type. Otherwise, undefined. - const Descriptor* message_type() const; - // If type is TYPE_ENUM, returns a descriptor for the enum. Otherwise, - // undefined. - const EnumDescriptor* enum_type() const; - - // EXPERIMENTAL; DO NOT USE. - // If this field is a map field, experimental_map_key() is the field - // that is the key for this map. - // experimental_map_key()->containing_type() is the same as message_type(). - const FieldDescriptor* experimental_map_key() const; - - // Get the FieldOptions for this field. This includes things listed in - // square brackets after the field definition. E.g., the field: - // optional string text = 1 [ctype=CORD]; - // has the "ctype" option set. Allowed options are defined by FieldOptions - // in google/protobuf/descriptor.proto, and any available extensions of that - // message. - const FieldOptions& options() const; - - // See Descriptor::CopyTo(). - void CopyTo(FieldDescriptorProto* proto) const; - - // See Descriptor::DebugString(). - string DebugString() const; - - // Helper method to get the CppType for a particular Type. - static CppType TypeToCppType(Type type); - - // Return true iff [packed = true] is valid for fields of this type. - static inline bool IsTypePackable(Type field_type); - - // Source Location --------------------------------------------------- - - // Updates |*out_location| to the source location of the complete - // extent of this field declaration. Returns false and leaves - // |*out_location| unchanged iff location information was not available. - bool GetSourceLocation(SourceLocation* out_location) const; - - private: - typedef FieldOptions OptionsType; - - // See Descriptor::DebugString(). - void DebugString(int depth, string *contents) const; - - // formats the default value appropriately and returns it as a string. - // Must have a default value to call this. If quote_string_type is true, then - // types of CPPTYPE_STRING whill be surrounded by quotes and CEscaped. - string DefaultValueAsString(bool quote_string_type) const; - - // Walks up the descriptor tree to generate the source location path - // to this descriptor from the file root. - void GetLocationPath(vector* output) const; - - const string* name_; - const string* full_name_; - const string* lowercase_name_; - const string* camelcase_name_; - const FileDescriptor* file_; - int number_; - Type type_; - Label label_; - bool is_extension_; - const Descriptor* containing_type_; - const Descriptor* extension_scope_; - const Descriptor* message_type_; - const EnumDescriptor* enum_type_; - const FieldDescriptor* experimental_map_key_; - const FieldOptions* options_; - // IMPORTANT: If you add a new field, make sure to search for all instances - // of Allocate() and AllocateArray() in - // descriptor.cc and update them to initialize the field. - - bool has_default_value_; - union { - int32 default_value_int32_; - int64 default_value_int64_; - uint32 default_value_uint32_; - uint64 default_value_uint64_; - float default_value_float_; - double default_value_double_; - bool default_value_bool_; - - const EnumValueDescriptor* default_value_enum_; - const string* default_value_string_; - }; - - static const CppType kTypeToCppTypeMap[MAX_TYPE + 1]; - - static const char * const kTypeToName[MAX_TYPE + 1]; - - static const char * const kCppTypeToName[MAX_CPPTYPE + 1]; - - static const char * const kLabelToName[MAX_LABEL + 1]; - - // Must be constructed using DescriptorPool. - FieldDescriptor() {} - friend class DescriptorBuilder; - friend class FileDescriptor; - friend class Descriptor; - GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(FieldDescriptor); -}; - -// Describes an enum type defined in a .proto file. To get the EnumDescriptor -// for a generated enum type, call TypeName_descriptor(). Use DescriptorPool -// to construct your own descriptors. -class LIBPROTOBUF_EXPORT EnumDescriptor { - public: - // The name of this enum type in the containing scope. - const string& name() const; - - // The fully-qualified name of the enum type, scope delimited by periods. - const string& full_name() const; - - // Index of this enum within the file or containing message's enum array. - int index() const; - - // The .proto file in which this enum type was defined. Never NULL. - const FileDescriptor* file() const; - - // The number of values for this EnumDescriptor. Guaranteed to be greater - // than zero. - int value_count() const; - // Gets a value by index, where 0 <= index < value_count(). - // These are returned in the order they were defined in the .proto file. - const EnumValueDescriptor* value(int index) const; - - // Looks up a value by name. Returns NULL if no such value exists. - const EnumValueDescriptor* FindValueByName(const string& name) const; - // Looks up a value by number. Returns NULL if no such value exists. If - // multiple values have this number, the first one defined is returned. - const EnumValueDescriptor* FindValueByNumber(int number) const; - - // If this enum type is nested in a message type, this is that message type. - // Otherwise, NULL. - const Descriptor* containing_type() const; - - // Get options for this enum type. These are specified in the .proto file by - // placing lines like "option foo = 1234;" in the enum definition. Allowed - // options are defined by EnumOptions in google/protobuf/descriptor.proto, - // and any available extensions of that message. - const EnumOptions& options() const; - - // See Descriptor::CopyTo(). - void CopyTo(EnumDescriptorProto* proto) const; - - // See Descriptor::DebugString(). - string DebugString() const; - - // Source Location --------------------------------------------------- - - // Updates |*out_location| to the source location of the complete - // extent of this enum declaration. Returns false and leaves - // |*out_location| unchanged iff location information was not available. - bool GetSourceLocation(SourceLocation* out_location) const; - - private: - typedef EnumOptions OptionsType; - - // See Descriptor::DebugString(). - void DebugString(int depth, string *contents) const; - - // Walks up the descriptor tree to generate the source location path - // to this descriptor from the file root. - void GetLocationPath(vector* output) const; - - const string* name_; - const string* full_name_; - const FileDescriptor* file_; - const Descriptor* containing_type_; - const EnumOptions* options_; - - // True if this is a placeholder for an unknown type. - bool is_placeholder_; - // True if this is a placeholder and the type name wasn't fully-qualified. - bool is_unqualified_placeholder_; - - int value_count_; - EnumValueDescriptor* values_; - // IMPORTANT: If you add a new field, make sure to search for all instances - // of Allocate() and AllocateArray() in - // descriptor.cc and update them to initialize the field. - - // Must be constructed using DescriptorPool. - EnumDescriptor() {} - friend class DescriptorBuilder; - friend class Descriptor; - friend class FieldDescriptor; - friend class EnumValueDescriptor; - friend class FileDescriptor; - GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(EnumDescriptor); -}; - -// Describes an individual enum constant of a particular type. To get the -// EnumValueDescriptor for a given enum value, first get the EnumDescriptor -// for its type, then use EnumDescriptor::FindValueByName() or -// EnumDescriptor::FindValueByNumber(). Use DescriptorPool to construct -// your own descriptors. -class LIBPROTOBUF_EXPORT EnumValueDescriptor { - public: - const string& name() const; // Name of this enum constant. - int index() const; // Index within the enums's Descriptor. - int number() const; // Numeric value of this enum constant. - - // The full_name of an enum value is a sibling symbol of the enum type. - // e.g. the full name of FieldDescriptorProto::TYPE_INT32 is actually - // "google.protobuf.FieldDescriptorProto.TYPE_INT32", NOT - // "google.protobuf.FieldDescriptorProto.Type.TYPE_INT32". This is to conform - // with C++ scoping rules for enums. - const string& full_name() const; - - // The type of this value. Never NULL. - const EnumDescriptor* type() const; - - // Get options for this enum value. These are specified in the .proto file - // by adding text like "[foo = 1234]" after an enum value definition. - // Allowed options are defined by EnumValueOptions in - // google/protobuf/descriptor.proto, and any available extensions of that - // message. - const EnumValueOptions& options() const; - - // See Descriptor::CopyTo(). - void CopyTo(EnumValueDescriptorProto* proto) const; - - // See Descriptor::DebugString(). - string DebugString() const; - - // Source Location --------------------------------------------------- - - // Updates |*out_location| to the source location of the complete - // extent of this enum value declaration. Returns false and leaves - // |*out_location| unchanged iff location information was not available. - bool GetSourceLocation(SourceLocation* out_location) const; - - private: - typedef EnumValueOptions OptionsType; - - // See Descriptor::DebugString(). - void DebugString(int depth, string *contents) const; - - // Walks up the descriptor tree to generate the source location path - // to this descriptor from the file root. - void GetLocationPath(vector* output) const; - - const string* name_; - const string* full_name_; - int number_; - const EnumDescriptor* type_; - const EnumValueOptions* options_; - // IMPORTANT: If you add a new field, make sure to search for all instances - // of Allocate() and AllocateArray() - // in descriptor.cc and update them to initialize the field. - - // Must be constructed using DescriptorPool. - EnumValueDescriptor() {} - friend class DescriptorBuilder; - friend class EnumDescriptor; - GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(EnumValueDescriptor); -}; - -// Describes an RPC service. To get the ServiceDescriptor for a service, -// call Service::GetDescriptor(). Generated service classes also have a -// static method called descriptor() which returns the type's -// ServiceDescriptor. Use DescriptorPool to construct your own descriptors. -class LIBPROTOBUF_EXPORT ServiceDescriptor { - public: - // The name of the service, not including its containing scope. - const string& name() const; - // The fully-qualified name of the service, scope delimited by periods. - const string& full_name() const; - // Index of this service within the file's services array. - int index() const; - - // The .proto file in which this service was defined. Never NULL. - const FileDescriptor* file() const; - - // Get options for this service type. These are specified in the .proto file - // by placing lines like "option foo = 1234;" in the service definition. - // Allowed options are defined by ServiceOptions in - // google/protobuf/descriptor.proto, and any available extensions of that - // message. - const ServiceOptions& options() const; - - // The number of methods this service defines. - int method_count() const; - // Gets a MethodDescriptor by index, where 0 <= index < method_count(). - // These are returned in the order they were defined in the .proto file. - const MethodDescriptor* method(int index) const; - - // Look up a MethodDescriptor by name. - const MethodDescriptor* FindMethodByName(const string& name) const; - // See Descriptor::CopyTo(). - void CopyTo(ServiceDescriptorProto* proto) const; - - // See Descriptor::DebugString(). - string DebugString() const; - - // Source Location --------------------------------------------------- - - // Updates |*out_location| to the source location of the complete - // extent of this service declaration. Returns false and leaves - // |*out_location| unchanged iff location information was not available. - bool GetSourceLocation(SourceLocation* out_location) const; - - private: - typedef ServiceOptions OptionsType; - - // See Descriptor::DebugString(). - void DebugString(string *contents) const; - - // Walks up the descriptor tree to generate the source location path - // to this descriptor from the file root. - void GetLocationPath(vector* output) const; - - const string* name_; - const string* full_name_; - const FileDescriptor* file_; - const ServiceOptions* options_; - int method_count_; - MethodDescriptor* methods_; - // IMPORTANT: If you add a new field, make sure to search for all instances - // of Allocate() and AllocateArray() in - // descriptor.cc and update them to initialize the field. - - // Must be constructed using DescriptorPool. - ServiceDescriptor() {} - friend class DescriptorBuilder; - friend class FileDescriptor; - friend class MethodDescriptor; - GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ServiceDescriptor); -}; - -// Describes an individual service method. To obtain a MethodDescriptor given -// a service, first get its ServiceDescriptor, then call -// ServiceDescriptor::FindMethodByName(). Use DescriptorPool to construct your -// own descriptors. -class LIBPROTOBUF_EXPORT MethodDescriptor { - public: - // Name of this method, not including containing scope. - const string& name() const; - // The fully-qualified name of the method, scope delimited by periods. - const string& full_name() const; - // Index within the service's Descriptor. - int index() const; - - // Gets the service to which this method belongs. Never NULL. - const ServiceDescriptor* service() const; - - // Gets the type of protocol message which this method accepts as input. - const Descriptor* input_type() const; - // Gets the type of protocol message which this message produces as output. - const Descriptor* output_type() const; - - // Get options for this method. These are specified in the .proto file by - // placing lines like "option foo = 1234;" in curly-braces after a method - // declaration. Allowed options are defined by MethodOptions in - // google/protobuf/descriptor.proto, and any available extensions of that - // message. - const MethodOptions& options() const; - - // See Descriptor::CopyTo(). - void CopyTo(MethodDescriptorProto* proto) const; - - // See Descriptor::DebugString(). - string DebugString() const; - - // Source Location --------------------------------------------------- - - // Updates |*out_location| to the source location of the complete - // extent of this method declaration. Returns false and leaves - // |*out_location| unchanged iff location information was not available. - bool GetSourceLocation(SourceLocation* out_location) const; - - private: - typedef MethodOptions OptionsType; - - // See Descriptor::DebugString(). - void DebugString(int depth, string *contents) const; - - // Walks up the descriptor tree to generate the source location path - // to this descriptor from the file root. - void GetLocationPath(vector* output) const; - - const string* name_; - const string* full_name_; - const ServiceDescriptor* service_; - const Descriptor* input_type_; - const Descriptor* output_type_; - const MethodOptions* options_; - // IMPORTANT: If you add a new field, make sure to search for all instances - // of Allocate() and AllocateArray() in - // descriptor.cc and update them to initialize the field. - - // Must be constructed using DescriptorPool. - MethodDescriptor() {} - friend class DescriptorBuilder; - friend class ServiceDescriptor; - GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(MethodDescriptor); -}; - - -// Describes a whole .proto file. To get the FileDescriptor for a compiled-in -// file, get the descriptor for something defined in that file and call -// descriptor->file(). Use DescriptorPool to construct your own descriptors. -class LIBPROTOBUF_EXPORT FileDescriptor { - public: - // The filename, relative to the source tree. - // e.g. "google/protobuf/descriptor.proto" - const string& name() const; - - // The package, e.g. "google.protobuf.compiler". - const string& package() const; - - // The DescriptorPool in which this FileDescriptor and all its contents were - // allocated. Never NULL. - const DescriptorPool* pool() const; - - // The number of files imported by this one. - int dependency_count() const; - // Gets an imported file by index, where 0 <= index < dependency_count(). - // These are returned in the order they were defined in the .proto file. - const FileDescriptor* dependency(int index) const; - - // The number of files public imported by this one. - // The public dependency list is a subset of the dependency list. - int public_dependency_count() const; - // Gets a public imported file by index, where 0 <= index < - // public_dependency_count(). - // These are returned in the order they were defined in the .proto file. - const FileDescriptor* public_dependency(int index) const; - - // The number of files that are imported for weak fields. - // The weak dependency list is a subset of the dependency list. - int weak_dependency_count() const; - // Gets a weak imported file by index, where 0 <= index < - // weak_dependency_count(). - // These are returned in the order they were defined in the .proto file. - const FileDescriptor* weak_dependency(int index) const; - - // Number of top-level message types defined in this file. (This does not - // include nested types.) - int message_type_count() const; - // Gets a top-level message type, where 0 <= index < message_type_count(). - // These are returned in the order they were defined in the .proto file. - const Descriptor* message_type(int index) const; - - // Number of top-level enum types defined in this file. (This does not - // include nested types.) - int enum_type_count() const; - // Gets a top-level enum type, where 0 <= index < enum_type_count(). - // These are returned in the order they were defined in the .proto file. - const EnumDescriptor* enum_type(int index) const; - - // Number of services defined in this file. - int service_count() const; - // Gets a service, where 0 <= index < service_count(). - // These are returned in the order they were defined in the .proto file. - const ServiceDescriptor* service(int index) const; - - // Number of extensions defined at file scope. (This does not include - // extensions nested within message types.) - int extension_count() const; - // Gets an extension's descriptor, where 0 <= index < extension_count(). - // These are returned in the order they were defined in the .proto file. - const FieldDescriptor* extension(int index) const; - - // Get options for this file. These are specified in the .proto file by - // placing lines like "option foo = 1234;" at the top level, outside of any - // other definitions. Allowed options are defined by FileOptions in - // google/protobuf/descriptor.proto, and any available extensions of that - // message. - const FileOptions& options() const; - - // Find a top-level message type by name. Returns NULL if not found. - const Descriptor* FindMessageTypeByName(const string& name) const; - // Find a top-level enum type by name. Returns NULL if not found. - const EnumDescriptor* FindEnumTypeByName(const string& name) const; - // Find an enum value defined in any top-level enum by name. Returns NULL if - // not found. - const EnumValueDescriptor* FindEnumValueByName(const string& name) const; - // Find a service definition by name. Returns NULL if not found. - const ServiceDescriptor* FindServiceByName(const string& name) const; - // Find a top-level extension definition by name. Returns NULL if not found. - const FieldDescriptor* FindExtensionByName(const string& name) const; - // Similar to FindExtensionByName(), but searches by lowercased-name. See - // Descriptor::FindFieldByLowercaseName(). - const FieldDescriptor* FindExtensionByLowercaseName(const string& name) const; - // Similar to FindExtensionByName(), but searches by camelcased-name. See - // Descriptor::FindFieldByCamelcaseName(). - const FieldDescriptor* FindExtensionByCamelcaseName(const string& name) const; - - // See Descriptor::CopyTo(). - // Notes: - // - This method does NOT copy source code information since it is relatively - // large and rarely needed. See CopySourceCodeInfoTo() below. - void CopyTo(FileDescriptorProto* proto) const; - // Write the source code information of this FileDescriptor into the given - // FileDescriptorProto. See CopyTo() above. - void CopySourceCodeInfoTo(FileDescriptorProto* proto) const; - - // See Descriptor::DebugString(). - string DebugString() const; - - private: - // Source Location --------------------------------------------------- - - // Updates |*out_location| to the source location of the complete - // extent of the declaration or declaration-part denoted by |path|. - // Returns false and leaves |*out_location| unchanged iff location - // information was not available. (See SourceCodeInfo for - // description of path encoding.) - bool GetSourceLocation(const vector& path, - SourceLocation* out_location) const; - - typedef FileOptions OptionsType; - - const string* name_; - const string* package_; - const DescriptorPool* pool_; - int dependency_count_; - const FileDescriptor** dependencies_; - int public_dependency_count_; - int* public_dependencies_; - int weak_dependency_count_; - int* weak_dependencies_; - int message_type_count_; - Descriptor* message_types_; - int enum_type_count_; - EnumDescriptor* enum_types_; - int service_count_; - ServiceDescriptor* services_; - int extension_count_; - FieldDescriptor* extensions_; - const FileOptions* options_; - - const FileDescriptorTables* tables_; - const SourceCodeInfo* source_code_info_; - // IMPORTANT: If you add a new field, make sure to search for all instances - // of Allocate() and AllocateArray() in - // descriptor.cc and update them to initialize the field. - - FileDescriptor() {} - friend class DescriptorBuilder; - friend class Descriptor; - friend class FieldDescriptor; - friend class EnumDescriptor; - friend class EnumValueDescriptor; - friend class MethodDescriptor; - friend class ServiceDescriptor; - GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(FileDescriptor); -}; - -// =================================================================== - -// Used to construct descriptors. -// -// Normally you won't want to build your own descriptors. Message classes -// constructed by the protocol compiler will provide them for you. However, -// if you are implementing Message on your own, or if you are writing a -// program which can operate on totally arbitrary types and needs to load -// them from some sort of database, you might need to. -// -// Since Descriptors are composed of a whole lot of cross-linked bits of -// data that would be a pain to put together manually, the -// DescriptorPool class is provided to make the process easier. It can -// take a FileDescriptorProto (defined in descriptor.proto), validate it, -// and convert it to a set of nicely cross-linked Descriptors. -// -// DescriptorPool also helps with memory management. Descriptors are -// composed of many objects containing static data and pointers to each -// other. In all likelihood, when it comes time to delete this data, -// you'll want to delete it all at once. In fact, it is not uncommon to -// have a whole pool of descriptors all cross-linked with each other which -// you wish to delete all at once. This class represents such a pool, and -// handles the memory management for you. -// -// You can also search for descriptors within a DescriptorPool by name, and -// extensions by number. -class LIBPROTOBUF_EXPORT DescriptorPool { - public: - // Create a normal, empty DescriptorPool. - DescriptorPool(); - - // Constructs a DescriptorPool that, when it can't find something among the - // descriptors already in the pool, looks for it in the given - // DescriptorDatabase. - // Notes: - // - If a DescriptorPool is constructed this way, its BuildFile*() methods - // must not be called (they will assert-fail). The only way to populate - // the pool with descriptors is to call the Find*By*() methods. - // - The Find*By*() methods may block the calling thread if the - // DescriptorDatabase blocks. This in turn means that parsing messages - // may block if they need to look up extensions. - // - The Find*By*() methods will use mutexes for thread-safety, thus making - // them slower even when they don't have to fall back to the database. - // In fact, even the Find*By*() methods of descriptor objects owned by - // this pool will be slower, since they will have to obtain locks too. - // - An ErrorCollector may optionally be given to collect validation errors - // in files loaded from the database. If not given, errors will be printed - // to GOOGLE_LOG(ERROR). Remember that files are built on-demand, so this - // ErrorCollector may be called from any thread that calls one of the - // Find*By*() methods. - class ErrorCollector; - explicit DescriptorPool(DescriptorDatabase* fallback_database, - ErrorCollector* error_collector = NULL); - - ~DescriptorPool(); - - // Get a pointer to the generated pool. Generated protocol message classes - // which are compiled into the binary will allocate their descriptors in - // this pool. Do not add your own descriptors to this pool. - static const DescriptorPool* generated_pool(); - - // Find a FileDescriptor in the pool by file name. Returns NULL if not - // found. - const FileDescriptor* FindFileByName(const string& name) const; - - // Find the FileDescriptor in the pool which defines the given symbol. - // If any of the Find*ByName() methods below would succeed, then this is - // equivalent to calling that method and calling the result's file() method. - // Otherwise this returns NULL. - const FileDescriptor* FindFileContainingSymbol( - const string& symbol_name) const; - - // Looking up descriptors ------------------------------------------ - // These find descriptors by fully-qualified name. These will find both - // top-level descriptors and nested descriptors. They return NULL if not - // found. - - const Descriptor* FindMessageTypeByName(const string& name) const; - const FieldDescriptor* FindFieldByName(const string& name) const; - const FieldDescriptor* FindExtensionByName(const string& name) const; - const EnumDescriptor* FindEnumTypeByName(const string& name) const; - const EnumValueDescriptor* FindEnumValueByName(const string& name) const; - const ServiceDescriptor* FindServiceByName(const string& name) const; - const MethodDescriptor* FindMethodByName(const string& name) const; - - // Finds an extension of the given type by number. The extendee must be - // a member of this DescriptorPool or one of its underlays. - const FieldDescriptor* FindExtensionByNumber(const Descriptor* extendee, - int number) const; - - // Finds extensions of extendee. The extensions will be appended to - // out in an undefined order. Only extensions defined directly in - // this DescriptorPool or one of its underlays are guaranteed to be - // found: extensions defined in the fallback database might not be found - // depending on the database implementation. - void FindAllExtensions(const Descriptor* extendee, - vector* out) const; - - // Building descriptors -------------------------------------------- - - // When converting a FileDescriptorProto to a FileDescriptor, various - // errors might be detected in the input. The caller may handle these - // programmatically by implementing an ErrorCollector. - class LIBPROTOBUF_EXPORT ErrorCollector { - public: - inline ErrorCollector() {} - virtual ~ErrorCollector(); - - // These constants specify what exact part of the construct is broken. - // This is useful e.g. for mapping the error back to an exact location - // in a .proto file. - enum ErrorLocation { - NAME, // the symbol name, or the package name for files - NUMBER, // field or extension range number - TYPE, // field type - EXTENDEE, // field extendee - DEFAULT_VALUE, // field default value - INPUT_TYPE, // method input type - OUTPUT_TYPE, // method output type - OPTION_NAME, // name in assignment - OPTION_VALUE, // value in option assignment - OTHER // some other problem - }; - - // Reports an error in the FileDescriptorProto. - virtual void AddError( - const string& filename, // File name in which the error occurred. - const string& element_name, // Full name of the erroneous element. - const Message* descriptor, // Descriptor of the erroneous element. - ErrorLocation location, // One of the location constants, above. - const string& message // Human-readable error message. - ) = 0; - - private: - GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ErrorCollector); - }; - - // Convert the FileDescriptorProto to real descriptors and place them in - // this DescriptorPool. All dependencies of the file must already be in - // the pool. Returns the resulting FileDescriptor, or NULL if there were - // problems with the input (e.g. the message was invalid, or dependencies - // were missing). Details about the errors are written to GOOGLE_LOG(ERROR). - const FileDescriptor* BuildFile(const FileDescriptorProto& proto); - - // Same as BuildFile() except errors are sent to the given ErrorCollector. - const FileDescriptor* BuildFileCollectingErrors( - const FileDescriptorProto& proto, - ErrorCollector* error_collector); - - // By default, it is an error if a FileDescriptorProto contains references - // to types or other files that are not found in the DescriptorPool (or its - // backing DescriptorDatabase, if any). If you call - // AllowUnknownDependencies(), however, then unknown types and files - // will be replaced by placeholder descriptors. This can allow you to - // perform some useful operations with a .proto file even if you do not - // have access to other .proto files on which it depends. However, some - // heuristics must be used to fill in the gaps in information, and these - // can lead to descriptors which are inaccurate. For example, the - // DescriptorPool may be forced to guess whether an unknown type is a message - // or an enum, as well as what package it resides in. Furthermore, - // placeholder types will not be discoverable via FindMessageTypeByName() - // and similar methods, which could confuse some descriptor-based algorithms. - // Generally, the results of this option should only be relied upon for - // debugging purposes. - void AllowUnknownDependencies() { allow_unknown_ = true; } - - // Internal stuff -------------------------------------------------- - // These methods MUST NOT be called from outside the proto2 library. - // These methods may contain hidden pitfalls and may be removed in a - // future library version. - - // Create a DescriptorPool which is overlaid on top of some other pool. - // If you search for a descriptor in the overlay and it is not found, the - // underlay will be searched as a backup. If the underlay has its own - // underlay, that will be searched next, and so on. This also means that - // files built in the overlay will be cross-linked with the underlay's - // descriptors if necessary. The underlay remains property of the caller; - // it must remain valid for the lifetime of the newly-constructed pool. - // - // Example: Say you want to parse a .proto file at runtime in order to use - // its type with a DynamicMessage. Say this .proto file has dependencies, - // but you know that all the dependencies will be things that are already - // compiled into the binary. For ease of use, you'd like to load the types - // right out of generated_pool() rather than have to parse redundant copies - // of all these .protos and runtime. But, you don't want to add the parsed - // types directly into generated_pool(): this is not allowed, and would be - // bad design anyway. So, instead, you could use generated_pool() as an - // underlay for a new DescriptorPool in which you add only the new file. - // - // WARNING: Use of underlays can lead to many subtle gotchas. Instead, - // try to formulate what you want to do in terms of DescriptorDatabases. - explicit DescriptorPool(const DescriptorPool* underlay); - - // Called by generated classes at init time to add their descriptors to - // generated_pool. Do NOT call this in your own code! filename must be a - // permanent string (e.g. a string literal). - static void InternalAddGeneratedFile( - const void* encoded_file_descriptor, int size); - - - // For internal use only: Gets a non-const pointer to the generated pool. - // This is called at static-initialization time only, so thread-safety is - // not a concern. If both an underlay and a fallback database are present, - // the underlay takes precedence. - static DescriptorPool* internal_generated_pool(); - - // For internal use only: Changes the behavior of BuildFile() such that it - // allows the file to make reference to message types declared in other files - // which it did not officially declare as dependencies. - void InternalDontEnforceDependencies(); - - // For internal use only. - void internal_set_underlay(const DescriptorPool* underlay) { - underlay_ = underlay; - } - - // For internal (unit test) use only: Returns true if a FileDescriptor has - // been constructed for the given file, false otherwise. Useful for testing - // lazy descriptor initialization behavior. - bool InternalIsFileLoaded(const string& filename) const; - - private: - friend class Descriptor; - friend class FieldDescriptor; - friend class EnumDescriptor; - friend class ServiceDescriptor; - friend class FileDescriptor; - friend class DescriptorBuilder; - - // Return true if the given name is a sub-symbol of any non-package - // descriptor that already exists in the descriptor pool. (The full - // definition of such types is already known.) - bool IsSubSymbolOfBuiltType(const string& name) const; - - // Tries to find something in the fallback database and link in the - // corresponding proto file. Returns true if successful, in which case - // the caller should search for the thing again. These are declared - // const because they are called by (semantically) const methods. - bool TryFindFileInFallbackDatabase(const string& name) const; - bool TryFindSymbolInFallbackDatabase(const string& name) const; - bool TryFindExtensionInFallbackDatabase(const Descriptor* containing_type, - int field_number) const; - - // Like BuildFile() but called internally when the file has been loaded from - // fallback_database_. Declared const because it is called by (semantically) - // const methods. - const FileDescriptor* BuildFileFromDatabase( - const FileDescriptorProto& proto) const; - - // If fallback_database_ is NULL, this is NULL. Otherwise, this is a mutex - // which must be locked while accessing tables_. - Mutex* mutex_; - - // See constructor. - DescriptorDatabase* fallback_database_; - ErrorCollector* default_error_collector_; - const DescriptorPool* underlay_; - - // This class contains a lot of hash maps with complicated types that - // we'd like to keep out of the header. - class Tables; - scoped_ptr tables_; - - bool enforce_dependencies_; - bool allow_unknown_; - - GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(DescriptorPool); -}; - -// inline methods ==================================================== - -// These macros makes this repetitive code more readable. -#define PROTOBUF_DEFINE_ACCESSOR(CLASS, FIELD, TYPE) \ - inline TYPE CLASS::FIELD() const { return FIELD##_; } - -// Strings fields are stored as pointers but returned as const references. -#define PROTOBUF_DEFINE_STRING_ACCESSOR(CLASS, FIELD) \ - inline const string& CLASS::FIELD() const { return *FIELD##_; } - -// Arrays take an index parameter, obviously. -#define PROTOBUF_DEFINE_ARRAY_ACCESSOR(CLASS, FIELD, TYPE) \ - inline TYPE CLASS::FIELD(int index) const { return FIELD##s_ + index; } - -#define PROTOBUF_DEFINE_OPTIONS_ACCESSOR(CLASS, TYPE) \ - inline const TYPE& CLASS::options() const { return *options_; } - -PROTOBUF_DEFINE_STRING_ACCESSOR(Descriptor, name) -PROTOBUF_DEFINE_STRING_ACCESSOR(Descriptor, full_name) -PROTOBUF_DEFINE_ACCESSOR(Descriptor, file, const FileDescriptor*) -PROTOBUF_DEFINE_ACCESSOR(Descriptor, containing_type, const Descriptor*) - -PROTOBUF_DEFINE_ACCESSOR(Descriptor, field_count, int) -PROTOBUF_DEFINE_ACCESSOR(Descriptor, nested_type_count, int) -PROTOBUF_DEFINE_ACCESSOR(Descriptor, enum_type_count, int) - -PROTOBUF_DEFINE_ARRAY_ACCESSOR(Descriptor, field, const FieldDescriptor*) -PROTOBUF_DEFINE_ARRAY_ACCESSOR(Descriptor, nested_type, const Descriptor*) -PROTOBUF_DEFINE_ARRAY_ACCESSOR(Descriptor, enum_type, const EnumDescriptor*) - -PROTOBUF_DEFINE_ACCESSOR(Descriptor, extension_range_count, int) -PROTOBUF_DEFINE_ACCESSOR(Descriptor, extension_count, int) -PROTOBUF_DEFINE_ARRAY_ACCESSOR(Descriptor, extension_range, - const Descriptor::ExtensionRange*) -PROTOBUF_DEFINE_ARRAY_ACCESSOR(Descriptor, extension, - const FieldDescriptor*) -PROTOBUF_DEFINE_OPTIONS_ACCESSOR(Descriptor, MessageOptions) - -PROTOBUF_DEFINE_STRING_ACCESSOR(FieldDescriptor, name) -PROTOBUF_DEFINE_STRING_ACCESSOR(FieldDescriptor, full_name) -PROTOBUF_DEFINE_STRING_ACCESSOR(FieldDescriptor, lowercase_name) -PROTOBUF_DEFINE_STRING_ACCESSOR(FieldDescriptor, camelcase_name) -PROTOBUF_DEFINE_ACCESSOR(FieldDescriptor, file, const FileDescriptor*) -PROTOBUF_DEFINE_ACCESSOR(FieldDescriptor, number, int) -PROTOBUF_DEFINE_ACCESSOR(FieldDescriptor, is_extension, bool) -PROTOBUF_DEFINE_ACCESSOR(FieldDescriptor, type, FieldDescriptor::Type) -PROTOBUF_DEFINE_ACCESSOR(FieldDescriptor, label, FieldDescriptor::Label) -PROTOBUF_DEFINE_ACCESSOR(FieldDescriptor, containing_type, const Descriptor*) -PROTOBUF_DEFINE_ACCESSOR(FieldDescriptor, extension_scope, const Descriptor*) -PROTOBUF_DEFINE_ACCESSOR(FieldDescriptor, message_type, const Descriptor*) -PROTOBUF_DEFINE_ACCESSOR(FieldDescriptor, enum_type, const EnumDescriptor*) -PROTOBUF_DEFINE_ACCESSOR(FieldDescriptor, experimental_map_key, - const FieldDescriptor*) -PROTOBUF_DEFINE_OPTIONS_ACCESSOR(FieldDescriptor, FieldOptions) -PROTOBUF_DEFINE_ACCESSOR(FieldDescriptor, has_default_value, bool) -PROTOBUF_DEFINE_ACCESSOR(FieldDescriptor, default_value_int32 , int32 ) -PROTOBUF_DEFINE_ACCESSOR(FieldDescriptor, default_value_int64 , int64 ) -PROTOBUF_DEFINE_ACCESSOR(FieldDescriptor, default_value_uint32, uint32) -PROTOBUF_DEFINE_ACCESSOR(FieldDescriptor, default_value_uint64, uint64) -PROTOBUF_DEFINE_ACCESSOR(FieldDescriptor, default_value_float , float ) -PROTOBUF_DEFINE_ACCESSOR(FieldDescriptor, default_value_double, double) -PROTOBUF_DEFINE_ACCESSOR(FieldDescriptor, default_value_bool , bool ) -PROTOBUF_DEFINE_ACCESSOR(FieldDescriptor, default_value_enum, - const EnumValueDescriptor*) -PROTOBUF_DEFINE_STRING_ACCESSOR(FieldDescriptor, default_value_string) - -PROTOBUF_DEFINE_STRING_ACCESSOR(EnumDescriptor, name) -PROTOBUF_DEFINE_STRING_ACCESSOR(EnumDescriptor, full_name) -PROTOBUF_DEFINE_ACCESSOR(EnumDescriptor, file, const FileDescriptor*) -PROTOBUF_DEFINE_ACCESSOR(EnumDescriptor, containing_type, const Descriptor*) -PROTOBUF_DEFINE_ACCESSOR(EnumDescriptor, value_count, int) -PROTOBUF_DEFINE_ARRAY_ACCESSOR(EnumDescriptor, value, - const EnumValueDescriptor*) -PROTOBUF_DEFINE_OPTIONS_ACCESSOR(EnumDescriptor, EnumOptions) - -PROTOBUF_DEFINE_STRING_ACCESSOR(EnumValueDescriptor, name) -PROTOBUF_DEFINE_STRING_ACCESSOR(EnumValueDescriptor, full_name) -PROTOBUF_DEFINE_ACCESSOR(EnumValueDescriptor, number, int) -PROTOBUF_DEFINE_ACCESSOR(EnumValueDescriptor, type, const EnumDescriptor*) -PROTOBUF_DEFINE_OPTIONS_ACCESSOR(EnumValueDescriptor, EnumValueOptions) - -PROTOBUF_DEFINE_STRING_ACCESSOR(ServiceDescriptor, name) -PROTOBUF_DEFINE_STRING_ACCESSOR(ServiceDescriptor, full_name) -PROTOBUF_DEFINE_ACCESSOR(ServiceDescriptor, file, const FileDescriptor*) -PROTOBUF_DEFINE_ACCESSOR(ServiceDescriptor, method_count, int) -PROTOBUF_DEFINE_ARRAY_ACCESSOR(ServiceDescriptor, method, - const MethodDescriptor*) -PROTOBUF_DEFINE_OPTIONS_ACCESSOR(ServiceDescriptor, ServiceOptions) - -PROTOBUF_DEFINE_STRING_ACCESSOR(MethodDescriptor, name) -PROTOBUF_DEFINE_STRING_ACCESSOR(MethodDescriptor, full_name) -PROTOBUF_DEFINE_ACCESSOR(MethodDescriptor, service, const ServiceDescriptor*) -PROTOBUF_DEFINE_ACCESSOR(MethodDescriptor, input_type, const Descriptor*) -PROTOBUF_DEFINE_ACCESSOR(MethodDescriptor, output_type, const Descriptor*) -PROTOBUF_DEFINE_OPTIONS_ACCESSOR(MethodDescriptor, MethodOptions) -PROTOBUF_DEFINE_STRING_ACCESSOR(FileDescriptor, name) -PROTOBUF_DEFINE_STRING_ACCESSOR(FileDescriptor, package) -PROTOBUF_DEFINE_ACCESSOR(FileDescriptor, pool, const DescriptorPool*) -PROTOBUF_DEFINE_ACCESSOR(FileDescriptor, dependency_count, int) -PROTOBUF_DEFINE_ACCESSOR(FileDescriptor, public_dependency_count, int) -PROTOBUF_DEFINE_ACCESSOR(FileDescriptor, weak_dependency_count, int) -PROTOBUF_DEFINE_ACCESSOR(FileDescriptor, message_type_count, int) -PROTOBUF_DEFINE_ACCESSOR(FileDescriptor, enum_type_count, int) -PROTOBUF_DEFINE_ACCESSOR(FileDescriptor, service_count, int) -PROTOBUF_DEFINE_ACCESSOR(FileDescriptor, extension_count, int) -PROTOBUF_DEFINE_OPTIONS_ACCESSOR(FileDescriptor, FileOptions) - -PROTOBUF_DEFINE_ARRAY_ACCESSOR(FileDescriptor, message_type, const Descriptor*) -PROTOBUF_DEFINE_ARRAY_ACCESSOR(FileDescriptor, enum_type, const EnumDescriptor*) -PROTOBUF_DEFINE_ARRAY_ACCESSOR(FileDescriptor, service, - const ServiceDescriptor*) -PROTOBUF_DEFINE_ARRAY_ACCESSOR(FileDescriptor, extension, - const FieldDescriptor*) - -#undef PROTOBUF_DEFINE_ACCESSOR -#undef PROTOBUF_DEFINE_STRING_ACCESSOR -#undef PROTOBUF_DEFINE_ARRAY_ACCESSOR - -// A few accessors differ from the macros... - -inline bool FieldDescriptor::is_required() const { - return label() == LABEL_REQUIRED; -} - -inline bool FieldDescriptor::is_optional() const { - return label() == LABEL_OPTIONAL; -} - -inline bool FieldDescriptor::is_repeated() const { - return label() == LABEL_REPEATED; -} - -inline bool FieldDescriptor::is_packable() const { - return is_repeated() && IsTypePackable(type()); -} - -// To save space, index() is computed by looking at the descriptor's position -// in the parent's array of children. -inline int FieldDescriptor::index() const { - if (!is_extension_) { - return this - containing_type_->fields_; - } else if (extension_scope_ != NULL) { - return this - extension_scope_->extensions_; - } else { - return this - file_->extensions_; - } -} - -inline int Descriptor::index() const { - if (containing_type_ == NULL) { - return this - file_->message_types_; - } else { - return this - containing_type_->nested_types_; - } -} - -inline int EnumDescriptor::index() const { - if (containing_type_ == NULL) { - return this - file_->enum_types_; - } else { - return this - containing_type_->enum_types_; - } -} - -inline int EnumValueDescriptor::index() const { - return this - type_->values_; -} - -inline int ServiceDescriptor::index() const { - return this - file_->services_; -} - -inline int MethodDescriptor::index() const { - return this - service_->methods_; -} - -inline const char* FieldDescriptor::type_name() const { - return kTypeToName[type_]; -} - -inline FieldDescriptor::CppType FieldDescriptor::cpp_type() const { - return kTypeToCppTypeMap[type_]; -} - -inline const char* FieldDescriptor::cpp_type_name() const { - return kCppTypeToName[kTypeToCppTypeMap[type_]]; -} - -inline FieldDescriptor::CppType FieldDescriptor::TypeToCppType(Type type) { - return kTypeToCppTypeMap[type]; -} - -inline bool FieldDescriptor::IsTypePackable(Type field_type) { - return (field_type != FieldDescriptor::TYPE_STRING && - field_type != FieldDescriptor::TYPE_GROUP && - field_type != FieldDescriptor::TYPE_MESSAGE && - field_type != FieldDescriptor::TYPE_BYTES); -} - -inline const FileDescriptor* FileDescriptor::dependency(int index) const { - return dependencies_[index]; -} - -inline const FileDescriptor* FileDescriptor::public_dependency( - int index) const { - return dependencies_[public_dependencies_[index]]; -} - -inline const FileDescriptor* FileDescriptor::weak_dependency( - int index) const { - return dependencies_[weak_dependencies_[index]]; -} - -} // namespace protobuf - -} // namespace google -#endif // GOOGLE_PROTOBUF_DESCRIPTOR_H__ diff --git a/modules/dnn/3rdparty/protobuf/src/google/protobuf/descriptor.pb.cc b/modules/dnn/3rdparty/protobuf/src/google/protobuf/descriptor.pb.cc deleted file mode 100644 index 65379f4d4..000000000 --- a/modules/dnn/3rdparty/protobuf/src/google/protobuf/descriptor.pb.cc +++ /dev/null @@ -1,8146 +0,0 @@ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: google/protobuf/descriptor.proto - -#define INTERNAL_SUPPRESS_PROTOBUF_FIELD_DEPRECATION -#include "google/protobuf/descriptor.pb.h" - -#include - -#include -#include -#include -#include -#include -#include -#include -#include -// @@protoc_insertion_point(includes) - -namespace google { -namespace protobuf { - -namespace { - -const ::google::protobuf::Descriptor* FileDescriptorSet_descriptor_ = NULL; -const ::google::protobuf::internal::GeneratedMessageReflection* - FileDescriptorSet_reflection_ = NULL; -const ::google::protobuf::Descriptor* FileDescriptorProto_descriptor_ = NULL; -const ::google::protobuf::internal::GeneratedMessageReflection* - FileDescriptorProto_reflection_ = NULL; -const ::google::protobuf::Descriptor* DescriptorProto_descriptor_ = NULL; -const ::google::protobuf::internal::GeneratedMessageReflection* - DescriptorProto_reflection_ = NULL; -const ::google::protobuf::Descriptor* DescriptorProto_ExtensionRange_descriptor_ = NULL; -const ::google::protobuf::internal::GeneratedMessageReflection* - DescriptorProto_ExtensionRange_reflection_ = NULL; -const ::google::protobuf::Descriptor* FieldDescriptorProto_descriptor_ = NULL; -const ::google::protobuf::internal::GeneratedMessageReflection* - FieldDescriptorProto_reflection_ = NULL; -const ::google::protobuf::EnumDescriptor* FieldDescriptorProto_Type_descriptor_ = NULL; -const ::google::protobuf::EnumDescriptor* FieldDescriptorProto_Label_descriptor_ = NULL; -const ::google::protobuf::Descriptor* EnumDescriptorProto_descriptor_ = NULL; -const ::google::protobuf::internal::GeneratedMessageReflection* - EnumDescriptorProto_reflection_ = NULL; -const ::google::protobuf::Descriptor* EnumValueDescriptorProto_descriptor_ = NULL; -const ::google::protobuf::internal::GeneratedMessageReflection* - EnumValueDescriptorProto_reflection_ = NULL; -const ::google::protobuf::Descriptor* ServiceDescriptorProto_descriptor_ = NULL; -const ::google::protobuf::internal::GeneratedMessageReflection* - ServiceDescriptorProto_reflection_ = NULL; -const ::google::protobuf::Descriptor* MethodDescriptorProto_descriptor_ = NULL; -const ::google::protobuf::internal::GeneratedMessageReflection* - MethodDescriptorProto_reflection_ = NULL; -const ::google::protobuf::Descriptor* FileOptions_descriptor_ = NULL; -const ::google::protobuf::internal::GeneratedMessageReflection* - FileOptions_reflection_ = NULL; -const ::google::protobuf::EnumDescriptor* FileOptions_OptimizeMode_descriptor_ = NULL; -const ::google::protobuf::Descriptor* MessageOptions_descriptor_ = NULL; -const ::google::protobuf::internal::GeneratedMessageReflection* - MessageOptions_reflection_ = NULL; -const ::google::protobuf::Descriptor* FieldOptions_descriptor_ = NULL; -const ::google::protobuf::internal::GeneratedMessageReflection* - FieldOptions_reflection_ = NULL; -const ::google::protobuf::EnumDescriptor* FieldOptions_CType_descriptor_ = NULL; -const ::google::protobuf::Descriptor* EnumOptions_descriptor_ = NULL; -const ::google::protobuf::internal::GeneratedMessageReflection* - EnumOptions_reflection_ = NULL; -const ::google::protobuf::Descriptor* EnumValueOptions_descriptor_ = NULL; -const ::google::protobuf::internal::GeneratedMessageReflection* - EnumValueOptions_reflection_ = NULL; -const ::google::protobuf::Descriptor* ServiceOptions_descriptor_ = NULL; -const ::google::protobuf::internal::GeneratedMessageReflection* - ServiceOptions_reflection_ = NULL; -const ::google::protobuf::Descriptor* MethodOptions_descriptor_ = NULL; -const ::google::protobuf::internal::GeneratedMessageReflection* - MethodOptions_reflection_ = NULL; -const ::google::protobuf::Descriptor* UninterpretedOption_descriptor_ = NULL; -const ::google::protobuf::internal::GeneratedMessageReflection* - UninterpretedOption_reflection_ = NULL; -const ::google::protobuf::Descriptor* UninterpretedOption_NamePart_descriptor_ = NULL; -const ::google::protobuf::internal::GeneratedMessageReflection* - UninterpretedOption_NamePart_reflection_ = NULL; -const ::google::protobuf::Descriptor* SourceCodeInfo_descriptor_ = NULL; -const ::google::protobuf::internal::GeneratedMessageReflection* - SourceCodeInfo_reflection_ = NULL; -const ::google::protobuf::Descriptor* SourceCodeInfo_Location_descriptor_ = NULL; -const ::google::protobuf::internal::GeneratedMessageReflection* - SourceCodeInfo_Location_reflection_ = NULL; - -} // namespace - - -void protobuf_AssignDesc_google_2fprotobuf_2fdescriptor_2eproto() { - protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto(); - const ::google::protobuf::FileDescriptor* file = - ::google::protobuf::DescriptorPool::generated_pool()->FindFileByName( - "google/protobuf/descriptor.proto"); - GOOGLE_CHECK(file != NULL); - FileDescriptorSet_descriptor_ = file->message_type(0); - static const int FileDescriptorSet_offsets_[1] = { - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileDescriptorSet, file_), - }; - FileDescriptorSet_reflection_ = - new ::google::protobuf::internal::GeneratedMessageReflection( - FileDescriptorSet_descriptor_, - FileDescriptorSet::default_instance_, - FileDescriptorSet_offsets_, - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileDescriptorSet, _has_bits_[0]), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileDescriptorSet, _unknown_fields_), - -1, - ::google::protobuf::DescriptorPool::generated_pool(), - ::google::protobuf::MessageFactory::generated_factory(), - sizeof(FileDescriptorSet)); - FileDescriptorProto_descriptor_ = file->message_type(1); - static const int FileDescriptorProto_offsets_[11] = { - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileDescriptorProto, name_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileDescriptorProto, package_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileDescriptorProto, dependency_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileDescriptorProto, public_dependency_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileDescriptorProto, weak_dependency_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileDescriptorProto, message_type_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileDescriptorProto, enum_type_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileDescriptorProto, service_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileDescriptorProto, extension_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileDescriptorProto, options_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileDescriptorProto, source_code_info_), - }; - FileDescriptorProto_reflection_ = - new ::google::protobuf::internal::GeneratedMessageReflection( - FileDescriptorProto_descriptor_, - FileDescriptorProto::default_instance_, - FileDescriptorProto_offsets_, - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileDescriptorProto, _has_bits_[0]), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileDescriptorProto, _unknown_fields_), - -1, - ::google::protobuf::DescriptorPool::generated_pool(), - ::google::protobuf::MessageFactory::generated_factory(), - sizeof(FileDescriptorProto)); - DescriptorProto_descriptor_ = file->message_type(2); - static const int DescriptorProto_offsets_[7] = { - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DescriptorProto, name_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DescriptorProto, field_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DescriptorProto, extension_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DescriptorProto, nested_type_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DescriptorProto, enum_type_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DescriptorProto, extension_range_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DescriptorProto, options_), - }; - DescriptorProto_reflection_ = - new ::google::protobuf::internal::GeneratedMessageReflection( - DescriptorProto_descriptor_, - DescriptorProto::default_instance_, - DescriptorProto_offsets_, - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DescriptorProto, _has_bits_[0]), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DescriptorProto, _unknown_fields_), - -1, - ::google::protobuf::DescriptorPool::generated_pool(), - ::google::protobuf::MessageFactory::generated_factory(), - sizeof(DescriptorProto)); - DescriptorProto_ExtensionRange_descriptor_ = DescriptorProto_descriptor_->nested_type(0); - static const int DescriptorProto_ExtensionRange_offsets_[2] = { - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DescriptorProto_ExtensionRange, start_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DescriptorProto_ExtensionRange, end_), - }; - DescriptorProto_ExtensionRange_reflection_ = - new ::google::protobuf::internal::GeneratedMessageReflection( - DescriptorProto_ExtensionRange_descriptor_, - DescriptorProto_ExtensionRange::default_instance_, - DescriptorProto_ExtensionRange_offsets_, - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DescriptorProto_ExtensionRange, _has_bits_[0]), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DescriptorProto_ExtensionRange, _unknown_fields_), - -1, - ::google::protobuf::DescriptorPool::generated_pool(), - ::google::protobuf::MessageFactory::generated_factory(), - sizeof(DescriptorProto_ExtensionRange)); - FieldDescriptorProto_descriptor_ = file->message_type(3); - static const int FieldDescriptorProto_offsets_[8] = { - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FieldDescriptorProto, name_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FieldDescriptorProto, number_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FieldDescriptorProto, label_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FieldDescriptorProto, type_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FieldDescriptorProto, type_name_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FieldDescriptorProto, extendee_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FieldDescriptorProto, default_value_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FieldDescriptorProto, options_), - }; - FieldDescriptorProto_reflection_ = - new ::google::protobuf::internal::GeneratedMessageReflection( - FieldDescriptorProto_descriptor_, - FieldDescriptorProto::default_instance_, - FieldDescriptorProto_offsets_, - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FieldDescriptorProto, _has_bits_[0]), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FieldDescriptorProto, _unknown_fields_), - -1, - ::google::protobuf::DescriptorPool::generated_pool(), - ::google::protobuf::MessageFactory::generated_factory(), - sizeof(FieldDescriptorProto)); - FieldDescriptorProto_Type_descriptor_ = FieldDescriptorProto_descriptor_->enum_type(0); - FieldDescriptorProto_Label_descriptor_ = FieldDescriptorProto_descriptor_->enum_type(1); - EnumDescriptorProto_descriptor_ = file->message_type(4); - static const int EnumDescriptorProto_offsets_[3] = { - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(EnumDescriptorProto, name_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(EnumDescriptorProto, value_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(EnumDescriptorProto, options_), - }; - EnumDescriptorProto_reflection_ = - new ::google::protobuf::internal::GeneratedMessageReflection( - EnumDescriptorProto_descriptor_, - EnumDescriptorProto::default_instance_, - EnumDescriptorProto_offsets_, - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(EnumDescriptorProto, _has_bits_[0]), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(EnumDescriptorProto, _unknown_fields_), - -1, - ::google::protobuf::DescriptorPool::generated_pool(), - ::google::protobuf::MessageFactory::generated_factory(), - sizeof(EnumDescriptorProto)); - EnumValueDescriptorProto_descriptor_ = file->message_type(5); - static const int EnumValueDescriptorProto_offsets_[3] = { - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(EnumValueDescriptorProto, name_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(EnumValueDescriptorProto, number_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(EnumValueDescriptorProto, options_), - }; - EnumValueDescriptorProto_reflection_ = - new ::google::protobuf::internal::GeneratedMessageReflection( - EnumValueDescriptorProto_descriptor_, - EnumValueDescriptorProto::default_instance_, - EnumValueDescriptorProto_offsets_, - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(EnumValueDescriptorProto, _has_bits_[0]), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(EnumValueDescriptorProto, _unknown_fields_), - -1, - ::google::protobuf::DescriptorPool::generated_pool(), - ::google::protobuf::MessageFactory::generated_factory(), - sizeof(EnumValueDescriptorProto)); - ServiceDescriptorProto_descriptor_ = file->message_type(6); - static const int ServiceDescriptorProto_offsets_[3] = { - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ServiceDescriptorProto, name_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ServiceDescriptorProto, method_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ServiceDescriptorProto, options_), - }; - ServiceDescriptorProto_reflection_ = - new ::google::protobuf::internal::GeneratedMessageReflection( - ServiceDescriptorProto_descriptor_, - ServiceDescriptorProto::default_instance_, - ServiceDescriptorProto_offsets_, - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ServiceDescriptorProto, _has_bits_[0]), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ServiceDescriptorProto, _unknown_fields_), - -1, - ::google::protobuf::DescriptorPool::generated_pool(), - ::google::protobuf::MessageFactory::generated_factory(), - sizeof(ServiceDescriptorProto)); - MethodDescriptorProto_descriptor_ = file->message_type(7); - static const int MethodDescriptorProto_offsets_[4] = { - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MethodDescriptorProto, name_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MethodDescriptorProto, input_type_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MethodDescriptorProto, output_type_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MethodDescriptorProto, options_), - }; - MethodDescriptorProto_reflection_ = - new ::google::protobuf::internal::GeneratedMessageReflection( - MethodDescriptorProto_descriptor_, - MethodDescriptorProto::default_instance_, - MethodDescriptorProto_offsets_, - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MethodDescriptorProto, _has_bits_[0]), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MethodDescriptorProto, _unknown_fields_), - -1, - ::google::protobuf::DescriptorPool::generated_pool(), - ::google::protobuf::MessageFactory::generated_factory(), - sizeof(MethodDescriptorProto)); - FileOptions_descriptor_ = file->message_type(8); - static const int FileOptions_offsets_[10] = { - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileOptions, java_package_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileOptions, java_outer_classname_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileOptions, java_multiple_files_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileOptions, java_generate_equals_and_hash_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileOptions, optimize_for_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileOptions, go_package_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileOptions, cc_generic_services_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileOptions, java_generic_services_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileOptions, py_generic_services_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileOptions, uninterpreted_option_), - }; - FileOptions_reflection_ = - new ::google::protobuf::internal::GeneratedMessageReflection( - FileOptions_descriptor_, - FileOptions::default_instance_, - FileOptions_offsets_, - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileOptions, _has_bits_[0]), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileOptions, _unknown_fields_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileOptions, _extensions_), - ::google::protobuf::DescriptorPool::generated_pool(), - ::google::protobuf::MessageFactory::generated_factory(), - sizeof(FileOptions)); - FileOptions_OptimizeMode_descriptor_ = FileOptions_descriptor_->enum_type(0); - MessageOptions_descriptor_ = file->message_type(9); - static const int MessageOptions_offsets_[3] = { - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MessageOptions, message_set_wire_format_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MessageOptions, no_standard_descriptor_accessor_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MessageOptions, uninterpreted_option_), - }; - MessageOptions_reflection_ = - new ::google::protobuf::internal::GeneratedMessageReflection( - MessageOptions_descriptor_, - MessageOptions::default_instance_, - MessageOptions_offsets_, - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MessageOptions, _has_bits_[0]), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MessageOptions, _unknown_fields_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MessageOptions, _extensions_), - ::google::protobuf::DescriptorPool::generated_pool(), - ::google::protobuf::MessageFactory::generated_factory(), - sizeof(MessageOptions)); - FieldOptions_descriptor_ = file->message_type(10); - static const int FieldOptions_offsets_[7] = { - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FieldOptions, ctype_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FieldOptions, packed_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FieldOptions, lazy_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FieldOptions, deprecated_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FieldOptions, experimental_map_key_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FieldOptions, weak_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FieldOptions, uninterpreted_option_), - }; - FieldOptions_reflection_ = - new ::google::protobuf::internal::GeneratedMessageReflection( - FieldOptions_descriptor_, - FieldOptions::default_instance_, - FieldOptions_offsets_, - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FieldOptions, _has_bits_[0]), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FieldOptions, _unknown_fields_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FieldOptions, _extensions_), - ::google::protobuf::DescriptorPool::generated_pool(), - ::google::protobuf::MessageFactory::generated_factory(), - sizeof(FieldOptions)); - FieldOptions_CType_descriptor_ = FieldOptions_descriptor_->enum_type(0); - EnumOptions_descriptor_ = file->message_type(11); - static const int EnumOptions_offsets_[2] = { - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(EnumOptions, allow_alias_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(EnumOptions, uninterpreted_option_), - }; - EnumOptions_reflection_ = - new ::google::protobuf::internal::GeneratedMessageReflection( - EnumOptions_descriptor_, - EnumOptions::default_instance_, - EnumOptions_offsets_, - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(EnumOptions, _has_bits_[0]), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(EnumOptions, _unknown_fields_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(EnumOptions, _extensions_), - ::google::protobuf::DescriptorPool::generated_pool(), - ::google::protobuf::MessageFactory::generated_factory(), - sizeof(EnumOptions)); - EnumValueOptions_descriptor_ = file->message_type(12); - static const int EnumValueOptions_offsets_[1] = { - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(EnumValueOptions, uninterpreted_option_), - }; - EnumValueOptions_reflection_ = - new ::google::protobuf::internal::GeneratedMessageReflection( - EnumValueOptions_descriptor_, - EnumValueOptions::default_instance_, - EnumValueOptions_offsets_, - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(EnumValueOptions, _has_bits_[0]), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(EnumValueOptions, _unknown_fields_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(EnumValueOptions, _extensions_), - ::google::protobuf::DescriptorPool::generated_pool(), - ::google::protobuf::MessageFactory::generated_factory(), - sizeof(EnumValueOptions)); - ServiceOptions_descriptor_ = file->message_type(13); - static const int ServiceOptions_offsets_[1] = { - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ServiceOptions, uninterpreted_option_), - }; - ServiceOptions_reflection_ = - new ::google::protobuf::internal::GeneratedMessageReflection( - ServiceOptions_descriptor_, - ServiceOptions::default_instance_, - ServiceOptions_offsets_, - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ServiceOptions, _has_bits_[0]), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ServiceOptions, _unknown_fields_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ServiceOptions, _extensions_), - ::google::protobuf::DescriptorPool::generated_pool(), - ::google::protobuf::MessageFactory::generated_factory(), - sizeof(ServiceOptions)); - MethodOptions_descriptor_ = file->message_type(14); - static const int MethodOptions_offsets_[1] = { - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MethodOptions, uninterpreted_option_), - }; - MethodOptions_reflection_ = - new ::google::protobuf::internal::GeneratedMessageReflection( - MethodOptions_descriptor_, - MethodOptions::default_instance_, - MethodOptions_offsets_, - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MethodOptions, _has_bits_[0]), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MethodOptions, _unknown_fields_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MethodOptions, _extensions_), - ::google::protobuf::DescriptorPool::generated_pool(), - ::google::protobuf::MessageFactory::generated_factory(), - sizeof(MethodOptions)); - UninterpretedOption_descriptor_ = file->message_type(15); - static const int UninterpretedOption_offsets_[7] = { - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(UninterpretedOption, name_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(UninterpretedOption, identifier_value_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(UninterpretedOption, positive_int_value_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(UninterpretedOption, negative_int_value_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(UninterpretedOption, double_value_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(UninterpretedOption, string_value_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(UninterpretedOption, aggregate_value_), - }; - UninterpretedOption_reflection_ = - new ::google::protobuf::internal::GeneratedMessageReflection( - UninterpretedOption_descriptor_, - UninterpretedOption::default_instance_, - UninterpretedOption_offsets_, - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(UninterpretedOption, _has_bits_[0]), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(UninterpretedOption, _unknown_fields_), - -1, - ::google::protobuf::DescriptorPool::generated_pool(), - ::google::protobuf::MessageFactory::generated_factory(), - sizeof(UninterpretedOption)); - UninterpretedOption_NamePart_descriptor_ = UninterpretedOption_descriptor_->nested_type(0); - static const int UninterpretedOption_NamePart_offsets_[2] = { - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(UninterpretedOption_NamePart, name_part_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(UninterpretedOption_NamePart, is_extension_), - }; - UninterpretedOption_NamePart_reflection_ = - new ::google::protobuf::internal::GeneratedMessageReflection( - UninterpretedOption_NamePart_descriptor_, - UninterpretedOption_NamePart::default_instance_, - UninterpretedOption_NamePart_offsets_, - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(UninterpretedOption_NamePart, _has_bits_[0]), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(UninterpretedOption_NamePart, _unknown_fields_), - -1, - ::google::protobuf::DescriptorPool::generated_pool(), - ::google::protobuf::MessageFactory::generated_factory(), - sizeof(UninterpretedOption_NamePart)); - SourceCodeInfo_descriptor_ = file->message_type(16); - static const int SourceCodeInfo_offsets_[1] = { - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(SourceCodeInfo, location_), - }; - SourceCodeInfo_reflection_ = - new ::google::protobuf::internal::GeneratedMessageReflection( - SourceCodeInfo_descriptor_, - SourceCodeInfo::default_instance_, - SourceCodeInfo_offsets_, - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(SourceCodeInfo, _has_bits_[0]), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(SourceCodeInfo, _unknown_fields_), - -1, - ::google::protobuf::DescriptorPool::generated_pool(), - ::google::protobuf::MessageFactory::generated_factory(), - sizeof(SourceCodeInfo)); - SourceCodeInfo_Location_descriptor_ = SourceCodeInfo_descriptor_->nested_type(0); - static const int SourceCodeInfo_Location_offsets_[4] = { - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(SourceCodeInfo_Location, path_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(SourceCodeInfo_Location, span_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(SourceCodeInfo_Location, leading_comments_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(SourceCodeInfo_Location, trailing_comments_), - }; - SourceCodeInfo_Location_reflection_ = - new ::google::protobuf::internal::GeneratedMessageReflection( - SourceCodeInfo_Location_descriptor_, - SourceCodeInfo_Location::default_instance_, - SourceCodeInfo_Location_offsets_, - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(SourceCodeInfo_Location, _has_bits_[0]), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(SourceCodeInfo_Location, _unknown_fields_), - -1, - ::google::protobuf::DescriptorPool::generated_pool(), - ::google::protobuf::MessageFactory::generated_factory(), - sizeof(SourceCodeInfo_Location)); -} - -namespace { - -GOOGLE_PROTOBUF_DECLARE_ONCE(protobuf_AssignDescriptors_once_); -inline void protobuf_AssignDescriptorsOnce() { - ::google::protobuf::GoogleOnceInit(&protobuf_AssignDescriptors_once_, - &protobuf_AssignDesc_google_2fprotobuf_2fdescriptor_2eproto); -} - -void protobuf_RegisterTypes(const ::std::string&) { - protobuf_AssignDescriptorsOnce(); - ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - FileDescriptorSet_descriptor_, &FileDescriptorSet::default_instance()); - ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - FileDescriptorProto_descriptor_, &FileDescriptorProto::default_instance()); - ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - DescriptorProto_descriptor_, &DescriptorProto::default_instance()); - ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - DescriptorProto_ExtensionRange_descriptor_, &DescriptorProto_ExtensionRange::default_instance()); - ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - FieldDescriptorProto_descriptor_, &FieldDescriptorProto::default_instance()); - ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - EnumDescriptorProto_descriptor_, &EnumDescriptorProto::default_instance()); - ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - EnumValueDescriptorProto_descriptor_, &EnumValueDescriptorProto::default_instance()); - ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - ServiceDescriptorProto_descriptor_, &ServiceDescriptorProto::default_instance()); - ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - MethodDescriptorProto_descriptor_, &MethodDescriptorProto::default_instance()); - ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - FileOptions_descriptor_, &FileOptions::default_instance()); - ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - MessageOptions_descriptor_, &MessageOptions::default_instance()); - ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - FieldOptions_descriptor_, &FieldOptions::default_instance()); - ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - EnumOptions_descriptor_, &EnumOptions::default_instance()); - ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - EnumValueOptions_descriptor_, &EnumValueOptions::default_instance()); - ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - ServiceOptions_descriptor_, &ServiceOptions::default_instance()); - ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - MethodOptions_descriptor_, &MethodOptions::default_instance()); - ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - UninterpretedOption_descriptor_, &UninterpretedOption::default_instance()); - ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - UninterpretedOption_NamePart_descriptor_, &UninterpretedOption_NamePart::default_instance()); - ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - SourceCodeInfo_descriptor_, &SourceCodeInfo::default_instance()); - ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - SourceCodeInfo_Location_descriptor_, &SourceCodeInfo_Location::default_instance()); -} - -} // namespace - -void protobuf_ShutdownFile_google_2fprotobuf_2fdescriptor_2eproto() { - delete FileDescriptorSet::default_instance_; - delete FileDescriptorSet_reflection_; - delete FileDescriptorProto::default_instance_; - delete FileDescriptorProto_reflection_; - delete DescriptorProto::default_instance_; - delete DescriptorProto_reflection_; - delete DescriptorProto_ExtensionRange::default_instance_; - delete DescriptorProto_ExtensionRange_reflection_; - delete FieldDescriptorProto::default_instance_; - delete FieldDescriptorProto_reflection_; - delete EnumDescriptorProto::default_instance_; - delete EnumDescriptorProto_reflection_; - delete EnumValueDescriptorProto::default_instance_; - delete EnumValueDescriptorProto_reflection_; - delete ServiceDescriptorProto::default_instance_; - delete ServiceDescriptorProto_reflection_; - delete MethodDescriptorProto::default_instance_; - delete MethodDescriptorProto_reflection_; - delete FileOptions::default_instance_; - delete FileOptions_reflection_; - delete MessageOptions::default_instance_; - delete MessageOptions_reflection_; - delete FieldOptions::default_instance_; - delete FieldOptions_reflection_; - delete EnumOptions::default_instance_; - delete EnumOptions_reflection_; - delete EnumValueOptions::default_instance_; - delete EnumValueOptions_reflection_; - delete ServiceOptions::default_instance_; - delete ServiceOptions_reflection_; - delete MethodOptions::default_instance_; - delete MethodOptions_reflection_; - delete UninterpretedOption::default_instance_; - delete UninterpretedOption_reflection_; - delete UninterpretedOption_NamePart::default_instance_; - delete UninterpretedOption_NamePart_reflection_; - delete SourceCodeInfo::default_instance_; - delete SourceCodeInfo_reflection_; - delete SourceCodeInfo_Location::default_instance_; - delete SourceCodeInfo_Location_reflection_; -} - -void protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto() { - static bool already_here = false; - if (already_here) return; - already_here = true; - GOOGLE_PROTOBUF_VERIFY_VERSION; - - ::google::protobuf::DescriptorPool::InternalAddGeneratedFile( - "\n google/protobuf/descriptor.proto\022\017goog" - "le.protobuf\"G\n\021FileDescriptorSet\0222\n\004file" - "\030\001 \003(\0132$.google.protobuf.FileDescriptorP" - "roto\"\313\003\n\023FileDescriptorProto\022\014\n\004name\030\001 \001" - "(\t\022\017\n\007package\030\002 \001(\t\022\022\n\ndependency\030\003 \003(\t\022" - "\031\n\021public_dependency\030\n \003(\005\022\027\n\017weak_depen" - "dency\030\013 \003(\005\0226\n\014message_type\030\004 \003(\0132 .goog" - "le.protobuf.DescriptorProto\0227\n\tenum_type" - "\030\005 \003(\0132$.google.protobuf.EnumDescriptorP" - "roto\0228\n\007service\030\006 \003(\0132\'.google.protobuf." - "ServiceDescriptorProto\0228\n\textension\030\007 \003(" - "\0132%.google.protobuf.FieldDescriptorProto" - "\022-\n\007options\030\010 \001(\0132\034.google.protobuf.File" - "Options\0229\n\020source_code_info\030\t \001(\0132\037.goog" - "le.protobuf.SourceCodeInfo\"\251\003\n\017Descripto" - "rProto\022\014\n\004name\030\001 \001(\t\0224\n\005field\030\002 \003(\0132%.go" - "ogle.protobuf.FieldDescriptorProto\0228\n\tex" - "tension\030\006 \003(\0132%.google.protobuf.FieldDes" - "criptorProto\0225\n\013nested_type\030\003 \003(\0132 .goog" - "le.protobuf.DescriptorProto\0227\n\tenum_type" - "\030\004 \003(\0132$.google.protobuf.EnumDescriptorP" - "roto\022H\n\017extension_range\030\005 \003(\0132/.google.p" - "rotobuf.DescriptorProto.ExtensionRange\0220" - "\n\007options\030\007 \001(\0132\037.google.protobuf.Messag" - "eOptions\032,\n\016ExtensionRange\022\r\n\005start\030\001 \001(" - "\005\022\013\n\003end\030\002 \001(\005\"\224\005\n\024FieldDescriptorProto\022" - "\014\n\004name\030\001 \001(\t\022\016\n\006number\030\003 \001(\005\022:\n\005label\030\004" - " \001(\0162+.google.protobuf.FieldDescriptorPr" - "oto.Label\0228\n\004type\030\005 \001(\0162*.google.protobu" - "f.FieldDescriptorProto.Type\022\021\n\ttype_name" - "\030\006 \001(\t\022\020\n\010extendee\030\002 \001(\t\022\025\n\rdefault_valu" - "e\030\007 \001(\t\022.\n\007options\030\010 \001(\0132\035.google.protob" - "uf.FieldOptions\"\266\002\n\004Type\022\017\n\013TYPE_DOUBLE\020" - "\001\022\016\n\nTYPE_FLOAT\020\002\022\016\n\nTYPE_INT64\020\003\022\017\n\013TYP" - "E_UINT64\020\004\022\016\n\nTYPE_INT32\020\005\022\020\n\014TYPE_FIXED" - "64\020\006\022\020\n\014TYPE_FIXED32\020\007\022\r\n\tTYPE_BOOL\020\010\022\017\n" - "\013TYPE_STRING\020\t\022\016\n\nTYPE_GROUP\020\n\022\020\n\014TYPE_M" - "ESSAGE\020\013\022\016\n\nTYPE_BYTES\020\014\022\017\n\013TYPE_UINT32\020" - "\r\022\r\n\tTYPE_ENUM\020\016\022\021\n\rTYPE_SFIXED32\020\017\022\021\n\rT" - "YPE_SFIXED64\020\020\022\017\n\013TYPE_SINT32\020\021\022\017\n\013TYPE_" - "SINT64\020\022\"C\n\005Label\022\022\n\016LABEL_OPTIONAL\020\001\022\022\n" - "\016LABEL_REQUIRED\020\002\022\022\n\016LABEL_REPEATED\020\003\"\214\001" - "\n\023EnumDescriptorProto\022\014\n\004name\030\001 \001(\t\0228\n\005v" - "alue\030\002 \003(\0132).google.protobuf.EnumValueDe" - "scriptorProto\022-\n\007options\030\003 \001(\0132\034.google." - "protobuf.EnumOptions\"l\n\030EnumValueDescrip" - "torProto\022\014\n\004name\030\001 \001(\t\022\016\n\006number\030\002 \001(\005\0222" - "\n\007options\030\003 \001(\0132!.google.protobuf.EnumVa" - "lueOptions\"\220\001\n\026ServiceDescriptorProto\022\014\n" - "\004name\030\001 \001(\t\0226\n\006method\030\002 \003(\0132&.google.pro" - "tobuf.MethodDescriptorProto\0220\n\007options\030\003" - " \001(\0132\037.google.protobuf.ServiceOptions\"\177\n" - "\025MethodDescriptorProto\022\014\n\004name\030\001 \001(\t\022\022\n\n" - "input_type\030\002 \001(\t\022\023\n\013output_type\030\003 \001(\t\022/\n" - "\007options\030\004 \001(\0132\036.google.protobuf.MethodO" - "ptions\"\351\003\n\013FileOptions\022\024\n\014java_package\030\001" - " \001(\t\022\034\n\024java_outer_classname\030\010 \001(\t\022\"\n\023ja" - "va_multiple_files\030\n \001(\010:\005false\022,\n\035java_g" - "enerate_equals_and_hash\030\024 \001(\010:\005false\022F\n\014" - "optimize_for\030\t \001(\0162).google.protobuf.Fil" - "eOptions.OptimizeMode:\005SPEED\022\022\n\ngo_packa" - "ge\030\013 \001(\t\022\"\n\023cc_generic_services\030\020 \001(\010:\005f" - "alse\022$\n\025java_generic_services\030\021 \001(\010:\005fal" - "se\022\"\n\023py_generic_services\030\022 \001(\010:\005false\022C" - "\n\024uninterpreted_option\030\347\007 \003(\0132$.google.p" - "rotobuf.UninterpretedOption\":\n\014OptimizeM" - "ode\022\t\n\005SPEED\020\001\022\r\n\tCODE_SIZE\020\002\022\020\n\014LITE_RU" - "NTIME\020\003*\t\010\350\007\020\200\200\200\200\002\"\270\001\n\016MessageOptions\022&\n" - "\027message_set_wire_format\030\001 \001(\010:\005false\022.\n" - "\037no_standard_descriptor_accessor\030\002 \001(\010:\005" - "false\022C\n\024uninterpreted_option\030\347\007 \003(\0132$.g" - "oogle.protobuf.UninterpretedOption*\t\010\350\007\020" - "\200\200\200\200\002\"\276\002\n\014FieldOptions\022:\n\005ctype\030\001 \001(\0162#." - "google.protobuf.FieldOptions.CType:\006STRI" - "NG\022\016\n\006packed\030\002 \001(\010\022\023\n\004lazy\030\005 \001(\010:\005false\022" - "\031\n\ndeprecated\030\003 \001(\010:\005false\022\034\n\024experiment" - "al_map_key\030\t \001(\t\022\023\n\004weak\030\n \001(\010:\005false\022C\n" - "\024uninterpreted_option\030\347\007 \003(\0132$.google.pr" - "otobuf.UninterpretedOption\"/\n\005CType\022\n\n\006S" - "TRING\020\000\022\010\n\004CORD\020\001\022\020\n\014STRING_PIECE\020\002*\t\010\350\007" - "\020\200\200\200\200\002\"x\n\013EnumOptions\022\031\n\013allow_alias\030\002 \001" - "(\010:\004true\022C\n\024uninterpreted_option\030\347\007 \003(\0132" - "$.google.protobuf.UninterpretedOption*\t\010" - "\350\007\020\200\200\200\200\002\"b\n\020EnumValueOptions\022C\n\024uninterp" - "reted_option\030\347\007 \003(\0132$.google.protobuf.Un" - "interpretedOption*\t\010\350\007\020\200\200\200\200\002\"`\n\016ServiceO" - "ptions\022C\n\024uninterpreted_option\030\347\007 \003(\0132$." - "google.protobuf.UninterpretedOption*\t\010\350\007" - "\020\200\200\200\200\002\"_\n\rMethodOptions\022C\n\024uninterpreted" - "_option\030\347\007 \003(\0132$.google.protobuf.Uninter" - "pretedOption*\t\010\350\007\020\200\200\200\200\002\"\236\002\n\023Uninterprete" - "dOption\022;\n\004name\030\002 \003(\0132-.google.protobuf." - "UninterpretedOption.NamePart\022\030\n\020identifi" - "er_value\030\003 \001(\t\022\032\n\022positive_int_value\030\004 \001" - "(\004\022\032\n\022negative_int_value\030\005 \001(\003\022\024\n\014double" - "_value\030\006 \001(\001\022\024\n\014string_value\030\007 \001(\014\022\027\n\017ag" - "gregate_value\030\010 \001(\t\0323\n\010NamePart\022\021\n\tname_" - "part\030\001 \002(\t\022\024\n\014is_extension\030\002 \002(\010\"\261\001\n\016Sou" - "rceCodeInfo\022:\n\010location\030\001 \003(\0132(.google.p" - "rotobuf.SourceCodeInfo.Location\032c\n\010Locat" - "ion\022\020\n\004path\030\001 \003(\005B\002\020\001\022\020\n\004span\030\002 \003(\005B\002\020\001\022" - "\030\n\020leading_comments\030\003 \001(\t\022\031\n\021trailing_co" - "mments\030\004 \001(\tB)\n\023com.google.protobufB\020Des" - "criptorProtosH\001", 4135); - ::google::protobuf::MessageFactory::InternalRegisterGeneratedFile( - "google/protobuf/descriptor.proto", &protobuf_RegisterTypes); - FileDescriptorSet::default_instance_ = new FileDescriptorSet(); - FileDescriptorProto::default_instance_ = new FileDescriptorProto(); - DescriptorProto::default_instance_ = new DescriptorProto(); - DescriptorProto_ExtensionRange::default_instance_ = new DescriptorProto_ExtensionRange(); - FieldDescriptorProto::default_instance_ = new FieldDescriptorProto(); - EnumDescriptorProto::default_instance_ = new EnumDescriptorProto(); - EnumValueDescriptorProto::default_instance_ = new EnumValueDescriptorProto(); - ServiceDescriptorProto::default_instance_ = new ServiceDescriptorProto(); - MethodDescriptorProto::default_instance_ = new MethodDescriptorProto(); - FileOptions::default_instance_ = new FileOptions(); - MessageOptions::default_instance_ = new MessageOptions(); - FieldOptions::default_instance_ = new FieldOptions(); - EnumOptions::default_instance_ = new EnumOptions(); - EnumValueOptions::default_instance_ = new EnumValueOptions(); - ServiceOptions::default_instance_ = new ServiceOptions(); - MethodOptions::default_instance_ = new MethodOptions(); - UninterpretedOption::default_instance_ = new UninterpretedOption(); - UninterpretedOption_NamePart::default_instance_ = new UninterpretedOption_NamePart(); - SourceCodeInfo::default_instance_ = new SourceCodeInfo(); - SourceCodeInfo_Location::default_instance_ = new SourceCodeInfo_Location(); - FileDescriptorSet::default_instance_->InitAsDefaultInstance(); - FileDescriptorProto::default_instance_->InitAsDefaultInstance(); - DescriptorProto::default_instance_->InitAsDefaultInstance(); - DescriptorProto_ExtensionRange::default_instance_->InitAsDefaultInstance(); - FieldDescriptorProto::default_instance_->InitAsDefaultInstance(); - EnumDescriptorProto::default_instance_->InitAsDefaultInstance(); - EnumValueDescriptorProto::default_instance_->InitAsDefaultInstance(); - ServiceDescriptorProto::default_instance_->InitAsDefaultInstance(); - MethodDescriptorProto::default_instance_->InitAsDefaultInstance(); - FileOptions::default_instance_->InitAsDefaultInstance(); - MessageOptions::default_instance_->InitAsDefaultInstance(); - FieldOptions::default_instance_->InitAsDefaultInstance(); - EnumOptions::default_instance_->InitAsDefaultInstance(); - EnumValueOptions::default_instance_->InitAsDefaultInstance(); - ServiceOptions::default_instance_->InitAsDefaultInstance(); - MethodOptions::default_instance_->InitAsDefaultInstance(); - UninterpretedOption::default_instance_->InitAsDefaultInstance(); - UninterpretedOption_NamePart::default_instance_->InitAsDefaultInstance(); - SourceCodeInfo::default_instance_->InitAsDefaultInstance(); - SourceCodeInfo_Location::default_instance_->InitAsDefaultInstance(); - ::google::protobuf::internal::OnShutdown(&protobuf_ShutdownFile_google_2fprotobuf_2fdescriptor_2eproto); -} - -// Force AddDescriptors() to be called at static initialization time. -struct StaticDescriptorInitializer_google_2fprotobuf_2fdescriptor_2eproto { - StaticDescriptorInitializer_google_2fprotobuf_2fdescriptor_2eproto() { - protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto(); - } -} static_descriptor_initializer_google_2fprotobuf_2fdescriptor_2eproto_; - -// =================================================================== - -#ifndef _MSC_VER -const int FileDescriptorSet::kFileFieldNumber; -#endif // !_MSC_VER - -FileDescriptorSet::FileDescriptorSet() - : ::google::protobuf::Message() { - SharedCtor(); -} - -void FileDescriptorSet::InitAsDefaultInstance() { -} - -FileDescriptorSet::FileDescriptorSet(const FileDescriptorSet& from) - : ::google::protobuf::Message() { - SharedCtor(); - MergeFrom(from); -} - -void FileDescriptorSet::SharedCtor() { - _cached_size_ = 0; - ::memset(_has_bits_, 0, sizeof(_has_bits_)); -} - -FileDescriptorSet::~FileDescriptorSet() { - SharedDtor(); -} - -void FileDescriptorSet::SharedDtor() { - if (this != default_instance_) { - } -} - -void FileDescriptorSet::SetCachedSize(int size) const { - GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); - _cached_size_ = size; - GOOGLE_SAFE_CONCURRENT_WRITES_END(); -} -const ::google::protobuf::Descriptor* FileDescriptorSet::descriptor() { - protobuf_AssignDescriptorsOnce(); - return FileDescriptorSet_descriptor_; -} - -const FileDescriptorSet& FileDescriptorSet::default_instance() { - if (default_instance_ == NULL) protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto(); - return *default_instance_; -} - -FileDescriptorSet* FileDescriptorSet::default_instance_ = NULL; - -FileDescriptorSet* FileDescriptorSet::New() const { - return new FileDescriptorSet; -} - -void FileDescriptorSet::Clear() { - file_.Clear(); - ::memset(_has_bits_, 0, sizeof(_has_bits_)); - mutable_unknown_fields()->Clear(); -} - -bool FileDescriptorSet::MergePartialFromCodedStream( - ::google::protobuf::io::CodedInputStream* input) { -#define DO_(EXPRESSION) if (!(EXPRESSION)) return false - ::google::protobuf::uint32 tag; - while ((tag = input->ReadTag()) != 0) { - switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { - // repeated .google.protobuf.FileDescriptorProto file = 1; - case 1: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) { - parse_file: - DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual( - input, add_file())); - } else { - goto handle_uninterpreted; - } - if (input->ExpectTag(10)) goto parse_file; - if (input->ExpectAtEnd()) return true; - break; - } - - default: { - handle_uninterpreted: - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) { - return true; - } - DO_(::google::protobuf::internal::WireFormat::SkipField( - input, tag, mutable_unknown_fields())); - break; - } - } - } - return true; -#undef DO_ -} - -void FileDescriptorSet::SerializeWithCachedSizes( - ::google::protobuf::io::CodedOutputStream* output) const { - // repeated .google.protobuf.FileDescriptorProto file = 1; - for (int i = 0; i < this->file_size(); i++) { - ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( - 1, this->file(i), output); - } - - if (!unknown_fields().empty()) { - ::google::protobuf::internal::WireFormat::SerializeUnknownFields( - unknown_fields(), output); - } -} - -::google::protobuf::uint8* FileDescriptorSet::SerializeWithCachedSizesToArray( - ::google::protobuf::uint8* target) const { - // repeated .google.protobuf.FileDescriptorProto file = 1; - for (int i = 0; i < this->file_size(); i++) { - target = ::google::protobuf::internal::WireFormatLite:: - WriteMessageNoVirtualToArray( - 1, this->file(i), target); - } - - if (!unknown_fields().empty()) { - target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray( - unknown_fields(), target); - } - return target; -} - -int FileDescriptorSet::ByteSize() const { - int total_size = 0; - - // repeated .google.protobuf.FileDescriptorProto file = 1; - total_size += 1 * this->file_size(); - for (int i = 0; i < this->file_size(); i++) { - total_size += - ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( - this->file(i)); - } - - if (!unknown_fields().empty()) { - total_size += - ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( - unknown_fields()); - } - GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); - _cached_size_ = total_size; - GOOGLE_SAFE_CONCURRENT_WRITES_END(); - return total_size; -} - -void FileDescriptorSet::MergeFrom(const ::google::protobuf::Message& from) { - GOOGLE_CHECK_NE(&from, this); - const FileDescriptorSet* source = - ::google::protobuf::internal::dynamic_cast_if_available( - &from); - if (source == NULL) { - ::google::protobuf::internal::ReflectionOps::Merge(from, this); - } else { - MergeFrom(*source); - } -} - -void FileDescriptorSet::MergeFrom(const FileDescriptorSet& from) { - GOOGLE_CHECK_NE(&from, this); - file_.MergeFrom(from.file_); - mutable_unknown_fields()->MergeFrom(from.unknown_fields()); -} - -void FileDescriptorSet::CopyFrom(const ::google::protobuf::Message& from) { - if (&from == this) return; - Clear(); - MergeFrom(from); -} - -void FileDescriptorSet::CopyFrom(const FileDescriptorSet& from) { - if (&from == this) return; - Clear(); - MergeFrom(from); -} - -bool FileDescriptorSet::IsInitialized() const { - - for (int i = 0; i < file_size(); i++) { - if (!this->file(i).IsInitialized()) return false; - } - return true; -} - -void FileDescriptorSet::Swap(FileDescriptorSet* other) { - if (other != this) { - file_.Swap(&other->file_); - std::swap(_has_bits_[0], other->_has_bits_[0]); - _unknown_fields_.Swap(&other->_unknown_fields_); - std::swap(_cached_size_, other->_cached_size_); - } -} - -::google::protobuf::Metadata FileDescriptorSet::GetMetadata() const { - protobuf_AssignDescriptorsOnce(); - ::google::protobuf::Metadata metadata; - metadata.descriptor = FileDescriptorSet_descriptor_; - metadata.reflection = FileDescriptorSet_reflection_; - return metadata; -} - - -// =================================================================== - -#ifndef _MSC_VER -const int FileDescriptorProto::kNameFieldNumber; -const int FileDescriptorProto::kPackageFieldNumber; -const int FileDescriptorProto::kDependencyFieldNumber; -const int FileDescriptorProto::kPublicDependencyFieldNumber; -const int FileDescriptorProto::kWeakDependencyFieldNumber; -const int FileDescriptorProto::kMessageTypeFieldNumber; -const int FileDescriptorProto::kEnumTypeFieldNumber; -const int FileDescriptorProto::kServiceFieldNumber; -const int FileDescriptorProto::kExtensionFieldNumber; -const int FileDescriptorProto::kOptionsFieldNumber; -const int FileDescriptorProto::kSourceCodeInfoFieldNumber; -#endif // !_MSC_VER - -FileDescriptorProto::FileDescriptorProto() - : ::google::protobuf::Message() { - SharedCtor(); -} - -void FileDescriptorProto::InitAsDefaultInstance() { - options_ = const_cast< ::google::protobuf::FileOptions*>(&::google::protobuf::FileOptions::default_instance()); - source_code_info_ = const_cast< ::google::protobuf::SourceCodeInfo*>(&::google::protobuf::SourceCodeInfo::default_instance()); -} - -FileDescriptorProto::FileDescriptorProto(const FileDescriptorProto& from) - : ::google::protobuf::Message() { - SharedCtor(); - MergeFrom(from); -} - -void FileDescriptorProto::SharedCtor() { - _cached_size_ = 0; - name_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); - package_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); - options_ = NULL; - source_code_info_ = NULL; - ::memset(_has_bits_, 0, sizeof(_has_bits_)); -} - -FileDescriptorProto::~FileDescriptorProto() { - SharedDtor(); -} - -void FileDescriptorProto::SharedDtor() { - if (name_ != &::google::protobuf::internal::kEmptyString) { - delete name_; - } - if (package_ != &::google::protobuf::internal::kEmptyString) { - delete package_; - } - if (this != default_instance_) { - delete options_; - delete source_code_info_; - } -} - -void FileDescriptorProto::SetCachedSize(int size) const { - GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); - _cached_size_ = size; - GOOGLE_SAFE_CONCURRENT_WRITES_END(); -} -const ::google::protobuf::Descriptor* FileDescriptorProto::descriptor() { - protobuf_AssignDescriptorsOnce(); - return FileDescriptorProto_descriptor_; -} - -const FileDescriptorProto& FileDescriptorProto::default_instance() { - if (default_instance_ == NULL) protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto(); - return *default_instance_; -} - -FileDescriptorProto* FileDescriptorProto::default_instance_ = NULL; - -FileDescriptorProto* FileDescriptorProto::New() const { - return new FileDescriptorProto; -} - -void FileDescriptorProto::Clear() { - if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) { - if (has_name()) { - if (name_ != &::google::protobuf::internal::kEmptyString) { - name_->clear(); - } - } - if (has_package()) { - if (package_ != &::google::protobuf::internal::kEmptyString) { - package_->clear(); - } - } - } - if (_has_bits_[9 / 32] & (0xffu << (9 % 32))) { - if (has_options()) { - if (options_ != NULL) options_->::google::protobuf::FileOptions::Clear(); - } - if (has_source_code_info()) { - if (source_code_info_ != NULL) source_code_info_->::google::protobuf::SourceCodeInfo::Clear(); - } - } - dependency_.Clear(); - public_dependency_.Clear(); - weak_dependency_.Clear(); - message_type_.Clear(); - enum_type_.Clear(); - service_.Clear(); - extension_.Clear(); - ::memset(_has_bits_, 0, sizeof(_has_bits_)); - mutable_unknown_fields()->Clear(); -} - -bool FileDescriptorProto::MergePartialFromCodedStream( - ::google::protobuf::io::CodedInputStream* input) { -#define DO_(EXPRESSION) if (!(EXPRESSION)) return false - ::google::protobuf::uint32 tag; - while ((tag = input->ReadTag()) != 0) { - switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { - // optional string name = 1; - case 1: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) { - DO_(::google::protobuf::internal::WireFormatLite::ReadString( - input, this->mutable_name())); - ::google::protobuf::internal::WireFormat::VerifyUTF8String( - this->name().data(), this->name().length(), - ::google::protobuf::internal::WireFormat::PARSE); - } else { - goto handle_uninterpreted; - } - if (input->ExpectTag(18)) goto parse_package; - break; - } - - // optional string package = 2; - case 2: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) { - parse_package: - DO_(::google::protobuf::internal::WireFormatLite::ReadString( - input, this->mutable_package())); - ::google::protobuf::internal::WireFormat::VerifyUTF8String( - this->package().data(), this->package().length(), - ::google::protobuf::internal::WireFormat::PARSE); - } else { - goto handle_uninterpreted; - } - if (input->ExpectTag(26)) goto parse_dependency; - break; - } - - // repeated string dependency = 3; - case 3: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) { - parse_dependency: - DO_(::google::protobuf::internal::WireFormatLite::ReadString( - input, this->add_dependency())); - ::google::protobuf::internal::WireFormat::VerifyUTF8String( - this->dependency(this->dependency_size() - 1).data(), - this->dependency(this->dependency_size() - 1).length(), - ::google::protobuf::internal::WireFormat::PARSE); - } else { - goto handle_uninterpreted; - } - if (input->ExpectTag(26)) goto parse_dependency; - if (input->ExpectTag(34)) goto parse_message_type; - break; - } - - // repeated .google.protobuf.DescriptorProto message_type = 4; - case 4: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) { - parse_message_type: - DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual( - input, add_message_type())); - } else { - goto handle_uninterpreted; - } - if (input->ExpectTag(34)) goto parse_message_type; - if (input->ExpectTag(42)) goto parse_enum_type; - break; - } - - // repeated .google.protobuf.EnumDescriptorProto enum_type = 5; - case 5: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) { - parse_enum_type: - DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual( - input, add_enum_type())); - } else { - goto handle_uninterpreted; - } - if (input->ExpectTag(42)) goto parse_enum_type; - if (input->ExpectTag(50)) goto parse_service; - break; - } - - // repeated .google.protobuf.ServiceDescriptorProto service = 6; - case 6: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) { - parse_service: - DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual( - input, add_service())); - } else { - goto handle_uninterpreted; - } - if (input->ExpectTag(50)) goto parse_service; - if (input->ExpectTag(58)) goto parse_extension; - break; - } - - // repeated .google.protobuf.FieldDescriptorProto extension = 7; - case 7: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) { - parse_extension: - DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual( - input, add_extension())); - } else { - goto handle_uninterpreted; - } - if (input->ExpectTag(58)) goto parse_extension; - if (input->ExpectTag(66)) goto parse_options; - break; - } - - // optional .google.protobuf.FileOptions options = 8; - case 8: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) { - parse_options: - DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual( - input, mutable_options())); - } else { - goto handle_uninterpreted; - } - if (input->ExpectTag(74)) goto parse_source_code_info; - break; - } - - // optional .google.protobuf.SourceCodeInfo source_code_info = 9; - case 9: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) { - parse_source_code_info: - DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual( - input, mutable_source_code_info())); - } else { - goto handle_uninterpreted; - } - if (input->ExpectTag(80)) goto parse_public_dependency; - break; - } - - // repeated int32 public_dependency = 10; - case 10: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) { - parse_public_dependency: - DO_((::google::protobuf::internal::WireFormatLite::ReadRepeatedPrimitive< - ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>( - 1, 80, input, this->mutable_public_dependency()))); - } else if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) - == ::google::protobuf::internal::WireFormatLite:: - WIRETYPE_LENGTH_DELIMITED) { - DO_((::google::protobuf::internal::WireFormatLite::ReadPackedPrimitiveNoInline< - ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>( - input, this->mutable_public_dependency()))); - } else { - goto handle_uninterpreted; - } - if (input->ExpectTag(80)) goto parse_public_dependency; - if (input->ExpectTag(88)) goto parse_weak_dependency; - break; - } - - // repeated int32 weak_dependency = 11; - case 11: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) { - parse_weak_dependency: - DO_((::google::protobuf::internal::WireFormatLite::ReadRepeatedPrimitive< - ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>( - 1, 88, input, this->mutable_weak_dependency()))); - } else if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) - == ::google::protobuf::internal::WireFormatLite:: - WIRETYPE_LENGTH_DELIMITED) { - DO_((::google::protobuf::internal::WireFormatLite::ReadPackedPrimitiveNoInline< - ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>( - input, this->mutable_weak_dependency()))); - } else { - goto handle_uninterpreted; - } - if (input->ExpectTag(88)) goto parse_weak_dependency; - if (input->ExpectAtEnd()) return true; - break; - } - - default: { - handle_uninterpreted: - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) { - return true; - } - DO_(::google::protobuf::internal::WireFormat::SkipField( - input, tag, mutable_unknown_fields())); - break; - } - } - } - return true; -#undef DO_ -} - -void FileDescriptorProto::SerializeWithCachedSizes( - ::google::protobuf::io::CodedOutputStream* output) const { - // optional string name = 1; - if (has_name()) { - ::google::protobuf::internal::WireFormat::VerifyUTF8String( - this->name().data(), this->name().length(), - ::google::protobuf::internal::WireFormat::SERIALIZE); - ::google::protobuf::internal::WireFormatLite::WriteString( - 1, this->name(), output); - } - - // optional string package = 2; - if (has_package()) { - ::google::protobuf::internal::WireFormat::VerifyUTF8String( - this->package().data(), this->package().length(), - ::google::protobuf::internal::WireFormat::SERIALIZE); - ::google::protobuf::internal::WireFormatLite::WriteString( - 2, this->package(), output); - } - - // repeated string dependency = 3; - for (int i = 0; i < this->dependency_size(); i++) { - ::google::protobuf::internal::WireFormat::VerifyUTF8String( - this->dependency(i).data(), this->dependency(i).length(), - ::google::protobuf::internal::WireFormat::SERIALIZE); - ::google::protobuf::internal::WireFormatLite::WriteString( - 3, this->dependency(i), output); - } - - // repeated .google.protobuf.DescriptorProto message_type = 4; - for (int i = 0; i < this->message_type_size(); i++) { - ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( - 4, this->message_type(i), output); - } - - // repeated .google.protobuf.EnumDescriptorProto enum_type = 5; - for (int i = 0; i < this->enum_type_size(); i++) { - ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( - 5, this->enum_type(i), output); - } - - // repeated .google.protobuf.ServiceDescriptorProto service = 6; - for (int i = 0; i < this->service_size(); i++) { - ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( - 6, this->service(i), output); - } - - // repeated .google.protobuf.FieldDescriptorProto extension = 7; - for (int i = 0; i < this->extension_size(); i++) { - ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( - 7, this->extension(i), output); - } - - // optional .google.protobuf.FileOptions options = 8; - if (has_options()) { - ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( - 8, this->options(), output); - } - - // optional .google.protobuf.SourceCodeInfo source_code_info = 9; - if (has_source_code_info()) { - ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( - 9, this->source_code_info(), output); - } - - // repeated int32 public_dependency = 10; - for (int i = 0; i < this->public_dependency_size(); i++) { - ::google::protobuf::internal::WireFormatLite::WriteInt32( - 10, this->public_dependency(i), output); - } - - // repeated int32 weak_dependency = 11; - for (int i = 0; i < this->weak_dependency_size(); i++) { - ::google::protobuf::internal::WireFormatLite::WriteInt32( - 11, this->weak_dependency(i), output); - } - - if (!unknown_fields().empty()) { - ::google::protobuf::internal::WireFormat::SerializeUnknownFields( - unknown_fields(), output); - } -} - -::google::protobuf::uint8* FileDescriptorProto::SerializeWithCachedSizesToArray( - ::google::protobuf::uint8* target) const { - // optional string name = 1; - if (has_name()) { - ::google::protobuf::internal::WireFormat::VerifyUTF8String( - this->name().data(), this->name().length(), - ::google::protobuf::internal::WireFormat::SERIALIZE); - target = - ::google::protobuf::internal::WireFormatLite::WriteStringToArray( - 1, this->name(), target); - } - - // optional string package = 2; - if (has_package()) { - ::google::protobuf::internal::WireFormat::VerifyUTF8String( - this->package().data(), this->package().length(), - ::google::protobuf::internal::WireFormat::SERIALIZE); - target = - ::google::protobuf::internal::WireFormatLite::WriteStringToArray( - 2, this->package(), target); - } - - // repeated string dependency = 3; - for (int i = 0; i < this->dependency_size(); i++) { - ::google::protobuf::internal::WireFormat::VerifyUTF8String( - this->dependency(i).data(), this->dependency(i).length(), - ::google::protobuf::internal::WireFormat::SERIALIZE); - target = ::google::protobuf::internal::WireFormatLite:: - WriteStringToArray(3, this->dependency(i), target); - } - - // repeated .google.protobuf.DescriptorProto message_type = 4; - for (int i = 0; i < this->message_type_size(); i++) { - target = ::google::protobuf::internal::WireFormatLite:: - WriteMessageNoVirtualToArray( - 4, this->message_type(i), target); - } - - // repeated .google.protobuf.EnumDescriptorProto enum_type = 5; - for (int i = 0; i < this->enum_type_size(); i++) { - target = ::google::protobuf::internal::WireFormatLite:: - WriteMessageNoVirtualToArray( - 5, this->enum_type(i), target); - } - - // repeated .google.protobuf.ServiceDescriptorProto service = 6; - for (int i = 0; i < this->service_size(); i++) { - target = ::google::protobuf::internal::WireFormatLite:: - WriteMessageNoVirtualToArray( - 6, this->service(i), target); - } - - // repeated .google.protobuf.FieldDescriptorProto extension = 7; - for (int i = 0; i < this->extension_size(); i++) { - target = ::google::protobuf::internal::WireFormatLite:: - WriteMessageNoVirtualToArray( - 7, this->extension(i), target); - } - - // optional .google.protobuf.FileOptions options = 8; - if (has_options()) { - target = ::google::protobuf::internal::WireFormatLite:: - WriteMessageNoVirtualToArray( - 8, this->options(), target); - } - - // optional .google.protobuf.SourceCodeInfo source_code_info = 9; - if (has_source_code_info()) { - target = ::google::protobuf::internal::WireFormatLite:: - WriteMessageNoVirtualToArray( - 9, this->source_code_info(), target); - } - - // repeated int32 public_dependency = 10; - for (int i = 0; i < this->public_dependency_size(); i++) { - target = ::google::protobuf::internal::WireFormatLite:: - WriteInt32ToArray(10, this->public_dependency(i), target); - } - - // repeated int32 weak_dependency = 11; - for (int i = 0; i < this->weak_dependency_size(); i++) { - target = ::google::protobuf::internal::WireFormatLite:: - WriteInt32ToArray(11, this->weak_dependency(i), target); - } - - if (!unknown_fields().empty()) { - target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray( - unknown_fields(), target); - } - return target; -} - -int FileDescriptorProto::ByteSize() const { - int total_size = 0; - - if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) { - // optional string name = 1; - if (has_name()) { - total_size += 1 + - ::google::protobuf::internal::WireFormatLite::StringSize( - this->name()); - } - - // optional string package = 2; - if (has_package()) { - total_size += 1 + - ::google::protobuf::internal::WireFormatLite::StringSize( - this->package()); - } - - } - if (_has_bits_[9 / 32] & (0xffu << (9 % 32))) { - // optional .google.protobuf.FileOptions options = 8; - if (has_options()) { - total_size += 1 + - ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( - this->options()); - } - - // optional .google.protobuf.SourceCodeInfo source_code_info = 9; - if (has_source_code_info()) { - total_size += 1 + - ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( - this->source_code_info()); - } - - } - // repeated string dependency = 3; - total_size += 1 * this->dependency_size(); - for (int i = 0; i < this->dependency_size(); i++) { - total_size += ::google::protobuf::internal::WireFormatLite::StringSize( - this->dependency(i)); - } - - // repeated int32 public_dependency = 10; - { - int data_size = 0; - for (int i = 0; i < this->public_dependency_size(); i++) { - data_size += ::google::protobuf::internal::WireFormatLite:: - Int32Size(this->public_dependency(i)); - } - total_size += 1 * this->public_dependency_size() + data_size; - } - - // repeated int32 weak_dependency = 11; - { - int data_size = 0; - for (int i = 0; i < this->weak_dependency_size(); i++) { - data_size += ::google::protobuf::internal::WireFormatLite:: - Int32Size(this->weak_dependency(i)); - } - total_size += 1 * this->weak_dependency_size() + data_size; - } - - // repeated .google.protobuf.DescriptorProto message_type = 4; - total_size += 1 * this->message_type_size(); - for (int i = 0; i < this->message_type_size(); i++) { - total_size += - ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( - this->message_type(i)); - } - - // repeated .google.protobuf.EnumDescriptorProto enum_type = 5; - total_size += 1 * this->enum_type_size(); - for (int i = 0; i < this->enum_type_size(); i++) { - total_size += - ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( - this->enum_type(i)); - } - - // repeated .google.protobuf.ServiceDescriptorProto service = 6; - total_size += 1 * this->service_size(); - for (int i = 0; i < this->service_size(); i++) { - total_size += - ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( - this->service(i)); - } - - // repeated .google.protobuf.FieldDescriptorProto extension = 7; - total_size += 1 * this->extension_size(); - for (int i = 0; i < this->extension_size(); i++) { - total_size += - ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( - this->extension(i)); - } - - if (!unknown_fields().empty()) { - total_size += - ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( - unknown_fields()); - } - GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); - _cached_size_ = total_size; - GOOGLE_SAFE_CONCURRENT_WRITES_END(); - return total_size; -} - -void FileDescriptorProto::MergeFrom(const ::google::protobuf::Message& from) { - GOOGLE_CHECK_NE(&from, this); - const FileDescriptorProto* source = - ::google::protobuf::internal::dynamic_cast_if_available( - &from); - if (source == NULL) { - ::google::protobuf::internal::ReflectionOps::Merge(from, this); - } else { - MergeFrom(*source); - } -} - -void FileDescriptorProto::MergeFrom(const FileDescriptorProto& from) { - GOOGLE_CHECK_NE(&from, this); - dependency_.MergeFrom(from.dependency_); - public_dependency_.MergeFrom(from.public_dependency_); - weak_dependency_.MergeFrom(from.weak_dependency_); - message_type_.MergeFrom(from.message_type_); - enum_type_.MergeFrom(from.enum_type_); - service_.MergeFrom(from.service_); - extension_.MergeFrom(from.extension_); - if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) { - if (from.has_name()) { - set_name(from.name()); - } - if (from.has_package()) { - set_package(from.package()); - } - } - if (from._has_bits_[9 / 32] & (0xffu << (9 % 32))) { - if (from.has_options()) { - mutable_options()->::google::protobuf::FileOptions::MergeFrom(from.options()); - } - if (from.has_source_code_info()) { - mutable_source_code_info()->::google::protobuf::SourceCodeInfo::MergeFrom(from.source_code_info()); - } - } - mutable_unknown_fields()->MergeFrom(from.unknown_fields()); -} - -void FileDescriptorProto::CopyFrom(const ::google::protobuf::Message& from) { - if (&from == this) return; - Clear(); - MergeFrom(from); -} - -void FileDescriptorProto::CopyFrom(const FileDescriptorProto& from) { - if (&from == this) return; - Clear(); - MergeFrom(from); -} - -bool FileDescriptorProto::IsInitialized() const { - - for (int i = 0; i < message_type_size(); i++) { - if (!this->message_type(i).IsInitialized()) return false; - } - for (int i = 0; i < enum_type_size(); i++) { - if (!this->enum_type(i).IsInitialized()) return false; - } - for (int i = 0; i < service_size(); i++) { - if (!this->service(i).IsInitialized()) return false; - } - for (int i = 0; i < extension_size(); i++) { - if (!this->extension(i).IsInitialized()) return false; - } - if (has_options()) { - if (!this->options().IsInitialized()) return false; - } - return true; -} - -void FileDescriptorProto::Swap(FileDescriptorProto* other) { - if (other != this) { - std::swap(name_, other->name_); - std::swap(package_, other->package_); - dependency_.Swap(&other->dependency_); - public_dependency_.Swap(&other->public_dependency_); - weak_dependency_.Swap(&other->weak_dependency_); - message_type_.Swap(&other->message_type_); - enum_type_.Swap(&other->enum_type_); - service_.Swap(&other->service_); - extension_.Swap(&other->extension_); - std::swap(options_, other->options_); - std::swap(source_code_info_, other->source_code_info_); - std::swap(_has_bits_[0], other->_has_bits_[0]); - _unknown_fields_.Swap(&other->_unknown_fields_); - std::swap(_cached_size_, other->_cached_size_); - } -} - -::google::protobuf::Metadata FileDescriptorProto::GetMetadata() const { - protobuf_AssignDescriptorsOnce(); - ::google::protobuf::Metadata metadata; - metadata.descriptor = FileDescriptorProto_descriptor_; - metadata.reflection = FileDescriptorProto_reflection_; - return metadata; -} - - -// =================================================================== - -#ifndef _MSC_VER -const int DescriptorProto_ExtensionRange::kStartFieldNumber; -const int DescriptorProto_ExtensionRange::kEndFieldNumber; -#endif // !_MSC_VER - -DescriptorProto_ExtensionRange::DescriptorProto_ExtensionRange() - : ::google::protobuf::Message() { - SharedCtor(); -} - -void DescriptorProto_ExtensionRange::InitAsDefaultInstance() { -} - -DescriptorProto_ExtensionRange::DescriptorProto_ExtensionRange(const DescriptorProto_ExtensionRange& from) - : ::google::protobuf::Message() { - SharedCtor(); - MergeFrom(from); -} - -void DescriptorProto_ExtensionRange::SharedCtor() { - _cached_size_ = 0; - start_ = 0; - end_ = 0; - ::memset(_has_bits_, 0, sizeof(_has_bits_)); -} - -DescriptorProto_ExtensionRange::~DescriptorProto_ExtensionRange() { - SharedDtor(); -} - -void DescriptorProto_ExtensionRange::SharedDtor() { - if (this != default_instance_) { - } -} - -void DescriptorProto_ExtensionRange::SetCachedSize(int size) const { - GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); - _cached_size_ = size; - GOOGLE_SAFE_CONCURRENT_WRITES_END(); -} -const ::google::protobuf::Descriptor* DescriptorProto_ExtensionRange::descriptor() { - protobuf_AssignDescriptorsOnce(); - return DescriptorProto_ExtensionRange_descriptor_; -} - -const DescriptorProto_ExtensionRange& DescriptorProto_ExtensionRange::default_instance() { - if (default_instance_ == NULL) protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto(); - return *default_instance_; -} - -DescriptorProto_ExtensionRange* DescriptorProto_ExtensionRange::default_instance_ = NULL; - -DescriptorProto_ExtensionRange* DescriptorProto_ExtensionRange::New() const { - return new DescriptorProto_ExtensionRange; -} - -void DescriptorProto_ExtensionRange::Clear() { - if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) { - start_ = 0; - end_ = 0; - } - ::memset(_has_bits_, 0, sizeof(_has_bits_)); - mutable_unknown_fields()->Clear(); -} - -bool DescriptorProto_ExtensionRange::MergePartialFromCodedStream( - ::google::protobuf::io::CodedInputStream* input) { -#define DO_(EXPRESSION) if (!(EXPRESSION)) return false - ::google::protobuf::uint32 tag; - while ((tag = input->ReadTag()) != 0) { - switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { - // optional int32 start = 1; - case 1: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) { - DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< - ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>( - input, &start_))); - set_has_start(); - } else { - goto handle_uninterpreted; - } - if (input->ExpectTag(16)) goto parse_end; - break; - } - - // optional int32 end = 2; - case 2: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) { - parse_end: - DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< - ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>( - input, &end_))); - set_has_end(); - } else { - goto handle_uninterpreted; - } - if (input->ExpectAtEnd()) return true; - break; - } - - default: { - handle_uninterpreted: - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) { - return true; - } - DO_(::google::protobuf::internal::WireFormat::SkipField( - input, tag, mutable_unknown_fields())); - break; - } - } - } - return true; -#undef DO_ -} - -void DescriptorProto_ExtensionRange::SerializeWithCachedSizes( - ::google::protobuf::io::CodedOutputStream* output) const { - // optional int32 start = 1; - if (has_start()) { - ::google::protobuf::internal::WireFormatLite::WriteInt32(1, this->start(), output); - } - - // optional int32 end = 2; - if (has_end()) { - ::google::protobuf::internal::WireFormatLite::WriteInt32(2, this->end(), output); - } - - if (!unknown_fields().empty()) { - ::google::protobuf::internal::WireFormat::SerializeUnknownFields( - unknown_fields(), output); - } -} - -::google::protobuf::uint8* DescriptorProto_ExtensionRange::SerializeWithCachedSizesToArray( - ::google::protobuf::uint8* target) const { - // optional int32 start = 1; - if (has_start()) { - target = ::google::protobuf::internal::WireFormatLite::WriteInt32ToArray(1, this->start(), target); - } - - // optional int32 end = 2; - if (has_end()) { - target = ::google::protobuf::internal::WireFormatLite::WriteInt32ToArray(2, this->end(), target); - } - - if (!unknown_fields().empty()) { - target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray( - unknown_fields(), target); - } - return target; -} - -int DescriptorProto_ExtensionRange::ByteSize() const { - int total_size = 0; - - if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) { - // optional int32 start = 1; - if (has_start()) { - total_size += 1 + - ::google::protobuf::internal::WireFormatLite::Int32Size( - this->start()); - } - - // optional int32 end = 2; - if (has_end()) { - total_size += 1 + - ::google::protobuf::internal::WireFormatLite::Int32Size( - this->end()); - } - - } - if (!unknown_fields().empty()) { - total_size += - ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( - unknown_fields()); - } - GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); - _cached_size_ = total_size; - GOOGLE_SAFE_CONCURRENT_WRITES_END(); - return total_size; -} - -void DescriptorProto_ExtensionRange::MergeFrom(const ::google::protobuf::Message& from) { - GOOGLE_CHECK_NE(&from, this); - const DescriptorProto_ExtensionRange* source = - ::google::protobuf::internal::dynamic_cast_if_available( - &from); - if (source == NULL) { - ::google::protobuf::internal::ReflectionOps::Merge(from, this); - } else { - MergeFrom(*source); - } -} - -void DescriptorProto_ExtensionRange::MergeFrom(const DescriptorProto_ExtensionRange& from) { - GOOGLE_CHECK_NE(&from, this); - if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) { - if (from.has_start()) { - set_start(from.start()); - } - if (from.has_end()) { - set_end(from.end()); - } - } - mutable_unknown_fields()->MergeFrom(from.unknown_fields()); -} - -void DescriptorProto_ExtensionRange::CopyFrom(const ::google::protobuf::Message& from) { - if (&from == this) return; - Clear(); - MergeFrom(from); -} - -void DescriptorProto_ExtensionRange::CopyFrom(const DescriptorProto_ExtensionRange& from) { - if (&from == this) return; - Clear(); - MergeFrom(from); -} - -bool DescriptorProto_ExtensionRange::IsInitialized() const { - - return true; -} - -void DescriptorProto_ExtensionRange::Swap(DescriptorProto_ExtensionRange* other) { - if (other != this) { - std::swap(start_, other->start_); - std::swap(end_, other->end_); - std::swap(_has_bits_[0], other->_has_bits_[0]); - _unknown_fields_.Swap(&other->_unknown_fields_); - std::swap(_cached_size_, other->_cached_size_); - } -} - -::google::protobuf::Metadata DescriptorProto_ExtensionRange::GetMetadata() const { - protobuf_AssignDescriptorsOnce(); - ::google::protobuf::Metadata metadata; - metadata.descriptor = DescriptorProto_ExtensionRange_descriptor_; - metadata.reflection = DescriptorProto_ExtensionRange_reflection_; - return metadata; -} - - -// ------------------------------------------------------------------- - -#ifndef _MSC_VER -const int DescriptorProto::kNameFieldNumber; -const int DescriptorProto::kFieldFieldNumber; -const int DescriptorProto::kExtensionFieldNumber; -const int DescriptorProto::kNestedTypeFieldNumber; -const int DescriptorProto::kEnumTypeFieldNumber; -const int DescriptorProto::kExtensionRangeFieldNumber; -const int DescriptorProto::kOptionsFieldNumber; -#endif // !_MSC_VER - -DescriptorProto::DescriptorProto() - : ::google::protobuf::Message() { - SharedCtor(); -} - -void DescriptorProto::InitAsDefaultInstance() { - options_ = const_cast< ::google::protobuf::MessageOptions*>(&::google::protobuf::MessageOptions::default_instance()); -} - -DescriptorProto::DescriptorProto(const DescriptorProto& from) - : ::google::protobuf::Message() { - SharedCtor(); - MergeFrom(from); -} - -void DescriptorProto::SharedCtor() { - _cached_size_ = 0; - name_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); - options_ = NULL; - ::memset(_has_bits_, 0, sizeof(_has_bits_)); -} - -DescriptorProto::~DescriptorProto() { - SharedDtor(); -} - -void DescriptorProto::SharedDtor() { - if (name_ != &::google::protobuf::internal::kEmptyString) { - delete name_; - } - if (this != default_instance_) { - delete options_; - } -} - -void DescriptorProto::SetCachedSize(int size) const { - GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); - _cached_size_ = size; - GOOGLE_SAFE_CONCURRENT_WRITES_END(); -} -const ::google::protobuf::Descriptor* DescriptorProto::descriptor() { - protobuf_AssignDescriptorsOnce(); - return DescriptorProto_descriptor_; -} - -const DescriptorProto& DescriptorProto::default_instance() { - if (default_instance_ == NULL) protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto(); - return *default_instance_; -} - -DescriptorProto* DescriptorProto::default_instance_ = NULL; - -DescriptorProto* DescriptorProto::New() const { - return new DescriptorProto; -} - -void DescriptorProto::Clear() { - if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) { - if (has_name()) { - if (name_ != &::google::protobuf::internal::kEmptyString) { - name_->clear(); - } - } - if (has_options()) { - if (options_ != NULL) options_->::google::protobuf::MessageOptions::Clear(); - } - } - field_.Clear(); - extension_.Clear(); - nested_type_.Clear(); - enum_type_.Clear(); - extension_range_.Clear(); - ::memset(_has_bits_, 0, sizeof(_has_bits_)); - mutable_unknown_fields()->Clear(); -} - -bool DescriptorProto::MergePartialFromCodedStream( - ::google::protobuf::io::CodedInputStream* input) { -#define DO_(EXPRESSION) if (!(EXPRESSION)) return false - ::google::protobuf::uint32 tag; - while ((tag = input->ReadTag()) != 0) { - switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { - // optional string name = 1; - case 1: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) { - DO_(::google::protobuf::internal::WireFormatLite::ReadString( - input, this->mutable_name())); - ::google::protobuf::internal::WireFormat::VerifyUTF8String( - this->name().data(), this->name().length(), - ::google::protobuf::internal::WireFormat::PARSE); - } else { - goto handle_uninterpreted; - } - if (input->ExpectTag(18)) goto parse_field; - break; - } - - // repeated .google.protobuf.FieldDescriptorProto field = 2; - case 2: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) { - parse_field: - DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual( - input, add_field())); - } else { - goto handle_uninterpreted; - } - if (input->ExpectTag(18)) goto parse_field; - if (input->ExpectTag(26)) goto parse_nested_type; - break; - } - - // repeated .google.protobuf.DescriptorProto nested_type = 3; - case 3: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) { - parse_nested_type: - DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual( - input, add_nested_type())); - } else { - goto handle_uninterpreted; - } - if (input->ExpectTag(26)) goto parse_nested_type; - if (input->ExpectTag(34)) goto parse_enum_type; - break; - } - - // repeated .google.protobuf.EnumDescriptorProto enum_type = 4; - case 4: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) { - parse_enum_type: - DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual( - input, add_enum_type())); - } else { - goto handle_uninterpreted; - } - if (input->ExpectTag(34)) goto parse_enum_type; - if (input->ExpectTag(42)) goto parse_extension_range; - break; - } - - // repeated .google.protobuf.DescriptorProto.ExtensionRange extension_range = 5; - case 5: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) { - parse_extension_range: - DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual( - input, add_extension_range())); - } else { - goto handle_uninterpreted; - } - if (input->ExpectTag(42)) goto parse_extension_range; - if (input->ExpectTag(50)) goto parse_extension; - break; - } - - // repeated .google.protobuf.FieldDescriptorProto extension = 6; - case 6: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) { - parse_extension: - DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual( - input, add_extension())); - } else { - goto handle_uninterpreted; - } - if (input->ExpectTag(50)) goto parse_extension; - if (input->ExpectTag(58)) goto parse_options; - break; - } - - // optional .google.protobuf.MessageOptions options = 7; - case 7: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) { - parse_options: - DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual( - input, mutable_options())); - } else { - goto handle_uninterpreted; - } - if (input->ExpectAtEnd()) return true; - break; - } - - default: { - handle_uninterpreted: - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) { - return true; - } - DO_(::google::protobuf::internal::WireFormat::SkipField( - input, tag, mutable_unknown_fields())); - break; - } - } - } - return true; -#undef DO_ -} - -void DescriptorProto::SerializeWithCachedSizes( - ::google::protobuf::io::CodedOutputStream* output) const { - // optional string name = 1; - if (has_name()) { - ::google::protobuf::internal::WireFormat::VerifyUTF8String( - this->name().data(), this->name().length(), - ::google::protobuf::internal::WireFormat::SERIALIZE); - ::google::protobuf::internal::WireFormatLite::WriteString( - 1, this->name(), output); - } - - // repeated .google.protobuf.FieldDescriptorProto field = 2; - for (int i = 0; i < this->field_size(); i++) { - ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( - 2, this->field(i), output); - } - - // repeated .google.protobuf.DescriptorProto nested_type = 3; - for (int i = 0; i < this->nested_type_size(); i++) { - ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( - 3, this->nested_type(i), output); - } - - // repeated .google.protobuf.EnumDescriptorProto enum_type = 4; - for (int i = 0; i < this->enum_type_size(); i++) { - ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( - 4, this->enum_type(i), output); - } - - // repeated .google.protobuf.DescriptorProto.ExtensionRange extension_range = 5; - for (int i = 0; i < this->extension_range_size(); i++) { - ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( - 5, this->extension_range(i), output); - } - - // repeated .google.protobuf.FieldDescriptorProto extension = 6; - for (int i = 0; i < this->extension_size(); i++) { - ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( - 6, this->extension(i), output); - } - - // optional .google.protobuf.MessageOptions options = 7; - if (has_options()) { - ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( - 7, this->options(), output); - } - - if (!unknown_fields().empty()) { - ::google::protobuf::internal::WireFormat::SerializeUnknownFields( - unknown_fields(), output); - } -} - -::google::protobuf::uint8* DescriptorProto::SerializeWithCachedSizesToArray( - ::google::protobuf::uint8* target) const { - // optional string name = 1; - if (has_name()) { - ::google::protobuf::internal::WireFormat::VerifyUTF8String( - this->name().data(), this->name().length(), - ::google::protobuf::internal::WireFormat::SERIALIZE); - target = - ::google::protobuf::internal::WireFormatLite::WriteStringToArray( - 1, this->name(), target); - } - - // repeated .google.protobuf.FieldDescriptorProto field = 2; - for (int i = 0; i < this->field_size(); i++) { - target = ::google::protobuf::internal::WireFormatLite:: - WriteMessageNoVirtualToArray( - 2, this->field(i), target); - } - - // repeated .google.protobuf.DescriptorProto nested_type = 3; - for (int i = 0; i < this->nested_type_size(); i++) { - target = ::google::protobuf::internal::WireFormatLite:: - WriteMessageNoVirtualToArray( - 3, this->nested_type(i), target); - } - - // repeated .google.protobuf.EnumDescriptorProto enum_type = 4; - for (int i = 0; i < this->enum_type_size(); i++) { - target = ::google::protobuf::internal::WireFormatLite:: - WriteMessageNoVirtualToArray( - 4, this->enum_type(i), target); - } - - // repeated .google.protobuf.DescriptorProto.ExtensionRange extension_range = 5; - for (int i = 0; i < this->extension_range_size(); i++) { - target = ::google::protobuf::internal::WireFormatLite:: - WriteMessageNoVirtualToArray( - 5, this->extension_range(i), target); - } - - // repeated .google.protobuf.FieldDescriptorProto extension = 6; - for (int i = 0; i < this->extension_size(); i++) { - target = ::google::protobuf::internal::WireFormatLite:: - WriteMessageNoVirtualToArray( - 6, this->extension(i), target); - } - - // optional .google.protobuf.MessageOptions options = 7; - if (has_options()) { - target = ::google::protobuf::internal::WireFormatLite:: - WriteMessageNoVirtualToArray( - 7, this->options(), target); - } - - if (!unknown_fields().empty()) { - target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray( - unknown_fields(), target); - } - return target; -} - -int DescriptorProto::ByteSize() const { - int total_size = 0; - - if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) { - // optional string name = 1; - if (has_name()) { - total_size += 1 + - ::google::protobuf::internal::WireFormatLite::StringSize( - this->name()); - } - - // optional .google.protobuf.MessageOptions options = 7; - if (has_options()) { - total_size += 1 + - ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( - this->options()); - } - - } - // repeated .google.protobuf.FieldDescriptorProto field = 2; - total_size += 1 * this->field_size(); - for (int i = 0; i < this->field_size(); i++) { - total_size += - ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( - this->field(i)); - } - - // repeated .google.protobuf.FieldDescriptorProto extension = 6; - total_size += 1 * this->extension_size(); - for (int i = 0; i < this->extension_size(); i++) { - total_size += - ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( - this->extension(i)); - } - - // repeated .google.protobuf.DescriptorProto nested_type = 3; - total_size += 1 * this->nested_type_size(); - for (int i = 0; i < this->nested_type_size(); i++) { - total_size += - ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( - this->nested_type(i)); - } - - // repeated .google.protobuf.EnumDescriptorProto enum_type = 4; - total_size += 1 * this->enum_type_size(); - for (int i = 0; i < this->enum_type_size(); i++) { - total_size += - ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( - this->enum_type(i)); - } - - // repeated .google.protobuf.DescriptorProto.ExtensionRange extension_range = 5; - total_size += 1 * this->extension_range_size(); - for (int i = 0; i < this->extension_range_size(); i++) { - total_size += - ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( - this->extension_range(i)); - } - - if (!unknown_fields().empty()) { - total_size += - ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( - unknown_fields()); - } - GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); - _cached_size_ = total_size; - GOOGLE_SAFE_CONCURRENT_WRITES_END(); - return total_size; -} - -void DescriptorProto::MergeFrom(const ::google::protobuf::Message& from) { - GOOGLE_CHECK_NE(&from, this); - const DescriptorProto* source = - ::google::protobuf::internal::dynamic_cast_if_available( - &from); - if (source == NULL) { - ::google::protobuf::internal::ReflectionOps::Merge(from, this); - } else { - MergeFrom(*source); - } -} - -void DescriptorProto::MergeFrom(const DescriptorProto& from) { - GOOGLE_CHECK_NE(&from, this); - field_.MergeFrom(from.field_); - extension_.MergeFrom(from.extension_); - nested_type_.MergeFrom(from.nested_type_); - enum_type_.MergeFrom(from.enum_type_); - extension_range_.MergeFrom(from.extension_range_); - if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) { - if (from.has_name()) { - set_name(from.name()); - } - if (from.has_options()) { - mutable_options()->::google::protobuf::MessageOptions::MergeFrom(from.options()); - } - } - mutable_unknown_fields()->MergeFrom(from.unknown_fields()); -} - -void DescriptorProto::CopyFrom(const ::google::protobuf::Message& from) { - if (&from == this) return; - Clear(); - MergeFrom(from); -} - -void DescriptorProto::CopyFrom(const DescriptorProto& from) { - if (&from == this) return; - Clear(); - MergeFrom(from); -} - -bool DescriptorProto::IsInitialized() const { - - for (int i = 0; i < field_size(); i++) { - if (!this->field(i).IsInitialized()) return false; - } - for (int i = 0; i < extension_size(); i++) { - if (!this->extension(i).IsInitialized()) return false; - } - for (int i = 0; i < nested_type_size(); i++) { - if (!this->nested_type(i).IsInitialized()) return false; - } - for (int i = 0; i < enum_type_size(); i++) { - if (!this->enum_type(i).IsInitialized()) return false; - } - if (has_options()) { - if (!this->options().IsInitialized()) return false; - } - return true; -} - -void DescriptorProto::Swap(DescriptorProto* other) { - if (other != this) { - std::swap(name_, other->name_); - field_.Swap(&other->field_); - extension_.Swap(&other->extension_); - nested_type_.Swap(&other->nested_type_); - enum_type_.Swap(&other->enum_type_); - extension_range_.Swap(&other->extension_range_); - std::swap(options_, other->options_); - std::swap(_has_bits_[0], other->_has_bits_[0]); - _unknown_fields_.Swap(&other->_unknown_fields_); - std::swap(_cached_size_, other->_cached_size_); - } -} - -::google::protobuf::Metadata DescriptorProto::GetMetadata() const { - protobuf_AssignDescriptorsOnce(); - ::google::protobuf::Metadata metadata; - metadata.descriptor = DescriptorProto_descriptor_; - metadata.reflection = DescriptorProto_reflection_; - return metadata; -} - - -// =================================================================== - -const ::google::protobuf::EnumDescriptor* FieldDescriptorProto_Type_descriptor() { - protobuf_AssignDescriptorsOnce(); - return FieldDescriptorProto_Type_descriptor_; -} -bool FieldDescriptorProto_Type_IsValid(int value) { - switch(value) { - case 1: - case 2: - case 3: - case 4: - case 5: - case 6: - case 7: - case 8: - case 9: - case 10: - case 11: - case 12: - case 13: - case 14: - case 15: - case 16: - case 17: - case 18: - return true; - default: - return false; - } -} - -#ifndef _MSC_VER -const FieldDescriptorProto_Type FieldDescriptorProto::TYPE_DOUBLE; -const FieldDescriptorProto_Type FieldDescriptorProto::TYPE_FLOAT; -const FieldDescriptorProto_Type FieldDescriptorProto::TYPE_INT64; -const FieldDescriptorProto_Type FieldDescriptorProto::TYPE_UINT64; -const FieldDescriptorProto_Type FieldDescriptorProto::TYPE_INT32; -const FieldDescriptorProto_Type FieldDescriptorProto::TYPE_FIXED64; -const FieldDescriptorProto_Type FieldDescriptorProto::TYPE_FIXED32; -const FieldDescriptorProto_Type FieldDescriptorProto::TYPE_BOOL; -const FieldDescriptorProto_Type FieldDescriptorProto::TYPE_STRING; -const FieldDescriptorProto_Type FieldDescriptorProto::TYPE_GROUP; -const FieldDescriptorProto_Type FieldDescriptorProto::TYPE_MESSAGE; -const FieldDescriptorProto_Type FieldDescriptorProto::TYPE_BYTES; -const FieldDescriptorProto_Type FieldDescriptorProto::TYPE_UINT32; -const FieldDescriptorProto_Type FieldDescriptorProto::TYPE_ENUM; -const FieldDescriptorProto_Type FieldDescriptorProto::TYPE_SFIXED32; -const FieldDescriptorProto_Type FieldDescriptorProto::TYPE_SFIXED64; -const FieldDescriptorProto_Type FieldDescriptorProto::TYPE_SINT32; -const FieldDescriptorProto_Type FieldDescriptorProto::TYPE_SINT64; -const FieldDescriptorProto_Type FieldDescriptorProto::Type_MIN; -const FieldDescriptorProto_Type FieldDescriptorProto::Type_MAX; -const int FieldDescriptorProto::Type_ARRAYSIZE; -#endif // _MSC_VER -const ::google::protobuf::EnumDescriptor* FieldDescriptorProto_Label_descriptor() { - protobuf_AssignDescriptorsOnce(); - return FieldDescriptorProto_Label_descriptor_; -} -bool FieldDescriptorProto_Label_IsValid(int value) { - switch(value) { - case 1: - case 2: - case 3: - return true; - default: - return false; - } -} - -#ifndef _MSC_VER -const FieldDescriptorProto_Label FieldDescriptorProto::LABEL_OPTIONAL; -const FieldDescriptorProto_Label FieldDescriptorProto::LABEL_REQUIRED; -const FieldDescriptorProto_Label FieldDescriptorProto::LABEL_REPEATED; -const FieldDescriptorProto_Label FieldDescriptorProto::Label_MIN; -const FieldDescriptorProto_Label FieldDescriptorProto::Label_MAX; -const int FieldDescriptorProto::Label_ARRAYSIZE; -#endif // _MSC_VER -#ifndef _MSC_VER -const int FieldDescriptorProto::kNameFieldNumber; -const int FieldDescriptorProto::kNumberFieldNumber; -const int FieldDescriptorProto::kLabelFieldNumber; -const int FieldDescriptorProto::kTypeFieldNumber; -const int FieldDescriptorProto::kTypeNameFieldNumber; -const int FieldDescriptorProto::kExtendeeFieldNumber; -const int FieldDescriptorProto::kDefaultValueFieldNumber; -const int FieldDescriptorProto::kOptionsFieldNumber; -#endif // !_MSC_VER - -FieldDescriptorProto::FieldDescriptorProto() - : ::google::protobuf::Message() { - SharedCtor(); -} - -void FieldDescriptorProto::InitAsDefaultInstance() { - options_ = const_cast< ::google::protobuf::FieldOptions*>(&::google::protobuf::FieldOptions::default_instance()); -} - -FieldDescriptorProto::FieldDescriptorProto(const FieldDescriptorProto& from) - : ::google::protobuf::Message() { - SharedCtor(); - MergeFrom(from); -} - -void FieldDescriptorProto::SharedCtor() { - _cached_size_ = 0; - name_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); - number_ = 0; - label_ = 1; - type_ = 1; - type_name_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); - extendee_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); - default_value_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); - options_ = NULL; - ::memset(_has_bits_, 0, sizeof(_has_bits_)); -} - -FieldDescriptorProto::~FieldDescriptorProto() { - SharedDtor(); -} - -void FieldDescriptorProto::SharedDtor() { - if (name_ != &::google::protobuf::internal::kEmptyString) { - delete name_; - } - if (type_name_ != &::google::protobuf::internal::kEmptyString) { - delete type_name_; - } - if (extendee_ != &::google::protobuf::internal::kEmptyString) { - delete extendee_; - } - if (default_value_ != &::google::protobuf::internal::kEmptyString) { - delete default_value_; - } - if (this != default_instance_) { - delete options_; - } -} - -void FieldDescriptorProto::SetCachedSize(int size) const { - GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); - _cached_size_ = size; - GOOGLE_SAFE_CONCURRENT_WRITES_END(); -} -const ::google::protobuf::Descriptor* FieldDescriptorProto::descriptor() { - protobuf_AssignDescriptorsOnce(); - return FieldDescriptorProto_descriptor_; -} - -const FieldDescriptorProto& FieldDescriptorProto::default_instance() { - if (default_instance_ == NULL) protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto(); - return *default_instance_; -} - -FieldDescriptorProto* FieldDescriptorProto::default_instance_ = NULL; - -FieldDescriptorProto* FieldDescriptorProto::New() const { - return new FieldDescriptorProto; -} - -void FieldDescriptorProto::Clear() { - if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) { - if (has_name()) { - if (name_ != &::google::protobuf::internal::kEmptyString) { - name_->clear(); - } - } - number_ = 0; - label_ = 1; - type_ = 1; - if (has_type_name()) { - if (type_name_ != &::google::protobuf::internal::kEmptyString) { - type_name_->clear(); - } - } - if (has_extendee()) { - if (extendee_ != &::google::protobuf::internal::kEmptyString) { - extendee_->clear(); - } - } - if (has_default_value()) { - if (default_value_ != &::google::protobuf::internal::kEmptyString) { - default_value_->clear(); - } - } - if (has_options()) { - if (options_ != NULL) options_->::google::protobuf::FieldOptions::Clear(); - } - } - ::memset(_has_bits_, 0, sizeof(_has_bits_)); - mutable_unknown_fields()->Clear(); -} - -bool FieldDescriptorProto::MergePartialFromCodedStream( - ::google::protobuf::io::CodedInputStream* input) { -#define DO_(EXPRESSION) if (!(EXPRESSION)) return false - ::google::protobuf::uint32 tag; - while ((tag = input->ReadTag()) != 0) { - switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { - // optional string name = 1; - case 1: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) { - DO_(::google::protobuf::internal::WireFormatLite::ReadString( - input, this->mutable_name())); - ::google::protobuf::internal::WireFormat::VerifyUTF8String( - this->name().data(), this->name().length(), - ::google::protobuf::internal::WireFormat::PARSE); - } else { - goto handle_uninterpreted; - } - if (input->ExpectTag(18)) goto parse_extendee; - break; - } - - // optional string extendee = 2; - case 2: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) { - parse_extendee: - DO_(::google::protobuf::internal::WireFormatLite::ReadString( - input, this->mutable_extendee())); - ::google::protobuf::internal::WireFormat::VerifyUTF8String( - this->extendee().data(), this->extendee().length(), - ::google::protobuf::internal::WireFormat::PARSE); - } else { - goto handle_uninterpreted; - } - if (input->ExpectTag(24)) goto parse_number; - break; - } - - // optional int32 number = 3; - case 3: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) { - parse_number: - DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< - ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>( - input, &number_))); - set_has_number(); - } else { - goto handle_uninterpreted; - } - if (input->ExpectTag(32)) goto parse_label; - break; - } - - // optional .google.protobuf.FieldDescriptorProto.Label label = 4; - case 4: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) { - parse_label: - int value; - DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< - int, ::google::protobuf::internal::WireFormatLite::TYPE_ENUM>( - input, &value))); - if (::google::protobuf::FieldDescriptorProto_Label_IsValid(value)) { - set_label(static_cast< ::google::protobuf::FieldDescriptorProto_Label >(value)); - } else { - mutable_unknown_fields()->AddVarint(4, value); - } - } else { - goto handle_uninterpreted; - } - if (input->ExpectTag(40)) goto parse_type; - break; - } - - // optional .google.protobuf.FieldDescriptorProto.Type type = 5; - case 5: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) { - parse_type: - int value; - DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< - int, ::google::protobuf::internal::WireFormatLite::TYPE_ENUM>( - input, &value))); - if (::google::protobuf::FieldDescriptorProto_Type_IsValid(value)) { - set_type(static_cast< ::google::protobuf::FieldDescriptorProto_Type >(value)); - } else { - mutable_unknown_fields()->AddVarint(5, value); - } - } else { - goto handle_uninterpreted; - } - if (input->ExpectTag(50)) goto parse_type_name; - break; - } - - // optional string type_name = 6; - case 6: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) { - parse_type_name: - DO_(::google::protobuf::internal::WireFormatLite::ReadString( - input, this->mutable_type_name())); - ::google::protobuf::internal::WireFormat::VerifyUTF8String( - this->type_name().data(), this->type_name().length(), - ::google::protobuf::internal::WireFormat::PARSE); - } else { - goto handle_uninterpreted; - } - if (input->ExpectTag(58)) goto parse_default_value; - break; - } - - // optional string default_value = 7; - case 7: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) { - parse_default_value: - DO_(::google::protobuf::internal::WireFormatLite::ReadString( - input, this->mutable_default_value())); - ::google::protobuf::internal::WireFormat::VerifyUTF8String( - this->default_value().data(), this->default_value().length(), - ::google::protobuf::internal::WireFormat::PARSE); - } else { - goto handle_uninterpreted; - } - if (input->ExpectTag(66)) goto parse_options; - break; - } - - // optional .google.protobuf.FieldOptions options = 8; - case 8: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) { - parse_options: - DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual( - input, mutable_options())); - } else { - goto handle_uninterpreted; - } - if (input->ExpectAtEnd()) return true; - break; - } - - default: { - handle_uninterpreted: - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) { - return true; - } - DO_(::google::protobuf::internal::WireFormat::SkipField( - input, tag, mutable_unknown_fields())); - break; - } - } - } - return true; -#undef DO_ -} - -void FieldDescriptorProto::SerializeWithCachedSizes( - ::google::protobuf::io::CodedOutputStream* output) const { - // optional string name = 1; - if (has_name()) { - ::google::protobuf::internal::WireFormat::VerifyUTF8String( - this->name().data(), this->name().length(), - ::google::protobuf::internal::WireFormat::SERIALIZE); - ::google::protobuf::internal::WireFormatLite::WriteString( - 1, this->name(), output); - } - - // optional string extendee = 2; - if (has_extendee()) { - ::google::protobuf::internal::WireFormat::VerifyUTF8String( - this->extendee().data(), this->extendee().length(), - ::google::protobuf::internal::WireFormat::SERIALIZE); - ::google::protobuf::internal::WireFormatLite::WriteString( - 2, this->extendee(), output); - } - - // optional int32 number = 3; - if (has_number()) { - ::google::protobuf::internal::WireFormatLite::WriteInt32(3, this->number(), output); - } - - // optional .google.protobuf.FieldDescriptorProto.Label label = 4; - if (has_label()) { - ::google::protobuf::internal::WireFormatLite::WriteEnum( - 4, this->label(), output); - } - - // optional .google.protobuf.FieldDescriptorProto.Type type = 5; - if (has_type()) { - ::google::protobuf::internal::WireFormatLite::WriteEnum( - 5, this->type(), output); - } - - // optional string type_name = 6; - if (has_type_name()) { - ::google::protobuf::internal::WireFormat::VerifyUTF8String( - this->type_name().data(), this->type_name().length(), - ::google::protobuf::internal::WireFormat::SERIALIZE); - ::google::protobuf::internal::WireFormatLite::WriteString( - 6, this->type_name(), output); - } - - // optional string default_value = 7; - if (has_default_value()) { - ::google::protobuf::internal::WireFormat::VerifyUTF8String( - this->default_value().data(), this->default_value().length(), - ::google::protobuf::internal::WireFormat::SERIALIZE); - ::google::protobuf::internal::WireFormatLite::WriteString( - 7, this->default_value(), output); - } - - // optional .google.protobuf.FieldOptions options = 8; - if (has_options()) { - ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( - 8, this->options(), output); - } - - if (!unknown_fields().empty()) { - ::google::protobuf::internal::WireFormat::SerializeUnknownFields( - unknown_fields(), output); - } -} - -::google::protobuf::uint8* FieldDescriptorProto::SerializeWithCachedSizesToArray( - ::google::protobuf::uint8* target) const { - // optional string name = 1; - if (has_name()) { - ::google::protobuf::internal::WireFormat::VerifyUTF8String( - this->name().data(), this->name().length(), - ::google::protobuf::internal::WireFormat::SERIALIZE); - target = - ::google::protobuf::internal::WireFormatLite::WriteStringToArray( - 1, this->name(), target); - } - - // optional string extendee = 2; - if (has_extendee()) { - ::google::protobuf::internal::WireFormat::VerifyUTF8String( - this->extendee().data(), this->extendee().length(), - ::google::protobuf::internal::WireFormat::SERIALIZE); - target = - ::google::protobuf::internal::WireFormatLite::WriteStringToArray( - 2, this->extendee(), target); - } - - // optional int32 number = 3; - if (has_number()) { - target = ::google::protobuf::internal::WireFormatLite::WriteInt32ToArray(3, this->number(), target); - } - - // optional .google.protobuf.FieldDescriptorProto.Label label = 4; - if (has_label()) { - target = ::google::protobuf::internal::WireFormatLite::WriteEnumToArray( - 4, this->label(), target); - } - - // optional .google.protobuf.FieldDescriptorProto.Type type = 5; - if (has_type()) { - target = ::google::protobuf::internal::WireFormatLite::WriteEnumToArray( - 5, this->type(), target); - } - - // optional string type_name = 6; - if (has_type_name()) { - ::google::protobuf::internal::WireFormat::VerifyUTF8String( - this->type_name().data(), this->type_name().length(), - ::google::protobuf::internal::WireFormat::SERIALIZE); - target = - ::google::protobuf::internal::WireFormatLite::WriteStringToArray( - 6, this->type_name(), target); - } - - // optional string default_value = 7; - if (has_default_value()) { - ::google::protobuf::internal::WireFormat::VerifyUTF8String( - this->default_value().data(), this->default_value().length(), - ::google::protobuf::internal::WireFormat::SERIALIZE); - target = - ::google::protobuf::internal::WireFormatLite::WriteStringToArray( - 7, this->default_value(), target); - } - - // optional .google.protobuf.FieldOptions options = 8; - if (has_options()) { - target = ::google::protobuf::internal::WireFormatLite:: - WriteMessageNoVirtualToArray( - 8, this->options(), target); - } - - if (!unknown_fields().empty()) { - target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray( - unknown_fields(), target); - } - return target; -} - -int FieldDescriptorProto::ByteSize() const { - int total_size = 0; - - if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) { - // optional string name = 1; - if (has_name()) { - total_size += 1 + - ::google::protobuf::internal::WireFormatLite::StringSize( - this->name()); - } - - // optional int32 number = 3; - if (has_number()) { - total_size += 1 + - ::google::protobuf::internal::WireFormatLite::Int32Size( - this->number()); - } - - // optional .google.protobuf.FieldDescriptorProto.Label label = 4; - if (has_label()) { - total_size += 1 + - ::google::protobuf::internal::WireFormatLite::EnumSize(this->label()); - } - - // optional .google.protobuf.FieldDescriptorProto.Type type = 5; - if (has_type()) { - total_size += 1 + - ::google::protobuf::internal::WireFormatLite::EnumSize(this->type()); - } - - // optional string type_name = 6; - if (has_type_name()) { - total_size += 1 + - ::google::protobuf::internal::WireFormatLite::StringSize( - this->type_name()); - } - - // optional string extendee = 2; - if (has_extendee()) { - total_size += 1 + - ::google::protobuf::internal::WireFormatLite::StringSize( - this->extendee()); - } - - // optional string default_value = 7; - if (has_default_value()) { - total_size += 1 + - ::google::protobuf::internal::WireFormatLite::StringSize( - this->default_value()); - } - - // optional .google.protobuf.FieldOptions options = 8; - if (has_options()) { - total_size += 1 + - ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( - this->options()); - } - - } - if (!unknown_fields().empty()) { - total_size += - ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( - unknown_fields()); - } - GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); - _cached_size_ = total_size; - GOOGLE_SAFE_CONCURRENT_WRITES_END(); - return total_size; -} - -void FieldDescriptorProto::MergeFrom(const ::google::protobuf::Message& from) { - GOOGLE_CHECK_NE(&from, this); - const FieldDescriptorProto* source = - ::google::protobuf::internal::dynamic_cast_if_available( - &from); - if (source == NULL) { - ::google::protobuf::internal::ReflectionOps::Merge(from, this); - } else { - MergeFrom(*source); - } -} - -void FieldDescriptorProto::MergeFrom(const FieldDescriptorProto& from) { - GOOGLE_CHECK_NE(&from, this); - if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) { - if (from.has_name()) { - set_name(from.name()); - } - if (from.has_number()) { - set_number(from.number()); - } - if (from.has_label()) { - set_label(from.label()); - } - if (from.has_type()) { - set_type(from.type()); - } - if (from.has_type_name()) { - set_type_name(from.type_name()); - } - if (from.has_extendee()) { - set_extendee(from.extendee()); - } - if (from.has_default_value()) { - set_default_value(from.default_value()); - } - if (from.has_options()) { - mutable_options()->::google::protobuf::FieldOptions::MergeFrom(from.options()); - } - } - mutable_unknown_fields()->MergeFrom(from.unknown_fields()); -} - -void FieldDescriptorProto::CopyFrom(const ::google::protobuf::Message& from) { - if (&from == this) return; - Clear(); - MergeFrom(from); -} - -void FieldDescriptorProto::CopyFrom(const FieldDescriptorProto& from) { - if (&from == this) return; - Clear(); - MergeFrom(from); -} - -bool FieldDescriptorProto::IsInitialized() const { - - if (has_options()) { - if (!this->options().IsInitialized()) return false; - } - return true; -} - -void FieldDescriptorProto::Swap(FieldDescriptorProto* other) { - if (other != this) { - std::swap(name_, other->name_); - std::swap(number_, other->number_); - std::swap(label_, other->label_); - std::swap(type_, other->type_); - std::swap(type_name_, other->type_name_); - std::swap(extendee_, other->extendee_); - std::swap(default_value_, other->default_value_); - std::swap(options_, other->options_); - std::swap(_has_bits_[0], other->_has_bits_[0]); - _unknown_fields_.Swap(&other->_unknown_fields_); - std::swap(_cached_size_, other->_cached_size_); - } -} - -::google::protobuf::Metadata FieldDescriptorProto::GetMetadata() const { - protobuf_AssignDescriptorsOnce(); - ::google::protobuf::Metadata metadata; - metadata.descriptor = FieldDescriptorProto_descriptor_; - metadata.reflection = FieldDescriptorProto_reflection_; - return metadata; -} - - -// =================================================================== - -#ifndef _MSC_VER -const int EnumDescriptorProto::kNameFieldNumber; -const int EnumDescriptorProto::kValueFieldNumber; -const int EnumDescriptorProto::kOptionsFieldNumber; -#endif // !_MSC_VER - -EnumDescriptorProto::EnumDescriptorProto() - : ::google::protobuf::Message() { - SharedCtor(); -} - -void EnumDescriptorProto::InitAsDefaultInstance() { - options_ = const_cast< ::google::protobuf::EnumOptions*>(&::google::protobuf::EnumOptions::default_instance()); -} - -EnumDescriptorProto::EnumDescriptorProto(const EnumDescriptorProto& from) - : ::google::protobuf::Message() { - SharedCtor(); - MergeFrom(from); -} - -void EnumDescriptorProto::SharedCtor() { - _cached_size_ = 0; - name_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); - options_ = NULL; - ::memset(_has_bits_, 0, sizeof(_has_bits_)); -} - -EnumDescriptorProto::~EnumDescriptorProto() { - SharedDtor(); -} - -void EnumDescriptorProto::SharedDtor() { - if (name_ != &::google::protobuf::internal::kEmptyString) { - delete name_; - } - if (this != default_instance_) { - delete options_; - } -} - -void EnumDescriptorProto::SetCachedSize(int size) const { - GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); - _cached_size_ = size; - GOOGLE_SAFE_CONCURRENT_WRITES_END(); -} -const ::google::protobuf::Descriptor* EnumDescriptorProto::descriptor() { - protobuf_AssignDescriptorsOnce(); - return EnumDescriptorProto_descriptor_; -} - -const EnumDescriptorProto& EnumDescriptorProto::default_instance() { - if (default_instance_ == NULL) protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto(); - return *default_instance_; -} - -EnumDescriptorProto* EnumDescriptorProto::default_instance_ = NULL; - -EnumDescriptorProto* EnumDescriptorProto::New() const { - return new EnumDescriptorProto; -} - -void EnumDescriptorProto::Clear() { - if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) { - if (has_name()) { - if (name_ != &::google::protobuf::internal::kEmptyString) { - name_->clear(); - } - } - if (has_options()) { - if (options_ != NULL) options_->::google::protobuf::EnumOptions::Clear(); - } - } - value_.Clear(); - ::memset(_has_bits_, 0, sizeof(_has_bits_)); - mutable_unknown_fields()->Clear(); -} - -bool EnumDescriptorProto::MergePartialFromCodedStream( - ::google::protobuf::io::CodedInputStream* input) { -#define DO_(EXPRESSION) if (!(EXPRESSION)) return false - ::google::protobuf::uint32 tag; - while ((tag = input->ReadTag()) != 0) { - switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { - // optional string name = 1; - case 1: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) { - DO_(::google::protobuf::internal::WireFormatLite::ReadString( - input, this->mutable_name())); - ::google::protobuf::internal::WireFormat::VerifyUTF8String( - this->name().data(), this->name().length(), - ::google::protobuf::internal::WireFormat::PARSE); - } else { - goto handle_uninterpreted; - } - if (input->ExpectTag(18)) goto parse_value; - break; - } - - // repeated .google.protobuf.EnumValueDescriptorProto value = 2; - case 2: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) { - parse_value: - DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual( - input, add_value())); - } else { - goto handle_uninterpreted; - } - if (input->ExpectTag(18)) goto parse_value; - if (input->ExpectTag(26)) goto parse_options; - break; - } - - // optional .google.protobuf.EnumOptions options = 3; - case 3: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) { - parse_options: - DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual( - input, mutable_options())); - } else { - goto handle_uninterpreted; - } - if (input->ExpectAtEnd()) return true; - break; - } - - default: { - handle_uninterpreted: - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) { - return true; - } - DO_(::google::protobuf::internal::WireFormat::SkipField( - input, tag, mutable_unknown_fields())); - break; - } - } - } - return true; -#undef DO_ -} - -void EnumDescriptorProto::SerializeWithCachedSizes( - ::google::protobuf::io::CodedOutputStream* output) const { - // optional string name = 1; - if (has_name()) { - ::google::protobuf::internal::WireFormat::VerifyUTF8String( - this->name().data(), this->name().length(), - ::google::protobuf::internal::WireFormat::SERIALIZE); - ::google::protobuf::internal::WireFormatLite::WriteString( - 1, this->name(), output); - } - - // repeated .google.protobuf.EnumValueDescriptorProto value = 2; - for (int i = 0; i < this->value_size(); i++) { - ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( - 2, this->value(i), output); - } - - // optional .google.protobuf.EnumOptions options = 3; - if (has_options()) { - ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( - 3, this->options(), output); - } - - if (!unknown_fields().empty()) { - ::google::protobuf::internal::WireFormat::SerializeUnknownFields( - unknown_fields(), output); - } -} - -::google::protobuf::uint8* EnumDescriptorProto::SerializeWithCachedSizesToArray( - ::google::protobuf::uint8* target) const { - // optional string name = 1; - if (has_name()) { - ::google::protobuf::internal::WireFormat::VerifyUTF8String( - this->name().data(), this->name().length(), - ::google::protobuf::internal::WireFormat::SERIALIZE); - target = - ::google::protobuf::internal::WireFormatLite::WriteStringToArray( - 1, this->name(), target); - } - - // repeated .google.protobuf.EnumValueDescriptorProto value = 2; - for (int i = 0; i < this->value_size(); i++) { - target = ::google::protobuf::internal::WireFormatLite:: - WriteMessageNoVirtualToArray( - 2, this->value(i), target); - } - - // optional .google.protobuf.EnumOptions options = 3; - if (has_options()) { - target = ::google::protobuf::internal::WireFormatLite:: - WriteMessageNoVirtualToArray( - 3, this->options(), target); - } - - if (!unknown_fields().empty()) { - target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray( - unknown_fields(), target); - } - return target; -} - -int EnumDescriptorProto::ByteSize() const { - int total_size = 0; - - if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) { - // optional string name = 1; - if (has_name()) { - total_size += 1 + - ::google::protobuf::internal::WireFormatLite::StringSize( - this->name()); - } - - // optional .google.protobuf.EnumOptions options = 3; - if (has_options()) { - total_size += 1 + - ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( - this->options()); - } - - } - // repeated .google.protobuf.EnumValueDescriptorProto value = 2; - total_size += 1 * this->value_size(); - for (int i = 0; i < this->value_size(); i++) { - total_size += - ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( - this->value(i)); - } - - if (!unknown_fields().empty()) { - total_size += - ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( - unknown_fields()); - } - GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); - _cached_size_ = total_size; - GOOGLE_SAFE_CONCURRENT_WRITES_END(); - return total_size; -} - -void EnumDescriptorProto::MergeFrom(const ::google::protobuf::Message& from) { - GOOGLE_CHECK_NE(&from, this); - const EnumDescriptorProto* source = - ::google::protobuf::internal::dynamic_cast_if_available( - &from); - if (source == NULL) { - ::google::protobuf::internal::ReflectionOps::Merge(from, this); - } else { - MergeFrom(*source); - } -} - -void EnumDescriptorProto::MergeFrom(const EnumDescriptorProto& from) { - GOOGLE_CHECK_NE(&from, this); - value_.MergeFrom(from.value_); - if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) { - if (from.has_name()) { - set_name(from.name()); - } - if (from.has_options()) { - mutable_options()->::google::protobuf::EnumOptions::MergeFrom(from.options()); - } - } - mutable_unknown_fields()->MergeFrom(from.unknown_fields()); -} - -void EnumDescriptorProto::CopyFrom(const ::google::protobuf::Message& from) { - if (&from == this) return; - Clear(); - MergeFrom(from); -} - -void EnumDescriptorProto::CopyFrom(const EnumDescriptorProto& from) { - if (&from == this) return; - Clear(); - MergeFrom(from); -} - -bool EnumDescriptorProto::IsInitialized() const { - - for (int i = 0; i < value_size(); i++) { - if (!this->value(i).IsInitialized()) return false; - } - if (has_options()) { - if (!this->options().IsInitialized()) return false; - } - return true; -} - -void EnumDescriptorProto::Swap(EnumDescriptorProto* other) { - if (other != this) { - std::swap(name_, other->name_); - value_.Swap(&other->value_); - std::swap(options_, other->options_); - std::swap(_has_bits_[0], other->_has_bits_[0]); - _unknown_fields_.Swap(&other->_unknown_fields_); - std::swap(_cached_size_, other->_cached_size_); - } -} - -::google::protobuf::Metadata EnumDescriptorProto::GetMetadata() const { - protobuf_AssignDescriptorsOnce(); - ::google::protobuf::Metadata metadata; - metadata.descriptor = EnumDescriptorProto_descriptor_; - metadata.reflection = EnumDescriptorProto_reflection_; - return metadata; -} - - -// =================================================================== - -#ifndef _MSC_VER -const int EnumValueDescriptorProto::kNameFieldNumber; -const int EnumValueDescriptorProto::kNumberFieldNumber; -const int EnumValueDescriptorProto::kOptionsFieldNumber; -#endif // !_MSC_VER - -EnumValueDescriptorProto::EnumValueDescriptorProto() - : ::google::protobuf::Message() { - SharedCtor(); -} - -void EnumValueDescriptorProto::InitAsDefaultInstance() { - options_ = const_cast< ::google::protobuf::EnumValueOptions*>(&::google::protobuf::EnumValueOptions::default_instance()); -} - -EnumValueDescriptorProto::EnumValueDescriptorProto(const EnumValueDescriptorProto& from) - : ::google::protobuf::Message() { - SharedCtor(); - MergeFrom(from); -} - -void EnumValueDescriptorProto::SharedCtor() { - _cached_size_ = 0; - name_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); - number_ = 0; - options_ = NULL; - ::memset(_has_bits_, 0, sizeof(_has_bits_)); -} - -EnumValueDescriptorProto::~EnumValueDescriptorProto() { - SharedDtor(); -} - -void EnumValueDescriptorProto::SharedDtor() { - if (name_ != &::google::protobuf::internal::kEmptyString) { - delete name_; - } - if (this != default_instance_) { - delete options_; - } -} - -void EnumValueDescriptorProto::SetCachedSize(int size) const { - GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); - _cached_size_ = size; - GOOGLE_SAFE_CONCURRENT_WRITES_END(); -} -const ::google::protobuf::Descriptor* EnumValueDescriptorProto::descriptor() { - protobuf_AssignDescriptorsOnce(); - return EnumValueDescriptorProto_descriptor_; -} - -const EnumValueDescriptorProto& EnumValueDescriptorProto::default_instance() { - if (default_instance_ == NULL) protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto(); - return *default_instance_; -} - -EnumValueDescriptorProto* EnumValueDescriptorProto::default_instance_ = NULL; - -EnumValueDescriptorProto* EnumValueDescriptorProto::New() const { - return new EnumValueDescriptorProto; -} - -void EnumValueDescriptorProto::Clear() { - if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) { - if (has_name()) { - if (name_ != &::google::protobuf::internal::kEmptyString) { - name_->clear(); - } - } - number_ = 0; - if (has_options()) { - if (options_ != NULL) options_->::google::protobuf::EnumValueOptions::Clear(); - } - } - ::memset(_has_bits_, 0, sizeof(_has_bits_)); - mutable_unknown_fields()->Clear(); -} - -bool EnumValueDescriptorProto::MergePartialFromCodedStream( - ::google::protobuf::io::CodedInputStream* input) { -#define DO_(EXPRESSION) if (!(EXPRESSION)) return false - ::google::protobuf::uint32 tag; - while ((tag = input->ReadTag()) != 0) { - switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { - // optional string name = 1; - case 1: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) { - DO_(::google::protobuf::internal::WireFormatLite::ReadString( - input, this->mutable_name())); - ::google::protobuf::internal::WireFormat::VerifyUTF8String( - this->name().data(), this->name().length(), - ::google::protobuf::internal::WireFormat::PARSE); - } else { - goto handle_uninterpreted; - } - if (input->ExpectTag(16)) goto parse_number; - break; - } - - // optional int32 number = 2; - case 2: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) { - parse_number: - DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< - ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>( - input, &number_))); - set_has_number(); - } else { - goto handle_uninterpreted; - } - if (input->ExpectTag(26)) goto parse_options; - break; - } - - // optional .google.protobuf.EnumValueOptions options = 3; - case 3: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) { - parse_options: - DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual( - input, mutable_options())); - } else { - goto handle_uninterpreted; - } - if (input->ExpectAtEnd()) return true; - break; - } - - default: { - handle_uninterpreted: - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) { - return true; - } - DO_(::google::protobuf::internal::WireFormat::SkipField( - input, tag, mutable_unknown_fields())); - break; - } - } - } - return true; -#undef DO_ -} - -void EnumValueDescriptorProto::SerializeWithCachedSizes( - ::google::protobuf::io::CodedOutputStream* output) const { - // optional string name = 1; - if (has_name()) { - ::google::protobuf::internal::WireFormat::VerifyUTF8String( - this->name().data(), this->name().length(), - ::google::protobuf::internal::WireFormat::SERIALIZE); - ::google::protobuf::internal::WireFormatLite::WriteString( - 1, this->name(), output); - } - - // optional int32 number = 2; - if (has_number()) { - ::google::protobuf::internal::WireFormatLite::WriteInt32(2, this->number(), output); - } - - // optional .google.protobuf.EnumValueOptions options = 3; - if (has_options()) { - ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( - 3, this->options(), output); - } - - if (!unknown_fields().empty()) { - ::google::protobuf::internal::WireFormat::SerializeUnknownFields( - unknown_fields(), output); - } -} - -::google::protobuf::uint8* EnumValueDescriptorProto::SerializeWithCachedSizesToArray( - ::google::protobuf::uint8* target) const { - // optional string name = 1; - if (has_name()) { - ::google::protobuf::internal::WireFormat::VerifyUTF8String( - this->name().data(), this->name().length(), - ::google::protobuf::internal::WireFormat::SERIALIZE); - target = - ::google::protobuf::internal::WireFormatLite::WriteStringToArray( - 1, this->name(), target); - } - - // optional int32 number = 2; - if (has_number()) { - target = ::google::protobuf::internal::WireFormatLite::WriteInt32ToArray(2, this->number(), target); - } - - // optional .google.protobuf.EnumValueOptions options = 3; - if (has_options()) { - target = ::google::protobuf::internal::WireFormatLite:: - WriteMessageNoVirtualToArray( - 3, this->options(), target); - } - - if (!unknown_fields().empty()) { - target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray( - unknown_fields(), target); - } - return target; -} - -int EnumValueDescriptorProto::ByteSize() const { - int total_size = 0; - - if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) { - // optional string name = 1; - if (has_name()) { - total_size += 1 + - ::google::protobuf::internal::WireFormatLite::StringSize( - this->name()); - } - - // optional int32 number = 2; - if (has_number()) { - total_size += 1 + - ::google::protobuf::internal::WireFormatLite::Int32Size( - this->number()); - } - - // optional .google.protobuf.EnumValueOptions options = 3; - if (has_options()) { - total_size += 1 + - ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( - this->options()); - } - - } - if (!unknown_fields().empty()) { - total_size += - ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( - unknown_fields()); - } - GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); - _cached_size_ = total_size; - GOOGLE_SAFE_CONCURRENT_WRITES_END(); - return total_size; -} - -void EnumValueDescriptorProto::MergeFrom(const ::google::protobuf::Message& from) { - GOOGLE_CHECK_NE(&from, this); - const EnumValueDescriptorProto* source = - ::google::protobuf::internal::dynamic_cast_if_available( - &from); - if (source == NULL) { - ::google::protobuf::internal::ReflectionOps::Merge(from, this); - } else { - MergeFrom(*source); - } -} - -void EnumValueDescriptorProto::MergeFrom(const EnumValueDescriptorProto& from) { - GOOGLE_CHECK_NE(&from, this); - if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) { - if (from.has_name()) { - set_name(from.name()); - } - if (from.has_number()) { - set_number(from.number()); - } - if (from.has_options()) { - mutable_options()->::google::protobuf::EnumValueOptions::MergeFrom(from.options()); - } - } - mutable_unknown_fields()->MergeFrom(from.unknown_fields()); -} - -void EnumValueDescriptorProto::CopyFrom(const ::google::protobuf::Message& from) { - if (&from == this) return; - Clear(); - MergeFrom(from); -} - -void EnumValueDescriptorProto::CopyFrom(const EnumValueDescriptorProto& from) { - if (&from == this) return; - Clear(); - MergeFrom(from); -} - -bool EnumValueDescriptorProto::IsInitialized() const { - - if (has_options()) { - if (!this->options().IsInitialized()) return false; - } - return true; -} - -void EnumValueDescriptorProto::Swap(EnumValueDescriptorProto* other) { - if (other != this) { - std::swap(name_, other->name_); - std::swap(number_, other->number_); - std::swap(options_, other->options_); - std::swap(_has_bits_[0], other->_has_bits_[0]); - _unknown_fields_.Swap(&other->_unknown_fields_); - std::swap(_cached_size_, other->_cached_size_); - } -} - -::google::protobuf::Metadata EnumValueDescriptorProto::GetMetadata() const { - protobuf_AssignDescriptorsOnce(); - ::google::protobuf::Metadata metadata; - metadata.descriptor = EnumValueDescriptorProto_descriptor_; - metadata.reflection = EnumValueDescriptorProto_reflection_; - return metadata; -} - - -// =================================================================== - -#ifndef _MSC_VER -const int ServiceDescriptorProto::kNameFieldNumber; -const int ServiceDescriptorProto::kMethodFieldNumber; -const int ServiceDescriptorProto::kOptionsFieldNumber; -#endif // !_MSC_VER - -ServiceDescriptorProto::ServiceDescriptorProto() - : ::google::protobuf::Message() { - SharedCtor(); -} - -void ServiceDescriptorProto::InitAsDefaultInstance() { - options_ = const_cast< ::google::protobuf::ServiceOptions*>(&::google::protobuf::ServiceOptions::default_instance()); -} - -ServiceDescriptorProto::ServiceDescriptorProto(const ServiceDescriptorProto& from) - : ::google::protobuf::Message() { - SharedCtor(); - MergeFrom(from); -} - -void ServiceDescriptorProto::SharedCtor() { - _cached_size_ = 0; - name_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); - options_ = NULL; - ::memset(_has_bits_, 0, sizeof(_has_bits_)); -} - -ServiceDescriptorProto::~ServiceDescriptorProto() { - SharedDtor(); -} - -void ServiceDescriptorProto::SharedDtor() { - if (name_ != &::google::protobuf::internal::kEmptyString) { - delete name_; - } - if (this != default_instance_) { - delete options_; - } -} - -void ServiceDescriptorProto::SetCachedSize(int size) const { - GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); - _cached_size_ = size; - GOOGLE_SAFE_CONCURRENT_WRITES_END(); -} -const ::google::protobuf::Descriptor* ServiceDescriptorProto::descriptor() { - protobuf_AssignDescriptorsOnce(); - return ServiceDescriptorProto_descriptor_; -} - -const ServiceDescriptorProto& ServiceDescriptorProto::default_instance() { - if (default_instance_ == NULL) protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto(); - return *default_instance_; -} - -ServiceDescriptorProto* ServiceDescriptorProto::default_instance_ = NULL; - -ServiceDescriptorProto* ServiceDescriptorProto::New() const { - return new ServiceDescriptorProto; -} - -void ServiceDescriptorProto::Clear() { - if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) { - if (has_name()) { - if (name_ != &::google::protobuf::internal::kEmptyString) { - name_->clear(); - } - } - if (has_options()) { - if (options_ != NULL) options_->::google::protobuf::ServiceOptions::Clear(); - } - } - method_.Clear(); - ::memset(_has_bits_, 0, sizeof(_has_bits_)); - mutable_unknown_fields()->Clear(); -} - -bool ServiceDescriptorProto::MergePartialFromCodedStream( - ::google::protobuf::io::CodedInputStream* input) { -#define DO_(EXPRESSION) if (!(EXPRESSION)) return false - ::google::protobuf::uint32 tag; - while ((tag = input->ReadTag()) != 0) { - switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { - // optional string name = 1; - case 1: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) { - DO_(::google::protobuf::internal::WireFormatLite::ReadString( - input, this->mutable_name())); - ::google::protobuf::internal::WireFormat::VerifyUTF8String( - this->name().data(), this->name().length(), - ::google::protobuf::internal::WireFormat::PARSE); - } else { - goto handle_uninterpreted; - } - if (input->ExpectTag(18)) goto parse_method; - break; - } - - // repeated .google.protobuf.MethodDescriptorProto method = 2; - case 2: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) { - parse_method: - DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual( - input, add_method())); - } else { - goto handle_uninterpreted; - } - if (input->ExpectTag(18)) goto parse_method; - if (input->ExpectTag(26)) goto parse_options; - break; - } - - // optional .google.protobuf.ServiceOptions options = 3; - case 3: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) { - parse_options: - DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual( - input, mutable_options())); - } else { - goto handle_uninterpreted; - } - if (input->ExpectAtEnd()) return true; - break; - } - - default: { - handle_uninterpreted: - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) { - return true; - } - DO_(::google::protobuf::internal::WireFormat::SkipField( - input, tag, mutable_unknown_fields())); - break; - } - } - } - return true; -#undef DO_ -} - -void ServiceDescriptorProto::SerializeWithCachedSizes( - ::google::protobuf::io::CodedOutputStream* output) const { - // optional string name = 1; - if (has_name()) { - ::google::protobuf::internal::WireFormat::VerifyUTF8String( - this->name().data(), this->name().length(), - ::google::protobuf::internal::WireFormat::SERIALIZE); - ::google::protobuf::internal::WireFormatLite::WriteString( - 1, this->name(), output); - } - - // repeated .google.protobuf.MethodDescriptorProto method = 2; - for (int i = 0; i < this->method_size(); i++) { - ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( - 2, this->method(i), output); - } - - // optional .google.protobuf.ServiceOptions options = 3; - if (has_options()) { - ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( - 3, this->options(), output); - } - - if (!unknown_fields().empty()) { - ::google::protobuf::internal::WireFormat::SerializeUnknownFields( - unknown_fields(), output); - } -} - -::google::protobuf::uint8* ServiceDescriptorProto::SerializeWithCachedSizesToArray( - ::google::protobuf::uint8* target) const { - // optional string name = 1; - if (has_name()) { - ::google::protobuf::internal::WireFormat::VerifyUTF8String( - this->name().data(), this->name().length(), - ::google::protobuf::internal::WireFormat::SERIALIZE); - target = - ::google::protobuf::internal::WireFormatLite::WriteStringToArray( - 1, this->name(), target); - } - - // repeated .google.protobuf.MethodDescriptorProto method = 2; - for (int i = 0; i < this->method_size(); i++) { - target = ::google::protobuf::internal::WireFormatLite:: - WriteMessageNoVirtualToArray( - 2, this->method(i), target); - } - - // optional .google.protobuf.ServiceOptions options = 3; - if (has_options()) { - target = ::google::protobuf::internal::WireFormatLite:: - WriteMessageNoVirtualToArray( - 3, this->options(), target); - } - - if (!unknown_fields().empty()) { - target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray( - unknown_fields(), target); - } - return target; -} - -int ServiceDescriptorProto::ByteSize() const { - int total_size = 0; - - if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) { - // optional string name = 1; - if (has_name()) { - total_size += 1 + - ::google::protobuf::internal::WireFormatLite::StringSize( - this->name()); - } - - // optional .google.protobuf.ServiceOptions options = 3; - if (has_options()) { - total_size += 1 + - ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( - this->options()); - } - - } - // repeated .google.protobuf.MethodDescriptorProto method = 2; - total_size += 1 * this->method_size(); - for (int i = 0; i < this->method_size(); i++) { - total_size += - ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( - this->method(i)); - } - - if (!unknown_fields().empty()) { - total_size += - ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( - unknown_fields()); - } - GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); - _cached_size_ = total_size; - GOOGLE_SAFE_CONCURRENT_WRITES_END(); - return total_size; -} - -void ServiceDescriptorProto::MergeFrom(const ::google::protobuf::Message& from) { - GOOGLE_CHECK_NE(&from, this); - const ServiceDescriptorProto* source = - ::google::protobuf::internal::dynamic_cast_if_available( - &from); - if (source == NULL) { - ::google::protobuf::internal::ReflectionOps::Merge(from, this); - } else { - MergeFrom(*source); - } -} - -void ServiceDescriptorProto::MergeFrom(const ServiceDescriptorProto& from) { - GOOGLE_CHECK_NE(&from, this); - method_.MergeFrom(from.method_); - if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) { - if (from.has_name()) { - set_name(from.name()); - } - if (from.has_options()) { - mutable_options()->::google::protobuf::ServiceOptions::MergeFrom(from.options()); - } - } - mutable_unknown_fields()->MergeFrom(from.unknown_fields()); -} - -void ServiceDescriptorProto::CopyFrom(const ::google::protobuf::Message& from) { - if (&from == this) return; - Clear(); - MergeFrom(from); -} - -void ServiceDescriptorProto::CopyFrom(const ServiceDescriptorProto& from) { - if (&from == this) return; - Clear(); - MergeFrom(from); -} - -bool ServiceDescriptorProto::IsInitialized() const { - - for (int i = 0; i < method_size(); i++) { - if (!this->method(i).IsInitialized()) return false; - } - if (has_options()) { - if (!this->options().IsInitialized()) return false; - } - return true; -} - -void ServiceDescriptorProto::Swap(ServiceDescriptorProto* other) { - if (other != this) { - std::swap(name_, other->name_); - method_.Swap(&other->method_); - std::swap(options_, other->options_); - std::swap(_has_bits_[0], other->_has_bits_[0]); - _unknown_fields_.Swap(&other->_unknown_fields_); - std::swap(_cached_size_, other->_cached_size_); - } -} - -::google::protobuf::Metadata ServiceDescriptorProto::GetMetadata() const { - protobuf_AssignDescriptorsOnce(); - ::google::protobuf::Metadata metadata; - metadata.descriptor = ServiceDescriptorProto_descriptor_; - metadata.reflection = ServiceDescriptorProto_reflection_; - return metadata; -} - - -// =================================================================== - -#ifndef _MSC_VER -const int MethodDescriptorProto::kNameFieldNumber; -const int MethodDescriptorProto::kInputTypeFieldNumber; -const int MethodDescriptorProto::kOutputTypeFieldNumber; -const int MethodDescriptorProto::kOptionsFieldNumber; -#endif // !_MSC_VER - -MethodDescriptorProto::MethodDescriptorProto() - : ::google::protobuf::Message() { - SharedCtor(); -} - -void MethodDescriptorProto::InitAsDefaultInstance() { - options_ = const_cast< ::google::protobuf::MethodOptions*>(&::google::protobuf::MethodOptions::default_instance()); -} - -MethodDescriptorProto::MethodDescriptorProto(const MethodDescriptorProto& from) - : ::google::protobuf::Message() { - SharedCtor(); - MergeFrom(from); -} - -void MethodDescriptorProto::SharedCtor() { - _cached_size_ = 0; - name_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); - input_type_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); - output_type_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); - options_ = NULL; - ::memset(_has_bits_, 0, sizeof(_has_bits_)); -} - -MethodDescriptorProto::~MethodDescriptorProto() { - SharedDtor(); -} - -void MethodDescriptorProto::SharedDtor() { - if (name_ != &::google::protobuf::internal::kEmptyString) { - delete name_; - } - if (input_type_ != &::google::protobuf::internal::kEmptyString) { - delete input_type_; - } - if (output_type_ != &::google::protobuf::internal::kEmptyString) { - delete output_type_; - } - if (this != default_instance_) { - delete options_; - } -} - -void MethodDescriptorProto::SetCachedSize(int size) const { - GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); - _cached_size_ = size; - GOOGLE_SAFE_CONCURRENT_WRITES_END(); -} -const ::google::protobuf::Descriptor* MethodDescriptorProto::descriptor() { - protobuf_AssignDescriptorsOnce(); - return MethodDescriptorProto_descriptor_; -} - -const MethodDescriptorProto& MethodDescriptorProto::default_instance() { - if (default_instance_ == NULL) protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto(); - return *default_instance_; -} - -MethodDescriptorProto* MethodDescriptorProto::default_instance_ = NULL; - -MethodDescriptorProto* MethodDescriptorProto::New() const { - return new MethodDescriptorProto; -} - -void MethodDescriptorProto::Clear() { - if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) { - if (has_name()) { - if (name_ != &::google::protobuf::internal::kEmptyString) { - name_->clear(); - } - } - if (has_input_type()) { - if (input_type_ != &::google::protobuf::internal::kEmptyString) { - input_type_->clear(); - } - } - if (has_output_type()) { - if (output_type_ != &::google::protobuf::internal::kEmptyString) { - output_type_->clear(); - } - } - if (has_options()) { - if (options_ != NULL) options_->::google::protobuf::MethodOptions::Clear(); - } - } - ::memset(_has_bits_, 0, sizeof(_has_bits_)); - mutable_unknown_fields()->Clear(); -} - -bool MethodDescriptorProto::MergePartialFromCodedStream( - ::google::protobuf::io::CodedInputStream* input) { -#define DO_(EXPRESSION) if (!(EXPRESSION)) return false - ::google::protobuf::uint32 tag; - while ((tag = input->ReadTag()) != 0) { - switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { - // optional string name = 1; - case 1: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) { - DO_(::google::protobuf::internal::WireFormatLite::ReadString( - input, this->mutable_name())); - ::google::protobuf::internal::WireFormat::VerifyUTF8String( - this->name().data(), this->name().length(), - ::google::protobuf::internal::WireFormat::PARSE); - } else { - goto handle_uninterpreted; - } - if (input->ExpectTag(18)) goto parse_input_type; - break; - } - - // optional string input_type = 2; - case 2: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) { - parse_input_type: - DO_(::google::protobuf::internal::WireFormatLite::ReadString( - input, this->mutable_input_type())); - ::google::protobuf::internal::WireFormat::VerifyUTF8String( - this->input_type().data(), this->input_type().length(), - ::google::protobuf::internal::WireFormat::PARSE); - } else { - goto handle_uninterpreted; - } - if (input->ExpectTag(26)) goto parse_output_type; - break; - } - - // optional string output_type = 3; - case 3: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) { - parse_output_type: - DO_(::google::protobuf::internal::WireFormatLite::ReadString( - input, this->mutable_output_type())); - ::google::protobuf::internal::WireFormat::VerifyUTF8String( - this->output_type().data(), this->output_type().length(), - ::google::protobuf::internal::WireFormat::PARSE); - } else { - goto handle_uninterpreted; - } - if (input->ExpectTag(34)) goto parse_options; - break; - } - - // optional .google.protobuf.MethodOptions options = 4; - case 4: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) { - parse_options: - DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual( - input, mutable_options())); - } else { - goto handle_uninterpreted; - } - if (input->ExpectAtEnd()) return true; - break; - } - - default: { - handle_uninterpreted: - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) { - return true; - } - DO_(::google::protobuf::internal::WireFormat::SkipField( - input, tag, mutable_unknown_fields())); - break; - } - } - } - return true; -#undef DO_ -} - -void MethodDescriptorProto::SerializeWithCachedSizes( - ::google::protobuf::io::CodedOutputStream* output) const { - // optional string name = 1; - if (has_name()) { - ::google::protobuf::internal::WireFormat::VerifyUTF8String( - this->name().data(), this->name().length(), - ::google::protobuf::internal::WireFormat::SERIALIZE); - ::google::protobuf::internal::WireFormatLite::WriteString( - 1, this->name(), output); - } - - // optional string input_type = 2; - if (has_input_type()) { - ::google::protobuf::internal::WireFormat::VerifyUTF8String( - this->input_type().data(), this->input_type().length(), - ::google::protobuf::internal::WireFormat::SERIALIZE); - ::google::protobuf::internal::WireFormatLite::WriteString( - 2, this->input_type(), output); - } - - // optional string output_type = 3; - if (has_output_type()) { - ::google::protobuf::internal::WireFormat::VerifyUTF8String( - this->output_type().data(), this->output_type().length(), - ::google::protobuf::internal::WireFormat::SERIALIZE); - ::google::protobuf::internal::WireFormatLite::WriteString( - 3, this->output_type(), output); - } - - // optional .google.protobuf.MethodOptions options = 4; - if (has_options()) { - ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( - 4, this->options(), output); - } - - if (!unknown_fields().empty()) { - ::google::protobuf::internal::WireFormat::SerializeUnknownFields( - unknown_fields(), output); - } -} - -::google::protobuf::uint8* MethodDescriptorProto::SerializeWithCachedSizesToArray( - ::google::protobuf::uint8* target) const { - // optional string name = 1; - if (has_name()) { - ::google::protobuf::internal::WireFormat::VerifyUTF8String( - this->name().data(), this->name().length(), - ::google::protobuf::internal::WireFormat::SERIALIZE); - target = - ::google::protobuf::internal::WireFormatLite::WriteStringToArray( - 1, this->name(), target); - } - - // optional string input_type = 2; - if (has_input_type()) { - ::google::protobuf::internal::WireFormat::VerifyUTF8String( - this->input_type().data(), this->input_type().length(), - ::google::protobuf::internal::WireFormat::SERIALIZE); - target = - ::google::protobuf::internal::WireFormatLite::WriteStringToArray( - 2, this->input_type(), target); - } - - // optional string output_type = 3; - if (has_output_type()) { - ::google::protobuf::internal::WireFormat::VerifyUTF8String( - this->output_type().data(), this->output_type().length(), - ::google::protobuf::internal::WireFormat::SERIALIZE); - target = - ::google::protobuf::internal::WireFormatLite::WriteStringToArray( - 3, this->output_type(), target); - } - - // optional .google.protobuf.MethodOptions options = 4; - if (has_options()) { - target = ::google::protobuf::internal::WireFormatLite:: - WriteMessageNoVirtualToArray( - 4, this->options(), target); - } - - if (!unknown_fields().empty()) { - target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray( - unknown_fields(), target); - } - return target; -} - -int MethodDescriptorProto::ByteSize() const { - int total_size = 0; - - if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) { - // optional string name = 1; - if (has_name()) { - total_size += 1 + - ::google::protobuf::internal::WireFormatLite::StringSize( - this->name()); - } - - // optional string input_type = 2; - if (has_input_type()) { - total_size += 1 + - ::google::protobuf::internal::WireFormatLite::StringSize( - this->input_type()); - } - - // optional string output_type = 3; - if (has_output_type()) { - total_size += 1 + - ::google::protobuf::internal::WireFormatLite::StringSize( - this->output_type()); - } - - // optional .google.protobuf.MethodOptions options = 4; - if (has_options()) { - total_size += 1 + - ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( - this->options()); - } - - } - if (!unknown_fields().empty()) { - total_size += - ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( - unknown_fields()); - } - GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); - _cached_size_ = total_size; - GOOGLE_SAFE_CONCURRENT_WRITES_END(); - return total_size; -} - -void MethodDescriptorProto::MergeFrom(const ::google::protobuf::Message& from) { - GOOGLE_CHECK_NE(&from, this); - const MethodDescriptorProto* source = - ::google::protobuf::internal::dynamic_cast_if_available( - &from); - if (source == NULL) { - ::google::protobuf::internal::ReflectionOps::Merge(from, this); - } else { - MergeFrom(*source); - } -} - -void MethodDescriptorProto::MergeFrom(const MethodDescriptorProto& from) { - GOOGLE_CHECK_NE(&from, this); - if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) { - if (from.has_name()) { - set_name(from.name()); - } - if (from.has_input_type()) { - set_input_type(from.input_type()); - } - if (from.has_output_type()) { - set_output_type(from.output_type()); - } - if (from.has_options()) { - mutable_options()->::google::protobuf::MethodOptions::MergeFrom(from.options()); - } - } - mutable_unknown_fields()->MergeFrom(from.unknown_fields()); -} - -void MethodDescriptorProto::CopyFrom(const ::google::protobuf::Message& from) { - if (&from == this) return; - Clear(); - MergeFrom(from); -} - -void MethodDescriptorProto::CopyFrom(const MethodDescriptorProto& from) { - if (&from == this) return; - Clear(); - MergeFrom(from); -} - -bool MethodDescriptorProto::IsInitialized() const { - - if (has_options()) { - if (!this->options().IsInitialized()) return false; - } - return true; -} - -void MethodDescriptorProto::Swap(MethodDescriptorProto* other) { - if (other != this) { - std::swap(name_, other->name_); - std::swap(input_type_, other->input_type_); - std::swap(output_type_, other->output_type_); - std::swap(options_, other->options_); - std::swap(_has_bits_[0], other->_has_bits_[0]); - _unknown_fields_.Swap(&other->_unknown_fields_); - std::swap(_cached_size_, other->_cached_size_); - } -} - -::google::protobuf::Metadata MethodDescriptorProto::GetMetadata() const { - protobuf_AssignDescriptorsOnce(); - ::google::protobuf::Metadata metadata; - metadata.descriptor = MethodDescriptorProto_descriptor_; - metadata.reflection = MethodDescriptorProto_reflection_; - return metadata; -} - - -// =================================================================== - -const ::google::protobuf::EnumDescriptor* FileOptions_OptimizeMode_descriptor() { - protobuf_AssignDescriptorsOnce(); - return FileOptions_OptimizeMode_descriptor_; -} -bool FileOptions_OptimizeMode_IsValid(int value) { - switch(value) { - case 1: - case 2: - case 3: - return true; - default: - return false; - } -} - -#ifndef _MSC_VER -const FileOptions_OptimizeMode FileOptions::SPEED; -const FileOptions_OptimizeMode FileOptions::CODE_SIZE; -const FileOptions_OptimizeMode FileOptions::LITE_RUNTIME; -const FileOptions_OptimizeMode FileOptions::OptimizeMode_MIN; -const FileOptions_OptimizeMode FileOptions::OptimizeMode_MAX; -const int FileOptions::OptimizeMode_ARRAYSIZE; -#endif // _MSC_VER -#ifndef _MSC_VER -const int FileOptions::kJavaPackageFieldNumber; -const int FileOptions::kJavaOuterClassnameFieldNumber; -const int FileOptions::kJavaMultipleFilesFieldNumber; -const int FileOptions::kJavaGenerateEqualsAndHashFieldNumber; -const int FileOptions::kOptimizeForFieldNumber; -const int FileOptions::kGoPackageFieldNumber; -const int FileOptions::kCcGenericServicesFieldNumber; -const int FileOptions::kJavaGenericServicesFieldNumber; -const int FileOptions::kPyGenericServicesFieldNumber; -const int FileOptions::kUninterpretedOptionFieldNumber; -#endif // !_MSC_VER - -FileOptions::FileOptions() - : ::google::protobuf::Message() { - SharedCtor(); -} - -void FileOptions::InitAsDefaultInstance() { -} - -FileOptions::FileOptions(const FileOptions& from) - : ::google::protobuf::Message() { - SharedCtor(); - MergeFrom(from); -} - -void FileOptions::SharedCtor() { - _cached_size_ = 0; - java_package_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); - java_outer_classname_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); - java_multiple_files_ = false; - java_generate_equals_and_hash_ = false; - optimize_for_ = 1; - go_package_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); - cc_generic_services_ = false; - java_generic_services_ = false; - py_generic_services_ = false; - ::memset(_has_bits_, 0, sizeof(_has_bits_)); -} - -FileOptions::~FileOptions() { - SharedDtor(); -} - -void FileOptions::SharedDtor() { - if (java_package_ != &::google::protobuf::internal::kEmptyString) { - delete java_package_; - } - if (java_outer_classname_ != &::google::protobuf::internal::kEmptyString) { - delete java_outer_classname_; - } - if (go_package_ != &::google::protobuf::internal::kEmptyString) { - delete go_package_; - } - if (this != default_instance_) { - } -} - -void FileOptions::SetCachedSize(int size) const { - GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); - _cached_size_ = size; - GOOGLE_SAFE_CONCURRENT_WRITES_END(); -} -const ::google::protobuf::Descriptor* FileOptions::descriptor() { - protobuf_AssignDescriptorsOnce(); - return FileOptions_descriptor_; -} - -const FileOptions& FileOptions::default_instance() { - if (default_instance_ == NULL) protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto(); - return *default_instance_; -} - -FileOptions* FileOptions::default_instance_ = NULL; - -FileOptions* FileOptions::New() const { - return new FileOptions; -} - -void FileOptions::Clear() { - _extensions_.Clear(); - if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) { - if (has_java_package()) { - if (java_package_ != &::google::protobuf::internal::kEmptyString) { - java_package_->clear(); - } - } - if (has_java_outer_classname()) { - if (java_outer_classname_ != &::google::protobuf::internal::kEmptyString) { - java_outer_classname_->clear(); - } - } - java_multiple_files_ = false; - java_generate_equals_and_hash_ = false; - optimize_for_ = 1; - if (has_go_package()) { - if (go_package_ != &::google::protobuf::internal::kEmptyString) { - go_package_->clear(); - } - } - cc_generic_services_ = false; - java_generic_services_ = false; - } - if (_has_bits_[8 / 32] & (0xffu << (8 % 32))) { - py_generic_services_ = false; - } - uninterpreted_option_.Clear(); - ::memset(_has_bits_, 0, sizeof(_has_bits_)); - mutable_unknown_fields()->Clear(); -} - -bool FileOptions::MergePartialFromCodedStream( - ::google::protobuf::io::CodedInputStream* input) { -#define DO_(EXPRESSION) if (!(EXPRESSION)) return false - ::google::protobuf::uint32 tag; - while ((tag = input->ReadTag()) != 0) { - switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { - // optional string java_package = 1; - case 1: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) { - DO_(::google::protobuf::internal::WireFormatLite::ReadString( - input, this->mutable_java_package())); - ::google::protobuf::internal::WireFormat::VerifyUTF8String( - this->java_package().data(), this->java_package().length(), - ::google::protobuf::internal::WireFormat::PARSE); - } else { - goto handle_uninterpreted; - } - if (input->ExpectTag(66)) goto parse_java_outer_classname; - break; - } - - // optional string java_outer_classname = 8; - case 8: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) { - parse_java_outer_classname: - DO_(::google::protobuf::internal::WireFormatLite::ReadString( - input, this->mutable_java_outer_classname())); - ::google::protobuf::internal::WireFormat::VerifyUTF8String( - this->java_outer_classname().data(), this->java_outer_classname().length(), - ::google::protobuf::internal::WireFormat::PARSE); - } else { - goto handle_uninterpreted; - } - if (input->ExpectTag(72)) goto parse_optimize_for; - break; - } - - // optional .google.protobuf.FileOptions.OptimizeMode optimize_for = 9 [default = SPEED]; - case 9: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) { - parse_optimize_for: - int value; - DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< - int, ::google::protobuf::internal::WireFormatLite::TYPE_ENUM>( - input, &value))); - if (::google::protobuf::FileOptions_OptimizeMode_IsValid(value)) { - set_optimize_for(static_cast< ::google::protobuf::FileOptions_OptimizeMode >(value)); - } else { - mutable_unknown_fields()->AddVarint(9, value); - } - } else { - goto handle_uninterpreted; - } - if (input->ExpectTag(80)) goto parse_java_multiple_files; - break; - } - - // optional bool java_multiple_files = 10 [default = false]; - case 10: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) { - parse_java_multiple_files: - DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< - bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>( - input, &java_multiple_files_))); - set_has_java_multiple_files(); - } else { - goto handle_uninterpreted; - } - if (input->ExpectTag(90)) goto parse_go_package; - break; - } - - // optional string go_package = 11; - case 11: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) { - parse_go_package: - DO_(::google::protobuf::internal::WireFormatLite::ReadString( - input, this->mutable_go_package())); - ::google::protobuf::internal::WireFormat::VerifyUTF8String( - this->go_package().data(), this->go_package().length(), - ::google::protobuf::internal::WireFormat::PARSE); - } else { - goto handle_uninterpreted; - } - if (input->ExpectTag(128)) goto parse_cc_generic_services; - break; - } - - // optional bool cc_generic_services = 16 [default = false]; - case 16: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) { - parse_cc_generic_services: - DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< - bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>( - input, &cc_generic_services_))); - set_has_cc_generic_services(); - } else { - goto handle_uninterpreted; - } - if (input->ExpectTag(136)) goto parse_java_generic_services; - break; - } - - // optional bool java_generic_services = 17 [default = false]; - case 17: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) { - parse_java_generic_services: - DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< - bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>( - input, &java_generic_services_))); - set_has_java_generic_services(); - } else { - goto handle_uninterpreted; - } - if (input->ExpectTag(144)) goto parse_py_generic_services; - break; - } - - // optional bool py_generic_services = 18 [default = false]; - case 18: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) { - parse_py_generic_services: - DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< - bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>( - input, &py_generic_services_))); - set_has_py_generic_services(); - } else { - goto handle_uninterpreted; - } - if (input->ExpectTag(160)) goto parse_java_generate_equals_and_hash; - break; - } - - // optional bool java_generate_equals_and_hash = 20 [default = false]; - case 20: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) { - parse_java_generate_equals_and_hash: - DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< - bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>( - input, &java_generate_equals_and_hash_))); - set_has_java_generate_equals_and_hash(); - } else { - goto handle_uninterpreted; - } - if (input->ExpectTag(7994)) goto parse_uninterpreted_option; - break; - } - - // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; - case 999: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) { - parse_uninterpreted_option: - DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual( - input, add_uninterpreted_option())); - } else { - goto handle_uninterpreted; - } - if (input->ExpectTag(7994)) goto parse_uninterpreted_option; - if (input->ExpectAtEnd()) return true; - break; - } - - default: { - handle_uninterpreted: - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) { - return true; - } - if ((8000u <= tag)) { - DO_(_extensions_.ParseField(tag, input, default_instance_, - mutable_unknown_fields())); - continue; - } - DO_(::google::protobuf::internal::WireFormat::SkipField( - input, tag, mutable_unknown_fields())); - break; - } - } - } - return true; -#undef DO_ -} - -void FileOptions::SerializeWithCachedSizes( - ::google::protobuf::io::CodedOutputStream* output) const { - // optional string java_package = 1; - if (has_java_package()) { - ::google::protobuf::internal::WireFormat::VerifyUTF8String( - this->java_package().data(), this->java_package().length(), - ::google::protobuf::internal::WireFormat::SERIALIZE); - ::google::protobuf::internal::WireFormatLite::WriteString( - 1, this->java_package(), output); - } - - // optional string java_outer_classname = 8; - if (has_java_outer_classname()) { - ::google::protobuf::internal::WireFormat::VerifyUTF8String( - this->java_outer_classname().data(), this->java_outer_classname().length(), - ::google::protobuf::internal::WireFormat::SERIALIZE); - ::google::protobuf::internal::WireFormatLite::WriteString( - 8, this->java_outer_classname(), output); - } - - // optional .google.protobuf.FileOptions.OptimizeMode optimize_for = 9 [default = SPEED]; - if (has_optimize_for()) { - ::google::protobuf::internal::WireFormatLite::WriteEnum( - 9, this->optimize_for(), output); - } - - // optional bool java_multiple_files = 10 [default = false]; - if (has_java_multiple_files()) { - ::google::protobuf::internal::WireFormatLite::WriteBool(10, this->java_multiple_files(), output); - } - - // optional string go_package = 11; - if (has_go_package()) { - ::google::protobuf::internal::WireFormat::VerifyUTF8String( - this->go_package().data(), this->go_package().length(), - ::google::protobuf::internal::WireFormat::SERIALIZE); - ::google::protobuf::internal::WireFormatLite::WriteString( - 11, this->go_package(), output); - } - - // optional bool cc_generic_services = 16 [default = false]; - if (has_cc_generic_services()) { - ::google::protobuf::internal::WireFormatLite::WriteBool(16, this->cc_generic_services(), output); - } - - // optional bool java_generic_services = 17 [default = false]; - if (has_java_generic_services()) { - ::google::protobuf::internal::WireFormatLite::WriteBool(17, this->java_generic_services(), output); - } - - // optional bool py_generic_services = 18 [default = false]; - if (has_py_generic_services()) { - ::google::protobuf::internal::WireFormatLite::WriteBool(18, this->py_generic_services(), output); - } - - // optional bool java_generate_equals_and_hash = 20 [default = false]; - if (has_java_generate_equals_and_hash()) { - ::google::protobuf::internal::WireFormatLite::WriteBool(20, this->java_generate_equals_and_hash(), output); - } - - // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; - for (int i = 0; i < this->uninterpreted_option_size(); i++) { - ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( - 999, this->uninterpreted_option(i), output); - } - - // Extension range [1000, 536870912) - _extensions_.SerializeWithCachedSizes( - 1000, 536870912, output); - - if (!unknown_fields().empty()) { - ::google::protobuf::internal::WireFormat::SerializeUnknownFields( - unknown_fields(), output); - } -} - -::google::protobuf::uint8* FileOptions::SerializeWithCachedSizesToArray( - ::google::protobuf::uint8* target) const { - // optional string java_package = 1; - if (has_java_package()) { - ::google::protobuf::internal::WireFormat::VerifyUTF8String( - this->java_package().data(), this->java_package().length(), - ::google::protobuf::internal::WireFormat::SERIALIZE); - target = - ::google::protobuf::internal::WireFormatLite::WriteStringToArray( - 1, this->java_package(), target); - } - - // optional string java_outer_classname = 8; - if (has_java_outer_classname()) { - ::google::protobuf::internal::WireFormat::VerifyUTF8String( - this->java_outer_classname().data(), this->java_outer_classname().length(), - ::google::protobuf::internal::WireFormat::SERIALIZE); - target = - ::google::protobuf::internal::WireFormatLite::WriteStringToArray( - 8, this->java_outer_classname(), target); - } - - // optional .google.protobuf.FileOptions.OptimizeMode optimize_for = 9 [default = SPEED]; - if (has_optimize_for()) { - target = ::google::protobuf::internal::WireFormatLite::WriteEnumToArray( - 9, this->optimize_for(), target); - } - - // optional bool java_multiple_files = 10 [default = false]; - if (has_java_multiple_files()) { - target = ::google::protobuf::internal::WireFormatLite::WriteBoolToArray(10, this->java_multiple_files(), target); - } - - // optional string go_package = 11; - if (has_go_package()) { - ::google::protobuf::internal::WireFormat::VerifyUTF8String( - this->go_package().data(), this->go_package().length(), - ::google::protobuf::internal::WireFormat::SERIALIZE); - target = - ::google::protobuf::internal::WireFormatLite::WriteStringToArray( - 11, this->go_package(), target); - } - - // optional bool cc_generic_services = 16 [default = false]; - if (has_cc_generic_services()) { - target = ::google::protobuf::internal::WireFormatLite::WriteBoolToArray(16, this->cc_generic_services(), target); - } - - // optional bool java_generic_services = 17 [default = false]; - if (has_java_generic_services()) { - target = ::google::protobuf::internal::WireFormatLite::WriteBoolToArray(17, this->java_generic_services(), target); - } - - // optional bool py_generic_services = 18 [default = false]; - if (has_py_generic_services()) { - target = ::google::protobuf::internal::WireFormatLite::WriteBoolToArray(18, this->py_generic_services(), target); - } - - // optional bool java_generate_equals_and_hash = 20 [default = false]; - if (has_java_generate_equals_and_hash()) { - target = ::google::protobuf::internal::WireFormatLite::WriteBoolToArray(20, this->java_generate_equals_and_hash(), target); - } - - // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; - for (int i = 0; i < this->uninterpreted_option_size(); i++) { - target = ::google::protobuf::internal::WireFormatLite:: - WriteMessageNoVirtualToArray( - 999, this->uninterpreted_option(i), target); - } - - // Extension range [1000, 536870912) - target = _extensions_.SerializeWithCachedSizesToArray( - 1000, 536870912, target); - - if (!unknown_fields().empty()) { - target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray( - unknown_fields(), target); - } - return target; -} - -int FileOptions::ByteSize() const { - int total_size = 0; - - if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) { - // optional string java_package = 1; - if (has_java_package()) { - total_size += 1 + - ::google::protobuf::internal::WireFormatLite::StringSize( - this->java_package()); - } - - // optional string java_outer_classname = 8; - if (has_java_outer_classname()) { - total_size += 1 + - ::google::protobuf::internal::WireFormatLite::StringSize( - this->java_outer_classname()); - } - - // optional bool java_multiple_files = 10 [default = false]; - if (has_java_multiple_files()) { - total_size += 1 + 1; - } - - // optional bool java_generate_equals_and_hash = 20 [default = false]; - if (has_java_generate_equals_and_hash()) { - total_size += 2 + 1; - } - - // optional .google.protobuf.FileOptions.OptimizeMode optimize_for = 9 [default = SPEED]; - if (has_optimize_for()) { - total_size += 1 + - ::google::protobuf::internal::WireFormatLite::EnumSize(this->optimize_for()); - } - - // optional string go_package = 11; - if (has_go_package()) { - total_size += 1 + - ::google::protobuf::internal::WireFormatLite::StringSize( - this->go_package()); - } - - // optional bool cc_generic_services = 16 [default = false]; - if (has_cc_generic_services()) { - total_size += 2 + 1; - } - - // optional bool java_generic_services = 17 [default = false]; - if (has_java_generic_services()) { - total_size += 2 + 1; - } - - } - if (_has_bits_[8 / 32] & (0xffu << (8 % 32))) { - // optional bool py_generic_services = 18 [default = false]; - if (has_py_generic_services()) { - total_size += 2 + 1; - } - - } - // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; - total_size += 2 * this->uninterpreted_option_size(); - for (int i = 0; i < this->uninterpreted_option_size(); i++) { - total_size += - ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( - this->uninterpreted_option(i)); - } - - total_size += _extensions_.ByteSize(); - - if (!unknown_fields().empty()) { - total_size += - ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( - unknown_fields()); - } - GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); - _cached_size_ = total_size; - GOOGLE_SAFE_CONCURRENT_WRITES_END(); - return total_size; -} - -void FileOptions::MergeFrom(const ::google::protobuf::Message& from) { - GOOGLE_CHECK_NE(&from, this); - const FileOptions* source = - ::google::protobuf::internal::dynamic_cast_if_available( - &from); - if (source == NULL) { - ::google::protobuf::internal::ReflectionOps::Merge(from, this); - } else { - MergeFrom(*source); - } -} - -void FileOptions::MergeFrom(const FileOptions& from) { - GOOGLE_CHECK_NE(&from, this); - uninterpreted_option_.MergeFrom(from.uninterpreted_option_); - if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) { - if (from.has_java_package()) { - set_java_package(from.java_package()); - } - if (from.has_java_outer_classname()) { - set_java_outer_classname(from.java_outer_classname()); - } - if (from.has_java_multiple_files()) { - set_java_multiple_files(from.java_multiple_files()); - } - if (from.has_java_generate_equals_and_hash()) { - set_java_generate_equals_and_hash(from.java_generate_equals_and_hash()); - } - if (from.has_optimize_for()) { - set_optimize_for(from.optimize_for()); - } - if (from.has_go_package()) { - set_go_package(from.go_package()); - } - if (from.has_cc_generic_services()) { - set_cc_generic_services(from.cc_generic_services()); - } - if (from.has_java_generic_services()) { - set_java_generic_services(from.java_generic_services()); - } - } - if (from._has_bits_[8 / 32] & (0xffu << (8 % 32))) { - if (from.has_py_generic_services()) { - set_py_generic_services(from.py_generic_services()); - } - } - _extensions_.MergeFrom(from._extensions_); - mutable_unknown_fields()->MergeFrom(from.unknown_fields()); -} - -void FileOptions::CopyFrom(const ::google::protobuf::Message& from) { - if (&from == this) return; - Clear(); - MergeFrom(from); -} - -void FileOptions::CopyFrom(const FileOptions& from) { - if (&from == this) return; - Clear(); - MergeFrom(from); -} - -bool FileOptions::IsInitialized() const { - - for (int i = 0; i < uninterpreted_option_size(); i++) { - if (!this->uninterpreted_option(i).IsInitialized()) return false; - } - - if (!_extensions_.IsInitialized()) return false; return true; -} - -void FileOptions::Swap(FileOptions* other) { - if (other != this) { - std::swap(java_package_, other->java_package_); - std::swap(java_outer_classname_, other->java_outer_classname_); - std::swap(java_multiple_files_, other->java_multiple_files_); - std::swap(java_generate_equals_and_hash_, other->java_generate_equals_and_hash_); - std::swap(optimize_for_, other->optimize_for_); - std::swap(go_package_, other->go_package_); - std::swap(cc_generic_services_, other->cc_generic_services_); - std::swap(java_generic_services_, other->java_generic_services_); - std::swap(py_generic_services_, other->py_generic_services_); - uninterpreted_option_.Swap(&other->uninterpreted_option_); - std::swap(_has_bits_[0], other->_has_bits_[0]); - _unknown_fields_.Swap(&other->_unknown_fields_); - std::swap(_cached_size_, other->_cached_size_); - _extensions_.Swap(&other->_extensions_); - } -} - -::google::protobuf::Metadata FileOptions::GetMetadata() const { - protobuf_AssignDescriptorsOnce(); - ::google::protobuf::Metadata metadata; - metadata.descriptor = FileOptions_descriptor_; - metadata.reflection = FileOptions_reflection_; - return metadata; -} - - -// =================================================================== - -#ifndef _MSC_VER -const int MessageOptions::kMessageSetWireFormatFieldNumber; -const int MessageOptions::kNoStandardDescriptorAccessorFieldNumber; -const int MessageOptions::kUninterpretedOptionFieldNumber; -#endif // !_MSC_VER - -MessageOptions::MessageOptions() - : ::google::protobuf::Message() { - SharedCtor(); -} - -void MessageOptions::InitAsDefaultInstance() { -} - -MessageOptions::MessageOptions(const MessageOptions& from) - : ::google::protobuf::Message() { - SharedCtor(); - MergeFrom(from); -} - -void MessageOptions::SharedCtor() { - _cached_size_ = 0; - message_set_wire_format_ = false; - no_standard_descriptor_accessor_ = false; - ::memset(_has_bits_, 0, sizeof(_has_bits_)); -} - -MessageOptions::~MessageOptions() { - SharedDtor(); -} - -void MessageOptions::SharedDtor() { - if (this != default_instance_) { - } -} - -void MessageOptions::SetCachedSize(int size) const { - GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); - _cached_size_ = size; - GOOGLE_SAFE_CONCURRENT_WRITES_END(); -} -const ::google::protobuf::Descriptor* MessageOptions::descriptor() { - protobuf_AssignDescriptorsOnce(); - return MessageOptions_descriptor_; -} - -const MessageOptions& MessageOptions::default_instance() { - if (default_instance_ == NULL) protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto(); - return *default_instance_; -} - -MessageOptions* MessageOptions::default_instance_ = NULL; - -MessageOptions* MessageOptions::New() const { - return new MessageOptions; -} - -void MessageOptions::Clear() { - _extensions_.Clear(); - if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) { - message_set_wire_format_ = false; - no_standard_descriptor_accessor_ = false; - } - uninterpreted_option_.Clear(); - ::memset(_has_bits_, 0, sizeof(_has_bits_)); - mutable_unknown_fields()->Clear(); -} - -bool MessageOptions::MergePartialFromCodedStream( - ::google::protobuf::io::CodedInputStream* input) { -#define DO_(EXPRESSION) if (!(EXPRESSION)) return false - ::google::protobuf::uint32 tag; - while ((tag = input->ReadTag()) != 0) { - switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { - // optional bool message_set_wire_format = 1 [default = false]; - case 1: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) { - DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< - bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>( - input, &message_set_wire_format_))); - set_has_message_set_wire_format(); - } else { - goto handle_uninterpreted; - } - if (input->ExpectTag(16)) goto parse_no_standard_descriptor_accessor; - break; - } - - // optional bool no_standard_descriptor_accessor = 2 [default = false]; - case 2: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) { - parse_no_standard_descriptor_accessor: - DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< - bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>( - input, &no_standard_descriptor_accessor_))); - set_has_no_standard_descriptor_accessor(); - } else { - goto handle_uninterpreted; - } - if (input->ExpectTag(7994)) goto parse_uninterpreted_option; - break; - } - - // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; - case 999: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) { - parse_uninterpreted_option: - DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual( - input, add_uninterpreted_option())); - } else { - goto handle_uninterpreted; - } - if (input->ExpectTag(7994)) goto parse_uninterpreted_option; - if (input->ExpectAtEnd()) return true; - break; - } - - default: { - handle_uninterpreted: - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) { - return true; - } - if ((8000u <= tag)) { - DO_(_extensions_.ParseField(tag, input, default_instance_, - mutable_unknown_fields())); - continue; - } - DO_(::google::protobuf::internal::WireFormat::SkipField( - input, tag, mutable_unknown_fields())); - break; - } - } - } - return true; -#undef DO_ -} - -void MessageOptions::SerializeWithCachedSizes( - ::google::protobuf::io::CodedOutputStream* output) const { - // optional bool message_set_wire_format = 1 [default = false]; - if (has_message_set_wire_format()) { - ::google::protobuf::internal::WireFormatLite::WriteBool(1, this->message_set_wire_format(), output); - } - - // optional bool no_standard_descriptor_accessor = 2 [default = false]; - if (has_no_standard_descriptor_accessor()) { - ::google::protobuf::internal::WireFormatLite::WriteBool(2, this->no_standard_descriptor_accessor(), output); - } - - // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; - for (int i = 0; i < this->uninterpreted_option_size(); i++) { - ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( - 999, this->uninterpreted_option(i), output); - } - - // Extension range [1000, 536870912) - _extensions_.SerializeWithCachedSizes( - 1000, 536870912, output); - - if (!unknown_fields().empty()) { - ::google::protobuf::internal::WireFormat::SerializeUnknownFields( - unknown_fields(), output); - } -} - -::google::protobuf::uint8* MessageOptions::SerializeWithCachedSizesToArray( - ::google::protobuf::uint8* target) const { - // optional bool message_set_wire_format = 1 [default = false]; - if (has_message_set_wire_format()) { - target = ::google::protobuf::internal::WireFormatLite::WriteBoolToArray(1, this->message_set_wire_format(), target); - } - - // optional bool no_standard_descriptor_accessor = 2 [default = false]; - if (has_no_standard_descriptor_accessor()) { - target = ::google::protobuf::internal::WireFormatLite::WriteBoolToArray(2, this->no_standard_descriptor_accessor(), target); - } - - // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; - for (int i = 0; i < this->uninterpreted_option_size(); i++) { - target = ::google::protobuf::internal::WireFormatLite:: - WriteMessageNoVirtualToArray( - 999, this->uninterpreted_option(i), target); - } - - // Extension range [1000, 536870912) - target = _extensions_.SerializeWithCachedSizesToArray( - 1000, 536870912, target); - - if (!unknown_fields().empty()) { - target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray( - unknown_fields(), target); - } - return target; -} - -int MessageOptions::ByteSize() const { - int total_size = 0; - - if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) { - // optional bool message_set_wire_format = 1 [default = false]; - if (has_message_set_wire_format()) { - total_size += 1 + 1; - } - - // optional bool no_standard_descriptor_accessor = 2 [default = false]; - if (has_no_standard_descriptor_accessor()) { - total_size += 1 + 1; - } - - } - // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; - total_size += 2 * this->uninterpreted_option_size(); - for (int i = 0; i < this->uninterpreted_option_size(); i++) { - total_size += - ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( - this->uninterpreted_option(i)); - } - - total_size += _extensions_.ByteSize(); - - if (!unknown_fields().empty()) { - total_size += - ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( - unknown_fields()); - } - GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); - _cached_size_ = total_size; - GOOGLE_SAFE_CONCURRENT_WRITES_END(); - return total_size; -} - -void MessageOptions::MergeFrom(const ::google::protobuf::Message& from) { - GOOGLE_CHECK_NE(&from, this); - const MessageOptions* source = - ::google::protobuf::internal::dynamic_cast_if_available( - &from); - if (source == NULL) { - ::google::protobuf::internal::ReflectionOps::Merge(from, this); - } else { - MergeFrom(*source); - } -} - -void MessageOptions::MergeFrom(const MessageOptions& from) { - GOOGLE_CHECK_NE(&from, this); - uninterpreted_option_.MergeFrom(from.uninterpreted_option_); - if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) { - if (from.has_message_set_wire_format()) { - set_message_set_wire_format(from.message_set_wire_format()); - } - if (from.has_no_standard_descriptor_accessor()) { - set_no_standard_descriptor_accessor(from.no_standard_descriptor_accessor()); - } - } - _extensions_.MergeFrom(from._extensions_); - mutable_unknown_fields()->MergeFrom(from.unknown_fields()); -} - -void MessageOptions::CopyFrom(const ::google::protobuf::Message& from) { - if (&from == this) return; - Clear(); - MergeFrom(from); -} - -void MessageOptions::CopyFrom(const MessageOptions& from) { - if (&from == this) return; - Clear(); - MergeFrom(from); -} - -bool MessageOptions::IsInitialized() const { - - for (int i = 0; i < uninterpreted_option_size(); i++) { - if (!this->uninterpreted_option(i).IsInitialized()) return false; - } - - if (!_extensions_.IsInitialized()) return false; return true; -} - -void MessageOptions::Swap(MessageOptions* other) { - if (other != this) { - std::swap(message_set_wire_format_, other->message_set_wire_format_); - std::swap(no_standard_descriptor_accessor_, other->no_standard_descriptor_accessor_); - uninterpreted_option_.Swap(&other->uninterpreted_option_); - std::swap(_has_bits_[0], other->_has_bits_[0]); - _unknown_fields_.Swap(&other->_unknown_fields_); - std::swap(_cached_size_, other->_cached_size_); - _extensions_.Swap(&other->_extensions_); - } -} - -::google::protobuf::Metadata MessageOptions::GetMetadata() const { - protobuf_AssignDescriptorsOnce(); - ::google::protobuf::Metadata metadata; - metadata.descriptor = MessageOptions_descriptor_; - metadata.reflection = MessageOptions_reflection_; - return metadata; -} - - -// =================================================================== - -const ::google::protobuf::EnumDescriptor* FieldOptions_CType_descriptor() { - protobuf_AssignDescriptorsOnce(); - return FieldOptions_CType_descriptor_; -} -bool FieldOptions_CType_IsValid(int value) { - switch(value) { - case 0: - case 1: - case 2: - return true; - default: - return false; - } -} - -#ifndef _MSC_VER -const FieldOptions_CType FieldOptions::STRING; -const FieldOptions_CType FieldOptions::CORD; -const FieldOptions_CType FieldOptions::STRING_PIECE; -const FieldOptions_CType FieldOptions::CType_MIN; -const FieldOptions_CType FieldOptions::CType_MAX; -const int FieldOptions::CType_ARRAYSIZE; -#endif // _MSC_VER -#ifndef _MSC_VER -const int FieldOptions::kCtypeFieldNumber; -const int FieldOptions::kPackedFieldNumber; -const int FieldOptions::kLazyFieldNumber; -const int FieldOptions::kDeprecatedFieldNumber; -const int FieldOptions::kExperimentalMapKeyFieldNumber; -const int FieldOptions::kWeakFieldNumber; -const int FieldOptions::kUninterpretedOptionFieldNumber; -#endif // !_MSC_VER - -FieldOptions::FieldOptions() - : ::google::protobuf::Message() { - SharedCtor(); -} - -void FieldOptions::InitAsDefaultInstance() { -} - -FieldOptions::FieldOptions(const FieldOptions& from) - : ::google::protobuf::Message() { - SharedCtor(); - MergeFrom(from); -} - -void FieldOptions::SharedCtor() { - _cached_size_ = 0; - ctype_ = 0; - packed_ = false; - lazy_ = false; - deprecated_ = false; - experimental_map_key_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); - weak_ = false; - ::memset(_has_bits_, 0, sizeof(_has_bits_)); -} - -FieldOptions::~FieldOptions() { - SharedDtor(); -} - -void FieldOptions::SharedDtor() { - if (experimental_map_key_ != &::google::protobuf::internal::kEmptyString) { - delete experimental_map_key_; - } - if (this != default_instance_) { - } -} - -void FieldOptions::SetCachedSize(int size) const { - GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); - _cached_size_ = size; - GOOGLE_SAFE_CONCURRENT_WRITES_END(); -} -const ::google::protobuf::Descriptor* FieldOptions::descriptor() { - protobuf_AssignDescriptorsOnce(); - return FieldOptions_descriptor_; -} - -const FieldOptions& FieldOptions::default_instance() { - if (default_instance_ == NULL) protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto(); - return *default_instance_; -} - -FieldOptions* FieldOptions::default_instance_ = NULL; - -FieldOptions* FieldOptions::New() const { - return new FieldOptions; -} - -void FieldOptions::Clear() { - _extensions_.Clear(); - if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) { - ctype_ = 0; - packed_ = false; - lazy_ = false; - deprecated_ = false; - if (has_experimental_map_key()) { - if (experimental_map_key_ != &::google::protobuf::internal::kEmptyString) { - experimental_map_key_->clear(); - } - } - weak_ = false; - } - uninterpreted_option_.Clear(); - ::memset(_has_bits_, 0, sizeof(_has_bits_)); - mutable_unknown_fields()->Clear(); -} - -bool FieldOptions::MergePartialFromCodedStream( - ::google::protobuf::io::CodedInputStream* input) { -#define DO_(EXPRESSION) if (!(EXPRESSION)) return false - ::google::protobuf::uint32 tag; - while ((tag = input->ReadTag()) != 0) { - switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { - // optional .google.protobuf.FieldOptions.CType ctype = 1 [default = STRING]; - case 1: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) { - int value; - DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< - int, ::google::protobuf::internal::WireFormatLite::TYPE_ENUM>( - input, &value))); - if (::google::protobuf::FieldOptions_CType_IsValid(value)) { - set_ctype(static_cast< ::google::protobuf::FieldOptions_CType >(value)); - } else { - mutable_unknown_fields()->AddVarint(1, value); - } - } else { - goto handle_uninterpreted; - } - if (input->ExpectTag(16)) goto parse_packed; - break; - } - - // optional bool packed = 2; - case 2: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) { - parse_packed: - DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< - bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>( - input, &packed_))); - set_has_packed(); - } else { - goto handle_uninterpreted; - } - if (input->ExpectTag(24)) goto parse_deprecated; - break; - } - - // optional bool deprecated = 3 [default = false]; - case 3: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) { - parse_deprecated: - DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< - bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>( - input, &deprecated_))); - set_has_deprecated(); - } else { - goto handle_uninterpreted; - } - if (input->ExpectTag(40)) goto parse_lazy; - break; - } - - // optional bool lazy = 5 [default = false]; - case 5: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) { - parse_lazy: - DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< - bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>( - input, &lazy_))); - set_has_lazy(); - } else { - goto handle_uninterpreted; - } - if (input->ExpectTag(74)) goto parse_experimental_map_key; - break; - } - - // optional string experimental_map_key = 9; - case 9: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) { - parse_experimental_map_key: - DO_(::google::protobuf::internal::WireFormatLite::ReadString( - input, this->mutable_experimental_map_key())); - ::google::protobuf::internal::WireFormat::VerifyUTF8String( - this->experimental_map_key().data(), this->experimental_map_key().length(), - ::google::protobuf::internal::WireFormat::PARSE); - } else { - goto handle_uninterpreted; - } - if (input->ExpectTag(80)) goto parse_weak; - break; - } - - // optional bool weak = 10 [default = false]; - case 10: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) { - parse_weak: - DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< - bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>( - input, &weak_))); - set_has_weak(); - } else { - goto handle_uninterpreted; - } - if (input->ExpectTag(7994)) goto parse_uninterpreted_option; - break; - } - - // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; - case 999: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) { - parse_uninterpreted_option: - DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual( - input, add_uninterpreted_option())); - } else { - goto handle_uninterpreted; - } - if (input->ExpectTag(7994)) goto parse_uninterpreted_option; - if (input->ExpectAtEnd()) return true; - break; - } - - default: { - handle_uninterpreted: - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) { - return true; - } - if ((8000u <= tag)) { - DO_(_extensions_.ParseField(tag, input, default_instance_, - mutable_unknown_fields())); - continue; - } - DO_(::google::protobuf::internal::WireFormat::SkipField( - input, tag, mutable_unknown_fields())); - break; - } - } - } - return true; -#undef DO_ -} - -void FieldOptions::SerializeWithCachedSizes( - ::google::protobuf::io::CodedOutputStream* output) const { - // optional .google.protobuf.FieldOptions.CType ctype = 1 [default = STRING]; - if (has_ctype()) { - ::google::protobuf::internal::WireFormatLite::WriteEnum( - 1, this->ctype(), output); - } - - // optional bool packed = 2; - if (has_packed()) { - ::google::protobuf::internal::WireFormatLite::WriteBool(2, this->packed(), output); - } - - // optional bool deprecated = 3 [default = false]; - if (has_deprecated()) { - ::google::protobuf::internal::WireFormatLite::WriteBool(3, this->deprecated(), output); - } - - // optional bool lazy = 5 [default = false]; - if (has_lazy()) { - ::google::protobuf::internal::WireFormatLite::WriteBool(5, this->lazy(), output); - } - - // optional string experimental_map_key = 9; - if (has_experimental_map_key()) { - ::google::protobuf::internal::WireFormat::VerifyUTF8String( - this->experimental_map_key().data(), this->experimental_map_key().length(), - ::google::protobuf::internal::WireFormat::SERIALIZE); - ::google::protobuf::internal::WireFormatLite::WriteString( - 9, this->experimental_map_key(), output); - } - - // optional bool weak = 10 [default = false]; - if (has_weak()) { - ::google::protobuf::internal::WireFormatLite::WriteBool(10, this->weak(), output); - } - - // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; - for (int i = 0; i < this->uninterpreted_option_size(); i++) { - ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( - 999, this->uninterpreted_option(i), output); - } - - // Extension range [1000, 536870912) - _extensions_.SerializeWithCachedSizes( - 1000, 536870912, output); - - if (!unknown_fields().empty()) { - ::google::protobuf::internal::WireFormat::SerializeUnknownFields( - unknown_fields(), output); - } -} - -::google::protobuf::uint8* FieldOptions::SerializeWithCachedSizesToArray( - ::google::protobuf::uint8* target) const { - // optional .google.protobuf.FieldOptions.CType ctype = 1 [default = STRING]; - if (has_ctype()) { - target = ::google::protobuf::internal::WireFormatLite::WriteEnumToArray( - 1, this->ctype(), target); - } - - // optional bool packed = 2; - if (has_packed()) { - target = ::google::protobuf::internal::WireFormatLite::WriteBoolToArray(2, this->packed(), target); - } - - // optional bool deprecated = 3 [default = false]; - if (has_deprecated()) { - target = ::google::protobuf::internal::WireFormatLite::WriteBoolToArray(3, this->deprecated(), target); - } - - // optional bool lazy = 5 [default = false]; - if (has_lazy()) { - target = ::google::protobuf::internal::WireFormatLite::WriteBoolToArray(5, this->lazy(), target); - } - - // optional string experimental_map_key = 9; - if (has_experimental_map_key()) { - ::google::protobuf::internal::WireFormat::VerifyUTF8String( - this->experimental_map_key().data(), this->experimental_map_key().length(), - ::google::protobuf::internal::WireFormat::SERIALIZE); - target = - ::google::protobuf::internal::WireFormatLite::WriteStringToArray( - 9, this->experimental_map_key(), target); - } - - // optional bool weak = 10 [default = false]; - if (has_weak()) { - target = ::google::protobuf::internal::WireFormatLite::WriteBoolToArray(10, this->weak(), target); - } - - // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; - for (int i = 0; i < this->uninterpreted_option_size(); i++) { - target = ::google::protobuf::internal::WireFormatLite:: - WriteMessageNoVirtualToArray( - 999, this->uninterpreted_option(i), target); - } - - // Extension range [1000, 536870912) - target = _extensions_.SerializeWithCachedSizesToArray( - 1000, 536870912, target); - - if (!unknown_fields().empty()) { - target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray( - unknown_fields(), target); - } - return target; -} - -int FieldOptions::ByteSize() const { - int total_size = 0; - - if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) { - // optional .google.protobuf.FieldOptions.CType ctype = 1 [default = STRING]; - if (has_ctype()) { - total_size += 1 + - ::google::protobuf::internal::WireFormatLite::EnumSize(this->ctype()); - } - - // optional bool packed = 2; - if (has_packed()) { - total_size += 1 + 1; - } - - // optional bool lazy = 5 [default = false]; - if (has_lazy()) { - total_size += 1 + 1; - } - - // optional bool deprecated = 3 [default = false]; - if (has_deprecated()) { - total_size += 1 + 1; - } - - // optional string experimental_map_key = 9; - if (has_experimental_map_key()) { - total_size += 1 + - ::google::protobuf::internal::WireFormatLite::StringSize( - this->experimental_map_key()); - } - - // optional bool weak = 10 [default = false]; - if (has_weak()) { - total_size += 1 + 1; - } - - } - // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; - total_size += 2 * this->uninterpreted_option_size(); - for (int i = 0; i < this->uninterpreted_option_size(); i++) { - total_size += - ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( - this->uninterpreted_option(i)); - } - - total_size += _extensions_.ByteSize(); - - if (!unknown_fields().empty()) { - total_size += - ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( - unknown_fields()); - } - GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); - _cached_size_ = total_size; - GOOGLE_SAFE_CONCURRENT_WRITES_END(); - return total_size; -} - -void FieldOptions::MergeFrom(const ::google::protobuf::Message& from) { - GOOGLE_CHECK_NE(&from, this); - const FieldOptions* source = - ::google::protobuf::internal::dynamic_cast_if_available( - &from); - if (source == NULL) { - ::google::protobuf::internal::ReflectionOps::Merge(from, this); - } else { - MergeFrom(*source); - } -} - -void FieldOptions::MergeFrom(const FieldOptions& from) { - GOOGLE_CHECK_NE(&from, this); - uninterpreted_option_.MergeFrom(from.uninterpreted_option_); - if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) { - if (from.has_ctype()) { - set_ctype(from.ctype()); - } - if (from.has_packed()) { - set_packed(from.packed()); - } - if (from.has_lazy()) { - set_lazy(from.lazy()); - } - if (from.has_deprecated()) { - set_deprecated(from.deprecated()); - } - if (from.has_experimental_map_key()) { - set_experimental_map_key(from.experimental_map_key()); - } - if (from.has_weak()) { - set_weak(from.weak()); - } - } - _extensions_.MergeFrom(from._extensions_); - mutable_unknown_fields()->MergeFrom(from.unknown_fields()); -} - -void FieldOptions::CopyFrom(const ::google::protobuf::Message& from) { - if (&from == this) return; - Clear(); - MergeFrom(from); -} - -void FieldOptions::CopyFrom(const FieldOptions& from) { - if (&from == this) return; - Clear(); - MergeFrom(from); -} - -bool FieldOptions::IsInitialized() const { - - for (int i = 0; i < uninterpreted_option_size(); i++) { - if (!this->uninterpreted_option(i).IsInitialized()) return false; - } - - if (!_extensions_.IsInitialized()) return false; return true; -} - -void FieldOptions::Swap(FieldOptions* other) { - if (other != this) { - std::swap(ctype_, other->ctype_); - std::swap(packed_, other->packed_); - std::swap(lazy_, other->lazy_); - std::swap(deprecated_, other->deprecated_); - std::swap(experimental_map_key_, other->experimental_map_key_); - std::swap(weak_, other->weak_); - uninterpreted_option_.Swap(&other->uninterpreted_option_); - std::swap(_has_bits_[0], other->_has_bits_[0]); - _unknown_fields_.Swap(&other->_unknown_fields_); - std::swap(_cached_size_, other->_cached_size_); - _extensions_.Swap(&other->_extensions_); - } -} - -::google::protobuf::Metadata FieldOptions::GetMetadata() const { - protobuf_AssignDescriptorsOnce(); - ::google::protobuf::Metadata metadata; - metadata.descriptor = FieldOptions_descriptor_; - metadata.reflection = FieldOptions_reflection_; - return metadata; -} - - -// =================================================================== - -#ifndef _MSC_VER -const int EnumOptions::kAllowAliasFieldNumber; -const int EnumOptions::kUninterpretedOptionFieldNumber; -#endif // !_MSC_VER - -EnumOptions::EnumOptions() - : ::google::protobuf::Message() { - SharedCtor(); -} - -void EnumOptions::InitAsDefaultInstance() { -} - -EnumOptions::EnumOptions(const EnumOptions& from) - : ::google::protobuf::Message() { - SharedCtor(); - MergeFrom(from); -} - -void EnumOptions::SharedCtor() { - _cached_size_ = 0; - allow_alias_ = true; - ::memset(_has_bits_, 0, sizeof(_has_bits_)); -} - -EnumOptions::~EnumOptions() { - SharedDtor(); -} - -void EnumOptions::SharedDtor() { - if (this != default_instance_) { - } -} - -void EnumOptions::SetCachedSize(int size) const { - GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); - _cached_size_ = size; - GOOGLE_SAFE_CONCURRENT_WRITES_END(); -} -const ::google::protobuf::Descriptor* EnumOptions::descriptor() { - protobuf_AssignDescriptorsOnce(); - return EnumOptions_descriptor_; -} - -const EnumOptions& EnumOptions::default_instance() { - if (default_instance_ == NULL) protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto(); - return *default_instance_; -} - -EnumOptions* EnumOptions::default_instance_ = NULL; - -EnumOptions* EnumOptions::New() const { - return new EnumOptions; -} - -void EnumOptions::Clear() { - _extensions_.Clear(); - if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) { - allow_alias_ = true; - } - uninterpreted_option_.Clear(); - ::memset(_has_bits_, 0, sizeof(_has_bits_)); - mutable_unknown_fields()->Clear(); -} - -bool EnumOptions::MergePartialFromCodedStream( - ::google::protobuf::io::CodedInputStream* input) { -#define DO_(EXPRESSION) if (!(EXPRESSION)) return false - ::google::protobuf::uint32 tag; - while ((tag = input->ReadTag()) != 0) { - switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { - // optional bool allow_alias = 2 [default = true]; - case 2: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) { - DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< - bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>( - input, &allow_alias_))); - set_has_allow_alias(); - } else { - goto handle_uninterpreted; - } - if (input->ExpectTag(7994)) goto parse_uninterpreted_option; - break; - } - - // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; - case 999: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) { - parse_uninterpreted_option: - DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual( - input, add_uninterpreted_option())); - } else { - goto handle_uninterpreted; - } - if (input->ExpectTag(7994)) goto parse_uninterpreted_option; - if (input->ExpectAtEnd()) return true; - break; - } - - default: { - handle_uninterpreted: - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) { - return true; - } - if ((8000u <= tag)) { - DO_(_extensions_.ParseField(tag, input, default_instance_, - mutable_unknown_fields())); - continue; - } - DO_(::google::protobuf::internal::WireFormat::SkipField( - input, tag, mutable_unknown_fields())); - break; - } - } - } - return true; -#undef DO_ -} - -void EnumOptions::SerializeWithCachedSizes( - ::google::protobuf::io::CodedOutputStream* output) const { - // optional bool allow_alias = 2 [default = true]; - if (has_allow_alias()) { - ::google::protobuf::internal::WireFormatLite::WriteBool(2, this->allow_alias(), output); - } - - // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; - for (int i = 0; i < this->uninterpreted_option_size(); i++) { - ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( - 999, this->uninterpreted_option(i), output); - } - - // Extension range [1000, 536870912) - _extensions_.SerializeWithCachedSizes( - 1000, 536870912, output); - - if (!unknown_fields().empty()) { - ::google::protobuf::internal::WireFormat::SerializeUnknownFields( - unknown_fields(), output); - } -} - -::google::protobuf::uint8* EnumOptions::SerializeWithCachedSizesToArray( - ::google::protobuf::uint8* target) const { - // optional bool allow_alias = 2 [default = true]; - if (has_allow_alias()) { - target = ::google::protobuf::internal::WireFormatLite::WriteBoolToArray(2, this->allow_alias(), target); - } - - // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; - for (int i = 0; i < this->uninterpreted_option_size(); i++) { - target = ::google::protobuf::internal::WireFormatLite:: - WriteMessageNoVirtualToArray( - 999, this->uninterpreted_option(i), target); - } - - // Extension range [1000, 536870912) - target = _extensions_.SerializeWithCachedSizesToArray( - 1000, 536870912, target); - - if (!unknown_fields().empty()) { - target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray( - unknown_fields(), target); - } - return target; -} - -int EnumOptions::ByteSize() const { - int total_size = 0; - - if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) { - // optional bool allow_alias = 2 [default = true]; - if (has_allow_alias()) { - total_size += 1 + 1; - } - - } - // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; - total_size += 2 * this->uninterpreted_option_size(); - for (int i = 0; i < this->uninterpreted_option_size(); i++) { - total_size += - ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( - this->uninterpreted_option(i)); - } - - total_size += _extensions_.ByteSize(); - - if (!unknown_fields().empty()) { - total_size += - ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( - unknown_fields()); - } - GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); - _cached_size_ = total_size; - GOOGLE_SAFE_CONCURRENT_WRITES_END(); - return total_size; -} - -void EnumOptions::MergeFrom(const ::google::protobuf::Message& from) { - GOOGLE_CHECK_NE(&from, this); - const EnumOptions* source = - ::google::protobuf::internal::dynamic_cast_if_available( - &from); - if (source == NULL) { - ::google::protobuf::internal::ReflectionOps::Merge(from, this); - } else { - MergeFrom(*source); - } -} - -void EnumOptions::MergeFrom(const EnumOptions& from) { - GOOGLE_CHECK_NE(&from, this); - uninterpreted_option_.MergeFrom(from.uninterpreted_option_); - if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) { - if (from.has_allow_alias()) { - set_allow_alias(from.allow_alias()); - } - } - _extensions_.MergeFrom(from._extensions_); - mutable_unknown_fields()->MergeFrom(from.unknown_fields()); -} - -void EnumOptions::CopyFrom(const ::google::protobuf::Message& from) { - if (&from == this) return; - Clear(); - MergeFrom(from); -} - -void EnumOptions::CopyFrom(const EnumOptions& from) { - if (&from == this) return; - Clear(); - MergeFrom(from); -} - -bool EnumOptions::IsInitialized() const { - - for (int i = 0; i < uninterpreted_option_size(); i++) { - if (!this->uninterpreted_option(i).IsInitialized()) return false; - } - - if (!_extensions_.IsInitialized()) return false; return true; -} - -void EnumOptions::Swap(EnumOptions* other) { - if (other != this) { - std::swap(allow_alias_, other->allow_alias_); - uninterpreted_option_.Swap(&other->uninterpreted_option_); - std::swap(_has_bits_[0], other->_has_bits_[0]); - _unknown_fields_.Swap(&other->_unknown_fields_); - std::swap(_cached_size_, other->_cached_size_); - _extensions_.Swap(&other->_extensions_); - } -} - -::google::protobuf::Metadata EnumOptions::GetMetadata() const { - protobuf_AssignDescriptorsOnce(); - ::google::protobuf::Metadata metadata; - metadata.descriptor = EnumOptions_descriptor_; - metadata.reflection = EnumOptions_reflection_; - return metadata; -} - - -// =================================================================== - -#ifndef _MSC_VER -const int EnumValueOptions::kUninterpretedOptionFieldNumber; -#endif // !_MSC_VER - -EnumValueOptions::EnumValueOptions() - : ::google::protobuf::Message() { - SharedCtor(); -} - -void EnumValueOptions::InitAsDefaultInstance() { -} - -EnumValueOptions::EnumValueOptions(const EnumValueOptions& from) - : ::google::protobuf::Message() { - SharedCtor(); - MergeFrom(from); -} - -void EnumValueOptions::SharedCtor() { - _cached_size_ = 0; - ::memset(_has_bits_, 0, sizeof(_has_bits_)); -} - -EnumValueOptions::~EnumValueOptions() { - SharedDtor(); -} - -void EnumValueOptions::SharedDtor() { - if (this != default_instance_) { - } -} - -void EnumValueOptions::SetCachedSize(int size) const { - GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); - _cached_size_ = size; - GOOGLE_SAFE_CONCURRENT_WRITES_END(); -} -const ::google::protobuf::Descriptor* EnumValueOptions::descriptor() { - protobuf_AssignDescriptorsOnce(); - return EnumValueOptions_descriptor_; -} - -const EnumValueOptions& EnumValueOptions::default_instance() { - if (default_instance_ == NULL) protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto(); - return *default_instance_; -} - -EnumValueOptions* EnumValueOptions::default_instance_ = NULL; - -EnumValueOptions* EnumValueOptions::New() const { - return new EnumValueOptions; -} - -void EnumValueOptions::Clear() { - _extensions_.Clear(); - uninterpreted_option_.Clear(); - ::memset(_has_bits_, 0, sizeof(_has_bits_)); - mutable_unknown_fields()->Clear(); -} - -bool EnumValueOptions::MergePartialFromCodedStream( - ::google::protobuf::io::CodedInputStream* input) { -#define DO_(EXPRESSION) if (!(EXPRESSION)) return false - ::google::protobuf::uint32 tag; - while ((tag = input->ReadTag()) != 0) { - switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { - // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; - case 999: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) { - parse_uninterpreted_option: - DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual( - input, add_uninterpreted_option())); - } else { - goto handle_uninterpreted; - } - if (input->ExpectTag(7994)) goto parse_uninterpreted_option; - if (input->ExpectAtEnd()) return true; - break; - } - - default: { - handle_uninterpreted: - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) { - return true; - } - if ((8000u <= tag)) { - DO_(_extensions_.ParseField(tag, input, default_instance_, - mutable_unknown_fields())); - continue; - } - DO_(::google::protobuf::internal::WireFormat::SkipField( - input, tag, mutable_unknown_fields())); - break; - } - } - } - return true; -#undef DO_ -} - -void EnumValueOptions::SerializeWithCachedSizes( - ::google::protobuf::io::CodedOutputStream* output) const { - // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; - for (int i = 0; i < this->uninterpreted_option_size(); i++) { - ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( - 999, this->uninterpreted_option(i), output); - } - - // Extension range [1000, 536870912) - _extensions_.SerializeWithCachedSizes( - 1000, 536870912, output); - - if (!unknown_fields().empty()) { - ::google::protobuf::internal::WireFormat::SerializeUnknownFields( - unknown_fields(), output); - } -} - -::google::protobuf::uint8* EnumValueOptions::SerializeWithCachedSizesToArray( - ::google::protobuf::uint8* target) const { - // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; - for (int i = 0; i < this->uninterpreted_option_size(); i++) { - target = ::google::protobuf::internal::WireFormatLite:: - WriteMessageNoVirtualToArray( - 999, this->uninterpreted_option(i), target); - } - - // Extension range [1000, 536870912) - target = _extensions_.SerializeWithCachedSizesToArray( - 1000, 536870912, target); - - if (!unknown_fields().empty()) { - target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray( - unknown_fields(), target); - } - return target; -} - -int EnumValueOptions::ByteSize() const { - int total_size = 0; - - // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; - total_size += 2 * this->uninterpreted_option_size(); - for (int i = 0; i < this->uninterpreted_option_size(); i++) { - total_size += - ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( - this->uninterpreted_option(i)); - } - - total_size += _extensions_.ByteSize(); - - if (!unknown_fields().empty()) { - total_size += - ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( - unknown_fields()); - } - GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); - _cached_size_ = total_size; - GOOGLE_SAFE_CONCURRENT_WRITES_END(); - return total_size; -} - -void EnumValueOptions::MergeFrom(const ::google::protobuf::Message& from) { - GOOGLE_CHECK_NE(&from, this); - const EnumValueOptions* source = - ::google::protobuf::internal::dynamic_cast_if_available( - &from); - if (source == NULL) { - ::google::protobuf::internal::ReflectionOps::Merge(from, this); - } else { - MergeFrom(*source); - } -} - -void EnumValueOptions::MergeFrom(const EnumValueOptions& from) { - GOOGLE_CHECK_NE(&from, this); - uninterpreted_option_.MergeFrom(from.uninterpreted_option_); - _extensions_.MergeFrom(from._extensions_); - mutable_unknown_fields()->MergeFrom(from.unknown_fields()); -} - -void EnumValueOptions::CopyFrom(const ::google::protobuf::Message& from) { - if (&from == this) return; - Clear(); - MergeFrom(from); -} - -void EnumValueOptions::CopyFrom(const EnumValueOptions& from) { - if (&from == this) return; - Clear(); - MergeFrom(from); -} - -bool EnumValueOptions::IsInitialized() const { - - for (int i = 0; i < uninterpreted_option_size(); i++) { - if (!this->uninterpreted_option(i).IsInitialized()) return false; - } - - if (!_extensions_.IsInitialized()) return false; return true; -} - -void EnumValueOptions::Swap(EnumValueOptions* other) { - if (other != this) { - uninterpreted_option_.Swap(&other->uninterpreted_option_); - std::swap(_has_bits_[0], other->_has_bits_[0]); - _unknown_fields_.Swap(&other->_unknown_fields_); - std::swap(_cached_size_, other->_cached_size_); - _extensions_.Swap(&other->_extensions_); - } -} - -::google::protobuf::Metadata EnumValueOptions::GetMetadata() const { - protobuf_AssignDescriptorsOnce(); - ::google::protobuf::Metadata metadata; - metadata.descriptor = EnumValueOptions_descriptor_; - metadata.reflection = EnumValueOptions_reflection_; - return metadata; -} - - -// =================================================================== - -#ifndef _MSC_VER -const int ServiceOptions::kUninterpretedOptionFieldNumber; -#endif // !_MSC_VER - -ServiceOptions::ServiceOptions() - : ::google::protobuf::Message() { - SharedCtor(); -} - -void ServiceOptions::InitAsDefaultInstance() { -} - -ServiceOptions::ServiceOptions(const ServiceOptions& from) - : ::google::protobuf::Message() { - SharedCtor(); - MergeFrom(from); -} - -void ServiceOptions::SharedCtor() { - _cached_size_ = 0; - ::memset(_has_bits_, 0, sizeof(_has_bits_)); -} - -ServiceOptions::~ServiceOptions() { - SharedDtor(); -} - -void ServiceOptions::SharedDtor() { - if (this != default_instance_) { - } -} - -void ServiceOptions::SetCachedSize(int size) const { - GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); - _cached_size_ = size; - GOOGLE_SAFE_CONCURRENT_WRITES_END(); -} -const ::google::protobuf::Descriptor* ServiceOptions::descriptor() { - protobuf_AssignDescriptorsOnce(); - return ServiceOptions_descriptor_; -} - -const ServiceOptions& ServiceOptions::default_instance() { - if (default_instance_ == NULL) protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto(); - return *default_instance_; -} - -ServiceOptions* ServiceOptions::default_instance_ = NULL; - -ServiceOptions* ServiceOptions::New() const { - return new ServiceOptions; -} - -void ServiceOptions::Clear() { - _extensions_.Clear(); - uninterpreted_option_.Clear(); - ::memset(_has_bits_, 0, sizeof(_has_bits_)); - mutable_unknown_fields()->Clear(); -} - -bool ServiceOptions::MergePartialFromCodedStream( - ::google::protobuf::io::CodedInputStream* input) { -#define DO_(EXPRESSION) if (!(EXPRESSION)) return false - ::google::protobuf::uint32 tag; - while ((tag = input->ReadTag()) != 0) { - switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { - // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; - case 999: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) { - parse_uninterpreted_option: - DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual( - input, add_uninterpreted_option())); - } else { - goto handle_uninterpreted; - } - if (input->ExpectTag(7994)) goto parse_uninterpreted_option; - if (input->ExpectAtEnd()) return true; - break; - } - - default: { - handle_uninterpreted: - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) { - return true; - } - if ((8000u <= tag)) { - DO_(_extensions_.ParseField(tag, input, default_instance_, - mutable_unknown_fields())); - continue; - } - DO_(::google::protobuf::internal::WireFormat::SkipField( - input, tag, mutable_unknown_fields())); - break; - } - } - } - return true; -#undef DO_ -} - -void ServiceOptions::SerializeWithCachedSizes( - ::google::protobuf::io::CodedOutputStream* output) const { - // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; - for (int i = 0; i < this->uninterpreted_option_size(); i++) { - ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( - 999, this->uninterpreted_option(i), output); - } - - // Extension range [1000, 536870912) - _extensions_.SerializeWithCachedSizes( - 1000, 536870912, output); - - if (!unknown_fields().empty()) { - ::google::protobuf::internal::WireFormat::SerializeUnknownFields( - unknown_fields(), output); - } -} - -::google::protobuf::uint8* ServiceOptions::SerializeWithCachedSizesToArray( - ::google::protobuf::uint8* target) const { - // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; - for (int i = 0; i < this->uninterpreted_option_size(); i++) { - target = ::google::protobuf::internal::WireFormatLite:: - WriteMessageNoVirtualToArray( - 999, this->uninterpreted_option(i), target); - } - - // Extension range [1000, 536870912) - target = _extensions_.SerializeWithCachedSizesToArray( - 1000, 536870912, target); - - if (!unknown_fields().empty()) { - target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray( - unknown_fields(), target); - } - return target; -} - -int ServiceOptions::ByteSize() const { - int total_size = 0; - - // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; - total_size += 2 * this->uninterpreted_option_size(); - for (int i = 0; i < this->uninterpreted_option_size(); i++) { - total_size += - ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( - this->uninterpreted_option(i)); - } - - total_size += _extensions_.ByteSize(); - - if (!unknown_fields().empty()) { - total_size += - ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( - unknown_fields()); - } - GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); - _cached_size_ = total_size; - GOOGLE_SAFE_CONCURRENT_WRITES_END(); - return total_size; -} - -void ServiceOptions::MergeFrom(const ::google::protobuf::Message& from) { - GOOGLE_CHECK_NE(&from, this); - const ServiceOptions* source = - ::google::protobuf::internal::dynamic_cast_if_available( - &from); - if (source == NULL) { - ::google::protobuf::internal::ReflectionOps::Merge(from, this); - } else { - MergeFrom(*source); - } -} - -void ServiceOptions::MergeFrom(const ServiceOptions& from) { - GOOGLE_CHECK_NE(&from, this); - uninterpreted_option_.MergeFrom(from.uninterpreted_option_); - _extensions_.MergeFrom(from._extensions_); - mutable_unknown_fields()->MergeFrom(from.unknown_fields()); -} - -void ServiceOptions::CopyFrom(const ::google::protobuf::Message& from) { - if (&from == this) return; - Clear(); - MergeFrom(from); -} - -void ServiceOptions::CopyFrom(const ServiceOptions& from) { - if (&from == this) return; - Clear(); - MergeFrom(from); -} - -bool ServiceOptions::IsInitialized() const { - - for (int i = 0; i < uninterpreted_option_size(); i++) { - if (!this->uninterpreted_option(i).IsInitialized()) return false; - } - - if (!_extensions_.IsInitialized()) return false; return true; -} - -void ServiceOptions::Swap(ServiceOptions* other) { - if (other != this) { - uninterpreted_option_.Swap(&other->uninterpreted_option_); - std::swap(_has_bits_[0], other->_has_bits_[0]); - _unknown_fields_.Swap(&other->_unknown_fields_); - std::swap(_cached_size_, other->_cached_size_); - _extensions_.Swap(&other->_extensions_); - } -} - -::google::protobuf::Metadata ServiceOptions::GetMetadata() const { - protobuf_AssignDescriptorsOnce(); - ::google::protobuf::Metadata metadata; - metadata.descriptor = ServiceOptions_descriptor_; - metadata.reflection = ServiceOptions_reflection_; - return metadata; -} - - -// =================================================================== - -#ifndef _MSC_VER -const int MethodOptions::kUninterpretedOptionFieldNumber; -#endif // !_MSC_VER - -MethodOptions::MethodOptions() - : ::google::protobuf::Message() { - SharedCtor(); -} - -void MethodOptions::InitAsDefaultInstance() { -} - -MethodOptions::MethodOptions(const MethodOptions& from) - : ::google::protobuf::Message() { - SharedCtor(); - MergeFrom(from); -} - -void MethodOptions::SharedCtor() { - _cached_size_ = 0; - ::memset(_has_bits_, 0, sizeof(_has_bits_)); -} - -MethodOptions::~MethodOptions() { - SharedDtor(); -} - -void MethodOptions::SharedDtor() { - if (this != default_instance_) { - } -} - -void MethodOptions::SetCachedSize(int size) const { - GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); - _cached_size_ = size; - GOOGLE_SAFE_CONCURRENT_WRITES_END(); -} -const ::google::protobuf::Descriptor* MethodOptions::descriptor() { - protobuf_AssignDescriptorsOnce(); - return MethodOptions_descriptor_; -} - -const MethodOptions& MethodOptions::default_instance() { - if (default_instance_ == NULL) protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto(); - return *default_instance_; -} - -MethodOptions* MethodOptions::default_instance_ = NULL; - -MethodOptions* MethodOptions::New() const { - return new MethodOptions; -} - -void MethodOptions::Clear() { - _extensions_.Clear(); - uninterpreted_option_.Clear(); - ::memset(_has_bits_, 0, sizeof(_has_bits_)); - mutable_unknown_fields()->Clear(); -} - -bool MethodOptions::MergePartialFromCodedStream( - ::google::protobuf::io::CodedInputStream* input) { -#define DO_(EXPRESSION) if (!(EXPRESSION)) return false - ::google::protobuf::uint32 tag; - while ((tag = input->ReadTag()) != 0) { - switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { - // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; - case 999: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) { - parse_uninterpreted_option: - DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual( - input, add_uninterpreted_option())); - } else { - goto handle_uninterpreted; - } - if (input->ExpectTag(7994)) goto parse_uninterpreted_option; - if (input->ExpectAtEnd()) return true; - break; - } - - default: { - handle_uninterpreted: - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) { - return true; - } - if ((8000u <= tag)) { - DO_(_extensions_.ParseField(tag, input, default_instance_, - mutable_unknown_fields())); - continue; - } - DO_(::google::protobuf::internal::WireFormat::SkipField( - input, tag, mutable_unknown_fields())); - break; - } - } - } - return true; -#undef DO_ -} - -void MethodOptions::SerializeWithCachedSizes( - ::google::protobuf::io::CodedOutputStream* output) const { - // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; - for (int i = 0; i < this->uninterpreted_option_size(); i++) { - ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( - 999, this->uninterpreted_option(i), output); - } - - // Extension range [1000, 536870912) - _extensions_.SerializeWithCachedSizes( - 1000, 536870912, output); - - if (!unknown_fields().empty()) { - ::google::protobuf::internal::WireFormat::SerializeUnknownFields( - unknown_fields(), output); - } -} - -::google::protobuf::uint8* MethodOptions::SerializeWithCachedSizesToArray( - ::google::protobuf::uint8* target) const { - // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; - for (int i = 0; i < this->uninterpreted_option_size(); i++) { - target = ::google::protobuf::internal::WireFormatLite:: - WriteMessageNoVirtualToArray( - 999, this->uninterpreted_option(i), target); - } - - // Extension range [1000, 536870912) - target = _extensions_.SerializeWithCachedSizesToArray( - 1000, 536870912, target); - - if (!unknown_fields().empty()) { - target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray( - unknown_fields(), target); - } - return target; -} - -int MethodOptions::ByteSize() const { - int total_size = 0; - - // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; - total_size += 2 * this->uninterpreted_option_size(); - for (int i = 0; i < this->uninterpreted_option_size(); i++) { - total_size += - ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( - this->uninterpreted_option(i)); - } - - total_size += _extensions_.ByteSize(); - - if (!unknown_fields().empty()) { - total_size += - ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( - unknown_fields()); - } - GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); - _cached_size_ = total_size; - GOOGLE_SAFE_CONCURRENT_WRITES_END(); - return total_size; -} - -void MethodOptions::MergeFrom(const ::google::protobuf::Message& from) { - GOOGLE_CHECK_NE(&from, this); - const MethodOptions* source = - ::google::protobuf::internal::dynamic_cast_if_available( - &from); - if (source == NULL) { - ::google::protobuf::internal::ReflectionOps::Merge(from, this); - } else { - MergeFrom(*source); - } -} - -void MethodOptions::MergeFrom(const MethodOptions& from) { - GOOGLE_CHECK_NE(&from, this); - uninterpreted_option_.MergeFrom(from.uninterpreted_option_); - _extensions_.MergeFrom(from._extensions_); - mutable_unknown_fields()->MergeFrom(from.unknown_fields()); -} - -void MethodOptions::CopyFrom(const ::google::protobuf::Message& from) { - if (&from == this) return; - Clear(); - MergeFrom(from); -} - -void MethodOptions::CopyFrom(const MethodOptions& from) { - if (&from == this) return; - Clear(); - MergeFrom(from); -} - -bool MethodOptions::IsInitialized() const { - - for (int i = 0; i < uninterpreted_option_size(); i++) { - if (!this->uninterpreted_option(i).IsInitialized()) return false; - } - - if (!_extensions_.IsInitialized()) return false; return true; -} - -void MethodOptions::Swap(MethodOptions* other) { - if (other != this) { - uninterpreted_option_.Swap(&other->uninterpreted_option_); - std::swap(_has_bits_[0], other->_has_bits_[0]); - _unknown_fields_.Swap(&other->_unknown_fields_); - std::swap(_cached_size_, other->_cached_size_); - _extensions_.Swap(&other->_extensions_); - } -} - -::google::protobuf::Metadata MethodOptions::GetMetadata() const { - protobuf_AssignDescriptorsOnce(); - ::google::protobuf::Metadata metadata; - metadata.descriptor = MethodOptions_descriptor_; - metadata.reflection = MethodOptions_reflection_; - return metadata; -} - - -// =================================================================== - -#ifndef _MSC_VER -const int UninterpretedOption_NamePart::kNamePartFieldNumber; -const int UninterpretedOption_NamePart::kIsExtensionFieldNumber; -#endif // !_MSC_VER - -UninterpretedOption_NamePart::UninterpretedOption_NamePart() - : ::google::protobuf::Message() { - SharedCtor(); -} - -void UninterpretedOption_NamePart::InitAsDefaultInstance() { -} - -UninterpretedOption_NamePart::UninterpretedOption_NamePart(const UninterpretedOption_NamePart& from) - : ::google::protobuf::Message() { - SharedCtor(); - MergeFrom(from); -} - -void UninterpretedOption_NamePart::SharedCtor() { - _cached_size_ = 0; - name_part_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); - is_extension_ = false; - ::memset(_has_bits_, 0, sizeof(_has_bits_)); -} - -UninterpretedOption_NamePart::~UninterpretedOption_NamePart() { - SharedDtor(); -} - -void UninterpretedOption_NamePart::SharedDtor() { - if (name_part_ != &::google::protobuf::internal::kEmptyString) { - delete name_part_; - } - if (this != default_instance_) { - } -} - -void UninterpretedOption_NamePart::SetCachedSize(int size) const { - GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); - _cached_size_ = size; - GOOGLE_SAFE_CONCURRENT_WRITES_END(); -} -const ::google::protobuf::Descriptor* UninterpretedOption_NamePart::descriptor() { - protobuf_AssignDescriptorsOnce(); - return UninterpretedOption_NamePart_descriptor_; -} - -const UninterpretedOption_NamePart& UninterpretedOption_NamePart::default_instance() { - if (default_instance_ == NULL) protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto(); - return *default_instance_; -} - -UninterpretedOption_NamePart* UninterpretedOption_NamePart::default_instance_ = NULL; - -UninterpretedOption_NamePart* UninterpretedOption_NamePart::New() const { - return new UninterpretedOption_NamePart; -} - -void UninterpretedOption_NamePart::Clear() { - if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) { - if (has_name_part()) { - if (name_part_ != &::google::protobuf::internal::kEmptyString) { - name_part_->clear(); - } - } - is_extension_ = false; - } - ::memset(_has_bits_, 0, sizeof(_has_bits_)); - mutable_unknown_fields()->Clear(); -} - -bool UninterpretedOption_NamePart::MergePartialFromCodedStream( - ::google::protobuf::io::CodedInputStream* input) { -#define DO_(EXPRESSION) if (!(EXPRESSION)) return false - ::google::protobuf::uint32 tag; - while ((tag = input->ReadTag()) != 0) { - switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { - // required string name_part = 1; - case 1: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) { - DO_(::google::protobuf::internal::WireFormatLite::ReadString( - input, this->mutable_name_part())); - ::google::protobuf::internal::WireFormat::VerifyUTF8String( - this->name_part().data(), this->name_part().length(), - ::google::protobuf::internal::WireFormat::PARSE); - } else { - goto handle_uninterpreted; - } - if (input->ExpectTag(16)) goto parse_is_extension; - break; - } - - // required bool is_extension = 2; - case 2: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) { - parse_is_extension: - DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< - bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>( - input, &is_extension_))); - set_has_is_extension(); - } else { - goto handle_uninterpreted; - } - if (input->ExpectAtEnd()) return true; - break; - } - - default: { - handle_uninterpreted: - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) { - return true; - } - DO_(::google::protobuf::internal::WireFormat::SkipField( - input, tag, mutable_unknown_fields())); - break; - } - } - } - return true; -#undef DO_ -} - -void UninterpretedOption_NamePart::SerializeWithCachedSizes( - ::google::protobuf::io::CodedOutputStream* output) const { - // required string name_part = 1; - if (has_name_part()) { - ::google::protobuf::internal::WireFormat::VerifyUTF8String( - this->name_part().data(), this->name_part().length(), - ::google::protobuf::internal::WireFormat::SERIALIZE); - ::google::protobuf::internal::WireFormatLite::WriteString( - 1, this->name_part(), output); - } - - // required bool is_extension = 2; - if (has_is_extension()) { - ::google::protobuf::internal::WireFormatLite::WriteBool(2, this->is_extension(), output); - } - - if (!unknown_fields().empty()) { - ::google::protobuf::internal::WireFormat::SerializeUnknownFields( - unknown_fields(), output); - } -} - -::google::protobuf::uint8* UninterpretedOption_NamePart::SerializeWithCachedSizesToArray( - ::google::protobuf::uint8* target) const { - // required string name_part = 1; - if (has_name_part()) { - ::google::protobuf::internal::WireFormat::VerifyUTF8String( - this->name_part().data(), this->name_part().length(), - ::google::protobuf::internal::WireFormat::SERIALIZE); - target = - ::google::protobuf::internal::WireFormatLite::WriteStringToArray( - 1, this->name_part(), target); - } - - // required bool is_extension = 2; - if (has_is_extension()) { - target = ::google::protobuf::internal::WireFormatLite::WriteBoolToArray(2, this->is_extension(), target); - } - - if (!unknown_fields().empty()) { - target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray( - unknown_fields(), target); - } - return target; -} - -int UninterpretedOption_NamePart::ByteSize() const { - int total_size = 0; - - if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) { - // required string name_part = 1; - if (has_name_part()) { - total_size += 1 + - ::google::protobuf::internal::WireFormatLite::StringSize( - this->name_part()); - } - - // required bool is_extension = 2; - if (has_is_extension()) { - total_size += 1 + 1; - } - - } - if (!unknown_fields().empty()) { - total_size += - ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( - unknown_fields()); - } - GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); - _cached_size_ = total_size; - GOOGLE_SAFE_CONCURRENT_WRITES_END(); - return total_size; -} - -void UninterpretedOption_NamePart::MergeFrom(const ::google::protobuf::Message& from) { - GOOGLE_CHECK_NE(&from, this); - const UninterpretedOption_NamePart* source = - ::google::protobuf::internal::dynamic_cast_if_available( - &from); - if (source == NULL) { - ::google::protobuf::internal::ReflectionOps::Merge(from, this); - } else { - MergeFrom(*source); - } -} - -void UninterpretedOption_NamePart::MergeFrom(const UninterpretedOption_NamePart& from) { - GOOGLE_CHECK_NE(&from, this); - if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) { - if (from.has_name_part()) { - set_name_part(from.name_part()); - } - if (from.has_is_extension()) { - set_is_extension(from.is_extension()); - } - } - mutable_unknown_fields()->MergeFrom(from.unknown_fields()); -} - -void UninterpretedOption_NamePart::CopyFrom(const ::google::protobuf::Message& from) { - if (&from == this) return; - Clear(); - MergeFrom(from); -} - -void UninterpretedOption_NamePart::CopyFrom(const UninterpretedOption_NamePart& from) { - if (&from == this) return; - Clear(); - MergeFrom(from); -} - -bool UninterpretedOption_NamePart::IsInitialized() const { - if ((_has_bits_[0] & 0x00000003) != 0x00000003) return false; - - return true; -} - -void UninterpretedOption_NamePart::Swap(UninterpretedOption_NamePart* other) { - if (other != this) { - std::swap(name_part_, other->name_part_); - std::swap(is_extension_, other->is_extension_); - std::swap(_has_bits_[0], other->_has_bits_[0]); - _unknown_fields_.Swap(&other->_unknown_fields_); - std::swap(_cached_size_, other->_cached_size_); - } -} - -::google::protobuf::Metadata UninterpretedOption_NamePart::GetMetadata() const { - protobuf_AssignDescriptorsOnce(); - ::google::protobuf::Metadata metadata; - metadata.descriptor = UninterpretedOption_NamePart_descriptor_; - metadata.reflection = UninterpretedOption_NamePart_reflection_; - return metadata; -} - - -// ------------------------------------------------------------------- - -#ifndef _MSC_VER -const int UninterpretedOption::kNameFieldNumber; -const int UninterpretedOption::kIdentifierValueFieldNumber; -const int UninterpretedOption::kPositiveIntValueFieldNumber; -const int UninterpretedOption::kNegativeIntValueFieldNumber; -const int UninterpretedOption::kDoubleValueFieldNumber; -const int UninterpretedOption::kStringValueFieldNumber; -const int UninterpretedOption::kAggregateValueFieldNumber; -#endif // !_MSC_VER - -UninterpretedOption::UninterpretedOption() - : ::google::protobuf::Message() { - SharedCtor(); -} - -void UninterpretedOption::InitAsDefaultInstance() { -} - -UninterpretedOption::UninterpretedOption(const UninterpretedOption& from) - : ::google::protobuf::Message() { - SharedCtor(); - MergeFrom(from); -} - -void UninterpretedOption::SharedCtor() { - _cached_size_ = 0; - identifier_value_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); - positive_int_value_ = GOOGLE_ULONGLONG(0); - negative_int_value_ = GOOGLE_LONGLONG(0); - double_value_ = 0; - string_value_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); - aggregate_value_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); - ::memset(_has_bits_, 0, sizeof(_has_bits_)); -} - -UninterpretedOption::~UninterpretedOption() { - SharedDtor(); -} - -void UninterpretedOption::SharedDtor() { - if (identifier_value_ != &::google::protobuf::internal::kEmptyString) { - delete identifier_value_; - } - if (string_value_ != &::google::protobuf::internal::kEmptyString) { - delete string_value_; - } - if (aggregate_value_ != &::google::protobuf::internal::kEmptyString) { - delete aggregate_value_; - } - if (this != default_instance_) { - } -} - -void UninterpretedOption::SetCachedSize(int size) const { - GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); - _cached_size_ = size; - GOOGLE_SAFE_CONCURRENT_WRITES_END(); -} -const ::google::protobuf::Descriptor* UninterpretedOption::descriptor() { - protobuf_AssignDescriptorsOnce(); - return UninterpretedOption_descriptor_; -} - -const UninterpretedOption& UninterpretedOption::default_instance() { - if (default_instance_ == NULL) protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto(); - return *default_instance_; -} - -UninterpretedOption* UninterpretedOption::default_instance_ = NULL; - -UninterpretedOption* UninterpretedOption::New() const { - return new UninterpretedOption; -} - -void UninterpretedOption::Clear() { - if (_has_bits_[1 / 32] & (0xffu << (1 % 32))) { - if (has_identifier_value()) { - if (identifier_value_ != &::google::protobuf::internal::kEmptyString) { - identifier_value_->clear(); - } - } - positive_int_value_ = GOOGLE_ULONGLONG(0); - negative_int_value_ = GOOGLE_LONGLONG(0); - double_value_ = 0; - if (has_string_value()) { - if (string_value_ != &::google::protobuf::internal::kEmptyString) { - string_value_->clear(); - } - } - if (has_aggregate_value()) { - if (aggregate_value_ != &::google::protobuf::internal::kEmptyString) { - aggregate_value_->clear(); - } - } - } - name_.Clear(); - ::memset(_has_bits_, 0, sizeof(_has_bits_)); - mutable_unknown_fields()->Clear(); -} - -bool UninterpretedOption::MergePartialFromCodedStream( - ::google::protobuf::io::CodedInputStream* input) { -#define DO_(EXPRESSION) if (!(EXPRESSION)) return false - ::google::protobuf::uint32 tag; - while ((tag = input->ReadTag()) != 0) { - switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { - // repeated .google.protobuf.UninterpretedOption.NamePart name = 2; - case 2: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) { - parse_name: - DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual( - input, add_name())); - } else { - goto handle_uninterpreted; - } - if (input->ExpectTag(18)) goto parse_name; - if (input->ExpectTag(26)) goto parse_identifier_value; - break; - } - - // optional string identifier_value = 3; - case 3: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) { - parse_identifier_value: - DO_(::google::protobuf::internal::WireFormatLite::ReadString( - input, this->mutable_identifier_value())); - ::google::protobuf::internal::WireFormat::VerifyUTF8String( - this->identifier_value().data(), this->identifier_value().length(), - ::google::protobuf::internal::WireFormat::PARSE); - } else { - goto handle_uninterpreted; - } - if (input->ExpectTag(32)) goto parse_positive_int_value; - break; - } - - // optional uint64 positive_int_value = 4; - case 4: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) { - parse_positive_int_value: - DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< - ::google::protobuf::uint64, ::google::protobuf::internal::WireFormatLite::TYPE_UINT64>( - input, &positive_int_value_))); - set_has_positive_int_value(); - } else { - goto handle_uninterpreted; - } - if (input->ExpectTag(40)) goto parse_negative_int_value; - break; - } - - // optional int64 negative_int_value = 5; - case 5: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) { - parse_negative_int_value: - DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< - ::google::protobuf::int64, ::google::protobuf::internal::WireFormatLite::TYPE_INT64>( - input, &negative_int_value_))); - set_has_negative_int_value(); - } else { - goto handle_uninterpreted; - } - if (input->ExpectTag(49)) goto parse_double_value; - break; - } - - // optional double double_value = 6; - case 6: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_FIXED64) { - parse_double_value: - DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< - double, ::google::protobuf::internal::WireFormatLite::TYPE_DOUBLE>( - input, &double_value_))); - set_has_double_value(); - } else { - goto handle_uninterpreted; - } - if (input->ExpectTag(58)) goto parse_string_value; - break; - } - - // optional bytes string_value = 7; - case 7: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) { - parse_string_value: - DO_(::google::protobuf::internal::WireFormatLite::ReadBytes( - input, this->mutable_string_value())); - } else { - goto handle_uninterpreted; - } - if (input->ExpectTag(66)) goto parse_aggregate_value; - break; - } - - // optional string aggregate_value = 8; - case 8: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) { - parse_aggregate_value: - DO_(::google::protobuf::internal::WireFormatLite::ReadString( - input, this->mutable_aggregate_value())); - ::google::protobuf::internal::WireFormat::VerifyUTF8String( - this->aggregate_value().data(), this->aggregate_value().length(), - ::google::protobuf::internal::WireFormat::PARSE); - } else { - goto handle_uninterpreted; - } - if (input->ExpectAtEnd()) return true; - break; - } - - default: { - handle_uninterpreted: - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) { - return true; - } - DO_(::google::protobuf::internal::WireFormat::SkipField( - input, tag, mutable_unknown_fields())); - break; - } - } - } - return true; -#undef DO_ -} - -void UninterpretedOption::SerializeWithCachedSizes( - ::google::protobuf::io::CodedOutputStream* output) const { - // repeated .google.protobuf.UninterpretedOption.NamePart name = 2; - for (int i = 0; i < this->name_size(); i++) { - ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( - 2, this->name(i), output); - } - - // optional string identifier_value = 3; - if (has_identifier_value()) { - ::google::protobuf::internal::WireFormat::VerifyUTF8String( - this->identifier_value().data(), this->identifier_value().length(), - ::google::protobuf::internal::WireFormat::SERIALIZE); - ::google::protobuf::internal::WireFormatLite::WriteString( - 3, this->identifier_value(), output); - } - - // optional uint64 positive_int_value = 4; - if (has_positive_int_value()) { - ::google::protobuf::internal::WireFormatLite::WriteUInt64(4, this->positive_int_value(), output); - } - - // optional int64 negative_int_value = 5; - if (has_negative_int_value()) { - ::google::protobuf::internal::WireFormatLite::WriteInt64(5, this->negative_int_value(), output); - } - - // optional double double_value = 6; - if (has_double_value()) { - ::google::protobuf::internal::WireFormatLite::WriteDouble(6, this->double_value(), output); - } - - // optional bytes string_value = 7; - if (has_string_value()) { - ::google::protobuf::internal::WireFormatLite::WriteBytes( - 7, this->string_value(), output); - } - - // optional string aggregate_value = 8; - if (has_aggregate_value()) { - ::google::protobuf::internal::WireFormat::VerifyUTF8String( - this->aggregate_value().data(), this->aggregate_value().length(), - ::google::protobuf::internal::WireFormat::SERIALIZE); - ::google::protobuf::internal::WireFormatLite::WriteString( - 8, this->aggregate_value(), output); - } - - if (!unknown_fields().empty()) { - ::google::protobuf::internal::WireFormat::SerializeUnknownFields( - unknown_fields(), output); - } -} - -::google::protobuf::uint8* UninterpretedOption::SerializeWithCachedSizesToArray( - ::google::protobuf::uint8* target) const { - // repeated .google.protobuf.UninterpretedOption.NamePart name = 2; - for (int i = 0; i < this->name_size(); i++) { - target = ::google::protobuf::internal::WireFormatLite:: - WriteMessageNoVirtualToArray( - 2, this->name(i), target); - } - - // optional string identifier_value = 3; - if (has_identifier_value()) { - ::google::protobuf::internal::WireFormat::VerifyUTF8String( - this->identifier_value().data(), this->identifier_value().length(), - ::google::protobuf::internal::WireFormat::SERIALIZE); - target = - ::google::protobuf::internal::WireFormatLite::WriteStringToArray( - 3, this->identifier_value(), target); - } - - // optional uint64 positive_int_value = 4; - if (has_positive_int_value()) { - target = ::google::protobuf::internal::WireFormatLite::WriteUInt64ToArray(4, this->positive_int_value(), target); - } - - // optional int64 negative_int_value = 5; - if (has_negative_int_value()) { - target = ::google::protobuf::internal::WireFormatLite::WriteInt64ToArray(5, this->negative_int_value(), target); - } - - // optional double double_value = 6; - if (has_double_value()) { - target = ::google::protobuf::internal::WireFormatLite::WriteDoubleToArray(6, this->double_value(), target); - } - - // optional bytes string_value = 7; - if (has_string_value()) { - target = - ::google::protobuf::internal::WireFormatLite::WriteBytesToArray( - 7, this->string_value(), target); - } - - // optional string aggregate_value = 8; - if (has_aggregate_value()) { - ::google::protobuf::internal::WireFormat::VerifyUTF8String( - this->aggregate_value().data(), this->aggregate_value().length(), - ::google::protobuf::internal::WireFormat::SERIALIZE); - target = - ::google::protobuf::internal::WireFormatLite::WriteStringToArray( - 8, this->aggregate_value(), target); - } - - if (!unknown_fields().empty()) { - target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray( - unknown_fields(), target); - } - return target; -} - -int UninterpretedOption::ByteSize() const { - int total_size = 0; - - if (_has_bits_[1 / 32] & (0xffu << (1 % 32))) { - // optional string identifier_value = 3; - if (has_identifier_value()) { - total_size += 1 + - ::google::protobuf::internal::WireFormatLite::StringSize( - this->identifier_value()); - } - - // optional uint64 positive_int_value = 4; - if (has_positive_int_value()) { - total_size += 1 + - ::google::protobuf::internal::WireFormatLite::UInt64Size( - this->positive_int_value()); - } - - // optional int64 negative_int_value = 5; - if (has_negative_int_value()) { - total_size += 1 + - ::google::protobuf::internal::WireFormatLite::Int64Size( - this->negative_int_value()); - } - - // optional double double_value = 6; - if (has_double_value()) { - total_size += 1 + 8; - } - - // optional bytes string_value = 7; - if (has_string_value()) { - total_size += 1 + - ::google::protobuf::internal::WireFormatLite::BytesSize( - this->string_value()); - } - - // optional string aggregate_value = 8; - if (has_aggregate_value()) { - total_size += 1 + - ::google::protobuf::internal::WireFormatLite::StringSize( - this->aggregate_value()); - } - - } - // repeated .google.protobuf.UninterpretedOption.NamePart name = 2; - total_size += 1 * this->name_size(); - for (int i = 0; i < this->name_size(); i++) { - total_size += - ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( - this->name(i)); - } - - if (!unknown_fields().empty()) { - total_size += - ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( - unknown_fields()); - } - GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); - _cached_size_ = total_size; - GOOGLE_SAFE_CONCURRENT_WRITES_END(); - return total_size; -} - -void UninterpretedOption::MergeFrom(const ::google::protobuf::Message& from) { - GOOGLE_CHECK_NE(&from, this); - const UninterpretedOption* source = - ::google::protobuf::internal::dynamic_cast_if_available( - &from); - if (source == NULL) { - ::google::protobuf::internal::ReflectionOps::Merge(from, this); - } else { - MergeFrom(*source); - } -} - -void UninterpretedOption::MergeFrom(const UninterpretedOption& from) { - GOOGLE_CHECK_NE(&from, this); - name_.MergeFrom(from.name_); - if (from._has_bits_[1 / 32] & (0xffu << (1 % 32))) { - if (from.has_identifier_value()) { - set_identifier_value(from.identifier_value()); - } - if (from.has_positive_int_value()) { - set_positive_int_value(from.positive_int_value()); - } - if (from.has_negative_int_value()) { - set_negative_int_value(from.negative_int_value()); - } - if (from.has_double_value()) { - set_double_value(from.double_value()); - } - if (from.has_string_value()) { - set_string_value(from.string_value()); - } - if (from.has_aggregate_value()) { - set_aggregate_value(from.aggregate_value()); - } - } - mutable_unknown_fields()->MergeFrom(from.unknown_fields()); -} - -void UninterpretedOption::CopyFrom(const ::google::protobuf::Message& from) { - if (&from == this) return; - Clear(); - MergeFrom(from); -} - -void UninterpretedOption::CopyFrom(const UninterpretedOption& from) { - if (&from == this) return; - Clear(); - MergeFrom(from); -} - -bool UninterpretedOption::IsInitialized() const { - - for (int i = 0; i < name_size(); i++) { - if (!this->name(i).IsInitialized()) return false; - } - return true; -} - -void UninterpretedOption::Swap(UninterpretedOption* other) { - if (other != this) { - name_.Swap(&other->name_); - std::swap(identifier_value_, other->identifier_value_); - std::swap(positive_int_value_, other->positive_int_value_); - std::swap(negative_int_value_, other->negative_int_value_); - std::swap(double_value_, other->double_value_); - std::swap(string_value_, other->string_value_); - std::swap(aggregate_value_, other->aggregate_value_); - std::swap(_has_bits_[0], other->_has_bits_[0]); - _unknown_fields_.Swap(&other->_unknown_fields_); - std::swap(_cached_size_, other->_cached_size_); - } -} - -::google::protobuf::Metadata UninterpretedOption::GetMetadata() const { - protobuf_AssignDescriptorsOnce(); - ::google::protobuf::Metadata metadata; - metadata.descriptor = UninterpretedOption_descriptor_; - metadata.reflection = UninterpretedOption_reflection_; - return metadata; -} - - -// =================================================================== - -#ifndef _MSC_VER -const int SourceCodeInfo_Location::kPathFieldNumber; -const int SourceCodeInfo_Location::kSpanFieldNumber; -const int SourceCodeInfo_Location::kLeadingCommentsFieldNumber; -const int SourceCodeInfo_Location::kTrailingCommentsFieldNumber; -#endif // !_MSC_VER - -SourceCodeInfo_Location::SourceCodeInfo_Location() - : ::google::protobuf::Message() { - SharedCtor(); -} - -void SourceCodeInfo_Location::InitAsDefaultInstance() { -} - -SourceCodeInfo_Location::SourceCodeInfo_Location(const SourceCodeInfo_Location& from) - : ::google::protobuf::Message() { - SharedCtor(); - MergeFrom(from); -} - -void SourceCodeInfo_Location::SharedCtor() { - _cached_size_ = 0; - leading_comments_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); - trailing_comments_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); - ::memset(_has_bits_, 0, sizeof(_has_bits_)); -} - -SourceCodeInfo_Location::~SourceCodeInfo_Location() { - SharedDtor(); -} - -void SourceCodeInfo_Location::SharedDtor() { - if (leading_comments_ != &::google::protobuf::internal::kEmptyString) { - delete leading_comments_; - } - if (trailing_comments_ != &::google::protobuf::internal::kEmptyString) { - delete trailing_comments_; - } - if (this != default_instance_) { - } -} - -void SourceCodeInfo_Location::SetCachedSize(int size) const { - GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); - _cached_size_ = size; - GOOGLE_SAFE_CONCURRENT_WRITES_END(); -} -const ::google::protobuf::Descriptor* SourceCodeInfo_Location::descriptor() { - protobuf_AssignDescriptorsOnce(); - return SourceCodeInfo_Location_descriptor_; -} - -const SourceCodeInfo_Location& SourceCodeInfo_Location::default_instance() { - if (default_instance_ == NULL) protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto(); - return *default_instance_; -} - -SourceCodeInfo_Location* SourceCodeInfo_Location::default_instance_ = NULL; - -SourceCodeInfo_Location* SourceCodeInfo_Location::New() const { - return new SourceCodeInfo_Location; -} - -void SourceCodeInfo_Location::Clear() { - if (_has_bits_[2 / 32] & (0xffu << (2 % 32))) { - if (has_leading_comments()) { - if (leading_comments_ != &::google::protobuf::internal::kEmptyString) { - leading_comments_->clear(); - } - } - if (has_trailing_comments()) { - if (trailing_comments_ != &::google::protobuf::internal::kEmptyString) { - trailing_comments_->clear(); - } - } - } - path_.Clear(); - span_.Clear(); - ::memset(_has_bits_, 0, sizeof(_has_bits_)); - mutable_unknown_fields()->Clear(); -} - -bool SourceCodeInfo_Location::MergePartialFromCodedStream( - ::google::protobuf::io::CodedInputStream* input) { -#define DO_(EXPRESSION) if (!(EXPRESSION)) return false - ::google::protobuf::uint32 tag; - while ((tag = input->ReadTag()) != 0) { - switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { - // repeated int32 path = 1 [packed = true]; - case 1: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) { - DO_((::google::protobuf::internal::WireFormatLite::ReadPackedPrimitive< - ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>( - input, this->mutable_path()))); - } else if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) - == ::google::protobuf::internal::WireFormatLite:: - WIRETYPE_VARINT) { - DO_((::google::protobuf::internal::WireFormatLite::ReadRepeatedPrimitiveNoInline< - ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>( - 1, 10, input, this->mutable_path()))); - } else { - goto handle_uninterpreted; - } - if (input->ExpectTag(18)) goto parse_span; - break; - } - - // repeated int32 span = 2 [packed = true]; - case 2: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) { - parse_span: - DO_((::google::protobuf::internal::WireFormatLite::ReadPackedPrimitive< - ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>( - input, this->mutable_span()))); - } else if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) - == ::google::protobuf::internal::WireFormatLite:: - WIRETYPE_VARINT) { - DO_((::google::protobuf::internal::WireFormatLite::ReadRepeatedPrimitiveNoInline< - ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>( - 1, 18, input, this->mutable_span()))); - } else { - goto handle_uninterpreted; - } - if (input->ExpectTag(26)) goto parse_leading_comments; - break; - } - - // optional string leading_comments = 3; - case 3: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) { - parse_leading_comments: - DO_(::google::protobuf::internal::WireFormatLite::ReadString( - input, this->mutable_leading_comments())); - ::google::protobuf::internal::WireFormat::VerifyUTF8String( - this->leading_comments().data(), this->leading_comments().length(), - ::google::protobuf::internal::WireFormat::PARSE); - } else { - goto handle_uninterpreted; - } - if (input->ExpectTag(34)) goto parse_trailing_comments; - break; - } - - // optional string trailing_comments = 4; - case 4: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) { - parse_trailing_comments: - DO_(::google::protobuf::internal::WireFormatLite::ReadString( - input, this->mutable_trailing_comments())); - ::google::protobuf::internal::WireFormat::VerifyUTF8String( - this->trailing_comments().data(), this->trailing_comments().length(), - ::google::protobuf::internal::WireFormat::PARSE); - } else { - goto handle_uninterpreted; - } - if (input->ExpectAtEnd()) return true; - break; - } - - default: { - handle_uninterpreted: - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) { - return true; - } - DO_(::google::protobuf::internal::WireFormat::SkipField( - input, tag, mutable_unknown_fields())); - break; - } - } - } - return true; -#undef DO_ -} - -void SourceCodeInfo_Location::SerializeWithCachedSizes( - ::google::protobuf::io::CodedOutputStream* output) const { - // repeated int32 path = 1 [packed = true]; - if (this->path_size() > 0) { - ::google::protobuf::internal::WireFormatLite::WriteTag(1, ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED, output); - output->WriteVarint32(_path_cached_byte_size_); - } - for (int i = 0; i < this->path_size(); i++) { - ::google::protobuf::internal::WireFormatLite::WriteInt32NoTag( - this->path(i), output); - } - - // repeated int32 span = 2 [packed = true]; - if (this->span_size() > 0) { - ::google::protobuf::internal::WireFormatLite::WriteTag(2, ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED, output); - output->WriteVarint32(_span_cached_byte_size_); - } - for (int i = 0; i < this->span_size(); i++) { - ::google::protobuf::internal::WireFormatLite::WriteInt32NoTag( - this->span(i), output); - } - - // optional string leading_comments = 3; - if (has_leading_comments()) { - ::google::protobuf::internal::WireFormat::VerifyUTF8String( - this->leading_comments().data(), this->leading_comments().length(), - ::google::protobuf::internal::WireFormat::SERIALIZE); - ::google::protobuf::internal::WireFormatLite::WriteString( - 3, this->leading_comments(), output); - } - - // optional string trailing_comments = 4; - if (has_trailing_comments()) { - ::google::protobuf::internal::WireFormat::VerifyUTF8String( - this->trailing_comments().data(), this->trailing_comments().length(), - ::google::protobuf::internal::WireFormat::SERIALIZE); - ::google::protobuf::internal::WireFormatLite::WriteString( - 4, this->trailing_comments(), output); - } - - if (!unknown_fields().empty()) { - ::google::protobuf::internal::WireFormat::SerializeUnknownFields( - unknown_fields(), output); - } -} - -::google::protobuf::uint8* SourceCodeInfo_Location::SerializeWithCachedSizesToArray( - ::google::protobuf::uint8* target) const { - // repeated int32 path = 1 [packed = true]; - if (this->path_size() > 0) { - target = ::google::protobuf::internal::WireFormatLite::WriteTagToArray( - 1, - ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED, - target); - target = ::google::protobuf::io::CodedOutputStream::WriteVarint32ToArray( - _path_cached_byte_size_, target); - } - for (int i = 0; i < this->path_size(); i++) { - target = ::google::protobuf::internal::WireFormatLite:: - WriteInt32NoTagToArray(this->path(i), target); - } - - // repeated int32 span = 2 [packed = true]; - if (this->span_size() > 0) { - target = ::google::protobuf::internal::WireFormatLite::WriteTagToArray( - 2, - ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED, - target); - target = ::google::protobuf::io::CodedOutputStream::WriteVarint32ToArray( - _span_cached_byte_size_, target); - } - for (int i = 0; i < this->span_size(); i++) { - target = ::google::protobuf::internal::WireFormatLite:: - WriteInt32NoTagToArray(this->span(i), target); - } - - // optional string leading_comments = 3; - if (has_leading_comments()) { - ::google::protobuf::internal::WireFormat::VerifyUTF8String( - this->leading_comments().data(), this->leading_comments().length(), - ::google::protobuf::internal::WireFormat::SERIALIZE); - target = - ::google::protobuf::internal::WireFormatLite::WriteStringToArray( - 3, this->leading_comments(), target); - } - - // optional string trailing_comments = 4; - if (has_trailing_comments()) { - ::google::protobuf::internal::WireFormat::VerifyUTF8String( - this->trailing_comments().data(), this->trailing_comments().length(), - ::google::protobuf::internal::WireFormat::SERIALIZE); - target = - ::google::protobuf::internal::WireFormatLite::WriteStringToArray( - 4, this->trailing_comments(), target); - } - - if (!unknown_fields().empty()) { - target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray( - unknown_fields(), target); - } - return target; -} - -int SourceCodeInfo_Location::ByteSize() const { - int total_size = 0; - - if (_has_bits_[2 / 32] & (0xffu << (2 % 32))) { - // optional string leading_comments = 3; - if (has_leading_comments()) { - total_size += 1 + - ::google::protobuf::internal::WireFormatLite::StringSize( - this->leading_comments()); - } - - // optional string trailing_comments = 4; - if (has_trailing_comments()) { - total_size += 1 + - ::google::protobuf::internal::WireFormatLite::StringSize( - this->trailing_comments()); - } - - } - // repeated int32 path = 1 [packed = true]; - { - int data_size = 0; - for (int i = 0; i < this->path_size(); i++) { - data_size += ::google::protobuf::internal::WireFormatLite:: - Int32Size(this->path(i)); - } - if (data_size > 0) { - total_size += 1 + - ::google::protobuf::internal::WireFormatLite::Int32Size(data_size); - } - GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); - _path_cached_byte_size_ = data_size; - GOOGLE_SAFE_CONCURRENT_WRITES_END(); - total_size += data_size; - } - - // repeated int32 span = 2 [packed = true]; - { - int data_size = 0; - for (int i = 0; i < this->span_size(); i++) { - data_size += ::google::protobuf::internal::WireFormatLite:: - Int32Size(this->span(i)); - } - if (data_size > 0) { - total_size += 1 + - ::google::protobuf::internal::WireFormatLite::Int32Size(data_size); - } - GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); - _span_cached_byte_size_ = data_size; - GOOGLE_SAFE_CONCURRENT_WRITES_END(); - total_size += data_size; - } - - if (!unknown_fields().empty()) { - total_size += - ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( - unknown_fields()); - } - GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); - _cached_size_ = total_size; - GOOGLE_SAFE_CONCURRENT_WRITES_END(); - return total_size; -} - -void SourceCodeInfo_Location::MergeFrom(const ::google::protobuf::Message& from) { - GOOGLE_CHECK_NE(&from, this); - const SourceCodeInfo_Location* source = - ::google::protobuf::internal::dynamic_cast_if_available( - &from); - if (source == NULL) { - ::google::protobuf::internal::ReflectionOps::Merge(from, this); - } else { - MergeFrom(*source); - } -} - -void SourceCodeInfo_Location::MergeFrom(const SourceCodeInfo_Location& from) { - GOOGLE_CHECK_NE(&from, this); - path_.MergeFrom(from.path_); - span_.MergeFrom(from.span_); - if (from._has_bits_[2 / 32] & (0xffu << (2 % 32))) { - if (from.has_leading_comments()) { - set_leading_comments(from.leading_comments()); - } - if (from.has_trailing_comments()) { - set_trailing_comments(from.trailing_comments()); - } - } - mutable_unknown_fields()->MergeFrom(from.unknown_fields()); -} - -void SourceCodeInfo_Location::CopyFrom(const ::google::protobuf::Message& from) { - if (&from == this) return; - Clear(); - MergeFrom(from); -} - -void SourceCodeInfo_Location::CopyFrom(const SourceCodeInfo_Location& from) { - if (&from == this) return; - Clear(); - MergeFrom(from); -} - -bool SourceCodeInfo_Location::IsInitialized() const { - - return true; -} - -void SourceCodeInfo_Location::Swap(SourceCodeInfo_Location* other) { - if (other != this) { - path_.Swap(&other->path_); - span_.Swap(&other->span_); - std::swap(leading_comments_, other->leading_comments_); - std::swap(trailing_comments_, other->trailing_comments_); - std::swap(_has_bits_[0], other->_has_bits_[0]); - _unknown_fields_.Swap(&other->_unknown_fields_); - std::swap(_cached_size_, other->_cached_size_); - } -} - -::google::protobuf::Metadata SourceCodeInfo_Location::GetMetadata() const { - protobuf_AssignDescriptorsOnce(); - ::google::protobuf::Metadata metadata; - metadata.descriptor = SourceCodeInfo_Location_descriptor_; - metadata.reflection = SourceCodeInfo_Location_reflection_; - return metadata; -} - - -// ------------------------------------------------------------------- - -#ifndef _MSC_VER -const int SourceCodeInfo::kLocationFieldNumber; -#endif // !_MSC_VER - -SourceCodeInfo::SourceCodeInfo() - : ::google::protobuf::Message() { - SharedCtor(); -} - -void SourceCodeInfo::InitAsDefaultInstance() { -} - -SourceCodeInfo::SourceCodeInfo(const SourceCodeInfo& from) - : ::google::protobuf::Message() { - SharedCtor(); - MergeFrom(from); -} - -void SourceCodeInfo::SharedCtor() { - _cached_size_ = 0; - ::memset(_has_bits_, 0, sizeof(_has_bits_)); -} - -SourceCodeInfo::~SourceCodeInfo() { - SharedDtor(); -} - -void SourceCodeInfo::SharedDtor() { - if (this != default_instance_) { - } -} - -void SourceCodeInfo::SetCachedSize(int size) const { - GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); - _cached_size_ = size; - GOOGLE_SAFE_CONCURRENT_WRITES_END(); -} -const ::google::protobuf::Descriptor* SourceCodeInfo::descriptor() { - protobuf_AssignDescriptorsOnce(); - return SourceCodeInfo_descriptor_; -} - -const SourceCodeInfo& SourceCodeInfo::default_instance() { - if (default_instance_ == NULL) protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto(); - return *default_instance_; -} - -SourceCodeInfo* SourceCodeInfo::default_instance_ = NULL; - -SourceCodeInfo* SourceCodeInfo::New() const { - return new SourceCodeInfo; -} - -void SourceCodeInfo::Clear() { - location_.Clear(); - ::memset(_has_bits_, 0, sizeof(_has_bits_)); - mutable_unknown_fields()->Clear(); -} - -bool SourceCodeInfo::MergePartialFromCodedStream( - ::google::protobuf::io::CodedInputStream* input) { -#define DO_(EXPRESSION) if (!(EXPRESSION)) return false - ::google::protobuf::uint32 tag; - while ((tag = input->ReadTag()) != 0) { - switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { - // repeated .google.protobuf.SourceCodeInfo.Location location = 1; - case 1: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) { - parse_location: - DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual( - input, add_location())); - } else { - goto handle_uninterpreted; - } - if (input->ExpectTag(10)) goto parse_location; - if (input->ExpectAtEnd()) return true; - break; - } - - default: { - handle_uninterpreted: - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) { - return true; - } - DO_(::google::protobuf::internal::WireFormat::SkipField( - input, tag, mutable_unknown_fields())); - break; - } - } - } - return true; -#undef DO_ -} - -void SourceCodeInfo::SerializeWithCachedSizes( - ::google::protobuf::io::CodedOutputStream* output) const { - // repeated .google.protobuf.SourceCodeInfo.Location location = 1; - for (int i = 0; i < this->location_size(); i++) { - ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( - 1, this->location(i), output); - } - - if (!unknown_fields().empty()) { - ::google::protobuf::internal::WireFormat::SerializeUnknownFields( - unknown_fields(), output); - } -} - -::google::protobuf::uint8* SourceCodeInfo::SerializeWithCachedSizesToArray( - ::google::protobuf::uint8* target) const { - // repeated .google.protobuf.SourceCodeInfo.Location location = 1; - for (int i = 0; i < this->location_size(); i++) { - target = ::google::protobuf::internal::WireFormatLite:: - WriteMessageNoVirtualToArray( - 1, this->location(i), target); - } - - if (!unknown_fields().empty()) { - target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray( - unknown_fields(), target); - } - return target; -} - -int SourceCodeInfo::ByteSize() const { - int total_size = 0; - - // repeated .google.protobuf.SourceCodeInfo.Location location = 1; - total_size += 1 * this->location_size(); - for (int i = 0; i < this->location_size(); i++) { - total_size += - ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( - this->location(i)); - } - - if (!unknown_fields().empty()) { - total_size += - ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( - unknown_fields()); - } - GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); - _cached_size_ = total_size; - GOOGLE_SAFE_CONCURRENT_WRITES_END(); - return total_size; -} - -void SourceCodeInfo::MergeFrom(const ::google::protobuf::Message& from) { - GOOGLE_CHECK_NE(&from, this); - const SourceCodeInfo* source = - ::google::protobuf::internal::dynamic_cast_if_available( - &from); - if (source == NULL) { - ::google::protobuf::internal::ReflectionOps::Merge(from, this); - } else { - MergeFrom(*source); - } -} - -void SourceCodeInfo::MergeFrom(const SourceCodeInfo& from) { - GOOGLE_CHECK_NE(&from, this); - location_.MergeFrom(from.location_); - mutable_unknown_fields()->MergeFrom(from.unknown_fields()); -} - -void SourceCodeInfo::CopyFrom(const ::google::protobuf::Message& from) { - if (&from == this) return; - Clear(); - MergeFrom(from); -} - -void SourceCodeInfo::CopyFrom(const SourceCodeInfo& from) { - if (&from == this) return; - Clear(); - MergeFrom(from); -} - -bool SourceCodeInfo::IsInitialized() const { - - return true; -} - -void SourceCodeInfo::Swap(SourceCodeInfo* other) { - if (other != this) { - location_.Swap(&other->location_); - std::swap(_has_bits_[0], other->_has_bits_[0]); - _unknown_fields_.Swap(&other->_unknown_fields_); - std::swap(_cached_size_, other->_cached_size_); - } -} - -::google::protobuf::Metadata SourceCodeInfo::GetMetadata() const { - protobuf_AssignDescriptorsOnce(); - ::google::protobuf::Metadata metadata; - metadata.descriptor = SourceCodeInfo_descriptor_; - metadata.reflection = SourceCodeInfo_reflection_; - return metadata; -} - - -// @@protoc_insertion_point(namespace_scope) - -} // namespace protobuf -} // namespace google - -// @@protoc_insertion_point(global_scope) diff --git a/modules/dnn/3rdparty/protobuf/src/google/protobuf/descriptor.pb.h b/modules/dnn/3rdparty/protobuf/src/google/protobuf/descriptor.pb.h deleted file mode 100644 index 07cf8077c..000000000 --- a/modules/dnn/3rdparty/protobuf/src/google/protobuf/descriptor.pb.h +++ /dev/null @@ -1,5992 +0,0 @@ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: google/protobuf/descriptor.proto - -#ifndef PROTOBUF_google_2fprotobuf_2fdescriptor_2eproto__INCLUDED -#define PROTOBUF_google_2fprotobuf_2fdescriptor_2eproto__INCLUDED - -#include - -#include - -#if GOOGLE_PROTOBUF_VERSION < 2005000 -#error This file was generated by a newer version of protoc which is -#error incompatible with your Protocol Buffer headers. Please update -#error your headers. -#endif -#if 2005000 < GOOGLE_PROTOBUF_MIN_PROTOC_VERSION -#error This file was generated by an older version of protoc which is -#error incompatible with your Protocol Buffer headers. Please -#error regenerate this file with a newer version of protoc. -#endif - -#include -#include -#include -#include -#include -#include -// @@protoc_insertion_point(includes) - -namespace google { -namespace protobuf { - -// Internal implementation detail -- do not call these. -void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto(); -void protobuf_AssignDesc_google_2fprotobuf_2fdescriptor_2eproto(); -void protobuf_ShutdownFile_google_2fprotobuf_2fdescriptor_2eproto(); - -class FileDescriptorSet; -class FileDescriptorProto; -class DescriptorProto; -class DescriptorProto_ExtensionRange; -class FieldDescriptorProto; -class EnumDescriptorProto; -class EnumValueDescriptorProto; -class ServiceDescriptorProto; -class MethodDescriptorProto; -class FileOptions; -class MessageOptions; -class FieldOptions; -class EnumOptions; -class EnumValueOptions; -class ServiceOptions; -class MethodOptions; -class UninterpretedOption; -class UninterpretedOption_NamePart; -class SourceCodeInfo; -class SourceCodeInfo_Location; - -enum FieldDescriptorProto_Type { - FieldDescriptorProto_Type_TYPE_DOUBLE = 1, - FieldDescriptorProto_Type_TYPE_FLOAT = 2, - FieldDescriptorProto_Type_TYPE_INT64 = 3, - FieldDescriptorProto_Type_TYPE_UINT64 = 4, - FieldDescriptorProto_Type_TYPE_INT32 = 5, - FieldDescriptorProto_Type_TYPE_FIXED64 = 6, - FieldDescriptorProto_Type_TYPE_FIXED32 = 7, - FieldDescriptorProto_Type_TYPE_BOOL = 8, - FieldDescriptorProto_Type_TYPE_STRING = 9, - FieldDescriptorProto_Type_TYPE_GROUP = 10, - FieldDescriptorProto_Type_TYPE_MESSAGE = 11, - FieldDescriptorProto_Type_TYPE_BYTES = 12, - FieldDescriptorProto_Type_TYPE_UINT32 = 13, - FieldDescriptorProto_Type_TYPE_ENUM = 14, - FieldDescriptorProto_Type_TYPE_SFIXED32 = 15, - FieldDescriptorProto_Type_TYPE_SFIXED64 = 16, - FieldDescriptorProto_Type_TYPE_SINT32 = 17, - FieldDescriptorProto_Type_TYPE_SINT64 = 18 -}; -LIBPROTOBUF_EXPORT bool FieldDescriptorProto_Type_IsValid(int value); -const FieldDescriptorProto_Type FieldDescriptorProto_Type_Type_MIN = FieldDescriptorProto_Type_TYPE_DOUBLE; -const FieldDescriptorProto_Type FieldDescriptorProto_Type_Type_MAX = FieldDescriptorProto_Type_TYPE_SINT64; -const int FieldDescriptorProto_Type_Type_ARRAYSIZE = FieldDescriptorProto_Type_Type_MAX + 1; - -LIBPROTOBUF_EXPORT const ::google::protobuf::EnumDescriptor* FieldDescriptorProto_Type_descriptor(); -inline const ::std::string& FieldDescriptorProto_Type_Name(FieldDescriptorProto_Type value) { - return ::google::protobuf::internal::NameOfEnum( - FieldDescriptorProto_Type_descriptor(), value); -} -inline bool FieldDescriptorProto_Type_Parse( - const ::std::string& name, FieldDescriptorProto_Type* value) { - return ::google::protobuf::internal::ParseNamedEnum( - FieldDescriptorProto_Type_descriptor(), name, value); -} -enum FieldDescriptorProto_Label { - FieldDescriptorProto_Label_LABEL_OPTIONAL = 1, - FieldDescriptorProto_Label_LABEL_REQUIRED = 2, - FieldDescriptorProto_Label_LABEL_REPEATED = 3 -}; -LIBPROTOBUF_EXPORT bool FieldDescriptorProto_Label_IsValid(int value); -const FieldDescriptorProto_Label FieldDescriptorProto_Label_Label_MIN = FieldDescriptorProto_Label_LABEL_OPTIONAL; -const FieldDescriptorProto_Label FieldDescriptorProto_Label_Label_MAX = FieldDescriptorProto_Label_LABEL_REPEATED; -const int FieldDescriptorProto_Label_Label_ARRAYSIZE = FieldDescriptorProto_Label_Label_MAX + 1; - -LIBPROTOBUF_EXPORT const ::google::protobuf::EnumDescriptor* FieldDescriptorProto_Label_descriptor(); -inline const ::std::string& FieldDescriptorProto_Label_Name(FieldDescriptorProto_Label value) { - return ::google::protobuf::internal::NameOfEnum( - FieldDescriptorProto_Label_descriptor(), value); -} -inline bool FieldDescriptorProto_Label_Parse( - const ::std::string& name, FieldDescriptorProto_Label* value) { - return ::google::protobuf::internal::ParseNamedEnum( - FieldDescriptorProto_Label_descriptor(), name, value); -} -enum FileOptions_OptimizeMode { - FileOptions_OptimizeMode_SPEED = 1, - FileOptions_OptimizeMode_CODE_SIZE = 2, - FileOptions_OptimizeMode_LITE_RUNTIME = 3 -}; -LIBPROTOBUF_EXPORT bool FileOptions_OptimizeMode_IsValid(int value); -const FileOptions_OptimizeMode FileOptions_OptimizeMode_OptimizeMode_MIN = FileOptions_OptimizeMode_SPEED; -const FileOptions_OptimizeMode FileOptions_OptimizeMode_OptimizeMode_MAX = FileOptions_OptimizeMode_LITE_RUNTIME; -const int FileOptions_OptimizeMode_OptimizeMode_ARRAYSIZE = FileOptions_OptimizeMode_OptimizeMode_MAX + 1; - -LIBPROTOBUF_EXPORT const ::google::protobuf::EnumDescriptor* FileOptions_OptimizeMode_descriptor(); -inline const ::std::string& FileOptions_OptimizeMode_Name(FileOptions_OptimizeMode value) { - return ::google::protobuf::internal::NameOfEnum( - FileOptions_OptimizeMode_descriptor(), value); -} -inline bool FileOptions_OptimizeMode_Parse( - const ::std::string& name, FileOptions_OptimizeMode* value) { - return ::google::protobuf::internal::ParseNamedEnum( - FileOptions_OptimizeMode_descriptor(), name, value); -} -enum FieldOptions_CType { - FieldOptions_CType_STRING = 0, - FieldOptions_CType_CORD = 1, - FieldOptions_CType_STRING_PIECE = 2 -}; -LIBPROTOBUF_EXPORT bool FieldOptions_CType_IsValid(int value); -const FieldOptions_CType FieldOptions_CType_CType_MIN = FieldOptions_CType_STRING; -const FieldOptions_CType FieldOptions_CType_CType_MAX = FieldOptions_CType_STRING_PIECE; -const int FieldOptions_CType_CType_ARRAYSIZE = FieldOptions_CType_CType_MAX + 1; - -LIBPROTOBUF_EXPORT const ::google::protobuf::EnumDescriptor* FieldOptions_CType_descriptor(); -inline const ::std::string& FieldOptions_CType_Name(FieldOptions_CType value) { - return ::google::protobuf::internal::NameOfEnum( - FieldOptions_CType_descriptor(), value); -} -inline bool FieldOptions_CType_Parse( - const ::std::string& name, FieldOptions_CType* value) { - return ::google::protobuf::internal::ParseNamedEnum( - FieldOptions_CType_descriptor(), name, value); -} -// =================================================================== - -class LIBPROTOBUF_EXPORT FileDescriptorSet : public ::google::protobuf::Message { - public: - FileDescriptorSet(); - virtual ~FileDescriptorSet(); - - FileDescriptorSet(const FileDescriptorSet& from); - - inline FileDescriptorSet& operator=(const FileDescriptorSet& from) { - CopyFrom(from); - return *this; - } - - inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const { - return _unknown_fields_; - } - - inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() { - return &_unknown_fields_; - } - - static const ::google::protobuf::Descriptor* descriptor(); - static const FileDescriptorSet& default_instance(); - - void Swap(FileDescriptorSet* other); - - // implements Message ---------------------------------------------- - - FileDescriptorSet* New() const; - void CopyFrom(const ::google::protobuf::Message& from); - void MergeFrom(const ::google::protobuf::Message& from); - void CopyFrom(const FileDescriptorSet& from); - void MergeFrom(const FileDescriptorSet& from); - void Clear(); - bool IsInitialized() const; - - int ByteSize() const; - bool MergePartialFromCodedStream( - ::google::protobuf::io::CodedInputStream* input); - void SerializeWithCachedSizes( - ::google::protobuf::io::CodedOutputStream* output) const; - ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const; - int GetCachedSize() const { return _cached_size_; } - private: - void SharedCtor(); - void SharedDtor(); - void SetCachedSize(int size) const; - public: - - ::google::protobuf::Metadata GetMetadata() const; - - // nested types ---------------------------------------------------- - - // accessors ------------------------------------------------------- - - // repeated .google.protobuf.FileDescriptorProto file = 1; - inline int file_size() const; - inline void clear_file(); - static const int kFileFieldNumber = 1; - inline const ::google::protobuf::FileDescriptorProto& file(int index) const; - inline ::google::protobuf::FileDescriptorProto* mutable_file(int index); - inline ::google::protobuf::FileDescriptorProto* add_file(); - inline const ::google::protobuf::RepeatedPtrField< ::google::protobuf::FileDescriptorProto >& - file() const; - inline ::google::protobuf::RepeatedPtrField< ::google::protobuf::FileDescriptorProto >* - mutable_file(); - - // @@protoc_insertion_point(class_scope:google.protobuf.FileDescriptorSet) - private: - - ::google::protobuf::UnknownFieldSet _unknown_fields_; - - ::google::protobuf::RepeatedPtrField< ::google::protobuf::FileDescriptorProto > file_; - - mutable int _cached_size_; - ::google::protobuf::uint32 _has_bits_[(1 + 31) / 32]; - - friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto(); - friend void protobuf_AssignDesc_google_2fprotobuf_2fdescriptor_2eproto(); - friend void protobuf_ShutdownFile_google_2fprotobuf_2fdescriptor_2eproto(); - - void InitAsDefaultInstance(); - static FileDescriptorSet* default_instance_; -}; -// ------------------------------------------------------------------- - -class LIBPROTOBUF_EXPORT FileDescriptorProto : public ::google::protobuf::Message { - public: - FileDescriptorProto(); - virtual ~FileDescriptorProto(); - - FileDescriptorProto(const FileDescriptorProto& from); - - inline FileDescriptorProto& operator=(const FileDescriptorProto& from) { - CopyFrom(from); - return *this; - } - - inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const { - return _unknown_fields_; - } - - inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() { - return &_unknown_fields_; - } - - static const ::google::protobuf::Descriptor* descriptor(); - static const FileDescriptorProto& default_instance(); - - void Swap(FileDescriptorProto* other); - - // implements Message ---------------------------------------------- - - FileDescriptorProto* New() const; - void CopyFrom(const ::google::protobuf::Message& from); - void MergeFrom(const ::google::protobuf::Message& from); - void CopyFrom(const FileDescriptorProto& from); - void MergeFrom(const FileDescriptorProto& from); - void Clear(); - bool IsInitialized() const; - - int ByteSize() const; - bool MergePartialFromCodedStream( - ::google::protobuf::io::CodedInputStream* input); - void SerializeWithCachedSizes( - ::google::protobuf::io::CodedOutputStream* output) const; - ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const; - int GetCachedSize() const { return _cached_size_; } - private: - void SharedCtor(); - void SharedDtor(); - void SetCachedSize(int size) const; - public: - - ::google::protobuf::Metadata GetMetadata() const; - - // nested types ---------------------------------------------------- - - // accessors ------------------------------------------------------- - - // optional string name = 1; - inline bool has_name() const; - inline void clear_name(); - static const int kNameFieldNumber = 1; - inline const ::std::string& name() const; - inline void set_name(const ::std::string& value); - inline void set_name(const char* value); - inline void set_name(const char* value, size_t size); - inline ::std::string* mutable_name(); - inline ::std::string* release_name(); - inline void set_allocated_name(::std::string* name); - - // optional string package = 2; - inline bool has_package() const; - inline void clear_package(); - static const int kPackageFieldNumber = 2; - inline const ::std::string& package() const; - inline void set_package(const ::std::string& value); - inline void set_package(const char* value); - inline void set_package(const char* value, size_t size); - inline ::std::string* mutable_package(); - inline ::std::string* release_package(); - inline void set_allocated_package(::std::string* package); - - // repeated string dependency = 3; - inline int dependency_size() const; - inline void clear_dependency(); - static const int kDependencyFieldNumber = 3; - inline const ::std::string& dependency(int index) const; - inline ::std::string* mutable_dependency(int index); - inline void set_dependency(int index, const ::std::string& value); - inline void set_dependency(int index, const char* value); - inline void set_dependency(int index, const char* value, size_t size); - inline ::std::string* add_dependency(); - inline void add_dependency(const ::std::string& value); - inline void add_dependency(const char* value); - inline void add_dependency(const char* value, size_t size); - inline const ::google::protobuf::RepeatedPtrField< ::std::string>& dependency() const; - inline ::google::protobuf::RepeatedPtrField< ::std::string>* mutable_dependency(); - - // repeated int32 public_dependency = 10; - inline int public_dependency_size() const; - inline void clear_public_dependency(); - static const int kPublicDependencyFieldNumber = 10; - inline ::google::protobuf::int32 public_dependency(int index) const; - inline void set_public_dependency(int index, ::google::protobuf::int32 value); - inline void add_public_dependency(::google::protobuf::int32 value); - inline const ::google::protobuf::RepeatedField< ::google::protobuf::int32 >& - public_dependency() const; - inline ::google::protobuf::RepeatedField< ::google::protobuf::int32 >* - mutable_public_dependency(); - - // repeated int32 weak_dependency = 11; - inline int weak_dependency_size() const; - inline void clear_weak_dependency(); - static const int kWeakDependencyFieldNumber = 11; - inline ::google::protobuf::int32 weak_dependency(int index) const; - inline void set_weak_dependency(int index, ::google::protobuf::int32 value); - inline void add_weak_dependency(::google::protobuf::int32 value); - inline const ::google::protobuf::RepeatedField< ::google::protobuf::int32 >& - weak_dependency() const; - inline ::google::protobuf::RepeatedField< ::google::protobuf::int32 >* - mutable_weak_dependency(); - - // repeated .google.protobuf.DescriptorProto message_type = 4; - inline int message_type_size() const; - inline void clear_message_type(); - static const int kMessageTypeFieldNumber = 4; - inline const ::google::protobuf::DescriptorProto& message_type(int index) const; - inline ::google::protobuf::DescriptorProto* mutable_message_type(int index); - inline ::google::protobuf::DescriptorProto* add_message_type(); - inline const ::google::protobuf::RepeatedPtrField< ::google::protobuf::DescriptorProto >& - message_type() const; - inline ::google::protobuf::RepeatedPtrField< ::google::protobuf::DescriptorProto >* - mutable_message_type(); - - // repeated .google.protobuf.EnumDescriptorProto enum_type = 5; - inline int enum_type_size() const; - inline void clear_enum_type(); - static const int kEnumTypeFieldNumber = 5; - inline const ::google::protobuf::EnumDescriptorProto& enum_type(int index) const; - inline ::google::protobuf::EnumDescriptorProto* mutable_enum_type(int index); - inline ::google::protobuf::EnumDescriptorProto* add_enum_type(); - inline const ::google::protobuf::RepeatedPtrField< ::google::protobuf::EnumDescriptorProto >& - enum_type() const; - inline ::google::protobuf::RepeatedPtrField< ::google::protobuf::EnumDescriptorProto >* - mutable_enum_type(); - - // repeated .google.protobuf.ServiceDescriptorProto service = 6; - inline int service_size() const; - inline void clear_service(); - static const int kServiceFieldNumber = 6; - inline const ::google::protobuf::ServiceDescriptorProto& service(int index) const; - inline ::google::protobuf::ServiceDescriptorProto* mutable_service(int index); - inline ::google::protobuf::ServiceDescriptorProto* add_service(); - inline const ::google::protobuf::RepeatedPtrField< ::google::protobuf::ServiceDescriptorProto >& - service() const; - inline ::google::protobuf::RepeatedPtrField< ::google::protobuf::ServiceDescriptorProto >* - mutable_service(); - - // repeated .google.protobuf.FieldDescriptorProto extension = 7; - inline int extension_size() const; - inline void clear_extension(); - static const int kExtensionFieldNumber = 7; - inline const ::google::protobuf::FieldDescriptorProto& extension(int index) const; - inline ::google::protobuf::FieldDescriptorProto* mutable_extension(int index); - inline ::google::protobuf::FieldDescriptorProto* add_extension(); - inline const ::google::protobuf::RepeatedPtrField< ::google::protobuf::FieldDescriptorProto >& - extension() const; - inline ::google::protobuf::RepeatedPtrField< ::google::protobuf::FieldDescriptorProto >* - mutable_extension(); - - // optional .google.protobuf.FileOptions options = 8; - inline bool has_options() const; - inline void clear_options(); - static const int kOptionsFieldNumber = 8; - inline const ::google::protobuf::FileOptions& options() const; - inline ::google::protobuf::FileOptions* mutable_options(); - inline ::google::protobuf::FileOptions* release_options(); - inline void set_allocated_options(::google::protobuf::FileOptions* options); - - // optional .google.protobuf.SourceCodeInfo source_code_info = 9; - inline bool has_source_code_info() const; - inline void clear_source_code_info(); - static const int kSourceCodeInfoFieldNumber = 9; - inline const ::google::protobuf::SourceCodeInfo& source_code_info() const; - inline ::google::protobuf::SourceCodeInfo* mutable_source_code_info(); - inline ::google::protobuf::SourceCodeInfo* release_source_code_info(); - inline void set_allocated_source_code_info(::google::protobuf::SourceCodeInfo* source_code_info); - - // @@protoc_insertion_point(class_scope:google.protobuf.FileDescriptorProto) - private: - inline void set_has_name(); - inline void clear_has_name(); - inline void set_has_package(); - inline void clear_has_package(); - inline void set_has_options(); - inline void clear_has_options(); - inline void set_has_source_code_info(); - inline void clear_has_source_code_info(); - - ::google::protobuf::UnknownFieldSet _unknown_fields_; - - ::std::string* name_; - ::std::string* package_; - ::google::protobuf::RepeatedPtrField< ::std::string> dependency_; - ::google::protobuf::RepeatedField< ::google::protobuf::int32 > public_dependency_; - ::google::protobuf::RepeatedField< ::google::protobuf::int32 > weak_dependency_; - ::google::protobuf::RepeatedPtrField< ::google::protobuf::DescriptorProto > message_type_; - ::google::protobuf::RepeatedPtrField< ::google::protobuf::EnumDescriptorProto > enum_type_; - ::google::protobuf::RepeatedPtrField< ::google::protobuf::ServiceDescriptorProto > service_; - ::google::protobuf::RepeatedPtrField< ::google::protobuf::FieldDescriptorProto > extension_; - ::google::protobuf::FileOptions* options_; - ::google::protobuf::SourceCodeInfo* source_code_info_; - - mutable int _cached_size_; - ::google::protobuf::uint32 _has_bits_[(11 + 31) / 32]; - - friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto(); - friend void protobuf_AssignDesc_google_2fprotobuf_2fdescriptor_2eproto(); - friend void protobuf_ShutdownFile_google_2fprotobuf_2fdescriptor_2eproto(); - - void InitAsDefaultInstance(); - static FileDescriptorProto* default_instance_; -}; -// ------------------------------------------------------------------- - -class LIBPROTOBUF_EXPORT DescriptorProto_ExtensionRange : public ::google::protobuf::Message { - public: - DescriptorProto_ExtensionRange(); - virtual ~DescriptorProto_ExtensionRange(); - - DescriptorProto_ExtensionRange(const DescriptorProto_ExtensionRange& from); - - inline DescriptorProto_ExtensionRange& operator=(const DescriptorProto_ExtensionRange& from) { - CopyFrom(from); - return *this; - } - - inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const { - return _unknown_fields_; - } - - inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() { - return &_unknown_fields_; - } - - static const ::google::protobuf::Descriptor* descriptor(); - static const DescriptorProto_ExtensionRange& default_instance(); - - void Swap(DescriptorProto_ExtensionRange* other); - - // implements Message ---------------------------------------------- - - DescriptorProto_ExtensionRange* New() const; - void CopyFrom(const ::google::protobuf::Message& from); - void MergeFrom(const ::google::protobuf::Message& from); - void CopyFrom(const DescriptorProto_ExtensionRange& from); - void MergeFrom(const DescriptorProto_ExtensionRange& from); - void Clear(); - bool IsInitialized() const; - - int ByteSize() const; - bool MergePartialFromCodedStream( - ::google::protobuf::io::CodedInputStream* input); - void SerializeWithCachedSizes( - ::google::protobuf::io::CodedOutputStream* output) const; - ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const; - int GetCachedSize() const { return _cached_size_; } - private: - void SharedCtor(); - void SharedDtor(); - void SetCachedSize(int size) const; - public: - - ::google::protobuf::Metadata GetMetadata() const; - - // nested types ---------------------------------------------------- - - // accessors ------------------------------------------------------- - - // optional int32 start = 1; - inline bool has_start() const; - inline void clear_start(); - static const int kStartFieldNumber = 1; - inline ::google::protobuf::int32 start() const; - inline void set_start(::google::protobuf::int32 value); - - // optional int32 end = 2; - inline bool has_end() const; - inline void clear_end(); - static const int kEndFieldNumber = 2; - inline ::google::protobuf::int32 end() const; - inline void set_end(::google::protobuf::int32 value); - - // @@protoc_insertion_point(class_scope:google.protobuf.DescriptorProto.ExtensionRange) - private: - inline void set_has_start(); - inline void clear_has_start(); - inline void set_has_end(); - inline void clear_has_end(); - - ::google::protobuf::UnknownFieldSet _unknown_fields_; - - ::google::protobuf::int32 start_; - ::google::protobuf::int32 end_; - - mutable int _cached_size_; - ::google::protobuf::uint32 _has_bits_[(2 + 31) / 32]; - - friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto(); - friend void protobuf_AssignDesc_google_2fprotobuf_2fdescriptor_2eproto(); - friend void protobuf_ShutdownFile_google_2fprotobuf_2fdescriptor_2eproto(); - - void InitAsDefaultInstance(); - static DescriptorProto_ExtensionRange* default_instance_; -}; -// ------------------------------------------------------------------- - -class LIBPROTOBUF_EXPORT DescriptorProto : public ::google::protobuf::Message { - public: - DescriptorProto(); - virtual ~DescriptorProto(); - - DescriptorProto(const DescriptorProto& from); - - inline DescriptorProto& operator=(const DescriptorProto& from) { - CopyFrom(from); - return *this; - } - - inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const { - return _unknown_fields_; - } - - inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() { - return &_unknown_fields_; - } - - static const ::google::protobuf::Descriptor* descriptor(); - static const DescriptorProto& default_instance(); - - void Swap(DescriptorProto* other); - - // implements Message ---------------------------------------------- - - DescriptorProto* New() const; - void CopyFrom(const ::google::protobuf::Message& from); - void MergeFrom(const ::google::protobuf::Message& from); - void CopyFrom(const DescriptorProto& from); - void MergeFrom(const DescriptorProto& from); - void Clear(); - bool IsInitialized() const; - - int ByteSize() const; - bool MergePartialFromCodedStream( - ::google::protobuf::io::CodedInputStream* input); - void SerializeWithCachedSizes( - ::google::protobuf::io::CodedOutputStream* output) const; - ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const; - int GetCachedSize() const { return _cached_size_; } - private: - void SharedCtor(); - void SharedDtor(); - void SetCachedSize(int size) const; - public: - - ::google::protobuf::Metadata GetMetadata() const; - - // nested types ---------------------------------------------------- - - typedef DescriptorProto_ExtensionRange ExtensionRange; - - // accessors ------------------------------------------------------- - - // optional string name = 1; - inline bool has_name() const; - inline void clear_name(); - static const int kNameFieldNumber = 1; - inline const ::std::string& name() const; - inline void set_name(const ::std::string& value); - inline void set_name(const char* value); - inline void set_name(const char* value, size_t size); - inline ::std::string* mutable_name(); - inline ::std::string* release_name(); - inline void set_allocated_name(::std::string* name); - - // repeated .google.protobuf.FieldDescriptorProto field = 2; - inline int field_size() const; - inline void clear_field(); - static const int kFieldFieldNumber = 2; - inline const ::google::protobuf::FieldDescriptorProto& field(int index) const; - inline ::google::protobuf::FieldDescriptorProto* mutable_field(int index); - inline ::google::protobuf::FieldDescriptorProto* add_field(); - inline const ::google::protobuf::RepeatedPtrField< ::google::protobuf::FieldDescriptorProto >& - field() const; - inline ::google::protobuf::RepeatedPtrField< ::google::protobuf::FieldDescriptorProto >* - mutable_field(); - - // repeated .google.protobuf.FieldDescriptorProto extension = 6; - inline int extension_size() const; - inline void clear_extension(); - static const int kExtensionFieldNumber = 6; - inline const ::google::protobuf::FieldDescriptorProto& extension(int index) const; - inline ::google::protobuf::FieldDescriptorProto* mutable_extension(int index); - inline ::google::protobuf::FieldDescriptorProto* add_extension(); - inline const ::google::protobuf::RepeatedPtrField< ::google::protobuf::FieldDescriptorProto >& - extension() const; - inline ::google::protobuf::RepeatedPtrField< ::google::protobuf::FieldDescriptorProto >* - mutable_extension(); - - // repeated .google.protobuf.DescriptorProto nested_type = 3; - inline int nested_type_size() const; - inline void clear_nested_type(); - static const int kNestedTypeFieldNumber = 3; - inline const ::google::protobuf::DescriptorProto& nested_type(int index) const; - inline ::google::protobuf::DescriptorProto* mutable_nested_type(int index); - inline ::google::protobuf::DescriptorProto* add_nested_type(); - inline const ::google::protobuf::RepeatedPtrField< ::google::protobuf::DescriptorProto >& - nested_type() const; - inline ::google::protobuf::RepeatedPtrField< ::google::protobuf::DescriptorProto >* - mutable_nested_type(); - - // repeated .google.protobuf.EnumDescriptorProto enum_type = 4; - inline int enum_type_size() const; - inline void clear_enum_type(); - static const int kEnumTypeFieldNumber = 4; - inline const ::google::protobuf::EnumDescriptorProto& enum_type(int index) const; - inline ::google::protobuf::EnumDescriptorProto* mutable_enum_type(int index); - inline ::google::protobuf::EnumDescriptorProto* add_enum_type(); - inline const ::google::protobuf::RepeatedPtrField< ::google::protobuf::EnumDescriptorProto >& - enum_type() const; - inline ::google::protobuf::RepeatedPtrField< ::google::protobuf::EnumDescriptorProto >* - mutable_enum_type(); - - // repeated .google.protobuf.DescriptorProto.ExtensionRange extension_range = 5; - inline int extension_range_size() const; - inline void clear_extension_range(); - static const int kExtensionRangeFieldNumber = 5; - inline const ::google::protobuf::DescriptorProto_ExtensionRange& extension_range(int index) const; - inline ::google::protobuf::DescriptorProto_ExtensionRange* mutable_extension_range(int index); - inline ::google::protobuf::DescriptorProto_ExtensionRange* add_extension_range(); - inline const ::google::protobuf::RepeatedPtrField< ::google::protobuf::DescriptorProto_ExtensionRange >& - extension_range() const; - inline ::google::protobuf::RepeatedPtrField< ::google::protobuf::DescriptorProto_ExtensionRange >* - mutable_extension_range(); - - // optional .google.protobuf.MessageOptions options = 7; - inline bool has_options() const; - inline void clear_options(); - static const int kOptionsFieldNumber = 7; - inline const ::google::protobuf::MessageOptions& options() const; - inline ::google::protobuf::MessageOptions* mutable_options(); - inline ::google::protobuf::MessageOptions* release_options(); - inline void set_allocated_options(::google::protobuf::MessageOptions* options); - - // @@protoc_insertion_point(class_scope:google.protobuf.DescriptorProto) - private: - inline void set_has_name(); - inline void clear_has_name(); - inline void set_has_options(); - inline void clear_has_options(); - - ::google::protobuf::UnknownFieldSet _unknown_fields_; - - ::std::string* name_; - ::google::protobuf::RepeatedPtrField< ::google::protobuf::FieldDescriptorProto > field_; - ::google::protobuf::RepeatedPtrField< ::google::protobuf::FieldDescriptorProto > extension_; - ::google::protobuf::RepeatedPtrField< ::google::protobuf::DescriptorProto > nested_type_; - ::google::protobuf::RepeatedPtrField< ::google::protobuf::EnumDescriptorProto > enum_type_; - ::google::protobuf::RepeatedPtrField< ::google::protobuf::DescriptorProto_ExtensionRange > extension_range_; - ::google::protobuf::MessageOptions* options_; - - mutable int _cached_size_; - ::google::protobuf::uint32 _has_bits_[(7 + 31) / 32]; - - friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto(); - friend void protobuf_AssignDesc_google_2fprotobuf_2fdescriptor_2eproto(); - friend void protobuf_ShutdownFile_google_2fprotobuf_2fdescriptor_2eproto(); - - void InitAsDefaultInstance(); - static DescriptorProto* default_instance_; -}; -// ------------------------------------------------------------------- - -class LIBPROTOBUF_EXPORT FieldDescriptorProto : public ::google::protobuf::Message { - public: - FieldDescriptorProto(); - virtual ~FieldDescriptorProto(); - - FieldDescriptorProto(const FieldDescriptorProto& from); - - inline FieldDescriptorProto& operator=(const FieldDescriptorProto& from) { - CopyFrom(from); - return *this; - } - - inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const { - return _unknown_fields_; - } - - inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() { - return &_unknown_fields_; - } - - static const ::google::protobuf::Descriptor* descriptor(); - static const FieldDescriptorProto& default_instance(); - - void Swap(FieldDescriptorProto* other); - - // implements Message ---------------------------------------------- - - FieldDescriptorProto* New() const; - void CopyFrom(const ::google::protobuf::Message& from); - void MergeFrom(const ::google::protobuf::Message& from); - void CopyFrom(const FieldDescriptorProto& from); - void MergeFrom(const FieldDescriptorProto& from); - void Clear(); - bool IsInitialized() const; - - int ByteSize() const; - bool MergePartialFromCodedStream( - ::google::protobuf::io::CodedInputStream* input); - void SerializeWithCachedSizes( - ::google::protobuf::io::CodedOutputStream* output) const; - ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const; - int GetCachedSize() const { return _cached_size_; } - private: - void SharedCtor(); - void SharedDtor(); - void SetCachedSize(int size) const; - public: - - ::google::protobuf::Metadata GetMetadata() const; - - // nested types ---------------------------------------------------- - - typedef FieldDescriptorProto_Type Type; - static const Type TYPE_DOUBLE = FieldDescriptorProto_Type_TYPE_DOUBLE; - static const Type TYPE_FLOAT = FieldDescriptorProto_Type_TYPE_FLOAT; - static const Type TYPE_INT64 = FieldDescriptorProto_Type_TYPE_INT64; - static const Type TYPE_UINT64 = FieldDescriptorProto_Type_TYPE_UINT64; - static const Type TYPE_INT32 = FieldDescriptorProto_Type_TYPE_INT32; - static const Type TYPE_FIXED64 = FieldDescriptorProto_Type_TYPE_FIXED64; - static const Type TYPE_FIXED32 = FieldDescriptorProto_Type_TYPE_FIXED32; - static const Type TYPE_BOOL = FieldDescriptorProto_Type_TYPE_BOOL; - static const Type TYPE_STRING = FieldDescriptorProto_Type_TYPE_STRING; - static const Type TYPE_GROUP = FieldDescriptorProto_Type_TYPE_GROUP; - static const Type TYPE_MESSAGE = FieldDescriptorProto_Type_TYPE_MESSAGE; - static const Type TYPE_BYTES = FieldDescriptorProto_Type_TYPE_BYTES; - static const Type TYPE_UINT32 = FieldDescriptorProto_Type_TYPE_UINT32; - static const Type TYPE_ENUM = FieldDescriptorProto_Type_TYPE_ENUM; - static const Type TYPE_SFIXED32 = FieldDescriptorProto_Type_TYPE_SFIXED32; - static const Type TYPE_SFIXED64 = FieldDescriptorProto_Type_TYPE_SFIXED64; - static const Type TYPE_SINT32 = FieldDescriptorProto_Type_TYPE_SINT32; - static const Type TYPE_SINT64 = FieldDescriptorProto_Type_TYPE_SINT64; - static inline bool Type_IsValid(int value) { - return FieldDescriptorProto_Type_IsValid(value); - } - static const Type Type_MIN = - FieldDescriptorProto_Type_Type_MIN; - static const Type Type_MAX = - FieldDescriptorProto_Type_Type_MAX; - static const int Type_ARRAYSIZE = - FieldDescriptorProto_Type_Type_ARRAYSIZE; - static inline const ::google::protobuf::EnumDescriptor* - Type_descriptor() { - return FieldDescriptorProto_Type_descriptor(); - } - static inline const ::std::string& Type_Name(Type value) { - return FieldDescriptorProto_Type_Name(value); - } - static inline bool Type_Parse(const ::std::string& name, - Type* value) { - return FieldDescriptorProto_Type_Parse(name, value); - } - - typedef FieldDescriptorProto_Label Label; - static const Label LABEL_OPTIONAL = FieldDescriptorProto_Label_LABEL_OPTIONAL; - static const Label LABEL_REQUIRED = FieldDescriptorProto_Label_LABEL_REQUIRED; - static const Label LABEL_REPEATED = FieldDescriptorProto_Label_LABEL_REPEATED; - static inline bool Label_IsValid(int value) { - return FieldDescriptorProto_Label_IsValid(value); - } - static const Label Label_MIN = - FieldDescriptorProto_Label_Label_MIN; - static const Label Label_MAX = - FieldDescriptorProto_Label_Label_MAX; - static const int Label_ARRAYSIZE = - FieldDescriptorProto_Label_Label_ARRAYSIZE; - static inline const ::google::protobuf::EnumDescriptor* - Label_descriptor() { - return FieldDescriptorProto_Label_descriptor(); - } - static inline const ::std::string& Label_Name(Label value) { - return FieldDescriptorProto_Label_Name(value); - } - static inline bool Label_Parse(const ::std::string& name, - Label* value) { - return FieldDescriptorProto_Label_Parse(name, value); - } - - // accessors ------------------------------------------------------- - - // optional string name = 1; - inline bool has_name() const; - inline void clear_name(); - static const int kNameFieldNumber = 1; - inline const ::std::string& name() const; - inline void set_name(const ::std::string& value); - inline void set_name(const char* value); - inline void set_name(const char* value, size_t size); - inline ::std::string* mutable_name(); - inline ::std::string* release_name(); - inline void set_allocated_name(::std::string* name); - - // optional int32 number = 3; - inline bool has_number() const; - inline void clear_number(); - static const int kNumberFieldNumber = 3; - inline ::google::protobuf::int32 number() const; - inline void set_number(::google::protobuf::int32 value); - - // optional .google.protobuf.FieldDescriptorProto.Label label = 4; - inline bool has_label() const; - inline void clear_label(); - static const int kLabelFieldNumber = 4; - inline ::google::protobuf::FieldDescriptorProto_Label label() const; - inline void set_label(::google::protobuf::FieldDescriptorProto_Label value); - - // optional .google.protobuf.FieldDescriptorProto.Type type = 5; - inline bool has_type() const; - inline void clear_type(); - static const int kTypeFieldNumber = 5; - inline ::google::protobuf::FieldDescriptorProto_Type type() const; - inline void set_type(::google::protobuf::FieldDescriptorProto_Type value); - - // optional string type_name = 6; - inline bool has_type_name() const; - inline void clear_type_name(); - static const int kTypeNameFieldNumber = 6; - inline const ::std::string& type_name() const; - inline void set_type_name(const ::std::string& value); - inline void set_type_name(const char* value); - inline void set_type_name(const char* value, size_t size); - inline ::std::string* mutable_type_name(); - inline ::std::string* release_type_name(); - inline void set_allocated_type_name(::std::string* type_name); - - // optional string extendee = 2; - inline bool has_extendee() const; - inline void clear_extendee(); - static const int kExtendeeFieldNumber = 2; - inline const ::std::string& extendee() const; - inline void set_extendee(const ::std::string& value); - inline void set_extendee(const char* value); - inline void set_extendee(const char* value, size_t size); - inline ::std::string* mutable_extendee(); - inline ::std::string* release_extendee(); - inline void set_allocated_extendee(::std::string* extendee); - - // optional string default_value = 7; - inline bool has_default_value() const; - inline void clear_default_value(); - static const int kDefaultValueFieldNumber = 7; - inline const ::std::string& default_value() const; - inline void set_default_value(const ::std::string& value); - inline void set_default_value(const char* value); - inline void set_default_value(const char* value, size_t size); - inline ::std::string* mutable_default_value(); - inline ::std::string* release_default_value(); - inline void set_allocated_default_value(::std::string* default_value); - - // optional .google.protobuf.FieldOptions options = 8; - inline bool has_options() const; - inline void clear_options(); - static const int kOptionsFieldNumber = 8; - inline const ::google::protobuf::FieldOptions& options() const; - inline ::google::protobuf::FieldOptions* mutable_options(); - inline ::google::protobuf::FieldOptions* release_options(); - inline void set_allocated_options(::google::protobuf::FieldOptions* options); - - // @@protoc_insertion_point(class_scope:google.protobuf.FieldDescriptorProto) - private: - inline void set_has_name(); - inline void clear_has_name(); - inline void set_has_number(); - inline void clear_has_number(); - inline void set_has_label(); - inline void clear_has_label(); - inline void set_has_type(); - inline void clear_has_type(); - inline void set_has_type_name(); - inline void clear_has_type_name(); - inline void set_has_extendee(); - inline void clear_has_extendee(); - inline void set_has_default_value(); - inline void clear_has_default_value(); - inline void set_has_options(); - inline void clear_has_options(); - - ::google::protobuf::UnknownFieldSet _unknown_fields_; - - ::std::string* name_; - ::google::protobuf::int32 number_; - int label_; - ::std::string* type_name_; - ::std::string* extendee_; - ::std::string* default_value_; - ::google::protobuf::FieldOptions* options_; - int type_; - - mutable int _cached_size_; - ::google::protobuf::uint32 _has_bits_[(8 + 31) / 32]; - - friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto(); - friend void protobuf_AssignDesc_google_2fprotobuf_2fdescriptor_2eproto(); - friend void protobuf_ShutdownFile_google_2fprotobuf_2fdescriptor_2eproto(); - - void InitAsDefaultInstance(); - static FieldDescriptorProto* default_instance_; -}; -// ------------------------------------------------------------------- - -class LIBPROTOBUF_EXPORT EnumDescriptorProto : public ::google::protobuf::Message { - public: - EnumDescriptorProto(); - virtual ~EnumDescriptorProto(); - - EnumDescriptorProto(const EnumDescriptorProto& from); - - inline EnumDescriptorProto& operator=(const EnumDescriptorProto& from) { - CopyFrom(from); - return *this; - } - - inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const { - return _unknown_fields_; - } - - inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() { - return &_unknown_fields_; - } - - static const ::google::protobuf::Descriptor* descriptor(); - static const EnumDescriptorProto& default_instance(); - - void Swap(EnumDescriptorProto* other); - - // implements Message ---------------------------------------------- - - EnumDescriptorProto* New() const; - void CopyFrom(const ::google::protobuf::Message& from); - void MergeFrom(const ::google::protobuf::Message& from); - void CopyFrom(const EnumDescriptorProto& from); - void MergeFrom(const EnumDescriptorProto& from); - void Clear(); - bool IsInitialized() const; - - int ByteSize() const; - bool MergePartialFromCodedStream( - ::google::protobuf::io::CodedInputStream* input); - void SerializeWithCachedSizes( - ::google::protobuf::io::CodedOutputStream* output) const; - ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const; - int GetCachedSize() const { return _cached_size_; } - private: - void SharedCtor(); - void SharedDtor(); - void SetCachedSize(int size) const; - public: - - ::google::protobuf::Metadata GetMetadata() const; - - // nested types ---------------------------------------------------- - - // accessors ------------------------------------------------------- - - // optional string name = 1; - inline bool has_name() const; - inline void clear_name(); - static const int kNameFieldNumber = 1; - inline const ::std::string& name() const; - inline void set_name(const ::std::string& value); - inline void set_name(const char* value); - inline void set_name(const char* value, size_t size); - inline ::std::string* mutable_name(); - inline ::std::string* release_name(); - inline void set_allocated_name(::std::string* name); - - // repeated .google.protobuf.EnumValueDescriptorProto value = 2; - inline int value_size() const; - inline void clear_value(); - static const int kValueFieldNumber = 2; - inline const ::google::protobuf::EnumValueDescriptorProto& value(int index) const; - inline ::google::protobuf::EnumValueDescriptorProto* mutable_value(int index); - inline ::google::protobuf::EnumValueDescriptorProto* add_value(); - inline const ::google::protobuf::RepeatedPtrField< ::google::protobuf::EnumValueDescriptorProto >& - value() const; - inline ::google::protobuf::RepeatedPtrField< ::google::protobuf::EnumValueDescriptorProto >* - mutable_value(); - - // optional .google.protobuf.EnumOptions options = 3; - inline bool has_options() const; - inline void clear_options(); - static const int kOptionsFieldNumber = 3; - inline const ::google::protobuf::EnumOptions& options() const; - inline ::google::protobuf::EnumOptions* mutable_options(); - inline ::google::protobuf::EnumOptions* release_options(); - inline void set_allocated_options(::google::protobuf::EnumOptions* options); - - // @@protoc_insertion_point(class_scope:google.protobuf.EnumDescriptorProto) - private: - inline void set_has_name(); - inline void clear_has_name(); - inline void set_has_options(); - inline void clear_has_options(); - - ::google::protobuf::UnknownFieldSet _unknown_fields_; - - ::std::string* name_; - ::google::protobuf::RepeatedPtrField< ::google::protobuf::EnumValueDescriptorProto > value_; - ::google::protobuf::EnumOptions* options_; - - mutable int _cached_size_; - ::google::protobuf::uint32 _has_bits_[(3 + 31) / 32]; - - friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto(); - friend void protobuf_AssignDesc_google_2fprotobuf_2fdescriptor_2eproto(); - friend void protobuf_ShutdownFile_google_2fprotobuf_2fdescriptor_2eproto(); - - void InitAsDefaultInstance(); - static EnumDescriptorProto* default_instance_; -}; -// ------------------------------------------------------------------- - -class LIBPROTOBUF_EXPORT EnumValueDescriptorProto : public ::google::protobuf::Message { - public: - EnumValueDescriptorProto(); - virtual ~EnumValueDescriptorProto(); - - EnumValueDescriptorProto(const EnumValueDescriptorProto& from); - - inline EnumValueDescriptorProto& operator=(const EnumValueDescriptorProto& from) { - CopyFrom(from); - return *this; - } - - inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const { - return _unknown_fields_; - } - - inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() { - return &_unknown_fields_; - } - - static const ::google::protobuf::Descriptor* descriptor(); - static const EnumValueDescriptorProto& default_instance(); - - void Swap(EnumValueDescriptorProto* other); - - // implements Message ---------------------------------------------- - - EnumValueDescriptorProto* New() const; - void CopyFrom(const ::google::protobuf::Message& from); - void MergeFrom(const ::google::protobuf::Message& from); - void CopyFrom(const EnumValueDescriptorProto& from); - void MergeFrom(const EnumValueDescriptorProto& from); - void Clear(); - bool IsInitialized() const; - - int ByteSize() const; - bool MergePartialFromCodedStream( - ::google::protobuf::io::CodedInputStream* input); - void SerializeWithCachedSizes( - ::google::protobuf::io::CodedOutputStream* output) const; - ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const; - int GetCachedSize() const { return _cached_size_; } - private: - void SharedCtor(); - void SharedDtor(); - void SetCachedSize(int size) const; - public: - - ::google::protobuf::Metadata GetMetadata() const; - - // nested types ---------------------------------------------------- - - // accessors ------------------------------------------------------- - - // optional string name = 1; - inline bool has_name() const; - inline void clear_name(); - static const int kNameFieldNumber = 1; - inline const ::std::string& name() const; - inline void set_name(const ::std::string& value); - inline void set_name(const char* value); - inline void set_name(const char* value, size_t size); - inline ::std::string* mutable_name(); - inline ::std::string* release_name(); - inline void set_allocated_name(::std::string* name); - - // optional int32 number = 2; - inline bool has_number() const; - inline void clear_number(); - static const int kNumberFieldNumber = 2; - inline ::google::protobuf::int32 number() const; - inline void set_number(::google::protobuf::int32 value); - - // optional .google.protobuf.EnumValueOptions options = 3; - inline bool has_options() const; - inline void clear_options(); - static const int kOptionsFieldNumber = 3; - inline const ::google::protobuf::EnumValueOptions& options() const; - inline ::google::protobuf::EnumValueOptions* mutable_options(); - inline ::google::protobuf::EnumValueOptions* release_options(); - inline void set_allocated_options(::google::protobuf::EnumValueOptions* options); - - // @@protoc_insertion_point(class_scope:google.protobuf.EnumValueDescriptorProto) - private: - inline void set_has_name(); - inline void clear_has_name(); - inline void set_has_number(); - inline void clear_has_number(); - inline void set_has_options(); - inline void clear_has_options(); - - ::google::protobuf::UnknownFieldSet _unknown_fields_; - - ::std::string* name_; - ::google::protobuf::EnumValueOptions* options_; - ::google::protobuf::int32 number_; - - mutable int _cached_size_; - ::google::protobuf::uint32 _has_bits_[(3 + 31) / 32]; - - friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto(); - friend void protobuf_AssignDesc_google_2fprotobuf_2fdescriptor_2eproto(); - friend void protobuf_ShutdownFile_google_2fprotobuf_2fdescriptor_2eproto(); - - void InitAsDefaultInstance(); - static EnumValueDescriptorProto* default_instance_; -}; -// ------------------------------------------------------------------- - -class LIBPROTOBUF_EXPORT ServiceDescriptorProto : public ::google::protobuf::Message { - public: - ServiceDescriptorProto(); - virtual ~ServiceDescriptorProto(); - - ServiceDescriptorProto(const ServiceDescriptorProto& from); - - inline ServiceDescriptorProto& operator=(const ServiceDescriptorProto& from) { - CopyFrom(from); - return *this; - } - - inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const { - return _unknown_fields_; - } - - inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() { - return &_unknown_fields_; - } - - static const ::google::protobuf::Descriptor* descriptor(); - static const ServiceDescriptorProto& default_instance(); - - void Swap(ServiceDescriptorProto* other); - - // implements Message ---------------------------------------------- - - ServiceDescriptorProto* New() const; - void CopyFrom(const ::google::protobuf::Message& from); - void MergeFrom(const ::google::protobuf::Message& from); - void CopyFrom(const ServiceDescriptorProto& from); - void MergeFrom(const ServiceDescriptorProto& from); - void Clear(); - bool IsInitialized() const; - - int ByteSize() const; - bool MergePartialFromCodedStream( - ::google::protobuf::io::CodedInputStream* input); - void SerializeWithCachedSizes( - ::google::protobuf::io::CodedOutputStream* output) const; - ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const; - int GetCachedSize() const { return _cached_size_; } - private: - void SharedCtor(); - void SharedDtor(); - void SetCachedSize(int size) const; - public: - - ::google::protobuf::Metadata GetMetadata() const; - - // nested types ---------------------------------------------------- - - // accessors ------------------------------------------------------- - - // optional string name = 1; - inline bool has_name() const; - inline void clear_name(); - static const int kNameFieldNumber = 1; - inline const ::std::string& name() const; - inline void set_name(const ::std::string& value); - inline void set_name(const char* value); - inline void set_name(const char* value, size_t size); - inline ::std::string* mutable_name(); - inline ::std::string* release_name(); - inline void set_allocated_name(::std::string* name); - - // repeated .google.protobuf.MethodDescriptorProto method = 2; - inline int method_size() const; - inline void clear_method(); - static const int kMethodFieldNumber = 2; - inline const ::google::protobuf::MethodDescriptorProto& method(int index) const; - inline ::google::protobuf::MethodDescriptorProto* mutable_method(int index); - inline ::google::protobuf::MethodDescriptorProto* add_method(); - inline const ::google::protobuf::RepeatedPtrField< ::google::protobuf::MethodDescriptorProto >& - method() const; - inline ::google::protobuf::RepeatedPtrField< ::google::protobuf::MethodDescriptorProto >* - mutable_method(); - - // optional .google.protobuf.ServiceOptions options = 3; - inline bool has_options() const; - inline void clear_options(); - static const int kOptionsFieldNumber = 3; - inline const ::google::protobuf::ServiceOptions& options() const; - inline ::google::protobuf::ServiceOptions* mutable_options(); - inline ::google::protobuf::ServiceOptions* release_options(); - inline void set_allocated_options(::google::protobuf::ServiceOptions* options); - - // @@protoc_insertion_point(class_scope:google.protobuf.ServiceDescriptorProto) - private: - inline void set_has_name(); - inline void clear_has_name(); - inline void set_has_options(); - inline void clear_has_options(); - - ::google::protobuf::UnknownFieldSet _unknown_fields_; - - ::std::string* name_; - ::google::protobuf::RepeatedPtrField< ::google::protobuf::MethodDescriptorProto > method_; - ::google::protobuf::ServiceOptions* options_; - - mutable int _cached_size_; - ::google::protobuf::uint32 _has_bits_[(3 + 31) / 32]; - - friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto(); - friend void protobuf_AssignDesc_google_2fprotobuf_2fdescriptor_2eproto(); - friend void protobuf_ShutdownFile_google_2fprotobuf_2fdescriptor_2eproto(); - - void InitAsDefaultInstance(); - static ServiceDescriptorProto* default_instance_; -}; -// ------------------------------------------------------------------- - -class LIBPROTOBUF_EXPORT MethodDescriptorProto : public ::google::protobuf::Message { - public: - MethodDescriptorProto(); - virtual ~MethodDescriptorProto(); - - MethodDescriptorProto(const MethodDescriptorProto& from); - - inline MethodDescriptorProto& operator=(const MethodDescriptorProto& from) { - CopyFrom(from); - return *this; - } - - inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const { - return _unknown_fields_; - } - - inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() { - return &_unknown_fields_; - } - - static const ::google::protobuf::Descriptor* descriptor(); - static const MethodDescriptorProto& default_instance(); - - void Swap(MethodDescriptorProto* other); - - // implements Message ---------------------------------------------- - - MethodDescriptorProto* New() const; - void CopyFrom(const ::google::protobuf::Message& from); - void MergeFrom(const ::google::protobuf::Message& from); - void CopyFrom(const MethodDescriptorProto& from); - void MergeFrom(const MethodDescriptorProto& from); - void Clear(); - bool IsInitialized() const; - - int ByteSize() const; - bool MergePartialFromCodedStream( - ::google::protobuf::io::CodedInputStream* input); - void SerializeWithCachedSizes( - ::google::protobuf::io::CodedOutputStream* output) const; - ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const; - int GetCachedSize() const { return _cached_size_; } - private: - void SharedCtor(); - void SharedDtor(); - void SetCachedSize(int size) const; - public: - - ::google::protobuf::Metadata GetMetadata() const; - - // nested types ---------------------------------------------------- - - // accessors ------------------------------------------------------- - - // optional string name = 1; - inline bool has_name() const; - inline void clear_name(); - static const int kNameFieldNumber = 1; - inline const ::std::string& name() const; - inline void set_name(const ::std::string& value); - inline void set_name(const char* value); - inline void set_name(const char* value, size_t size); - inline ::std::string* mutable_name(); - inline ::std::string* release_name(); - inline void set_allocated_name(::std::string* name); - - // optional string input_type = 2; - inline bool has_input_type() const; - inline void clear_input_type(); - static const int kInputTypeFieldNumber = 2; - inline const ::std::string& input_type() const; - inline void set_input_type(const ::std::string& value); - inline void set_input_type(const char* value); - inline void set_input_type(const char* value, size_t size); - inline ::std::string* mutable_input_type(); - inline ::std::string* release_input_type(); - inline void set_allocated_input_type(::std::string* input_type); - - // optional string output_type = 3; - inline bool has_output_type() const; - inline void clear_output_type(); - static const int kOutputTypeFieldNumber = 3; - inline const ::std::string& output_type() const; - inline void set_output_type(const ::std::string& value); - inline void set_output_type(const char* value); - inline void set_output_type(const char* value, size_t size); - inline ::std::string* mutable_output_type(); - inline ::std::string* release_output_type(); - inline void set_allocated_output_type(::std::string* output_type); - - // optional .google.protobuf.MethodOptions options = 4; - inline bool has_options() const; - inline void clear_options(); - static const int kOptionsFieldNumber = 4; - inline const ::google::protobuf::MethodOptions& options() const; - inline ::google::protobuf::MethodOptions* mutable_options(); - inline ::google::protobuf::MethodOptions* release_options(); - inline void set_allocated_options(::google::protobuf::MethodOptions* options); - - // @@protoc_insertion_point(class_scope:google.protobuf.MethodDescriptorProto) - private: - inline void set_has_name(); - inline void clear_has_name(); - inline void set_has_input_type(); - inline void clear_has_input_type(); - inline void set_has_output_type(); - inline void clear_has_output_type(); - inline void set_has_options(); - inline void clear_has_options(); - - ::google::protobuf::UnknownFieldSet _unknown_fields_; - - ::std::string* name_; - ::std::string* input_type_; - ::std::string* output_type_; - ::google::protobuf::MethodOptions* options_; - - mutable int _cached_size_; - ::google::protobuf::uint32 _has_bits_[(4 + 31) / 32]; - - friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto(); - friend void protobuf_AssignDesc_google_2fprotobuf_2fdescriptor_2eproto(); - friend void protobuf_ShutdownFile_google_2fprotobuf_2fdescriptor_2eproto(); - - void InitAsDefaultInstance(); - static MethodDescriptorProto* default_instance_; -}; -// ------------------------------------------------------------------- - -class LIBPROTOBUF_EXPORT FileOptions : public ::google::protobuf::Message { - public: - FileOptions(); - virtual ~FileOptions(); - - FileOptions(const FileOptions& from); - - inline FileOptions& operator=(const FileOptions& from) { - CopyFrom(from); - return *this; - } - - inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const { - return _unknown_fields_; - } - - inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() { - return &_unknown_fields_; - } - - static const ::google::protobuf::Descriptor* descriptor(); - static const FileOptions& default_instance(); - - void Swap(FileOptions* other); - - // implements Message ---------------------------------------------- - - FileOptions* New() const; - void CopyFrom(const ::google::protobuf::Message& from); - void MergeFrom(const ::google::protobuf::Message& from); - void CopyFrom(const FileOptions& from); - void MergeFrom(const FileOptions& from); - void Clear(); - bool IsInitialized() const; - - int ByteSize() const; - bool MergePartialFromCodedStream( - ::google::protobuf::io::CodedInputStream* input); - void SerializeWithCachedSizes( - ::google::protobuf::io::CodedOutputStream* output) const; - ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const; - int GetCachedSize() const { return _cached_size_; } - private: - void SharedCtor(); - void SharedDtor(); - void SetCachedSize(int size) const; - public: - - ::google::protobuf::Metadata GetMetadata() const; - - // nested types ---------------------------------------------------- - - typedef FileOptions_OptimizeMode OptimizeMode; - static const OptimizeMode SPEED = FileOptions_OptimizeMode_SPEED; - static const OptimizeMode CODE_SIZE = FileOptions_OptimizeMode_CODE_SIZE; - static const OptimizeMode LITE_RUNTIME = FileOptions_OptimizeMode_LITE_RUNTIME; - static inline bool OptimizeMode_IsValid(int value) { - return FileOptions_OptimizeMode_IsValid(value); - } - static const OptimizeMode OptimizeMode_MIN = - FileOptions_OptimizeMode_OptimizeMode_MIN; - static const OptimizeMode OptimizeMode_MAX = - FileOptions_OptimizeMode_OptimizeMode_MAX; - static const int OptimizeMode_ARRAYSIZE = - FileOptions_OptimizeMode_OptimizeMode_ARRAYSIZE; - static inline const ::google::protobuf::EnumDescriptor* - OptimizeMode_descriptor() { - return FileOptions_OptimizeMode_descriptor(); - } - static inline const ::std::string& OptimizeMode_Name(OptimizeMode value) { - return FileOptions_OptimizeMode_Name(value); - } - static inline bool OptimizeMode_Parse(const ::std::string& name, - OptimizeMode* value) { - return FileOptions_OptimizeMode_Parse(name, value); - } - - // accessors ------------------------------------------------------- - - // optional string java_package = 1; - inline bool has_java_package() const; - inline void clear_java_package(); - static const int kJavaPackageFieldNumber = 1; - inline const ::std::string& java_package() const; - inline void set_java_package(const ::std::string& value); - inline void set_java_package(const char* value); - inline void set_java_package(const char* value, size_t size); - inline ::std::string* mutable_java_package(); - inline ::std::string* release_java_package(); - inline void set_allocated_java_package(::std::string* java_package); - - // optional string java_outer_classname = 8; - inline bool has_java_outer_classname() const; - inline void clear_java_outer_classname(); - static const int kJavaOuterClassnameFieldNumber = 8; - inline const ::std::string& java_outer_classname() const; - inline void set_java_outer_classname(const ::std::string& value); - inline void set_java_outer_classname(const char* value); - inline void set_java_outer_classname(const char* value, size_t size); - inline ::std::string* mutable_java_outer_classname(); - inline ::std::string* release_java_outer_classname(); - inline void set_allocated_java_outer_classname(::std::string* java_outer_classname); - - // optional bool java_multiple_files = 10 [default = false]; - inline bool has_java_multiple_files() const; - inline void clear_java_multiple_files(); - static const int kJavaMultipleFilesFieldNumber = 10; - inline bool java_multiple_files() const; - inline void set_java_multiple_files(bool value); - - // optional bool java_generate_equals_and_hash = 20 [default = false]; - inline bool has_java_generate_equals_and_hash() const; - inline void clear_java_generate_equals_and_hash(); - static const int kJavaGenerateEqualsAndHashFieldNumber = 20; - inline bool java_generate_equals_and_hash() const; - inline void set_java_generate_equals_and_hash(bool value); - - // optional .google.protobuf.FileOptions.OptimizeMode optimize_for = 9 [default = SPEED]; - inline bool has_optimize_for() const; - inline void clear_optimize_for(); - static const int kOptimizeForFieldNumber = 9; - inline ::google::protobuf::FileOptions_OptimizeMode optimize_for() const; - inline void set_optimize_for(::google::protobuf::FileOptions_OptimizeMode value); - - // optional string go_package = 11; - inline bool has_go_package() const; - inline void clear_go_package(); - static const int kGoPackageFieldNumber = 11; - inline const ::std::string& go_package() const; - inline void set_go_package(const ::std::string& value); - inline void set_go_package(const char* value); - inline void set_go_package(const char* value, size_t size); - inline ::std::string* mutable_go_package(); - inline ::std::string* release_go_package(); - inline void set_allocated_go_package(::std::string* go_package); - - // optional bool cc_generic_services = 16 [default = false]; - inline bool has_cc_generic_services() const; - inline void clear_cc_generic_services(); - static const int kCcGenericServicesFieldNumber = 16; - inline bool cc_generic_services() const; - inline void set_cc_generic_services(bool value); - - // optional bool java_generic_services = 17 [default = false]; - inline bool has_java_generic_services() const; - inline void clear_java_generic_services(); - static const int kJavaGenericServicesFieldNumber = 17; - inline bool java_generic_services() const; - inline void set_java_generic_services(bool value); - - // optional bool py_generic_services = 18 [default = false]; - inline bool has_py_generic_services() const; - inline void clear_py_generic_services(); - static const int kPyGenericServicesFieldNumber = 18; - inline bool py_generic_services() const; - inline void set_py_generic_services(bool value); - - // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; - inline int uninterpreted_option_size() const; - inline void clear_uninterpreted_option(); - static const int kUninterpretedOptionFieldNumber = 999; - inline const ::google::protobuf::UninterpretedOption& uninterpreted_option(int index) const; - inline ::google::protobuf::UninterpretedOption* mutable_uninterpreted_option(int index); - inline ::google::protobuf::UninterpretedOption* add_uninterpreted_option(); - inline const ::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption >& - uninterpreted_option() const; - inline ::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption >* - mutable_uninterpreted_option(); - - GOOGLE_PROTOBUF_EXTENSION_ACCESSORS(FileOptions) - // @@protoc_insertion_point(class_scope:google.protobuf.FileOptions) - private: - inline void set_has_java_package(); - inline void clear_has_java_package(); - inline void set_has_java_outer_classname(); - inline void clear_has_java_outer_classname(); - inline void set_has_java_multiple_files(); - inline void clear_has_java_multiple_files(); - inline void set_has_java_generate_equals_and_hash(); - inline void clear_has_java_generate_equals_and_hash(); - inline void set_has_optimize_for(); - inline void clear_has_optimize_for(); - inline void set_has_go_package(); - inline void clear_has_go_package(); - inline void set_has_cc_generic_services(); - inline void clear_has_cc_generic_services(); - inline void set_has_java_generic_services(); - inline void clear_has_java_generic_services(); - inline void set_has_py_generic_services(); - inline void clear_has_py_generic_services(); - - ::google::protobuf::internal::ExtensionSet _extensions_; - - ::google::protobuf::UnknownFieldSet _unknown_fields_; - - ::std::string* java_package_; - ::std::string* java_outer_classname_; - int optimize_for_; - bool java_multiple_files_; - bool java_generate_equals_and_hash_; - bool cc_generic_services_; - bool java_generic_services_; - ::std::string* go_package_; - ::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption > uninterpreted_option_; - bool py_generic_services_; - - mutable int _cached_size_; - ::google::protobuf::uint32 _has_bits_[(10 + 31) / 32]; - - friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto(); - friend void protobuf_AssignDesc_google_2fprotobuf_2fdescriptor_2eproto(); - friend void protobuf_ShutdownFile_google_2fprotobuf_2fdescriptor_2eproto(); - - void InitAsDefaultInstance(); - static FileOptions* default_instance_; -}; -// ------------------------------------------------------------------- - -class LIBPROTOBUF_EXPORT MessageOptions : public ::google::protobuf::Message { - public: - MessageOptions(); - virtual ~MessageOptions(); - - MessageOptions(const MessageOptions& from); - - inline MessageOptions& operator=(const MessageOptions& from) { - CopyFrom(from); - return *this; - } - - inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const { - return _unknown_fields_; - } - - inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() { - return &_unknown_fields_; - } - - static const ::google::protobuf::Descriptor* descriptor(); - static const MessageOptions& default_instance(); - - void Swap(MessageOptions* other); - - // implements Message ---------------------------------------------- - - MessageOptions* New() const; - void CopyFrom(const ::google::protobuf::Message& from); - void MergeFrom(const ::google::protobuf::Message& from); - void CopyFrom(const MessageOptions& from); - void MergeFrom(const MessageOptions& from); - void Clear(); - bool IsInitialized() const; - - int ByteSize() const; - bool MergePartialFromCodedStream( - ::google::protobuf::io::CodedInputStream* input); - void SerializeWithCachedSizes( - ::google::protobuf::io::CodedOutputStream* output) const; - ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const; - int GetCachedSize() const { return _cached_size_; } - private: - void SharedCtor(); - void SharedDtor(); - void SetCachedSize(int size) const; - public: - - ::google::protobuf::Metadata GetMetadata() const; - - // nested types ---------------------------------------------------- - - // accessors ------------------------------------------------------- - - // optional bool message_set_wire_format = 1 [default = false]; - inline bool has_message_set_wire_format() const; - inline void clear_message_set_wire_format(); - static const int kMessageSetWireFormatFieldNumber = 1; - inline bool message_set_wire_format() const; - inline void set_message_set_wire_format(bool value); - - // optional bool no_standard_descriptor_accessor = 2 [default = false]; - inline bool has_no_standard_descriptor_accessor() const; - inline void clear_no_standard_descriptor_accessor(); - static const int kNoStandardDescriptorAccessorFieldNumber = 2; - inline bool no_standard_descriptor_accessor() const; - inline void set_no_standard_descriptor_accessor(bool value); - - // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; - inline int uninterpreted_option_size() const; - inline void clear_uninterpreted_option(); - static const int kUninterpretedOptionFieldNumber = 999; - inline const ::google::protobuf::UninterpretedOption& uninterpreted_option(int index) const; - inline ::google::protobuf::UninterpretedOption* mutable_uninterpreted_option(int index); - inline ::google::protobuf::UninterpretedOption* add_uninterpreted_option(); - inline const ::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption >& - uninterpreted_option() const; - inline ::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption >* - mutable_uninterpreted_option(); - - GOOGLE_PROTOBUF_EXTENSION_ACCESSORS(MessageOptions) - // @@protoc_insertion_point(class_scope:google.protobuf.MessageOptions) - private: - inline void set_has_message_set_wire_format(); - inline void clear_has_message_set_wire_format(); - inline void set_has_no_standard_descriptor_accessor(); - inline void clear_has_no_standard_descriptor_accessor(); - - ::google::protobuf::internal::ExtensionSet _extensions_; - - ::google::protobuf::UnknownFieldSet _unknown_fields_; - - ::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption > uninterpreted_option_; - bool message_set_wire_format_; - bool no_standard_descriptor_accessor_; - - mutable int _cached_size_; - ::google::protobuf::uint32 _has_bits_[(3 + 31) / 32]; - - friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto(); - friend void protobuf_AssignDesc_google_2fprotobuf_2fdescriptor_2eproto(); - friend void protobuf_ShutdownFile_google_2fprotobuf_2fdescriptor_2eproto(); - - void InitAsDefaultInstance(); - static MessageOptions* default_instance_; -}; -// ------------------------------------------------------------------- - -class LIBPROTOBUF_EXPORT FieldOptions : public ::google::protobuf::Message { - public: - FieldOptions(); - virtual ~FieldOptions(); - - FieldOptions(const FieldOptions& from); - - inline FieldOptions& operator=(const FieldOptions& from) { - CopyFrom(from); - return *this; - } - - inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const { - return _unknown_fields_; - } - - inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() { - return &_unknown_fields_; - } - - static const ::google::protobuf::Descriptor* descriptor(); - static const FieldOptions& default_instance(); - - void Swap(FieldOptions* other); - - // implements Message ---------------------------------------------- - - FieldOptions* New() const; - void CopyFrom(const ::google::protobuf::Message& from); - void MergeFrom(const ::google::protobuf::Message& from); - void CopyFrom(const FieldOptions& from); - void MergeFrom(const FieldOptions& from); - void Clear(); - bool IsInitialized() const; - - int ByteSize() const; - bool MergePartialFromCodedStream( - ::google::protobuf::io::CodedInputStream* input); - void SerializeWithCachedSizes( - ::google::protobuf::io::CodedOutputStream* output) const; - ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const; - int GetCachedSize() const { return _cached_size_; } - private: - void SharedCtor(); - void SharedDtor(); - void SetCachedSize(int size) const; - public: - - ::google::protobuf::Metadata GetMetadata() const; - - // nested types ---------------------------------------------------- - - typedef FieldOptions_CType CType; - static const CType STRING = FieldOptions_CType_STRING; - static const CType CORD = FieldOptions_CType_CORD; - static const CType STRING_PIECE = FieldOptions_CType_STRING_PIECE; - static inline bool CType_IsValid(int value) { - return FieldOptions_CType_IsValid(value); - } - static const CType CType_MIN = - FieldOptions_CType_CType_MIN; - static const CType CType_MAX = - FieldOptions_CType_CType_MAX; - static const int CType_ARRAYSIZE = - FieldOptions_CType_CType_ARRAYSIZE; - static inline const ::google::protobuf::EnumDescriptor* - CType_descriptor() { - return FieldOptions_CType_descriptor(); - } - static inline const ::std::string& CType_Name(CType value) { - return FieldOptions_CType_Name(value); - } - static inline bool CType_Parse(const ::std::string& name, - CType* value) { - return FieldOptions_CType_Parse(name, value); - } - - // accessors ------------------------------------------------------- - - // optional .google.protobuf.FieldOptions.CType ctype = 1 [default = STRING]; - inline bool has_ctype() const; - inline void clear_ctype(); - static const int kCtypeFieldNumber = 1; - inline ::google::protobuf::FieldOptions_CType ctype() const; - inline void set_ctype(::google::protobuf::FieldOptions_CType value); - - // optional bool packed = 2; - inline bool has_packed() const; - inline void clear_packed(); - static const int kPackedFieldNumber = 2; - inline bool packed() const; - inline void set_packed(bool value); - - // optional bool lazy = 5 [default = false]; - inline bool has_lazy() const; - inline void clear_lazy(); - static const int kLazyFieldNumber = 5; - inline bool lazy() const; - inline void set_lazy(bool value); - - // optional bool deprecated = 3 [default = false]; - inline bool has_deprecated() const; - inline void clear_deprecated(); - static const int kDeprecatedFieldNumber = 3; - inline bool deprecated() const; - inline void set_deprecated(bool value); - - // optional string experimental_map_key = 9; - inline bool has_experimental_map_key() const; - inline void clear_experimental_map_key(); - static const int kExperimentalMapKeyFieldNumber = 9; - inline const ::std::string& experimental_map_key() const; - inline void set_experimental_map_key(const ::std::string& value); - inline void set_experimental_map_key(const char* value); - inline void set_experimental_map_key(const char* value, size_t size); - inline ::std::string* mutable_experimental_map_key(); - inline ::std::string* release_experimental_map_key(); - inline void set_allocated_experimental_map_key(::std::string* experimental_map_key); - - // optional bool weak = 10 [default = false]; - inline bool has_weak() const; - inline void clear_weak(); - static const int kWeakFieldNumber = 10; - inline bool weak() const; - inline void set_weak(bool value); - - // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; - inline int uninterpreted_option_size() const; - inline void clear_uninterpreted_option(); - static const int kUninterpretedOptionFieldNumber = 999; - inline const ::google::protobuf::UninterpretedOption& uninterpreted_option(int index) const; - inline ::google::protobuf::UninterpretedOption* mutable_uninterpreted_option(int index); - inline ::google::protobuf::UninterpretedOption* add_uninterpreted_option(); - inline const ::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption >& - uninterpreted_option() const; - inline ::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption >* - mutable_uninterpreted_option(); - - GOOGLE_PROTOBUF_EXTENSION_ACCESSORS(FieldOptions) - // @@protoc_insertion_point(class_scope:google.protobuf.FieldOptions) - private: - inline void set_has_ctype(); - inline void clear_has_ctype(); - inline void set_has_packed(); - inline void clear_has_packed(); - inline void set_has_lazy(); - inline void clear_has_lazy(); - inline void set_has_deprecated(); - inline void clear_has_deprecated(); - inline void set_has_experimental_map_key(); - inline void clear_has_experimental_map_key(); - inline void set_has_weak(); - inline void clear_has_weak(); - - ::google::protobuf::internal::ExtensionSet _extensions_; - - ::google::protobuf::UnknownFieldSet _unknown_fields_; - - int ctype_; - bool packed_; - bool lazy_; - bool deprecated_; - bool weak_; - ::std::string* experimental_map_key_; - ::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption > uninterpreted_option_; - - mutable int _cached_size_; - ::google::protobuf::uint32 _has_bits_[(7 + 31) / 32]; - - friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto(); - friend void protobuf_AssignDesc_google_2fprotobuf_2fdescriptor_2eproto(); - friend void protobuf_ShutdownFile_google_2fprotobuf_2fdescriptor_2eproto(); - - void InitAsDefaultInstance(); - static FieldOptions* default_instance_; -}; -// ------------------------------------------------------------------- - -class LIBPROTOBUF_EXPORT EnumOptions : public ::google::protobuf::Message { - public: - EnumOptions(); - virtual ~EnumOptions(); - - EnumOptions(const EnumOptions& from); - - inline EnumOptions& operator=(const EnumOptions& from) { - CopyFrom(from); - return *this; - } - - inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const { - return _unknown_fields_; - } - - inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() { - return &_unknown_fields_; - } - - static const ::google::protobuf::Descriptor* descriptor(); - static const EnumOptions& default_instance(); - - void Swap(EnumOptions* other); - - // implements Message ---------------------------------------------- - - EnumOptions* New() const; - void CopyFrom(const ::google::protobuf::Message& from); - void MergeFrom(const ::google::protobuf::Message& from); - void CopyFrom(const EnumOptions& from); - void MergeFrom(const EnumOptions& from); - void Clear(); - bool IsInitialized() const; - - int ByteSize() const; - bool MergePartialFromCodedStream( - ::google::protobuf::io::CodedInputStream* input); - void SerializeWithCachedSizes( - ::google::protobuf::io::CodedOutputStream* output) const; - ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const; - int GetCachedSize() const { return _cached_size_; } - private: - void SharedCtor(); - void SharedDtor(); - void SetCachedSize(int size) const; - public: - - ::google::protobuf::Metadata GetMetadata() const; - - // nested types ---------------------------------------------------- - - // accessors ------------------------------------------------------- - - // optional bool allow_alias = 2 [default = true]; - inline bool has_allow_alias() const; - inline void clear_allow_alias(); - static const int kAllowAliasFieldNumber = 2; - inline bool allow_alias() const; - inline void set_allow_alias(bool value); - - // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; - inline int uninterpreted_option_size() const; - inline void clear_uninterpreted_option(); - static const int kUninterpretedOptionFieldNumber = 999; - inline const ::google::protobuf::UninterpretedOption& uninterpreted_option(int index) const; - inline ::google::protobuf::UninterpretedOption* mutable_uninterpreted_option(int index); - inline ::google::protobuf::UninterpretedOption* add_uninterpreted_option(); - inline const ::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption >& - uninterpreted_option() const; - inline ::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption >* - mutable_uninterpreted_option(); - - GOOGLE_PROTOBUF_EXTENSION_ACCESSORS(EnumOptions) - // @@protoc_insertion_point(class_scope:google.protobuf.EnumOptions) - private: - inline void set_has_allow_alias(); - inline void clear_has_allow_alias(); - - ::google::protobuf::internal::ExtensionSet _extensions_; - - ::google::protobuf::UnknownFieldSet _unknown_fields_; - - ::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption > uninterpreted_option_; - bool allow_alias_; - - mutable int _cached_size_; - ::google::protobuf::uint32 _has_bits_[(2 + 31) / 32]; - - friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto(); - friend void protobuf_AssignDesc_google_2fprotobuf_2fdescriptor_2eproto(); - friend void protobuf_ShutdownFile_google_2fprotobuf_2fdescriptor_2eproto(); - - void InitAsDefaultInstance(); - static EnumOptions* default_instance_; -}; -// ------------------------------------------------------------------- - -class LIBPROTOBUF_EXPORT EnumValueOptions : public ::google::protobuf::Message { - public: - EnumValueOptions(); - virtual ~EnumValueOptions(); - - EnumValueOptions(const EnumValueOptions& from); - - inline EnumValueOptions& operator=(const EnumValueOptions& from) { - CopyFrom(from); - return *this; - } - - inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const { - return _unknown_fields_; - } - - inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() { - return &_unknown_fields_; - } - - static const ::google::protobuf::Descriptor* descriptor(); - static const EnumValueOptions& default_instance(); - - void Swap(EnumValueOptions* other); - - // implements Message ---------------------------------------------- - - EnumValueOptions* New() const; - void CopyFrom(const ::google::protobuf::Message& from); - void MergeFrom(const ::google::protobuf::Message& from); - void CopyFrom(const EnumValueOptions& from); - void MergeFrom(const EnumValueOptions& from); - void Clear(); - bool IsInitialized() const; - - int ByteSize() const; - bool MergePartialFromCodedStream( - ::google::protobuf::io::CodedInputStream* input); - void SerializeWithCachedSizes( - ::google::protobuf::io::CodedOutputStream* output) const; - ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const; - int GetCachedSize() const { return _cached_size_; } - private: - void SharedCtor(); - void SharedDtor(); - void SetCachedSize(int size) const; - public: - - ::google::protobuf::Metadata GetMetadata() const; - - // nested types ---------------------------------------------------- - - // accessors ------------------------------------------------------- - - // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; - inline int uninterpreted_option_size() const; - inline void clear_uninterpreted_option(); - static const int kUninterpretedOptionFieldNumber = 999; - inline const ::google::protobuf::UninterpretedOption& uninterpreted_option(int index) const; - inline ::google::protobuf::UninterpretedOption* mutable_uninterpreted_option(int index); - inline ::google::protobuf::UninterpretedOption* add_uninterpreted_option(); - inline const ::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption >& - uninterpreted_option() const; - inline ::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption >* - mutable_uninterpreted_option(); - - GOOGLE_PROTOBUF_EXTENSION_ACCESSORS(EnumValueOptions) - // @@protoc_insertion_point(class_scope:google.protobuf.EnumValueOptions) - private: - - ::google::protobuf::internal::ExtensionSet _extensions_; - - ::google::protobuf::UnknownFieldSet _unknown_fields_; - - ::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption > uninterpreted_option_; - - mutable int _cached_size_; - ::google::protobuf::uint32 _has_bits_[(1 + 31) / 32]; - - friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto(); - friend void protobuf_AssignDesc_google_2fprotobuf_2fdescriptor_2eproto(); - friend void protobuf_ShutdownFile_google_2fprotobuf_2fdescriptor_2eproto(); - - void InitAsDefaultInstance(); - static EnumValueOptions* default_instance_; -}; -// ------------------------------------------------------------------- - -class LIBPROTOBUF_EXPORT ServiceOptions : public ::google::protobuf::Message { - public: - ServiceOptions(); - virtual ~ServiceOptions(); - - ServiceOptions(const ServiceOptions& from); - - inline ServiceOptions& operator=(const ServiceOptions& from) { - CopyFrom(from); - return *this; - } - - inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const { - return _unknown_fields_; - } - - inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() { - return &_unknown_fields_; - } - - static const ::google::protobuf::Descriptor* descriptor(); - static const ServiceOptions& default_instance(); - - void Swap(ServiceOptions* other); - - // implements Message ---------------------------------------------- - - ServiceOptions* New() const; - void CopyFrom(const ::google::protobuf::Message& from); - void MergeFrom(const ::google::protobuf::Message& from); - void CopyFrom(const ServiceOptions& from); - void MergeFrom(const ServiceOptions& from); - void Clear(); - bool IsInitialized() const; - - int ByteSize() const; - bool MergePartialFromCodedStream( - ::google::protobuf::io::CodedInputStream* input); - void SerializeWithCachedSizes( - ::google::protobuf::io::CodedOutputStream* output) const; - ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const; - int GetCachedSize() const { return _cached_size_; } - private: - void SharedCtor(); - void SharedDtor(); - void SetCachedSize(int size) const; - public: - - ::google::protobuf::Metadata GetMetadata() const; - - // nested types ---------------------------------------------------- - - // accessors ------------------------------------------------------- - - // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; - inline int uninterpreted_option_size() const; - inline void clear_uninterpreted_option(); - static const int kUninterpretedOptionFieldNumber = 999; - inline const ::google::protobuf::UninterpretedOption& uninterpreted_option(int index) const; - inline ::google::protobuf::UninterpretedOption* mutable_uninterpreted_option(int index); - inline ::google::protobuf::UninterpretedOption* add_uninterpreted_option(); - inline const ::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption >& - uninterpreted_option() const; - inline ::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption >* - mutable_uninterpreted_option(); - - GOOGLE_PROTOBUF_EXTENSION_ACCESSORS(ServiceOptions) - // @@protoc_insertion_point(class_scope:google.protobuf.ServiceOptions) - private: - - ::google::protobuf::internal::ExtensionSet _extensions_; - - ::google::protobuf::UnknownFieldSet _unknown_fields_; - - ::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption > uninterpreted_option_; - - mutable int _cached_size_; - ::google::protobuf::uint32 _has_bits_[(1 + 31) / 32]; - - friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto(); - friend void protobuf_AssignDesc_google_2fprotobuf_2fdescriptor_2eproto(); - friend void protobuf_ShutdownFile_google_2fprotobuf_2fdescriptor_2eproto(); - - void InitAsDefaultInstance(); - static ServiceOptions* default_instance_; -}; -// ------------------------------------------------------------------- - -class LIBPROTOBUF_EXPORT MethodOptions : public ::google::protobuf::Message { - public: - MethodOptions(); - virtual ~MethodOptions(); - - MethodOptions(const MethodOptions& from); - - inline MethodOptions& operator=(const MethodOptions& from) { - CopyFrom(from); - return *this; - } - - inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const { - return _unknown_fields_; - } - - inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() { - return &_unknown_fields_; - } - - static const ::google::protobuf::Descriptor* descriptor(); - static const MethodOptions& default_instance(); - - void Swap(MethodOptions* other); - - // implements Message ---------------------------------------------- - - MethodOptions* New() const; - void CopyFrom(const ::google::protobuf::Message& from); - void MergeFrom(const ::google::protobuf::Message& from); - void CopyFrom(const MethodOptions& from); - void MergeFrom(const MethodOptions& from); - void Clear(); - bool IsInitialized() const; - - int ByteSize() const; - bool MergePartialFromCodedStream( - ::google::protobuf::io::CodedInputStream* input); - void SerializeWithCachedSizes( - ::google::protobuf::io::CodedOutputStream* output) const; - ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const; - int GetCachedSize() const { return _cached_size_; } - private: - void SharedCtor(); - void SharedDtor(); - void SetCachedSize(int size) const; - public: - - ::google::protobuf::Metadata GetMetadata() const; - - // nested types ---------------------------------------------------- - - // accessors ------------------------------------------------------- - - // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; - inline int uninterpreted_option_size() const; - inline void clear_uninterpreted_option(); - static const int kUninterpretedOptionFieldNumber = 999; - inline const ::google::protobuf::UninterpretedOption& uninterpreted_option(int index) const; - inline ::google::protobuf::UninterpretedOption* mutable_uninterpreted_option(int index); - inline ::google::protobuf::UninterpretedOption* add_uninterpreted_option(); - inline const ::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption >& - uninterpreted_option() const; - inline ::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption >* - mutable_uninterpreted_option(); - - GOOGLE_PROTOBUF_EXTENSION_ACCESSORS(MethodOptions) - // @@protoc_insertion_point(class_scope:google.protobuf.MethodOptions) - private: - - ::google::protobuf::internal::ExtensionSet _extensions_; - - ::google::protobuf::UnknownFieldSet _unknown_fields_; - - ::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption > uninterpreted_option_; - - mutable int _cached_size_; - ::google::protobuf::uint32 _has_bits_[(1 + 31) / 32]; - - friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto(); - friend void protobuf_AssignDesc_google_2fprotobuf_2fdescriptor_2eproto(); - friend void protobuf_ShutdownFile_google_2fprotobuf_2fdescriptor_2eproto(); - - void InitAsDefaultInstance(); - static MethodOptions* default_instance_; -}; -// ------------------------------------------------------------------- - -class LIBPROTOBUF_EXPORT UninterpretedOption_NamePart : public ::google::protobuf::Message { - public: - UninterpretedOption_NamePart(); - virtual ~UninterpretedOption_NamePart(); - - UninterpretedOption_NamePart(const UninterpretedOption_NamePart& from); - - inline UninterpretedOption_NamePart& operator=(const UninterpretedOption_NamePart& from) { - CopyFrom(from); - return *this; - } - - inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const { - return _unknown_fields_; - } - - inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() { - return &_unknown_fields_; - } - - static const ::google::protobuf::Descriptor* descriptor(); - static const UninterpretedOption_NamePart& default_instance(); - - void Swap(UninterpretedOption_NamePart* other); - - // implements Message ---------------------------------------------- - - UninterpretedOption_NamePart* New() const; - void CopyFrom(const ::google::protobuf::Message& from); - void MergeFrom(const ::google::protobuf::Message& from); - void CopyFrom(const UninterpretedOption_NamePart& from); - void MergeFrom(const UninterpretedOption_NamePart& from); - void Clear(); - bool IsInitialized() const; - - int ByteSize() const; - bool MergePartialFromCodedStream( - ::google::protobuf::io::CodedInputStream* input); - void SerializeWithCachedSizes( - ::google::protobuf::io::CodedOutputStream* output) const; - ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const; - int GetCachedSize() const { return _cached_size_; } - private: - void SharedCtor(); - void SharedDtor(); - void SetCachedSize(int size) const; - public: - - ::google::protobuf::Metadata GetMetadata() const; - - // nested types ---------------------------------------------------- - - // accessors ------------------------------------------------------- - - // required string name_part = 1; - inline bool has_name_part() const; - inline void clear_name_part(); - static const int kNamePartFieldNumber = 1; - inline const ::std::string& name_part() const; - inline void set_name_part(const ::std::string& value); - inline void set_name_part(const char* value); - inline void set_name_part(const char* value, size_t size); - inline ::std::string* mutable_name_part(); - inline ::std::string* release_name_part(); - inline void set_allocated_name_part(::std::string* name_part); - - // required bool is_extension = 2; - inline bool has_is_extension() const; - inline void clear_is_extension(); - static const int kIsExtensionFieldNumber = 2; - inline bool is_extension() const; - inline void set_is_extension(bool value); - - // @@protoc_insertion_point(class_scope:google.protobuf.UninterpretedOption.NamePart) - private: - inline void set_has_name_part(); - inline void clear_has_name_part(); - inline void set_has_is_extension(); - inline void clear_has_is_extension(); - - ::google::protobuf::UnknownFieldSet _unknown_fields_; - - ::std::string* name_part_; - bool is_extension_; - - mutable int _cached_size_; - ::google::protobuf::uint32 _has_bits_[(2 + 31) / 32]; - - friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto(); - friend void protobuf_AssignDesc_google_2fprotobuf_2fdescriptor_2eproto(); - friend void protobuf_ShutdownFile_google_2fprotobuf_2fdescriptor_2eproto(); - - void InitAsDefaultInstance(); - static UninterpretedOption_NamePart* default_instance_; -}; -// ------------------------------------------------------------------- - -class LIBPROTOBUF_EXPORT UninterpretedOption : public ::google::protobuf::Message { - public: - UninterpretedOption(); - virtual ~UninterpretedOption(); - - UninterpretedOption(const UninterpretedOption& from); - - inline UninterpretedOption& operator=(const UninterpretedOption& from) { - CopyFrom(from); - return *this; - } - - inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const { - return _unknown_fields_; - } - - inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() { - return &_unknown_fields_; - } - - static const ::google::protobuf::Descriptor* descriptor(); - static const UninterpretedOption& default_instance(); - - void Swap(UninterpretedOption* other); - - // implements Message ---------------------------------------------- - - UninterpretedOption* New() const; - void CopyFrom(const ::google::protobuf::Message& from); - void MergeFrom(const ::google::protobuf::Message& from); - void CopyFrom(const UninterpretedOption& from); - void MergeFrom(const UninterpretedOption& from); - void Clear(); - bool IsInitialized() const; - - int ByteSize() const; - bool MergePartialFromCodedStream( - ::google::protobuf::io::CodedInputStream* input); - void SerializeWithCachedSizes( - ::google::protobuf::io::CodedOutputStream* output) const; - ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const; - int GetCachedSize() const { return _cached_size_; } - private: - void SharedCtor(); - void SharedDtor(); - void SetCachedSize(int size) const; - public: - - ::google::protobuf::Metadata GetMetadata() const; - - // nested types ---------------------------------------------------- - - typedef UninterpretedOption_NamePart NamePart; - - // accessors ------------------------------------------------------- - - // repeated .google.protobuf.UninterpretedOption.NamePart name = 2; - inline int name_size() const; - inline void clear_name(); - static const int kNameFieldNumber = 2; - inline const ::google::protobuf::UninterpretedOption_NamePart& name(int index) const; - inline ::google::protobuf::UninterpretedOption_NamePart* mutable_name(int index); - inline ::google::protobuf::UninterpretedOption_NamePart* add_name(); - inline const ::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption_NamePart >& - name() const; - inline ::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption_NamePart >* - mutable_name(); - - // optional string identifier_value = 3; - inline bool has_identifier_value() const; - inline void clear_identifier_value(); - static const int kIdentifierValueFieldNumber = 3; - inline const ::std::string& identifier_value() const; - inline void set_identifier_value(const ::std::string& value); - inline void set_identifier_value(const char* value); - inline void set_identifier_value(const char* value, size_t size); - inline ::std::string* mutable_identifier_value(); - inline ::std::string* release_identifier_value(); - inline void set_allocated_identifier_value(::std::string* identifier_value); - - // optional uint64 positive_int_value = 4; - inline bool has_positive_int_value() const; - inline void clear_positive_int_value(); - static const int kPositiveIntValueFieldNumber = 4; - inline ::google::protobuf::uint64 positive_int_value() const; - inline void set_positive_int_value(::google::protobuf::uint64 value); - - // optional int64 negative_int_value = 5; - inline bool has_negative_int_value() const; - inline void clear_negative_int_value(); - static const int kNegativeIntValueFieldNumber = 5; - inline ::google::protobuf::int64 negative_int_value() const; - inline void set_negative_int_value(::google::protobuf::int64 value); - - // optional double double_value = 6; - inline bool has_double_value() const; - inline void clear_double_value(); - static const int kDoubleValueFieldNumber = 6; - inline double double_value() const; - inline void set_double_value(double value); - - // optional bytes string_value = 7; - inline bool has_string_value() const; - inline void clear_string_value(); - static const int kStringValueFieldNumber = 7; - inline const ::std::string& string_value() const; - inline void set_string_value(const ::std::string& value); - inline void set_string_value(const char* value); - inline void set_string_value(const void* value, size_t size); - inline ::std::string* mutable_string_value(); - inline ::std::string* release_string_value(); - inline void set_allocated_string_value(::std::string* string_value); - - // optional string aggregate_value = 8; - inline bool has_aggregate_value() const; - inline void clear_aggregate_value(); - static const int kAggregateValueFieldNumber = 8; - inline const ::std::string& aggregate_value() const; - inline void set_aggregate_value(const ::std::string& value); - inline void set_aggregate_value(const char* value); - inline void set_aggregate_value(const char* value, size_t size); - inline ::std::string* mutable_aggregate_value(); - inline ::std::string* release_aggregate_value(); - inline void set_allocated_aggregate_value(::std::string* aggregate_value); - - // @@protoc_insertion_point(class_scope:google.protobuf.UninterpretedOption) - private: - inline void set_has_identifier_value(); - inline void clear_has_identifier_value(); - inline void set_has_positive_int_value(); - inline void clear_has_positive_int_value(); - inline void set_has_negative_int_value(); - inline void clear_has_negative_int_value(); - inline void set_has_double_value(); - inline void clear_has_double_value(); - inline void set_has_string_value(); - inline void clear_has_string_value(); - inline void set_has_aggregate_value(); - inline void clear_has_aggregate_value(); - - ::google::protobuf::UnknownFieldSet _unknown_fields_; - - ::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption_NamePart > name_; - ::std::string* identifier_value_; - ::google::protobuf::uint64 positive_int_value_; - ::google::protobuf::int64 negative_int_value_; - double double_value_; - ::std::string* string_value_; - ::std::string* aggregate_value_; - - mutable int _cached_size_; - ::google::protobuf::uint32 _has_bits_[(7 + 31) / 32]; - - friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto(); - friend void protobuf_AssignDesc_google_2fprotobuf_2fdescriptor_2eproto(); - friend void protobuf_ShutdownFile_google_2fprotobuf_2fdescriptor_2eproto(); - - void InitAsDefaultInstance(); - static UninterpretedOption* default_instance_; -}; -// ------------------------------------------------------------------- - -class LIBPROTOBUF_EXPORT SourceCodeInfo_Location : public ::google::protobuf::Message { - public: - SourceCodeInfo_Location(); - virtual ~SourceCodeInfo_Location(); - - SourceCodeInfo_Location(const SourceCodeInfo_Location& from); - - inline SourceCodeInfo_Location& operator=(const SourceCodeInfo_Location& from) { - CopyFrom(from); - return *this; - } - - inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const { - return _unknown_fields_; - } - - inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() { - return &_unknown_fields_; - } - - static const ::google::protobuf::Descriptor* descriptor(); - static const SourceCodeInfo_Location& default_instance(); - - void Swap(SourceCodeInfo_Location* other); - - // implements Message ---------------------------------------------- - - SourceCodeInfo_Location* New() const; - void CopyFrom(const ::google::protobuf::Message& from); - void MergeFrom(const ::google::protobuf::Message& from); - void CopyFrom(const SourceCodeInfo_Location& from); - void MergeFrom(const SourceCodeInfo_Location& from); - void Clear(); - bool IsInitialized() const; - - int ByteSize() const; - bool MergePartialFromCodedStream( - ::google::protobuf::io::CodedInputStream* input); - void SerializeWithCachedSizes( - ::google::protobuf::io::CodedOutputStream* output) const; - ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const; - int GetCachedSize() const { return _cached_size_; } - private: - void SharedCtor(); - void SharedDtor(); - void SetCachedSize(int size) const; - public: - - ::google::protobuf::Metadata GetMetadata() const; - - // nested types ---------------------------------------------------- - - // accessors ------------------------------------------------------- - - // repeated int32 path = 1 [packed = true]; - inline int path_size() const; - inline void clear_path(); - static const int kPathFieldNumber = 1; - inline ::google::protobuf::int32 path(int index) const; - inline void set_path(int index, ::google::protobuf::int32 value); - inline void add_path(::google::protobuf::int32 value); - inline const ::google::protobuf::RepeatedField< ::google::protobuf::int32 >& - path() const; - inline ::google::protobuf::RepeatedField< ::google::protobuf::int32 >* - mutable_path(); - - // repeated int32 span = 2 [packed = true]; - inline int span_size() const; - inline void clear_span(); - static const int kSpanFieldNumber = 2; - inline ::google::protobuf::int32 span(int index) const; - inline void set_span(int index, ::google::protobuf::int32 value); - inline void add_span(::google::protobuf::int32 value); - inline const ::google::protobuf::RepeatedField< ::google::protobuf::int32 >& - span() const; - inline ::google::protobuf::RepeatedField< ::google::protobuf::int32 >* - mutable_span(); - - // optional string leading_comments = 3; - inline bool has_leading_comments() const; - inline void clear_leading_comments(); - static const int kLeadingCommentsFieldNumber = 3; - inline const ::std::string& leading_comments() const; - inline void set_leading_comments(const ::std::string& value); - inline void set_leading_comments(const char* value); - inline void set_leading_comments(const char* value, size_t size); - inline ::std::string* mutable_leading_comments(); - inline ::std::string* release_leading_comments(); - inline void set_allocated_leading_comments(::std::string* leading_comments); - - // optional string trailing_comments = 4; - inline bool has_trailing_comments() const; - inline void clear_trailing_comments(); - static const int kTrailingCommentsFieldNumber = 4; - inline const ::std::string& trailing_comments() const; - inline void set_trailing_comments(const ::std::string& value); - inline void set_trailing_comments(const char* value); - inline void set_trailing_comments(const char* value, size_t size); - inline ::std::string* mutable_trailing_comments(); - inline ::std::string* release_trailing_comments(); - inline void set_allocated_trailing_comments(::std::string* trailing_comments); - - // @@protoc_insertion_point(class_scope:google.protobuf.SourceCodeInfo.Location) - private: - inline void set_has_leading_comments(); - inline void clear_has_leading_comments(); - inline void set_has_trailing_comments(); - inline void clear_has_trailing_comments(); - - ::google::protobuf::UnknownFieldSet _unknown_fields_; - - ::google::protobuf::RepeatedField< ::google::protobuf::int32 > path_; - mutable int _path_cached_byte_size_; - ::google::protobuf::RepeatedField< ::google::protobuf::int32 > span_; - mutable int _span_cached_byte_size_; - ::std::string* leading_comments_; - ::std::string* trailing_comments_; - - mutable int _cached_size_; - ::google::protobuf::uint32 _has_bits_[(4 + 31) / 32]; - - friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto(); - friend void protobuf_AssignDesc_google_2fprotobuf_2fdescriptor_2eproto(); - friend void protobuf_ShutdownFile_google_2fprotobuf_2fdescriptor_2eproto(); - - void InitAsDefaultInstance(); - static SourceCodeInfo_Location* default_instance_; -}; -// ------------------------------------------------------------------- - -class LIBPROTOBUF_EXPORT SourceCodeInfo : public ::google::protobuf::Message { - public: - SourceCodeInfo(); - virtual ~SourceCodeInfo(); - - SourceCodeInfo(const SourceCodeInfo& from); - - inline SourceCodeInfo& operator=(const SourceCodeInfo& from) { - CopyFrom(from); - return *this; - } - - inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const { - return _unknown_fields_; - } - - inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() { - return &_unknown_fields_; - } - - static const ::google::protobuf::Descriptor* descriptor(); - static const SourceCodeInfo& default_instance(); - - void Swap(SourceCodeInfo* other); - - // implements Message ---------------------------------------------- - - SourceCodeInfo* New() const; - void CopyFrom(const ::google::protobuf::Message& from); - void MergeFrom(const ::google::protobuf::Message& from); - void CopyFrom(const SourceCodeInfo& from); - void MergeFrom(const SourceCodeInfo& from); - void Clear(); - bool IsInitialized() const; - - int ByteSize() const; - bool MergePartialFromCodedStream( - ::google::protobuf::io::CodedInputStream* input); - void SerializeWithCachedSizes( - ::google::protobuf::io::CodedOutputStream* output) const; - ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const; - int GetCachedSize() const { return _cached_size_; } - private: - void SharedCtor(); - void SharedDtor(); - void SetCachedSize(int size) const; - public: - - ::google::protobuf::Metadata GetMetadata() const; - - // nested types ---------------------------------------------------- - - typedef SourceCodeInfo_Location Location; - - // accessors ------------------------------------------------------- - - // repeated .google.protobuf.SourceCodeInfo.Location location = 1; - inline int location_size() const; - inline void clear_location(); - static const int kLocationFieldNumber = 1; - inline const ::google::protobuf::SourceCodeInfo_Location& location(int index) const; - inline ::google::protobuf::SourceCodeInfo_Location* mutable_location(int index); - inline ::google::protobuf::SourceCodeInfo_Location* add_location(); - inline const ::google::protobuf::RepeatedPtrField< ::google::protobuf::SourceCodeInfo_Location >& - location() const; - inline ::google::protobuf::RepeatedPtrField< ::google::protobuf::SourceCodeInfo_Location >* - mutable_location(); - - // @@protoc_insertion_point(class_scope:google.protobuf.SourceCodeInfo) - private: - - ::google::protobuf::UnknownFieldSet _unknown_fields_; - - ::google::protobuf::RepeatedPtrField< ::google::protobuf::SourceCodeInfo_Location > location_; - - mutable int _cached_size_; - ::google::protobuf::uint32 _has_bits_[(1 + 31) / 32]; - - friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto(); - friend void protobuf_AssignDesc_google_2fprotobuf_2fdescriptor_2eproto(); - friend void protobuf_ShutdownFile_google_2fprotobuf_2fdescriptor_2eproto(); - - void InitAsDefaultInstance(); - static SourceCodeInfo* default_instance_; -}; -// =================================================================== - - -// =================================================================== - -// FileDescriptorSet - -// repeated .google.protobuf.FileDescriptorProto file = 1; -inline int FileDescriptorSet::file_size() const { - return file_.size(); -} -inline void FileDescriptorSet::clear_file() { - file_.Clear(); -} -inline const ::google::protobuf::FileDescriptorProto& FileDescriptorSet::file(int index) const { - return file_.Get(index); -} -inline ::google::protobuf::FileDescriptorProto* FileDescriptorSet::mutable_file(int index) { - return file_.Mutable(index); -} -inline ::google::protobuf::FileDescriptorProto* FileDescriptorSet::add_file() { - return file_.Add(); -} -inline const ::google::protobuf::RepeatedPtrField< ::google::protobuf::FileDescriptorProto >& -FileDescriptorSet::file() const { - return file_; -} -inline ::google::protobuf::RepeatedPtrField< ::google::protobuf::FileDescriptorProto >* -FileDescriptorSet::mutable_file() { - return &file_; -} - -// ------------------------------------------------------------------- - -// FileDescriptorProto - -// optional string name = 1; -inline bool FileDescriptorProto::has_name() const { - return (_has_bits_[0] & 0x00000001u) != 0; -} -inline void FileDescriptorProto::set_has_name() { - _has_bits_[0] |= 0x00000001u; -} -inline void FileDescriptorProto::clear_has_name() { - _has_bits_[0] &= ~0x00000001u; -} -inline void FileDescriptorProto::clear_name() { - if (name_ != &::google::protobuf::internal::kEmptyString) { - name_->clear(); - } - clear_has_name(); -} -inline const ::std::string& FileDescriptorProto::name() const { - return *name_; -} -inline void FileDescriptorProto::set_name(const ::std::string& value) { - set_has_name(); - if (name_ == &::google::protobuf::internal::kEmptyString) { - name_ = new ::std::string; - } - name_->assign(value); -} -inline void FileDescriptorProto::set_name(const char* value) { - set_has_name(); - if (name_ == &::google::protobuf::internal::kEmptyString) { - name_ = new ::std::string; - } - name_->assign(value); -} -inline void FileDescriptorProto::set_name(const char* value, size_t size) { - set_has_name(); - if (name_ == &::google::protobuf::internal::kEmptyString) { - name_ = new ::std::string; - } - name_->assign(reinterpret_cast(value), size); -} -inline ::std::string* FileDescriptorProto::mutable_name() { - set_has_name(); - if (name_ == &::google::protobuf::internal::kEmptyString) { - name_ = new ::std::string; - } - return name_; -} -inline ::std::string* FileDescriptorProto::release_name() { - clear_has_name(); - if (name_ == &::google::protobuf::internal::kEmptyString) { - return NULL; - } else { - ::std::string* temp = name_; - name_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); - return temp; - } -} -inline void FileDescriptorProto::set_allocated_name(::std::string* name) { - if (name_ != &::google::protobuf::internal::kEmptyString) { - delete name_; - } - if (name) { - set_has_name(); - name_ = name; - } else { - clear_has_name(); - name_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); - } -} - -// optional string package = 2; -inline bool FileDescriptorProto::has_package() const { - return (_has_bits_[0] & 0x00000002u) != 0; -} -inline void FileDescriptorProto::set_has_package() { - _has_bits_[0] |= 0x00000002u; -} -inline void FileDescriptorProto::clear_has_package() { - _has_bits_[0] &= ~0x00000002u; -} -inline void FileDescriptorProto::clear_package() { - if (package_ != &::google::protobuf::internal::kEmptyString) { - package_->clear(); - } - clear_has_package(); -} -inline const ::std::string& FileDescriptorProto::package() const { - return *package_; -} -inline void FileDescriptorProto::set_package(const ::std::string& value) { - set_has_package(); - if (package_ == &::google::protobuf::internal::kEmptyString) { - package_ = new ::std::string; - } - package_->assign(value); -} -inline void FileDescriptorProto::set_package(const char* value) { - set_has_package(); - if (package_ == &::google::protobuf::internal::kEmptyString) { - package_ = new ::std::string; - } - package_->assign(value); -} -inline void FileDescriptorProto::set_package(const char* value, size_t size) { - set_has_package(); - if (package_ == &::google::protobuf::internal::kEmptyString) { - package_ = new ::std::string; - } - package_->assign(reinterpret_cast(value), size); -} -inline ::std::string* FileDescriptorProto::mutable_package() { - set_has_package(); - if (package_ == &::google::protobuf::internal::kEmptyString) { - package_ = new ::std::string; - } - return package_; -} -inline ::std::string* FileDescriptorProto::release_package() { - clear_has_package(); - if (package_ == &::google::protobuf::internal::kEmptyString) { - return NULL; - } else { - ::std::string* temp = package_; - package_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); - return temp; - } -} -inline void FileDescriptorProto::set_allocated_package(::std::string* package) { - if (package_ != &::google::protobuf::internal::kEmptyString) { - delete package_; - } - if (package) { - set_has_package(); - package_ = package; - } else { - clear_has_package(); - package_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); - } -} - -// repeated string dependency = 3; -inline int FileDescriptorProto::dependency_size() const { - return dependency_.size(); -} -inline void FileDescriptorProto::clear_dependency() { - dependency_.Clear(); -} -inline const ::std::string& FileDescriptorProto::dependency(int index) const { - return dependency_.Get(index); -} -inline ::std::string* FileDescriptorProto::mutable_dependency(int index) { - return dependency_.Mutable(index); -} -inline void FileDescriptorProto::set_dependency(int index, const ::std::string& value) { - dependency_.Mutable(index)->assign(value); -} -inline void FileDescriptorProto::set_dependency(int index, const char* value) { - dependency_.Mutable(index)->assign(value); -} -inline void FileDescriptorProto::set_dependency(int index, const char* value, size_t size) { - dependency_.Mutable(index)->assign( - reinterpret_cast(value), size); -} -inline ::std::string* FileDescriptorProto::add_dependency() { - return dependency_.Add(); -} -inline void FileDescriptorProto::add_dependency(const ::std::string& value) { - dependency_.Add()->assign(value); -} -inline void FileDescriptorProto::add_dependency(const char* value) { - dependency_.Add()->assign(value); -} -inline void FileDescriptorProto::add_dependency(const char* value, size_t size) { - dependency_.Add()->assign(reinterpret_cast(value), size); -} -inline const ::google::protobuf::RepeatedPtrField< ::std::string>& -FileDescriptorProto::dependency() const { - return dependency_; -} -inline ::google::protobuf::RepeatedPtrField< ::std::string>* -FileDescriptorProto::mutable_dependency() { - return &dependency_; -} - -// repeated int32 public_dependency = 10; -inline int FileDescriptorProto::public_dependency_size() const { - return public_dependency_.size(); -} -inline void FileDescriptorProto::clear_public_dependency() { - public_dependency_.Clear(); -} -inline ::google::protobuf::int32 FileDescriptorProto::public_dependency(int index) const { - return public_dependency_.Get(index); -} -inline void FileDescriptorProto::set_public_dependency(int index, ::google::protobuf::int32 value) { - public_dependency_.Set(index, value); -} -inline void FileDescriptorProto::add_public_dependency(::google::protobuf::int32 value) { - public_dependency_.Add(value); -} -inline const ::google::protobuf::RepeatedField< ::google::protobuf::int32 >& -FileDescriptorProto::public_dependency() const { - return public_dependency_; -} -inline ::google::protobuf::RepeatedField< ::google::protobuf::int32 >* -FileDescriptorProto::mutable_public_dependency() { - return &public_dependency_; -} - -// repeated int32 weak_dependency = 11; -inline int FileDescriptorProto::weak_dependency_size() const { - return weak_dependency_.size(); -} -inline void FileDescriptorProto::clear_weak_dependency() { - weak_dependency_.Clear(); -} -inline ::google::protobuf::int32 FileDescriptorProto::weak_dependency(int index) const { - return weak_dependency_.Get(index); -} -inline void FileDescriptorProto::set_weak_dependency(int index, ::google::protobuf::int32 value) { - weak_dependency_.Set(index, value); -} -inline void FileDescriptorProto::add_weak_dependency(::google::protobuf::int32 value) { - weak_dependency_.Add(value); -} -inline const ::google::protobuf::RepeatedField< ::google::protobuf::int32 >& -FileDescriptorProto::weak_dependency() const { - return weak_dependency_; -} -inline ::google::protobuf::RepeatedField< ::google::protobuf::int32 >* -FileDescriptorProto::mutable_weak_dependency() { - return &weak_dependency_; -} - -// repeated .google.protobuf.DescriptorProto message_type = 4; -inline int FileDescriptorProto::message_type_size() const { - return message_type_.size(); -} -inline void FileDescriptorProto::clear_message_type() { - message_type_.Clear(); -} -inline const ::google::protobuf::DescriptorProto& FileDescriptorProto::message_type(int index) const { - return message_type_.Get(index); -} -inline ::google::protobuf::DescriptorProto* FileDescriptorProto::mutable_message_type(int index) { - return message_type_.Mutable(index); -} -inline ::google::protobuf::DescriptorProto* FileDescriptorProto::add_message_type() { - return message_type_.Add(); -} -inline const ::google::protobuf::RepeatedPtrField< ::google::protobuf::DescriptorProto >& -FileDescriptorProto::message_type() const { - return message_type_; -} -inline ::google::protobuf::RepeatedPtrField< ::google::protobuf::DescriptorProto >* -FileDescriptorProto::mutable_message_type() { - return &message_type_; -} - -// repeated .google.protobuf.EnumDescriptorProto enum_type = 5; -inline int FileDescriptorProto::enum_type_size() const { - return enum_type_.size(); -} -inline void FileDescriptorProto::clear_enum_type() { - enum_type_.Clear(); -} -inline const ::google::protobuf::EnumDescriptorProto& FileDescriptorProto::enum_type(int index) const { - return enum_type_.Get(index); -} -inline ::google::protobuf::EnumDescriptorProto* FileDescriptorProto::mutable_enum_type(int index) { - return enum_type_.Mutable(index); -} -inline ::google::protobuf::EnumDescriptorProto* FileDescriptorProto::add_enum_type() { - return enum_type_.Add(); -} -inline const ::google::protobuf::RepeatedPtrField< ::google::protobuf::EnumDescriptorProto >& -FileDescriptorProto::enum_type() const { - return enum_type_; -} -inline ::google::protobuf::RepeatedPtrField< ::google::protobuf::EnumDescriptorProto >* -FileDescriptorProto::mutable_enum_type() { - return &enum_type_; -} - -// repeated .google.protobuf.ServiceDescriptorProto service = 6; -inline int FileDescriptorProto::service_size() const { - return service_.size(); -} -inline void FileDescriptorProto::clear_service() { - service_.Clear(); -} -inline const ::google::protobuf::ServiceDescriptorProto& FileDescriptorProto::service(int index) const { - return service_.Get(index); -} -inline ::google::protobuf::ServiceDescriptorProto* FileDescriptorProto::mutable_service(int index) { - return service_.Mutable(index); -} -inline ::google::protobuf::ServiceDescriptorProto* FileDescriptorProto::add_service() { - return service_.Add(); -} -inline const ::google::protobuf::RepeatedPtrField< ::google::protobuf::ServiceDescriptorProto >& -FileDescriptorProto::service() const { - return service_; -} -inline ::google::protobuf::RepeatedPtrField< ::google::protobuf::ServiceDescriptorProto >* -FileDescriptorProto::mutable_service() { - return &service_; -} - -// repeated .google.protobuf.FieldDescriptorProto extension = 7; -inline int FileDescriptorProto::extension_size() const { - return extension_.size(); -} -inline void FileDescriptorProto::clear_extension() { - extension_.Clear(); -} -inline const ::google::protobuf::FieldDescriptorProto& FileDescriptorProto::extension(int index) const { - return extension_.Get(index); -} -inline ::google::protobuf::FieldDescriptorProto* FileDescriptorProto::mutable_extension(int index) { - return extension_.Mutable(index); -} -inline ::google::protobuf::FieldDescriptorProto* FileDescriptorProto::add_extension() { - return extension_.Add(); -} -inline const ::google::protobuf::RepeatedPtrField< ::google::protobuf::FieldDescriptorProto >& -FileDescriptorProto::extension() const { - return extension_; -} -inline ::google::protobuf::RepeatedPtrField< ::google::protobuf::FieldDescriptorProto >* -FileDescriptorProto::mutable_extension() { - return &extension_; -} - -// optional .google.protobuf.FileOptions options = 8; -inline bool FileDescriptorProto::has_options() const { - return (_has_bits_[0] & 0x00000200u) != 0; -} -inline void FileDescriptorProto::set_has_options() { - _has_bits_[0] |= 0x00000200u; -} -inline void FileDescriptorProto::clear_has_options() { - _has_bits_[0] &= ~0x00000200u; -} -inline void FileDescriptorProto::clear_options() { - if (options_ != NULL) options_->::google::protobuf::FileOptions::Clear(); - clear_has_options(); -} -inline const ::google::protobuf::FileOptions& FileDescriptorProto::options() const { - return options_ != NULL ? *options_ : *default_instance_->options_; -} -inline ::google::protobuf::FileOptions* FileDescriptorProto::mutable_options() { - set_has_options(); - if (options_ == NULL) options_ = new ::google::protobuf::FileOptions; - return options_; -} -inline ::google::protobuf::FileOptions* FileDescriptorProto::release_options() { - clear_has_options(); - ::google::protobuf::FileOptions* temp = options_; - options_ = NULL; - return temp; -} -inline void FileDescriptorProto::set_allocated_options(::google::protobuf::FileOptions* options) { - delete options_; - options_ = options; - if (options) { - set_has_options(); - } else { - clear_has_options(); - } -} - -// optional .google.protobuf.SourceCodeInfo source_code_info = 9; -inline bool FileDescriptorProto::has_source_code_info() const { - return (_has_bits_[0] & 0x00000400u) != 0; -} -inline void FileDescriptorProto::set_has_source_code_info() { - _has_bits_[0] |= 0x00000400u; -} -inline void FileDescriptorProto::clear_has_source_code_info() { - _has_bits_[0] &= ~0x00000400u; -} -inline void FileDescriptorProto::clear_source_code_info() { - if (source_code_info_ != NULL) source_code_info_->::google::protobuf::SourceCodeInfo::Clear(); - clear_has_source_code_info(); -} -inline const ::google::protobuf::SourceCodeInfo& FileDescriptorProto::source_code_info() const { - return source_code_info_ != NULL ? *source_code_info_ : *default_instance_->source_code_info_; -} -inline ::google::protobuf::SourceCodeInfo* FileDescriptorProto::mutable_source_code_info() { - set_has_source_code_info(); - if (source_code_info_ == NULL) source_code_info_ = new ::google::protobuf::SourceCodeInfo; - return source_code_info_; -} -inline ::google::protobuf::SourceCodeInfo* FileDescriptorProto::release_source_code_info() { - clear_has_source_code_info(); - ::google::protobuf::SourceCodeInfo* temp = source_code_info_; - source_code_info_ = NULL; - return temp; -} -inline void FileDescriptorProto::set_allocated_source_code_info(::google::protobuf::SourceCodeInfo* source_code_info) { - delete source_code_info_; - source_code_info_ = source_code_info; - if (source_code_info) { - set_has_source_code_info(); - } else { - clear_has_source_code_info(); - } -} - -// ------------------------------------------------------------------- - -// DescriptorProto_ExtensionRange - -// optional int32 start = 1; -inline bool DescriptorProto_ExtensionRange::has_start() const { - return (_has_bits_[0] & 0x00000001u) != 0; -} -inline void DescriptorProto_ExtensionRange::set_has_start() { - _has_bits_[0] |= 0x00000001u; -} -inline void DescriptorProto_ExtensionRange::clear_has_start() { - _has_bits_[0] &= ~0x00000001u; -} -inline void DescriptorProto_ExtensionRange::clear_start() { - start_ = 0; - clear_has_start(); -} -inline ::google::protobuf::int32 DescriptorProto_ExtensionRange::start() const { - return start_; -} -inline void DescriptorProto_ExtensionRange::set_start(::google::protobuf::int32 value) { - set_has_start(); - start_ = value; -} - -// optional int32 end = 2; -inline bool DescriptorProto_ExtensionRange::has_end() const { - return (_has_bits_[0] & 0x00000002u) != 0; -} -inline void DescriptorProto_ExtensionRange::set_has_end() { - _has_bits_[0] |= 0x00000002u; -} -inline void DescriptorProto_ExtensionRange::clear_has_end() { - _has_bits_[0] &= ~0x00000002u; -} -inline void DescriptorProto_ExtensionRange::clear_end() { - end_ = 0; - clear_has_end(); -} -inline ::google::protobuf::int32 DescriptorProto_ExtensionRange::end() const { - return end_; -} -inline void DescriptorProto_ExtensionRange::set_end(::google::protobuf::int32 value) { - set_has_end(); - end_ = value; -} - -// ------------------------------------------------------------------- - -// DescriptorProto - -// optional string name = 1; -inline bool DescriptorProto::has_name() const { - return (_has_bits_[0] & 0x00000001u) != 0; -} -inline void DescriptorProto::set_has_name() { - _has_bits_[0] |= 0x00000001u; -} -inline void DescriptorProto::clear_has_name() { - _has_bits_[0] &= ~0x00000001u; -} -inline void DescriptorProto::clear_name() { - if (name_ != &::google::protobuf::internal::kEmptyString) { - name_->clear(); - } - clear_has_name(); -} -inline const ::std::string& DescriptorProto::name() const { - return *name_; -} -inline void DescriptorProto::set_name(const ::std::string& value) { - set_has_name(); - if (name_ == &::google::protobuf::internal::kEmptyString) { - name_ = new ::std::string; - } - name_->assign(value); -} -inline void DescriptorProto::set_name(const char* value) { - set_has_name(); - if (name_ == &::google::protobuf::internal::kEmptyString) { - name_ = new ::std::string; - } - name_->assign(value); -} -inline void DescriptorProto::set_name(const char* value, size_t size) { - set_has_name(); - if (name_ == &::google::protobuf::internal::kEmptyString) { - name_ = new ::std::string; - } - name_->assign(reinterpret_cast(value), size); -} -inline ::std::string* DescriptorProto::mutable_name() { - set_has_name(); - if (name_ == &::google::protobuf::internal::kEmptyString) { - name_ = new ::std::string; - } - return name_; -} -inline ::std::string* DescriptorProto::release_name() { - clear_has_name(); - if (name_ == &::google::protobuf::internal::kEmptyString) { - return NULL; - } else { - ::std::string* temp = name_; - name_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); - return temp; - } -} -inline void DescriptorProto::set_allocated_name(::std::string* name) { - if (name_ != &::google::protobuf::internal::kEmptyString) { - delete name_; - } - if (name) { - set_has_name(); - name_ = name; - } else { - clear_has_name(); - name_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); - } -} - -// repeated .google.protobuf.FieldDescriptorProto field = 2; -inline int DescriptorProto::field_size() const { - return field_.size(); -} -inline void DescriptorProto::clear_field() { - field_.Clear(); -} -inline const ::google::protobuf::FieldDescriptorProto& DescriptorProto::field(int index) const { - return field_.Get(index); -} -inline ::google::protobuf::FieldDescriptorProto* DescriptorProto::mutable_field(int index) { - return field_.Mutable(index); -} -inline ::google::protobuf::FieldDescriptorProto* DescriptorProto::add_field() { - return field_.Add(); -} -inline const ::google::protobuf::RepeatedPtrField< ::google::protobuf::FieldDescriptorProto >& -DescriptorProto::field() const { - return field_; -} -inline ::google::protobuf::RepeatedPtrField< ::google::protobuf::FieldDescriptorProto >* -DescriptorProto::mutable_field() { - return &field_; -} - -// repeated .google.protobuf.FieldDescriptorProto extension = 6; -inline int DescriptorProto::extension_size() const { - return extension_.size(); -} -inline void DescriptorProto::clear_extension() { - extension_.Clear(); -} -inline const ::google::protobuf::FieldDescriptorProto& DescriptorProto::extension(int index) const { - return extension_.Get(index); -} -inline ::google::protobuf::FieldDescriptorProto* DescriptorProto::mutable_extension(int index) { - return extension_.Mutable(index); -} -inline ::google::protobuf::FieldDescriptorProto* DescriptorProto::add_extension() { - return extension_.Add(); -} -inline const ::google::protobuf::RepeatedPtrField< ::google::protobuf::FieldDescriptorProto >& -DescriptorProto::extension() const { - return extension_; -} -inline ::google::protobuf::RepeatedPtrField< ::google::protobuf::FieldDescriptorProto >* -DescriptorProto::mutable_extension() { - return &extension_; -} - -// repeated .google.protobuf.DescriptorProto nested_type = 3; -inline int DescriptorProto::nested_type_size() const { - return nested_type_.size(); -} -inline void DescriptorProto::clear_nested_type() { - nested_type_.Clear(); -} -inline const ::google::protobuf::DescriptorProto& DescriptorProto::nested_type(int index) const { - return nested_type_.Get(index); -} -inline ::google::protobuf::DescriptorProto* DescriptorProto::mutable_nested_type(int index) { - return nested_type_.Mutable(index); -} -inline ::google::protobuf::DescriptorProto* DescriptorProto::add_nested_type() { - return nested_type_.Add(); -} -inline const ::google::protobuf::RepeatedPtrField< ::google::protobuf::DescriptorProto >& -DescriptorProto::nested_type() const { - return nested_type_; -} -inline ::google::protobuf::RepeatedPtrField< ::google::protobuf::DescriptorProto >* -DescriptorProto::mutable_nested_type() { - return &nested_type_; -} - -// repeated .google.protobuf.EnumDescriptorProto enum_type = 4; -inline int DescriptorProto::enum_type_size() const { - return enum_type_.size(); -} -inline void DescriptorProto::clear_enum_type() { - enum_type_.Clear(); -} -inline const ::google::protobuf::EnumDescriptorProto& DescriptorProto::enum_type(int index) const { - return enum_type_.Get(index); -} -inline ::google::protobuf::EnumDescriptorProto* DescriptorProto::mutable_enum_type(int index) { - return enum_type_.Mutable(index); -} -inline ::google::protobuf::EnumDescriptorProto* DescriptorProto::add_enum_type() { - return enum_type_.Add(); -} -inline const ::google::protobuf::RepeatedPtrField< ::google::protobuf::EnumDescriptorProto >& -DescriptorProto::enum_type() const { - return enum_type_; -} -inline ::google::protobuf::RepeatedPtrField< ::google::protobuf::EnumDescriptorProto >* -DescriptorProto::mutable_enum_type() { - return &enum_type_; -} - -// repeated .google.protobuf.DescriptorProto.ExtensionRange extension_range = 5; -inline int DescriptorProto::extension_range_size() const { - return extension_range_.size(); -} -inline void DescriptorProto::clear_extension_range() { - extension_range_.Clear(); -} -inline const ::google::protobuf::DescriptorProto_ExtensionRange& DescriptorProto::extension_range(int index) const { - return extension_range_.Get(index); -} -inline ::google::protobuf::DescriptorProto_ExtensionRange* DescriptorProto::mutable_extension_range(int index) { - return extension_range_.Mutable(index); -} -inline ::google::protobuf::DescriptorProto_ExtensionRange* DescriptorProto::add_extension_range() { - return extension_range_.Add(); -} -inline const ::google::protobuf::RepeatedPtrField< ::google::protobuf::DescriptorProto_ExtensionRange >& -DescriptorProto::extension_range() const { - return extension_range_; -} -inline ::google::protobuf::RepeatedPtrField< ::google::protobuf::DescriptorProto_ExtensionRange >* -DescriptorProto::mutable_extension_range() { - return &extension_range_; -} - -// optional .google.protobuf.MessageOptions options = 7; -inline bool DescriptorProto::has_options() const { - return (_has_bits_[0] & 0x00000040u) != 0; -} -inline void DescriptorProto::set_has_options() { - _has_bits_[0] |= 0x00000040u; -} -inline void DescriptorProto::clear_has_options() { - _has_bits_[0] &= ~0x00000040u; -} -inline void DescriptorProto::clear_options() { - if (options_ != NULL) options_->::google::protobuf::MessageOptions::Clear(); - clear_has_options(); -} -inline const ::google::protobuf::MessageOptions& DescriptorProto::options() const { - return options_ != NULL ? *options_ : *default_instance_->options_; -} -inline ::google::protobuf::MessageOptions* DescriptorProto::mutable_options() { - set_has_options(); - if (options_ == NULL) options_ = new ::google::protobuf::MessageOptions; - return options_; -} -inline ::google::protobuf::MessageOptions* DescriptorProto::release_options() { - clear_has_options(); - ::google::protobuf::MessageOptions* temp = options_; - options_ = NULL; - return temp; -} -inline void DescriptorProto::set_allocated_options(::google::protobuf::MessageOptions* options) { - delete options_; - options_ = options; - if (options) { - set_has_options(); - } else { - clear_has_options(); - } -} - -// ------------------------------------------------------------------- - -// FieldDescriptorProto - -// optional string name = 1; -inline bool FieldDescriptorProto::has_name() const { - return (_has_bits_[0] & 0x00000001u) != 0; -} -inline void FieldDescriptorProto::set_has_name() { - _has_bits_[0] |= 0x00000001u; -} -inline void FieldDescriptorProto::clear_has_name() { - _has_bits_[0] &= ~0x00000001u; -} -inline void FieldDescriptorProto::clear_name() { - if (name_ != &::google::protobuf::internal::kEmptyString) { - name_->clear(); - } - clear_has_name(); -} -inline const ::std::string& FieldDescriptorProto::name() const { - return *name_; -} -inline void FieldDescriptorProto::set_name(const ::std::string& value) { - set_has_name(); - if (name_ == &::google::protobuf::internal::kEmptyString) { - name_ = new ::std::string; - } - name_->assign(value); -} -inline void FieldDescriptorProto::set_name(const char* value) { - set_has_name(); - if (name_ == &::google::protobuf::internal::kEmptyString) { - name_ = new ::std::string; - } - name_->assign(value); -} -inline void FieldDescriptorProto::set_name(const char* value, size_t size) { - set_has_name(); - if (name_ == &::google::protobuf::internal::kEmptyString) { - name_ = new ::std::string; - } - name_->assign(reinterpret_cast(value), size); -} -inline ::std::string* FieldDescriptorProto::mutable_name() { - set_has_name(); - if (name_ == &::google::protobuf::internal::kEmptyString) { - name_ = new ::std::string; - } - return name_; -} -inline ::std::string* FieldDescriptorProto::release_name() { - clear_has_name(); - if (name_ == &::google::protobuf::internal::kEmptyString) { - return NULL; - } else { - ::std::string* temp = name_; - name_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); - return temp; - } -} -inline void FieldDescriptorProto::set_allocated_name(::std::string* name) { - if (name_ != &::google::protobuf::internal::kEmptyString) { - delete name_; - } - if (name) { - set_has_name(); - name_ = name; - } else { - clear_has_name(); - name_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); - } -} - -// optional int32 number = 3; -inline bool FieldDescriptorProto::has_number() const { - return (_has_bits_[0] & 0x00000002u) != 0; -} -inline void FieldDescriptorProto::set_has_number() { - _has_bits_[0] |= 0x00000002u; -} -inline void FieldDescriptorProto::clear_has_number() { - _has_bits_[0] &= ~0x00000002u; -} -inline void FieldDescriptorProto::clear_number() { - number_ = 0; - clear_has_number(); -} -inline ::google::protobuf::int32 FieldDescriptorProto::number() const { - return number_; -} -inline void FieldDescriptorProto::set_number(::google::protobuf::int32 value) { - set_has_number(); - number_ = value; -} - -// optional .google.protobuf.FieldDescriptorProto.Label label = 4; -inline bool FieldDescriptorProto::has_label() const { - return (_has_bits_[0] & 0x00000004u) != 0; -} -inline void FieldDescriptorProto::set_has_label() { - _has_bits_[0] |= 0x00000004u; -} -inline void FieldDescriptorProto::clear_has_label() { - _has_bits_[0] &= ~0x00000004u; -} -inline void FieldDescriptorProto::clear_label() { - label_ = 1; - clear_has_label(); -} -inline ::google::protobuf::FieldDescriptorProto_Label FieldDescriptorProto::label() const { - return static_cast< ::google::protobuf::FieldDescriptorProto_Label >(label_); -} -inline void FieldDescriptorProto::set_label(::google::protobuf::FieldDescriptorProto_Label value) { - assert(::google::protobuf::FieldDescriptorProto_Label_IsValid(value)); - set_has_label(); - label_ = value; -} - -// optional .google.protobuf.FieldDescriptorProto.Type type = 5; -inline bool FieldDescriptorProto::has_type() const { - return (_has_bits_[0] & 0x00000008u) != 0; -} -inline void FieldDescriptorProto::set_has_type() { - _has_bits_[0] |= 0x00000008u; -} -inline void FieldDescriptorProto::clear_has_type() { - _has_bits_[0] &= ~0x00000008u; -} -inline void FieldDescriptorProto::clear_type() { - type_ = 1; - clear_has_type(); -} -inline ::google::protobuf::FieldDescriptorProto_Type FieldDescriptorProto::type() const { - return static_cast< ::google::protobuf::FieldDescriptorProto_Type >(type_); -} -inline void FieldDescriptorProto::set_type(::google::protobuf::FieldDescriptorProto_Type value) { - assert(::google::protobuf::FieldDescriptorProto_Type_IsValid(value)); - set_has_type(); - type_ = value; -} - -// optional string type_name = 6; -inline bool FieldDescriptorProto::has_type_name() const { - return (_has_bits_[0] & 0x00000010u) != 0; -} -inline void FieldDescriptorProto::set_has_type_name() { - _has_bits_[0] |= 0x00000010u; -} -inline void FieldDescriptorProto::clear_has_type_name() { - _has_bits_[0] &= ~0x00000010u; -} -inline void FieldDescriptorProto::clear_type_name() { - if (type_name_ != &::google::protobuf::internal::kEmptyString) { - type_name_->clear(); - } - clear_has_type_name(); -} -inline const ::std::string& FieldDescriptorProto::type_name() const { - return *type_name_; -} -inline void FieldDescriptorProto::set_type_name(const ::std::string& value) { - set_has_type_name(); - if (type_name_ == &::google::protobuf::internal::kEmptyString) { - type_name_ = new ::std::string; - } - type_name_->assign(value); -} -inline void FieldDescriptorProto::set_type_name(const char* value) { - set_has_type_name(); - if (type_name_ == &::google::protobuf::internal::kEmptyString) { - type_name_ = new ::std::string; - } - type_name_->assign(value); -} -inline void FieldDescriptorProto::set_type_name(const char* value, size_t size) { - set_has_type_name(); - if (type_name_ == &::google::protobuf::internal::kEmptyString) { - type_name_ = new ::std::string; - } - type_name_->assign(reinterpret_cast(value), size); -} -inline ::std::string* FieldDescriptorProto::mutable_type_name() { - set_has_type_name(); - if (type_name_ == &::google::protobuf::internal::kEmptyString) { - type_name_ = new ::std::string; - } - return type_name_; -} -inline ::std::string* FieldDescriptorProto::release_type_name() { - clear_has_type_name(); - if (type_name_ == &::google::protobuf::internal::kEmptyString) { - return NULL; - } else { - ::std::string* temp = type_name_; - type_name_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); - return temp; - } -} -inline void FieldDescriptorProto::set_allocated_type_name(::std::string* type_name) { - if (type_name_ != &::google::protobuf::internal::kEmptyString) { - delete type_name_; - } - if (type_name) { - set_has_type_name(); - type_name_ = type_name; - } else { - clear_has_type_name(); - type_name_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); - } -} - -// optional string extendee = 2; -inline bool FieldDescriptorProto::has_extendee() const { - return (_has_bits_[0] & 0x00000020u) != 0; -} -inline void FieldDescriptorProto::set_has_extendee() { - _has_bits_[0] |= 0x00000020u; -} -inline void FieldDescriptorProto::clear_has_extendee() { - _has_bits_[0] &= ~0x00000020u; -} -inline void FieldDescriptorProto::clear_extendee() { - if (extendee_ != &::google::protobuf::internal::kEmptyString) { - extendee_->clear(); - } - clear_has_extendee(); -} -inline const ::std::string& FieldDescriptorProto::extendee() const { - return *extendee_; -} -inline void FieldDescriptorProto::set_extendee(const ::std::string& value) { - set_has_extendee(); - if (extendee_ == &::google::protobuf::internal::kEmptyString) { - extendee_ = new ::std::string; - } - extendee_->assign(value); -} -inline void FieldDescriptorProto::set_extendee(const char* value) { - set_has_extendee(); - if (extendee_ == &::google::protobuf::internal::kEmptyString) { - extendee_ = new ::std::string; - } - extendee_->assign(value); -} -inline void FieldDescriptorProto::set_extendee(const char* value, size_t size) { - set_has_extendee(); - if (extendee_ == &::google::protobuf::internal::kEmptyString) { - extendee_ = new ::std::string; - } - extendee_->assign(reinterpret_cast(value), size); -} -inline ::std::string* FieldDescriptorProto::mutable_extendee() { - set_has_extendee(); - if (extendee_ == &::google::protobuf::internal::kEmptyString) { - extendee_ = new ::std::string; - } - return extendee_; -} -inline ::std::string* FieldDescriptorProto::release_extendee() { - clear_has_extendee(); - if (extendee_ == &::google::protobuf::internal::kEmptyString) { - return NULL; - } else { - ::std::string* temp = extendee_; - extendee_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); - return temp; - } -} -inline void FieldDescriptorProto::set_allocated_extendee(::std::string* extendee) { - if (extendee_ != &::google::protobuf::internal::kEmptyString) { - delete extendee_; - } - if (extendee) { - set_has_extendee(); - extendee_ = extendee; - } else { - clear_has_extendee(); - extendee_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); - } -} - -// optional string default_value = 7; -inline bool FieldDescriptorProto::has_default_value() const { - return (_has_bits_[0] & 0x00000040u) != 0; -} -inline void FieldDescriptorProto::set_has_default_value() { - _has_bits_[0] |= 0x00000040u; -} -inline void FieldDescriptorProto::clear_has_default_value() { - _has_bits_[0] &= ~0x00000040u; -} -inline void FieldDescriptorProto::clear_default_value() { - if (default_value_ != &::google::protobuf::internal::kEmptyString) { - default_value_->clear(); - } - clear_has_default_value(); -} -inline const ::std::string& FieldDescriptorProto::default_value() const { - return *default_value_; -} -inline void FieldDescriptorProto::set_default_value(const ::std::string& value) { - set_has_default_value(); - if (default_value_ == &::google::protobuf::internal::kEmptyString) { - default_value_ = new ::std::string; - } - default_value_->assign(value); -} -inline void FieldDescriptorProto::set_default_value(const char* value) { - set_has_default_value(); - if (default_value_ == &::google::protobuf::internal::kEmptyString) { - default_value_ = new ::std::string; - } - default_value_->assign(value); -} -inline void FieldDescriptorProto::set_default_value(const char* value, size_t size) { - set_has_default_value(); - if (default_value_ == &::google::protobuf::internal::kEmptyString) { - default_value_ = new ::std::string; - } - default_value_->assign(reinterpret_cast(value), size); -} -inline ::std::string* FieldDescriptorProto::mutable_default_value() { - set_has_default_value(); - if (default_value_ == &::google::protobuf::internal::kEmptyString) { - default_value_ = new ::std::string; - } - return default_value_; -} -inline ::std::string* FieldDescriptorProto::release_default_value() { - clear_has_default_value(); - if (default_value_ == &::google::protobuf::internal::kEmptyString) { - return NULL; - } else { - ::std::string* temp = default_value_; - default_value_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); - return temp; - } -} -inline void FieldDescriptorProto::set_allocated_default_value(::std::string* default_value) { - if (default_value_ != &::google::protobuf::internal::kEmptyString) { - delete default_value_; - } - if (default_value) { - set_has_default_value(); - default_value_ = default_value; - } else { - clear_has_default_value(); - default_value_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); - } -} - -// optional .google.protobuf.FieldOptions options = 8; -inline bool FieldDescriptorProto::has_options() const { - return (_has_bits_[0] & 0x00000080u) != 0; -} -inline void FieldDescriptorProto::set_has_options() { - _has_bits_[0] |= 0x00000080u; -} -inline void FieldDescriptorProto::clear_has_options() { - _has_bits_[0] &= ~0x00000080u; -} -inline void FieldDescriptorProto::clear_options() { - if (options_ != NULL) options_->::google::protobuf::FieldOptions::Clear(); - clear_has_options(); -} -inline const ::google::protobuf::FieldOptions& FieldDescriptorProto::options() const { - return options_ != NULL ? *options_ : *default_instance_->options_; -} -inline ::google::protobuf::FieldOptions* FieldDescriptorProto::mutable_options() { - set_has_options(); - if (options_ == NULL) options_ = new ::google::protobuf::FieldOptions; - return options_; -} -inline ::google::protobuf::FieldOptions* FieldDescriptorProto::release_options() { - clear_has_options(); - ::google::protobuf::FieldOptions* temp = options_; - options_ = NULL; - return temp; -} -inline void FieldDescriptorProto::set_allocated_options(::google::protobuf::FieldOptions* options) { - delete options_; - options_ = options; - if (options) { - set_has_options(); - } else { - clear_has_options(); - } -} - -// ------------------------------------------------------------------- - -// EnumDescriptorProto - -// optional string name = 1; -inline bool EnumDescriptorProto::has_name() const { - return (_has_bits_[0] & 0x00000001u) != 0; -} -inline void EnumDescriptorProto::set_has_name() { - _has_bits_[0] |= 0x00000001u; -} -inline void EnumDescriptorProto::clear_has_name() { - _has_bits_[0] &= ~0x00000001u; -} -inline void EnumDescriptorProto::clear_name() { - if (name_ != &::google::protobuf::internal::kEmptyString) { - name_->clear(); - } - clear_has_name(); -} -inline const ::std::string& EnumDescriptorProto::name() const { - return *name_; -} -inline void EnumDescriptorProto::set_name(const ::std::string& value) { - set_has_name(); - if (name_ == &::google::protobuf::internal::kEmptyString) { - name_ = new ::std::string; - } - name_->assign(value); -} -inline void EnumDescriptorProto::set_name(const char* value) { - set_has_name(); - if (name_ == &::google::protobuf::internal::kEmptyString) { - name_ = new ::std::string; - } - name_->assign(value); -} -inline void EnumDescriptorProto::set_name(const char* value, size_t size) { - set_has_name(); - if (name_ == &::google::protobuf::internal::kEmptyString) { - name_ = new ::std::string; - } - name_->assign(reinterpret_cast(value), size); -} -inline ::std::string* EnumDescriptorProto::mutable_name() { - set_has_name(); - if (name_ == &::google::protobuf::internal::kEmptyString) { - name_ = new ::std::string; - } - return name_; -} -inline ::std::string* EnumDescriptorProto::release_name() { - clear_has_name(); - if (name_ == &::google::protobuf::internal::kEmptyString) { - return NULL; - } else { - ::std::string* temp = name_; - name_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); - return temp; - } -} -inline void EnumDescriptorProto::set_allocated_name(::std::string* name) { - if (name_ != &::google::protobuf::internal::kEmptyString) { - delete name_; - } - if (name) { - set_has_name(); - name_ = name; - } else { - clear_has_name(); - name_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); - } -} - -// repeated .google.protobuf.EnumValueDescriptorProto value = 2; -inline int EnumDescriptorProto::value_size() const { - return value_.size(); -} -inline void EnumDescriptorProto::clear_value() { - value_.Clear(); -} -inline const ::google::protobuf::EnumValueDescriptorProto& EnumDescriptorProto::value(int index) const { - return value_.Get(index); -} -inline ::google::protobuf::EnumValueDescriptorProto* EnumDescriptorProto::mutable_value(int index) { - return value_.Mutable(index); -} -inline ::google::protobuf::EnumValueDescriptorProto* EnumDescriptorProto::add_value() { - return value_.Add(); -} -inline const ::google::protobuf::RepeatedPtrField< ::google::protobuf::EnumValueDescriptorProto >& -EnumDescriptorProto::value() const { - return value_; -} -inline ::google::protobuf::RepeatedPtrField< ::google::protobuf::EnumValueDescriptorProto >* -EnumDescriptorProto::mutable_value() { - return &value_; -} - -// optional .google.protobuf.EnumOptions options = 3; -inline bool EnumDescriptorProto::has_options() const { - return (_has_bits_[0] & 0x00000004u) != 0; -} -inline void EnumDescriptorProto::set_has_options() { - _has_bits_[0] |= 0x00000004u; -} -inline void EnumDescriptorProto::clear_has_options() { - _has_bits_[0] &= ~0x00000004u; -} -inline void EnumDescriptorProto::clear_options() { - if (options_ != NULL) options_->::google::protobuf::EnumOptions::Clear(); - clear_has_options(); -} -inline const ::google::protobuf::EnumOptions& EnumDescriptorProto::options() const { - return options_ != NULL ? *options_ : *default_instance_->options_; -} -inline ::google::protobuf::EnumOptions* EnumDescriptorProto::mutable_options() { - set_has_options(); - if (options_ == NULL) options_ = new ::google::protobuf::EnumOptions; - return options_; -} -inline ::google::protobuf::EnumOptions* EnumDescriptorProto::release_options() { - clear_has_options(); - ::google::protobuf::EnumOptions* temp = options_; - options_ = NULL; - return temp; -} -inline void EnumDescriptorProto::set_allocated_options(::google::protobuf::EnumOptions* options) { - delete options_; - options_ = options; - if (options) { - set_has_options(); - } else { - clear_has_options(); - } -} - -// ------------------------------------------------------------------- - -// EnumValueDescriptorProto - -// optional string name = 1; -inline bool EnumValueDescriptorProto::has_name() const { - return (_has_bits_[0] & 0x00000001u) != 0; -} -inline void EnumValueDescriptorProto::set_has_name() { - _has_bits_[0] |= 0x00000001u; -} -inline void EnumValueDescriptorProto::clear_has_name() { - _has_bits_[0] &= ~0x00000001u; -} -inline void EnumValueDescriptorProto::clear_name() { - if (name_ != &::google::protobuf::internal::kEmptyString) { - name_->clear(); - } - clear_has_name(); -} -inline const ::std::string& EnumValueDescriptorProto::name() const { - return *name_; -} -inline void EnumValueDescriptorProto::set_name(const ::std::string& value) { - set_has_name(); - if (name_ == &::google::protobuf::internal::kEmptyString) { - name_ = new ::std::string; - } - name_->assign(value); -} -inline void EnumValueDescriptorProto::set_name(const char* value) { - set_has_name(); - if (name_ == &::google::protobuf::internal::kEmptyString) { - name_ = new ::std::string; - } - name_->assign(value); -} -inline void EnumValueDescriptorProto::set_name(const char* value, size_t size) { - set_has_name(); - if (name_ == &::google::protobuf::internal::kEmptyString) { - name_ = new ::std::string; - } - name_->assign(reinterpret_cast(value), size); -} -inline ::std::string* EnumValueDescriptorProto::mutable_name() { - set_has_name(); - if (name_ == &::google::protobuf::internal::kEmptyString) { - name_ = new ::std::string; - } - return name_; -} -inline ::std::string* EnumValueDescriptorProto::release_name() { - clear_has_name(); - if (name_ == &::google::protobuf::internal::kEmptyString) { - return NULL; - } else { - ::std::string* temp = name_; - name_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); - return temp; - } -} -inline void EnumValueDescriptorProto::set_allocated_name(::std::string* name) { - if (name_ != &::google::protobuf::internal::kEmptyString) { - delete name_; - } - if (name) { - set_has_name(); - name_ = name; - } else { - clear_has_name(); - name_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); - } -} - -// optional int32 number = 2; -inline bool EnumValueDescriptorProto::has_number() const { - return (_has_bits_[0] & 0x00000002u) != 0; -} -inline void EnumValueDescriptorProto::set_has_number() { - _has_bits_[0] |= 0x00000002u; -} -inline void EnumValueDescriptorProto::clear_has_number() { - _has_bits_[0] &= ~0x00000002u; -} -inline void EnumValueDescriptorProto::clear_number() { - number_ = 0; - clear_has_number(); -} -inline ::google::protobuf::int32 EnumValueDescriptorProto::number() const { - return number_; -} -inline void EnumValueDescriptorProto::set_number(::google::protobuf::int32 value) { - set_has_number(); - number_ = value; -} - -// optional .google.protobuf.EnumValueOptions options = 3; -inline bool EnumValueDescriptorProto::has_options() const { - return (_has_bits_[0] & 0x00000004u) != 0; -} -inline void EnumValueDescriptorProto::set_has_options() { - _has_bits_[0] |= 0x00000004u; -} -inline void EnumValueDescriptorProto::clear_has_options() { - _has_bits_[0] &= ~0x00000004u; -} -inline void EnumValueDescriptorProto::clear_options() { - if (options_ != NULL) options_->::google::protobuf::EnumValueOptions::Clear(); - clear_has_options(); -} -inline const ::google::protobuf::EnumValueOptions& EnumValueDescriptorProto::options() const { - return options_ != NULL ? *options_ : *default_instance_->options_; -} -inline ::google::protobuf::EnumValueOptions* EnumValueDescriptorProto::mutable_options() { - set_has_options(); - if (options_ == NULL) options_ = new ::google::protobuf::EnumValueOptions; - return options_; -} -inline ::google::protobuf::EnumValueOptions* EnumValueDescriptorProto::release_options() { - clear_has_options(); - ::google::protobuf::EnumValueOptions* temp = options_; - options_ = NULL; - return temp; -} -inline void EnumValueDescriptorProto::set_allocated_options(::google::protobuf::EnumValueOptions* options) { - delete options_; - options_ = options; - if (options) { - set_has_options(); - } else { - clear_has_options(); - } -} - -// ------------------------------------------------------------------- - -// ServiceDescriptorProto - -// optional string name = 1; -inline bool ServiceDescriptorProto::has_name() const { - return (_has_bits_[0] & 0x00000001u) != 0; -} -inline void ServiceDescriptorProto::set_has_name() { - _has_bits_[0] |= 0x00000001u; -} -inline void ServiceDescriptorProto::clear_has_name() { - _has_bits_[0] &= ~0x00000001u; -} -inline void ServiceDescriptorProto::clear_name() { - if (name_ != &::google::protobuf::internal::kEmptyString) { - name_->clear(); - } - clear_has_name(); -} -inline const ::std::string& ServiceDescriptorProto::name() const { - return *name_; -} -inline void ServiceDescriptorProto::set_name(const ::std::string& value) { - set_has_name(); - if (name_ == &::google::protobuf::internal::kEmptyString) { - name_ = new ::std::string; - } - name_->assign(value); -} -inline void ServiceDescriptorProto::set_name(const char* value) { - set_has_name(); - if (name_ == &::google::protobuf::internal::kEmptyString) { - name_ = new ::std::string; - } - name_->assign(value); -} -inline void ServiceDescriptorProto::set_name(const char* value, size_t size) { - set_has_name(); - if (name_ == &::google::protobuf::internal::kEmptyString) { - name_ = new ::std::string; - } - name_->assign(reinterpret_cast(value), size); -} -inline ::std::string* ServiceDescriptorProto::mutable_name() { - set_has_name(); - if (name_ == &::google::protobuf::internal::kEmptyString) { - name_ = new ::std::string; - } - return name_; -} -inline ::std::string* ServiceDescriptorProto::release_name() { - clear_has_name(); - if (name_ == &::google::protobuf::internal::kEmptyString) { - return NULL; - } else { - ::std::string* temp = name_; - name_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); - return temp; - } -} -inline void ServiceDescriptorProto::set_allocated_name(::std::string* name) { - if (name_ != &::google::protobuf::internal::kEmptyString) { - delete name_; - } - if (name) { - set_has_name(); - name_ = name; - } else { - clear_has_name(); - name_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); - } -} - -// repeated .google.protobuf.MethodDescriptorProto method = 2; -inline int ServiceDescriptorProto::method_size() const { - return method_.size(); -} -inline void ServiceDescriptorProto::clear_method() { - method_.Clear(); -} -inline const ::google::protobuf::MethodDescriptorProto& ServiceDescriptorProto::method(int index) const { - return method_.Get(index); -} -inline ::google::protobuf::MethodDescriptorProto* ServiceDescriptorProto::mutable_method(int index) { - return method_.Mutable(index); -} -inline ::google::protobuf::MethodDescriptorProto* ServiceDescriptorProto::add_method() { - return method_.Add(); -} -inline const ::google::protobuf::RepeatedPtrField< ::google::protobuf::MethodDescriptorProto >& -ServiceDescriptorProto::method() const { - return method_; -} -inline ::google::protobuf::RepeatedPtrField< ::google::protobuf::MethodDescriptorProto >* -ServiceDescriptorProto::mutable_method() { - return &method_; -} - -// optional .google.protobuf.ServiceOptions options = 3; -inline bool ServiceDescriptorProto::has_options() const { - return (_has_bits_[0] & 0x00000004u) != 0; -} -inline void ServiceDescriptorProto::set_has_options() { - _has_bits_[0] |= 0x00000004u; -} -inline void ServiceDescriptorProto::clear_has_options() { - _has_bits_[0] &= ~0x00000004u; -} -inline void ServiceDescriptorProto::clear_options() { - if (options_ != NULL) options_->::google::protobuf::ServiceOptions::Clear(); - clear_has_options(); -} -inline const ::google::protobuf::ServiceOptions& ServiceDescriptorProto::options() const { - return options_ != NULL ? *options_ : *default_instance_->options_; -} -inline ::google::protobuf::ServiceOptions* ServiceDescriptorProto::mutable_options() { - set_has_options(); - if (options_ == NULL) options_ = new ::google::protobuf::ServiceOptions; - return options_; -} -inline ::google::protobuf::ServiceOptions* ServiceDescriptorProto::release_options() { - clear_has_options(); - ::google::protobuf::ServiceOptions* temp = options_; - options_ = NULL; - return temp; -} -inline void ServiceDescriptorProto::set_allocated_options(::google::protobuf::ServiceOptions* options) { - delete options_; - options_ = options; - if (options) { - set_has_options(); - } else { - clear_has_options(); - } -} - -// ------------------------------------------------------------------- - -// MethodDescriptorProto - -// optional string name = 1; -inline bool MethodDescriptorProto::has_name() const { - return (_has_bits_[0] & 0x00000001u) != 0; -} -inline void MethodDescriptorProto::set_has_name() { - _has_bits_[0] |= 0x00000001u; -} -inline void MethodDescriptorProto::clear_has_name() { - _has_bits_[0] &= ~0x00000001u; -} -inline void MethodDescriptorProto::clear_name() { - if (name_ != &::google::protobuf::internal::kEmptyString) { - name_->clear(); - } - clear_has_name(); -} -inline const ::std::string& MethodDescriptorProto::name() const { - return *name_; -} -inline void MethodDescriptorProto::set_name(const ::std::string& value) { - set_has_name(); - if (name_ == &::google::protobuf::internal::kEmptyString) { - name_ = new ::std::string; - } - name_->assign(value); -} -inline void MethodDescriptorProto::set_name(const char* value) { - set_has_name(); - if (name_ == &::google::protobuf::internal::kEmptyString) { - name_ = new ::std::string; - } - name_->assign(value); -} -inline void MethodDescriptorProto::set_name(const char* value, size_t size) { - set_has_name(); - if (name_ == &::google::protobuf::internal::kEmptyString) { - name_ = new ::std::string; - } - name_->assign(reinterpret_cast(value), size); -} -inline ::std::string* MethodDescriptorProto::mutable_name() { - set_has_name(); - if (name_ == &::google::protobuf::internal::kEmptyString) { - name_ = new ::std::string; - } - return name_; -} -inline ::std::string* MethodDescriptorProto::release_name() { - clear_has_name(); - if (name_ == &::google::protobuf::internal::kEmptyString) { - return NULL; - } else { - ::std::string* temp = name_; - name_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); - return temp; - } -} -inline void MethodDescriptorProto::set_allocated_name(::std::string* name) { - if (name_ != &::google::protobuf::internal::kEmptyString) { - delete name_; - } - if (name) { - set_has_name(); - name_ = name; - } else { - clear_has_name(); - name_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); - } -} - -// optional string input_type = 2; -inline bool MethodDescriptorProto::has_input_type() const { - return (_has_bits_[0] & 0x00000002u) != 0; -} -inline void MethodDescriptorProto::set_has_input_type() { - _has_bits_[0] |= 0x00000002u; -} -inline void MethodDescriptorProto::clear_has_input_type() { - _has_bits_[0] &= ~0x00000002u; -} -inline void MethodDescriptorProto::clear_input_type() { - if (input_type_ != &::google::protobuf::internal::kEmptyString) { - input_type_->clear(); - } - clear_has_input_type(); -} -inline const ::std::string& MethodDescriptorProto::input_type() const { - return *input_type_; -} -inline void MethodDescriptorProto::set_input_type(const ::std::string& value) { - set_has_input_type(); - if (input_type_ == &::google::protobuf::internal::kEmptyString) { - input_type_ = new ::std::string; - } - input_type_->assign(value); -} -inline void MethodDescriptorProto::set_input_type(const char* value) { - set_has_input_type(); - if (input_type_ == &::google::protobuf::internal::kEmptyString) { - input_type_ = new ::std::string; - } - input_type_->assign(value); -} -inline void MethodDescriptorProto::set_input_type(const char* value, size_t size) { - set_has_input_type(); - if (input_type_ == &::google::protobuf::internal::kEmptyString) { - input_type_ = new ::std::string; - } - input_type_->assign(reinterpret_cast(value), size); -} -inline ::std::string* MethodDescriptorProto::mutable_input_type() { - set_has_input_type(); - if (input_type_ == &::google::protobuf::internal::kEmptyString) { - input_type_ = new ::std::string; - } - return input_type_; -} -inline ::std::string* MethodDescriptorProto::release_input_type() { - clear_has_input_type(); - if (input_type_ == &::google::protobuf::internal::kEmptyString) { - return NULL; - } else { - ::std::string* temp = input_type_; - input_type_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); - return temp; - } -} -inline void MethodDescriptorProto::set_allocated_input_type(::std::string* input_type) { - if (input_type_ != &::google::protobuf::internal::kEmptyString) { - delete input_type_; - } - if (input_type) { - set_has_input_type(); - input_type_ = input_type; - } else { - clear_has_input_type(); - input_type_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); - } -} - -// optional string output_type = 3; -inline bool MethodDescriptorProto::has_output_type() const { - return (_has_bits_[0] & 0x00000004u) != 0; -} -inline void MethodDescriptorProto::set_has_output_type() { - _has_bits_[0] |= 0x00000004u; -} -inline void MethodDescriptorProto::clear_has_output_type() { - _has_bits_[0] &= ~0x00000004u; -} -inline void MethodDescriptorProto::clear_output_type() { - if (output_type_ != &::google::protobuf::internal::kEmptyString) { - output_type_->clear(); - } - clear_has_output_type(); -} -inline const ::std::string& MethodDescriptorProto::output_type() const { - return *output_type_; -} -inline void MethodDescriptorProto::set_output_type(const ::std::string& value) { - set_has_output_type(); - if (output_type_ == &::google::protobuf::internal::kEmptyString) { - output_type_ = new ::std::string; - } - output_type_->assign(value); -} -inline void MethodDescriptorProto::set_output_type(const char* value) { - set_has_output_type(); - if (output_type_ == &::google::protobuf::internal::kEmptyString) { - output_type_ = new ::std::string; - } - output_type_->assign(value); -} -inline void MethodDescriptorProto::set_output_type(const char* value, size_t size) { - set_has_output_type(); - if (output_type_ == &::google::protobuf::internal::kEmptyString) { - output_type_ = new ::std::string; - } - output_type_->assign(reinterpret_cast(value), size); -} -inline ::std::string* MethodDescriptorProto::mutable_output_type() { - set_has_output_type(); - if (output_type_ == &::google::protobuf::internal::kEmptyString) { - output_type_ = new ::std::string; - } - return output_type_; -} -inline ::std::string* MethodDescriptorProto::release_output_type() { - clear_has_output_type(); - if (output_type_ == &::google::protobuf::internal::kEmptyString) { - return NULL; - } else { - ::std::string* temp = output_type_; - output_type_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); - return temp; - } -} -inline void MethodDescriptorProto::set_allocated_output_type(::std::string* output_type) { - if (output_type_ != &::google::protobuf::internal::kEmptyString) { - delete output_type_; - } - if (output_type) { - set_has_output_type(); - output_type_ = output_type; - } else { - clear_has_output_type(); - output_type_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); - } -} - -// optional .google.protobuf.MethodOptions options = 4; -inline bool MethodDescriptorProto::has_options() const { - return (_has_bits_[0] & 0x00000008u) != 0; -} -inline void MethodDescriptorProto::set_has_options() { - _has_bits_[0] |= 0x00000008u; -} -inline void MethodDescriptorProto::clear_has_options() { - _has_bits_[0] &= ~0x00000008u; -} -inline void MethodDescriptorProto::clear_options() { - if (options_ != NULL) options_->::google::protobuf::MethodOptions::Clear(); - clear_has_options(); -} -inline const ::google::protobuf::MethodOptions& MethodDescriptorProto::options() const { - return options_ != NULL ? *options_ : *default_instance_->options_; -} -inline ::google::protobuf::MethodOptions* MethodDescriptorProto::mutable_options() { - set_has_options(); - if (options_ == NULL) options_ = new ::google::protobuf::MethodOptions; - return options_; -} -inline ::google::protobuf::MethodOptions* MethodDescriptorProto::release_options() { - clear_has_options(); - ::google::protobuf::MethodOptions* temp = options_; - options_ = NULL; - return temp; -} -inline void MethodDescriptorProto::set_allocated_options(::google::protobuf::MethodOptions* options) { - delete options_; - options_ = options; - if (options) { - set_has_options(); - } else { - clear_has_options(); - } -} - -// ------------------------------------------------------------------- - -// FileOptions - -// optional string java_package = 1; -inline bool FileOptions::has_java_package() const { - return (_has_bits_[0] & 0x00000001u) != 0; -} -inline void FileOptions::set_has_java_package() { - _has_bits_[0] |= 0x00000001u; -} -inline void FileOptions::clear_has_java_package() { - _has_bits_[0] &= ~0x00000001u; -} -inline void FileOptions::clear_java_package() { - if (java_package_ != &::google::protobuf::internal::kEmptyString) { - java_package_->clear(); - } - clear_has_java_package(); -} -inline const ::std::string& FileOptions::java_package() const { - return *java_package_; -} -inline void FileOptions::set_java_package(const ::std::string& value) { - set_has_java_package(); - if (java_package_ == &::google::protobuf::internal::kEmptyString) { - java_package_ = new ::std::string; - } - java_package_->assign(value); -} -inline void FileOptions::set_java_package(const char* value) { - set_has_java_package(); - if (java_package_ == &::google::protobuf::internal::kEmptyString) { - java_package_ = new ::std::string; - } - java_package_->assign(value); -} -inline void FileOptions::set_java_package(const char* value, size_t size) { - set_has_java_package(); - if (java_package_ == &::google::protobuf::internal::kEmptyString) { - java_package_ = new ::std::string; - } - java_package_->assign(reinterpret_cast(value), size); -} -inline ::std::string* FileOptions::mutable_java_package() { - set_has_java_package(); - if (java_package_ == &::google::protobuf::internal::kEmptyString) { - java_package_ = new ::std::string; - } - return java_package_; -} -inline ::std::string* FileOptions::release_java_package() { - clear_has_java_package(); - if (java_package_ == &::google::protobuf::internal::kEmptyString) { - return NULL; - } else { - ::std::string* temp = java_package_; - java_package_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); - return temp; - } -} -inline void FileOptions::set_allocated_java_package(::std::string* java_package) { - if (java_package_ != &::google::protobuf::internal::kEmptyString) { - delete java_package_; - } - if (java_package) { - set_has_java_package(); - java_package_ = java_package; - } else { - clear_has_java_package(); - java_package_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); - } -} - -// optional string java_outer_classname = 8; -inline bool FileOptions::has_java_outer_classname() const { - return (_has_bits_[0] & 0x00000002u) != 0; -} -inline void FileOptions::set_has_java_outer_classname() { - _has_bits_[0] |= 0x00000002u; -} -inline void FileOptions::clear_has_java_outer_classname() { - _has_bits_[0] &= ~0x00000002u; -} -inline void FileOptions::clear_java_outer_classname() { - if (java_outer_classname_ != &::google::protobuf::internal::kEmptyString) { - java_outer_classname_->clear(); - } - clear_has_java_outer_classname(); -} -inline const ::std::string& FileOptions::java_outer_classname() const { - return *java_outer_classname_; -} -inline void FileOptions::set_java_outer_classname(const ::std::string& value) { - set_has_java_outer_classname(); - if (java_outer_classname_ == &::google::protobuf::internal::kEmptyString) { - java_outer_classname_ = new ::std::string; - } - java_outer_classname_->assign(value); -} -inline void FileOptions::set_java_outer_classname(const char* value) { - set_has_java_outer_classname(); - if (java_outer_classname_ == &::google::protobuf::internal::kEmptyString) { - java_outer_classname_ = new ::std::string; - } - java_outer_classname_->assign(value); -} -inline void FileOptions::set_java_outer_classname(const char* value, size_t size) { - set_has_java_outer_classname(); - if (java_outer_classname_ == &::google::protobuf::internal::kEmptyString) { - java_outer_classname_ = new ::std::string; - } - java_outer_classname_->assign(reinterpret_cast(value), size); -} -inline ::std::string* FileOptions::mutable_java_outer_classname() { - set_has_java_outer_classname(); - if (java_outer_classname_ == &::google::protobuf::internal::kEmptyString) { - java_outer_classname_ = new ::std::string; - } - return java_outer_classname_; -} -inline ::std::string* FileOptions::release_java_outer_classname() { - clear_has_java_outer_classname(); - if (java_outer_classname_ == &::google::protobuf::internal::kEmptyString) { - return NULL; - } else { - ::std::string* temp = java_outer_classname_; - java_outer_classname_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); - return temp; - } -} -inline void FileOptions::set_allocated_java_outer_classname(::std::string* java_outer_classname) { - if (java_outer_classname_ != &::google::protobuf::internal::kEmptyString) { - delete java_outer_classname_; - } - if (java_outer_classname) { - set_has_java_outer_classname(); - java_outer_classname_ = java_outer_classname; - } else { - clear_has_java_outer_classname(); - java_outer_classname_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); - } -} - -// optional bool java_multiple_files = 10 [default = false]; -inline bool FileOptions::has_java_multiple_files() const { - return (_has_bits_[0] & 0x00000004u) != 0; -} -inline void FileOptions::set_has_java_multiple_files() { - _has_bits_[0] |= 0x00000004u; -} -inline void FileOptions::clear_has_java_multiple_files() { - _has_bits_[0] &= ~0x00000004u; -} -inline void FileOptions::clear_java_multiple_files() { - java_multiple_files_ = false; - clear_has_java_multiple_files(); -} -inline bool FileOptions::java_multiple_files() const { - return java_multiple_files_; -} -inline void FileOptions::set_java_multiple_files(bool value) { - set_has_java_multiple_files(); - java_multiple_files_ = value; -} - -// optional bool java_generate_equals_and_hash = 20 [default = false]; -inline bool FileOptions::has_java_generate_equals_and_hash() const { - return (_has_bits_[0] & 0x00000008u) != 0; -} -inline void FileOptions::set_has_java_generate_equals_and_hash() { - _has_bits_[0] |= 0x00000008u; -} -inline void FileOptions::clear_has_java_generate_equals_and_hash() { - _has_bits_[0] &= ~0x00000008u; -} -inline void FileOptions::clear_java_generate_equals_and_hash() { - java_generate_equals_and_hash_ = false; - clear_has_java_generate_equals_and_hash(); -} -inline bool FileOptions::java_generate_equals_and_hash() const { - return java_generate_equals_and_hash_; -} -inline void FileOptions::set_java_generate_equals_and_hash(bool value) { - set_has_java_generate_equals_and_hash(); - java_generate_equals_and_hash_ = value; -} - -// optional .google.protobuf.FileOptions.OptimizeMode optimize_for = 9 [default = SPEED]; -inline bool FileOptions::has_optimize_for() const { - return (_has_bits_[0] & 0x00000010u) != 0; -} -inline void FileOptions::set_has_optimize_for() { - _has_bits_[0] |= 0x00000010u; -} -inline void FileOptions::clear_has_optimize_for() { - _has_bits_[0] &= ~0x00000010u; -} -inline void FileOptions::clear_optimize_for() { - optimize_for_ = 1; - clear_has_optimize_for(); -} -inline ::google::protobuf::FileOptions_OptimizeMode FileOptions::optimize_for() const { - return static_cast< ::google::protobuf::FileOptions_OptimizeMode >(optimize_for_); -} -inline void FileOptions::set_optimize_for(::google::protobuf::FileOptions_OptimizeMode value) { - assert(::google::protobuf::FileOptions_OptimizeMode_IsValid(value)); - set_has_optimize_for(); - optimize_for_ = value; -} - -// optional string go_package = 11; -inline bool FileOptions::has_go_package() const { - return (_has_bits_[0] & 0x00000020u) != 0; -} -inline void FileOptions::set_has_go_package() { - _has_bits_[0] |= 0x00000020u; -} -inline void FileOptions::clear_has_go_package() { - _has_bits_[0] &= ~0x00000020u; -} -inline void FileOptions::clear_go_package() { - if (go_package_ != &::google::protobuf::internal::kEmptyString) { - go_package_->clear(); - } - clear_has_go_package(); -} -inline const ::std::string& FileOptions::go_package() const { - return *go_package_; -} -inline void FileOptions::set_go_package(const ::std::string& value) { - set_has_go_package(); - if (go_package_ == &::google::protobuf::internal::kEmptyString) { - go_package_ = new ::std::string; - } - go_package_->assign(value); -} -inline void FileOptions::set_go_package(const char* value) { - set_has_go_package(); - if (go_package_ == &::google::protobuf::internal::kEmptyString) { - go_package_ = new ::std::string; - } - go_package_->assign(value); -} -inline void FileOptions::set_go_package(const char* value, size_t size) { - set_has_go_package(); - if (go_package_ == &::google::protobuf::internal::kEmptyString) { - go_package_ = new ::std::string; - } - go_package_->assign(reinterpret_cast(value), size); -} -inline ::std::string* FileOptions::mutable_go_package() { - set_has_go_package(); - if (go_package_ == &::google::protobuf::internal::kEmptyString) { - go_package_ = new ::std::string; - } - return go_package_; -} -inline ::std::string* FileOptions::release_go_package() { - clear_has_go_package(); - if (go_package_ == &::google::protobuf::internal::kEmptyString) { - return NULL; - } else { - ::std::string* temp = go_package_; - go_package_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); - return temp; - } -} -inline void FileOptions::set_allocated_go_package(::std::string* go_package) { - if (go_package_ != &::google::protobuf::internal::kEmptyString) { - delete go_package_; - } - if (go_package) { - set_has_go_package(); - go_package_ = go_package; - } else { - clear_has_go_package(); - go_package_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); - } -} - -// optional bool cc_generic_services = 16 [default = false]; -inline bool FileOptions::has_cc_generic_services() const { - return (_has_bits_[0] & 0x00000040u) != 0; -} -inline void FileOptions::set_has_cc_generic_services() { - _has_bits_[0] |= 0x00000040u; -} -inline void FileOptions::clear_has_cc_generic_services() { - _has_bits_[0] &= ~0x00000040u; -} -inline void FileOptions::clear_cc_generic_services() { - cc_generic_services_ = false; - clear_has_cc_generic_services(); -} -inline bool FileOptions::cc_generic_services() const { - return cc_generic_services_; -} -inline void FileOptions::set_cc_generic_services(bool value) { - set_has_cc_generic_services(); - cc_generic_services_ = value; -} - -// optional bool java_generic_services = 17 [default = false]; -inline bool FileOptions::has_java_generic_services() const { - return (_has_bits_[0] & 0x00000080u) != 0; -} -inline void FileOptions::set_has_java_generic_services() { - _has_bits_[0] |= 0x00000080u; -} -inline void FileOptions::clear_has_java_generic_services() { - _has_bits_[0] &= ~0x00000080u; -} -inline void FileOptions::clear_java_generic_services() { - java_generic_services_ = false; - clear_has_java_generic_services(); -} -inline bool FileOptions::java_generic_services() const { - return java_generic_services_; -} -inline void FileOptions::set_java_generic_services(bool value) { - set_has_java_generic_services(); - java_generic_services_ = value; -} - -// optional bool py_generic_services = 18 [default = false]; -inline bool FileOptions::has_py_generic_services() const { - return (_has_bits_[0] & 0x00000100u) != 0; -} -inline void FileOptions::set_has_py_generic_services() { - _has_bits_[0] |= 0x00000100u; -} -inline void FileOptions::clear_has_py_generic_services() { - _has_bits_[0] &= ~0x00000100u; -} -inline void FileOptions::clear_py_generic_services() { - py_generic_services_ = false; - clear_has_py_generic_services(); -} -inline bool FileOptions::py_generic_services() const { - return py_generic_services_; -} -inline void FileOptions::set_py_generic_services(bool value) { - set_has_py_generic_services(); - py_generic_services_ = value; -} - -// repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; -inline int FileOptions::uninterpreted_option_size() const { - return uninterpreted_option_.size(); -} -inline void FileOptions::clear_uninterpreted_option() { - uninterpreted_option_.Clear(); -} -inline const ::google::protobuf::UninterpretedOption& FileOptions::uninterpreted_option(int index) const { - return uninterpreted_option_.Get(index); -} -inline ::google::protobuf::UninterpretedOption* FileOptions::mutable_uninterpreted_option(int index) { - return uninterpreted_option_.Mutable(index); -} -inline ::google::protobuf::UninterpretedOption* FileOptions::add_uninterpreted_option() { - return uninterpreted_option_.Add(); -} -inline const ::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption >& -FileOptions::uninterpreted_option() const { - return uninterpreted_option_; -} -inline ::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption >* -FileOptions::mutable_uninterpreted_option() { - return &uninterpreted_option_; -} - -// ------------------------------------------------------------------- - -// MessageOptions - -// optional bool message_set_wire_format = 1 [default = false]; -inline bool MessageOptions::has_message_set_wire_format() const { - return (_has_bits_[0] & 0x00000001u) != 0; -} -inline void MessageOptions::set_has_message_set_wire_format() { - _has_bits_[0] |= 0x00000001u; -} -inline void MessageOptions::clear_has_message_set_wire_format() { - _has_bits_[0] &= ~0x00000001u; -} -inline void MessageOptions::clear_message_set_wire_format() { - message_set_wire_format_ = false; - clear_has_message_set_wire_format(); -} -inline bool MessageOptions::message_set_wire_format() const { - return message_set_wire_format_; -} -inline void MessageOptions::set_message_set_wire_format(bool value) { - set_has_message_set_wire_format(); - message_set_wire_format_ = value; -} - -// optional bool no_standard_descriptor_accessor = 2 [default = false]; -inline bool MessageOptions::has_no_standard_descriptor_accessor() const { - return (_has_bits_[0] & 0x00000002u) != 0; -} -inline void MessageOptions::set_has_no_standard_descriptor_accessor() { - _has_bits_[0] |= 0x00000002u; -} -inline void MessageOptions::clear_has_no_standard_descriptor_accessor() { - _has_bits_[0] &= ~0x00000002u; -} -inline void MessageOptions::clear_no_standard_descriptor_accessor() { - no_standard_descriptor_accessor_ = false; - clear_has_no_standard_descriptor_accessor(); -} -inline bool MessageOptions::no_standard_descriptor_accessor() const { - return no_standard_descriptor_accessor_; -} -inline void MessageOptions::set_no_standard_descriptor_accessor(bool value) { - set_has_no_standard_descriptor_accessor(); - no_standard_descriptor_accessor_ = value; -} - -// repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; -inline int MessageOptions::uninterpreted_option_size() const { - return uninterpreted_option_.size(); -} -inline void MessageOptions::clear_uninterpreted_option() { - uninterpreted_option_.Clear(); -} -inline const ::google::protobuf::UninterpretedOption& MessageOptions::uninterpreted_option(int index) const { - return uninterpreted_option_.Get(index); -} -inline ::google::protobuf::UninterpretedOption* MessageOptions::mutable_uninterpreted_option(int index) { - return uninterpreted_option_.Mutable(index); -} -inline ::google::protobuf::UninterpretedOption* MessageOptions::add_uninterpreted_option() { - return uninterpreted_option_.Add(); -} -inline const ::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption >& -MessageOptions::uninterpreted_option() const { - return uninterpreted_option_; -} -inline ::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption >* -MessageOptions::mutable_uninterpreted_option() { - return &uninterpreted_option_; -} - -// ------------------------------------------------------------------- - -// FieldOptions - -// optional .google.protobuf.FieldOptions.CType ctype = 1 [default = STRING]; -inline bool FieldOptions::has_ctype() const { - return (_has_bits_[0] & 0x00000001u) != 0; -} -inline void FieldOptions::set_has_ctype() { - _has_bits_[0] |= 0x00000001u; -} -inline void FieldOptions::clear_has_ctype() { - _has_bits_[0] &= ~0x00000001u; -} -inline void FieldOptions::clear_ctype() { - ctype_ = 0; - clear_has_ctype(); -} -inline ::google::protobuf::FieldOptions_CType FieldOptions::ctype() const { - return static_cast< ::google::protobuf::FieldOptions_CType >(ctype_); -} -inline void FieldOptions::set_ctype(::google::protobuf::FieldOptions_CType value) { - assert(::google::protobuf::FieldOptions_CType_IsValid(value)); - set_has_ctype(); - ctype_ = value; -} - -// optional bool packed = 2; -inline bool FieldOptions::has_packed() const { - return (_has_bits_[0] & 0x00000002u) != 0; -} -inline void FieldOptions::set_has_packed() { - _has_bits_[0] |= 0x00000002u; -} -inline void FieldOptions::clear_has_packed() { - _has_bits_[0] &= ~0x00000002u; -} -inline void FieldOptions::clear_packed() { - packed_ = false; - clear_has_packed(); -} -inline bool FieldOptions::packed() const { - return packed_; -} -inline void FieldOptions::set_packed(bool value) { - set_has_packed(); - packed_ = value; -} - -// optional bool lazy = 5 [default = false]; -inline bool FieldOptions::has_lazy() const { - return (_has_bits_[0] & 0x00000004u) != 0; -} -inline void FieldOptions::set_has_lazy() { - _has_bits_[0] |= 0x00000004u; -} -inline void FieldOptions::clear_has_lazy() { - _has_bits_[0] &= ~0x00000004u; -} -inline void FieldOptions::clear_lazy() { - lazy_ = false; - clear_has_lazy(); -} -inline bool FieldOptions::lazy() const { - return lazy_; -} -inline void FieldOptions::set_lazy(bool value) { - set_has_lazy(); - lazy_ = value; -} - -// optional bool deprecated = 3 [default = false]; -inline bool FieldOptions::has_deprecated() const { - return (_has_bits_[0] & 0x00000008u) != 0; -} -inline void FieldOptions::set_has_deprecated() { - _has_bits_[0] |= 0x00000008u; -} -inline void FieldOptions::clear_has_deprecated() { - _has_bits_[0] &= ~0x00000008u; -} -inline void FieldOptions::clear_deprecated() { - deprecated_ = false; - clear_has_deprecated(); -} -inline bool FieldOptions::deprecated() const { - return deprecated_; -} -inline void FieldOptions::set_deprecated(bool value) { - set_has_deprecated(); - deprecated_ = value; -} - -// optional string experimental_map_key = 9; -inline bool FieldOptions::has_experimental_map_key() const { - return (_has_bits_[0] & 0x00000010u) != 0; -} -inline void FieldOptions::set_has_experimental_map_key() { - _has_bits_[0] |= 0x00000010u; -} -inline void FieldOptions::clear_has_experimental_map_key() { - _has_bits_[0] &= ~0x00000010u; -} -inline void FieldOptions::clear_experimental_map_key() { - if (experimental_map_key_ != &::google::protobuf::internal::kEmptyString) { - experimental_map_key_->clear(); - } - clear_has_experimental_map_key(); -} -inline const ::std::string& FieldOptions::experimental_map_key() const { - return *experimental_map_key_; -} -inline void FieldOptions::set_experimental_map_key(const ::std::string& value) { - set_has_experimental_map_key(); - if (experimental_map_key_ == &::google::protobuf::internal::kEmptyString) { - experimental_map_key_ = new ::std::string; - } - experimental_map_key_->assign(value); -} -inline void FieldOptions::set_experimental_map_key(const char* value) { - set_has_experimental_map_key(); - if (experimental_map_key_ == &::google::protobuf::internal::kEmptyString) { - experimental_map_key_ = new ::std::string; - } - experimental_map_key_->assign(value); -} -inline void FieldOptions::set_experimental_map_key(const char* value, size_t size) { - set_has_experimental_map_key(); - if (experimental_map_key_ == &::google::protobuf::internal::kEmptyString) { - experimental_map_key_ = new ::std::string; - } - experimental_map_key_->assign(reinterpret_cast(value), size); -} -inline ::std::string* FieldOptions::mutable_experimental_map_key() { - set_has_experimental_map_key(); - if (experimental_map_key_ == &::google::protobuf::internal::kEmptyString) { - experimental_map_key_ = new ::std::string; - } - return experimental_map_key_; -} -inline ::std::string* FieldOptions::release_experimental_map_key() { - clear_has_experimental_map_key(); - if (experimental_map_key_ == &::google::protobuf::internal::kEmptyString) { - return NULL; - } else { - ::std::string* temp = experimental_map_key_; - experimental_map_key_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); - return temp; - } -} -inline void FieldOptions::set_allocated_experimental_map_key(::std::string* experimental_map_key) { - if (experimental_map_key_ != &::google::protobuf::internal::kEmptyString) { - delete experimental_map_key_; - } - if (experimental_map_key) { - set_has_experimental_map_key(); - experimental_map_key_ = experimental_map_key; - } else { - clear_has_experimental_map_key(); - experimental_map_key_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); - } -} - -// optional bool weak = 10 [default = false]; -inline bool FieldOptions::has_weak() const { - return (_has_bits_[0] & 0x00000020u) != 0; -} -inline void FieldOptions::set_has_weak() { - _has_bits_[0] |= 0x00000020u; -} -inline void FieldOptions::clear_has_weak() { - _has_bits_[0] &= ~0x00000020u; -} -inline void FieldOptions::clear_weak() { - weak_ = false; - clear_has_weak(); -} -inline bool FieldOptions::weak() const { - return weak_; -} -inline void FieldOptions::set_weak(bool value) { - set_has_weak(); - weak_ = value; -} - -// repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; -inline int FieldOptions::uninterpreted_option_size() const { - return uninterpreted_option_.size(); -} -inline void FieldOptions::clear_uninterpreted_option() { - uninterpreted_option_.Clear(); -} -inline const ::google::protobuf::UninterpretedOption& FieldOptions::uninterpreted_option(int index) const { - return uninterpreted_option_.Get(index); -} -inline ::google::protobuf::UninterpretedOption* FieldOptions::mutable_uninterpreted_option(int index) { - return uninterpreted_option_.Mutable(index); -} -inline ::google::protobuf::UninterpretedOption* FieldOptions::add_uninterpreted_option() { - return uninterpreted_option_.Add(); -} -inline const ::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption >& -FieldOptions::uninterpreted_option() const { - return uninterpreted_option_; -} -inline ::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption >* -FieldOptions::mutable_uninterpreted_option() { - return &uninterpreted_option_; -} - -// ------------------------------------------------------------------- - -// EnumOptions - -// optional bool allow_alias = 2 [default = true]; -inline bool EnumOptions::has_allow_alias() const { - return (_has_bits_[0] & 0x00000001u) != 0; -} -inline void EnumOptions::set_has_allow_alias() { - _has_bits_[0] |= 0x00000001u; -} -inline void EnumOptions::clear_has_allow_alias() { - _has_bits_[0] &= ~0x00000001u; -} -inline void EnumOptions::clear_allow_alias() { - allow_alias_ = true; - clear_has_allow_alias(); -} -inline bool EnumOptions::allow_alias() const { - return allow_alias_; -} -inline void EnumOptions::set_allow_alias(bool value) { - set_has_allow_alias(); - allow_alias_ = value; -} - -// repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; -inline int EnumOptions::uninterpreted_option_size() const { - return uninterpreted_option_.size(); -} -inline void EnumOptions::clear_uninterpreted_option() { - uninterpreted_option_.Clear(); -} -inline const ::google::protobuf::UninterpretedOption& EnumOptions::uninterpreted_option(int index) const { - return uninterpreted_option_.Get(index); -} -inline ::google::protobuf::UninterpretedOption* EnumOptions::mutable_uninterpreted_option(int index) { - return uninterpreted_option_.Mutable(index); -} -inline ::google::protobuf::UninterpretedOption* EnumOptions::add_uninterpreted_option() { - return uninterpreted_option_.Add(); -} -inline const ::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption >& -EnumOptions::uninterpreted_option() const { - return uninterpreted_option_; -} -inline ::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption >* -EnumOptions::mutable_uninterpreted_option() { - return &uninterpreted_option_; -} - -// ------------------------------------------------------------------- - -// EnumValueOptions - -// repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; -inline int EnumValueOptions::uninterpreted_option_size() const { - return uninterpreted_option_.size(); -} -inline void EnumValueOptions::clear_uninterpreted_option() { - uninterpreted_option_.Clear(); -} -inline const ::google::protobuf::UninterpretedOption& EnumValueOptions::uninterpreted_option(int index) const { - return uninterpreted_option_.Get(index); -} -inline ::google::protobuf::UninterpretedOption* EnumValueOptions::mutable_uninterpreted_option(int index) { - return uninterpreted_option_.Mutable(index); -} -inline ::google::protobuf::UninterpretedOption* EnumValueOptions::add_uninterpreted_option() { - return uninterpreted_option_.Add(); -} -inline const ::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption >& -EnumValueOptions::uninterpreted_option() const { - return uninterpreted_option_; -} -inline ::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption >* -EnumValueOptions::mutable_uninterpreted_option() { - return &uninterpreted_option_; -} - -// ------------------------------------------------------------------- - -// ServiceOptions - -// repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; -inline int ServiceOptions::uninterpreted_option_size() const { - return uninterpreted_option_.size(); -} -inline void ServiceOptions::clear_uninterpreted_option() { - uninterpreted_option_.Clear(); -} -inline const ::google::protobuf::UninterpretedOption& ServiceOptions::uninterpreted_option(int index) const { - return uninterpreted_option_.Get(index); -} -inline ::google::protobuf::UninterpretedOption* ServiceOptions::mutable_uninterpreted_option(int index) { - return uninterpreted_option_.Mutable(index); -} -inline ::google::protobuf::UninterpretedOption* ServiceOptions::add_uninterpreted_option() { - return uninterpreted_option_.Add(); -} -inline const ::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption >& -ServiceOptions::uninterpreted_option() const { - return uninterpreted_option_; -} -inline ::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption >* -ServiceOptions::mutable_uninterpreted_option() { - return &uninterpreted_option_; -} - -// ------------------------------------------------------------------- - -// MethodOptions - -// repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; -inline int MethodOptions::uninterpreted_option_size() const { - return uninterpreted_option_.size(); -} -inline void MethodOptions::clear_uninterpreted_option() { - uninterpreted_option_.Clear(); -} -inline const ::google::protobuf::UninterpretedOption& MethodOptions::uninterpreted_option(int index) const { - return uninterpreted_option_.Get(index); -} -inline ::google::protobuf::UninterpretedOption* MethodOptions::mutable_uninterpreted_option(int index) { - return uninterpreted_option_.Mutable(index); -} -inline ::google::protobuf::UninterpretedOption* MethodOptions::add_uninterpreted_option() { - return uninterpreted_option_.Add(); -} -inline const ::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption >& -MethodOptions::uninterpreted_option() const { - return uninterpreted_option_; -} -inline ::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption >* -MethodOptions::mutable_uninterpreted_option() { - return &uninterpreted_option_; -} - -// ------------------------------------------------------------------- - -// UninterpretedOption_NamePart - -// required string name_part = 1; -inline bool UninterpretedOption_NamePart::has_name_part() const { - return (_has_bits_[0] & 0x00000001u) != 0; -} -inline void UninterpretedOption_NamePart::set_has_name_part() { - _has_bits_[0] |= 0x00000001u; -} -inline void UninterpretedOption_NamePart::clear_has_name_part() { - _has_bits_[0] &= ~0x00000001u; -} -inline void UninterpretedOption_NamePart::clear_name_part() { - if (name_part_ != &::google::protobuf::internal::kEmptyString) { - name_part_->clear(); - } - clear_has_name_part(); -} -inline const ::std::string& UninterpretedOption_NamePart::name_part() const { - return *name_part_; -} -inline void UninterpretedOption_NamePart::set_name_part(const ::std::string& value) { - set_has_name_part(); - if (name_part_ == &::google::protobuf::internal::kEmptyString) { - name_part_ = new ::std::string; - } - name_part_->assign(value); -} -inline void UninterpretedOption_NamePart::set_name_part(const char* value) { - set_has_name_part(); - if (name_part_ == &::google::protobuf::internal::kEmptyString) { - name_part_ = new ::std::string; - } - name_part_->assign(value); -} -inline void UninterpretedOption_NamePart::set_name_part(const char* value, size_t size) { - set_has_name_part(); - if (name_part_ == &::google::protobuf::internal::kEmptyString) { - name_part_ = new ::std::string; - } - name_part_->assign(reinterpret_cast(value), size); -} -inline ::std::string* UninterpretedOption_NamePart::mutable_name_part() { - set_has_name_part(); - if (name_part_ == &::google::protobuf::internal::kEmptyString) { - name_part_ = new ::std::string; - } - return name_part_; -} -inline ::std::string* UninterpretedOption_NamePart::release_name_part() { - clear_has_name_part(); - if (name_part_ == &::google::protobuf::internal::kEmptyString) { - return NULL; - } else { - ::std::string* temp = name_part_; - name_part_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); - return temp; - } -} -inline void UninterpretedOption_NamePart::set_allocated_name_part(::std::string* name_part) { - if (name_part_ != &::google::protobuf::internal::kEmptyString) { - delete name_part_; - } - if (name_part) { - set_has_name_part(); - name_part_ = name_part; - } else { - clear_has_name_part(); - name_part_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); - } -} - -// required bool is_extension = 2; -inline bool UninterpretedOption_NamePart::has_is_extension() const { - return (_has_bits_[0] & 0x00000002u) != 0; -} -inline void UninterpretedOption_NamePart::set_has_is_extension() { - _has_bits_[0] |= 0x00000002u; -} -inline void UninterpretedOption_NamePart::clear_has_is_extension() { - _has_bits_[0] &= ~0x00000002u; -} -inline void UninterpretedOption_NamePart::clear_is_extension() { - is_extension_ = false; - clear_has_is_extension(); -} -inline bool UninterpretedOption_NamePart::is_extension() const { - return is_extension_; -} -inline void UninterpretedOption_NamePart::set_is_extension(bool value) { - set_has_is_extension(); - is_extension_ = value; -} - -// ------------------------------------------------------------------- - -// UninterpretedOption - -// repeated .google.protobuf.UninterpretedOption.NamePart name = 2; -inline int UninterpretedOption::name_size() const { - return name_.size(); -} -inline void UninterpretedOption::clear_name() { - name_.Clear(); -} -inline const ::google::protobuf::UninterpretedOption_NamePart& UninterpretedOption::name(int index) const { - return name_.Get(index); -} -inline ::google::protobuf::UninterpretedOption_NamePart* UninterpretedOption::mutable_name(int index) { - return name_.Mutable(index); -} -inline ::google::protobuf::UninterpretedOption_NamePart* UninterpretedOption::add_name() { - return name_.Add(); -} -inline const ::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption_NamePart >& -UninterpretedOption::name() const { - return name_; -} -inline ::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption_NamePart >* -UninterpretedOption::mutable_name() { - return &name_; -} - -// optional string identifier_value = 3; -inline bool UninterpretedOption::has_identifier_value() const { - return (_has_bits_[0] & 0x00000002u) != 0; -} -inline void UninterpretedOption::set_has_identifier_value() { - _has_bits_[0] |= 0x00000002u; -} -inline void UninterpretedOption::clear_has_identifier_value() { - _has_bits_[0] &= ~0x00000002u; -} -inline void UninterpretedOption::clear_identifier_value() { - if (identifier_value_ != &::google::protobuf::internal::kEmptyString) { - identifier_value_->clear(); - } - clear_has_identifier_value(); -} -inline const ::std::string& UninterpretedOption::identifier_value() const { - return *identifier_value_; -} -inline void UninterpretedOption::set_identifier_value(const ::std::string& value) { - set_has_identifier_value(); - if (identifier_value_ == &::google::protobuf::internal::kEmptyString) { - identifier_value_ = new ::std::string; - } - identifier_value_->assign(value); -} -inline void UninterpretedOption::set_identifier_value(const char* value) { - set_has_identifier_value(); - if (identifier_value_ == &::google::protobuf::internal::kEmptyString) { - identifier_value_ = new ::std::string; - } - identifier_value_->assign(value); -} -inline void UninterpretedOption::set_identifier_value(const char* value, size_t size) { - set_has_identifier_value(); - if (identifier_value_ == &::google::protobuf::internal::kEmptyString) { - identifier_value_ = new ::std::string; - } - identifier_value_->assign(reinterpret_cast(value), size); -} -inline ::std::string* UninterpretedOption::mutable_identifier_value() { - set_has_identifier_value(); - if (identifier_value_ == &::google::protobuf::internal::kEmptyString) { - identifier_value_ = new ::std::string; - } - return identifier_value_; -} -inline ::std::string* UninterpretedOption::release_identifier_value() { - clear_has_identifier_value(); - if (identifier_value_ == &::google::protobuf::internal::kEmptyString) { - return NULL; - } else { - ::std::string* temp = identifier_value_; - identifier_value_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); - return temp; - } -} -inline void UninterpretedOption::set_allocated_identifier_value(::std::string* identifier_value) { - if (identifier_value_ != &::google::protobuf::internal::kEmptyString) { - delete identifier_value_; - } - if (identifier_value) { - set_has_identifier_value(); - identifier_value_ = identifier_value; - } else { - clear_has_identifier_value(); - identifier_value_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); - } -} - -// optional uint64 positive_int_value = 4; -inline bool UninterpretedOption::has_positive_int_value() const { - return (_has_bits_[0] & 0x00000004u) != 0; -} -inline void UninterpretedOption::set_has_positive_int_value() { - _has_bits_[0] |= 0x00000004u; -} -inline void UninterpretedOption::clear_has_positive_int_value() { - _has_bits_[0] &= ~0x00000004u; -} -inline void UninterpretedOption::clear_positive_int_value() { - positive_int_value_ = GOOGLE_ULONGLONG(0); - clear_has_positive_int_value(); -} -inline ::google::protobuf::uint64 UninterpretedOption::positive_int_value() const { - return positive_int_value_; -} -inline void UninterpretedOption::set_positive_int_value(::google::protobuf::uint64 value) { - set_has_positive_int_value(); - positive_int_value_ = value; -} - -// optional int64 negative_int_value = 5; -inline bool UninterpretedOption::has_negative_int_value() const { - return (_has_bits_[0] & 0x00000008u) != 0; -} -inline void UninterpretedOption::set_has_negative_int_value() { - _has_bits_[0] |= 0x00000008u; -} -inline void UninterpretedOption::clear_has_negative_int_value() { - _has_bits_[0] &= ~0x00000008u; -} -inline void UninterpretedOption::clear_negative_int_value() { - negative_int_value_ = GOOGLE_LONGLONG(0); - clear_has_negative_int_value(); -} -inline ::google::protobuf::int64 UninterpretedOption::negative_int_value() const { - return negative_int_value_; -} -inline void UninterpretedOption::set_negative_int_value(::google::protobuf::int64 value) { - set_has_negative_int_value(); - negative_int_value_ = value; -} - -// optional double double_value = 6; -inline bool UninterpretedOption::has_double_value() const { - return (_has_bits_[0] & 0x00000010u) != 0; -} -inline void UninterpretedOption::set_has_double_value() { - _has_bits_[0] |= 0x00000010u; -} -inline void UninterpretedOption::clear_has_double_value() { - _has_bits_[0] &= ~0x00000010u; -} -inline void UninterpretedOption::clear_double_value() { - double_value_ = 0; - clear_has_double_value(); -} -inline double UninterpretedOption::double_value() const { - return double_value_; -} -inline void UninterpretedOption::set_double_value(double value) { - set_has_double_value(); - double_value_ = value; -} - -// optional bytes string_value = 7; -inline bool UninterpretedOption::has_string_value() const { - return (_has_bits_[0] & 0x00000020u) != 0; -} -inline void UninterpretedOption::set_has_string_value() { - _has_bits_[0] |= 0x00000020u; -} -inline void UninterpretedOption::clear_has_string_value() { - _has_bits_[0] &= ~0x00000020u; -} -inline void UninterpretedOption::clear_string_value() { - if (string_value_ != &::google::protobuf::internal::kEmptyString) { - string_value_->clear(); - } - clear_has_string_value(); -} -inline const ::std::string& UninterpretedOption::string_value() const { - return *string_value_; -} -inline void UninterpretedOption::set_string_value(const ::std::string& value) { - set_has_string_value(); - if (string_value_ == &::google::protobuf::internal::kEmptyString) { - string_value_ = new ::std::string; - } - string_value_->assign(value); -} -inline void UninterpretedOption::set_string_value(const char* value) { - set_has_string_value(); - if (string_value_ == &::google::protobuf::internal::kEmptyString) { - string_value_ = new ::std::string; - } - string_value_->assign(value); -} -inline void UninterpretedOption::set_string_value(const void* value, size_t size) { - set_has_string_value(); - if (string_value_ == &::google::protobuf::internal::kEmptyString) { - string_value_ = new ::std::string; - } - string_value_->assign(reinterpret_cast(value), size); -} -inline ::std::string* UninterpretedOption::mutable_string_value() { - set_has_string_value(); - if (string_value_ == &::google::protobuf::internal::kEmptyString) { - string_value_ = new ::std::string; - } - return string_value_; -} -inline ::std::string* UninterpretedOption::release_string_value() { - clear_has_string_value(); - if (string_value_ == &::google::protobuf::internal::kEmptyString) { - return NULL; - } else { - ::std::string* temp = string_value_; - string_value_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); - return temp; - } -} -inline void UninterpretedOption::set_allocated_string_value(::std::string* string_value) { - if (string_value_ != &::google::protobuf::internal::kEmptyString) { - delete string_value_; - } - if (string_value) { - set_has_string_value(); - string_value_ = string_value; - } else { - clear_has_string_value(); - string_value_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); - } -} - -// optional string aggregate_value = 8; -inline bool UninterpretedOption::has_aggregate_value() const { - return (_has_bits_[0] & 0x00000040u) != 0; -} -inline void UninterpretedOption::set_has_aggregate_value() { - _has_bits_[0] |= 0x00000040u; -} -inline void UninterpretedOption::clear_has_aggregate_value() { - _has_bits_[0] &= ~0x00000040u; -} -inline void UninterpretedOption::clear_aggregate_value() { - if (aggregate_value_ != &::google::protobuf::internal::kEmptyString) { - aggregate_value_->clear(); - } - clear_has_aggregate_value(); -} -inline const ::std::string& UninterpretedOption::aggregate_value() const { - return *aggregate_value_; -} -inline void UninterpretedOption::set_aggregate_value(const ::std::string& value) { - set_has_aggregate_value(); - if (aggregate_value_ == &::google::protobuf::internal::kEmptyString) { - aggregate_value_ = new ::std::string; - } - aggregate_value_->assign(value); -} -inline void UninterpretedOption::set_aggregate_value(const char* value) { - set_has_aggregate_value(); - if (aggregate_value_ == &::google::protobuf::internal::kEmptyString) { - aggregate_value_ = new ::std::string; - } - aggregate_value_->assign(value); -} -inline void UninterpretedOption::set_aggregate_value(const char* value, size_t size) { - set_has_aggregate_value(); - if (aggregate_value_ == &::google::protobuf::internal::kEmptyString) { - aggregate_value_ = new ::std::string; - } - aggregate_value_->assign(reinterpret_cast(value), size); -} -inline ::std::string* UninterpretedOption::mutable_aggregate_value() { - set_has_aggregate_value(); - if (aggregate_value_ == &::google::protobuf::internal::kEmptyString) { - aggregate_value_ = new ::std::string; - } - return aggregate_value_; -} -inline ::std::string* UninterpretedOption::release_aggregate_value() { - clear_has_aggregate_value(); - if (aggregate_value_ == &::google::protobuf::internal::kEmptyString) { - return NULL; - } else { - ::std::string* temp = aggregate_value_; - aggregate_value_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); - return temp; - } -} -inline void UninterpretedOption::set_allocated_aggregate_value(::std::string* aggregate_value) { - if (aggregate_value_ != &::google::protobuf::internal::kEmptyString) { - delete aggregate_value_; - } - if (aggregate_value) { - set_has_aggregate_value(); - aggregate_value_ = aggregate_value; - } else { - clear_has_aggregate_value(); - aggregate_value_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); - } -} - -// ------------------------------------------------------------------- - -// SourceCodeInfo_Location - -// repeated int32 path = 1 [packed = true]; -inline int SourceCodeInfo_Location::path_size() const { - return path_.size(); -} -inline void SourceCodeInfo_Location::clear_path() { - path_.Clear(); -} -inline ::google::protobuf::int32 SourceCodeInfo_Location::path(int index) const { - return path_.Get(index); -} -inline void SourceCodeInfo_Location::set_path(int index, ::google::protobuf::int32 value) { - path_.Set(index, value); -} -inline void SourceCodeInfo_Location::add_path(::google::protobuf::int32 value) { - path_.Add(value); -} -inline const ::google::protobuf::RepeatedField< ::google::protobuf::int32 >& -SourceCodeInfo_Location::path() const { - return path_; -} -inline ::google::protobuf::RepeatedField< ::google::protobuf::int32 >* -SourceCodeInfo_Location::mutable_path() { - return &path_; -} - -// repeated int32 span = 2 [packed = true]; -inline int SourceCodeInfo_Location::span_size() const { - return span_.size(); -} -inline void SourceCodeInfo_Location::clear_span() { - span_.Clear(); -} -inline ::google::protobuf::int32 SourceCodeInfo_Location::span(int index) const { - return span_.Get(index); -} -inline void SourceCodeInfo_Location::set_span(int index, ::google::protobuf::int32 value) { - span_.Set(index, value); -} -inline void SourceCodeInfo_Location::add_span(::google::protobuf::int32 value) { - span_.Add(value); -} -inline const ::google::protobuf::RepeatedField< ::google::protobuf::int32 >& -SourceCodeInfo_Location::span() const { - return span_; -} -inline ::google::protobuf::RepeatedField< ::google::protobuf::int32 >* -SourceCodeInfo_Location::mutable_span() { - return &span_; -} - -// optional string leading_comments = 3; -inline bool SourceCodeInfo_Location::has_leading_comments() const { - return (_has_bits_[0] & 0x00000004u) != 0; -} -inline void SourceCodeInfo_Location::set_has_leading_comments() { - _has_bits_[0] |= 0x00000004u; -} -inline void SourceCodeInfo_Location::clear_has_leading_comments() { - _has_bits_[0] &= ~0x00000004u; -} -inline void SourceCodeInfo_Location::clear_leading_comments() { - if (leading_comments_ != &::google::protobuf::internal::kEmptyString) { - leading_comments_->clear(); - } - clear_has_leading_comments(); -} -inline const ::std::string& SourceCodeInfo_Location::leading_comments() const { - return *leading_comments_; -} -inline void SourceCodeInfo_Location::set_leading_comments(const ::std::string& value) { - set_has_leading_comments(); - if (leading_comments_ == &::google::protobuf::internal::kEmptyString) { - leading_comments_ = new ::std::string; - } - leading_comments_->assign(value); -} -inline void SourceCodeInfo_Location::set_leading_comments(const char* value) { - set_has_leading_comments(); - if (leading_comments_ == &::google::protobuf::internal::kEmptyString) { - leading_comments_ = new ::std::string; - } - leading_comments_->assign(value); -} -inline void SourceCodeInfo_Location::set_leading_comments(const char* value, size_t size) { - set_has_leading_comments(); - if (leading_comments_ == &::google::protobuf::internal::kEmptyString) { - leading_comments_ = new ::std::string; - } - leading_comments_->assign(reinterpret_cast(value), size); -} -inline ::std::string* SourceCodeInfo_Location::mutable_leading_comments() { - set_has_leading_comments(); - if (leading_comments_ == &::google::protobuf::internal::kEmptyString) { - leading_comments_ = new ::std::string; - } - return leading_comments_; -} -inline ::std::string* SourceCodeInfo_Location::release_leading_comments() { - clear_has_leading_comments(); - if (leading_comments_ == &::google::protobuf::internal::kEmptyString) { - return NULL; - } else { - ::std::string* temp = leading_comments_; - leading_comments_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); - return temp; - } -} -inline void SourceCodeInfo_Location::set_allocated_leading_comments(::std::string* leading_comments) { - if (leading_comments_ != &::google::protobuf::internal::kEmptyString) { - delete leading_comments_; - } - if (leading_comments) { - set_has_leading_comments(); - leading_comments_ = leading_comments; - } else { - clear_has_leading_comments(); - leading_comments_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); - } -} - -// optional string trailing_comments = 4; -inline bool SourceCodeInfo_Location::has_trailing_comments() const { - return (_has_bits_[0] & 0x00000008u) != 0; -} -inline void SourceCodeInfo_Location::set_has_trailing_comments() { - _has_bits_[0] |= 0x00000008u; -} -inline void SourceCodeInfo_Location::clear_has_trailing_comments() { - _has_bits_[0] &= ~0x00000008u; -} -inline void SourceCodeInfo_Location::clear_trailing_comments() { - if (trailing_comments_ != &::google::protobuf::internal::kEmptyString) { - trailing_comments_->clear(); - } - clear_has_trailing_comments(); -} -inline const ::std::string& SourceCodeInfo_Location::trailing_comments() const { - return *trailing_comments_; -} -inline void SourceCodeInfo_Location::set_trailing_comments(const ::std::string& value) { - set_has_trailing_comments(); - if (trailing_comments_ == &::google::protobuf::internal::kEmptyString) { - trailing_comments_ = new ::std::string; - } - trailing_comments_->assign(value); -} -inline void SourceCodeInfo_Location::set_trailing_comments(const char* value) { - set_has_trailing_comments(); - if (trailing_comments_ == &::google::protobuf::internal::kEmptyString) { - trailing_comments_ = new ::std::string; - } - trailing_comments_->assign(value); -} -inline void SourceCodeInfo_Location::set_trailing_comments(const char* value, size_t size) { - set_has_trailing_comments(); - if (trailing_comments_ == &::google::protobuf::internal::kEmptyString) { - trailing_comments_ = new ::std::string; - } - trailing_comments_->assign(reinterpret_cast(value), size); -} -inline ::std::string* SourceCodeInfo_Location::mutable_trailing_comments() { - set_has_trailing_comments(); - if (trailing_comments_ == &::google::protobuf::internal::kEmptyString) { - trailing_comments_ = new ::std::string; - } - return trailing_comments_; -} -inline ::std::string* SourceCodeInfo_Location::release_trailing_comments() { - clear_has_trailing_comments(); - if (trailing_comments_ == &::google::protobuf::internal::kEmptyString) { - return NULL; - } else { - ::std::string* temp = trailing_comments_; - trailing_comments_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); - return temp; - } -} -inline void SourceCodeInfo_Location::set_allocated_trailing_comments(::std::string* trailing_comments) { - if (trailing_comments_ != &::google::protobuf::internal::kEmptyString) { - delete trailing_comments_; - } - if (trailing_comments) { - set_has_trailing_comments(); - trailing_comments_ = trailing_comments; - } else { - clear_has_trailing_comments(); - trailing_comments_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); - } -} - -// ------------------------------------------------------------------- - -// SourceCodeInfo - -// repeated .google.protobuf.SourceCodeInfo.Location location = 1; -inline int SourceCodeInfo::location_size() const { - return location_.size(); -} -inline void SourceCodeInfo::clear_location() { - location_.Clear(); -} -inline const ::google::protobuf::SourceCodeInfo_Location& SourceCodeInfo::location(int index) const { - return location_.Get(index); -} -inline ::google::protobuf::SourceCodeInfo_Location* SourceCodeInfo::mutable_location(int index) { - return location_.Mutable(index); -} -inline ::google::protobuf::SourceCodeInfo_Location* SourceCodeInfo::add_location() { - return location_.Add(); -} -inline const ::google::protobuf::RepeatedPtrField< ::google::protobuf::SourceCodeInfo_Location >& -SourceCodeInfo::location() const { - return location_; -} -inline ::google::protobuf::RepeatedPtrField< ::google::protobuf::SourceCodeInfo_Location >* -SourceCodeInfo::mutable_location() { - return &location_; -} - - -// @@protoc_insertion_point(namespace_scope) - -} // namespace protobuf -} // namespace google - -#ifndef SWIG -namespace google { -namespace protobuf { - -template <> -inline const EnumDescriptor* GetEnumDescriptor< ::google::protobuf::FieldDescriptorProto_Type>() { - return ::google::protobuf::FieldDescriptorProto_Type_descriptor(); -} -template <> -inline const EnumDescriptor* GetEnumDescriptor< ::google::protobuf::FieldDescriptorProto_Label>() { - return ::google::protobuf::FieldDescriptorProto_Label_descriptor(); -} -template <> -inline const EnumDescriptor* GetEnumDescriptor< ::google::protobuf::FileOptions_OptimizeMode>() { - return ::google::protobuf::FileOptions_OptimizeMode_descriptor(); -} -template <> -inline const EnumDescriptor* GetEnumDescriptor< ::google::protobuf::FieldOptions_CType>() { - return ::google::protobuf::FieldOptions_CType_descriptor(); -} - -} // namespace google -} // namespace protobuf -#endif // SWIG - -// @@protoc_insertion_point(global_scope) - -#endif // PROTOBUF_google_2fprotobuf_2fdescriptor_2eproto__INCLUDED diff --git a/modules/dnn/3rdparty/protobuf/src/google/protobuf/descriptor.proto b/modules/dnn/3rdparty/protobuf/src/google/protobuf/descriptor.proto deleted file mode 100644 index a785f79fa..000000000 --- a/modules/dnn/3rdparty/protobuf/src/google/protobuf/descriptor.proto +++ /dev/null @@ -1,620 +0,0 @@ -// Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// http://code.google.com/p/protobuf/ -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -// Author: kenton@google.com (Kenton Varda) -// Based on original Protocol Buffers design by -// Sanjay Ghemawat, Jeff Dean, and others. -// -// The messages in this file describe the definitions found in .proto files. -// A valid .proto file can be translated directly to a FileDescriptorProto -// without any other information (e.g. without reading its imports). - - - -package google.protobuf; -option java_package = "com.google.protobuf"; -option java_outer_classname = "DescriptorProtos"; - -// descriptor.proto must be optimized for speed because reflection-based -// algorithms don't work during bootstrapping. -option optimize_for = SPEED; - -// The protocol compiler can output a FileDescriptorSet containing the .proto -// files it parses. -message FileDescriptorSet { - repeated FileDescriptorProto file = 1; -} - -// Describes a complete .proto file. -message FileDescriptorProto { - optional string name = 1; // file name, relative to root of source tree - optional string package = 2; // e.g. "foo", "foo.bar", etc. - - // Names of files imported by this file. - repeated string dependency = 3; - // Indexes of the public imported files in the dependency list above. - repeated int32 public_dependency = 10; - // Indexes of the weak imported files in the dependency list. - // For Google-internal migration only. Do not use. - repeated int32 weak_dependency = 11; - - // All top-level definitions in this file. - repeated DescriptorProto message_type = 4; - repeated EnumDescriptorProto enum_type = 5; - repeated ServiceDescriptorProto service = 6; - repeated FieldDescriptorProto extension = 7; - - optional FileOptions options = 8; - - // This field contains optional information about the original source code. - // You may safely remove this entire field whithout harming runtime - // functionality of the descriptors -- the information is needed only by - // development tools. - optional SourceCodeInfo source_code_info = 9; -} - -// Describes a message type. -message DescriptorProto { - optional string name = 1; - - repeated FieldDescriptorProto field = 2; - repeated FieldDescriptorProto extension = 6; - - repeated DescriptorProto nested_type = 3; - repeated EnumDescriptorProto enum_type = 4; - - message ExtensionRange { - optional int32 start = 1; - optional int32 end = 2; - } - repeated ExtensionRange extension_range = 5; - - optional MessageOptions options = 7; -} - -// Describes a field within a message. -message FieldDescriptorProto { - enum Type { - // 0 is reserved for errors. - // Order is weird for historical reasons. - TYPE_DOUBLE = 1; - TYPE_FLOAT = 2; - // Not ZigZag encoded. Negative numbers take 10 bytes. Use TYPE_SINT64 if - // negative values are likely. - TYPE_INT64 = 3; - TYPE_UINT64 = 4; - // Not ZigZag encoded. Negative numbers take 10 bytes. Use TYPE_SINT32 if - // negative values are likely. - TYPE_INT32 = 5; - TYPE_FIXED64 = 6; - TYPE_FIXED32 = 7; - TYPE_BOOL = 8; - TYPE_STRING = 9; - TYPE_GROUP = 10; // Tag-delimited aggregate. - TYPE_MESSAGE = 11; // Length-delimited aggregate. - - // New in version 2. - TYPE_BYTES = 12; - TYPE_UINT32 = 13; - TYPE_ENUM = 14; - TYPE_SFIXED32 = 15; - TYPE_SFIXED64 = 16; - TYPE_SINT32 = 17; // Uses ZigZag encoding. - TYPE_SINT64 = 18; // Uses ZigZag encoding. - }; - - enum Label { - // 0 is reserved for errors - LABEL_OPTIONAL = 1; - LABEL_REQUIRED = 2; - LABEL_REPEATED = 3; - // TODO(sanjay): Should we add LABEL_MAP? - }; - - optional string name = 1; - optional int32 number = 3; - optional Label label = 4; - - // If type_name is set, this need not be set. If both this and type_name - // are set, this must be either TYPE_ENUM or TYPE_MESSAGE. - optional Type type = 5; - - // For message and enum types, this is the name of the type. If the name - // starts with a '.', it is fully-qualified. Otherwise, C++-like scoping - // rules are used to find the type (i.e. first the nested types within this - // message are searched, then within the parent, on up to the root - // namespace). - optional string type_name = 6; - - // For extensions, this is the name of the type being extended. It is - // resolved in the same manner as type_name. - optional string extendee = 2; - - // For numeric types, contains the original text representation of the value. - // For booleans, "true" or "false". - // For strings, contains the default text contents (not escaped in any way). - // For bytes, contains the C escaped value. All bytes >= 128 are escaped. - // TODO(kenton): Base-64 encode? - optional string default_value = 7; - - optional FieldOptions options = 8; -} - -// Describes an enum type. -message EnumDescriptorProto { - optional string name = 1; - - repeated EnumValueDescriptorProto value = 2; - - optional EnumOptions options = 3; -} - -// Describes a value within an enum. -message EnumValueDescriptorProto { - optional string name = 1; - optional int32 number = 2; - - optional EnumValueOptions options = 3; -} - -// Describes a service. -message ServiceDescriptorProto { - optional string name = 1; - repeated MethodDescriptorProto method = 2; - - optional ServiceOptions options = 3; -} - -// Describes a method of a service. -message MethodDescriptorProto { - optional string name = 1; - - // Input and output type names. These are resolved in the same way as - // FieldDescriptorProto.type_name, but must refer to a message type. - optional string input_type = 2; - optional string output_type = 3; - - optional MethodOptions options = 4; -} - - -// =================================================================== -// Options - -// Each of the definitions above may have "options" attached. These are -// just annotations which may cause code to be generated slightly differently -// or may contain hints for code that manipulates protocol messages. -// -// Clients may define custom options as extensions of the *Options messages. -// These extensions may not yet be known at parsing time, so the parser cannot -// store the values in them. Instead it stores them in a field in the *Options -// message called uninterpreted_option. This field must have the same name -// across all *Options messages. We then use this field to populate the -// extensions when we build a descriptor, at which point all protos have been -// parsed and so all extensions are known. -// -// Extension numbers for custom options may be chosen as follows: -// * For options which will only be used within a single application or -// organization, or for experimental options, use field numbers 50000 -// through 99999. It is up to you to ensure that you do not use the -// same number for multiple options. -// * For options which will be published and used publicly by multiple -// independent entities, e-mail protobuf-global-extension-registry@google.com -// to reserve extension numbers. Simply provide your project name (e.g. -// Object-C plugin) and your porject website (if available) -- there's no need -// to explain how you intend to use them. Usually you only need one extension -// number. You can declare multiple options with only one extension number by -// putting them in a sub-message. See the Custom Options section of the docs -// for examples: -// http://code.google.com/apis/protocolbuffers/docs/proto.html#options -// If this turns out to be popular, a web service will be set up -// to automatically assign option numbers. - - -message FileOptions { - - // Sets the Java package where classes generated from this .proto will be - // placed. By default, the proto package is used, but this is often - // inappropriate because proto packages do not normally start with backwards - // domain names. - optional string java_package = 1; - - - // If set, all the classes from the .proto file are wrapped in a single - // outer class with the given name. This applies to both Proto1 - // (equivalent to the old "--one_java_file" option) and Proto2 (where - // a .proto always translates to a single class, but you may want to - // explicitly choose the class name). - optional string java_outer_classname = 8; - - // If set true, then the Java code generator will generate a separate .java - // file for each top-level message, enum, and service defined in the .proto - // file. Thus, these types will *not* be nested inside the outer class - // named by java_outer_classname. However, the outer class will still be - // generated to contain the file's getDescriptor() method as well as any - // top-level extensions defined in the file. - optional bool java_multiple_files = 10 [default=false]; - - // If set true, then the Java code generator will generate equals() and - // hashCode() methods for all messages defined in the .proto file. This is - // purely a speed optimization, as the AbstractMessage base class includes - // reflection-based implementations of these methods. - optional bool java_generate_equals_and_hash = 20 [default=false]; - - // Generated classes can be optimized for speed or code size. - enum OptimizeMode { - SPEED = 1; // Generate complete code for parsing, serialization, - // etc. - CODE_SIZE = 2; // Use ReflectionOps to implement these methods. - LITE_RUNTIME = 3; // Generate code using MessageLite and the lite runtime. - } - optional OptimizeMode optimize_for = 9 [default=SPEED]; - - // Sets the Go package where structs generated from this .proto will be - // placed. There is no default. - optional string go_package = 11; - - - - // Should generic services be generated in each language? "Generic" services - // are not specific to any particular RPC system. They are generated by the - // main code generators in each language (without additional plugins). - // Generic services were the only kind of service generation supported by - // early versions of proto2. - // - // Generic services are now considered deprecated in favor of using plugins - // that generate code specific to your particular RPC system. Therefore, - // these default to false. Old code which depends on generic services should - // explicitly set them to true. - optional bool cc_generic_services = 16 [default=false]; - optional bool java_generic_services = 17 [default=false]; - optional bool py_generic_services = 18 [default=false]; - - // The parser stores options it doesn't recognize here. See above. - repeated UninterpretedOption uninterpreted_option = 999; - - // Clients can define custom options in extensions of this message. See above. - extensions 1000 to max; -} - -message MessageOptions { - // Set true to use the old proto1 MessageSet wire format for extensions. - // This is provided for backwards-compatibility with the MessageSet wire - // format. You should not use this for any other reason: It's less - // efficient, has fewer features, and is more complicated. - // - // The message must be defined exactly as follows: - // message Foo { - // option message_set_wire_format = true; - // extensions 4 to max; - // } - // Note that the message cannot have any defined fields; MessageSets only - // have extensions. - // - // All extensions of your type must be singular messages; e.g. they cannot - // be int32s, enums, or repeated messages. - // - // Because this is an option, the above two restrictions are not enforced by - // the protocol compiler. - optional bool message_set_wire_format = 1 [default=false]; - - // Disables the generation of the standard "descriptor()" accessor, which can - // conflict with a field of the same name. This is meant to make migration - // from proto1 easier; new code should avoid fields named "descriptor". - optional bool no_standard_descriptor_accessor = 2 [default=false]; - - // The parser stores options it doesn't recognize here. See above. - repeated UninterpretedOption uninterpreted_option = 999; - - // Clients can define custom options in extensions of this message. See above. - extensions 1000 to max; -} - -message FieldOptions { - // The ctype option instructs the C++ code generator to use a different - // representation of the field than it normally would. See the specific - // options below. This option is not yet implemented in the open source - // release -- sorry, we'll try to include it in a future version! - optional CType ctype = 1 [default = STRING]; - enum CType { - // Default mode. - STRING = 0; - - CORD = 1; - - STRING_PIECE = 2; - } - // The packed option can be enabled for repeated primitive fields to enable - // a more efficient representation on the wire. Rather than repeatedly - // writing the tag and type for each element, the entire array is encoded as - // a single length-delimited blob. - optional bool packed = 2; - - - - // Should this field be parsed lazily? Lazy applies only to message-type - // fields. It means that when the outer message is initially parsed, the - // inner message's contents will not be parsed but instead stored in encoded - // form. The inner message will actually be parsed when it is first accessed. - // - // This is only a hint. Implementations are free to choose whether to use - // eager or lazy parsing regardless of the value of this option. However, - // setting this option true suggests that the protocol author believes that - // using lazy parsing on this field is worth the additional bookkeeping - // overhead typically needed to implement it. - // - // This option does not affect the public interface of any generated code; - // all method signatures remain the same. Furthermore, thread-safety of the - // interface is not affected by this option; const methods remain safe to - // call from multiple threads concurrently, while non-const methods continue - // to require exclusive access. - // - // - // Note that implementations may choose not to check required fields within - // a lazy sub-message. That is, calling IsInitialized() on the outher message - // may return true even if the inner message has missing required fields. - // This is necessary because otherwise the inner message would have to be - // parsed in order to perform the check, defeating the purpose of lazy - // parsing. An implementation which chooses not to check required fields - // must be consistent about it. That is, for any particular sub-message, the - // implementation must either *always* check its required fields, or *never* - // check its required fields, regardless of whether or not the message has - // been parsed. - optional bool lazy = 5 [default=false]; - - // Is this field deprecated? - // Depending on the target platform, this can emit Deprecated annotations - // for accessors, or it will be completely ignored; in the very least, this - // is a formalization for deprecating fields. - optional bool deprecated = 3 [default=false]; - - // EXPERIMENTAL. DO NOT USE. - // For "map" fields, the name of the field in the enclosed type that - // is the key for this map. For example, suppose we have: - // message Item { - // required string name = 1; - // required string value = 2; - // } - // message Config { - // repeated Item items = 1 [experimental_map_key="name"]; - // } - // In this situation, the map key for Item will be set to "name". - // TODO: Fully-implement this, then remove the "experimental_" prefix. - optional string experimental_map_key = 9; - - // For Google-internal migration only. Do not use. - optional bool weak = 10 [default=false]; - - // The parser stores options it doesn't recognize here. See above. - repeated UninterpretedOption uninterpreted_option = 999; - - // Clients can define custom options in extensions of this message. See above. - extensions 1000 to max; -} - -message EnumOptions { - - // Set this option to false to disallow mapping different tag names to a same - // value. - optional bool allow_alias = 2 [default=true]; - - // The parser stores options it doesn't recognize here. See above. - repeated UninterpretedOption uninterpreted_option = 999; - - // Clients can define custom options in extensions of this message. See above. - extensions 1000 to max; -} - -message EnumValueOptions { - // The parser stores options it doesn't recognize here. See above. - repeated UninterpretedOption uninterpreted_option = 999; - - // Clients can define custom options in extensions of this message. See above. - extensions 1000 to max; -} - -message ServiceOptions { - - // Note: Field numbers 1 through 32 are reserved for Google's internal RPC - // framework. We apologize for hoarding these numbers to ourselves, but - // we were already using them long before we decided to release Protocol - // Buffers. - - // The parser stores options it doesn't recognize here. See above. - repeated UninterpretedOption uninterpreted_option = 999; - - // Clients can define custom options in extensions of this message. See above. - extensions 1000 to max; -} - -message MethodOptions { - - // Note: Field numbers 1 through 32 are reserved for Google's internal RPC - // framework. We apologize for hoarding these numbers to ourselves, but - // we were already using them long before we decided to release Protocol - // Buffers. - - // The parser stores options it doesn't recognize here. See above. - repeated UninterpretedOption uninterpreted_option = 999; - - // Clients can define custom options in extensions of this message. See above. - extensions 1000 to max; -} - - -// A message representing a option the parser does not recognize. This only -// appears in options protos created by the compiler::Parser class. -// DescriptorPool resolves these when building Descriptor objects. Therefore, -// options protos in descriptor objects (e.g. returned by Descriptor::options(), -// or produced by Descriptor::CopyTo()) will never have UninterpretedOptions -// in them. -message UninterpretedOption { - // The name of the uninterpreted option. Each string represents a segment in - // a dot-separated name. is_extension is true iff a segment represents an - // extension (denoted with parentheses in options specs in .proto files). - // E.g.,{ ["foo", false], ["bar.baz", true], ["qux", false] } represents - // "foo.(bar.baz).qux". - message NamePart { - required string name_part = 1; - required bool is_extension = 2; - } - repeated NamePart name = 2; - - // The value of the uninterpreted option, in whatever type the tokenizer - // identified it as during parsing. Exactly one of these should be set. - optional string identifier_value = 3; - optional uint64 positive_int_value = 4; - optional int64 negative_int_value = 5; - optional double double_value = 6; - optional bytes string_value = 7; - optional string aggregate_value = 8; -} - -// =================================================================== -// Optional source code info - -// Encapsulates information about the original source file from which a -// FileDescriptorProto was generated. -message SourceCodeInfo { - // A Location identifies a piece of source code in a .proto file which - // corresponds to a particular definition. This information is intended - // to be useful to IDEs, code indexers, documentation generators, and similar - // tools. - // - // For example, say we have a file like: - // message Foo { - // optional string foo = 1; - // } - // Let's look at just the field definition: - // optional string foo = 1; - // ^ ^^ ^^ ^ ^^^ - // a bc de f ghi - // We have the following locations: - // span path represents - // [a,i) [ 4, 0, 2, 0 ] The whole field definition. - // [a,b) [ 4, 0, 2, 0, 4 ] The label (optional). - // [c,d) [ 4, 0, 2, 0, 5 ] The type (string). - // [e,f) [ 4, 0, 2, 0, 1 ] The name (foo). - // [g,h) [ 4, 0, 2, 0, 3 ] The number (1). - // - // Notes: - // - A location may refer to a repeated field itself (i.e. not to any - // particular index within it). This is used whenever a set of elements are - // logically enclosed in a single code segment. For example, an entire - // extend block (possibly containing multiple extension definitions) will - // have an outer location whose path refers to the "extensions" repeated - // field without an index. - // - Multiple locations may have the same path. This happens when a single - // logical declaration is spread out across multiple places. The most - // obvious example is the "extend" block again -- there may be multiple - // extend blocks in the same scope, each of which will have the same path. - // - A location's span is not always a subset of its parent's span. For - // example, the "extendee" of an extension declaration appears at the - // beginning of the "extend" block and is shared by all extensions within - // the block. - // - Just because a location's span is a subset of some other location's span - // does not mean that it is a descendent. For example, a "group" defines - // both a type and a field in a single declaration. Thus, the locations - // corresponding to the type and field and their components will overlap. - // - Code which tries to interpret locations should probably be designed to - // ignore those that it doesn't understand, as more types of locations could - // be recorded in the future. - repeated Location location = 1; - message Location { - // Identifies which part of the FileDescriptorProto was defined at this - // location. - // - // Each element is a field number or an index. They form a path from - // the root FileDescriptorProto to the place where the definition. For - // example, this path: - // [ 4, 3, 2, 7, 1 ] - // refers to: - // file.message_type(3) // 4, 3 - // .field(7) // 2, 7 - // .name() // 1 - // This is because FileDescriptorProto.message_type has field number 4: - // repeated DescriptorProto message_type = 4; - // and DescriptorProto.field has field number 2: - // repeated FieldDescriptorProto field = 2; - // and FieldDescriptorProto.name has field number 1: - // optional string name = 1; - // - // Thus, the above path gives the location of a field name. If we removed - // the last element: - // [ 4, 3, 2, 7 ] - // this path refers to the whole field declaration (from the beginning - // of the label to the terminating semicolon). - repeated int32 path = 1 [packed=true]; - - // Always has exactly three or four elements: start line, start column, - // end line (optional, otherwise assumed same as start line), end column. - // These are packed into a single field for efficiency. Note that line - // and column numbers are zero-based -- typically you will want to add - // 1 to each before displaying to a user. - repeated int32 span = 2 [packed=true]; - - // If this SourceCodeInfo represents a complete declaration, these are any - // comments appearing before and after the declaration which appear to be - // attached to the declaration. - // - // A series of line comments appearing on consecutive lines, with no other - // tokens appearing on those lines, will be treated as a single comment. - // - // Only the comment content is provided; comment markers (e.g. //) are - // stripped out. For block comments, leading whitespace and an asterisk - // will be stripped from the beginning of each line other than the first. - // Newlines are included in the output. - // - // Examples: - // - // optional int32 foo = 1; // Comment attached to foo. - // // Comment attached to bar. - // optional int32 bar = 2; - // - // optional string baz = 3; - // // Comment attached to baz. - // // Another line attached to baz. - // - // // Comment attached to qux. - // // - // // Another line attached to qux. - // optional double qux = 4; - // - // optional string corge = 5; - // /* Block comment attached - // * to corge. Leading asterisks - // * will be removed. */ - // /* Block comment attached to - // * grault. */ - // optional int32 grault = 6; - optional string leading_comments = 3; - optional string trailing_comments = 4; - } -} diff --git a/modules/dnn/3rdparty/protobuf/src/google/protobuf/descriptor_database.cc b/modules/dnn/3rdparty/protobuf/src/google/protobuf/descriptor_database.cc deleted file mode 100644 index 35e459d53..000000000 --- a/modules/dnn/3rdparty/protobuf/src/google/protobuf/descriptor_database.cc +++ /dev/null @@ -1,541 +0,0 @@ -// Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// http://code.google.com/p/protobuf/ -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -// Author: kenton@google.com (Kenton Varda) -// Based on original Protocol Buffers design by -// Sanjay Ghemawat, Jeff Dean, and others. - -#include - -#include - -#include -#include -#include -#include -#include - -namespace google { -namespace protobuf { - -DescriptorDatabase::~DescriptorDatabase() {} - -// =================================================================== - -template -bool SimpleDescriptorDatabase::DescriptorIndex::AddFile( - const FileDescriptorProto& file, - Value value) { - if (!InsertIfNotPresent(&by_name_, file.name(), value)) { - GOOGLE_LOG(ERROR) << "File already exists in database: " << file.name(); - return false; - } - - // We must be careful here -- calling file.package() if file.has_package() is - // false could access an uninitialized static-storage variable if we are being - // run at startup time. - string path = file.has_package() ? file.package() : string(); - if (!path.empty()) path += '.'; - - for (int i = 0; i < file.message_type_size(); i++) { - if (!AddSymbol(path + file.message_type(i).name(), value)) return false; - if (!AddNestedExtensions(file.message_type(i), value)) return false; - } - for (int i = 0; i < file.enum_type_size(); i++) { - if (!AddSymbol(path + file.enum_type(i).name(), value)) return false; - } - for (int i = 0; i < file.extension_size(); i++) { - if (!AddSymbol(path + file.extension(i).name(), value)) return false; - if (!AddExtension(file.extension(i), value)) return false; - } - for (int i = 0; i < file.service_size(); i++) { - if (!AddSymbol(path + file.service(i).name(), value)) return false; - } - - return true; -} - -template -bool SimpleDescriptorDatabase::DescriptorIndex::AddSymbol( - const string& name, Value value) { - // We need to make sure not to violate our map invariant. - - // If the symbol name is invalid it could break our lookup algorithm (which - // relies on the fact that '.' sorts before all other characters that are - // valid in symbol names). - if (!ValidateSymbolName(name)) { - GOOGLE_LOG(ERROR) << "Invalid symbol name: " << name; - return false; - } - - // Try to look up the symbol to make sure a super-symbol doesn't already - // exist. - typename map::iterator iter = FindLastLessOrEqual(name); - - if (iter == by_symbol_.end()) { - // Apparently the map is currently empty. Just insert and be done with it. - by_symbol_.insert(typename map::value_type(name, value)); - return true; - } - - if (IsSubSymbol(iter->first, name)) { - GOOGLE_LOG(ERROR) << "Symbol name \"" << name << "\" conflicts with the existing " - "symbol \"" << iter->first << "\"."; - return false; - } - - // OK, that worked. Now we have to make sure that no symbol in the map is - // a sub-symbol of the one we are inserting. The only symbol which could - // be so is the first symbol that is greater than the new symbol. Since - // |iter| points at the last symbol that is less than or equal, we just have - // to increment it. - ++iter; - - if (iter != by_symbol_.end() && IsSubSymbol(name, iter->first)) { - GOOGLE_LOG(ERROR) << "Symbol name \"" << name << "\" conflicts with the existing " - "symbol \"" << iter->first << "\"."; - return false; - } - - // OK, no conflicts. - - // Insert the new symbol using the iterator as a hint, the new entry will - // appear immediately before the one the iterator is pointing at. - by_symbol_.insert(iter, typename map::value_type(name, value)); - - return true; -} - -template -bool SimpleDescriptorDatabase::DescriptorIndex::AddNestedExtensions( - const DescriptorProto& message_type, - Value value) { - for (int i = 0; i < message_type.nested_type_size(); i++) { - if (!AddNestedExtensions(message_type.nested_type(i), value)) return false; - } - for (int i = 0; i < message_type.extension_size(); i++) { - if (!AddExtension(message_type.extension(i), value)) return false; - } - return true; -} - -template -bool SimpleDescriptorDatabase::DescriptorIndex::AddExtension( - const FieldDescriptorProto& field, - Value value) { - if (!field.extendee().empty() && field.extendee()[0] == '.') { - // The extension is fully-qualified. We can use it as a lookup key in - // the by_symbol_ table. - if (!InsertIfNotPresent(&by_extension_, - make_pair(field.extendee().substr(1), - field.number()), - value)) { - GOOGLE_LOG(ERROR) << "Extension conflicts with extension already in database: " - "extend " << field.extendee() << " { " - << field.name() << " = " << field.number() << " }"; - return false; - } - } else { - // Not fully-qualified. We can't really do anything here, unfortunately. - // We don't consider this an error, though, because the descriptor is - // valid. - } - return true; -} - -template -Value SimpleDescriptorDatabase::DescriptorIndex::FindFile( - const string& filename) { - return FindWithDefault(by_name_, filename, Value()); -} - -template -Value SimpleDescriptorDatabase::DescriptorIndex::FindSymbol( - const string& name) { - typename map::iterator iter = FindLastLessOrEqual(name); - - return (iter != by_symbol_.end() && IsSubSymbol(iter->first, name)) ? - iter->second : Value(); -} - -template -Value SimpleDescriptorDatabase::DescriptorIndex::FindExtension( - const string& containing_type, - int field_number) { - return FindWithDefault(by_extension_, - make_pair(containing_type, field_number), - Value()); -} - -template -bool SimpleDescriptorDatabase::DescriptorIndex::FindAllExtensionNumbers( - const string& containing_type, - vector* output) { - typename map, Value >::const_iterator it = - by_extension_.lower_bound(make_pair(containing_type, 0)); - bool success = false; - - for (; it != by_extension_.end() && it->first.first == containing_type; - ++it) { - output->push_back(it->first.second); - success = true; - } - - return success; -} - -template -typename map::iterator -SimpleDescriptorDatabase::DescriptorIndex::FindLastLessOrEqual( - const string& name) { - // Find the last key in the map which sorts less than or equal to the - // symbol name. Since upper_bound() returns the *first* key that sorts - // *greater* than the input, we want the element immediately before that. - typename map::iterator iter = by_symbol_.upper_bound(name); - if (iter != by_symbol_.begin()) --iter; - return iter; -} - -template -bool SimpleDescriptorDatabase::DescriptorIndex::IsSubSymbol( - const string& sub_symbol, const string& super_symbol) { - return sub_symbol == super_symbol || - (HasPrefixString(super_symbol, sub_symbol) && - super_symbol[sub_symbol.size()] == '.'); -} - -template -bool SimpleDescriptorDatabase::DescriptorIndex::ValidateSymbolName( - const string& name) { - for (int i = 0; i < name.size(); i++) { - // I don't trust ctype.h due to locales. :( - if (name[i] != '.' && name[i] != '_' && - (name[i] < '0' || name[i] > '9') && - (name[i] < 'A' || name[i] > 'Z') && - (name[i] < 'a' || name[i] > 'z')) { - return false; - } - } - return true; -} - -// ------------------------------------------------------------------- - -SimpleDescriptorDatabase::SimpleDescriptorDatabase() {} -SimpleDescriptorDatabase::~SimpleDescriptorDatabase() { - STLDeleteElements(&files_to_delete_); -} - -bool SimpleDescriptorDatabase::Add(const FileDescriptorProto& file) { - FileDescriptorProto* new_file = new FileDescriptorProto; - new_file->CopyFrom(file); - return AddAndOwn(new_file); -} - -bool SimpleDescriptorDatabase::AddAndOwn(const FileDescriptorProto* file) { - files_to_delete_.push_back(file); - return index_.AddFile(*file, file); -} - -bool SimpleDescriptorDatabase::FindFileByName( - const string& filename, - FileDescriptorProto* output) { - return MaybeCopy(index_.FindFile(filename), output); -} - -bool SimpleDescriptorDatabase::FindFileContainingSymbol( - const string& symbol_name, - FileDescriptorProto* output) { - return MaybeCopy(index_.FindSymbol(symbol_name), output); -} - -bool SimpleDescriptorDatabase::FindFileContainingExtension( - const string& containing_type, - int field_number, - FileDescriptorProto* output) { - return MaybeCopy(index_.FindExtension(containing_type, field_number), output); -} - -bool SimpleDescriptorDatabase::FindAllExtensionNumbers( - const string& extendee_type, - vector* output) { - return index_.FindAllExtensionNumbers(extendee_type, output); -} - -bool SimpleDescriptorDatabase::MaybeCopy(const FileDescriptorProto* file, - FileDescriptorProto* output) { - if (file == NULL) return false; - output->CopyFrom(*file); - return true; -} - -// ------------------------------------------------------------------- - -EncodedDescriptorDatabase::EncodedDescriptorDatabase() {} -EncodedDescriptorDatabase::~EncodedDescriptorDatabase() { - for (int i = 0; i < files_to_delete_.size(); i++) { - operator delete(files_to_delete_[i]); - } -} - -bool EncodedDescriptorDatabase::Add( - const void* encoded_file_descriptor, int size) { - FileDescriptorProto file; - if (file.ParseFromArray(encoded_file_descriptor, size)) { - return index_.AddFile(file, make_pair(encoded_file_descriptor, size)); - } else { - GOOGLE_LOG(ERROR) << "Invalid file descriptor data passed to " - "EncodedDescriptorDatabase::Add()."; - return false; - } -} - -bool EncodedDescriptorDatabase::AddCopy( - const void* encoded_file_descriptor, int size) { - void* copy = operator new(size); - memcpy(copy, encoded_file_descriptor, size); - files_to_delete_.push_back(copy); - return Add(copy, size); -} - -bool EncodedDescriptorDatabase::FindFileByName( - const string& filename, - FileDescriptorProto* output) { - return MaybeParse(index_.FindFile(filename), output); -} - -bool EncodedDescriptorDatabase::FindFileContainingSymbol( - const string& symbol_name, - FileDescriptorProto* output) { - return MaybeParse(index_.FindSymbol(symbol_name), output); -} - -bool EncodedDescriptorDatabase::FindNameOfFileContainingSymbol( - const string& symbol_name, - string* output) { - pair encoded_file = index_.FindSymbol(symbol_name); - if (encoded_file.first == NULL) return false; - - // Optimization: The name should be the first field in the encoded message. - // Try to just read it directly. - io::CodedInputStream input(reinterpret_cast(encoded_file.first), - encoded_file.second); - - const uint32 kNameTag = internal::WireFormatLite::MakeTag( - FileDescriptorProto::kNameFieldNumber, - internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED); - - if (input.ReadTag() == kNameTag) { - // Success! - return internal::WireFormatLite::ReadString(&input, output); - } else { - // Slow path. Parse whole message. - FileDescriptorProto file_proto; - if (!file_proto.ParseFromArray(encoded_file.first, encoded_file.second)) { - return false; - } - *output = file_proto.name(); - return true; - } -} - -bool EncodedDescriptorDatabase::FindFileContainingExtension( - const string& containing_type, - int field_number, - FileDescriptorProto* output) { - return MaybeParse(index_.FindExtension(containing_type, field_number), - output); -} - -bool EncodedDescriptorDatabase::FindAllExtensionNumbers( - const string& extendee_type, - vector* output) { - return index_.FindAllExtensionNumbers(extendee_type, output); -} - -bool EncodedDescriptorDatabase::MaybeParse( - pair encoded_file, - FileDescriptorProto* output) { - if (encoded_file.first == NULL) return false; - return output->ParseFromArray(encoded_file.first, encoded_file.second); -} - -// =================================================================== - -DescriptorPoolDatabase::DescriptorPoolDatabase(const DescriptorPool& pool) - : pool_(pool) {} -DescriptorPoolDatabase::~DescriptorPoolDatabase() {} - -bool DescriptorPoolDatabase::FindFileByName( - const string& filename, - FileDescriptorProto* output) { - const FileDescriptor* file = pool_.FindFileByName(filename); - if (file == NULL) return false; - output->Clear(); - file->CopyTo(output); - return true; -} - -bool DescriptorPoolDatabase::FindFileContainingSymbol( - const string& symbol_name, - FileDescriptorProto* output) { - const FileDescriptor* file = pool_.FindFileContainingSymbol(symbol_name); - if (file == NULL) return false; - output->Clear(); - file->CopyTo(output); - return true; -} - -bool DescriptorPoolDatabase::FindFileContainingExtension( - const string& containing_type, - int field_number, - FileDescriptorProto* output) { - const Descriptor* extendee = pool_.FindMessageTypeByName(containing_type); - if (extendee == NULL) return false; - - const FieldDescriptor* extension = - pool_.FindExtensionByNumber(extendee, field_number); - if (extension == NULL) return false; - - output->Clear(); - extension->file()->CopyTo(output); - return true; -} - -bool DescriptorPoolDatabase::FindAllExtensionNumbers( - const string& extendee_type, - vector* output) { - const Descriptor* extendee = pool_.FindMessageTypeByName(extendee_type); - if (extendee == NULL) return false; - - vector extensions; - pool_.FindAllExtensions(extendee, &extensions); - - for (int i = 0; i < extensions.size(); ++i) { - output->push_back(extensions[i]->number()); - } - - return true; -} - -// =================================================================== - -MergedDescriptorDatabase::MergedDescriptorDatabase( - DescriptorDatabase* source1, - DescriptorDatabase* source2) { - sources_.push_back(source1); - sources_.push_back(source2); -} -MergedDescriptorDatabase::MergedDescriptorDatabase( - const vector& sources) - : sources_(sources) {} -MergedDescriptorDatabase::~MergedDescriptorDatabase() {} - -bool MergedDescriptorDatabase::FindFileByName( - const string& filename, - FileDescriptorProto* output) { - for (int i = 0; i < sources_.size(); i++) { - if (sources_[i]->FindFileByName(filename, output)) { - return true; - } - } - return false; -} - -bool MergedDescriptorDatabase::FindFileContainingSymbol( - const string& symbol_name, - FileDescriptorProto* output) { - for (int i = 0; i < sources_.size(); i++) { - if (sources_[i]->FindFileContainingSymbol(symbol_name, output)) { - // The symbol was found in source i. However, if one of the previous - // sources defines a file with the same name (which presumably doesn't - // contain the symbol, since it wasn't found in that source), then we - // must hide it from the caller. - FileDescriptorProto temp; - for (int j = 0; j < i; j++) { - if (sources_[j]->FindFileByName(output->name(), &temp)) { - // Found conflicting file in a previous source. - return false; - } - } - return true; - } - } - return false; -} - -bool MergedDescriptorDatabase::FindFileContainingExtension( - const string& containing_type, - int field_number, - FileDescriptorProto* output) { - for (int i = 0; i < sources_.size(); i++) { - if (sources_[i]->FindFileContainingExtension( - containing_type, field_number, output)) { - // The symbol was found in source i. However, if one of the previous - // sources defines a file with the same name (which presumably doesn't - // contain the symbol, since it wasn't found in that source), then we - // must hide it from the caller. - FileDescriptorProto temp; - for (int j = 0; j < i; j++) { - if (sources_[j]->FindFileByName(output->name(), &temp)) { - // Found conflicting file in a previous source. - return false; - } - } - return true; - } - } - return false; -} - -bool MergedDescriptorDatabase::FindAllExtensionNumbers( - const string& extendee_type, - vector* output) { - set merged_results; - vector results; - bool success = false; - - for (int i = 0; i < sources_.size(); i++) { - if (sources_[i]->FindAllExtensionNumbers(extendee_type, &results)) { - copy(results.begin(), results.end(), - insert_iterator >(merged_results, merged_results.begin())); - success = true; - } - results.clear(); - } - - copy(merged_results.begin(), merged_results.end(), - insert_iterator >(*output, output->end())); - - return success; -} - -} // namespace protobuf -} // namespace google diff --git a/modules/dnn/3rdparty/protobuf/src/google/protobuf/descriptor_database.h b/modules/dnn/3rdparty/protobuf/src/google/protobuf/descriptor_database.h deleted file mode 100644 index 2ccb14583..000000000 --- a/modules/dnn/3rdparty/protobuf/src/google/protobuf/descriptor_database.h +++ /dev/null @@ -1,367 +0,0 @@ -// Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// http://code.google.com/p/protobuf/ -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -// Author: kenton@google.com (Kenton Varda) -// Based on original Protocol Buffers design by -// Sanjay Ghemawat, Jeff Dean, and others. -// -// Interface for manipulating databases of descriptors. - -#ifndef GOOGLE_PROTOBUF_DESCRIPTOR_DATABASE_H__ -#define GOOGLE_PROTOBUF_DESCRIPTOR_DATABASE_H__ - -#include -#include -#include -#include -#include -#include - -namespace google { -namespace protobuf { - -// Defined in this file. -class DescriptorDatabase; -class SimpleDescriptorDatabase; -class EncodedDescriptorDatabase; -class DescriptorPoolDatabase; -class MergedDescriptorDatabase; - -// Abstract interface for a database of descriptors. -// -// This is useful if you want to create a DescriptorPool which loads -// descriptors on-demand from some sort of large database. If the database -// is large, it may be inefficient to enumerate every .proto file inside it -// calling DescriptorPool::BuildFile() for each one. Instead, a DescriptorPool -// can be created which wraps a DescriptorDatabase and only builds particular -// descriptors when they are needed. -class LIBPROTOBUF_EXPORT DescriptorDatabase { - public: - inline DescriptorDatabase() {} - virtual ~DescriptorDatabase(); - - // Find a file by file name. Fills in in *output and returns true if found. - // Otherwise, returns false, leaving the contents of *output undefined. - virtual bool FindFileByName(const string& filename, - FileDescriptorProto* output) = 0; - - // Find the file that declares the given fully-qualified symbol name. - // If found, fills in *output and returns true, otherwise returns false - // and leaves *output undefined. - virtual bool FindFileContainingSymbol(const string& symbol_name, - FileDescriptorProto* output) = 0; - - // Find the file which defines an extension extending the given message type - // with the given field number. If found, fills in *output and returns true, - // otherwise returns false and leaves *output undefined. containing_type - // must be a fully-qualified type name. - virtual bool FindFileContainingExtension(const string& containing_type, - int field_number, - FileDescriptorProto* output) = 0; - - // Finds the tag numbers used by all known extensions of - // extendee_type, and appends them to output in an undefined - // order. This method is best-effort: it's not guaranteed that the - // database will find all extensions, and it's not guaranteed that - // FindFileContainingExtension will return true on all of the found - // numbers. Returns true if the search was successful, otherwise - // returns false and leaves output unchanged. - // - // This method has a default implementation that always returns - // false. - virtual bool FindAllExtensionNumbers(const string& extendee_type, - vector* output) { - return false; - } - - private: - GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(DescriptorDatabase); -}; - -// A DescriptorDatabase into which you can insert files manually. -// -// FindFileContainingSymbol() is fully-implemented. When you add a file, its -// symbols will be indexed for this purpose. Note that the implementation -// may return false positives, but only if it isn't possible for the symbol -// to be defined in any other file. In particular, if a file defines a symbol -// "Foo", then searching for "Foo.[anything]" will match that file. This way, -// the database does not need to aggressively index all children of a symbol. -// -// FindFileContainingExtension() is mostly-implemented. It works if and only -// if the original FieldDescriptorProto defining the extension has a -// fully-qualified type name in its "extendee" field (i.e. starts with a '.'). -// If the extendee is a relative name, SimpleDescriptorDatabase will not -// attempt to resolve the type, so it will not know what type the extension is -// extending. Therefore, calling FindFileContainingExtension() with the -// extension's containing type will never actually find that extension. Note -// that this is an unlikely problem, as all FileDescriptorProtos created by the -// protocol compiler (as well as ones created by calling -// FileDescriptor::CopyTo()) will always use fully-qualified names for all -// types. You only need to worry if you are constructing FileDescriptorProtos -// yourself, or are calling compiler::Parser directly. -class LIBPROTOBUF_EXPORT SimpleDescriptorDatabase : public DescriptorDatabase { - public: - SimpleDescriptorDatabase(); - ~SimpleDescriptorDatabase(); - - // Adds the FileDescriptorProto to the database, making a copy. The object - // can be deleted after Add() returns. Returns false if the file conflicted - // with a file already in the database, in which case an error will have - // been written to GOOGLE_LOG(ERROR). - bool Add(const FileDescriptorProto& file); - - // Adds the FileDescriptorProto to the database and takes ownership of it. - bool AddAndOwn(const FileDescriptorProto* file); - - // implements DescriptorDatabase ----------------------------------- - bool FindFileByName(const string& filename, - FileDescriptorProto* output); - bool FindFileContainingSymbol(const string& symbol_name, - FileDescriptorProto* output); - bool FindFileContainingExtension(const string& containing_type, - int field_number, - FileDescriptorProto* output); - bool FindAllExtensionNumbers(const string& extendee_type, - vector* output); - - private: - // So that it can use DescriptorIndex. - friend class EncodedDescriptorDatabase; - - // An index mapping file names, symbol names, and extension numbers to - // some sort of values. - template - class DescriptorIndex { - public: - // Helpers to recursively add particular descriptors and all their contents - // to the index. - bool AddFile(const FileDescriptorProto& file, - Value value); - bool AddSymbol(const string& name, Value value); - bool AddNestedExtensions(const DescriptorProto& message_type, - Value value); - bool AddExtension(const FieldDescriptorProto& field, - Value value); - - Value FindFile(const string& filename); - Value FindSymbol(const string& name); - Value FindExtension(const string& containing_type, int field_number); - bool FindAllExtensionNumbers(const string& containing_type, - vector* output); - - private: - map by_name_; - map by_symbol_; - map, Value> by_extension_; - - // Invariant: The by_symbol_ map does not contain any symbols which are - // prefixes of other symbols in the map. For example, "foo.bar" is a - // prefix of "foo.bar.baz" (but is not a prefix of "foo.barbaz"). - // - // This invariant is important because it means that given a symbol name, - // we can find a key in the map which is a prefix of the symbol in O(lg n) - // time, and we know that there is at most one such key. - // - // The prefix lookup algorithm works like so: - // 1) Find the last key in the map which is less than or equal to the - // search key. - // 2) If the found key is a prefix of the search key, then return it. - // Otherwise, there is no match. - // - // I am sure this algorithm has been described elsewhere, but since I - // wasn't able to find it quickly I will instead prove that it works - // myself. The key to the algorithm is that if a match exists, step (1) - // will find it. Proof: - // 1) Define the "search key" to be the key we are looking for, the "found - // key" to be the key found in step (1), and the "match key" to be the - // key which actually matches the serach key (i.e. the key we're trying - // to find). - // 2) The found key must be less than or equal to the search key by - // definition. - // 3) The match key must also be less than or equal to the search key - // (because it is a prefix). - // 4) The match key cannot be greater than the found key, because if it - // were, then step (1) of the algorithm would have returned the match - // key instead (since it finds the *greatest* key which is less than or - // equal to the search key). - // 5) Therefore, the found key must be between the match key and the search - // key, inclusive. - // 6) Since the search key must be a sub-symbol of the match key, if it is - // not equal to the match key, then search_key[match_key.size()] must - // be '.'. - // 7) Since '.' sorts before any other character that is valid in a symbol - // name, then if the found key is not equal to the match key, then - // found_key[match_key.size()] must also be '.', because any other value - // would make it sort after the search key. - // 8) Therefore, if the found key is not equal to the match key, then the - // found key must be a sub-symbol of the match key. However, this would - // contradict our map invariant which says that no symbol in the map is - // a sub-symbol of any other. - // 9) Therefore, the found key must match the match key. - // - // The above proof assumes the match key exists. In the case that the - // match key does not exist, then step (1) will return some other symbol. - // That symbol cannot be a super-symbol of the search key since if it were, - // then it would be a match, and we're assuming the match key doesn't exist. - // Therefore, step 2 will correctly return no match. - - // Find the last entry in the by_symbol_ map whose key is less than or - // equal to the given name. - typename map::iterator FindLastLessOrEqual( - const string& name); - - // True if either the arguments are equal or super_symbol identifies a - // parent symbol of sub_symbol (e.g. "foo.bar" is a parent of - // "foo.bar.baz", but not a parent of "foo.barbaz"). - bool IsSubSymbol(const string& sub_symbol, const string& super_symbol); - - // Returns true if and only if all characters in the name are alphanumerics, - // underscores, or periods. - bool ValidateSymbolName(const string& name); - }; - - - DescriptorIndex index_; - vector files_to_delete_; - - // If file is non-NULL, copy it into *output and return true, otherwise - // return false. - bool MaybeCopy(const FileDescriptorProto* file, - FileDescriptorProto* output); - - GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(SimpleDescriptorDatabase); -}; - -// Very similar to SimpleDescriptorDatabase, but stores all the descriptors -// as raw bytes and generally tries to use as little memory as possible. -// -// The same caveats regarding FindFileContainingExtension() apply as with -// SimpleDescriptorDatabase. -class LIBPROTOBUF_EXPORT EncodedDescriptorDatabase : public DescriptorDatabase { - public: - EncodedDescriptorDatabase(); - ~EncodedDescriptorDatabase(); - - // Adds the FileDescriptorProto to the database. The descriptor is provided - // in encoded form. The database does not make a copy of the bytes, nor - // does it take ownership; it's up to the caller to make sure the bytes - // remain valid for the life of the database. Returns false and logs an error - // if the bytes are not a valid FileDescriptorProto or if the file conflicted - // with a file already in the database. - bool Add(const void* encoded_file_descriptor, int size); - - // Like Add(), but makes a copy of the data, so that the caller does not - // need to keep it around. - bool AddCopy(const void* encoded_file_descriptor, int size); - - // Like FindFileContainingSymbol but returns only the name of the file. - bool FindNameOfFileContainingSymbol(const string& symbol_name, - string* output); - - // implements DescriptorDatabase ----------------------------------- - bool FindFileByName(const string& filename, - FileDescriptorProto* output); - bool FindFileContainingSymbol(const string& symbol_name, - FileDescriptorProto* output); - bool FindFileContainingExtension(const string& containing_type, - int field_number, - FileDescriptorProto* output); - bool FindAllExtensionNumbers(const string& extendee_type, - vector* output); - - private: - SimpleDescriptorDatabase::DescriptorIndex > index_; - vector files_to_delete_; - - // If encoded_file.first is non-NULL, parse the data into *output and return - // true, otherwise return false. - bool MaybeParse(pair encoded_file, - FileDescriptorProto* output); - - GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(EncodedDescriptorDatabase); -}; - -// A DescriptorDatabase that fetches files from a given pool. -class LIBPROTOBUF_EXPORT DescriptorPoolDatabase : public DescriptorDatabase { - public: - DescriptorPoolDatabase(const DescriptorPool& pool); - ~DescriptorPoolDatabase(); - - // implements DescriptorDatabase ----------------------------------- - bool FindFileByName(const string& filename, - FileDescriptorProto* output); - bool FindFileContainingSymbol(const string& symbol_name, - FileDescriptorProto* output); - bool FindFileContainingExtension(const string& containing_type, - int field_number, - FileDescriptorProto* output); - bool FindAllExtensionNumbers(const string& extendee_type, - vector* output); - - private: - const DescriptorPool& pool_; - GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(DescriptorPoolDatabase); -}; - -// A DescriptorDatabase that wraps two or more others. It first searches the -// first database and, if that fails, tries the second, and so on. -class LIBPROTOBUF_EXPORT MergedDescriptorDatabase : public DescriptorDatabase { - public: - // Merge just two databases. The sources remain property of the caller. - MergedDescriptorDatabase(DescriptorDatabase* source1, - DescriptorDatabase* source2); - // Merge more than two databases. The sources remain property of the caller. - // The vector may be deleted after the constructor returns but the - // DescriptorDatabases need to stick around. - MergedDescriptorDatabase(const vector& sources); - ~MergedDescriptorDatabase(); - - // implements DescriptorDatabase ----------------------------------- - bool FindFileByName(const string& filename, - FileDescriptorProto* output); - bool FindFileContainingSymbol(const string& symbol_name, - FileDescriptorProto* output); - bool FindFileContainingExtension(const string& containing_type, - int field_number, - FileDescriptorProto* output); - // Merges the results of calling all databases. Returns true iff any - // of the databases returned true. - bool FindAllExtensionNumbers(const string& extendee_type, - vector* output); - - private: - vector sources_; - GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(MergedDescriptorDatabase); -}; - -} // namespace protobuf - -} // namespace google -#endif // GOOGLE_PROTOBUF_DESCRIPTOR_DATABASE_H__ diff --git a/modules/dnn/3rdparty/protobuf/src/google/protobuf/descriptor_database_unittest.cc b/modules/dnn/3rdparty/protobuf/src/google/protobuf/descriptor_database_unittest.cc deleted file mode 100644 index ac72ddcdb..000000000 --- a/modules/dnn/3rdparty/protobuf/src/google/protobuf/descriptor_database_unittest.cc +++ /dev/null @@ -1,748 +0,0 @@ -// Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// http://code.google.com/p/protobuf/ -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -// Author: kenton@google.com (Kenton Varda) -// Based on original Protocol Buffers design by -// Sanjay Ghemawat, Jeff Dean, and others. -// -// This file makes extensive use of RFC 3092. :) - -#include - -#include -#include -#include -#include -#include - -#include -#include -#include - -namespace google { -namespace protobuf { -namespace { - -static void AddToDatabase(SimpleDescriptorDatabase* database, - const char* file_text) { - FileDescriptorProto file_proto; - EXPECT_TRUE(TextFormat::ParseFromString(file_text, &file_proto)); - database->Add(file_proto); -} - -static void ExpectContainsType(const FileDescriptorProto& proto, - const string& type_name) { - for (int i = 0; i < proto.message_type_size(); i++) { - if (proto.message_type(i).name() == type_name) return; - } - ADD_FAILURE() << "\"" << proto.name() - << "\" did not contain expected type \"" - << type_name << "\"."; -} - -// =================================================================== - -#if GTEST_HAS_PARAM_TEST - -// SimpleDescriptorDatabase, EncodedDescriptorDatabase, and -// DescriptorPoolDatabase call for very similar tests. Instead of writing -// three nearly-identical sets of tests, we use parameterized tests to apply -// the same code to all three. - -// The parameterized test runs against a DescriptarDatabaseTestCase. We have -// implementations for each of the three classes we want to test. -class DescriptorDatabaseTestCase { - public: - virtual ~DescriptorDatabaseTestCase() {} - - virtual DescriptorDatabase* GetDatabase() = 0; - virtual bool AddToDatabase(const FileDescriptorProto& file) = 0; -}; - -// Factory function type. -typedef DescriptorDatabaseTestCase* DescriptorDatabaseTestCaseFactory(); - -// Specialization for SimpleDescriptorDatabase. -class SimpleDescriptorDatabaseTestCase : public DescriptorDatabaseTestCase { - public: - static DescriptorDatabaseTestCase* New() { - return new SimpleDescriptorDatabaseTestCase; - } - - virtual ~SimpleDescriptorDatabaseTestCase() {} - - virtual DescriptorDatabase* GetDatabase() { - return &database_; - } - virtual bool AddToDatabase(const FileDescriptorProto& file) { - return database_.Add(file); - } - - private: - SimpleDescriptorDatabase database_; -}; - -// Specialization for EncodedDescriptorDatabase. -class EncodedDescriptorDatabaseTestCase : public DescriptorDatabaseTestCase { - public: - static DescriptorDatabaseTestCase* New() { - return new EncodedDescriptorDatabaseTestCase; - } - - virtual ~EncodedDescriptorDatabaseTestCase() {} - - virtual DescriptorDatabase* GetDatabase() { - return &database_; - } - virtual bool AddToDatabase(const FileDescriptorProto& file) { - string data; - file.SerializeToString(&data); - return database_.AddCopy(data.data(), data.size()); - } - - private: - EncodedDescriptorDatabase database_; -}; - -// Specialization for DescriptorPoolDatabase. -class DescriptorPoolDatabaseTestCase : public DescriptorDatabaseTestCase { - public: - static DescriptorDatabaseTestCase* New() { - return new EncodedDescriptorDatabaseTestCase; - } - - DescriptorPoolDatabaseTestCase() : database_(pool_) {} - virtual ~DescriptorPoolDatabaseTestCase() {} - - virtual DescriptorDatabase* GetDatabase() { - return &database_; - } - virtual bool AddToDatabase(const FileDescriptorProto& file) { - return pool_.BuildFile(file); - } - - private: - DescriptorPool pool_; - DescriptorPoolDatabase database_; -}; - -// ------------------------------------------------------------------- - -class DescriptorDatabaseTest - : public testing::TestWithParam { - protected: - virtual void SetUp() { - test_case_.reset(GetParam()()); - database_ = test_case_->GetDatabase(); - } - - void AddToDatabase(const char* file_descriptor_text) { - FileDescriptorProto file_proto; - EXPECT_TRUE(TextFormat::ParseFromString(file_descriptor_text, &file_proto)); - EXPECT_TRUE(test_case_->AddToDatabase(file_proto)); - } - - void AddToDatabaseWithError(const char* file_descriptor_text) { - FileDescriptorProto file_proto; - EXPECT_TRUE(TextFormat::ParseFromString(file_descriptor_text, &file_proto)); - EXPECT_FALSE(test_case_->AddToDatabase(file_proto)); - } - - scoped_ptr test_case_; - DescriptorDatabase* database_; -}; - -TEST_P(DescriptorDatabaseTest, FindFileByName) { - AddToDatabase( - "name: \"foo.proto\" " - "message_type { name:\"Foo\" }"); - AddToDatabase( - "name: \"bar.proto\" " - "message_type { name:\"Bar\" }"); - - { - FileDescriptorProto file; - EXPECT_TRUE(database_->FindFileByName("foo.proto", &file)); - EXPECT_EQ("foo.proto", file.name()); - ExpectContainsType(file, "Foo"); - } - - { - FileDescriptorProto file; - EXPECT_TRUE(database_->FindFileByName("bar.proto", &file)); - EXPECT_EQ("bar.proto", file.name()); - ExpectContainsType(file, "Bar"); - } - - { - // Fails to find undefined files. - FileDescriptorProto file; - EXPECT_FALSE(database_->FindFileByName("baz.proto", &file)); - } -} - -TEST_P(DescriptorDatabaseTest, FindFileContainingSymbol) { - AddToDatabase( - "name: \"foo.proto\" " - "message_type { " - " name: \"Foo\" " - " field { name:\"qux\" }" - " nested_type { name: \"Grault\" } " - " enum_type { name: \"Garply\" } " - "} " - "enum_type { " - " name: \"Waldo\" " - " value { name:\"FRED\" } " - "} " - "extension { name: \"plugh\" } " - "service { " - " name: \"Xyzzy\" " - " method { name: \"Thud\" } " - "}" - ); - AddToDatabase( - "name: \"bar.proto\" " - "package: \"corge\" " - "message_type { name: \"Bar\" }"); - - { - FileDescriptorProto file; - EXPECT_TRUE(database_->FindFileContainingSymbol("Foo", &file)); - EXPECT_EQ("foo.proto", file.name()); - } - - { - // Can find fields. - FileDescriptorProto file; - EXPECT_TRUE(database_->FindFileContainingSymbol("Foo.qux", &file)); - EXPECT_EQ("foo.proto", file.name()); - } - - { - // Can find nested types. - FileDescriptorProto file; - EXPECT_TRUE(database_->FindFileContainingSymbol("Foo.Grault", &file)); - EXPECT_EQ("foo.proto", file.name()); - } - - { - // Can find nested enums. - FileDescriptorProto file; - EXPECT_TRUE(database_->FindFileContainingSymbol("Foo.Garply", &file)); - EXPECT_EQ("foo.proto", file.name()); - } - - { - // Can find enum types. - FileDescriptorProto file; - EXPECT_TRUE(database_->FindFileContainingSymbol("Waldo", &file)); - EXPECT_EQ("foo.proto", file.name()); - } - - { - // Can find enum values. - FileDescriptorProto file; - EXPECT_TRUE(database_->FindFileContainingSymbol("Waldo.FRED", &file)); - EXPECT_EQ("foo.proto", file.name()); - } - - { - // Can find extensions. - FileDescriptorProto file; - EXPECT_TRUE(database_->FindFileContainingSymbol("plugh", &file)); - EXPECT_EQ("foo.proto", file.name()); - } - - { - // Can find services. - FileDescriptorProto file; - EXPECT_TRUE(database_->FindFileContainingSymbol("Xyzzy", &file)); - EXPECT_EQ("foo.proto", file.name()); - } - - { - // Can find methods. - FileDescriptorProto file; - EXPECT_TRUE(database_->FindFileContainingSymbol("Xyzzy.Thud", &file)); - EXPECT_EQ("foo.proto", file.name()); - } - - { - // Can find things in packages. - FileDescriptorProto file; - EXPECT_TRUE(database_->FindFileContainingSymbol("corge.Bar", &file)); - EXPECT_EQ("bar.proto", file.name()); - } - - { - // Fails to find undefined symbols. - FileDescriptorProto file; - EXPECT_FALSE(database_->FindFileContainingSymbol("Baz", &file)); - } - - { - // Names must be fully-qualified. - FileDescriptorProto file; - EXPECT_FALSE(database_->FindFileContainingSymbol("Bar", &file)); - } -} - -TEST_P(DescriptorDatabaseTest, FindFileContainingExtension) { - AddToDatabase( - "name: \"foo.proto\" " - "message_type { " - " name: \"Foo\" " - " extension_range { start: 1 end: 1000 } " - " extension { name:\"qux\" label:LABEL_OPTIONAL type:TYPE_INT32 number:5 " - " extendee: \".Foo\" }" - "}"); - AddToDatabase( - "name: \"bar.proto\" " - "package: \"corge\" " - "dependency: \"foo.proto\" " - "message_type { " - " name: \"Bar\" " - " extension_range { start: 1 end: 1000 } " - "} " - "extension { name:\"grault\" extendee: \".Foo\" number:32 } " - "extension { name:\"garply\" extendee: \".corge.Bar\" number:70 } " - "extension { name:\"waldo\" extendee: \"Bar\" number:56 } "); - - { - FileDescriptorProto file; - EXPECT_TRUE(database_->FindFileContainingExtension("Foo", 5, &file)); - EXPECT_EQ("foo.proto", file.name()); - } - - { - FileDescriptorProto file; - EXPECT_TRUE(database_->FindFileContainingExtension("Foo", 32, &file)); - EXPECT_EQ("bar.proto", file.name()); - } - - { - // Can find extensions for qualified type names. - FileDescriptorProto file; - EXPECT_TRUE(database_->FindFileContainingExtension("corge.Bar", 70, &file)); - EXPECT_EQ("bar.proto", file.name()); - } - - { - // Can't find extensions whose extendee was not fully-qualified in the - // FileDescriptorProto. - FileDescriptorProto file; - EXPECT_FALSE(database_->FindFileContainingExtension("Bar", 56, &file)); - EXPECT_FALSE( - database_->FindFileContainingExtension("corge.Bar", 56, &file)); - } - - { - // Can't find non-existent extension numbers. - FileDescriptorProto file; - EXPECT_FALSE(database_->FindFileContainingExtension("Foo", 12, &file)); - } - - { - // Can't find extensions for non-existent types. - FileDescriptorProto file; - EXPECT_FALSE( - database_->FindFileContainingExtension("NoSuchType", 5, &file)); - } - - { - // Can't find extensions for unqualified type names. - FileDescriptorProto file; - EXPECT_FALSE(database_->FindFileContainingExtension("Bar", 70, &file)); - } -} - -TEST_P(DescriptorDatabaseTest, FindAllExtensionNumbers) { - AddToDatabase( - "name: \"foo.proto\" " - "message_type { " - " name: \"Foo\" " - " extension_range { start: 1 end: 1000 } " - " extension { name:\"qux\" label:LABEL_OPTIONAL type:TYPE_INT32 number:5 " - " extendee: \".Foo\" }" - "}"); - AddToDatabase( - "name: \"bar.proto\" " - "package: \"corge\" " - "dependency: \"foo.proto\" " - "message_type { " - " name: \"Bar\" " - " extension_range { start: 1 end: 1000 } " - "} " - "extension { name:\"grault\" extendee: \".Foo\" number:32 } " - "extension { name:\"garply\" extendee: \".corge.Bar\" number:70 } " - "extension { name:\"waldo\" extendee: \"Bar\" number:56 } "); - - { - vector numbers; - EXPECT_TRUE(database_->FindAllExtensionNumbers("Foo", &numbers)); - ASSERT_EQ(2, numbers.size()); - sort(numbers.begin(), numbers.end()); - EXPECT_EQ(5, numbers[0]); - EXPECT_EQ(32, numbers[1]); - } - - { - vector numbers; - EXPECT_TRUE(database_->FindAllExtensionNumbers("corge.Bar", &numbers)); - // Note: won't find extension 56 due to the name not being fully qualified. - ASSERT_EQ(1, numbers.size()); - EXPECT_EQ(70, numbers[0]); - } - - { - // Can't find extensions for non-existent types. - vector numbers; - EXPECT_FALSE(database_->FindAllExtensionNumbers("NoSuchType", &numbers)); - } - - { - // Can't find extensions for unqualified types. - vector numbers; - EXPECT_FALSE(database_->FindAllExtensionNumbers("Bar", &numbers)); - } -} - -TEST_P(DescriptorDatabaseTest, ConflictingFileError) { - AddToDatabase( - "name: \"foo.proto\" " - "message_type { " - " name: \"Foo\" " - "}"); - AddToDatabaseWithError( - "name: \"foo.proto\" " - "message_type { " - " name: \"Bar\" " - "}"); -} - -TEST_P(DescriptorDatabaseTest, ConflictingTypeError) { - AddToDatabase( - "name: \"foo.proto\" " - "message_type { " - " name: \"Foo\" " - "}"); - AddToDatabaseWithError( - "name: \"bar.proto\" " - "message_type { " - " name: \"Foo\" " - "}"); -} - -TEST_P(DescriptorDatabaseTest, ConflictingExtensionError) { - AddToDatabase( - "name: \"foo.proto\" " - "extension { name:\"foo\" label:LABEL_OPTIONAL type:TYPE_INT32 number:5 " - " extendee: \".Foo\" }"); - AddToDatabaseWithError( - "name: \"bar.proto\" " - "extension { name:\"bar\" label:LABEL_OPTIONAL type:TYPE_INT32 number:5 " - " extendee: \".Foo\" }"); -} - -INSTANTIATE_TEST_CASE_P(Simple, DescriptorDatabaseTest, - testing::Values(&SimpleDescriptorDatabaseTestCase::New)); -INSTANTIATE_TEST_CASE_P(MemoryConserving, DescriptorDatabaseTest, - testing::Values(&EncodedDescriptorDatabaseTestCase::New)); -INSTANTIATE_TEST_CASE_P(Pool, DescriptorDatabaseTest, - testing::Values(&DescriptorPoolDatabaseTestCase::New)); - -#endif // GTEST_HAS_PARAM_TEST - -TEST(EncodedDescriptorDatabaseExtraTest, FindNameOfFileContainingSymbol) { - // Create two files, one of which is in two parts. - FileDescriptorProto file1, file2a, file2b; - file1.set_name("foo.proto"); - file1.set_package("foo"); - file1.add_message_type()->set_name("Foo"); - file2a.set_name("bar.proto"); - file2b.set_package("bar"); - file2b.add_message_type()->set_name("Bar"); - - // Normal serialization allows our optimization to kick in. - string data1 = file1.SerializeAsString(); - - // Force out-of-order serialization to test slow path. - string data2 = file2b.SerializeAsString() + file2a.SerializeAsString(); - - // Create EncodedDescriptorDatabase containing both files. - EncodedDescriptorDatabase db; - db.Add(data1.data(), data1.size()); - db.Add(data2.data(), data2.size()); - - // Test! - string filename; - EXPECT_TRUE(db.FindNameOfFileContainingSymbol("foo.Foo", &filename)); - EXPECT_EQ("foo.proto", filename); - EXPECT_TRUE(db.FindNameOfFileContainingSymbol("foo.Foo.Blah", &filename)); - EXPECT_EQ("foo.proto", filename); - EXPECT_TRUE(db.FindNameOfFileContainingSymbol("bar.Bar", &filename)); - EXPECT_EQ("bar.proto", filename); - EXPECT_FALSE(db.FindNameOfFileContainingSymbol("foo", &filename)); - EXPECT_FALSE(db.FindNameOfFileContainingSymbol("bar", &filename)); - EXPECT_FALSE(db.FindNameOfFileContainingSymbol("baz.Baz", &filename)); -} - -// =================================================================== - -class MergedDescriptorDatabaseTest : public testing::Test { - protected: - MergedDescriptorDatabaseTest() - : forward_merged_(&database1_, &database2_), - reverse_merged_(&database2_, &database1_) {} - - virtual void SetUp() { - AddToDatabase(&database1_, - "name: \"foo.proto\" " - "message_type { name:\"Foo\" extension_range { start: 1 end: 100 } } " - "extension { name:\"foo_ext\" extendee: \".Foo\" number:3 " - " label:LABEL_OPTIONAL type:TYPE_INT32 } "); - AddToDatabase(&database2_, - "name: \"bar.proto\" " - "message_type { name:\"Bar\" extension_range { start: 1 end: 100 } } " - "extension { name:\"bar_ext\" extendee: \".Bar\" number:5 " - " label:LABEL_OPTIONAL type:TYPE_INT32 } "); - - // baz.proto exists in both pools, with different definitions. - AddToDatabase(&database1_, - "name: \"baz.proto\" " - "message_type { name:\"Baz\" extension_range { start: 1 end: 100 } } " - "message_type { name:\"FromPool1\" } " - "extension { name:\"baz_ext\" extendee: \".Baz\" number:12 " - " label:LABEL_OPTIONAL type:TYPE_INT32 } " - "extension { name:\"database1_only_ext\" extendee: \".Baz\" number:13 " - " label:LABEL_OPTIONAL type:TYPE_INT32 } "); - AddToDatabase(&database2_, - "name: \"baz.proto\" " - "message_type { name:\"Baz\" extension_range { start: 1 end: 100 } } " - "message_type { name:\"FromPool2\" } " - "extension { name:\"baz_ext\" extendee: \".Baz\" number:12 " - " label:LABEL_OPTIONAL type:TYPE_INT32 } "); - } - - SimpleDescriptorDatabase database1_; - SimpleDescriptorDatabase database2_; - - MergedDescriptorDatabase forward_merged_; - MergedDescriptorDatabase reverse_merged_; -}; - -TEST_F(MergedDescriptorDatabaseTest, FindFileByName) { - { - // Can find file that is only in database1_. - FileDescriptorProto file; - EXPECT_TRUE(forward_merged_.FindFileByName("foo.proto", &file)); - EXPECT_EQ("foo.proto", file.name()); - ExpectContainsType(file, "Foo"); - } - - { - // Can find file that is only in database2_. - FileDescriptorProto file; - EXPECT_TRUE(forward_merged_.FindFileByName("bar.proto", &file)); - EXPECT_EQ("bar.proto", file.name()); - ExpectContainsType(file, "Bar"); - } - - { - // In forward_merged_, database1_'s baz.proto takes precedence. - FileDescriptorProto file; - EXPECT_TRUE(forward_merged_.FindFileByName("baz.proto", &file)); - EXPECT_EQ("baz.proto", file.name()); - ExpectContainsType(file, "FromPool1"); - } - - { - // In reverse_merged_, database2_'s baz.proto takes precedence. - FileDescriptorProto file; - EXPECT_TRUE(reverse_merged_.FindFileByName("baz.proto", &file)); - EXPECT_EQ("baz.proto", file.name()); - ExpectContainsType(file, "FromPool2"); - } - - { - // Can't find non-existent file. - FileDescriptorProto file; - EXPECT_FALSE(forward_merged_.FindFileByName("no_such.proto", &file)); - } -} - -TEST_F(MergedDescriptorDatabaseTest, FindFileContainingSymbol) { - { - // Can find file that is only in database1_. - FileDescriptorProto file; - EXPECT_TRUE(forward_merged_.FindFileContainingSymbol("Foo", &file)); - EXPECT_EQ("foo.proto", file.name()); - ExpectContainsType(file, "Foo"); - } - - { - // Can find file that is only in database2_. - FileDescriptorProto file; - EXPECT_TRUE(forward_merged_.FindFileContainingSymbol("Bar", &file)); - EXPECT_EQ("bar.proto", file.name()); - ExpectContainsType(file, "Bar"); - } - - { - // In forward_merged_, database1_'s baz.proto takes precedence. - FileDescriptorProto file; - EXPECT_TRUE(forward_merged_.FindFileContainingSymbol("Baz", &file)); - EXPECT_EQ("baz.proto", file.name()); - ExpectContainsType(file, "FromPool1"); - } - - { - // In reverse_merged_, database2_'s baz.proto takes precedence. - FileDescriptorProto file; - EXPECT_TRUE(reverse_merged_.FindFileContainingSymbol("Baz", &file)); - EXPECT_EQ("baz.proto", file.name()); - ExpectContainsType(file, "FromPool2"); - } - - { - // FromPool1 only shows up in forward_merged_ because it is masked by - // database2_'s baz.proto in reverse_merged_. - FileDescriptorProto file; - EXPECT_TRUE(forward_merged_.FindFileContainingSymbol("FromPool1", &file)); - EXPECT_FALSE(reverse_merged_.FindFileContainingSymbol("FromPool1", &file)); - } - - { - // Can't find non-existent symbol. - FileDescriptorProto file; - EXPECT_FALSE( - forward_merged_.FindFileContainingSymbol("NoSuchType", &file)); - } -} - -TEST_F(MergedDescriptorDatabaseTest, FindFileContainingExtension) { - { - // Can find file that is only in database1_. - FileDescriptorProto file; - EXPECT_TRUE( - forward_merged_.FindFileContainingExtension("Foo", 3, &file)); - EXPECT_EQ("foo.proto", file.name()); - ExpectContainsType(file, "Foo"); - } - - { - // Can find file that is only in database2_. - FileDescriptorProto file; - EXPECT_TRUE( - forward_merged_.FindFileContainingExtension("Bar", 5, &file)); - EXPECT_EQ("bar.proto", file.name()); - ExpectContainsType(file, "Bar"); - } - - { - // In forward_merged_, database1_'s baz.proto takes precedence. - FileDescriptorProto file; - EXPECT_TRUE( - forward_merged_.FindFileContainingExtension("Baz", 12, &file)); - EXPECT_EQ("baz.proto", file.name()); - ExpectContainsType(file, "FromPool1"); - } - - { - // In reverse_merged_, database2_'s baz.proto takes precedence. - FileDescriptorProto file; - EXPECT_TRUE( - reverse_merged_.FindFileContainingExtension("Baz", 12, &file)); - EXPECT_EQ("baz.proto", file.name()); - ExpectContainsType(file, "FromPool2"); - } - - { - // Baz's extension 13 only shows up in forward_merged_ because it is - // masked by database2_'s baz.proto in reverse_merged_. - FileDescriptorProto file; - EXPECT_TRUE(forward_merged_.FindFileContainingExtension("Baz", 13, &file)); - EXPECT_FALSE(reverse_merged_.FindFileContainingExtension("Baz", 13, &file)); - } - - { - // Can't find non-existent extension. - FileDescriptorProto file; - EXPECT_FALSE( - forward_merged_.FindFileContainingExtension("Foo", 6, &file)); - } -} - -TEST_F(MergedDescriptorDatabaseTest, FindAllExtensionNumbers) { - { - // Message only has extension in database1_ - vector numbers; - EXPECT_TRUE(forward_merged_.FindAllExtensionNumbers("Foo", &numbers)); - ASSERT_EQ(1, numbers.size()); - EXPECT_EQ(3, numbers[0]); - } - - { - // Message only has extension in database2_ - vector numbers; - EXPECT_TRUE(forward_merged_.FindAllExtensionNumbers("Bar", &numbers)); - ASSERT_EQ(1, numbers.size()); - EXPECT_EQ(5, numbers[0]); - } - - { - // Merge results from the two databases. - vector numbers; - EXPECT_TRUE(forward_merged_.FindAllExtensionNumbers("Baz", &numbers)); - ASSERT_EQ(2, numbers.size()); - sort(numbers.begin(), numbers.end()); - EXPECT_EQ(12, numbers[0]); - EXPECT_EQ(13, numbers[1]); - } - - { - vector numbers; - EXPECT_TRUE(reverse_merged_.FindAllExtensionNumbers("Baz", &numbers)); - ASSERT_EQ(2, numbers.size()); - sort(numbers.begin(), numbers.end()); - EXPECT_EQ(12, numbers[0]); - EXPECT_EQ(13, numbers[1]); - } - - { - // Can't find extensions for a non-existent message. - vector numbers; - EXPECT_FALSE(reverse_merged_.FindAllExtensionNumbers("Blah", &numbers)); - } -} - -} // anonymous namespace -} // namespace protobuf -} // namespace google diff --git a/modules/dnn/3rdparty/protobuf/src/google/protobuf/descriptor_unittest.cc b/modules/dnn/3rdparty/protobuf/src/google/protobuf/descriptor_unittest.cc deleted file mode 100644 index 86e6a49d8..000000000 --- a/modules/dnn/3rdparty/protobuf/src/google/protobuf/descriptor_unittest.cc +++ /dev/null @@ -1,4656 +0,0 @@ -// Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// http://code.google.com/p/protobuf/ -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -// Author: kenton@google.com (Kenton Varda) -// Based on original Protocol Buffers design by -// Sanjay Ghemawat, Jeff Dean, and others. -// -// This file makes extensive use of RFC 3092. :) - -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -namespace google { -namespace protobuf { - -// Can't use an anonymous namespace here due to brokenness of Tru64 compiler. -namespace descriptor_unittest { - -// Some helpers to make assembling descriptors faster. -DescriptorProto* AddMessage(FileDescriptorProto* file, const string& name) { - DescriptorProto* result = file->add_message_type(); - result->set_name(name); - return result; -} - -DescriptorProto* AddNestedMessage(DescriptorProto* parent, const string& name) { - DescriptorProto* result = parent->add_nested_type(); - result->set_name(name); - return result; -} - -EnumDescriptorProto* AddEnum(FileDescriptorProto* file, const string& name) { - EnumDescriptorProto* result = file->add_enum_type(); - result->set_name(name); - return result; -} - -EnumDescriptorProto* AddNestedEnum(DescriptorProto* parent, - const string& name) { - EnumDescriptorProto* result = parent->add_enum_type(); - result->set_name(name); - return result; -} - -ServiceDescriptorProto* AddService(FileDescriptorProto* file, - const string& name) { - ServiceDescriptorProto* result = file->add_service(); - result->set_name(name); - return result; -} - -FieldDescriptorProto* AddField(DescriptorProto* parent, - const string& name, int number, - FieldDescriptorProto::Label label, - FieldDescriptorProto::Type type) { - FieldDescriptorProto* result = parent->add_field(); - result->set_name(name); - result->set_number(number); - result->set_label(label); - result->set_type(type); - return result; -} - -FieldDescriptorProto* AddExtension(FileDescriptorProto* file, - const string& extendee, - const string& name, int number, - FieldDescriptorProto::Label label, - FieldDescriptorProto::Type type) { - FieldDescriptorProto* result = file->add_extension(); - result->set_name(name); - result->set_number(number); - result->set_label(label); - result->set_type(type); - result->set_extendee(extendee); - return result; -} - -FieldDescriptorProto* AddNestedExtension(DescriptorProto* parent, - const string& extendee, - const string& name, int number, - FieldDescriptorProto::Label label, - FieldDescriptorProto::Type type) { - FieldDescriptorProto* result = parent->add_extension(); - result->set_name(name); - result->set_number(number); - result->set_label(label); - result->set_type(type); - result->set_extendee(extendee); - return result; -} - -DescriptorProto::ExtensionRange* AddExtensionRange(DescriptorProto* parent, - int start, int end) { - DescriptorProto::ExtensionRange* result = parent->add_extension_range(); - result->set_start(start); - result->set_end(end); - return result; -} - -EnumValueDescriptorProto* AddEnumValue(EnumDescriptorProto* enum_proto, - const string& name, int number) { - EnumValueDescriptorProto* result = enum_proto->add_value(); - result->set_name(name); - result->set_number(number); - return result; -} - -MethodDescriptorProto* AddMethod(ServiceDescriptorProto* service, - const string& name, - const string& input_type, - const string& output_type) { - MethodDescriptorProto* result = service->add_method(); - result->set_name(name); - result->set_input_type(input_type); - result->set_output_type(output_type); - return result; -} - -// Empty enums technically aren't allowed. We need to insert a dummy value -// into them. -void AddEmptyEnum(FileDescriptorProto* file, const string& name) { - AddEnumValue(AddEnum(file, name), name + "_DUMMY", 1); -} - -// =================================================================== - -// Test simple files. -class FileDescriptorTest : public testing::Test { - protected: - virtual void SetUp() { - // Build descriptors for the following definitions: - // - // // in "foo.proto" - // message FooMessage { extensions 1; } - // enum FooEnum {FOO_ENUM_VALUE = 1;} - // service FooService {} - // extend FooMessage { optional int32 foo_extension = 1; } - // - // // in "bar.proto" - // package bar_package; - // message BarMessage { extensions 1; } - // enum BarEnum {BAR_ENUM_VALUE = 1;} - // service BarService {} - // extend BarMessage { optional int32 bar_extension = 1; } - // - // Also, we have an empty file "baz.proto". This file's purpose is to - // make sure that even though it has the same package as foo.proto, - // searching it for members of foo.proto won't work. - - FileDescriptorProto foo_file; - foo_file.set_name("foo.proto"); - AddExtensionRange(AddMessage(&foo_file, "FooMessage"), 1, 2); - AddEnumValue(AddEnum(&foo_file, "FooEnum"), "FOO_ENUM_VALUE", 1); - AddService(&foo_file, "FooService"); - AddExtension(&foo_file, "FooMessage", "foo_extension", 1, - FieldDescriptorProto::LABEL_OPTIONAL, - FieldDescriptorProto::TYPE_INT32); - - FileDescriptorProto bar_file; - bar_file.set_name("bar.proto"); - bar_file.set_package("bar_package"); - bar_file.add_dependency("foo.proto"); - AddExtensionRange(AddMessage(&bar_file, "BarMessage"), 1, 2); - AddEnumValue(AddEnum(&bar_file, "BarEnum"), "BAR_ENUM_VALUE", 1); - AddService(&bar_file, "BarService"); - AddExtension(&bar_file, "bar_package.BarMessage", "bar_extension", 1, - FieldDescriptorProto::LABEL_OPTIONAL, - FieldDescriptorProto::TYPE_INT32); - - FileDescriptorProto baz_file; - baz_file.set_name("baz.proto"); - - // Build the descriptors and get the pointers. - foo_file_ = pool_.BuildFile(foo_file); - ASSERT_TRUE(foo_file_ != NULL); - - bar_file_ = pool_.BuildFile(bar_file); - ASSERT_TRUE(bar_file_ != NULL); - - baz_file_ = pool_.BuildFile(baz_file); - ASSERT_TRUE(baz_file_ != NULL); - - ASSERT_EQ(1, foo_file_->message_type_count()); - foo_message_ = foo_file_->message_type(0); - ASSERT_EQ(1, foo_file_->enum_type_count()); - foo_enum_ = foo_file_->enum_type(0); - ASSERT_EQ(1, foo_enum_->value_count()); - foo_enum_value_ = foo_enum_->value(0); - ASSERT_EQ(1, foo_file_->service_count()); - foo_service_ = foo_file_->service(0); - ASSERT_EQ(1, foo_file_->extension_count()); - foo_extension_ = foo_file_->extension(0); - - ASSERT_EQ(1, bar_file_->message_type_count()); - bar_message_ = bar_file_->message_type(0); - ASSERT_EQ(1, bar_file_->enum_type_count()); - bar_enum_ = bar_file_->enum_type(0); - ASSERT_EQ(1, bar_enum_->value_count()); - bar_enum_value_ = bar_enum_->value(0); - ASSERT_EQ(1, bar_file_->service_count()); - bar_service_ = bar_file_->service(0); - ASSERT_EQ(1, bar_file_->extension_count()); - bar_extension_ = bar_file_->extension(0); - } - - DescriptorPool pool_; - - const FileDescriptor* foo_file_; - const FileDescriptor* bar_file_; - const FileDescriptor* baz_file_; - - const Descriptor* foo_message_; - const EnumDescriptor* foo_enum_; - const EnumValueDescriptor* foo_enum_value_; - const ServiceDescriptor* foo_service_; - const FieldDescriptor* foo_extension_; - - const Descriptor* bar_message_; - const EnumDescriptor* bar_enum_; - const EnumValueDescriptor* bar_enum_value_; - const ServiceDescriptor* bar_service_; - const FieldDescriptor* bar_extension_; -}; - -TEST_F(FileDescriptorTest, Name) { - EXPECT_EQ("foo.proto", foo_file_->name()); - EXPECT_EQ("bar.proto", bar_file_->name()); - EXPECT_EQ("baz.proto", baz_file_->name()); -} - -TEST_F(FileDescriptorTest, Package) { - EXPECT_EQ("", foo_file_->package()); - EXPECT_EQ("bar_package", bar_file_->package()); -} - -TEST_F(FileDescriptorTest, Dependencies) { - EXPECT_EQ(0, foo_file_->dependency_count()); - EXPECT_EQ(1, bar_file_->dependency_count()); - EXPECT_EQ(foo_file_, bar_file_->dependency(0)); -} - -TEST_F(FileDescriptorTest, FindMessageTypeByName) { - EXPECT_EQ(foo_message_, foo_file_->FindMessageTypeByName("FooMessage")); - EXPECT_EQ(bar_message_, bar_file_->FindMessageTypeByName("BarMessage")); - - EXPECT_TRUE(foo_file_->FindMessageTypeByName("BarMessage") == NULL); - EXPECT_TRUE(bar_file_->FindMessageTypeByName("FooMessage") == NULL); - EXPECT_TRUE(baz_file_->FindMessageTypeByName("FooMessage") == NULL); - - EXPECT_TRUE(foo_file_->FindMessageTypeByName("NoSuchMessage") == NULL); - EXPECT_TRUE(foo_file_->FindMessageTypeByName("FooEnum") == NULL); -} - -TEST_F(FileDescriptorTest, FindEnumTypeByName) { - EXPECT_EQ(foo_enum_, foo_file_->FindEnumTypeByName("FooEnum")); - EXPECT_EQ(bar_enum_, bar_file_->FindEnumTypeByName("BarEnum")); - - EXPECT_TRUE(foo_file_->FindEnumTypeByName("BarEnum") == NULL); - EXPECT_TRUE(bar_file_->FindEnumTypeByName("FooEnum") == NULL); - EXPECT_TRUE(baz_file_->FindEnumTypeByName("FooEnum") == NULL); - - EXPECT_TRUE(foo_file_->FindEnumTypeByName("NoSuchEnum") == NULL); - EXPECT_TRUE(foo_file_->FindEnumTypeByName("FooMessage") == NULL); -} - -TEST_F(FileDescriptorTest, FindEnumValueByName) { - EXPECT_EQ(foo_enum_value_, foo_file_->FindEnumValueByName("FOO_ENUM_VALUE")); - EXPECT_EQ(bar_enum_value_, bar_file_->FindEnumValueByName("BAR_ENUM_VALUE")); - - EXPECT_TRUE(foo_file_->FindEnumValueByName("BAR_ENUM_VALUE") == NULL); - EXPECT_TRUE(bar_file_->FindEnumValueByName("FOO_ENUM_VALUE") == NULL); - EXPECT_TRUE(baz_file_->FindEnumValueByName("FOO_ENUM_VALUE") == NULL); - - EXPECT_TRUE(foo_file_->FindEnumValueByName("NO_SUCH_VALUE") == NULL); - EXPECT_TRUE(foo_file_->FindEnumValueByName("FooMessage") == NULL); -} - -TEST_F(FileDescriptorTest, FindServiceByName) { - EXPECT_EQ(foo_service_, foo_file_->FindServiceByName("FooService")); - EXPECT_EQ(bar_service_, bar_file_->FindServiceByName("BarService")); - - EXPECT_TRUE(foo_file_->FindServiceByName("BarService") == NULL); - EXPECT_TRUE(bar_file_->FindServiceByName("FooService") == NULL); - EXPECT_TRUE(baz_file_->FindServiceByName("FooService") == NULL); - - EXPECT_TRUE(foo_file_->FindServiceByName("NoSuchService") == NULL); - EXPECT_TRUE(foo_file_->FindServiceByName("FooMessage") == NULL); -} - -TEST_F(FileDescriptorTest, FindExtensionByName) { - EXPECT_EQ(foo_extension_, foo_file_->FindExtensionByName("foo_extension")); - EXPECT_EQ(bar_extension_, bar_file_->FindExtensionByName("bar_extension")); - - EXPECT_TRUE(foo_file_->FindExtensionByName("bar_extension") == NULL); - EXPECT_TRUE(bar_file_->FindExtensionByName("foo_extension") == NULL); - EXPECT_TRUE(baz_file_->FindExtensionByName("foo_extension") == NULL); - - EXPECT_TRUE(foo_file_->FindExtensionByName("no_such_extension") == NULL); - EXPECT_TRUE(foo_file_->FindExtensionByName("FooMessage") == NULL); -} - -TEST_F(FileDescriptorTest, FindExtensionByNumber) { - EXPECT_EQ(foo_extension_, pool_.FindExtensionByNumber(foo_message_, 1)); - EXPECT_EQ(bar_extension_, pool_.FindExtensionByNumber(bar_message_, 1)); - - EXPECT_TRUE(pool_.FindExtensionByNumber(foo_message_, 2) == NULL); -} - -TEST_F(FileDescriptorTest, BuildAgain) { - // Test that if te call BuildFile again on the same input we get the same - // FileDescriptor back. - FileDescriptorProto file; - foo_file_->CopyTo(&file); - EXPECT_EQ(foo_file_, pool_.BuildFile(file)); - - // But if we change the file then it won't work. - file.set_package("some.other.package"); - EXPECT_TRUE(pool_.BuildFile(file) == NULL); -} - -// =================================================================== - -// Test simple flat messages and fields. -class DescriptorTest : public testing::Test { - protected: - virtual void SetUp() { - // Build descriptors for the following definitions: - // - // // in "foo.proto" - // message TestForeign {} - // enum TestEnum {} - // - // message TestMessage { - // required string foo = 1; - // optional TestEnum bar = 6; - // repeated TestForeign baz = 500000000; - // optional group qux = 15 {} - // } - // - // // in "bar.proto" - // package corge.grault; - // message TestMessage2 { - // required string foo = 1; - // required string bar = 2; - // required string quux = 6; - // } - // - // We cheat and use TestForeign as the type for qux rather than create - // an actual nested type. - // - // Since all primitive types (including string) use the same building - // code, there's no need to test each one individually. - // - // TestMessage2 is primarily here to test FindFieldByName and friends. - // All messages created from the same DescriptorPool share the same lookup - // table, so we need to insure that they don't interfere. - - FileDescriptorProto foo_file; - foo_file.set_name("foo.proto"); - AddMessage(&foo_file, "TestForeign"); - AddEmptyEnum(&foo_file, "TestEnum"); - - DescriptorProto* message = AddMessage(&foo_file, "TestMessage"); - AddField(message, "foo", 1, - FieldDescriptorProto::LABEL_REQUIRED, - FieldDescriptorProto::TYPE_STRING); - AddField(message, "bar", 6, - FieldDescriptorProto::LABEL_OPTIONAL, - FieldDescriptorProto::TYPE_ENUM) - ->set_type_name("TestEnum"); - AddField(message, "baz", 500000000, - FieldDescriptorProto::LABEL_REPEATED, - FieldDescriptorProto::TYPE_MESSAGE) - ->set_type_name("TestForeign"); - AddField(message, "qux", 15, - FieldDescriptorProto::LABEL_OPTIONAL, - FieldDescriptorProto::TYPE_GROUP) - ->set_type_name("TestForeign"); - - FileDescriptorProto bar_file; - bar_file.set_name("bar.proto"); - bar_file.set_package("corge.grault"); - - DescriptorProto* message2 = AddMessage(&bar_file, "TestMessage2"); - AddField(message2, "foo", 1, - FieldDescriptorProto::LABEL_REQUIRED, - FieldDescriptorProto::TYPE_STRING); - AddField(message2, "bar", 2, - FieldDescriptorProto::LABEL_REQUIRED, - FieldDescriptorProto::TYPE_STRING); - AddField(message2, "quux", 6, - FieldDescriptorProto::LABEL_REQUIRED, - FieldDescriptorProto::TYPE_STRING); - - // Build the descriptors and get the pointers. - foo_file_ = pool_.BuildFile(foo_file); - ASSERT_TRUE(foo_file_ != NULL); - - bar_file_ = pool_.BuildFile(bar_file); - ASSERT_TRUE(bar_file_ != NULL); - - ASSERT_EQ(1, foo_file_->enum_type_count()); - enum_ = foo_file_->enum_type(0); - - ASSERT_EQ(2, foo_file_->message_type_count()); - foreign_ = foo_file_->message_type(0); - message_ = foo_file_->message_type(1); - - ASSERT_EQ(4, message_->field_count()); - foo_ = message_->field(0); - bar_ = message_->field(1); - baz_ = message_->field(2); - qux_ = message_->field(3); - - ASSERT_EQ(1, bar_file_->message_type_count()); - message2_ = bar_file_->message_type(0); - - ASSERT_EQ(3, message2_->field_count()); - foo2_ = message2_->field(0); - bar2_ = message2_->field(1); - quux2_ = message2_->field(2); - } - - DescriptorPool pool_; - - const FileDescriptor* foo_file_; - const FileDescriptor* bar_file_; - - const Descriptor* message_; - const Descriptor* message2_; - const Descriptor* foreign_; - const EnumDescriptor* enum_; - - const FieldDescriptor* foo_; - const FieldDescriptor* bar_; - const FieldDescriptor* baz_; - const FieldDescriptor* qux_; - - const FieldDescriptor* foo2_; - const FieldDescriptor* bar2_; - const FieldDescriptor* quux2_; -}; - -TEST_F(DescriptorTest, Name) { - EXPECT_EQ("TestMessage", message_->name()); - EXPECT_EQ("TestMessage", message_->full_name()); - EXPECT_EQ(foo_file_, message_->file()); - - EXPECT_EQ("TestMessage2", message2_->name()); - EXPECT_EQ("corge.grault.TestMessage2", message2_->full_name()); - EXPECT_EQ(bar_file_, message2_->file()); -} - -TEST_F(DescriptorTest, ContainingType) { - EXPECT_TRUE(message_->containing_type() == NULL); - EXPECT_TRUE(message2_->containing_type() == NULL); -} - -TEST_F(DescriptorTest, FieldsByIndex) { - ASSERT_EQ(4, message_->field_count()); - EXPECT_EQ(foo_, message_->field(0)); - EXPECT_EQ(bar_, message_->field(1)); - EXPECT_EQ(baz_, message_->field(2)); - EXPECT_EQ(qux_, message_->field(3)); -} - -TEST_F(DescriptorTest, FindFieldByName) { - // All messages in the same DescriptorPool share a single lookup table for - // fields. So, in addition to testing that FindFieldByName finds the fields - // of the message, we need to test that it does *not* find the fields of - // *other* messages. - - EXPECT_EQ(foo_, message_->FindFieldByName("foo")); - EXPECT_EQ(bar_, message_->FindFieldByName("bar")); - EXPECT_EQ(baz_, message_->FindFieldByName("baz")); - EXPECT_EQ(qux_, message_->FindFieldByName("qux")); - EXPECT_TRUE(message_->FindFieldByName("no_such_field") == NULL); - EXPECT_TRUE(message_->FindFieldByName("quux") == NULL); - - EXPECT_EQ(foo2_ , message2_->FindFieldByName("foo" )); - EXPECT_EQ(bar2_ , message2_->FindFieldByName("bar" )); - EXPECT_EQ(quux2_, message2_->FindFieldByName("quux")); - EXPECT_TRUE(message2_->FindFieldByName("baz") == NULL); - EXPECT_TRUE(message2_->FindFieldByName("qux") == NULL); -} - -TEST_F(DescriptorTest, FindFieldByNumber) { - EXPECT_EQ(foo_, message_->FindFieldByNumber(1)); - EXPECT_EQ(bar_, message_->FindFieldByNumber(6)); - EXPECT_EQ(baz_, message_->FindFieldByNumber(500000000)); - EXPECT_EQ(qux_, message_->FindFieldByNumber(15)); - EXPECT_TRUE(message_->FindFieldByNumber(837592) == NULL); - EXPECT_TRUE(message_->FindFieldByNumber(2) == NULL); - - EXPECT_EQ(foo2_ , message2_->FindFieldByNumber(1)); - EXPECT_EQ(bar2_ , message2_->FindFieldByNumber(2)); - EXPECT_EQ(quux2_, message2_->FindFieldByNumber(6)); - EXPECT_TRUE(message2_->FindFieldByNumber(15) == NULL); - EXPECT_TRUE(message2_->FindFieldByNumber(500000000) == NULL); -} - -TEST_F(DescriptorTest, FieldName) { - EXPECT_EQ("foo", foo_->name()); - EXPECT_EQ("bar", bar_->name()); - EXPECT_EQ("baz", baz_->name()); - EXPECT_EQ("qux", qux_->name()); -} - -TEST_F(DescriptorTest, FieldFullName) { - EXPECT_EQ("TestMessage.foo", foo_->full_name()); - EXPECT_EQ("TestMessage.bar", bar_->full_name()); - EXPECT_EQ("TestMessage.baz", baz_->full_name()); - EXPECT_EQ("TestMessage.qux", qux_->full_name()); - - EXPECT_EQ("corge.grault.TestMessage2.foo", foo2_->full_name()); - EXPECT_EQ("corge.grault.TestMessage2.bar", bar2_->full_name()); - EXPECT_EQ("corge.grault.TestMessage2.quux", quux2_->full_name()); -} - -TEST_F(DescriptorTest, FieldFile) { - EXPECT_EQ(foo_file_, foo_->file()); - EXPECT_EQ(foo_file_, bar_->file()); - EXPECT_EQ(foo_file_, baz_->file()); - EXPECT_EQ(foo_file_, qux_->file()); - - EXPECT_EQ(bar_file_, foo2_->file()); - EXPECT_EQ(bar_file_, bar2_->file()); - EXPECT_EQ(bar_file_, quux2_->file()); -} - -TEST_F(DescriptorTest, FieldIndex) { - EXPECT_EQ(0, foo_->index()); - EXPECT_EQ(1, bar_->index()); - EXPECT_EQ(2, baz_->index()); - EXPECT_EQ(3, qux_->index()); -} - -TEST_F(DescriptorTest, FieldNumber) { - EXPECT_EQ( 1, foo_->number()); - EXPECT_EQ( 6, bar_->number()); - EXPECT_EQ(500000000, baz_->number()); - EXPECT_EQ( 15, qux_->number()); -} - -TEST_F(DescriptorTest, FieldType) { - EXPECT_EQ(FieldDescriptor::TYPE_STRING , foo_->type()); - EXPECT_EQ(FieldDescriptor::TYPE_ENUM , bar_->type()); - EXPECT_EQ(FieldDescriptor::TYPE_MESSAGE, baz_->type()); - EXPECT_EQ(FieldDescriptor::TYPE_GROUP , qux_->type()); -} - -TEST_F(DescriptorTest, FieldLabel) { - EXPECT_EQ(FieldDescriptor::LABEL_REQUIRED, foo_->label()); - EXPECT_EQ(FieldDescriptor::LABEL_OPTIONAL, bar_->label()); - EXPECT_EQ(FieldDescriptor::LABEL_REPEATED, baz_->label()); - EXPECT_EQ(FieldDescriptor::LABEL_OPTIONAL, qux_->label()); - - EXPECT_TRUE (foo_->is_required()); - EXPECT_FALSE(foo_->is_optional()); - EXPECT_FALSE(foo_->is_repeated()); - - EXPECT_FALSE(bar_->is_required()); - EXPECT_TRUE (bar_->is_optional()); - EXPECT_FALSE(bar_->is_repeated()); - - EXPECT_FALSE(baz_->is_required()); - EXPECT_FALSE(baz_->is_optional()); - EXPECT_TRUE (baz_->is_repeated()); -} - -TEST_F(DescriptorTest, FieldHasDefault) { - EXPECT_FALSE(foo_->has_default_value()); - EXPECT_FALSE(bar_->has_default_value()); - EXPECT_FALSE(baz_->has_default_value()); - EXPECT_FALSE(qux_->has_default_value()); -} - -TEST_F(DescriptorTest, FieldContainingType) { - EXPECT_EQ(message_, foo_->containing_type()); - EXPECT_EQ(message_, bar_->containing_type()); - EXPECT_EQ(message_, baz_->containing_type()); - EXPECT_EQ(message_, qux_->containing_type()); - - EXPECT_EQ(message2_, foo2_ ->containing_type()); - EXPECT_EQ(message2_, bar2_ ->containing_type()); - EXPECT_EQ(message2_, quux2_->containing_type()); -} - -TEST_F(DescriptorTest, FieldMessageType) { - EXPECT_TRUE(foo_->message_type() == NULL); - EXPECT_TRUE(bar_->message_type() == NULL); - - EXPECT_EQ(foreign_, baz_->message_type()); - EXPECT_EQ(foreign_, qux_->message_type()); -} - -TEST_F(DescriptorTest, FieldEnumType) { - EXPECT_TRUE(foo_->enum_type() == NULL); - EXPECT_TRUE(baz_->enum_type() == NULL); - EXPECT_TRUE(qux_->enum_type() == NULL); - - EXPECT_EQ(enum_, bar_->enum_type()); -} - -// =================================================================== - -class StylizedFieldNamesTest : public testing::Test { - protected: - void SetUp() { - FileDescriptorProto file; - file.set_name("foo.proto"); - - AddExtensionRange(AddMessage(&file, "ExtendableMessage"), 1, 1000); - - DescriptorProto* message = AddMessage(&file, "TestMessage"); - AddField(message, "foo_foo", 1, - FieldDescriptorProto::LABEL_OPTIONAL, - FieldDescriptorProto::TYPE_INT32); - AddField(message, "FooBar", 2, - FieldDescriptorProto::LABEL_OPTIONAL, - FieldDescriptorProto::TYPE_INT32); - AddField(message, "fooBaz", 3, - FieldDescriptorProto::LABEL_OPTIONAL, - FieldDescriptorProto::TYPE_INT32); - AddField(message, "fooFoo", 4, // Camel-case conflict with foo_foo. - FieldDescriptorProto::LABEL_OPTIONAL, - FieldDescriptorProto::TYPE_INT32); - AddField(message, "foobar", 5, // Lower-case conflict with FooBar. - FieldDescriptorProto::LABEL_OPTIONAL, - FieldDescriptorProto::TYPE_INT32); - - AddNestedExtension(message, "ExtendableMessage", "bar_foo", 1, - FieldDescriptorProto::LABEL_OPTIONAL, - FieldDescriptorProto::TYPE_INT32); - AddNestedExtension(message, "ExtendableMessage", "BarBar", 2, - FieldDescriptorProto::LABEL_OPTIONAL, - FieldDescriptorProto::TYPE_INT32); - AddNestedExtension(message, "ExtendableMessage", "BarBaz", 3, - FieldDescriptorProto::LABEL_OPTIONAL, - FieldDescriptorProto::TYPE_INT32); - AddNestedExtension(message, "ExtendableMessage", "barFoo", 4, // Conflict - FieldDescriptorProto::LABEL_OPTIONAL, - FieldDescriptorProto::TYPE_INT32); - AddNestedExtension(message, "ExtendableMessage", "barbar", 5, // Conflict - FieldDescriptorProto::LABEL_OPTIONAL, - FieldDescriptorProto::TYPE_INT32); - - AddExtension(&file, "ExtendableMessage", "baz_foo", 11, - FieldDescriptorProto::LABEL_OPTIONAL, - FieldDescriptorProto::TYPE_INT32); - AddExtension(&file, "ExtendableMessage", "BazBar", 12, - FieldDescriptorProto::LABEL_OPTIONAL, - FieldDescriptorProto::TYPE_INT32); - AddExtension(&file, "ExtendableMessage", "BazBaz", 13, - FieldDescriptorProto::LABEL_OPTIONAL, - FieldDescriptorProto::TYPE_INT32); - AddExtension(&file, "ExtendableMessage", "bazFoo", 14, // Conflict - FieldDescriptorProto::LABEL_OPTIONAL, - FieldDescriptorProto::TYPE_INT32); - AddExtension(&file, "ExtendableMessage", "bazbar", 15, // Conflict - FieldDescriptorProto::LABEL_OPTIONAL, - FieldDescriptorProto::TYPE_INT32); - - file_ = pool_.BuildFile(file); - ASSERT_TRUE(file_ != NULL); - ASSERT_EQ(2, file_->message_type_count()); - message_ = file_->message_type(1); - ASSERT_EQ("TestMessage", message_->name()); - ASSERT_EQ(5, message_->field_count()); - ASSERT_EQ(5, message_->extension_count()); - ASSERT_EQ(5, file_->extension_count()); - } - - DescriptorPool pool_; - const FileDescriptor* file_; - const Descriptor* message_; -}; - -TEST_F(StylizedFieldNamesTest, LowercaseName) { - EXPECT_EQ("foo_foo", message_->field(0)->lowercase_name()); - EXPECT_EQ("foobar" , message_->field(1)->lowercase_name()); - EXPECT_EQ("foobaz" , message_->field(2)->lowercase_name()); - EXPECT_EQ("foofoo" , message_->field(3)->lowercase_name()); - EXPECT_EQ("foobar" , message_->field(4)->lowercase_name()); - - EXPECT_EQ("bar_foo", message_->extension(0)->lowercase_name()); - EXPECT_EQ("barbar" , message_->extension(1)->lowercase_name()); - EXPECT_EQ("barbaz" , message_->extension(2)->lowercase_name()); - EXPECT_EQ("barfoo" , message_->extension(3)->lowercase_name()); - EXPECT_EQ("barbar" , message_->extension(4)->lowercase_name()); - - EXPECT_EQ("baz_foo", file_->extension(0)->lowercase_name()); - EXPECT_EQ("bazbar" , file_->extension(1)->lowercase_name()); - EXPECT_EQ("bazbaz" , file_->extension(2)->lowercase_name()); - EXPECT_EQ("bazfoo" , file_->extension(3)->lowercase_name()); - EXPECT_EQ("bazbar" , file_->extension(4)->lowercase_name()); -} - -TEST_F(StylizedFieldNamesTest, CamelcaseName) { - EXPECT_EQ("fooFoo", message_->field(0)->camelcase_name()); - EXPECT_EQ("fooBar", message_->field(1)->camelcase_name()); - EXPECT_EQ("fooBaz", message_->field(2)->camelcase_name()); - EXPECT_EQ("fooFoo", message_->field(3)->camelcase_name()); - EXPECT_EQ("foobar", message_->field(4)->camelcase_name()); - - EXPECT_EQ("barFoo", message_->extension(0)->camelcase_name()); - EXPECT_EQ("barBar", message_->extension(1)->camelcase_name()); - EXPECT_EQ("barBaz", message_->extension(2)->camelcase_name()); - EXPECT_EQ("barFoo", message_->extension(3)->camelcase_name()); - EXPECT_EQ("barbar", message_->extension(4)->camelcase_name()); - - EXPECT_EQ("bazFoo", file_->extension(0)->camelcase_name()); - EXPECT_EQ("bazBar", file_->extension(1)->camelcase_name()); - EXPECT_EQ("bazBaz", file_->extension(2)->camelcase_name()); - EXPECT_EQ("bazFoo", file_->extension(3)->camelcase_name()); - EXPECT_EQ("bazbar", file_->extension(4)->camelcase_name()); -} - -TEST_F(StylizedFieldNamesTest, FindByLowercaseName) { - EXPECT_EQ(message_->field(0), - message_->FindFieldByLowercaseName("foo_foo")); - EXPECT_EQ(message_->field(1), - message_->FindFieldByLowercaseName("foobar")); - EXPECT_EQ(message_->field(2), - message_->FindFieldByLowercaseName("foobaz")); - EXPECT_TRUE(message_->FindFieldByLowercaseName("FooBar") == NULL); - EXPECT_TRUE(message_->FindFieldByLowercaseName("fooBaz") == NULL); - EXPECT_TRUE(message_->FindFieldByLowercaseName("bar_foo") == NULL); - EXPECT_TRUE(message_->FindFieldByLowercaseName("nosuchfield") == NULL); - - EXPECT_EQ(message_->extension(0), - message_->FindExtensionByLowercaseName("bar_foo")); - EXPECT_EQ(message_->extension(1), - message_->FindExtensionByLowercaseName("barbar")); - EXPECT_EQ(message_->extension(2), - message_->FindExtensionByLowercaseName("barbaz")); - EXPECT_TRUE(message_->FindExtensionByLowercaseName("BarBar") == NULL); - EXPECT_TRUE(message_->FindExtensionByLowercaseName("barBaz") == NULL); - EXPECT_TRUE(message_->FindExtensionByLowercaseName("foo_foo") == NULL); - EXPECT_TRUE(message_->FindExtensionByLowercaseName("nosuchfield") == NULL); - - EXPECT_EQ(file_->extension(0), - file_->FindExtensionByLowercaseName("baz_foo")); - EXPECT_EQ(file_->extension(1), - file_->FindExtensionByLowercaseName("bazbar")); - EXPECT_EQ(file_->extension(2), - file_->FindExtensionByLowercaseName("bazbaz")); - EXPECT_TRUE(file_->FindExtensionByLowercaseName("BazBar") == NULL); - EXPECT_TRUE(file_->FindExtensionByLowercaseName("bazBaz") == NULL); - EXPECT_TRUE(file_->FindExtensionByLowercaseName("nosuchfield") == NULL); -} - -TEST_F(StylizedFieldNamesTest, FindByCamelcaseName) { - EXPECT_EQ(message_->field(0), - message_->FindFieldByCamelcaseName("fooFoo")); - EXPECT_EQ(message_->field(1), - message_->FindFieldByCamelcaseName("fooBar")); - EXPECT_EQ(message_->field(2), - message_->FindFieldByCamelcaseName("fooBaz")); - EXPECT_TRUE(message_->FindFieldByCamelcaseName("foo_foo") == NULL); - EXPECT_TRUE(message_->FindFieldByCamelcaseName("FooBar") == NULL); - EXPECT_TRUE(message_->FindFieldByCamelcaseName("barFoo") == NULL); - EXPECT_TRUE(message_->FindFieldByCamelcaseName("nosuchfield") == NULL); - - EXPECT_EQ(message_->extension(0), - message_->FindExtensionByCamelcaseName("barFoo")); - EXPECT_EQ(message_->extension(1), - message_->FindExtensionByCamelcaseName("barBar")); - EXPECT_EQ(message_->extension(2), - message_->FindExtensionByCamelcaseName("barBaz")); - EXPECT_TRUE(message_->FindExtensionByCamelcaseName("bar_foo") == NULL); - EXPECT_TRUE(message_->FindExtensionByCamelcaseName("BarBar") == NULL); - EXPECT_TRUE(message_->FindExtensionByCamelcaseName("fooFoo") == NULL); - EXPECT_TRUE(message_->FindExtensionByCamelcaseName("nosuchfield") == NULL); - - EXPECT_EQ(file_->extension(0), - file_->FindExtensionByCamelcaseName("bazFoo")); - EXPECT_EQ(file_->extension(1), - file_->FindExtensionByCamelcaseName("bazBar")); - EXPECT_EQ(file_->extension(2), - file_->FindExtensionByCamelcaseName("bazBaz")); - EXPECT_TRUE(file_->FindExtensionByCamelcaseName("baz_foo") == NULL); - EXPECT_TRUE(file_->FindExtensionByCamelcaseName("BazBar") == NULL); - EXPECT_TRUE(file_->FindExtensionByCamelcaseName("nosuchfield") == NULL); -} - -// =================================================================== - -// Test enum descriptors. -class EnumDescriptorTest : public testing::Test { - protected: - virtual void SetUp() { - // Build descriptors for the following definitions: - // - // // in "foo.proto" - // enum TestEnum { - // FOO = 1; - // BAR = 2; - // } - // - // // in "bar.proto" - // package corge.grault; - // enum TestEnum2 { - // FOO = 1; - // BAZ = 3; - // } - // - // TestEnum2 is primarily here to test FindValueByName and friends. - // All enums created from the same DescriptorPool share the same lookup - // table, so we need to insure that they don't interfere. - - // TestEnum - FileDescriptorProto foo_file; - foo_file.set_name("foo.proto"); - - EnumDescriptorProto* enum_proto = AddEnum(&foo_file, "TestEnum"); - AddEnumValue(enum_proto, "FOO", 1); - AddEnumValue(enum_proto, "BAR", 2); - - // TestEnum2 - FileDescriptorProto bar_file; - bar_file.set_name("bar.proto"); - bar_file.set_package("corge.grault"); - - EnumDescriptorProto* enum2_proto = AddEnum(&bar_file, "TestEnum2"); - AddEnumValue(enum2_proto, "FOO", 1); - AddEnumValue(enum2_proto, "BAZ", 3); - - // Build the descriptors and get the pointers. - foo_file_ = pool_.BuildFile(foo_file); - ASSERT_TRUE(foo_file_ != NULL); - - bar_file_ = pool_.BuildFile(bar_file); - ASSERT_TRUE(bar_file_ != NULL); - - ASSERT_EQ(1, foo_file_->enum_type_count()); - enum_ = foo_file_->enum_type(0); - - ASSERT_EQ(2, enum_->value_count()); - foo_ = enum_->value(0); - bar_ = enum_->value(1); - - ASSERT_EQ(1, bar_file_->enum_type_count()); - enum2_ = bar_file_->enum_type(0); - - ASSERT_EQ(2, enum2_->value_count()); - foo2_ = enum2_->value(0); - baz2_ = enum2_->value(1); - } - - DescriptorPool pool_; - - const FileDescriptor* foo_file_; - const FileDescriptor* bar_file_; - - const EnumDescriptor* enum_; - const EnumDescriptor* enum2_; - - const EnumValueDescriptor* foo_; - const EnumValueDescriptor* bar_; - - const EnumValueDescriptor* foo2_; - const EnumValueDescriptor* baz2_; -}; - -TEST_F(EnumDescriptorTest, Name) { - EXPECT_EQ("TestEnum", enum_->name()); - EXPECT_EQ("TestEnum", enum_->full_name()); - EXPECT_EQ(foo_file_, enum_->file()); - - EXPECT_EQ("TestEnum2", enum2_->name()); - EXPECT_EQ("corge.grault.TestEnum2", enum2_->full_name()); - EXPECT_EQ(bar_file_, enum2_->file()); -} - -TEST_F(EnumDescriptorTest, ContainingType) { - EXPECT_TRUE(enum_->containing_type() == NULL); - EXPECT_TRUE(enum2_->containing_type() == NULL); -} - -TEST_F(EnumDescriptorTest, ValuesByIndex) { - ASSERT_EQ(2, enum_->value_count()); - EXPECT_EQ(foo_, enum_->value(0)); - EXPECT_EQ(bar_, enum_->value(1)); -} - -TEST_F(EnumDescriptorTest, FindValueByName) { - EXPECT_EQ(foo_ , enum_ ->FindValueByName("FOO")); - EXPECT_EQ(bar_ , enum_ ->FindValueByName("BAR")); - EXPECT_EQ(foo2_, enum2_->FindValueByName("FOO")); - EXPECT_EQ(baz2_, enum2_->FindValueByName("BAZ")); - - EXPECT_TRUE(enum_ ->FindValueByName("NO_SUCH_VALUE") == NULL); - EXPECT_TRUE(enum_ ->FindValueByName("BAZ" ) == NULL); - EXPECT_TRUE(enum2_->FindValueByName("BAR" ) == NULL); -} - -TEST_F(EnumDescriptorTest, FindValueByNumber) { - EXPECT_EQ(foo_ , enum_ ->FindValueByNumber(1)); - EXPECT_EQ(bar_ , enum_ ->FindValueByNumber(2)); - EXPECT_EQ(foo2_, enum2_->FindValueByNumber(1)); - EXPECT_EQ(baz2_, enum2_->FindValueByNumber(3)); - - EXPECT_TRUE(enum_ ->FindValueByNumber(416) == NULL); - EXPECT_TRUE(enum_ ->FindValueByNumber(3) == NULL); - EXPECT_TRUE(enum2_->FindValueByNumber(2) == NULL); -} - -TEST_F(EnumDescriptorTest, ValueName) { - EXPECT_EQ("FOO", foo_->name()); - EXPECT_EQ("BAR", bar_->name()); -} - -TEST_F(EnumDescriptorTest, ValueFullName) { - EXPECT_EQ("FOO", foo_->full_name()); - EXPECT_EQ("BAR", bar_->full_name()); - EXPECT_EQ("corge.grault.FOO", foo2_->full_name()); - EXPECT_EQ("corge.grault.BAZ", baz2_->full_name()); -} - -TEST_F(EnumDescriptorTest, ValueIndex) { - EXPECT_EQ(0, foo_->index()); - EXPECT_EQ(1, bar_->index()); -} - -TEST_F(EnumDescriptorTest, ValueNumber) { - EXPECT_EQ(1, foo_->number()); - EXPECT_EQ(2, bar_->number()); -} - -TEST_F(EnumDescriptorTest, ValueType) { - EXPECT_EQ(enum_ , foo_ ->type()); - EXPECT_EQ(enum_ , bar_ ->type()); - EXPECT_EQ(enum2_, foo2_->type()); - EXPECT_EQ(enum2_, baz2_->type()); -} - -// =================================================================== - -// Test service descriptors. -class ServiceDescriptorTest : public testing::Test { - protected: - virtual void SetUp() { - // Build descriptors for the following messages and service: - // // in "foo.proto" - // message FooRequest {} - // message FooResponse {} - // message BarRequest {} - // message BarResponse {} - // message BazRequest {} - // message BazResponse {} - // - // service TestService { - // rpc Foo(FooRequest) returns (FooResponse); - // rpc Bar(BarRequest) returns (BarResponse); - // } - // - // // in "bar.proto" - // package corge.grault - // service TestService2 { - // rpc Foo(FooRequest) returns (FooResponse); - // rpc Baz(BazRequest) returns (BazResponse); - // } - - FileDescriptorProto foo_file; - foo_file.set_name("foo.proto"); - - AddMessage(&foo_file, "FooRequest"); - AddMessage(&foo_file, "FooResponse"); - AddMessage(&foo_file, "BarRequest"); - AddMessage(&foo_file, "BarResponse"); - AddMessage(&foo_file, "BazRequest"); - AddMessage(&foo_file, "BazResponse"); - - ServiceDescriptorProto* service = AddService(&foo_file, "TestService"); - AddMethod(service, "Foo", "FooRequest", "FooResponse"); - AddMethod(service, "Bar", "BarRequest", "BarResponse"); - - FileDescriptorProto bar_file; - bar_file.set_name("bar.proto"); - bar_file.set_package("corge.grault"); - bar_file.add_dependency("foo.proto"); - - ServiceDescriptorProto* service2 = AddService(&bar_file, "TestService2"); - AddMethod(service2, "Foo", "FooRequest", "FooResponse"); - AddMethod(service2, "Baz", "BazRequest", "BazResponse"); - - // Build the descriptors and get the pointers. - foo_file_ = pool_.BuildFile(foo_file); - ASSERT_TRUE(foo_file_ != NULL); - - bar_file_ = pool_.BuildFile(bar_file); - ASSERT_TRUE(bar_file_ != NULL); - - ASSERT_EQ(6, foo_file_->message_type_count()); - foo_request_ = foo_file_->message_type(0); - foo_response_ = foo_file_->message_type(1); - bar_request_ = foo_file_->message_type(2); - bar_response_ = foo_file_->message_type(3); - baz_request_ = foo_file_->message_type(4); - baz_response_ = foo_file_->message_type(5); - - ASSERT_EQ(1, foo_file_->service_count()); - service_ = foo_file_->service(0); - - ASSERT_EQ(2, service_->method_count()); - foo_ = service_->method(0); - bar_ = service_->method(1); - - ASSERT_EQ(1, bar_file_->service_count()); - service2_ = bar_file_->service(0); - - ASSERT_EQ(2, service2_->method_count()); - foo2_ = service2_->method(0); - baz2_ = service2_->method(1); - } - - DescriptorPool pool_; - - const FileDescriptor* foo_file_; - const FileDescriptor* bar_file_; - - const Descriptor* foo_request_; - const Descriptor* foo_response_; - const Descriptor* bar_request_; - const Descriptor* bar_response_; - const Descriptor* baz_request_; - const Descriptor* baz_response_; - - const ServiceDescriptor* service_; - const ServiceDescriptor* service2_; - - const MethodDescriptor* foo_; - const MethodDescriptor* bar_; - - const MethodDescriptor* foo2_; - const MethodDescriptor* baz2_; -}; - -TEST_F(ServiceDescriptorTest, Name) { - EXPECT_EQ("TestService", service_->name()); - EXPECT_EQ("TestService", service_->full_name()); - EXPECT_EQ(foo_file_, service_->file()); - - EXPECT_EQ("TestService2", service2_->name()); - EXPECT_EQ("corge.grault.TestService2", service2_->full_name()); - EXPECT_EQ(bar_file_, service2_->file()); -} - -TEST_F(ServiceDescriptorTest, MethodsByIndex) { - ASSERT_EQ(2, service_->method_count()); - EXPECT_EQ(foo_, service_->method(0)); - EXPECT_EQ(bar_, service_->method(1)); -} - -TEST_F(ServiceDescriptorTest, FindMethodByName) { - EXPECT_EQ(foo_ , service_ ->FindMethodByName("Foo")); - EXPECT_EQ(bar_ , service_ ->FindMethodByName("Bar")); - EXPECT_EQ(foo2_, service2_->FindMethodByName("Foo")); - EXPECT_EQ(baz2_, service2_->FindMethodByName("Baz")); - - EXPECT_TRUE(service_ ->FindMethodByName("NoSuchMethod") == NULL); - EXPECT_TRUE(service_ ->FindMethodByName("Baz" ) == NULL); - EXPECT_TRUE(service2_->FindMethodByName("Bar" ) == NULL); -} - -TEST_F(ServiceDescriptorTest, MethodName) { - EXPECT_EQ("Foo", foo_->name()); - EXPECT_EQ("Bar", bar_->name()); -} - -TEST_F(ServiceDescriptorTest, MethodFullName) { - EXPECT_EQ("TestService.Foo", foo_->full_name()); - EXPECT_EQ("TestService.Bar", bar_->full_name()); - EXPECT_EQ("corge.grault.TestService2.Foo", foo2_->full_name()); - EXPECT_EQ("corge.grault.TestService2.Baz", baz2_->full_name()); -} - -TEST_F(ServiceDescriptorTest, MethodIndex) { - EXPECT_EQ(0, foo_->index()); - EXPECT_EQ(1, bar_->index()); -} - -TEST_F(ServiceDescriptorTest, MethodParent) { - EXPECT_EQ(service_, foo_->service()); - EXPECT_EQ(service_, bar_->service()); -} - -TEST_F(ServiceDescriptorTest, MethodInputType) { - EXPECT_EQ(foo_request_, foo_->input_type()); - EXPECT_EQ(bar_request_, bar_->input_type()); -} - -TEST_F(ServiceDescriptorTest, MethodOutputType) { - EXPECT_EQ(foo_response_, foo_->output_type()); - EXPECT_EQ(bar_response_, bar_->output_type()); -} - -// =================================================================== - -// Test nested types. -class NestedDescriptorTest : public testing::Test { - protected: - virtual void SetUp() { - // Build descriptors for the following definitions: - // - // // in "foo.proto" - // message TestMessage { - // message Foo {} - // message Bar {} - // enum Baz { A = 1; } - // enum Qux { B = 1; } - // } - // - // // in "bar.proto" - // package corge.grault; - // message TestMessage2 { - // message Foo {} - // message Baz {} - // enum Qux { A = 1; } - // enum Quux { C = 1; } - // } - // - // TestMessage2 is primarily here to test FindNestedTypeByName and friends. - // All messages created from the same DescriptorPool share the same lookup - // table, so we need to insure that they don't interfere. - // - // We add enum values to the enums in order to test searching for enum - // values across a message's scope. - - FileDescriptorProto foo_file; - foo_file.set_name("foo.proto"); - - DescriptorProto* message = AddMessage(&foo_file, "TestMessage"); - AddNestedMessage(message, "Foo"); - AddNestedMessage(message, "Bar"); - EnumDescriptorProto* baz = AddNestedEnum(message, "Baz"); - AddEnumValue(baz, "A", 1); - EnumDescriptorProto* qux = AddNestedEnum(message, "Qux"); - AddEnumValue(qux, "B", 1); - - FileDescriptorProto bar_file; - bar_file.set_name("bar.proto"); - bar_file.set_package("corge.grault"); - - DescriptorProto* message2 = AddMessage(&bar_file, "TestMessage2"); - AddNestedMessage(message2, "Foo"); - AddNestedMessage(message2, "Baz"); - EnumDescriptorProto* qux2 = AddNestedEnum(message2, "Qux"); - AddEnumValue(qux2, "A", 1); - EnumDescriptorProto* quux2 = AddNestedEnum(message2, "Quux"); - AddEnumValue(quux2, "C", 1); - - // Build the descriptors and get the pointers. - foo_file_ = pool_.BuildFile(foo_file); - ASSERT_TRUE(foo_file_ != NULL); - - bar_file_ = pool_.BuildFile(bar_file); - ASSERT_TRUE(bar_file_ != NULL); - - ASSERT_EQ(1, foo_file_->message_type_count()); - message_ = foo_file_->message_type(0); - - ASSERT_EQ(2, message_->nested_type_count()); - foo_ = message_->nested_type(0); - bar_ = message_->nested_type(1); - - ASSERT_EQ(2, message_->enum_type_count()); - baz_ = message_->enum_type(0); - qux_ = message_->enum_type(1); - - ASSERT_EQ(1, baz_->value_count()); - a_ = baz_->value(0); - ASSERT_EQ(1, qux_->value_count()); - b_ = qux_->value(0); - - ASSERT_EQ(1, bar_file_->message_type_count()); - message2_ = bar_file_->message_type(0); - - ASSERT_EQ(2, message2_->nested_type_count()); - foo2_ = message2_->nested_type(0); - baz2_ = message2_->nested_type(1); - - ASSERT_EQ(2, message2_->enum_type_count()); - qux2_ = message2_->enum_type(0); - quux2_ = message2_->enum_type(1); - - ASSERT_EQ(1, qux2_->value_count()); - a2_ = qux2_->value(0); - ASSERT_EQ(1, quux2_->value_count()); - c2_ = quux2_->value(0); - } - - DescriptorPool pool_; - - const FileDescriptor* foo_file_; - const FileDescriptor* bar_file_; - - const Descriptor* message_; - const Descriptor* message2_; - - const Descriptor* foo_; - const Descriptor* bar_; - const EnumDescriptor* baz_; - const EnumDescriptor* qux_; - const EnumValueDescriptor* a_; - const EnumValueDescriptor* b_; - - const Descriptor* foo2_; - const Descriptor* baz2_; - const EnumDescriptor* qux2_; - const EnumDescriptor* quux2_; - const EnumValueDescriptor* a2_; - const EnumValueDescriptor* c2_; -}; - -TEST_F(NestedDescriptorTest, MessageName) { - EXPECT_EQ("Foo", foo_ ->name()); - EXPECT_EQ("Bar", bar_ ->name()); - EXPECT_EQ("Foo", foo2_->name()); - EXPECT_EQ("Baz", baz2_->name()); - - EXPECT_EQ("TestMessage.Foo", foo_->full_name()); - EXPECT_EQ("TestMessage.Bar", bar_->full_name()); - EXPECT_EQ("corge.grault.TestMessage2.Foo", foo2_->full_name()); - EXPECT_EQ("corge.grault.TestMessage2.Baz", baz2_->full_name()); -} - -TEST_F(NestedDescriptorTest, MessageContainingType) { - EXPECT_EQ(message_ , foo_ ->containing_type()); - EXPECT_EQ(message_ , bar_ ->containing_type()); - EXPECT_EQ(message2_, foo2_->containing_type()); - EXPECT_EQ(message2_, baz2_->containing_type()); -} - -TEST_F(NestedDescriptorTest, NestedMessagesByIndex) { - ASSERT_EQ(2, message_->nested_type_count()); - EXPECT_EQ(foo_, message_->nested_type(0)); - EXPECT_EQ(bar_, message_->nested_type(1)); -} - -TEST_F(NestedDescriptorTest, FindFieldByNameDoesntFindNestedTypes) { - EXPECT_TRUE(message_->FindFieldByName("Foo") == NULL); - EXPECT_TRUE(message_->FindFieldByName("Qux") == NULL); - EXPECT_TRUE(message_->FindExtensionByName("Foo") == NULL); - EXPECT_TRUE(message_->FindExtensionByName("Qux") == NULL); -} - -TEST_F(NestedDescriptorTest, FindNestedTypeByName) { - EXPECT_EQ(foo_ , message_ ->FindNestedTypeByName("Foo")); - EXPECT_EQ(bar_ , message_ ->FindNestedTypeByName("Bar")); - EXPECT_EQ(foo2_, message2_->FindNestedTypeByName("Foo")); - EXPECT_EQ(baz2_, message2_->FindNestedTypeByName("Baz")); - - EXPECT_TRUE(message_ ->FindNestedTypeByName("NoSuchType") == NULL); - EXPECT_TRUE(message_ ->FindNestedTypeByName("Baz" ) == NULL); - EXPECT_TRUE(message2_->FindNestedTypeByName("Bar" ) == NULL); - - EXPECT_TRUE(message_->FindNestedTypeByName("Qux") == NULL); -} - -TEST_F(NestedDescriptorTest, EnumName) { - EXPECT_EQ("Baz" , baz_ ->name()); - EXPECT_EQ("Qux" , qux_ ->name()); - EXPECT_EQ("Qux" , qux2_->name()); - EXPECT_EQ("Quux", quux2_->name()); - - EXPECT_EQ("TestMessage.Baz", baz_->full_name()); - EXPECT_EQ("TestMessage.Qux", qux_->full_name()); - EXPECT_EQ("corge.grault.TestMessage2.Qux" , qux2_ ->full_name()); - EXPECT_EQ("corge.grault.TestMessage2.Quux", quux2_->full_name()); -} - -TEST_F(NestedDescriptorTest, EnumContainingType) { - EXPECT_EQ(message_ , baz_ ->containing_type()); - EXPECT_EQ(message_ , qux_ ->containing_type()); - EXPECT_EQ(message2_, qux2_ ->containing_type()); - EXPECT_EQ(message2_, quux2_->containing_type()); -} - -TEST_F(NestedDescriptorTest, NestedEnumsByIndex) { - ASSERT_EQ(2, message_->nested_type_count()); - EXPECT_EQ(foo_, message_->nested_type(0)); - EXPECT_EQ(bar_, message_->nested_type(1)); -} - -TEST_F(NestedDescriptorTest, FindEnumTypeByName) { - EXPECT_EQ(baz_ , message_ ->FindEnumTypeByName("Baz" )); - EXPECT_EQ(qux_ , message_ ->FindEnumTypeByName("Qux" )); - EXPECT_EQ(qux2_ , message2_->FindEnumTypeByName("Qux" )); - EXPECT_EQ(quux2_, message2_->FindEnumTypeByName("Quux")); - - EXPECT_TRUE(message_ ->FindEnumTypeByName("NoSuchType") == NULL); - EXPECT_TRUE(message_ ->FindEnumTypeByName("Quux" ) == NULL); - EXPECT_TRUE(message2_->FindEnumTypeByName("Baz" ) == NULL); - - EXPECT_TRUE(message_->FindEnumTypeByName("Foo") == NULL); -} - -TEST_F(NestedDescriptorTest, FindEnumValueByName) { - EXPECT_EQ(a_ , message_ ->FindEnumValueByName("A")); - EXPECT_EQ(b_ , message_ ->FindEnumValueByName("B")); - EXPECT_EQ(a2_, message2_->FindEnumValueByName("A")); - EXPECT_EQ(c2_, message2_->FindEnumValueByName("C")); - - EXPECT_TRUE(message_ ->FindEnumValueByName("NO_SUCH_VALUE") == NULL); - EXPECT_TRUE(message_ ->FindEnumValueByName("C" ) == NULL); - EXPECT_TRUE(message2_->FindEnumValueByName("B" ) == NULL); - - EXPECT_TRUE(message_->FindEnumValueByName("Foo") == NULL); -} - -// =================================================================== - -// Test extensions. -class ExtensionDescriptorTest : public testing::Test { - protected: - virtual void SetUp() { - // Build descriptors for the following definitions: - // - // enum Baz {} - // message Qux {} - // - // message Foo { - // extensions 10 to 19; - // extensions 30 to 39; - // } - // extends Foo with optional int32 foo_int32 = 10; - // extends Foo with repeated TestEnum foo_enum = 19; - // message Bar { - // extends Foo with optional Qux foo_message = 30; - // // (using Qux as the group type) - // extends Foo with repeated group foo_group = 39; - // } - - FileDescriptorProto foo_file; - foo_file.set_name("foo.proto"); - - AddEmptyEnum(&foo_file, "Baz"); - AddMessage(&foo_file, "Qux"); - - DescriptorProto* foo = AddMessage(&foo_file, "Foo"); - AddExtensionRange(foo, 10, 20); - AddExtensionRange(foo, 30, 40); - - AddExtension(&foo_file, "Foo", "foo_int32", 10, - FieldDescriptorProto::LABEL_OPTIONAL, - FieldDescriptorProto::TYPE_INT32); - AddExtension(&foo_file, "Foo", "foo_enum", 19, - FieldDescriptorProto::LABEL_REPEATED, - FieldDescriptorProto::TYPE_ENUM) - ->set_type_name("Baz"); - - DescriptorProto* bar = AddMessage(&foo_file, "Bar"); - AddNestedExtension(bar, "Foo", "foo_message", 30, - FieldDescriptorProto::LABEL_OPTIONAL, - FieldDescriptorProto::TYPE_MESSAGE) - ->set_type_name("Qux"); - AddNestedExtension(bar, "Foo", "foo_group", 39, - FieldDescriptorProto::LABEL_REPEATED, - FieldDescriptorProto::TYPE_GROUP) - ->set_type_name("Qux"); - - // Build the descriptors and get the pointers. - foo_file_ = pool_.BuildFile(foo_file); - ASSERT_TRUE(foo_file_ != NULL); - - ASSERT_EQ(1, foo_file_->enum_type_count()); - baz_ = foo_file_->enum_type(0); - - ASSERT_EQ(3, foo_file_->message_type_count()); - qux_ = foo_file_->message_type(0); - foo_ = foo_file_->message_type(1); - bar_ = foo_file_->message_type(2); - } - - DescriptorPool pool_; - - const FileDescriptor* foo_file_; - - const Descriptor* foo_; - const Descriptor* bar_; - const EnumDescriptor* baz_; - const Descriptor* qux_; -}; - -TEST_F(ExtensionDescriptorTest, ExtensionRanges) { - EXPECT_EQ(0, bar_->extension_range_count()); - ASSERT_EQ(2, foo_->extension_range_count()); - - EXPECT_EQ(10, foo_->extension_range(0)->start); - EXPECT_EQ(30, foo_->extension_range(1)->start); - - EXPECT_EQ(20, foo_->extension_range(0)->end); - EXPECT_EQ(40, foo_->extension_range(1)->end); -}; - -TEST_F(ExtensionDescriptorTest, Extensions) { - EXPECT_EQ(0, foo_->extension_count()); - ASSERT_EQ(2, foo_file_->extension_count()); - ASSERT_EQ(2, bar_->extension_count()); - - EXPECT_TRUE(foo_file_->extension(0)->is_extension()); - EXPECT_TRUE(foo_file_->extension(1)->is_extension()); - EXPECT_TRUE(bar_->extension(0)->is_extension()); - EXPECT_TRUE(bar_->extension(1)->is_extension()); - - EXPECT_EQ("foo_int32" , foo_file_->extension(0)->name()); - EXPECT_EQ("foo_enum" , foo_file_->extension(1)->name()); - EXPECT_EQ("foo_message", bar_->extension(0)->name()); - EXPECT_EQ("foo_group" , bar_->extension(1)->name()); - - EXPECT_EQ(10, foo_file_->extension(0)->number()); - EXPECT_EQ(19, foo_file_->extension(1)->number()); - EXPECT_EQ(30, bar_->extension(0)->number()); - EXPECT_EQ(39, bar_->extension(1)->number()); - - EXPECT_EQ(FieldDescriptor::TYPE_INT32 , foo_file_->extension(0)->type()); - EXPECT_EQ(FieldDescriptor::TYPE_ENUM , foo_file_->extension(1)->type()); - EXPECT_EQ(FieldDescriptor::TYPE_MESSAGE, bar_->extension(0)->type()); - EXPECT_EQ(FieldDescriptor::TYPE_GROUP , bar_->extension(1)->type()); - - EXPECT_EQ(baz_, foo_file_->extension(1)->enum_type()); - EXPECT_EQ(qux_, bar_->extension(0)->message_type()); - EXPECT_EQ(qux_, bar_->extension(1)->message_type()); - - EXPECT_EQ(FieldDescriptor::LABEL_OPTIONAL, foo_file_->extension(0)->label()); - EXPECT_EQ(FieldDescriptor::LABEL_REPEATED, foo_file_->extension(1)->label()); - EXPECT_EQ(FieldDescriptor::LABEL_OPTIONAL, bar_->extension(0)->label()); - EXPECT_EQ(FieldDescriptor::LABEL_REPEATED, bar_->extension(1)->label()); - - EXPECT_EQ(foo_, foo_file_->extension(0)->containing_type()); - EXPECT_EQ(foo_, foo_file_->extension(1)->containing_type()); - EXPECT_EQ(foo_, bar_->extension(0)->containing_type()); - EXPECT_EQ(foo_, bar_->extension(1)->containing_type()); - - EXPECT_TRUE(foo_file_->extension(0)->extension_scope() == NULL); - EXPECT_TRUE(foo_file_->extension(1)->extension_scope() == NULL); - EXPECT_EQ(bar_, bar_->extension(0)->extension_scope()); - EXPECT_EQ(bar_, bar_->extension(1)->extension_scope()); -}; - -TEST_F(ExtensionDescriptorTest, IsExtensionNumber) { - EXPECT_FALSE(foo_->IsExtensionNumber( 9)); - EXPECT_TRUE (foo_->IsExtensionNumber(10)); - EXPECT_TRUE (foo_->IsExtensionNumber(19)); - EXPECT_FALSE(foo_->IsExtensionNumber(20)); - EXPECT_FALSE(foo_->IsExtensionNumber(29)); - EXPECT_TRUE (foo_->IsExtensionNumber(30)); - EXPECT_TRUE (foo_->IsExtensionNumber(39)); - EXPECT_FALSE(foo_->IsExtensionNumber(40)); -} - -TEST_F(ExtensionDescriptorTest, FindExtensionByName) { - // Note that FileDescriptor::FindExtensionByName() is tested by - // FileDescriptorTest. - ASSERT_EQ(2, bar_->extension_count()); - - EXPECT_EQ(bar_->extension(0), bar_->FindExtensionByName("foo_message")); - EXPECT_EQ(bar_->extension(1), bar_->FindExtensionByName("foo_group" )); - - EXPECT_TRUE(bar_->FindExtensionByName("no_such_extension") == NULL); - EXPECT_TRUE(foo_->FindExtensionByName("foo_int32") == NULL); - EXPECT_TRUE(foo_->FindExtensionByName("foo_message") == NULL); -} - -TEST_F(ExtensionDescriptorTest, FindAllExtensions) { - vector extensions; - pool_.FindAllExtensions(foo_, &extensions); - ASSERT_EQ(4, extensions.size()); - EXPECT_EQ(10, extensions[0]->number()); - EXPECT_EQ(19, extensions[1]->number()); - EXPECT_EQ(30, extensions[2]->number()); - EXPECT_EQ(39, extensions[3]->number()); -} - -// =================================================================== - -class MiscTest : public testing::Test { - protected: - // Function which makes a field descriptor of the given type. - const FieldDescriptor* GetFieldDescriptorOfType(FieldDescriptor::Type type) { - FileDescriptorProto file_proto; - file_proto.set_name("foo.proto"); - AddEmptyEnum(&file_proto, "DummyEnum"); - - DescriptorProto* message = AddMessage(&file_proto, "TestMessage"); - FieldDescriptorProto* field = - AddField(message, "foo", 1, FieldDescriptorProto::LABEL_OPTIONAL, - static_cast(static_cast(type))); - - if (type == FieldDescriptor::TYPE_MESSAGE || - type == FieldDescriptor::TYPE_GROUP) { - field->set_type_name("TestMessage"); - } else if (type == FieldDescriptor::TYPE_ENUM) { - field->set_type_name("DummyEnum"); - } - - // Build the descriptors and get the pointers. - pool_.reset(new DescriptorPool()); - const FileDescriptor* file = pool_->BuildFile(file_proto); - - if (file != NULL && - file->message_type_count() == 1 && - file->message_type(0)->field_count() == 1) { - return file->message_type(0)->field(0); - } else { - return NULL; - } - } - - const char* GetTypeNameForFieldType(FieldDescriptor::Type type) { - const FieldDescriptor* field = GetFieldDescriptorOfType(type); - return field != NULL ? field->type_name() : ""; - } - - FieldDescriptor::CppType GetCppTypeForFieldType(FieldDescriptor::Type type) { - const FieldDescriptor* field = GetFieldDescriptorOfType(type); - return field != NULL ? field->cpp_type() : - static_cast(0); - } - - const char* GetCppTypeNameForFieldType(FieldDescriptor::Type type) { - const FieldDescriptor* field = GetFieldDescriptorOfType(type); - return field != NULL ? field->cpp_type_name() : ""; - } - - scoped_ptr pool_; -}; - -TEST_F(MiscTest, TypeNames) { - // Test that correct type names are returned. - - typedef FieldDescriptor FD; // avoid ugly line wrapping - - EXPECT_STREQ("double" , GetTypeNameForFieldType(FD::TYPE_DOUBLE )); - EXPECT_STREQ("float" , GetTypeNameForFieldType(FD::TYPE_FLOAT )); - EXPECT_STREQ("int64" , GetTypeNameForFieldType(FD::TYPE_INT64 )); - EXPECT_STREQ("uint64" , GetTypeNameForFieldType(FD::TYPE_UINT64 )); - EXPECT_STREQ("int32" , GetTypeNameForFieldType(FD::TYPE_INT32 )); - EXPECT_STREQ("fixed64" , GetTypeNameForFieldType(FD::TYPE_FIXED64 )); - EXPECT_STREQ("fixed32" , GetTypeNameForFieldType(FD::TYPE_FIXED32 )); - EXPECT_STREQ("bool" , GetTypeNameForFieldType(FD::TYPE_BOOL )); - EXPECT_STREQ("string" , GetTypeNameForFieldType(FD::TYPE_STRING )); - EXPECT_STREQ("group" , GetTypeNameForFieldType(FD::TYPE_GROUP )); - EXPECT_STREQ("message" , GetTypeNameForFieldType(FD::TYPE_MESSAGE )); - EXPECT_STREQ("bytes" , GetTypeNameForFieldType(FD::TYPE_BYTES )); - EXPECT_STREQ("uint32" , GetTypeNameForFieldType(FD::TYPE_UINT32 )); - EXPECT_STREQ("enum" , GetTypeNameForFieldType(FD::TYPE_ENUM )); - EXPECT_STREQ("sfixed32", GetTypeNameForFieldType(FD::TYPE_SFIXED32)); - EXPECT_STREQ("sfixed64", GetTypeNameForFieldType(FD::TYPE_SFIXED64)); - EXPECT_STREQ("sint32" , GetTypeNameForFieldType(FD::TYPE_SINT32 )); - EXPECT_STREQ("sint64" , GetTypeNameForFieldType(FD::TYPE_SINT64 )); -} - -TEST_F(MiscTest, CppTypes) { - // Test that CPP types are assigned correctly. - - typedef FieldDescriptor FD; // avoid ugly line wrapping - - EXPECT_EQ(FD::CPPTYPE_DOUBLE , GetCppTypeForFieldType(FD::TYPE_DOUBLE )); - EXPECT_EQ(FD::CPPTYPE_FLOAT , GetCppTypeForFieldType(FD::TYPE_FLOAT )); - EXPECT_EQ(FD::CPPTYPE_INT64 , GetCppTypeForFieldType(FD::TYPE_INT64 )); - EXPECT_EQ(FD::CPPTYPE_UINT64 , GetCppTypeForFieldType(FD::TYPE_UINT64 )); - EXPECT_EQ(FD::CPPTYPE_INT32 , GetCppTypeForFieldType(FD::TYPE_INT32 )); - EXPECT_EQ(FD::CPPTYPE_UINT64 , GetCppTypeForFieldType(FD::TYPE_FIXED64 )); - EXPECT_EQ(FD::CPPTYPE_UINT32 , GetCppTypeForFieldType(FD::TYPE_FIXED32 )); - EXPECT_EQ(FD::CPPTYPE_BOOL , GetCppTypeForFieldType(FD::TYPE_BOOL )); - EXPECT_EQ(FD::CPPTYPE_STRING , GetCppTypeForFieldType(FD::TYPE_STRING )); - EXPECT_EQ(FD::CPPTYPE_MESSAGE, GetCppTypeForFieldType(FD::TYPE_GROUP )); - EXPECT_EQ(FD::CPPTYPE_MESSAGE, GetCppTypeForFieldType(FD::TYPE_MESSAGE )); - EXPECT_EQ(FD::CPPTYPE_STRING , GetCppTypeForFieldType(FD::TYPE_BYTES )); - EXPECT_EQ(FD::CPPTYPE_UINT32 , GetCppTypeForFieldType(FD::TYPE_UINT32 )); - EXPECT_EQ(FD::CPPTYPE_ENUM , GetCppTypeForFieldType(FD::TYPE_ENUM )); - EXPECT_EQ(FD::CPPTYPE_INT32 , GetCppTypeForFieldType(FD::TYPE_SFIXED32)); - EXPECT_EQ(FD::CPPTYPE_INT64 , GetCppTypeForFieldType(FD::TYPE_SFIXED64)); - EXPECT_EQ(FD::CPPTYPE_INT32 , GetCppTypeForFieldType(FD::TYPE_SINT32 )); - EXPECT_EQ(FD::CPPTYPE_INT64 , GetCppTypeForFieldType(FD::TYPE_SINT64 )); -} - -TEST_F(MiscTest, CppTypeNames) { - // Test that correct CPP type names are returned. - - typedef FieldDescriptor FD; // avoid ugly line wrapping - - EXPECT_STREQ("double" , GetCppTypeNameForFieldType(FD::TYPE_DOUBLE )); - EXPECT_STREQ("float" , GetCppTypeNameForFieldType(FD::TYPE_FLOAT )); - EXPECT_STREQ("int64" , GetCppTypeNameForFieldType(FD::TYPE_INT64 )); - EXPECT_STREQ("uint64" , GetCppTypeNameForFieldType(FD::TYPE_UINT64 )); - EXPECT_STREQ("int32" , GetCppTypeNameForFieldType(FD::TYPE_INT32 )); - EXPECT_STREQ("uint64" , GetCppTypeNameForFieldType(FD::TYPE_FIXED64 )); - EXPECT_STREQ("uint32" , GetCppTypeNameForFieldType(FD::TYPE_FIXED32 )); - EXPECT_STREQ("bool" , GetCppTypeNameForFieldType(FD::TYPE_BOOL )); - EXPECT_STREQ("string" , GetCppTypeNameForFieldType(FD::TYPE_STRING )); - EXPECT_STREQ("message", GetCppTypeNameForFieldType(FD::TYPE_GROUP )); - EXPECT_STREQ("message", GetCppTypeNameForFieldType(FD::TYPE_MESSAGE )); - EXPECT_STREQ("string" , GetCppTypeNameForFieldType(FD::TYPE_BYTES )); - EXPECT_STREQ("uint32" , GetCppTypeNameForFieldType(FD::TYPE_UINT32 )); - EXPECT_STREQ("enum" , GetCppTypeNameForFieldType(FD::TYPE_ENUM )); - EXPECT_STREQ("int32" , GetCppTypeNameForFieldType(FD::TYPE_SFIXED32)); - EXPECT_STREQ("int64" , GetCppTypeNameForFieldType(FD::TYPE_SFIXED64)); - EXPECT_STREQ("int32" , GetCppTypeNameForFieldType(FD::TYPE_SINT32 )); - EXPECT_STREQ("int64" , GetCppTypeNameForFieldType(FD::TYPE_SINT64 )); -} - -TEST_F(MiscTest, DefaultValues) { - // Test that setting default values works. - FileDescriptorProto file_proto; - file_proto.set_name("foo.proto"); - - EnumDescriptorProto* enum_type_proto = AddEnum(&file_proto, "DummyEnum"); - AddEnumValue(enum_type_proto, "A", 1); - AddEnumValue(enum_type_proto, "B", 2); - - DescriptorProto* message_proto = AddMessage(&file_proto, "TestMessage"); - - typedef FieldDescriptorProto FD; // avoid ugly line wrapping - const FD::Label label = FD::LABEL_OPTIONAL; - - // Create fields of every CPP type with default values. - AddField(message_proto, "int32" , 1, label, FD::TYPE_INT32 ) - ->set_default_value("-1"); - AddField(message_proto, "int64" , 2, label, FD::TYPE_INT64 ) - ->set_default_value("-1000000000000"); - AddField(message_proto, "uint32", 3, label, FD::TYPE_UINT32) - ->set_default_value("42"); - AddField(message_proto, "uint64", 4, label, FD::TYPE_UINT64) - ->set_default_value("2000000000000"); - AddField(message_proto, "float" , 5, label, FD::TYPE_FLOAT ) - ->set_default_value("4.5"); - AddField(message_proto, "double", 6, label, FD::TYPE_DOUBLE) - ->set_default_value("10e100"); - AddField(message_proto, "bool" , 7, label, FD::TYPE_BOOL ) - ->set_default_value("true"); - AddField(message_proto, "string", 8, label, FD::TYPE_STRING) - ->set_default_value("hello"); - AddField(message_proto, "data" , 9, label, FD::TYPE_BYTES ) - ->set_default_value("\\001\\002\\003"); - - FieldDescriptorProto* enum_field = - AddField(message_proto, "enum", 10, label, FD::TYPE_ENUM); - enum_field->set_type_name("DummyEnum"); - enum_field->set_default_value("B"); - - // Strings are allowed to have empty defaults. (At one point, due to - // a bug, empty defaults for strings were rejected. Oops.) - AddField(message_proto, "empty_string", 11, label, FD::TYPE_STRING) - ->set_default_value(""); - - // Add a second set of fields with implicit defalut values. - AddField(message_proto, "implicit_int32" , 21, label, FD::TYPE_INT32 ); - AddField(message_proto, "implicit_int64" , 22, label, FD::TYPE_INT64 ); - AddField(message_proto, "implicit_uint32", 23, label, FD::TYPE_UINT32); - AddField(message_proto, "implicit_uint64", 24, label, FD::TYPE_UINT64); - AddField(message_proto, "implicit_float" , 25, label, FD::TYPE_FLOAT ); - AddField(message_proto, "implicit_double", 26, label, FD::TYPE_DOUBLE); - AddField(message_proto, "implicit_bool" , 27, label, FD::TYPE_BOOL ); - AddField(message_proto, "implicit_string", 28, label, FD::TYPE_STRING); - AddField(message_proto, "implicit_data" , 29, label, FD::TYPE_BYTES ); - AddField(message_proto, "implicit_enum" , 30, label, FD::TYPE_ENUM) - ->set_type_name("DummyEnum"); - - // Build it. - DescriptorPool pool; - const FileDescriptor* file = pool.BuildFile(file_proto); - ASSERT_TRUE(file != NULL); - - ASSERT_EQ(1, file->enum_type_count()); - const EnumDescriptor* enum_type = file->enum_type(0); - ASSERT_EQ(2, enum_type->value_count()); - const EnumValueDescriptor* enum_value_a = enum_type->value(0); - const EnumValueDescriptor* enum_value_b = enum_type->value(1); - - ASSERT_EQ(1, file->message_type_count()); - const Descriptor* message = file->message_type(0); - - ASSERT_EQ(21, message->field_count()); - - // Check the default values. - ASSERT_TRUE(message->field(0)->has_default_value()); - ASSERT_TRUE(message->field(1)->has_default_value()); - ASSERT_TRUE(message->field(2)->has_default_value()); - ASSERT_TRUE(message->field(3)->has_default_value()); - ASSERT_TRUE(message->field(4)->has_default_value()); - ASSERT_TRUE(message->field(5)->has_default_value()); - ASSERT_TRUE(message->field(6)->has_default_value()); - ASSERT_TRUE(message->field(7)->has_default_value()); - ASSERT_TRUE(message->field(8)->has_default_value()); - ASSERT_TRUE(message->field(9)->has_default_value()); - ASSERT_TRUE(message->field(10)->has_default_value()); - - EXPECT_EQ(-1 , message->field(0)->default_value_int32 ()); - EXPECT_EQ(-GOOGLE_ULONGLONG(1000000000000), - message->field(1)->default_value_int64 ()); - EXPECT_EQ(42 , message->field(2)->default_value_uint32()); - EXPECT_EQ(GOOGLE_ULONGLONG(2000000000000), - message->field(3)->default_value_uint64()); - EXPECT_EQ(4.5 , message->field(4)->default_value_float ()); - EXPECT_EQ(10e100 , message->field(5)->default_value_double()); - EXPECT_TRUE( message->field(6)->default_value_bool ()); - EXPECT_EQ("hello" , message->field(7)->default_value_string()); - EXPECT_EQ("\001\002\003" , message->field(8)->default_value_string()); - EXPECT_EQ(enum_value_b , message->field(9)->default_value_enum ()); - EXPECT_EQ("" , message->field(10)->default_value_string()); - - ASSERT_FALSE(message->field(11)->has_default_value()); - ASSERT_FALSE(message->field(12)->has_default_value()); - ASSERT_FALSE(message->field(13)->has_default_value()); - ASSERT_FALSE(message->field(14)->has_default_value()); - ASSERT_FALSE(message->field(15)->has_default_value()); - ASSERT_FALSE(message->field(16)->has_default_value()); - ASSERT_FALSE(message->field(17)->has_default_value()); - ASSERT_FALSE(message->field(18)->has_default_value()); - ASSERT_FALSE(message->field(19)->has_default_value()); - ASSERT_FALSE(message->field(20)->has_default_value()); - - EXPECT_EQ(0 , message->field(11)->default_value_int32 ()); - EXPECT_EQ(0 , message->field(12)->default_value_int64 ()); - EXPECT_EQ(0 , message->field(13)->default_value_uint32()); - EXPECT_EQ(0 , message->field(14)->default_value_uint64()); - EXPECT_EQ(0.0f , message->field(15)->default_value_float ()); - EXPECT_EQ(0.0 , message->field(16)->default_value_double()); - EXPECT_FALSE( message->field(17)->default_value_bool ()); - EXPECT_EQ("" , message->field(18)->default_value_string()); - EXPECT_EQ("" , message->field(19)->default_value_string()); - EXPECT_EQ(enum_value_a, message->field(20)->default_value_enum()); -} - -TEST_F(MiscTest, FieldOptions) { - // Try setting field options. - - FileDescriptorProto file_proto; - file_proto.set_name("foo.proto"); - - DescriptorProto* message_proto = AddMessage(&file_proto, "TestMessage"); - AddField(message_proto, "foo", 1, - FieldDescriptorProto::LABEL_OPTIONAL, - FieldDescriptorProto::TYPE_INT32); - FieldDescriptorProto* bar_proto = - AddField(message_proto, "bar", 2, - FieldDescriptorProto::LABEL_OPTIONAL, - FieldDescriptorProto::TYPE_INT32); - - FieldOptions* options = bar_proto->mutable_options(); - options->set_ctype(FieldOptions::CORD); - - // Build the descriptors and get the pointers. - DescriptorPool pool; - const FileDescriptor* file = pool.BuildFile(file_proto); - ASSERT_TRUE(file != NULL); - - ASSERT_EQ(1, file->message_type_count()); - const Descriptor* message = file->message_type(0); - - ASSERT_EQ(2, message->field_count()); - const FieldDescriptor* foo = message->field(0); - const FieldDescriptor* bar = message->field(1); - - // "foo" had no options set, so it should return the default options. - EXPECT_EQ(&FieldOptions::default_instance(), &foo->options()); - - // "bar" had options set. - EXPECT_NE(&FieldOptions::default_instance(), options); - EXPECT_TRUE(bar->options().has_ctype()); - EXPECT_EQ(FieldOptions::CORD, bar->options().ctype()); -} - -// =================================================================== -enum DescriptorPoolMode { - NO_DATABASE, - FALLBACK_DATABASE -}; - -class AllowUnknownDependenciesTest - : public testing::TestWithParam { - protected: - DescriptorPoolMode mode() { - return GetParam(); - } - - virtual void SetUp() { - FileDescriptorProto foo_proto, bar_proto; - - switch (mode()) { - case NO_DATABASE: - pool_.reset(new DescriptorPool); - break; - case FALLBACK_DATABASE: - pool_.reset(new DescriptorPool(&db_)); - break; - } - - pool_->AllowUnknownDependencies(); - - ASSERT_TRUE(TextFormat::ParseFromString( - "name: 'foo.proto'" - "dependency: 'bar.proto'" - "dependency: 'baz.proto'" - "message_type {" - " name: 'Foo'" - " field { name:'bar' number:1 label:LABEL_OPTIONAL type_name:'Bar' }" - " field { name:'baz' number:2 label:LABEL_OPTIONAL type_name:'Baz' }" - " field { name:'qux' number:3 label:LABEL_OPTIONAL" - " type_name: '.corge.Qux'" - " type: TYPE_ENUM" - " options {" - " uninterpreted_option {" - " name {" - " name_part: 'grault'" - " is_extension: true" - " }" - " positive_int_value: 1234" - " }" - " }" - " }" - "}", - &foo_proto)); - ASSERT_TRUE(TextFormat::ParseFromString( - "name: 'bar.proto'" - "message_type { name: 'Bar' }", - &bar_proto)); - - // Collect pointers to stuff. - bar_file_ = BuildFile(bar_proto); - ASSERT_TRUE(bar_file_ != NULL); - - ASSERT_EQ(1, bar_file_->message_type_count()); - bar_type_ = bar_file_->message_type(0); - - foo_file_ = BuildFile(foo_proto); - ASSERT_TRUE(foo_file_ != NULL); - - ASSERT_EQ(1, foo_file_->message_type_count()); - foo_type_ = foo_file_->message_type(0); - - ASSERT_EQ(3, foo_type_->field_count()); - bar_field_ = foo_type_->field(0); - baz_field_ = foo_type_->field(1); - qux_field_ = foo_type_->field(2); - } - - const FileDescriptor* BuildFile(const FileDescriptorProto& proto) { - switch (mode()) { - case NO_DATABASE: - return pool_->BuildFile(proto); - break; - case FALLBACK_DATABASE: { - EXPECT_TRUE(db_.Add(proto)); - return pool_->FindFileByName(proto.name()); - } - } - GOOGLE_LOG(FATAL) << "Can't get here."; - return NULL; - } - - const FileDescriptor* bar_file_; - const Descriptor* bar_type_; - const FileDescriptor* foo_file_; - const Descriptor* foo_type_; - const FieldDescriptor* bar_field_; - const FieldDescriptor* baz_field_; - const FieldDescriptor* qux_field_; - - SimpleDescriptorDatabase db_; // used if in FALLBACK_DATABASE mode. - scoped_ptr pool_; -}; - -TEST_P(AllowUnknownDependenciesTest, PlaceholderFile) { - ASSERT_EQ(2, foo_file_->dependency_count()); - EXPECT_EQ(bar_file_, foo_file_->dependency(0)); - - const FileDescriptor* baz_file = foo_file_->dependency(1); - EXPECT_EQ("baz.proto", baz_file->name()); - EXPECT_EQ(0, baz_file->message_type_count()); - - // Placeholder files should not be findable. - EXPECT_EQ(bar_file_, pool_->FindFileByName(bar_file_->name())); - EXPECT_TRUE(pool_->FindFileByName(baz_file->name()) == NULL); -} - -TEST_P(AllowUnknownDependenciesTest, PlaceholderTypes) { - ASSERT_EQ(FieldDescriptor::TYPE_MESSAGE, bar_field_->type()); - EXPECT_EQ(bar_type_, bar_field_->message_type()); - - ASSERT_EQ(FieldDescriptor::TYPE_MESSAGE, baz_field_->type()); - const Descriptor* baz_type = baz_field_->message_type(); - EXPECT_EQ("Baz", baz_type->name()); - EXPECT_EQ("Baz", baz_type->full_name()); - EXPECT_EQ("Baz.placeholder.proto", baz_type->file()->name()); - EXPECT_EQ(0, baz_type->extension_range_count()); - - ASSERT_EQ(FieldDescriptor::TYPE_ENUM, qux_field_->type()); - const EnumDescriptor* qux_type = qux_field_->enum_type(); - EXPECT_EQ("Qux", qux_type->name()); - EXPECT_EQ("corge.Qux", qux_type->full_name()); - EXPECT_EQ("corge.Qux.placeholder.proto", qux_type->file()->name()); - - // Placeholder types should not be findable. - EXPECT_EQ(bar_type_, pool_->FindMessageTypeByName(bar_type_->full_name())); - EXPECT_TRUE(pool_->FindMessageTypeByName(baz_type->full_name()) == NULL); - EXPECT_TRUE(pool_->FindEnumTypeByName(qux_type->full_name()) == NULL); -} - -TEST_P(AllowUnknownDependenciesTest, CopyTo) { - // FieldDescriptor::CopyTo() should write non-fully-qualified type names - // for placeholder types which were not originally fully-qualified. - FieldDescriptorProto proto; - - // Bar is not a placeholder, so it is fully-qualified. - bar_field_->CopyTo(&proto); - EXPECT_EQ(".Bar", proto.type_name()); - EXPECT_EQ(FieldDescriptorProto::TYPE_MESSAGE, proto.type()); - - // Baz is an unqualified placeholder. - proto.Clear(); - baz_field_->CopyTo(&proto); - EXPECT_EQ("Baz", proto.type_name()); - EXPECT_FALSE(proto.has_type()); - - // Qux is a fully-qualified placeholder. - proto.Clear(); - qux_field_->CopyTo(&proto); - EXPECT_EQ(".corge.Qux", proto.type_name()); - EXPECT_EQ(FieldDescriptorProto::TYPE_ENUM, proto.type()); -} - -TEST_P(AllowUnknownDependenciesTest, CustomOptions) { - // Qux should still have the uninterpreted option attached. - ASSERT_EQ(1, qux_field_->options().uninterpreted_option_size()); - const UninterpretedOption& option = - qux_field_->options().uninterpreted_option(0); - ASSERT_EQ(1, option.name_size()); - EXPECT_EQ("grault", option.name(0).name_part()); -} - -TEST_P(AllowUnknownDependenciesTest, UnknownExtendee) { - // Test that we can extend an unknown type. This is slightly tricky because - // it means that the placeholder type must have an extension range. - - FileDescriptorProto extension_proto; - - ASSERT_TRUE(TextFormat::ParseFromString( - "name: 'extension.proto'" - "extension { extendee: 'UnknownType' name:'some_extension' number:123" - " label:LABEL_OPTIONAL type:TYPE_INT32 }", - &extension_proto)); - const FileDescriptor* file = BuildFile(extension_proto); - - ASSERT_TRUE(file != NULL); - - ASSERT_EQ(1, file->extension_count()); - const Descriptor* extendee = file->extension(0)->containing_type(); - EXPECT_EQ("UnknownType", extendee->name()); - ASSERT_EQ(1, extendee->extension_range_count()); - EXPECT_EQ(1, extendee->extension_range(0)->start); - EXPECT_EQ(FieldDescriptor::kMaxNumber + 1, extendee->extension_range(0)->end); -} - -TEST_P(AllowUnknownDependenciesTest, CustomOption) { - // Test that we can use a custom option without having parsed - // descriptor.proto. - - FileDescriptorProto option_proto; - - ASSERT_TRUE(TextFormat::ParseFromString( - "name: \"unknown_custom_options.proto\" " - "dependency: \"google/protobuf/descriptor.proto\" " - "extension { " - " extendee: \"google.protobuf.FileOptions\" " - " name: \"some_option\" " - " number: 123456 " - " label: LABEL_OPTIONAL " - " type: TYPE_INT32 " - "} " - "options { " - " uninterpreted_option { " - " name { " - " name_part: \"some_option\" " - " is_extension: true " - " } " - " positive_int_value: 1234 " - " } " - " uninterpreted_option { " - " name { " - " name_part: \"unknown_option\" " - " is_extension: true " - " } " - " positive_int_value: 1234 " - " } " - " uninterpreted_option { " - " name { " - " name_part: \"optimize_for\" " - " is_extension: false " - " } " - " identifier_value: \"SPEED\" " - " } " - "}", - &option_proto)); - - const FileDescriptor* file = BuildFile(option_proto); - ASSERT_TRUE(file != NULL); - - // Verify that no extension options were set, but they were left as - // uninterpreted_options. - vector fields; - file->options().GetReflection()->ListFields(file->options(), &fields); - ASSERT_EQ(2, fields.size()); - EXPECT_TRUE(file->options().has_optimize_for()); - EXPECT_EQ(2, file->options().uninterpreted_option_size()); -} - -TEST_P(AllowUnknownDependenciesTest, - UndeclaredDependencyTriggersBuildOfDependency) { - // Crazy case: suppose foo.proto refers to a symbol without declaring the - // dependency that finds it. In the event that the pool is backed by a - // DescriptorDatabase, the pool will attempt to find the symbol in the - // database. If successful, it will build the undeclared dependency to verify - // that the file does indeed contain the symbol. If that file fails to build, - // then its descriptors must be rolled back. However, we still want foo.proto - // to build successfully, since we are allowing unknown dependencies. - - FileDescriptorProto undeclared_dep_proto; - // We make this file fail to build by giving it two fields with tag 1. - ASSERT_TRUE(TextFormat::ParseFromString( - "name: \"invalid_file_as_undeclared_dep.proto\" " - "package: \"undeclared\" " - "message_type: { " - " name: \"Quux\" " - " field { " - " name:'qux' number:1 label:LABEL_OPTIONAL type: TYPE_INT32 " - " }" - " field { " - " name:'quux' number:1 label:LABEL_OPTIONAL type: TYPE_INT64 " - " }" - "}", - &undeclared_dep_proto)); - // We can't use the BuildFile() helper because we don't actually want to build - // it into the descriptor pool in the fallback database case: it just needs to - // be sitting in the database so that it gets built during the building of - // test.proto below. - switch (mode()) { - case NO_DATABASE: { - ASSERT_TRUE(pool_->BuildFile(undeclared_dep_proto) == NULL); - break; - } - case FALLBACK_DATABASE: { - ASSERT_TRUE(db_.Add(undeclared_dep_proto)); - } - } - - FileDescriptorProto test_proto; - ASSERT_TRUE(TextFormat::ParseFromString( - "name: \"test.proto\" " - "message_type: { " - " name: \"Corge\" " - " field { " - " name:'quux' number:1 label: LABEL_OPTIONAL " - " type_name:'undeclared.Quux' type: TYPE_MESSAGE " - " }" - "}", - &test_proto)); - - const FileDescriptor* file = BuildFile(test_proto); - ASSERT_TRUE(file != NULL); - GOOGLE_LOG(INFO) << file->DebugString(); - - EXPECT_EQ(0, file->dependency_count()); - ASSERT_EQ(1, file->message_type_count()); - const Descriptor* corge_desc = file->message_type(0); - ASSERT_EQ("Corge", corge_desc->name()); - ASSERT_EQ(1, corge_desc->field_count()); - - const FieldDescriptor* quux_field = corge_desc->field(0); - ASSERT_EQ(FieldDescriptor::TYPE_MESSAGE, quux_field->type()); - ASSERT_EQ("Quux", quux_field->message_type()->name()); - ASSERT_EQ("undeclared.Quux", quux_field->message_type()->full_name()); - EXPECT_EQ("undeclared.Quux.placeholder.proto", - quux_field->message_type()->file()->name()); - // The place holder type should not be findable. - ASSERT_TRUE(pool_->FindMessageTypeByName("undeclared.Quux") == NULL); -} - -INSTANTIATE_TEST_CASE_P(DatabaseSource, - AllowUnknownDependenciesTest, - testing::Values(NO_DATABASE, FALLBACK_DATABASE)); - -// =================================================================== - -TEST(CustomOptions, OptionLocations) { - const Descriptor* message = - protobuf_unittest::TestMessageWithCustomOptions::descriptor(); - const FileDescriptor* file = message->file(); - const FieldDescriptor* field = message->FindFieldByName("field1"); - const EnumDescriptor* enm = message->FindEnumTypeByName("AnEnum"); - // TODO(benjy): Support EnumValue options, once the compiler does. - const ServiceDescriptor* service = - file->FindServiceByName("TestServiceWithCustomOptions"); - const MethodDescriptor* method = service->FindMethodByName("Foo"); - - EXPECT_EQ(GOOGLE_LONGLONG(9876543210), - file->options().GetExtension(protobuf_unittest::file_opt1)); - EXPECT_EQ(-56, - message->options().GetExtension(protobuf_unittest::message_opt1)); - EXPECT_EQ(GOOGLE_LONGLONG(8765432109), - field->options().GetExtension(protobuf_unittest::field_opt1)); - EXPECT_EQ(42, // Check that we get the default for an option we don't set. - field->options().GetExtension(protobuf_unittest::field_opt2)); - EXPECT_EQ(-789, - enm->options().GetExtension(protobuf_unittest::enum_opt1)); - EXPECT_EQ(123, - enm->value(1)->options().GetExtension( - protobuf_unittest::enum_value_opt1)); - EXPECT_EQ(GOOGLE_LONGLONG(-9876543210), - service->options().GetExtension(protobuf_unittest::service_opt1)); - EXPECT_EQ(protobuf_unittest::METHODOPT1_VAL2, - method->options().GetExtension(protobuf_unittest::method_opt1)); - - // See that the regular options went through unscathed. - EXPECT_TRUE(message->options().has_message_set_wire_format()); - EXPECT_EQ(FieldOptions::CORD, field->options().ctype()); -} - -TEST(CustomOptions, OptionTypes) { - const MessageOptions* options = NULL; - - options = - &protobuf_unittest::CustomOptionMinIntegerValues::descriptor()->options(); - EXPECT_FALSE( options->GetExtension(protobuf_unittest::bool_opt)); - EXPECT_EQ(kint32min, options->GetExtension(protobuf_unittest::int32_opt)); - EXPECT_EQ(kint64min, options->GetExtension(protobuf_unittest::int64_opt)); - EXPECT_EQ(0 , options->GetExtension(protobuf_unittest::uint32_opt)); - EXPECT_EQ(0 , options->GetExtension(protobuf_unittest::uint64_opt)); - EXPECT_EQ(kint32min, options->GetExtension(protobuf_unittest::sint32_opt)); - EXPECT_EQ(kint64min, options->GetExtension(protobuf_unittest::sint64_opt)); - EXPECT_EQ(0 , options->GetExtension(protobuf_unittest::fixed32_opt)); - EXPECT_EQ(0 , options->GetExtension(protobuf_unittest::fixed64_opt)); - EXPECT_EQ(kint32min, options->GetExtension(protobuf_unittest::sfixed32_opt)); - EXPECT_EQ(kint64min, options->GetExtension(protobuf_unittest::sfixed64_opt)); - - options = - &protobuf_unittest::CustomOptionMaxIntegerValues::descriptor()->options(); - EXPECT_TRUE( options->GetExtension(protobuf_unittest::bool_opt)); - EXPECT_EQ(kint32max , options->GetExtension(protobuf_unittest::int32_opt)); - EXPECT_EQ(kint64max , options->GetExtension(protobuf_unittest::int64_opt)); - EXPECT_EQ(kuint32max, options->GetExtension(protobuf_unittest::uint32_opt)); - EXPECT_EQ(kuint64max, options->GetExtension(protobuf_unittest::uint64_opt)); - EXPECT_EQ(kint32max , options->GetExtension(protobuf_unittest::sint32_opt)); - EXPECT_EQ(kint64max , options->GetExtension(protobuf_unittest::sint64_opt)); - EXPECT_EQ(kuint32max, options->GetExtension(protobuf_unittest::fixed32_opt)); - EXPECT_EQ(kuint64max, options->GetExtension(protobuf_unittest::fixed64_opt)); - EXPECT_EQ(kint32max , options->GetExtension(protobuf_unittest::sfixed32_opt)); - EXPECT_EQ(kint64max , options->GetExtension(protobuf_unittest::sfixed64_opt)); - - options = - &protobuf_unittest::CustomOptionOtherValues::descriptor()->options(); - EXPECT_EQ(-100, options->GetExtension(protobuf_unittest::int32_opt)); - EXPECT_FLOAT_EQ(12.3456789, - options->GetExtension(protobuf_unittest::float_opt)); - EXPECT_DOUBLE_EQ(1.234567890123456789, - options->GetExtension(protobuf_unittest::double_opt)); - EXPECT_EQ("Hello, \"World\"", - options->GetExtension(protobuf_unittest::string_opt)); - - EXPECT_EQ(string("Hello\0World", 11), - options->GetExtension(protobuf_unittest::bytes_opt)); - - EXPECT_EQ(protobuf_unittest::DummyMessageContainingEnum::TEST_OPTION_ENUM_TYPE2, - options->GetExtension(protobuf_unittest::enum_opt)); - - options = - &protobuf_unittest::SettingRealsFromPositiveInts::descriptor()->options(); - EXPECT_FLOAT_EQ(12, options->GetExtension(protobuf_unittest::float_opt)); - EXPECT_DOUBLE_EQ(154, options->GetExtension(protobuf_unittest::double_opt)); - - options = - &protobuf_unittest::SettingRealsFromNegativeInts::descriptor()->options(); - EXPECT_FLOAT_EQ(-12, options->GetExtension(protobuf_unittest::float_opt)); - EXPECT_DOUBLE_EQ(-154, options->GetExtension(protobuf_unittest::double_opt)); -} - -TEST(CustomOptions, ComplexExtensionOptions) { - const MessageOptions* options = - &protobuf_unittest::VariousComplexOptions::descriptor()->options(); - EXPECT_EQ(options->GetExtension(protobuf_unittest::complex_opt1).foo(), 42); - EXPECT_EQ(options->GetExtension(protobuf_unittest::complex_opt1). - GetExtension(protobuf_unittest::quux), 324); - EXPECT_EQ(options->GetExtension(protobuf_unittest::complex_opt1). - GetExtension(protobuf_unittest::corge).qux(), 876); - EXPECT_EQ(options->GetExtension(protobuf_unittest::complex_opt2).baz(), 987); - EXPECT_EQ(options->GetExtension(protobuf_unittest::complex_opt2). - GetExtension(protobuf_unittest::grault), 654); - EXPECT_EQ(options->GetExtension(protobuf_unittest::complex_opt2).bar().foo(), - 743); - EXPECT_EQ(options->GetExtension(protobuf_unittest::complex_opt2).bar(). - GetExtension(protobuf_unittest::quux), 1999); - EXPECT_EQ(options->GetExtension(protobuf_unittest::complex_opt2).bar(). - GetExtension(protobuf_unittest::corge).qux(), 2008); - EXPECT_EQ(options->GetExtension(protobuf_unittest::complex_opt2). - GetExtension(protobuf_unittest::garply).foo(), 741); - EXPECT_EQ(options->GetExtension(protobuf_unittest::complex_opt2). - GetExtension(protobuf_unittest::garply). - GetExtension(protobuf_unittest::quux), 1998); - EXPECT_EQ(options->GetExtension(protobuf_unittest::complex_opt2). - GetExtension(protobuf_unittest::garply). - GetExtension(protobuf_unittest::corge).qux(), 2121); - EXPECT_EQ(options->GetExtension( - protobuf_unittest::ComplexOptionType2::ComplexOptionType4::complex_opt4). - waldo(), 1971); - EXPECT_EQ(options->GetExtension(protobuf_unittest::complex_opt2). - fred().waldo(), 321); - EXPECT_EQ(9, options->GetExtension(protobuf_unittest::complex_opt3).qux()); - EXPECT_EQ(22, options->GetExtension(protobuf_unittest::complex_opt3). - complexoptiontype5().plugh()); - EXPECT_EQ(24, options->GetExtension(protobuf_unittest::complexopt6).xyzzy()); -} - -TEST(CustomOptions, OptionsFromOtherFile) { - // Test that to use a custom option, we only need to import the file - // defining the option; we do not also have to import descriptor.proto. - DescriptorPool pool; - - FileDescriptorProto file_proto; - FileDescriptorProto::descriptor()->file()->CopyTo(&file_proto); - ASSERT_TRUE(pool.BuildFile(file_proto) != NULL); - - protobuf_unittest::TestMessageWithCustomOptions::descriptor() - ->file()->CopyTo(&file_proto); - ASSERT_TRUE(pool.BuildFile(file_proto) != NULL); - - ASSERT_TRUE(TextFormat::ParseFromString( - "name: \"custom_options_import.proto\" " - "package: \"protobuf_unittest\" " - "dependency: \"google/protobuf/unittest_custom_options.proto\" " - "options { " - " uninterpreted_option { " - " name { " - " name_part: \"file_opt1\" " - " is_extension: true " - " } " - " positive_int_value: 1234 " - " } " - // Test a non-extension option too. (At one point this failed due to a - // bug.) - " uninterpreted_option { " - " name { " - " name_part: \"java_package\" " - " is_extension: false " - " } " - " string_value: \"foo\" " - " } " - // Test that enum-typed options still work too. (At one point this also - // failed due to a bug.) - " uninterpreted_option { " - " name { " - " name_part: \"optimize_for\" " - " is_extension: false " - " } " - " identifier_value: \"SPEED\" " - " } " - "}" - , - &file_proto)); - - const FileDescriptor* file = pool.BuildFile(file_proto); - ASSERT_TRUE(file != NULL); - EXPECT_EQ(1234, file->options().GetExtension(protobuf_unittest::file_opt1)); - EXPECT_TRUE(file->options().has_java_package()); - EXPECT_EQ("foo", file->options().java_package()); - EXPECT_TRUE(file->options().has_optimize_for()); - EXPECT_EQ(FileOptions::SPEED, file->options().optimize_for()); -} - -TEST(CustomOptions, MessageOptionThreeFieldsSet) { - // This tests a bug which previously existed in custom options parsing. The - // bug occurred when you defined a custom option with message type and then - // set three fields of that option on a single definition (see the example - // below). The bug is a bit hard to explain, so check the change history if - // you want to know more. - DescriptorPool pool; - - FileDescriptorProto file_proto; - FileDescriptorProto::descriptor()->file()->CopyTo(&file_proto); - ASSERT_TRUE(pool.BuildFile(file_proto) != NULL); - - protobuf_unittest::TestMessageWithCustomOptions::descriptor() - ->file()->CopyTo(&file_proto); - ASSERT_TRUE(pool.BuildFile(file_proto) != NULL); - - // The following represents the definition: - // - // import "google/protobuf/unittest_custom_options.proto" - // package protobuf_unittest; - // message Foo { - // option (complex_opt1).foo = 1234; - // option (complex_opt1).foo2 = 1234; - // option (complex_opt1).foo3 = 1234; - // } - ASSERT_TRUE(TextFormat::ParseFromString( - "name: \"custom_options_import.proto\" " - "package: \"protobuf_unittest\" " - "dependency: \"google/protobuf/unittest_custom_options.proto\" " - "message_type { " - " name: \"Foo\" " - " options { " - " uninterpreted_option { " - " name { " - " name_part: \"complex_opt1\" " - " is_extension: true " - " } " - " name { " - " name_part: \"foo\" " - " is_extension: false " - " } " - " positive_int_value: 1234 " - " } " - " uninterpreted_option { " - " name { " - " name_part: \"complex_opt1\" " - " is_extension: true " - " } " - " name { " - " name_part: \"foo2\" " - " is_extension: false " - " } " - " positive_int_value: 1234 " - " } " - " uninterpreted_option { " - " name { " - " name_part: \"complex_opt1\" " - " is_extension: true " - " } " - " name { " - " name_part: \"foo3\" " - " is_extension: false " - " } " - " positive_int_value: 1234 " - " } " - " } " - "}", - &file_proto)); - - const FileDescriptor* file = pool.BuildFile(file_proto); - ASSERT_TRUE(file != NULL); - ASSERT_EQ(1, file->message_type_count()); - - const MessageOptions& options = file->message_type(0)->options(); - EXPECT_EQ(1234, options.GetExtension(protobuf_unittest::complex_opt1).foo()); -} - -// Check that aggregate options were parsed and saved correctly in -// the appropriate descriptors. -TEST(CustomOptions, AggregateOptions) { - const Descriptor* msg = protobuf_unittest::AggregateMessage::descriptor(); - const FileDescriptor* file = msg->file(); - const FieldDescriptor* field = msg->FindFieldByName("fieldname"); - const EnumDescriptor* enumd = file->FindEnumTypeByName("AggregateEnum"); - const EnumValueDescriptor* enumv = enumd->FindValueByName("VALUE"); - const ServiceDescriptor* service = file->FindServiceByName( - "AggregateService"); - const MethodDescriptor* method = service->FindMethodByName("Method"); - - // Tests for the different types of data embedded in fileopt - const protobuf_unittest::Aggregate& file_options = - file->options().GetExtension(protobuf_unittest::fileopt); - EXPECT_EQ(100, file_options.i()); - EXPECT_EQ("FileAnnotation", file_options.s()); - EXPECT_EQ("NestedFileAnnotation", file_options.sub().s()); - EXPECT_EQ("FileExtensionAnnotation", - file_options.file().GetExtension(protobuf_unittest::fileopt).s()); - EXPECT_EQ("EmbeddedMessageSetElement", - file_options.mset().GetExtension( - protobuf_unittest::AggregateMessageSetElement - ::message_set_extension).s()); - - // Simple tests for all the other types of annotations - EXPECT_EQ("MessageAnnotation", - msg->options().GetExtension(protobuf_unittest::msgopt).s()); - EXPECT_EQ("FieldAnnotation", - field->options().GetExtension(protobuf_unittest::fieldopt).s()); - EXPECT_EQ("EnumAnnotation", - enumd->options().GetExtension(protobuf_unittest::enumopt).s()); - EXPECT_EQ("EnumValueAnnotation", - enumv->options().GetExtension(protobuf_unittest::enumvalopt).s()); - EXPECT_EQ("ServiceAnnotation", - service->options().GetExtension(protobuf_unittest::serviceopt).s()); - EXPECT_EQ("MethodAnnotation", - method->options().GetExtension(protobuf_unittest::methodopt).s()); -} - -// =================================================================== - -// The tests below trigger every unique call to AddError() in descriptor.cc, -// in the order in which they appear in that file. I'm using TextFormat here -// to specify the input descriptors because building them using code would -// be too bulky. - -class MockErrorCollector : public DescriptorPool::ErrorCollector { - public: - MockErrorCollector() {} - ~MockErrorCollector() {} - - string text_; - - // implements ErrorCollector --------------------------------------- - void AddError(const string& filename, - const string& element_name, const Message* descriptor, - ErrorLocation location, const string& message) { - const char* location_name = NULL; - switch (location) { - case NAME : location_name = "NAME" ; break; - case NUMBER : location_name = "NUMBER" ; break; - case TYPE : location_name = "TYPE" ; break; - case EXTENDEE : location_name = "EXTENDEE" ; break; - case DEFAULT_VALUE: location_name = "DEFAULT_VALUE"; break; - case OPTION_NAME : location_name = "OPTION_NAME" ; break; - case OPTION_VALUE : location_name = "OPTION_VALUE" ; break; - case INPUT_TYPE : location_name = "INPUT_TYPE" ; break; - case OUTPUT_TYPE : location_name = "OUTPUT_TYPE" ; break; - case OTHER : location_name = "OTHER" ; break; - } - - strings::SubstituteAndAppend( - &text_, "$0: $1: $2: $3\n", - filename, element_name, location_name, message); - } -}; - -class ValidationErrorTest : public testing::Test { - protected: - // Parse file_text as a FileDescriptorProto in text format and add it - // to the DescriptorPool. Expect no errors. - void BuildFile(const string& file_text) { - FileDescriptorProto file_proto; - ASSERT_TRUE(TextFormat::ParseFromString(file_text, &file_proto)); - ASSERT_TRUE(pool_.BuildFile(file_proto) != NULL); - } - - // Parse file_text as a FileDescriptorProto in text format and add it - // to the DescriptorPool. Expect errors to be produced which match the - // given error text. - void BuildFileWithErrors(const string& file_text, - const string& expected_errors) { - FileDescriptorProto file_proto; - ASSERT_TRUE(TextFormat::ParseFromString(file_text, &file_proto)); - - MockErrorCollector error_collector; - EXPECT_TRUE( - pool_.BuildFileCollectingErrors(file_proto, &error_collector) == NULL); - EXPECT_EQ(expected_errors, error_collector.text_); - } - - // Builds some already-parsed file in our test pool. - void BuildFileInTestPool(const FileDescriptor* file) { - FileDescriptorProto file_proto; - file->CopyTo(&file_proto); - ASSERT_TRUE(pool_.BuildFile(file_proto) != NULL); - } - - // Build descriptor.proto in our test pool. This allows us to extend it in - // the test pool, so we can test custom options. - void BuildDescriptorMessagesInTestPool() { - BuildFileInTestPool(DescriptorProto::descriptor()->file()); - } - - DescriptorPool pool_; -}; - -TEST_F(ValidationErrorTest, AlreadyDefined) { - BuildFileWithErrors( - "name: \"foo.proto\" " - "message_type { name: \"Foo\" }" - "message_type { name: \"Foo\" }", - - "foo.proto: Foo: NAME: \"Foo\" is already defined.\n"); -} - -TEST_F(ValidationErrorTest, AlreadyDefinedInPackage) { - BuildFileWithErrors( - "name: \"foo.proto\" " - "package: \"foo.bar\" " - "message_type { name: \"Foo\" }" - "message_type { name: \"Foo\" }", - - "foo.proto: foo.bar.Foo: NAME: \"Foo\" is already defined in " - "\"foo.bar\".\n"); -} - -TEST_F(ValidationErrorTest, AlreadyDefinedInOtherFile) { - BuildFile( - "name: \"foo.proto\" " - "message_type { name: \"Foo\" }"); - - BuildFileWithErrors( - "name: \"bar.proto\" " - "message_type { name: \"Foo\" }", - - "bar.proto: Foo: NAME: \"Foo\" is already defined in file " - "\"foo.proto\".\n"); -} - -TEST_F(ValidationErrorTest, PackageAlreadyDefined) { - BuildFile( - "name: \"foo.proto\" " - "message_type { name: \"foo\" }"); - BuildFileWithErrors( - "name: \"bar.proto\" " - "package: \"foo.bar\"", - - "bar.proto: foo: NAME: \"foo\" is already defined (as something other " - "than a package) in file \"foo.proto\".\n"); -} - -TEST_F(ValidationErrorTest, EnumValueAlreadyDefinedInParent) { - BuildFileWithErrors( - "name: \"foo.proto\" " - "enum_type { name: \"Foo\" value { name: \"FOO\" number: 1 } } " - "enum_type { name: \"Bar\" value { name: \"FOO\" number: 1 } } ", - - "foo.proto: FOO: NAME: \"FOO\" is already defined.\n" - "foo.proto: FOO: NAME: Note that enum values use C++ scoping rules, " - "meaning that enum values are siblings of their type, not children of " - "it. Therefore, \"FOO\" must be unique within the global scope, not " - "just within \"Bar\".\n"); -} - -TEST_F(ValidationErrorTest, EnumValueAlreadyDefinedInParentNonGlobal) { - BuildFileWithErrors( - "name: \"foo.proto\" " - "package: \"pkg\" " - "enum_type { name: \"Foo\" value { name: \"FOO\" number: 1 } } " - "enum_type { name: \"Bar\" value { name: \"FOO\" number: 1 } } ", - - "foo.proto: pkg.FOO: NAME: \"FOO\" is already defined in \"pkg\".\n" - "foo.proto: pkg.FOO: NAME: Note that enum values use C++ scoping rules, " - "meaning that enum values are siblings of their type, not children of " - "it. Therefore, \"FOO\" must be unique within \"pkg\", not just within " - "\"Bar\".\n"); -} - -TEST_F(ValidationErrorTest, MissingName) { - BuildFileWithErrors( - "name: \"foo.proto\" " - "message_type { }", - - "foo.proto: : NAME: Missing name.\n"); -} - -TEST_F(ValidationErrorTest, InvalidName) { - BuildFileWithErrors( - "name: \"foo.proto\" " - "message_type { name: \"$\" }", - - "foo.proto: $: NAME: \"$\" is not a valid identifier.\n"); -} - -TEST_F(ValidationErrorTest, InvalidPackageName) { - BuildFileWithErrors( - "name: \"foo.proto\" " - "package: \"foo.$\"", - - "foo.proto: foo.$: NAME: \"$\" is not a valid identifier.\n"); -} - -TEST_F(ValidationErrorTest, MissingFileName) { - BuildFileWithErrors( - "", - - ": : OTHER: Missing field: FileDescriptorProto.name.\n"); -} - -TEST_F(ValidationErrorTest, DupeDependency) { - BuildFile("name: \"foo.proto\""); - BuildFileWithErrors( - "name: \"bar.proto\" " - "dependency: \"foo.proto\" " - "dependency: \"foo.proto\" ", - - "bar.proto: bar.proto: OTHER: Import \"foo.proto\" was listed twice.\n"); -} - -TEST_F(ValidationErrorTest, UnknownDependency) { - BuildFileWithErrors( - "name: \"bar.proto\" " - "dependency: \"foo.proto\" ", - - "bar.proto: bar.proto: OTHER: Import \"foo.proto\" has not been loaded.\n"); -} - -TEST_F(ValidationErrorTest, InvalidPublicDependencyIndex) { - BuildFile("name: \"foo.proto\""); - BuildFileWithErrors( - "name: \"bar.proto\" " - "dependency: \"foo.proto\" " - "public_dependency: 1", - "bar.proto: bar.proto: OTHER: Invalid public dependency index.\n"); -} - -TEST_F(ValidationErrorTest, ForeignUnimportedPackageNoCrash) { - // Used to crash: If we depend on a non-existent file and then refer to a - // package defined in a file that we didn't import, and that package is - // nested within a parent package which this file is also in, and we don't - // include that parent package in the name (i.e. we do a relative lookup)... - // Yes, really. - BuildFile( - "name: 'foo.proto' " - "package: 'outer.foo' "); - BuildFileWithErrors( - "name: 'bar.proto' " - "dependency: 'baz.proto' " - "package: 'outer.bar' " - "message_type { " - " name: 'Bar' " - " field { name:'bar' number:1 label:LABEL_OPTIONAL type_name:'foo.Foo' }" - "}", - - "bar.proto: bar.proto: OTHER: Import \"baz.proto\" has not been loaded.\n" - "bar.proto: outer.bar.Bar.bar: TYPE: \"outer.foo\" seems to be defined in " - "\"foo.proto\", which is not imported by \"bar.proto\". To use it here, " - "please add the necessary import.\n"); -} - -TEST_F(ValidationErrorTest, DupeFile) { - BuildFile( - "name: \"foo.proto\" " - "message_type { name: \"Foo\" }"); - // Note: We should *not* get redundant errors about "Foo" already being - // defined. - BuildFileWithErrors( - "name: \"foo.proto\" " - "message_type { name: \"Foo\" } " - // Add another type so that the files aren't identical (in which case there - // would be no error). - "enum_type { name: \"Bar\" }", - - "foo.proto: foo.proto: OTHER: A file with this name is already in the " - "pool.\n"); -} - -TEST_F(ValidationErrorTest, FieldInExtensionRange) { - BuildFileWithErrors( - "name: \"foo.proto\" " - "message_type {" - " name: \"Foo\"" - " field { name: \"foo\" number: 9 label:LABEL_OPTIONAL type:TYPE_INT32 }" - " field { name: \"bar\" number: 10 label:LABEL_OPTIONAL type:TYPE_INT32 }" - " field { name: \"baz\" number: 19 label:LABEL_OPTIONAL type:TYPE_INT32 }" - " field { name: \"qux\" number: 20 label:LABEL_OPTIONAL type:TYPE_INT32 }" - " extension_range { start: 10 end: 20 }" - "}", - - "foo.proto: Foo.bar: NUMBER: Extension range 10 to 19 includes field " - "\"bar\" (10).\n" - "foo.proto: Foo.baz: NUMBER: Extension range 10 to 19 includes field " - "\"baz\" (19).\n"); -} - -TEST_F(ValidationErrorTest, OverlappingExtensionRanges) { - BuildFileWithErrors( - "name: \"foo.proto\" " - "message_type {" - " name: \"Foo\"" - " extension_range { start: 10 end: 20 }" - " extension_range { start: 20 end: 30 }" - " extension_range { start: 19 end: 21 }" - "}", - - "foo.proto: Foo: NUMBER: Extension range 19 to 20 overlaps with " - "already-defined range 10 to 19.\n" - "foo.proto: Foo: NUMBER: Extension range 19 to 20 overlaps with " - "already-defined range 20 to 29.\n"); -} - -TEST_F(ValidationErrorTest, InvalidDefaults) { - BuildFileWithErrors( - "name: \"foo.proto\" " - "message_type {" - " name: \"Foo\"" - - // Invalid number. - " field { name: \"foo\" number: 1 label: LABEL_OPTIONAL type: TYPE_INT32" - " default_value: \"abc\" }" - - // Empty default value. - " field { name: \"bar\" number: 2 label: LABEL_OPTIONAL type: TYPE_INT32" - " default_value: \"\" }" - - // Invalid boolean. - " field { name: \"baz\" number: 3 label: LABEL_OPTIONAL type: TYPE_BOOL" - " default_value: \"abc\" }" - - // Messages can't have defaults. - " field { name: \"qux\" number: 4 label: LABEL_OPTIONAL type: TYPE_MESSAGE" - " default_value: \"abc\" type_name: \"Foo\" }" - - // Same thing, but we don't know that this field has message type until - // we look up the type name. - " field { name: \"quux\" number: 5 label: LABEL_OPTIONAL" - " default_value: \"abc\" type_name: \"Foo\" }" - - // Repeateds can't have defaults. - " field { name: \"corge\" number: 6 label: LABEL_REPEATED type: TYPE_INT32" - " default_value: \"1\" }" - "}", - - "foo.proto: Foo.foo: DEFAULT_VALUE: Couldn't parse default value.\n" - "foo.proto: Foo.bar: DEFAULT_VALUE: Couldn't parse default value.\n" - "foo.proto: Foo.baz: DEFAULT_VALUE: Boolean default must be true or " - "false.\n" - "foo.proto: Foo.qux: DEFAULT_VALUE: Messages can't have default values.\n" - "foo.proto: Foo.corge: DEFAULT_VALUE: Repeated fields can't have default " - "values.\n" - // This ends up being reported later because the error is detected at - // cross-linking time. - "foo.proto: Foo.quux: DEFAULT_VALUE: Messages can't have default " - "values.\n"); -} - -TEST_F(ValidationErrorTest, NegativeFieldNumber) { - BuildFileWithErrors( - "name: \"foo.proto\" " - "message_type {" - " name: \"Foo\"" - " field { name: \"foo\" number: -1 label:LABEL_OPTIONAL type:TYPE_INT32 }" - "}", - - "foo.proto: Foo.foo: NUMBER: Field numbers must be positive integers.\n"); -} - -TEST_F(ValidationErrorTest, HugeFieldNumber) { - BuildFileWithErrors( - "name: \"foo.proto\" " - "message_type {" - " name: \"Foo\"" - " field { name: \"foo\" number: 0x70000000 " - " label:LABEL_OPTIONAL type:TYPE_INT32 }" - "}", - - "foo.proto: Foo.foo: NUMBER: Field numbers cannot be greater than " - "536870911.\n"); -} - -TEST_F(ValidationErrorTest, ReservedFieldNumber) { - BuildFileWithErrors( - "name: \"foo.proto\" " - "message_type {" - " name: \"Foo\"" - " field {name:\"foo\" number: 18999 label:LABEL_OPTIONAL type:TYPE_INT32 }" - " field {name:\"bar\" number: 19000 label:LABEL_OPTIONAL type:TYPE_INT32 }" - " field {name:\"baz\" number: 19999 label:LABEL_OPTIONAL type:TYPE_INT32 }" - " field {name:\"qux\" number: 20000 label:LABEL_OPTIONAL type:TYPE_INT32 }" - "}", - - "foo.proto: Foo.bar: NUMBER: Field numbers 19000 through 19999 are " - "reserved for the protocol buffer library implementation.\n" - "foo.proto: Foo.baz: NUMBER: Field numbers 19000 through 19999 are " - "reserved for the protocol buffer library implementation.\n"); -} - -TEST_F(ValidationErrorTest, ExtensionMissingExtendee) { - BuildFileWithErrors( - "name: \"foo.proto\" " - "message_type {" - " name: \"Foo\"" - " extension { name: \"foo\" number: 1 label: LABEL_OPTIONAL" - " type_name: \"Foo\" }" - "}", - - "foo.proto: Foo.foo: EXTENDEE: FieldDescriptorProto.extendee not set for " - "extension field.\n"); -} - -TEST_F(ValidationErrorTest, NonExtensionWithExtendee) { - BuildFileWithErrors( - "name: \"foo.proto\" " - "message_type {" - " name: \"Bar\"" - " extension_range { start: 1 end: 2 }" - "}" - "message_type {" - " name: \"Foo\"" - " field { name: \"foo\" number: 1 label: LABEL_OPTIONAL" - " type_name: \"Foo\" extendee: \"Bar\" }" - "}", - - "foo.proto: Foo.foo: EXTENDEE: FieldDescriptorProto.extendee set for " - "non-extension field.\n"); -} - -TEST_F(ValidationErrorTest, FieldNumberConflict) { - BuildFileWithErrors( - "name: \"foo.proto\" " - "message_type {" - " name: \"Foo\"" - " field { name: \"foo\" number: 1 label:LABEL_OPTIONAL type:TYPE_INT32 }" - " field { name: \"bar\" number: 1 label:LABEL_OPTIONAL type:TYPE_INT32 }" - "}", - - "foo.proto: Foo.bar: NUMBER: Field number 1 has already been used in " - "\"Foo\" by field \"foo\".\n"); -} - -TEST_F(ValidationErrorTest, BadMessageSetExtensionType) { - BuildFileWithErrors( - "name: \"foo.proto\" " - "message_type {" - " name: \"MessageSet\"" - " options { message_set_wire_format: true }" - " extension_range { start: 4 end: 5 }" - "}" - "message_type {" - " name: \"Foo\"" - " extension { name:\"foo\" number:4 label:LABEL_OPTIONAL type:TYPE_INT32" - " extendee: \"MessageSet\" }" - "}", - - "foo.proto: Foo.foo: TYPE: Extensions of MessageSets must be optional " - "messages.\n"); -} - -TEST_F(ValidationErrorTest, BadMessageSetExtensionLabel) { - BuildFileWithErrors( - "name: \"foo.proto\" " - "message_type {" - " name: \"MessageSet\"" - " options { message_set_wire_format: true }" - " extension_range { start: 4 end: 5 }" - "}" - "message_type {" - " name: \"Foo\"" - " extension { name:\"foo\" number:4 label:LABEL_REPEATED type:TYPE_MESSAGE" - " type_name: \"Foo\" extendee: \"MessageSet\" }" - "}", - - "foo.proto: Foo.foo: TYPE: Extensions of MessageSets must be optional " - "messages.\n"); -} - -TEST_F(ValidationErrorTest, FieldInMessageSet) { - BuildFileWithErrors( - "name: \"foo.proto\" " - "message_type {" - " name: \"Foo\"" - " options { message_set_wire_format: true }" - " field { name: \"foo\" number: 1 label:LABEL_OPTIONAL type:TYPE_INT32 }" - "}", - - "foo.proto: Foo.foo: NAME: MessageSets cannot have fields, only " - "extensions.\n"); -} - -TEST_F(ValidationErrorTest, NegativeExtensionRangeNumber) { - BuildFileWithErrors( - "name: \"foo.proto\" " - "message_type {" - " name: \"Foo\"" - " extension_range { start: -10 end: -1 }" - "}", - - "foo.proto: Foo: NUMBER: Extension numbers must be positive integers.\n"); -} - -TEST_F(ValidationErrorTest, HugeExtensionRangeNumber) { - BuildFileWithErrors( - "name: \"foo.proto\" " - "message_type {" - " name: \"Foo\"" - " extension_range { start: 1 end: 0x70000000 }" - "}", - - "foo.proto: Foo: NUMBER: Extension numbers cannot be greater than " - "536870911.\n"); -} - -TEST_F(ValidationErrorTest, ExtensionRangeEndBeforeStart) { - BuildFileWithErrors( - "name: \"foo.proto\" " - "message_type {" - " name: \"Foo\"" - " extension_range { start: 10 end: 10 }" - " extension_range { start: 10 end: 5 }" - "}", - - "foo.proto: Foo: NUMBER: Extension range end number must be greater than " - "start number.\n" - "foo.proto: Foo: NUMBER: Extension range end number must be greater than " - "start number.\n"); -} - -TEST_F(ValidationErrorTest, EmptyEnum) { - BuildFileWithErrors( - "name: \"foo.proto\" " - "enum_type { name: \"Foo\" }" - // Also use the empty enum in a message to make sure there are no crashes - // during validation (possible if the code attempts to derive a default - // value for the field). - "message_type {" - " name: \"Bar\"" - " field { name: \"foo\" number: 1 label:LABEL_OPTIONAL type_name:\"Foo\" }" - " field { name: \"bar\" number: 2 label:LABEL_OPTIONAL type_name:\"Foo\" " - " default_value: \"NO_SUCH_VALUE\" }" - "}", - - "foo.proto: Foo: NAME: Enums must contain at least one value.\n" - "foo.proto: Bar.bar: DEFAULT_VALUE: Enum type \"Foo\" has no value named " - "\"NO_SUCH_VALUE\".\n"); -} - -TEST_F(ValidationErrorTest, UndefinedExtendee) { - BuildFileWithErrors( - "name: \"foo.proto\" " - "message_type {" - " name: \"Foo\"" - " extension { name:\"foo\" number:1 label:LABEL_OPTIONAL type:TYPE_INT32" - " extendee: \"Bar\" }" - "}", - - "foo.proto: Foo.foo: EXTENDEE: \"Bar\" is not defined.\n"); -} - -TEST_F(ValidationErrorTest, NonMessageExtendee) { - BuildFileWithErrors( - "name: \"foo.proto\" " - "enum_type { name: \"Bar\" value { name:\"DUMMY\" number:0 } }" - "message_type {" - " name: \"Foo\"" - " extension { name:\"foo\" number:1 label:LABEL_OPTIONAL type:TYPE_INT32" - " extendee: \"Bar\" }" - "}", - - "foo.proto: Foo.foo: EXTENDEE: \"Bar\" is not a message type.\n"); -} - -TEST_F(ValidationErrorTest, NotAnExtensionNumber) { - BuildFileWithErrors( - "name: \"foo.proto\" " - "message_type {" - " name: \"Bar\"" - "}" - "message_type {" - " name: \"Foo\"" - " extension { name:\"foo\" number:1 label:LABEL_OPTIONAL type:TYPE_INT32" - " extendee: \"Bar\" }" - "}", - - "foo.proto: Foo.foo: NUMBER: \"Bar\" does not declare 1 as an extension " - "number.\n"); -} - -TEST_F(ValidationErrorTest, UndefinedFieldType) { - BuildFileWithErrors( - "name: \"foo.proto\" " - "message_type {" - " name: \"Foo\"" - " field { name:\"foo\" number:1 label:LABEL_OPTIONAL type_name:\"Bar\" }" - "}", - - "foo.proto: Foo.foo: TYPE: \"Bar\" is not defined.\n"); -} - -TEST_F(ValidationErrorTest, FieldTypeDefinedInUndeclaredDependency) { - BuildFile( - "name: \"bar.proto\" " - "message_type { name: \"Bar\" } "); - - BuildFileWithErrors( - "name: \"foo.proto\" " - "message_type {" - " name: \"Foo\"" - " field { name:\"foo\" number:1 label:LABEL_OPTIONAL type_name:\"Bar\" }" - "}", - "foo.proto: Foo.foo: TYPE: \"Bar\" seems to be defined in \"bar.proto\", " - "which is not imported by \"foo.proto\". To use it here, please add the " - "necessary import.\n"); -} - -TEST_F(ValidationErrorTest, FieldTypeDefinedInIndirectDependency) { - // Test for hidden dependencies. - // - // // bar.proto - // message Bar{} - // - // // forward.proto - // import "bar.proto" - // - // // foo.proto - // import "forward.proto" - // message Foo { - // optional Bar foo = 1; // Error, needs to import bar.proto explicitly. - // } - // - BuildFile( - "name: \"bar.proto\" " - "message_type { name: \"Bar\" }"); - - BuildFile( - "name: \"forward.proto\"" - "dependency: \"bar.proto\""); - - BuildFileWithErrors( - "name: \"foo.proto\" " - "dependency: \"forward.proto\" " - "message_type {" - " name: \"Foo\"" - " field { name:\"foo\" number:1 label:LABEL_OPTIONAL type_name:\"Bar\" }" - "}", - "foo.proto: Foo.foo: TYPE: \"Bar\" seems to be defined in \"bar.proto\", " - "which is not imported by \"foo.proto\". To use it here, please add the " - "necessary import.\n"); -} - -TEST_F(ValidationErrorTest, FieldTypeDefinedInPublicDependency) { - // Test for public dependencies. - // - // // bar.proto - // message Bar{} - // - // // forward.proto - // import public "bar.proto" - // - // // foo.proto - // import "forward.proto" - // message Foo { - // optional Bar foo = 1; // Correct. "bar.proto" is public imported into - // // forward.proto, so when "foo.proto" imports - // // "forward.proto", it imports "bar.proto" too. - // } - // - BuildFile( - "name: \"bar.proto\" " - "message_type { name: \"Bar\" }"); - - BuildFile( - "name: \"forward.proto\"" - "dependency: \"bar.proto\" " - "public_dependency: 0"); - - BuildFile( - "name: \"foo.proto\" " - "dependency: \"forward.proto\" " - "message_type {" - " name: \"Foo\"" - " field { name:\"foo\" number:1 label:LABEL_OPTIONAL type_name:\"Bar\" }" - "}"); -} - -TEST_F(ValidationErrorTest, FieldTypeDefinedInTransitivePublicDependency) { - // Test for public dependencies. - // - // // bar.proto - // message Bar{} - // - // // forward.proto - // import public "bar.proto" - // - // // forward2.proto - // import public "forward.proto" - // - // // foo.proto - // import "forward2.proto" - // message Foo { - // optional Bar foo = 1; // Correct, public imports are transitive. - // } - // - BuildFile( - "name: \"bar.proto\" " - "message_type { name: \"Bar\" }"); - - BuildFile( - "name: \"forward.proto\"" - "dependency: \"bar.proto\" " - "public_dependency: 0"); - - BuildFile( - "name: \"forward2.proto\"" - "dependency: \"forward.proto\" " - "public_dependency: 0"); - - BuildFile( - "name: \"foo.proto\" " - "dependency: \"forward2.proto\" " - "message_type {" - " name: \"Foo\"" - " field { name:\"foo\" number:1 label:LABEL_OPTIONAL type_name:\"Bar\" }" - "}"); -} - -TEST_F(ValidationErrorTest, - FieldTypeDefinedInPrivateDependencyOfPublicDependency) { - // Test for public dependencies. - // - // // bar.proto - // message Bar{} - // - // // forward.proto - // import "bar.proto" - // - // // forward2.proto - // import public "forward.proto" - // - // // foo.proto - // import "forward2.proto" - // message Foo { - // optional Bar foo = 1; // Error, the "bar.proto" is not public imported - // // into "forward.proto", so will not be imported - // // into either "forward2.proto" or "foo.proto". - // } - // - BuildFile( - "name: \"bar.proto\" " - "message_type { name: \"Bar\" }"); - - BuildFile( - "name: \"forward.proto\"" - "dependency: \"bar.proto\""); - - BuildFile( - "name: \"forward2.proto\"" - "dependency: \"forward.proto\" " - "public_dependency: 0"); - - BuildFileWithErrors( - "name: \"foo.proto\" " - "dependency: \"forward2.proto\" " - "message_type {" - " name: \"Foo\"" - " field { name:\"foo\" number:1 label:LABEL_OPTIONAL type_name:\"Bar\" }" - "}", - "foo.proto: Foo.foo: TYPE: \"Bar\" seems to be defined in \"bar.proto\", " - "which is not imported by \"foo.proto\". To use it here, please add the " - "necessary import.\n"); -} - - -TEST_F(ValidationErrorTest, SearchMostLocalFirst) { - // The following should produce an error that Bar.Baz is not defined: - // message Bar { message Baz {} } - // message Foo { - // message Bar { - // // Placing "message Baz{}" here, or removing Foo.Bar altogether, - // // would fix the error. - // } - // optional Bar.Baz baz = 1; - // } - // An one point the lookup code incorrectly did not produce an error in this - // case, because when looking for Bar.Baz, it would try "Foo.Bar.Baz" first, - // fail, and ten try "Bar.Baz" and succeed, even though "Bar" should actually - // refer to the inner Bar, not the outer one. - BuildFileWithErrors( - "name: \"foo.proto\" " - "message_type {" - " name: \"Bar\"" - " nested_type { name: \"Baz\" }" - "}" - "message_type {" - " name: \"Foo\"" - " nested_type { name: \"Bar\" }" - " field { name:\"baz\" number:1 label:LABEL_OPTIONAL" - " type_name:\"Bar.Baz\" }" - "}", - - "foo.proto: Foo.baz: TYPE: \"Bar.Baz\" is not defined.\n"); -} - -TEST_F(ValidationErrorTest, SearchMostLocalFirst2) { - // This test would find the most local "Bar" first, and does, but - // proceeds to find the outer one because the inner one's not an - // aggregate. - BuildFile( - "name: \"foo.proto\" " - "message_type {" - " name: \"Bar\"" - " nested_type { name: \"Baz\" }" - "}" - "message_type {" - " name: \"Foo\"" - " field { name: \"Bar\" number:1 type:TYPE_BYTES } " - " field { name:\"baz\" number:2 label:LABEL_OPTIONAL" - " type_name:\"Bar.Baz\" }" - "}"); -} - -TEST_F(ValidationErrorTest, PackageOriginallyDeclaredInTransitiveDependent) { - // Imagine we have the following: - // - // foo.proto: - // package foo.bar; - // bar.proto: - // package foo.bar; - // import "foo.proto"; - // message Bar {} - // baz.proto: - // package foo; - // import "bar.proto" - // message Baz { optional bar.Bar qux = 1; } - // - // When validating baz.proto, we will look up "bar.Bar". As part of this - // lookup, we first lookup "bar" then try to find "Bar" within it. "bar" - // should resolve to "foo.bar". Note, though, that "foo.bar" was originally - // defined in foo.proto, which is not a direct dependency of baz.proto. The - // implementation of FindSymbol() normally only returns symbols in direct - // dependencies, not indirect ones. This test insures that this does not - // prevent it from finding "foo.bar". - - BuildFile( - "name: \"foo.proto\" " - "package: \"foo.bar\" "); - BuildFile( - "name: \"bar.proto\" " - "package: \"foo.bar\" " - "dependency: \"foo.proto\" " - "message_type { name: \"Bar\" }"); - BuildFile( - "name: \"baz.proto\" " - "package: \"foo\" " - "dependency: \"bar.proto\" " - "message_type { " - " name: \"Baz\" " - " field { name:\"qux\" number:1 label:LABEL_OPTIONAL " - " type_name:\"bar.Bar\" }" - "}"); -} - -TEST_F(ValidationErrorTest, FieldTypeNotAType) { - BuildFileWithErrors( - "name: \"foo.proto\" " - "message_type {" - " name: \"Foo\"" - " field { name:\"foo\" number:1 label:LABEL_OPTIONAL " - " type_name:\".Foo.bar\" }" - " field { name:\"bar\" number:2 label:LABEL_OPTIONAL type:TYPE_INT32 }" - "}", - - "foo.proto: Foo.foo: TYPE: \".Foo.bar\" is not a type.\n"); -} - -TEST_F(ValidationErrorTest, RelativeFieldTypeNotAType) { - BuildFileWithErrors( - "name: \"foo.proto\" " - "message_type {" - " nested_type {" - " name: \"Bar\"" - " field { name:\"Baz\" number:2 label:LABEL_OPTIONAL type:TYPE_INT32 }" - " }" - " name: \"Foo\"" - " field { name:\"foo\" number:1 label:LABEL_OPTIONAL " - " type_name:\"Bar.Baz\" }" - "}", - "foo.proto: Foo.foo: TYPE: \"Bar.Baz\" is not a type.\n"); -} - -TEST_F(ValidationErrorTest, FieldTypeMayBeItsName) { - BuildFile( - "name: \"foo.proto\" " - "message_type {" - " name: \"Bar\"" - "}" - "message_type {" - " name: \"Foo\"" - " field { name:\"Bar\" number:1 label:LABEL_OPTIONAL type_name:\"Bar\" }" - "}"); -} - -TEST_F(ValidationErrorTest, EnumFieldTypeIsMessage) { - BuildFileWithErrors( - "name: \"foo.proto\" " - "message_type { name: \"Bar\" } " - "message_type {" - " name: \"Foo\"" - " field { name:\"foo\" number:1 label:LABEL_OPTIONAL type:TYPE_ENUM" - " type_name:\"Bar\" }" - "}", - - "foo.proto: Foo.foo: TYPE: \"Bar\" is not an enum type.\n"); -} - -TEST_F(ValidationErrorTest, MessageFieldTypeIsEnum) { - BuildFileWithErrors( - "name: \"foo.proto\" " - "enum_type { name: \"Bar\" value { name:\"DUMMY\" number:0 } } " - "message_type {" - " name: \"Foo\"" - " field { name:\"foo\" number:1 label:LABEL_OPTIONAL type:TYPE_MESSAGE" - " type_name:\"Bar\" }" - "}", - - "foo.proto: Foo.foo: TYPE: \"Bar\" is not a message type.\n"); -} - -TEST_F(ValidationErrorTest, BadEnumDefaultValue) { - BuildFileWithErrors( - "name: \"foo.proto\" " - "enum_type { name: \"Bar\" value { name:\"DUMMY\" number:0 } } " - "message_type {" - " name: \"Foo\"" - " field { name:\"foo\" number:1 label:LABEL_OPTIONAL type_name:\"Bar\"" - " default_value:\"NO_SUCH_VALUE\" }" - "}", - - "foo.proto: Foo.foo: DEFAULT_VALUE: Enum type \"Bar\" has no value named " - "\"NO_SUCH_VALUE\".\n"); -} - -TEST_F(ValidationErrorTest, PrimitiveWithTypeName) { - BuildFileWithErrors( - "name: \"foo.proto\" " - "message_type {" - " name: \"Foo\"" - " field { name:\"foo\" number:1 label:LABEL_OPTIONAL type:TYPE_INT32" - " type_name:\"Foo\" }" - "}", - - "foo.proto: Foo.foo: TYPE: Field with primitive type has type_name.\n"); -} - -TEST_F(ValidationErrorTest, NonPrimitiveWithoutTypeName) { - BuildFileWithErrors( - "name: \"foo.proto\" " - "message_type {" - " name: \"Foo\"" - " field { name:\"foo\" number:1 label:LABEL_OPTIONAL type:TYPE_MESSAGE }" - "}", - - "foo.proto: Foo.foo: TYPE: Field with message or enum type missing " - "type_name.\n"); -} - -TEST_F(ValidationErrorTest, InputTypeNotDefined) { - BuildFileWithErrors( - "name: \"foo.proto\" " - "message_type { name: \"Foo\" } " - "service {" - " name: \"TestService\"" - " method { name: \"A\" input_type: \"Bar\" output_type: \"Foo\" }" - "}", - - "foo.proto: TestService.A: INPUT_TYPE: \"Bar\" is not defined.\n" - ); -} - -TEST_F(ValidationErrorTest, InputTypeNotAMessage) { - BuildFileWithErrors( - "name: \"foo.proto\" " - "message_type { name: \"Foo\" } " - "enum_type { name: \"Bar\" value { name:\"DUMMY\" number:0 } } " - "service {" - " name: \"TestService\"" - " method { name: \"A\" input_type: \"Bar\" output_type: \"Foo\" }" - "}", - - "foo.proto: TestService.A: INPUT_TYPE: \"Bar\" is not a message type.\n" - ); -} - -TEST_F(ValidationErrorTest, OutputTypeNotDefined) { - BuildFileWithErrors( - "name: \"foo.proto\" " - "message_type { name: \"Foo\" } " - "service {" - " name: \"TestService\"" - " method { name: \"A\" input_type: \"Foo\" output_type: \"Bar\" }" - "}", - - "foo.proto: TestService.A: OUTPUT_TYPE: \"Bar\" is not defined.\n" - ); -} - -TEST_F(ValidationErrorTest, OutputTypeNotAMessage) { - BuildFileWithErrors( - "name: \"foo.proto\" " - "message_type { name: \"Foo\" } " - "enum_type { name: \"Bar\" value { name:\"DUMMY\" number:0 } } " - "service {" - " name: \"TestService\"" - " method { name: \"A\" input_type: \"Foo\" output_type: \"Bar\" }" - "}", - - "foo.proto: TestService.A: OUTPUT_TYPE: \"Bar\" is not a message type.\n" - ); -} - - -TEST_F(ValidationErrorTest, IllegalPackedField) { - BuildFileWithErrors( - "name: \"foo.proto\" " - "message_type {\n" - " name: \"Foo\"" - " field { name:\"packed_string\" number:1 label:LABEL_REPEATED " - " type:TYPE_STRING " - " options { uninterpreted_option {" - " name { name_part: \"packed\" is_extension: false }" - " identifier_value: \"true\" }}}\n" - " field { name:\"packed_message\" number:3 label:LABEL_REPEATED " - " type_name: \"Foo\"" - " options { uninterpreted_option {" - " name { name_part: \"packed\" is_extension: false }" - " identifier_value: \"true\" }}}\n" - " field { name:\"optional_int32\" number: 4 label: LABEL_OPTIONAL " - " type:TYPE_INT32 " - " options { uninterpreted_option {" - " name { name_part: \"packed\" is_extension: false }" - " identifier_value: \"true\" }}}\n" - "}", - - "foo.proto: Foo.packed_string: TYPE: [packed = true] can only be " - "specified for repeated primitive fields.\n" - "foo.proto: Foo.packed_message: TYPE: [packed = true] can only be " - "specified for repeated primitive fields.\n" - "foo.proto: Foo.optional_int32: TYPE: [packed = true] can only be " - "specified for repeated primitive fields.\n" - ); -} - -TEST_F(ValidationErrorTest, OptionWrongType) { - BuildFileWithErrors( - "name: \"foo.proto\" " - "message_type { " - " name: \"TestMessage\" " - " field { name:\"foo\" number:1 label:LABEL_OPTIONAL type:TYPE_STRING " - " options { uninterpreted_option { name { name_part: \"ctype\" " - " is_extension: false }" - " positive_int_value: 1 }" - " }" - " }" - "}\n", - - "foo.proto: TestMessage.foo: OPTION_VALUE: Value must be identifier for " - "enum-valued option \"google.protobuf.FieldOptions.ctype\".\n"); -} - -TEST_F(ValidationErrorTest, OptionExtendsAtomicType) { - BuildFileWithErrors( - "name: \"foo.proto\" " - "message_type { " - " name: \"TestMessage\" " - " field { name:\"foo\" number:1 label:LABEL_OPTIONAL type:TYPE_STRING " - " options { uninterpreted_option { name { name_part: \"ctype\" " - " is_extension: false }" - " name { name_part: \"foo\" " - " is_extension: true }" - " positive_int_value: 1 }" - " }" - " }" - "}\n", - - "foo.proto: TestMessage.foo: OPTION_NAME: Option \"ctype\" is an " - "atomic type, not a message.\n"); -} - -TEST_F(ValidationErrorTest, DupOption) { - BuildFileWithErrors( - "name: \"foo.proto\" " - "message_type { " - " name: \"TestMessage\" " - " field { name:\"foo\" number:1 label:LABEL_OPTIONAL type:TYPE_UINT32 " - " options { uninterpreted_option { name { name_part: \"ctype\" " - " is_extension: false }" - " identifier_value: \"CORD\" }" - " uninterpreted_option { name { name_part: \"ctype\" " - " is_extension: false }" - " identifier_value: \"CORD\" }" - " }" - " }" - "}\n", - - "foo.proto: TestMessage.foo: OPTION_NAME: Option \"ctype\" was " - "already set.\n"); -} - -TEST_F(ValidationErrorTest, InvalidOptionName) { - BuildFileWithErrors( - "name: \"foo.proto\" " - "message_type { " - " name: \"TestMessage\" " - " field { name:\"foo\" number:1 label:LABEL_OPTIONAL type:TYPE_BOOL " - " options { uninterpreted_option { " - " name { name_part: \"uninterpreted_option\" " - " is_extension: false }" - " positive_int_value: 1 " - " }" - " }" - " }" - "}\n", - - "foo.proto: TestMessage.foo: OPTION_NAME: Option must not use " - "reserved name \"uninterpreted_option\".\n"); -} - -TEST_F(ValidationErrorTest, RepeatedOption) { - BuildDescriptorMessagesInTestPool(); - - BuildFileWithErrors( - "name: \"foo.proto\" " - "dependency: \"google/protobuf/descriptor.proto\" " - "extension { name: \"foo\" number: 7672757 label: LABEL_REPEATED " - " type: TYPE_FLOAT extendee: \"google.protobuf.FileOptions\" }" - "options { uninterpreted_option { name { name_part: \"foo\" " - " is_extension: true } " - " double_value: 1.2 } }", - - "foo.proto: foo.proto: OPTION_NAME: Option field \"(foo)\" is repeated. " - "Repeated options are not supported.\n"); -} - -TEST_F(ValidationErrorTest, CustomOptionConflictingFieldNumber) { - BuildDescriptorMessagesInTestPool(); - - BuildFileWithErrors( - "name: \"foo.proto\" " - "dependency: \"google/protobuf/descriptor.proto\" " - "extension { name: \"foo1\" number: 7672757 label: LABEL_OPTIONAL " - " type: TYPE_INT32 extendee: \"google.protobuf.FieldOptions\" }" - "extension { name: \"foo2\" number: 7672757 label: LABEL_OPTIONAL " - " type: TYPE_INT32 extendee: \"google.protobuf.FieldOptions\" }", - - "foo.proto: foo2: NUMBER: Extension number 7672757 has already been used " - "in \"google.protobuf.FieldOptions\" by extension \"foo1\".\n"); -} - -TEST_F(ValidationErrorTest, Int32OptionValueOutOfPositiveRange) { - BuildDescriptorMessagesInTestPool(); - - BuildFileWithErrors( - "name: \"foo.proto\" " - "dependency: \"google/protobuf/descriptor.proto\" " - "extension { name: \"foo\" number: 7672757 label: LABEL_OPTIONAL " - " type: TYPE_INT32 extendee: \"google.protobuf.FileOptions\" }" - "options { uninterpreted_option { name { name_part: \"foo\" " - " is_extension: true } " - " positive_int_value: 0x80000000 } " - "}", - - "foo.proto: foo.proto: OPTION_VALUE: Value out of range " - "for int32 option \"foo\".\n"); -} - -TEST_F(ValidationErrorTest, Int32OptionValueOutOfNegativeRange) { - BuildDescriptorMessagesInTestPool(); - - BuildFileWithErrors( - "name: \"foo.proto\" " - "dependency: \"google/protobuf/descriptor.proto\" " - "extension { name: \"foo\" number: 7672757 label: LABEL_OPTIONAL " - " type: TYPE_INT32 extendee: \"google.protobuf.FileOptions\" }" - "options { uninterpreted_option { name { name_part: \"foo\" " - " is_extension: true } " - " negative_int_value: -0x80000001 } " - "}", - - "foo.proto: foo.proto: OPTION_VALUE: Value out of range " - "for int32 option \"foo\".\n"); -} - -TEST_F(ValidationErrorTest, Int32OptionValueIsNotPositiveInt) { - BuildDescriptorMessagesInTestPool(); - - BuildFileWithErrors( - "name: \"foo.proto\" " - "dependency: \"google/protobuf/descriptor.proto\" " - "extension { name: \"foo\" number: 7672757 label: LABEL_OPTIONAL " - " type: TYPE_INT32 extendee: \"google.protobuf.FileOptions\" }" - "options { uninterpreted_option { name { name_part: \"foo\" " - " is_extension: true } " - " string_value: \"5\" } }", - - "foo.proto: foo.proto: OPTION_VALUE: Value must be integer " - "for int32 option \"foo\".\n"); -} - -TEST_F(ValidationErrorTest, Int64OptionValueOutOfRange) { - BuildDescriptorMessagesInTestPool(); - - BuildFileWithErrors( - "name: \"foo.proto\" " - "dependency: \"google/protobuf/descriptor.proto\" " - "extension { name: \"foo\" number: 7672757 label: LABEL_OPTIONAL " - " type: TYPE_INT64 extendee: \"google.protobuf.FileOptions\" }" - "options { uninterpreted_option { name { name_part: \"foo\" " - " is_extension: true } " - " positive_int_value: 0x8000000000000000 } " - "}", - - "foo.proto: foo.proto: OPTION_VALUE: Value out of range " - "for int64 option \"foo\".\n"); -} - -TEST_F(ValidationErrorTest, Int64OptionValueIsNotPositiveInt) { - BuildDescriptorMessagesInTestPool(); - - BuildFileWithErrors( - "name: \"foo.proto\" " - "dependency: \"google/protobuf/descriptor.proto\" " - "extension { name: \"foo\" number: 7672757 label: LABEL_OPTIONAL " - " type: TYPE_INT64 extendee: \"google.protobuf.FileOptions\" }" - "options { uninterpreted_option { name { name_part: \"foo\" " - " is_extension: true } " - " identifier_value: \"5\" } }", - - "foo.proto: foo.proto: OPTION_VALUE: Value must be integer " - "for int64 option \"foo\".\n"); -} - -TEST_F(ValidationErrorTest, UInt32OptionValueOutOfRange) { - BuildDescriptorMessagesInTestPool(); - - BuildFileWithErrors( - "name: \"foo.proto\" " - "dependency: \"google/protobuf/descriptor.proto\" " - "extension { name: \"foo\" number: 7672757 label: LABEL_OPTIONAL " - " type: TYPE_UINT32 extendee: \"google.protobuf.FileOptions\" }" - "options { uninterpreted_option { name { name_part: \"foo\" " - " is_extension: true } " - " positive_int_value: 0x100000000 } }", - - "foo.proto: foo.proto: OPTION_VALUE: Value out of range " - "for uint32 option \"foo\".\n"); -} - -TEST_F(ValidationErrorTest, UInt32OptionValueIsNotPositiveInt) { - BuildDescriptorMessagesInTestPool(); - - BuildFileWithErrors( - "name: \"foo.proto\" " - "dependency: \"google/protobuf/descriptor.proto\" " - "extension { name: \"foo\" number: 7672757 label: LABEL_OPTIONAL " - " type: TYPE_UINT32 extendee: \"google.protobuf.FileOptions\" }" - "options { uninterpreted_option { name { name_part: \"foo\" " - " is_extension: true } " - " double_value: -5.6 } }", - - "foo.proto: foo.proto: OPTION_VALUE: Value must be non-negative integer " - "for uint32 option \"foo\".\n"); -} - -TEST_F(ValidationErrorTest, UInt64OptionValueIsNotPositiveInt) { - BuildDescriptorMessagesInTestPool(); - - BuildFileWithErrors( - "name: \"foo.proto\" " - "dependency: \"google/protobuf/descriptor.proto\" " - "extension { name: \"foo\" number: 7672757 label: LABEL_OPTIONAL " - " type: TYPE_UINT64 extendee: \"google.protobuf.FileOptions\" }" - "options { uninterpreted_option { name { name_part: \"foo\" " - " is_extension: true } " - " negative_int_value: -5 } }", - - "foo.proto: foo.proto: OPTION_VALUE: Value must be non-negative integer " - "for uint64 option \"foo\".\n"); -} - -TEST_F(ValidationErrorTest, FloatOptionValueIsNotNumber) { - BuildDescriptorMessagesInTestPool(); - - BuildFileWithErrors( - "name: \"foo.proto\" " - "dependency: \"google/protobuf/descriptor.proto\" " - "extension { name: \"foo\" number: 7672757 label: LABEL_OPTIONAL " - " type: TYPE_FLOAT extendee: \"google.protobuf.FileOptions\" }" - "options { uninterpreted_option { name { name_part: \"foo\" " - " is_extension: true } " - " string_value: \"bar\" } }", - - "foo.proto: foo.proto: OPTION_VALUE: Value must be number " - "for float option \"foo\".\n"); -} - -TEST_F(ValidationErrorTest, DoubleOptionValueIsNotNumber) { - BuildDescriptorMessagesInTestPool(); - - BuildFileWithErrors( - "name: \"foo.proto\" " - "dependency: \"google/protobuf/descriptor.proto\" " - "extension { name: \"foo\" number: 7672757 label: LABEL_OPTIONAL " - " type: TYPE_DOUBLE extendee: \"google.protobuf.FileOptions\" }" - "options { uninterpreted_option { name { name_part: \"foo\" " - " is_extension: true } " - " string_value: \"bar\" } }", - - "foo.proto: foo.proto: OPTION_VALUE: Value must be number " - "for double option \"foo\".\n"); -} - -TEST_F(ValidationErrorTest, BoolOptionValueIsNotTrueOrFalse) { - BuildDescriptorMessagesInTestPool(); - - BuildFileWithErrors( - "name: \"foo.proto\" " - "dependency: \"google/protobuf/descriptor.proto\" " - "extension { name: \"foo\" number: 7672757 label: LABEL_OPTIONAL " - " type: TYPE_BOOL extendee: \"google.protobuf.FileOptions\" }" - "options { uninterpreted_option { name { name_part: \"foo\" " - " is_extension: true } " - " identifier_value: \"bar\" } }", - - "foo.proto: foo.proto: OPTION_VALUE: Value must be \"true\" or \"false\" " - "for boolean option \"foo\".\n"); -} - -TEST_F(ValidationErrorTest, EnumOptionValueIsNotIdentifier) { - BuildDescriptorMessagesInTestPool(); - - BuildFileWithErrors( - "name: \"foo.proto\" " - "dependency: \"google/protobuf/descriptor.proto\" " - "enum_type { name: \"FooEnum\" value { name: \"BAR\" number: 1 } " - " value { name: \"BAZ\" number: 2 } }" - "extension { name: \"foo\" number: 7672757 label: LABEL_OPTIONAL " - " type: TYPE_ENUM type_name: \"FooEnum\" " - " extendee: \"google.protobuf.FileOptions\" }" - "options { uninterpreted_option { name { name_part: \"foo\" " - " is_extension: true } " - " string_value: \"QUUX\" } }", - - "foo.proto: foo.proto: OPTION_VALUE: Value must be identifier for " - "enum-valued option \"foo\".\n"); -} - -TEST_F(ValidationErrorTest, EnumOptionValueIsNotEnumValueName) { - BuildDescriptorMessagesInTestPool(); - - BuildFileWithErrors( - "name: \"foo.proto\" " - "dependency: \"google/protobuf/descriptor.proto\" " - "enum_type { name: \"FooEnum\" value { name: \"BAR\" number: 1 } " - " value { name: \"BAZ\" number: 2 } }" - "extension { name: \"foo\" number: 7672757 label: LABEL_OPTIONAL " - " type: TYPE_ENUM type_name: \"FooEnum\" " - " extendee: \"google.protobuf.FileOptions\" }" - "options { uninterpreted_option { name { name_part: \"foo\" " - " is_extension: true } " - " identifier_value: \"QUUX\" } }", - - "foo.proto: foo.proto: OPTION_VALUE: Enum type \"FooEnum\" has no value " - "named \"QUUX\" for option \"foo\".\n"); -} - -TEST_F(ValidationErrorTest, EnumOptionValueIsSiblingEnumValueName) { - BuildDescriptorMessagesInTestPool(); - - BuildFileWithErrors( - "name: \"foo.proto\" " - "dependency: \"google/protobuf/descriptor.proto\" " - "enum_type { name: \"FooEnum1\" value { name: \"BAR\" number: 1 } " - " value { name: \"BAZ\" number: 2 } }" - "enum_type { name: \"FooEnum2\" value { name: \"QUX\" number: 1 } " - " value { name: \"QUUX\" number: 2 } }" - "extension { name: \"foo\" number: 7672757 label: LABEL_OPTIONAL " - " type: TYPE_ENUM type_name: \"FooEnum1\" " - " extendee: \"google.protobuf.FileOptions\" }" - "options { uninterpreted_option { name { name_part: \"foo\" " - " is_extension: true } " - " identifier_value: \"QUUX\" } }", - - "foo.proto: foo.proto: OPTION_VALUE: Enum type \"FooEnum1\" has no value " - "named \"QUUX\" for option \"foo\". This appears to be a value from a " - "sibling type.\n"); -} - -TEST_F(ValidationErrorTest, StringOptionValueIsNotString) { - BuildDescriptorMessagesInTestPool(); - - BuildFileWithErrors( - "name: \"foo.proto\" " - "dependency: \"google/protobuf/descriptor.proto\" " - "extension { name: \"foo\" number: 7672757 label: LABEL_OPTIONAL " - " type: TYPE_STRING extendee: \"google.protobuf.FileOptions\" }" - "options { uninterpreted_option { name { name_part: \"foo\" " - " is_extension: true } " - " identifier_value: \"QUUX\" } }", - - "foo.proto: foo.proto: OPTION_VALUE: Value must be quoted string for " - "string option \"foo\".\n"); -} - -// Helper function for tests that check for aggregate value parsing -// errors. The "value" argument is embedded inside the -// "uninterpreted_option" portion of the result. -static string EmbedAggregateValue(const char* value) { - return strings::Substitute( - "name: \"foo.proto\" " - "dependency: \"google/protobuf/descriptor.proto\" " - "message_type { name: \"Foo\" } " - "extension { name: \"foo\" number: 7672757 label: LABEL_OPTIONAL " - " type: TYPE_MESSAGE type_name: \"Foo\" " - " extendee: \"google.protobuf.FileOptions\" }" - "options { uninterpreted_option { name { name_part: \"foo\" " - " is_extension: true } " - " $0 } }", - value); -} - -TEST_F(ValidationErrorTest, AggregateValueNotFound) { - BuildDescriptorMessagesInTestPool(); - - BuildFileWithErrors( - EmbedAggregateValue("string_value: \"\""), - "foo.proto: foo.proto: OPTION_VALUE: Option \"foo\" is a message. " - "To set the entire message, use syntax like " - "\"foo = { }\". To set fields within it, use " - "syntax like \"foo.foo = value\".\n"); -} - -TEST_F(ValidationErrorTest, AggregateValueParseError) { - BuildDescriptorMessagesInTestPool(); - - BuildFileWithErrors( - EmbedAggregateValue("aggregate_value: \"1+2\""), - "foo.proto: foo.proto: OPTION_VALUE: Error while parsing option " - "value for \"foo\": Expected identifier.\n"); -} - -TEST_F(ValidationErrorTest, AggregateValueUnknownFields) { - BuildDescriptorMessagesInTestPool(); - - BuildFileWithErrors( - EmbedAggregateValue("aggregate_value: \"x:100\""), - "foo.proto: foo.proto: OPTION_VALUE: Error while parsing option " - "value for \"foo\": Message type \"Foo\" has no field named \"x\".\n"); -} - -TEST_F(ValidationErrorTest, NotLiteImportsLite) { - BuildFile( - "name: \"bar.proto\" " - "options { optimize_for: LITE_RUNTIME } "); - - BuildFileWithErrors( - "name: \"foo.proto\" " - "dependency: \"bar.proto\" ", - - "foo.proto: foo.proto: OTHER: Files that do not use optimize_for = " - "LITE_RUNTIME cannot import files which do use this option. This file " - "is not lite, but it imports \"bar.proto\" which is.\n"); -} - -TEST_F(ValidationErrorTest, LiteExtendsNotLite) { - BuildFile( - "name: \"bar.proto\" " - "message_type: {" - " name: \"Bar\"" - " extension_range { start: 1 end: 1000 }" - "}"); - - BuildFileWithErrors( - "name: \"foo.proto\" " - "dependency: \"bar.proto\" " - "options { optimize_for: LITE_RUNTIME } " - "extension { name: \"ext\" number: 123 label: LABEL_OPTIONAL " - " type: TYPE_INT32 extendee: \"Bar\" }", - - "foo.proto: ext: EXTENDEE: Extensions to non-lite types can only be " - "declared in non-lite files. Note that you cannot extend a non-lite " - "type to contain a lite type, but the reverse is allowed.\n"); -} - -TEST_F(ValidationErrorTest, NoLiteServices) { - BuildFileWithErrors( - "name: \"foo.proto\" " - "options {" - " optimize_for: LITE_RUNTIME" - " cc_generic_services: true" - " java_generic_services: true" - "} " - "service { name: \"Foo\" }", - - "foo.proto: Foo: NAME: Files with optimize_for = LITE_RUNTIME cannot " - "define services unless you set both options cc_generic_services and " - "java_generic_sevices to false.\n"); - - BuildFile( - "name: \"bar.proto\" " - "options {" - " optimize_for: LITE_RUNTIME" - " cc_generic_services: false" - " java_generic_services: false" - "} " - "service { name: \"Bar\" }"); -} - -TEST_F(ValidationErrorTest, RollbackAfterError) { - // Build a file which contains every kind of construct but references an - // undefined type. All these constructs will be added to the symbol table - // before the undefined type error is noticed. The DescriptorPool will then - // have to roll everything back. - BuildFileWithErrors( - "name: \"foo.proto\" " - "message_type {" - " name: \"TestMessage\"" - " field { name:\"foo\" label:LABEL_OPTIONAL type:TYPE_INT32 number:1 }" - "} " - "enum_type {" - " name: \"TestEnum\"" - " value { name:\"BAR\" number:1 }" - "} " - "service {" - " name: \"TestService\"" - " method {" - " name: \"Baz\"" - " input_type: \"NoSuchType\"" // error - " output_type: \"TestMessage\"" - " }" - "}", - - "foo.proto: TestService.Baz: INPUT_TYPE: \"NoSuchType\" is not defined.\n" - ); - - // Make sure that if we build the same file again with the error fixed, - // it works. If the above rollback was incomplete, then some symbols will - // be left defined, and this second attempt will fail since it tries to - // re-define the same symbols. - BuildFile( - "name: \"foo.proto\" " - "message_type {" - " name: \"TestMessage\"" - " field { name:\"foo\" label:LABEL_OPTIONAL type:TYPE_INT32 number:1 }" - "} " - "enum_type {" - " name: \"TestEnum\"" - " value { name:\"BAR\" number:1 }" - "} " - "service {" - " name: \"TestService\"" - " method { name:\"Baz\"" - " input_type:\"TestMessage\"" - " output_type:\"TestMessage\" }" - "}"); -} - -TEST_F(ValidationErrorTest, ErrorsReportedToLogError) { - // Test that errors are reported to GOOGLE_LOG(ERROR) if no error collector is - // provided. - - FileDescriptorProto file_proto; - ASSERT_TRUE(TextFormat::ParseFromString( - "name: \"foo.proto\" " - "message_type { name: \"Foo\" } " - "message_type { name: \"Foo\" } ", - &file_proto)); - - vector errors; - - { - ScopedMemoryLog log; - EXPECT_TRUE(pool_.BuildFile(file_proto) == NULL); - errors = log.GetMessages(ERROR); - } - - ASSERT_EQ(2, errors.size()); - - EXPECT_EQ("Invalid proto descriptor for file \"foo.proto\":", errors[0]); - EXPECT_EQ(" Foo: \"Foo\" is already defined.", errors[1]); -} - -TEST_F(ValidationErrorTest, DisallowEnumAlias) { - BuildFileWithErrors( - "name: \"foo.proto\" " - "enum_type {" - " name: \"Bar\"" - " value { name:\"ENUM_A\" number:0 }" - " value { name:\"ENUM_B\" number:0 }" - " options { allow_alias: false }" - "}", - "foo.proto: Bar: NUMBER: " - "\"ENUM_B\" uses the same enum value as \"ENUM_A\". " - "If this is intended, set 'option allow_alias = true;' to the enum " - "definition.\n"); -} - -// =================================================================== -// DescriptorDatabase - -static void AddToDatabase(SimpleDescriptorDatabase* database, - const char* file_text) { - FileDescriptorProto file_proto; - EXPECT_TRUE(TextFormat::ParseFromString(file_text, &file_proto)); - database->Add(file_proto); -} - -class DatabaseBackedPoolTest : public testing::Test { - protected: - DatabaseBackedPoolTest() {} - - SimpleDescriptorDatabase database_; - - virtual void SetUp() { - AddToDatabase(&database_, - "name: 'foo.proto' " - "message_type { name:'Foo' extension_range { start: 1 end: 100 } } " - "enum_type { name:'TestEnum' value { name:'DUMMY' number:0 } } " - "service { name:'TestService' } "); - AddToDatabase(&database_, - "name: 'bar.proto' " - "dependency: 'foo.proto' " - "message_type { name:'Bar' } " - "extension { name:'foo_ext' extendee: '.Foo' number:5 " - " label:LABEL_OPTIONAL type:TYPE_INT32 } "); - // Baz has an undeclared dependency on Foo. - AddToDatabase(&database_, - "name: 'baz.proto' " - "message_type { " - " name:'Baz' " - " field { name:'foo' number:1 label:LABEL_OPTIONAL type_name:'Foo' } " - "}"); - } - - // We can't inject a file containing errors into a DescriptorPool, so we - // need an actual mock DescriptorDatabase to test errors. - class ErrorDescriptorDatabase : public DescriptorDatabase { - public: - ErrorDescriptorDatabase() {} - ~ErrorDescriptorDatabase() {} - - // implements DescriptorDatabase --------------------------------- - bool FindFileByName(const string& filename, - FileDescriptorProto* output) { - // error.proto and error2.proto cyclically import each other. - if (filename == "error.proto") { - output->Clear(); - output->set_name("error.proto"); - output->add_dependency("error2.proto"); - return true; - } else if (filename == "error2.proto") { - output->Clear(); - output->set_name("error2.proto"); - output->add_dependency("error.proto"); - return true; - } else { - return false; - } - } - bool FindFileContainingSymbol(const string& symbol_name, - FileDescriptorProto* output) { - return false; - } - bool FindFileContainingExtension(const string& containing_type, - int field_number, - FileDescriptorProto* output) { - return false; - } - }; - - // A DescriptorDatabase that counts how many times each method has been - // called and forwards to some other DescriptorDatabase. - class CallCountingDatabase : public DescriptorDatabase { - public: - CallCountingDatabase(DescriptorDatabase* wrapped_db) - : wrapped_db_(wrapped_db) { - Clear(); - } - ~CallCountingDatabase() {} - - DescriptorDatabase* wrapped_db_; - - int call_count_; - - void Clear() { - call_count_ = 0; - } - - // implements DescriptorDatabase --------------------------------- - bool FindFileByName(const string& filename, - FileDescriptorProto* output) { - ++call_count_; - return wrapped_db_->FindFileByName(filename, output); - } - bool FindFileContainingSymbol(const string& symbol_name, - FileDescriptorProto* output) { - ++call_count_; - return wrapped_db_->FindFileContainingSymbol(symbol_name, output); - } - bool FindFileContainingExtension(const string& containing_type, - int field_number, - FileDescriptorProto* output) { - ++call_count_; - return wrapped_db_->FindFileContainingExtension( - containing_type, field_number, output); - } - }; - - // A DescriptorDatabase which falsely always returns foo.proto when searching - // for any symbol or extension number. This shouldn't cause the - // DescriptorPool to reload foo.proto if it is already loaded. - class FalsePositiveDatabase : public DescriptorDatabase { - public: - FalsePositiveDatabase(DescriptorDatabase* wrapped_db) - : wrapped_db_(wrapped_db) {} - ~FalsePositiveDatabase() {} - - DescriptorDatabase* wrapped_db_; - - // implements DescriptorDatabase --------------------------------- - bool FindFileByName(const string& filename, - FileDescriptorProto* output) { - return wrapped_db_->FindFileByName(filename, output); - } - bool FindFileContainingSymbol(const string& symbol_name, - FileDescriptorProto* output) { - return FindFileByName("foo.proto", output); - } - bool FindFileContainingExtension(const string& containing_type, - int field_number, - FileDescriptorProto* output) { - return FindFileByName("foo.proto", output); - } - }; -}; - -TEST_F(DatabaseBackedPoolTest, FindFileByName) { - DescriptorPool pool(&database_); - - const FileDescriptor* foo = pool.FindFileByName("foo.proto"); - ASSERT_TRUE(foo != NULL); - EXPECT_EQ("foo.proto", foo->name()); - ASSERT_EQ(1, foo->message_type_count()); - EXPECT_EQ("Foo", foo->message_type(0)->name()); - - EXPECT_EQ(foo, pool.FindFileByName("foo.proto")); - - EXPECT_TRUE(pool.FindFileByName("no_such_file.proto") == NULL); -} - -TEST_F(DatabaseBackedPoolTest, FindDependencyBeforeDependent) { - DescriptorPool pool(&database_); - - const FileDescriptor* foo = pool.FindFileByName("foo.proto"); - ASSERT_TRUE(foo != NULL); - EXPECT_EQ("foo.proto", foo->name()); - ASSERT_EQ(1, foo->message_type_count()); - EXPECT_EQ("Foo", foo->message_type(0)->name()); - - const FileDescriptor* bar = pool.FindFileByName("bar.proto"); - ASSERT_TRUE(bar != NULL); - EXPECT_EQ("bar.proto", bar->name()); - ASSERT_EQ(1, bar->message_type_count()); - EXPECT_EQ("Bar", bar->message_type(0)->name()); - - ASSERT_EQ(1, bar->dependency_count()); - EXPECT_EQ(foo, bar->dependency(0)); -} - -TEST_F(DatabaseBackedPoolTest, FindDependentBeforeDependency) { - DescriptorPool pool(&database_); - - const FileDescriptor* bar = pool.FindFileByName("bar.proto"); - ASSERT_TRUE(bar != NULL); - EXPECT_EQ("bar.proto", bar->name()); - ASSERT_EQ(1, bar->message_type_count()); - ASSERT_EQ("Bar", bar->message_type(0)->name()); - - const FileDescriptor* foo = pool.FindFileByName("foo.proto"); - ASSERT_TRUE(foo != NULL); - EXPECT_EQ("foo.proto", foo->name()); - ASSERT_EQ(1, foo->message_type_count()); - ASSERT_EQ("Foo", foo->message_type(0)->name()); - - ASSERT_EQ(1, bar->dependency_count()); - EXPECT_EQ(foo, bar->dependency(0)); -} - -TEST_F(DatabaseBackedPoolTest, FindFileContainingSymbol) { - DescriptorPool pool(&database_); - - const FileDescriptor* file = pool.FindFileContainingSymbol("Foo"); - ASSERT_TRUE(file != NULL); - EXPECT_EQ("foo.proto", file->name()); - EXPECT_EQ(file, pool.FindFileByName("foo.proto")); - - EXPECT_TRUE(pool.FindFileContainingSymbol("NoSuchSymbol") == NULL); -} - -TEST_F(DatabaseBackedPoolTest, FindMessageTypeByName) { - DescriptorPool pool(&database_); - - const Descriptor* type = pool.FindMessageTypeByName("Foo"); - ASSERT_TRUE(type != NULL); - EXPECT_EQ("Foo", type->name()); - EXPECT_EQ(type->file(), pool.FindFileByName("foo.proto")); - - EXPECT_TRUE(pool.FindMessageTypeByName("NoSuchType") == NULL); -} - -TEST_F(DatabaseBackedPoolTest, FindExtensionByNumber) { - DescriptorPool pool(&database_); - - const Descriptor* foo = pool.FindMessageTypeByName("Foo"); - ASSERT_TRUE(foo != NULL); - - const FieldDescriptor* extension = pool.FindExtensionByNumber(foo, 5); - ASSERT_TRUE(extension != NULL); - EXPECT_EQ("foo_ext", extension->name()); - EXPECT_EQ(extension->file(), pool.FindFileByName("bar.proto")); - - EXPECT_TRUE(pool.FindExtensionByNumber(foo, 12) == NULL); -} - -TEST_F(DatabaseBackedPoolTest, FindAllExtensions) { - DescriptorPool pool(&database_); - - const Descriptor* foo = pool.FindMessageTypeByName("Foo"); - - for (int i = 0; i < 2; ++i) { - // Repeat the lookup twice, to check that we get consistent - // results despite the fallback database lookup mutating the pool. - vector extensions; - pool.FindAllExtensions(foo, &extensions); - ASSERT_EQ(1, extensions.size()); - EXPECT_EQ(5, extensions[0]->number()); - } -} - -TEST_F(DatabaseBackedPoolTest, ErrorWithoutErrorCollector) { - ErrorDescriptorDatabase error_database; - DescriptorPool pool(&error_database); - - vector errors; - - { - ScopedMemoryLog log; - EXPECT_TRUE(pool.FindFileByName("error.proto") == NULL); - errors = log.GetMessages(ERROR); - } - - EXPECT_FALSE(errors.empty()); -} - -TEST_F(DatabaseBackedPoolTest, ErrorWithErrorCollector) { - ErrorDescriptorDatabase error_database; - MockErrorCollector error_collector; - DescriptorPool pool(&error_database, &error_collector); - - EXPECT_TRUE(pool.FindFileByName("error.proto") == NULL); - EXPECT_EQ( - "error.proto: error.proto: OTHER: File recursively imports itself: " - "error.proto -> error2.proto -> error.proto\n" - "error2.proto: error2.proto: OTHER: Import \"error.proto\" was not " - "found or had errors.\n" - "error.proto: error.proto: OTHER: Import \"error2.proto\" was not " - "found or had errors.\n", - error_collector.text_); -} - -TEST_F(DatabaseBackedPoolTest, UndeclaredDependencyOnUnbuiltType) { - // Check that we find and report undeclared dependencies on types that exist - // in the descriptor database but that have not not been built yet. - MockErrorCollector error_collector; - DescriptorPool pool(&database_, &error_collector); - EXPECT_TRUE(pool.FindMessageTypeByName("Baz") == NULL); - EXPECT_EQ( - "baz.proto: Baz.foo: TYPE: \"Foo\" seems to be defined in \"foo.proto\", " - "which is not imported by \"baz.proto\". To use it here, please add " - "the necessary import.\n", - error_collector.text_); -} - -TEST_F(DatabaseBackedPoolTest, RollbackAfterError) { - // Make sure that all traces of bad types are removed from the pool. This used - // to be b/4529436, due to the fact that a symbol resolution failure could - // potentially cause another file to be recursively built, which would trigger - // a checkpoint _past_ possibly invalid symbols. - // Baz is defined in the database, but the file is invalid because it is - // missing a necessary import. - DescriptorPool pool(&database_); - EXPECT_TRUE(pool.FindMessageTypeByName("Baz") == NULL); - // Make sure that searching again for the file or the type fails. - EXPECT_TRUE(pool.FindFileByName("baz.proto") == NULL); - EXPECT_TRUE(pool.FindMessageTypeByName("Baz") == NULL); -} - -TEST_F(DatabaseBackedPoolTest, UnittestProto) { - // Try to load all of unittest.proto from a DescriptorDatabase. This should - // thoroughly test all paths through DescriptorBuilder to insure that there - // are no deadlocking problems when pool_->mutex_ is non-NULL. - const FileDescriptor* original_file = - protobuf_unittest::TestAllTypes::descriptor()->file(); - - DescriptorPoolDatabase database(*DescriptorPool::generated_pool()); - DescriptorPool pool(&database); - const FileDescriptor* file_from_database = - pool.FindFileByName(original_file->name()); - - ASSERT_TRUE(file_from_database != NULL); - - FileDescriptorProto original_file_proto; - original_file->CopyTo(&original_file_proto); - - FileDescriptorProto file_from_database_proto; - file_from_database->CopyTo(&file_from_database_proto); - - EXPECT_EQ(original_file_proto.DebugString(), - file_from_database_proto.DebugString()); -} - -TEST_F(DatabaseBackedPoolTest, DoesntRetryDbUnnecessarily) { - // Searching for a child of an existing descriptor should never fall back - // to the DescriptorDatabase even if it isn't found, because we know all - // children are already loaded. - CallCountingDatabase call_counter(&database_); - DescriptorPool pool(&call_counter); - - const FileDescriptor* file = pool.FindFileByName("foo.proto"); - ASSERT_TRUE(file != NULL); - const Descriptor* foo = pool.FindMessageTypeByName("Foo"); - ASSERT_TRUE(foo != NULL); - const EnumDescriptor* test_enum = pool.FindEnumTypeByName("TestEnum"); - ASSERT_TRUE(test_enum != NULL); - const ServiceDescriptor* test_service = pool.FindServiceByName("TestService"); - ASSERT_TRUE(test_service != NULL); - - EXPECT_NE(0, call_counter.call_count_); - call_counter.Clear(); - - EXPECT_TRUE(foo->FindFieldByName("no_such_field") == NULL); - EXPECT_TRUE(foo->FindExtensionByName("no_such_extension") == NULL); - EXPECT_TRUE(foo->FindNestedTypeByName("NoSuchMessageType") == NULL); - EXPECT_TRUE(foo->FindEnumTypeByName("NoSuchEnumType") == NULL); - EXPECT_TRUE(foo->FindEnumValueByName("NO_SUCH_VALUE") == NULL); - EXPECT_TRUE(test_enum->FindValueByName("NO_SUCH_VALUE") == NULL); - EXPECT_TRUE(test_service->FindMethodByName("NoSuchMethod") == NULL); - - EXPECT_TRUE(file->FindMessageTypeByName("NoSuchMessageType") == NULL); - EXPECT_TRUE(file->FindEnumTypeByName("NoSuchEnumType") == NULL); - EXPECT_TRUE(file->FindEnumValueByName("NO_SUCH_VALUE") == NULL); - EXPECT_TRUE(file->FindServiceByName("NO_SUCH_VALUE") == NULL); - EXPECT_TRUE(file->FindExtensionByName("no_such_extension") == NULL); - - EXPECT_TRUE(pool.FindFileContainingSymbol("Foo.no.such.field") == NULL); - EXPECT_TRUE(pool.FindFileContainingSymbol("Foo.no_such_field") == NULL); - EXPECT_TRUE(pool.FindMessageTypeByName("Foo.NoSuchMessageType") == NULL); - EXPECT_TRUE(pool.FindFieldByName("Foo.no_such_field") == NULL); - EXPECT_TRUE(pool.FindExtensionByName("Foo.no_such_extension") == NULL); - EXPECT_TRUE(pool.FindEnumTypeByName("Foo.NoSuchEnumType") == NULL); - EXPECT_TRUE(pool.FindEnumValueByName("Foo.NO_SUCH_VALUE") == NULL); - EXPECT_TRUE(pool.FindMethodByName("TestService.NoSuchMethod") == NULL); - - EXPECT_EQ(0, call_counter.call_count_); -} - -TEST_F(DatabaseBackedPoolTest, DoesntReloadFilesUncesessarily) { - // If FindFileContainingSymbol() or FindFileContainingExtension() return a - // file that is already in the DescriptorPool, it should not attempt to - // reload the file. - FalsePositiveDatabase false_positive_database(&database_); - MockErrorCollector error_collector; - DescriptorPool pool(&false_positive_database, &error_collector); - - // First make sure foo.proto is loaded. - const Descriptor* foo = pool.FindMessageTypeByName("Foo"); - ASSERT_TRUE(foo != NULL); - - // Try inducing false positives. - EXPECT_TRUE(pool.FindMessageTypeByName("NoSuchSymbol") == NULL); - EXPECT_TRUE(pool.FindExtensionByNumber(foo, 22) == NULL); - - // No errors should have been reported. (If foo.proto was incorrectly - // loaded multiple times, errors would have been reported.) - EXPECT_EQ("", error_collector.text_); -} - -TEST_F(DatabaseBackedPoolTest, DoesntReloadKnownBadFiles) { - ErrorDescriptorDatabase error_database; - MockErrorCollector error_collector; - DescriptorPool pool(&error_database, &error_collector); - - EXPECT_TRUE(pool.FindFileByName("error.proto") == NULL); - error_collector.text_.clear(); - EXPECT_TRUE(pool.FindFileByName("error.proto") == NULL); - EXPECT_EQ("", error_collector.text_); -} - -TEST_F(DatabaseBackedPoolTest, DoesntFallbackOnWrongType) { - // If a lookup finds a symbol of the wrong type (e.g. we pass a type name - // to FindFieldByName()), we should fail fast, without checking the fallback - // database. - CallCountingDatabase call_counter(&database_); - DescriptorPool pool(&call_counter); - - const FileDescriptor* file = pool.FindFileByName("foo.proto"); - ASSERT_TRUE(file != NULL); - const Descriptor* foo = pool.FindMessageTypeByName("Foo"); - ASSERT_TRUE(foo != NULL); - const EnumDescriptor* test_enum = pool.FindEnumTypeByName("TestEnum"); - ASSERT_TRUE(test_enum != NULL); - - EXPECT_NE(0, call_counter.call_count_); - call_counter.Clear(); - - EXPECT_TRUE(pool.FindMessageTypeByName("TestEnum") == NULL); - EXPECT_TRUE(pool.FindFieldByName("Foo") == NULL); - EXPECT_TRUE(pool.FindExtensionByName("Foo") == NULL); - EXPECT_TRUE(pool.FindEnumTypeByName("Foo") == NULL); - EXPECT_TRUE(pool.FindEnumValueByName("Foo") == NULL); - EXPECT_TRUE(pool.FindServiceByName("Foo") == NULL); - EXPECT_TRUE(pool.FindMethodByName("Foo") == NULL); - - EXPECT_EQ(0, call_counter.call_count_); -} - -// =================================================================== - -class AbortingErrorCollector : public DescriptorPool::ErrorCollector { - public: - AbortingErrorCollector() {} - - virtual void AddError( - const string &filename, - const string &element_name, - const Message *message, - ErrorLocation location, - const string &error_message) { - GOOGLE_LOG(FATAL) << "AddError() called unexpectedly: " << filename << ": " - << error_message; - } - private: - GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(AbortingErrorCollector); -}; - -// A source tree containing only one file. -class SingletonSourceTree : public compiler::SourceTree { - public: - SingletonSourceTree(const string& filename, const string& contents) - : filename_(filename), contents_(contents) {} - - virtual io::ZeroCopyInputStream* Open(const string& filename) { - return filename == filename_ ? - new io::ArrayInputStream(contents_.data(), contents_.size()) : NULL; - } - - private: - const string filename_; - const string contents_; - - GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(SingletonSourceTree); -}; - -const char *const kSourceLocationTestInput = - "syntax = \"proto2\";\n" - "message A {\n" - " optional int32 a = 1;\n" - " message B {\n" - " required double b = 1;\n" - " }\n" - "}\n" - "enum Indecision {\n" - " YES = 1;\n" - " NO = 2;\n" - " MAYBE = 3;\n" - "}\n" - "service S {\n" - " rpc Method(A) returns (A.B);\n" - // Put an empty line here to make the source location range match. - "\n" - "}\n"; - -class SourceLocationTest : public testing::Test { - public: - SourceLocationTest() - : source_tree_("/test/test.proto", kSourceLocationTestInput), - db_(&source_tree_), - pool_(&db_, &collector_) {} - - static string PrintSourceLocation(const SourceLocation &loc) { - return strings::Substitute("$0:$1-$2:$3", - 1 + loc.start_line, - 1 + loc.start_column, - 1 + loc.end_line, - 1 + loc.end_column); - } - - private: - AbortingErrorCollector collector_; - SingletonSourceTree source_tree_; - compiler::SourceTreeDescriptorDatabase db_; - - protected: - DescriptorPool pool_; -}; - -// TODO(adonovan): implement support for option fields and for -// subparts of declarations. - -TEST_F(SourceLocationTest, GetSourceLocation) { - SourceLocation loc; - - const FileDescriptor *file_desc = - GOOGLE_CHECK_NOTNULL(pool_.FindFileByName("/test/test.proto")); - - const Descriptor *a_desc = file_desc->FindMessageTypeByName("A"); - EXPECT_TRUE(a_desc->GetSourceLocation(&loc)); - EXPECT_EQ("2:1-7:2", PrintSourceLocation(loc)); - - const Descriptor *a_b_desc = a_desc->FindNestedTypeByName("B"); - EXPECT_TRUE(a_b_desc->GetSourceLocation(&loc)); - EXPECT_EQ("4:3-6:4", PrintSourceLocation(loc)); - - const EnumDescriptor *e_desc = file_desc->FindEnumTypeByName("Indecision"); - EXPECT_TRUE(e_desc->GetSourceLocation(&loc)); - EXPECT_EQ("8:1-12:2", PrintSourceLocation(loc)); - - const EnumValueDescriptor *yes_desc = e_desc->FindValueByName("YES"); - EXPECT_TRUE(yes_desc->GetSourceLocation(&loc)); - EXPECT_EQ("9:3-9:13", PrintSourceLocation(loc)); - - const ServiceDescriptor *s_desc = file_desc->FindServiceByName("S"); - EXPECT_TRUE(s_desc->GetSourceLocation(&loc)); - EXPECT_EQ("13:1-16:2", PrintSourceLocation(loc)); - - const MethodDescriptor *m_desc = s_desc->FindMethodByName("Method"); - EXPECT_TRUE(m_desc->GetSourceLocation(&loc)); - EXPECT_EQ("14:3-14:31", PrintSourceLocation(loc)); - -} - -// Missing SourceCodeInfo doesn't cause crash: -TEST_F(SourceLocationTest, GetSourceLocation_MissingSourceCodeInfo) { - SourceLocation loc; - - const FileDescriptor *file_desc = - GOOGLE_CHECK_NOTNULL(pool_.FindFileByName("/test/test.proto")); - - FileDescriptorProto proto; - file_desc->CopyTo(&proto); // Note, this discards the SourceCodeInfo. - EXPECT_FALSE(proto.has_source_code_info()); - - DescriptorPool bad1_pool(&pool_); - const FileDescriptor* bad1_file_desc = - GOOGLE_CHECK_NOTNULL(bad1_pool.BuildFile(proto)); - const Descriptor *bad1_a_desc = bad1_file_desc->FindMessageTypeByName("A"); - EXPECT_FALSE(bad1_a_desc->GetSourceLocation(&loc)); -} - -// Corrupt SourceCodeInfo doesn't cause crash: -TEST_F(SourceLocationTest, GetSourceLocation_BogusSourceCodeInfo) { - SourceLocation loc; - - const FileDescriptor *file_desc = - GOOGLE_CHECK_NOTNULL(pool_.FindFileByName("/test/test.proto")); - - FileDescriptorProto proto; - file_desc->CopyTo(&proto); // Note, this discards the SourceCodeInfo. - EXPECT_FALSE(proto.has_source_code_info()); - SourceCodeInfo_Location *loc_msg = - proto.mutable_source_code_info()->add_location(); - loc_msg->add_path(1); - loc_msg->add_path(2); - loc_msg->add_path(3); - loc_msg->add_span(4); - loc_msg->add_span(5); - loc_msg->add_span(6); - - DescriptorPool bad2_pool(&pool_); - const FileDescriptor* bad2_file_desc = - GOOGLE_CHECK_NOTNULL(bad2_pool.BuildFile(proto)); - const Descriptor *bad2_a_desc = bad2_file_desc->FindMessageTypeByName("A"); - EXPECT_FALSE(bad2_a_desc->GetSourceLocation(&loc)); -} - -// =================================================================== - -const char* const kCopySourceCodeInfoToTestInput = - "syntax = \"proto2\";\n" - "message Foo {}\n"; - -// Required since source code information is not preserved by -// FileDescriptorTest. -class CopySourceCodeInfoToTest : public testing::Test { - public: - CopySourceCodeInfoToTest() - : source_tree_("/test/test.proto", kCopySourceCodeInfoToTestInput), - db_(&source_tree_), - pool_(&db_, &collector_) {} - - private: - AbortingErrorCollector collector_; - SingletonSourceTree source_tree_; - compiler::SourceTreeDescriptorDatabase db_; - - protected: - DescriptorPool pool_; -}; - -TEST_F(CopySourceCodeInfoToTest, CopyTo_DoesNotCopySourceCodeInfo) { - const FileDescriptor* file_desc = - GOOGLE_CHECK_NOTNULL(pool_.FindFileByName("/test/test.proto")); - FileDescriptorProto file_desc_proto; - ASSERT_FALSE(file_desc_proto.has_source_code_info()); - - file_desc->CopyTo(&file_desc_proto); - EXPECT_FALSE(file_desc_proto.has_source_code_info()); -} - -TEST_F(CopySourceCodeInfoToTest, CopySourceCodeInfoTo) { - const FileDescriptor* file_desc = - GOOGLE_CHECK_NOTNULL(pool_.FindFileByName("/test/test.proto")); - FileDescriptorProto file_desc_proto; - ASSERT_FALSE(file_desc_proto.has_source_code_info()); - - file_desc->CopySourceCodeInfoTo(&file_desc_proto); - const SourceCodeInfo& info = file_desc_proto.source_code_info(); - ASSERT_EQ(3, info.location_size()); - // Get the Foo message location - const SourceCodeInfo_Location& foo_location = info.location(1); - ASSERT_EQ(2, foo_location.path_size()); - EXPECT_EQ(FileDescriptorProto::kMessageTypeFieldNumber, foo_location.path(0)); - EXPECT_EQ(0, foo_location.path(1)); // Foo is the first message defined - ASSERT_EQ(3, foo_location.span_size()); // Foo spans one line - EXPECT_EQ(1, foo_location.span(0)); // Foo is declared on line 1 - EXPECT_EQ(0, foo_location.span(1)); // Foo starts at column 0 - EXPECT_EQ(14, foo_location.span(2)); // Foo ends on column 14 -} - -// =================================================================== - - -} // namespace descriptor_unittest -} // namespace protobuf -} // namespace google diff --git a/modules/dnn/3rdparty/protobuf/src/google/protobuf/dynamic_message.cc b/modules/dnn/3rdparty/protobuf/src/google/protobuf/dynamic_message.cc deleted file mode 100644 index 09bec5436..000000000 --- a/modules/dnn/3rdparty/protobuf/src/google/protobuf/dynamic_message.cc +++ /dev/null @@ -1,571 +0,0 @@ -// Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// http://code.google.com/p/protobuf/ -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -// Author: kenton@google.com (Kenton Varda) -// Based on original Protocol Buffers design by -// Sanjay Ghemawat, Jeff Dean, and others. -// -// DynamicMessage is implemented by constructing a data structure which -// has roughly the same memory layout as a generated message would have. -// Then, we use GeneratedMessageReflection to implement our reflection -// interface. All the other operations we need to implement (e.g. -// parsing, copying, etc.) are already implemented in terms of -// Reflection, so the rest is easy. -// -// The up side of this strategy is that it's very efficient. We don't -// need to use hash_maps or generic representations of fields. The -// down side is that this is a low-level memory management hack which -// can be tricky to get right. -// -// As mentioned in the header, we only expose a DynamicMessageFactory -// publicly, not the DynamicMessage class itself. This is because -// GenericMessageReflection wants to have a pointer to a "default" -// copy of the class, with all fields initialized to their default -// values. We only want to construct one of these per message type, -// so DynamicMessageFactory stores a cache of default messages for -// each type it sees (each unique Descriptor pointer). The code -// refers to the "default" copy of the class as the "prototype". -// -// Note on memory allocation: This module often calls "operator new()" -// to allocate untyped memory, rather than calling something like -// "new uint8[]". This is because "operator new()" means "Give me some -// space which I can use as I please." while "new uint8[]" means "Give -// me an array of 8-bit integers.". In practice, the later may return -// a pointer that is not aligned correctly for general use. I believe -// Item 8 of "More Effective C++" discusses this in more detail, though -// I don't have the book on me right now so I'm not sure. - -#include -#include - -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -namespace google { -namespace protobuf { - -using internal::WireFormat; -using internal::ExtensionSet; -using internal::GeneratedMessageReflection; - - -// =================================================================== -// Some helper tables and functions... - -namespace { - -// Compute the byte size of the in-memory representation of the field. -int FieldSpaceUsed(const FieldDescriptor* field) { - typedef FieldDescriptor FD; // avoid line wrapping - if (field->label() == FD::LABEL_REPEATED) { - switch (field->cpp_type()) { - case FD::CPPTYPE_INT32 : return sizeof(RepeatedField); - case FD::CPPTYPE_INT64 : return sizeof(RepeatedField); - case FD::CPPTYPE_UINT32 : return sizeof(RepeatedField); - case FD::CPPTYPE_UINT64 : return sizeof(RepeatedField); - case FD::CPPTYPE_DOUBLE : return sizeof(RepeatedField); - case FD::CPPTYPE_FLOAT : return sizeof(RepeatedField); - case FD::CPPTYPE_BOOL : return sizeof(RepeatedField); - case FD::CPPTYPE_ENUM : return sizeof(RepeatedField); - case FD::CPPTYPE_MESSAGE: return sizeof(RepeatedPtrField); - - case FD::CPPTYPE_STRING: - switch (field->options().ctype()) { - default: // TODO(kenton): Support other string reps. - case FieldOptions::STRING: - return sizeof(RepeatedPtrField); - } - break; - } - } else { - switch (field->cpp_type()) { - case FD::CPPTYPE_INT32 : return sizeof(int32 ); - case FD::CPPTYPE_INT64 : return sizeof(int64 ); - case FD::CPPTYPE_UINT32 : return sizeof(uint32 ); - case FD::CPPTYPE_UINT64 : return sizeof(uint64 ); - case FD::CPPTYPE_DOUBLE : return sizeof(double ); - case FD::CPPTYPE_FLOAT : return sizeof(float ); - case FD::CPPTYPE_BOOL : return sizeof(bool ); - case FD::CPPTYPE_ENUM : return sizeof(int ); - - case FD::CPPTYPE_MESSAGE: - return sizeof(Message*); - - case FD::CPPTYPE_STRING: - switch (field->options().ctype()) { - default: // TODO(kenton): Support other string reps. - case FieldOptions::STRING: - return sizeof(string*); - } - break; - } - } - - GOOGLE_LOG(DFATAL) << "Can't get here."; - return 0; -} - -inline int DivideRoundingUp(int i, int j) { - return (i + (j - 1)) / j; -} - -static const int kSafeAlignment = sizeof(uint64); - -inline int AlignTo(int offset, int alignment) { - return DivideRoundingUp(offset, alignment) * alignment; -} - -// Rounds the given byte offset up to the next offset aligned such that any -// type may be stored at it. -inline int AlignOffset(int offset) { - return AlignTo(offset, kSafeAlignment); -} - -#define bitsizeof(T) (sizeof(T) * 8) - -} // namespace - -// =================================================================== - -class DynamicMessage : public Message { - public: - struct TypeInfo { - int size; - int has_bits_offset; - int unknown_fields_offset; - int extensions_offset; - - // Not owned by the TypeInfo. - DynamicMessageFactory* factory; // The factory that created this object. - const DescriptorPool* pool; // The factory's DescriptorPool. - const Descriptor* type; // Type of this DynamicMessage. - - // Warning: The order in which the following pointers are defined is - // important (the prototype must be deleted *before* the offsets). - scoped_array offsets; - scoped_ptr reflection; - // Don't use a scoped_ptr to hold the prototype: the destructor for - // DynamicMessage needs to know whether it is the prototype, and does so by - // looking back at this field. This would assume details about the - // implementation of scoped_ptr. - const DynamicMessage* prototype; - - TypeInfo() : prototype(NULL) {} - - ~TypeInfo() { - delete prototype; - } - }; - - DynamicMessage(const TypeInfo* type_info); - ~DynamicMessage(); - - // Called on the prototype after construction to initialize message fields. - void CrossLinkPrototypes(); - - // implements Message ---------------------------------------------- - - Message* New() const; - - int GetCachedSize() const; - void SetCachedSize(int size) const; - - Metadata GetMetadata() const; - - private: - GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(DynamicMessage); - - inline bool is_prototype() const { - return type_info_->prototype == this || - // If type_info_->prototype is NULL, then we must be constructing - // the prototype now, which means we must be the prototype. - type_info_->prototype == NULL; - } - - inline void* OffsetToPointer(int offset) { - return reinterpret_cast(this) + offset; - } - inline const void* OffsetToPointer(int offset) const { - return reinterpret_cast(this) + offset; - } - - const TypeInfo* type_info_; - - // TODO(kenton): Make this an atomic when C++ supports it. - mutable int cached_byte_size_; -}; - -DynamicMessage::DynamicMessage(const TypeInfo* type_info) - : type_info_(type_info), - cached_byte_size_(0) { - // We need to call constructors for various fields manually and set - // default values where appropriate. We use placement new to call - // constructors. If you haven't heard of placement new, I suggest Googling - // it now. We use placement new even for primitive types that don't have - // constructors for consistency. (In theory, placement new should be used - // any time you are trying to convert untyped memory to typed memory, though - // in practice that's not strictly necessary for types that don't have a - // constructor.) - - const Descriptor* descriptor = type_info_->type; - - new(OffsetToPointer(type_info_->unknown_fields_offset)) UnknownFieldSet; - - if (type_info_->extensions_offset != -1) { - new(OffsetToPointer(type_info_->extensions_offset)) ExtensionSet; - } - - for (int i = 0; i < descriptor->field_count(); i++) { - const FieldDescriptor* field = descriptor->field(i); - void* field_ptr = OffsetToPointer(type_info_->offsets[i]); - switch (field->cpp_type()) { -#define HANDLE_TYPE(CPPTYPE, TYPE) \ - case FieldDescriptor::CPPTYPE_##CPPTYPE: \ - if (!field->is_repeated()) { \ - new(field_ptr) TYPE(field->default_value_##TYPE()); \ - } else { \ - new(field_ptr) RepeatedField(); \ - } \ - break; - - HANDLE_TYPE(INT32 , int32 ); - HANDLE_TYPE(INT64 , int64 ); - HANDLE_TYPE(UINT32, uint32); - HANDLE_TYPE(UINT64, uint64); - HANDLE_TYPE(DOUBLE, double); - HANDLE_TYPE(FLOAT , float ); - HANDLE_TYPE(BOOL , bool ); -#undef HANDLE_TYPE - - case FieldDescriptor::CPPTYPE_ENUM: - if (!field->is_repeated()) { - new(field_ptr) int(field->default_value_enum()->number()); - } else { - new(field_ptr) RepeatedField(); - } - break; - - case FieldDescriptor::CPPTYPE_STRING: - switch (field->options().ctype()) { - default: // TODO(kenton): Support other string reps. - case FieldOptions::STRING: - if (!field->is_repeated()) { - if (is_prototype()) { - new(field_ptr) const string*(&field->default_value_string()); - } else { - string* default_value = - *reinterpret_cast( - type_info_->prototype->OffsetToPointer( - type_info_->offsets[i])); - new(field_ptr) string*(default_value); - } - } else { - new(field_ptr) RepeatedPtrField(); - } - break; - } - break; - - case FieldDescriptor::CPPTYPE_MESSAGE: { - if (!field->is_repeated()) { - new(field_ptr) Message*(NULL); - } else { - new(field_ptr) RepeatedPtrField(); - } - break; - } - } - } -} - -DynamicMessage::~DynamicMessage() { - const Descriptor* descriptor = type_info_->type; - - reinterpret_cast( - OffsetToPointer(type_info_->unknown_fields_offset))->~UnknownFieldSet(); - - if (type_info_->extensions_offset != -1) { - reinterpret_cast( - OffsetToPointer(type_info_->extensions_offset))->~ExtensionSet(); - } - - // We need to manually run the destructors for repeated fields and strings, - // just as we ran their constructors in the the DynamicMessage constructor. - // Additionally, if any singular embedded messages have been allocated, we - // need to delete them, UNLESS we are the prototype message of this type, - // in which case any embedded messages are other prototypes and shouldn't - // be touched. - for (int i = 0; i < descriptor->field_count(); i++) { - const FieldDescriptor* field = descriptor->field(i); - void* field_ptr = OffsetToPointer(type_info_->offsets[i]); - - if (field->is_repeated()) { - switch (field->cpp_type()) { -#define HANDLE_TYPE(UPPERCASE, LOWERCASE) \ - case FieldDescriptor::CPPTYPE_##UPPERCASE : \ - reinterpret_cast*>(field_ptr) \ - ->~RepeatedField(); \ - break - - HANDLE_TYPE( INT32, int32); - HANDLE_TYPE( INT64, int64); - HANDLE_TYPE(UINT32, uint32); - HANDLE_TYPE(UINT64, uint64); - HANDLE_TYPE(DOUBLE, double); - HANDLE_TYPE( FLOAT, float); - HANDLE_TYPE( BOOL, bool); - HANDLE_TYPE( ENUM, int); -#undef HANDLE_TYPE - - case FieldDescriptor::CPPTYPE_STRING: - switch (field->options().ctype()) { - default: // TODO(kenton): Support other string reps. - case FieldOptions::STRING: - reinterpret_cast*>(field_ptr) - ->~RepeatedPtrField(); - break; - } - break; - - case FieldDescriptor::CPPTYPE_MESSAGE: - reinterpret_cast*>(field_ptr) - ->~RepeatedPtrField(); - break; - } - - } else if (field->cpp_type() == FieldDescriptor::CPPTYPE_STRING) { - switch (field->options().ctype()) { - default: // TODO(kenton): Support other string reps. - case FieldOptions::STRING: { - string* ptr = *reinterpret_cast(field_ptr); - if (ptr != &field->default_value_string()) { - delete ptr; - } - break; - } - } - } else if (field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE) { - if (!is_prototype()) { - Message* message = *reinterpret_cast(field_ptr); - if (message != NULL) { - delete message; - } - } - } - } -} - -void DynamicMessage::CrossLinkPrototypes() { - // This should only be called on the prototype message. - GOOGLE_CHECK(is_prototype()); - - DynamicMessageFactory* factory = type_info_->factory; - const Descriptor* descriptor = type_info_->type; - - // Cross-link default messages. - for (int i = 0; i < descriptor->field_count(); i++) { - const FieldDescriptor* field = descriptor->field(i); - void* field_ptr = OffsetToPointer(type_info_->offsets[i]); - - if (field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE && - !field->is_repeated()) { - // For fields with message types, we need to cross-link with the - // prototype for the field's type. - // For singular fields, the field is just a pointer which should - // point to the prototype. - *reinterpret_cast(field_ptr) = - factory->GetPrototypeNoLock(field->message_type()); - } - } -} - -Message* DynamicMessage::New() const { - void* new_base = operator new(type_info_->size); - memset(new_base, 0, type_info_->size); - return new(new_base) DynamicMessage(type_info_); -} - -int DynamicMessage::GetCachedSize() const { - return cached_byte_size_; -} - -void DynamicMessage::SetCachedSize(int size) const { - // This is theoretically not thread-compatible, but in practice it works - // because if multiple threads write this simultaneously, they will be - // writing the exact same value. - cached_byte_size_ = size; -} - -Metadata DynamicMessage::GetMetadata() const { - Metadata metadata; - metadata.descriptor = type_info_->type; - metadata.reflection = type_info_->reflection.get(); - return metadata; -} - -// =================================================================== - -struct DynamicMessageFactory::PrototypeMap { - typedef hash_map Map; - Map map_; -}; - -DynamicMessageFactory::DynamicMessageFactory() - : pool_(NULL), delegate_to_generated_factory_(false), - prototypes_(new PrototypeMap) { -} - -DynamicMessageFactory::DynamicMessageFactory(const DescriptorPool* pool) - : pool_(pool), delegate_to_generated_factory_(false), - prototypes_(new PrototypeMap) { -} - -DynamicMessageFactory::~DynamicMessageFactory() { - for (PrototypeMap::Map::iterator iter = prototypes_->map_.begin(); - iter != prototypes_->map_.end(); ++iter) { - delete iter->second; - } -} - -const Message* DynamicMessageFactory::GetPrototype(const Descriptor* type) { - MutexLock lock(&prototypes_mutex_); - return GetPrototypeNoLock(type); -} - -const Message* DynamicMessageFactory::GetPrototypeNoLock( - const Descriptor* type) { - if (delegate_to_generated_factory_ && - type->file()->pool() == DescriptorPool::generated_pool()) { - return MessageFactory::generated_factory()->GetPrototype(type); - } - - const DynamicMessage::TypeInfo** target = &prototypes_->map_[type]; - if (*target != NULL) { - // Already exists. - return (*target)->prototype; - } - - DynamicMessage::TypeInfo* type_info = new DynamicMessage::TypeInfo; - *target = type_info; - - type_info->type = type; - type_info->pool = (pool_ == NULL) ? type->file()->pool() : pool_; - type_info->factory = this; - - // We need to construct all the structures passed to - // GeneratedMessageReflection's constructor. This includes: - // - A block of memory that contains space for all the message's fields. - // - An array of integers indicating the byte offset of each field within - // this block. - // - A big bitfield containing a bit for each field indicating whether - // or not that field is set. - - // Compute size and offsets. - int* offsets = new int[type->field_count()]; - type_info->offsets.reset(offsets); - - // Decide all field offsets by packing in order. - // We place the DynamicMessage object itself at the beginning of the allocated - // space. - int size = sizeof(DynamicMessage); - size = AlignOffset(size); - - // Next the has_bits, which is an array of uint32s. - type_info->has_bits_offset = size; - int has_bits_array_size = - DivideRoundingUp(type->field_count(), bitsizeof(uint32)); - size += has_bits_array_size * sizeof(uint32); - size = AlignOffset(size); - - // The ExtensionSet, if any. - if (type->extension_range_count() > 0) { - type_info->extensions_offset = size; - size += sizeof(ExtensionSet); - size = AlignOffset(size); - } else { - // No extensions. - type_info->extensions_offset = -1; - } - - // All the fields. - for (int i = 0; i < type->field_count(); i++) { - // Make sure field is aligned to avoid bus errors. - int field_size = FieldSpaceUsed(type->field(i)); - size = AlignTo(size, min(kSafeAlignment, field_size)); - offsets[i] = size; - size += field_size; - } - - // Add the UnknownFieldSet to the end. - size = AlignOffset(size); - type_info->unknown_fields_offset = size; - size += sizeof(UnknownFieldSet); - - // Align the final size to make sure no clever allocators think that - // alignment is not necessary. - size = AlignOffset(size); - type_info->size = size; - - // Allocate the prototype. - void* base = operator new(size); - memset(base, 0, size); - DynamicMessage* prototype = new(base) DynamicMessage(type_info); - type_info->prototype = prototype; - - // Construct the reflection object. - type_info->reflection.reset( - new GeneratedMessageReflection( - type_info->type, - type_info->prototype, - type_info->offsets.get(), - type_info->has_bits_offset, - type_info->unknown_fields_offset, - type_info->extensions_offset, - type_info->pool, - this, - type_info->size)); - - // Cross link prototypes. - prototype->CrossLinkPrototypes(); - - return prototype; -} - -} // namespace protobuf -} // namespace google diff --git a/modules/dnn/3rdparty/protobuf/src/google/protobuf/dynamic_message.h b/modules/dnn/3rdparty/protobuf/src/google/protobuf/dynamic_message.h deleted file mode 100644 index b3d1e5d28..000000000 --- a/modules/dnn/3rdparty/protobuf/src/google/protobuf/dynamic_message.h +++ /dev/null @@ -1,136 +0,0 @@ -// Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// http://code.google.com/p/protobuf/ -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -// Author: kenton@google.com (Kenton Varda) -// Based on original Protocol Buffers design by -// Sanjay Ghemawat, Jeff Dean, and others. -// -// Defines an implementation of Message which can emulate types which are not -// known at compile-time. - -#ifndef GOOGLE_PROTOBUF_DYNAMIC_MESSAGE_H__ -#define GOOGLE_PROTOBUF_DYNAMIC_MESSAGE_H__ - -#include -#include - -namespace google { -namespace protobuf { - -// Defined in other files. -class Descriptor; // descriptor.h -class DescriptorPool; // descriptor.h - -// Constructs implementations of Message which can emulate types which are not -// known at compile-time. -// -// Sometimes you want to be able to manipulate protocol types that you don't -// know about at compile time. It would be nice to be able to construct -// a Message object which implements the message type given by any arbitrary -// Descriptor. DynamicMessage provides this. -// -// As it turns out, a DynamicMessage needs to construct extra -// information about its type in order to operate. Most of this information -// can be shared between all DynamicMessages of the same type. But, caching -// this information in some sort of global map would be a bad idea, since -// the cached information for a particular descriptor could outlive the -// descriptor itself. To avoid this problem, DynamicMessageFactory -// encapsulates this "cache". All DynamicMessages of the same type created -// from the same factory will share the same support data. Any Descriptors -// used with a particular factory must outlive the factory. -class LIBPROTOBUF_EXPORT DynamicMessageFactory : public MessageFactory { - public: - // Construct a DynamicMessageFactory that will search for extensions in - // the DescriptorPool in which the extendee is defined. - DynamicMessageFactory(); - - // Construct a DynamicMessageFactory that will search for extensions in - // the given DescriptorPool. - // - // DEPRECATED: Use CodedInputStream::SetExtensionRegistry() to tell the - // parser to look for extensions in an alternate pool. However, note that - // this is almost never what you want to do. Almost all users should use - // the zero-arg constructor. - DynamicMessageFactory(const DescriptorPool* pool); - - ~DynamicMessageFactory(); - - // Call this to tell the DynamicMessageFactory that if it is given a - // Descriptor d for which: - // d->file()->pool() == DescriptorPool::generated_pool(), - // then it should delegate to MessageFactory::generated_factory() instead - // of constructing a dynamic implementation of the message. In theory there - // is no down side to doing this, so it may become the default in the future. - void SetDelegateToGeneratedFactory(bool enable) { - delegate_to_generated_factory_ = enable; - } - - // implements MessageFactory --------------------------------------- - - // Given a Descriptor, constructs the default (prototype) Message of that - // type. You can then call that message's New() method to construct a - // mutable message of that type. - // - // Calling this method twice with the same Descriptor returns the same - // object. The returned object remains property of the factory and will - // be destroyed when the factory is destroyed. Also, any objects created - // by calling the prototype's New() method share some data with the - // prototype, so these must be destroyed before the DynamicMessageFactory - // is destroyed. - // - // The given descriptor must outlive the returned message, and hence must - // outlive the DynamicMessageFactory. - // - // The method is thread-safe. - const Message* GetPrototype(const Descriptor* type); - - private: - const DescriptorPool* pool_; - bool delegate_to_generated_factory_; - - // This struct just contains a hash_map. We can't #include from - // this header due to hacks needed for hash_map portability in the open source - // release. Namely, stubs/hash.h, which defines hash_map portably, is not a - // public header (for good reason), but dynamic_message.h is, and public - // headers may only #include other public headers. - struct PrototypeMap; - scoped_ptr prototypes_; - mutable Mutex prototypes_mutex_; - - friend class DynamicMessage; - const Message* GetPrototypeNoLock(const Descriptor* type); - - GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(DynamicMessageFactory); -}; - -} // namespace protobuf - -} // namespace google -#endif // GOOGLE_PROTOBUF_DYNAMIC_MESSAGE_H__ diff --git a/modules/dnn/3rdparty/protobuf/src/google/protobuf/dynamic_message_unittest.cc b/modules/dnn/3rdparty/protobuf/src/google/protobuf/dynamic_message_unittest.cc deleted file mode 100644 index e46159702..000000000 --- a/modules/dnn/3rdparty/protobuf/src/google/protobuf/dynamic_message_unittest.cc +++ /dev/null @@ -1,166 +0,0 @@ -// Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// http://code.google.com/p/protobuf/ -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -// Author: kenton@google.com (Kenton Varda) -// Based on original Protocol Buffers design by -// Sanjay Ghemawat, Jeff Dean, and others. -// -// Since the reflection interface for DynamicMessage is implemented by -// GenericMessageReflection, the only thing we really have to test is -// that DynamicMessage correctly sets up the information that -// GenericMessageReflection needs to use. So, we focus on that in this -// test. Other tests, such as generic_message_reflection_unittest and -// reflection_ops_unittest, cover the rest of the functionality used by -// DynamicMessage. - -#include -#include -#include -#include -#include -#include - -#include -#include - -namespace google { -namespace protobuf { - -class DynamicMessageTest : public testing::Test { - protected: - DescriptorPool pool_; - DynamicMessageFactory factory_; - const Descriptor* descriptor_; - const Message* prototype_; - const Descriptor* extensions_descriptor_; - const Message* extensions_prototype_; - const Descriptor* packed_descriptor_; - const Message* packed_prototype_; - - DynamicMessageTest(): factory_(&pool_) {} - - virtual void SetUp() { - // We want to make sure that DynamicMessage works (particularly with - // extensions) even if we use descriptors that are *not* from compiled-in - // types, so we make copies of the descriptors for unittest.proto and - // unittest_import.proto. - FileDescriptorProto unittest_file; - FileDescriptorProto unittest_import_file; - FileDescriptorProto unittest_import_public_file; - - unittest::TestAllTypes::descriptor()->file()->CopyTo(&unittest_file); - unittest_import::ImportMessage::descriptor()->file()->CopyTo( - &unittest_import_file); - unittest_import::PublicImportMessage::descriptor()->file()->CopyTo( - &unittest_import_public_file); - - ASSERT_TRUE(pool_.BuildFile(unittest_import_public_file) != NULL); - ASSERT_TRUE(pool_.BuildFile(unittest_import_file) != NULL); - ASSERT_TRUE(pool_.BuildFile(unittest_file) != NULL); - - descriptor_ = pool_.FindMessageTypeByName("protobuf_unittest.TestAllTypes"); - ASSERT_TRUE(descriptor_ != NULL); - prototype_ = factory_.GetPrototype(descriptor_); - - extensions_descriptor_ = - pool_.FindMessageTypeByName("protobuf_unittest.TestAllExtensions"); - ASSERT_TRUE(extensions_descriptor_ != NULL); - extensions_prototype_ = factory_.GetPrototype(extensions_descriptor_); - - packed_descriptor_ = - pool_.FindMessageTypeByName("protobuf_unittest.TestPackedTypes"); - ASSERT_TRUE(packed_descriptor_ != NULL); - packed_prototype_ = factory_.GetPrototype(packed_descriptor_); - } -}; - -TEST_F(DynamicMessageTest, Descriptor) { - // Check that the descriptor on the DynamicMessage matches the descriptor - // passed to GetPrototype(). - EXPECT_EQ(prototype_->GetDescriptor(), descriptor_); -} - -TEST_F(DynamicMessageTest, OnePrototype) { - // Check that requesting the same prototype twice produces the same object. - EXPECT_EQ(prototype_, factory_.GetPrototype(descriptor_)); -} - -TEST_F(DynamicMessageTest, Defaults) { - // Check that all default values are set correctly in the initial message. - TestUtil::ReflectionTester reflection_tester(descriptor_); - reflection_tester.ExpectClearViaReflection(*prototype_); -} - -TEST_F(DynamicMessageTest, IndependentOffsets) { - // Check that all fields have independent offsets by setting each - // one to a unique value then checking that they all still have those - // unique values (i.e. they don't stomp each other). - scoped_ptr message(prototype_->New()); - TestUtil::ReflectionTester reflection_tester(descriptor_); - - reflection_tester.SetAllFieldsViaReflection(message.get()); - reflection_tester.ExpectAllFieldsSetViaReflection(*message); -} - -TEST_F(DynamicMessageTest, Extensions) { - // Check that extensions work. - scoped_ptr message(extensions_prototype_->New()); - TestUtil::ReflectionTester reflection_tester(extensions_descriptor_); - - reflection_tester.SetAllFieldsViaReflection(message.get()); - reflection_tester.ExpectAllFieldsSetViaReflection(*message); -} - -TEST_F(DynamicMessageTest, PackedFields) { - // Check that packed fields work properly. - scoped_ptr message(packed_prototype_->New()); - TestUtil::ReflectionTester reflection_tester(packed_descriptor_); - - reflection_tester.SetPackedFieldsViaReflection(message.get()); - reflection_tester.ExpectPackedFieldsSetViaReflection(*message); -} - -TEST_F(DynamicMessageTest, SpaceUsed) { - // Test that SpaceUsed() works properly - - // Since we share the implementation with generated messages, we don't need - // to test very much here. Just make sure it appears to be working. - - scoped_ptr message(prototype_->New()); - TestUtil::ReflectionTester reflection_tester(descriptor_); - - int initial_space_used = message->SpaceUsed(); - - reflection_tester.SetAllFieldsViaReflection(message.get()); - EXPECT_LT(initial_space_used, message->SpaceUsed()); -} - -} // namespace protobuf -} // namespace google diff --git a/modules/dnn/3rdparty/protobuf/src/google/protobuf/extension_set.cc b/modules/dnn/3rdparty/protobuf/src/google/protobuf/extension_set.cc deleted file mode 100644 index 2cbba8f54..000000000 --- a/modules/dnn/3rdparty/protobuf/src/google/protobuf/extension_set.cc +++ /dev/null @@ -1,1461 +0,0 @@ -// Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// http://code.google.com/p/protobuf/ -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -// Author: kenton@google.com (Kenton Varda) -// Based on original Protocol Buffers design by -// Sanjay Ghemawat, Jeff Dean, and others. - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -namespace google { -namespace protobuf { -namespace internal { - -namespace { - -inline WireFormatLite::FieldType real_type(FieldType type) { - GOOGLE_DCHECK(type > 0 && type <= WireFormatLite::MAX_FIELD_TYPE); - return static_cast(type); -} - -inline WireFormatLite::CppType cpp_type(FieldType type) { - return WireFormatLite::FieldTypeToCppType(real_type(type)); -} - -// Registry stuff. -typedef hash_map, - ExtensionInfo> ExtensionRegistry; -ExtensionRegistry* registry_ = NULL; -GOOGLE_PROTOBUF_DECLARE_ONCE(registry_init_); - -void DeleteRegistry() { - delete registry_; - registry_ = NULL; -} - -void InitRegistry() { - registry_ = new ExtensionRegistry; - OnShutdown(&DeleteRegistry); -} - -// This function is only called at startup, so there is no need for thread- -// safety. -void Register(const MessageLite* containing_type, - int number, ExtensionInfo info) { - ::google::protobuf::GoogleOnceInit(®istry_init_, &InitRegistry); - - if (!InsertIfNotPresent(registry_, make_pair(containing_type, number), - info)) { - GOOGLE_LOG(FATAL) << "Multiple extension registrations for type \"" - << containing_type->GetTypeName() - << "\", field number " << number << "."; - } -} - -const ExtensionInfo* FindRegisteredExtension( - const MessageLite* containing_type, int number) { - return (registry_ == NULL) ? NULL : - FindOrNull(*registry_, make_pair(containing_type, number)); -} - -} // namespace - -ExtensionFinder::~ExtensionFinder() {} - -bool GeneratedExtensionFinder::Find(int number, ExtensionInfo* output) { - const ExtensionInfo* extension = - FindRegisteredExtension(containing_type_, number); - if (extension == NULL) { - return false; - } else { - *output = *extension; - return true; - } -} - -void ExtensionSet::RegisterExtension(const MessageLite* containing_type, - int number, FieldType type, - bool is_repeated, bool is_packed) { - GOOGLE_CHECK_NE(type, WireFormatLite::TYPE_ENUM); - GOOGLE_CHECK_NE(type, WireFormatLite::TYPE_MESSAGE); - GOOGLE_CHECK_NE(type, WireFormatLite::TYPE_GROUP); - ExtensionInfo info(type, is_repeated, is_packed); - Register(containing_type, number, info); -} - -static bool CallNoArgValidityFunc(const void* arg, int number) { - // Note: Must use C-style cast here rather than reinterpret_cast because - // the C++ standard at one point did not allow casts between function and - // data pointers and some compilers enforce this for C++-style casts. No - // compiler enforces it for C-style casts since lots of C-style code has - // relied on these kinds of casts for a long time, despite being - // technically undefined. See: - // http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#195 - // Also note: Some compilers do not allow function pointers to be "const". - // Which makes sense, I suppose, because it's meaningless. - return ((EnumValidityFunc*)arg)(number); -} - -void ExtensionSet::RegisterEnumExtension(const MessageLite* containing_type, - int number, FieldType type, - bool is_repeated, bool is_packed, - EnumValidityFunc* is_valid) { - GOOGLE_CHECK_EQ(type, WireFormatLite::TYPE_ENUM); - ExtensionInfo info(type, is_repeated, is_packed); - info.enum_validity_check.func = CallNoArgValidityFunc; - // See comment in CallNoArgValidityFunc() about why we use a c-style cast. - info.enum_validity_check.arg = (void*)is_valid; - Register(containing_type, number, info); -} - -void ExtensionSet::RegisterMessageExtension(const MessageLite* containing_type, - int number, FieldType type, - bool is_repeated, bool is_packed, - const MessageLite* prototype) { - GOOGLE_CHECK(type == WireFormatLite::TYPE_MESSAGE || - type == WireFormatLite::TYPE_GROUP); - ExtensionInfo info(type, is_repeated, is_packed); - info.message_prototype = prototype; - Register(containing_type, number, info); -} - - -// =================================================================== -// Constructors and basic methods. - -ExtensionSet::ExtensionSet() {} - -ExtensionSet::~ExtensionSet() { - for (map::iterator iter = extensions_.begin(); - iter != extensions_.end(); ++iter) { - iter->second.Free(); - } -} - -// Defined in extension_set_heavy.cc. -// void ExtensionSet::AppendToList(const Descriptor* containing_type, -// const DescriptorPool* pool, -// vector* output) const - -bool ExtensionSet::Has(int number) const { - map::const_iterator iter = extensions_.find(number); - if (iter == extensions_.end()) return false; - GOOGLE_DCHECK(!iter->second.is_repeated); - return !iter->second.is_cleared; -} - -int ExtensionSet::NumExtensions() const { - int result = 0; - for (map::const_iterator iter = extensions_.begin(); - iter != extensions_.end(); ++iter) { - if (!iter->second.is_cleared) { - ++result; - } - } - return result; -} - -int ExtensionSet::ExtensionSize(int number) const { - map::const_iterator iter = extensions_.find(number); - if (iter == extensions_.end()) return false; - return iter->second.GetSize(); -} - -FieldType ExtensionSet::ExtensionType(int number) const { - map::const_iterator iter = extensions_.find(number); - if (iter == extensions_.end()) { - GOOGLE_LOG(DFATAL) << "Don't lookup extension types if they aren't present (1). "; - return 0; - } - if (iter->second.is_cleared) { - GOOGLE_LOG(DFATAL) << "Don't lookup extension types if they aren't present (2). "; - } - return iter->second.type; -} - -void ExtensionSet::ClearExtension(int number) { - map::iterator iter = extensions_.find(number); - if (iter == extensions_.end()) return; - iter->second.Clear(); -} - -// =================================================================== -// Field accessors - -namespace { - -enum Cardinality { - REPEATED, - OPTIONAL -}; - -} // namespace - -#define GOOGLE_DCHECK_TYPE(EXTENSION, LABEL, CPPTYPE) \ - GOOGLE_DCHECK_EQ((EXTENSION).is_repeated ? REPEATED : OPTIONAL, LABEL); \ - GOOGLE_DCHECK_EQ(cpp_type((EXTENSION).type), WireFormatLite::CPPTYPE_##CPPTYPE) - -// ------------------------------------------------------------------- -// Primitives - -#define PRIMITIVE_ACCESSORS(UPPERCASE, LOWERCASE, CAMELCASE) \ - \ -LOWERCASE ExtensionSet::Get##CAMELCASE(int number, \ - LOWERCASE default_value) const { \ - map::const_iterator iter = extensions_.find(number); \ - if (iter == extensions_.end() || iter->second.is_cleared) { \ - return default_value; \ - } else { \ - GOOGLE_DCHECK_TYPE(iter->second, OPTIONAL, UPPERCASE); \ - return iter->second.LOWERCASE##_value; \ - } \ -} \ - \ -void ExtensionSet::Set##CAMELCASE(int number, FieldType type, \ - LOWERCASE value, \ - const FieldDescriptor* descriptor) { \ - Extension* extension; \ - if (MaybeNewExtension(number, descriptor, &extension)) { \ - extension->type = type; \ - GOOGLE_DCHECK_EQ(cpp_type(extension->type), WireFormatLite::CPPTYPE_##UPPERCASE); \ - extension->is_repeated = false; \ - } else { \ - GOOGLE_DCHECK_TYPE(*extension, OPTIONAL, UPPERCASE); \ - } \ - extension->is_cleared = false; \ - extension->LOWERCASE##_value = value; \ -} \ - \ -LOWERCASE ExtensionSet::GetRepeated##CAMELCASE(int number, int index) const { \ - map::const_iterator iter = extensions_.find(number); \ - GOOGLE_CHECK(iter != extensions_.end()) << "Index out-of-bounds (field is empty)."; \ - GOOGLE_DCHECK_TYPE(iter->second, REPEATED, UPPERCASE); \ - return iter->second.repeated_##LOWERCASE##_value->Get(index); \ -} \ - \ -void ExtensionSet::SetRepeated##CAMELCASE( \ - int number, int index, LOWERCASE value) { \ - map::iterator iter = extensions_.find(number); \ - GOOGLE_CHECK(iter != extensions_.end()) << "Index out-of-bounds (field is empty)."; \ - GOOGLE_DCHECK_TYPE(iter->second, REPEATED, UPPERCASE); \ - iter->second.repeated_##LOWERCASE##_value->Set(index, value); \ -} \ - \ -void ExtensionSet::Add##CAMELCASE(int number, FieldType type, \ - bool packed, LOWERCASE value, \ - const FieldDescriptor* descriptor) { \ - Extension* extension; \ - if (MaybeNewExtension(number, descriptor, &extension)) { \ - extension->type = type; \ - GOOGLE_DCHECK_EQ(cpp_type(extension->type), WireFormatLite::CPPTYPE_##UPPERCASE); \ - extension->is_repeated = true; \ - extension->is_packed = packed; \ - extension->repeated_##LOWERCASE##_value = new RepeatedField(); \ - } else { \ - GOOGLE_DCHECK_TYPE(*extension, REPEATED, UPPERCASE); \ - GOOGLE_DCHECK_EQ(extension->is_packed, packed); \ - } \ - extension->repeated_##LOWERCASE##_value->Add(value); \ -} - -PRIMITIVE_ACCESSORS( INT32, int32, Int32) -PRIMITIVE_ACCESSORS( INT64, int64, Int64) -PRIMITIVE_ACCESSORS(UINT32, uint32, UInt32) -PRIMITIVE_ACCESSORS(UINT64, uint64, UInt64) -PRIMITIVE_ACCESSORS( FLOAT, float, Float) -PRIMITIVE_ACCESSORS(DOUBLE, double, Double) -PRIMITIVE_ACCESSORS( BOOL, bool, Bool) - -#undef PRIMITIVE_ACCESSORS - -void* ExtensionSet::MutableRawRepeatedField(int number) { - // We assume that all the RepeatedField<>* pointers have the same - // size and alignment within the anonymous union in Extension. - map::const_iterator iter = extensions_.find(number); - GOOGLE_CHECK(iter != extensions_.end()) << "no extension numbered " << number; - return iter->second.repeated_int32_value; -} - -// ------------------------------------------------------------------- -// Enums - -int ExtensionSet::GetEnum(int number, int default_value) const { - map::const_iterator iter = extensions_.find(number); - if (iter == extensions_.end() || iter->second.is_cleared) { - // Not present. Return the default value. - return default_value; - } else { - GOOGLE_DCHECK_TYPE(iter->second, OPTIONAL, ENUM); - return iter->second.enum_value; - } -} - -void ExtensionSet::SetEnum(int number, FieldType type, int value, - const FieldDescriptor* descriptor) { - Extension* extension; - if (MaybeNewExtension(number, descriptor, &extension)) { - extension->type = type; - GOOGLE_DCHECK_EQ(cpp_type(extension->type), WireFormatLite::CPPTYPE_ENUM); - extension->is_repeated = false; - } else { - GOOGLE_DCHECK_TYPE(*extension, OPTIONAL, ENUM); - } - extension->is_cleared = false; - extension->enum_value = value; -} - -int ExtensionSet::GetRepeatedEnum(int number, int index) const { - map::const_iterator iter = extensions_.find(number); - GOOGLE_CHECK(iter != extensions_.end()) << "Index out-of-bounds (field is empty)."; - GOOGLE_DCHECK_TYPE(iter->second, REPEATED, ENUM); - return iter->second.repeated_enum_value->Get(index); -} - -void ExtensionSet::SetRepeatedEnum(int number, int index, int value) { - map::iterator iter = extensions_.find(number); - GOOGLE_CHECK(iter != extensions_.end()) << "Index out-of-bounds (field is empty)."; - GOOGLE_DCHECK_TYPE(iter->second, REPEATED, ENUM); - iter->second.repeated_enum_value->Set(index, value); -} - -void ExtensionSet::AddEnum(int number, FieldType type, - bool packed, int value, - const FieldDescriptor* descriptor) { - Extension* extension; - if (MaybeNewExtension(number, descriptor, &extension)) { - extension->type = type; - GOOGLE_DCHECK_EQ(cpp_type(extension->type), WireFormatLite::CPPTYPE_ENUM); - extension->is_repeated = true; - extension->is_packed = packed; - extension->repeated_enum_value = new RepeatedField(); - } else { - GOOGLE_DCHECK_TYPE(*extension, REPEATED, ENUM); - GOOGLE_DCHECK_EQ(extension->is_packed, packed); - } - extension->repeated_enum_value->Add(value); -} - -// ------------------------------------------------------------------- -// Strings - -const string& ExtensionSet::GetString(int number, - const string& default_value) const { - map::const_iterator iter = extensions_.find(number); - if (iter == extensions_.end() || iter->second.is_cleared) { - // Not present. Return the default value. - return default_value; - } else { - GOOGLE_DCHECK_TYPE(iter->second, OPTIONAL, STRING); - return *iter->second.string_value; - } -} - -string* ExtensionSet::MutableString(int number, FieldType type, - const FieldDescriptor* descriptor) { - Extension* extension; - if (MaybeNewExtension(number, descriptor, &extension)) { - extension->type = type; - GOOGLE_DCHECK_EQ(cpp_type(extension->type), WireFormatLite::CPPTYPE_STRING); - extension->is_repeated = false; - extension->string_value = new string; - } else { - GOOGLE_DCHECK_TYPE(*extension, OPTIONAL, STRING); - } - extension->is_cleared = false; - return extension->string_value; -} - -const string& ExtensionSet::GetRepeatedString(int number, int index) const { - map::const_iterator iter = extensions_.find(number); - GOOGLE_CHECK(iter != extensions_.end()) << "Index out-of-bounds (field is empty)."; - GOOGLE_DCHECK_TYPE(iter->second, REPEATED, STRING); - return iter->second.repeated_string_value->Get(index); -} - -string* ExtensionSet::MutableRepeatedString(int number, int index) { - map::iterator iter = extensions_.find(number); - GOOGLE_CHECK(iter != extensions_.end()) << "Index out-of-bounds (field is empty)."; - GOOGLE_DCHECK_TYPE(iter->second, REPEATED, STRING); - return iter->second.repeated_string_value->Mutable(index); -} - -string* ExtensionSet::AddString(int number, FieldType type, - const FieldDescriptor* descriptor) { - Extension* extension; - if (MaybeNewExtension(number, descriptor, &extension)) { - extension->type = type; - GOOGLE_DCHECK_EQ(cpp_type(extension->type), WireFormatLite::CPPTYPE_STRING); - extension->is_repeated = true; - extension->is_packed = false; - extension->repeated_string_value = new RepeatedPtrField(); - } else { - GOOGLE_DCHECK_TYPE(*extension, REPEATED, STRING); - } - return extension->repeated_string_value->Add(); -} - -// ------------------------------------------------------------------- -// Messages - -const MessageLite& ExtensionSet::GetMessage( - int number, const MessageLite& default_value) const { - map::const_iterator iter = extensions_.find(number); - if (iter == extensions_.end()) { - // Not present. Return the default value. - return default_value; - } else { - GOOGLE_DCHECK_TYPE(iter->second, OPTIONAL, MESSAGE); - if (iter->second.is_lazy) { - return iter->second.lazymessage_value->GetMessage(default_value); - } else { - return *iter->second.message_value; - } - } -} - -// Defined in extension_set_heavy.cc. -// const MessageLite& ExtensionSet::GetMessage(int number, -// const Descriptor* message_type, -// MessageFactory* factory) const - -MessageLite* ExtensionSet::MutableMessage(int number, FieldType type, - const MessageLite& prototype, - const FieldDescriptor* descriptor) { - Extension* extension; - if (MaybeNewExtension(number, descriptor, &extension)) { - extension->type = type; - GOOGLE_DCHECK_EQ(cpp_type(extension->type), WireFormatLite::CPPTYPE_MESSAGE); - extension->is_repeated = false; - extension->is_lazy = false; - extension->message_value = prototype.New(); - extension->is_cleared = false; - return extension->message_value; - } else { - GOOGLE_DCHECK_TYPE(*extension, OPTIONAL, MESSAGE); - extension->is_cleared = false; - if (extension->is_lazy) { - return extension->lazymessage_value->MutableMessage(prototype); - } else { - return extension->message_value; - } - } -} - -// Defined in extension_set_heavy.cc. -// MessageLite* ExtensionSet::MutableMessage(int number, FieldType type, -// const Descriptor* message_type, -// MessageFactory* factory) - -void ExtensionSet::SetAllocatedMessage(int number, FieldType type, - const FieldDescriptor* descriptor, - MessageLite* message) { - if (message == NULL) { - ClearExtension(number); - return; - } - Extension* extension; - if (MaybeNewExtension(number, descriptor, &extension)) { - extension->type = type; - GOOGLE_DCHECK_EQ(cpp_type(extension->type), WireFormatLite::CPPTYPE_MESSAGE); - extension->is_repeated = false; - extension->is_lazy = false; - extension->message_value = message; - } else { - GOOGLE_DCHECK_TYPE(*extension, OPTIONAL, MESSAGE); - if (extension->is_lazy) { - extension->lazymessage_value->SetAllocatedMessage(message); - } else { - delete extension->message_value; - extension->message_value = message; - } - } - extension->is_cleared = false; -} - -MessageLite* ExtensionSet::ReleaseMessage(int number, - const MessageLite& prototype) { - map::iterator iter = extensions_.find(number); - if (iter == extensions_.end()) { - // Not present. Return NULL. - return NULL; - } else { - GOOGLE_DCHECK_TYPE(iter->second, OPTIONAL, MESSAGE); - MessageLite* ret = NULL; - if (iter->second.is_lazy) { - ret = iter->second.lazymessage_value->ReleaseMessage(prototype); - delete iter->second.lazymessage_value; - } else { - ret = iter->second.message_value; - } - extensions_.erase(number); - return ret; - } -} - -// Defined in extension_set_heavy.cc. -// MessageLite* ExtensionSet::ReleaseMessage(const FieldDescriptor* descriptor, -// MessageFactory* factory); - -const MessageLite& ExtensionSet::GetRepeatedMessage( - int number, int index) const { - map::const_iterator iter = extensions_.find(number); - GOOGLE_CHECK(iter != extensions_.end()) << "Index out-of-bounds (field is empty)."; - GOOGLE_DCHECK_TYPE(iter->second, REPEATED, MESSAGE); - return iter->second.repeated_message_value->Get(index); -} - -MessageLite* ExtensionSet::MutableRepeatedMessage(int number, int index) { - map::iterator iter = extensions_.find(number); - GOOGLE_CHECK(iter != extensions_.end()) << "Index out-of-bounds (field is empty)."; - GOOGLE_DCHECK_TYPE(iter->second, REPEATED, MESSAGE); - return iter->second.repeated_message_value->Mutable(index); -} - -MessageLite* ExtensionSet::AddMessage(int number, FieldType type, - const MessageLite& prototype, - const FieldDescriptor* descriptor) { - Extension* extension; - if (MaybeNewExtension(number, descriptor, &extension)) { - extension->type = type; - GOOGLE_DCHECK_EQ(cpp_type(extension->type), WireFormatLite::CPPTYPE_MESSAGE); - extension->is_repeated = true; - extension->repeated_message_value = - new RepeatedPtrField(); - } else { - GOOGLE_DCHECK_TYPE(*extension, REPEATED, MESSAGE); - } - - // RepeatedPtrField does not know how to Add() since it cannot - // allocate an abstract object, so we have to be tricky. - MessageLite* result = extension->repeated_message_value - ->AddFromCleared >(); - if (result == NULL) { - result = prototype.New(); - extension->repeated_message_value->AddAllocated(result); - } - return result; -} - -// Defined in extension_set_heavy.cc. -// MessageLite* ExtensionSet::AddMessage(int number, FieldType type, -// const Descriptor* message_type, -// MessageFactory* factory) - -#undef GOOGLE_DCHECK_TYPE - -void ExtensionSet::RemoveLast(int number) { - map::iterator iter = extensions_.find(number); - GOOGLE_CHECK(iter != extensions_.end()) << "Index out-of-bounds (field is empty)."; - - Extension* extension = &iter->second; - GOOGLE_DCHECK(extension->is_repeated); - - switch(cpp_type(extension->type)) { - case WireFormatLite::CPPTYPE_INT32: - extension->repeated_int32_value->RemoveLast(); - break; - case WireFormatLite::CPPTYPE_INT64: - extension->repeated_int64_value->RemoveLast(); - break; - case WireFormatLite::CPPTYPE_UINT32: - extension->repeated_uint32_value->RemoveLast(); - break; - case WireFormatLite::CPPTYPE_UINT64: - extension->repeated_uint64_value->RemoveLast(); - break; - case WireFormatLite::CPPTYPE_FLOAT: - extension->repeated_float_value->RemoveLast(); - break; - case WireFormatLite::CPPTYPE_DOUBLE: - extension->repeated_double_value->RemoveLast(); - break; - case WireFormatLite::CPPTYPE_BOOL: - extension->repeated_bool_value->RemoveLast(); - break; - case WireFormatLite::CPPTYPE_ENUM: - extension->repeated_enum_value->RemoveLast(); - break; - case WireFormatLite::CPPTYPE_STRING: - extension->repeated_string_value->RemoveLast(); - break; - case WireFormatLite::CPPTYPE_MESSAGE: - extension->repeated_message_value->RemoveLast(); - break; - } -} - -MessageLite* ExtensionSet::ReleaseLast(int number) { - map::iterator iter = extensions_.find(number); - GOOGLE_CHECK(iter != extensions_.end()) << "Index out-of-bounds (field is empty)."; - - Extension* extension = &iter->second; - GOOGLE_DCHECK(extension->is_repeated); - GOOGLE_DCHECK(cpp_type(extension->type) == WireFormatLite::CPPTYPE_MESSAGE); - return extension->repeated_message_value->ReleaseLast(); -} - -void ExtensionSet::SwapElements(int number, int index1, int index2) { - map::iterator iter = extensions_.find(number); - GOOGLE_CHECK(iter != extensions_.end()) << "Index out-of-bounds (field is empty)."; - - Extension* extension = &iter->second; - GOOGLE_DCHECK(extension->is_repeated); - - switch(cpp_type(extension->type)) { - case WireFormatLite::CPPTYPE_INT32: - extension->repeated_int32_value->SwapElements(index1, index2); - break; - case WireFormatLite::CPPTYPE_INT64: - extension->repeated_int64_value->SwapElements(index1, index2); - break; - case WireFormatLite::CPPTYPE_UINT32: - extension->repeated_uint32_value->SwapElements(index1, index2); - break; - case WireFormatLite::CPPTYPE_UINT64: - extension->repeated_uint64_value->SwapElements(index1, index2); - break; - case WireFormatLite::CPPTYPE_FLOAT: - extension->repeated_float_value->SwapElements(index1, index2); - break; - case WireFormatLite::CPPTYPE_DOUBLE: - extension->repeated_double_value->SwapElements(index1, index2); - break; - case WireFormatLite::CPPTYPE_BOOL: - extension->repeated_bool_value->SwapElements(index1, index2); - break; - case WireFormatLite::CPPTYPE_ENUM: - extension->repeated_enum_value->SwapElements(index1, index2); - break; - case WireFormatLite::CPPTYPE_STRING: - extension->repeated_string_value->SwapElements(index1, index2); - break; - case WireFormatLite::CPPTYPE_MESSAGE: - extension->repeated_message_value->SwapElements(index1, index2); - break; - } -} - -// =================================================================== - -void ExtensionSet::Clear() { - for (map::iterator iter = extensions_.begin(); - iter != extensions_.end(); ++iter) { - iter->second.Clear(); - } -} - -void ExtensionSet::MergeFrom(const ExtensionSet& other) { - for (map::const_iterator iter = other.extensions_.begin(); - iter != other.extensions_.end(); ++iter) { - const Extension& other_extension = iter->second; - - if (other_extension.is_repeated) { - Extension* extension; - bool is_new = MaybeNewExtension(iter->first, other_extension.descriptor, - &extension); - if (is_new) { - // Extension did not already exist in set. - extension->type = other_extension.type; - extension->is_packed = other_extension.is_packed; - extension->is_repeated = true; - } else { - GOOGLE_DCHECK_EQ(extension->type, other_extension.type); - GOOGLE_DCHECK_EQ(extension->is_packed, other_extension.is_packed); - GOOGLE_DCHECK(extension->is_repeated); - } - - switch (cpp_type(other_extension.type)) { -#define HANDLE_TYPE(UPPERCASE, LOWERCASE, REPEATED_TYPE) \ - case WireFormatLite::CPPTYPE_##UPPERCASE: \ - if (is_new) { \ - extension->repeated_##LOWERCASE##_value = \ - new REPEATED_TYPE; \ - } \ - extension->repeated_##LOWERCASE##_value->MergeFrom( \ - *other_extension.repeated_##LOWERCASE##_value); \ - break; - - HANDLE_TYPE( INT32, int32, RepeatedField < int32>); - HANDLE_TYPE( INT64, int64, RepeatedField < int64>); - HANDLE_TYPE( UINT32, uint32, RepeatedField < uint32>); - HANDLE_TYPE( UINT64, uint64, RepeatedField < uint64>); - HANDLE_TYPE( FLOAT, float, RepeatedField < float>); - HANDLE_TYPE( DOUBLE, double, RepeatedField < double>); - HANDLE_TYPE( BOOL, bool, RepeatedField < bool>); - HANDLE_TYPE( ENUM, enum, RepeatedField < int>); - HANDLE_TYPE( STRING, string, RepeatedPtrField< string>); -#undef HANDLE_TYPE - - case WireFormatLite::CPPTYPE_MESSAGE: - if (is_new) { - extension->repeated_message_value = - new RepeatedPtrField(); - } - // We can't call RepeatedPtrField::MergeFrom() because - // it would attempt to allocate new objects. - RepeatedPtrField* other_repeated_message = - other_extension.repeated_message_value; - for (int i = 0; i < other_repeated_message->size(); i++) { - const MessageLite& other_message = other_repeated_message->Get(i); - MessageLite* target = extension->repeated_message_value - ->AddFromCleared >(); - if (target == NULL) { - target = other_message.New(); - extension->repeated_message_value->AddAllocated(target); - } - target->CheckTypeAndMergeFrom(other_message); - } - break; - } - } else { - if (!other_extension.is_cleared) { - switch (cpp_type(other_extension.type)) { -#define HANDLE_TYPE(UPPERCASE, LOWERCASE, CAMELCASE) \ - case WireFormatLite::CPPTYPE_##UPPERCASE: \ - Set##CAMELCASE(iter->first, other_extension.type, \ - other_extension.LOWERCASE##_value, \ - other_extension.descriptor); \ - break; - - HANDLE_TYPE( INT32, int32, Int32); - HANDLE_TYPE( INT64, int64, Int64); - HANDLE_TYPE(UINT32, uint32, UInt32); - HANDLE_TYPE(UINT64, uint64, UInt64); - HANDLE_TYPE( FLOAT, float, Float); - HANDLE_TYPE(DOUBLE, double, Double); - HANDLE_TYPE( BOOL, bool, Bool); - HANDLE_TYPE( ENUM, enum, Enum); -#undef HANDLE_TYPE - case WireFormatLite::CPPTYPE_STRING: - SetString(iter->first, other_extension.type, - *other_extension.string_value, - other_extension.descriptor); - break; - case WireFormatLite::CPPTYPE_MESSAGE: { - Extension* extension; - bool is_new = MaybeNewExtension(iter->first, - other_extension.descriptor, - &extension); - if (is_new) { - extension->type = other_extension.type; - extension->is_packed = other_extension.is_packed; - extension->is_repeated = false; - if (other_extension.is_lazy) { - extension->is_lazy = true; - extension->lazymessage_value = - other_extension.lazymessage_value->New(); - extension->lazymessage_value->MergeFrom( - *other_extension.lazymessage_value); - } else { - extension->is_lazy = false; - extension->message_value = - other_extension.message_value->New(); - extension->message_value->CheckTypeAndMergeFrom( - *other_extension.message_value); - } - } else { - GOOGLE_DCHECK_EQ(extension->type, other_extension.type); - GOOGLE_DCHECK_EQ(extension->is_packed,other_extension.is_packed); - GOOGLE_DCHECK(!extension->is_repeated); - if (other_extension.is_lazy) { - if (extension->is_lazy) { - extension->lazymessage_value->MergeFrom( - *other_extension.lazymessage_value); - } else { - extension->message_value->CheckTypeAndMergeFrom( - other_extension.lazymessage_value->GetMessage( - *extension->message_value)); - } - } else { - if (extension->is_lazy) { - extension->lazymessage_value->MutableMessage( - *other_extension.message_value)->CheckTypeAndMergeFrom( - *other_extension.message_value); - } else { - extension->message_value->CheckTypeAndMergeFrom( - *other_extension.message_value); - } - } - } - extension->is_cleared = false; - break; - } - } - } - } - } -} - -void ExtensionSet::Swap(ExtensionSet* x) { - extensions_.swap(x->extensions_); -} - -bool ExtensionSet::IsInitialized() const { - // Extensions are never required. However, we need to check that all - // embedded messages are initialized. - for (map::const_iterator iter = extensions_.begin(); - iter != extensions_.end(); ++iter) { - const Extension& extension = iter->second; - if (cpp_type(extension.type) == WireFormatLite::CPPTYPE_MESSAGE) { - if (extension.is_repeated) { - for (int i = 0; i < extension.repeated_message_value->size(); i++) { - if (!extension.repeated_message_value->Get(i).IsInitialized()) { - return false; - } - } - } else { - if (!extension.is_cleared) { - if (extension.is_lazy) { - if (!extension.lazymessage_value->IsInitialized()) return false; - } else { - if (!extension.message_value->IsInitialized()) return false; - } - } - } - } - } - - return true; -} - -bool ExtensionSet::FindExtensionInfoFromTag( - uint32 tag, ExtensionFinder* extension_finder, - int* field_number, ExtensionInfo* extension) { - *field_number = WireFormatLite::GetTagFieldNumber(tag); - WireFormatLite::WireType wire_type = WireFormatLite::GetTagWireType(tag); - - bool is_unknown; - if (!extension_finder->Find(*field_number, extension)) { - is_unknown = true; - } else if (extension->is_packed) { - is_unknown = (wire_type != WireFormatLite::WIRETYPE_LENGTH_DELIMITED); - } else { - WireFormatLite::WireType expected_wire_type = - WireFormatLite::WireTypeForFieldType(real_type(extension->type)); - is_unknown = (wire_type != expected_wire_type); - } - return !is_unknown; -} - -bool ExtensionSet::ParseField(uint32 tag, io::CodedInputStream* input, - ExtensionFinder* extension_finder, - FieldSkipper* field_skipper) { - int number; - ExtensionInfo extension; - if (!FindExtensionInfoFromTag(tag, extension_finder, &number, &extension)) { - return field_skipper->SkipField(input, tag); - } else { - return ParseFieldWithExtensionInfo(number, extension, input, field_skipper); - } -} - -bool ExtensionSet::ParseFieldWithExtensionInfo( - int number, const ExtensionInfo& extension, - io::CodedInputStream* input, - FieldSkipper* field_skipper) { - if (extension.is_packed) { - uint32 size; - if (!input->ReadVarint32(&size)) return false; - io::CodedInputStream::Limit limit = input->PushLimit(size); - - switch (extension.type) { -#define HANDLE_TYPE(UPPERCASE, CPP_CAMELCASE, CPP_LOWERCASE) \ - case WireFormatLite::TYPE_##UPPERCASE: \ - while (input->BytesUntilLimit() > 0) { \ - CPP_LOWERCASE value; \ - if (!WireFormatLite::ReadPrimitive< \ - CPP_LOWERCASE, WireFormatLite::TYPE_##UPPERCASE>( \ - input, &value)) return false; \ - Add##CPP_CAMELCASE(number, WireFormatLite::TYPE_##UPPERCASE, \ - true, value, extension.descriptor); \ - } \ - break - - HANDLE_TYPE( INT32, Int32, int32); - HANDLE_TYPE( INT64, Int64, int64); - HANDLE_TYPE( UINT32, UInt32, uint32); - HANDLE_TYPE( UINT64, UInt64, uint64); - HANDLE_TYPE( SINT32, Int32, int32); - HANDLE_TYPE( SINT64, Int64, int64); - HANDLE_TYPE( FIXED32, UInt32, uint32); - HANDLE_TYPE( FIXED64, UInt64, uint64); - HANDLE_TYPE(SFIXED32, Int32, int32); - HANDLE_TYPE(SFIXED64, Int64, int64); - HANDLE_TYPE( FLOAT, Float, float); - HANDLE_TYPE( DOUBLE, Double, double); - HANDLE_TYPE( BOOL, Bool, bool); -#undef HANDLE_TYPE - - case WireFormatLite::TYPE_ENUM: - while (input->BytesUntilLimit() > 0) { - int value; - if (!WireFormatLite::ReadPrimitive( - input, &value)) return false; - if (extension.enum_validity_check.func( - extension.enum_validity_check.arg, value)) { - AddEnum(number, WireFormatLite::TYPE_ENUM, true, value, - extension.descriptor); - } - } - break; - - case WireFormatLite::TYPE_STRING: - case WireFormatLite::TYPE_BYTES: - case WireFormatLite::TYPE_GROUP: - case WireFormatLite::TYPE_MESSAGE: - GOOGLE_LOG(FATAL) << "Non-primitive types can't be packed."; - break; - } - - input->PopLimit(limit); - } else { - switch (extension.type) { -#define HANDLE_TYPE(UPPERCASE, CPP_CAMELCASE, CPP_LOWERCASE) \ - case WireFormatLite::TYPE_##UPPERCASE: { \ - CPP_LOWERCASE value; \ - if (!WireFormatLite::ReadPrimitive< \ - CPP_LOWERCASE, WireFormatLite::TYPE_##UPPERCASE>( \ - input, &value)) return false; \ - if (extension.is_repeated) { \ - Add##CPP_CAMELCASE(number, WireFormatLite::TYPE_##UPPERCASE, \ - false, value, extension.descriptor); \ - } else { \ - Set##CPP_CAMELCASE(number, WireFormatLite::TYPE_##UPPERCASE, value, \ - extension.descriptor); \ - } \ - } break - - HANDLE_TYPE( INT32, Int32, int32); - HANDLE_TYPE( INT64, Int64, int64); - HANDLE_TYPE( UINT32, UInt32, uint32); - HANDLE_TYPE( UINT64, UInt64, uint64); - HANDLE_TYPE( SINT32, Int32, int32); - HANDLE_TYPE( SINT64, Int64, int64); - HANDLE_TYPE( FIXED32, UInt32, uint32); - HANDLE_TYPE( FIXED64, UInt64, uint64); - HANDLE_TYPE(SFIXED32, Int32, int32); - HANDLE_TYPE(SFIXED64, Int64, int64); - HANDLE_TYPE( FLOAT, Float, float); - HANDLE_TYPE( DOUBLE, Double, double); - HANDLE_TYPE( BOOL, Bool, bool); -#undef HANDLE_TYPE - - case WireFormatLite::TYPE_ENUM: { - int value; - if (!WireFormatLite::ReadPrimitive( - input, &value)) return false; - - if (!extension.enum_validity_check.func( - extension.enum_validity_check.arg, value)) { - // Invalid value. Treat as unknown. - field_skipper->SkipUnknownEnum(number, value); - } else if (extension.is_repeated) { - AddEnum(number, WireFormatLite::TYPE_ENUM, false, value, - extension.descriptor); - } else { - SetEnum(number, WireFormatLite::TYPE_ENUM, value, - extension.descriptor); - } - break; - } - - case WireFormatLite::TYPE_STRING: { - string* value = extension.is_repeated ? - AddString(number, WireFormatLite::TYPE_STRING, extension.descriptor) : - MutableString(number, WireFormatLite::TYPE_STRING, - extension.descriptor); - if (!WireFormatLite::ReadString(input, value)) return false; - break; - } - - case WireFormatLite::TYPE_BYTES: { - string* value = extension.is_repeated ? - AddString(number, WireFormatLite::TYPE_BYTES, extension.descriptor) : - MutableString(number, WireFormatLite::TYPE_BYTES, - extension.descriptor); - if (!WireFormatLite::ReadBytes(input, value)) return false; - break; - } - - case WireFormatLite::TYPE_GROUP: { - MessageLite* value = extension.is_repeated ? - AddMessage(number, WireFormatLite::TYPE_GROUP, - *extension.message_prototype, extension.descriptor) : - MutableMessage(number, WireFormatLite::TYPE_GROUP, - *extension.message_prototype, extension.descriptor); - if (!WireFormatLite::ReadGroup(number, input, value)) return false; - break; - } - - case WireFormatLite::TYPE_MESSAGE: { - MessageLite* value = extension.is_repeated ? - AddMessage(number, WireFormatLite::TYPE_MESSAGE, - *extension.message_prototype, extension.descriptor) : - MutableMessage(number, WireFormatLite::TYPE_MESSAGE, - *extension.message_prototype, extension.descriptor); - if (!WireFormatLite::ReadMessage(input, value)) return false; - break; - } - } - } - - return true; -} - -bool ExtensionSet::ParseField(uint32 tag, io::CodedInputStream* input, - const MessageLite* containing_type) { - FieldSkipper skipper; - GeneratedExtensionFinder finder(containing_type); - return ParseField(tag, input, &finder, &skipper); -} - -// Defined in extension_set_heavy.cc. -// bool ExtensionSet::ParseField(uint32 tag, io::CodedInputStream* input, -// const MessageLite* containing_type, -// UnknownFieldSet* unknown_fields) - -// Defined in extension_set_heavy.cc. -// bool ExtensionSet::ParseMessageSet(io::CodedInputStream* input, -// const MessageLite* containing_type, -// UnknownFieldSet* unknown_fields); - -void ExtensionSet::SerializeWithCachedSizes( - int start_field_number, int end_field_number, - io::CodedOutputStream* output) const { - map::const_iterator iter; - for (iter = extensions_.lower_bound(start_field_number); - iter != extensions_.end() && iter->first < end_field_number; - ++iter) { - iter->second.SerializeFieldWithCachedSizes(iter->first, output); - } -} - -int ExtensionSet::ByteSize() const { - int total_size = 0; - - for (map::const_iterator iter = extensions_.begin(); - iter != extensions_.end(); ++iter) { - total_size += iter->second.ByteSize(iter->first); - } - - return total_size; -} - -// Defined in extension_set_heavy.cc. -// int ExtensionSet::SpaceUsedExcludingSelf() const - -bool ExtensionSet::MaybeNewExtension(int number, - const FieldDescriptor* descriptor, - Extension** result) { - pair::iterator, bool> insert_result = - extensions_.insert(make_pair(number, Extension())); - *result = &insert_result.first->second; - (*result)->descriptor = descriptor; - return insert_result.second; -} - -// =================================================================== -// Methods of ExtensionSet::Extension - -void ExtensionSet::Extension::Clear() { - if (is_repeated) { - switch (cpp_type(type)) { -#define HANDLE_TYPE(UPPERCASE, LOWERCASE) \ - case WireFormatLite::CPPTYPE_##UPPERCASE: \ - repeated_##LOWERCASE##_value->Clear(); \ - break - - HANDLE_TYPE( INT32, int32); - HANDLE_TYPE( INT64, int64); - HANDLE_TYPE( UINT32, uint32); - HANDLE_TYPE( UINT64, uint64); - HANDLE_TYPE( FLOAT, float); - HANDLE_TYPE( DOUBLE, double); - HANDLE_TYPE( BOOL, bool); - HANDLE_TYPE( ENUM, enum); - HANDLE_TYPE( STRING, string); - HANDLE_TYPE(MESSAGE, message); -#undef HANDLE_TYPE - } - } else { - if (!is_cleared) { - switch (cpp_type(type)) { - case WireFormatLite::CPPTYPE_STRING: - string_value->clear(); - break; - case WireFormatLite::CPPTYPE_MESSAGE: - if (is_lazy) { - lazymessage_value->Clear(); - } else { - message_value->Clear(); - } - break; - default: - // No need to do anything. Get*() will return the default value - // as long as is_cleared is true and Set*() will overwrite the - // previous value. - break; - } - - is_cleared = true; - } - } -} - -void ExtensionSet::Extension::SerializeFieldWithCachedSizes( - int number, - io::CodedOutputStream* output) const { - if (is_repeated) { - if (is_packed) { - if (cached_size == 0) return; - - WireFormatLite::WriteTag(number, - WireFormatLite::WIRETYPE_LENGTH_DELIMITED, output); - output->WriteVarint32(cached_size); - - switch (real_type(type)) { -#define HANDLE_TYPE(UPPERCASE, CAMELCASE, LOWERCASE) \ - case WireFormatLite::TYPE_##UPPERCASE: \ - for (int i = 0; i < repeated_##LOWERCASE##_value->size(); i++) { \ - WireFormatLite::Write##CAMELCASE##NoTag( \ - repeated_##LOWERCASE##_value->Get(i), output); \ - } \ - break - - HANDLE_TYPE( INT32, Int32, int32); - HANDLE_TYPE( INT64, Int64, int64); - HANDLE_TYPE( UINT32, UInt32, uint32); - HANDLE_TYPE( UINT64, UInt64, uint64); - HANDLE_TYPE( SINT32, SInt32, int32); - HANDLE_TYPE( SINT64, SInt64, int64); - HANDLE_TYPE( FIXED32, Fixed32, uint32); - HANDLE_TYPE( FIXED64, Fixed64, uint64); - HANDLE_TYPE(SFIXED32, SFixed32, int32); - HANDLE_TYPE(SFIXED64, SFixed64, int64); - HANDLE_TYPE( FLOAT, Float, float); - HANDLE_TYPE( DOUBLE, Double, double); - HANDLE_TYPE( BOOL, Bool, bool); - HANDLE_TYPE( ENUM, Enum, enum); -#undef HANDLE_TYPE - - case WireFormatLite::TYPE_STRING: - case WireFormatLite::TYPE_BYTES: - case WireFormatLite::TYPE_GROUP: - case WireFormatLite::TYPE_MESSAGE: - GOOGLE_LOG(FATAL) << "Non-primitive types can't be packed."; - break; - } - } else { - switch (real_type(type)) { -#define HANDLE_TYPE(UPPERCASE, CAMELCASE, LOWERCASE) \ - case WireFormatLite::TYPE_##UPPERCASE: \ - for (int i = 0; i < repeated_##LOWERCASE##_value->size(); i++) { \ - WireFormatLite::Write##CAMELCASE(number, \ - repeated_##LOWERCASE##_value->Get(i), output); \ - } \ - break - - HANDLE_TYPE( INT32, Int32, int32); - HANDLE_TYPE( INT64, Int64, int64); - HANDLE_TYPE( UINT32, UInt32, uint32); - HANDLE_TYPE( UINT64, UInt64, uint64); - HANDLE_TYPE( SINT32, SInt32, int32); - HANDLE_TYPE( SINT64, SInt64, int64); - HANDLE_TYPE( FIXED32, Fixed32, uint32); - HANDLE_TYPE( FIXED64, Fixed64, uint64); - HANDLE_TYPE(SFIXED32, SFixed32, int32); - HANDLE_TYPE(SFIXED64, SFixed64, int64); - HANDLE_TYPE( FLOAT, Float, float); - HANDLE_TYPE( DOUBLE, Double, double); - HANDLE_TYPE( BOOL, Bool, bool); - HANDLE_TYPE( STRING, String, string); - HANDLE_TYPE( BYTES, Bytes, string); - HANDLE_TYPE( ENUM, Enum, enum); - HANDLE_TYPE( GROUP, Group, message); - HANDLE_TYPE( MESSAGE, Message, message); -#undef HANDLE_TYPE - } - } - } else if (!is_cleared) { - switch (real_type(type)) { -#define HANDLE_TYPE(UPPERCASE, CAMELCASE, VALUE) \ - case WireFormatLite::TYPE_##UPPERCASE: \ - WireFormatLite::Write##CAMELCASE(number, VALUE, output); \ - break - - HANDLE_TYPE( INT32, Int32, int32_value); - HANDLE_TYPE( INT64, Int64, int64_value); - HANDLE_TYPE( UINT32, UInt32, uint32_value); - HANDLE_TYPE( UINT64, UInt64, uint64_value); - HANDLE_TYPE( SINT32, SInt32, int32_value); - HANDLE_TYPE( SINT64, SInt64, int64_value); - HANDLE_TYPE( FIXED32, Fixed32, uint32_value); - HANDLE_TYPE( FIXED64, Fixed64, uint64_value); - HANDLE_TYPE(SFIXED32, SFixed32, int32_value); - HANDLE_TYPE(SFIXED64, SFixed64, int64_value); - HANDLE_TYPE( FLOAT, Float, float_value); - HANDLE_TYPE( DOUBLE, Double, double_value); - HANDLE_TYPE( BOOL, Bool, bool_value); - HANDLE_TYPE( STRING, String, *string_value); - HANDLE_TYPE( BYTES, Bytes, *string_value); - HANDLE_TYPE( ENUM, Enum, enum_value); - HANDLE_TYPE( GROUP, Group, *message_value); -#undef HANDLE_TYPE - case WireFormatLite::TYPE_MESSAGE: - if (is_lazy) { - lazymessage_value->WriteMessage(number, output); - } else { - WireFormatLite::WriteMessage(number, *message_value, output); - } - break; - } - } -} - -int ExtensionSet::Extension::ByteSize(int number) const { - int result = 0; - - if (is_repeated) { - if (is_packed) { - switch (real_type(type)) { -#define HANDLE_TYPE(UPPERCASE, CAMELCASE, LOWERCASE) \ - case WireFormatLite::TYPE_##UPPERCASE: \ - for (int i = 0; i < repeated_##LOWERCASE##_value->size(); i++) { \ - result += WireFormatLite::CAMELCASE##Size( \ - repeated_##LOWERCASE##_value->Get(i)); \ - } \ - break - - HANDLE_TYPE( INT32, Int32, int32); - HANDLE_TYPE( INT64, Int64, int64); - HANDLE_TYPE( UINT32, UInt32, uint32); - HANDLE_TYPE( UINT64, UInt64, uint64); - HANDLE_TYPE( SINT32, SInt32, int32); - HANDLE_TYPE( SINT64, SInt64, int64); - HANDLE_TYPE( ENUM, Enum, enum); -#undef HANDLE_TYPE - - // Stuff with fixed size. -#define HANDLE_TYPE(UPPERCASE, CAMELCASE, LOWERCASE) \ - case WireFormatLite::TYPE_##UPPERCASE: \ - result += WireFormatLite::k##CAMELCASE##Size * \ - repeated_##LOWERCASE##_value->size(); \ - break - HANDLE_TYPE( FIXED32, Fixed32, uint32); - HANDLE_TYPE( FIXED64, Fixed64, uint64); - HANDLE_TYPE(SFIXED32, SFixed32, int32); - HANDLE_TYPE(SFIXED64, SFixed64, int64); - HANDLE_TYPE( FLOAT, Float, float); - HANDLE_TYPE( DOUBLE, Double, double); - HANDLE_TYPE( BOOL, Bool, bool); -#undef HANDLE_TYPE - - case WireFormatLite::TYPE_STRING: - case WireFormatLite::TYPE_BYTES: - case WireFormatLite::TYPE_GROUP: - case WireFormatLite::TYPE_MESSAGE: - GOOGLE_LOG(FATAL) << "Non-primitive types can't be packed."; - break; - } - - cached_size = result; - if (result > 0) { - result += io::CodedOutputStream::VarintSize32(result); - result += io::CodedOutputStream::VarintSize32( - WireFormatLite::MakeTag(number, - WireFormatLite::WIRETYPE_LENGTH_DELIMITED)); - } - } else { - int tag_size = WireFormatLite::TagSize(number, real_type(type)); - - switch (real_type(type)) { -#define HANDLE_TYPE(UPPERCASE, CAMELCASE, LOWERCASE) \ - case WireFormatLite::TYPE_##UPPERCASE: \ - result += tag_size * repeated_##LOWERCASE##_value->size(); \ - for (int i = 0; i < repeated_##LOWERCASE##_value->size(); i++) { \ - result += WireFormatLite::CAMELCASE##Size( \ - repeated_##LOWERCASE##_value->Get(i)); \ - } \ - break - - HANDLE_TYPE( INT32, Int32, int32); - HANDLE_TYPE( INT64, Int64, int64); - HANDLE_TYPE( UINT32, UInt32, uint32); - HANDLE_TYPE( UINT64, UInt64, uint64); - HANDLE_TYPE( SINT32, SInt32, int32); - HANDLE_TYPE( SINT64, SInt64, int64); - HANDLE_TYPE( STRING, String, string); - HANDLE_TYPE( BYTES, Bytes, string); - HANDLE_TYPE( ENUM, Enum, enum); - HANDLE_TYPE( GROUP, Group, message); - HANDLE_TYPE( MESSAGE, Message, message); -#undef HANDLE_TYPE - - // Stuff with fixed size. -#define HANDLE_TYPE(UPPERCASE, CAMELCASE, LOWERCASE) \ - case WireFormatLite::TYPE_##UPPERCASE: \ - result += (tag_size + WireFormatLite::k##CAMELCASE##Size) * \ - repeated_##LOWERCASE##_value->size(); \ - break - HANDLE_TYPE( FIXED32, Fixed32, uint32); - HANDLE_TYPE( FIXED64, Fixed64, uint64); - HANDLE_TYPE(SFIXED32, SFixed32, int32); - HANDLE_TYPE(SFIXED64, SFixed64, int64); - HANDLE_TYPE( FLOAT, Float, float); - HANDLE_TYPE( DOUBLE, Double, double); - HANDLE_TYPE( BOOL, Bool, bool); -#undef HANDLE_TYPE - } - } - } else if (!is_cleared) { - result += WireFormatLite::TagSize(number, real_type(type)); - switch (real_type(type)) { -#define HANDLE_TYPE(UPPERCASE, CAMELCASE, LOWERCASE) \ - case WireFormatLite::TYPE_##UPPERCASE: \ - result += WireFormatLite::CAMELCASE##Size(LOWERCASE); \ - break - - HANDLE_TYPE( INT32, Int32, int32_value); - HANDLE_TYPE( INT64, Int64, int64_value); - HANDLE_TYPE( UINT32, UInt32, uint32_value); - HANDLE_TYPE( UINT64, UInt64, uint64_value); - HANDLE_TYPE( SINT32, SInt32, int32_value); - HANDLE_TYPE( SINT64, SInt64, int64_value); - HANDLE_TYPE( STRING, String, *string_value); - HANDLE_TYPE( BYTES, Bytes, *string_value); - HANDLE_TYPE( ENUM, Enum, enum_value); - HANDLE_TYPE( GROUP, Group, *message_value); -#undef HANDLE_TYPE - case WireFormatLite::TYPE_MESSAGE: { - if (is_lazy) { - int size = lazymessage_value->ByteSize(); - result += io::CodedOutputStream::VarintSize32(size) + size; - } else { - result += WireFormatLite::MessageSize(*message_value); - } - break; - } - - // Stuff with fixed size. -#define HANDLE_TYPE(UPPERCASE, CAMELCASE) \ - case WireFormatLite::TYPE_##UPPERCASE: \ - result += WireFormatLite::k##CAMELCASE##Size; \ - break - HANDLE_TYPE( FIXED32, Fixed32); - HANDLE_TYPE( FIXED64, Fixed64); - HANDLE_TYPE(SFIXED32, SFixed32); - HANDLE_TYPE(SFIXED64, SFixed64); - HANDLE_TYPE( FLOAT, Float); - HANDLE_TYPE( DOUBLE, Double); - HANDLE_TYPE( BOOL, Bool); -#undef HANDLE_TYPE - } - } - - return result; -} - -int ExtensionSet::Extension::GetSize() const { - GOOGLE_DCHECK(is_repeated); - switch (cpp_type(type)) { -#define HANDLE_TYPE(UPPERCASE, LOWERCASE) \ - case WireFormatLite::CPPTYPE_##UPPERCASE: \ - return repeated_##LOWERCASE##_value->size() - - HANDLE_TYPE( INT32, int32); - HANDLE_TYPE( INT64, int64); - HANDLE_TYPE( UINT32, uint32); - HANDLE_TYPE( UINT64, uint64); - HANDLE_TYPE( FLOAT, float); - HANDLE_TYPE( DOUBLE, double); - HANDLE_TYPE( BOOL, bool); - HANDLE_TYPE( ENUM, enum); - HANDLE_TYPE( STRING, string); - HANDLE_TYPE(MESSAGE, message); -#undef HANDLE_TYPE - } - - GOOGLE_LOG(FATAL) << "Can't get here."; - return 0; -} - -void ExtensionSet::Extension::Free() { - if (is_repeated) { - switch (cpp_type(type)) { -#define HANDLE_TYPE(UPPERCASE, LOWERCASE) \ - case WireFormatLite::CPPTYPE_##UPPERCASE: \ - delete repeated_##LOWERCASE##_value; \ - break - - HANDLE_TYPE( INT32, int32); - HANDLE_TYPE( INT64, int64); - HANDLE_TYPE( UINT32, uint32); - HANDLE_TYPE( UINT64, uint64); - HANDLE_TYPE( FLOAT, float); - HANDLE_TYPE( DOUBLE, double); - HANDLE_TYPE( BOOL, bool); - HANDLE_TYPE( ENUM, enum); - HANDLE_TYPE( STRING, string); - HANDLE_TYPE(MESSAGE, message); -#undef HANDLE_TYPE - } - } else { - switch (cpp_type(type)) { - case WireFormatLite::CPPTYPE_STRING: - delete string_value; - break; - case WireFormatLite::CPPTYPE_MESSAGE: - if (is_lazy) { - delete lazymessage_value; - } else { - delete message_value; - } - break; - default: - break; - } - } -} - -// Defined in extension_set_heavy.cc. -// int ExtensionSet::Extension::SpaceUsedExcludingSelf() const - -} // namespace internal -} // namespace protobuf -} // namespace google diff --git a/modules/dnn/3rdparty/protobuf/src/google/protobuf/extension_set.h b/modules/dnn/3rdparty/protobuf/src/google/protobuf/extension_set.h deleted file mode 100644 index df8f1f368..000000000 --- a/modules/dnn/3rdparty/protobuf/src/google/protobuf/extension_set.h +++ /dev/null @@ -1,1007 +0,0 @@ -// Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// http://code.google.com/p/protobuf/ -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -// Author: kenton@google.com (Kenton Varda) -// Based on original Protocol Buffers design by -// Sanjay Ghemawat, Jeff Dean, and others. -// -// This header is logically internal, but is made public because it is used -// from protocol-compiler-generated code, which may reside in other components. - -#ifndef GOOGLE_PROTOBUF_EXTENSION_SET_H__ -#define GOOGLE_PROTOBUF_EXTENSION_SET_H__ - -#include -#include -#include -#include - - -#include - -namespace google { - -namespace protobuf { - class Descriptor; // descriptor.h - class FieldDescriptor; // descriptor.h - class DescriptorPool; // descriptor.h - class MessageLite; // message_lite.h - class Message; // message.h - class MessageFactory; // message.h - class UnknownFieldSet; // unknown_field_set.h - namespace io { - class CodedInputStream; // coded_stream.h - class CodedOutputStream; // coded_stream.h - } - namespace internal { - class FieldSkipper; // wire_format_lite.h - class RepeatedPtrFieldBase; // repeated_field.h - } - template class RepeatedField; // repeated_field.h - template class RepeatedPtrField; // repeated_field.h -} - -namespace protobuf { -namespace internal { - -// Used to store values of type WireFormatLite::FieldType without having to -// #include wire_format_lite.h. Also, ensures that we use only one byte to -// store these values, which is important to keep the layout of -// ExtensionSet::Extension small. -typedef uint8 FieldType; - -// A function which, given an integer value, returns true if the number -// matches one of the defined values for the corresponding enum type. This -// is used with RegisterEnumExtension, below. -typedef bool EnumValidityFunc(int number); - -// Version of the above which takes an argument. This is needed to deal with -// extensions that are not compiled in. -typedef bool EnumValidityFuncWithArg(const void* arg, int number); - -// Information about a registered extension. -struct ExtensionInfo { - inline ExtensionInfo() {} - inline ExtensionInfo(FieldType type_param, bool isrepeated, bool ispacked) - : type(type_param), is_repeated(isrepeated), is_packed(ispacked), - descriptor(NULL) {} - - FieldType type; - bool is_repeated; - bool is_packed; - - struct EnumValidityCheck { - EnumValidityFuncWithArg* func; - const void* arg; - }; - - union { - EnumValidityCheck enum_validity_check; - const MessageLite* message_prototype; - }; - - // The descriptor for this extension, if one exists and is known. May be - // NULL. Must not be NULL if the descriptor for the extension does not - // live in the same pool as the descriptor for the containing type. - const FieldDescriptor* descriptor; -}; - -// Abstract interface for an object which looks up extension definitions. Used -// when parsing. -class LIBPROTOBUF_EXPORT ExtensionFinder { - public: - virtual ~ExtensionFinder(); - - // Find the extension with the given containing type and number. - virtual bool Find(int number, ExtensionInfo* output) = 0; -}; - -// Implementation of ExtensionFinder which finds extensions defined in .proto -// files which have been compiled into the binary. -class LIBPROTOBUF_EXPORT GeneratedExtensionFinder : public ExtensionFinder { - public: - GeneratedExtensionFinder(const MessageLite* containing_type) - : containing_type_(containing_type) {} - virtual ~GeneratedExtensionFinder() {} - - // Returns true and fills in *output if found, otherwise returns false. - virtual bool Find(int number, ExtensionInfo* output); - - private: - const MessageLite* containing_type_; -}; - -// Note: extension_set_heavy.cc defines DescriptorPoolExtensionFinder for -// finding extensions from a DescriptorPool. - -// This is an internal helper class intended for use within the protocol buffer -// library and generated classes. Clients should not use it directly. Instead, -// use the generated accessors such as GetExtension() of the class being -// extended. -// -// This class manages extensions for a protocol message object. The -// message's HasExtension(), GetExtension(), MutableExtension(), and -// ClearExtension() methods are just thin wrappers around the embedded -// ExtensionSet. When parsing, if a tag number is encountered which is -// inside one of the message type's extension ranges, the tag is passed -// off to the ExtensionSet for parsing. Etc. -class LIBPROTOBUF_EXPORT ExtensionSet { - public: - ExtensionSet(); - ~ExtensionSet(); - - // These are called at startup by protocol-compiler-generated code to - // register known extensions. The registrations are used by ParseField() - // to look up extensions for parsed field numbers. Note that dynamic parsing - // does not use ParseField(); only protocol-compiler-generated parsing - // methods do. - static void RegisterExtension(const MessageLite* containing_type, - int number, FieldType type, - bool is_repeated, bool is_packed); - static void RegisterEnumExtension(const MessageLite* containing_type, - int number, FieldType type, - bool is_repeated, bool is_packed, - EnumValidityFunc* is_valid); - static void RegisterMessageExtension(const MessageLite* containing_type, - int number, FieldType type, - bool is_repeated, bool is_packed, - const MessageLite* prototype); - - // ================================================================= - - // Add all fields which are currently present to the given vector. This - // is useful to implement Reflection::ListFields(). - void AppendToList(const Descriptor* containing_type, - const DescriptorPool* pool, - vector* output) const; - - // ================================================================= - // Accessors - // - // Generated message classes include type-safe templated wrappers around - // these methods. Generally you should use those rather than call these - // directly, unless you are doing low-level memory management. - // - // When calling any of these accessors, the extension number requested - // MUST exist in the DescriptorPool provided to the constructor. Otheriwse, - // the method will fail an assert. Normally, though, you would not call - // these directly; you would either call the generated accessors of your - // message class (e.g. GetExtension()) or you would call the accessors - // of the reflection interface. In both cases, it is impossible to - // trigger this assert failure: the generated accessors only accept - // linked-in extension types as parameters, while the Reflection interface - // requires you to provide the FieldDescriptor describing the extension. - // - // When calling any of these accessors, a protocol-compiler-generated - // implementation of the extension corresponding to the number MUST - // be linked in, and the FieldDescriptor used to refer to it MUST be - // the one generated by that linked-in code. Otherwise, the method will - // die on an assert failure. The message objects returned by the message - // accessors are guaranteed to be of the correct linked-in type. - // - // These methods pretty much match Reflection except that: - // - They're not virtual. - // - They identify fields by number rather than FieldDescriptors. - // - They identify enum values using integers rather than descriptors. - // - Strings provide Mutable() in addition to Set() accessors. - - bool Has(int number) const; - int ExtensionSize(int number) const; // Size of a repeated extension. - int NumExtensions() const; // The number of extensions - FieldType ExtensionType(int number) const; - void ClearExtension(int number); - - // singular fields ------------------------------------------------- - - int32 GetInt32 (int number, int32 default_value) const; - int64 GetInt64 (int number, int64 default_value) const; - uint32 GetUInt32(int number, uint32 default_value) const; - uint64 GetUInt64(int number, uint64 default_value) const; - float GetFloat (int number, float default_value) const; - double GetDouble(int number, double default_value) const; - bool GetBool (int number, bool default_value) const; - int GetEnum (int number, int default_value) const; - const string & GetString (int number, const string& default_value) const; - const MessageLite& GetMessage(int number, - const MessageLite& default_value) const; - const MessageLite& GetMessage(int number, const Descriptor* message_type, - MessageFactory* factory) const; - - // |descriptor| may be NULL so long as it is known that the descriptor for - // the extension lives in the same pool as the descriptor for the containing - // type. -#define desc const FieldDescriptor* descriptor // avoid line wrapping - void SetInt32 (int number, FieldType type, int32 value, desc); - void SetInt64 (int number, FieldType type, int64 value, desc); - void SetUInt32(int number, FieldType type, uint32 value, desc); - void SetUInt64(int number, FieldType type, uint64 value, desc); - void SetFloat (int number, FieldType type, float value, desc); - void SetDouble(int number, FieldType type, double value, desc); - void SetBool (int number, FieldType type, bool value, desc); - void SetEnum (int number, FieldType type, int value, desc); - void SetString(int number, FieldType type, const string& value, desc); - string * MutableString (int number, FieldType type, desc); - MessageLite* MutableMessage(int number, FieldType type, - const MessageLite& prototype, desc); - MessageLite* MutableMessage(const FieldDescriptor* decsriptor, - MessageFactory* factory); - // Adds the given message to the ExtensionSet, taking ownership of the - // message object. Existing message with the same number will be deleted. - // If "message" is NULL, this is equivalent to "ClearExtension(number)". - void SetAllocatedMessage(int number, FieldType type, - const FieldDescriptor* descriptor, - MessageLite* message); - MessageLite* ReleaseMessage(int number, const MessageLite& prototype); - MessageLite* ReleaseMessage(const FieldDescriptor* descriptor, - MessageFactory* factory); -#undef desc - - // repeated fields ------------------------------------------------- - - void* MutableRawRepeatedField(int number); - - int32 GetRepeatedInt32 (int number, int index) const; - int64 GetRepeatedInt64 (int number, int index) const; - uint32 GetRepeatedUInt32(int number, int index) const; - uint64 GetRepeatedUInt64(int number, int index) const; - float GetRepeatedFloat (int number, int index) const; - double GetRepeatedDouble(int number, int index) const; - bool GetRepeatedBool (int number, int index) const; - int GetRepeatedEnum (int number, int index) const; - const string & GetRepeatedString (int number, int index) const; - const MessageLite& GetRepeatedMessage(int number, int index) const; - - void SetRepeatedInt32 (int number, int index, int32 value); - void SetRepeatedInt64 (int number, int index, int64 value); - void SetRepeatedUInt32(int number, int index, uint32 value); - void SetRepeatedUInt64(int number, int index, uint64 value); - void SetRepeatedFloat (int number, int index, float value); - void SetRepeatedDouble(int number, int index, double value); - void SetRepeatedBool (int number, int index, bool value); - void SetRepeatedEnum (int number, int index, int value); - void SetRepeatedString(int number, int index, const string& value); - string * MutableRepeatedString (int number, int index); - MessageLite* MutableRepeatedMessage(int number, int index); - -#define desc const FieldDescriptor* descriptor // avoid line wrapping - void AddInt32 (int number, FieldType type, bool packed, int32 value, desc); - void AddInt64 (int number, FieldType type, bool packed, int64 value, desc); - void AddUInt32(int number, FieldType type, bool packed, uint32 value, desc); - void AddUInt64(int number, FieldType type, bool packed, uint64 value, desc); - void AddFloat (int number, FieldType type, bool packed, float value, desc); - void AddDouble(int number, FieldType type, bool packed, double value, desc); - void AddBool (int number, FieldType type, bool packed, bool value, desc); - void AddEnum (int number, FieldType type, bool packed, int value, desc); - void AddString(int number, FieldType type, const string& value, desc); - string * AddString (int number, FieldType type, desc); - MessageLite* AddMessage(int number, FieldType type, - const MessageLite& prototype, desc); - MessageLite* AddMessage(const FieldDescriptor* descriptor, - MessageFactory* factory); -#undef desc - - void RemoveLast(int number); - MessageLite* ReleaseLast(int number); - void SwapElements(int number, int index1, int index2); - - // ----------------------------------------------------------------- - // TODO(kenton): Hardcore memory management accessors - - // ================================================================= - // convenience methods for implementing methods of Message - // - // These could all be implemented in terms of the other methods of this - // class, but providing them here helps keep the generated code size down. - - void Clear(); - void MergeFrom(const ExtensionSet& other); - void Swap(ExtensionSet* other); - bool IsInitialized() const; - - // Parses a single extension from the input. The input should start out - // positioned immediately after the tag. - bool ParseField(uint32 tag, io::CodedInputStream* input, - ExtensionFinder* extension_finder, - FieldSkipper* field_skipper); - - // Specific versions for lite or full messages (constructs the appropriate - // FieldSkipper automatically). |containing_type| is the default - // instance for the containing message; it is used only to look up the - // extension by number. See RegisterExtension(), above. Unlike the other - // methods of ExtensionSet, this only works for generated message types -- - // it looks up extensions registered using RegisterExtension(). - bool ParseField(uint32 tag, io::CodedInputStream* input, - const MessageLite* containing_type); - bool ParseField(uint32 tag, io::CodedInputStream* input, - const Message* containing_type, - UnknownFieldSet* unknown_fields); - - // Parse an entire message in MessageSet format. Such messages have no - // fields, only extensions. - bool ParseMessageSet(io::CodedInputStream* input, - ExtensionFinder* extension_finder, - FieldSkipper* field_skipper); - - // Specific versions for lite or full messages (constructs the appropriate - // FieldSkipper automatically). - bool ParseMessageSet(io::CodedInputStream* input, - const MessageLite* containing_type); - bool ParseMessageSet(io::CodedInputStream* input, - const Message* containing_type, - UnknownFieldSet* unknown_fields); - - // Write all extension fields with field numbers in the range - // [start_field_number, end_field_number) - // to the output stream, using the cached sizes computed when ByteSize() was - // last called. Note that the range bounds are inclusive-exclusive. - void SerializeWithCachedSizes(int start_field_number, - int end_field_number, - io::CodedOutputStream* output) const; - - // Same as SerializeWithCachedSizes, but without any bounds checking. - // The caller must ensure that target has sufficient capacity for the - // serialized extensions. - // - // Returns a pointer past the last written byte. - uint8* SerializeWithCachedSizesToArray(int start_field_number, - int end_field_number, - uint8* target) const; - - // Like above but serializes in MessageSet format. - void SerializeMessageSetWithCachedSizes(io::CodedOutputStream* output) const; - uint8* SerializeMessageSetWithCachedSizesToArray(uint8* target) const; - - // Returns the total serialized size of all the extensions. - int ByteSize() const; - - // Like ByteSize() but uses MessageSet format. - int MessageSetByteSize() const; - - // Returns (an estimate of) the total number of bytes used for storing the - // extensions in memory, excluding sizeof(*this). If the ExtensionSet is - // for a lite message (and thus possibly contains lite messages), the results - // are undefined (might work, might crash, might corrupt data, might not even - // be linked in). It's up to the protocol compiler to avoid calling this on - // such ExtensionSets (easy enough since lite messages don't implement - // SpaceUsed()). - int SpaceUsedExcludingSelf() const; - - private: - - // Interface of a lazily parsed singular message extension. - class LIBPROTOBUF_EXPORT LazyMessageExtension { - public: - LazyMessageExtension() {} - virtual ~LazyMessageExtension() {} - - virtual LazyMessageExtension* New() const = 0; - virtual const MessageLite& GetMessage( - const MessageLite& prototype) const = 0; - virtual MessageLite* MutableMessage(const MessageLite& prototype) = 0; - virtual void SetAllocatedMessage(MessageLite *message) = 0; - virtual MessageLite* ReleaseMessage(const MessageLite& prototype) = 0; - - virtual bool IsInitialized() const = 0; - virtual int ByteSize() const = 0; - virtual int SpaceUsed() const = 0; - - virtual void MergeFrom(const LazyMessageExtension& other) = 0; - virtual void Clear() = 0; - - virtual bool ReadMessage(const MessageLite& prototype, - io::CodedInputStream* input) = 0; - virtual void WriteMessage(int number, - io::CodedOutputStream* output) const = 0; - virtual uint8* WriteMessageToArray(int number, uint8* target) const = 0; - private: - GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(LazyMessageExtension); - }; - struct Extension { - // The order of these fields packs Extension into 24 bytes when using 8 - // byte alignment. Consider this when adding or removing fields here. - union { - int32 int32_value; - int64 int64_value; - uint32 uint32_value; - uint64 uint64_value; - float float_value; - double double_value; - bool bool_value; - int enum_value; - string* string_value; - MessageLite* message_value; - LazyMessageExtension* lazymessage_value; - - RepeatedField * repeated_int32_value; - RepeatedField * repeated_int64_value; - RepeatedField * repeated_uint32_value; - RepeatedField * repeated_uint64_value; - RepeatedField * repeated_float_value; - RepeatedField * repeated_double_value; - RepeatedField * repeated_bool_value; - RepeatedField * repeated_enum_value; - RepeatedPtrField* repeated_string_value; - RepeatedPtrField* repeated_message_value; - }; - - FieldType type; - bool is_repeated; - - // For singular types, indicates if the extension is "cleared". This - // happens when an extension is set and then later cleared by the caller. - // We want to keep the Extension object around for reuse, so instead of - // removing it from the map, we just set is_cleared = true. This has no - // meaning for repeated types; for those, the size of the RepeatedField - // simply becomes zero when cleared. - bool is_cleared : 4; - - // For singular message types, indicates whether lazy parsing is enabled - // for this extension. This field is only valid when type == TYPE_MESSAGE - // and !is_repeated because we only support lazy parsing for singular - // message types currently. If is_lazy = true, the extension is stored in - // lazymessage_value. Otherwise, the extension will be message_value. - bool is_lazy : 4; - - // For repeated types, this indicates if the [packed=true] option is set. - bool is_packed; - - // For packed fields, the size of the packed data is recorded here when - // ByteSize() is called then used during serialization. - // TODO(kenton): Use atomic when C++ supports it. - mutable int cached_size; - - // The descriptor for this extension, if one exists and is known. May be - // NULL. Must not be NULL if the descriptor for the extension does not - // live in the same pool as the descriptor for the containing type. - const FieldDescriptor* descriptor; - - // Some helper methods for operations on a single Extension. - void SerializeFieldWithCachedSizes( - int number, - io::CodedOutputStream* output) const; - uint8* SerializeFieldWithCachedSizesToArray( - int number, - uint8* target) const; - void SerializeMessageSetItemWithCachedSizes( - int number, - io::CodedOutputStream* output) const; - uint8* SerializeMessageSetItemWithCachedSizesToArray( - int number, - uint8* target) const; - int ByteSize(int number) const; - int MessageSetItemByteSize(int number) const; - void Clear(); - int GetSize() const; - void Free(); - int SpaceUsedExcludingSelf() const; - }; - - - // Returns true and fills field_number and extension if extension is found. - bool FindExtensionInfoFromTag(uint32 tag, ExtensionFinder* extension_finder, - int* field_number, ExtensionInfo* extension); - - // Parses a single extension from the input. The input should start out - // positioned immediately after the wire tag. This method is called in - // ParseField() after field number is extracted from the wire tag and - // ExtensionInfo is found by the field number. - bool ParseFieldWithExtensionInfo(int field_number, - const ExtensionInfo& extension, - io::CodedInputStream* input, - FieldSkipper* field_skipper); - - // Like ParseField(), but this method may parse singular message extensions - // lazily depending on the value of FLAGS_eagerly_parse_message_sets. - bool ParseFieldMaybeLazily(uint32 tag, io::CodedInputStream* input, - ExtensionFinder* extension_finder, - FieldSkipper* field_skipper); - - // Gets the extension with the given number, creating it if it does not - // already exist. Returns true if the extension did not already exist. - bool MaybeNewExtension(int number, const FieldDescriptor* descriptor, - Extension** result); - - // Parse a single MessageSet item -- called just after the item group start - // tag has been read. - bool ParseMessageSetItem(io::CodedInputStream* input, - ExtensionFinder* extension_finder, - FieldSkipper* field_skipper); - - - // Hack: RepeatedPtrFieldBase declares ExtensionSet as a friend. This - // friendship should automatically extend to ExtensionSet::Extension, but - // unfortunately some older compilers (e.g. GCC 3.4.4) do not implement this - // correctly. So, we must provide helpers for calling methods of that - // class. - - // Defined in extension_set_heavy.cc. - static inline int RepeatedMessage_SpaceUsedExcludingSelf( - RepeatedPtrFieldBase* field); - - // The Extension struct is small enough to be passed by value, so we use it - // directly as the value type in the map rather than use pointers. We use - // a map rather than hash_map here because we expect most ExtensionSets will - // only contain a small number of extensions whereas hash_map is optimized - // for 100 elements or more. Also, we want AppendToList() to order fields - // by field number. - std::map extensions_; - - GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ExtensionSet); -}; - -// These are just for convenience... -inline void ExtensionSet::SetString(int number, FieldType type, - const string& value, - const FieldDescriptor* descriptor) { - MutableString(number, type, descriptor)->assign(value); -} -inline void ExtensionSet::SetRepeatedString(int number, int index, - const string& value) { - MutableRepeatedString(number, index)->assign(value); -} -inline void ExtensionSet::AddString(int number, FieldType type, - const string& value, - const FieldDescriptor* descriptor) { - AddString(number, type, descriptor)->assign(value); -} - -// =================================================================== -// Glue for generated extension accessors - -// ------------------------------------------------------------------- -// Template magic - -// First we have a set of classes representing "type traits" for different -// field types. A type traits class knows how to implement basic accessors -// for extensions of a particular type given an ExtensionSet. The signature -// for a type traits class looks like this: -// -// class TypeTraits { -// public: -// typedef ? ConstType; -// typedef ? MutableType; -// -// static inline ConstType Get(int number, const ExtensionSet& set); -// static inline void Set(int number, ConstType value, ExtensionSet* set); -// static inline MutableType Mutable(int number, ExtensionSet* set); -// -// // Variants for repeated fields. -// static inline ConstType Get(int number, const ExtensionSet& set, -// int index); -// static inline void Set(int number, int index, -// ConstType value, ExtensionSet* set); -// static inline MutableType Mutable(int number, int index, -// ExtensionSet* set); -// static inline void Add(int number, ConstType value, ExtensionSet* set); -// static inline MutableType Add(int number, ExtensionSet* set); -// }; -// -// Not all of these methods make sense for all field types. For example, the -// "Mutable" methods only make sense for strings and messages, and the -// repeated methods only make sense for repeated types. So, each type -// traits class implements only the set of methods from this signature that it -// actually supports. This will cause a compiler error if the user tries to -// access an extension using a method that doesn't make sense for its type. -// For example, if "foo" is an extension of type "optional int32", then if you -// try to write code like: -// my_message.MutableExtension(foo) -// you will get a compile error because PrimitiveTypeTraits does not -// have a "Mutable()" method. - -// ------------------------------------------------------------------- -// PrimitiveTypeTraits - -// Since the ExtensionSet has different methods for each primitive type, -// we must explicitly define the methods of the type traits class for each -// known type. -template -class PrimitiveTypeTraits { - public: - typedef Type ConstType; - - static inline ConstType Get(int number, const ExtensionSet& set, - ConstType default_value); - static inline void Set(int number, FieldType field_type, - ConstType value, ExtensionSet* set); -}; - -template -class RepeatedPrimitiveTypeTraits { - public: - typedef Type ConstType; - - static inline Type Get(int number, const ExtensionSet& set, int index); - static inline void Set(int number, int index, Type value, ExtensionSet* set); - static inline void Add(int number, FieldType field_type, - bool is_packed, Type value, ExtensionSet* set); -}; - -#define PROTOBUF_DEFINE_PRIMITIVE_TYPE(TYPE, METHOD) \ -template<> inline TYPE PrimitiveTypeTraits::Get( \ - int number, const ExtensionSet& set, TYPE default_value) { \ - return set.Get##METHOD(number, default_value); \ -} \ -template<> inline void PrimitiveTypeTraits::Set( \ - int number, FieldType field_type, TYPE value, ExtensionSet* set) { \ - set->Set##METHOD(number, field_type, value, NULL); \ -} \ - \ -template<> inline TYPE RepeatedPrimitiveTypeTraits::Get( \ - int number, const ExtensionSet& set, int index) { \ - return set.GetRepeated##METHOD(number, index); \ -} \ -template<> inline void RepeatedPrimitiveTypeTraits::Set( \ - int number, int index, TYPE value, ExtensionSet* set) { \ - set->SetRepeated##METHOD(number, index, value); \ -} \ -template<> inline void RepeatedPrimitiveTypeTraits::Add( \ - int number, FieldType field_type, bool is_packed, \ - TYPE value, ExtensionSet* set) { \ - set->Add##METHOD(number, field_type, is_packed, value, NULL); \ -} - -PROTOBUF_DEFINE_PRIMITIVE_TYPE( int32, Int32) -PROTOBUF_DEFINE_PRIMITIVE_TYPE( int64, Int64) -PROTOBUF_DEFINE_PRIMITIVE_TYPE(uint32, UInt32) -PROTOBUF_DEFINE_PRIMITIVE_TYPE(uint64, UInt64) -PROTOBUF_DEFINE_PRIMITIVE_TYPE( float, Float) -PROTOBUF_DEFINE_PRIMITIVE_TYPE(double, Double) -PROTOBUF_DEFINE_PRIMITIVE_TYPE( bool, Bool) - -#undef PROTOBUF_DEFINE_PRIMITIVE_TYPE - -// ------------------------------------------------------------------- -// StringTypeTraits - -// Strings support both Set() and Mutable(). -class LIBPROTOBUF_EXPORT StringTypeTraits { - public: - typedef const string& ConstType; - typedef string* MutableType; - - static inline const string& Get(int number, const ExtensionSet& set, - ConstType default_value) { - return set.GetString(number, default_value); - } - static inline void Set(int number, FieldType field_type, - const string& value, ExtensionSet* set) { - set->SetString(number, field_type, value, NULL); - } - static inline string* Mutable(int number, FieldType field_type, - ExtensionSet* set) { - return set->MutableString(number, field_type, NULL); - } -}; - -class LIBPROTOBUF_EXPORT RepeatedStringTypeTraits { - public: - typedef const string& ConstType; - typedef string* MutableType; - - static inline const string& Get(int number, const ExtensionSet& set, - int index) { - return set.GetRepeatedString(number, index); - } - static inline void Set(int number, int index, - const string& value, ExtensionSet* set) { - set->SetRepeatedString(number, index, value); - } - static inline string* Mutable(int number, int index, ExtensionSet* set) { - return set->MutableRepeatedString(number, index); - } - static inline void Add(int number, FieldType field_type, - bool /*is_packed*/, const string& value, - ExtensionSet* set) { - set->AddString(number, field_type, value, NULL); - } - static inline string* Add(int number, FieldType field_type, - ExtensionSet* set) { - return set->AddString(number, field_type, NULL); - } -}; - -// ------------------------------------------------------------------- -// EnumTypeTraits - -// ExtensionSet represents enums using integers internally, so we have to -// static_cast around. -template -class EnumTypeTraits { - public: - typedef Type ConstType; - - static inline ConstType Get(int number, const ExtensionSet& set, - ConstType default_value) { - return static_cast(set.GetEnum(number, default_value)); - } - static inline void Set(int number, FieldType field_type, - ConstType value, ExtensionSet* set) { - GOOGLE_DCHECK(IsValid(value)); - set->SetEnum(number, field_type, value, NULL); - } -}; - -template -class RepeatedEnumTypeTraits { - public: - typedef Type ConstType; - - static inline ConstType Get(int number, const ExtensionSet& set, int index) { - return static_cast(set.GetRepeatedEnum(number, index)); - } - static inline void Set(int number, int index, - ConstType value, ExtensionSet* set) { - GOOGLE_DCHECK(IsValid(value)); - set->SetRepeatedEnum(number, index, value); - } - static inline void Add(int number, FieldType field_type, - bool is_packed, ConstType value, ExtensionSet* set) { - GOOGLE_DCHECK(IsValid(value)); - set->AddEnum(number, field_type, is_packed, value, NULL); - } -}; - -// ------------------------------------------------------------------- -// MessageTypeTraits - -// ExtensionSet guarantees that when manipulating extensions with message -// types, the implementation used will be the compiled-in class representing -// that type. So, we can static_cast down to the exact type we expect. -template -class MessageTypeTraits { - public: - typedef const Type& ConstType; - typedef Type* MutableType; - - static inline ConstType Get(int number, const ExtensionSet& set, - ConstType default_value) { - return static_cast( - set.GetMessage(number, default_value)); - } - static inline MutableType Mutable(int number, FieldType field_type, - ExtensionSet* set) { - return static_cast( - set->MutableMessage(number, field_type, Type::default_instance(), NULL)); - } - static inline void SetAllocated(int number, FieldType field_type, - MutableType message, ExtensionSet* set) { - set->SetAllocatedMessage(number, field_type, NULL, message); - } - static inline MutableType Release(int number, FieldType field_type, - ExtensionSet* set) { - return static_cast(set->ReleaseMessage( - number, Type::default_instance())); - } -}; - -template -class RepeatedMessageTypeTraits { - public: - typedef const Type& ConstType; - typedef Type* MutableType; - - static inline ConstType Get(int number, const ExtensionSet& set, int index) { - return static_cast(set.GetRepeatedMessage(number, index)); - } - static inline MutableType Mutable(int number, int index, ExtensionSet* set) { - return static_cast(set->MutableRepeatedMessage(number, index)); - } - static inline MutableType Add(int number, FieldType field_type, - ExtensionSet* set) { - return static_cast( - set->AddMessage(number, field_type, Type::default_instance(), NULL)); - } -}; - -// ------------------------------------------------------------------- -// ExtensionIdentifier - -// This is the type of actual extension objects. E.g. if you have: -// extends Foo with optional int32 bar = 1234; -// then "bar" will be defined in C++ as: -// ExtensionIdentifier, 1, false> bar(1234); -// -// Note that we could, in theory, supply the field number as a template -// parameter, and thus make an instance of ExtensionIdentifier have no -// actual contents. However, if we did that, then using at extension -// identifier would not necessarily cause the compiler to output any sort -// of reference to any simple defined in the extension's .pb.o file. Some -// linkers will actually drop object files that are not explicitly referenced, -// but that would be bad because it would cause this extension to not be -// registered at static initialization, and therefore using it would crash. - -template -class ExtensionIdentifier { - public: - typedef TypeTraitsType TypeTraits; - typedef ExtendeeType Extendee; - - ExtensionIdentifier(int number, typename TypeTraits::ConstType default_value) - : number_(number), default_value_(default_value) {} - inline int number() const { return number_; } - typename TypeTraits::ConstType default_value() const { - return default_value_; - } - - private: - const int number_; - typename TypeTraits::ConstType default_value_; -}; - -// ------------------------------------------------------------------- -// Generated accessors - -// This macro should be expanded in the context of a generated type which -// has extensions. -// -// We use "_proto_TypeTraits" as a type name below because "TypeTraits" -// causes problems if the class has a nested message or enum type with that -// name and "_TypeTraits" is technically reserved for the C++ library since -// it starts with an underscore followed by a capital letter. -// -// For similar reason, we use "_field_type" and "_is_packed" as parameter names -// below, so that "field_type" and "is_packed" can be used as field names. -#define GOOGLE_PROTOBUF_EXTENSION_ACCESSORS(CLASSNAME) \ - /* Has, Size, Clear */ \ - template \ - inline bool HasExtension( \ - const ::google::protobuf::internal::ExtensionIdentifier< \ - CLASSNAME, _proto_TypeTraits, _field_type, _is_packed>& id) const { \ - return _extensions_.Has(id.number()); \ - } \ - \ - template \ - inline void ClearExtension( \ - const ::google::protobuf::internal::ExtensionIdentifier< \ - CLASSNAME, _proto_TypeTraits, _field_type, _is_packed>& id) { \ - _extensions_.ClearExtension(id.number()); \ - } \ - \ - template \ - inline int ExtensionSize( \ - const ::google::protobuf::internal::ExtensionIdentifier< \ - CLASSNAME, _proto_TypeTraits, _field_type, _is_packed>& id) const { \ - return _extensions_.ExtensionSize(id.number()); \ - } \ - \ - /* Singular accessors */ \ - template \ - inline typename _proto_TypeTraits::ConstType GetExtension( \ - const ::google::protobuf::internal::ExtensionIdentifier< \ - CLASSNAME, _proto_TypeTraits, _field_type, _is_packed>& id) const { \ - return _proto_TypeTraits::Get(id.number(), _extensions_, \ - id.default_value()); \ - } \ - \ - template \ - inline typename _proto_TypeTraits::MutableType MutableExtension( \ - const ::google::protobuf::internal::ExtensionIdentifier< \ - CLASSNAME, _proto_TypeTraits, _field_type, _is_packed>& id) { \ - return _proto_TypeTraits::Mutable(id.number(), _field_type, \ - &_extensions_); \ - } \ - \ - template \ - inline void SetExtension( \ - const ::google::protobuf::internal::ExtensionIdentifier< \ - CLASSNAME, _proto_TypeTraits, _field_type, _is_packed>& id, \ - typename _proto_TypeTraits::ConstType value) { \ - _proto_TypeTraits::Set(id.number(), _field_type, value, &_extensions_); \ - } \ - \ - template \ - inline void SetAllocatedExtension( \ - const ::google::protobuf::internal::ExtensionIdentifier< \ - CLASSNAME, _proto_TypeTraits, _field_type, _is_packed>& id, \ - typename _proto_TypeTraits::MutableType value) { \ - _proto_TypeTraits::SetAllocated(id.number(), _field_type, \ - value, &_extensions_); \ - } \ - template \ - inline typename _proto_TypeTraits::MutableType ReleaseExtension( \ - const ::google::protobuf::internal::ExtensionIdentifier< \ - CLASSNAME, _proto_TypeTraits, _field_type, _is_packed>& id) { \ - return _proto_TypeTraits::Release(id.number(), _field_type, \ - &_extensions_); \ - } \ - \ - /* Repeated accessors */ \ - template \ - inline typename _proto_TypeTraits::ConstType GetExtension( \ - const ::google::protobuf::internal::ExtensionIdentifier< \ - CLASSNAME, _proto_TypeTraits, _field_type, _is_packed>& id, \ - int index) const { \ - return _proto_TypeTraits::Get(id.number(), _extensions_, index); \ - } \ - \ - template \ - inline typename _proto_TypeTraits::MutableType MutableExtension( \ - const ::google::protobuf::internal::ExtensionIdentifier< \ - CLASSNAME, _proto_TypeTraits, _field_type, _is_packed>& id, \ - int index) { \ - return _proto_TypeTraits::Mutable(id.number(), index, &_extensions_); \ - } \ - \ - template \ - inline void SetExtension( \ - const ::google::protobuf::internal::ExtensionIdentifier< \ - CLASSNAME, _proto_TypeTraits, _field_type, _is_packed>& id, \ - int index, typename _proto_TypeTraits::ConstType value) { \ - _proto_TypeTraits::Set(id.number(), index, value, &_extensions_); \ - } \ - \ - template \ - inline typename _proto_TypeTraits::MutableType AddExtension( \ - const ::google::protobuf::internal::ExtensionIdentifier< \ - CLASSNAME, _proto_TypeTraits, _field_type, _is_packed>& id) { \ - return _proto_TypeTraits::Add(id.number(), _field_type, &_extensions_); \ - } \ - \ - template \ - inline void AddExtension( \ - const ::google::protobuf::internal::ExtensionIdentifier< \ - CLASSNAME, _proto_TypeTraits, _field_type, _is_packed>& id, \ - typename _proto_TypeTraits::ConstType value) { \ - _proto_TypeTraits::Add(id.number(), _field_type, _is_packed, \ - value, &_extensions_); \ - } - -} // namespace internal -} // namespace protobuf - -} // namespace google -#endif // GOOGLE_PROTOBUF_EXTENSION_SET_H__ diff --git a/modules/dnn/3rdparty/protobuf/src/google/protobuf/extension_set_heavy.cc b/modules/dnn/3rdparty/protobuf/src/google/protobuf/extension_set_heavy.cc deleted file mode 100644 index 483d7055d..000000000 --- a/modules/dnn/3rdparty/protobuf/src/google/protobuf/extension_set_heavy.cc +++ /dev/null @@ -1,711 +0,0 @@ -// Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// http://code.google.com/p/protobuf/ -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -// Author: kenton@google.com (Kenton Varda) -// Based on original Protocol Buffers design by -// Sanjay Ghemawat, Jeff Dean, and others. -// -// Contains methods defined in extension_set.h which cannot be part of the -// lite library because they use descriptors or reflection. - -#include -#include -#include -#include -#include -#include -#include - -namespace google { - -namespace protobuf { -namespace internal { - - -// Implementation of ExtensionFinder which finds extensions in a given -// DescriptorPool, using the given MessageFactory to construct sub-objects. -// This class is implemented in extension_set_heavy.cc. -class DescriptorPoolExtensionFinder : public ExtensionFinder { - public: - DescriptorPoolExtensionFinder(const DescriptorPool* pool, - MessageFactory* factory, - const Descriptor* containing_type) - : pool_(pool), factory_(factory), containing_type_(containing_type) {} - virtual ~DescriptorPoolExtensionFinder() {} - - virtual bool Find(int number, ExtensionInfo* output); - - private: - const DescriptorPool* pool_; - MessageFactory* factory_; - const Descriptor* containing_type_; -}; - -void ExtensionSet::AppendToList(const Descriptor* containing_type, - const DescriptorPool* pool, - vector* output) const { - for (map::const_iterator iter = extensions_.begin(); - iter != extensions_.end(); ++iter) { - bool has = false; - if (iter->second.is_repeated) { - has = iter->second.GetSize() > 0; - } else { - has = !iter->second.is_cleared; - } - - if (has) { - // TODO(kenton): Looking up each field by number is somewhat unfortunate. - // Is there a better way? The problem is that descriptors are lazily- - // initialized, so they might not even be constructed until - // AppendToList() is called. - - if (iter->second.descriptor == NULL) { - output->push_back(pool->FindExtensionByNumber( - containing_type, iter->first)); - } else { - output->push_back(iter->second.descriptor); - } - } - } -} - -inline FieldDescriptor::Type real_type(FieldType type) { - GOOGLE_DCHECK(type > 0 && type <= FieldDescriptor::MAX_TYPE); - return static_cast(type); -} - -inline FieldDescriptor::CppType cpp_type(FieldType type) { - return FieldDescriptor::TypeToCppType( - static_cast(type)); -} - -inline WireFormatLite::FieldType field_type(FieldType type) { - GOOGLE_DCHECK(type > 0 && type <= WireFormatLite::MAX_FIELD_TYPE); - return static_cast(type); -} - -#define GOOGLE_DCHECK_TYPE(EXTENSION, LABEL, CPPTYPE) \ - GOOGLE_DCHECK_EQ((EXTENSION).is_repeated ? FieldDescriptor::LABEL_REPEATED \ - : FieldDescriptor::LABEL_OPTIONAL, \ - FieldDescriptor::LABEL_##LABEL); \ - GOOGLE_DCHECK_EQ(cpp_type((EXTENSION).type), FieldDescriptor::CPPTYPE_##CPPTYPE) - -const MessageLite& ExtensionSet::GetMessage(int number, - const Descriptor* message_type, - MessageFactory* factory) const { - map::const_iterator iter = extensions_.find(number); - if (iter == extensions_.end() || iter->second.is_cleared) { - // Not present. Return the default value. - return *factory->GetPrototype(message_type); - } else { - GOOGLE_DCHECK_TYPE(iter->second, OPTIONAL, MESSAGE); - if (iter->second.is_lazy) { - return iter->second.lazymessage_value->GetMessage( - *factory->GetPrototype(message_type)); - } else { - return *iter->second.message_value; - } - } -} - -MessageLite* ExtensionSet::MutableMessage(const FieldDescriptor* descriptor, - MessageFactory* factory) { - Extension* extension; - if (MaybeNewExtension(descriptor->number(), descriptor, &extension)) { - extension->type = descriptor->type(); - GOOGLE_DCHECK_EQ(cpp_type(extension->type), FieldDescriptor::CPPTYPE_MESSAGE); - extension->is_repeated = false; - extension->is_packed = false; - const MessageLite* prototype = - factory->GetPrototype(descriptor->message_type()); - extension->is_lazy = false; - extension->message_value = prototype->New(); - extension->is_cleared = false; - return extension->message_value; - } else { - GOOGLE_DCHECK_TYPE(*extension, OPTIONAL, MESSAGE); - extension->is_cleared = false; - if (extension->is_lazy) { - return extension->lazymessage_value->MutableMessage( - *factory->GetPrototype(descriptor->message_type())); - } else { - return extension->message_value; - } - } -} - -MessageLite* ExtensionSet::ReleaseMessage(const FieldDescriptor* descriptor, - MessageFactory* factory) { - map::iterator iter = extensions_.find(descriptor->number()); - if (iter == extensions_.end()) { - // Not present. Return NULL. - return NULL; - } else { - GOOGLE_DCHECK_TYPE(iter->second, OPTIONAL, MESSAGE); - MessageLite* ret = NULL; - if (iter->second.is_lazy) { - ret = iter->second.lazymessage_value->ReleaseMessage( - *factory->GetPrototype(descriptor->message_type())); - delete iter->second.lazymessage_value; - } else { - ret = iter->second.message_value; - } - extensions_.erase(descriptor->number()); - return ret; - } -} - -MessageLite* ExtensionSet::AddMessage(const FieldDescriptor* descriptor, - MessageFactory* factory) { - Extension* extension; - if (MaybeNewExtension(descriptor->number(), descriptor, &extension)) { - extension->type = descriptor->type(); - GOOGLE_DCHECK_EQ(cpp_type(extension->type), FieldDescriptor::CPPTYPE_MESSAGE); - extension->is_repeated = true; - extension->repeated_message_value = - new RepeatedPtrField(); - } else { - GOOGLE_DCHECK_TYPE(*extension, REPEATED, MESSAGE); - } - - // RepeatedPtrField does not know how to Add() since it cannot - // allocate an abstract object, so we have to be tricky. - MessageLite* result = extension->repeated_message_value - ->AddFromCleared >(); - if (result == NULL) { - const MessageLite* prototype; - if (extension->repeated_message_value->size() == 0) { - prototype = factory->GetPrototype(descriptor->message_type()); - GOOGLE_CHECK(prototype != NULL); - } else { - prototype = &extension->repeated_message_value->Get(0); - } - result = prototype->New(); - extension->repeated_message_value->AddAllocated(result); - } - return result; -} - -static bool ValidateEnumUsingDescriptor(const void* arg, int number) { - return reinterpret_cast(arg) - ->FindValueByNumber(number) != NULL; -} - -bool DescriptorPoolExtensionFinder::Find(int number, ExtensionInfo* output) { - const FieldDescriptor* extension = - pool_->FindExtensionByNumber(containing_type_, number); - if (extension == NULL) { - return false; - } else { - output->type = extension->type(); - output->is_repeated = extension->is_repeated(); - output->is_packed = extension->options().packed(); - output->descriptor = extension; - if (extension->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE) { - output->message_prototype = - factory_->GetPrototype(extension->message_type()); - GOOGLE_CHECK(output->message_prototype != NULL) - << "Extension factory's GetPrototype() returned NULL for extension: " - << extension->full_name(); - } else if (extension->cpp_type() == FieldDescriptor::CPPTYPE_ENUM) { - output->enum_validity_check.func = ValidateEnumUsingDescriptor; - output->enum_validity_check.arg = extension->enum_type(); - } - - return true; - } -} - -bool ExtensionSet::ParseField(uint32 tag, io::CodedInputStream* input, - const Message* containing_type, - UnknownFieldSet* unknown_fields) { - UnknownFieldSetFieldSkipper skipper(unknown_fields); - if (input->GetExtensionPool() == NULL) { - GeneratedExtensionFinder finder(containing_type); - return ParseField(tag, input, &finder, &skipper); - } else { - DescriptorPoolExtensionFinder finder(input->GetExtensionPool(), - input->GetExtensionFactory(), - containing_type->GetDescriptor()); - return ParseField(tag, input, &finder, &skipper); - } -} - -bool ExtensionSet::ParseMessageSet(io::CodedInputStream* input, - const Message* containing_type, - UnknownFieldSet* unknown_fields) { - UnknownFieldSetFieldSkipper skipper(unknown_fields); - if (input->GetExtensionPool() == NULL) { - GeneratedExtensionFinder finder(containing_type); - return ParseMessageSet(input, &finder, &skipper); - } else { - DescriptorPoolExtensionFinder finder(input->GetExtensionPool(), - input->GetExtensionFactory(), - containing_type->GetDescriptor()); - return ParseMessageSet(input, &finder, &skipper); - } -} - -int ExtensionSet::SpaceUsedExcludingSelf() const { - int total_size = - extensions_.size() * sizeof(map::value_type); - for (map::const_iterator iter = extensions_.begin(), - end = extensions_.end(); - iter != end; - ++iter) { - total_size += iter->second.SpaceUsedExcludingSelf(); - } - return total_size; -} - -inline int ExtensionSet::RepeatedMessage_SpaceUsedExcludingSelf( - RepeatedPtrFieldBase* field) { - return field->SpaceUsedExcludingSelf >(); -} - -int ExtensionSet::Extension::SpaceUsedExcludingSelf() const { - int total_size = 0; - if (is_repeated) { - switch (cpp_type(type)) { -#define HANDLE_TYPE(UPPERCASE, LOWERCASE) \ - case FieldDescriptor::CPPTYPE_##UPPERCASE: \ - total_size += sizeof(*repeated_##LOWERCASE##_value) + \ - repeated_##LOWERCASE##_value->SpaceUsedExcludingSelf();\ - break - - HANDLE_TYPE( INT32, int32); - HANDLE_TYPE( INT64, int64); - HANDLE_TYPE( UINT32, uint32); - HANDLE_TYPE( UINT64, uint64); - HANDLE_TYPE( FLOAT, float); - HANDLE_TYPE( DOUBLE, double); - HANDLE_TYPE( BOOL, bool); - HANDLE_TYPE( ENUM, enum); - HANDLE_TYPE( STRING, string); -#undef HANDLE_TYPE - - case FieldDescriptor::CPPTYPE_MESSAGE: - // repeated_message_value is actually a RepeatedPtrField, - // but MessageLite has no SpaceUsed(), so we must directly call - // RepeatedPtrFieldBase::SpaceUsedExcludingSelf() with a different type - // handler. - total_size += sizeof(*repeated_message_value) + - RepeatedMessage_SpaceUsedExcludingSelf(repeated_message_value); - break; - } - } else { - switch (cpp_type(type)) { - case FieldDescriptor::CPPTYPE_STRING: - total_size += sizeof(*string_value) + - StringSpaceUsedExcludingSelf(*string_value); - break; - case FieldDescriptor::CPPTYPE_MESSAGE: - if (is_lazy) { - total_size += lazymessage_value->SpaceUsed(); - } else { - total_size += down_cast(message_value)->SpaceUsed(); - } - break; - default: - // No extra storage costs for primitive types. - break; - } - } - return total_size; -} - -// The Serialize*ToArray methods are only needed in the heavy library, as -// the lite library only generates SerializeWithCachedSizes. -uint8* ExtensionSet::SerializeWithCachedSizesToArray( - int start_field_number, int end_field_number, - uint8* target) const { - map::const_iterator iter; - for (iter = extensions_.lower_bound(start_field_number); - iter != extensions_.end() && iter->first < end_field_number; - ++iter) { - target = iter->second.SerializeFieldWithCachedSizesToArray(iter->first, - target); - } - return target; -} - -uint8* ExtensionSet::SerializeMessageSetWithCachedSizesToArray( - uint8* target) const { - map::const_iterator iter; - for (iter = extensions_.begin(); iter != extensions_.end(); ++iter) { - target = iter->second.SerializeMessageSetItemWithCachedSizesToArray( - iter->first, target); - } - return target; -} - -uint8* ExtensionSet::Extension::SerializeFieldWithCachedSizesToArray( - int number, uint8* target) const { - if (is_repeated) { - if (is_packed) { - if (cached_size == 0) return target; - - target = WireFormatLite::WriteTagToArray(number, - WireFormatLite::WIRETYPE_LENGTH_DELIMITED, target); - target = WireFormatLite::WriteInt32NoTagToArray(cached_size, target); - - switch (real_type(type)) { -#define HANDLE_TYPE(UPPERCASE, CAMELCASE, LOWERCASE) \ - case FieldDescriptor::TYPE_##UPPERCASE: \ - for (int i = 0; i < repeated_##LOWERCASE##_value->size(); i++) { \ - target = WireFormatLite::Write##CAMELCASE##NoTagToArray( \ - repeated_##LOWERCASE##_value->Get(i), target); \ - } \ - break - - HANDLE_TYPE( INT32, Int32, int32); - HANDLE_TYPE( INT64, Int64, int64); - HANDLE_TYPE( UINT32, UInt32, uint32); - HANDLE_TYPE( UINT64, UInt64, uint64); - HANDLE_TYPE( SINT32, SInt32, int32); - HANDLE_TYPE( SINT64, SInt64, int64); - HANDLE_TYPE( FIXED32, Fixed32, uint32); - HANDLE_TYPE( FIXED64, Fixed64, uint64); - HANDLE_TYPE(SFIXED32, SFixed32, int32); - HANDLE_TYPE(SFIXED64, SFixed64, int64); - HANDLE_TYPE( FLOAT, Float, float); - HANDLE_TYPE( DOUBLE, Double, double); - HANDLE_TYPE( BOOL, Bool, bool); - HANDLE_TYPE( ENUM, Enum, enum); -#undef HANDLE_TYPE - - case WireFormatLite::TYPE_STRING: - case WireFormatLite::TYPE_BYTES: - case WireFormatLite::TYPE_GROUP: - case WireFormatLite::TYPE_MESSAGE: - GOOGLE_LOG(FATAL) << "Non-primitive types can't be packed."; - break; - } - } else { - switch (real_type(type)) { -#define HANDLE_TYPE(UPPERCASE, CAMELCASE, LOWERCASE) \ - case FieldDescriptor::TYPE_##UPPERCASE: \ - for (int i = 0; i < repeated_##LOWERCASE##_value->size(); i++) { \ - target = WireFormatLite::Write##CAMELCASE##ToArray(number, \ - repeated_##LOWERCASE##_value->Get(i), target); \ - } \ - break - - HANDLE_TYPE( INT32, Int32, int32); - HANDLE_TYPE( INT64, Int64, int64); - HANDLE_TYPE( UINT32, UInt32, uint32); - HANDLE_TYPE( UINT64, UInt64, uint64); - HANDLE_TYPE( SINT32, SInt32, int32); - HANDLE_TYPE( SINT64, SInt64, int64); - HANDLE_TYPE( FIXED32, Fixed32, uint32); - HANDLE_TYPE( FIXED64, Fixed64, uint64); - HANDLE_TYPE(SFIXED32, SFixed32, int32); - HANDLE_TYPE(SFIXED64, SFixed64, int64); - HANDLE_TYPE( FLOAT, Float, float); - HANDLE_TYPE( DOUBLE, Double, double); - HANDLE_TYPE( BOOL, Bool, bool); - HANDLE_TYPE( STRING, String, string); - HANDLE_TYPE( BYTES, Bytes, string); - HANDLE_TYPE( ENUM, Enum, enum); - HANDLE_TYPE( GROUP, Group, message); - HANDLE_TYPE( MESSAGE, Message, message); -#undef HANDLE_TYPE - } - } - } else if (!is_cleared) { - switch (real_type(type)) { -#define HANDLE_TYPE(UPPERCASE, CAMELCASE, VALUE) \ - case FieldDescriptor::TYPE_##UPPERCASE: \ - target = WireFormatLite::Write##CAMELCASE##ToArray( \ - number, VALUE, target); \ - break - - HANDLE_TYPE( INT32, Int32, int32_value); - HANDLE_TYPE( INT64, Int64, int64_value); - HANDLE_TYPE( UINT32, UInt32, uint32_value); - HANDLE_TYPE( UINT64, UInt64, uint64_value); - HANDLE_TYPE( SINT32, SInt32, int32_value); - HANDLE_TYPE( SINT64, SInt64, int64_value); - HANDLE_TYPE( FIXED32, Fixed32, uint32_value); - HANDLE_TYPE( FIXED64, Fixed64, uint64_value); - HANDLE_TYPE(SFIXED32, SFixed32, int32_value); - HANDLE_TYPE(SFIXED64, SFixed64, int64_value); - HANDLE_TYPE( FLOAT, Float, float_value); - HANDLE_TYPE( DOUBLE, Double, double_value); - HANDLE_TYPE( BOOL, Bool, bool_value); - HANDLE_TYPE( STRING, String, *string_value); - HANDLE_TYPE( BYTES, Bytes, *string_value); - HANDLE_TYPE( ENUM, Enum, enum_value); - HANDLE_TYPE( GROUP, Group, *message_value); -#undef HANDLE_TYPE - case FieldDescriptor::TYPE_MESSAGE: - if (is_lazy) { - target = lazymessage_value->WriteMessageToArray(number, target); - } else { - target = WireFormatLite::WriteMessageToArray( - number, *message_value, target); - } - break; - } - } - return target; -} - -uint8* ExtensionSet::Extension::SerializeMessageSetItemWithCachedSizesToArray( - int number, - uint8* target) const { - if (type != WireFormatLite::TYPE_MESSAGE || is_repeated) { - // Not a valid MessageSet extension, but serialize it the normal way. - GOOGLE_LOG(WARNING) << "Invalid message set extension."; - return SerializeFieldWithCachedSizesToArray(number, target); - } - - if (is_cleared) return target; - - // Start group. - target = io::CodedOutputStream::WriteTagToArray( - WireFormatLite::kMessageSetItemStartTag, target); - // Write type ID. - target = WireFormatLite::WriteUInt32ToArray( - WireFormatLite::kMessageSetTypeIdNumber, number, target); - // Write message. - if (is_lazy) { - target = lazymessage_value->WriteMessageToArray( - WireFormatLite::kMessageSetMessageNumber, target); - } else { - target = WireFormatLite::WriteMessageToArray( - WireFormatLite::kMessageSetMessageNumber, *message_value, target); - } - // End group. - target = io::CodedOutputStream::WriteTagToArray( - WireFormatLite::kMessageSetItemEndTag, target); - return target; -} - - -bool ExtensionSet::ParseFieldMaybeLazily( - uint32 tag, io::CodedInputStream* input, - ExtensionFinder* extension_finder, - FieldSkipper* field_skipper) { - return ParseField(tag, input, extension_finder, field_skipper); -} - -bool ExtensionSet::ParseMessageSet(io::CodedInputStream* input, - ExtensionFinder* extension_finder, - FieldSkipper* field_skipper) { - while (true) { - uint32 tag = input->ReadTag(); - switch (tag) { - case 0: - return true; - case WireFormatLite::kMessageSetItemStartTag: - if (!ParseMessageSetItem(input, extension_finder, field_skipper)) { - return false; - } - break; - default: - if (!ParseField(tag, input, extension_finder, field_skipper)) { - return false; - } - break; - } - } -} - -bool ExtensionSet::ParseMessageSet(io::CodedInputStream* input, - const MessageLite* containing_type) { - FieldSkipper skipper; - GeneratedExtensionFinder finder(containing_type); - return ParseMessageSet(input, &finder, &skipper); -} - -bool ExtensionSet::ParseMessageSetItem(io::CodedInputStream* input, - ExtensionFinder* extension_finder, - FieldSkipper* field_skipper) { - // TODO(kenton): It would be nice to share code between this and - // WireFormatLite::ParseAndMergeMessageSetItem(), but I think the - // differences would be hard to factor out. - - // This method parses a group which should contain two fields: - // required int32 type_id = 2; - // required data message = 3; - - // Once we see a type_id, we'll construct a fake tag for this extension - // which is the tag it would have had under the proto2 extensions wire - // format. - uint32 fake_tag = 0; - - // If we see message data before the type_id, we'll append it to this so - // we can parse it later. - string message_data; - - while (true) { - uint32 tag = input->ReadTag(); - if (tag == 0) return false; - - switch (tag) { - case WireFormatLite::kMessageSetTypeIdTag: { - uint32 type_id; - if (!input->ReadVarint32(&type_id)) return false; - fake_tag = WireFormatLite::MakeTag(type_id, - WireFormatLite::WIRETYPE_LENGTH_DELIMITED); - - if (!message_data.empty()) { - // We saw some message data before the type_id. Have to parse it - // now. - io::CodedInputStream sub_input( - reinterpret_cast(message_data.data()), - message_data.size()); - if (!ParseFieldMaybeLazily(fake_tag, &sub_input, - extension_finder, field_skipper)) { - return false; - } - message_data.clear(); - } - - break; - } - - case WireFormatLite::kMessageSetMessageTag: { - if (fake_tag == 0) { - // We haven't seen a type_id yet. Append this data to message_data. - string temp; - uint32 length; - if (!input->ReadVarint32(&length)) return false; - if (!input->ReadString(&temp, length)) return false; - io::StringOutputStream output_stream(&message_data); - io::CodedOutputStream coded_output(&output_stream); - coded_output.WriteVarint32(length); - coded_output.WriteString(temp); - } else { - // Already saw type_id, so we can parse this directly. - if (!ParseFieldMaybeLazily(fake_tag, input, - extension_finder, field_skipper)) { - return false; - } - } - - break; - } - - case WireFormatLite::kMessageSetItemEndTag: { - return true; - } - - default: { - if (!field_skipper->SkipField(input, tag)) return false; - } - } - } -} - -void ExtensionSet::Extension::SerializeMessageSetItemWithCachedSizes( - int number, - io::CodedOutputStream* output) const { - if (type != WireFormatLite::TYPE_MESSAGE || is_repeated) { - // Not a valid MessageSet extension, but serialize it the normal way. - SerializeFieldWithCachedSizes(number, output); - return; - } - - if (is_cleared) return; - - // Start group. - output->WriteTag(WireFormatLite::kMessageSetItemStartTag); - - // Write type ID. - WireFormatLite::WriteUInt32(WireFormatLite::kMessageSetTypeIdNumber, - number, - output); - // Write message. - if (is_lazy) { - lazymessage_value->WriteMessage( - WireFormatLite::kMessageSetMessageNumber, output); - } else { - WireFormatLite::WriteMessageMaybeToArray( - WireFormatLite::kMessageSetMessageNumber, - *message_value, - output); - } - - // End group. - output->WriteTag(WireFormatLite::kMessageSetItemEndTag); -} - -int ExtensionSet::Extension::MessageSetItemByteSize(int number) const { - if (type != WireFormatLite::TYPE_MESSAGE || is_repeated) { - // Not a valid MessageSet extension, but compute the byte size for it the - // normal way. - return ByteSize(number); - } - - if (is_cleared) return 0; - - int our_size = WireFormatLite::kMessageSetItemTagsSize; - - // type_id - our_size += io::CodedOutputStream::VarintSize32(number); - - // message - int message_size = 0; - if (is_lazy) { - message_size = lazymessage_value->ByteSize(); - } else { - message_size = message_value->ByteSize(); - } - - our_size += io::CodedOutputStream::VarintSize32(message_size); - our_size += message_size; - - return our_size; -} - -void ExtensionSet::SerializeMessageSetWithCachedSizes( - io::CodedOutputStream* output) const { - map::const_iterator iter; - for (iter = extensions_.begin(); iter != extensions_.end(); ++iter) { - iter->second.SerializeMessageSetItemWithCachedSizes(iter->first, output); - } -} - -int ExtensionSet::MessageSetByteSize() const { - int total_size = 0; - - for (map::const_iterator iter = extensions_.begin(); - iter != extensions_.end(); ++iter) { - total_size += iter->second.MessageSetItemByteSize(iter->first); - } - - return total_size; -} - -} // namespace internal -} // namespace protobuf -} // namespace google diff --git a/modules/dnn/3rdparty/protobuf/src/google/protobuf/extension_set_unittest.cc b/modules/dnn/3rdparty/protobuf/src/google/protobuf/extension_set_unittest.cc deleted file mode 100644 index 559de6e13..000000000 --- a/modules/dnn/3rdparty/protobuf/src/google/protobuf/extension_set_unittest.cc +++ /dev/null @@ -1,726 +0,0 @@ -// Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// http://code.google.com/p/protobuf/ -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -// Author: kenton@google.com (Kenton Varda) -// Based on original Protocol Buffers design by -// Sanjay Ghemawat, Jeff Dean, and others. - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include - -namespace google { - -namespace protobuf { -namespace internal { -namespace { - -// This test closely mirrors google/protobuf/compiler/cpp/unittest.cc -// except that it uses extensions rather than regular fields. - -TEST(ExtensionSetTest, Defaults) { - // Check that all default values are set correctly in the initial message. - unittest::TestAllExtensions message; - - TestUtil::ExpectExtensionsClear(message); - - // Messages should return pointers to default instances until first use. - // (This is not checked by ExpectClear() since it is not actually true after - // the fields have been set and then cleared.) - EXPECT_EQ(&unittest::OptionalGroup_extension::default_instance(), - &message.GetExtension(unittest::optionalgroup_extension)); - EXPECT_EQ(&unittest::TestAllTypes::NestedMessage::default_instance(), - &message.GetExtension(unittest::optional_nested_message_extension)); - EXPECT_EQ(&unittest::ForeignMessage::default_instance(), - &message.GetExtension( - unittest::optional_foreign_message_extension)); - EXPECT_EQ(&unittest_import::ImportMessage::default_instance(), - &message.GetExtension(unittest::optional_import_message_extension)); -} - -TEST(ExtensionSetTest, Accessors) { - // Set every field to a unique value then go back and check all those - // values. - unittest::TestAllExtensions message; - - TestUtil::SetAllExtensions(&message); - TestUtil::ExpectAllExtensionsSet(message); - - TestUtil::ModifyRepeatedExtensions(&message); - TestUtil::ExpectRepeatedExtensionsModified(message); -} - -TEST(ExtensionSetTest, Clear) { - // Set every field to a unique value, clear the message, then check that - // it is cleared. - unittest::TestAllExtensions message; - - TestUtil::SetAllExtensions(&message); - message.Clear(); - TestUtil::ExpectExtensionsClear(message); - - // Unlike with the defaults test, we do NOT expect that requesting embedded - // messages will return a pointer to the default instance. Instead, they - // should return the objects that were created when mutable_blah() was - // called. - EXPECT_NE(&unittest::OptionalGroup_extension::default_instance(), - &message.GetExtension(unittest::optionalgroup_extension)); - EXPECT_NE(&unittest::TestAllTypes::NestedMessage::default_instance(), - &message.GetExtension(unittest::optional_nested_message_extension)); - EXPECT_NE(&unittest::ForeignMessage::default_instance(), - &message.GetExtension( - unittest::optional_foreign_message_extension)); - EXPECT_NE(&unittest_import::ImportMessage::default_instance(), - &message.GetExtension(unittest::optional_import_message_extension)); - - // Make sure setting stuff again after clearing works. (This takes slightly - // different code paths since the objects are reused.) - TestUtil::SetAllExtensions(&message); - TestUtil::ExpectAllExtensionsSet(message); -} - -TEST(ExtensionSetTest, ClearOneField) { - // Set every field to a unique value, then clear one value and insure that - // only that one value is cleared. - unittest::TestAllExtensions message; - - TestUtil::SetAllExtensions(&message); - int64 original_value = - message.GetExtension(unittest::optional_int64_extension); - - // Clear the field and make sure it shows up as cleared. - message.ClearExtension(unittest::optional_int64_extension); - EXPECT_FALSE(message.HasExtension(unittest::optional_int64_extension)); - EXPECT_EQ(0, message.GetExtension(unittest::optional_int64_extension)); - - // Other adjacent fields should not be cleared. - EXPECT_TRUE(message.HasExtension(unittest::optional_int32_extension)); - EXPECT_TRUE(message.HasExtension(unittest::optional_uint32_extension)); - - // Make sure if we set it again, then all fields are set. - message.SetExtension(unittest::optional_int64_extension, original_value); - TestUtil::ExpectAllExtensionsSet(message); -} - -TEST(ExtensionSetTest, SetAllocatedExtensin) { - unittest::TestAllExtensions message; - EXPECT_FALSE(message.HasExtension( - unittest::optional_foreign_message_extension)); - // Add a extension using SetAllocatedExtension - unittest::ForeignMessage* foreign_message = new unittest::ForeignMessage(); - message.SetAllocatedExtension(unittest::optional_foreign_message_extension, - foreign_message); - EXPECT_TRUE(message.HasExtension( - unittest::optional_foreign_message_extension)); - EXPECT_EQ(foreign_message, - message.MutableExtension( - unittest::optional_foreign_message_extension)); - EXPECT_EQ(foreign_message, - &message.GetExtension( - unittest::optional_foreign_message_extension)); - - // SetAllocatedExtension should delete the previously existing extension. - // (We reply on unittest to check memory leaks for this case) - message.SetAllocatedExtension(unittest::optional_foreign_message_extension, - new unittest::ForeignMessage()); - - // SetAllocatedExtension with a NULL parameter is equivalent to ClearExtenion. - message.SetAllocatedExtension(unittest::optional_foreign_message_extension, - NULL); - EXPECT_FALSE(message.HasExtension( - unittest::optional_foreign_message_extension)); -} - -TEST(ExtensionSetTest, ReleaseExtension) { - unittest::TestMessageSet message; - EXPECT_FALSE(message.HasExtension( - unittest::TestMessageSetExtension1::message_set_extension)); - // Add a extension using SetAllocatedExtension - unittest::TestMessageSetExtension1* extension = - new unittest::TestMessageSetExtension1(); - message.SetAllocatedExtension( - unittest::TestMessageSetExtension1::message_set_extension, - extension); - EXPECT_TRUE(message.HasExtension( - unittest::TestMessageSetExtension1::message_set_extension)); - // Release the extension using ReleaseExtension - unittest::TestMessageSetExtension1* released_extension = - message.ReleaseExtension( - unittest::TestMessageSetExtension1::message_set_extension); - EXPECT_EQ(extension, released_extension); - EXPECT_FALSE(message.HasExtension( - unittest::TestMessageSetExtension1::message_set_extension)); - // ReleaseExtension will return the underlying object even after - // ClearExtension is called. - message.SetAllocatedExtension( - unittest::TestMessageSetExtension1::message_set_extension, - extension); - message.ClearExtension( - unittest::TestMessageSetExtension1::message_set_extension); - released_extension = message.ReleaseExtension( - unittest::TestMessageSetExtension1::message_set_extension); - EXPECT_TRUE(released_extension != NULL); - delete released_extension; -} - - -TEST(ExtensionSetTest, CopyFrom) { - unittest::TestAllExtensions message1, message2; - - TestUtil::SetAllExtensions(&message1); - message2.CopyFrom(message1); - TestUtil::ExpectAllExtensionsSet(message2); - message2.CopyFrom(message1); // exercise copy when fields already exist - TestUtil::ExpectAllExtensionsSet(message2); -} - -TEST(ExtensioSetTest, CopyFromPacked) { - unittest::TestPackedExtensions message1, message2; - - TestUtil::SetPackedExtensions(&message1); - message2.CopyFrom(message1); - TestUtil::ExpectPackedExtensionsSet(message2); - message2.CopyFrom(message1); // exercise copy when fields already exist - TestUtil::ExpectPackedExtensionsSet(message2); -} - -TEST(ExtensionSetTest, CopyFromUpcasted) { - unittest::TestAllExtensions message1, message2; - const Message& upcasted_message = message1; - - TestUtil::SetAllExtensions(&message1); - message2.CopyFrom(upcasted_message); - TestUtil::ExpectAllExtensionsSet(message2); - // exercise copy when fields already exist - message2.CopyFrom(upcasted_message); - TestUtil::ExpectAllExtensionsSet(message2); -} - -TEST(ExtensionSetTest, SwapWithEmpty) { - unittest::TestAllExtensions message1, message2; - TestUtil::SetAllExtensions(&message1); - - TestUtil::ExpectAllExtensionsSet(message1); - TestUtil::ExpectExtensionsClear(message2); - message1.Swap(&message2); - TestUtil::ExpectAllExtensionsSet(message2); - TestUtil::ExpectExtensionsClear(message1); -} - -TEST(ExtensionSetTest, SwapWithSelf) { - unittest::TestAllExtensions message; - TestUtil::SetAllExtensions(&message); - - TestUtil::ExpectAllExtensionsSet(message); - message.Swap(&message); - TestUtil::ExpectAllExtensionsSet(message); -} - -TEST(ExtensionSetTest, SerializationToArray) { - // Serialize as TestAllExtensions and parse as TestAllTypes to insure wire - // compatibility of extensions. - // - // This checks serialization to a flat array by explicitly reserving space in - // the string and calling the generated message's - // SerializeWithCachedSizesToArray. - unittest::TestAllExtensions source; - unittest::TestAllTypes destination; - TestUtil::SetAllExtensions(&source); - int size = source.ByteSize(); - string data; - data.resize(size); - uint8* target = reinterpret_cast(string_as_array(&data)); - uint8* end = source.SerializeWithCachedSizesToArray(target); - EXPECT_EQ(size, end - target); - EXPECT_TRUE(destination.ParseFromString(data)); - TestUtil::ExpectAllFieldsSet(destination); -} - -TEST(ExtensionSetTest, SerializationToStream) { - // Serialize as TestAllExtensions and parse as TestAllTypes to insure wire - // compatibility of extensions. - // - // This checks serialization to an output stream by creating an array output - // stream that can only buffer 1 byte at a time - this prevents the message - // from ever jumping to the fast path, ensuring that serialization happens via - // the CodedOutputStream. - unittest::TestAllExtensions source; - unittest::TestAllTypes destination; - TestUtil::SetAllExtensions(&source); - int size = source.ByteSize(); - string data; - data.resize(size); - { - io::ArrayOutputStream array_stream(string_as_array(&data), size, 1); - io::CodedOutputStream output_stream(&array_stream); - source.SerializeWithCachedSizes(&output_stream); - ASSERT_FALSE(output_stream.HadError()); - } - EXPECT_TRUE(destination.ParseFromString(data)); - TestUtil::ExpectAllFieldsSet(destination); -} - -TEST(ExtensionSetTest, PackedSerializationToArray) { - // Serialize as TestPackedExtensions and parse as TestPackedTypes to insure - // wire compatibility of extensions. - // - // This checks serialization to a flat array by explicitly reserving space in - // the string and calling the generated message's - // SerializeWithCachedSizesToArray. - unittest::TestPackedExtensions source; - unittest::TestPackedTypes destination; - TestUtil::SetPackedExtensions(&source); - int size = source.ByteSize(); - string data; - data.resize(size); - uint8* target = reinterpret_cast(string_as_array(&data)); - uint8* end = source.SerializeWithCachedSizesToArray(target); - EXPECT_EQ(size, end - target); - EXPECT_TRUE(destination.ParseFromString(data)); - TestUtil::ExpectPackedFieldsSet(destination); -} - -TEST(ExtensionSetTest, PackedSerializationToStream) { - // Serialize as TestPackedExtensions and parse as TestPackedTypes to insure - // wire compatibility of extensions. - // - // This checks serialization to an output stream by creating an array output - // stream that can only buffer 1 byte at a time - this prevents the message - // from ever jumping to the fast path, ensuring that serialization happens via - // the CodedOutputStream. - unittest::TestPackedExtensions source; - unittest::TestPackedTypes destination; - TestUtil::SetPackedExtensions(&source); - int size = source.ByteSize(); - string data; - data.resize(size); - { - io::ArrayOutputStream array_stream(string_as_array(&data), size, 1); - io::CodedOutputStream output_stream(&array_stream); - source.SerializeWithCachedSizes(&output_stream); - ASSERT_FALSE(output_stream.HadError()); - } - EXPECT_TRUE(destination.ParseFromString(data)); - TestUtil::ExpectPackedFieldsSet(destination); -} - -TEST(ExtensionSetTest, Parsing) { - // Serialize as TestAllTypes and parse as TestAllExtensions. - unittest::TestAllTypes source; - unittest::TestAllExtensions destination; - string data; - - TestUtil::SetAllFields(&source); - source.SerializeToString(&data); - EXPECT_TRUE(destination.ParseFromString(data)); - TestUtil::ExpectAllExtensionsSet(destination); -} - -TEST(ExtensionSetTest, PackedParsing) { - // Serialize as TestPackedTypes and parse as TestPackedExtensions. - unittest::TestPackedTypes source; - unittest::TestPackedExtensions destination; - string data; - - TestUtil::SetPackedFields(&source); - source.SerializeToString(&data); - EXPECT_TRUE(destination.ParseFromString(data)); - TestUtil::ExpectPackedExtensionsSet(destination); -} - -TEST(ExtensionSetTest, IsInitialized) { - // Test that IsInitialized() returns false if required fields in nested - // extensions are missing. - unittest::TestAllExtensions message; - - EXPECT_TRUE(message.IsInitialized()); - - message.MutableExtension(unittest::TestRequired::single); - EXPECT_FALSE(message.IsInitialized()); - - message.MutableExtension(unittest::TestRequired::single)->set_a(1); - EXPECT_FALSE(message.IsInitialized()); - message.MutableExtension(unittest::TestRequired::single)->set_b(2); - EXPECT_FALSE(message.IsInitialized()); - message.MutableExtension(unittest::TestRequired::single)->set_c(3); - EXPECT_TRUE(message.IsInitialized()); - - message.AddExtension(unittest::TestRequired::multi); - EXPECT_FALSE(message.IsInitialized()); - - message.MutableExtension(unittest::TestRequired::multi, 0)->set_a(1); - EXPECT_FALSE(message.IsInitialized()); - message.MutableExtension(unittest::TestRequired::multi, 0)->set_b(2); - EXPECT_FALSE(message.IsInitialized()); - message.MutableExtension(unittest::TestRequired::multi, 0)->set_c(3); - EXPECT_TRUE(message.IsInitialized()); -} - -TEST(ExtensionSetTest, MutableString) { - // Test the mutable string accessors. - unittest::TestAllExtensions message; - - message.MutableExtension(unittest::optional_string_extension)->assign("foo"); - EXPECT_TRUE(message.HasExtension(unittest::optional_string_extension)); - EXPECT_EQ("foo", message.GetExtension(unittest::optional_string_extension)); - - message.AddExtension(unittest::repeated_string_extension)->assign("bar"); - ASSERT_EQ(1, message.ExtensionSize(unittest::repeated_string_extension)); - EXPECT_EQ("bar", - message.GetExtension(unittest::repeated_string_extension, 0)); -} - -TEST(ExtensionSetTest, SpaceUsedExcludingSelf) { - // Scalar primitive extensions should increase the extension set size by a - // minimum of the size of the primitive type. -#define TEST_SCALAR_EXTENSIONS_SPACE_USED(type, value) \ - do { \ - unittest::TestAllExtensions message; \ - const int base_size = message.SpaceUsed(); \ - message.SetExtension(unittest::optional_##type##_extension, value); \ - int min_expected_size = base_size + \ - sizeof(message.GetExtension(unittest::optional_##type##_extension)); \ - EXPECT_LE(min_expected_size, message.SpaceUsed()); \ - } while (0) - - TEST_SCALAR_EXTENSIONS_SPACE_USED(int32 , 101); - TEST_SCALAR_EXTENSIONS_SPACE_USED(int64 , 102); - TEST_SCALAR_EXTENSIONS_SPACE_USED(uint32 , 103); - TEST_SCALAR_EXTENSIONS_SPACE_USED(uint64 , 104); - TEST_SCALAR_EXTENSIONS_SPACE_USED(sint32 , 105); - TEST_SCALAR_EXTENSIONS_SPACE_USED(sint64 , 106); - TEST_SCALAR_EXTENSIONS_SPACE_USED(fixed32 , 107); - TEST_SCALAR_EXTENSIONS_SPACE_USED(fixed64 , 108); - TEST_SCALAR_EXTENSIONS_SPACE_USED(sfixed32, 109); - TEST_SCALAR_EXTENSIONS_SPACE_USED(sfixed64, 110); - TEST_SCALAR_EXTENSIONS_SPACE_USED(float , 111); - TEST_SCALAR_EXTENSIONS_SPACE_USED(double , 112); - TEST_SCALAR_EXTENSIONS_SPACE_USED(bool , true); -#undef TEST_SCALAR_EXTENSIONS_SPACE_USED - { - unittest::TestAllExtensions message; - const int base_size = message.SpaceUsed(); - message.SetExtension(unittest::optional_nested_enum_extension, - unittest::TestAllTypes::FOO); - int min_expected_size = base_size + - sizeof(message.GetExtension(unittest::optional_nested_enum_extension)); - EXPECT_LE(min_expected_size, message.SpaceUsed()); - } - { - // Strings may cause extra allocations depending on their length; ensure - // that gets included as well. - unittest::TestAllExtensions message; - const int base_size = message.SpaceUsed(); - const string s("this is a fairly large string that will cause some " - "allocation in order to store it in the extension"); - message.SetExtension(unittest::optional_string_extension, s); - int min_expected_size = base_size + s.length(); - EXPECT_LE(min_expected_size, message.SpaceUsed()); - } - { - // Messages also have additional allocation that need to be counted. - unittest::TestAllExtensions message; - const int base_size = message.SpaceUsed(); - unittest::ForeignMessage foreign; - foreign.set_c(42); - message.MutableExtension(unittest::optional_foreign_message_extension)-> - CopyFrom(foreign); - int min_expected_size = base_size + foreign.SpaceUsed(); - EXPECT_LE(min_expected_size, message.SpaceUsed()); - } - - // Repeated primitive extensions will increase space used by at least a - // RepeatedField, and will cause additional allocations when the array - // gets too big for the initial space. - // This macro: - // - Adds a value to the repeated extension, then clears it, establishing - // the base size. - // - Adds a small number of values, testing that it doesn't increase the - // SpaceUsed() - // - Adds a large number of values (requiring allocation in the repeated - // field), and ensures that that allocation is included in SpaceUsed() -#define TEST_REPEATED_EXTENSIONS_SPACE_USED(type, cpptype, value) \ - do { \ - unittest::TestAllExtensions message; \ - const int base_size = message.SpaceUsed(); \ - int min_expected_size = sizeof(RepeatedField) + base_size; \ - message.AddExtension(unittest::repeated_##type##_extension, value); \ - message.ClearExtension(unittest::repeated_##type##_extension); \ - const int empty_repeated_field_size = message.SpaceUsed(); \ - EXPECT_LE(min_expected_size, empty_repeated_field_size) << #type; \ - message.AddExtension(unittest::repeated_##type##_extension, value); \ - message.AddExtension(unittest::repeated_##type##_extension, value); \ - EXPECT_EQ(empty_repeated_field_size, message.SpaceUsed()) << #type; \ - message.ClearExtension(unittest::repeated_##type##_extension); \ - for (int i = 0; i < 16; ++i) { \ - message.AddExtension(unittest::repeated_##type##_extension, value); \ - } \ - int expected_size = sizeof(cpptype) * (16 - \ - kMinRepeatedFieldAllocationSize) + empty_repeated_field_size; \ - EXPECT_EQ(expected_size, message.SpaceUsed()) << #type; \ - } while (0) - - TEST_REPEATED_EXTENSIONS_SPACE_USED(int32 , int32 , 101); - TEST_REPEATED_EXTENSIONS_SPACE_USED(int64 , int64 , 102); - TEST_REPEATED_EXTENSIONS_SPACE_USED(uint32 , uint32, 103); - TEST_REPEATED_EXTENSIONS_SPACE_USED(uint64 , uint64, 104); - TEST_REPEATED_EXTENSIONS_SPACE_USED(sint32 , int32 , 105); - TEST_REPEATED_EXTENSIONS_SPACE_USED(sint64 , int64 , 106); - TEST_REPEATED_EXTENSIONS_SPACE_USED(fixed32 , uint32, 107); - TEST_REPEATED_EXTENSIONS_SPACE_USED(fixed64 , uint64, 108); - TEST_REPEATED_EXTENSIONS_SPACE_USED(sfixed32, int32 , 109); - TEST_REPEATED_EXTENSIONS_SPACE_USED(sfixed64, int64 , 110); - TEST_REPEATED_EXTENSIONS_SPACE_USED(float , float , 111); - TEST_REPEATED_EXTENSIONS_SPACE_USED(double , double, 112); - TEST_REPEATED_EXTENSIONS_SPACE_USED(bool , bool , true); - TEST_REPEATED_EXTENSIONS_SPACE_USED(nested_enum, int, - unittest::TestAllTypes::FOO); -#undef TEST_REPEATED_EXTENSIONS_SPACE_USED - // Repeated strings - { - unittest::TestAllExtensions message; - const int base_size = message.SpaceUsed(); - int min_expected_size = sizeof(RepeatedPtrField) + base_size; - const string value(256, 'x'); - // Once items are allocated, they may stick around even when cleared so - // without the hardcore memory management accessors there isn't a notion of - // the empty repeated field memory usage as there is with primitive types. - for (int i = 0; i < 16; ++i) { - message.AddExtension(unittest::repeated_string_extension, value); - } - min_expected_size += (sizeof(value) + value.size()) * - (16 - kMinRepeatedFieldAllocationSize); - EXPECT_LE(min_expected_size, message.SpaceUsed()); - } - // Repeated messages - { - unittest::TestAllExtensions message; - const int base_size = message.SpaceUsed(); - int min_expected_size = sizeof(RepeatedPtrField) + - base_size; - unittest::ForeignMessage prototype; - prototype.set_c(2); - for (int i = 0; i < 16; ++i) { - message.AddExtension(unittest::repeated_foreign_message_extension)-> - CopyFrom(prototype); - } - min_expected_size += - (16 - kMinRepeatedFieldAllocationSize) * prototype.SpaceUsed(); - EXPECT_LE(min_expected_size, message.SpaceUsed()); - } -} - -#ifdef PROTOBUF_HAS_DEATH_TEST - -TEST(ExtensionSetTest, InvalidEnumDeath) { - unittest::TestAllExtensions message; - EXPECT_DEBUG_DEATH( - message.SetExtension(unittest::optional_foreign_enum_extension, - static_cast(53)), - "IsValid"); -} - -#endif // PROTOBUF_HAS_DEATH_TEST - -TEST(ExtensionSetTest, DynamicExtensions) { - // Test adding a dynamic extension to a compiled-in message object. - - FileDescriptorProto dynamic_proto; - dynamic_proto.set_name("dynamic_extensions_test.proto"); - dynamic_proto.add_dependency( - unittest::TestAllExtensions::descriptor()->file()->name()); - dynamic_proto.set_package("dynamic_extensions"); - - // Copy the fields and nested types from TestDynamicExtensions into our new - // proto, converting the fields into extensions. - const Descriptor* template_descriptor = - unittest::TestDynamicExtensions::descriptor(); - DescriptorProto template_descriptor_proto; - template_descriptor->CopyTo(&template_descriptor_proto); - dynamic_proto.mutable_message_type()->MergeFrom( - template_descriptor_proto.nested_type()); - dynamic_proto.mutable_enum_type()->MergeFrom( - template_descriptor_proto.enum_type()); - dynamic_proto.mutable_extension()->MergeFrom( - template_descriptor_proto.field()); - - // For each extension that we added... - for (int i = 0; i < dynamic_proto.extension_size(); i++) { - // Set its extendee to TestAllExtensions. - FieldDescriptorProto* extension = dynamic_proto.mutable_extension(i); - extension->set_extendee( - unittest::TestAllExtensions::descriptor()->full_name()); - - // If the field refers to one of the types nested in TestDynamicExtensions, - // make it refer to the type in our dynamic proto instead. - string prefix = "." + template_descriptor->full_name() + "."; - if (extension->has_type_name()) { - string* type_name = extension->mutable_type_name(); - if (HasPrefixString(*type_name, prefix)) { - type_name->replace(0, prefix.size(), ".dynamic_extensions."); - } - } - } - - // Now build the file, using the generated pool as an underlay. - DescriptorPool dynamic_pool(DescriptorPool::generated_pool()); - const FileDescriptor* file = dynamic_pool.BuildFile(dynamic_proto); - ASSERT_TRUE(file != NULL); - DynamicMessageFactory dynamic_factory(&dynamic_pool); - dynamic_factory.SetDelegateToGeneratedFactory(true); - - // Construct a message that we can parse with the extensions we defined. - // Since the extensions were based off of the fields of TestDynamicExtensions, - // we can use that message to create this test message. - string data; - { - unittest::TestDynamicExtensions message; - message.set_scalar_extension(123); - message.set_enum_extension(unittest::FOREIGN_BAR); - message.set_dynamic_enum_extension( - unittest::TestDynamicExtensions::DYNAMIC_BAZ); - message.mutable_message_extension()->set_c(456); - message.mutable_dynamic_message_extension()->set_dynamic_field(789); - message.add_repeated_extension("foo"); - message.add_repeated_extension("bar"); - message.add_packed_extension(12); - message.add_packed_extension(-34); - message.add_packed_extension(56); - message.add_packed_extension(-78); - - // Also add some unknown fields. - - // An unknown enum value (for a known field). - message.mutable_unknown_fields()->AddVarint( - unittest::TestDynamicExtensions::kDynamicEnumExtensionFieldNumber, - 12345); - // A regular unknown field. - message.mutable_unknown_fields()->AddLengthDelimited(54321, "unknown"); - - message.SerializeToString(&data); - } - - // Now we can parse this using our dynamic extension definitions... - unittest::TestAllExtensions message; - { - io::ArrayInputStream raw_input(data.data(), data.size()); - io::CodedInputStream input(&raw_input); - input.SetExtensionRegistry(&dynamic_pool, &dynamic_factory); - ASSERT_TRUE(message.ParseFromCodedStream(&input)); - ASSERT_TRUE(input.ConsumedEntireMessage()); - } - - // Can we print it? - EXPECT_EQ( - "[dynamic_extensions.scalar_extension]: 123\n" - "[dynamic_extensions.enum_extension]: FOREIGN_BAR\n" - "[dynamic_extensions.dynamic_enum_extension]: DYNAMIC_BAZ\n" - "[dynamic_extensions.message_extension] {\n" - " c: 456\n" - "}\n" - "[dynamic_extensions.dynamic_message_extension] {\n" - " dynamic_field: 789\n" - "}\n" - "[dynamic_extensions.repeated_extension]: \"foo\"\n" - "[dynamic_extensions.repeated_extension]: \"bar\"\n" - "[dynamic_extensions.packed_extension]: 12\n" - "[dynamic_extensions.packed_extension]: -34\n" - "[dynamic_extensions.packed_extension]: 56\n" - "[dynamic_extensions.packed_extension]: -78\n" - "2002: 12345\n" - "54321: \"unknown\"\n", - message.DebugString()); - - // Can we serialize it? - // (Don't use EXPECT_EQ because we don't want to dump raw binary data to the - // terminal on failure.) - EXPECT_TRUE(message.SerializeAsString() == data); - - // What if we parse using the reflection-based parser? - { - unittest::TestAllExtensions message2; - io::ArrayInputStream raw_input(data.data(), data.size()); - io::CodedInputStream input(&raw_input); - input.SetExtensionRegistry(&dynamic_pool, &dynamic_factory); - ASSERT_TRUE(WireFormat::ParseAndMergePartial(&input, &message2)); - ASSERT_TRUE(input.ConsumedEntireMessage()); - EXPECT_EQ(message.DebugString(), message2.DebugString()); - } - - // Are the embedded generated types actually using the generated objects? - { - const FieldDescriptor* message_extension = - file->FindExtensionByName("message_extension"); - ASSERT_TRUE(message_extension != NULL); - const Message& sub_message = - message.GetReflection()->GetMessage(message, message_extension); - const unittest::ForeignMessage* typed_sub_message = -#ifdef GOOGLE_PROTOBUF_NO_RTTI - static_cast(&sub_message); -#else - dynamic_cast(&sub_message); -#endif - ASSERT_TRUE(typed_sub_message != NULL); - EXPECT_EQ(456, typed_sub_message->c()); - } - - // What does GetMessage() return for the embedded dynamic type if it isn't - // present? - { - const FieldDescriptor* dynamic_message_extension = - file->FindExtensionByName("dynamic_message_extension"); - ASSERT_TRUE(dynamic_message_extension != NULL); - const Message& parent = unittest::TestAllExtensions::default_instance(); - const Message& sub_message = - parent.GetReflection()->GetMessage(parent, dynamic_message_extension, - &dynamic_factory); - const Message* prototype = - dynamic_factory.GetPrototype(dynamic_message_extension->message_type()); - EXPECT_EQ(prototype, &sub_message); - } -} - -} // namespace -} // namespace internal -} // namespace protobuf -} // namespace google diff --git a/modules/dnn/3rdparty/protobuf/src/google/protobuf/generated_enum_reflection.h b/modules/dnn/3rdparty/protobuf/src/google/protobuf/generated_enum_reflection.h deleted file mode 100644 index a09a540bf..000000000 --- a/modules/dnn/3rdparty/protobuf/src/google/protobuf/generated_enum_reflection.h +++ /dev/null @@ -1,85 +0,0 @@ -// Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// http://code.google.com/p/protobuf/ -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -// Author: jasonh@google.com (Jason Hsueh) -// -// This header is logically internal, but is made public because it is used -// from protocol-compiler-generated code, which may reside in other components. -// It provides reflection support for generated enums, and is included in -// generated .pb.h files and should have minimal dependencies. The methods are -// implemented in generated_message_reflection.cc. - -#ifndef GOOGLE_PROTOBUF_GENERATED_ENUM_REFLECTION_H__ -#define GOOGLE_PROTOBUF_GENERATED_ENUM_REFLECTION_H__ - -#include - -namespace google { -namespace protobuf { - class EnumDescriptor; -} // namespace protobuf - -namespace protobuf { - -// Returns the EnumDescriptor for enum type E, which must be a -// proto-declared enum type. Code generated by the protocol compiler -// will include specializations of this template for each enum type declared. -template -const EnumDescriptor* GetEnumDescriptor(); - -namespace internal { - -// Helper for EnumType_Parse functions: try to parse the string 'name' as an -// enum name of the given type, returning true and filling in value on success, -// or returning false and leaving value unchanged on failure. -LIBPROTOBUF_EXPORT bool ParseNamedEnum(const EnumDescriptor* descriptor, - const string& name, - int* value); - -template -bool ParseNamedEnum(const EnumDescriptor* descriptor, - const string& name, - EnumType* value) { - int tmp; - if (!ParseNamedEnum(descriptor, name, &tmp)) return false; - *value = static_cast(tmp); - return true; -} - -// Just a wrapper around printing the name of a value. The main point of this -// function is not to be inlined, so that you can do this without including -// descriptor.h. -LIBPROTOBUF_EXPORT const string& NameOfEnum(const EnumDescriptor* descriptor, int value); - -} // namespace internal -} // namespace protobuf - -} // namespace google -#endif // GOOGLE_PROTOBUF_GENERATED_ENUM_REFLECTION_H__ diff --git a/modules/dnn/3rdparty/protobuf/src/google/protobuf/generated_message_reflection.cc b/modules/dnn/3rdparty/protobuf/src/google/protobuf/generated_message_reflection.cc deleted file mode 100644 index f4d0851d2..000000000 --- a/modules/dnn/3rdparty/protobuf/src/google/protobuf/generated_message_reflection.cc +++ /dev/null @@ -1,1293 +0,0 @@ -// Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// http://code.google.com/p/protobuf/ -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -// Author: kenton@google.com (Kenton Varda) -// Based on original Protocol Buffers design by -// Sanjay Ghemawat, Jeff Dean, and others. - -#include -#include -#include -#include -#include -#include -#include -#include - -namespace google { -namespace protobuf { -namespace internal { - -int StringSpaceUsedExcludingSelf(const string& str) { - const void* start = &str; - const void* end = &str + 1; - - if (start <= str.data() && str.data() <= end) { - // The string's data is stored inside the string object itself. - return 0; - } else { - return str.capacity(); - } -} - -bool ParseNamedEnum(const EnumDescriptor* descriptor, - const string& name, - int* value) { - const EnumValueDescriptor* d = descriptor->FindValueByName(name); - if (d == NULL) return false; - *value = d->number(); - return true; -} - -const string& NameOfEnum(const EnumDescriptor* descriptor, int value) { - const EnumValueDescriptor* d = descriptor->FindValueByNumber(value); - return (d == NULL ? kEmptyString : d->name()); -} - -// =================================================================== -// Helpers for reporting usage errors (e.g. trying to use GetInt32() on -// a string field). - -namespace { - -void ReportReflectionUsageError( - const Descriptor* descriptor, const FieldDescriptor* field, - const char* method, const char* description) { - GOOGLE_LOG(FATAL) - << "Protocol Buffer reflection usage error:\n" - " Method : google::protobuf::Reflection::" << method << "\n" - " Message type: " << descriptor->full_name() << "\n" - " Field : " << field->full_name() << "\n" - " Problem : " << description; -} - -const char* cpptype_names_[FieldDescriptor::MAX_CPPTYPE + 1] = { - "INVALID_CPPTYPE", - "CPPTYPE_INT32", - "CPPTYPE_INT64", - "CPPTYPE_UINT32", - "CPPTYPE_UINT64", - "CPPTYPE_DOUBLE", - "CPPTYPE_FLOAT", - "CPPTYPE_BOOL", - "CPPTYPE_ENUM", - "CPPTYPE_STRING", - "CPPTYPE_MESSAGE" -}; - -static void ReportReflectionUsageTypeError( - const Descriptor* descriptor, const FieldDescriptor* field, - const char* method, - FieldDescriptor::CppType expected_type) { - GOOGLE_LOG(FATAL) - << "Protocol Buffer reflection usage error:\n" - " Method : google::protobuf::Reflection::" << method << "\n" - " Message type: " << descriptor->full_name() << "\n" - " Field : " << field->full_name() << "\n" - " Problem : Field is not the right type for this message:\n" - " Expected : " << cpptype_names_[expected_type] << "\n" - " Field type: " << cpptype_names_[field->cpp_type()]; -} - -static void ReportReflectionUsageEnumTypeError( - const Descriptor* descriptor, const FieldDescriptor* field, - const char* method, const EnumValueDescriptor* value) { - GOOGLE_LOG(FATAL) - << "Protocol Buffer reflection usage error:\n" - " Method : google::protobuf::Reflection::" << method << "\n" - " Message type: " << descriptor->full_name() << "\n" - " Field : " << field->full_name() << "\n" - " Problem : Enum value did not match field type:\n" - " Expected : " << field->enum_type()->full_name() << "\n" - " Actual : " << value->full_name(); -} - -#define USAGE_CHECK(CONDITION, METHOD, ERROR_DESCRIPTION) \ - if (!(CONDITION)) \ - ReportReflectionUsageError(descriptor_, field, #METHOD, ERROR_DESCRIPTION) -#define USAGE_CHECK_EQ(A, B, METHOD, ERROR_DESCRIPTION) \ - USAGE_CHECK((A) == (B), METHOD, ERROR_DESCRIPTION) -#define USAGE_CHECK_NE(A, B, METHOD, ERROR_DESCRIPTION) \ - USAGE_CHECK((A) != (B), METHOD, ERROR_DESCRIPTION) - -#define USAGE_CHECK_TYPE(METHOD, CPPTYPE) \ - if (field->cpp_type() != FieldDescriptor::CPPTYPE_##CPPTYPE) \ - ReportReflectionUsageTypeError(descriptor_, field, #METHOD, \ - FieldDescriptor::CPPTYPE_##CPPTYPE) - -#define USAGE_CHECK_ENUM_VALUE(METHOD) \ - if (value->type() != field->enum_type()) \ - ReportReflectionUsageEnumTypeError(descriptor_, field, #METHOD, value) - -#define USAGE_CHECK_MESSAGE_TYPE(METHOD) \ - USAGE_CHECK_EQ(field->containing_type(), descriptor_, \ - METHOD, "Field does not match message type."); -#define USAGE_CHECK_SINGULAR(METHOD) \ - USAGE_CHECK_NE(field->label(), FieldDescriptor::LABEL_REPEATED, METHOD, \ - "Field is repeated; the method requires a singular field.") -#define USAGE_CHECK_REPEATED(METHOD) \ - USAGE_CHECK_EQ(field->label(), FieldDescriptor::LABEL_REPEATED, METHOD, \ - "Field is singular; the method requires a repeated field.") - -#define USAGE_CHECK_ALL(METHOD, LABEL, CPPTYPE) \ - USAGE_CHECK_MESSAGE_TYPE(METHOD); \ - USAGE_CHECK_##LABEL(METHOD); \ - USAGE_CHECK_TYPE(METHOD, CPPTYPE) - -} // namespace - -// =================================================================== - -GeneratedMessageReflection::GeneratedMessageReflection( - const Descriptor* descriptor, - const Message* default_instance, - const int offsets[], - int has_bits_offset, - int unknown_fields_offset, - int extensions_offset, - const DescriptorPool* descriptor_pool, - MessageFactory* factory, - int object_size) - : descriptor_ (descriptor), - default_instance_ (default_instance), - offsets_ (offsets), - has_bits_offset_ (has_bits_offset), - unknown_fields_offset_(unknown_fields_offset), - extensions_offset_(extensions_offset), - object_size_ (object_size), - descriptor_pool_ ((descriptor_pool == NULL) ? - DescriptorPool::generated_pool() : - descriptor_pool), - message_factory_ (factory) { -} - -GeneratedMessageReflection::~GeneratedMessageReflection() {} - -const UnknownFieldSet& GeneratedMessageReflection::GetUnknownFields( - const Message& message) const { - const void* ptr = reinterpret_cast(&message) + - unknown_fields_offset_; - return *reinterpret_cast(ptr); -} -UnknownFieldSet* GeneratedMessageReflection::MutableUnknownFields( - Message* message) const { - void* ptr = reinterpret_cast(message) + unknown_fields_offset_; - return reinterpret_cast(ptr); -} - -int GeneratedMessageReflection::SpaceUsed(const Message& message) const { - // object_size_ already includes the in-memory representation of each field - // in the message, so we only need to account for additional memory used by - // the fields. - int total_size = object_size_; - - total_size += GetUnknownFields(message).SpaceUsedExcludingSelf(); - - if (extensions_offset_ != -1) { - total_size += GetExtensionSet(message).SpaceUsedExcludingSelf(); - } - - for (int i = 0; i < descriptor_->field_count(); i++) { - const FieldDescriptor* field = descriptor_->field(i); - - if (field->is_repeated()) { - switch (field->cpp_type()) { -#define HANDLE_TYPE(UPPERCASE, LOWERCASE) \ - case FieldDescriptor::CPPTYPE_##UPPERCASE : \ - total_size += GetRaw >(message, field) \ - .SpaceUsedExcludingSelf(); \ - break - - HANDLE_TYPE( INT32, int32); - HANDLE_TYPE( INT64, int64); - HANDLE_TYPE(UINT32, uint32); - HANDLE_TYPE(UINT64, uint64); - HANDLE_TYPE(DOUBLE, double); - HANDLE_TYPE( FLOAT, float); - HANDLE_TYPE( BOOL, bool); - HANDLE_TYPE( ENUM, int); -#undef HANDLE_TYPE - - case FieldDescriptor::CPPTYPE_STRING: - switch (field->options().ctype()) { - default: // TODO(kenton): Support other string reps. - case FieldOptions::STRING: - total_size += GetRaw >(message, field) - .SpaceUsedExcludingSelf(); - break; - } - break; - - case FieldDescriptor::CPPTYPE_MESSAGE: - // We don't know which subclass of RepeatedPtrFieldBase the type is, - // so we use RepeatedPtrFieldBase directly. - total_size += - GetRaw(message, field) - .SpaceUsedExcludingSelf >(); - break; - } - } else { - switch (field->cpp_type()) { - case FieldDescriptor::CPPTYPE_INT32 : - case FieldDescriptor::CPPTYPE_INT64 : - case FieldDescriptor::CPPTYPE_UINT32: - case FieldDescriptor::CPPTYPE_UINT64: - case FieldDescriptor::CPPTYPE_DOUBLE: - case FieldDescriptor::CPPTYPE_FLOAT : - case FieldDescriptor::CPPTYPE_BOOL : - case FieldDescriptor::CPPTYPE_ENUM : - // Field is inline, so we've already counted it. - break; - - case FieldDescriptor::CPPTYPE_STRING: { - switch (field->options().ctype()) { - default: // TODO(kenton): Support other string reps. - case FieldOptions::STRING: { - const string* ptr = GetField(message, field); - - // Initially, the string points to the default value stored in - // the prototype. Only count the string if it has been changed - // from the default value. - const string* default_ptr = DefaultRaw(field); - - if (ptr != default_ptr) { - // string fields are represented by just a pointer, so also - // include sizeof(string) as well. - total_size += sizeof(*ptr) + StringSpaceUsedExcludingSelf(*ptr); - } - break; - } - } - break; - } - - case FieldDescriptor::CPPTYPE_MESSAGE: - if (&message == default_instance_) { - // For singular fields, the prototype just stores a pointer to the - // external type's prototype, so there is no extra memory usage. - } else { - const Message* sub_message = GetRaw(message, field); - if (sub_message != NULL) { - total_size += sub_message->SpaceUsed(); - } - } - break; - } - } - } - - return total_size; -} - -void GeneratedMessageReflection::Swap( - Message* message1, - Message* message2) const { - if (message1 == message2) return; - - // TODO(kenton): Other Reflection methods should probably check this too. - GOOGLE_CHECK_EQ(message1->GetReflection(), this) - << "First argument to Swap() (of type \"" - << message1->GetDescriptor()->full_name() - << "\") is not compatible with this reflection object (which is for type \"" - << descriptor_->full_name() - << "\"). Note that the exact same class is required; not just the same " - "descriptor."; - GOOGLE_CHECK_EQ(message2->GetReflection(), this) - << "Second argument to Swap() (of type \"" - << message2->GetDescriptor()->full_name() - << "\") is not compatible with this reflection object (which is for type \"" - << descriptor_->full_name() - << "\"). Note that the exact same class is required; not just the same " - "descriptor."; - - uint32* has_bits1 = MutableHasBits(message1); - uint32* has_bits2 = MutableHasBits(message2); - int has_bits_size = (descriptor_->field_count() + 31) / 32; - - for (int i = 0; i < has_bits_size; i++) { - std::swap(has_bits1[i], has_bits2[i]); - } - - for (int i = 0; i < descriptor_->field_count(); i++) { - const FieldDescriptor* field = descriptor_->field(i); - if (field->is_repeated()) { - switch (field->cpp_type()) { -#define SWAP_ARRAYS(CPPTYPE, TYPE) \ - case FieldDescriptor::CPPTYPE_##CPPTYPE: \ - MutableRaw >(message1, field)->Swap( \ - MutableRaw >(message2, field)); \ - break; - - SWAP_ARRAYS(INT32 , int32 ); - SWAP_ARRAYS(INT64 , int64 ); - SWAP_ARRAYS(UINT32, uint32); - SWAP_ARRAYS(UINT64, uint64); - SWAP_ARRAYS(FLOAT , float ); - SWAP_ARRAYS(DOUBLE, double); - SWAP_ARRAYS(BOOL , bool ); - SWAP_ARRAYS(ENUM , int ); -#undef SWAP_ARRAYS - - case FieldDescriptor::CPPTYPE_STRING: - case FieldDescriptor::CPPTYPE_MESSAGE: - MutableRaw(message1, field)->Swap( - MutableRaw(message2, field)); - break; - - default: - GOOGLE_LOG(FATAL) << "Unimplemented type: " << field->cpp_type(); - } - } else { - switch (field->cpp_type()) { -#define SWAP_VALUES(CPPTYPE, TYPE) \ - case FieldDescriptor::CPPTYPE_##CPPTYPE: \ - std::swap(*MutableRaw(message1, field), \ - *MutableRaw(message2, field)); \ - break; - - SWAP_VALUES(INT32 , int32 ); - SWAP_VALUES(INT64 , int64 ); - SWAP_VALUES(UINT32, uint32); - SWAP_VALUES(UINT64, uint64); - SWAP_VALUES(FLOAT , float ); - SWAP_VALUES(DOUBLE, double); - SWAP_VALUES(BOOL , bool ); - SWAP_VALUES(ENUM , int ); -#undef SWAP_VALUES - case FieldDescriptor::CPPTYPE_MESSAGE: - std::swap(*MutableRaw(message1, field), - *MutableRaw(message2, field)); - break; - - case FieldDescriptor::CPPTYPE_STRING: - switch (field->options().ctype()) { - default: // TODO(kenton): Support other string reps. - case FieldOptions::STRING: - std::swap(*MutableRaw(message1, field), - *MutableRaw(message2, field)); - break; - } - break; - - default: - GOOGLE_LOG(FATAL) << "Unimplemented type: " << field->cpp_type(); - } - } - } - - if (extensions_offset_ != -1) { - MutableExtensionSet(message1)->Swap(MutableExtensionSet(message2)); - } - - MutableUnknownFields(message1)->Swap(MutableUnknownFields(message2)); -} - -// ------------------------------------------------------------------- - -bool GeneratedMessageReflection::HasField(const Message& message, - const FieldDescriptor* field) const { - USAGE_CHECK_MESSAGE_TYPE(HasField); - USAGE_CHECK_SINGULAR(HasField); - - if (field->is_extension()) { - return GetExtensionSet(message).Has(field->number()); - } else { - return HasBit(message, field); - } -} - -int GeneratedMessageReflection::FieldSize(const Message& message, - const FieldDescriptor* field) const { - USAGE_CHECK_MESSAGE_TYPE(FieldSize); - USAGE_CHECK_REPEATED(FieldSize); - - if (field->is_extension()) { - return GetExtensionSet(message).ExtensionSize(field->number()); - } else { - switch (field->cpp_type()) { -#define HANDLE_TYPE(UPPERCASE, LOWERCASE) \ - case FieldDescriptor::CPPTYPE_##UPPERCASE : \ - return GetRaw >(message, field).size() - - HANDLE_TYPE( INT32, int32); - HANDLE_TYPE( INT64, int64); - HANDLE_TYPE(UINT32, uint32); - HANDLE_TYPE(UINT64, uint64); - HANDLE_TYPE(DOUBLE, double); - HANDLE_TYPE( FLOAT, float); - HANDLE_TYPE( BOOL, bool); - HANDLE_TYPE( ENUM, int); -#undef HANDLE_TYPE - - case FieldDescriptor::CPPTYPE_STRING: - case FieldDescriptor::CPPTYPE_MESSAGE: - return GetRaw(message, field).size(); - } - - GOOGLE_LOG(FATAL) << "Can't get here."; - return 0; - } -} - -void GeneratedMessageReflection::ClearField( - Message* message, const FieldDescriptor* field) const { - USAGE_CHECK_MESSAGE_TYPE(ClearField); - - if (field->is_extension()) { - MutableExtensionSet(message)->ClearExtension(field->number()); - } else if (!field->is_repeated()) { - if (HasBit(*message, field)) { - ClearBit(message, field); - - // We need to set the field back to its default value. - switch (field->cpp_type()) { -#define CLEAR_TYPE(CPPTYPE, TYPE) \ - case FieldDescriptor::CPPTYPE_##CPPTYPE: \ - *MutableRaw(message, field) = \ - field->default_value_##TYPE(); \ - break; - - CLEAR_TYPE(INT32 , int32 ); - CLEAR_TYPE(INT64 , int64 ); - CLEAR_TYPE(UINT32, uint32); - CLEAR_TYPE(UINT64, uint64); - CLEAR_TYPE(FLOAT , float ); - CLEAR_TYPE(DOUBLE, double); - CLEAR_TYPE(BOOL , bool ); -#undef CLEAR_TYPE - - case FieldDescriptor::CPPTYPE_ENUM: - *MutableRaw(message, field) = - field->default_value_enum()->number(); - break; - - case FieldDescriptor::CPPTYPE_STRING: { - switch (field->options().ctype()) { - default: // TODO(kenton): Support other string reps. - case FieldOptions::STRING: - const string* default_ptr = DefaultRaw(field); - string** value = MutableRaw(message, field); - if (*value != default_ptr) { - if (field->has_default_value()) { - (*value)->assign(field->default_value_string()); - } else { - (*value)->clear(); - } - } - break; - } - break; - } - - case FieldDescriptor::CPPTYPE_MESSAGE: - (*MutableRaw(message, field))->Clear(); - break; - } - } - } else { - switch (field->cpp_type()) { -#define HANDLE_TYPE(UPPERCASE, LOWERCASE) \ - case FieldDescriptor::CPPTYPE_##UPPERCASE : \ - MutableRaw >(message, field)->Clear(); \ - break - - HANDLE_TYPE( INT32, int32); - HANDLE_TYPE( INT64, int64); - HANDLE_TYPE(UINT32, uint32); - HANDLE_TYPE(UINT64, uint64); - HANDLE_TYPE(DOUBLE, double); - HANDLE_TYPE( FLOAT, float); - HANDLE_TYPE( BOOL, bool); - HANDLE_TYPE( ENUM, int); -#undef HANDLE_TYPE - - case FieldDescriptor::CPPTYPE_STRING: { - switch (field->options().ctype()) { - default: // TODO(kenton): Support other string reps. - case FieldOptions::STRING: - MutableRaw >(message, field)->Clear(); - break; - } - break; - } - - case FieldDescriptor::CPPTYPE_MESSAGE: { - // We don't know which subclass of RepeatedPtrFieldBase the type is, - // so we use RepeatedPtrFieldBase directly. - MutableRaw(message, field) - ->Clear >(); - break; - } - } - } -} - -void GeneratedMessageReflection::RemoveLast( - Message* message, - const FieldDescriptor* field) const { - USAGE_CHECK_MESSAGE_TYPE(RemoveLast); - USAGE_CHECK_REPEATED(RemoveLast); - - if (field->is_extension()) { - MutableExtensionSet(message)->RemoveLast(field->number()); - } else { - switch (field->cpp_type()) { -#define HANDLE_TYPE(UPPERCASE, LOWERCASE) \ - case FieldDescriptor::CPPTYPE_##UPPERCASE : \ - MutableRaw >(message, field)->RemoveLast(); \ - break - - HANDLE_TYPE( INT32, int32); - HANDLE_TYPE( INT64, int64); - HANDLE_TYPE(UINT32, uint32); - HANDLE_TYPE(UINT64, uint64); - HANDLE_TYPE(DOUBLE, double); - HANDLE_TYPE( FLOAT, float); - HANDLE_TYPE( BOOL, bool); - HANDLE_TYPE( ENUM, int); -#undef HANDLE_TYPE - - case FieldDescriptor::CPPTYPE_STRING: - switch (field->options().ctype()) { - default: // TODO(kenton): Support other string reps. - case FieldOptions::STRING: - MutableRaw >(message, field)->RemoveLast(); - break; - } - break; - - case FieldDescriptor::CPPTYPE_MESSAGE: - MutableRaw(message, field) - ->RemoveLast >(); - break; - } - } -} - -Message* GeneratedMessageReflection::ReleaseLast( - Message* message, - const FieldDescriptor* field) const { - USAGE_CHECK_ALL(ReleaseLast, REPEATED, MESSAGE); - - if (field->is_extension()) { - return static_cast( - MutableExtensionSet(message)->ReleaseLast(field->number())); - } else { - return MutableRaw(message, field) - ->ReleaseLast >(); - } -} - -void GeneratedMessageReflection::SwapElements( - Message* message, - const FieldDescriptor* field, - int index1, - int index2) const { - USAGE_CHECK_MESSAGE_TYPE(Swap); - USAGE_CHECK_REPEATED(Swap); - - if (field->is_extension()) { - MutableExtensionSet(message)->SwapElements(field->number(), index1, index2); - } else { - switch (field->cpp_type()) { -#define HANDLE_TYPE(UPPERCASE, LOWERCASE) \ - case FieldDescriptor::CPPTYPE_##UPPERCASE : \ - MutableRaw >(message, field) \ - ->SwapElements(index1, index2); \ - break - - HANDLE_TYPE( INT32, int32); - HANDLE_TYPE( INT64, int64); - HANDLE_TYPE(UINT32, uint32); - HANDLE_TYPE(UINT64, uint64); - HANDLE_TYPE(DOUBLE, double); - HANDLE_TYPE( FLOAT, float); - HANDLE_TYPE( BOOL, bool); - HANDLE_TYPE( ENUM, int); -#undef HANDLE_TYPE - - case FieldDescriptor::CPPTYPE_STRING: - case FieldDescriptor::CPPTYPE_MESSAGE: - MutableRaw(message, field) - ->SwapElements(index1, index2); - break; - } - } -} - -namespace { -// Comparison functor for sorting FieldDescriptors by field number. -struct FieldNumberSorter { - bool operator()(const FieldDescriptor* left, - const FieldDescriptor* right) const { - return left->number() < right->number(); - } -}; -} // namespace - -void GeneratedMessageReflection::ListFields( - const Message& message, - vector* output) const { - output->clear(); - - // Optimization: The default instance never has any fields set. - if (&message == default_instance_) return; - - for (int i = 0; i < descriptor_->field_count(); i++) { - const FieldDescriptor* field = descriptor_->field(i); - if (field->is_repeated()) { - if (FieldSize(message, field) > 0) { - output->push_back(field); - } - } else { - if (HasBit(message, field)) { - output->push_back(field); - } - } - } - - if (extensions_offset_ != -1) { - GetExtensionSet(message).AppendToList(descriptor_, descriptor_pool_, - output); - } - - // ListFields() must sort output by field number. - sort(output->begin(), output->end(), FieldNumberSorter()); -} - -// ------------------------------------------------------------------- - -#undef DEFINE_PRIMITIVE_ACCESSORS -#define DEFINE_PRIMITIVE_ACCESSORS(TYPENAME, TYPE, PASSTYPE, CPPTYPE) \ - PASSTYPE GeneratedMessageReflection::Get##TYPENAME( \ - const Message& message, const FieldDescriptor* field) const { \ - USAGE_CHECK_ALL(Get##TYPENAME, SINGULAR, CPPTYPE); \ - if (field->is_extension()) { \ - return GetExtensionSet(message).Get##TYPENAME( \ - field->number(), field->default_value_##PASSTYPE()); \ - } else { \ - return GetField(message, field); \ - } \ - } \ - \ - void GeneratedMessageReflection::Set##TYPENAME( \ - Message* message, const FieldDescriptor* field, \ - PASSTYPE value) const { \ - USAGE_CHECK_ALL(Set##TYPENAME, SINGULAR, CPPTYPE); \ - if (field->is_extension()) { \ - return MutableExtensionSet(message)->Set##TYPENAME( \ - field->number(), field->type(), value, field); \ - } else { \ - SetField(message, field, value); \ - } \ - } \ - \ - PASSTYPE GeneratedMessageReflection::GetRepeated##TYPENAME( \ - const Message& message, \ - const FieldDescriptor* field, int index) const { \ - USAGE_CHECK_ALL(GetRepeated##TYPENAME, REPEATED, CPPTYPE); \ - if (field->is_extension()) { \ - return GetExtensionSet(message).GetRepeated##TYPENAME( \ - field->number(), index); \ - } else { \ - return GetRepeatedField(message, field, index); \ - } \ - } \ - \ - void GeneratedMessageReflection::SetRepeated##TYPENAME( \ - Message* message, const FieldDescriptor* field, \ - int index, PASSTYPE value) const { \ - USAGE_CHECK_ALL(SetRepeated##TYPENAME, REPEATED, CPPTYPE); \ - if (field->is_extension()) { \ - MutableExtensionSet(message)->SetRepeated##TYPENAME( \ - field->number(), index, value); \ - } else { \ - SetRepeatedField(message, field, index, value); \ - } \ - } \ - \ - void GeneratedMessageReflection::Add##TYPENAME( \ - Message* message, const FieldDescriptor* field, \ - PASSTYPE value) const { \ - USAGE_CHECK_ALL(Add##TYPENAME, REPEATED, CPPTYPE); \ - if (field->is_extension()) { \ - MutableExtensionSet(message)->Add##TYPENAME( \ - field->number(), field->type(), field->options().packed(), value, \ - field); \ - } else { \ - AddField(message, field, value); \ - } \ - } - -DEFINE_PRIMITIVE_ACCESSORS(Int32 , int32 , int32 , INT32 ) -DEFINE_PRIMITIVE_ACCESSORS(Int64 , int64 , int64 , INT64 ) -DEFINE_PRIMITIVE_ACCESSORS(UInt32, uint32, uint32, UINT32) -DEFINE_PRIMITIVE_ACCESSORS(UInt64, uint64, uint64, UINT64) -DEFINE_PRIMITIVE_ACCESSORS(Float , float , float , FLOAT ) -DEFINE_PRIMITIVE_ACCESSORS(Double, double, double, DOUBLE) -DEFINE_PRIMITIVE_ACCESSORS(Bool , bool , bool , BOOL ) -#undef DEFINE_PRIMITIVE_ACCESSORS - -// ------------------------------------------------------------------- - -string GeneratedMessageReflection::GetString( - const Message& message, const FieldDescriptor* field) const { - USAGE_CHECK_ALL(GetString, SINGULAR, STRING); - if (field->is_extension()) { - return GetExtensionSet(message).GetString(field->number(), - field->default_value_string()); - } else { - switch (field->options().ctype()) { - default: // TODO(kenton): Support other string reps. - case FieldOptions::STRING: - return *GetField(message, field); - } - - GOOGLE_LOG(FATAL) << "Can't get here."; - return kEmptyString; // Make compiler happy. - } -} - -const string& GeneratedMessageReflection::GetStringReference( - const Message& message, - const FieldDescriptor* field, string* scratch) const { - USAGE_CHECK_ALL(GetStringReference, SINGULAR, STRING); - if (field->is_extension()) { - return GetExtensionSet(message).GetString(field->number(), - field->default_value_string()); - } else { - switch (field->options().ctype()) { - default: // TODO(kenton): Support other string reps. - case FieldOptions::STRING: - return *GetField(message, field); - } - - GOOGLE_LOG(FATAL) << "Can't get here."; - return kEmptyString; // Make compiler happy. - } -} - - -void GeneratedMessageReflection::SetString( - Message* message, const FieldDescriptor* field, - const string& value) const { - USAGE_CHECK_ALL(SetString, SINGULAR, STRING); - if (field->is_extension()) { - return MutableExtensionSet(message)->SetString(field->number(), - field->type(), value, field); - } else { - switch (field->options().ctype()) { - default: // TODO(kenton): Support other string reps. - case FieldOptions::STRING: { - string** ptr = MutableField(message, field); - if (*ptr == DefaultRaw(field)) { - *ptr = new string(value); - } else { - (*ptr)->assign(value); - } - break; - } - } - } -} - - -string GeneratedMessageReflection::GetRepeatedString( - const Message& message, const FieldDescriptor* field, int index) const { - USAGE_CHECK_ALL(GetRepeatedString, REPEATED, STRING); - if (field->is_extension()) { - return GetExtensionSet(message).GetRepeatedString(field->number(), index); - } else { - switch (field->options().ctype()) { - default: // TODO(kenton): Support other string reps. - case FieldOptions::STRING: - return GetRepeatedPtrField(message, field, index); - } - - GOOGLE_LOG(FATAL) << "Can't get here."; - return kEmptyString; // Make compiler happy. - } -} - -const string& GeneratedMessageReflection::GetRepeatedStringReference( - const Message& message, const FieldDescriptor* field, - int index, string* scratch) const { - USAGE_CHECK_ALL(GetRepeatedStringReference, REPEATED, STRING); - if (field->is_extension()) { - return GetExtensionSet(message).GetRepeatedString(field->number(), index); - } else { - switch (field->options().ctype()) { - default: // TODO(kenton): Support other string reps. - case FieldOptions::STRING: - return GetRepeatedPtrField(message, field, index); - } - - GOOGLE_LOG(FATAL) << "Can't get here."; - return kEmptyString; // Make compiler happy. - } -} - - -void GeneratedMessageReflection::SetRepeatedString( - Message* message, const FieldDescriptor* field, - int index, const string& value) const { - USAGE_CHECK_ALL(SetRepeatedString, REPEATED, STRING); - if (field->is_extension()) { - MutableExtensionSet(message)->SetRepeatedString( - field->number(), index, value); - } else { - switch (field->options().ctype()) { - default: // TODO(kenton): Support other string reps. - case FieldOptions::STRING: - *MutableRepeatedField(message, field, index) = value; - break; - } - } -} - - -void GeneratedMessageReflection::AddString( - Message* message, const FieldDescriptor* field, - const string& value) const { - USAGE_CHECK_ALL(AddString, REPEATED, STRING); - if (field->is_extension()) { - MutableExtensionSet(message)->AddString(field->number(), - field->type(), value, field); - } else { - switch (field->options().ctype()) { - default: // TODO(kenton): Support other string reps. - case FieldOptions::STRING: - *AddField(message, field) = value; - break; - } - } -} - - -// ------------------------------------------------------------------- - -const EnumValueDescriptor* GeneratedMessageReflection::GetEnum( - const Message& message, const FieldDescriptor* field) const { - USAGE_CHECK_ALL(GetEnum, SINGULAR, ENUM); - - int value; - if (field->is_extension()) { - value = GetExtensionSet(message).GetEnum( - field->number(), field->default_value_enum()->number()); - } else { - value = GetField(message, field); - } - const EnumValueDescriptor* result = - field->enum_type()->FindValueByNumber(value); - GOOGLE_CHECK(result != NULL) << "Value " << value << " is not valid for field " - << field->full_name() << " of type " - << field->enum_type()->full_name() << "."; - return result; -} - -void GeneratedMessageReflection::SetEnum( - Message* message, const FieldDescriptor* field, - const EnumValueDescriptor* value) const { - USAGE_CHECK_ALL(SetEnum, SINGULAR, ENUM); - USAGE_CHECK_ENUM_VALUE(SetEnum); - - if (field->is_extension()) { - MutableExtensionSet(message)->SetEnum(field->number(), field->type(), - value->number(), field); - } else { - SetField(message, field, value->number()); - } -} - -const EnumValueDescriptor* GeneratedMessageReflection::GetRepeatedEnum( - const Message& message, const FieldDescriptor* field, int index) const { - USAGE_CHECK_ALL(GetRepeatedEnum, REPEATED, ENUM); - - int value; - if (field->is_extension()) { - value = GetExtensionSet(message).GetRepeatedEnum(field->number(), index); - } else { - value = GetRepeatedField(message, field, index); - } - const EnumValueDescriptor* result = - field->enum_type()->FindValueByNumber(value); - GOOGLE_CHECK(result != NULL) << "Value " << value << " is not valid for field " - << field->full_name() << " of type " - << field->enum_type()->full_name() << "."; - return result; -} - -void GeneratedMessageReflection::SetRepeatedEnum( - Message* message, - const FieldDescriptor* field, int index, - const EnumValueDescriptor* value) const { - USAGE_CHECK_ALL(SetRepeatedEnum, REPEATED, ENUM); - USAGE_CHECK_ENUM_VALUE(SetRepeatedEnum); - - if (field->is_extension()) { - MutableExtensionSet(message)->SetRepeatedEnum( - field->number(), index, value->number()); - } else { - SetRepeatedField(message, field, index, value->number()); - } -} - -void GeneratedMessageReflection::AddEnum( - Message* message, const FieldDescriptor* field, - const EnumValueDescriptor* value) const { - USAGE_CHECK_ALL(AddEnum, REPEATED, ENUM); - USAGE_CHECK_ENUM_VALUE(AddEnum); - - if (field->is_extension()) { - MutableExtensionSet(message)->AddEnum(field->number(), field->type(), - field->options().packed(), - value->number(), field); - } else { - AddField(message, field, value->number()); - } -} - -// ------------------------------------------------------------------- - -const Message& GeneratedMessageReflection::GetMessage( - const Message& message, const FieldDescriptor* field, - MessageFactory* factory) const { - USAGE_CHECK_ALL(GetMessage, SINGULAR, MESSAGE); - - if (factory == NULL) factory = message_factory_; - - if (field->is_extension()) { - return static_cast( - GetExtensionSet(message).GetMessage( - field->number(), field->message_type(), factory)); - } else { - const Message* result; - result = GetRaw(message, field); - if (result == NULL) { - result = DefaultRaw(field); - } - return *result; - } -} - -Message* GeneratedMessageReflection::MutableMessage( - Message* message, const FieldDescriptor* field, - MessageFactory* factory) const { - USAGE_CHECK_ALL(MutableMessage, SINGULAR, MESSAGE); - - if (factory == NULL) factory = message_factory_; - - if (field->is_extension()) { - return static_cast( - MutableExtensionSet(message)->MutableMessage(field, factory)); - } else { - Message* result; - Message** result_holder = MutableField(message, field); - if (*result_holder == NULL) { - const Message* default_message = DefaultRaw(field); - *result_holder = default_message->New(); - } - result = *result_holder; - return result; - } -} - -Message* GeneratedMessageReflection::ReleaseMessage( - Message* message, - const FieldDescriptor* field, - MessageFactory* factory) const { - USAGE_CHECK_ALL(ReleaseMessage, SINGULAR, MESSAGE); - - if (factory == NULL) factory = message_factory_; - - if (field->is_extension()) { - return static_cast( - MutableExtensionSet(message)->ReleaseMessage(field, factory)); - } else { - ClearBit(message, field); - Message** result = MutableRaw(message, field); - Message* ret = *result; - *result = NULL; - return ret; - } -} - -const Message& GeneratedMessageReflection::GetRepeatedMessage( - const Message& message, const FieldDescriptor* field, int index) const { - USAGE_CHECK_ALL(GetRepeatedMessage, REPEATED, MESSAGE); - - if (field->is_extension()) { - return static_cast( - GetExtensionSet(message).GetRepeatedMessage(field->number(), index)); - } else { - return GetRaw(message, field) - .Get >(index); - } -} - -Message* GeneratedMessageReflection::MutableRepeatedMessage( - Message* message, const FieldDescriptor* field, int index) const { - USAGE_CHECK_ALL(MutableRepeatedMessage, REPEATED, MESSAGE); - - if (field->is_extension()) { - return static_cast( - MutableExtensionSet(message)->MutableRepeatedMessage( - field->number(), index)); - } else { - return MutableRaw(message, field) - ->Mutable >(index); - } -} - -Message* GeneratedMessageReflection::AddMessage( - Message* message, const FieldDescriptor* field, - MessageFactory* factory) const { - USAGE_CHECK_ALL(AddMessage, REPEATED, MESSAGE); - - if (factory == NULL) factory = message_factory_; - - if (field->is_extension()) { - return static_cast( - MutableExtensionSet(message)->AddMessage(field, factory)); - } else { - // We can't use AddField() because RepeatedPtrFieldBase doesn't - // know how to allocate one. - RepeatedPtrFieldBase* repeated = - MutableRaw(message, field); - Message* result = repeated->AddFromCleared >(); - if (result == NULL) { - // We must allocate a new object. - const Message* prototype; - if (repeated->size() == 0) { - prototype = factory->GetPrototype(field->message_type()); - } else { - prototype = &repeated->Get >(0); - } - result = prototype->New(); - repeated->AddAllocated >(result); - } - return result; - } -} - -void* GeneratedMessageReflection::MutableRawRepeatedField( - Message* message, const FieldDescriptor* field, - FieldDescriptor::CppType cpptype, - int ctype, const Descriptor* desc) const { - USAGE_CHECK_REPEATED("MutableRawRepeatedField"); - if (field->cpp_type() != cpptype) - ReportReflectionUsageTypeError(descriptor_, - field, "MutableRawRepeatedField", cpptype); - if (ctype >= 0) - GOOGLE_CHECK_EQ(field->options().ctype(), ctype) << "subtype mismatch"; - if (desc != NULL) - GOOGLE_CHECK_EQ(field->message_type(), desc) << "wrong submessage type"; - if (field->is_extension()) - return MutableExtensionSet(message)->MutableRawRepeatedField( - field->number()); - else - return reinterpret_cast(message) + offsets_[field->index()]; -} - -// ----------------------------------------------------------------------------- - -const FieldDescriptor* GeneratedMessageReflection::FindKnownExtensionByName( - const string& name) const { - if (extensions_offset_ == -1) return NULL; - - const FieldDescriptor* result = descriptor_pool_->FindExtensionByName(name); - if (result != NULL && result->containing_type() == descriptor_) { - return result; - } - - if (descriptor_->options().message_set_wire_format()) { - // MessageSet extensions may be identified by type name. - const Descriptor* type = descriptor_pool_->FindMessageTypeByName(name); - if (type != NULL) { - // Look for a matching extension in the foreign type's scope. - for (int i = 0; i < type->extension_count(); i++) { - const FieldDescriptor* extension = type->extension(i); - if (extension->containing_type() == descriptor_ && - extension->type() == FieldDescriptor::TYPE_MESSAGE && - extension->is_optional() && - extension->message_type() == type) { - // Found it. - return extension; - } - } - } - } - - return NULL; -} - -const FieldDescriptor* GeneratedMessageReflection::FindKnownExtensionByNumber( - int number) const { - if (extensions_offset_ == -1) return NULL; - return descriptor_pool_->FindExtensionByNumber(descriptor_, number); -} - -// =================================================================== -// Some private helpers. - -// These simple template accessors obtain pointers (or references) to -// the given field. -template -inline const Type& GeneratedMessageReflection::GetRaw( - const Message& message, const FieldDescriptor* field) const { - const void* ptr = reinterpret_cast(&message) + - offsets_[field->index()]; - return *reinterpret_cast(ptr); -} - -template -inline Type* GeneratedMessageReflection::MutableRaw( - Message* message, const FieldDescriptor* field) const { - void* ptr = reinterpret_cast(message) + offsets_[field->index()]; - return reinterpret_cast(ptr); -} - -template -inline const Type& GeneratedMessageReflection::DefaultRaw( - const FieldDescriptor* field) const { - const void* ptr = reinterpret_cast(default_instance_) + - offsets_[field->index()]; - return *reinterpret_cast(ptr); -} - -inline const uint32* GeneratedMessageReflection::GetHasBits( - const Message& message) const { - const void* ptr = reinterpret_cast(&message) + has_bits_offset_; - return reinterpret_cast(ptr); -} -inline uint32* GeneratedMessageReflection::MutableHasBits( - Message* message) const { - void* ptr = reinterpret_cast(message) + has_bits_offset_; - return reinterpret_cast(ptr); -} - -inline const ExtensionSet& GeneratedMessageReflection::GetExtensionSet( - const Message& message) const { - GOOGLE_DCHECK_NE(extensions_offset_, -1); - const void* ptr = reinterpret_cast(&message) + - extensions_offset_; - return *reinterpret_cast(ptr); -} -inline ExtensionSet* GeneratedMessageReflection::MutableExtensionSet( - Message* message) const { - GOOGLE_DCHECK_NE(extensions_offset_, -1); - void* ptr = reinterpret_cast(message) + extensions_offset_; - return reinterpret_cast(ptr); -} - -// Simple accessors for manipulating has_bits_. -inline bool GeneratedMessageReflection::HasBit( - const Message& message, const FieldDescriptor* field) const { - return GetHasBits(message)[field->index() / 32] & - (1 << (field->index() % 32)); -} - -inline void GeneratedMessageReflection::SetBit( - Message* message, const FieldDescriptor* field) const { - MutableHasBits(message)[field->index() / 32] |= (1 << (field->index() % 32)); -} - -inline void GeneratedMessageReflection::ClearBit( - Message* message, const FieldDescriptor* field) const { - MutableHasBits(message)[field->index() / 32] &= ~(1 << (field->index() % 32)); -} - -// Template implementations of basic accessors. Inline because each -// template instance is only called from one location. These are -// used for all types except messages. -template -inline const Type& GeneratedMessageReflection::GetField( - const Message& message, const FieldDescriptor* field) const { - return GetRaw(message, field); -} - -template -inline void GeneratedMessageReflection::SetField( - Message* message, const FieldDescriptor* field, const Type& value) const { - *MutableRaw(message, field) = value; - SetBit(message, field); -} - -template -inline Type* GeneratedMessageReflection::MutableField( - Message* message, const FieldDescriptor* field) const { - SetBit(message, field); - return MutableRaw(message, field); -} - -template -inline const Type& GeneratedMessageReflection::GetRepeatedField( - const Message& message, const FieldDescriptor* field, int index) const { - return GetRaw >(message, field).Get(index); -} - -template -inline const Type& GeneratedMessageReflection::GetRepeatedPtrField( - const Message& message, const FieldDescriptor* field, int index) const { - return GetRaw >(message, field).Get(index); -} - -template -inline void GeneratedMessageReflection::SetRepeatedField( - Message* message, const FieldDescriptor* field, - int index, Type value) const { - MutableRaw >(message, field)->Set(index, value); -} - -template -inline Type* GeneratedMessageReflection::MutableRepeatedField( - Message* message, const FieldDescriptor* field, int index) const { - RepeatedPtrField* repeated = - MutableRaw >(message, field); - return repeated->Mutable(index); -} - -template -inline void GeneratedMessageReflection::AddField( - Message* message, const FieldDescriptor* field, const Type& value) const { - MutableRaw >(message, field)->Add(value); -} - -template -inline Type* GeneratedMessageReflection::AddField( - Message* message, const FieldDescriptor* field) const { - RepeatedPtrField* repeated = - MutableRaw >(message, field); - return repeated->Add(); -} - -} // namespace internal -} // namespace protobuf -} // namespace google diff --git a/modules/dnn/3rdparty/protobuf/src/google/protobuf/generated_message_reflection.h b/modules/dnn/3rdparty/protobuf/src/google/protobuf/generated_message_reflection.h deleted file mode 100644 index c1c142fa8..000000000 --- a/modules/dnn/3rdparty/protobuf/src/google/protobuf/generated_message_reflection.h +++ /dev/null @@ -1,419 +0,0 @@ -// Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// http://code.google.com/p/protobuf/ -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -// Author: kenton@google.com (Kenton Varda) -// Based on original Protocol Buffers design by -// Sanjay Ghemawat, Jeff Dean, and others. -// -// This header is logically internal, but is made public because it is used -// from protocol-compiler-generated code, which may reside in other components. - -#ifndef GOOGLE_PROTOBUF_GENERATED_MESSAGE_REFLECTION_H__ -#define GOOGLE_PROTOBUF_GENERATED_MESSAGE_REFLECTION_H__ - -#include -#include -#include -// TODO(jasonh): Remove this once the compiler change to directly include this -// is released to components. -#include -#include -#include - - -namespace google { -namespace upb { -namespace google_opensource { -class GMR_Handlers; -} // namespace google_opensource -} // namespace upb - -namespace protobuf { - class DescriptorPool; -} - -namespace protobuf { -namespace internal { - -// Defined in this file. -class GeneratedMessageReflection; - -// Defined in other files. -class ExtensionSet; // extension_set.h - -// THIS CLASS IS NOT INTENDED FOR DIRECT USE. It is intended for use -// by generated code. This class is just a big hack that reduces code -// size. -// -// A GeneratedMessageReflection is an implementation of Reflection -// which expects all fields to be backed by simple variables located in -// memory. The locations are given using a base pointer and a set of -// offsets. -// -// It is required that the user represents fields of each type in a standard -// way, so that GeneratedMessageReflection can cast the void* pointer to -// the appropriate type. For primitive fields and string fields, each field -// should be represented using the obvious C++ primitive type. Enums and -// Messages are different: -// - Singular Message fields are stored as a pointer to a Message. These -// should start out NULL, except for in the default instance where they -// should start out pointing to other default instances. -// - Enum fields are stored as an int. This int must always contain -// a valid value, such that EnumDescriptor::FindValueByNumber() would -// not return NULL. -// - Repeated fields are stored as RepeatedFields or RepeatedPtrFields -// of whatever type the individual field would be. Strings and -// Messages use RepeatedPtrFields while everything else uses -// RepeatedFields. -class LIBPROTOBUF_EXPORT GeneratedMessageReflection : public Reflection { - public: - // Constructs a GeneratedMessageReflection. - // Parameters: - // descriptor: The descriptor for the message type being implemented. - // default_instance: The default instance of the message. This is only - // used to obtain pointers to default instances of embedded - // messages, which GetMessage() will return if the particular - // sub-message has not been initialized yet. (Thus, all - // embedded message fields *must* have non-NULL pointers - // in the default instance.) - // offsets: An array of ints giving the byte offsets, relative to - // the start of the message object, of each field. These can - // be computed at compile time using the - // GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET() macro, defined - // below. - // has_bits_offset: Offset in the message of an array of uint32s of size - // descriptor->field_count()/32, rounded up. This is a - // bitfield where each bit indicates whether or not the - // corresponding field of the message has been initialized. - // The bit for field index i is obtained by the expression: - // has_bits[i / 32] & (1 << (i % 32)) - // unknown_fields_offset: Offset in the message of the UnknownFieldSet for - // the message. - // extensions_offset: Offset in the message of the ExtensionSet for the - // message, or -1 if the message type has no extension - // ranges. - // pool: DescriptorPool to search for extension definitions. Only - // used by FindKnownExtensionByName() and - // FindKnownExtensionByNumber(). - // factory: MessageFactory to use to construct extension messages. - // object_size: The size of a message object of this type, as measured - // by sizeof(). - GeneratedMessageReflection(const Descriptor* descriptor, - const Message* default_instance, - const int offsets[], - int has_bits_offset, - int unknown_fields_offset, - int extensions_offset, - const DescriptorPool* pool, - MessageFactory* factory, - int object_size); - ~GeneratedMessageReflection(); - - // implements Reflection ------------------------------------------- - - const UnknownFieldSet& GetUnknownFields(const Message& message) const; - UnknownFieldSet* MutableUnknownFields(Message* message) const; - - int SpaceUsed(const Message& message) const; - - bool HasField(const Message& message, const FieldDescriptor* field) const; - int FieldSize(const Message& message, const FieldDescriptor* field) const; - void ClearField(Message* message, const FieldDescriptor* field) const; - void RemoveLast(Message* message, const FieldDescriptor* field) const; - Message* ReleaseLast(Message* message, const FieldDescriptor* field) const; - void Swap(Message* message1, Message* message2) const; - void SwapElements(Message* message, const FieldDescriptor* field, - int index1, int index2) const; - void ListFields(const Message& message, - vector* output) const; - - int32 GetInt32 (const Message& message, - const FieldDescriptor* field) const; - int64 GetInt64 (const Message& message, - const FieldDescriptor* field) const; - uint32 GetUInt32(const Message& message, - const FieldDescriptor* field) const; - uint64 GetUInt64(const Message& message, - const FieldDescriptor* field) const; - float GetFloat (const Message& message, - const FieldDescriptor* field) const; - double GetDouble(const Message& message, - const FieldDescriptor* field) const; - bool GetBool (const Message& message, - const FieldDescriptor* field) const; - string GetString(const Message& message, - const FieldDescriptor* field) const; - const string& GetStringReference(const Message& message, - const FieldDescriptor* field, - string* scratch) const; - const EnumValueDescriptor* GetEnum(const Message& message, - const FieldDescriptor* field) const; - const Message& GetMessage(const Message& message, - const FieldDescriptor* field, - MessageFactory* factory = NULL) const; - - void SetInt32 (Message* message, - const FieldDescriptor* field, int32 value) const; - void SetInt64 (Message* message, - const FieldDescriptor* field, int64 value) const; - void SetUInt32(Message* message, - const FieldDescriptor* field, uint32 value) const; - void SetUInt64(Message* message, - const FieldDescriptor* field, uint64 value) const; - void SetFloat (Message* message, - const FieldDescriptor* field, float value) const; - void SetDouble(Message* message, - const FieldDescriptor* field, double value) const; - void SetBool (Message* message, - const FieldDescriptor* field, bool value) const; - void SetString(Message* message, - const FieldDescriptor* field, - const string& value) const; - void SetEnum (Message* message, const FieldDescriptor* field, - const EnumValueDescriptor* value) const; - Message* MutableMessage(Message* message, const FieldDescriptor* field, - MessageFactory* factory = NULL) const; - Message* ReleaseMessage(Message* message, const FieldDescriptor* field, - MessageFactory* factory = NULL) const; - - int32 GetRepeatedInt32 (const Message& message, - const FieldDescriptor* field, int index) const; - int64 GetRepeatedInt64 (const Message& message, - const FieldDescriptor* field, int index) const; - uint32 GetRepeatedUInt32(const Message& message, - const FieldDescriptor* field, int index) const; - uint64 GetRepeatedUInt64(const Message& message, - const FieldDescriptor* field, int index) const; - float GetRepeatedFloat (const Message& message, - const FieldDescriptor* field, int index) const; - double GetRepeatedDouble(const Message& message, - const FieldDescriptor* field, int index) const; - bool GetRepeatedBool (const Message& message, - const FieldDescriptor* field, int index) const; - string GetRepeatedString(const Message& message, - const FieldDescriptor* field, int index) const; - const string& GetRepeatedStringReference(const Message& message, - const FieldDescriptor* field, - int index, string* scratch) const; - const EnumValueDescriptor* GetRepeatedEnum(const Message& message, - const FieldDescriptor* field, - int index) const; - const Message& GetRepeatedMessage(const Message& message, - const FieldDescriptor* field, - int index) const; - - // Set the value of a field. - void SetRepeatedInt32 (Message* message, - const FieldDescriptor* field, int index, int32 value) const; - void SetRepeatedInt64 (Message* message, - const FieldDescriptor* field, int index, int64 value) const; - void SetRepeatedUInt32(Message* message, - const FieldDescriptor* field, int index, uint32 value) const; - void SetRepeatedUInt64(Message* message, - const FieldDescriptor* field, int index, uint64 value) const; - void SetRepeatedFloat (Message* message, - const FieldDescriptor* field, int index, float value) const; - void SetRepeatedDouble(Message* message, - const FieldDescriptor* field, int index, double value) const; - void SetRepeatedBool (Message* message, - const FieldDescriptor* field, int index, bool value) const; - void SetRepeatedString(Message* message, - const FieldDescriptor* field, int index, - const string& value) const; - void SetRepeatedEnum(Message* message, const FieldDescriptor* field, - int index, const EnumValueDescriptor* value) const; - // Get a mutable pointer to a field with a message type. - Message* MutableRepeatedMessage(Message* message, - const FieldDescriptor* field, - int index) const; - - void AddInt32 (Message* message, - const FieldDescriptor* field, int32 value) const; - void AddInt64 (Message* message, - const FieldDescriptor* field, int64 value) const; - void AddUInt32(Message* message, - const FieldDescriptor* field, uint32 value) const; - void AddUInt64(Message* message, - const FieldDescriptor* field, uint64 value) const; - void AddFloat (Message* message, - const FieldDescriptor* field, float value) const; - void AddDouble(Message* message, - const FieldDescriptor* field, double value) const; - void AddBool (Message* message, - const FieldDescriptor* field, bool value) const; - void AddString(Message* message, - const FieldDescriptor* field, const string& value) const; - void AddEnum(Message* message, - const FieldDescriptor* field, - const EnumValueDescriptor* value) const; - Message* AddMessage(Message* message, const FieldDescriptor* field, - MessageFactory* factory = NULL) const; - - const FieldDescriptor* FindKnownExtensionByName(const string& name) const; - const FieldDescriptor* FindKnownExtensionByNumber(int number) const; - - protected: - virtual void* MutableRawRepeatedField( - Message* message, const FieldDescriptor* field, FieldDescriptor::CppType, - int ctype, const Descriptor* desc) const; - - private: - friend class GeneratedMessage; - - // To parse directly into a proto2 generated class, the class GMR_Handlers - // needs access to member offsets and hasbits. - friend class LIBPROTOBUF_EXPORT upb::google_opensource::GMR_Handlers; - - const Descriptor* descriptor_; - const Message* default_instance_; - const int* offsets_; - - int has_bits_offset_; - int unknown_fields_offset_; - int extensions_offset_; - int object_size_; - - const DescriptorPool* descriptor_pool_; - MessageFactory* message_factory_; - - template - inline const Type& GetRaw(const Message& message, - const FieldDescriptor* field) const; - template - inline Type* MutableRaw(Message* message, - const FieldDescriptor* field) const; - template - inline const Type& DefaultRaw(const FieldDescriptor* field) const; - - inline const uint32* GetHasBits(const Message& message) const; - inline uint32* MutableHasBits(Message* message) const; - inline const ExtensionSet& GetExtensionSet(const Message& message) const; - inline ExtensionSet* MutableExtensionSet(Message* message) const; - - inline bool HasBit(const Message& message, - const FieldDescriptor* field) const; - inline void SetBit(Message* message, - const FieldDescriptor* field) const; - inline void ClearBit(Message* message, - const FieldDescriptor* field) const; - - template - inline const Type& GetField(const Message& message, - const FieldDescriptor* field) const; - template - inline void SetField(Message* message, - const FieldDescriptor* field, const Type& value) const; - template - inline Type* MutableField(Message* message, - const FieldDescriptor* field) const; - template - inline const Type& GetRepeatedField(const Message& message, - const FieldDescriptor* field, - int index) const; - template - inline const Type& GetRepeatedPtrField(const Message& message, - const FieldDescriptor* field, - int index) const; - template - inline void SetRepeatedField(Message* message, - const FieldDescriptor* field, int index, - Type value) const; - template - inline Type* MutableRepeatedField(Message* message, - const FieldDescriptor* field, - int index) const; - template - inline void AddField(Message* message, - const FieldDescriptor* field, const Type& value) const; - template - inline Type* AddField(Message* message, - const FieldDescriptor* field) const; - - int GetExtensionNumberOrDie(const Descriptor* type) const; - - GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(GeneratedMessageReflection); -}; - -// Returns the offset of the given field within the given aggregate type. -// This is equivalent to the ANSI C offsetof() macro. However, according -// to the C++ standard, offsetof() only works on POD types, and GCC -// enforces this requirement with a warning. In practice, this rule is -// unnecessarily strict; there is probably no compiler or platform on -// which the offsets of the direct fields of a class are non-constant. -// Fields inherited from superclasses *can* have non-constant offsets, -// but that's not what this macro will be used for. -// -// Note that we calculate relative to the pointer value 16 here since if we -// just use zero, GCC complains about dereferencing a NULL pointer. We -// choose 16 rather than some other number just in case the compiler would -// be confused by an unaligned pointer. -#define GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(TYPE, FIELD) \ - static_cast( \ - reinterpret_cast( \ - &reinterpret_cast(16)->FIELD) - \ - reinterpret_cast(16)) - -// There are some places in proto2 where dynamic_cast would be useful as an -// optimization. For example, take Message::MergeFrom(const Message& other). -// For a given generated message FooMessage, we generate these two methods: -// void MergeFrom(const FooMessage& other); -// void MergeFrom(const Message& other); -// The former method can be implemented directly in terms of FooMessage's -// inline accessors, but the latter method must work with the reflection -// interface. However, if the parameter to the latter method is actually of -// type FooMessage, then we'd like to be able to just call the other method -// as an optimization. So, we use dynamic_cast to check this. -// -// That said, dynamic_cast requires RTTI, which many people like to disable -// for performance and code size reasons. When RTTI is not available, we -// still need to produce correct results. So, in this case we have to fall -// back to using reflection, which is what we would have done anyway if the -// objects were not of the exact same class. -// -// dynamic_cast_if_available() implements this logic. If RTTI is -// enabled, it does a dynamic_cast. If RTTI is disabled, it just returns -// NULL. -// -// If you need to compile without RTTI, simply #define GOOGLE_PROTOBUF_NO_RTTI. -// On MSVC, this should be detected automatically. -template -inline To dynamic_cast_if_available(From from) { -#if defined(GOOGLE_PROTOBUF_NO_RTTI) || (defined(_MSC_VER)&&!defined(_CPPRTTI)) - return NULL; -#else - return dynamic_cast(from); -#endif -} - -} // namespace internal -} // namespace protobuf - -} // namespace google -#endif // GOOGLE_PROTOBUF_GENERATED_MESSAGE_REFLECTION_H__ diff --git a/modules/dnn/3rdparty/protobuf/src/google/protobuf/generated_message_reflection_unittest.cc b/modules/dnn/3rdparty/protobuf/src/google/protobuf/generated_message_reflection_unittest.cc deleted file mode 100644 index 39aa55fb4..000000000 --- a/modules/dnn/3rdparty/protobuf/src/google/protobuf/generated_message_reflection_unittest.cc +++ /dev/null @@ -1,484 +0,0 @@ -// Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// http://code.google.com/p/protobuf/ -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -// Author: kenton@google.com (Kenton Varda) -// Based on original Protocol Buffers design by -// Sanjay Ghemawat, Jeff Dean, and others. -// -// To test GeneratedMessageReflection, we actually let the protocol compiler -// generate a full protocol message implementation and then test its -// reflection interface. This is much easier and more maintainable than -// trying to create our own Message class for GeneratedMessageReflection -// to wrap. -// -// The tests here closely mirror some of the tests in -// compiler/cpp/unittest, except using the reflection interface -// rather than generated accessors. - -#include -#include -#include -#include - -#include -#include -#include - -namespace google { -namespace protobuf { - -namespace { - -// Shorthand to get a FieldDescriptor for a field of unittest::TestAllTypes. -const FieldDescriptor* F(const string& name) { - const FieldDescriptor* result = - unittest::TestAllTypes::descriptor()->FindFieldByName(name); - GOOGLE_CHECK(result != NULL); - return result; -} - -TEST(GeneratedMessageReflectionTest, Defaults) { - // Check that all default values are set correctly in the initial message. - unittest::TestAllTypes message; - TestUtil::ReflectionTester reflection_tester( - unittest::TestAllTypes::descriptor()); - - reflection_tester.ExpectClearViaReflection(message); - - const Reflection* reflection = message.GetReflection(); - - // Messages should return pointers to default instances until first use. - // (This is not checked by ExpectClear() since it is not actually true after - // the fields have been set and then cleared.) - EXPECT_EQ(&unittest::TestAllTypes::OptionalGroup::default_instance(), - &reflection->GetMessage(message, F("optionalgroup"))); - EXPECT_EQ(&unittest::TestAllTypes::NestedMessage::default_instance(), - &reflection->GetMessage(message, F("optional_nested_message"))); - EXPECT_EQ(&unittest::ForeignMessage::default_instance(), - &reflection->GetMessage(message, F("optional_foreign_message"))); - EXPECT_EQ(&unittest_import::ImportMessage::default_instance(), - &reflection->GetMessage(message, F("optional_import_message"))); -} - -TEST(GeneratedMessageReflectionTest, Accessors) { - // Set every field to a unique value then go back and check all those - // values. - unittest::TestAllTypes message; - TestUtil::ReflectionTester reflection_tester( - unittest::TestAllTypes::descriptor()); - - reflection_tester.SetAllFieldsViaReflection(&message); - TestUtil::ExpectAllFieldsSet(message); - reflection_tester.ExpectAllFieldsSetViaReflection(message); - - reflection_tester.ModifyRepeatedFieldsViaReflection(&message); - TestUtil::ExpectRepeatedFieldsModified(message); -} - -TEST(GeneratedMessageReflectionTest, GetStringReference) { - // Test that GetStringReference() returns the underlying string when it is - // a normal string field. - unittest::TestAllTypes message; - message.set_optional_string("foo"); - message.add_repeated_string("foo"); - - const Reflection* reflection = message.GetReflection(); - string scratch; - - EXPECT_EQ(&message.optional_string(), - &reflection->GetStringReference(message, F("optional_string"), &scratch)) - << "For simple string fields, GetStringReference() should return a " - "reference to the underlying string."; - EXPECT_EQ(&message.repeated_string(0), - &reflection->GetRepeatedStringReference(message, F("repeated_string"), - 0, &scratch)) - << "For simple string fields, GetRepeatedStringReference() should return " - "a reference to the underlying string."; -} - - -TEST(GeneratedMessageReflectionTest, DefaultsAfterClear) { - // Check that after setting all fields and then clearing, getting an - // embedded message does NOT return the default instance. - unittest::TestAllTypes message; - TestUtil::ReflectionTester reflection_tester( - unittest::TestAllTypes::descriptor()); - - TestUtil::SetAllFields(&message); - message.Clear(); - - const Reflection* reflection = message.GetReflection(); - - EXPECT_NE(&unittest::TestAllTypes::OptionalGroup::default_instance(), - &reflection->GetMessage(message, F("optionalgroup"))); - EXPECT_NE(&unittest::TestAllTypes::NestedMessage::default_instance(), - &reflection->GetMessage(message, F("optional_nested_message"))); - EXPECT_NE(&unittest::ForeignMessage::default_instance(), - &reflection->GetMessage(message, F("optional_foreign_message"))); - EXPECT_NE(&unittest_import::ImportMessage::default_instance(), - &reflection->GetMessage(message, F("optional_import_message"))); -} - - -TEST(GeneratedMessageReflectionTest, Swap) { - unittest::TestAllTypes message1; - unittest::TestAllTypes message2; - - TestUtil::SetAllFields(&message1); - - const Reflection* reflection = message1.GetReflection(); - reflection->Swap(&message1, &message2); - - TestUtil::ExpectClear(message1); - TestUtil::ExpectAllFieldsSet(message2); -} - -TEST(GeneratedMessageReflectionTest, SwapWithBothSet) { - unittest::TestAllTypes message1; - unittest::TestAllTypes message2; - - TestUtil::SetAllFields(&message1); - TestUtil::SetAllFields(&message2); - TestUtil::ModifyRepeatedFields(&message2); - - const Reflection* reflection = message1.GetReflection(); - reflection->Swap(&message1, &message2); - - TestUtil::ExpectRepeatedFieldsModified(message1); - TestUtil::ExpectAllFieldsSet(message2); - - message1.set_optional_int32(532819); - - reflection->Swap(&message1, &message2); - - EXPECT_EQ(532819, message2.optional_int32()); -} - -TEST(GeneratedMessageReflectionTest, SwapExtensions) { - unittest::TestAllExtensions message1; - unittest::TestAllExtensions message2; - - TestUtil::SetAllExtensions(&message1); - - const Reflection* reflection = message1.GetReflection(); - reflection->Swap(&message1, &message2); - - TestUtil::ExpectExtensionsClear(message1); - TestUtil::ExpectAllExtensionsSet(message2); -} - -TEST(GeneratedMessageReflectionTest, SwapUnknown) { - unittest::TestEmptyMessage message1, message2; - - message1.mutable_unknown_fields()->AddVarint(1234, 1); - - EXPECT_EQ(1, message1.unknown_fields().field_count()); - EXPECT_EQ(0, message2.unknown_fields().field_count()); - const Reflection* reflection = message1.GetReflection(); - reflection->Swap(&message1, &message2); - EXPECT_EQ(0, message1.unknown_fields().field_count()); - EXPECT_EQ(1, message2.unknown_fields().field_count()); -} - -TEST(GeneratedMessageReflectionTest, RemoveLast) { - unittest::TestAllTypes message; - TestUtil::ReflectionTester reflection_tester( - unittest::TestAllTypes::descriptor()); - - TestUtil::SetAllFields(&message); - - reflection_tester.RemoveLastRepeatedsViaReflection(&message); - - TestUtil::ExpectLastRepeatedsRemoved(message); -} - -TEST(GeneratedMessageReflectionTest, RemoveLastExtensions) { - unittest::TestAllExtensions message; - TestUtil::ReflectionTester reflection_tester( - unittest::TestAllExtensions::descriptor()); - - TestUtil::SetAllExtensions(&message); - - reflection_tester.RemoveLastRepeatedsViaReflection(&message); - - TestUtil::ExpectLastRepeatedExtensionsRemoved(message); -} - -TEST(GeneratedMessageReflectionTest, ReleaseLast) { - unittest::TestAllTypes message; - const Descriptor* descriptor = message.GetDescriptor(); - TestUtil::ReflectionTester reflection_tester(descriptor); - - TestUtil::SetAllFields(&message); - - reflection_tester.ReleaseLastRepeatedsViaReflection(&message, false); - - TestUtil::ExpectLastRepeatedsReleased(message); - - // Now test that we actually release the right message. - message.Clear(); - TestUtil::SetAllFields(&message); - ASSERT_EQ(2, message.repeated_foreign_message_size()); - const protobuf_unittest::ForeignMessage* expected = - message.mutable_repeated_foreign_message(1); - scoped_ptr released(message.GetReflection()->ReleaseLast( - &message, descriptor->FindFieldByName("repeated_foreign_message"))); - EXPECT_EQ(expected, released.get()); -} - -TEST(GeneratedMessageReflectionTest, ReleaseLastExtensions) { - unittest::TestAllExtensions message; - const Descriptor* descriptor = message.GetDescriptor(); - TestUtil::ReflectionTester reflection_tester(descriptor); - - TestUtil::SetAllExtensions(&message); - - reflection_tester.ReleaseLastRepeatedsViaReflection(&message, true); - - TestUtil::ExpectLastRepeatedExtensionsReleased(message); - - // Now test that we actually release the right message. - message.Clear(); - TestUtil::SetAllExtensions(&message); - ASSERT_EQ(2, message.ExtensionSize( - unittest::repeated_foreign_message_extension)); - const protobuf_unittest::ForeignMessage* expected = message.MutableExtension( - unittest::repeated_foreign_message_extension, 1); - scoped_ptr released(message.GetReflection()->ReleaseLast( - &message, descriptor->file()->FindExtensionByName( - "repeated_foreign_message_extension"))); - EXPECT_EQ(expected, released.get()); - -} - -TEST(GeneratedMessageReflectionTest, SwapRepeatedElements) { - unittest::TestAllTypes message; - TestUtil::ReflectionTester reflection_tester( - unittest::TestAllTypes::descriptor()); - - TestUtil::SetAllFields(&message); - - // Swap and test that fields are all swapped. - reflection_tester.SwapRepeatedsViaReflection(&message); - TestUtil::ExpectRepeatedsSwapped(message); - - // Swap back and test that fields are all back to original values. - reflection_tester.SwapRepeatedsViaReflection(&message); - TestUtil::ExpectAllFieldsSet(message); -} - -TEST(GeneratedMessageReflectionTest, SwapRepeatedElementsExtension) { - unittest::TestAllExtensions message; - TestUtil::ReflectionTester reflection_tester( - unittest::TestAllExtensions::descriptor()); - - TestUtil::SetAllExtensions(&message); - - // Swap and test that fields are all swapped. - reflection_tester.SwapRepeatedsViaReflection(&message); - TestUtil::ExpectRepeatedExtensionsSwapped(message); - - // Swap back and test that fields are all back to original values. - reflection_tester.SwapRepeatedsViaReflection(&message); - TestUtil::ExpectAllExtensionsSet(message); -} - -TEST(GeneratedMessageReflectionTest, Extensions) { - // Set every extension to a unique value then go back and check all those - // values. - unittest::TestAllExtensions message; - TestUtil::ReflectionTester reflection_tester( - unittest::TestAllExtensions::descriptor()); - - reflection_tester.SetAllFieldsViaReflection(&message); - TestUtil::ExpectAllExtensionsSet(message); - reflection_tester.ExpectAllFieldsSetViaReflection(message); - - reflection_tester.ModifyRepeatedFieldsViaReflection(&message); - TestUtil::ExpectRepeatedExtensionsModified(message); -} - -TEST(GeneratedMessageReflectionTest, FindExtensionTypeByNumber) { - const Reflection* reflection = - unittest::TestAllExtensions::default_instance().GetReflection(); - - const FieldDescriptor* extension1 = - unittest::TestAllExtensions::descriptor()->file()->FindExtensionByName( - "optional_int32_extension"); - const FieldDescriptor* extension2 = - unittest::TestAllExtensions::descriptor()->file()->FindExtensionByName( - "repeated_string_extension"); - - EXPECT_EQ(extension1, - reflection->FindKnownExtensionByNumber(extension1->number())); - EXPECT_EQ(extension2, - reflection->FindKnownExtensionByNumber(extension2->number())); - - // Non-existent extension. - EXPECT_TRUE(reflection->FindKnownExtensionByNumber(62341) == NULL); - - // Extensions of TestAllExtensions should not show up as extensions of - // other types. - EXPECT_TRUE(unittest::TestAllTypes::default_instance().GetReflection()-> - FindKnownExtensionByNumber(extension1->number()) == NULL); -} - -TEST(GeneratedMessageReflectionTest, FindKnownExtensionByName) { - const Reflection* reflection = - unittest::TestAllExtensions::default_instance().GetReflection(); - - const FieldDescriptor* extension1 = - unittest::TestAllExtensions::descriptor()->file()->FindExtensionByName( - "optional_int32_extension"); - const FieldDescriptor* extension2 = - unittest::TestAllExtensions::descriptor()->file()->FindExtensionByName( - "repeated_string_extension"); - - EXPECT_EQ(extension1, - reflection->FindKnownExtensionByName(extension1->full_name())); - EXPECT_EQ(extension2, - reflection->FindKnownExtensionByName(extension2->full_name())); - - // Non-existent extension. - EXPECT_TRUE(reflection->FindKnownExtensionByName("no_such_ext") == NULL); - - // Extensions of TestAllExtensions should not show up as extensions of - // other types. - EXPECT_TRUE(unittest::TestAllTypes::default_instance().GetReflection()-> - FindKnownExtensionByName(extension1->full_name()) == NULL); -} - -TEST(GeneratedMessageReflectionTest, ReleaseMessageTest) { - unittest::TestAllTypes message; - TestUtil::ReflectionTester reflection_tester( - unittest::TestAllTypes::descriptor()); - - // When nothing is set, we expect all released messages to be NULL. - reflection_tester.ExpectMessagesReleasedViaReflection( - &message, TestUtil::ReflectionTester::IS_NULL); - - // After fields are set we should get non-NULL releases. - reflection_tester.SetAllFieldsViaReflection(&message); - reflection_tester.ExpectMessagesReleasedViaReflection( - &message, TestUtil::ReflectionTester::NOT_NULL); - - // After Clear() we may or may not get a message from ReleaseMessage(). - // This is implementation specific. - reflection_tester.SetAllFieldsViaReflection(&message); - message.Clear(); - reflection_tester.ExpectMessagesReleasedViaReflection( - &message, TestUtil::ReflectionTester::CAN_BE_NULL); - - // Test a different code path for setting after releasing. - TestUtil::SetAllFields(&message); - TestUtil::ExpectAllFieldsSet(message); -} - -TEST(GeneratedMessageReflectionTest, ReleaseExtensionMessageTest) { - unittest::TestAllExtensions message; - TestUtil::ReflectionTester reflection_tester( - unittest::TestAllExtensions::descriptor()); - - // When nothing is set, we expect all released messages to be NULL. - reflection_tester.ExpectMessagesReleasedViaReflection( - &message, TestUtil::ReflectionTester::IS_NULL); - - // After fields are set we should get non-NULL releases. - reflection_tester.SetAllFieldsViaReflection(&message); - reflection_tester.ExpectMessagesReleasedViaReflection( - &message, TestUtil::ReflectionTester::NOT_NULL); - - // After Clear() we may or may not get a message from ReleaseMessage(). - // This is implementation specific. - reflection_tester.SetAllFieldsViaReflection(&message); - message.Clear(); - reflection_tester.ExpectMessagesReleasedViaReflection( - &message, TestUtil::ReflectionTester::CAN_BE_NULL); - - // Test a different code path for setting after releasing. - TestUtil::SetAllExtensions(&message); - TestUtil::ExpectAllExtensionsSet(message); -} - -#ifdef PROTOBUF_HAS_DEATH_TEST - -TEST(GeneratedMessageReflectionTest, UsageErrors) { - unittest::TestAllTypes message; - const Reflection* reflection = message.GetReflection(); - const Descriptor* descriptor = message.GetDescriptor(); - -#define f(NAME) descriptor->FindFieldByName(NAME) - - // Testing every single failure mode would be too much work. Let's just - // check a few. - EXPECT_DEATH( - reflection->GetInt32( - message, descriptor->FindFieldByName("optional_int64")), - "Protocol Buffer reflection usage error:\n" - " Method : google::protobuf::Reflection::GetInt32\n" - " Message type: protobuf_unittest\\.TestAllTypes\n" - " Field : protobuf_unittest\\.TestAllTypes\\.optional_int64\n" - " Problem : Field is not the right type for this message:\n" - " Expected : CPPTYPE_INT32\n" - " Field type: CPPTYPE_INT64"); - EXPECT_DEATH( - reflection->GetInt32( - message, descriptor->FindFieldByName("repeated_int32")), - "Protocol Buffer reflection usage error:\n" - " Method : google::protobuf::Reflection::GetInt32\n" - " Message type: protobuf_unittest.TestAllTypes\n" - " Field : protobuf_unittest.TestAllTypes.repeated_int32\n" - " Problem : Field is repeated; the method requires a singular field."); - EXPECT_DEATH( - reflection->GetInt32( - message, unittest::ForeignMessage::descriptor()->FindFieldByName("c")), - "Protocol Buffer reflection usage error:\n" - " Method : google::protobuf::Reflection::GetInt32\n" - " Message type: protobuf_unittest.TestAllTypes\n" - " Field : protobuf_unittest.ForeignMessage.c\n" - " Problem : Field does not match message type."); - EXPECT_DEATH( - reflection->HasField( - message, unittest::ForeignMessage::descriptor()->FindFieldByName("c")), - "Protocol Buffer reflection usage error:\n" - " Method : google::protobuf::Reflection::HasField\n" - " Message type: protobuf_unittest.TestAllTypes\n" - " Field : protobuf_unittest.ForeignMessage.c\n" - " Problem : Field does not match message type."); - -#undef f -} - -#endif // PROTOBUF_HAS_DEATH_TEST - - -} // namespace -} // namespace protobuf -} // namespace google diff --git a/modules/dnn/3rdparty/protobuf/src/google/protobuf/generated_message_util.cc b/modules/dnn/3rdparty/protobuf/src/google/protobuf/generated_message_util.cc deleted file mode 100644 index ac3215014..000000000 --- a/modules/dnn/3rdparty/protobuf/src/google/protobuf/generated_message_util.cc +++ /dev/null @@ -1,54 +0,0 @@ -// Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// http://code.google.com/p/protobuf/ -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -// Author: kenton@google.com (Kenton Varda) -// Based on original Protocol Buffers design by -// Sanjay Ghemawat, Jeff Dean, and others. - -#include - -#include - -namespace google { -namespace protobuf { -namespace internal { - -double Infinity() { - return std::numeric_limits::infinity(); -} -double NaN() { - return std::numeric_limits::quiet_NaN(); -} - -const ::std::string kEmptyString; - -} // namespace internal -} // namespace protobuf -} // namespace google diff --git a/modules/dnn/3rdparty/protobuf/src/google/protobuf/generated_message_util.h b/modules/dnn/3rdparty/protobuf/src/google/protobuf/generated_message_util.h deleted file mode 100644 index b2fb8f0be..000000000 --- a/modules/dnn/3rdparty/protobuf/src/google/protobuf/generated_message_util.h +++ /dev/null @@ -1,77 +0,0 @@ -// Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// http://code.google.com/p/protobuf/ -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -// Author: kenton@google.com (Kenton Varda) -// Based on original Protocol Buffers design by -// Sanjay Ghemawat, Jeff Dean, and others. -// -// This file contains miscellaneous helper code used by generated code -- -// including lite types -- but which should not be used directly by users. - -#ifndef GOOGLE_PROTOBUF_GENERATED_MESSAGE_UTIL_H__ -#define GOOGLE_PROTOBUF_GENERATED_MESSAGE_UTIL_H__ - -#include - -#include -namespace google { -namespace protobuf { -namespace internal { - -// Annotation for the compiler to emit a deprecation message if a field marked -// with option 'deprecated=true' is used in the code, or for other things in -// generated code which are deprecated. -// -// For internal use in the pb.cc files, deprecation warnings are suppressed -// there. -#undef DEPRECATED_PROTOBUF_FIELD -#define PROTOBUF_DEPRECATED - - -// Constants for special floating point values. -LIBPROTOBUF_EXPORT double Infinity(); -LIBPROTOBUF_EXPORT double NaN(); - -// Constant used for empty default strings. -LIBPROTOBUF_EXPORT extern const ::std::string kEmptyString; - -// Defined in generated_message_reflection.cc -- not actually part of the lite -// library. -// -// TODO(jasonh): The various callers get this declaration from a variety of -// places: probably in most cases repeated_field.h. Clean these up so they all -// get the declaration from this file. -LIBPROTOBUF_EXPORT int StringSpaceUsedExcludingSelf(const string& str); - -} // namespace internal -} // namespace protobuf - -} // namespace google -#endif // GOOGLE_PROTOBUF_GENERATED_MESSAGE_UTIL_H__ diff --git a/modules/dnn/3rdparty/protobuf/src/google/protobuf/io/coded_stream.cc b/modules/dnn/3rdparty/protobuf/src/google/protobuf/io/coded_stream.cc deleted file mode 100644 index 36add8c3e..000000000 --- a/modules/dnn/3rdparty/protobuf/src/google/protobuf/io/coded_stream.cc +++ /dev/null @@ -1,857 +0,0 @@ -// Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// http://code.google.com/p/protobuf/ -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -// Author: kenton@google.com (Kenton Varda) -// Based on original Protocol Buffers design by -// Sanjay Ghemawat, Jeff Dean, and others. -// -// This implementation is heavily optimized to make reads and writes -// of small values (especially varints) as fast as possible. In -// particular, we optimize for the common case that a read or a write -// will not cross the end of the buffer, since we can avoid a lot -// of branching in this case. - -#include -#include -#include -#include -#include -#include - - -namespace google { -namespace protobuf { -namespace io { - -namespace { - -static const int kMaxVarintBytes = 10; -static const int kMaxVarint32Bytes = 5; - - -inline bool NextNonEmpty(ZeroCopyInputStream* input, - const void** data, int* size) { - bool success; - do { - success = input->Next(data, size); - } while (success && *size == 0); - return success; -} - -} // namespace - -// CodedInputStream ================================================== - -CodedInputStream::~CodedInputStream() { - if (input_ != NULL) { - BackUpInputToCurrentPosition(); - } - - if (total_bytes_warning_threshold_ == -2) { - GOOGLE_LOG(WARNING) << "The total number of bytes read was " << total_bytes_read_; - } -} - -// Static. -int CodedInputStream::default_recursion_limit_ = 100; - - -void CodedInputStream::BackUpInputToCurrentPosition() { - int backup_bytes = BufferSize() + buffer_size_after_limit_ + overflow_bytes_; - if (backup_bytes > 0) { - input_->BackUp(backup_bytes); - - // total_bytes_read_ doesn't include overflow_bytes_. - total_bytes_read_ -= BufferSize() + buffer_size_after_limit_; - buffer_end_ = buffer_; - buffer_size_after_limit_ = 0; - overflow_bytes_ = 0; - } -} - -inline void CodedInputStream::RecomputeBufferLimits() { - buffer_end_ += buffer_size_after_limit_; - int closest_limit = min(current_limit_, total_bytes_limit_); - if (closest_limit < total_bytes_read_) { - // The limit position is in the current buffer. We must adjust - // the buffer size accordingly. - buffer_size_after_limit_ = total_bytes_read_ - closest_limit; - buffer_end_ -= buffer_size_after_limit_; - } else { - buffer_size_after_limit_ = 0; - } -} - -CodedInputStream::Limit CodedInputStream::PushLimit(int byte_limit) { - // Current position relative to the beginning of the stream. - int current_position = CurrentPosition(); - - Limit old_limit = current_limit_; - - // security: byte_limit is possibly evil, so check for negative values - // and overflow. - if (byte_limit >= 0 && - byte_limit <= INT_MAX - current_position) { - current_limit_ = current_position + byte_limit; - } else { - // Negative or overflow. - current_limit_ = INT_MAX; - } - - // We need to enforce all limits, not just the new one, so if the previous - // limit was before the new requested limit, we continue to enforce the - // previous limit. - current_limit_ = min(current_limit_, old_limit); - - RecomputeBufferLimits(); - return old_limit; -} - -void CodedInputStream::PopLimit(Limit limit) { - // The limit passed in is actually the *old* limit, which we returned from - // PushLimit(). - current_limit_ = limit; - RecomputeBufferLimits(); - - // We may no longer be at a legitimate message end. ReadTag() needs to be - // called again to find out. - legitimate_message_end_ = false; -} - -int CodedInputStream::BytesUntilLimit() const { - if (current_limit_ == INT_MAX) return -1; - int current_position = CurrentPosition(); - - return current_limit_ - current_position; -} - -void CodedInputStream::SetTotalBytesLimit( - int total_bytes_limit, int warning_threshold) { - // Make sure the limit isn't already past, since this could confuse other - // code. - int current_position = CurrentPosition(); - total_bytes_limit_ = max(current_position, total_bytes_limit); - if (warning_threshold >= 0) { - total_bytes_warning_threshold_ = warning_threshold; - } else { - // warning_threshold is negative - total_bytes_warning_threshold_ = -1; - } - RecomputeBufferLimits(); -} - -void CodedInputStream::PrintTotalBytesLimitError() { - GOOGLE_LOG(ERROR) << "A protocol message was rejected because it was too " - "big (more than " << total_bytes_limit_ - << " bytes). To increase the limit (or to disable these " - "warnings), see CodedInputStream::SetTotalBytesLimit() " - "in google/protobuf/io/coded_stream.h."; -} - -bool CodedInputStream::Skip(int count) { - if (count < 0) return false; // security: count is often user-supplied - - const int original_buffer_size = BufferSize(); - - if (count <= original_buffer_size) { - // Just skipping within the current buffer. Easy. - Advance(count); - return true; - } - - if (buffer_size_after_limit_ > 0) { - // We hit a limit inside this buffer. Advance to the limit and fail. - Advance(original_buffer_size); - return false; - } - - count -= original_buffer_size; - buffer_ = NULL; - buffer_end_ = buffer_; - - // Make sure this skip doesn't try to skip past the current limit. - int closest_limit = min(current_limit_, total_bytes_limit_); - int bytes_until_limit = closest_limit - total_bytes_read_; - if (bytes_until_limit < count) { - // We hit the limit. Skip up to it then fail. - if (bytes_until_limit > 0) { - total_bytes_read_ = closest_limit; - input_->Skip(bytes_until_limit); - } - return false; - } - - total_bytes_read_ += count; - return input_->Skip(count); -} - -bool CodedInputStream::GetDirectBufferPointer(const void** data, int* size) { - if (BufferSize() == 0 && !Refresh()) return false; - - *data = buffer_; - *size = BufferSize(); - return true; -} - -bool CodedInputStream::ReadRaw(void* buffer, int size) { - int current_buffer_size; - while ((current_buffer_size = BufferSize()) < size) { - // Reading past end of buffer. Copy what we have, then refresh. - memcpy(buffer, buffer_, current_buffer_size); - buffer = reinterpret_cast(buffer) + current_buffer_size; - size -= current_buffer_size; - Advance(current_buffer_size); - if (!Refresh()) return false; - } - - memcpy(buffer, buffer_, size); - Advance(size); - - return true; -} - -bool CodedInputStream::ReadString(string* buffer, int size) { - if (size < 0) return false; // security: size is often user-supplied - return InternalReadStringInline(buffer, size); -} - -bool CodedInputStream::ReadStringFallback(string* buffer, int size) { - if (!buffer->empty()) { - buffer->clear(); - } - - int current_buffer_size; - while ((current_buffer_size = BufferSize()) < size) { - // Some STL implementations "helpfully" crash on buffer->append(NULL, 0). - if (current_buffer_size != 0) { - // Note: string1.append(string2) is O(string2.size()) (as opposed to - // O(string1.size() + string2.size()), which would be bad). - buffer->append(reinterpret_cast(buffer_), - current_buffer_size); - } - size -= current_buffer_size; - Advance(current_buffer_size); - if (!Refresh()) return false; - } - - buffer->append(reinterpret_cast(buffer_), size); - Advance(size); - - return true; -} - - -bool CodedInputStream::ReadLittleEndian32Fallback(uint32* value) { - uint8 bytes[sizeof(*value)]; - - const uint8* ptr; - if (BufferSize() >= sizeof(*value)) { - // Fast path: Enough bytes in the buffer to read directly. - ptr = buffer_; - Advance(sizeof(*value)); - } else { - // Slow path: Had to read past the end of the buffer. - if (!ReadRaw(bytes, sizeof(*value))) return false; - ptr = bytes; - } - ReadLittleEndian32FromArray(ptr, value); - return true; -} - -bool CodedInputStream::ReadLittleEndian64Fallback(uint64* value) { - uint8 bytes[sizeof(*value)]; - - const uint8* ptr; - if (BufferSize() >= sizeof(*value)) { - // Fast path: Enough bytes in the buffer to read directly. - ptr = buffer_; - Advance(sizeof(*value)); - } else { - // Slow path: Had to read past the end of the buffer. - if (!ReadRaw(bytes, sizeof(*value))) return false; - ptr = bytes; - } - ReadLittleEndian64FromArray(ptr, value); - return true; -} - -namespace { - -inline const uint8* ReadVarint32FromArray( - const uint8* buffer, uint32* value) GOOGLE_ATTRIBUTE_ALWAYS_INLINE; -inline const uint8* ReadVarint32FromArray(const uint8* buffer, uint32* value) { - // Fast path: We have enough bytes left in the buffer to guarantee that - // this read won't cross the end, so we can skip the checks. - const uint8* ptr = buffer; - uint32 b; - uint32 result; - - b = *(ptr++); result = (b & 0x7F) ; if (!(b & 0x80)) goto done; - b = *(ptr++); result |= (b & 0x7F) << 7; if (!(b & 0x80)) goto done; - b = *(ptr++); result |= (b & 0x7F) << 14; if (!(b & 0x80)) goto done; - b = *(ptr++); result |= (b & 0x7F) << 21; if (!(b & 0x80)) goto done; - b = *(ptr++); result |= b << 28; if (!(b & 0x80)) goto done; - - // If the input is larger than 32 bits, we still need to read it all - // and discard the high-order bits. - for (int i = 0; i < kMaxVarintBytes - kMaxVarint32Bytes; i++) { - b = *(ptr++); if (!(b & 0x80)) goto done; - } - - // We have overrun the maximum size of a varint (10 bytes). Assume - // the data is corrupt. - return NULL; - - done: - *value = result; - return ptr; -} - -} // namespace - -bool CodedInputStream::ReadVarint32Slow(uint32* value) { - uint64 result; - // Directly invoke ReadVarint64Fallback, since we already tried to optimize - // for one-byte varints. - if (!ReadVarint64Fallback(&result)) return false; - *value = (uint32)result; - return true; -} - -bool CodedInputStream::ReadVarint32Fallback(uint32* value) { - if (BufferSize() >= kMaxVarintBytes || - // Optimization: If the varint ends at exactly the end of the buffer, - // we can detect that and still use the fast path. - (buffer_end_ > buffer_ && !(buffer_end_[-1] & 0x80))) { - const uint8* end = ReadVarint32FromArray(buffer_, value); - if (end == NULL) return false; - buffer_ = end; - return true; - } else { - // Really slow case: we will incur the cost of an extra function call here, - // but moving this out of line reduces the size of this function, which - // improves the common case. In micro benchmarks, this is worth about 10-15% - return ReadVarint32Slow(value); - } -} - -uint32 CodedInputStream::ReadTagSlow() { - if (buffer_ == buffer_end_) { - // Call refresh. - if (!Refresh()) { - // Refresh failed. Make sure that it failed due to EOF, not because - // we hit total_bytes_limit_, which, unlike normal limits, is not a - // valid place to end a message. - int current_position = total_bytes_read_ - buffer_size_after_limit_; - if (current_position >= total_bytes_limit_) { - // Hit total_bytes_limit_. But if we also hit the normal limit, - // we're still OK. - legitimate_message_end_ = current_limit_ == total_bytes_limit_; - } else { - legitimate_message_end_ = true; - } - return 0; - } - } - - // For the slow path, just do a 64-bit read. Try to optimize for one-byte tags - // again, since we have now refreshed the buffer. - uint64 result = 0; - if (!ReadVarint64(&result)) return 0; - return static_cast(result); -} - -uint32 CodedInputStream::ReadTagFallback() { - const int buf_size = BufferSize(); - if (buf_size >= kMaxVarintBytes || - // Optimization: If the varint ends at exactly the end of the buffer, - // we can detect that and still use the fast path. - (buf_size > 0 && !(buffer_end_[-1] & 0x80))) { - uint32 tag; - const uint8* end = ReadVarint32FromArray(buffer_, &tag); - if (end == NULL) { - return 0; - } - buffer_ = end; - return tag; - } else { - // We are commonly at a limit when attempting to read tags. Try to quickly - // detect this case without making another function call. - if ((buf_size == 0) && - ((buffer_size_after_limit_ > 0) || - (total_bytes_read_ == current_limit_)) && - // Make sure that the limit we hit is not total_bytes_limit_, since - // in that case we still need to call Refresh() so that it prints an - // error. - total_bytes_read_ - buffer_size_after_limit_ < total_bytes_limit_) { - // We hit a byte limit. - legitimate_message_end_ = true; - return 0; - } - return ReadTagSlow(); - } -} - -bool CodedInputStream::ReadVarint64Slow(uint64* value) { - // Slow path: This read might cross the end of the buffer, so we - // need to check and refresh the buffer if and when it does. - - uint64 result = 0; - int count = 0; - uint32 b; - - do { - if (count == kMaxVarintBytes) return false; - while (buffer_ == buffer_end_) { - if (!Refresh()) return false; - } - b = *buffer_; - result |= static_cast(b & 0x7F) << (7 * count); - Advance(1); - ++count; - } while (b & 0x80); - - *value = result; - return true; -} - -bool CodedInputStream::ReadVarint64Fallback(uint64* value) { - if (BufferSize() >= kMaxVarintBytes || - // Optimization: If the varint ends at exactly the end of the buffer, - // we can detect that and still use the fast path. - (buffer_end_ > buffer_ && !(buffer_end_[-1] & 0x80))) { - // Fast path: We have enough bytes left in the buffer to guarantee that - // this read won't cross the end, so we can skip the checks. - - const uint8* ptr = buffer_; - uint32 b; - - // Splitting into 32-bit pieces gives better performance on 32-bit - // processors. - uint32 part0 = 0, part1 = 0, part2 = 0; - - b = *(ptr++); part0 = (b & 0x7F) ; if (!(b & 0x80)) goto done; - b = *(ptr++); part0 |= (b & 0x7F) << 7; if (!(b & 0x80)) goto done; - b = *(ptr++); part0 |= (b & 0x7F) << 14; if (!(b & 0x80)) goto done; - b = *(ptr++); part0 |= (b & 0x7F) << 21; if (!(b & 0x80)) goto done; - b = *(ptr++); part1 = (b & 0x7F) ; if (!(b & 0x80)) goto done; - b = *(ptr++); part1 |= (b & 0x7F) << 7; if (!(b & 0x80)) goto done; - b = *(ptr++); part1 |= (b & 0x7F) << 14; if (!(b & 0x80)) goto done; - b = *(ptr++); part1 |= (b & 0x7F) << 21; if (!(b & 0x80)) goto done; - b = *(ptr++); part2 = (b & 0x7F) ; if (!(b & 0x80)) goto done; - b = *(ptr++); part2 |= (b & 0x7F) << 7; if (!(b & 0x80)) goto done; - - // We have overrun the maximum size of a varint (10 bytes). The data - // must be corrupt. - return false; - - done: - Advance(ptr - buffer_); - *value = (static_cast(part0) ) | - (static_cast(part1) << 28) | - (static_cast(part2) << 56); - return true; - } else { - return ReadVarint64Slow(value); - } -} - -bool CodedInputStream::Refresh() { - GOOGLE_DCHECK_EQ(0, BufferSize()); - - if (buffer_size_after_limit_ > 0 || overflow_bytes_ > 0 || - total_bytes_read_ == current_limit_) { - // We've hit a limit. Stop. - int current_position = total_bytes_read_ - buffer_size_after_limit_; - - if (current_position >= total_bytes_limit_ && - total_bytes_limit_ != current_limit_) { - // Hit total_bytes_limit_. - PrintTotalBytesLimitError(); - } - - return false; - } - - if (total_bytes_warning_threshold_ >= 0 && - total_bytes_read_ >= total_bytes_warning_threshold_) { - GOOGLE_LOG(WARNING) << "Reading dangerously large protocol message. If the " - "message turns out to be larger than " - << total_bytes_limit_ << " bytes, parsing will be halted " - "for security reasons. To increase the limit (or to " - "disable these warnings), see " - "CodedInputStream::SetTotalBytesLimit() in " - "google/protobuf/io/coded_stream.h."; - - // Don't warn again for this stream, and print total size at the end. - total_bytes_warning_threshold_ = -2; - } - - const void* void_buffer; - int buffer_size; - if (NextNonEmpty(input_, &void_buffer, &buffer_size)) { - buffer_ = reinterpret_cast(void_buffer); - buffer_end_ = buffer_ + buffer_size; - GOOGLE_CHECK_GE(buffer_size, 0); - - if (total_bytes_read_ <= INT_MAX - buffer_size) { - total_bytes_read_ += buffer_size; - } else { - // Overflow. Reset buffer_end_ to not include the bytes beyond INT_MAX. - // We can't get that far anyway, because total_bytes_limit_ is guaranteed - // to be less than it. We need to keep track of the number of bytes - // we discarded, though, so that we can call input_->BackUp() to back - // up over them on destruction. - - // The following line is equivalent to: - // overflow_bytes_ = total_bytes_read_ + buffer_size - INT_MAX; - // except that it avoids overflows. Signed integer overflow has - // undefined results according to the C standard. - overflow_bytes_ = total_bytes_read_ - (INT_MAX - buffer_size); - buffer_end_ -= overflow_bytes_; - total_bytes_read_ = INT_MAX; - } - - RecomputeBufferLimits(); - return true; - } else { - buffer_ = NULL; - buffer_end_ = NULL; - return false; - } -} - -// CodedOutputStream ================================================= - -CodedOutputStream::CodedOutputStream(ZeroCopyOutputStream* output) - : output_(output), - buffer_(NULL), - buffer_size_(0), - total_bytes_(0), - had_error_(false) { - // Eagerly Refresh() so buffer space is immediately available. - Refresh(); - // The Refresh() may have failed. If the client doesn't write any data, - // though, don't consider this an error. If the client does write data, then - // another Refresh() will be attempted and it will set the error once again. - had_error_ = false; -} - -CodedOutputStream::~CodedOutputStream() { - if (buffer_size_ > 0) { - output_->BackUp(buffer_size_); - } -} - -bool CodedOutputStream::Skip(int count) { - if (count < 0) return false; - - while (count > buffer_size_) { - count -= buffer_size_; - if (!Refresh()) return false; - } - - Advance(count); - return true; -} - -bool CodedOutputStream::GetDirectBufferPointer(void** data, int* size) { - if (buffer_size_ == 0 && !Refresh()) return false; - - *data = buffer_; - *size = buffer_size_; - return true; -} - -void CodedOutputStream::WriteRaw(const void* data, int size) { - while (buffer_size_ < size) { - memcpy(buffer_, data, buffer_size_); - size -= buffer_size_; - data = reinterpret_cast(data) + buffer_size_; - if (!Refresh()) return; - } - - memcpy(buffer_, data, size); - Advance(size); -} - -uint8* CodedOutputStream::WriteRawToArray( - const void* data, int size, uint8* target) { - memcpy(target, data, size); - return target + size; -} - - -void CodedOutputStream::WriteLittleEndian32(uint32 value) { - uint8 bytes[sizeof(value)]; - - bool use_fast = buffer_size_ >= sizeof(value); - uint8* ptr = use_fast ? buffer_ : bytes; - - WriteLittleEndian32ToArray(value, ptr); - - if (use_fast) { - Advance(sizeof(value)); - } else { - WriteRaw(bytes, sizeof(value)); - } -} - -void CodedOutputStream::WriteLittleEndian64(uint64 value) { - uint8 bytes[sizeof(value)]; - - bool use_fast = buffer_size_ >= sizeof(value); - uint8* ptr = use_fast ? buffer_ : bytes; - - WriteLittleEndian64ToArray(value, ptr); - - if (use_fast) { - Advance(sizeof(value)); - } else { - WriteRaw(bytes, sizeof(value)); - } -} - -inline uint8* CodedOutputStream::WriteVarint32FallbackToArrayInline( - uint32 value, uint8* target) { - target[0] = static_cast(value | 0x80); - if (value >= (1 << 7)) { - target[1] = static_cast((value >> 7) | 0x80); - if (value >= (1 << 14)) { - target[2] = static_cast((value >> 14) | 0x80); - if (value >= (1 << 21)) { - target[3] = static_cast((value >> 21) | 0x80); - if (value >= (1 << 28)) { - target[4] = static_cast(value >> 28); - return target + 5; - } else { - target[3] &= 0x7F; - return target + 4; - } - } else { - target[2] &= 0x7F; - return target + 3; - } - } else { - target[1] &= 0x7F; - return target + 2; - } - } else { - target[0] &= 0x7F; - return target + 1; - } -} - -void CodedOutputStream::WriteVarint32(uint32 value) { - if (buffer_size_ >= kMaxVarint32Bytes) { - // Fast path: We have enough bytes left in the buffer to guarantee that - // this write won't cross the end, so we can skip the checks. - uint8* target = buffer_; - uint8* end = WriteVarint32FallbackToArrayInline(value, target); - int size = end - target; - Advance(size); - } else { - // Slow path: This write might cross the end of the buffer, so we - // compose the bytes first then use WriteRaw(). - uint8 bytes[kMaxVarint32Bytes]; - int size = 0; - while (value > 0x7F) { - bytes[size++] = (static_cast(value) & 0x7F) | 0x80; - value >>= 7; - } - bytes[size++] = static_cast(value) & 0x7F; - WriteRaw(bytes, size); - } -} - -uint8* CodedOutputStream::WriteVarint32FallbackToArray( - uint32 value, uint8* target) { - return WriteVarint32FallbackToArrayInline(value, target); -} - -inline uint8* CodedOutputStream::WriteVarint64ToArrayInline( - uint64 value, uint8* target) { - // Splitting into 32-bit pieces gives better performance on 32-bit - // processors. - uint32 part0 = static_cast(value ); - uint32 part1 = static_cast(value >> 28); - uint32 part2 = static_cast(value >> 56); - - int size; - - // Here we can't really optimize for small numbers, since the value is - // split into three parts. Cheking for numbers < 128, for instance, - // would require three comparisons, since you'd have to make sure part1 - // and part2 are zero. However, if the caller is using 64-bit integers, - // it is likely that they expect the numbers to often be very large, so - // we probably don't want to optimize for small numbers anyway. Thus, - // we end up with a hardcoded binary search tree... - if (part2 == 0) { - if (part1 == 0) { - if (part0 < (1 << 14)) { - if (part0 < (1 << 7)) { - size = 1; goto size1; - } else { - size = 2; goto size2; - } - } else { - if (part0 < (1 << 21)) { - size = 3; goto size3; - } else { - size = 4; goto size4; - } - } - } else { - if (part1 < (1 << 14)) { - if (part1 < (1 << 7)) { - size = 5; goto size5; - } else { - size = 6; goto size6; - } - } else { - if (part1 < (1 << 21)) { - size = 7; goto size7; - } else { - size = 8; goto size8; - } - } - } - } else { - if (part2 < (1 << 7)) { - size = 9; goto size9; - } else { - size = 10; goto size10; - } - } - - GOOGLE_LOG(FATAL) << "Can't get here."; - - size10: target[9] = static_cast((part2 >> 7) | 0x80); - size9 : target[8] = static_cast((part2 ) | 0x80); - size8 : target[7] = static_cast((part1 >> 21) | 0x80); - size7 : target[6] = static_cast((part1 >> 14) | 0x80); - size6 : target[5] = static_cast((part1 >> 7) | 0x80); - size5 : target[4] = static_cast((part1 ) | 0x80); - size4 : target[3] = static_cast((part0 >> 21) | 0x80); - size3 : target[2] = static_cast((part0 >> 14) | 0x80); - size2 : target[1] = static_cast((part0 >> 7) | 0x80); - size1 : target[0] = static_cast((part0 ) | 0x80); - - target[size-1] &= 0x7F; - return target + size; -} - -void CodedOutputStream::WriteVarint64(uint64 value) { - if (buffer_size_ >= kMaxVarintBytes) { - // Fast path: We have enough bytes left in the buffer to guarantee that - // this write won't cross the end, so we can skip the checks. - uint8* target = buffer_; - - uint8* end = WriteVarint64ToArrayInline(value, target); - int size = end - target; - Advance(size); - } else { - // Slow path: This write might cross the end of the buffer, so we - // compose the bytes first then use WriteRaw(). - uint8 bytes[kMaxVarintBytes]; - int size = 0; - while (value > 0x7F) { - bytes[size++] = (static_cast(value) & 0x7F) | 0x80; - value >>= 7; - } - bytes[size++] = static_cast(value) & 0x7F; - WriteRaw(bytes, size); - } -} - -uint8* CodedOutputStream::WriteVarint64ToArray( - uint64 value, uint8* target) { - return WriteVarint64ToArrayInline(value, target); -} - -bool CodedOutputStream::Refresh() { - void* void_buffer; - if (output_->Next(&void_buffer, &buffer_size_)) { - buffer_ = reinterpret_cast(void_buffer); - total_bytes_ += buffer_size_; - return true; - } else { - buffer_ = NULL; - buffer_size_ = 0; - had_error_ = true; - return false; - } -} - -int CodedOutputStream::VarintSize32Fallback(uint32 value) { - if (value < (1 << 7)) { - return 1; - } else if (value < (1 << 14)) { - return 2; - } else if (value < (1 << 21)) { - return 3; - } else if (value < (1 << 28)) { - return 4; - } else { - return 5; - } -} - -int CodedOutputStream::VarintSize64(uint64 value) { - if (value < (1ull << 35)) { - if (value < (1ull << 7)) { - return 1; - } else if (value < (1ull << 14)) { - return 2; - } else if (value < (1ull << 21)) { - return 3; - } else if (value < (1ull << 28)) { - return 4; - } else { - return 5; - } - } else { - if (value < (1ull << 42)) { - return 6; - } else if (value < (1ull << 49)) { - return 7; - } else if (value < (1ull << 56)) { - return 8; - } else if (value < (1ull << 63)) { - return 9; - } else { - return 10; - } - } -} - -} // namespace io -} // namespace protobuf -} // namespace google diff --git a/modules/dnn/3rdparty/protobuf/src/google/protobuf/io/coded_stream.h b/modules/dnn/3rdparty/protobuf/src/google/protobuf/io/coded_stream.h deleted file mode 100644 index 66cbee003..000000000 --- a/modules/dnn/3rdparty/protobuf/src/google/protobuf/io/coded_stream.h +++ /dev/null @@ -1,1136 +0,0 @@ -// Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// http://code.google.com/p/protobuf/ -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -// Author: kenton@google.com (Kenton Varda) -// Based on original Protocol Buffers design by -// Sanjay Ghemawat, Jeff Dean, and others. -// -// This file contains the CodedInputStream and CodedOutputStream classes, -// which wrap a ZeroCopyInputStream or ZeroCopyOutputStream, respectively, -// and allow you to read or write individual pieces of data in various -// formats. In particular, these implement the varint encoding for -// integers, a simple variable-length encoding in which smaller numbers -// take fewer bytes. -// -// Typically these classes will only be used internally by the protocol -// buffer library in order to encode and decode protocol buffers. Clients -// of the library only need to know about this class if they wish to write -// custom message parsing or serialization procedures. -// -// CodedOutputStream example: -// // Write some data to "myfile". First we write a 4-byte "magic number" -// // to identify the file type, then write a length-delimited string. The -// // string is composed of a varint giving the length followed by the raw -// // bytes. -// int fd = open("myfile", O_WRONLY); -// ZeroCopyOutputStream* raw_output = new FileOutputStream(fd); -// CodedOutputStream* coded_output = new CodedOutputStream(raw_output); -// -// int magic_number = 1234; -// char text[] = "Hello world!"; -// coded_output->WriteLittleEndian32(magic_number); -// coded_output->WriteVarint32(strlen(text)); -// coded_output->WriteRaw(text, strlen(text)); -// -// delete coded_output; -// delete raw_output; -// close(fd); -// -// CodedInputStream example: -// // Read a file created by the above code. -// int fd = open("myfile", O_RDONLY); -// ZeroCopyInputStream* raw_input = new FileInputStream(fd); -// CodedInputStream coded_input = new CodedInputStream(raw_input); -// -// coded_input->ReadLittleEndian32(&magic_number); -// if (magic_number != 1234) { -// cerr << "File not in expected format." << endl; -// return; -// } -// -// uint32 size; -// coded_input->ReadVarint32(&size); -// -// char* text = new char[size + 1]; -// coded_input->ReadRaw(buffer, size); -// text[size] = '\0'; -// -// delete coded_input; -// delete raw_input; -// close(fd); -// -// cout << "Text is: " << text << endl; -// delete [] text; -// -// For those who are interested, varint encoding is defined as follows: -// -// The encoding operates on unsigned integers of up to 64 bits in length. -// Each byte of the encoded value has the format: -// * bits 0-6: Seven bits of the number being encoded. -// * bit 7: Zero if this is the last byte in the encoding (in which -// case all remaining bits of the number are zero) or 1 if -// more bytes follow. -// The first byte contains the least-significant 7 bits of the number, the -// second byte (if present) contains the next-least-significant 7 bits, -// and so on. So, the binary number 1011000101011 would be encoded in two -// bytes as "10101011 00101100". -// -// In theory, varint could be used to encode integers of any length. -// However, for practicality we set a limit at 64 bits. The maximum encoded -// length of a number is thus 10 bytes. - -#ifndef GOOGLE_PROTOBUF_IO_CODED_STREAM_H__ -#define GOOGLE_PROTOBUF_IO_CODED_STREAM_H__ - -#include -#ifdef _MSC_VER - #if defined(_M_IX86) && \ - !defined(PROTOBUF_DISABLE_LITTLE_ENDIAN_OPT_FOR_TEST) - #define PROTOBUF_LITTLE_ENDIAN 1 - #endif - #if _MSC_VER >= 1300 - // If MSVC has "/RTCc" set, it will complain about truncating casts at - // runtime. This file contains some intentional truncating casts. - #pragma runtime_checks("c", off) - #endif -#else - #include // __BYTE_ORDER - #if defined(__BYTE_ORDER) && __BYTE_ORDER == __LITTLE_ENDIAN && \ - !defined(PROTOBUF_DISABLE_LITTLE_ENDIAN_OPT_FOR_TEST) - #define PROTOBUF_LITTLE_ENDIAN 1 - #endif -#endif -#include - - -namespace google { -namespace protobuf { - -class DescriptorPool; -class MessageFactory; - -namespace io { - -// Defined in this file. -class CodedInputStream; -class CodedOutputStream; - -// Defined in other files. -class ZeroCopyInputStream; // zero_copy_stream.h -class ZeroCopyOutputStream; // zero_copy_stream.h - -// Class which reads and decodes binary data which is composed of varint- -// encoded integers and fixed-width pieces. Wraps a ZeroCopyInputStream. -// Most users will not need to deal with CodedInputStream. -// -// Most methods of CodedInputStream that return a bool return false if an -// underlying I/O error occurs or if the data is malformed. Once such a -// failure occurs, the CodedInputStream is broken and is no longer useful. -class LIBPROTOBUF_EXPORT CodedInputStream { - public: - // Create a CodedInputStream that reads from the given ZeroCopyInputStream. - explicit CodedInputStream(ZeroCopyInputStream* input); - - // Create a CodedInputStream that reads from the given flat array. This is - // faster than using an ArrayInputStream. PushLimit(size) is implied by - // this constructor. - explicit CodedInputStream(const uint8* buffer, int size); - - // Destroy the CodedInputStream and position the underlying - // ZeroCopyInputStream at the first unread byte. If an error occurred while - // reading (causing a method to return false), then the exact position of - // the input stream may be anywhere between the last value that was read - // successfully and the stream's byte limit. - ~CodedInputStream(); - - // Return true if this CodedInputStream reads from a flat array instead of - // a ZeroCopyInputStream. - inline bool IsFlat() const; - - // Skips a number of bytes. Returns false if an underlying read error - // occurs. - bool Skip(int count); - - // Sets *data to point directly at the unread part of the CodedInputStream's - // underlying buffer, and *size to the size of that buffer, but does not - // advance the stream's current position. This will always either produce - // a non-empty buffer or return false. If the caller consumes any of - // this data, it should then call Skip() to skip over the consumed bytes. - // This may be useful for implementing external fast parsing routines for - // types of data not covered by the CodedInputStream interface. - bool GetDirectBufferPointer(const void** data, int* size); - - // Like GetDirectBufferPointer, but this method is inlined, and does not - // attempt to Refresh() if the buffer is currently empty. - inline void GetDirectBufferPointerInline(const void** data, - int* size) GOOGLE_ATTRIBUTE_ALWAYS_INLINE; - - // Read raw bytes, copying them into the given buffer. - bool ReadRaw(void* buffer, int size); - - // Like ReadRaw, but reads into a string. - // - // Implementation Note: ReadString() grows the string gradually as it - // reads in the data, rather than allocating the entire requested size - // upfront. This prevents denial-of-service attacks in which a client - // could claim that a string is going to be MAX_INT bytes long in order to - // crash the server because it can't allocate this much space at once. - bool ReadString(string* buffer, int size); - // Like the above, with inlined optimizations. This should only be used - // by the protobuf implementation. - inline bool InternalReadStringInline(string* buffer, - int size) GOOGLE_ATTRIBUTE_ALWAYS_INLINE; - - - // Read a 32-bit little-endian integer. - bool ReadLittleEndian32(uint32* value); - // Read a 64-bit little-endian integer. - bool ReadLittleEndian64(uint64* value); - - // These methods read from an externally provided buffer. The caller is - // responsible for ensuring that the buffer has sufficient space. - // Read a 32-bit little-endian integer. - static const uint8* ReadLittleEndian32FromArray(const uint8* buffer, - uint32* value); - // Read a 64-bit little-endian integer. - static const uint8* ReadLittleEndian64FromArray(const uint8* buffer, - uint64* value); - - // Read an unsigned integer with Varint encoding, truncating to 32 bits. - // Reading a 32-bit value is equivalent to reading a 64-bit one and casting - // it to uint32, but may be more efficient. - bool ReadVarint32(uint32* value); - // Read an unsigned integer with Varint encoding. - bool ReadVarint64(uint64* value); - - // Read a tag. This calls ReadVarint32() and returns the result, or returns - // zero (which is not a valid tag) if ReadVarint32() fails. Also, it updates - // the last tag value, which can be checked with LastTagWas(). - // Always inline because this is only called in once place per parse loop - // but it is called for every iteration of said loop, so it should be fast. - // GCC doesn't want to inline this by default. - uint32 ReadTag() GOOGLE_ATTRIBUTE_ALWAYS_INLINE; - - // Usually returns true if calling ReadVarint32() now would produce the given - // value. Will always return false if ReadVarint32() would not return the - // given value. If ExpectTag() returns true, it also advances past - // the varint. For best performance, use a compile-time constant as the - // parameter. - // Always inline because this collapses to a small number of instructions - // when given a constant parameter, but GCC doesn't want to inline by default. - bool ExpectTag(uint32 expected) GOOGLE_ATTRIBUTE_ALWAYS_INLINE; - - // Like above, except this reads from the specified buffer. The caller is - // responsible for ensuring that the buffer is large enough to read a varint - // of the expected size. For best performance, use a compile-time constant as - // the expected tag parameter. - // - // Returns a pointer beyond the expected tag if it was found, or NULL if it - // was not. - static const uint8* ExpectTagFromArray( - const uint8* buffer, - uint32 expected) GOOGLE_ATTRIBUTE_ALWAYS_INLINE; - - // Usually returns true if no more bytes can be read. Always returns false - // if more bytes can be read. If ExpectAtEnd() returns true, a subsequent - // call to LastTagWas() will act as if ReadTag() had been called and returned - // zero, and ConsumedEntireMessage() will return true. - bool ExpectAtEnd(); - - // If the last call to ReadTag() returned the given value, returns true. - // Otherwise, returns false; - // - // This is needed because parsers for some types of embedded messages - // (with field type TYPE_GROUP) don't actually know that they've reached the - // end of a message until they see an ENDGROUP tag, which was actually part - // of the enclosing message. The enclosing message would like to check that - // tag to make sure it had the right number, so it calls LastTagWas() on - // return from the embedded parser to check. - bool LastTagWas(uint32 expected); - - // When parsing message (but NOT a group), this method must be called - // immediately after MergeFromCodedStream() returns (if it returns true) - // to further verify that the message ended in a legitimate way. For - // example, this verifies that parsing did not end on an end-group tag. - // It also checks for some cases where, due to optimizations, - // MergeFromCodedStream() can incorrectly return true. - bool ConsumedEntireMessage(); - - // Limits ---------------------------------------------------------- - // Limits are used when parsing length-delimited embedded messages. - // After the message's length is read, PushLimit() is used to prevent - // the CodedInputStream from reading beyond that length. Once the - // embedded message has been parsed, PopLimit() is called to undo the - // limit. - - // Opaque type used with PushLimit() and PopLimit(). Do not modify - // values of this type yourself. The only reason that this isn't a - // struct with private internals is for efficiency. - typedef int Limit; - - // Places a limit on the number of bytes that the stream may read, - // starting from the current position. Once the stream hits this limit, - // it will act like the end of the input has been reached until PopLimit() - // is called. - // - // As the names imply, the stream conceptually has a stack of limits. The - // shortest limit on the stack is always enforced, even if it is not the - // top limit. - // - // The value returned by PushLimit() is opaque to the caller, and must - // be passed unchanged to the corresponding call to PopLimit(). - Limit PushLimit(int byte_limit); - - // Pops the last limit pushed by PushLimit(). The input must be the value - // returned by that call to PushLimit(). - void PopLimit(Limit limit); - - // Returns the number of bytes left until the nearest limit on the - // stack is hit, or -1 if no limits are in place. - int BytesUntilLimit() const; - - // Returns current position relative to the beginning of the input stream. - int CurrentPosition() const; - - // Total Bytes Limit ----------------------------------------------- - // To prevent malicious users from sending excessively large messages - // and causing integer overflows or memory exhaustion, CodedInputStream - // imposes a hard limit on the total number of bytes it will read. - - // Sets the maximum number of bytes that this CodedInputStream will read - // before refusing to continue. To prevent integer overflows in the - // protocol buffers implementation, as well as to prevent servers from - // allocating enormous amounts of memory to hold parsed messages, the - // maximum message length should be limited to the shortest length that - // will not harm usability. The theoretical shortest message that could - // cause integer overflows is 512MB. The default limit is 64MB. Apps - // should set shorter limits if possible. If warning_threshold is not -1, - // a warning will be printed to stderr after warning_threshold bytes are - // read. For backwards compatibility all negative values get squached to -1, - // as other negative values might have special internal meanings. - // An error will always be printed to stderr if the limit is reached. - // - // This is unrelated to PushLimit()/PopLimit(). - // - // Hint: If you are reading this because your program is printing a - // warning about dangerously large protocol messages, you may be - // confused about what to do next. The best option is to change your - // design such that excessively large messages are not necessary. - // For example, try to design file formats to consist of many small - // messages rather than a single large one. If this is infeasible, - // you will need to increase the limit. Chances are, though, that - // your code never constructs a CodedInputStream on which the limit - // can be set. You probably parse messages by calling things like - // Message::ParseFromString(). In this case, you will need to change - // your code to instead construct some sort of ZeroCopyInputStream - // (e.g. an ArrayInputStream), construct a CodedInputStream around - // that, then call Message::ParseFromCodedStream() instead. Then - // you can adjust the limit. Yes, it's more work, but you're doing - // something unusual. - void SetTotalBytesLimit(int total_bytes_limit, int warning_threshold); - - // Recursion Limit ------------------------------------------------- - // To prevent corrupt or malicious messages from causing stack overflows, - // we must keep track of the depth of recursion when parsing embedded - // messages and groups. CodedInputStream keeps track of this because it - // is the only object that is passed down the stack during parsing. - - // Sets the maximum recursion depth. The default is 100. - void SetRecursionLimit(int limit); - - - // Increments the current recursion depth. Returns true if the depth is - // under the limit, false if it has gone over. - bool IncrementRecursionDepth(); - - // Decrements the recursion depth. - void DecrementRecursionDepth(); - - // Extension Registry ---------------------------------------------- - // ADVANCED USAGE: 99.9% of people can ignore this section. - // - // By default, when parsing extensions, the parser looks for extension - // definitions in the pool which owns the outer message's Descriptor. - // However, you may call SetExtensionRegistry() to provide an alternative - // pool instead. This makes it possible, for example, to parse a message - // using a generated class, but represent some extensions using - // DynamicMessage. - - // Set the pool used to look up extensions. Most users do not need to call - // this as the correct pool will be chosen automatically. - // - // WARNING: It is very easy to misuse this. Carefully read the requirements - // below. Do not use this unless you are sure you need it. Almost no one - // does. - // - // Let's say you are parsing a message into message object m, and you want - // to take advantage of SetExtensionRegistry(). You must follow these - // requirements: - // - // The given DescriptorPool must contain m->GetDescriptor(). It is not - // sufficient for it to simply contain a descriptor that has the same name - // and content -- it must be the *exact object*. In other words: - // assert(pool->FindMessageTypeByName(m->GetDescriptor()->full_name()) == - // m->GetDescriptor()); - // There are two ways to satisfy this requirement: - // 1) Use m->GetDescriptor()->pool() as the pool. This is generally useless - // because this is the pool that would be used anyway if you didn't call - // SetExtensionRegistry() at all. - // 2) Use a DescriptorPool which has m->GetDescriptor()->pool() as an - // "underlay". Read the documentation for DescriptorPool for more - // information about underlays. - // - // You must also provide a MessageFactory. This factory will be used to - // construct Message objects representing extensions. The factory's - // GetPrototype() MUST return non-NULL for any Descriptor which can be found - // through the provided pool. - // - // If the provided factory might return instances of protocol-compiler- - // generated (i.e. compiled-in) types, or if the outer message object m is - // a generated type, then the given factory MUST have this property: If - // GetPrototype() is given a Descriptor which resides in - // DescriptorPool::generated_pool(), the factory MUST return the same - // prototype which MessageFactory::generated_factory() would return. That - // is, given a descriptor for a generated type, the factory must return an - // instance of the generated class (NOT DynamicMessage). However, when - // given a descriptor for a type that is NOT in generated_pool, the factory - // is free to return any implementation. - // - // The reason for this requirement is that generated sub-objects may be - // accessed via the standard (non-reflection) extension accessor methods, - // and these methods will down-cast the object to the generated class type. - // If the object is not actually of that type, the results would be undefined. - // On the other hand, if an extension is not compiled in, then there is no - // way the code could end up accessing it via the standard accessors -- the - // only way to access the extension is via reflection. When using reflection, - // DynamicMessage and generated messages are indistinguishable, so it's fine - // if these objects are represented using DynamicMessage. - // - // Using DynamicMessageFactory on which you have called - // SetDelegateToGeneratedFactory(true) should be sufficient to satisfy the - // above requirement. - // - // If either pool or factory is NULL, both must be NULL. - // - // Note that this feature is ignored when parsing "lite" messages as they do - // not have descriptors. - void SetExtensionRegistry(const DescriptorPool* pool, - MessageFactory* factory); - - // Get the DescriptorPool set via SetExtensionRegistry(), or NULL if no pool - // has been provided. - const DescriptorPool* GetExtensionPool(); - - // Get the MessageFactory set via SetExtensionRegistry(), or NULL if no - // factory has been provided. - MessageFactory* GetExtensionFactory(); - - private: - GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(CodedInputStream); - - ZeroCopyInputStream* input_; - const uint8* buffer_; - const uint8* buffer_end_; // pointer to the end of the buffer. - int total_bytes_read_; // total bytes read from input_, including - // the current buffer - - // If total_bytes_read_ surpasses INT_MAX, we record the extra bytes here - // so that we can BackUp() on destruction. - int overflow_bytes_; - - // LastTagWas() stuff. - uint32 last_tag_; // result of last ReadTag(). - - // This is set true by ReadTag{Fallback/Slow}() if it is called when exactly - // at EOF, or by ExpectAtEnd() when it returns true. This happens when we - // reach the end of a message and attempt to read another tag. - bool legitimate_message_end_; - - // See EnableAliasing(). - bool aliasing_enabled_; - - // Limits - Limit current_limit_; // if position = -1, no limit is applied - - // For simplicity, if the current buffer crosses a limit (either a normal - // limit created by PushLimit() or the total bytes limit), buffer_size_ - // only tracks the number of bytes before that limit. This field - // contains the number of bytes after it. Note that this implies that if - // buffer_size_ == 0 and buffer_size_after_limit_ > 0, we know we've - // hit a limit. However, if both are zero, it doesn't necessarily mean - // we aren't at a limit -- the buffer may have ended exactly at the limit. - int buffer_size_after_limit_; - - // Maximum number of bytes to read, period. This is unrelated to - // current_limit_. Set using SetTotalBytesLimit(). - int total_bytes_limit_; - - // If positive/0: Limit for bytes read after which a warning due to size - // should be logged. - // If -1: Printing of warning disabled. Can be set by client. - // If -2: Internal: Limit has been reached, print full size when destructing. - int total_bytes_warning_threshold_; - - // Current recursion depth, controlled by IncrementRecursionDepth() and - // DecrementRecursionDepth(). - int recursion_depth_; - // Recursion depth limit, set by SetRecursionLimit(). - int recursion_limit_; - - // See SetExtensionRegistry(). - const DescriptorPool* extension_pool_; - MessageFactory* extension_factory_; - - // Private member functions. - - // Advance the buffer by a given number of bytes. - void Advance(int amount); - - // Back up input_ to the current buffer position. - void BackUpInputToCurrentPosition(); - - // Recomputes the value of buffer_size_after_limit_. Must be called after - // current_limit_ or total_bytes_limit_ changes. - void RecomputeBufferLimits(); - - // Writes an error message saying that we hit total_bytes_limit_. - void PrintTotalBytesLimitError(); - - // Called when the buffer runs out to request more data. Implies an - // Advance(BufferSize()). - bool Refresh(); - - // When parsing varints, we optimize for the common case of small values, and - // then optimize for the case when the varint fits within the current buffer - // piece. The Fallback method is used when we can't use the one-byte - // optimization. The Slow method is yet another fallback when the buffer is - // not large enough. Making the slow path out-of-line speeds up the common - // case by 10-15%. The slow path is fairly uncommon: it only triggers when a - // message crosses multiple buffers. - bool ReadVarint32Fallback(uint32* value); - bool ReadVarint64Fallback(uint64* value); - bool ReadVarint32Slow(uint32* value); - bool ReadVarint64Slow(uint64* value); - bool ReadLittleEndian32Fallback(uint32* value); - bool ReadLittleEndian64Fallback(uint64* value); - // Fallback/slow methods for reading tags. These do not update last_tag_, - // but will set legitimate_message_end_ if we are at the end of the input - // stream. - uint32 ReadTagFallback(); - uint32 ReadTagSlow(); - bool ReadStringFallback(string* buffer, int size); - - // Return the size of the buffer. - int BufferSize() const; - - static const int kDefaultTotalBytesLimit = 64 << 20; // 64MB - - static const int kDefaultTotalBytesWarningThreshold = 32 << 20; // 32MB - - static int default_recursion_limit_; // 100 by default. -}; - -// Class which encodes and writes binary data which is composed of varint- -// encoded integers and fixed-width pieces. Wraps a ZeroCopyOutputStream. -// Most users will not need to deal with CodedOutputStream. -// -// Most methods of CodedOutputStream which return a bool return false if an -// underlying I/O error occurs. Once such a failure occurs, the -// CodedOutputStream is broken and is no longer useful. The Write* methods do -// not return the stream status, but will invalidate the stream if an error -// occurs. The client can probe HadError() to determine the status. -// -// Note that every method of CodedOutputStream which writes some data has -// a corresponding static "ToArray" version. These versions write directly -// to the provided buffer, returning a pointer past the last written byte. -// They require that the buffer has sufficient capacity for the encoded data. -// This allows an optimization where we check if an output stream has enough -// space for an entire message before we start writing and, if there is, we -// call only the ToArray methods to avoid doing bound checks for each -// individual value. -// i.e., in the example above: -// -// CodedOutputStream coded_output = new CodedOutputStream(raw_output); -// int magic_number = 1234; -// char text[] = "Hello world!"; -// -// int coded_size = sizeof(magic_number) + -// CodedOutputStream::VarintSize32(strlen(text)) + -// strlen(text); -// -// uint8* buffer = -// coded_output->GetDirectBufferForNBytesAndAdvance(coded_size); -// if (buffer != NULL) { -// // The output stream has enough space in the buffer: write directly to -// // the array. -// buffer = CodedOutputStream::WriteLittleEndian32ToArray(magic_number, -// buffer); -// buffer = CodedOutputStream::WriteVarint32ToArray(strlen(text), buffer); -// buffer = CodedOutputStream::WriteRawToArray(text, strlen(text), buffer); -// } else { -// // Make bound-checked writes, which will ask the underlying stream for -// // more space as needed. -// coded_output->WriteLittleEndian32(magic_number); -// coded_output->WriteVarint32(strlen(text)); -// coded_output->WriteRaw(text, strlen(text)); -// } -// -// delete coded_output; -class LIBPROTOBUF_EXPORT CodedOutputStream { - public: - // Create an CodedOutputStream that writes to the given ZeroCopyOutputStream. - explicit CodedOutputStream(ZeroCopyOutputStream* output); - - // Destroy the CodedOutputStream and position the underlying - // ZeroCopyOutputStream immediately after the last byte written. - ~CodedOutputStream(); - - // Skips a number of bytes, leaving the bytes unmodified in the underlying - // buffer. Returns false if an underlying write error occurs. This is - // mainly useful with GetDirectBufferPointer(). - bool Skip(int count); - - // Sets *data to point directly at the unwritten part of the - // CodedOutputStream's underlying buffer, and *size to the size of that - // buffer, but does not advance the stream's current position. This will - // always either produce a non-empty buffer or return false. If the caller - // writes any data to this buffer, it should then call Skip() to skip over - // the consumed bytes. This may be useful for implementing external fast - // serialization routines for types of data not covered by the - // CodedOutputStream interface. - bool GetDirectBufferPointer(void** data, int* size); - - // If there are at least "size" bytes available in the current buffer, - // returns a pointer directly into the buffer and advances over these bytes. - // The caller may then write directly into this buffer (e.g. using the - // *ToArray static methods) rather than go through CodedOutputStream. If - // there are not enough bytes available, returns NULL. The return pointer is - // invalidated as soon as any other non-const method of CodedOutputStream - // is called. - inline uint8* GetDirectBufferForNBytesAndAdvance(int size); - - // Write raw bytes, copying them from the given buffer. - void WriteRaw(const void* buffer, int size); - // Like WriteRaw() but writing directly to the target array. - // This is _not_ inlined, as the compiler often optimizes memcpy into inline - // copy loops. Since this gets called by every field with string or bytes - // type, inlining may lead to a significant amount of code bloat, with only a - // minor performance gain. - static uint8* WriteRawToArray(const void* buffer, int size, uint8* target); - - // Equivalent to WriteRaw(str.data(), str.size()). - void WriteString(const string& str); - // Like WriteString() but writing directly to the target array. - static uint8* WriteStringToArray(const string& str, uint8* target); - - - // Write a 32-bit little-endian integer. - void WriteLittleEndian32(uint32 value); - // Like WriteLittleEndian32() but writing directly to the target array. - static uint8* WriteLittleEndian32ToArray(uint32 value, uint8* target); - // Write a 64-bit little-endian integer. - void WriteLittleEndian64(uint64 value); - // Like WriteLittleEndian64() but writing directly to the target array. - static uint8* WriteLittleEndian64ToArray(uint64 value, uint8* target); - - // Write an unsigned integer with Varint encoding. Writing a 32-bit value - // is equivalent to casting it to uint64 and writing it as a 64-bit value, - // but may be more efficient. - void WriteVarint32(uint32 value); - // Like WriteVarint32() but writing directly to the target array. - static uint8* WriteVarint32ToArray(uint32 value, uint8* target); - // Write an unsigned integer with Varint encoding. - void WriteVarint64(uint64 value); - // Like WriteVarint64() but writing directly to the target array. - static uint8* WriteVarint64ToArray(uint64 value, uint8* target); - - // Equivalent to WriteVarint32() except when the value is negative, - // in which case it must be sign-extended to a full 10 bytes. - void WriteVarint32SignExtended(int32 value); - // Like WriteVarint32SignExtended() but writing directly to the target array. - static uint8* WriteVarint32SignExtendedToArray(int32 value, uint8* target); - - // This is identical to WriteVarint32(), but optimized for writing tags. - // In particular, if the input is a compile-time constant, this method - // compiles down to a couple instructions. - // Always inline because otherwise the aformentioned optimization can't work, - // but GCC by default doesn't want to inline this. - void WriteTag(uint32 value); - // Like WriteTag() but writing directly to the target array. - static uint8* WriteTagToArray( - uint32 value, uint8* target) GOOGLE_ATTRIBUTE_ALWAYS_INLINE; - - // Returns the number of bytes needed to encode the given value as a varint. - static int VarintSize32(uint32 value); - // Returns the number of bytes needed to encode the given value as a varint. - static int VarintSize64(uint64 value); - - // If negative, 10 bytes. Otheriwse, same as VarintSize32(). - static int VarintSize32SignExtended(int32 value); - - // Compile-time equivalent of VarintSize32(). - template - struct StaticVarintSize32 { - static const int value = - (Value < (1 << 7)) - ? 1 - : (Value < (1 << 14)) - ? 2 - : (Value < (1 << 21)) - ? 3 - : (Value < (1 << 28)) - ? 4 - : 5; - }; - - // Returns the total number of bytes written since this object was created. - inline int ByteCount() const; - - // Returns true if there was an underlying I/O error since this object was - // created. - bool HadError() const { return had_error_; } - - private: - GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(CodedOutputStream); - - ZeroCopyOutputStream* output_; - uint8* buffer_; - int buffer_size_; - int total_bytes_; // Sum of sizes of all buffers seen so far. - bool had_error_; // Whether an error occurred during output. - - // Advance the buffer by a given number of bytes. - void Advance(int amount); - - // Called when the buffer runs out to request more data. Implies an - // Advance(buffer_size_). - bool Refresh(); - - static uint8* WriteVarint32FallbackToArray(uint32 value, uint8* target); - - // Always-inlined versions of WriteVarint* functions so that code can be - // reused, while still controlling size. For instance, WriteVarint32ToArray() - // should not directly call this: since it is inlined itself, doing so - // would greatly increase the size of generated code. Instead, it should call - // WriteVarint32FallbackToArray. Meanwhile, WriteVarint32() is already - // out-of-line, so it should just invoke this directly to avoid any extra - // function call overhead. - static uint8* WriteVarint32FallbackToArrayInline( - uint32 value, uint8* target) GOOGLE_ATTRIBUTE_ALWAYS_INLINE; - static uint8* WriteVarint64ToArrayInline( - uint64 value, uint8* target) GOOGLE_ATTRIBUTE_ALWAYS_INLINE; - - static int VarintSize32Fallback(uint32 value); -}; - -// inline methods ==================================================== -// The vast majority of varints are only one byte. These inline -// methods optimize for that case. - -inline bool CodedInputStream::ReadVarint32(uint32* value) { - if (GOOGLE_PREDICT_TRUE(buffer_ < buffer_end_) && *buffer_ < 0x80) { - *value = *buffer_; - Advance(1); - return true; - } else { - return ReadVarint32Fallback(value); - } -} - -inline bool CodedInputStream::ReadVarint64(uint64* value) { - if (GOOGLE_PREDICT_TRUE(buffer_ < buffer_end_) && *buffer_ < 0x80) { - *value = *buffer_; - Advance(1); - return true; - } else { - return ReadVarint64Fallback(value); - } -} - -// static -inline const uint8* CodedInputStream::ReadLittleEndian32FromArray( - const uint8* buffer, - uint32* value) { -#if defined(PROTOBUF_LITTLE_ENDIAN) - memcpy(value, buffer, sizeof(*value)); - return buffer + sizeof(*value); -#else - *value = (static_cast(buffer[0]) ) | - (static_cast(buffer[1]) << 8) | - (static_cast(buffer[2]) << 16) | - (static_cast(buffer[3]) << 24); - return buffer + sizeof(*value); -#endif -} -// static -inline const uint8* CodedInputStream::ReadLittleEndian64FromArray( - const uint8* buffer, - uint64* value) { -#if defined(PROTOBUF_LITTLE_ENDIAN) - memcpy(value, buffer, sizeof(*value)); - return buffer + sizeof(*value); -#else - uint32 part0 = (static_cast(buffer[0]) ) | - (static_cast(buffer[1]) << 8) | - (static_cast(buffer[2]) << 16) | - (static_cast(buffer[3]) << 24); - uint32 part1 = (static_cast(buffer[4]) ) | - (static_cast(buffer[5]) << 8) | - (static_cast(buffer[6]) << 16) | - (static_cast(buffer[7]) << 24); - *value = static_cast(part0) | - (static_cast(part1) << 32); - return buffer + sizeof(*value); -#endif -} - -inline bool CodedInputStream::ReadLittleEndian32(uint32* value) { -#if defined(PROTOBUF_LITTLE_ENDIAN) - if (GOOGLE_PREDICT_TRUE(BufferSize() >= static_cast(sizeof(*value)))) { - memcpy(value, buffer_, sizeof(*value)); - Advance(sizeof(*value)); - return true; - } else { - return ReadLittleEndian32Fallback(value); - } -#else - return ReadLittleEndian32Fallback(value); -#endif -} - -inline bool CodedInputStream::ReadLittleEndian64(uint64* value) { -#if defined(PROTOBUF_LITTLE_ENDIAN) - if (GOOGLE_PREDICT_TRUE(BufferSize() >= static_cast(sizeof(*value)))) { - memcpy(value, buffer_, sizeof(*value)); - Advance(sizeof(*value)); - return true; - } else { - return ReadLittleEndian64Fallback(value); - } -#else - return ReadLittleEndian64Fallback(value); -#endif -} - -inline uint32 CodedInputStream::ReadTag() { - if (GOOGLE_PREDICT_TRUE(buffer_ < buffer_end_) && buffer_[0] < 0x80) { - last_tag_ = buffer_[0]; - Advance(1); - return last_tag_; - } else { - last_tag_ = ReadTagFallback(); - return last_tag_; - } -} - -inline bool CodedInputStream::LastTagWas(uint32 expected) { - return last_tag_ == expected; -} - -inline bool CodedInputStream::ConsumedEntireMessage() { - return legitimate_message_end_; -} - -inline bool CodedInputStream::ExpectTag(uint32 expected) { - if (expected < (1 << 7)) { - if (GOOGLE_PREDICT_TRUE(buffer_ < buffer_end_) && buffer_[0] == expected) { - Advance(1); - return true; - } else { - return false; - } - } else if (expected < (1 << 14)) { - if (GOOGLE_PREDICT_TRUE(BufferSize() >= 2) && - buffer_[0] == static_cast(expected | 0x80) && - buffer_[1] == static_cast(expected >> 7)) { - Advance(2); - return true; - } else { - return false; - } - } else { - // Don't bother optimizing for larger values. - return false; - } -} - -inline const uint8* CodedInputStream::ExpectTagFromArray( - const uint8* buffer, uint32 expected) { - if (expected < (1 << 7)) { - if (buffer[0] == expected) { - return buffer + 1; - } - } else if (expected < (1 << 14)) { - if (buffer[0] == static_cast(expected | 0x80) && - buffer[1] == static_cast(expected >> 7)) { - return buffer + 2; - } - } - return NULL; -} - -inline void CodedInputStream::GetDirectBufferPointerInline(const void** data, - int* size) { - *data = buffer_; - *size = buffer_end_ - buffer_; -} - -inline bool CodedInputStream::ExpectAtEnd() { - // If we are at a limit we know no more bytes can be read. Otherwise, it's - // hard to say without calling Refresh(), and we'd rather not do that. - - if (buffer_ == buffer_end_ && - ((buffer_size_after_limit_ != 0) || - (total_bytes_read_ == current_limit_))) { - last_tag_ = 0; // Pretend we called ReadTag()... - legitimate_message_end_ = true; // ... and it hit EOF. - return true; - } else { - return false; - } -} - -inline int CodedInputStream::CurrentPosition() const { - return total_bytes_read_ - (BufferSize() + buffer_size_after_limit_); -} - -inline uint8* CodedOutputStream::GetDirectBufferForNBytesAndAdvance(int size) { - if (buffer_size_ < size) { - return NULL; - } else { - uint8* result = buffer_; - Advance(size); - return result; - } -} - -inline uint8* CodedOutputStream::WriteVarint32ToArray(uint32 value, - uint8* target) { - if (value < 0x80) { - *target = value; - return target + 1; - } else { - return WriteVarint32FallbackToArray(value, target); - } -} - -inline void CodedOutputStream::WriteVarint32SignExtended(int32 value) { - if (value < 0) { - WriteVarint64(static_cast(value)); - } else { - WriteVarint32(static_cast(value)); - } -} - -inline uint8* CodedOutputStream::WriteVarint32SignExtendedToArray( - int32 value, uint8* target) { - if (value < 0) { - return WriteVarint64ToArray(static_cast(value), target); - } else { - return WriteVarint32ToArray(static_cast(value), target); - } -} - -inline uint8* CodedOutputStream::WriteLittleEndian32ToArray(uint32 value, - uint8* target) { -#if defined(PROTOBUF_LITTLE_ENDIAN) - memcpy(target, &value, sizeof(value)); -#else - target[0] = static_cast(value); - target[1] = static_cast(value >> 8); - target[2] = static_cast(value >> 16); - target[3] = static_cast(value >> 24); -#endif - return target + sizeof(value); -} - -inline uint8* CodedOutputStream::WriteLittleEndian64ToArray(uint64 value, - uint8* target) { -#if defined(PROTOBUF_LITTLE_ENDIAN) - memcpy(target, &value, sizeof(value)); -#else - uint32 part0 = static_cast(value); - uint32 part1 = static_cast(value >> 32); - - target[0] = static_cast(part0); - target[1] = static_cast(part0 >> 8); - target[2] = static_cast(part0 >> 16); - target[3] = static_cast(part0 >> 24); - target[4] = static_cast(part1); - target[5] = static_cast(part1 >> 8); - target[6] = static_cast(part1 >> 16); - target[7] = static_cast(part1 >> 24); -#endif - return target + sizeof(value); -} - -inline void CodedOutputStream::WriteTag(uint32 value) { - WriteVarint32(value); -} - -inline uint8* CodedOutputStream::WriteTagToArray( - uint32 value, uint8* target) { - if (value < (1 << 7)) { - target[0] = value; - return target + 1; - } else if (value < (1 << 14)) { - target[0] = static_cast(value | 0x80); - target[1] = static_cast(value >> 7); - return target + 2; - } else { - return WriteVarint32FallbackToArray(value, target); - } -} - -inline int CodedOutputStream::VarintSize32(uint32 value) { - if (value < (1 << 7)) { - return 1; - } else { - return VarintSize32Fallback(value); - } -} - -inline int CodedOutputStream::VarintSize32SignExtended(int32 value) { - if (value < 0) { - return 10; // TODO(kenton): Make this a symbolic constant. - } else { - return VarintSize32(static_cast(value)); - } -} - -inline void CodedOutputStream::WriteString(const string& str) { - WriteRaw(str.data(), static_cast(str.size())); -} - -inline uint8* CodedOutputStream::WriteStringToArray( - const string& str, uint8* target) { - return WriteRawToArray(str.data(), static_cast(str.size()), target); -} - -inline int CodedOutputStream::ByteCount() const { - return total_bytes_ - buffer_size_; -} - -inline void CodedInputStream::Advance(int amount) { - buffer_ += amount; -} - -inline void CodedOutputStream::Advance(int amount) { - buffer_ += amount; - buffer_size_ -= amount; -} - -inline void CodedInputStream::SetRecursionLimit(int limit) { - recursion_limit_ = limit; -} - -inline bool CodedInputStream::IncrementRecursionDepth() { - ++recursion_depth_; - return recursion_depth_ <= recursion_limit_; -} - -inline void CodedInputStream::DecrementRecursionDepth() { - if (recursion_depth_ > 0) --recursion_depth_; -} - -inline void CodedInputStream::SetExtensionRegistry(const DescriptorPool* pool, - MessageFactory* factory) { - extension_pool_ = pool; - extension_factory_ = factory; -} - -inline const DescriptorPool* CodedInputStream::GetExtensionPool() { - return extension_pool_; -} - -inline MessageFactory* CodedInputStream::GetExtensionFactory() { - return extension_factory_; -} - -inline int CodedInputStream::BufferSize() const { - return buffer_end_ - buffer_; -} - -inline CodedInputStream::CodedInputStream(ZeroCopyInputStream* input) - : input_(input), - buffer_(NULL), - buffer_end_(NULL), - total_bytes_read_(0), - overflow_bytes_(0), - last_tag_(0), - legitimate_message_end_(false), - aliasing_enabled_(false), - current_limit_(kint32max), - buffer_size_after_limit_(0), - total_bytes_limit_(kDefaultTotalBytesLimit), - total_bytes_warning_threshold_(kDefaultTotalBytesWarningThreshold), - recursion_depth_(0), - recursion_limit_(default_recursion_limit_), - extension_pool_(NULL), - extension_factory_(NULL) { - // Eagerly Refresh() so buffer space is immediately available. - Refresh(); -} - -inline CodedInputStream::CodedInputStream(const uint8* buffer, int size) - : input_(NULL), - buffer_(buffer), - buffer_end_(buffer + size), - total_bytes_read_(size), - overflow_bytes_(0), - last_tag_(0), - legitimate_message_end_(false), - aliasing_enabled_(false), - current_limit_(size), - buffer_size_after_limit_(0), - total_bytes_limit_(kDefaultTotalBytesLimit), - total_bytes_warning_threshold_(kDefaultTotalBytesWarningThreshold), - recursion_depth_(0), - recursion_limit_(default_recursion_limit_), - extension_pool_(NULL), - extension_factory_(NULL) { - // Note that setting current_limit_ == size is important to prevent some - // code paths from trying to access input_ and segfaulting. -} - -inline bool CodedInputStream::IsFlat() const { - return input_ == NULL; -} - -} // namespace io -} // namespace protobuf - - -#if defined(_MSC_VER) && _MSC_VER >= 1300 - #pragma runtime_checks("c", restore) -#endif // _MSC_VER - -} // namespace google -#endif // GOOGLE_PROTOBUF_IO_CODED_STREAM_H__ diff --git a/modules/dnn/3rdparty/protobuf/src/google/protobuf/io/coded_stream_inl.h b/modules/dnn/3rdparty/protobuf/src/google/protobuf/io/coded_stream_inl.h deleted file mode 100644 index 144f44f06..000000000 --- a/modules/dnn/3rdparty/protobuf/src/google/protobuf/io/coded_stream_inl.h +++ /dev/null @@ -1,68 +0,0 @@ -// Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// http://code.google.com/p/protobuf/ -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -// Author: jasonh@google.com (Jason Hsueh) -// -// Implements methods of coded_stream.h that need to be inlined for performance -// reasons, but should not be defined in a public header. - -#ifndef GOOGLE_PROTOBUF_IO_CODED_STREAM_INL_H__ -#define GOOGLE_PROTOBUF_IO_CODED_STREAM_INL_H__ - -#include -#include -#include - -namespace google { -namespace protobuf { -namespace io { - -inline bool CodedInputStream::InternalReadStringInline(string* buffer, - int size) { - if (size < 0) return false; // security: size is often user-supplied - - if (BufferSize() >= size) { - STLStringResizeUninitialized(buffer, size); - // When buffer is empty, string_as_array(buffer) will return NULL but memcpy - // requires non-NULL pointers even when size is 0. Hench this check. - if (size > 0) { - memcpy(string_as_array(buffer), buffer_, size); - Advance(size); - } - return true; - } - - return ReadStringFallback(buffer, size); -} - -} // namespace io -} // namespace protobuf -} // namespace google -#endif // GOOGLE_PROTOBUF_IO_CODED_STREAM_INL_H__ diff --git a/modules/dnn/3rdparty/protobuf/src/google/protobuf/io/coded_stream_unittest.cc b/modules/dnn/3rdparty/protobuf/src/google/protobuf/io/coded_stream_unittest.cc deleted file mode 100644 index 2daab194c..000000000 --- a/modules/dnn/3rdparty/protobuf/src/google/protobuf/io/coded_stream_unittest.cc +++ /dev/null @@ -1,1191 +0,0 @@ -// Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// http://code.google.com/p/protobuf/ -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -// Author: kenton@google.com (Kenton Varda) -// Based on original Protocol Buffers design by -// Sanjay Ghemawat, Jeff Dean, and others. -// -// This file contains tests and benchmarks. - -#include - -#include - -#include - -#include -#include -#include -#include - - -// This declares an unsigned long long integer literal in a portable way. -// (The original macro is way too big and ruins my formatting.) -#undef ULL -#define ULL(x) GOOGLE_ULONGLONG(x) - -namespace google { -namespace protobuf { -namespace io { -namespace { - -// =================================================================== -// Data-Driven Test Infrastructure - -// TEST_1D and TEST_2D are macros I'd eventually like to see added to -// gTest. These macros can be used to declare tests which should be -// run multiple times, once for each item in some input array. TEST_1D -// tests all cases in a single input array. TEST_2D tests all -// combinations of cases from two arrays. The arrays must be statically -// defined such that the GOOGLE_ARRAYSIZE() macro works on them. Example: -// -// int kCases[] = {1, 2, 3, 4} -// TEST_1D(MyFixture, MyTest, kCases) { -// EXPECT_GT(kCases_case, 0); -// } -// -// This test iterates through the numbers 1, 2, 3, and 4 and tests that -// they are all grater than zero. In case of failure, the exact case -// which failed will be printed. The case type must be printable using -// ostream::operator<<. - -// TODO(kenton): gTest now supports "parameterized tests" which would be -// a better way to accomplish this. Rewrite when time permits. - -#define TEST_1D(FIXTURE, NAME, CASES) \ - class FIXTURE##_##NAME##_DD : public FIXTURE { \ - protected: \ - template \ - void DoSingleCase(const CaseType& CASES##_case); \ - }; \ - \ - TEST_F(FIXTURE##_##NAME##_DD, NAME) { \ - for (int i = 0; i < GOOGLE_ARRAYSIZE(CASES); i++) { \ - SCOPED_TRACE(testing::Message() \ - << #CASES " case #" << i << ": " << CASES[i]); \ - DoSingleCase(CASES[i]); \ - } \ - } \ - \ - template \ - void FIXTURE##_##NAME##_DD::DoSingleCase(const CaseType& CASES##_case) - -#define TEST_2D(FIXTURE, NAME, CASES1, CASES2) \ - class FIXTURE##_##NAME##_DD : public FIXTURE { \ - protected: \ - template \ - void DoSingleCase(const CaseType1& CASES1##_case, \ - const CaseType2& CASES2##_case); \ - }; \ - \ - TEST_F(FIXTURE##_##NAME##_DD, NAME) { \ - for (int i = 0; i < GOOGLE_ARRAYSIZE(CASES1); i++) { \ - for (int j = 0; j < GOOGLE_ARRAYSIZE(CASES2); j++) { \ - SCOPED_TRACE(testing::Message() \ - << #CASES1 " case #" << i << ": " << CASES1[i] << ", " \ - << #CASES2 " case #" << j << ": " << CASES2[j]); \ - DoSingleCase(CASES1[i], CASES2[j]); \ - } \ - } \ - } \ - \ - template \ - void FIXTURE##_##NAME##_DD::DoSingleCase(const CaseType1& CASES1##_case, \ - const CaseType2& CASES2##_case) - -// =================================================================== - -class CodedStreamTest : public testing::Test { - protected: - // Helper method used by tests for bytes warning. See implementation comment - // for further information. - static void SetupTotalBytesLimitWarningTest( - int total_bytes_limit, int warning_threshold, - vector* out_errors, vector* out_warnings); - - // Buffer used during most of the tests. This assumes tests run sequentially. - static const int kBufferSize = 1024 * 64; - static uint8 buffer_[kBufferSize]; -}; - -uint8 CodedStreamTest::buffer_[CodedStreamTest::kBufferSize]; - -// We test each operation over a variety of block sizes to insure that -// we test cases where reads or writes cross buffer boundaries, cases -// where they don't, and cases where there is so much buffer left that -// we can use special optimized paths that don't worry about bounds -// checks. -const int kBlockSizes[] = {1, 2, 3, 5, 7, 13, 32, 1024}; - -// ------------------------------------------------------------------- -// Varint tests. - -struct VarintCase { - uint8 bytes[10]; // Encoded bytes. - int size; // Encoded size, in bytes. - uint64 value; // Parsed value. -}; - -inline std::ostream& operator<<(std::ostream& os, const VarintCase& c) { - return os << c.value; -} - -VarintCase kVarintCases[] = { - // 32-bit values - {{0x00} , 1, 0}, - {{0x01} , 1, 1}, - {{0x7f} , 1, 127}, - {{0xa2, 0x74}, 2, (0x22 << 0) | (0x74 << 7)}, // 14882 - {{0xbe, 0xf7, 0x92, 0x84, 0x0b}, 5, // 2961488830 - (0x3e << 0) | (0x77 << 7) | (0x12 << 14) | (0x04 << 21) | - (ULL(0x0b) << 28)}, - - // 64-bit - {{0xbe, 0xf7, 0x92, 0x84, 0x1b}, 5, // 7256456126 - (0x3e << 0) | (0x77 << 7) | (0x12 << 14) | (0x04 << 21) | - (ULL(0x1b) << 28)}, - {{0x80, 0xe6, 0xeb, 0x9c, 0xc3, 0xc9, 0xa4, 0x49}, 8, // 41256202580718336 - (0x00 << 0) | (0x66 << 7) | (0x6b << 14) | (0x1c << 21) | - (ULL(0x43) << 28) | (ULL(0x49) << 35) | (ULL(0x24) << 42) | - (ULL(0x49) << 49)}, - // 11964378330978735131 - {{0x9b, 0xa8, 0xf9, 0xc2, 0xbb, 0xd6, 0x80, 0x85, 0xa6, 0x01}, 10, - (0x1b << 0) | (0x28 << 7) | (0x79 << 14) | (0x42 << 21) | - (ULL(0x3b) << 28) | (ULL(0x56) << 35) | (ULL(0x00) << 42) | - (ULL(0x05) << 49) | (ULL(0x26) << 56) | (ULL(0x01) << 63)}, -}; - -TEST_2D(CodedStreamTest, ReadVarint32, kVarintCases, kBlockSizes) { - memcpy(buffer_, kVarintCases_case.bytes, kVarintCases_case.size); - ArrayInputStream input(buffer_, sizeof(buffer_), kBlockSizes_case); - - { - CodedInputStream coded_input(&input); - - uint32 value; - EXPECT_TRUE(coded_input.ReadVarint32(&value)); - EXPECT_EQ(static_cast(kVarintCases_case.value), value); - } - - EXPECT_EQ(kVarintCases_case.size, input.ByteCount()); -} - -TEST_2D(CodedStreamTest, ReadTag, kVarintCases, kBlockSizes) { - memcpy(buffer_, kVarintCases_case.bytes, kVarintCases_case.size); - ArrayInputStream input(buffer_, sizeof(buffer_), kBlockSizes_case); - - { - CodedInputStream coded_input(&input); - - uint32 expected_value = static_cast(kVarintCases_case.value); - EXPECT_EQ(expected_value, coded_input.ReadTag()); - - EXPECT_TRUE(coded_input.LastTagWas(expected_value)); - EXPECT_FALSE(coded_input.LastTagWas(expected_value + 1)); - } - - EXPECT_EQ(kVarintCases_case.size, input.ByteCount()); -} - -// This is the regression test that verifies that there is no issues -// with the empty input buffers handling. -TEST_F(CodedStreamTest, EmptyInputBeforeEos) { - class In : public ZeroCopyInputStream { - public: - In() : count_(0) {} - private: - virtual bool Next(const void** data, int* size) { - *data = NULL; - *size = 0; - return count_++ < 2; - } - virtual void BackUp(int count) { - GOOGLE_LOG(FATAL) << "Tests never call this."; - } - virtual bool Skip(int count) { - GOOGLE_LOG(FATAL) << "Tests never call this."; - return false; - } - virtual int64 ByteCount() const { return 0; } - int count_; - } in; - CodedInputStream input(&in); - input.ReadTag(); - EXPECT_TRUE(input.ConsumedEntireMessage()); -} - -TEST_1D(CodedStreamTest, ExpectTag, kVarintCases) { - // Leave one byte at the beginning of the buffer so we can read it - // to force the first buffer to be loaded. - buffer_[0] = '\0'; - memcpy(buffer_ + 1, kVarintCases_case.bytes, kVarintCases_case.size); - ArrayInputStream input(buffer_, sizeof(buffer_)); - - { - CodedInputStream coded_input(&input); - - // Read one byte to force coded_input.Refill() to be called. Otherwise, - // ExpectTag() will return a false negative. - uint8 dummy; - coded_input.ReadRaw(&dummy, 1); - EXPECT_EQ((uint)'\0', (uint)dummy); - - uint32 expected_value = static_cast(kVarintCases_case.value); - - // ExpectTag() produces false negatives for large values. - if (kVarintCases_case.size <= 2) { - EXPECT_FALSE(coded_input.ExpectTag(expected_value + 1)); - EXPECT_TRUE(coded_input.ExpectTag(expected_value)); - } else { - EXPECT_FALSE(coded_input.ExpectTag(expected_value)); - } - } - - if (kVarintCases_case.size <= 2) { - EXPECT_EQ(kVarintCases_case.size + 1, input.ByteCount()); - } else { - EXPECT_EQ(1, input.ByteCount()); - } -} - -TEST_1D(CodedStreamTest, ExpectTagFromArray, kVarintCases) { - memcpy(buffer_, kVarintCases_case.bytes, kVarintCases_case.size); - - const uint32 expected_value = static_cast(kVarintCases_case.value); - - // If the expectation succeeds, it should return a pointer past the tag. - if (kVarintCases_case.size <= 2) { - EXPECT_TRUE(NULL == - CodedInputStream::ExpectTagFromArray(buffer_, - expected_value + 1)); - EXPECT_TRUE(buffer_ + kVarintCases_case.size == - CodedInputStream::ExpectTagFromArray(buffer_, expected_value)); - } else { - EXPECT_TRUE(NULL == - CodedInputStream::ExpectTagFromArray(buffer_, expected_value)); - } -} - -TEST_2D(CodedStreamTest, ReadVarint64, kVarintCases, kBlockSizes) { - memcpy(buffer_, kVarintCases_case.bytes, kVarintCases_case.size); - ArrayInputStream input(buffer_, sizeof(buffer_), kBlockSizes_case); - - { - CodedInputStream coded_input(&input); - - uint64 value; - EXPECT_TRUE(coded_input.ReadVarint64(&value)); - EXPECT_EQ(kVarintCases_case.value, value); - } - - EXPECT_EQ(kVarintCases_case.size, input.ByteCount()); -} - -TEST_2D(CodedStreamTest, WriteVarint32, kVarintCases, kBlockSizes) { - if (kVarintCases_case.value > ULL(0x00000000FFFFFFFF)) { - // Skip this test for the 64-bit values. - return; - } - - ArrayOutputStream output(buffer_, sizeof(buffer_), kBlockSizes_case); - - { - CodedOutputStream coded_output(&output); - - coded_output.WriteVarint32(static_cast(kVarintCases_case.value)); - EXPECT_FALSE(coded_output.HadError()); - - EXPECT_EQ(kVarintCases_case.size, coded_output.ByteCount()); - } - - EXPECT_EQ(kVarintCases_case.size, output.ByteCount()); - EXPECT_EQ(0, - memcmp(buffer_, kVarintCases_case.bytes, kVarintCases_case.size)); -} - -TEST_2D(CodedStreamTest, WriteVarint64, kVarintCases, kBlockSizes) { - ArrayOutputStream output(buffer_, sizeof(buffer_), kBlockSizes_case); - - { - CodedOutputStream coded_output(&output); - - coded_output.WriteVarint64(kVarintCases_case.value); - EXPECT_FALSE(coded_output.HadError()); - - EXPECT_EQ(kVarintCases_case.size, coded_output.ByteCount()); - } - - EXPECT_EQ(kVarintCases_case.size, output.ByteCount()); - EXPECT_EQ(0, - memcmp(buffer_, kVarintCases_case.bytes, kVarintCases_case.size)); -} - -// This test causes gcc 3.3.5 (and earlier?) to give the cryptic error: -// "sorry, unimplemented: `method_call_expr' not supported by dump_expr" -#if !defined(__GNUC__) || __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ > 3) - -int32 kSignExtendedVarintCases[] = { - 0, 1, -1, 1237894, -37895138 -}; - -TEST_2D(CodedStreamTest, WriteVarint32SignExtended, - kSignExtendedVarintCases, kBlockSizes) { - ArrayOutputStream output(buffer_, sizeof(buffer_), kBlockSizes_case); - - { - CodedOutputStream coded_output(&output); - - coded_output.WriteVarint32SignExtended(kSignExtendedVarintCases_case); - EXPECT_FALSE(coded_output.HadError()); - - if (kSignExtendedVarintCases_case < 0) { - EXPECT_EQ(10, coded_output.ByteCount()); - } else { - EXPECT_LE(coded_output.ByteCount(), 5); - } - } - - if (kSignExtendedVarintCases_case < 0) { - EXPECT_EQ(10, output.ByteCount()); - } else { - EXPECT_LE(output.ByteCount(), 5); - } - - // Read value back in as a varint64 and insure it matches. - ArrayInputStream input(buffer_, sizeof(buffer_)); - - { - CodedInputStream coded_input(&input); - - uint64 value; - EXPECT_TRUE(coded_input.ReadVarint64(&value)); - - EXPECT_EQ(kSignExtendedVarintCases_case, static_cast(value)); - } - - EXPECT_EQ(output.ByteCount(), input.ByteCount()); -} - -#endif - - -// ------------------------------------------------------------------- -// Varint failure test. - -struct VarintErrorCase { - uint8 bytes[12]; - int size; - bool can_parse; -}; - -inline std::ostream& operator<<(std::ostream& os, const VarintErrorCase& c) { - return os << "size " << c.size; -} - -const VarintErrorCase kVarintErrorCases[] = { - // Control case. (Insures that there isn't something else wrong that - // makes parsing always fail.) - {{0x00}, 1, true}, - - // No input data. - {{}, 0, false}, - - // Input ends unexpectedly. - {{0xf0, 0xab}, 2, false}, - - // Input ends unexpectedly after 32 bits. - {{0xf0, 0xab, 0xc9, 0x9a, 0xf8, 0xb2}, 6, false}, - - // Longer than 10 bytes. - {{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x01}, - 11, false}, -}; - -TEST_2D(CodedStreamTest, ReadVarint32Error, kVarintErrorCases, kBlockSizes) { - memcpy(buffer_, kVarintErrorCases_case.bytes, kVarintErrorCases_case.size); - ArrayInputStream input(buffer_, kVarintErrorCases_case.size, - kBlockSizes_case); - CodedInputStream coded_input(&input); - - uint32 value; - EXPECT_EQ(kVarintErrorCases_case.can_parse, coded_input.ReadVarint32(&value)); -} - -TEST_2D(CodedStreamTest, ReadVarint64Error, kVarintErrorCases, kBlockSizes) { - memcpy(buffer_, kVarintErrorCases_case.bytes, kVarintErrorCases_case.size); - ArrayInputStream input(buffer_, kVarintErrorCases_case.size, - kBlockSizes_case); - CodedInputStream coded_input(&input); - - uint64 value; - EXPECT_EQ(kVarintErrorCases_case.can_parse, coded_input.ReadVarint64(&value)); -} - -// ------------------------------------------------------------------- -// VarintSize - -struct VarintSizeCase { - uint64 value; - int size; -}; - -inline std::ostream& operator<<(std::ostream& os, const VarintSizeCase& c) { - return os << c.value; -} - -VarintSizeCase kVarintSizeCases[] = { - {0u, 1}, - {1u, 1}, - {127u, 1}, - {128u, 2}, - {758923u, 3}, - {4000000000u, 5}, - {ULL(41256202580718336), 8}, - {ULL(11964378330978735131), 10}, -}; - -TEST_1D(CodedStreamTest, VarintSize32, kVarintSizeCases) { - if (kVarintSizeCases_case.value > 0xffffffffu) { - // Skip 64-bit values. - return; - } - - EXPECT_EQ(kVarintSizeCases_case.size, - CodedOutputStream::VarintSize32( - static_cast(kVarintSizeCases_case.value))); -} - -TEST_1D(CodedStreamTest, VarintSize64, kVarintSizeCases) { - EXPECT_EQ(kVarintSizeCases_case.size, - CodedOutputStream::VarintSize64(kVarintSizeCases_case.value)); -} - -// ------------------------------------------------------------------- -// Fixed-size int tests - -struct Fixed32Case { - uint8 bytes[sizeof(uint32)]; // Encoded bytes. - uint32 value; // Parsed value. -}; - -struct Fixed64Case { - uint8 bytes[sizeof(uint64)]; // Encoded bytes. - uint64 value; // Parsed value. -}; - -inline std::ostream& operator<<(std::ostream& os, const Fixed32Case& c) { - return os << "0x" << hex << c.value << dec; -} - -inline std::ostream& operator<<(std::ostream& os, const Fixed64Case& c) { - return os << "0x" << hex << c.value << dec; -} - -Fixed32Case kFixed32Cases[] = { - {{0xef, 0xcd, 0xab, 0x90}, 0x90abcdefu}, - {{0x12, 0x34, 0x56, 0x78}, 0x78563412u}, -}; - -Fixed64Case kFixed64Cases[] = { - {{0xef, 0xcd, 0xab, 0x90, 0x12, 0x34, 0x56, 0x78}, ULL(0x7856341290abcdef)}, - {{0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88}, ULL(0x8877665544332211)}, -}; - -TEST_2D(CodedStreamTest, ReadLittleEndian32, kFixed32Cases, kBlockSizes) { - memcpy(buffer_, kFixed32Cases_case.bytes, sizeof(kFixed32Cases_case.bytes)); - ArrayInputStream input(buffer_, sizeof(buffer_), kBlockSizes_case); - - { - CodedInputStream coded_input(&input); - - uint32 value; - EXPECT_TRUE(coded_input.ReadLittleEndian32(&value)); - EXPECT_EQ(kFixed32Cases_case.value, value); - } - - EXPECT_EQ(sizeof(uint32), input.ByteCount()); -} - -TEST_2D(CodedStreamTest, ReadLittleEndian64, kFixed64Cases, kBlockSizes) { - memcpy(buffer_, kFixed64Cases_case.bytes, sizeof(kFixed64Cases_case.bytes)); - ArrayInputStream input(buffer_, sizeof(buffer_), kBlockSizes_case); - - { - CodedInputStream coded_input(&input); - - uint64 value; - EXPECT_TRUE(coded_input.ReadLittleEndian64(&value)); - EXPECT_EQ(kFixed64Cases_case.value, value); - } - - EXPECT_EQ(sizeof(uint64), input.ByteCount()); -} - -TEST_2D(CodedStreamTest, WriteLittleEndian32, kFixed32Cases, kBlockSizes) { - ArrayOutputStream output(buffer_, sizeof(buffer_), kBlockSizes_case); - - { - CodedOutputStream coded_output(&output); - - coded_output.WriteLittleEndian32(kFixed32Cases_case.value); - EXPECT_FALSE(coded_output.HadError()); - - EXPECT_EQ(sizeof(uint32), coded_output.ByteCount()); - } - - EXPECT_EQ(sizeof(uint32), output.ByteCount()); - EXPECT_EQ(0, memcmp(buffer_, kFixed32Cases_case.bytes, sizeof(uint32))); -} - -TEST_2D(CodedStreamTest, WriteLittleEndian64, kFixed64Cases, kBlockSizes) { - ArrayOutputStream output(buffer_, sizeof(buffer_), kBlockSizes_case); - - { - CodedOutputStream coded_output(&output); - - coded_output.WriteLittleEndian64(kFixed64Cases_case.value); - EXPECT_FALSE(coded_output.HadError()); - - EXPECT_EQ(sizeof(uint64), coded_output.ByteCount()); - } - - EXPECT_EQ(sizeof(uint64), output.ByteCount()); - EXPECT_EQ(0, memcmp(buffer_, kFixed64Cases_case.bytes, sizeof(uint64))); -} - -// Tests using the static methods to read fixed-size values from raw arrays. - -TEST_1D(CodedStreamTest, ReadLittleEndian32FromArray, kFixed32Cases) { - memcpy(buffer_, kFixed32Cases_case.bytes, sizeof(kFixed32Cases_case.bytes)); - - uint32 value; - const uint8* end = CodedInputStream::ReadLittleEndian32FromArray( - buffer_, &value); - EXPECT_EQ(kFixed32Cases_case.value, value); - EXPECT_TRUE(end == buffer_ + sizeof(value)); -} - -TEST_1D(CodedStreamTest, ReadLittleEndian64FromArray, kFixed64Cases) { - memcpy(buffer_, kFixed64Cases_case.bytes, sizeof(kFixed64Cases_case.bytes)); - - uint64 value; - const uint8* end = CodedInputStream::ReadLittleEndian64FromArray( - buffer_, &value); - EXPECT_EQ(kFixed64Cases_case.value, value); - EXPECT_TRUE(end == buffer_ + sizeof(value)); -} - -// ------------------------------------------------------------------- -// Raw reads and writes - -const char kRawBytes[] = "Some bytes which will be written and read raw."; - -TEST_1D(CodedStreamTest, ReadRaw, kBlockSizes) { - memcpy(buffer_, kRawBytes, sizeof(kRawBytes)); - ArrayInputStream input(buffer_, sizeof(buffer_), kBlockSizes_case); - char read_buffer[sizeof(kRawBytes)]; - - { - CodedInputStream coded_input(&input); - - EXPECT_TRUE(coded_input.ReadRaw(read_buffer, sizeof(kRawBytes))); - EXPECT_EQ(0, memcmp(kRawBytes, read_buffer, sizeof(kRawBytes))); - } - - EXPECT_EQ(sizeof(kRawBytes), input.ByteCount()); -} - -TEST_1D(CodedStreamTest, WriteRaw, kBlockSizes) { - ArrayOutputStream output(buffer_, sizeof(buffer_), kBlockSizes_case); - - { - CodedOutputStream coded_output(&output); - - coded_output.WriteRaw(kRawBytes, sizeof(kRawBytes)); - EXPECT_FALSE(coded_output.HadError()); - - EXPECT_EQ(sizeof(kRawBytes), coded_output.ByteCount()); - } - - EXPECT_EQ(sizeof(kRawBytes), output.ByteCount()); - EXPECT_EQ(0, memcmp(buffer_, kRawBytes, sizeof(kRawBytes))); -} - -TEST_1D(CodedStreamTest, ReadString, kBlockSizes) { - memcpy(buffer_, kRawBytes, sizeof(kRawBytes)); - ArrayInputStream input(buffer_, sizeof(buffer_), kBlockSizes_case); - - { - CodedInputStream coded_input(&input); - - string str; - EXPECT_TRUE(coded_input.ReadString(&str, strlen(kRawBytes))); - EXPECT_EQ(kRawBytes, str); - } - - EXPECT_EQ(strlen(kRawBytes), input.ByteCount()); -} - -// Check to make sure ReadString doesn't crash on impossibly large strings. -TEST_1D(CodedStreamTest, ReadStringImpossiblyLarge, kBlockSizes) { - ArrayInputStream input(buffer_, sizeof(buffer_), kBlockSizes_case); - - { - CodedInputStream coded_input(&input); - - string str; - // Try to read a gigabyte. - EXPECT_FALSE(coded_input.ReadString(&str, 1 << 30)); - } -} - -TEST_F(CodedStreamTest, ReadStringImpossiblyLargeFromStringOnStack) { - // Same test as above, except directly use a buffer. This used to cause - // crashes while the above did not. - uint8 buffer[8]; - CodedInputStream coded_input(buffer, 8); - string str; - EXPECT_FALSE(coded_input.ReadString(&str, 1 << 30)); -} - -TEST_F(CodedStreamTest, ReadStringImpossiblyLargeFromStringOnHeap) { - scoped_array buffer(new uint8[8]); - CodedInputStream coded_input(buffer.get(), 8); - string str; - EXPECT_FALSE(coded_input.ReadString(&str, 1 << 30)); -} - - -// ------------------------------------------------------------------- -// Skip - -const char kSkipTestBytes[] = - ""; -const char kSkipOutputTestBytes[] = - "---------------------------------"; - -TEST_1D(CodedStreamTest, SkipInput, kBlockSizes) { - memcpy(buffer_, kSkipTestBytes, sizeof(kSkipTestBytes)); - ArrayInputStream input(buffer_, sizeof(buffer_), kBlockSizes_case); - - { - CodedInputStream coded_input(&input); - - string str; - EXPECT_TRUE(coded_input.ReadString(&str, strlen(""))); - EXPECT_EQ("", str); - EXPECT_TRUE(coded_input.Skip(strlen(""))); - EXPECT_TRUE(coded_input.ReadString(&str, strlen(""))); - EXPECT_EQ("", str); - } - - EXPECT_EQ(strlen(kSkipTestBytes), input.ByteCount()); -} - -// ------------------------------------------------------------------- -// GetDirectBufferPointer - -TEST_F(CodedStreamTest, GetDirectBufferPointerInput) { - ArrayInputStream input(buffer_, sizeof(buffer_), 8); - CodedInputStream coded_input(&input); - - const void* ptr; - int size; - - EXPECT_TRUE(coded_input.GetDirectBufferPointer(&ptr, &size)); - EXPECT_EQ(buffer_, ptr); - EXPECT_EQ(8, size); - - // Peeking again should return the same pointer. - EXPECT_TRUE(coded_input.GetDirectBufferPointer(&ptr, &size)); - EXPECT_EQ(buffer_, ptr); - EXPECT_EQ(8, size); - - // Skip forward in the same buffer then peek again. - EXPECT_TRUE(coded_input.Skip(3)); - EXPECT_TRUE(coded_input.GetDirectBufferPointer(&ptr, &size)); - EXPECT_EQ(buffer_ + 3, ptr); - EXPECT_EQ(5, size); - - // Skip to end of buffer and peek -- should get next buffer. - EXPECT_TRUE(coded_input.Skip(5)); - EXPECT_TRUE(coded_input.GetDirectBufferPointer(&ptr, &size)); - EXPECT_EQ(buffer_ + 8, ptr); - EXPECT_EQ(8, size); -} - -TEST_F(CodedStreamTest, GetDirectBufferPointerInlineInput) { - ArrayInputStream input(buffer_, sizeof(buffer_), 8); - CodedInputStream coded_input(&input); - - const void* ptr; - int size; - - coded_input.GetDirectBufferPointerInline(&ptr, &size); - EXPECT_EQ(buffer_, ptr); - EXPECT_EQ(8, size); - - // Peeking again should return the same pointer. - coded_input.GetDirectBufferPointerInline(&ptr, &size); - EXPECT_EQ(buffer_, ptr); - EXPECT_EQ(8, size); - - // Skip forward in the same buffer then peek again. - EXPECT_TRUE(coded_input.Skip(3)); - coded_input.GetDirectBufferPointerInline(&ptr, &size); - EXPECT_EQ(buffer_ + 3, ptr); - EXPECT_EQ(5, size); - - // Skip to end of buffer and peek -- should return false and provide an empty - // buffer. It does not try to Refresh(). - EXPECT_TRUE(coded_input.Skip(5)); - coded_input.GetDirectBufferPointerInline(&ptr, &size); - EXPECT_EQ(buffer_ + 8, ptr); - EXPECT_EQ(0, size); -} - -TEST_F(CodedStreamTest, GetDirectBufferPointerOutput) { - ArrayOutputStream output(buffer_, sizeof(buffer_), 8); - CodedOutputStream coded_output(&output); - - void* ptr; - int size; - - EXPECT_TRUE(coded_output.GetDirectBufferPointer(&ptr, &size)); - EXPECT_EQ(buffer_, ptr); - EXPECT_EQ(8, size); - - // Peeking again should return the same pointer. - EXPECT_TRUE(coded_output.GetDirectBufferPointer(&ptr, &size)); - EXPECT_EQ(buffer_, ptr); - EXPECT_EQ(8, size); - - // Skip forward in the same buffer then peek again. - EXPECT_TRUE(coded_output.Skip(3)); - EXPECT_TRUE(coded_output.GetDirectBufferPointer(&ptr, &size)); - EXPECT_EQ(buffer_ + 3, ptr); - EXPECT_EQ(5, size); - - // Skip to end of buffer and peek -- should get next buffer. - EXPECT_TRUE(coded_output.Skip(5)); - EXPECT_TRUE(coded_output.GetDirectBufferPointer(&ptr, &size)); - EXPECT_EQ(buffer_ + 8, ptr); - EXPECT_EQ(8, size); - - // Skip over multiple buffers. - EXPECT_TRUE(coded_output.Skip(22)); - EXPECT_TRUE(coded_output.GetDirectBufferPointer(&ptr, &size)); - EXPECT_EQ(buffer_ + 30, ptr); - EXPECT_EQ(2, size); -} - -// ------------------------------------------------------------------- -// Limits - -TEST_1D(CodedStreamTest, BasicLimit, kBlockSizes) { - ArrayInputStream input(buffer_, sizeof(buffer_), kBlockSizes_case); - - { - CodedInputStream coded_input(&input); - - EXPECT_EQ(-1, coded_input.BytesUntilLimit()); - CodedInputStream::Limit limit = coded_input.PushLimit(8); - - // Read until we hit the limit. - uint32 value; - EXPECT_EQ(8, coded_input.BytesUntilLimit()); - EXPECT_TRUE(coded_input.ReadLittleEndian32(&value)); - EXPECT_EQ(4, coded_input.BytesUntilLimit()); - EXPECT_TRUE(coded_input.ReadLittleEndian32(&value)); - EXPECT_EQ(0, coded_input.BytesUntilLimit()); - EXPECT_FALSE(coded_input.ReadLittleEndian32(&value)); - EXPECT_EQ(0, coded_input.BytesUntilLimit()); - - coded_input.PopLimit(limit); - - EXPECT_EQ(-1, coded_input.BytesUntilLimit()); - EXPECT_TRUE(coded_input.ReadLittleEndian32(&value)); - } - - EXPECT_EQ(12, input.ByteCount()); -} - -// Test what happens when we push two limits where the second (top) one is -// shorter. -TEST_1D(CodedStreamTest, SmallLimitOnTopOfBigLimit, kBlockSizes) { - ArrayInputStream input(buffer_, sizeof(buffer_), kBlockSizes_case); - - { - CodedInputStream coded_input(&input); - - EXPECT_EQ(-1, coded_input.BytesUntilLimit()); - CodedInputStream::Limit limit1 = coded_input.PushLimit(8); - EXPECT_EQ(8, coded_input.BytesUntilLimit()); - CodedInputStream::Limit limit2 = coded_input.PushLimit(4); - - uint32 value; - - // Read until we hit limit2, the top and shortest limit. - EXPECT_EQ(4, coded_input.BytesUntilLimit()); - EXPECT_TRUE(coded_input.ReadLittleEndian32(&value)); - EXPECT_EQ(0, coded_input.BytesUntilLimit()); - EXPECT_FALSE(coded_input.ReadLittleEndian32(&value)); - EXPECT_EQ(0, coded_input.BytesUntilLimit()); - - coded_input.PopLimit(limit2); - - // Read until we hit limit1. - EXPECT_EQ(4, coded_input.BytesUntilLimit()); - EXPECT_TRUE(coded_input.ReadLittleEndian32(&value)); - EXPECT_EQ(0, coded_input.BytesUntilLimit()); - EXPECT_FALSE(coded_input.ReadLittleEndian32(&value)); - EXPECT_EQ(0, coded_input.BytesUntilLimit()); - - coded_input.PopLimit(limit1); - - // No more limits. - EXPECT_EQ(-1, coded_input.BytesUntilLimit()); - EXPECT_TRUE(coded_input.ReadLittleEndian32(&value)); - } - - EXPECT_EQ(12, input.ByteCount()); -} - -// Test what happens when we push two limits where the second (top) one is -// longer. In this case, the top limit is shortened to match the previous -// limit. -TEST_1D(CodedStreamTest, BigLimitOnTopOfSmallLimit, kBlockSizes) { - ArrayInputStream input(buffer_, sizeof(buffer_), kBlockSizes_case); - - { - CodedInputStream coded_input(&input); - - EXPECT_EQ(-1, coded_input.BytesUntilLimit()); - CodedInputStream::Limit limit1 = coded_input.PushLimit(4); - EXPECT_EQ(4, coded_input.BytesUntilLimit()); - CodedInputStream::Limit limit2 = coded_input.PushLimit(8); - - uint32 value; - - // Read until we hit limit2. Except, wait! limit1 is shorter, so - // we end up hitting that first, despite having 4 bytes to go on - // limit2. - EXPECT_EQ(4, coded_input.BytesUntilLimit()); - EXPECT_TRUE(coded_input.ReadLittleEndian32(&value)); - EXPECT_EQ(0, coded_input.BytesUntilLimit()); - EXPECT_FALSE(coded_input.ReadLittleEndian32(&value)); - EXPECT_EQ(0, coded_input.BytesUntilLimit()); - - coded_input.PopLimit(limit2); - - // OK, popped limit2, now limit1 is on top, which we've already hit. - EXPECT_EQ(0, coded_input.BytesUntilLimit()); - EXPECT_FALSE(coded_input.ReadLittleEndian32(&value)); - EXPECT_EQ(0, coded_input.BytesUntilLimit()); - - coded_input.PopLimit(limit1); - - // No more limits. - EXPECT_EQ(-1, coded_input.BytesUntilLimit()); - EXPECT_TRUE(coded_input.ReadLittleEndian32(&value)); - } - - EXPECT_EQ(8, input.ByteCount()); -} - -TEST_F(CodedStreamTest, ExpectAtEnd) { - // Test ExpectAtEnd(), which is based on limits. - ArrayInputStream input(buffer_, sizeof(buffer_)); - CodedInputStream coded_input(&input); - - EXPECT_FALSE(coded_input.ExpectAtEnd()); - - CodedInputStream::Limit limit = coded_input.PushLimit(4); - - uint32 value; - EXPECT_TRUE(coded_input.ReadLittleEndian32(&value)); - EXPECT_TRUE(coded_input.ExpectAtEnd()); - - coded_input.PopLimit(limit); - EXPECT_FALSE(coded_input.ExpectAtEnd()); -} - -TEST_F(CodedStreamTest, NegativeLimit) { - // Check what happens when we push a negative limit. - ArrayInputStream input(buffer_, sizeof(buffer_)); - CodedInputStream coded_input(&input); - - CodedInputStream::Limit limit = coded_input.PushLimit(-1234); - // BytesUntilLimit() returns -1 to mean "no limit", which actually means - // "the limit is INT_MAX relative to the beginning of the stream". - EXPECT_EQ(-1, coded_input.BytesUntilLimit()); - coded_input.PopLimit(limit); -} - -TEST_F(CodedStreamTest, NegativeLimitAfterReading) { - // Check what happens when we push a negative limit. - ArrayInputStream input(buffer_, sizeof(buffer_)); - CodedInputStream coded_input(&input); - ASSERT_TRUE(coded_input.Skip(128)); - - CodedInputStream::Limit limit = coded_input.PushLimit(-64); - // BytesUntilLimit() returns -1 to mean "no limit", which actually means - // "the limit is INT_MAX relative to the beginning of the stream". - EXPECT_EQ(-1, coded_input.BytesUntilLimit()); - coded_input.PopLimit(limit); -} - -TEST_F(CodedStreamTest, OverflowLimit) { - // Check what happens when we push a limit large enough that its absolute - // position is more than 2GB into the stream. - ArrayInputStream input(buffer_, sizeof(buffer_)); - CodedInputStream coded_input(&input); - ASSERT_TRUE(coded_input.Skip(128)); - - CodedInputStream::Limit limit = coded_input.PushLimit(INT_MAX); - // BytesUntilLimit() returns -1 to mean "no limit", which actually means - // "the limit is INT_MAX relative to the beginning of the stream". - EXPECT_EQ(-1, coded_input.BytesUntilLimit()); - coded_input.PopLimit(limit); -} - -TEST_F(CodedStreamTest, TotalBytesLimit) { - ArrayInputStream input(buffer_, sizeof(buffer_)); - CodedInputStream coded_input(&input); - coded_input.SetTotalBytesLimit(16, -1); - - string str; - EXPECT_TRUE(coded_input.ReadString(&str, 16)); - - vector errors; - - { - ScopedMemoryLog error_log; - EXPECT_FALSE(coded_input.ReadString(&str, 1)); - errors = error_log.GetMessages(ERROR); - } - - ASSERT_EQ(1, errors.size()); - EXPECT_PRED_FORMAT2(testing::IsSubstring, - "A protocol message was rejected because it was too big", errors[0]); - - coded_input.SetTotalBytesLimit(32, -1); - EXPECT_TRUE(coded_input.ReadString(&str, 16)); -} - -TEST_F(CodedStreamTest, TotalBytesLimitNotValidMessageEnd) { - // total_bytes_limit_ is not a valid place for a message to end. - - ArrayInputStream input(buffer_, sizeof(buffer_)); - CodedInputStream coded_input(&input); - - // Set both total_bytes_limit and a regular limit at 16 bytes. - coded_input.SetTotalBytesLimit(16, -1); - CodedInputStream::Limit limit = coded_input.PushLimit(16); - - // Read 16 bytes. - string str; - EXPECT_TRUE(coded_input.ReadString(&str, 16)); - - // Read a tag. Should fail, but report being a valid endpoint since it's - // a regular limit. - EXPECT_EQ(0, coded_input.ReadTag()); - EXPECT_TRUE(coded_input.ConsumedEntireMessage()); - - // Pop the limit. - coded_input.PopLimit(limit); - - // Read a tag. Should fail, and report *not* being a valid endpoint, since - // this time we're hitting the total bytes limit. - EXPECT_EQ(0, coded_input.ReadTag()); - EXPECT_FALSE(coded_input.ConsumedEntireMessage()); -} - -// This method is used by the tests below. -// It constructs a CodedInputStream with the given limits and tries to read 2KiB -// of data from it. Then it returns the logged errors and warnings in the given -// vectors. -void CodedStreamTest::SetupTotalBytesLimitWarningTest( - int total_bytes_limit, int warning_threshold, - vector* out_errors, vector* out_warnings) { - ArrayInputStream raw_input(buffer_, sizeof(buffer_), 128); - - ScopedMemoryLog scoped_log; - { - CodedInputStream input(&raw_input); - input.SetTotalBytesLimit(total_bytes_limit, warning_threshold); - string str; - EXPECT_TRUE(input.ReadString(&str, 2048)); - } - - *out_errors = scoped_log.GetMessages(ERROR); - *out_warnings = scoped_log.GetMessages(WARNING); -} - -TEST_F(CodedStreamTest, TotalBytesLimitWarning) { - vector errors; - vector warnings; - SetupTotalBytesLimitWarningTest(10240, 1024, &errors, &warnings); - - EXPECT_EQ(0, errors.size()); - - ASSERT_EQ(2, warnings.size()); - EXPECT_PRED_FORMAT2(testing::IsSubstring, - "Reading dangerously large protocol message. If the message turns out to " - "be larger than 10240 bytes, parsing will be halted for security reasons.", - warnings[0]); - EXPECT_PRED_FORMAT2(testing::IsSubstring, - "The total number of bytes read was 2048", - warnings[1]); -} - -TEST_F(CodedStreamTest, TotalBytesLimitWarningDisabled) { - vector errors; - vector warnings; - - // Test with -1 - SetupTotalBytesLimitWarningTest(10240, -1, &errors, &warnings); - EXPECT_EQ(0, errors.size()); - EXPECT_EQ(0, warnings.size()); - - // Test again with -2, expecting the same result - SetupTotalBytesLimitWarningTest(10240, -2, &errors, &warnings); - EXPECT_EQ(0, errors.size()); - EXPECT_EQ(0, warnings.size()); -} - - -TEST_F(CodedStreamTest, RecursionLimit) { - ArrayInputStream input(buffer_, sizeof(buffer_)); - CodedInputStream coded_input(&input); - coded_input.SetRecursionLimit(4); - - // This is way too much testing for a counter. - EXPECT_TRUE(coded_input.IncrementRecursionDepth()); // 1 - EXPECT_TRUE(coded_input.IncrementRecursionDepth()); // 2 - EXPECT_TRUE(coded_input.IncrementRecursionDepth()); // 3 - EXPECT_TRUE(coded_input.IncrementRecursionDepth()); // 4 - EXPECT_FALSE(coded_input.IncrementRecursionDepth()); // 5 - EXPECT_FALSE(coded_input.IncrementRecursionDepth()); // 6 - coded_input.DecrementRecursionDepth(); // 5 - EXPECT_FALSE(coded_input.IncrementRecursionDepth()); // 6 - coded_input.DecrementRecursionDepth(); // 5 - coded_input.DecrementRecursionDepth(); // 4 - coded_input.DecrementRecursionDepth(); // 3 - EXPECT_TRUE(coded_input.IncrementRecursionDepth()); // 4 - EXPECT_FALSE(coded_input.IncrementRecursionDepth()); // 5 - coded_input.DecrementRecursionDepth(); // 4 - coded_input.DecrementRecursionDepth(); // 3 - coded_input.DecrementRecursionDepth(); // 2 - coded_input.DecrementRecursionDepth(); // 1 - coded_input.DecrementRecursionDepth(); // 0 - coded_input.DecrementRecursionDepth(); // 0 - coded_input.DecrementRecursionDepth(); // 0 - EXPECT_TRUE(coded_input.IncrementRecursionDepth()); // 1 - EXPECT_TRUE(coded_input.IncrementRecursionDepth()); // 2 - EXPECT_TRUE(coded_input.IncrementRecursionDepth()); // 3 - EXPECT_TRUE(coded_input.IncrementRecursionDepth()); // 4 - EXPECT_FALSE(coded_input.IncrementRecursionDepth()); // 5 - - coded_input.SetRecursionLimit(6); - EXPECT_TRUE(coded_input.IncrementRecursionDepth()); // 6 - EXPECT_FALSE(coded_input.IncrementRecursionDepth()); // 7 -} - - -class ReallyBigInputStream : public ZeroCopyInputStream { - public: - ReallyBigInputStream() : backup_amount_(0), buffer_count_(0) {} - ~ReallyBigInputStream() {} - - // implements ZeroCopyInputStream ---------------------------------- - bool Next(const void** data, int* size) { - // We only expect BackUp() to be called at the end. - EXPECT_EQ(0, backup_amount_); - - switch (buffer_count_++) { - case 0: - *data = buffer_; - *size = sizeof(buffer_); - return true; - case 1: - // Return an enormously large buffer that, when combined with the 1k - // returned already, should overflow the total_bytes_read_ counter in - // CodedInputStream. Note that we'll only read the first 1024 bytes - // of this buffer so it's OK that we have it point at buffer_. - *data = buffer_; - *size = INT_MAX; - return true; - default: - return false; - } - } - - void BackUp(int count) { - backup_amount_ = count; - } - - bool Skip(int count) { GOOGLE_LOG(FATAL) << "Not implemented."; return false; } - int64 ByteCount() const { GOOGLE_LOG(FATAL) << "Not implemented."; return 0; } - - int backup_amount_; - - private: - char buffer_[1024]; - int64 buffer_count_; -}; - -TEST_F(CodedStreamTest, InputOver2G) { - // CodedInputStream should gracefully handle input over 2G and call - // input.BackUp() with the correct number of bytes on destruction. - ReallyBigInputStream input; - - vector errors; - - { - ScopedMemoryLog error_log; - CodedInputStream coded_input(&input); - string str; - EXPECT_TRUE(coded_input.ReadString(&str, 512)); - EXPECT_TRUE(coded_input.ReadString(&str, 1024)); - errors = error_log.GetMessages(ERROR); - } - - EXPECT_EQ(INT_MAX - 512, input.backup_amount_); - EXPECT_EQ(0, errors.size()); -} - -// =================================================================== - - -} // namespace -} // namespace io -} // namespace protobuf -} // namespace google diff --git a/modules/dnn/3rdparty/protobuf/src/google/protobuf/io/gzip_stream.cc b/modules/dnn/3rdparty/protobuf/src/google/protobuf/io/gzip_stream.cc deleted file mode 100644 index fe1f3319d..000000000 --- a/modules/dnn/3rdparty/protobuf/src/google/protobuf/io/gzip_stream.cc +++ /dev/null @@ -1,326 +0,0 @@ -// Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// http://code.google.com/p/protobuf/ -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -// Author: brianolson@google.com (Brian Olson) -// -// This file contains the implementation of classes GzipInputStream and -// GzipOutputStream. - -#include "config.h" - -#if HAVE_ZLIB -#include - -#include - -namespace google { -namespace protobuf { -namespace io { - -static const int kDefaultBufferSize = 65536; - -GzipInputStream::GzipInputStream( - ZeroCopyInputStream* sub_stream, Format format, int buffer_size) - : format_(format), sub_stream_(sub_stream), zerror_(Z_OK) { - zcontext_.zalloc = Z_NULL; - zcontext_.zfree = Z_NULL; - zcontext_.opaque = Z_NULL; - zcontext_.total_out = 0; - zcontext_.next_in = NULL; - zcontext_.avail_in = 0; - zcontext_.total_in = 0; - zcontext_.msg = NULL; - if (buffer_size == -1) { - output_buffer_length_ = kDefaultBufferSize; - } else { - output_buffer_length_ = buffer_size; - } - output_buffer_ = operator new(output_buffer_length_); - GOOGLE_CHECK(output_buffer_ != NULL); - zcontext_.next_out = static_cast(output_buffer_); - zcontext_.avail_out = output_buffer_length_; - output_position_ = output_buffer_; -} -GzipInputStream::~GzipInputStream() { - operator delete(output_buffer_); - zerror_ = inflateEnd(&zcontext_); -} - -static inline int internalInflateInit2( - z_stream* zcontext, GzipInputStream::Format format) { - int windowBitsFormat = 0; - switch (format) { - case GzipInputStream::GZIP: windowBitsFormat = 16; break; - case GzipInputStream::AUTO: windowBitsFormat = 32; break; - case GzipInputStream::ZLIB: windowBitsFormat = 0; break; - } - return inflateInit2(zcontext, /* windowBits */15 | windowBitsFormat); -} - -int GzipInputStream::Inflate(int flush) { - if ((zerror_ == Z_OK) && (zcontext_.avail_out == 0)) { - // previous inflate filled output buffer. don't change input params yet. - } else if (zcontext_.avail_in == 0) { - const void* in; - int in_size; - bool first = zcontext_.next_in == NULL; - bool ok = sub_stream_->Next(&in, &in_size); - if (!ok) { - zcontext_.next_out = NULL; - zcontext_.avail_out = 0; - return Z_STREAM_END; - } - zcontext_.next_in = static_cast(const_cast(in)); - zcontext_.avail_in = in_size; - if (first) { - int error = internalInflateInit2(&zcontext_, format_); - if (error != Z_OK) { - return error; - } - } - } - zcontext_.next_out = static_cast(output_buffer_); - zcontext_.avail_out = output_buffer_length_; - output_position_ = output_buffer_; - int error = inflate(&zcontext_, flush); - return error; -} - -void GzipInputStream::DoNextOutput(const void** data, int* size) { - *data = output_position_; - *size = ((uintptr_t)zcontext_.next_out) - ((uintptr_t)output_position_); - output_position_ = zcontext_.next_out; -} - -// implements ZeroCopyInputStream ---------------------------------- -bool GzipInputStream::Next(const void** data, int* size) { - bool ok = (zerror_ == Z_OK) || (zerror_ == Z_STREAM_END) - || (zerror_ == Z_BUF_ERROR); - if ((!ok) || (zcontext_.next_out == NULL)) { - return false; - } - if (zcontext_.next_out != output_position_) { - DoNextOutput(data, size); - return true; - } - if (zerror_ == Z_STREAM_END) { - if (zcontext_.next_out != NULL) { - // sub_stream_ may have concatenated streams to follow - zerror_ = inflateEnd(&zcontext_); - if (zerror_ != Z_OK) { - return false; - } - zerror_ = internalInflateInit2(&zcontext_, format_); - if (zerror_ != Z_OK) { - return false; - } - } else { - *data = NULL; - *size = 0; - return false; - } - } - zerror_ = Inflate(Z_NO_FLUSH); - if ((zerror_ == Z_STREAM_END) && (zcontext_.next_out == NULL)) { - // The underlying stream's Next returned false inside Inflate. - return false; - } - ok = (zerror_ == Z_OK) || (zerror_ == Z_STREAM_END) - || (zerror_ == Z_BUF_ERROR); - if (!ok) { - return false; - } - DoNextOutput(data, size); - return true; -} -void GzipInputStream::BackUp(int count) { - output_position_ = reinterpret_cast( - reinterpret_cast(output_position_) - count); -} -bool GzipInputStream::Skip(int count) { - const void* data; - int size; - bool ok = Next(&data, &size); - while (ok && (size < count)) { - count -= size; - ok = Next(&data, &size); - } - if (size > count) { - BackUp(size - count); - } - return ok; -} -int64 GzipInputStream::ByteCount() const { - return zcontext_.total_out + - (((uintptr_t)zcontext_.next_out) - ((uintptr_t)output_position_)); -} - -// ========================================================================= - -GzipOutputStream::Options::Options() - : format(GZIP), - buffer_size(kDefaultBufferSize), - compression_level(Z_DEFAULT_COMPRESSION), - compression_strategy(Z_DEFAULT_STRATEGY) {} - -GzipOutputStream::GzipOutputStream(ZeroCopyOutputStream* sub_stream) { - Init(sub_stream, Options()); -} - -GzipOutputStream::GzipOutputStream(ZeroCopyOutputStream* sub_stream, - const Options& options) { - Init(sub_stream, options); -} - -void GzipOutputStream::Init(ZeroCopyOutputStream* sub_stream, - const Options& options) { - sub_stream_ = sub_stream; - sub_data_ = NULL; - sub_data_size_ = 0; - - input_buffer_length_ = options.buffer_size; - input_buffer_ = operator new(input_buffer_length_); - GOOGLE_CHECK(input_buffer_ != NULL); - - zcontext_.zalloc = Z_NULL; - zcontext_.zfree = Z_NULL; - zcontext_.opaque = Z_NULL; - zcontext_.next_out = NULL; - zcontext_.avail_out = 0; - zcontext_.total_out = 0; - zcontext_.next_in = NULL; - zcontext_.avail_in = 0; - zcontext_.total_in = 0; - zcontext_.msg = NULL; - // default to GZIP format - int windowBitsFormat = 16; - if (options.format == ZLIB) { - windowBitsFormat = 0; - } - zerror_ = deflateInit2( - &zcontext_, - options.compression_level, - Z_DEFLATED, - /* windowBits */15 | windowBitsFormat, - /* memLevel (default) */8, - options.compression_strategy); -} - -GzipOutputStream::~GzipOutputStream() { - Close(); - if (input_buffer_ != NULL) { - operator delete(input_buffer_); - } -} - -// private -int GzipOutputStream::Deflate(int flush) { - int error = Z_OK; - do { - if ((sub_data_ == NULL) || (zcontext_.avail_out == 0)) { - bool ok = sub_stream_->Next(&sub_data_, &sub_data_size_); - if (!ok) { - sub_data_ = NULL; - sub_data_size_ = 0; - return Z_BUF_ERROR; - } - GOOGLE_CHECK_GT(sub_data_size_, 0); - zcontext_.next_out = static_cast(sub_data_); - zcontext_.avail_out = sub_data_size_; - } - error = deflate(&zcontext_, flush); - } while (error == Z_OK && zcontext_.avail_out == 0); - if ((flush == Z_FULL_FLUSH) || (flush == Z_FINISH)) { - // Notify lower layer of data. - sub_stream_->BackUp(zcontext_.avail_out); - // We don't own the buffer anymore. - sub_data_ = NULL; - sub_data_size_ = 0; - } - return error; -} - -// implements ZeroCopyOutputStream --------------------------------- -bool GzipOutputStream::Next(void** data, int* size) { - if ((zerror_ != Z_OK) && (zerror_ != Z_BUF_ERROR)) { - return false; - } - if (zcontext_.avail_in != 0) { - zerror_ = Deflate(Z_NO_FLUSH); - if (zerror_ != Z_OK) { - return false; - } - } - if (zcontext_.avail_in == 0) { - // all input was consumed. reset the buffer. - zcontext_.next_in = static_cast(input_buffer_); - zcontext_.avail_in = input_buffer_length_; - *data = input_buffer_; - *size = input_buffer_length_; - } else { - // The loop in Deflate should consume all avail_in - GOOGLE_LOG(DFATAL) << "Deflate left bytes unconsumed"; - } - return true; -} -void GzipOutputStream::BackUp(int count) { - GOOGLE_CHECK_GE(zcontext_.avail_in, count); - zcontext_.avail_in -= count; -} -int64 GzipOutputStream::ByteCount() const { - return zcontext_.total_in + zcontext_.avail_in; -} - -bool GzipOutputStream::Flush() { - zerror_ = Deflate(Z_FULL_FLUSH); - // Return true if the flush succeeded or if it was a no-op. - return (zerror_ == Z_OK) || - (zerror_ == Z_BUF_ERROR && zcontext_.avail_in == 0 && - zcontext_.avail_out != 0); -} - -bool GzipOutputStream::Close() { - if ((zerror_ != Z_OK) && (zerror_ != Z_BUF_ERROR)) { - return false; - } - do { - zerror_ = Deflate(Z_FINISH); - } while (zerror_ == Z_OK); - zerror_ = deflateEnd(&zcontext_); - bool ok = zerror_ == Z_OK; - zerror_ = Z_STREAM_END; - return ok; -} - -} // namespace io -} // namespace protobuf -} // namespace google - -#endif // HAVE_ZLIB diff --git a/modules/dnn/3rdparty/protobuf/src/google/protobuf/io/gzip_stream.h b/modules/dnn/3rdparty/protobuf/src/google/protobuf/io/gzip_stream.h deleted file mode 100644 index 365e9ea5f..000000000 --- a/modules/dnn/3rdparty/protobuf/src/google/protobuf/io/gzip_stream.h +++ /dev/null @@ -1,209 +0,0 @@ -// Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// http://code.google.com/p/protobuf/ -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -// Author: brianolson@google.com (Brian Olson) -// -// This file contains the definition for classes GzipInputStream and -// GzipOutputStream. -// -// GzipInputStream decompresses data from an underlying -// ZeroCopyInputStream and provides the decompressed data as a -// ZeroCopyInputStream. -// -// GzipOutputStream is an ZeroCopyOutputStream that compresses data to -// an underlying ZeroCopyOutputStream. - -#ifndef GOOGLE_PROTOBUF_IO_GZIP_STREAM_H__ -#define GOOGLE_PROTOBUF_IO_GZIP_STREAM_H__ - -#include - -#include -#include - -namespace google { -namespace protobuf { -namespace io { - -// A ZeroCopyInputStream that reads compressed data through zlib -class LIBPROTOBUF_EXPORT GzipInputStream : public ZeroCopyInputStream { - public: - // Format key for constructor - enum Format { - // zlib will autodetect gzip header or deflate stream - AUTO = 0, - - // GZIP streams have some extra header data for file attributes. - GZIP = 1, - - // Simpler zlib stream format. - ZLIB = 2, - }; - - // buffer_size and format may be -1 for default of 64kB and GZIP format - explicit GzipInputStream( - ZeroCopyInputStream* sub_stream, - Format format = AUTO, - int buffer_size = -1); - virtual ~GzipInputStream(); - - // Return last error message or NULL if no error. - inline const char* ZlibErrorMessage() const { - return zcontext_.msg; - } - inline int ZlibErrorCode() const { - return zerror_; - } - - // implements ZeroCopyInputStream ---------------------------------- - bool Next(const void** data, int* size); - void BackUp(int count); - bool Skip(int count); - int64 ByteCount() const; - - private: - Format format_; - - ZeroCopyInputStream* sub_stream_; - - z_stream zcontext_; - int zerror_; - - void* output_buffer_; - void* output_position_; - size_t output_buffer_length_; - - int Inflate(int flush); - void DoNextOutput(const void** data, int* size); - - GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(GzipInputStream); -}; - - -class LIBPROTOBUF_EXPORT GzipOutputStream : public ZeroCopyOutputStream { - public: - // Format key for constructor - enum Format { - // GZIP streams have some extra header data for file attributes. - GZIP = 1, - - // Simpler zlib stream format. - ZLIB = 2, - }; - - struct LIBPROTOBUF_EXPORT Options { - // Defaults to GZIP. - Format format; - - // What size buffer to use internally. Defaults to 64kB. - int buffer_size; - - // A number between 0 and 9, where 0 is no compression and 9 is best - // compression. Defaults to Z_DEFAULT_COMPRESSION (see zlib.h). - int compression_level; - - // Defaults to Z_DEFAULT_STRATEGY. Can also be set to Z_FILTERED, - // Z_HUFFMAN_ONLY, or Z_RLE. See the documentation for deflateInit2 in - // zlib.h for definitions of these constants. - int compression_strategy; - - Options(); // Initializes with default values. - }; - - // Create a GzipOutputStream with default options. - explicit GzipOutputStream(ZeroCopyOutputStream* sub_stream); - - // Create a GzipOutputStream with the given options. - GzipOutputStream( - ZeroCopyOutputStream* sub_stream, - const Options& options); - - virtual ~GzipOutputStream(); - - // Return last error message or NULL if no error. - inline const char* ZlibErrorMessage() const { - return zcontext_.msg; - } - inline int ZlibErrorCode() const { - return zerror_; - } - - // Flushes data written so far to zipped data in the underlying stream. - // It is the caller's responsibility to flush the underlying stream if - // necessary. - // Compression may be less efficient stopping and starting around flushes. - // Returns true if no error. - // - // Please ensure that block size is > 6. Here is an excerpt from the zlib - // doc that explains why: - // - // In the case of a Z_FULL_FLUSH or Z_SYNC_FLUSH, make sure that avail_out - // is greater than six to avoid repeated flush markers due to - // avail_out == 0 on return. - bool Flush(); - - // Writes out all data and closes the gzip stream. - // It is the caller's responsibility to close the underlying stream if - // necessary. - // Returns true if no error. - bool Close(); - - // implements ZeroCopyOutputStream --------------------------------- - bool Next(void** data, int* size); - void BackUp(int count); - int64 ByteCount() const; - - private: - ZeroCopyOutputStream* sub_stream_; - // Result from calling Next() on sub_stream_ - void* sub_data_; - int sub_data_size_; - - z_stream zcontext_; - int zerror_; - void* input_buffer_; - size_t input_buffer_length_; - - // Shared constructor code. - void Init(ZeroCopyOutputStream* sub_stream, const Options& options); - - // Do some compression. - // Takes zlib flush mode. - // Returns zlib error code. - int Deflate(int flush); - - GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(GzipOutputStream); -}; - -} // namespace io -} // namespace protobuf - -} // namespace google -#endif // GOOGLE_PROTOBUF_IO_GZIP_STREAM_H__ diff --git a/modules/dnn/3rdparty/protobuf/src/google/protobuf/io/gzip_stream_unittest.sh b/modules/dnn/3rdparty/protobuf/src/google/protobuf/io/gzip_stream_unittest.sh deleted file mode 100644 index 6e8a09437..000000000 --- a/modules/dnn/3rdparty/protobuf/src/google/protobuf/io/gzip_stream_unittest.sh +++ /dev/null @@ -1,44 +0,0 @@ -#!/bin/sh -x -# -# Protocol Buffers - Google's data interchange format -# Copyright 2009 Google Inc. All rights reserved. -# http://code.google.com/p/protobuf/ -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are -# met: -# -# * Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# * Redistributions in binary form must reproduce the above -# copyright notice, this list of conditions and the following disclaimer -# in the documentation and/or other materials provided with the -# distribution. -# * Neither the name of Google Inc. nor the names of its -# contributors may be used to endorse or promote products derived from -# this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# -# Author: brianolson@google.com (Brian Olson) -# -# Test compatibility between command line gzip/gunzip binaries and -# ZeroCopyStream versions. - -TESTFILE=Makefile - -(./zcgzip < ${TESTFILE} | gunzip | cmp - ${TESTFILE}) && \ -(gzip < ${TESTFILE} | ./zcgunzip | cmp - ${TESTFILE}) - -# Result of "(cmd) && (cmd)" implicitly becomes result of this script -# and thus the test. diff --git a/modules/dnn/3rdparty/protobuf/src/google/protobuf/io/package_info.h b/modules/dnn/3rdparty/protobuf/src/google/protobuf/io/package_info.h deleted file mode 100644 index 7a7a4e773..000000000 --- a/modules/dnn/3rdparty/protobuf/src/google/protobuf/io/package_info.h +++ /dev/null @@ -1,54 +0,0 @@ -// Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// http://code.google.com/p/protobuf/ -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -// Author: kenton@google.com (Kenton Varda) -// Based on original Protocol Buffers design by -// Sanjay Ghemawat, Jeff Dean, and others. -// -// This file exists solely to document the google::protobuf::io namespace. -// It is not compiled into anything, but it may be read by an automated -// documentation generator. - -namespace google { - -namespace protobuf { - -// Auxiliary classes used for I/O. -// -// The Protocol Buffer library uses the classes in this package to deal with -// I/O and encoding/decoding raw bytes. Most users will not need to -// deal with this package. However, users who want to adapt the system to -// work with their own I/O abstractions -- e.g., to allow Protocol Buffers -// to be read from a different kind of input stream without the need for a -// temporary buffer -- should take a closer look. -namespace io {} - -} // namespace protobuf -} // namespace google diff --git a/modules/dnn/3rdparty/protobuf/src/google/protobuf/io/printer.cc b/modules/dnn/3rdparty/protobuf/src/google/protobuf/io/printer.cc deleted file mode 100644 index d2bf3f549..000000000 --- a/modules/dnn/3rdparty/protobuf/src/google/protobuf/io/printer.cc +++ /dev/null @@ -1,198 +0,0 @@ -// Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// http://code.google.com/p/protobuf/ -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -// Author: kenton@google.com (Kenton Varda) -// Based on original Protocol Buffers design by -// Sanjay Ghemawat, Jeff Dean, and others. - -#include -#include -#include - -namespace google { -namespace protobuf { -namespace io { - -Printer::Printer(ZeroCopyOutputStream* output, char variable_delimiter) - : variable_delimiter_(variable_delimiter), - output_(output), - buffer_(NULL), - buffer_size_(0), - at_start_of_line_(true), - failed_(false) { -} - -Printer::~Printer() { - // Only BackUp() if we have called Next() at least once and never failed. - if (buffer_size_ > 0 && !failed_) { - output_->BackUp(buffer_size_); - } -} - -void Printer::Print(const map& variables, const char* text) { - int size = strlen(text); - int pos = 0; // The number of bytes we've written so far. - - for (int i = 0; i < size; i++) { - if (text[i] == '\n') { - // Saw newline. If there is more text, we may need to insert an indent - // here. So, write what we have so far, including the '\n'. - WriteRaw(text + pos, i - pos + 1); - pos = i + 1; - - // Setting this true will cause the next WriteRaw() to insert an indent - // first. - at_start_of_line_ = true; - - } else if (text[i] == variable_delimiter_) { - // Saw the start of a variable name. - - // Write what we have so far. - WriteRaw(text + pos, i - pos); - pos = i + 1; - - // Find closing delimiter. - const char* end = strchr(text + pos, variable_delimiter_); - if (end == NULL) { - GOOGLE_LOG(DFATAL) << " Unclosed variable name."; - end = text + pos; - } - int endpos = end - text; - - string varname(text + pos, endpos - pos); - if (varname.empty()) { - // Two delimiters in a row reduce to a literal delimiter character. - WriteRaw(&variable_delimiter_, 1); - } else { - // Replace with the variable's value. - map::const_iterator iter = variables.find(varname); - if (iter == variables.end()) { - GOOGLE_LOG(DFATAL) << " Undefined variable: " << varname; - } else { - WriteRaw(iter->second.data(), iter->second.size()); - } - } - - // Advance past this variable. - i = endpos; - pos = endpos + 1; - } - } - - // Write the rest. - WriteRaw(text + pos, size - pos); -} - -void Printer::Print(const char* text) { - static map empty; - Print(empty, text); -} - -void Printer::Print(const char* text, - const char* variable, const string& value) { - map vars; - vars[variable] = value; - Print(vars, text); -} - -void Printer::Print(const char* text, - const char* variable1, const string& value1, - const char* variable2, const string& value2) { - map vars; - vars[variable1] = value1; - vars[variable2] = value2; - Print(vars, text); -} - -void Printer::Print(const char* text, - const char* variable1, const string& value1, - const char* variable2, const string& value2, - const char* variable3, const string& value3) { - map vars; - vars[variable1] = value1; - vars[variable2] = value2; - vars[variable3] = value3; - Print(vars, text); -} - -void Printer::Indent() { - indent_ += " "; -} - -void Printer::Outdent() { - if (indent_.empty()) { - GOOGLE_LOG(DFATAL) << " Outdent() without matching Indent()."; - return; - } - - indent_.resize(indent_.size() - 2); -} - -void Printer::PrintRaw(const string& data) { - WriteRaw(data.data(), data.size()); -} - -void Printer::PrintRaw(const char* data) { - if (failed_) return; - WriteRaw(data, strlen(data)); -} - -void Printer::WriteRaw(const char* data, int size) { - if (failed_) return; - if (size == 0) return; - - if (at_start_of_line_ && (size > 0) && (data[0] != '\n')) { - // Insert an indent. - at_start_of_line_ = false; - WriteRaw(indent_.data(), indent_.size()); - if (failed_) return; - } - - while (size > buffer_size_) { - // Data exceeds space in the buffer. Copy what we can and request a - // new buffer. - memcpy(buffer_, data, buffer_size_); - data += buffer_size_; - size -= buffer_size_; - void* void_buffer; - failed_ = !output_->Next(&void_buffer, &buffer_size_); - if (failed_) return; - buffer_ = reinterpret_cast(void_buffer); - } - - // Buffer is big enough to receive the data; copy it. - memcpy(buffer_, data, size); - buffer_ += size; - buffer_size_ -= size; -} - -} // namespace io -} // namespace protobuf -} // namespace google diff --git a/modules/dnn/3rdparty/protobuf/src/google/protobuf/io/printer.h b/modules/dnn/3rdparty/protobuf/src/google/protobuf/io/printer.h deleted file mode 100644 index 5be48543a..000000000 --- a/modules/dnn/3rdparty/protobuf/src/google/protobuf/io/printer.h +++ /dev/null @@ -1,136 +0,0 @@ -// Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// http://code.google.com/p/protobuf/ -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -// Author: kenton@google.com (Kenton Varda) -// Based on original Protocol Buffers design by -// Sanjay Ghemawat, Jeff Dean, and others. -// -// Utility class for writing text to a ZeroCopyOutputStream. - -#ifndef GOOGLE_PROTOBUF_IO_PRINTER_H__ -#define GOOGLE_PROTOBUF_IO_PRINTER_H__ - -#include -#include -#include - -namespace google { -namespace protobuf { -namespace io { - -class ZeroCopyOutputStream; // zero_copy_stream.h - -// This simple utility class assists in code generation. It basically -// allows the caller to define a set of variables and then output some -// text with variable substitutions. Example usage: -// -// Printer printer(output, '$'); -// map vars; -// vars["name"] = "Bob"; -// printer.Print(vars, "My name is $name$."); -// -// The above writes "My name is Bob." to the output stream. -// -// Printer aggressively enforces correct usage, crashing (with assert failures) -// in the case of undefined variables in debug builds. This helps greatly in -// debugging code which uses it. -class LIBPROTOBUF_EXPORT Printer { - public: - // Create a printer that writes text to the given output stream. Use the - // given character as the delimiter for variables. - Printer(ZeroCopyOutputStream* output, char variable_delimiter); - ~Printer(); - - // Print some text after applying variable substitutions. If a particular - // variable in the text is not defined, this will crash. Variables to be - // substituted are identified by their names surrounded by delimiter - // characters (as given to the constructor). The variable bindings are - // defined by the given map. - void Print(const map& variables, const char* text); - - // Like the first Print(), except the substitutions are given as parameters. - void Print(const char* text); - // Like the first Print(), except the substitutions are given as parameters. - void Print(const char* text, const char* variable, const string& value); - // Like the first Print(), except the substitutions are given as parameters. - void Print(const char* text, const char* variable1, const string& value1, - const char* variable2, const string& value2); - // Like the first Print(), except the substitutions are given as parameters. - void Print(const char* text, const char* variable1, const string& value1, - const char* variable2, const string& value2, - const char* variable3, const string& value3); - // TODO(kenton): Overloaded versions with more variables? Three seems - // to be enough. - - // Indent text by two spaces. After calling Indent(), two spaces will be - // inserted at the beginning of each line of text. Indent() may be called - // multiple times to produce deeper indents. - void Indent(); - - // Reduces the current indent level by two spaces, or crashes if the indent - // level is zero. - void Outdent(); - - // Write a string to the output buffer. - // This method does not look for newlines to add indentation. - void PrintRaw(const string& data); - - // Write a zero-delimited string to output buffer. - // This method does not look for newlines to add indentation. - void PrintRaw(const char* data); - - // Write some bytes to the output buffer. - // This method does not look for newlines to add indentation. - void WriteRaw(const char* data, int size); - - // True if any write to the underlying stream failed. (We don't just - // crash in this case because this is an I/O failure, not a programming - // error.) - bool failed() const { return failed_; } - - private: - const char variable_delimiter_; - - ZeroCopyOutputStream* const output_; - char* buffer_; - int buffer_size_; - - string indent_; - bool at_start_of_line_; - bool failed_; - - GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(Printer); -}; - -} // namespace io -} // namespace protobuf - -} // namespace google -#endif // GOOGLE_PROTOBUF_IO_PRINTER_H__ diff --git a/modules/dnn/3rdparty/protobuf/src/google/protobuf/io/printer_unittest.cc b/modules/dnn/3rdparty/protobuf/src/google/protobuf/io/printer_unittest.cc deleted file mode 100644 index c9b303596..000000000 --- a/modules/dnn/3rdparty/protobuf/src/google/protobuf/io/printer_unittest.cc +++ /dev/null @@ -1,285 +0,0 @@ -// Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// http://code.google.com/p/protobuf/ -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -// Author: kenton@google.com (Kenton Varda) -// Based on original Protocol Buffers design by -// Sanjay Ghemawat, Jeff Dean, and others. - -#include - -#include -#include - -#include -#include -#include - -namespace google { -namespace protobuf { -namespace io { -namespace { - -// Each test repeats over several block sizes in order to test both cases -// where particular writes cross a buffer boundary and cases where they do -// not. - -TEST(Printer, EmptyPrinter) { - char buffer[8192]; - const int block_size = 100; - ArrayOutputStream output(buffer, GOOGLE_ARRAYSIZE(buffer), block_size); - Printer printer(&output, '\0'); - EXPECT_TRUE(!printer.failed()); -} - -TEST(Printer, BasicPrinting) { - char buffer[8192]; - - for (int block_size = 1; block_size < 512; block_size *= 2) { - ArrayOutputStream output(buffer, sizeof(buffer), block_size); - - { - Printer printer(&output, '\0'); - - printer.Print("Hello World!"); - printer.Print(" This is the same line.\n"); - printer.Print("But this is a new one.\nAnd this is another one."); - - EXPECT_FALSE(printer.failed()); - } - - buffer[output.ByteCount()] = '\0'; - - EXPECT_STREQ("Hello World! This is the same line.\n" - "But this is a new one.\n" - "And this is another one.", - buffer); - } -} - -TEST(Printer, WriteRaw) { - char buffer[8192]; - - for (int block_size = 1; block_size < 512; block_size *= 2) { - ArrayOutputStream output(buffer, sizeof(buffer), block_size); - - { - string string_obj = "From an object\n"; - Printer printer(&output, '$'); - printer.WriteRaw("Hello World!", 12); - printer.PrintRaw(" This is the same line.\n"); - printer.PrintRaw("But this is a new one.\nAnd this is another one."); - printer.WriteRaw("\n", 1); - printer.PrintRaw(string_obj); - EXPECT_FALSE(printer.failed()); - } - - buffer[output.ByteCount()] = '\0'; - - EXPECT_STREQ("Hello World! This is the same line.\n" - "But this is a new one.\n" - "And this is another one." - "\n" - "From an object\n", - buffer); - } -} - -TEST(Printer, VariableSubstitution) { - char buffer[8192]; - - for (int block_size = 1; block_size < 512; block_size *= 2) { - ArrayOutputStream output(buffer, sizeof(buffer), block_size); - - { - Printer printer(&output, '$'); - map vars; - - vars["foo"] = "World"; - vars["bar"] = "$foo$"; - vars["abcdefg"] = "1234"; - - printer.Print(vars, "Hello $foo$!\nbar = $bar$\n"); - printer.PrintRaw("RawBit\n"); - printer.Print(vars, "$abcdefg$\nA literal dollar sign: $$"); - - vars["foo"] = "blah"; - printer.Print(vars, "\nNow foo = $foo$."); - - EXPECT_FALSE(printer.failed()); - } - - buffer[output.ByteCount()] = '\0'; - - EXPECT_STREQ("Hello World!\n" - "bar = $foo$\n" - "RawBit\n" - "1234\n" - "A literal dollar sign: $\n" - "Now foo = blah.", - buffer); - } -} - -TEST(Printer, InlineVariableSubstitution) { - char buffer[8192]; - - ArrayOutputStream output(buffer, sizeof(buffer)); - - { - Printer printer(&output, '$'); - printer.Print("Hello $foo$!\n", "foo", "World"); - printer.PrintRaw("RawBit\n"); - printer.Print("$foo$ $bar$\n", "foo", "one", "bar", "two"); - EXPECT_FALSE(printer.failed()); - } - - buffer[output.ByteCount()] = '\0'; - - EXPECT_STREQ("Hello World!\n" - "RawBit\n" - "one two\n", - buffer); -} - -TEST(Printer, Indenting) { - char buffer[8192]; - - for (int block_size = 1; block_size < 512; block_size *= 2) { - ArrayOutputStream output(buffer, sizeof(buffer), block_size); - - { - Printer printer(&output, '$'); - map vars; - - vars["newline"] = "\n"; - - printer.Print("This is not indented.\n"); - printer.Indent(); - printer.Print("This is indented\nAnd so is this\n"); - printer.Outdent(); - printer.Print("But this is not."); - printer.Indent(); - printer.Print(" And this is still the same line.\n" - "But this is indented.\n"); - printer.PrintRaw("RawBit has indent at start\n"); - printer.PrintRaw("but not after a raw newline\n"); - printer.Print(vars, "Note that a newline in a variable will break " - "indenting, as we see$newline$here.\n"); - printer.Indent(); - printer.Print("And this"); - printer.Outdent(); - printer.Outdent(); - printer.Print(" is double-indented\nBack to normal."); - - EXPECT_FALSE(printer.failed()); - } - - buffer[output.ByteCount()] = '\0'; - - EXPECT_STREQ( - "This is not indented.\n" - " This is indented\n" - " And so is this\n" - "But this is not. And this is still the same line.\n" - " But this is indented.\n" - " RawBit has indent at start\n" - "but not after a raw newline\n" - "Note that a newline in a variable will break indenting, as we see\n" - "here.\n" - " And this is double-indented\n" - "Back to normal.", - buffer); - } -} - -// Death tests do not work on Windows as of yet. -#ifdef PROTOBUF_HAS_DEATH_TEST -TEST(Printer, Death) { - char buffer[8192]; - - ArrayOutputStream output(buffer, sizeof(buffer)); - Printer printer(&output, '$'); - - EXPECT_DEBUG_DEATH(printer.Print("$nosuchvar$"), "Undefined variable"); - EXPECT_DEBUG_DEATH(printer.Print("$unclosed"), "Unclosed variable name"); - EXPECT_DEBUG_DEATH(printer.Outdent(), "without matching Indent"); -} -#endif // PROTOBUF__HAS_DEATH_TEST - -TEST(Printer, WriteFailurePartial) { - char buffer[17]; - - ArrayOutputStream output(buffer, sizeof(buffer)); - Printer printer(&output, '$'); - - // Print 16 bytes to almost fill the buffer (should not fail). - printer.Print("0123456789abcdef"); - EXPECT_FALSE(printer.failed()); - - // Try to print 2 chars. Only one fits. - printer.Print("<>"); - EXPECT_TRUE(printer.failed()); - - // Anything else should fail too. - printer.Print(" "); - EXPECT_TRUE(printer.failed()); - printer.Print("blah"); - EXPECT_TRUE(printer.failed()); - - // Buffer should contain the first 17 bytes written. - EXPECT_EQ("0123456789abcdef<", string(buffer, sizeof(buffer))); -} - -TEST(Printer, WriteFailureExact) { - char buffer[16]; - - ArrayOutputStream output(buffer, sizeof(buffer)); - Printer printer(&output, '$'); - - // Print 16 bytes to fill the buffer exactly (should not fail). - printer.Print("0123456789abcdef"); - EXPECT_FALSE(printer.failed()); - - // Try to print one more byte (should fail). - printer.Print(" "); - EXPECT_TRUE(printer.failed()); - - // Should not crash - printer.Print("blah"); - EXPECT_TRUE(printer.failed()); - - // Buffer should contain the first 16 bytes written. - EXPECT_EQ("0123456789abcdef", string(buffer, sizeof(buffer))); -} - -} // namespace -} // namespace io -} // namespace protobuf -} // namespace google diff --git a/modules/dnn/3rdparty/protobuf/src/google/protobuf/io/tokenizer.cc b/modules/dnn/3rdparty/protobuf/src/google/protobuf/io/tokenizer.cc deleted file mode 100644 index a022b71db..000000000 --- a/modules/dnn/3rdparty/protobuf/src/google/protobuf/io/tokenizer.cc +++ /dev/null @@ -1,1091 +0,0 @@ -// Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// http://code.google.com/p/protobuf/ -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -// Author: kenton@google.com (Kenton Varda) -// Based on original Protocol Buffers design by -// Sanjay Ghemawat, Jeff Dean, and others. -// -// Here we have a hand-written lexer. At first you might ask yourself, -// "Hand-written text processing? Is Kenton crazy?!" Well, first of all, -// yes I am crazy, but that's beside the point. There are actually reasons -// why I ended up writing this this way. -// -// The traditional approach to lexing is to use lex to generate a lexer for -// you. Unfortunately, lex's output is ridiculously ugly and difficult to -// integrate cleanly with C++ code, especially abstract code or code meant -// as a library. Better parser-generators exist but would add dependencies -// which most users won't already have, which we'd like to avoid. (GNU flex -// has a C++ output option, but it's still ridiculously ugly, non-abstract, -// and not library-friendly.) -// -// The next approach that any good software engineer should look at is to -// use regular expressions. And, indeed, I did. I have code which -// implements this same class using regular expressions. It's about 200 -// lines shorter. However: -// - Rather than error messages telling you "This string has an invalid -// escape sequence at line 5, column 45", you get error messages like -// "Parse error on line 5". Giving more precise errors requires adding -// a lot of code that ends up basically as complex as the hand-coded -// version anyway. -// - The regular expression to match a string literal looks like this: -// kString = new RE("(\"([^\"\\\\]|" // non-escaped -// "\\\\[abfnrtv?\"'\\\\0-7]|" // normal escape -// "\\\\x[0-9a-fA-F])*\"|" // hex escape -// "\'([^\'\\\\]|" // Also support single-quotes. -// "\\\\[abfnrtv?\"'\\\\0-7]|" -// "\\\\x[0-9a-fA-F])*\')"); -// Verifying the correctness of this line noise is actually harder than -// verifying the correctness of ConsumeString(), defined below. I'm not -// even confident that the above is correct, after staring at it for some -// time. -// - PCRE is fast, but there's still more overhead involved than the code -// below. -// - Sadly, regular expressions are not part of the C standard library, so -// using them would require depending on some other library. For the -// open source release, this could be really annoying. Nobody likes -// downloading one piece of software just to find that they need to -// download something else to make it work, and in all likelihood -// people downloading Protocol Buffers will already be doing so just -// to make something else work. We could include a copy of PCRE with -// our code, but that obligates us to keep it up-to-date and just seems -// like a big waste just to save 200 lines of code. -// -// On a similar but unrelated note, I'm even scared to use ctype.h. -// Apparently functions like isalpha() are locale-dependent. So, if we used -// that, then if this code is being called from some program that doesn't -// have its locale set to "C", it would behave strangely. We can't just set -// the locale to "C" ourselves since we might break the calling program that -// way, particularly if it is multi-threaded. WTF? Someone please let me -// (Kenton) know if I'm missing something here... -// -// I'd love to hear about other alternatives, though, as this code isn't -// exactly pretty. - -#include -#include -#include -#include -#include -#include - -namespace google { -namespace protobuf { -namespace io { -namespace { - -// As mentioned above, I don't trust ctype.h due to the presence of "locales". -// So, I have written replacement functions here. Someone please smack me if -// this is a bad idea or if there is some way around this. -// -// These "character classes" are designed to be used in template methods. -// For instance, Tokenizer::ConsumeZeroOrMore() will eat -// whitespace. - -// Note: No class is allowed to contain '\0', since this is used to mark end- -// of-input and is handled specially. - -#define CHARACTER_CLASS(NAME, EXPRESSION) \ - class NAME { \ - public: \ - static inline bool InClass(char c) { \ - return EXPRESSION; \ - } \ - } - -CHARACTER_CLASS(Whitespace, c == ' ' || c == '\n' || c == '\t' || - c == '\r' || c == '\v' || c == '\f'); -CHARACTER_CLASS(WhitespaceNoNewline, c == ' ' || c == '\t' || - c == '\r' || c == '\v' || c == '\f'); - -CHARACTER_CLASS(Unprintable, c < ' ' && c > '\0'); - -CHARACTER_CLASS(Digit, '0' <= c && c <= '9'); -CHARACTER_CLASS(OctalDigit, '0' <= c && c <= '7'); -CHARACTER_CLASS(HexDigit, ('0' <= c && c <= '9') || - ('a' <= c && c <= 'f') || - ('A' <= c && c <= 'F')); - -CHARACTER_CLASS(Letter, ('a' <= c && c <= 'z') || - ('A' <= c && c <= 'Z') || - (c == '_')); - -CHARACTER_CLASS(Alphanumeric, ('a' <= c && c <= 'z') || - ('A' <= c && c <= 'Z') || - ('0' <= c && c <= '9') || - (c == '_')); - -CHARACTER_CLASS(Escape, c == 'a' || c == 'b' || c == 'f' || c == 'n' || - c == 'r' || c == 't' || c == 'v' || c == '\\' || - c == '?' || c == '\'' || c == '\"'); - -#undef CHARACTER_CLASS - -// Given a char, interpret it as a numeric digit and return its value. -// This supports any number base up to 36. -inline int DigitValue(char digit) { - if ('0' <= digit && digit <= '9') return digit - '0'; - if ('a' <= digit && digit <= 'z') return digit - 'a' + 10; - if ('A' <= digit && digit <= 'Z') return digit - 'A' + 10; - return -1; -} - -// Inline because it's only used in one place. -inline char TranslateEscape(char c) { - switch (c) { - case 'a': return '\a'; - case 'b': return '\b'; - case 'f': return '\f'; - case 'n': return '\n'; - case 'r': return '\r'; - case 't': return '\t'; - case 'v': return '\v'; - case '\\': return '\\'; - case '?': return '\?'; // Trigraphs = :( - case '\'': return '\''; - case '"': return '\"'; - - // We expect escape sequences to have been validated separately. - default: return '?'; - } -} - -} // anonymous namespace - -ErrorCollector::~ErrorCollector() {} - -// =================================================================== - -Tokenizer::Tokenizer(ZeroCopyInputStream* input, - ErrorCollector* error_collector) - : input_(input), - error_collector_(error_collector), - buffer_(NULL), - buffer_size_(0), - buffer_pos_(0), - read_error_(false), - line_(0), - column_(0), - record_target_(NULL), - record_start_(-1), - allow_f_after_float_(false), - comment_style_(CPP_COMMENT_STYLE) { - - current_.line = 0; - current_.column = 0; - current_.end_column = 0; - current_.type = TYPE_START; - - Refresh(); -} - -Tokenizer::~Tokenizer() { - // If we had any buffer left unread, return it to the underlying stream - // so that someone else can read it. - if (buffer_size_ > buffer_pos_) { - input_->BackUp(buffer_size_ - buffer_pos_); - } -} - -// ------------------------------------------------------------------- -// Internal helpers. - -void Tokenizer::NextChar() { - // Update our line and column counters based on the character being - // consumed. - if (current_char_ == '\n') { - ++line_; - column_ = 0; - } else if (current_char_ == '\t') { - column_ += kTabWidth - column_ % kTabWidth; - } else { - ++column_; - } - - // Advance to the next character. - ++buffer_pos_; - if (buffer_pos_ < buffer_size_) { - current_char_ = buffer_[buffer_pos_]; - } else { - Refresh(); - } -} - -void Tokenizer::Refresh() { - if (read_error_) { - current_char_ = '\0'; - return; - } - - // If we're in a token, append the rest of the buffer to it. - if (record_target_ != NULL && record_start_ < buffer_size_) { - record_target_->append(buffer_ + record_start_, buffer_size_ - record_start_); - record_start_ = 0; - } - - const void* data = NULL; - buffer_ = NULL; - buffer_pos_ = 0; - do { - if (!input_->Next(&data, &buffer_size_)) { - // end of stream (or read error) - buffer_size_ = 0; - read_error_ = true; - current_char_ = '\0'; - return; - } - } while (buffer_size_ == 0); - - buffer_ = static_cast(data); - - current_char_ = buffer_[0]; -} - -inline void Tokenizer::RecordTo(string* target) { - record_target_ = target; - record_start_ = buffer_pos_; -} - -inline void Tokenizer::StopRecording() { - // Note: The if() is necessary because some STL implementations crash when - // you call string::append(NULL, 0), presumably because they are trying to - // be helpful by detecting the NULL pointer, even though there's nothing - // wrong with reading zero bytes from NULL. - if (buffer_pos_ != record_start_) { - record_target_->append(buffer_ + record_start_, buffer_pos_ - record_start_); - } - record_target_ = NULL; - record_start_ = -1; -} - -inline void Tokenizer::StartToken() { - current_.type = TYPE_START; // Just for the sake of initializing it. - current_.text.clear(); - current_.line = line_; - current_.column = column_; - RecordTo(¤t_.text); -} - -inline void Tokenizer::EndToken() { - StopRecording(); - current_.end_column = column_; -} - -// ------------------------------------------------------------------- -// Helper methods that consume characters. - -template -inline bool Tokenizer::LookingAt() { - return CharacterClass::InClass(current_char_); -} - -template -inline bool Tokenizer::TryConsumeOne() { - if (CharacterClass::InClass(current_char_)) { - NextChar(); - return true; - } else { - return false; - } -} - -inline bool Tokenizer::TryConsume(char c) { - if (current_char_ == c) { - NextChar(); - return true; - } else { - return false; - } -} - -template -inline void Tokenizer::ConsumeZeroOrMore() { - while (CharacterClass::InClass(current_char_)) { - NextChar(); - } -} - -template -inline void Tokenizer::ConsumeOneOrMore(const char* error) { - if (!CharacterClass::InClass(current_char_)) { - AddError(error); - } else { - do { - NextChar(); - } while (CharacterClass::InClass(current_char_)); - } -} - -// ------------------------------------------------------------------- -// Methods that read whole patterns matching certain kinds of tokens -// or comments. - -void Tokenizer::ConsumeString(char delimiter) { - while (true) { - switch (current_char_) { - case '\0': - case '\n': { - AddError("String literals cannot cross line boundaries."); - return; - } - - case '\\': { - // An escape sequence. - NextChar(); - if (TryConsumeOne()) { - // Valid escape sequence. - } else if (TryConsumeOne()) { - // Possibly followed by two more octal digits, but these will - // just be consumed by the main loop anyway so we don't need - // to do so explicitly here. - } else if (TryConsume('x') || TryConsume('X')) { - if (!TryConsumeOne()) { - AddError("Expected hex digits for escape sequence."); - } - // Possibly followed by another hex digit, but again we don't care. - } else if (TryConsume('u')) { - if (!TryConsumeOne() || - !TryConsumeOne() || - !TryConsumeOne() || - !TryConsumeOne()) { - AddError("Expected four hex digits for \\u escape sequence."); - } - } else if (TryConsume('U')) { - // We expect 8 hex digits; but only the range up to 0x10ffff is - // legal. - if (!TryConsume('0') || - !TryConsume('0') || - !(TryConsume('0') || TryConsume('1')) || - !TryConsumeOne() || - !TryConsumeOne() || - !TryConsumeOne() || - !TryConsumeOne() || - !TryConsumeOne()) { - AddError("Expected eight hex digits up to 10ffff for \\U escape " - "sequence"); - } - } else { - AddError("Invalid escape sequence in string literal."); - } - break; - } - - default: { - if (current_char_ == delimiter) { - NextChar(); - return; - } - NextChar(); - break; - } - } - } -} - -Tokenizer::TokenType Tokenizer::ConsumeNumber(bool started_with_zero, - bool started_with_dot) { - bool is_float = false; - - if (started_with_zero && (TryConsume('x') || TryConsume('X'))) { - // A hex number (started with "0x"). - ConsumeOneOrMore("\"0x\" must be followed by hex digits."); - - } else if (started_with_zero && LookingAt()) { - // An octal number (had a leading zero). - ConsumeZeroOrMore(); - if (LookingAt()) { - AddError("Numbers starting with leading zero must be in octal."); - ConsumeZeroOrMore(); - } - - } else { - // A decimal number. - if (started_with_dot) { - is_float = true; - ConsumeZeroOrMore(); - } else { - ConsumeZeroOrMore(); - - if (TryConsume('.')) { - is_float = true; - ConsumeZeroOrMore(); - } - } - - if (TryConsume('e') || TryConsume('E')) { - is_float = true; - TryConsume('-') || TryConsume('+'); - ConsumeOneOrMore("\"e\" must be followed by exponent."); - } - - if (allow_f_after_float_ && (TryConsume('f') || TryConsume('F'))) { - is_float = true; - } - } - - if (LookingAt()) { - AddError("Need space between number and identifier."); - } else if (current_char_ == '.') { - if (is_float) { - AddError( - "Already saw decimal point or exponent; can't have another one."); - } else { - AddError("Hex and octal numbers must be integers."); - } - } - - return is_float ? TYPE_FLOAT : TYPE_INTEGER; -} - -void Tokenizer::ConsumeLineComment(string* content) { - if (content != NULL) RecordTo(content); - - while (current_char_ != '\0' && current_char_ != '\n') { - NextChar(); - } - TryConsume('\n'); - - if (content != NULL) StopRecording(); -} - -void Tokenizer::ConsumeBlockComment(string* content) { - int start_line = line_; - int start_column = column_ - 2; - - if (content != NULL) RecordTo(content); - - while (true) { - while (current_char_ != '\0' && - current_char_ != '*' && - current_char_ != '/' && - current_char_ != '\n') { - NextChar(); - } - - if (TryConsume('\n')) { - if (content != NULL) StopRecording(); - - // Consume leading whitespace and asterisk; - ConsumeZeroOrMore(); - if (TryConsume('*')) { - if (TryConsume('/')) { - // End of comment. - break; - } - } - - if (content != NULL) RecordTo(content); - } else if (TryConsume('*') && TryConsume('/')) { - // End of comment. - if (content != NULL) { - StopRecording(); - // Strip trailing "*/". - content->erase(content->size() - 2); - } - break; - } else if (TryConsume('/') && current_char_ == '*') { - // Note: We didn't consume the '*' because if there is a '/' after it - // we want to interpret that as the end of the comment. - AddError( - "\"/*\" inside block comment. Block comments cannot be nested."); - } else if (current_char_ == '\0') { - AddError("End-of-file inside block comment."); - error_collector_->AddError( - start_line, start_column, " Comment started here."); - if (content != NULL) StopRecording(); - break; - } - } -} - -Tokenizer::NextCommentStatus Tokenizer::TryConsumeCommentStart() { - if (comment_style_ == CPP_COMMENT_STYLE && TryConsume('/')) { - if (TryConsume('/')) { - return LINE_COMMENT; - } else if (TryConsume('*')) { - return BLOCK_COMMENT; - } else { - // Oops, it was just a slash. Return it. - current_.type = TYPE_SYMBOL; - current_.text = "/"; - current_.line = line_; - current_.column = column_ - 1; - current_.end_column = column_; - return SLASH_NOT_COMMENT; - } - } else if (comment_style_ == SH_COMMENT_STYLE && TryConsume('#')) { - return LINE_COMMENT; - } else { - return NO_COMMENT; - } -} - -// ------------------------------------------------------------------- - -bool Tokenizer::Next() { - previous_ = current_; - - while (!read_error_) { - ConsumeZeroOrMore(); - - switch (TryConsumeCommentStart()) { - case LINE_COMMENT: - ConsumeLineComment(NULL); - continue; - case BLOCK_COMMENT: - ConsumeBlockComment(NULL); - continue; - case SLASH_NOT_COMMENT: - return true; - case NO_COMMENT: - break; - } - - // Check for EOF before continuing. - if (read_error_) break; - - if (LookingAt() || current_char_ == '\0') { - AddError("Invalid control characters encountered in text."); - NextChar(); - // Skip more unprintable characters, too. But, remember that '\0' is - // also what current_char_ is set to after EOF / read error. We have - // to be careful not to go into an infinite loop of trying to consume - // it, so make sure to check read_error_ explicitly before consuming - // '\0'. - while (TryConsumeOne() || - (!read_error_ && TryConsume('\0'))) { - // Ignore. - } - - } else { - // Reading some sort of token. - StartToken(); - - if (TryConsumeOne()) { - ConsumeZeroOrMore(); - current_.type = TYPE_IDENTIFIER; - } else if (TryConsume('0')) { - current_.type = ConsumeNumber(true, false); - } else if (TryConsume('.')) { - // This could be the beginning of a floating-point number, or it could - // just be a '.' symbol. - - if (TryConsumeOne()) { - // It's a floating-point number. - if (previous_.type == TYPE_IDENTIFIER && - current_.line == previous_.line && - current_.column == previous_.end_column) { - // We don't accept syntax like "blah.123". - error_collector_->AddError(line_, column_ - 2, - "Need space between identifier and decimal point."); - } - current_.type = ConsumeNumber(false, true); - } else { - current_.type = TYPE_SYMBOL; - } - } else if (TryConsumeOne()) { - current_.type = ConsumeNumber(false, false); - } else if (TryConsume('\"')) { - ConsumeString('\"'); - current_.type = TYPE_STRING; - } else if (TryConsume('\'')) { - ConsumeString('\''); - current_.type = TYPE_STRING; - } else { - NextChar(); - current_.type = TYPE_SYMBOL; - } - - EndToken(); - return true; - } - } - - // EOF - current_.type = TYPE_END; - current_.text.clear(); - current_.line = line_; - current_.column = column_; - current_.end_column = column_; - return false; -} - -namespace { - -// Helper class for collecting comments and putting them in the right places. -// -// This basically just buffers the most recent comment until it can be decided -// exactly where that comment should be placed. When Flush() is called, the -// current comment goes into either prev_trailing_comments or detached_comments. -// When the CommentCollector is destroyed, the last buffered comment goes into -// next_leading_comments. -class CommentCollector { - public: - CommentCollector(string* prev_trailing_comments, - vector* detached_comments, - string* next_leading_comments) - : prev_trailing_comments_(prev_trailing_comments), - detached_comments_(detached_comments), - next_leading_comments_(next_leading_comments), - has_comment_(false), - is_line_comment_(false), - can_attach_to_prev_(true) { - if (prev_trailing_comments != NULL) prev_trailing_comments->clear(); - if (detached_comments != NULL) detached_comments->clear(); - if (next_leading_comments != NULL) next_leading_comments->clear(); - } - - ~CommentCollector() { - // Whatever is in the buffer is a leading comment. - if (next_leading_comments_ != NULL && has_comment_) { - comment_buffer_.swap(*next_leading_comments_); - } - } - - // About to read a line comment. Get the comment buffer pointer in order to - // read into it. - string* GetBufferForLineComment() { - // We want to combine with previous line comments, but not block comments. - if (has_comment_ && !is_line_comment_) { - Flush(); - } - has_comment_ = true; - is_line_comment_ = true; - return &comment_buffer_; - } - - // About to read a block comment. Get the comment buffer pointer in order to - // read into it. - string* GetBufferForBlockComment() { - if (has_comment_) { - Flush(); - } - has_comment_ = true; - is_line_comment_ = false; - return &comment_buffer_; - } - - void ClearBuffer() { - comment_buffer_.clear(); - has_comment_ = false; - } - - // Called once we know that the comment buffer is complete and is *not* - // connected to the next token. - void Flush() { - if (has_comment_) { - if (can_attach_to_prev_) { - if (prev_trailing_comments_ != NULL) { - prev_trailing_comments_->append(comment_buffer_); - } - can_attach_to_prev_ = false; - } else { - if (detached_comments_ != NULL) { - detached_comments_->push_back(comment_buffer_); - } - } - ClearBuffer(); - } - } - - void DetachFromPrev() { - can_attach_to_prev_ = false; - } - - private: - string* prev_trailing_comments_; - vector* detached_comments_; - string* next_leading_comments_; - - string comment_buffer_; - - // True if any comments were read into comment_buffer_. This can be true even - // if comment_buffer_ is empty, namely if the comment was "/**/". - bool has_comment_; - - // Is the comment in the comment buffer a line comment? - bool is_line_comment_; - - // Is it still possible that we could be reading a comment attached to the - // previous token? - bool can_attach_to_prev_; -}; - -} // namespace - -bool Tokenizer::NextWithComments(string* prev_trailing_comments, - vector* detached_comments, - string* next_leading_comments) { - CommentCollector collector(prev_trailing_comments, detached_comments, - next_leading_comments); - - if (current_.type == TYPE_START) { - collector.DetachFromPrev(); - } else { - // A comment appearing on the same line must be attached to the previous - // declaration. - ConsumeZeroOrMore(); - switch (TryConsumeCommentStart()) { - case LINE_COMMENT: - ConsumeLineComment(collector.GetBufferForLineComment()); - - // Don't allow comments on subsequent lines to be attached to a trailing - // comment. - collector.Flush(); - break; - case BLOCK_COMMENT: - ConsumeBlockComment(collector.GetBufferForBlockComment()); - - ConsumeZeroOrMore(); - if (!TryConsume('\n')) { - // Oops, the next token is on the same line. If we recorded a comment - // we really have no idea which token it should be attached to. - collector.ClearBuffer(); - return Next(); - } - - // Don't allow comments on subsequent lines to be attached to a trailing - // comment. - collector.Flush(); - break; - case SLASH_NOT_COMMENT: - return true; - case NO_COMMENT: - if (!TryConsume('\n')) { - // The next token is on the same line. There are no comments. - return Next(); - } - break; - } - } - - // OK, we are now on the line *after* the previous token. - while (true) { - ConsumeZeroOrMore(); - - switch (TryConsumeCommentStart()) { - case LINE_COMMENT: - ConsumeLineComment(collector.GetBufferForLineComment()); - break; - case BLOCK_COMMENT: - ConsumeBlockComment(collector.GetBufferForBlockComment()); - - // Consume the rest of the line so that we don't interpret it as a - // blank line the next time around the loop. - ConsumeZeroOrMore(); - TryConsume('\n'); - break; - case SLASH_NOT_COMMENT: - return true; - case NO_COMMENT: - if (TryConsume('\n')) { - // Completely blank line. - collector.Flush(); - collector.DetachFromPrev(); - } else { - bool result = Next(); - if (!result || - current_.text == "}" || - current_.text == "]" || - current_.text == ")") { - // It looks like we're at the end of a scope. In this case it - // makes no sense to attach a comment to the following token. - collector.Flush(); - } - return result; - } - break; - } - } -} - -// ------------------------------------------------------------------- -// Token-parsing helpers. Remember that these don't need to report -// errors since any errors should already have been reported while -// tokenizing. Also, these can assume that whatever text they -// are given is text that the tokenizer actually parsed as a token -// of the given type. - -bool Tokenizer::ParseInteger(const string& text, uint64 max_value, - uint64* output) { - // Sadly, we can't just use strtoul() since it is only 32-bit and strtoull() - // is non-standard. I hate the C standard library. :( - -// return strtoull(text.c_str(), NULL, 0); - - const char* ptr = text.c_str(); - int base = 10; - if (ptr[0] == '0') { - if (ptr[1] == 'x' || ptr[1] == 'X') { - // This is hex. - base = 16; - ptr += 2; - } else { - // This is octal. - base = 8; - } - } - - uint64 result = 0; - for (; *ptr != '\0'; ptr++) { - int digit = DigitValue(*ptr); - GOOGLE_LOG_IF(DFATAL, digit < 0 || digit >= base) - << " Tokenizer::ParseInteger() passed text that could not have been" - " tokenized as an integer: " << CEscape(text); - if (digit > max_value || result > (max_value - digit) / base) { - // Overflow. - return false; - } - result = result * base + digit; - } - - *output = result; - return true; -} - -double Tokenizer::ParseFloat(const string& text) { - const char* start = text.c_str(); - char* end; - double result = NoLocaleStrtod(start, &end); - - // "1e" is not a valid float, but if the tokenizer reads it, it will - // report an error but still return it as a valid token. We need to - // accept anything the tokenizer could possibly return, error or not. - if (*end == 'e' || *end == 'E') { - ++end; - if (*end == '-' || *end == '+') ++end; - } - - // If the Tokenizer had allow_f_after_float_ enabled, the float may be - // suffixed with the letter 'f'. - if (*end == 'f' || *end == 'F') { - ++end; - } - - GOOGLE_LOG_IF(DFATAL, end - start != text.size() || *start == '-') - << " Tokenizer::ParseFloat() passed text that could not have been" - " tokenized as a float: " << CEscape(text); - return result; -} - -// Helper to append a Unicode code point to a string as UTF8, without bringing -// in any external dependencies. -static void AppendUTF8(uint32 code_point, string* output) { - uint32 tmp = 0; - int len = 0; - if (code_point <= 0x7f) { - tmp = code_point; - len = 1; - } else if (code_point <= 0x07ff) { - tmp = 0x0000c080 | - ((code_point & 0x07c0) << 2) | - (code_point & 0x003f); - len = 2; - } else if (code_point <= 0xffff) { - tmp = 0x00e08080 | - ((code_point & 0xf000) << 4) | - ((code_point & 0x0fc0) << 2) | - (code_point & 0x003f); - len = 3; - } else if (code_point <= 0x1fffff) { - tmp = 0xf0808080 | - ((code_point & 0x1c0000) << 6) | - ((code_point & 0x03f000) << 4) | - ((code_point & 0x000fc0) << 2) | - (code_point & 0x003f); - len = 4; - } else { - // UTF-16 is only defined for code points up to 0x10FFFF, and UTF-8 is - // normally only defined up to there as well. - StringAppendF(output, "\\U%08x", code_point); - return; - } - tmp = ghtonl(tmp); - output->append(reinterpret_cast(&tmp) + sizeof(tmp) - len, len); -} - -// Try to read hex digits from ptr, and stuff the numeric result into -// *result. Returns true if that many digits were successfully consumed. -static bool ReadHexDigits(const char* ptr, int len, uint32* result) { - *result = 0; - if (len == 0) return false; - for (const char* end = ptr + len; ptr < end; ++ptr) { - if (*ptr == '\0') return false; - *result = (*result << 4) + DigitValue(*ptr); - } - return true; -} - -// Handling UTF-16 surrogate pairs. UTF-16 encodes code points in the range -// 0x10000...0x10ffff as a pair of numbers, a head surrogate followed by a trail -// surrogate. These numbers are in a reserved range of Unicode code points, so -// if we encounter such a pair we know how to parse it and convert it into a -// single code point. -static const uint32 kMinHeadSurrogate = 0xd800; -static const uint32 kMaxHeadSurrogate = 0xdc00; -static const uint32 kMinTrailSurrogate = 0xdc00; -static const uint32 kMaxTrailSurrogate = 0xe000; - -static inline bool IsHeadSurrogate(uint32 code_point) { - return (code_point >= kMinHeadSurrogate) && (code_point < kMaxHeadSurrogate); -} - -static inline bool IsTrailSurrogate(uint32 code_point) { - return (code_point >= kMinTrailSurrogate) && - (code_point < kMaxTrailSurrogate); -} - -// Combine a head and trail surrogate into a single Unicode code point. -static uint32 AssembleUTF16(uint32 head_surrogate, uint32 trail_surrogate) { - GOOGLE_DCHECK(IsHeadSurrogate(head_surrogate)); - GOOGLE_DCHECK(IsTrailSurrogate(trail_surrogate)); - return 0x10000 + (((head_surrogate - kMinHeadSurrogate) << 10) | - (trail_surrogate - kMinTrailSurrogate)); -} - -// Convert the escape sequence parameter to a number of expected hex digits. -static inline int UnicodeLength(char key) { - if (key == 'u') return 4; - if (key == 'U') return 8; - return 0; -} - -// Given a pointer to the 'u' or 'U' starting a Unicode escape sequence, attempt -// to parse that sequence. On success, returns a pointer to the first char -// beyond that sequence, and fills in *code_point. On failure, returns ptr -// itself. -static const char* FetchUnicodePoint(const char* ptr, uint32* code_point) { - const char* p = ptr; - // Fetch the code point. - const int len = UnicodeLength(*p++); - if (!ReadHexDigits(p, len, code_point)) - return ptr; - p += len; - - // Check if the code point we read is a "head surrogate." If so, then we - // expect it to be immediately followed by another code point which is a valid - // "trail surrogate," and together they form a UTF-16 pair which decodes into - // a single Unicode point. Trail surrogates may only use \u, not \U. - if (IsHeadSurrogate(*code_point) && *p == '\\' && *(p + 1) == 'u') { - uint32 trail_surrogate; - if (ReadHexDigits(p + 2, 4, &trail_surrogate) && - IsTrailSurrogate(trail_surrogate)) { - *code_point = AssembleUTF16(*code_point, trail_surrogate); - p += 6; - } - // If this failed, then we just emit the head surrogate as a code point. - // It's bogus, but so is the string. - } - - return p; -} - -// The text string must begin and end with single or double quote -// characters. -void Tokenizer::ParseStringAppend(const string& text, string* output) { - // Reminder: text[0] is always a quote character. (If text is - // empty, it's invalid, so we'll just return). - const size_t text_size = text.size(); - if (text_size == 0) { - GOOGLE_LOG(DFATAL) - << " Tokenizer::ParseStringAppend() passed text that could not" - " have been tokenized as a string: " << CEscape(text); - return; - } - - // Reserve room for new string. The branch is necessary because if - // there is already space available the reserve() call might - // downsize the output. - const size_t new_len = text_size + output->size(); - if (new_len > output->capacity()) { - output->reserve(new_len); - } - - // Loop through the string copying characters to "output" and - // interpreting escape sequences. Note that any invalid escape - // sequences or other errors were already reported while tokenizing. - // In this case we do not need to produce valid results. - for (const char* ptr = text.c_str() + 1; *ptr != '\0'; ptr++) { - if (*ptr == '\\' && ptr[1] != '\0') { - // An escape sequence. - ++ptr; - - if (OctalDigit::InClass(*ptr)) { - // An octal escape. May one, two, or three digits. - int code = DigitValue(*ptr); - if (OctalDigit::InClass(ptr[1])) { - ++ptr; - code = code * 8 + DigitValue(*ptr); - } - if (OctalDigit::InClass(ptr[1])) { - ++ptr; - code = code * 8 + DigitValue(*ptr); - } - output->push_back(static_cast(code)); - - } else if (*ptr == 'x') { - // A hex escape. May zero, one, or two digits. (The zero case - // will have been caught as an error earlier.) - int code = 0; - if (HexDigit::InClass(ptr[1])) { - ++ptr; - code = DigitValue(*ptr); - } - if (HexDigit::InClass(ptr[1])) { - ++ptr; - code = code * 16 + DigitValue(*ptr); - } - output->push_back(static_cast(code)); - - } else if (*ptr == 'u' || *ptr == 'U') { - uint32 unicode; - const char* end = FetchUnicodePoint(ptr, &unicode); - if (end == ptr) { - // Failure: Just dump out what we saw, don't try to parse it. - output->push_back(*ptr); - } else { - AppendUTF8(unicode, output); - ptr = end - 1; // Because we're about to ++ptr. - } - } else { - // Some other escape code. - output->push_back(TranslateEscape(*ptr)); - } - - } else if (*ptr == text[0] && ptr[1] == '\0') { - // Ignore final quote matching the starting quote. - } else { - output->push_back(*ptr); - } - } -} - -} // namespace io -} // namespace protobuf -} // namespace google diff --git a/modules/dnn/3rdparty/protobuf/src/google/protobuf/io/tokenizer.h b/modules/dnn/3rdparty/protobuf/src/google/protobuf/io/tokenizer.h deleted file mode 100644 index d85b82f9d..000000000 --- a/modules/dnn/3rdparty/protobuf/src/google/protobuf/io/tokenizer.h +++ /dev/null @@ -1,384 +0,0 @@ -// Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// http://code.google.com/p/protobuf/ -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -// Author: kenton@google.com (Kenton Varda) -// Based on original Protocol Buffers design by -// Sanjay Ghemawat, Jeff Dean, and others. -// -// Class for parsing tokenized text from a ZeroCopyInputStream. - -#ifndef GOOGLE_PROTOBUF_IO_TOKENIZER_H__ -#define GOOGLE_PROTOBUF_IO_TOKENIZER_H__ - -#include -#include -#include - -namespace google { -namespace protobuf { -namespace io { - -class ZeroCopyInputStream; // zero_copy_stream.h - -// Defined in this file. -class ErrorCollector; -class Tokenizer; - -// Abstract interface for an object which collects the errors that occur -// during parsing. A typical implementation might simply print the errors -// to stdout. -class LIBPROTOBUF_EXPORT ErrorCollector { - public: - inline ErrorCollector() {} - virtual ~ErrorCollector(); - - // Indicates that there was an error in the input at the given line and - // column numbers. The numbers are zero-based, so you may want to add - // 1 to each before printing them. - virtual void AddError(int line, int column, const string& message) = 0; - - // Indicates that there was a warning in the input at the given line and - // column numbers. The numbers are zero-based, so you may want to add - // 1 to each before printing them. - virtual void AddWarning(int line, int column, const string& message) { } - - private: - GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ErrorCollector); -}; - -// This class converts a stream of raw text into a stream of tokens for -// the protocol definition parser to parse. The tokens recognized are -// similar to those that make up the C language; see the TokenType enum for -// precise descriptions. Whitespace and comments are skipped. By default, -// C- and C++-style comments are recognized, but other styles can be used by -// calling set_comment_style(). -class LIBPROTOBUF_EXPORT Tokenizer { - public: - // Construct a Tokenizer that reads and tokenizes text from the given - // input stream and writes errors to the given error_collector. - // The caller keeps ownership of input and error_collector. - Tokenizer(ZeroCopyInputStream* input, ErrorCollector* error_collector); - ~Tokenizer(); - - enum TokenType { - TYPE_START, // Next() has not yet been called. - TYPE_END, // End of input reached. "text" is empty. - - TYPE_IDENTIFIER, // A sequence of letters, digits, and underscores, not - // starting with a digit. It is an error for a number - // to be followed by an identifier with no space in - // between. - TYPE_INTEGER, // A sequence of digits representing an integer. Normally - // the digits are decimal, but a prefix of "0x" indicates - // a hex number and a leading zero indicates octal, just - // like with C numeric literals. A leading negative sign - // is NOT included in the token; it's up to the parser to - // interpret the unary minus operator on its own. - TYPE_FLOAT, // A floating point literal, with a fractional part and/or - // an exponent. Always in decimal. Again, never - // negative. - TYPE_STRING, // A quoted sequence of escaped characters. Either single - // or double quotes can be used, but they must match. - // A string literal cannot cross a line break. - TYPE_SYMBOL, // Any other printable character, like '!' or '+'. - // Symbols are always a single character, so "!+$%" is - // four tokens. - }; - - // Structure representing a token read from the token stream. - struct Token { - TokenType type; - string text; // The exact text of the token as it appeared in - // the input. e.g. tokens of TYPE_STRING will still - // be escaped and in quotes. - - // "line" and "column" specify the position of the first character of - // the token within the input stream. They are zero-based. - int line; - int column; - int end_column; - }; - - // Get the current token. This is updated when Next() is called. Before - // the first call to Next(), current() has type TYPE_START and no contents. - const Token& current(); - - // Return the previous token -- i.e. what current() returned before the - // previous call to Next(). - const Token& previous(); - - // Advance to the next token. Returns false if the end of the input is - // reached. - bool Next(); - - // Like Next(), but also collects comments which appear between the previous - // and next tokens. - // - // Comments which appear to be attached to the previous token are stored - // in *prev_tailing_comments. Comments which appear to be attached to the - // next token are stored in *next_leading_comments. Comments appearing in - // between which do not appear to be attached to either will be added to - // detached_comments. Any of these parameters can be NULL to simply discard - // the comments. - // - // A series of line comments appearing on consecutive lines, with no other - // tokens appearing on those lines, will be treated as a single comment. - // - // Only the comment content is returned; comment markers (e.g. //) are - // stripped out. For block comments, leading whitespace and an asterisk will - // be stripped from the beginning of each line other than the first. Newlines - // are included in the output. - // - // Examples: - // - // optional int32 foo = 1; // Comment attached to foo. - // // Comment attached to bar. - // optional int32 bar = 2; - // - // optional string baz = 3; - // // Comment attached to baz. - // // Another line attached to baz. - // - // // Comment attached to qux. - // // - // // Another line attached to qux. - // optional double qux = 4; - // - // // Detached comment. This is not attached to qux or corge - // // because there are blank lines separating it from both. - // - // optional string corge = 5; - // /* Block comment attached - // * to corge. Leading asterisks - // * will be removed. */ - // /* Block comment attached to - // * grault. */ - // optional int32 grault = 6; - bool NextWithComments(string* prev_trailing_comments, - vector* detached_comments, - string* next_leading_comments); - - // Parse helpers --------------------------------------------------- - - // Parses a TYPE_FLOAT token. This never fails, so long as the text actually - // comes from a TYPE_FLOAT token parsed by Tokenizer. If it doesn't, the - // result is undefined (possibly an assert failure). - static double ParseFloat(const string& text); - - // Parses a TYPE_STRING token. This never fails, so long as the text actually - // comes from a TYPE_STRING token parsed by Tokenizer. If it doesn't, the - // result is undefined (possibly an assert failure). - static void ParseString(const string& text, string* output); - - // Identical to ParseString, but appends to output. - static void ParseStringAppend(const string& text, string* output); - - // Parses a TYPE_INTEGER token. Returns false if the result would be - // greater than max_value. Otherwise, returns true and sets *output to the - // result. If the text is not from a Token of type TYPE_INTEGER originally - // parsed by a Tokenizer, the result is undefined (possibly an assert - // failure). - static bool ParseInteger(const string& text, uint64 max_value, - uint64* output); - - // Options --------------------------------------------------------- - - // Set true to allow floats to be suffixed with the letter 'f'. Tokens - // which would otherwise be integers but which have the 'f' suffix will be - // forced to be interpreted as floats. For all other purposes, the 'f' is - // ignored. - void set_allow_f_after_float(bool value) { allow_f_after_float_ = value; } - - // Valid values for set_comment_style(). - enum CommentStyle { - // Line comments begin with "//", block comments are delimited by "/*" and - // "*/". - CPP_COMMENT_STYLE, - // Line comments begin with "#". No way to write block comments. - SH_COMMENT_STYLE - }; - - // Sets the comment style. - void set_comment_style(CommentStyle style) { comment_style_ = style; } - - // ----------------------------------------------------------------- - private: - GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(Tokenizer); - - Token current_; // Returned by current(). - Token previous_; // Returned by previous(). - - ZeroCopyInputStream* input_; - ErrorCollector* error_collector_; - - char current_char_; // == buffer_[buffer_pos_], updated by NextChar(). - const char* buffer_; // Current buffer returned from input_. - int buffer_size_; // Size of buffer_. - int buffer_pos_; // Current position within the buffer. - bool read_error_; // Did we previously encounter a read error? - - // Line and column number of current_char_ within the whole input stream. - int line_; - int column_; - - // String to which text should be appended as we advance through it. - // Call RecordTo(&str) to start recording and StopRecording() to stop. - // E.g. StartToken() calls RecordTo(¤t_.text). record_start_ is the - // position within the current buffer where recording started. - string* record_target_; - int record_start_; - - // Options. - bool allow_f_after_float_; - CommentStyle comment_style_; - - // Since we count columns we need to interpret tabs somehow. We'll take - // the standard 8-character definition for lack of any way to do better. - static const int kTabWidth = 8; - - // ----------------------------------------------------------------- - // Helper methods. - - // Consume this character and advance to the next one. - void NextChar(); - - // Read a new buffer from the input. - void Refresh(); - - inline void RecordTo(string* target); - inline void StopRecording(); - - // Called when the current character is the first character of a new - // token (not including whitespace or comments). - inline void StartToken(); - // Called when the current character is the first character after the - // end of the last token. After this returns, current_.text will - // contain all text consumed since StartToken() was called. - inline void EndToken(); - - // Convenience method to add an error at the current line and column. - void AddError(const string& message) { - error_collector_->AddError(line_, column_, message); - } - - // ----------------------------------------------------------------- - // The following four methods are used to consume tokens of specific - // types. They are actually used to consume all characters *after* - // the first, since the calling function consumes the first character - // in order to decide what kind of token is being read. - - // Read and consume a string, ending when the given delimiter is - // consumed. - void ConsumeString(char delimiter); - - // Read and consume a number, returning TYPE_FLOAT or TYPE_INTEGER - // depending on what was read. This needs to know if the first - // character was a zero in order to correctly recognize hex and octal - // numbers. - // It also needs to know if the first characted was a . to parse floating - // point correctly. - TokenType ConsumeNumber(bool started_with_zero, bool started_with_dot); - - // Consume the rest of a line. - void ConsumeLineComment(string* content); - // Consume until "*/". - void ConsumeBlockComment(string* content); - - enum NextCommentStatus { - // Started a line comment. - LINE_COMMENT, - - // Started a block comment. - BLOCK_COMMENT, - - // Consumed a slash, then realized it wasn't a comment. current_ has - // been filled in with a slash token. The caller should return it. - SLASH_NOT_COMMENT, - - // We do not appear to be starting a comment here. - NO_COMMENT - }; - - // If we're at the start of a new comment, consume it and return what kind - // of comment it is. - NextCommentStatus TryConsumeCommentStart(); - - // ----------------------------------------------------------------- - // These helper methods make the parsing code more readable. The - // "character classes" refered to are defined at the top of the .cc file. - // Basically it is a C++ class with one method: - // static bool InClass(char c); - // The method returns true if c is a member of this "class", like "Letter" - // or "Digit". - - // Returns true if the current character is of the given character - // class, but does not consume anything. - template - inline bool LookingAt(); - - // If the current character is in the given class, consume it and return - // true. Otherwise return false. - // e.g. TryConsumeOne() - template - inline bool TryConsumeOne(); - - // Like above, but try to consume the specific character indicated. - inline bool TryConsume(char c); - - // Consume zero or more of the given character class. - template - inline void ConsumeZeroOrMore(); - - // Consume one or more of the given character class or log the given - // error message. - // e.g. ConsumeOneOrMore("Expected digits."); - template - inline void ConsumeOneOrMore(const char* error); -}; - -// inline methods ==================================================== -inline const Tokenizer::Token& Tokenizer::current() { - return current_; -} - -inline const Tokenizer::Token& Tokenizer::previous() { - return previous_; -} - -inline void Tokenizer::ParseString(const string& text, string* output) { - output->clear(); - ParseStringAppend(text, output); -} - -} // namespace io -} // namespace protobuf - -} // namespace google -#endif // GOOGLE_PROTOBUF_IO_TOKENIZER_H__ diff --git a/modules/dnn/3rdparty/protobuf/src/google/protobuf/io/tokenizer_unittest.cc b/modules/dnn/3rdparty/protobuf/src/google/protobuf/io/tokenizer_unittest.cc deleted file mode 100644 index dbb5be4f6..000000000 --- a/modules/dnn/3rdparty/protobuf/src/google/protobuf/io/tokenizer_unittest.cc +++ /dev/null @@ -1,1001 +0,0 @@ -// Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// http://code.google.com/p/protobuf/ -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -// Author: kenton@google.com (Kenton Varda) -// Based on original Protocol Buffers design by -// Sanjay Ghemawat, Jeff Dean, and others. - -#include -#include - -#include - -#include -#include - -#include -#include -#include -#include -#include - -namespace google { -namespace protobuf { -namespace io { -namespace { - -// =================================================================== -// Data-Driven Test Infrastructure - -// TODO(kenton): This is copied from coded_stream_unittest. This is -// temporary until these fetaures are integrated into gTest itself. - -// TEST_1D and TEST_2D are macros I'd eventually like to see added to -// gTest. These macros can be used to declare tests which should be -// run multiple times, once for each item in some input array. TEST_1D -// tests all cases in a single input array. TEST_2D tests all -// combinations of cases from two arrays. The arrays must be statically -// defined such that the GOOGLE_ARRAYSIZE() macro works on them. Example: -// -// int kCases[] = {1, 2, 3, 4} -// TEST_1D(MyFixture, MyTest, kCases) { -// EXPECT_GT(kCases_case, 0); -// } -// -// This test iterates through the numbers 1, 2, 3, and 4 and tests that -// they are all grater than zero. In case of failure, the exact case -// which failed will be printed. The case type must be printable using -// ostream::operator<<. - -#define TEST_1D(FIXTURE, NAME, CASES) \ - class FIXTURE##_##NAME##_DD : public FIXTURE { \ - protected: \ - template \ - void DoSingleCase(const CaseType& CASES##_case); \ - }; \ - \ - TEST_F(FIXTURE##_##NAME##_DD, NAME) { \ - for (int i = 0; i < GOOGLE_ARRAYSIZE(CASES); i++) { \ - SCOPED_TRACE(testing::Message() \ - << #CASES " case #" << i << ": " << CASES[i]); \ - DoSingleCase(CASES[i]); \ - } \ - } \ - \ - template \ - void FIXTURE##_##NAME##_DD::DoSingleCase(const CaseType& CASES##_case) - -#define TEST_2D(FIXTURE, NAME, CASES1, CASES2) \ - class FIXTURE##_##NAME##_DD : public FIXTURE { \ - protected: \ - template \ - void DoSingleCase(const CaseType1& CASES1##_case, \ - const CaseType2& CASES2##_case); \ - }; \ - \ - TEST_F(FIXTURE##_##NAME##_DD, NAME) { \ - for (int i = 0; i < GOOGLE_ARRAYSIZE(CASES1); i++) { \ - for (int j = 0; j < GOOGLE_ARRAYSIZE(CASES2); j++) { \ - SCOPED_TRACE(testing::Message() \ - << #CASES1 " case #" << i << ": " << CASES1[i] << ", " \ - << #CASES2 " case #" << j << ": " << CASES2[j]); \ - DoSingleCase(CASES1[i], CASES2[j]); \ - } \ - } \ - } \ - \ - template \ - void FIXTURE##_##NAME##_DD::DoSingleCase(const CaseType1& CASES1##_case, \ - const CaseType2& CASES2##_case) - -// ------------------------------------------------------------------- - -// An input stream that is basically like an ArrayInputStream but sometimes -// returns empty buffers, just to throw us off. -class TestInputStream : public ZeroCopyInputStream { - public: - TestInputStream(const void* data, int size, int block_size) - : array_stream_(data, size, block_size), counter_(0) {} - ~TestInputStream() {} - - // implements ZeroCopyInputStream ---------------------------------- - bool Next(const void** data, int* size) { - // We'll return empty buffers starting with the first buffer, and every - // 3 and 5 buffers after that. - if (counter_ % 3 == 0 || counter_ % 5 == 0) { - *data = NULL; - *size = 0; - ++counter_; - return true; - } else { - ++counter_; - return array_stream_.Next(data, size); - } - } - - void BackUp(int count) { return array_stream_.BackUp(count); } - bool Skip(int count) { return array_stream_.Skip(count); } - int64 ByteCount() const { return array_stream_.ByteCount(); } - - private: - ArrayInputStream array_stream_; - int counter_; -}; - -// ------------------------------------------------------------------- - -// An error collector which simply concatenates all its errors into a big -// block of text which can be checked. -class TestErrorCollector : public ErrorCollector { - public: - TestErrorCollector() {} - ~TestErrorCollector() {} - - string text_; - - // implements ErrorCollector --------------------------------------- - void AddError(int line, int column, const string& message) { - strings::SubstituteAndAppend(&text_, "$0:$1: $2\n", - line, column, message); - } -}; - -// ------------------------------------------------------------------- - -// We test each operation over a variety of block sizes to insure that -// we test cases where reads cross buffer boundaries as well as cases -// where they don't. This is sort of a brute-force approach to this, -// but it's easy to write and easy to understand. -const int kBlockSizes[] = {1, 2, 3, 5, 7, 13, 32, 1024}; - -class TokenizerTest : public testing::Test { - protected: - // For easy testing. - uint64 ParseInteger(const string& text) { - uint64 result; - EXPECT_TRUE(Tokenizer::ParseInteger(text, kuint64max, &result)); - return result; - } -}; - -// =================================================================== - -// These tests causes gcc 3.3.5 (and earlier?) to give the cryptic error: -// "sorry, unimplemented: `method_call_expr' not supported by dump_expr" -#if !defined(__GNUC__) || __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ > 3) - -// In each test case, the entire input text should parse as a single token -// of the given type. -struct SimpleTokenCase { - string input; - Tokenizer::TokenType type; -}; - -inline ostream& operator<<(ostream& out, - const SimpleTokenCase& test_case) { - return out << CEscape(test_case.input); -} - -SimpleTokenCase kSimpleTokenCases[] = { - // Test identifiers. - { "hello", Tokenizer::TYPE_IDENTIFIER }, - - // Test integers. - { "123", Tokenizer::TYPE_INTEGER }, - { "0xab6", Tokenizer::TYPE_INTEGER }, - { "0XAB6", Tokenizer::TYPE_INTEGER }, - { "0X1234567", Tokenizer::TYPE_INTEGER }, - { "0x89abcdef", Tokenizer::TYPE_INTEGER }, - { "0x89ABCDEF", Tokenizer::TYPE_INTEGER }, - { "01234567", Tokenizer::TYPE_INTEGER }, - - // Test floats. - { "123.45", Tokenizer::TYPE_FLOAT }, - { "1.", Tokenizer::TYPE_FLOAT }, - { "1e3", Tokenizer::TYPE_FLOAT }, - { "1E3", Tokenizer::TYPE_FLOAT }, - { "1e-3", Tokenizer::TYPE_FLOAT }, - { "1e+3", Tokenizer::TYPE_FLOAT }, - { "1.e3", Tokenizer::TYPE_FLOAT }, - { "1.2e3", Tokenizer::TYPE_FLOAT }, - { ".1", Tokenizer::TYPE_FLOAT }, - { ".1e3", Tokenizer::TYPE_FLOAT }, - { ".1e-3", Tokenizer::TYPE_FLOAT }, - { ".1e+3", Tokenizer::TYPE_FLOAT }, - - // Test strings. - { "'hello'", Tokenizer::TYPE_STRING }, - { "\"foo\"", Tokenizer::TYPE_STRING }, - { "'a\"b'", Tokenizer::TYPE_STRING }, - { "\"a'b\"", Tokenizer::TYPE_STRING }, - { "'a\\'b'", Tokenizer::TYPE_STRING }, - { "\"a\\\"b\"", Tokenizer::TYPE_STRING }, - { "'\\xf'", Tokenizer::TYPE_STRING }, - { "'\\0'", Tokenizer::TYPE_STRING }, - - // Test symbols. - { "+", Tokenizer::TYPE_SYMBOL }, - { ".", Tokenizer::TYPE_SYMBOL }, -}; - -TEST_2D(TokenizerTest, SimpleTokens, kSimpleTokenCases, kBlockSizes) { - // Set up the tokenizer. - TestInputStream input(kSimpleTokenCases_case.input.data(), - kSimpleTokenCases_case.input.size(), - kBlockSizes_case); - TestErrorCollector error_collector; - Tokenizer tokenizer(&input, &error_collector); - - // Before Next() is called, the initial token should always be TYPE_START. - EXPECT_EQ(Tokenizer::TYPE_START, tokenizer.current().type); - EXPECT_EQ("", tokenizer.current().text); - EXPECT_EQ(0, tokenizer.current().line); - EXPECT_EQ(0, tokenizer.current().column); - EXPECT_EQ(0, tokenizer.current().end_column); - - // Parse the token. - ASSERT_TRUE(tokenizer.Next()); - - // Check that it has the right type. - EXPECT_EQ(kSimpleTokenCases_case.type, tokenizer.current().type); - // Check that it contains the complete input text. - EXPECT_EQ(kSimpleTokenCases_case.input, tokenizer.current().text); - // Check that it is located at the beginning of the input - EXPECT_EQ(0, tokenizer.current().line); - EXPECT_EQ(0, tokenizer.current().column); - EXPECT_EQ(kSimpleTokenCases_case.input.size(), - tokenizer.current().end_column); - - // There should be no more input. - EXPECT_FALSE(tokenizer.Next()); - - // After Next() returns false, the token should have type TYPE_END. - EXPECT_EQ(Tokenizer::TYPE_END, tokenizer.current().type); - EXPECT_EQ("", tokenizer.current().text); - EXPECT_EQ(0, tokenizer.current().line); - EXPECT_EQ(kSimpleTokenCases_case.input.size(), tokenizer.current().column); - EXPECT_EQ(kSimpleTokenCases_case.input.size(), - tokenizer.current().end_column); - - // There should be no errors. - EXPECT_TRUE(error_collector.text_.empty()); -} - -TEST_1D(TokenizerTest, FloatSuffix, kBlockSizes) { - // Test the "allow_f_after_float" option. - - // Set up the tokenizer. - const char* text = "1f 2.5f 6e3f 7F"; - TestInputStream input(text, strlen(text), kBlockSizes_case); - TestErrorCollector error_collector; - Tokenizer tokenizer(&input, &error_collector); - tokenizer.set_allow_f_after_float(true); - - // Advance through tokens and check that they are parsed as expected. - ASSERT_TRUE(tokenizer.Next()); - EXPECT_EQ(tokenizer.current().text, "1f"); - EXPECT_EQ(tokenizer.current().type, Tokenizer::TYPE_FLOAT); - ASSERT_TRUE(tokenizer.Next()); - EXPECT_EQ(tokenizer.current().text, "2.5f"); - EXPECT_EQ(tokenizer.current().type, Tokenizer::TYPE_FLOAT); - ASSERT_TRUE(tokenizer.Next()); - EXPECT_EQ(tokenizer.current().text, "6e3f"); - EXPECT_EQ(tokenizer.current().type, Tokenizer::TYPE_FLOAT); - ASSERT_TRUE(tokenizer.Next()); - EXPECT_EQ(tokenizer.current().text, "7F"); - EXPECT_EQ(tokenizer.current().type, Tokenizer::TYPE_FLOAT); - - // There should be no more input. - EXPECT_FALSE(tokenizer.Next()); - // There should be no errors. - EXPECT_TRUE(error_collector.text_.empty()); -} - -#endif - -// ------------------------------------------------------------------- - -// In each case, the input is parsed to produce a list of tokens. The -// last token in "output" must have type TYPE_END. -struct MultiTokenCase { - string input; - Tokenizer::Token output[10]; // The compiler wants a constant array - // size for initialization to work. There - // is no reason this can't be increased if - // needed. -}; - -inline ostream& operator<<(ostream& out, - const MultiTokenCase& test_case) { - return out << CEscape(test_case.input); -} - -MultiTokenCase kMultiTokenCases[] = { - // Test empty input. - { "", { - { Tokenizer::TYPE_END , "" , 0, 0 }, - }}, - - // Test all token types at the same time. - { "foo 1 1.2 + 'bar'", { - { Tokenizer::TYPE_IDENTIFIER, "foo" , 0, 0, 3 }, - { Tokenizer::TYPE_INTEGER , "1" , 0, 4, 5 }, - { Tokenizer::TYPE_FLOAT , "1.2" , 0, 6, 9 }, - { Tokenizer::TYPE_SYMBOL , "+" , 0, 10, 11 }, - { Tokenizer::TYPE_STRING , "'bar'", 0, 12, 17 }, - { Tokenizer::TYPE_END , "" , 0, 17, 17 }, - }}, - - // Test that consecutive symbols are parsed as separate tokens. - { "!@+%", { - { Tokenizer::TYPE_SYMBOL , "!" , 0, 0, 1 }, - { Tokenizer::TYPE_SYMBOL , "@" , 0, 1, 2 }, - { Tokenizer::TYPE_SYMBOL , "+" , 0, 2, 3 }, - { Tokenizer::TYPE_SYMBOL , "%" , 0, 3, 4 }, - { Tokenizer::TYPE_END , "" , 0, 4, 4 }, - }}, - - // Test that newlines affect line numbers correctly. - { "foo bar\nrab oof", { - { Tokenizer::TYPE_IDENTIFIER, "foo", 0, 0, 3 }, - { Tokenizer::TYPE_IDENTIFIER, "bar", 0, 4, 7 }, - { Tokenizer::TYPE_IDENTIFIER, "rab", 1, 0, 3 }, - { Tokenizer::TYPE_IDENTIFIER, "oof", 1, 4, 7 }, - { Tokenizer::TYPE_END , "" , 1, 7, 7 }, - }}, - - // Test that tabs affect column numbers correctly. - { "foo\tbar \tbaz", { - { Tokenizer::TYPE_IDENTIFIER, "foo", 0, 0, 3 }, - { Tokenizer::TYPE_IDENTIFIER, "bar", 0, 8, 11 }, - { Tokenizer::TYPE_IDENTIFIER, "baz", 0, 16, 19 }, - { Tokenizer::TYPE_END , "" , 0, 19, 19 }, - }}, - - // Test that tabs in string literals affect column numbers correctly. - { "\"foo\tbar\" baz", { - { Tokenizer::TYPE_STRING , "\"foo\tbar\"", 0, 0, 12 }, - { Tokenizer::TYPE_IDENTIFIER, "baz" , 0, 13, 16 }, - { Tokenizer::TYPE_END , "" , 0, 16, 16 }, - }}, - - // Test that line comments are ignored. - { "foo // This is a comment\n" - "bar // This is another comment", { - { Tokenizer::TYPE_IDENTIFIER, "foo", 0, 0, 3 }, - { Tokenizer::TYPE_IDENTIFIER, "bar", 1, 0, 3 }, - { Tokenizer::TYPE_END , "" , 1, 30, 30 }, - }}, - - // Test that block comments are ignored. - { "foo /* This is a block comment */ bar", { - { Tokenizer::TYPE_IDENTIFIER, "foo", 0, 0, 3 }, - { Tokenizer::TYPE_IDENTIFIER, "bar", 0, 34, 37 }, - { Tokenizer::TYPE_END , "" , 0, 37, 37 }, - }}, - - // Test that sh-style comments are not ignored by default. - { "foo # bar\n" - "baz", { - { Tokenizer::TYPE_IDENTIFIER, "foo", 0, 0, 3 }, - { Tokenizer::TYPE_SYMBOL , "#" , 0, 4, 5 }, - { Tokenizer::TYPE_IDENTIFIER, "bar", 0, 6, 9 }, - { Tokenizer::TYPE_IDENTIFIER, "baz", 1, 0, 3 }, - { Tokenizer::TYPE_END , "" , 1, 3, 3 }, - }}, - - // Bytes with the high-order bit set should not be seen as control characters. - { "\300", { - { Tokenizer::TYPE_SYMBOL, "\300", 0, 0, 1 }, - { Tokenizer::TYPE_END , "" , 0, 1, 1 }, - }}, - - // Test all whitespace chars - { "foo\n\t\r\v\fbar", { - { Tokenizer::TYPE_IDENTIFIER, "foo", 0, 0, 3 }, - { Tokenizer::TYPE_IDENTIFIER, "bar", 1, 11, 14 }, - { Tokenizer::TYPE_END , "" , 1, 14, 14 }, - }}, -}; - -TEST_2D(TokenizerTest, MultipleTokens, kMultiTokenCases, kBlockSizes) { - // Set up the tokenizer. - TestInputStream input(kMultiTokenCases_case.input.data(), - kMultiTokenCases_case.input.size(), - kBlockSizes_case); - TestErrorCollector error_collector; - Tokenizer tokenizer(&input, &error_collector); - - // Before Next() is called, the initial token should always be TYPE_START. - EXPECT_EQ(Tokenizer::TYPE_START, tokenizer.current().type); - EXPECT_EQ("", tokenizer.current().text); - EXPECT_EQ(0, tokenizer.current().line); - EXPECT_EQ(0, tokenizer.current().column); - EXPECT_EQ(0, tokenizer.current().end_column); - - // Loop through all expected tokens. - int i = 0; - Tokenizer::Token token; - do { - token = kMultiTokenCases_case.output[i++]; - - SCOPED_TRACE(testing::Message() << "Token #" << i << ": " << token.text); - - Tokenizer::Token previous = tokenizer.current(); - - // Next() should only return false when it hits the end token. - if (token.type != Tokenizer::TYPE_END) { - ASSERT_TRUE(tokenizer.Next()); - } else { - ASSERT_FALSE(tokenizer.Next()); - } - - // Check that the previous token is set correctly. - EXPECT_EQ(previous.type, tokenizer.previous().type); - EXPECT_EQ(previous.text, tokenizer.previous().text); - EXPECT_EQ(previous.line, tokenizer.previous().line); - EXPECT_EQ(previous.column, tokenizer.previous().column); - EXPECT_EQ(previous.end_column, tokenizer.previous().end_column); - - // Check that the token matches the expected one. - EXPECT_EQ(token.type, tokenizer.current().type); - EXPECT_EQ(token.text, tokenizer.current().text); - EXPECT_EQ(token.line, tokenizer.current().line); - EXPECT_EQ(token.column, tokenizer.current().column); - EXPECT_EQ(token.end_column, tokenizer.current().end_column); - - } while (token.type != Tokenizer::TYPE_END); - - // There should be no errors. - EXPECT_TRUE(error_collector.text_.empty()); -} - -// This test causes gcc 3.3.5 (and earlier?) to give the cryptic error: -// "sorry, unimplemented: `method_call_expr' not supported by dump_expr" -#if !defined(__GNUC__) || __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ > 3) - -TEST_1D(TokenizerTest, ShCommentStyle, kBlockSizes) { - // Test the "comment_style" option. - - const char* text = "foo # bar\n" - "baz // qux\n" - "corge /* grault */\n" - "garply"; - const char* const kTokens[] = {"foo", // "# bar" is ignored - "baz", "/", "/", "qux", - "corge", "/", "*", "grault", "*", "/", - "garply"}; - - // Set up the tokenizer. - TestInputStream input(text, strlen(text), kBlockSizes_case); - TestErrorCollector error_collector; - Tokenizer tokenizer(&input, &error_collector); - tokenizer.set_comment_style(Tokenizer::SH_COMMENT_STYLE); - - // Advance through tokens and check that they are parsed as expected. - for (int i = 0; i < GOOGLE_ARRAYSIZE(kTokens); i++) { - EXPECT_TRUE(tokenizer.Next()); - EXPECT_EQ(tokenizer.current().text, kTokens[i]); - } - - // There should be no more input. - EXPECT_FALSE(tokenizer.Next()); - // There should be no errors. - EXPECT_TRUE(error_collector.text_.empty()); -} - -#endif - -// ------------------------------------------------------------------- - -// In each case, the input is expected to have two tokens named "prev" and -// "next" with comments in between. -struct DocCommentCase { - string input; - - const char* prev_trailing_comments; - const char* detached_comments[10]; - const char* next_leading_comments; -}; - -inline ostream& operator<<(ostream& out, - const DocCommentCase& test_case) { - return out << CEscape(test_case.input); -} - -DocCommentCase kDocCommentCases[] = { - { - "prev next", - - "", - {}, - "" - }, - - { - "prev /* ignored */ next", - - "", - {}, - "" - }, - - { - "prev // trailing comment\n" - "next", - - " trailing comment\n", - {}, - "" - }, - - { - "prev\n" - "// leading comment\n" - "// line 2\n" - "next", - - "", - {}, - " leading comment\n" - " line 2\n" - }, - - { - "prev\n" - "// trailing comment\n" - "// line 2\n" - "\n" - "next", - - " trailing comment\n" - " line 2\n", - {}, - "" - }, - - { - "prev // trailing comment\n" - "// leading comment\n" - "// line 2\n" - "next", - - " trailing comment\n", - {}, - " leading comment\n" - " line 2\n" - }, - - { - "prev /* trailing block comment */\n" - "/* leading block comment\n" - " * line 2\n" - " * line 3 */" - "next", - - " trailing block comment ", - {}, - " leading block comment\n" - " line 2\n" - " line 3 " - }, - - { - "prev\n" - "/* trailing block comment\n" - " * line 2\n" - " * line 3\n" - " */\n" - "/* leading block comment\n" - " * line 2\n" - " * line 3 */" - "next", - - " trailing block comment\n" - " line 2\n" - " line 3\n", - {}, - " leading block comment\n" - " line 2\n" - " line 3 " - }, - - { - "prev\n" - "// trailing comment\n" - "\n" - "// detached comment\n" - "// line 2\n" - "\n" - "// second detached comment\n" - "/* third detached comment\n" - " * line 2 */\n" - "// leading comment\n" - "next", - - " trailing comment\n", - { - " detached comment\n" - " line 2\n", - " second detached comment\n", - " third detached comment\n" - " line 2 " - }, - " leading comment\n" - }, - - { - "prev /**/\n" - "\n" - "// detached comment\n" - "\n" - "// leading comment\n" - "next", - - "", - { - " detached comment\n" - }, - " leading comment\n" - }, - - { - "prev /**/\n" - "// leading comment\n" - "next", - - "", - {}, - " leading comment\n" - }, - }; - -TEST_2D(TokenizerTest, DocComments, kDocCommentCases, kBlockSizes) { - // Set up the tokenizer. - TestInputStream input(kDocCommentCases_case.input.data(), - kDocCommentCases_case.input.size(), - kBlockSizes_case); - TestErrorCollector error_collector; - Tokenizer tokenizer(&input, &error_collector); - - // Set up a second tokenizer where we'll pass all NULLs to NextWithComments(). - TestInputStream input2(kDocCommentCases_case.input.data(), - kDocCommentCases_case.input.size(), - kBlockSizes_case); - Tokenizer tokenizer2(&input2, &error_collector); - - tokenizer.Next(); - tokenizer2.Next(); - - EXPECT_EQ("prev", tokenizer.current().text); - EXPECT_EQ("prev", tokenizer2.current().text); - - string prev_trailing_comments; - vector detached_comments; - string next_leading_comments; - tokenizer.NextWithComments(&prev_trailing_comments, &detached_comments, - &next_leading_comments); - tokenizer2.NextWithComments(NULL, NULL, NULL); - EXPECT_EQ("next", tokenizer.current().text); - EXPECT_EQ("next", tokenizer2.current().text); - - EXPECT_EQ(kDocCommentCases_case.prev_trailing_comments, - prev_trailing_comments); - - for (int i = 0; i < detached_comments.size(); i++) { - ASSERT_LT(i, GOOGLE_ARRAYSIZE(kDocCommentCases)); - ASSERT_TRUE(kDocCommentCases_case.detached_comments[i] != NULL); - EXPECT_EQ(kDocCommentCases_case.detached_comments[i], - detached_comments[i]); - } - - // Verify that we matched all the detached comments. - EXPECT_EQ(NULL, - kDocCommentCases_case.detached_comments[detached_comments.size()]); - - EXPECT_EQ(kDocCommentCases_case.next_leading_comments, - next_leading_comments); -} - -// ------------------------------------------------------------------- - -// Test parse helpers. It's not really worth setting up a full data-driven -// test here. -TEST_F(TokenizerTest, ParseInteger) { - EXPECT_EQ(0, ParseInteger("0")); - EXPECT_EQ(123, ParseInteger("123")); - EXPECT_EQ(0xabcdef12u, ParseInteger("0xabcdef12")); - EXPECT_EQ(0xabcdef12u, ParseInteger("0xABCDEF12")); - EXPECT_EQ(kuint64max, ParseInteger("0xFFFFFFFFFFFFFFFF")); - EXPECT_EQ(01234567, ParseInteger("01234567")); - EXPECT_EQ(0X123, ParseInteger("0X123")); - - // Test invalid integers that may still be tokenized as integers. - EXPECT_EQ(0, ParseInteger("0x")); - - uint64 i; -#ifdef PROTOBUF_HASDEATH_TEST // death tests do not work on Windows yet - // Test invalid integers that will never be tokenized as integers. - EXPECT_DEBUG_DEATH(Tokenizer::ParseInteger("zxy", kuint64max, &i), - "passed text that could not have been tokenized as an integer"); - EXPECT_DEBUG_DEATH(Tokenizer::ParseInteger("1.2", kuint64max, &i), - "passed text that could not have been tokenized as an integer"); - EXPECT_DEBUG_DEATH(Tokenizer::ParseInteger("08", kuint64max, &i), - "passed text that could not have been tokenized as an integer"); - EXPECT_DEBUG_DEATH(Tokenizer::ParseInteger("0xg", kuint64max, &i), - "passed text that could not have been tokenized as an integer"); - EXPECT_DEBUG_DEATH(Tokenizer::ParseInteger("-1", kuint64max, &i), - "passed text that could not have been tokenized as an integer"); -#endif // PROTOBUF_HASDEATH_TEST - - // Test overflows. - EXPECT_TRUE (Tokenizer::ParseInteger("0", 0, &i)); - EXPECT_FALSE(Tokenizer::ParseInteger("1", 0, &i)); - EXPECT_TRUE (Tokenizer::ParseInteger("1", 1, &i)); - EXPECT_TRUE (Tokenizer::ParseInteger("12345", 12345, &i)); - EXPECT_FALSE(Tokenizer::ParseInteger("12346", 12345, &i)); - EXPECT_TRUE (Tokenizer::ParseInteger("0xFFFFFFFFFFFFFFFF" , kuint64max, &i)); - EXPECT_FALSE(Tokenizer::ParseInteger("0x10000000000000000", kuint64max, &i)); -} - -TEST_F(TokenizerTest, ParseFloat) { - EXPECT_DOUBLE_EQ(1 , Tokenizer::ParseFloat("1.")); - EXPECT_DOUBLE_EQ(1e3 , Tokenizer::ParseFloat("1e3")); - EXPECT_DOUBLE_EQ(1e3 , Tokenizer::ParseFloat("1E3")); - EXPECT_DOUBLE_EQ(1.5e3, Tokenizer::ParseFloat("1.5e3")); - EXPECT_DOUBLE_EQ(.1 , Tokenizer::ParseFloat(".1")); - EXPECT_DOUBLE_EQ(.25 , Tokenizer::ParseFloat(".25")); - EXPECT_DOUBLE_EQ(.1e3 , Tokenizer::ParseFloat(".1e3")); - EXPECT_DOUBLE_EQ(.25e3, Tokenizer::ParseFloat(".25e3")); - EXPECT_DOUBLE_EQ(.1e+3, Tokenizer::ParseFloat(".1e+3")); - EXPECT_DOUBLE_EQ(.1e-3, Tokenizer::ParseFloat(".1e-3")); - EXPECT_DOUBLE_EQ(5 , Tokenizer::ParseFloat("5")); - EXPECT_DOUBLE_EQ(6e-12, Tokenizer::ParseFloat("6e-12")); - EXPECT_DOUBLE_EQ(1.2 , Tokenizer::ParseFloat("1.2")); - EXPECT_DOUBLE_EQ(1.e2 , Tokenizer::ParseFloat("1.e2")); - - // Test invalid integers that may still be tokenized as integers. - EXPECT_DOUBLE_EQ(1, Tokenizer::ParseFloat("1e")); - EXPECT_DOUBLE_EQ(1, Tokenizer::ParseFloat("1e-")); - EXPECT_DOUBLE_EQ(1, Tokenizer::ParseFloat("1.e")); - - // Test 'f' suffix. - EXPECT_DOUBLE_EQ(1, Tokenizer::ParseFloat("1f")); - EXPECT_DOUBLE_EQ(1, Tokenizer::ParseFloat("1.0f")); - EXPECT_DOUBLE_EQ(1, Tokenizer::ParseFloat("1F")); - - // These should parse successfully even though they are out of range. - // Overflows become infinity and underflows become zero. - EXPECT_EQ( 0.0, Tokenizer::ParseFloat("1e-9999999999999999999999999999")); - EXPECT_EQ(HUGE_VAL, Tokenizer::ParseFloat("1e+9999999999999999999999999999")); - -#ifdef PROTOBUF_HASDEATH_TEST // death tests do not work on Windows yet - // Test invalid integers that will never be tokenized as integers. - EXPECT_DEBUG_DEATH(Tokenizer::ParseFloat("zxy"), - "passed text that could not have been tokenized as a float"); - EXPECT_DEBUG_DEATH(Tokenizer::ParseFloat("1-e0"), - "passed text that could not have been tokenized as a float"); - EXPECT_DEBUG_DEATH(Tokenizer::ParseFloat("-1.0"), - "passed text that could not have been tokenized as a float"); -#endif // PROTOBUF_HASDEATH_TEST -} - -TEST_F(TokenizerTest, ParseString) { - string output; - Tokenizer::ParseString("'hello'", &output); - EXPECT_EQ("hello", output); - Tokenizer::ParseString("\"blah\\nblah2\"", &output); - EXPECT_EQ("blah\nblah2", output); - Tokenizer::ParseString("'\\1x\\1\\123\\739\\52\\334n\\3'", &output); - EXPECT_EQ("\1x\1\123\739\52\334n\3", output); - Tokenizer::ParseString("'\\x20\\x4'", &output); - EXPECT_EQ("\x20\x4", output); - - // Test invalid strings that may still be tokenized as strings. - Tokenizer::ParseString("\"\\a\\l\\v\\t", &output); // \l is invalid - EXPECT_EQ("\a?\v\t", output); - Tokenizer::ParseString("'", &output); - EXPECT_EQ("", output); - Tokenizer::ParseString("'\\", &output); - EXPECT_EQ("\\", output); - - // Experiment with Unicode escapes. Here are one-, two- and three-byte Unicode - // characters. - Tokenizer::ParseString("'\\u0024\\u00a2\\u20ac\\U00024b62XX'", &output); - EXPECT_EQ("$¢€𤭢XX", output); - // Same thing encoded using UTF16. - Tokenizer::ParseString("'\\u0024\\u00a2\\u20ac\\ud852\\udf62XX'", &output); - EXPECT_EQ("$¢€𤭢XX", output); - // Here's some broken UTF16; there's a head surrogate with no tail surrogate. - // We just output this as if it were UTF8; it's not a defined code point, but - // it has a defined encoding. - Tokenizer::ParseString("'\\ud852XX'", &output); - EXPECT_EQ("\xed\xa1\x92XX", output); - // Malformed escape: Demons may fly out of the nose. - Tokenizer::ParseString("\\u0", &output); - EXPECT_EQ("u0", output); - - // Test invalid strings that will never be tokenized as strings. -#ifdef PROTOBUF_HASDEATH_TEST // death tests do not work on Windows yet - EXPECT_DEBUG_DEATH(Tokenizer::ParseString("", &output), - "passed text that could not have been tokenized as a string"); -#endif // PROTOBUF_HASDEATH_TEST -} - -TEST_F(TokenizerTest, ParseStringAppend) { - // Check that ParseString and ParseStringAppend differ. - string output("stuff+"); - Tokenizer::ParseStringAppend("'hello'", &output); - EXPECT_EQ("stuff+hello", output); - Tokenizer::ParseString("'hello'", &output); - EXPECT_EQ("hello", output); -} - -// ------------------------------------------------------------------- - -// Each case parses some input text, ignoring the tokens produced, and -// checks that the error output matches what is expected. -struct ErrorCase { - string input; - bool recoverable; // True if the tokenizer should be able to recover and - // parse more tokens after seeing this error. Cases - // for which this is true must end with "foo" as - // the last token, which the test will check for. - const char* errors; -}; - -inline ostream& operator<<(ostream& out, - const ErrorCase& test_case) { - return out << CEscape(test_case.input); -} - -ErrorCase kErrorCases[] = { - // String errors. - { "'\\l' foo", true, - "0:2: Invalid escape sequence in string literal.\n" }, - { "'\\x' foo", true, - "0:3: Expected hex digits for escape sequence.\n" }, - { "'foo", false, - "0:4: String literals cannot cross line boundaries.\n" }, - { "'bar\nfoo", true, - "0:4: String literals cannot cross line boundaries.\n" }, - { "'\\u01' foo", true, - "0:5: Expected four hex digits for \\u escape sequence.\n" }, - { "'\\u01' foo", true, - "0:5: Expected four hex digits for \\u escape sequence.\n" }, - { "'\\uXYZ' foo", true, - "0:3: Expected four hex digits for \\u escape sequence.\n" }, - - // Integer errors. - { "123foo", true, - "0:3: Need space between number and identifier.\n" }, - - // Hex/octal errors. - { "0x foo", true, - "0:2: \"0x\" must be followed by hex digits.\n" }, - { "0541823 foo", true, - "0:4: Numbers starting with leading zero must be in octal.\n" }, - { "0x123z foo", true, - "0:5: Need space between number and identifier.\n" }, - { "0x123.4 foo", true, - "0:5: Hex and octal numbers must be integers.\n" }, - { "0123.4 foo", true, - "0:4: Hex and octal numbers must be integers.\n" }, - - // Float errors. - { "1e foo", true, - "0:2: \"e\" must be followed by exponent.\n" }, - { "1e- foo", true, - "0:3: \"e\" must be followed by exponent.\n" }, - { "1.2.3 foo", true, - "0:3: Already saw decimal point or exponent; can't have another one.\n" }, - { "1e2.3 foo", true, - "0:3: Already saw decimal point or exponent; can't have another one.\n" }, - { "a.1 foo", true, - "0:1: Need space between identifier and decimal point.\n" }, - // allow_f_after_float not enabled, so this should be an error. - { "1.0f foo", true, - "0:3: Need space between number and identifier.\n" }, - - // Block comment errors. - { "/*", false, - "0:2: End-of-file inside block comment.\n" - "0:0: Comment started here.\n"}, - { "/*/*/ foo", true, - "0:3: \"/*\" inside block comment. Block comments cannot be nested.\n"}, - - // Control characters. Multiple consecutive control characters should only - // produce one error. - { "\b foo", true, - "0:0: Invalid control characters encountered in text.\n" }, - { "\b\b foo", true, - "0:0: Invalid control characters encountered in text.\n" }, - - // Check that control characters at end of input don't result in an - // infinite loop. - { "\b", false, - "0:0: Invalid control characters encountered in text.\n" }, - - // Check recovery from '\0'. We have to explicitly specify the length of - // these strings because otherwise the string constructor will just call - // strlen() which will see the first '\0' and think that is the end of the - // string. - { string("\0foo", 4), true, - "0:0: Invalid control characters encountered in text.\n" }, - { string("\0\0foo", 5), true, - "0:0: Invalid control characters encountered in text.\n" }, -}; - -TEST_2D(TokenizerTest, Errors, kErrorCases, kBlockSizes) { - // Set up the tokenizer. - TestInputStream input(kErrorCases_case.input.data(), - kErrorCases_case.input.size(), - kBlockSizes_case); - TestErrorCollector error_collector; - Tokenizer tokenizer(&input, &error_collector); - - // Ignore all input, except remember if the last token was "foo". - bool last_was_foo = false; - while (tokenizer.Next()) { - last_was_foo = tokenizer.current().text == "foo"; - } - - // Check that the errors match what was expected. - EXPECT_EQ(kErrorCases_case.errors, error_collector.text_); - - // If the error was recoverable, make sure we saw "foo" after it. - if (kErrorCases_case.recoverable) { - EXPECT_TRUE(last_was_foo); - } -} - -// ------------------------------------------------------------------- - -TEST_1D(TokenizerTest, BackUpOnDestruction, kBlockSizes) { - string text = "foo bar"; - TestInputStream input(text.data(), text.size(), kBlockSizes_case); - - // Create a tokenizer, read one token, then destroy it. - { - TestErrorCollector error_collector; - Tokenizer tokenizer(&input, &error_collector); - - tokenizer.Next(); - } - - // Only "foo" should have been read. - EXPECT_EQ(strlen("foo"), input.ByteCount()); -} - - -} // namespace -} // namespace io -} // namespace protobuf -} // namespace google diff --git a/modules/dnn/3rdparty/protobuf/src/google/protobuf/io/zero_copy_stream.cc b/modules/dnn/3rdparty/protobuf/src/google/protobuf/io/zero_copy_stream.cc deleted file mode 100644 index dad6ff144..000000000 --- a/modules/dnn/3rdparty/protobuf/src/google/protobuf/io/zero_copy_stream.cc +++ /dev/null @@ -1,48 +0,0 @@ -// Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// http://code.google.com/p/protobuf/ -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -// Author: kenton@google.com (Kenton Varda) -// Based on original Protocol Buffers design by -// Sanjay Ghemawat, Jeff Dean, and others. - -#include - - -namespace google { -namespace protobuf { -namespace io { - -ZeroCopyInputStream::~ZeroCopyInputStream() {} -ZeroCopyOutputStream::~ZeroCopyOutputStream() {} - - -} // namespace io -} // namespace protobuf -} // namespace google diff --git a/modules/dnn/3rdparty/protobuf/src/google/protobuf/io/zero_copy_stream.h b/modules/dnn/3rdparty/protobuf/src/google/protobuf/io/zero_copy_stream.h deleted file mode 100644 index db5326f70..000000000 --- a/modules/dnn/3rdparty/protobuf/src/google/protobuf/io/zero_copy_stream.h +++ /dev/null @@ -1,238 +0,0 @@ -// Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// http://code.google.com/p/protobuf/ -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -// Author: kenton@google.com (Kenton Varda) -// Based on original Protocol Buffers design by -// Sanjay Ghemawat, Jeff Dean, and others. -// -// This file contains the ZeroCopyInputStream and ZeroCopyOutputStream -// interfaces, which represent abstract I/O streams to and from which -// protocol buffers can be read and written. For a few simple -// implementations of these interfaces, see zero_copy_stream_impl.h. -// -// These interfaces are different from classic I/O streams in that they -// try to minimize the amount of data copying that needs to be done. -// To accomplish this, responsibility for allocating buffers is moved to -// the stream object, rather than being the responsibility of the caller. -// So, the stream can return a buffer which actually points directly into -// the final data structure where the bytes are to be stored, and the caller -// can interact directly with that buffer, eliminating an intermediate copy -// operation. -// -// As an example, consider the common case in which you are reading bytes -// from an array that is already in memory (or perhaps an mmap()ed file). -// With classic I/O streams, you would do something like: -// char buffer[BUFFER_SIZE]; -// input->Read(buffer, BUFFER_SIZE); -// DoSomething(buffer, BUFFER_SIZE); -// Then, the stream basically just calls memcpy() to copy the data from -// the array into your buffer. With a ZeroCopyInputStream, you would do -// this instead: -// const void* buffer; -// int size; -// input->Next(&buffer, &size); -// DoSomething(buffer, size); -// Here, no copy is performed. The input stream returns a pointer directly -// into the backing array, and the caller ends up reading directly from it. -// -// If you want to be able to read the old-fashion way, you can create -// a CodedInputStream or CodedOutputStream wrapping these objects and use -// their ReadRaw()/WriteRaw() methods. These will, of course, add a copy -// step, but Coded*Stream will handle buffering so at least it will be -// reasonably efficient. -// -// ZeroCopyInputStream example: -// // Read in a file and print its contents to stdout. -// int fd = open("myfile", O_RDONLY); -// ZeroCopyInputStream* input = new FileInputStream(fd); -// -// const void* buffer; -// int size; -// while (input->Next(&buffer, &size)) { -// cout.write(buffer, size); -// } -// -// delete input; -// close(fd); -// -// ZeroCopyOutputStream example: -// // Copy the contents of "infile" to "outfile", using plain read() for -// // "infile" but a ZeroCopyOutputStream for "outfile". -// int infd = open("infile", O_RDONLY); -// int outfd = open("outfile", O_WRONLY); -// ZeroCopyOutputStream* output = new FileOutputStream(outfd); -// -// void* buffer; -// int size; -// while (output->Next(&buffer, &size)) { -// int bytes = read(infd, buffer, size); -// if (bytes < size) { -// // Reached EOF. -// output->BackUp(size - bytes); -// break; -// } -// } -// -// delete output; -// close(infd); -// close(outfd); - -#ifndef GOOGLE_PROTOBUF_IO_ZERO_COPY_STREAM_H__ -#define GOOGLE_PROTOBUF_IO_ZERO_COPY_STREAM_H__ - -#include -#include - -namespace google { - -namespace protobuf { -namespace io { - -// Defined in this file. -class ZeroCopyInputStream; -class ZeroCopyOutputStream; - -// Abstract interface similar to an input stream but designed to minimize -// copying. -class LIBPROTOBUF_EXPORT ZeroCopyInputStream { - public: - inline ZeroCopyInputStream() {} - virtual ~ZeroCopyInputStream(); - - // Obtains a chunk of data from the stream. - // - // Preconditions: - // * "size" and "data" are not NULL. - // - // Postconditions: - // * If the returned value is false, there is no more data to return or - // an error occurred. All errors are permanent. - // * Otherwise, "size" points to the actual number of bytes read and "data" - // points to a pointer to a buffer containing these bytes. - // * Ownership of this buffer remains with the stream, and the buffer - // remains valid only until some other method of the stream is called - // or the stream is destroyed. - // * It is legal for the returned buffer to have zero size, as long - // as repeatedly calling Next() eventually yields a buffer with non-zero - // size. - virtual bool Next(const void** data, int* size) = 0; - - // Backs up a number of bytes, so that the next call to Next() returns - // data again that was already returned by the last call to Next(). This - // is useful when writing procedures that are only supposed to read up - // to a certain point in the input, then return. If Next() returns a - // buffer that goes beyond what you wanted to read, you can use BackUp() - // to return to the point where you intended to finish. - // - // Preconditions: - // * The last method called must have been Next(). - // * count must be less than or equal to the size of the last buffer - // returned by Next(). - // - // Postconditions: - // * The last "count" bytes of the last buffer returned by Next() will be - // pushed back into the stream. Subsequent calls to Next() will return - // the same data again before producing new data. - virtual void BackUp(int count) = 0; - - // Skips a number of bytes. Returns false if the end of the stream is - // reached or some input error occurred. In the end-of-stream case, the - // stream is advanced to the end of the stream (so ByteCount() will return - // the total size of the stream). - virtual bool Skip(int count) = 0; - - // Returns the total number of bytes read since this object was created. - virtual int64 ByteCount() const = 0; - - - private: - GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ZeroCopyInputStream); -}; - -// Abstract interface similar to an output stream but designed to minimize -// copying. -class LIBPROTOBUF_EXPORT ZeroCopyOutputStream { - public: - inline ZeroCopyOutputStream() {} - virtual ~ZeroCopyOutputStream(); - - // Obtains a buffer into which data can be written. Any data written - // into this buffer will eventually (maybe instantly, maybe later on) - // be written to the output. - // - // Preconditions: - // * "size" and "data" are not NULL. - // - // Postconditions: - // * If the returned value is false, an error occurred. All errors are - // permanent. - // * Otherwise, "size" points to the actual number of bytes in the buffer - // and "data" points to the buffer. - // * Ownership of this buffer remains with the stream, and the buffer - // remains valid only until some other method of the stream is called - // or the stream is destroyed. - // * Any data which the caller stores in this buffer will eventually be - // written to the output (unless BackUp() is called). - // * It is legal for the returned buffer to have zero size, as long - // as repeatedly calling Next() eventually yields a buffer with non-zero - // size. - virtual bool Next(void** data, int* size) = 0; - - // Backs up a number of bytes, so that the end of the last buffer returned - // by Next() is not actually written. This is needed when you finish - // writing all the data you want to write, but the last buffer was bigger - // than you needed. You don't want to write a bunch of garbage after the - // end of your data, so you use BackUp() to back up. - // - // Preconditions: - // * The last method called must have been Next(). - // * count must be less than or equal to the size of the last buffer - // returned by Next(). - // * The caller must not have written anything to the last "count" bytes - // of that buffer. - // - // Postconditions: - // * The last "count" bytes of the last buffer returned by Next() will be - // ignored. - virtual void BackUp(int count) = 0; - - // Returns the total number of bytes written since this object was created. - virtual int64 ByteCount() const = 0; - - - private: - GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ZeroCopyOutputStream); -}; - -} // namespace io -} // namespace protobuf - -} // namespace google -#endif // GOOGLE_PROTOBUF_IO_ZERO_COPY_STREAM_H__ diff --git a/modules/dnn/3rdparty/protobuf/src/google/protobuf/io/zero_copy_stream_impl.cc b/modules/dnn/3rdparty/protobuf/src/google/protobuf/io/zero_copy_stream_impl.cc deleted file mode 100644 index 9fcbb622a..000000000 --- a/modules/dnn/3rdparty/protobuf/src/google/protobuf/io/zero_copy_stream_impl.cc +++ /dev/null @@ -1,471 +0,0 @@ -// Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// http://code.google.com/p/protobuf/ -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -// Author: kenton@google.com (Kenton Varda) -// Based on original Protocol Buffers design by -// Sanjay Ghemawat, Jeff Dean, and others. - -#ifdef _MSC_VER -#include -#else -#include -#include -#include -#include -#endif -#include -#include -#include - -#include -#include -#include - - -namespace google { -namespace protobuf { -namespace io { - -#ifdef _WIN32 -// Win32 lseek is broken: If invoked on a non-seekable file descriptor, its -// return value is undefined. We re-define it to always produce an error. -#define lseek(fd, offset, origin) ((off_t)-1) -#endif - -namespace { - -// EINTR sucks. -int close_no_eintr(int fd) { - int result; - do { - result = close(fd); - } while (result < 0 && errno == EINTR); - return result; -} - -} // namespace - - -// =================================================================== - -FileInputStream::FileInputStream(int file_descriptor, int block_size) - : copying_input_(file_descriptor), - impl_(©ing_input_, block_size) { -} - -FileInputStream::~FileInputStream() {} - -bool FileInputStream::Close() { - return copying_input_.Close(); -} - -bool FileInputStream::Next(const void** data, int* size) { - return impl_.Next(data, size); -} - -void FileInputStream::BackUp(int count) { - impl_.BackUp(count); -} - -bool FileInputStream::Skip(int count) { - return impl_.Skip(count); -} - -int64 FileInputStream::ByteCount() const { - return impl_.ByteCount(); -} - -FileInputStream::CopyingFileInputStream::CopyingFileInputStream( - int file_descriptor) - : file_(file_descriptor), - close_on_delete_(false), - is_closed_(false), - errno_(0), - previous_seek_failed_(false) { -} - -FileInputStream::CopyingFileInputStream::~CopyingFileInputStream() { - if (close_on_delete_) { - if (!Close()) { - GOOGLE_LOG(ERROR) << "close() failed: " << strerror(errno_); - } - } -} - -bool FileInputStream::CopyingFileInputStream::Close() { - GOOGLE_CHECK(!is_closed_); - - is_closed_ = true; - if (close_no_eintr(file_) != 0) { - // The docs on close() do not specify whether a file descriptor is still - // open after close() fails with EIO. However, the glibc source code - // seems to indicate that it is not. - errno_ = errno; - return false; - } - - return true; -} - -int FileInputStream::CopyingFileInputStream::Read(void* buffer, int size) { - GOOGLE_CHECK(!is_closed_); - - int result; - do { - result = read(file_, buffer, size); - } while (result < 0 && errno == EINTR); - - if (result < 0) { - // Read error (not EOF). - errno_ = errno; - } - - return result; -} - -int FileInputStream::CopyingFileInputStream::Skip(int count) { - GOOGLE_CHECK(!is_closed_); - - if (!previous_seek_failed_ && - lseek(file_, count, SEEK_CUR) != (off_t)-1) { - // Seek succeeded. - return count; - } else { - // Failed to seek. - - // Note to self: Don't seek again. This file descriptor doesn't - // support it. - previous_seek_failed_ = true; - - // Use the default implementation. - return CopyingInputStream::Skip(count); - } -} - -// =================================================================== - -FileOutputStream::FileOutputStream(int file_descriptor, int block_size) - : copying_output_(file_descriptor), - impl_(©ing_output_, block_size) { -} - -FileOutputStream::~FileOutputStream() { - impl_.Flush(); -} - -bool FileOutputStream::Close() { - bool flush_succeeded = impl_.Flush(); - return copying_output_.Close() && flush_succeeded; -} - -bool FileOutputStream::Flush() { - return impl_.Flush(); -} - -bool FileOutputStream::Next(void** data, int* size) { - return impl_.Next(data, size); -} - -void FileOutputStream::BackUp(int count) { - impl_.BackUp(count); -} - -int64 FileOutputStream::ByteCount() const { - return impl_.ByteCount(); -} - -FileOutputStream::CopyingFileOutputStream::CopyingFileOutputStream( - int file_descriptor) - : file_(file_descriptor), - close_on_delete_(false), - is_closed_(false), - errno_(0) { -} - -FileOutputStream::CopyingFileOutputStream::~CopyingFileOutputStream() { - if (close_on_delete_) { - if (!Close()) { - GOOGLE_LOG(ERROR) << "close() failed: " << strerror(errno_); - } - } -} - -bool FileOutputStream::CopyingFileOutputStream::Close() { - GOOGLE_CHECK(!is_closed_); - - is_closed_ = true; - if (close_no_eintr(file_) != 0) { - // The docs on close() do not specify whether a file descriptor is still - // open after close() fails with EIO. However, the glibc source code - // seems to indicate that it is not. - errno_ = errno; - return false; - } - - return true; -} - -bool FileOutputStream::CopyingFileOutputStream::Write( - const void* buffer, int size) { - GOOGLE_CHECK(!is_closed_); - int total_written = 0; - - const uint8* buffer_base = reinterpret_cast(buffer); - - while (total_written < size) { - int bytes; - do { - bytes = write(file_, buffer_base + total_written, size - total_written); - } while (bytes < 0 && errno == EINTR); - - if (bytes <= 0) { - // Write error. - - // FIXME(kenton): According to the man page, if write() returns zero, - // there was no error; write() simply did not write anything. It's - // unclear under what circumstances this might happen, but presumably - // errno won't be set in this case. I am confused as to how such an - // event should be handled. For now I'm treating it as an error, since - // retrying seems like it could lead to an infinite loop. I suspect - // this never actually happens anyway. - - if (bytes < 0) { - errno_ = errno; - } - return false; - } - total_written += bytes; - } - - return true; -} - -// =================================================================== - -IstreamInputStream::IstreamInputStream(istream* input, int block_size) - : copying_input_(input), - impl_(©ing_input_, block_size) { -} - -IstreamInputStream::~IstreamInputStream() {} - -bool IstreamInputStream::Next(const void** data, int* size) { - return impl_.Next(data, size); -} - -void IstreamInputStream::BackUp(int count) { - impl_.BackUp(count); -} - -bool IstreamInputStream::Skip(int count) { - return impl_.Skip(count); -} - -int64 IstreamInputStream::ByteCount() const { - return impl_.ByteCount(); -} - -IstreamInputStream::CopyingIstreamInputStream::CopyingIstreamInputStream( - istream* input) - : input_(input) { -} - -IstreamInputStream::CopyingIstreamInputStream::~CopyingIstreamInputStream() {} - -int IstreamInputStream::CopyingIstreamInputStream::Read( - void* buffer, int size) { - input_->read(reinterpret_cast(buffer), size); - int result = input_->gcount(); - if (result == 0 && input_->fail() && !input_->eof()) { - return -1; - } - return result; -} - -// =================================================================== - -OstreamOutputStream::OstreamOutputStream(ostream* output, int block_size) - : copying_output_(output), - impl_(©ing_output_, block_size) { -} - -OstreamOutputStream::~OstreamOutputStream() { - impl_.Flush(); -} - -bool OstreamOutputStream::Next(void** data, int* size) { - return impl_.Next(data, size); -} - -void OstreamOutputStream::BackUp(int count) { - impl_.BackUp(count); -} - -int64 OstreamOutputStream::ByteCount() const { - return impl_.ByteCount(); -} - -OstreamOutputStream::CopyingOstreamOutputStream::CopyingOstreamOutputStream( - ostream* output) - : output_(output) { -} - -OstreamOutputStream::CopyingOstreamOutputStream::~CopyingOstreamOutputStream() { -} - -bool OstreamOutputStream::CopyingOstreamOutputStream::Write( - const void* buffer, int size) { - output_->write(reinterpret_cast(buffer), size); - return output_->good(); -} - -// =================================================================== - -ConcatenatingInputStream::ConcatenatingInputStream( - ZeroCopyInputStream* const streams[], int count) - : streams_(streams), stream_count_(count), bytes_retired_(0) { -} - -ConcatenatingInputStream::~ConcatenatingInputStream() { -} - -bool ConcatenatingInputStream::Next(const void** data, int* size) { - while (stream_count_ > 0) { - if (streams_[0]->Next(data, size)) return true; - - // That stream is done. Advance to the next one. - bytes_retired_ += streams_[0]->ByteCount(); - ++streams_; - --stream_count_; - } - - // No more streams. - return false; -} - -void ConcatenatingInputStream::BackUp(int count) { - if (stream_count_ > 0) { - streams_[0]->BackUp(count); - } else { - GOOGLE_LOG(DFATAL) << "Can't BackUp() after failed Next()."; - } -} - -bool ConcatenatingInputStream::Skip(int count) { - while (stream_count_ > 0) { - // Assume that ByteCount() can be used to find out how much we actually - // skipped when Skip() fails. - int64 target_byte_count = streams_[0]->ByteCount() + count; - if (streams_[0]->Skip(count)) return true; - - // Hit the end of the stream. Figure out how many more bytes we still have - // to skip. - int64 final_byte_count = streams_[0]->ByteCount(); - GOOGLE_DCHECK_LT(final_byte_count, target_byte_count); - count = target_byte_count - final_byte_count; - - // That stream is done. Advance to the next one. - bytes_retired_ += final_byte_count; - ++streams_; - --stream_count_; - } - - return false; -} - -int64 ConcatenatingInputStream::ByteCount() const { - if (stream_count_ == 0) { - return bytes_retired_; - } else { - return bytes_retired_ + streams_[0]->ByteCount(); - } -} - - -// =================================================================== - -LimitingInputStream::LimitingInputStream(ZeroCopyInputStream* input, - int64 limit) - : input_(input), limit_(limit) {} - -LimitingInputStream::~LimitingInputStream() { - // If we overshot the limit, back up. - if (limit_ < 0) input_->BackUp(-limit_); -} - -bool LimitingInputStream::Next(const void** data, int* size) { - if (limit_ <= 0) return false; - if (!input_->Next(data, size)) return false; - - limit_ -= *size; - if (limit_ < 0) { - // We overshot the limit. Reduce *size to hide the rest of the buffer. - *size += limit_; - } - return true; -} - -void LimitingInputStream::BackUp(int count) { - if (limit_ < 0) { - input_->BackUp(count - limit_); - limit_ = count; - } else { - input_->BackUp(count); - limit_ += count; - } -} - -bool LimitingInputStream::Skip(int count) { - if (count > limit_) { - if (limit_ < 0) return false; - input_->Skip(limit_); - limit_ = 0; - return false; - } else { - if (!input_->Skip(count)) return false; - limit_ -= count; - return true; - } -} - -int64 LimitingInputStream::ByteCount() const { - if (limit_ < 0) { - return input_->ByteCount() + limit_; - } else { - return input_->ByteCount(); - } -} - - -// =================================================================== - -} // namespace io -} // namespace protobuf -} // namespace google diff --git a/modules/dnn/3rdparty/protobuf/src/google/protobuf/io/zero_copy_stream_impl.h b/modules/dnn/3rdparty/protobuf/src/google/protobuf/io/zero_copy_stream_impl.h deleted file mode 100644 index 9fedb0057..000000000 --- a/modules/dnn/3rdparty/protobuf/src/google/protobuf/io/zero_copy_stream_impl.h +++ /dev/null @@ -1,357 +0,0 @@ -// Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// http://code.google.com/p/protobuf/ -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -// Author: kenton@google.com (Kenton Varda) -// Based on original Protocol Buffers design by -// Sanjay Ghemawat, Jeff Dean, and others. -// -// This file contains common implementations of the interfaces defined in -// zero_copy_stream.h which are only included in the full (non-lite) -// protobuf library. These implementations include Unix file descriptors -// and C++ iostreams. See also: zero_copy_stream_impl_lite.h - -#ifndef GOOGLE_PROTOBUF_IO_ZERO_COPY_STREAM_IMPL_H__ -#define GOOGLE_PROTOBUF_IO_ZERO_COPY_STREAM_IMPL_H__ - -#include -#include -#include -#include -#include - - -namespace google { -namespace protobuf { -namespace io { - - -// =================================================================== - -// A ZeroCopyInputStream which reads from a file descriptor. -// -// FileInputStream is preferred over using an ifstream with IstreamInputStream. -// The latter will introduce an extra layer of buffering, harming performance. -// Also, it's conceivable that FileInputStream could someday be enhanced -// to use zero-copy file descriptors on OSs which support them. -class LIBPROTOBUF_EXPORT FileInputStream : public ZeroCopyInputStream { - public: - // Creates a stream that reads from the given Unix file descriptor. - // If a block_size is given, it specifies the number of bytes that - // should be read and returned with each call to Next(). Otherwise, - // a reasonable default is used. - explicit FileInputStream(int file_descriptor, int block_size = -1); - ~FileInputStream(); - - // Flushes any buffers and closes the underlying file. Returns false if - // an error occurs during the process; use GetErrno() to examine the error. - // Even if an error occurs, the file descriptor is closed when this returns. - bool Close(); - - // By default, the file descriptor is not closed when the stream is - // destroyed. Call SetCloseOnDelete(true) to change that. WARNING: - // This leaves no way for the caller to detect if close() fails. If - // detecting close() errors is important to you, you should arrange - // to close the descriptor yourself. - void SetCloseOnDelete(bool value) { copying_input_.SetCloseOnDelete(value); } - - // If an I/O error has occurred on this file descriptor, this is the - // errno from that error. Otherwise, this is zero. Once an error - // occurs, the stream is broken and all subsequent operations will - // fail. - int GetErrno() { return copying_input_.GetErrno(); } - - // implements ZeroCopyInputStream ---------------------------------- - bool Next(const void** data, int* size); - void BackUp(int count); - bool Skip(int count); - int64 ByteCount() const; - - private: - class LIBPROTOBUF_EXPORT CopyingFileInputStream : public CopyingInputStream { - public: - CopyingFileInputStream(int file_descriptor); - ~CopyingFileInputStream(); - - bool Close(); - void SetCloseOnDelete(bool value) { close_on_delete_ = value; } - int GetErrno() { return errno_; } - - // implements CopyingInputStream --------------------------------- - int Read(void* buffer, int size); - int Skip(int count); - - private: - // The file descriptor. - const int file_; - bool close_on_delete_; - bool is_closed_; - - // The errno of the I/O error, if one has occurred. Otherwise, zero. - int errno_; - - // Did we try to seek once and fail? If so, we assume this file descriptor - // doesn't support seeking and won't try again. - bool previous_seek_failed_; - - GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(CopyingFileInputStream); - }; - - CopyingFileInputStream copying_input_; - CopyingInputStreamAdaptor impl_; - - GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(FileInputStream); -}; - -// =================================================================== - -// A ZeroCopyOutputStream which writes to a file descriptor. -// -// FileOutputStream is preferred over using an ofstream with -// OstreamOutputStream. The latter will introduce an extra layer of buffering, -// harming performance. Also, it's conceivable that FileOutputStream could -// someday be enhanced to use zero-copy file descriptors on OSs which -// support them. -class LIBPROTOBUF_EXPORT FileOutputStream : public ZeroCopyOutputStream { - public: - // Creates a stream that writes to the given Unix file descriptor. - // If a block_size is given, it specifies the size of the buffers - // that should be returned by Next(). Otherwise, a reasonable default - // is used. - explicit FileOutputStream(int file_descriptor, int block_size = -1); - ~FileOutputStream(); - - // Flushes any buffers and closes the underlying file. Returns false if - // an error occurs during the process; use GetErrno() to examine the error. - // Even if an error occurs, the file descriptor is closed when this returns. - bool Close(); - - // Flushes FileOutputStream's buffers but does not close the - // underlying file. No special measures are taken to ensure that - // underlying operating system file object is synchronized to disk. - bool Flush(); - - // By default, the file descriptor is not closed when the stream is - // destroyed. Call SetCloseOnDelete(true) to change that. WARNING: - // This leaves no way for the caller to detect if close() fails. If - // detecting close() errors is important to you, you should arrange - // to close the descriptor yourself. - void SetCloseOnDelete(bool value) { copying_output_.SetCloseOnDelete(value); } - - // If an I/O error has occurred on this file descriptor, this is the - // errno from that error. Otherwise, this is zero. Once an error - // occurs, the stream is broken and all subsequent operations will - // fail. - int GetErrno() { return copying_output_.GetErrno(); } - - // implements ZeroCopyOutputStream --------------------------------- - bool Next(void** data, int* size); - void BackUp(int count); - int64 ByteCount() const; - - private: - class LIBPROTOBUF_EXPORT CopyingFileOutputStream : public CopyingOutputStream { - public: - CopyingFileOutputStream(int file_descriptor); - ~CopyingFileOutputStream(); - - bool Close(); - void SetCloseOnDelete(bool value) { close_on_delete_ = value; } - int GetErrno() { return errno_; } - - // implements CopyingOutputStream -------------------------------- - bool Write(const void* buffer, int size); - - private: - // The file descriptor. - const int file_; - bool close_on_delete_; - bool is_closed_; - - // The errno of the I/O error, if one has occurred. Otherwise, zero. - int errno_; - - GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(CopyingFileOutputStream); - }; - - CopyingFileOutputStream copying_output_; - CopyingOutputStreamAdaptor impl_; - - GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(FileOutputStream); -}; - -// =================================================================== - -// A ZeroCopyInputStream which reads from a C++ istream. -// -// Note that for reading files (or anything represented by a file descriptor), -// FileInputStream is more efficient. -class LIBPROTOBUF_EXPORT IstreamInputStream : public ZeroCopyInputStream { - public: - // Creates a stream that reads from the given C++ istream. - // If a block_size is given, it specifies the number of bytes that - // should be read and returned with each call to Next(). Otherwise, - // a reasonable default is used. - explicit IstreamInputStream(istream* stream, int block_size = -1); - ~IstreamInputStream(); - - // implements ZeroCopyInputStream ---------------------------------- - bool Next(const void** data, int* size); - void BackUp(int count); - bool Skip(int count); - int64 ByteCount() const; - - private: - class LIBPROTOBUF_EXPORT CopyingIstreamInputStream : public CopyingInputStream { - public: - CopyingIstreamInputStream(istream* input); - ~CopyingIstreamInputStream(); - - // implements CopyingInputStream --------------------------------- - int Read(void* buffer, int size); - // (We use the default implementation of Skip().) - - private: - // The stream. - istream* input_; - - GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(CopyingIstreamInputStream); - }; - - CopyingIstreamInputStream copying_input_; - CopyingInputStreamAdaptor impl_; - - GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(IstreamInputStream); -}; - -// =================================================================== - -// A ZeroCopyOutputStream which writes to a C++ ostream. -// -// Note that for writing files (or anything represented by a file descriptor), -// FileOutputStream is more efficient. -class LIBPROTOBUF_EXPORT OstreamOutputStream : public ZeroCopyOutputStream { - public: - // Creates a stream that writes to the given C++ ostream. - // If a block_size is given, it specifies the size of the buffers - // that should be returned by Next(). Otherwise, a reasonable default - // is used. - explicit OstreamOutputStream(ostream* stream, int block_size = -1); - ~OstreamOutputStream(); - - // implements ZeroCopyOutputStream --------------------------------- - bool Next(void** data, int* size); - void BackUp(int count); - int64 ByteCount() const; - - private: - class LIBPROTOBUF_EXPORT CopyingOstreamOutputStream : public CopyingOutputStream { - public: - CopyingOstreamOutputStream(ostream* output); - ~CopyingOstreamOutputStream(); - - // implements CopyingOutputStream -------------------------------- - bool Write(const void* buffer, int size); - - private: - // The stream. - ostream* output_; - - GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(CopyingOstreamOutputStream); - }; - - CopyingOstreamOutputStream copying_output_; - CopyingOutputStreamAdaptor impl_; - - GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(OstreamOutputStream); -}; - -// =================================================================== - -// A ZeroCopyInputStream which reads from several other streams in sequence. -// ConcatenatingInputStream is unable to distinguish between end-of-stream -// and read errors in the underlying streams, so it assumes any errors mean -// end-of-stream. So, if the underlying streams fail for any other reason, -// ConcatenatingInputStream may do odd things. It is suggested that you do -// not use ConcatenatingInputStream on streams that might produce read errors -// other than end-of-stream. -class LIBPROTOBUF_EXPORT ConcatenatingInputStream : public ZeroCopyInputStream { - public: - // All streams passed in as well as the array itself must remain valid - // until the ConcatenatingInputStream is destroyed. - ConcatenatingInputStream(ZeroCopyInputStream* const streams[], int count); - ~ConcatenatingInputStream(); - - // implements ZeroCopyInputStream ---------------------------------- - bool Next(const void** data, int* size); - void BackUp(int count); - bool Skip(int count); - int64 ByteCount() const; - - - private: - // As streams are retired, streams_ is incremented and count_ is - // decremented. - ZeroCopyInputStream* const* streams_; - int stream_count_; - int64 bytes_retired_; // Bytes read from previous streams. - - GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ConcatenatingInputStream); -}; - -// =================================================================== - -// A ZeroCopyInputStream which wraps some other stream and limits it to -// a particular byte count. -class LIBPROTOBUF_EXPORT LimitingInputStream : public ZeroCopyInputStream { - public: - LimitingInputStream(ZeroCopyInputStream* input, int64 limit); - ~LimitingInputStream(); - - // implements ZeroCopyInputStream ---------------------------------- - bool Next(const void** data, int* size); - void BackUp(int count); - bool Skip(int count); - int64 ByteCount() const; - - - private: - ZeroCopyInputStream* input_; - int64 limit_; // Decreases as we go, becomes negative if we overshoot. - - GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(LimitingInputStream); -}; - -// =================================================================== - -} // namespace io -} // namespace protobuf - -} // namespace google -#endif // GOOGLE_PROTOBUF_IO_ZERO_COPY_STREAM_IMPL_H__ diff --git a/modules/dnn/3rdparty/protobuf/src/google/protobuf/io/zero_copy_stream_impl_lite.cc b/modules/dnn/3rdparty/protobuf/src/google/protobuf/io/zero_copy_stream_impl_lite.cc deleted file mode 100644 index 07b2b2bfc..000000000 --- a/modules/dnn/3rdparty/protobuf/src/google/protobuf/io/zero_copy_stream_impl_lite.cc +++ /dev/null @@ -1,394 +0,0 @@ -// Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// http://code.google.com/p/protobuf/ -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -// Author: kenton@google.com (Kenton Varda) -// Based on original Protocol Buffers design by -// Sanjay Ghemawat, Jeff Dean, and others. - -#include -#include -#include -#include - -namespace google { -namespace protobuf { -namespace io { - -namespace { - -// Default block size for Copying{In,Out}putStreamAdaptor. -static const int kDefaultBlockSize = 8192; - -} // namespace - -// =================================================================== - -ArrayInputStream::ArrayInputStream(const void* data, int size, - int block_size) - : data_(reinterpret_cast(data)), - size_(size), - block_size_(block_size > 0 ? block_size : size), - position_(0), - last_returned_size_(0) { -} - -ArrayInputStream::~ArrayInputStream() { -} - -bool ArrayInputStream::Next(const void** data, int* size) { - if (position_ < size_) { - last_returned_size_ = std::min(block_size_, size_ - position_); - *data = data_ + position_; - *size = last_returned_size_; - position_ += last_returned_size_; - return true; - } else { - // We're at the end of the array. - last_returned_size_ = 0; // Don't let caller back up. - return false; - } -} - -void ArrayInputStream::BackUp(int count) { - GOOGLE_CHECK_GT(last_returned_size_, 0) - << "BackUp() can only be called after a successful Next()."; - GOOGLE_CHECK_LE(count, last_returned_size_); - GOOGLE_CHECK_GE(count, 0); - position_ -= count; - last_returned_size_ = 0; // Don't let caller back up further. -} - -bool ArrayInputStream::Skip(int count) { - GOOGLE_CHECK_GE(count, 0); - last_returned_size_ = 0; // Don't let caller back up. - if (count > size_ - position_) { - position_ = size_; - return false; - } else { - position_ += count; - return true; - } -} - -int64 ArrayInputStream::ByteCount() const { - return position_; -} - - -// =================================================================== - -ArrayOutputStream::ArrayOutputStream(void* data, int size, int block_size) - : data_(reinterpret_cast(data)), - size_(size), - block_size_(block_size > 0 ? block_size : size), - position_(0), - last_returned_size_(0) { -} - -ArrayOutputStream::~ArrayOutputStream() { -} - -bool ArrayOutputStream::Next(void** data, int* size) { - if (position_ < size_) { - last_returned_size_ = std::min(block_size_, size_ - position_); - *data = data_ + position_; - *size = last_returned_size_; - position_ += last_returned_size_; - return true; - } else { - // We're at the end of the array. - last_returned_size_ = 0; // Don't let caller back up. - return false; - } -} - -void ArrayOutputStream::BackUp(int count) { - GOOGLE_CHECK_GT(last_returned_size_, 0) - << "BackUp() can only be called after a successful Next()."; - GOOGLE_CHECK_LE(count, last_returned_size_); - GOOGLE_CHECK_GE(count, 0); - position_ -= count; - last_returned_size_ = 0; // Don't let caller back up further. -} - -int64 ArrayOutputStream::ByteCount() const { - return position_; -} - -// =================================================================== - -StringOutputStream::StringOutputStream(string* target) - : target_(target) { -} - -StringOutputStream::~StringOutputStream() { -} - -bool StringOutputStream::Next(void** data, int* size) { - int old_size = target_->size(); - - // Grow the string. - if (old_size < target_->capacity()) { - // Resize the string to match its capacity, since we can get away - // without a memory allocation this way. - STLStringResizeUninitialized(target_, target_->capacity()); - } else { - // Size has reached capacity, so double the size. Also make sure - // that the new size is at least kMinimumSize. - STLStringResizeUninitialized( - target_, - std::max(old_size * 2, - kMinimumSize + 0)); // "+ 0" works around GCC4 weirdness. - } - - *data = string_as_array(target_) + old_size; - *size = target_->size() - old_size; - return true; -} - -void StringOutputStream::BackUp(int count) { - GOOGLE_CHECK_GE(count, 0); - GOOGLE_CHECK_LE(count, target_->size()); - target_->resize(target_->size() - count); -} - -int64 StringOutputStream::ByteCount() const { - return target_->size(); -} - -// =================================================================== - -CopyingInputStream::~CopyingInputStream() {} - -int CopyingInputStream::Skip(int count) { - char junk[4096]; - int skipped = 0; - while (skipped < count) { - int bytes = Read(junk, std::min(count - skipped, - implicit_cast(sizeof(junk)))); - if (bytes <= 0) { - // EOF or read error. - return skipped; - } - skipped += bytes; - } - return skipped; -} - -CopyingInputStreamAdaptor::CopyingInputStreamAdaptor( - CopyingInputStream* copying_stream, int block_size) - : copying_stream_(copying_stream), - owns_copying_stream_(false), - failed_(false), - position_(0), - buffer_size_(block_size > 0 ? block_size : kDefaultBlockSize), - buffer_used_(0), - backup_bytes_(0) { -} - -CopyingInputStreamAdaptor::~CopyingInputStreamAdaptor() { - if (owns_copying_stream_) { - delete copying_stream_; - } -} - -bool CopyingInputStreamAdaptor::Next(const void** data, int* size) { - if (failed_) { - // Already failed on a previous read. - return false; - } - - AllocateBufferIfNeeded(); - - if (backup_bytes_ > 0) { - // We have data left over from a previous BackUp(), so just return that. - *data = buffer_.get() + buffer_used_ - backup_bytes_; - *size = backup_bytes_; - backup_bytes_ = 0; - return true; - } - - // Read new data into the buffer. - buffer_used_ = copying_stream_->Read(buffer_.get(), buffer_size_); - if (buffer_used_ <= 0) { - // EOF or read error. We don't need the buffer anymore. - if (buffer_used_ < 0) { - // Read error (not EOF). - failed_ = true; - } - FreeBuffer(); - return false; - } - position_ += buffer_used_; - - *size = buffer_used_; - *data = buffer_.get(); - return true; -} - -void CopyingInputStreamAdaptor::BackUp(int count) { - GOOGLE_CHECK(backup_bytes_ == 0 && buffer_.get() != NULL) - << " BackUp() can only be called after Next()."; - GOOGLE_CHECK_LE(count, buffer_used_) - << " Can't back up over more bytes than were returned by the last call" - " to Next()."; - GOOGLE_CHECK_GE(count, 0) - << " Parameter to BackUp() can't be negative."; - - backup_bytes_ = count; -} - -bool CopyingInputStreamAdaptor::Skip(int count) { - GOOGLE_CHECK_GE(count, 0); - - if (failed_) { - // Already failed on a previous read. - return false; - } - - // First skip any bytes left over from a previous BackUp(). - if (backup_bytes_ >= count) { - // We have more data left over than we're trying to skip. Just chop it. - backup_bytes_ -= count; - return true; - } - - count -= backup_bytes_; - backup_bytes_ = 0; - - int skipped = copying_stream_->Skip(count); - position_ += skipped; - return skipped == count; -} - -int64 CopyingInputStreamAdaptor::ByteCount() const { - return position_ - backup_bytes_; -} - -void CopyingInputStreamAdaptor::AllocateBufferIfNeeded() { - if (buffer_.get() == NULL) { - buffer_.reset(new uint8[buffer_size_]); - } -} - -void CopyingInputStreamAdaptor::FreeBuffer() { - GOOGLE_CHECK_EQ(backup_bytes_, 0); - buffer_used_ = 0; - buffer_.reset(); -} - -// =================================================================== - -CopyingOutputStream::~CopyingOutputStream() {} - -CopyingOutputStreamAdaptor::CopyingOutputStreamAdaptor( - CopyingOutputStream* copying_stream, int block_size) - : copying_stream_(copying_stream), - owns_copying_stream_(false), - failed_(false), - position_(0), - buffer_size_(block_size > 0 ? block_size : kDefaultBlockSize), - buffer_used_(0) { -} - -CopyingOutputStreamAdaptor::~CopyingOutputStreamAdaptor() { - WriteBuffer(); - if (owns_copying_stream_) { - delete copying_stream_; - } -} - -bool CopyingOutputStreamAdaptor::Flush() { - return WriteBuffer(); -} - -bool CopyingOutputStreamAdaptor::Next(void** data, int* size) { - if (buffer_used_ == buffer_size_) { - if (!WriteBuffer()) return false; - } - - AllocateBufferIfNeeded(); - - *data = buffer_.get() + buffer_used_; - *size = buffer_size_ - buffer_used_; - buffer_used_ = buffer_size_; - return true; -} - -void CopyingOutputStreamAdaptor::BackUp(int count) { - GOOGLE_CHECK_GE(count, 0); - GOOGLE_CHECK_EQ(buffer_used_, buffer_size_) - << " BackUp() can only be called after Next()."; - GOOGLE_CHECK_LE(count, buffer_used_) - << " Can't back up over more bytes than were returned by the last call" - " to Next()."; - - buffer_used_ -= count; -} - -int64 CopyingOutputStreamAdaptor::ByteCount() const { - return position_ + buffer_used_; -} - -bool CopyingOutputStreamAdaptor::WriteBuffer() { - if (failed_) { - // Already failed on a previous write. - return false; - } - - if (buffer_used_ == 0) return true; - - if (copying_stream_->Write(buffer_.get(), buffer_used_)) { - position_ += buffer_used_; - buffer_used_ = 0; - return true; - } else { - failed_ = true; - FreeBuffer(); - return false; - } -} - -void CopyingOutputStreamAdaptor::AllocateBufferIfNeeded() { - if (buffer_ == NULL) { - buffer_.reset(new uint8[buffer_size_]); - } -} - -void CopyingOutputStreamAdaptor::FreeBuffer() { - buffer_used_ = 0; - buffer_.reset(); -} - -// =================================================================== - -} // namespace io -} // namespace protobuf -} // namespace google diff --git a/modules/dnn/3rdparty/protobuf/src/google/protobuf/io/zero_copy_stream_impl_lite.h b/modules/dnn/3rdparty/protobuf/src/google/protobuf/io/zero_copy_stream_impl_lite.h deleted file mode 100644 index 153f543ee..000000000 --- a/modules/dnn/3rdparty/protobuf/src/google/protobuf/io/zero_copy_stream_impl_lite.h +++ /dev/null @@ -1,340 +0,0 @@ -// Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// http://code.google.com/p/protobuf/ -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -// Author: kenton@google.com (Kenton Varda) -// Based on original Protocol Buffers design by -// Sanjay Ghemawat, Jeff Dean, and others. -// -// This file contains common implementations of the interfaces defined in -// zero_copy_stream.h which are included in the "lite" protobuf library. -// These implementations cover I/O on raw arrays and strings, as well as -// adaptors which make it easy to implement streams based on traditional -// streams. Of course, many users will probably want to write their own -// implementations of these interfaces specific to the particular I/O -// abstractions they prefer to use, but these should cover the most common -// cases. - -#ifndef GOOGLE_PROTOBUF_IO_ZERO_COPY_STREAM_IMPL_LITE_H__ -#define GOOGLE_PROTOBUF_IO_ZERO_COPY_STREAM_IMPL_LITE_H__ - -#include -#include -#include -#include - - -namespace google { -namespace protobuf { -namespace io { - -// =================================================================== - -// A ZeroCopyInputStream backed by an in-memory array of bytes. -class LIBPROTOBUF_EXPORT ArrayInputStream : public ZeroCopyInputStream { - public: - // Create an InputStream that returns the bytes pointed to by "data". - // "data" remains the property of the caller but must remain valid until - // the stream is destroyed. If a block_size is given, calls to Next() - // will return data blocks no larger than the given size. Otherwise, the - // first call to Next() returns the entire array. block_size is mainly - // useful for testing; in production you would probably never want to set - // it. - ArrayInputStream(const void* data, int size, int block_size = -1); - ~ArrayInputStream(); - - // implements ZeroCopyInputStream ---------------------------------- - bool Next(const void** data, int* size); - void BackUp(int count); - bool Skip(int count); - int64 ByteCount() const; - - - private: - const uint8* const data_; // The byte array. - const int size_; // Total size of the array. - const int block_size_; // How many bytes to return at a time. - - int position_; - int last_returned_size_; // How many bytes we returned last time Next() - // was called (used for error checking only). - - GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ArrayInputStream); -}; - -// =================================================================== - -// A ZeroCopyOutputStream backed by an in-memory array of bytes. -class LIBPROTOBUF_EXPORT ArrayOutputStream : public ZeroCopyOutputStream { - public: - // Create an OutputStream that writes to the bytes pointed to by "data". - // "data" remains the property of the caller but must remain valid until - // the stream is destroyed. If a block_size is given, calls to Next() - // will return data blocks no larger than the given size. Otherwise, the - // first call to Next() returns the entire array. block_size is mainly - // useful for testing; in production you would probably never want to set - // it. - ArrayOutputStream(void* data, int size, int block_size = -1); - ~ArrayOutputStream(); - - // implements ZeroCopyOutputStream --------------------------------- - bool Next(void** data, int* size); - void BackUp(int count); - int64 ByteCount() const; - - private: - uint8* const data_; // The byte array. - const int size_; // Total size of the array. - const int block_size_; // How many bytes to return at a time. - - int position_; - int last_returned_size_; // How many bytes we returned last time Next() - // was called (used for error checking only). - - GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ArrayOutputStream); -}; - -// =================================================================== - -// A ZeroCopyOutputStream which appends bytes to a string. -class LIBPROTOBUF_EXPORT StringOutputStream : public ZeroCopyOutputStream { - public: - // Create a StringOutputStream which appends bytes to the given string. - // The string remains property of the caller, but it MUST NOT be accessed - // in any way until the stream is destroyed. - // - // Hint: If you call target->reserve(n) before creating the stream, - // the first call to Next() will return at least n bytes of buffer - // space. - explicit StringOutputStream(string* target); - ~StringOutputStream(); - - // implements ZeroCopyOutputStream --------------------------------- - bool Next(void** data, int* size); - void BackUp(int count); - int64 ByteCount() const; - - private: - static const int kMinimumSize = 16; - - string* target_; - - GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(StringOutputStream); -}; - -// Note: There is no StringInputStream. Instead, just create an -// ArrayInputStream as follows: -// ArrayInputStream input(str.data(), str.size()); - -// =================================================================== - -// A generic traditional input stream interface. -// -// Lots of traditional input streams (e.g. file descriptors, C stdio -// streams, and C++ iostreams) expose an interface where every read -// involves copying bytes into a buffer. If you want to take such an -// interface and make a ZeroCopyInputStream based on it, simply implement -// CopyingInputStream and then use CopyingInputStreamAdaptor. -// -// CopyingInputStream implementations should avoid buffering if possible. -// CopyingInputStreamAdaptor does its own buffering and will read data -// in large blocks. -class LIBPROTOBUF_EXPORT CopyingInputStream { - public: - virtual ~CopyingInputStream(); - - // Reads up to "size" bytes into the given buffer. Returns the number of - // bytes read. Read() waits until at least one byte is available, or - // returns zero if no bytes will ever become available (EOF), or -1 if a - // permanent read error occurred. - virtual int Read(void* buffer, int size) = 0; - - // Skips the next "count" bytes of input. Returns the number of bytes - // actually skipped. This will always be exactly equal to "count" unless - // EOF was reached or a permanent read error occurred. - // - // The default implementation just repeatedly calls Read() into a scratch - // buffer. - virtual int Skip(int count); -}; - -// A ZeroCopyInputStream which reads from a CopyingInputStream. This is -// useful for implementing ZeroCopyInputStreams that read from traditional -// streams. Note that this class is not really zero-copy. -// -// If you want to read from file descriptors or C++ istreams, this is -// already implemented for you: use FileInputStream or IstreamInputStream -// respectively. -class LIBPROTOBUF_EXPORT CopyingInputStreamAdaptor : public ZeroCopyInputStream { - public: - // Creates a stream that reads from the given CopyingInputStream. - // If a block_size is given, it specifies the number of bytes that - // should be read and returned with each call to Next(). Otherwise, - // a reasonable default is used. The caller retains ownership of - // copying_stream unless SetOwnsCopyingStream(true) is called. - explicit CopyingInputStreamAdaptor(CopyingInputStream* copying_stream, - int block_size = -1); - ~CopyingInputStreamAdaptor(); - - // Call SetOwnsCopyingStream(true) to tell the CopyingInputStreamAdaptor to - // delete the underlying CopyingInputStream when it is destroyed. - void SetOwnsCopyingStream(bool value) { owns_copying_stream_ = value; } - - // implements ZeroCopyInputStream ---------------------------------- - bool Next(const void** data, int* size); - void BackUp(int count); - bool Skip(int count); - int64 ByteCount() const; - - private: - // Insures that buffer_ is not NULL. - void AllocateBufferIfNeeded(); - // Frees the buffer and resets buffer_used_. - void FreeBuffer(); - - // The underlying copying stream. - CopyingInputStream* copying_stream_; - bool owns_copying_stream_; - - // True if we have seen a permenant error from the underlying stream. - bool failed_; - - // The current position of copying_stream_, relative to the point where - // we started reading. - int64 position_; - - // Data is read into this buffer. It may be NULL if no buffer is currently - // in use. Otherwise, it points to an array of size buffer_size_. - scoped_array buffer_; - const int buffer_size_; - - // Number of valid bytes currently in the buffer (i.e. the size last - // returned by Next()). 0 <= buffer_used_ <= buffer_size_. - int buffer_used_; - - // Number of bytes in the buffer which were backed up over by a call to - // BackUp(). These need to be returned again. - // 0 <= backup_bytes_ <= buffer_used_ - int backup_bytes_; - - GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(CopyingInputStreamAdaptor); -}; - -// =================================================================== - -// A generic traditional output stream interface. -// -// Lots of traditional output streams (e.g. file descriptors, C stdio -// streams, and C++ iostreams) expose an interface where every write -// involves copying bytes from a buffer. If you want to take such an -// interface and make a ZeroCopyOutputStream based on it, simply implement -// CopyingOutputStream and then use CopyingOutputStreamAdaptor. -// -// CopyingOutputStream implementations should avoid buffering if possible. -// CopyingOutputStreamAdaptor does its own buffering and will write data -// in large blocks. -class LIBPROTOBUF_EXPORT CopyingOutputStream { - public: - virtual ~CopyingOutputStream(); - - // Writes "size" bytes from the given buffer to the output. Returns true - // if successful, false on a write error. - virtual bool Write(const void* buffer, int size) = 0; -}; - -// A ZeroCopyOutputStream which writes to a CopyingOutputStream. This is -// useful for implementing ZeroCopyOutputStreams that write to traditional -// streams. Note that this class is not really zero-copy. -// -// If you want to write to file descriptors or C++ ostreams, this is -// already implemented for you: use FileOutputStream or OstreamOutputStream -// respectively. -class LIBPROTOBUF_EXPORT CopyingOutputStreamAdaptor : public ZeroCopyOutputStream { - public: - // Creates a stream that writes to the given Unix file descriptor. - // If a block_size is given, it specifies the size of the buffers - // that should be returned by Next(). Otherwise, a reasonable default - // is used. - explicit CopyingOutputStreamAdaptor(CopyingOutputStream* copying_stream, - int block_size = -1); - ~CopyingOutputStreamAdaptor(); - - // Writes all pending data to the underlying stream. Returns false if a - // write error occurred on the underlying stream. (The underlying - // stream itself is not necessarily flushed.) - bool Flush(); - - // Call SetOwnsCopyingStream(true) to tell the CopyingOutputStreamAdaptor to - // delete the underlying CopyingOutputStream when it is destroyed. - void SetOwnsCopyingStream(bool value) { owns_copying_stream_ = value; } - - // implements ZeroCopyOutputStream --------------------------------- - bool Next(void** data, int* size); - void BackUp(int count); - int64 ByteCount() const; - - private: - // Write the current buffer, if it is present. - bool WriteBuffer(); - // Insures that buffer_ is not NULL. - void AllocateBufferIfNeeded(); - // Frees the buffer. - void FreeBuffer(); - - // The underlying copying stream. - CopyingOutputStream* copying_stream_; - bool owns_copying_stream_; - - // True if we have seen a permenant error from the underlying stream. - bool failed_; - - // The current position of copying_stream_, relative to the point where - // we started writing. - int64 position_; - - // Data is written from this buffer. It may be NULL if no buffer is - // currently in use. Otherwise, it points to an array of size buffer_size_. - scoped_array buffer_; - const int buffer_size_; - - // Number of valid bytes currently in the buffer (i.e. the size last - // returned by Next()). When BackUp() is called, we just reduce this. - // 0 <= buffer_used_ <= buffer_size_. - int buffer_used_; - - GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(CopyingOutputStreamAdaptor); -}; - -// =================================================================== - -} // namespace io -} // namespace protobuf - -} // namespace google -#endif // GOOGLE_PROTOBUF_IO_ZERO_COPY_STREAM_IMPL_LITE_H__ diff --git a/modules/dnn/3rdparty/protobuf/src/google/protobuf/io/zero_copy_stream_unittest.cc b/modules/dnn/3rdparty/protobuf/src/google/protobuf/io/zero_copy_stream_unittest.cc deleted file mode 100644 index 6f155df7e..000000000 --- a/modules/dnn/3rdparty/protobuf/src/google/protobuf/io/zero_copy_stream_unittest.cc +++ /dev/null @@ -1,944 +0,0 @@ -// Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// http://code.google.com/p/protobuf/ -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -// Author: kenton@google.com (Kenton Varda) -// Based on original Protocol Buffers design by -// Sanjay Ghemawat, Jeff Dean, and others. -// -// Testing strategy: For each type of I/O (array, string, file, etc.) we -// create an output stream and write some data to it, then create a -// corresponding input stream to read the same data back and expect it to -// match. When the data is written, it is written in several small chunks -// of varying sizes, with a BackUp() after each chunk. It is read back -// similarly, but with chunks separated at different points. The whole -// process is run with a variety of block sizes for both the input and -// the output. -// -// TODO(kenton): Rewrite this test to bring it up to the standards of all -// the other proto2 tests. May want to wait for gTest to implement -// "parametized tests" so that one set of tests can be used on all the -// implementations. - -#include "config.h" - -#ifdef _MSC_VER -#include -#else -#include -#endif -#include -#include -#include -#include -#include -#include - -#include -#include - -#if HAVE_ZLIB -#include -#endif - -#include -#include -#include -#include - -namespace google { -namespace protobuf { -namespace io { -namespace { - -#ifdef _WIN32 -#define pipe(fds) _pipe(fds, 4096, O_BINARY) -#endif - -#ifndef O_BINARY -#ifdef _O_BINARY -#define O_BINARY _O_BINARY -#else -#define O_BINARY 0 // If this isn't defined, the platform doesn't need it. -#endif -#endif - -class IoTest : public testing::Test { - protected: - // Test helpers. - - // Helper to write an array of data to an output stream. - bool WriteToOutput(ZeroCopyOutputStream* output, const void* data, int size); - // Helper to read a fixed-length array of data from an input stream. - int ReadFromInput(ZeroCopyInputStream* input, void* data, int size); - // Write a string to the output stream. - void WriteString(ZeroCopyOutputStream* output, const string& str); - // Read a number of bytes equal to the size of the given string and checks - // that it matches the string. - void ReadString(ZeroCopyInputStream* input, const string& str); - // Writes some text to the output stream in a particular order. Returns - // the number of bytes written, incase the caller needs that to set up an - // input stream. - int WriteStuff(ZeroCopyOutputStream* output); - // Reads text from an input stream and expects it to match what - // WriteStuff() writes. - void ReadStuff(ZeroCopyInputStream* input); - - // Similar to WriteStuff, but performs more sophisticated testing. - int WriteStuffLarge(ZeroCopyOutputStream* output); - // Reads and tests a stream that should have been written to - // via WriteStuffLarge(). - void ReadStuffLarge(ZeroCopyInputStream* input); - -#if HAVE_ZLIB - string Compress(const string& data, const GzipOutputStream::Options& options); - string Uncompress(const string& data); -#endif - - static const int kBlockSizes[]; - static const int kBlockSizeCount; -}; - -const int IoTest::kBlockSizes[] = {-1, 1, 2, 5, 7, 10, 23, 64}; -const int IoTest::kBlockSizeCount = GOOGLE_ARRAYSIZE(IoTest::kBlockSizes); - -bool IoTest::WriteToOutput(ZeroCopyOutputStream* output, - const void* data, int size) { - const uint8* in = reinterpret_cast(data); - int in_size = size; - - void* out; - int out_size; - - while (true) { - if (!output->Next(&out, &out_size)) { - return false; - } - EXPECT_GT(out_size, 0); - - if (in_size <= out_size) { - memcpy(out, in, in_size); - output->BackUp(out_size - in_size); - return true; - } - - memcpy(out, in, out_size); - in += out_size; - in_size -= out_size; - } -} - -#define MAX_REPEATED_ZEROS 100 - -int IoTest::ReadFromInput(ZeroCopyInputStream* input, void* data, int size) { - uint8* out = reinterpret_cast(data); - int out_size = size; - - const void* in; - int in_size = 0; - - int repeated_zeros = 0; - - while (true) { - if (!input->Next(&in, &in_size)) { - return size - out_size; - } - EXPECT_GT(in_size, -1); - if (in_size == 0) { - repeated_zeros++; - } else { - repeated_zeros = 0; - } - EXPECT_LT(repeated_zeros, MAX_REPEATED_ZEROS); - - if (out_size <= in_size) { - memcpy(out, in, out_size); - if (in_size > out_size) { - input->BackUp(in_size - out_size); - } - return size; // Copied all of it. - } - - memcpy(out, in, in_size); - out += in_size; - out_size -= in_size; - } -} - -void IoTest::WriteString(ZeroCopyOutputStream* output, const string& str) { - EXPECT_TRUE(WriteToOutput(output, str.c_str(), str.size())); -} - -void IoTest::ReadString(ZeroCopyInputStream* input, const string& str) { - scoped_array buffer(new char[str.size() + 1]); - buffer[str.size()] = '\0'; - EXPECT_EQ(ReadFromInput(input, buffer.get(), str.size()), str.size()); - EXPECT_STREQ(str.c_str(), buffer.get()); -} - -int IoTest::WriteStuff(ZeroCopyOutputStream* output) { - WriteString(output, "Hello world!\n"); - WriteString(output, "Some te"); - WriteString(output, "xt. Blah blah."); - WriteString(output, "abcdefg"); - WriteString(output, "01234567890123456789"); - WriteString(output, "foobar"); - - EXPECT_EQ(output->ByteCount(), 68); - - int result = output->ByteCount(); - return result; -} - -// Reads text from an input stream and expects it to match what WriteStuff() -// writes. -void IoTest::ReadStuff(ZeroCopyInputStream* input) { - ReadString(input, "Hello world!\n"); - ReadString(input, "Some text. "); - ReadString(input, "Blah "); - ReadString(input, "blah."); - ReadString(input, "abcdefg"); - EXPECT_TRUE(input->Skip(20)); - ReadString(input, "foo"); - ReadString(input, "bar"); - - EXPECT_EQ(input->ByteCount(), 68); - - uint8 byte; - EXPECT_EQ(ReadFromInput(input, &byte, 1), 0); -} - -int IoTest::WriteStuffLarge(ZeroCopyOutputStream* output) { - WriteString(output, "Hello world!\n"); - WriteString(output, "Some te"); - WriteString(output, "xt. Blah blah."); - WriteString(output, string(100000, 'x')); // A very long string - WriteString(output, string(100000, 'y')); // A very long string - WriteString(output, "01234567890123456789"); - - EXPECT_EQ(output->ByteCount(), 200055); - - int result = output->ByteCount(); - return result; -} - -// Reads text from an input stream and expects it to match what WriteStuff() -// writes. -void IoTest::ReadStuffLarge(ZeroCopyInputStream* input) { - ReadString(input, "Hello world!\nSome text. "); - EXPECT_TRUE(input->Skip(5)); - ReadString(input, "blah."); - EXPECT_TRUE(input->Skip(100000 - 10)); - ReadString(input, string(10, 'x') + string(100000 - 20000, 'y')); - EXPECT_TRUE(input->Skip(20000 - 10)); - ReadString(input, "yyyyyyyyyy01234567890123456789"); - - EXPECT_EQ(input->ByteCount(), 200055); - - uint8 byte; - EXPECT_EQ(ReadFromInput(input, &byte, 1), 0); -} - -// =================================================================== - -TEST_F(IoTest, ArrayIo) { - const int kBufferSize = 256; - uint8 buffer[kBufferSize]; - - for (int i = 0; i < kBlockSizeCount; i++) { - for (int j = 0; j < kBlockSizeCount; j++) { - int size; - { - ArrayOutputStream output(buffer, kBufferSize, kBlockSizes[i]); - size = WriteStuff(&output); - } - { - ArrayInputStream input(buffer, size, kBlockSizes[j]); - ReadStuff(&input); - } - } - } -} - -TEST_F(IoTest, TwoSessionWrite) { - // Test that two concatenated write sessions read correctly - - static const char* strA = "0123456789"; - static const char* strB = "WhirledPeas"; - const int kBufferSize = 2*1024; - uint8* buffer = new uint8[kBufferSize]; - char* temp_buffer = new char[40]; - - for (int i = 0; i < kBlockSizeCount; i++) { - for (int j = 0; j < kBlockSizeCount; j++) { - ArrayOutputStream* output = - new ArrayOutputStream(buffer, kBufferSize, kBlockSizes[i]); - CodedOutputStream* coded_output = new CodedOutputStream(output); - coded_output->WriteVarint32(strlen(strA)); - coded_output->WriteRaw(strA, strlen(strA)); - delete coded_output; // flush - int64 pos = output->ByteCount(); - delete output; - output = new ArrayOutputStream( - buffer + pos, kBufferSize - pos, kBlockSizes[i]); - coded_output = new CodedOutputStream(output); - coded_output->WriteVarint32(strlen(strB)); - coded_output->WriteRaw(strB, strlen(strB)); - delete coded_output; // flush - int64 size = pos + output->ByteCount(); - delete output; - - ArrayInputStream* input = - new ArrayInputStream(buffer, size, kBlockSizes[j]); - CodedInputStream* coded_input = new CodedInputStream(input); - uint32 insize; - EXPECT_TRUE(coded_input->ReadVarint32(&insize)); - EXPECT_EQ(strlen(strA), insize); - EXPECT_TRUE(coded_input->ReadRaw(temp_buffer, insize)); - EXPECT_EQ(0, memcmp(temp_buffer, strA, insize)); - - EXPECT_TRUE(coded_input->ReadVarint32(&insize)); - EXPECT_EQ(strlen(strB), insize); - EXPECT_TRUE(coded_input->ReadRaw(temp_buffer, insize)); - EXPECT_EQ(0, memcmp(temp_buffer, strB, insize)); - - delete coded_input; - delete input; - } - } - - delete [] temp_buffer; - delete [] buffer; -} - -#if HAVE_ZLIB -TEST_F(IoTest, GzipIo) { - const int kBufferSize = 2*1024; - uint8* buffer = new uint8[kBufferSize]; - for (int i = 0; i < kBlockSizeCount; i++) { - for (int j = 0; j < kBlockSizeCount; j++) { - for (int z = 0; z < kBlockSizeCount; z++) { - int gzip_buffer_size = kBlockSizes[z]; - int size; - { - ArrayOutputStream output(buffer, kBufferSize, kBlockSizes[i]); - GzipOutputStream::Options options; - options.format = GzipOutputStream::GZIP; - if (gzip_buffer_size != -1) { - options.buffer_size = gzip_buffer_size; - } - GzipOutputStream gzout(&output, options); - WriteStuff(&gzout); - gzout.Close(); - size = output.ByteCount(); - } - { - ArrayInputStream input(buffer, size, kBlockSizes[j]); - GzipInputStream gzin( - &input, GzipInputStream::GZIP, gzip_buffer_size); - ReadStuff(&gzin); - } - } - } - } - delete [] buffer; -} - -TEST_F(IoTest, GzipIoWithFlush) { - const int kBufferSize = 2*1024; - uint8* buffer = new uint8[kBufferSize]; - // We start with i = 4 as we want a block size > 6. With block size <= 6 - // Flush() fills up the entire 2K buffer with flush markers and the test - // fails. See documentation for Flush() for more detail. - for (int i = 4; i < kBlockSizeCount; i++) { - for (int j = 0; j < kBlockSizeCount; j++) { - for (int z = 0; z < kBlockSizeCount; z++) { - int gzip_buffer_size = kBlockSizes[z]; - int size; - { - ArrayOutputStream output(buffer, kBufferSize, kBlockSizes[i]); - GzipOutputStream::Options options; - options.format = GzipOutputStream::GZIP; - if (gzip_buffer_size != -1) { - options.buffer_size = gzip_buffer_size; - } - GzipOutputStream gzout(&output, options); - WriteStuff(&gzout); - EXPECT_TRUE(gzout.Flush()); - gzout.Close(); - size = output.ByteCount(); - } - { - ArrayInputStream input(buffer, size, kBlockSizes[j]); - GzipInputStream gzin( - &input, GzipInputStream::GZIP, gzip_buffer_size); - ReadStuff(&gzin); - } - } - } - } - delete [] buffer; -} - -TEST_F(IoTest, GzipIoContiguousFlushes) { - const int kBufferSize = 2*1024; - uint8* buffer = new uint8[kBufferSize]; - - int block_size = kBlockSizes[4]; - int gzip_buffer_size = block_size; - int size; - - ArrayOutputStream output(buffer, kBufferSize, block_size); - GzipOutputStream::Options options; - options.format = GzipOutputStream::GZIP; - if (gzip_buffer_size != -1) { - options.buffer_size = gzip_buffer_size; - } - GzipOutputStream gzout(&output, options); - WriteStuff(&gzout); - EXPECT_TRUE(gzout.Flush()); - EXPECT_TRUE(gzout.Flush()); - gzout.Close(); - size = output.ByteCount(); - - ArrayInputStream input(buffer, size, block_size); - GzipInputStream gzin( - &input, GzipInputStream::GZIP, gzip_buffer_size); - ReadStuff(&gzin); - - delete [] buffer; -} - -TEST_F(IoTest, GzipIoReadAfterFlush) { - const int kBufferSize = 2*1024; - uint8* buffer = new uint8[kBufferSize]; - - int block_size = kBlockSizes[4]; - int gzip_buffer_size = block_size; - int size; - ArrayOutputStream output(buffer, kBufferSize, block_size); - GzipOutputStream::Options options; - options.format = GzipOutputStream::GZIP; - if (gzip_buffer_size != -1) { - options.buffer_size = gzip_buffer_size; - } - - GzipOutputStream gzout(&output, options); - WriteStuff(&gzout); - EXPECT_TRUE(gzout.Flush()); - size = output.ByteCount(); - - ArrayInputStream input(buffer, size, block_size); - GzipInputStream gzin( - &input, GzipInputStream::GZIP, gzip_buffer_size); - ReadStuff(&gzin); - - gzout.Close(); - - delete [] buffer; -} - -TEST_F(IoTest, ZlibIo) { - const int kBufferSize = 2*1024; - uint8* buffer = new uint8[kBufferSize]; - for (int i = 0; i < kBlockSizeCount; i++) { - for (int j = 0; j < kBlockSizeCount; j++) { - for (int z = 0; z < kBlockSizeCount; z++) { - int gzip_buffer_size = kBlockSizes[z]; - int size; - { - ArrayOutputStream output(buffer, kBufferSize, kBlockSizes[i]); - GzipOutputStream::Options options; - options.format = GzipOutputStream::ZLIB; - if (gzip_buffer_size != -1) { - options.buffer_size = gzip_buffer_size; - } - GzipOutputStream gzout(&output, options); - WriteStuff(&gzout); - gzout.Close(); - size = output.ByteCount(); - } - { - ArrayInputStream input(buffer, size, kBlockSizes[j]); - GzipInputStream gzin( - &input, GzipInputStream::ZLIB, gzip_buffer_size); - ReadStuff(&gzin); - } - } - } - } - delete [] buffer; -} - -TEST_F(IoTest, ZlibIoInputAutodetect) { - const int kBufferSize = 2*1024; - uint8* buffer = new uint8[kBufferSize]; - int size; - { - ArrayOutputStream output(buffer, kBufferSize); - GzipOutputStream::Options options; - options.format = GzipOutputStream::ZLIB; - GzipOutputStream gzout(&output, options); - WriteStuff(&gzout); - gzout.Close(); - size = output.ByteCount(); - } - { - ArrayInputStream input(buffer, size); - GzipInputStream gzin(&input, GzipInputStream::AUTO); - ReadStuff(&gzin); - } - { - ArrayOutputStream output(buffer, kBufferSize); - GzipOutputStream::Options options; - options.format = GzipOutputStream::GZIP; - GzipOutputStream gzout(&output, options); - WriteStuff(&gzout); - gzout.Close(); - size = output.ByteCount(); - } - { - ArrayInputStream input(buffer, size); - GzipInputStream gzin(&input, GzipInputStream::AUTO); - ReadStuff(&gzin); - } - delete [] buffer; -} - -string IoTest::Compress(const string& data, - const GzipOutputStream::Options& options) { - string result; - { - StringOutputStream output(&result); - GzipOutputStream gzout(&output, options); - WriteToOutput(&gzout, data.data(), data.size()); - } - return result; -} - -string IoTest::Uncompress(const string& data) { - string result; - { - ArrayInputStream input(data.data(), data.size()); - GzipInputStream gzin(&input); - const void* buffer; - int size; - while (gzin.Next(&buffer, &size)) { - result.append(reinterpret_cast(buffer), size); - } - } - return result; -} - -TEST_F(IoTest, CompressionOptions) { - // Some ad-hoc testing of compression options. - - string golden; - File::ReadFileToStringOrDie( - TestSourceDir() + "/google/protobuf/testdata/golden_message", - &golden); - - GzipOutputStream::Options options; - string gzip_compressed = Compress(golden, options); - - options.compression_level = 0; - string not_compressed = Compress(golden, options); - - // Try zlib compression for fun. - options = GzipOutputStream::Options(); - options.format = GzipOutputStream::ZLIB; - string zlib_compressed = Compress(golden, options); - - // Uncompressed should be bigger than the original since it should have some - // sort of header. - EXPECT_GT(not_compressed.size(), golden.size()); - - // Higher compression levels should result in smaller sizes. - EXPECT_LT(zlib_compressed.size(), not_compressed.size()); - - // ZLIB format should differ from GZIP format. - EXPECT_TRUE(zlib_compressed != gzip_compressed); - - // Everything should decompress correctly. - EXPECT_TRUE(Uncompress(not_compressed) == golden); - EXPECT_TRUE(Uncompress(gzip_compressed) == golden); - EXPECT_TRUE(Uncompress(zlib_compressed) == golden); -} - -TEST_F(IoTest, TwoSessionWriteGzip) { - // Test that two concatenated gzip streams can be read correctly - - static const char* strA = "0123456789"; - static const char* strB = "QuickBrownFox"; - const int kBufferSize = 2*1024; - uint8* buffer = new uint8[kBufferSize]; - char* temp_buffer = new char[40]; - - for (int i = 0; i < kBlockSizeCount; i++) { - for (int j = 0; j < kBlockSizeCount; j++) { - ArrayOutputStream* output = - new ArrayOutputStream(buffer, kBufferSize, kBlockSizes[i]); - GzipOutputStream* gzout = new GzipOutputStream(output); - CodedOutputStream* coded_output = new CodedOutputStream(gzout); - int32 outlen = strlen(strA) + 1; - coded_output->WriteVarint32(outlen); - coded_output->WriteRaw(strA, outlen); - delete coded_output; // flush - delete gzout; // flush - int64 pos = output->ByteCount(); - delete output; - output = new ArrayOutputStream( - buffer + pos, kBufferSize - pos, kBlockSizes[i]); - gzout = new GzipOutputStream(output); - coded_output = new CodedOutputStream(gzout); - outlen = strlen(strB) + 1; - coded_output->WriteVarint32(outlen); - coded_output->WriteRaw(strB, outlen); - delete coded_output; // flush - delete gzout; // flush - int64 size = pos + output->ByteCount(); - delete output; - - ArrayInputStream* input = - new ArrayInputStream(buffer, size, kBlockSizes[j]); - GzipInputStream* gzin = new GzipInputStream(input); - CodedInputStream* coded_input = new CodedInputStream(gzin); - uint32 insize; - EXPECT_TRUE(coded_input->ReadVarint32(&insize)); - EXPECT_EQ(strlen(strA) + 1, insize); - EXPECT_TRUE(coded_input->ReadRaw(temp_buffer, insize)); - EXPECT_EQ(0, memcmp(temp_buffer, strA, insize)) - << "strA=" << strA << " in=" << temp_buffer; - - EXPECT_TRUE(coded_input->ReadVarint32(&insize)); - EXPECT_EQ(strlen(strB) + 1, insize); - EXPECT_TRUE(coded_input->ReadRaw(temp_buffer, insize)); - EXPECT_EQ(0, memcmp(temp_buffer, strB, insize)) - << " out_block_size=" << kBlockSizes[i] - << " in_block_size=" << kBlockSizes[j] - << " pos=" << pos - << " size=" << size - << " strB=" << strB << " in=" << temp_buffer; - - delete coded_input; - delete gzin; - delete input; - } - } - - delete [] temp_buffer; - delete [] buffer; -} -#endif - -// There is no string input, only string output. Also, it doesn't support -// explicit block sizes. So, we'll only run one test and we'll use -// ArrayInput to read back the results. -TEST_F(IoTest, StringIo) { - string str; - { - StringOutputStream output(&str); - WriteStuff(&output); - } - { - ArrayInputStream input(str.data(), str.size()); - ReadStuff(&input); - } -} - - -// To test files, we create a temporary file, write, read, truncate, repeat. -TEST_F(IoTest, FileIo) { - string filename = TestTempDir() + "/zero_copy_stream_test_file"; - - for (int i = 0; i < kBlockSizeCount; i++) { - for (int j = 0; j < kBlockSizeCount; j++) { - // Make a temporary file. - int file = - open(filename.c_str(), O_RDWR | O_CREAT | O_TRUNC | O_BINARY, 0777); - ASSERT_GE(file, 0); - - { - FileOutputStream output(file, kBlockSizes[i]); - WriteStuff(&output); - EXPECT_EQ(0, output.GetErrno()); - } - - // Rewind. - ASSERT_NE(lseek(file, 0, SEEK_SET), (off_t)-1); - - { - FileInputStream input(file, kBlockSizes[j]); - ReadStuff(&input); - EXPECT_EQ(0, input.GetErrno()); - } - - close(file); - } - } -} - -#if HAVE_ZLIB -TEST_F(IoTest, GzipFileIo) { - string filename = TestTempDir() + "/zero_copy_stream_test_file"; - - for (int i = 0; i < kBlockSizeCount; i++) { - for (int j = 0; j < kBlockSizeCount; j++) { - // Make a temporary file. - int file = - open(filename.c_str(), O_RDWR | O_CREAT | O_TRUNC | O_BINARY, 0777); - ASSERT_GE(file, 0); - { - FileOutputStream output(file, kBlockSizes[i]); - GzipOutputStream gzout(&output); - WriteStuffLarge(&gzout); - gzout.Close(); - output.Flush(); - EXPECT_EQ(0, output.GetErrno()); - } - - // Rewind. - ASSERT_NE(lseek(file, 0, SEEK_SET), (off_t)-1); - - { - FileInputStream input(file, kBlockSizes[j]); - GzipInputStream gzin(&input); - ReadStuffLarge(&gzin); - EXPECT_EQ(0, input.GetErrno()); - } - - close(file); - } - } -} -#endif - -// MSVC raises various debugging exceptions if we try to use a file -// descriptor of -1, defeating our tests below. This class will disable -// these debug assertions while in scope. -class MsvcDebugDisabler { - public: -#if defined(_MSC_VER) && _MSC_VER >= 1400 - MsvcDebugDisabler() { - old_handler_ = _set_invalid_parameter_handler(MyHandler); - old_mode_ = _CrtSetReportMode(_CRT_ASSERT, 0); - } - ~MsvcDebugDisabler() { - old_handler_ = _set_invalid_parameter_handler(old_handler_); - old_mode_ = _CrtSetReportMode(_CRT_ASSERT, old_mode_); - } - - static void MyHandler(const wchar_t *expr, - const wchar_t *func, - const wchar_t *file, - unsigned int line, - uintptr_t pReserved) { - // do nothing - } - - _invalid_parameter_handler old_handler_; - int old_mode_; -#else - // Dummy constructor and destructor to ensure that GCC doesn't complain - // that debug_disabler is an unused variable. - MsvcDebugDisabler() {} - ~MsvcDebugDisabler() {} -#endif -}; - -// Test that FileInputStreams report errors correctly. -TEST_F(IoTest, FileReadError) { - MsvcDebugDisabler debug_disabler; - - // -1 = invalid file descriptor. - FileInputStream input(-1); - - const void* buffer; - int size; - EXPECT_FALSE(input.Next(&buffer, &size)); - EXPECT_EQ(EBADF, input.GetErrno()); -} - -// Test that FileOutputStreams report errors correctly. -TEST_F(IoTest, FileWriteError) { - MsvcDebugDisabler debug_disabler; - - // -1 = invalid file descriptor. - FileOutputStream input(-1); - - void* buffer; - int size; - - // The first call to Next() succeeds because it doesn't have anything to - // write yet. - EXPECT_TRUE(input.Next(&buffer, &size)); - - // Second call fails. - EXPECT_FALSE(input.Next(&buffer, &size)); - - EXPECT_EQ(EBADF, input.GetErrno()); -} - -// Pipes are not seekable, so File{Input,Output}Stream ends up doing some -// different things to handle them. We'll test by writing to a pipe and -// reading back from it. -TEST_F(IoTest, PipeIo) { - int files[2]; - - for (int i = 0; i < kBlockSizeCount; i++) { - for (int j = 0; j < kBlockSizeCount; j++) { - // Need to create a new pipe each time because ReadStuff() expects - // to see EOF at the end. - ASSERT_EQ(pipe(files), 0); - - { - FileOutputStream output(files[1], kBlockSizes[i]); - WriteStuff(&output); - EXPECT_EQ(0, output.GetErrno()); - } - close(files[1]); // Send EOF. - - { - FileInputStream input(files[0], kBlockSizes[j]); - ReadStuff(&input); - EXPECT_EQ(0, input.GetErrno()); - } - close(files[0]); - } - } -} - -// Test using C++ iostreams. -TEST_F(IoTest, IostreamIo) { - for (int i = 0; i < kBlockSizeCount; i++) { - for (int j = 0; j < kBlockSizeCount; j++) { - { - stringstream stream; - - { - OstreamOutputStream output(&stream, kBlockSizes[i]); - WriteStuff(&output); - EXPECT_FALSE(stream.fail()); - } - - { - IstreamInputStream input(&stream, kBlockSizes[j]); - ReadStuff(&input); - EXPECT_TRUE(stream.eof()); - } - } - - { - stringstream stream; - - { - OstreamOutputStream output(&stream, kBlockSizes[i]); - WriteStuffLarge(&output); - EXPECT_FALSE(stream.fail()); - } - - { - IstreamInputStream input(&stream, kBlockSizes[j]); - ReadStuffLarge(&input); - EXPECT_TRUE(stream.eof()); - } - } - } - } -} - -// To test ConcatenatingInputStream, we create several ArrayInputStreams -// covering a buffer and then concatenate them. -TEST_F(IoTest, ConcatenatingInputStream) { - const int kBufferSize = 256; - uint8 buffer[kBufferSize]; - - // Fill the buffer. - ArrayOutputStream output(buffer, kBufferSize); - WriteStuff(&output); - - // Now split it up into multiple streams of varying sizes. - ASSERT_EQ(68, output.ByteCount()); // Test depends on this. - ArrayInputStream input1(buffer , 12); - ArrayInputStream input2(buffer + 12, 7); - ArrayInputStream input3(buffer + 19, 6); - ArrayInputStream input4(buffer + 25, 15); - ArrayInputStream input5(buffer + 40, 0); - // Note: We want to make sure we have a stream boundary somewhere between - // bytes 42 and 62, which is the range that it Skip()ed by ReadStuff(). This - // tests that a bug that existed in the original code for Skip() is fixed. - ArrayInputStream input6(buffer + 40, 10); - ArrayInputStream input7(buffer + 50, 18); // Total = 68 bytes. - - ZeroCopyInputStream* streams[] = - {&input1, &input2, &input3, &input4, &input5, &input6, &input7}; - - // Create the concatenating stream and read. - ConcatenatingInputStream input(streams, GOOGLE_ARRAYSIZE(streams)); - ReadStuff(&input); -} - -// To test LimitingInputStream, we write our golden text to a buffer, then -// create an ArrayInputStream that contains the whole buffer (not just the -// bytes written), then use a LimitingInputStream to limit it just to the -// bytes written. -TEST_F(IoTest, LimitingInputStream) { - const int kBufferSize = 256; - uint8 buffer[kBufferSize]; - - // Fill the buffer. - ArrayOutputStream output(buffer, kBufferSize); - WriteStuff(&output); - - // Set up input. - ArrayInputStream array_input(buffer, kBufferSize); - LimitingInputStream input(&array_input, output.ByteCount()); - - ReadStuff(&input); -} - -// Check that a zero-size array doesn't confuse the code. -TEST(ZeroSizeArray, Input) { - ArrayInputStream input(NULL, 0); - const void* data; - int size; - EXPECT_FALSE(input.Next(&data, &size)); -} - -TEST(ZeroSizeArray, Output) { - ArrayOutputStream output(NULL, 0); - void* data; - int size; - EXPECT_FALSE(output.Next(&data, &size)); -} - -} // namespace -} // namespace io -} // namespace protobuf -} // namespace google diff --git a/modules/dnn/3rdparty/protobuf/src/google/protobuf/lite_unittest.cc b/modules/dnn/3rdparty/protobuf/src/google/protobuf/lite_unittest.cc deleted file mode 100644 index 7a0a57b77..000000000 --- a/modules/dnn/3rdparty/protobuf/src/google/protobuf/lite_unittest.cc +++ /dev/null @@ -1,185 +0,0 @@ -// Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// http://code.google.com/p/protobuf/ -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -// Author: kenton@google.com (Kenton Varda) - -#include -#include - -#include -#include -#include - -using namespace std; - -namespace { -// Helper methods to test parsing merge behavior. -void ExpectMessageMerged(const google::protobuf::unittest::TestAllTypesLite& message) { - GOOGLE_CHECK(message.optional_int32() == 3); - GOOGLE_CHECK(message.optional_int64() == 2); - GOOGLE_CHECK(message.optional_string() == "hello"); -} - -void AssignParsingMergeMessages( - google::protobuf::unittest::TestAllTypesLite* msg1, - google::protobuf::unittest::TestAllTypesLite* msg2, - google::protobuf::unittest::TestAllTypesLite* msg3) { - msg1->set_optional_int32(1); - msg2->set_optional_int64(2); - msg3->set_optional_int32(3); - msg3->set_optional_string("hello"); -} - -} // namespace - -int main(int argc, char* argv[]) { - string data, packed_data; - - { - protobuf_unittest::TestAllTypesLite message, message2, message3; - google::protobuf::TestUtilLite::ExpectClear(message); - google::protobuf::TestUtilLite::SetAllFields(&message); - message2.CopyFrom(message); - data = message.SerializeAsString(); - message3.ParseFromString(data); - google::protobuf::TestUtilLite::ExpectAllFieldsSet(message); - google::protobuf::TestUtilLite::ExpectAllFieldsSet(message2); - google::protobuf::TestUtilLite::ExpectAllFieldsSet(message3); - google::protobuf::TestUtilLite::ModifyRepeatedFields(&message); - google::protobuf::TestUtilLite::ExpectRepeatedFieldsModified(message); - message.Clear(); - google::protobuf::TestUtilLite::ExpectClear(message); - } - - { - protobuf_unittest::TestAllExtensionsLite message, message2, message3; - google::protobuf::TestUtilLite::ExpectExtensionsClear(message); - google::protobuf::TestUtilLite::SetAllExtensions(&message); - message2.CopyFrom(message); - string extensions_data = message.SerializeAsString(); - GOOGLE_CHECK(extensions_data == data); - message3.ParseFromString(extensions_data); - google::protobuf::TestUtilLite::ExpectAllExtensionsSet(message); - google::protobuf::TestUtilLite::ExpectAllExtensionsSet(message2); - google::protobuf::TestUtilLite::ExpectAllExtensionsSet(message3); - google::protobuf::TestUtilLite::ModifyRepeatedExtensions(&message); - google::protobuf::TestUtilLite::ExpectRepeatedExtensionsModified(message); - message.Clear(); - google::protobuf::TestUtilLite::ExpectExtensionsClear(message); - } - - { - protobuf_unittest::TestPackedTypesLite message, message2, message3; - google::protobuf::TestUtilLite::ExpectPackedClear(message); - google::protobuf::TestUtilLite::SetPackedFields(&message); - message2.CopyFrom(message); - packed_data = message.SerializeAsString(); - message3.ParseFromString(packed_data); - google::protobuf::TestUtilLite::ExpectPackedFieldsSet(message); - google::protobuf::TestUtilLite::ExpectPackedFieldsSet(message2); - google::protobuf::TestUtilLite::ExpectPackedFieldsSet(message3); - google::protobuf::TestUtilLite::ModifyPackedFields(&message); - google::protobuf::TestUtilLite::ExpectPackedFieldsModified(message); - message.Clear(); - google::protobuf::TestUtilLite::ExpectPackedClear(message); - } - - { - protobuf_unittest::TestPackedExtensionsLite message, message2, message3; - google::protobuf::TestUtilLite::ExpectPackedExtensionsClear(message); - google::protobuf::TestUtilLite::SetPackedExtensions(&message); - message2.CopyFrom(message); - string packed_extensions_data = message.SerializeAsString(); - GOOGLE_CHECK(packed_extensions_data == packed_data); - message3.ParseFromString(packed_extensions_data); - google::protobuf::TestUtilLite::ExpectPackedExtensionsSet(message); - google::protobuf::TestUtilLite::ExpectPackedExtensionsSet(message2); - google::protobuf::TestUtilLite::ExpectPackedExtensionsSet(message3); - google::protobuf::TestUtilLite::ModifyPackedExtensions(&message); - google::protobuf::TestUtilLite::ExpectPackedExtensionsModified(message); - message.Clear(); - google::protobuf::TestUtilLite::ExpectPackedExtensionsClear(message); - } - - { - // Test that if an optional or required message/group field appears multiple - // times in the input, they need to be merged. - google::protobuf::unittest::TestParsingMergeLite::RepeatedFieldsGenerator generator; - google::protobuf::unittest::TestAllTypesLite* msg1; - google::protobuf::unittest::TestAllTypesLite* msg2; - google::protobuf::unittest::TestAllTypesLite* msg3; - -#define ASSIGN_REPEATED_FIELD(FIELD) \ - msg1 = generator.add_##FIELD(); \ - msg2 = generator.add_##FIELD(); \ - msg3 = generator.add_##FIELD(); \ - AssignParsingMergeMessages(msg1, msg2, msg3) - - ASSIGN_REPEATED_FIELD(field1); - ASSIGN_REPEATED_FIELD(field2); - ASSIGN_REPEATED_FIELD(field3); - ASSIGN_REPEATED_FIELD(ext1); - ASSIGN_REPEATED_FIELD(ext2); - -#undef ASSIGN_REPEATED_FIELD -#define ASSIGN_REPEATED_GROUP(FIELD) \ - msg1 = generator.add_##FIELD()->mutable_field1(); \ - msg2 = generator.add_##FIELD()->mutable_field1(); \ - msg3 = generator.add_##FIELD()->mutable_field1(); \ - AssignParsingMergeMessages(msg1, msg2, msg3) - - ASSIGN_REPEATED_GROUP(group1); - ASSIGN_REPEATED_GROUP(group2); - -#undef ASSIGN_REPEATED_GROUP - - string buffer; - generator.SerializeToString(&buffer); - google::protobuf::unittest::TestParsingMergeLite parsing_merge; - parsing_merge.ParseFromString(buffer); - - // Required and optional fields should be merged. - ExpectMessageMerged(parsing_merge.required_all_types()); - ExpectMessageMerged(parsing_merge.optional_all_types()); - ExpectMessageMerged( - parsing_merge.optionalgroup().optional_group_all_types()); - ExpectMessageMerged(parsing_merge.GetExtension( - google::protobuf::unittest::TestParsingMergeLite::optional_ext)); - - // Repeated fields should not be merged. - GOOGLE_CHECK(parsing_merge.repeated_all_types_size() == 3); - GOOGLE_CHECK(parsing_merge.repeatedgroup_size() == 3); - GOOGLE_CHECK(parsing_merge.ExtensionSize( - google::protobuf::unittest::TestParsingMergeLite::repeated_ext) == 3); - } - - cout << "PASS" << endl; - return 0; -} diff --git a/modules/dnn/3rdparty/protobuf/src/google/protobuf/message.cc b/modules/dnn/3rdparty/protobuf/src/google/protobuf/message.cc deleted file mode 100644 index ab7efa990..000000000 --- a/modules/dnn/3rdparty/protobuf/src/google/protobuf/message.cc +++ /dev/null @@ -1,358 +0,0 @@ -// Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// http://code.google.com/p/protobuf/ -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -// Author: kenton@google.com (Kenton Varda) -// Based on original Protocol Buffers design by -// Sanjay Ghemawat, Jeff Dean, and others. - -#include -#include -#include - -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -namespace google { -namespace protobuf { - -using internal::WireFormat; -using internal::ReflectionOps; - -Message::~Message() {} - -void Message::MergeFrom(const Message& from) { - const Descriptor* descriptor = GetDescriptor(); - GOOGLE_CHECK_EQ(from.GetDescriptor(), descriptor) - << ": Tried to merge from a message with a different type. " - "to: " << descriptor->full_name() << ", " - "from:" << from.GetDescriptor()->full_name(); - ReflectionOps::Merge(from, this); -} - -void Message::CheckTypeAndMergeFrom(const MessageLite& other) { - MergeFrom(*down_cast(&other)); -} - -void Message::CopyFrom(const Message& from) { - const Descriptor* descriptor = GetDescriptor(); - GOOGLE_CHECK_EQ(from.GetDescriptor(), descriptor) - << ": Tried to copy from a message with a different type." - "to: " << descriptor->full_name() << ", " - "from:" << from.GetDescriptor()->full_name(); - ReflectionOps::Copy(from, this); -} - -string Message::GetTypeName() const { - return GetDescriptor()->full_name(); -} - -void Message::Clear() { - ReflectionOps::Clear(this); -} - -bool Message::IsInitialized() const { - return ReflectionOps::IsInitialized(*this); -} - -void Message::FindInitializationErrors(vector* errors) const { - return ReflectionOps::FindInitializationErrors(*this, "", errors); -} - -string Message::InitializationErrorString() const { - vector errors; - FindInitializationErrors(&errors); - return JoinStrings(errors, ", "); -} - -void Message::CheckInitialized() const { - GOOGLE_CHECK(IsInitialized()) - << "Message of type \"" << GetDescriptor()->full_name() - << "\" is missing required fields: " << InitializationErrorString(); -} - -void Message::DiscardUnknownFields() { - return ReflectionOps::DiscardUnknownFields(this); -} - -bool Message::MergePartialFromCodedStream(io::CodedInputStream* input) { - return WireFormat::ParseAndMergePartial(input, this); -} - -bool Message::ParseFromFileDescriptor(int file_descriptor) { - io::FileInputStream input(file_descriptor); - return ParseFromZeroCopyStream(&input) && input.GetErrno() == 0; -} - -bool Message::ParsePartialFromFileDescriptor(int file_descriptor) { - io::FileInputStream input(file_descriptor); - return ParsePartialFromZeroCopyStream(&input) && input.GetErrno() == 0; -} - -bool Message::ParseFromIstream(istream* input) { - io::IstreamInputStream zero_copy_input(input); - return ParseFromZeroCopyStream(&zero_copy_input) && input->eof(); -} - -bool Message::ParsePartialFromIstream(istream* input) { - io::IstreamInputStream zero_copy_input(input); - return ParsePartialFromZeroCopyStream(&zero_copy_input) && input->eof(); -} - - -void Message::SerializeWithCachedSizes( - io::CodedOutputStream* output) const { - WireFormat::SerializeWithCachedSizes(*this, GetCachedSize(), output); -} - -int Message::ByteSize() const { - int size = WireFormat::ByteSize(*this); - SetCachedSize(size); - return size; -} - -void Message::SetCachedSize(int size) const { - GOOGLE_LOG(FATAL) << "Message class \"" << GetDescriptor()->full_name() - << "\" implements neither SetCachedSize() nor ByteSize(). " - "Must implement one or the other."; -} - -int Message::SpaceUsed() const { - return GetReflection()->SpaceUsed(*this); -} - -bool Message::SerializeToFileDescriptor(int file_descriptor) const { - io::FileOutputStream output(file_descriptor); - return SerializeToZeroCopyStream(&output); -} - -bool Message::SerializePartialToFileDescriptor(int file_descriptor) const { - io::FileOutputStream output(file_descriptor); - return SerializePartialToZeroCopyStream(&output); -} - -bool Message::SerializeToOstream(ostream* output) const { - { - io::OstreamOutputStream zero_copy_output(output); - if (!SerializeToZeroCopyStream(&zero_copy_output)) return false; - } - return output->good(); -} - -bool Message::SerializePartialToOstream(ostream* output) const { - io::OstreamOutputStream zero_copy_output(output); - return SerializePartialToZeroCopyStream(&zero_copy_output); -} - - -// ============================================================================= -// Reflection and associated Template Specializations - -Reflection::~Reflection() {} - -#define HANDLE_TYPE(TYPE, CPPTYPE, CTYPE) \ -template<> \ -const RepeatedField& Reflection::GetRepeatedField( \ - const Message& message, const FieldDescriptor* field) const { \ - return *static_cast* >( \ - MutableRawRepeatedField(const_cast(&message), \ - field, CPPTYPE, CTYPE, NULL)); \ -} \ - \ -template<> \ -RepeatedField* Reflection::MutableRepeatedField( \ - Message* message, const FieldDescriptor* field) const { \ - return static_cast* >( \ - MutableRawRepeatedField(message, field, CPPTYPE, CTYPE, NULL)); \ -} - -HANDLE_TYPE(int32, FieldDescriptor::CPPTYPE_INT32, -1); -HANDLE_TYPE(int64, FieldDescriptor::CPPTYPE_INT64, -1); -HANDLE_TYPE(uint32, FieldDescriptor::CPPTYPE_UINT32, -1); -HANDLE_TYPE(uint64, FieldDescriptor::CPPTYPE_UINT64, -1); -HANDLE_TYPE(float, FieldDescriptor::CPPTYPE_FLOAT, -1); -HANDLE_TYPE(double, FieldDescriptor::CPPTYPE_DOUBLE, -1); -HANDLE_TYPE(bool, FieldDescriptor::CPPTYPE_BOOL, -1); - - -#undef HANDLE_TYPE - -void* Reflection::MutableRawRepeatedString( - Message* message, const FieldDescriptor* field, bool is_string) const { - return MutableRawRepeatedField(message, field, - FieldDescriptor::CPPTYPE_STRING, FieldOptions::STRING, NULL); -} - - -// ============================================================================= -// MessageFactory - -MessageFactory::~MessageFactory() {} - -namespace { - -class GeneratedMessageFactory : public MessageFactory { - public: - GeneratedMessageFactory(); - ~GeneratedMessageFactory(); - - static GeneratedMessageFactory* singleton(); - - typedef void RegistrationFunc(const string&); - void RegisterFile(const char* file, RegistrationFunc* registration_func); - void RegisterType(const Descriptor* descriptor, const Message* prototype); - - // implements MessageFactory --------------------------------------- - const Message* GetPrototype(const Descriptor* type); - - private: - // Only written at static init time, so does not require locking. - hash_map, streq> file_map_; - - // Initialized lazily, so requires locking. - Mutex mutex_; - hash_map type_map_; -}; - -GeneratedMessageFactory* generated_message_factory_ = NULL; -GOOGLE_PROTOBUF_DECLARE_ONCE(generated_message_factory_once_init_); - -void ShutdownGeneratedMessageFactory() { - delete generated_message_factory_; -} - -void InitGeneratedMessageFactory() { - generated_message_factory_ = new GeneratedMessageFactory; - internal::OnShutdown(&ShutdownGeneratedMessageFactory); -} - -GeneratedMessageFactory::GeneratedMessageFactory() {} -GeneratedMessageFactory::~GeneratedMessageFactory() {} - -GeneratedMessageFactory* GeneratedMessageFactory::singleton() { - ::google::protobuf::GoogleOnceInit(&generated_message_factory_once_init_, - &InitGeneratedMessageFactory); - return generated_message_factory_; -} - -void GeneratedMessageFactory::RegisterFile( - const char* file, RegistrationFunc* registration_func) { - if (!InsertIfNotPresent(&file_map_, file, registration_func)) { - GOOGLE_LOG(FATAL) << "File is already registered: " << file; - } -} - -void GeneratedMessageFactory::RegisterType(const Descriptor* descriptor, - const Message* prototype) { - GOOGLE_DCHECK_EQ(descriptor->file()->pool(), DescriptorPool::generated_pool()) - << "Tried to register a non-generated type with the generated " - "type registry."; - - // This should only be called as a result of calling a file registration - // function during GetPrototype(), in which case we already have locked - // the mutex. - mutex_.AssertHeld(); - if (!InsertIfNotPresent(&type_map_, descriptor, prototype)) { - GOOGLE_LOG(DFATAL) << "Type is already registered: " << descriptor->full_name(); - } -} - - -const Message* GeneratedMessageFactory::GetPrototype(const Descriptor* type) { - { - ReaderMutexLock lock(&mutex_); - const Message* result = FindPtrOrNull(type_map_, type); - if (result != NULL) return result; - } - - // If the type is not in the generated pool, then we can't possibly handle - // it. - if (type->file()->pool() != DescriptorPool::generated_pool()) return NULL; - - // Apparently the file hasn't been registered yet. Let's do that now. - RegistrationFunc* registration_func = - FindPtrOrNull(file_map_, type->file()->name().c_str()); - if (registration_func == NULL) { - GOOGLE_LOG(DFATAL) << "File appears to be in generated pool but wasn't " - "registered: " << type->file()->name(); - return NULL; - } - - WriterMutexLock lock(&mutex_); - - // Check if another thread preempted us. - const Message* result = FindPtrOrNull(type_map_, type); - if (result == NULL) { - // Nope. OK, register everything. - registration_func(type->file()->name()); - // Should be here now. - result = FindPtrOrNull(type_map_, type); - } - - if (result == NULL) { - GOOGLE_LOG(DFATAL) << "Type appears to be in generated pool but wasn't " - << "registered: " << type->full_name(); - } - - return result; -} - -} // namespace - -MessageFactory* MessageFactory::generated_factory() { - return GeneratedMessageFactory::singleton(); -} - -void MessageFactory::InternalRegisterGeneratedFile( - const char* filename, void (*register_messages)(const string&)) { - GeneratedMessageFactory::singleton()->RegisterFile(filename, - register_messages); -} - -void MessageFactory::InternalRegisterGeneratedMessage( - const Descriptor* descriptor, const Message* prototype) { - GeneratedMessageFactory::singleton()->RegisterType(descriptor, prototype); -} - - -} // namespace protobuf -} // namespace google diff --git a/modules/dnn/3rdparty/protobuf/src/google/protobuf/message.h b/modules/dnn/3rdparty/protobuf/src/google/protobuf/message.h deleted file mode 100644 index 0f90bc1a1..000000000 --- a/modules/dnn/3rdparty/protobuf/src/google/protobuf/message.h +++ /dev/null @@ -1,837 +0,0 @@ -// Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// http://code.google.com/p/protobuf/ -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -// Author: kenton@google.com (Kenton Varda) -// Based on original Protocol Buffers design by -// Sanjay Ghemawat, Jeff Dean, and others. -// -// Defines Message, the abstract interface implemented by non-lite -// protocol message objects. Although it's possible to implement this -// interface manually, most users will use the protocol compiler to -// generate implementations. -// -// Example usage: -// -// Say you have a message defined as: -// -// message Foo { -// optional string text = 1; -// repeated int32 numbers = 2; -// } -// -// Then, if you used the protocol compiler to generate a class from the above -// definition, you could use it like so: -// -// string data; // Will store a serialized version of the message. -// -// { -// // Create a message and serialize it. -// Foo foo; -// foo.set_text("Hello World!"); -// foo.add_numbers(1); -// foo.add_numbers(5); -// foo.add_numbers(42); -// -// foo.SerializeToString(&data); -// } -// -// { -// // Parse the serialized message and check that it contains the -// // correct data. -// Foo foo; -// foo.ParseFromString(data); -// -// assert(foo.text() == "Hello World!"); -// assert(foo.numbers_size() == 3); -// assert(foo.numbers(0) == 1); -// assert(foo.numbers(1) == 5); -// assert(foo.numbers(2) == 42); -// } -// -// { -// // Same as the last block, but do it dynamically via the Message -// // reflection interface. -// Message* foo = new Foo; -// const Descriptor* descriptor = foo->GetDescriptor(); -// -// // Get the descriptors for the fields we're interested in and verify -// // their types. -// const FieldDescriptor* text_field = descriptor->FindFieldByName("text"); -// assert(text_field != NULL); -// assert(text_field->type() == FieldDescriptor::TYPE_STRING); -// assert(text_field->label() == FieldDescriptor::LABEL_OPTIONAL); -// const FieldDescriptor* numbers_field = descriptor-> -// FindFieldByName("numbers"); -// assert(numbers_field != NULL); -// assert(numbers_field->type() == FieldDescriptor::TYPE_INT32); -// assert(numbers_field->label() == FieldDescriptor::LABEL_REPEATED); -// -// // Parse the message. -// foo->ParseFromString(data); -// -// // Use the reflection interface to examine the contents. -// const Reflection* reflection = foo->GetReflection(); -// assert(reflection->GetString(foo, text_field) == "Hello World!"); -// assert(reflection->FieldSize(foo, numbers_field) == 3); -// assert(reflection->GetRepeatedInt32(foo, numbers_field, 0) == 1); -// assert(reflection->GetRepeatedInt32(foo, numbers_field, 1) == 5); -// assert(reflection->GetRepeatedInt32(foo, numbers_field, 2) == 42); -// -// delete foo; -// } - -#ifndef GOOGLE_PROTOBUF_MESSAGE_H__ -#define GOOGLE_PROTOBUF_MESSAGE_H__ - -#include -#include - -#ifdef __DECCXX -// HP C++'s iosfwd doesn't work. -#include -#else -#include -#endif - -#include - -#include -#include - - -namespace google { -namespace protobuf { - -// Defined in this file. -class Message; -class Reflection; -class MessageFactory; - -// Defined in other files. -class UnknownFieldSet; // unknown_field_set.h -namespace io { - class ZeroCopyInputStream; // zero_copy_stream.h - class ZeroCopyOutputStream; // zero_copy_stream.h - class CodedInputStream; // coded_stream.h - class CodedOutputStream; // coded_stream.h -} - - -template -class RepeatedField; // repeated_field.h - -template -class RepeatedPtrField; // repeated_field.h - -// A container to hold message metadata. -struct Metadata { - const Descriptor* descriptor; - const Reflection* reflection; -}; - -// Abstract interface for protocol messages. -// -// See also MessageLite, which contains most every-day operations. Message -// adds descriptors and reflection on top of that. -// -// The methods of this class that are virtual but not pure-virtual have -// default implementations based on reflection. Message classes which are -// optimized for speed will want to override these with faster implementations, -// but classes optimized for code size may be happy with keeping them. See -// the optimize_for option in descriptor.proto. -class LIBPROTOBUF_EXPORT Message : public MessageLite { - public: - inline Message() {} - virtual ~Message(); - - // Basic Operations ------------------------------------------------ - - // Construct a new instance of the same type. Ownership is passed to the - // caller. (This is also defined in MessageLite, but is defined again here - // for return-type covariance.) - virtual Message* New() const = 0; - - // Make this message into a copy of the given message. The given message - // must have the same descriptor, but need not necessarily be the same class. - // By default this is just implemented as "Clear(); MergeFrom(from);". - virtual void CopyFrom(const Message& from); - - // Merge the fields from the given message into this message. Singular - // fields will be overwritten, except for embedded messages which will - // be merged. Repeated fields will be concatenated. The given message - // must be of the same type as this message (i.e. the exact same class). - virtual void MergeFrom(const Message& from); - - // Verifies that IsInitialized() returns true. GOOGLE_CHECK-fails otherwise, with - // a nice error message. - void CheckInitialized() const; - - // Slowly build a list of all required fields that are not set. - // This is much, much slower than IsInitialized() as it is implemented - // purely via reflection. Generally, you should not call this unless you - // have already determined that an error exists by calling IsInitialized(). - void FindInitializationErrors(vector* errors) const; - - // Like FindInitializationErrors, but joins all the strings, delimited by - // commas, and returns them. - string InitializationErrorString() const; - - // Clears all unknown fields from this message and all embedded messages. - // Normally, if unknown tag numbers are encountered when parsing a message, - // the tag and value are stored in the message's UnknownFieldSet and - // then written back out when the message is serialized. This allows servers - // which simply route messages to other servers to pass through messages - // that have new field definitions which they don't yet know about. However, - // this behavior can have security implications. To avoid it, call this - // method after parsing. - // - // See Reflection::GetUnknownFields() for more on unknown fields. - virtual void DiscardUnknownFields(); - - // Computes (an estimate of) the total number of bytes currently used for - // storing the message in memory. The default implementation calls the - // Reflection object's SpaceUsed() method. - virtual int SpaceUsed() const; - - // Debugging & Testing---------------------------------------------- - - // Generates a human readable form of this message, useful for debugging - // and other purposes. - string DebugString() const; - // Like DebugString(), but with less whitespace. - string ShortDebugString() const; - // Like DebugString(), but do not escape UTF-8 byte sequences. - string Utf8DebugString() const; - // Convenience function useful in GDB. Prints DebugString() to stdout. - void PrintDebugString() const; - - // Heavy I/O ------------------------------------------------------- - // Additional parsing and serialization methods not implemented by - // MessageLite because they are not supported by the lite library. - - // Parse a protocol buffer from a file descriptor. If successful, the entire - // input will be consumed. - bool ParseFromFileDescriptor(int file_descriptor); - // Like ParseFromFileDescriptor(), but accepts messages that are missing - // required fields. - bool ParsePartialFromFileDescriptor(int file_descriptor); - // Parse a protocol buffer from a C++ istream. If successful, the entire - // input will be consumed. - bool ParseFromIstream(istream* input); - // Like ParseFromIstream(), but accepts messages that are missing - // required fields. - bool ParsePartialFromIstream(istream* input); - - // Serialize the message and write it to the given file descriptor. All - // required fields must be set. - bool SerializeToFileDescriptor(int file_descriptor) const; - // Like SerializeToFileDescriptor(), but allows missing required fields. - bool SerializePartialToFileDescriptor(int file_descriptor) const; - // Serialize the message and write it to the given C++ ostream. All - // required fields must be set. - bool SerializeToOstream(ostream* output) const; - // Like SerializeToOstream(), but allows missing required fields. - bool SerializePartialToOstream(ostream* output) const; - - - // Reflection-based methods ---------------------------------------- - // These methods are pure-virtual in MessageLite, but Message provides - // reflection-based default implementations. - - virtual string GetTypeName() const; - virtual void Clear(); - virtual bool IsInitialized() const; - virtual void CheckTypeAndMergeFrom(const MessageLite& other); - virtual bool MergePartialFromCodedStream(io::CodedInputStream* input); - virtual int ByteSize() const; - virtual void SerializeWithCachedSizes(io::CodedOutputStream* output) const; - - private: - // This is called only by the default implementation of ByteSize(), to - // update the cached size. If you override ByteSize(), you do not need - // to override this. If you do not override ByteSize(), you MUST override - // this; the default implementation will crash. - // - // The method is private because subclasses should never call it; only - // override it. Yes, C++ lets you do that. Crazy, huh? - virtual void SetCachedSize(int size) const; - - public: - - // Introspection --------------------------------------------------- - - // Typedef for backwards-compatibility. - typedef google::protobuf::Reflection Reflection; - - // Get a Descriptor for this message's type. This describes what - // fields the message contains, the types of those fields, etc. - const Descriptor* GetDescriptor() const { return GetMetadata().descriptor; } - - // Get the Reflection interface for this Message, which can be used to - // read and modify the fields of the Message dynamically (in other words, - // without knowing the message type at compile time). This object remains - // property of the Message. - // - // This method remains virtual in case a subclass does not implement - // reflection and wants to override the default behavior. - virtual const Reflection* GetReflection() const { - return GetMetadata().reflection; - } - - protected: - // Get a struct containing the metadata for the Message. Most subclasses only - // need to implement this method, rather than the GetDescriptor() and - // GetReflection() wrappers. - virtual Metadata GetMetadata() const = 0; - - - private: - GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(Message); -}; - -// This interface contains methods that can be used to dynamically access -// and modify the fields of a protocol message. Their semantics are -// similar to the accessors the protocol compiler generates. -// -// To get the Reflection for a given Message, call Message::GetReflection(). -// -// This interface is separate from Message only for efficiency reasons; -// the vast majority of implementations of Message will share the same -// implementation of Reflection (GeneratedMessageReflection, -// defined in generated_message.h), and all Messages of a particular class -// should share the same Reflection object (though you should not rely on -// the latter fact). -// -// There are several ways that these methods can be used incorrectly. For -// example, any of the following conditions will lead to undefined -// results (probably assertion failures): -// - The FieldDescriptor is not a field of this message type. -// - The method called is not appropriate for the field's type. For -// each field type in FieldDescriptor::TYPE_*, there is only one -// Get*() method, one Set*() method, and one Add*() method that is -// valid for that type. It should be obvious which (except maybe -// for TYPE_BYTES, which are represented using strings in C++). -// - A Get*() or Set*() method for singular fields is called on a repeated -// field. -// - GetRepeated*(), SetRepeated*(), or Add*() is called on a non-repeated -// field. -// - The Message object passed to any method is not of the right type for -// this Reflection object (i.e. message.GetReflection() != reflection). -// -// You might wonder why there is not any abstract representation for a field -// of arbitrary type. E.g., why isn't there just a "GetField()" method that -// returns "const Field&", where "Field" is some class with accessors like -// "GetInt32Value()". The problem is that someone would have to deal with -// allocating these Field objects. For generated message classes, having to -// allocate space for an additional object to wrap every field would at least -// double the message's memory footprint, probably worse. Allocating the -// objects on-demand, on the other hand, would be expensive and prone to -// memory leaks. So, instead we ended up with this flat interface. -// -// TODO(kenton): Create a utility class which callers can use to read and -// write fields from a Reflection without paying attention to the type. -class LIBPROTOBUF_EXPORT Reflection { - public: - inline Reflection() {} - virtual ~Reflection(); - - // Get the UnknownFieldSet for the message. This contains fields which - // were seen when the Message was parsed but were not recognized according - // to the Message's definition. - virtual const UnknownFieldSet& GetUnknownFields( - const Message& message) const = 0; - // Get a mutable pointer to the UnknownFieldSet for the message. This - // contains fields which were seen when the Message was parsed but were not - // recognized according to the Message's definition. - virtual UnknownFieldSet* MutableUnknownFields(Message* message) const = 0; - - // Estimate the amount of memory used by the message object. - virtual int SpaceUsed(const Message& message) const = 0; - - // Check if the given non-repeated field is set. - virtual bool HasField(const Message& message, - const FieldDescriptor* field) const = 0; - - // Get the number of elements of a repeated field. - virtual int FieldSize(const Message& message, - const FieldDescriptor* field) const = 0; - - // Clear the value of a field, so that HasField() returns false or - // FieldSize() returns zero. - virtual void ClearField(Message* message, - const FieldDescriptor* field) const = 0; - - // Removes the last element of a repeated field. - // We don't provide a way to remove any element other than the last - // because it invites inefficient use, such as O(n^2) filtering loops - // that should have been O(n). If you want to remove an element other - // than the last, the best way to do it is to re-arrange the elements - // (using Swap()) so that the one you want removed is at the end, then - // call RemoveLast(). - virtual void RemoveLast(Message* message, - const FieldDescriptor* field) const = 0; - // Removes the last element of a repeated message field, and returns the - // pointer to the caller. Caller takes ownership of the returned pointer. - virtual Message* ReleaseLast(Message* message, - const FieldDescriptor* field) const = 0; - - // Swap the complete contents of two messages. - virtual void Swap(Message* message1, Message* message2) const = 0; - - // Swap two elements of a repeated field. - virtual void SwapElements(Message* message, - const FieldDescriptor* field, - int index1, - int index2) const = 0; - - // List all fields of the message which are currently set. This includes - // extensions. Singular fields will only be listed if HasField(field) would - // return true and repeated fields will only be listed if FieldSize(field) - // would return non-zero. Fields (both normal fields and extension fields) - // will be listed ordered by field number. - virtual void ListFields(const Message& message, - vector* output) const = 0; - - // Singular field getters ------------------------------------------ - // These get the value of a non-repeated field. They return the default - // value for fields that aren't set. - - virtual int32 GetInt32 (const Message& message, - const FieldDescriptor* field) const = 0; - virtual int64 GetInt64 (const Message& message, - const FieldDescriptor* field) const = 0; - virtual uint32 GetUInt32(const Message& message, - const FieldDescriptor* field) const = 0; - virtual uint64 GetUInt64(const Message& message, - const FieldDescriptor* field) const = 0; - virtual float GetFloat (const Message& message, - const FieldDescriptor* field) const = 0; - virtual double GetDouble(const Message& message, - const FieldDescriptor* field) const = 0; - virtual bool GetBool (const Message& message, - const FieldDescriptor* field) const = 0; - virtual string GetString(const Message& message, - const FieldDescriptor* field) const = 0; - virtual const EnumValueDescriptor* GetEnum( - const Message& message, const FieldDescriptor* field) const = 0; - // See MutableMessage() for the meaning of the "factory" parameter. - virtual const Message& GetMessage(const Message& message, - const FieldDescriptor* field, - MessageFactory* factory = NULL) const = 0; - - // Get a string value without copying, if possible. - // - // GetString() necessarily returns a copy of the string. This can be - // inefficient when the string is already stored in a string object in the - // underlying message. GetStringReference() will return a reference to the - // underlying string in this case. Otherwise, it will copy the string into - // *scratch and return that. - // - // Note: It is perfectly reasonable and useful to write code like: - // str = reflection->GetStringReference(field, &str); - // This line would ensure that only one copy of the string is made - // regardless of the field's underlying representation. When initializing - // a newly-constructed string, though, it's just as fast and more readable - // to use code like: - // string str = reflection->GetString(field); - virtual const string& GetStringReference(const Message& message, - const FieldDescriptor* field, - string* scratch) const = 0; - - - // Singular field mutators ----------------------------------------- - // These mutate the value of a non-repeated field. - - virtual void SetInt32 (Message* message, - const FieldDescriptor* field, int32 value) const = 0; - virtual void SetInt64 (Message* message, - const FieldDescriptor* field, int64 value) const = 0; - virtual void SetUInt32(Message* message, - const FieldDescriptor* field, uint32 value) const = 0; - virtual void SetUInt64(Message* message, - const FieldDescriptor* field, uint64 value) const = 0; - virtual void SetFloat (Message* message, - const FieldDescriptor* field, float value) const = 0; - virtual void SetDouble(Message* message, - const FieldDescriptor* field, double value) const = 0; - virtual void SetBool (Message* message, - const FieldDescriptor* field, bool value) const = 0; - virtual void SetString(Message* message, - const FieldDescriptor* field, - const string& value) const = 0; - virtual void SetEnum (Message* message, - const FieldDescriptor* field, - const EnumValueDescriptor* value) const = 0; - // Get a mutable pointer to a field with a message type. If a MessageFactory - // is provided, it will be used to construct instances of the sub-message; - // otherwise, the default factory is used. If the field is an extension that - // does not live in the same pool as the containing message's descriptor (e.g. - // it lives in an overlay pool), then a MessageFactory must be provided. - // If you have no idea what that meant, then you probably don't need to worry - // about it (don't provide a MessageFactory). WARNING: If the - // FieldDescriptor is for a compiled-in extension, then - // factory->GetPrototype(field->message_type() MUST return an instance of the - // compiled-in class for this type, NOT DynamicMessage. - virtual Message* MutableMessage(Message* message, - const FieldDescriptor* field, - MessageFactory* factory = NULL) const = 0; - // Releases the message specified by 'field' and returns the pointer, - // ReleaseMessage() will return the message the message object if it exists. - // Otherwise, it may or may not return NULL. In any case, if the return value - // is non-NULL, the caller takes ownership of the pointer. - // If the field existed (HasField() is true), then the returned pointer will - // be the same as the pointer returned by MutableMessage(). - // This function has the same effect as ClearField(). - virtual Message* ReleaseMessage(Message* message, - const FieldDescriptor* field, - MessageFactory* factory = NULL) const = 0; - - - // Repeated field getters ------------------------------------------ - // These get the value of one element of a repeated field. - - virtual int32 GetRepeatedInt32 (const Message& message, - const FieldDescriptor* field, - int index) const = 0; - virtual int64 GetRepeatedInt64 (const Message& message, - const FieldDescriptor* field, - int index) const = 0; - virtual uint32 GetRepeatedUInt32(const Message& message, - const FieldDescriptor* field, - int index) const = 0; - virtual uint64 GetRepeatedUInt64(const Message& message, - const FieldDescriptor* field, - int index) const = 0; - virtual float GetRepeatedFloat (const Message& message, - const FieldDescriptor* field, - int index) const = 0; - virtual double GetRepeatedDouble(const Message& message, - const FieldDescriptor* field, - int index) const = 0; - virtual bool GetRepeatedBool (const Message& message, - const FieldDescriptor* field, - int index) const = 0; - virtual string GetRepeatedString(const Message& message, - const FieldDescriptor* field, - int index) const = 0; - virtual const EnumValueDescriptor* GetRepeatedEnum( - const Message& message, - const FieldDescriptor* field, int index) const = 0; - virtual const Message& GetRepeatedMessage( - const Message& message, - const FieldDescriptor* field, int index) const = 0; - - // See GetStringReference(), above. - virtual const string& GetRepeatedStringReference( - const Message& message, const FieldDescriptor* field, - int index, string* scratch) const = 0; - - - // Repeated field mutators ----------------------------------------- - // These mutate the value of one element of a repeated field. - - virtual void SetRepeatedInt32 (Message* message, - const FieldDescriptor* field, - int index, int32 value) const = 0; - virtual void SetRepeatedInt64 (Message* message, - const FieldDescriptor* field, - int index, int64 value) const = 0; - virtual void SetRepeatedUInt32(Message* message, - const FieldDescriptor* field, - int index, uint32 value) const = 0; - virtual void SetRepeatedUInt64(Message* message, - const FieldDescriptor* field, - int index, uint64 value) const = 0; - virtual void SetRepeatedFloat (Message* message, - const FieldDescriptor* field, - int index, float value) const = 0; - virtual void SetRepeatedDouble(Message* message, - const FieldDescriptor* field, - int index, double value) const = 0; - virtual void SetRepeatedBool (Message* message, - const FieldDescriptor* field, - int index, bool value) const = 0; - virtual void SetRepeatedString(Message* message, - const FieldDescriptor* field, - int index, const string& value) const = 0; - virtual void SetRepeatedEnum(Message* message, - const FieldDescriptor* field, int index, - const EnumValueDescriptor* value) const = 0; - // Get a mutable pointer to an element of a repeated field with a message - // type. - virtual Message* MutableRepeatedMessage( - Message* message, const FieldDescriptor* field, int index) const = 0; - - - // Repeated field adders ------------------------------------------- - // These add an element to a repeated field. - - virtual void AddInt32 (Message* message, - const FieldDescriptor* field, int32 value) const = 0; - virtual void AddInt64 (Message* message, - const FieldDescriptor* field, int64 value) const = 0; - virtual void AddUInt32(Message* message, - const FieldDescriptor* field, uint32 value) const = 0; - virtual void AddUInt64(Message* message, - const FieldDescriptor* field, uint64 value) const = 0; - virtual void AddFloat (Message* message, - const FieldDescriptor* field, float value) const = 0; - virtual void AddDouble(Message* message, - const FieldDescriptor* field, double value) const = 0; - virtual void AddBool (Message* message, - const FieldDescriptor* field, bool value) const = 0; - virtual void AddString(Message* message, - const FieldDescriptor* field, - const string& value) const = 0; - virtual void AddEnum (Message* message, - const FieldDescriptor* field, - const EnumValueDescriptor* value) const = 0; - // See MutableMessage() for comments on the "factory" parameter. - virtual Message* AddMessage(Message* message, - const FieldDescriptor* field, - MessageFactory* factory = NULL) const = 0; - - - // Repeated field accessors ------------------------------------------------- - // The methods above, e.g. GetRepeatedInt32(msg, fd, index), provide singular - // access to the data in a RepeatedField. The methods below provide aggregate - // access by exposing the RepeatedField object itself with the Message. - // Applying these templates to inappropriate types will lead to an undefined - // reference at link time (e.g. GetRepeatedField<***double>), or possibly a - // template matching error at compile time (e.g. GetRepeatedPtrField). - // - // Usage example: my_doubs = refl->GetRepeatedField(msg, fd); - - // for T = Cord and all protobuf scalar types except enums. - template - const RepeatedField& GetRepeatedField( - const Message&, const FieldDescriptor*) const; - - // for T = Cord and all protobuf scalar types except enums. - template - RepeatedField* MutableRepeatedField( - Message*, const FieldDescriptor*) const; - - // for T = string, google::protobuf::internal::StringPieceField - // google::protobuf::Message & descendants. - template - const RepeatedPtrField& GetRepeatedPtrField( - const Message&, const FieldDescriptor*) const; - - // for T = string, google::protobuf::internal::StringPieceField - // google::protobuf::Message & descendants. - template - RepeatedPtrField* MutableRepeatedPtrField( - Message*, const FieldDescriptor*) const; - - // Extensions ---------------------------------------------------------------- - - // Try to find an extension of this message type by fully-qualified field - // name. Returns NULL if no extension is known for this name or number. - virtual const FieldDescriptor* FindKnownExtensionByName( - const string& name) const = 0; - - // Try to find an extension of this message type by field number. - // Returns NULL if no extension is known for this name or number. - virtual const FieldDescriptor* FindKnownExtensionByNumber( - int number) const = 0; - - // --------------------------------------------------------------------------- - - protected: - // Obtain a pointer to a Repeated Field Structure and do some type checking: - // on field->cpp_type(), - // on field->field_option().ctype() (if ctype >= 0) - // of field->message_type() (if message_type != NULL). - // We use 1 routine rather than 4 (const vs mutable) x (scalar vs pointer). - virtual void* MutableRawRepeatedField( - Message* message, const FieldDescriptor* field, FieldDescriptor::CppType, - int ctype, const Descriptor* message_type) const = 0; - - private: - // Special version for specialized implementations of string. We can't call - // MutableRawRepeatedField directly here because we don't have access to - // FieldOptions::* which are defined in descriptor.pb.h. Including that - // file here is not possible because it would cause a circular include cycle. - void* MutableRawRepeatedString( - Message* message, const FieldDescriptor* field, bool is_string) const; - - GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(Reflection); -}; - -// Abstract interface for a factory for message objects. -class LIBPROTOBUF_EXPORT MessageFactory { - public: - inline MessageFactory() {} - virtual ~MessageFactory(); - - // Given a Descriptor, gets or constructs the default (prototype) Message - // of that type. You can then call that message's New() method to construct - // a mutable message of that type. - // - // Calling this method twice with the same Descriptor returns the same - // object. The returned object remains property of the factory. Also, any - // objects created by calling the prototype's New() method share some data - // with the prototype, so these must be destoyed before the MessageFactory - // is destroyed. - // - // The given descriptor must outlive the returned message, and hence must - // outlive the MessageFactory. - // - // Some implementations do not support all types. GetPrototype() will - // return NULL if the descriptor passed in is not supported. - // - // This method may or may not be thread-safe depending on the implementation. - // Each implementation should document its own degree thread-safety. - virtual const Message* GetPrototype(const Descriptor* type) = 0; - - // Gets a MessageFactory which supports all generated, compiled-in messages. - // In other words, for any compiled-in type FooMessage, the following is true: - // MessageFactory::generated_factory()->GetPrototype( - // FooMessage::descriptor()) == FooMessage::default_instance() - // This factory supports all types which are found in - // DescriptorPool::generated_pool(). If given a descriptor from any other - // pool, GetPrototype() will return NULL. (You can also check if a - // descriptor is for a generated message by checking if - // descriptor->file()->pool() == DescriptorPool::generated_pool().) - // - // This factory is 100% thread-safe; calling GetPrototype() does not modify - // any shared data. - // - // This factory is a singleton. The caller must not delete the object. - static MessageFactory* generated_factory(); - - // For internal use only: Registers a .proto file at static initialization - // time, to be placed in generated_factory. The first time GetPrototype() - // is called with a descriptor from this file, |register_messages| will be - // called, with the file name as the parameter. It must call - // InternalRegisterGeneratedMessage() (below) to register each message type - // in the file. This strange mechanism is necessary because descriptors are - // built lazily, so we can't register types by their descriptor until we - // know that the descriptor exists. |filename| must be a permanent string. - static void InternalRegisterGeneratedFile( - const char* filename, void (*register_messages)(const string&)); - - // For internal use only: Registers a message type. Called only by the - // functions which are registered with InternalRegisterGeneratedFile(), - // above. - static void InternalRegisterGeneratedMessage(const Descriptor* descriptor, - const Message* prototype); - - - private: - GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(MessageFactory); -}; - -#define DECLARE_GET_REPEATED_FIELD(TYPE) \ -template<> \ -LIBPROTOBUF_EXPORT \ -const RepeatedField& Reflection::GetRepeatedField( \ - const Message& message, const FieldDescriptor* field) const; \ - \ -template<> \ -LIBPROTOBUF_EXPORT \ -RepeatedField* Reflection::MutableRepeatedField( \ - Message* message, const FieldDescriptor* field) const; - -DECLARE_GET_REPEATED_FIELD(int32) -DECLARE_GET_REPEATED_FIELD(int64) -DECLARE_GET_REPEATED_FIELD(uint32) -DECLARE_GET_REPEATED_FIELD(uint64) -DECLARE_GET_REPEATED_FIELD(float) -DECLARE_GET_REPEATED_FIELD(double) -DECLARE_GET_REPEATED_FIELD(bool) - -#undef DECLARE_GET_REPEATED_FIELD - -// ============================================================================= -// Implementation details for {Get,Mutable}RawRepeatedPtrField. We provide -// specializations for , and and handle -// everything else with the default template which will match any type having -// a method with signature "static const google::protobuf::Descriptor* descriptor()". -// Such a type presumably is a descendant of google::protobuf::Message. - -template<> -inline const RepeatedPtrField& Reflection::GetRepeatedPtrField( - const Message& message, const FieldDescriptor* field) const { - return *static_cast* >( - MutableRawRepeatedString(const_cast(&message), field, true)); -} - -template<> -inline RepeatedPtrField* Reflection::MutableRepeatedPtrField( - Message* message, const FieldDescriptor* field) const { - return static_cast* >( - MutableRawRepeatedString(message, field, true)); -} - - -// ----- - -template<> -inline const RepeatedPtrField& Reflection::GetRepeatedPtrField( - const Message& message, const FieldDescriptor* field) const { - return *static_cast* >( - MutableRawRepeatedField(const_cast(&message), field, - FieldDescriptor::CPPTYPE_MESSAGE, -1, - NULL)); -} - -template<> -inline RepeatedPtrField* Reflection::MutableRepeatedPtrField( - Message* message, const FieldDescriptor* field) const { - return static_cast* >( - MutableRawRepeatedField(message, field, - FieldDescriptor::CPPTYPE_MESSAGE, -1, - NULL)); -} - -template -inline const RepeatedPtrField& Reflection::GetRepeatedPtrField( - const Message& message, const FieldDescriptor* field) const { - return *static_cast* >( - MutableRawRepeatedField(const_cast(&message), field, - FieldDescriptor::CPPTYPE_MESSAGE, -1, - PB::default_instance().GetDescriptor())); -} - -template -inline RepeatedPtrField* Reflection::MutableRepeatedPtrField( - Message* message, const FieldDescriptor* field) const { - return static_cast* >( - MutableRawRepeatedField(message, field, - FieldDescriptor::CPPTYPE_MESSAGE, -1, - PB::default_instance().GetDescriptor())); -} - -} // namespace protobuf - -} // namespace google -#endif // GOOGLE_PROTOBUF_MESSAGE_H__ diff --git a/modules/dnn/3rdparty/protobuf/src/google/protobuf/message_lite.cc b/modules/dnn/3rdparty/protobuf/src/google/protobuf/message_lite.cc deleted file mode 100644 index 49dbe6e09..000000000 --- a/modules/dnn/3rdparty/protobuf/src/google/protobuf/message_lite.cc +++ /dev/null @@ -1,334 +0,0 @@ -// Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// http://code.google.com/p/protobuf/ -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -// Authors: wink@google.com (Wink Saville), -// kenton@google.com (Kenton Varda) -// Based on original Protocol Buffers design by -// Sanjay Ghemawat, Jeff Dean, and others. - -#include -#include -#include -#include -#include -#include - -namespace google { -namespace protobuf { - -MessageLite::~MessageLite() {} - -string MessageLite::InitializationErrorString() const { - return "(cannot determine missing fields for lite message)"; -} - -namespace { - -// When serializing, we first compute the byte size, then serialize the message. -// If serialization produces a different number of bytes than expected, we -// call this function, which crashes. The problem could be due to a bug in the -// protobuf implementation but is more likely caused by concurrent modification -// of the message. This function attempts to distinguish between the two and -// provide a useful error message. -void ByteSizeConsistencyError(int byte_size_before_serialization, - int byte_size_after_serialization, - int bytes_produced_by_serialization) { - GOOGLE_CHECK_EQ(byte_size_before_serialization, byte_size_after_serialization) - << "Protocol message was modified concurrently during serialization."; - GOOGLE_CHECK_EQ(bytes_produced_by_serialization, byte_size_before_serialization) - << "Byte size calculation and serialization were inconsistent. This " - "may indicate a bug in protocol buffers or it may be caused by " - "concurrent modification of the message."; - GOOGLE_LOG(FATAL) << "This shouldn't be called if all the sizes are equal."; -} - -string InitializationErrorMessage(const char* action, - const MessageLite& message) { - // Note: We want to avoid depending on strutil in the lite library, otherwise - // we'd use: - // - // return strings::Substitute( - // "Can't $0 message of type \"$1\" because it is missing required " - // "fields: $2", - // action, message.GetTypeName(), - // message.InitializationErrorString()); - - string result; - result += "Can't "; - result += action; - result += " message of type \""; - result += message.GetTypeName(); - result += "\" because it is missing required fields: "; - result += message.InitializationErrorString(); - return result; -} - -// Several of the Parse methods below just do one thing and then call another -// method. In a naive implementation, we might have ParseFromString() call -// ParseFromArray() which would call ParseFromZeroCopyStream() which would call -// ParseFromCodedStream() which would call MergeFromCodedStream() which would -// call MergePartialFromCodedStream(). However, when parsing very small -// messages, every function call introduces significant overhead. To avoid -// this without reproducing code, we use these forced-inline helpers. -// -// Note: GCC only allows GOOGLE_ATTRIBUTE_ALWAYS_INLINE on declarations, not -// definitions. -inline bool InlineMergeFromCodedStream(io::CodedInputStream* input, - MessageLite* message) - GOOGLE_ATTRIBUTE_ALWAYS_INLINE; -inline bool InlineParseFromCodedStream(io::CodedInputStream* input, - MessageLite* message) - GOOGLE_ATTRIBUTE_ALWAYS_INLINE; -inline bool InlineParsePartialFromCodedStream(io::CodedInputStream* input, - MessageLite* message) - GOOGLE_ATTRIBUTE_ALWAYS_INLINE; -inline bool InlineParseFromArray(const void* data, int size, - MessageLite* message) - GOOGLE_ATTRIBUTE_ALWAYS_INLINE; -inline bool InlineParsePartialFromArray(const void* data, int size, - MessageLite* message) - GOOGLE_ATTRIBUTE_ALWAYS_INLINE; - -bool InlineMergeFromCodedStream(io::CodedInputStream* input, - MessageLite* message) { - if (!message->MergePartialFromCodedStream(input)) return false; - if (!message->IsInitialized()) { - GOOGLE_LOG(ERROR) << InitializationErrorMessage("parse", *message); - return false; - } - return true; -} - -bool InlineParseFromCodedStream(io::CodedInputStream* input, - MessageLite* message) { - message->Clear(); - return InlineMergeFromCodedStream(input, message); -} - -bool InlineParsePartialFromCodedStream(io::CodedInputStream* input, - MessageLite* message) { - message->Clear(); - return message->MergePartialFromCodedStream(input); -} - -bool InlineParseFromArray(const void* data, int size, MessageLite* message) { - io::CodedInputStream input(reinterpret_cast(data), size); - return InlineParseFromCodedStream(&input, message) && - input.ConsumedEntireMessage(); -} - -bool InlineParsePartialFromArray(const void* data, int size, - MessageLite* message) { - io::CodedInputStream input(reinterpret_cast(data), size); - return InlineParsePartialFromCodedStream(&input, message) && - input.ConsumedEntireMessage(); -} - -} // namespace - -bool MessageLite::MergeFromCodedStream(io::CodedInputStream* input) { - return InlineMergeFromCodedStream(input, this); -} - -bool MessageLite::ParseFromCodedStream(io::CodedInputStream* input) { - return InlineParseFromCodedStream(input, this); -} - -bool MessageLite::ParsePartialFromCodedStream(io::CodedInputStream* input) { - return InlineParsePartialFromCodedStream(input, this); -} - -bool MessageLite::ParseFromZeroCopyStream(io::ZeroCopyInputStream* input) { - io::CodedInputStream decoder(input); - return ParseFromCodedStream(&decoder) && decoder.ConsumedEntireMessage(); -} - -bool MessageLite::ParsePartialFromZeroCopyStream( - io::ZeroCopyInputStream* input) { - io::CodedInputStream decoder(input); - return ParsePartialFromCodedStream(&decoder) && - decoder.ConsumedEntireMessage(); -} - -bool MessageLite::ParseFromBoundedZeroCopyStream( - io::ZeroCopyInputStream* input, int size) { - io::CodedInputStream decoder(input); - decoder.PushLimit(size); - return ParseFromCodedStream(&decoder) && - decoder.ConsumedEntireMessage() && - decoder.BytesUntilLimit() == 0; -} - -bool MessageLite::ParsePartialFromBoundedZeroCopyStream( - io::ZeroCopyInputStream* input, int size) { - io::CodedInputStream decoder(input); - decoder.PushLimit(size); - return ParsePartialFromCodedStream(&decoder) && - decoder.ConsumedEntireMessage() && - decoder.BytesUntilLimit() == 0; -} - -bool MessageLite::ParseFromString(const string& data) { - return InlineParseFromArray(data.data(), data.size(), this); -} - -bool MessageLite::ParsePartialFromString(const string& data) { - return InlineParsePartialFromArray(data.data(), data.size(), this); -} - -bool MessageLite::ParseFromArray(const void* data, int size) { - return InlineParseFromArray(data, size, this); -} - -bool MessageLite::ParsePartialFromArray(const void* data, int size) { - return InlineParsePartialFromArray(data, size, this); -} - - -// =================================================================== - -uint8* MessageLite::SerializeWithCachedSizesToArray(uint8* target) const { - // We only optimize this when using optimize_for = SPEED. In other cases - // we just use the CodedOutputStream path. - int size = GetCachedSize(); - io::ArrayOutputStream out(target, size); - io::CodedOutputStream coded_out(&out); - SerializeWithCachedSizes(&coded_out); - GOOGLE_CHECK(!coded_out.HadError()); - return target + size; -} - -bool MessageLite::SerializeToCodedStream(io::CodedOutputStream* output) const { - GOOGLE_DCHECK(IsInitialized()) << InitializationErrorMessage("serialize", *this); - return SerializePartialToCodedStream(output); -} - -bool MessageLite::SerializePartialToCodedStream( - io::CodedOutputStream* output) const { - const int size = ByteSize(); // Force size to be cached. - uint8* buffer = output->GetDirectBufferForNBytesAndAdvance(size); - if (buffer != NULL) { - uint8* end = SerializeWithCachedSizesToArray(buffer); - if (end - buffer != size) { - ByteSizeConsistencyError(size, ByteSize(), end - buffer); - } - return true; - } else { - int original_byte_count = output->ByteCount(); - SerializeWithCachedSizes(output); - if (output->HadError()) { - return false; - } - int final_byte_count = output->ByteCount(); - - if (final_byte_count - original_byte_count != size) { - ByteSizeConsistencyError(size, ByteSize(), - final_byte_count - original_byte_count); - } - - return true; - } -} - -bool MessageLite::SerializeToZeroCopyStream( - io::ZeroCopyOutputStream* output) const { - io::CodedOutputStream encoder(output); - return SerializeToCodedStream(&encoder); -} - -bool MessageLite::SerializePartialToZeroCopyStream( - io::ZeroCopyOutputStream* output) const { - io::CodedOutputStream encoder(output); - return SerializePartialToCodedStream(&encoder); -} - -bool MessageLite::AppendToString(string* output) const { - GOOGLE_DCHECK(IsInitialized()) << InitializationErrorMessage("serialize", *this); - return AppendPartialToString(output); -} - -bool MessageLite::AppendPartialToString(string* output) const { - int old_size = output->size(); - int byte_size = ByteSize(); - STLStringResizeUninitialized(output, old_size + byte_size); - uint8* start = reinterpret_cast(string_as_array(output) + old_size); - uint8* end = SerializeWithCachedSizesToArray(start); - if (end - start != byte_size) { - ByteSizeConsistencyError(byte_size, ByteSize(), end - start); - } - return true; -} - -bool MessageLite::SerializeToString(string* output) const { - output->clear(); - return AppendToString(output); -} - -bool MessageLite::SerializePartialToString(string* output) const { - output->clear(); - return AppendPartialToString(output); -} - -bool MessageLite::SerializeToArray(void* data, int size) const { - GOOGLE_DCHECK(IsInitialized()) << InitializationErrorMessage("serialize", *this); - return SerializePartialToArray(data, size); -} - -bool MessageLite::SerializePartialToArray(void* data, int size) const { - int byte_size = ByteSize(); - if (size < byte_size) return false; - uint8* start = reinterpret_cast(data); - uint8* end = SerializeWithCachedSizesToArray(start); - if (end - start != byte_size) { - ByteSizeConsistencyError(byte_size, ByteSize(), end - start); - } - return true; -} - -string MessageLite::SerializeAsString() const { - // If the compiler implements the (Named) Return Value Optimization, - // the local variable 'result' will not actually reside on the stack - // of this function, but will be overlaid with the object that the - // caller supplied for the return value to be constructed in. - string output; - if (!AppendToString(&output)) - output.clear(); - return output; -} - -string MessageLite::SerializePartialAsString() const { - string output; - if (!AppendPartialToString(&output)) - output.clear(); - return output; -} - -} // namespace protobuf -} // namespace google diff --git a/modules/dnn/3rdparty/protobuf/src/google/protobuf/message_lite.h b/modules/dnn/3rdparty/protobuf/src/google/protobuf/message_lite.h deleted file mode 100644 index 1ec3068cf..000000000 --- a/modules/dnn/3rdparty/protobuf/src/google/protobuf/message_lite.h +++ /dev/null @@ -1,246 +0,0 @@ -// Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// http://code.google.com/p/protobuf/ -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -// Authors: wink@google.com (Wink Saville), -// kenton@google.com (Kenton Varda) -// Based on original Protocol Buffers design by -// Sanjay Ghemawat, Jeff Dean, and others. -// -// Defines MessageLite, the abstract interface implemented by all (lite -// and non-lite) protocol message objects. - -#ifndef GOOGLE_PROTOBUF_MESSAGE_LITE_H__ -#define GOOGLE_PROTOBUF_MESSAGE_LITE_H__ - -#include - -namespace google { -namespace protobuf { - -namespace io { - class CodedInputStream; - class CodedOutputStream; - class ZeroCopyInputStream; - class ZeroCopyOutputStream; -} - -// Interface to light weight protocol messages. -// -// This interface is implemented by all protocol message objects. Non-lite -// messages additionally implement the Message interface, which is a -// subclass of MessageLite. Use MessageLite instead when you only need -// the subset of features which it supports -- namely, nothing that uses -// descriptors or reflection. You can instruct the protocol compiler -// to generate classes which implement only MessageLite, not the full -// Message interface, by adding the following line to the .proto file: -// -// option optimize_for = LITE_RUNTIME; -// -// This is particularly useful on resource-constrained systems where -// the full protocol buffers runtime library is too big. -// -// Note that on non-constrained systems (e.g. servers) when you need -// to link in lots of protocol definitions, a better way to reduce -// total code footprint is to use optimize_for = CODE_SIZE. This -// will make the generated code smaller while still supporting all the -// same features (at the expense of speed). optimize_for = LITE_RUNTIME -// is best when you only have a small number of message types linked -// into your binary, in which case the size of the protocol buffers -// runtime itself is the biggest problem. -class LIBPROTOBUF_EXPORT MessageLite { - public: - inline MessageLite() {} - virtual ~MessageLite(); - - // Basic Operations ------------------------------------------------ - - // Get the name of this message type, e.g. "foo.bar.BazProto". - virtual string GetTypeName() const = 0; - - // Construct a new instance of the same type. Ownership is passed to the - // caller. - virtual MessageLite* New() const = 0; - - // Clear all fields of the message and set them to their default values. - // Clear() avoids freeing memory, assuming that any memory allocated - // to hold parts of the message will be needed again to hold the next - // message. If you actually want to free the memory used by a Message, - // you must delete it. - virtual void Clear() = 0; - - // Quickly check if all required fields have values set. - virtual bool IsInitialized() const = 0; - - // This is not implemented for Lite messages -- it just returns "(cannot - // determine missing fields for lite message)". However, it is implemented - // for full messages. See message.h. - virtual string InitializationErrorString() const; - - // If |other| is the exact same class as this, calls MergeFrom(). Otherwise, - // results are undefined (probably crash). - virtual void CheckTypeAndMergeFrom(const MessageLite& other) = 0; - - // Parsing --------------------------------------------------------- - // Methods for parsing in protocol buffer format. Most of these are - // just simple wrappers around MergeFromCodedStream(). - - // Fill the message with a protocol buffer parsed from the given input - // stream. Returns false on a read error or if the input is in the - // wrong format. - bool ParseFromCodedStream(io::CodedInputStream* input); - // Like ParseFromCodedStream(), but accepts messages that are missing - // required fields. - bool ParsePartialFromCodedStream(io::CodedInputStream* input); - // Read a protocol buffer from the given zero-copy input stream. If - // successful, the entire input will be consumed. - bool ParseFromZeroCopyStream(io::ZeroCopyInputStream* input); - // Like ParseFromZeroCopyStream(), but accepts messages that are missing - // required fields. - bool ParsePartialFromZeroCopyStream(io::ZeroCopyInputStream* input); - // Read a protocol buffer from the given zero-copy input stream, expecting - // the message to be exactly "size" bytes long. If successful, exactly - // this many bytes will have been consumed from the input. - bool ParseFromBoundedZeroCopyStream(io::ZeroCopyInputStream* input, int size); - // Like ParseFromBoundedZeroCopyStream(), but accepts messages that are - // missing required fields. - bool ParsePartialFromBoundedZeroCopyStream(io::ZeroCopyInputStream* input, - int size); - // Parse a protocol buffer contained in a string. - bool ParseFromString(const string& data); - // Like ParseFromString(), but accepts messages that are missing - // required fields. - bool ParsePartialFromString(const string& data); - // Parse a protocol buffer contained in an array of bytes. - bool ParseFromArray(const void* data, int size); - // Like ParseFromArray(), but accepts messages that are missing - // required fields. - bool ParsePartialFromArray(const void* data, int size); - - - // Reads a protocol buffer from the stream and merges it into this - // Message. Singular fields read from the input overwrite what is - // already in the Message and repeated fields are appended to those - // already present. - // - // It is the responsibility of the caller to call input->LastTagWas() - // (for groups) or input->ConsumedEntireMessage() (for non-groups) after - // this returns to verify that the message's end was delimited correctly. - // - // ParsefromCodedStream() is implemented as Clear() followed by - // MergeFromCodedStream(). - bool MergeFromCodedStream(io::CodedInputStream* input); - - // Like MergeFromCodedStream(), but succeeds even if required fields are - // missing in the input. - // - // MergeFromCodedStream() is just implemented as MergePartialFromCodedStream() - // followed by IsInitialized(). - virtual bool MergePartialFromCodedStream(io::CodedInputStream* input) = 0; - - - // Serialization --------------------------------------------------- - // Methods for serializing in protocol buffer format. Most of these - // are just simple wrappers around ByteSize() and SerializeWithCachedSizes(). - - // Write a protocol buffer of this message to the given output. Returns - // false on a write error. If the message is missing required fields, - // this may GOOGLE_CHECK-fail. - bool SerializeToCodedStream(io::CodedOutputStream* output) const; - // Like SerializeToCodedStream(), but allows missing required fields. - bool SerializePartialToCodedStream(io::CodedOutputStream* output) const; - // Write the message to the given zero-copy output stream. All required - // fields must be set. - bool SerializeToZeroCopyStream(io::ZeroCopyOutputStream* output) const; - // Like SerializeToZeroCopyStream(), but allows missing required fields. - bool SerializePartialToZeroCopyStream(io::ZeroCopyOutputStream* output) const; - // Serialize the message and store it in the given string. All required - // fields must be set. - bool SerializeToString(string* output) const; - // Like SerializeToString(), but allows missing required fields. - bool SerializePartialToString(string* output) const; - // Serialize the message and store it in the given byte array. All required - // fields must be set. - bool SerializeToArray(void* data, int size) const; - // Like SerializeToArray(), but allows missing required fields. - bool SerializePartialToArray(void* data, int size) const; - - // Make a string encoding the message. Is equivalent to calling - // SerializeToString() on a string and using that. Returns the empty - // string if SerializeToString() would have returned an error. - // Note: If you intend to generate many such strings, you may - // reduce heap fragmentation by instead re-using the same string - // object with calls to SerializeToString(). - string SerializeAsString() const; - // Like SerializeAsString(), but allows missing required fields. - string SerializePartialAsString() const; - - // Like SerializeToString(), but appends to the data to the string's existing - // contents. All required fields must be set. - bool AppendToString(string* output) const; - // Like AppendToString(), but allows missing required fields. - bool AppendPartialToString(string* output) const; - - // Computes the serialized size of the message. This recursively calls - // ByteSize() on all embedded messages. If a subclass does not override - // this, it MUST override SetCachedSize(). - virtual int ByteSize() const = 0; - - // Serializes the message without recomputing the size. The message must - // not have changed since the last call to ByteSize(); if it has, the results - // are undefined. - virtual void SerializeWithCachedSizes( - io::CodedOutputStream* output) const = 0; - - // Like SerializeWithCachedSizes, but writes directly to *target, returning - // a pointer to the byte immediately after the last byte written. "target" - // must point at a byte array of at least ByteSize() bytes. - virtual uint8* SerializeWithCachedSizesToArray(uint8* target) const; - - // Returns the result of the last call to ByteSize(). An embedded message's - // size is needed both to serialize it (because embedded messages are - // length-delimited) and to compute the outer message's size. Caching - // the size avoids computing it multiple times. - // - // ByteSize() does not automatically use the cached size when available - // because this would require invalidating it every time the message was - // modified, which would be too hard and expensive. (E.g. if a deeply-nested - // sub-message is changed, all of its parents' cached sizes would need to be - // invalidated, which is too much work for an otherwise inlined setter - // method.) - virtual int GetCachedSize() const = 0; - - private: - GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(MessageLite); -}; - -} // namespace protobuf - -} // namespace google -#endif // GOOGLE_PROTOBUF_MESSAGE_LITE_H__ diff --git a/modules/dnn/3rdparty/protobuf/src/google/protobuf/message_unittest.cc b/modules/dnn/3rdparty/protobuf/src/google/protobuf/message_unittest.cc deleted file mode 100644 index a1449c76f..000000000 --- a/modules/dnn/3rdparty/protobuf/src/google/protobuf/message_unittest.cc +++ /dev/null @@ -1,354 +0,0 @@ -// Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// http://code.google.com/p/protobuf/ -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -// Author: kenton@google.com (Kenton Varda) -// Based on original Protocol Buffers design by -// Sanjay Ghemawat, Jeff Dean, and others. - -#include - -#include -#include -#include -#ifdef _MSC_VER -#include -#else -#include -#endif -#include -#include - -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -namespace google { -namespace protobuf { - -#ifndef O_BINARY -#ifdef _O_BINARY -#define O_BINARY _O_BINARY -#else -#define O_BINARY 0 // If this isn't defined, the platform doesn't need it. -#endif -#endif - -TEST(MessageTest, SerializeHelpers) { - // TODO(kenton): Test more helpers? They're all two-liners so it seems - // like a waste of time. - - protobuf_unittest::TestAllTypes message; - TestUtil::SetAllFields(&message); - stringstream stream; - - string str1("foo"); - string str2("bar"); - - EXPECT_TRUE(message.SerializeToString(&str1)); - EXPECT_TRUE(message.AppendToString(&str2)); - EXPECT_TRUE(message.SerializeToOstream(&stream)); - - EXPECT_EQ(str1.size() + 3, str2.size()); - EXPECT_EQ("bar", str2.substr(0, 3)); - // Don't use EXPECT_EQ because we don't want to dump raw binary data to - // stdout. - EXPECT_TRUE(str2.substr(3) == str1); - - // GCC gives some sort of error if we try to just do stream.str() == str1. - string temp = stream.str(); - EXPECT_TRUE(temp == str1); - - EXPECT_TRUE(message.SerializeAsString() == str1); - -} - -TEST(MessageTest, SerializeToBrokenOstream) { - ofstream out; - protobuf_unittest::TestAllTypes message; - message.set_optional_int32(123); - - EXPECT_FALSE(message.SerializeToOstream(&out)); -} - -TEST(MessageTest, ParseFromFileDescriptor) { - string filename = TestSourceDir() + - "/google/protobuf/testdata/golden_message"; - int file = open(filename.c_str(), O_RDONLY | O_BINARY); - - unittest::TestAllTypes message; - EXPECT_TRUE(message.ParseFromFileDescriptor(file)); - TestUtil::ExpectAllFieldsSet(message); - - EXPECT_GE(close(file), 0); -} - -TEST(MessageTest, ParsePackedFromFileDescriptor) { - string filename = - TestSourceDir() + - "/google/protobuf/testdata/golden_packed_fields_message"; - int file = open(filename.c_str(), O_RDONLY | O_BINARY); - - unittest::TestPackedTypes message; - EXPECT_TRUE(message.ParseFromFileDescriptor(file)); - TestUtil::ExpectPackedFieldsSet(message); - - EXPECT_GE(close(file), 0); -} - -TEST(MessageTest, ParseHelpers) { - // TODO(kenton): Test more helpers? They're all two-liners so it seems - // like a waste of time. - string data; - - { - // Set up. - protobuf_unittest::TestAllTypes message; - TestUtil::SetAllFields(&message); - message.SerializeToString(&data); - } - - { - // Test ParseFromString. - protobuf_unittest::TestAllTypes message; - EXPECT_TRUE(message.ParseFromString(data)); - TestUtil::ExpectAllFieldsSet(message); - } - - { - // Test ParseFromIstream. - protobuf_unittest::TestAllTypes message; - stringstream stream(data); - EXPECT_TRUE(message.ParseFromIstream(&stream)); - EXPECT_TRUE(stream.eof()); - TestUtil::ExpectAllFieldsSet(message); - } - - { - // Test ParseFromBoundedZeroCopyStream. - string data_with_junk(data); - data_with_junk.append("some junk on the end"); - io::ArrayInputStream stream(data_with_junk.data(), data_with_junk.size()); - protobuf_unittest::TestAllTypes message; - EXPECT_TRUE(message.ParseFromBoundedZeroCopyStream(&stream, data.size())); - TestUtil::ExpectAllFieldsSet(message); - } - - { - // Test that ParseFromBoundedZeroCopyStream fails (but doesn't crash) if - // EOF is reached before the expected number of bytes. - io::ArrayInputStream stream(data.data(), data.size()); - protobuf_unittest::TestAllTypes message; - EXPECT_FALSE( - message.ParseFromBoundedZeroCopyStream(&stream, data.size() + 1)); - } -} - -TEST(MessageTest, ParseFailsIfNotInitialized) { - unittest::TestRequired message; - vector errors; - - { - ScopedMemoryLog log; - EXPECT_FALSE(message.ParseFromString("")); - errors = log.GetMessages(ERROR); - } - - ASSERT_EQ(1, errors.size()); - EXPECT_EQ("Can't parse message of type \"protobuf_unittest.TestRequired\" " - "because it is missing required fields: a, b, c", - errors[0]); -} - -TEST(MessageTest, BypassInitializationCheckOnParse) { - unittest::TestRequired message; - io::ArrayInputStream raw_input(NULL, 0); - io::CodedInputStream input(&raw_input); - EXPECT_TRUE(message.MergePartialFromCodedStream(&input)); -} - -TEST(MessageTest, InitializationErrorString) { - unittest::TestRequired message; - EXPECT_EQ("a, b, c", message.InitializationErrorString()); -} - -#ifdef PROTOBUF_HAS_DEATH_TEST - -TEST(MessageTest, SerializeFailsIfNotInitialized) { - unittest::TestRequired message; - string data; - EXPECT_DEBUG_DEATH(EXPECT_TRUE(message.SerializeToString(&data)), - "Can't serialize message of type \"protobuf_unittest.TestRequired\" because " - "it is missing required fields: a, b, c"); -} - -TEST(MessageTest, CheckInitialized) { - unittest::TestRequired message; - EXPECT_DEATH(message.CheckInitialized(), - "Message of type \"protobuf_unittest.TestRequired\" is missing required " - "fields: a, b, c"); -} - -#endif // PROTOBUF_HAS_DEATH_TEST - -TEST(MessageTest, BypassInitializationCheckOnSerialize) { - unittest::TestRequired message; - io::ArrayOutputStream raw_output(NULL, 0); - io::CodedOutputStream output(&raw_output); - EXPECT_TRUE(message.SerializePartialToCodedStream(&output)); -} - -TEST(MessageTest, FindInitializationErrors) { - unittest::TestRequired message; - vector errors; - message.FindInitializationErrors(&errors); - ASSERT_EQ(3, errors.size()); - EXPECT_EQ("a", errors[0]); - EXPECT_EQ("b", errors[1]); - EXPECT_EQ("c", errors[2]); -} - -TEST(MessageTest, ParseFailsOnInvalidMessageEnd) { - unittest::TestAllTypes message; - - // Control case. - EXPECT_TRUE(message.ParseFromArray("", 0)); - - // The byte is a valid varint, but not a valid tag (zero). - EXPECT_FALSE(message.ParseFromArray("\0", 1)); - - // The byte is a malformed varint. - EXPECT_FALSE(message.ParseFromArray("\200", 1)); - - // The byte is an endgroup tag, but we aren't parsing a group. - EXPECT_FALSE(message.ParseFromArray("\014", 1)); -} - -namespace { - -void ExpectMessageMerged(const unittest::TestAllTypes& message) { - EXPECT_EQ(3, message.optional_int32()); - EXPECT_EQ(2, message.optional_int64()); - EXPECT_EQ("hello", message.optional_string()); -} - -void AssignParsingMergeMessages( - unittest::TestAllTypes* msg1, - unittest::TestAllTypes* msg2, - unittest::TestAllTypes* msg3) { - msg1->set_optional_int32(1); - msg2->set_optional_int64(2); - msg3->set_optional_int32(3); - msg3->set_optional_string("hello"); -} - -} // namespace - -// Test that if an optional or required message/group field appears multiple -// times in the input, they need to be merged. -TEST(MessageTest, ParsingMerge) { - unittest::TestParsingMerge::RepeatedFieldsGenerator generator; - unittest::TestAllTypes* msg1; - unittest::TestAllTypes* msg2; - unittest::TestAllTypes* msg3; - -#define ASSIGN_REPEATED_FIELD(FIELD) \ - msg1 = generator.add_##FIELD(); \ - msg2 = generator.add_##FIELD(); \ - msg3 = generator.add_##FIELD(); \ - AssignParsingMergeMessages(msg1, msg2, msg3) - - ASSIGN_REPEATED_FIELD(field1); - ASSIGN_REPEATED_FIELD(field2); - ASSIGN_REPEATED_FIELD(field3); - ASSIGN_REPEATED_FIELD(ext1); - ASSIGN_REPEATED_FIELD(ext2); - -#undef ASSIGN_REPEATED_FIELD -#define ASSIGN_REPEATED_GROUP(FIELD) \ - msg1 = generator.add_##FIELD()->mutable_field1(); \ - msg2 = generator.add_##FIELD()->mutable_field1(); \ - msg3 = generator.add_##FIELD()->mutable_field1(); \ - AssignParsingMergeMessages(msg1, msg2, msg3) - - ASSIGN_REPEATED_GROUP(group1); - ASSIGN_REPEATED_GROUP(group2); - -#undef ASSIGN_REPEATED_GROUP - - string buffer; - generator.SerializeToString(&buffer); - unittest::TestParsingMerge parsing_merge; - parsing_merge.ParseFromString(buffer); - - // Required and optional fields should be merged. - ExpectMessageMerged(parsing_merge.required_all_types()); - ExpectMessageMerged(parsing_merge.optional_all_types()); - ExpectMessageMerged( - parsing_merge.optionalgroup().optional_group_all_types()); - ExpectMessageMerged( - parsing_merge.GetExtension(unittest::TestParsingMerge::optional_ext)); - - // Repeated fields should not be merged. - EXPECT_EQ(3, parsing_merge.repeated_all_types_size()); - EXPECT_EQ(3, parsing_merge.repeatedgroup_size()); - EXPECT_EQ(3, parsing_merge.ExtensionSize( - unittest::TestParsingMerge::repeated_ext)); -} - -TEST(MessageFactoryTest, GeneratedFactoryLookup) { - EXPECT_EQ( - MessageFactory::generated_factory()->GetPrototype( - protobuf_unittest::TestAllTypes::descriptor()), - &protobuf_unittest::TestAllTypes::default_instance()); -} - -TEST(MessageFactoryTest, GeneratedFactoryUnknownType) { - // Construct a new descriptor. - DescriptorPool pool; - FileDescriptorProto file; - file.set_name("foo.proto"); - file.add_message_type()->set_name("Foo"); - const Descriptor* descriptor = pool.BuildFile(file)->message_type(0); - - // Trying to construct it should return NULL. - EXPECT_TRUE( - MessageFactory::generated_factory()->GetPrototype(descriptor) == NULL); -} - - -} // namespace protobuf -} // namespace google diff --git a/modules/dnn/3rdparty/protobuf/src/google/protobuf/package_info.h b/modules/dnn/3rdparty/protobuf/src/google/protobuf/package_info.h deleted file mode 100644 index 60cd3994c..000000000 --- a/modules/dnn/3rdparty/protobuf/src/google/protobuf/package_info.h +++ /dev/null @@ -1,64 +0,0 @@ -// Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// http://code.google.com/p/protobuf/ -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -// Author: kenton@google.com (Kenton Varda) -// Based on original Protocol Buffers design by -// Sanjay Ghemawat, Jeff Dean, and others. -// -// This file exists solely to document the google::protobuf namespace. -// It is not compiled into anything, but it may be read by an automated -// documentation generator. - -namespace google { - -// Core components of the Protocol Buffers runtime library. -// -// The files in this package represent the core of the Protocol Buffer -// system. All of them are part of the libprotobuf library. -// -// A note on thread-safety: -// -// Thread-safety in the Protocol Buffer library follows a simple rule: -// unless explicitly noted otherwise, it is always safe to use an object -// from multiple threads simultaneously as long as the object is declared -// const in all threads (or, it is only used in ways that would be allowed -// if it were declared const). However, if an object is accessed in one -// thread in a way that would not be allowed if it were const, then it is -// not safe to access that object in any other thread simultaneously. -// -// Put simply, read-only access to an object can happen in multiple threads -// simultaneously, but write access can only happen in a single thread at -// a time. -// -// The implementation does contain some "const" methods which actually modify -// the object behind the scenes -- e.g., to cache results -- but in these cases -// mutex locking is used to make the access thread-safe. -namespace protobuf {} -} // namespace google diff --git a/modules/dnn/3rdparty/protobuf/src/google/protobuf/reflection_ops.cc b/modules/dnn/3rdparty/protobuf/src/google/protobuf/reflection_ops.cc deleted file mode 100644 index f00997c69..000000000 --- a/modules/dnn/3rdparty/protobuf/src/google/protobuf/reflection_ops.cc +++ /dev/null @@ -1,267 +0,0 @@ -// Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// http://code.google.com/p/protobuf/ -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -// Author: kenton@google.com (Kenton Varda) -// Based on original Protocol Buffers design by -// Sanjay Ghemawat, Jeff Dean, and others. - -#include -#include - -#include -#include -#include -#include -#include - -namespace google { -namespace protobuf { -namespace internal { - -void ReflectionOps::Copy(const Message& from, Message* to) { - if (&from == to) return; - Clear(to); - Merge(from, to); -} - -void ReflectionOps::Merge(const Message& from, Message* to) { - GOOGLE_CHECK_NE(&from, to); - - const Descriptor* descriptor = from.GetDescriptor(); - GOOGLE_CHECK_EQ(to->GetDescriptor(), descriptor) - << "Tried to merge messages of different types."; - - const Reflection* from_reflection = from.GetReflection(); - const Reflection* to_reflection = to->GetReflection(); - - vector fields; - from_reflection->ListFields(from, &fields); - for (int i = 0; i < fields.size(); i++) { - const FieldDescriptor* field = fields[i]; - - if (field->is_repeated()) { - int count = from_reflection->FieldSize(from, field); - for (int j = 0; j < count; j++) { - switch (field->cpp_type()) { -#define HANDLE_TYPE(CPPTYPE, METHOD) \ - case FieldDescriptor::CPPTYPE_##CPPTYPE: \ - to_reflection->Add##METHOD(to, field, \ - from_reflection->GetRepeated##METHOD(from, field, j)); \ - break; - - HANDLE_TYPE(INT32 , Int32 ); - HANDLE_TYPE(INT64 , Int64 ); - HANDLE_TYPE(UINT32, UInt32); - HANDLE_TYPE(UINT64, UInt64); - HANDLE_TYPE(FLOAT , Float ); - HANDLE_TYPE(DOUBLE, Double); - HANDLE_TYPE(BOOL , Bool ); - HANDLE_TYPE(STRING, String); - HANDLE_TYPE(ENUM , Enum ); -#undef HANDLE_TYPE - - case FieldDescriptor::CPPTYPE_MESSAGE: - to_reflection->AddMessage(to, field)->MergeFrom( - from_reflection->GetRepeatedMessage(from, field, j)); - break; - } - } - } else { - switch (field->cpp_type()) { -#define HANDLE_TYPE(CPPTYPE, METHOD) \ - case FieldDescriptor::CPPTYPE_##CPPTYPE: \ - to_reflection->Set##METHOD(to, field, \ - from_reflection->Get##METHOD(from, field)); \ - break; - - HANDLE_TYPE(INT32 , Int32 ); - HANDLE_TYPE(INT64 , Int64 ); - HANDLE_TYPE(UINT32, UInt32); - HANDLE_TYPE(UINT64, UInt64); - HANDLE_TYPE(FLOAT , Float ); - HANDLE_TYPE(DOUBLE, Double); - HANDLE_TYPE(BOOL , Bool ); - HANDLE_TYPE(STRING, String); - HANDLE_TYPE(ENUM , Enum ); -#undef HANDLE_TYPE - - case FieldDescriptor::CPPTYPE_MESSAGE: - to_reflection->MutableMessage(to, field)->MergeFrom( - from_reflection->GetMessage(from, field)); - break; - } - } - } - - to_reflection->MutableUnknownFields(to)->MergeFrom( - from_reflection->GetUnknownFields(from)); -} - -void ReflectionOps::Clear(Message* message) { - const Reflection* reflection = message->GetReflection(); - - vector fields; - reflection->ListFields(*message, &fields); - for (int i = 0; i < fields.size(); i++) { - reflection->ClearField(message, fields[i]); - } - - reflection->MutableUnknownFields(message)->Clear(); -} - -bool ReflectionOps::IsInitialized(const Message& message) { - const Descriptor* descriptor = message.GetDescriptor(); - const Reflection* reflection = message.GetReflection(); - - // Check required fields of this message. - for (int i = 0; i < descriptor->field_count(); i++) { - if (descriptor->field(i)->is_required()) { - if (!reflection->HasField(message, descriptor->field(i))) { - return false; - } - } - } - - // Check that sub-messages are initialized. - vector fields; - reflection->ListFields(message, &fields); - for (int i = 0; i < fields.size(); i++) { - const FieldDescriptor* field = fields[i]; - if (field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE) { - - if (field->is_repeated()) { - int size = reflection->FieldSize(message, field); - - for (int j = 0; j < size; j++) { - if (!reflection->GetRepeatedMessage(message, field, j) - .IsInitialized()) { - return false; - } - } - } else { - if (!reflection->GetMessage(message, field).IsInitialized()) { - return false; - } - } - } - } - - return true; -} - -void ReflectionOps::DiscardUnknownFields(Message* message) { - const Reflection* reflection = message->GetReflection(); - - reflection->MutableUnknownFields(message)->Clear(); - - vector fields; - reflection->ListFields(*message, &fields); - for (int i = 0; i < fields.size(); i++) { - const FieldDescriptor* field = fields[i]; - if (field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE) { - if (field->is_repeated()) { - int size = reflection->FieldSize(*message, field); - for (int j = 0; j < size; j++) { - reflection->MutableRepeatedMessage(message, field, j) - ->DiscardUnknownFields(); - } - } else { - reflection->MutableMessage(message, field)->DiscardUnknownFields(); - } - } - } -} - -static string SubMessagePrefix(const string& prefix, - const FieldDescriptor* field, - int index) { - string result(prefix); - if (field->is_extension()) { - result.append("("); - result.append(field->full_name()); - result.append(")"); - } else { - result.append(field->name()); - } - if (index != -1) { - result.append("["); - result.append(SimpleItoa(index)); - result.append("]"); - } - result.append("."); - return result; -} - -void ReflectionOps::FindInitializationErrors( - const Message& message, - const string& prefix, - vector* errors) { - const Descriptor* descriptor = message.GetDescriptor(); - const Reflection* reflection = message.GetReflection(); - - // Check required fields of this message. - for (int i = 0; i < descriptor->field_count(); i++) { - if (descriptor->field(i)->is_required()) { - if (!reflection->HasField(message, descriptor->field(i))) { - errors->push_back(prefix + descriptor->field(i)->name()); - } - } - } - - // Check sub-messages. - vector fields; - reflection->ListFields(message, &fields); - for (int i = 0; i < fields.size(); i++) { - const FieldDescriptor* field = fields[i]; - if (field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE) { - - if (field->is_repeated()) { - int size = reflection->FieldSize(message, field); - - for (int j = 0; j < size; j++) { - const Message& sub_message = - reflection->GetRepeatedMessage(message, field, j); - FindInitializationErrors(sub_message, - SubMessagePrefix(prefix, field, j), - errors); - } - } else { - const Message& sub_message = reflection->GetMessage(message, field); - FindInitializationErrors(sub_message, - SubMessagePrefix(prefix, field, -1), - errors); - } - } - } -} - -} // namespace internal -} // namespace protobuf -} // namespace google diff --git a/modules/dnn/3rdparty/protobuf/src/google/protobuf/reflection_ops.h b/modules/dnn/3rdparty/protobuf/src/google/protobuf/reflection_ops.h deleted file mode 100644 index 60165c2a6..000000000 --- a/modules/dnn/3rdparty/protobuf/src/google/protobuf/reflection_ops.h +++ /dev/null @@ -1,81 +0,0 @@ -// Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// http://code.google.com/p/protobuf/ -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -// Author: kenton@google.com (Kenton Varda) -// Based on original Protocol Buffers design by -// Sanjay Ghemawat, Jeff Dean, and others. -// -// This header is logically internal, but is made public because it is used -// from protocol-compiler-generated code, which may reside in other components. - -#ifndef GOOGLE_PROTOBUF_REFLECTION_OPS_H__ -#define GOOGLE_PROTOBUF_REFLECTION_OPS_H__ - -#include -#include - -namespace google { -namespace protobuf { -namespace internal { - -// Basic operations that can be performed using reflection. -// These can be used as a cheap way to implement the corresponding -// methods of the Message interface, though they are likely to be -// slower than implementations tailored for the specific message type. -// -// This class should stay limited to operations needed to implement -// the Message interface. -// -// This class is really a namespace that contains only static methods. -class LIBPROTOBUF_EXPORT ReflectionOps { - public: - static void Copy(const Message& from, Message* to); - static void Merge(const Message& from, Message* to); - static void Clear(Message* message); - static bool IsInitialized(const Message& message); - static void DiscardUnknownFields(Message* message); - - // Finds all unset required fields in the message and adds their full - // paths (e.g. "foo.bar[5].baz") to *names. "prefix" will be attached to - // the front of each name. - static void FindInitializationErrors(const Message& message, - const string& prefix, - vector* errors); - - private: - // All methods are static. No need to construct. - GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ReflectionOps); -}; - -} // namespace internal -} // namespace protobuf - -} // namespace google -#endif // GOOGLE_PROTOBUF_REFLECTION_OPS_H__ diff --git a/modules/dnn/3rdparty/protobuf/src/google/protobuf/reflection_ops_unittest.cc b/modules/dnn/3rdparty/protobuf/src/google/protobuf/reflection_ops_unittest.cc deleted file mode 100644 index 29229b5a7..000000000 --- a/modules/dnn/3rdparty/protobuf/src/google/protobuf/reflection_ops_unittest.cc +++ /dev/null @@ -1,405 +0,0 @@ -// Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// http://code.google.com/p/protobuf/ -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -// Author: kenton@google.com (Kenton Varda) -// Based on original Protocol Buffers design by -// Sanjay Ghemawat, Jeff Dean, and others. - -#include -#include -#include -#include - -#include -#include -#include -#include - -namespace google { -namespace protobuf { -namespace internal { -namespace { - -TEST(ReflectionOpsTest, SanityCheck) { - unittest::TestAllTypes message; - - TestUtil::SetAllFields(&message); - TestUtil::ExpectAllFieldsSet(message); -} - -TEST(ReflectionOpsTest, Copy) { - unittest::TestAllTypes message, message2; - - TestUtil::SetAllFields(&message); - - ReflectionOps::Copy(message, &message2); - - TestUtil::ExpectAllFieldsSet(message2); - - // Copying from self should be a no-op. - ReflectionOps::Copy(message2, &message2); - TestUtil::ExpectAllFieldsSet(message2); -} - -TEST(ReflectionOpsTest, CopyExtensions) { - unittest::TestAllExtensions message, message2; - - TestUtil::SetAllExtensions(&message); - - ReflectionOps::Copy(message, &message2); - - TestUtil::ExpectAllExtensionsSet(message2); -} - -TEST(ReflectionOpsTest, Merge) { - // Note: Copy is implemented in terms of Merge() so technically the Copy - // test already tested most of this. - - unittest::TestAllTypes message, message2; - - TestUtil::SetAllFields(&message); - - // This field will test merging into an empty spot. - message2.set_optional_int32(message.optional_int32()); - message.clear_optional_int32(); - - // This tests overwriting. - message2.set_optional_string(message.optional_string()); - message.set_optional_string("something else"); - - // This tests concatenating. - message2.add_repeated_int32(message.repeated_int32(1)); - int32 i = message.repeated_int32(0); - message.clear_repeated_int32(); - message.add_repeated_int32(i); - - ReflectionOps::Merge(message2, &message); - - TestUtil::ExpectAllFieldsSet(message); -} - -TEST(ReflectionOpsTest, MergeExtensions) { - // Note: Copy is implemented in terms of Merge() so technically the Copy - // test already tested most of this. - - unittest::TestAllExtensions message, message2; - - TestUtil::SetAllExtensions(&message); - - // This field will test merging into an empty spot. - message2.SetExtension(unittest::optional_int32_extension, - message.GetExtension(unittest::optional_int32_extension)); - message.ClearExtension(unittest::optional_int32_extension); - - // This tests overwriting. - message2.SetExtension(unittest::optional_string_extension, - message.GetExtension(unittest::optional_string_extension)); - message.SetExtension(unittest::optional_string_extension, "something else"); - - // This tests concatenating. - message2.AddExtension(unittest::repeated_int32_extension, - message.GetExtension(unittest::repeated_int32_extension, 1)); - int32 i = message.GetExtension(unittest::repeated_int32_extension, 0); - message.ClearExtension(unittest::repeated_int32_extension); - message.AddExtension(unittest::repeated_int32_extension, i); - - ReflectionOps::Merge(message2, &message); - - TestUtil::ExpectAllExtensionsSet(message); -} - -TEST(ReflectionOpsTest, MergeUnknown) { - // Test that the messages' UnknownFieldSets are correctly merged. - unittest::TestEmptyMessage message1, message2; - message1.mutable_unknown_fields()->AddVarint(1234, 1); - message2.mutable_unknown_fields()->AddVarint(1234, 2); - - ReflectionOps::Merge(message2, &message1); - - ASSERT_EQ(2, message1.unknown_fields().field_count()); - ASSERT_EQ(UnknownField::TYPE_VARINT, - message1.unknown_fields().field(0).type()); - EXPECT_EQ(1, message1.unknown_fields().field(0).varint()); - ASSERT_EQ(UnknownField::TYPE_VARINT, - message1.unknown_fields().field(1).type()); - EXPECT_EQ(2, message1.unknown_fields().field(1).varint()); -} - -#ifdef PROTOBUF_HAS_DEATH_TEST - -TEST(ReflectionOpsTest, MergeFromSelf) { - // Note: Copy is implemented in terms of Merge() so technically the Copy - // test already tested most of this. - - unittest::TestAllTypes message; - - EXPECT_DEATH( - ReflectionOps::Merge(message, &message), - "&from"); -} - -#endif // PROTOBUF_HAS_DEATH_TEST - -TEST(ReflectionOpsTest, Clear) { - unittest::TestAllTypes message; - - TestUtil::SetAllFields(&message); - - ReflectionOps::Clear(&message); - - TestUtil::ExpectClear(message); - - // Check that getting embedded messages returns the objects created during - // SetAllFields() rather than default instances. - EXPECT_NE(&unittest::TestAllTypes::OptionalGroup::default_instance(), - &message.optionalgroup()); - EXPECT_NE(&unittest::TestAllTypes::NestedMessage::default_instance(), - &message.optional_nested_message()); - EXPECT_NE(&unittest::ForeignMessage::default_instance(), - &message.optional_foreign_message()); - EXPECT_NE(&unittest_import::ImportMessage::default_instance(), - &message.optional_import_message()); -} - -TEST(ReflectionOpsTest, ClearExtensions) { - unittest::TestAllExtensions message; - - TestUtil::SetAllExtensions(&message); - - ReflectionOps::Clear(&message); - - TestUtil::ExpectExtensionsClear(message); - - // Check that getting embedded messages returns the objects created during - // SetAllExtensions() rather than default instances. - EXPECT_NE(&unittest::OptionalGroup_extension::default_instance(), - &message.GetExtension(unittest::optionalgroup_extension)); - EXPECT_NE(&unittest::TestAllTypes::NestedMessage::default_instance(), - &message.GetExtension(unittest::optional_nested_message_extension)); - EXPECT_NE(&unittest::ForeignMessage::default_instance(), - &message.GetExtension( - unittest::optional_foreign_message_extension)); - EXPECT_NE(&unittest_import::ImportMessage::default_instance(), - &message.GetExtension(unittest::optional_import_message_extension)); -} - -TEST(ReflectionOpsTest, ClearUnknown) { - // Test that the message's UnknownFieldSet is correctly cleared. - unittest::TestEmptyMessage message; - message.mutable_unknown_fields()->AddVarint(1234, 1); - - ReflectionOps::Clear(&message); - - EXPECT_EQ(0, message.unknown_fields().field_count()); -} - -TEST(ReflectionOpsTest, DiscardUnknownFields) { - unittest::TestAllTypes message; - TestUtil::SetAllFields(&message); - - // Set some unknown fields in message. - message.mutable_unknown_fields() - ->AddVarint(123456, 654321); - message.mutable_optional_nested_message() - ->mutable_unknown_fields() - ->AddVarint(123456, 654321); - message.mutable_repeated_nested_message(0) - ->mutable_unknown_fields() - ->AddVarint(123456, 654321); - - EXPECT_EQ(1, message.unknown_fields().field_count()); - EXPECT_EQ(1, message.optional_nested_message() - .unknown_fields().field_count()); - EXPECT_EQ(1, message.repeated_nested_message(0) - .unknown_fields().field_count()); - - // Discard them. - ReflectionOps::DiscardUnknownFields(&message); - TestUtil::ExpectAllFieldsSet(message); - - EXPECT_EQ(0, message.unknown_fields().field_count()); - EXPECT_EQ(0, message.optional_nested_message() - .unknown_fields().field_count()); - EXPECT_EQ(0, message.repeated_nested_message(0) - .unknown_fields().field_count()); -} - -TEST(ReflectionOpsTest, DiscardUnknownExtensions) { - unittest::TestAllExtensions message; - TestUtil::SetAllExtensions(&message); - - // Set some unknown fields. - message.mutable_unknown_fields() - ->AddVarint(123456, 654321); - message.MutableExtension(unittest::optional_nested_message_extension) - ->mutable_unknown_fields() - ->AddVarint(123456, 654321); - message.MutableExtension(unittest::repeated_nested_message_extension, 0) - ->mutable_unknown_fields() - ->AddVarint(123456, 654321); - - EXPECT_EQ(1, message.unknown_fields().field_count()); - EXPECT_EQ(1, - message.GetExtension(unittest::optional_nested_message_extension) - .unknown_fields().field_count()); - EXPECT_EQ(1, - message.GetExtension(unittest::repeated_nested_message_extension, 0) - .unknown_fields().field_count()); - - // Discard them. - ReflectionOps::DiscardUnknownFields(&message); - TestUtil::ExpectAllExtensionsSet(message); - - EXPECT_EQ(0, message.unknown_fields().field_count()); - EXPECT_EQ(0, - message.GetExtension(unittest::optional_nested_message_extension) - .unknown_fields().field_count()); - EXPECT_EQ(0, - message.GetExtension(unittest::repeated_nested_message_extension, 0) - .unknown_fields().field_count()); -} - -TEST(ReflectionOpsTest, IsInitialized) { - unittest::TestRequired message; - - EXPECT_FALSE(ReflectionOps::IsInitialized(message)); - message.set_a(1); - EXPECT_FALSE(ReflectionOps::IsInitialized(message)); - message.set_b(2); - EXPECT_FALSE(ReflectionOps::IsInitialized(message)); - message.set_c(3); - EXPECT_TRUE(ReflectionOps::IsInitialized(message)); -} - -TEST(ReflectionOpsTest, ForeignIsInitialized) { - unittest::TestRequiredForeign message; - - // Starts out initialized because the foreign message is itself an optional - // field. - EXPECT_TRUE(ReflectionOps::IsInitialized(message)); - - // Once we create that field, the message is no longer initialized. - message.mutable_optional_message(); - EXPECT_FALSE(ReflectionOps::IsInitialized(message)); - - // Initialize it. Now we're initialized. - message.mutable_optional_message()->set_a(1); - message.mutable_optional_message()->set_b(2); - message.mutable_optional_message()->set_c(3); - EXPECT_TRUE(ReflectionOps::IsInitialized(message)); - - // Add a repeated version of the message. No longer initialized. - unittest::TestRequired* sub_message = message.add_repeated_message(); - EXPECT_FALSE(ReflectionOps::IsInitialized(message)); - - // Initialize that repeated version. - sub_message->set_a(1); - sub_message->set_b(2); - sub_message->set_c(3); - EXPECT_TRUE(ReflectionOps::IsInitialized(message)); -} - -TEST(ReflectionOpsTest, ExtensionIsInitialized) { - unittest::TestAllExtensions message; - - // Starts out initialized because the foreign message is itself an optional - // field. - EXPECT_TRUE(ReflectionOps::IsInitialized(message)); - - // Once we create that field, the message is no longer initialized. - message.MutableExtension(unittest::TestRequired::single); - EXPECT_FALSE(ReflectionOps::IsInitialized(message)); - - // Initialize it. Now we're initialized. - message.MutableExtension(unittest::TestRequired::single)->set_a(1); - message.MutableExtension(unittest::TestRequired::single)->set_b(2); - message.MutableExtension(unittest::TestRequired::single)->set_c(3); - EXPECT_TRUE(ReflectionOps::IsInitialized(message)); - - // Add a repeated version of the message. No longer initialized. - message.AddExtension(unittest::TestRequired::multi); - EXPECT_FALSE(ReflectionOps::IsInitialized(message)); - - // Initialize that repeated version. - message.MutableExtension(unittest::TestRequired::multi, 0)->set_a(1); - message.MutableExtension(unittest::TestRequired::multi, 0)->set_b(2); - message.MutableExtension(unittest::TestRequired::multi, 0)->set_c(3); - EXPECT_TRUE(ReflectionOps::IsInitialized(message)); -} - -static string FindInitializationErrors(const Message& message) { - vector errors; - ReflectionOps::FindInitializationErrors(message, "", &errors); - return JoinStrings(errors, ","); -} - -TEST(ReflectionOpsTest, FindInitializationErrors) { - unittest::TestRequired message; - EXPECT_EQ("a,b,c", FindInitializationErrors(message)); -} - -TEST(ReflectionOpsTest, FindForeignInitializationErrors) { - unittest::TestRequiredForeign message; - message.mutable_optional_message(); - message.add_repeated_message(); - message.add_repeated_message(); - EXPECT_EQ("optional_message.a," - "optional_message.b," - "optional_message.c," - "repeated_message[0].a," - "repeated_message[0].b," - "repeated_message[0].c," - "repeated_message[1].a," - "repeated_message[1].b," - "repeated_message[1].c", - FindInitializationErrors(message)); -} - -TEST(ReflectionOpsTest, FindExtensionInitializationErrors) { - unittest::TestAllExtensions message; - message.MutableExtension(unittest::TestRequired::single); - message.AddExtension(unittest::TestRequired::multi); - message.AddExtension(unittest::TestRequired::multi); - EXPECT_EQ("(protobuf_unittest.TestRequired.single).a," - "(protobuf_unittest.TestRequired.single).b," - "(protobuf_unittest.TestRequired.single).c," - "(protobuf_unittest.TestRequired.multi)[0].a," - "(protobuf_unittest.TestRequired.multi)[0].b," - "(protobuf_unittest.TestRequired.multi)[0].c," - "(protobuf_unittest.TestRequired.multi)[1].a," - "(protobuf_unittest.TestRequired.multi)[1].b," - "(protobuf_unittest.TestRequired.multi)[1].c", - FindInitializationErrors(message)); -} - -} // namespace -} // namespace internal -} // namespace protobuf -} // namespace google diff --git a/modules/dnn/3rdparty/protobuf/src/google/protobuf/repeated_field.cc b/modules/dnn/3rdparty/protobuf/src/google/protobuf/repeated_field.cc deleted file mode 100644 index 2c1f74c58..000000000 --- a/modules/dnn/3rdparty/protobuf/src/google/protobuf/repeated_field.cc +++ /dev/null @@ -1,87 +0,0 @@ -// Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// http://code.google.com/p/protobuf/ -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -// Author: kenton@google.com (Kenton Varda) -// Based on original Protocol Buffers design by -// Sanjay Ghemawat, Jeff Dean, and others. - -#include - -#include -#include - -namespace google { -namespace protobuf { - -namespace internal { - -void RepeatedPtrFieldBase::Reserve(int new_size) { - if (total_size_ >= new_size) return; - - void** old_elements = elements_; - total_size_ = max(kMinRepeatedFieldAllocationSize, - max(total_size_ * 2, new_size)); - elements_ = new void*[total_size_]; - if (old_elements != NULL) { - memcpy(elements_, old_elements, allocated_size_ * sizeof(elements_[0])); - delete [] old_elements; - } -} - -void RepeatedPtrFieldBase::Swap(RepeatedPtrFieldBase* other) { - if (this == other) return; - void** swap_elements = elements_; - int swap_current_size = current_size_; - int swap_allocated_size = allocated_size_; - int swap_total_size = total_size_; - - elements_ = other->elements_; - current_size_ = other->current_size_; - allocated_size_ = other->allocated_size_; - total_size_ = other->total_size_; - - other->elements_ = swap_elements; - other->current_size_ = swap_current_size; - other->allocated_size_ = swap_allocated_size; - other->total_size_ = swap_total_size; -} - -string* StringTypeHandlerBase::New() { - return new string; -} -void StringTypeHandlerBase::Delete(string* value) { - delete value; -} - -} // namespace internal - - -} // namespace protobuf -} // namespace google diff --git a/modules/dnn/3rdparty/protobuf/src/google/protobuf/repeated_field.h b/modules/dnn/3rdparty/protobuf/src/google/protobuf/repeated_field.h deleted file mode 100644 index 570d4b751..000000000 --- a/modules/dnn/3rdparty/protobuf/src/google/protobuf/repeated_field.h +++ /dev/null @@ -1,1519 +0,0 @@ -// Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// http://code.google.com/p/protobuf/ -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -// Author: kenton@google.com (Kenton Varda) -// Based on original Protocol Buffers design by -// Sanjay Ghemawat, Jeff Dean, and others. -// -// RepeatedField and RepeatedPtrField are used by generated protocol message -// classes to manipulate repeated fields. These classes are very similar to -// STL's vector, but include a number of optimizations found to be useful -// specifically in the case of Protocol Buffers. RepeatedPtrField is -// particularly different from STL vector as it manages ownership of the -// pointers that it contains. -// -// Typically, clients should not need to access RepeatedField objects directly, -// but should instead use the accessor functions generated automatically by the -// protocol compiler. - -#ifndef GOOGLE_PROTOBUF_REPEATED_FIELD_H__ -#define GOOGLE_PROTOBUF_REPEATED_FIELD_H__ - -#include -#include -#include -#include -#include -#include -#include - -namespace google { - -namespace upb { -namespace google_opensource { -class GMR_Handlers; -} // namespace google_opensource -} // namespace upb - -namespace protobuf { - -class Message; - -namespace internal { - -static const int kMinRepeatedFieldAllocationSize = 4; - -// A utility function for logging that doesn't need any template types. -void LogIndexOutOfBounds(int index, int size); -} // namespace internal - - -// RepeatedField is used to represent repeated fields of a primitive type (in -// other words, everything except strings and nested Messages). Most users will -// not ever use a RepeatedField directly; they will use the get-by-index, -// set-by-index, and add accessors that are generated for all repeated fields. -template -class RepeatedField { - public: - RepeatedField(); - RepeatedField(const RepeatedField& other); - template - RepeatedField(Iter begin, const Iter& end); - ~RepeatedField(); - - RepeatedField& operator=(const RepeatedField& other); - - int size() const; - - const Element& Get(int index) const; - Element* Mutable(int index); - void Set(int index, const Element& value); - void Add(const Element& value); - Element* Add(); - // Remove the last element in the array. - void RemoveLast(); - - // Extract elements with indices in "[start .. start+num-1]". - // Copy them into "elements[0 .. num-1]" if "elements" is not NULL. - // Caution: implementation also moves elements with indices [start+num ..]. - // Calling this routine inside a loop can cause quadratic behavior. - void ExtractSubrange(int start, int num, Element* elements); - - void Clear(); - void MergeFrom(const RepeatedField& other); - void CopyFrom(const RepeatedField& other); - - // Reserve space to expand the field to at least the given size. If the - // array is grown, it will always be at least doubled in size. - void Reserve(int new_size); - - // Resize the RepeatedField to a new, smaller size. This is O(1). - void Truncate(int new_size); - - void AddAlreadyReserved(const Element& value); - Element* AddAlreadyReserved(); - int Capacity() const; - - // Gets the underlying array. This pointer is possibly invalidated by - // any add or remove operation. - Element* mutable_data(); - const Element* data() const; - - // Swap entire contents with "other". - void Swap(RepeatedField* other); - - // Swap two elements. - void SwapElements(int index1, int index2); - - // STL-like iterator support - typedef Element* iterator; - typedef const Element* const_iterator; - typedef Element value_type; - typedef value_type& reference; - typedef const value_type& const_reference; - typedef value_type* pointer; - typedef const value_type* const_pointer; - typedef int size_type; - typedef ptrdiff_t difference_type; - - iterator begin(); - const_iterator begin() const; - iterator end(); - const_iterator end() const; - - // Reverse iterator support - typedef std::reverse_iterator const_reverse_iterator; - typedef std::reverse_iterator reverse_iterator; - reverse_iterator rbegin() { - return reverse_iterator(end()); - } - const_reverse_iterator rbegin() const { - return const_reverse_iterator(end()); - } - reverse_iterator rend() { - return reverse_iterator(begin()); - } - const_reverse_iterator rend() const { - return const_reverse_iterator(begin()); - } - - // Returns the number of bytes used by the repeated field, excluding - // sizeof(*this) - int SpaceUsedExcludingSelf() const; - - private: - static const int kInitialSize = 0; - - Element* elements_; - int current_size_; - int total_size_; - - // Move the contents of |from| into |to|, possibly clobbering |from| in the - // process. For primitive types this is just a memcpy(), but it could be - // specialized for non-primitive types to, say, swap each element instead. - void MoveArray(Element to[], Element from[], int size); - - // Copy the elements of |from| into |to|. - void CopyArray(Element to[], const Element from[], int size); -}; - -namespace internal { -template class RepeatedPtrIterator; -template class RepeatedPtrOverPtrsIterator; -} // namespace internal - -namespace internal { - -// This is a helper template to copy an array of elements effeciently when they -// have a trivial copy constructor, and correctly otherwise. This really -// shouldn't be necessary, but our compiler doesn't optimize std::copy very -// effectively. -template ::value> -struct ElementCopier { - void operator()(Element to[], const Element from[], int array_size); -}; - -} // namespace internal - -namespace internal { - -// This is the common base class for RepeatedPtrFields. It deals only in void* -// pointers. Users should not use this interface directly. -// -// The methods of this interface correspond to the methods of RepeatedPtrField, -// but may have a template argument called TypeHandler. Its signature is: -// class TypeHandler { -// public: -// typedef MyType Type; -// static Type* New(); -// static void Delete(Type*); -// static void Clear(Type*); -// static void Merge(const Type& from, Type* to); -// -// // Only needs to be implemented if SpaceUsedExcludingSelf() is called. -// static int SpaceUsed(const Type&); -// }; -class LIBPROTOBUF_EXPORT RepeatedPtrFieldBase { - protected: - // The reflection implementation needs to call protected methods directly, - // reinterpreting pointers as being to Message instead of a specific Message - // subclass. - friend class GeneratedMessageReflection; - - // ExtensionSet stores repeated message extensions as - // RepeatedPtrField, but non-lite ExtensionSets need to - // implement SpaceUsed(), and thus need to call SpaceUsedExcludingSelf() - // reinterpreting MessageLite as Message. ExtensionSet also needs to make - // use of AddFromCleared(), which is not part of the public interface. - friend class ExtensionSet; - - // To parse directly into a proto2 generated class, the upb class GMR_Handlers - // needs to be able to modify a RepeatedPtrFieldBase directly. - friend class LIBPROTOBUF_EXPORT upb::google_opensource::GMR_Handlers; - - RepeatedPtrFieldBase(); - - // Must be called from destructor. - template - void Destroy(); - - int size() const; - - template - const typename TypeHandler::Type& Get(int index) const; - template - typename TypeHandler::Type* Mutable(int index); - template - typename TypeHandler::Type* Add(); - template - void RemoveLast(); - template - void Clear(); - template - void MergeFrom(const RepeatedPtrFieldBase& other); - template - void CopyFrom(const RepeatedPtrFieldBase& other); - - void CloseGap(int start, int num) { - // Close up a gap of "num" elements starting at offset "start". - for (int i = start + num; i < allocated_size_; ++i) - elements_[i - num] = elements_[i]; - current_size_ -= num; - allocated_size_ -= num; - } - - void Reserve(int new_size); - - int Capacity() const; - - // Used for constructing iterators. - void* const* raw_data() const; - void** raw_mutable_data() const; - - template - typename TypeHandler::Type** mutable_data(); - template - const typename TypeHandler::Type* const* data() const; - - void Swap(RepeatedPtrFieldBase* other); - - void SwapElements(int index1, int index2); - - template - int SpaceUsedExcludingSelf() const; - - - // Advanced memory management -------------------------------------- - - // Like Add(), but if there are no cleared objects to use, returns NULL. - template - typename TypeHandler::Type* AddFromCleared(); - - template - void AddAllocated(typename TypeHandler::Type* value); - template - typename TypeHandler::Type* ReleaseLast(); - - int ClearedCount() const; - template - void AddCleared(typename TypeHandler::Type* value); - template - typename TypeHandler::Type* ReleaseCleared(); - - private: - GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(RepeatedPtrFieldBase); - - static const int kInitialSize = 0; - - void** elements_; - int current_size_; - int allocated_size_; - int total_size_; - - template - static inline typename TypeHandler::Type* cast(void* element) { - return reinterpret_cast(element); - } - template - static inline const typename TypeHandler::Type* cast(const void* element) { - return reinterpret_cast(element); - } -}; - -template -class GenericTypeHandler { - public: - typedef GenericType Type; - static GenericType* New() { return new GenericType; } - static void Delete(GenericType* value) { delete value; } - static void Clear(GenericType* value) { value->Clear(); } - static void Merge(const GenericType& from, GenericType* to) { - to->MergeFrom(from); - } - static int SpaceUsed(const GenericType& value) { return value.SpaceUsed(); } - static const Type& default_instance() { return Type::default_instance(); } -}; - -template <> -inline void GenericTypeHandler::Merge( - const MessageLite& from, MessageLite* to) { - to->CheckTypeAndMergeFrom(from); -} - -template <> -inline const MessageLite& GenericTypeHandler::default_instance() { - // Yes, the behavior of the code is undefined, but this function is only - // called when we're already deep into the world of undefined, because the - // caller called Get(index) out of bounds. - MessageLite* null = NULL; - return *null; -} - -template <> -inline const Message& GenericTypeHandler::default_instance() { - // Yes, the behavior of the code is undefined, but this function is only - // called when we're already deep into the world of undefined, because the - // caller called Get(index) out of bounds. - Message* null = NULL; - return *null; -} - - -// HACK: If a class is declared as DLL-exported in MSVC, it insists on -// generating copies of all its methods -- even inline ones -- to include -// in the DLL. But SpaceUsed() calls StringSpaceUsedExcludingSelf() which -// isn't in the lite library, therefore the lite library cannot link if -// StringTypeHandler is exported. So, we factor out StringTypeHandlerBase, -// export that, then make StringTypeHandler be a subclass which is NOT -// exported. -// TODO(kenton): There has to be a better way. -class LIBPROTOBUF_EXPORT StringTypeHandlerBase { - public: - typedef string Type; - static string* New(); - static void Delete(string* value); - static void Clear(string* value) { value->clear(); } - static void Merge(const string& from, string* to) { *to = from; } - static const Type& default_instance() { - return ::google::protobuf::internal::kEmptyString; - } -}; - -class StringTypeHandler : public StringTypeHandlerBase { - public: - static int SpaceUsed(const string& value) { - return sizeof(value) + StringSpaceUsedExcludingSelf(value); - } -}; - - -} // namespace internal - -// RepeatedPtrField is like RepeatedField, but used for repeated strings or -// Messages. -template -class RepeatedPtrField : public internal::RepeatedPtrFieldBase { - public: - RepeatedPtrField(); - RepeatedPtrField(const RepeatedPtrField& other); - template - RepeatedPtrField(Iter begin, const Iter& end); - ~RepeatedPtrField(); - - RepeatedPtrField& operator=(const RepeatedPtrField& other); - - int size() const; - - const Element& Get(int index) const; - Element* Mutable(int index); - Element* Add(); - - // Remove the last element in the array. - // Ownership of the element is retained by the array. - void RemoveLast(); - - // Delete elements with indices in the range [start .. start+num-1]. - // Caution: implementation moves all elements with indices [start+num .. ]. - // Calling this routine inside a loop can cause quadratic behavior. - void DeleteSubrange(int start, int num); - - void Clear(); - void MergeFrom(const RepeatedPtrField& other); - void CopyFrom(const RepeatedPtrField& other); - - // Reserve space to expand the field to at least the given size. This only - // resizes the pointer array; it doesn't allocate any objects. If the - // array is grown, it will always be at least doubled in size. - void Reserve(int new_size); - - int Capacity() const; - - // Gets the underlying array. This pointer is possibly invalidated by - // any add or remove operation. - Element** mutable_data(); - const Element* const* data() const; - - // Swap entire contents with "other". - void Swap(RepeatedPtrField* other); - - // Swap two elements. - void SwapElements(int index1, int index2); - - // STL-like iterator support - typedef internal::RepeatedPtrIterator iterator; - typedef internal::RepeatedPtrIterator const_iterator; - typedef Element value_type; - typedef value_type& reference; - typedef const value_type& const_reference; - typedef value_type* pointer; - typedef const value_type* const_pointer; - typedef int size_type; - typedef ptrdiff_t difference_type; - - iterator begin(); - const_iterator begin() const; - iterator end(); - const_iterator end() const; - - // Reverse iterator support - typedef std::reverse_iterator const_reverse_iterator; - typedef std::reverse_iterator reverse_iterator; - reverse_iterator rbegin() { - return reverse_iterator(end()); - } - const_reverse_iterator rbegin() const { - return const_reverse_iterator(end()); - } - reverse_iterator rend() { - return reverse_iterator(begin()); - } - const_reverse_iterator rend() const { - return const_reverse_iterator(begin()); - } - - // Custom STL-like iterator that iterates over and returns the underlying - // pointers to Element rather than Element itself. - typedef internal::RepeatedPtrOverPtrsIterator - pointer_iterator; - typedef internal::RepeatedPtrOverPtrsIterator - const_pointer_iterator; - pointer_iterator pointer_begin(); - const_pointer_iterator pointer_begin() const; - pointer_iterator pointer_end(); - const_pointer_iterator pointer_end() const; - - // Returns (an estimate of) the number of bytes used by the repeated field, - // excluding sizeof(*this). - int SpaceUsedExcludingSelf() const; - - // Advanced memory management -------------------------------------- - // When hardcore memory management becomes necessary -- as it sometimes - // does here at Google -- the following methods may be useful. - - // Add an already-allocated object, passing ownership to the - // RepeatedPtrField. - void AddAllocated(Element* value); - // Remove the last element and return it, passing ownership to the caller. - // Requires: size() > 0 - Element* ReleaseLast(); - - // Extract elements with indices in the range "[start .. start+num-1]". - // The caller assumes ownership of the extracted elements and is responsible - // for deleting them when they are no longer needed. - // If "elements" is non-NULL, then pointers to the extracted elements - // are stored in "elements[0 .. num-1]" for the convenience of the caller. - // If "elements" is NULL, then the caller must use some other mechanism - // to perform any further operations (like deletion) on these elements. - // Caution: implementation also moves elements with indices [start+num ..]. - // Calling this routine inside a loop can cause quadratic behavior. - void ExtractSubrange(int start, int num, Element** elements); - - // When elements are removed by calls to RemoveLast() or Clear(), they - // are not actually freed. Instead, they are cleared and kept so that - // they can be reused later. This can save lots of CPU time when - // repeatedly reusing a protocol message for similar purposes. - // - // Hardcore programs may choose to manipulate these cleared objects - // to better optimize memory management using the following routines. - - // Get the number of cleared objects that are currently being kept - // around for reuse. - int ClearedCount() const; - // Add an element to the pool of cleared objects, passing ownership to - // the RepeatedPtrField. The element must be cleared prior to calling - // this method. - void AddCleared(Element* value); - // Remove a single element from the cleared pool and return it, passing - // ownership to the caller. The element is guaranteed to be cleared. - // Requires: ClearedCount() > 0 - Element* ReleaseCleared(); - - protected: - // Note: RepeatedPtrField SHOULD NOT be subclassed by users. We only - // subclass it in one place as a hack for compatibility with proto1. The - // subclass needs to know about TypeHandler in order to call protected - // methods on RepeatedPtrFieldBase. - class TypeHandler; - -}; - -// implementation ==================================================== - -template -inline RepeatedField::RepeatedField() - : elements_(NULL), - current_size_(0), - total_size_(kInitialSize) { -} - -template -inline RepeatedField::RepeatedField(const RepeatedField& other) - : elements_(NULL), - current_size_(0), - total_size_(kInitialSize) { - CopyFrom(other); -} - -template -template -inline RepeatedField::RepeatedField(Iter begin, const Iter& end) - : elements_(NULL), - current_size_(0), - total_size_(kInitialSize) { - for (; begin != end; ++begin) { - Add(*begin); - } -} - -template -RepeatedField::~RepeatedField() { - delete [] elements_; -} - -template -inline RepeatedField& -RepeatedField::operator=(const RepeatedField& other) { - if (this != &other) - CopyFrom(other); - return *this; -} - -template -inline int RepeatedField::size() const { - return current_size_; -} - -template -inline int RepeatedField::Capacity() const { - return total_size_; -} - -template -inline void RepeatedField::AddAlreadyReserved(const Element& value) { - GOOGLE_DCHECK_LT(size(), Capacity()); - elements_[current_size_++] = value; -} - -template -inline Element* RepeatedField::AddAlreadyReserved() { - GOOGLE_DCHECK_LT(size(), Capacity()); - return &elements_[current_size_++]; -} - -template -inline const Element& RepeatedField::Get(int index) const { - GOOGLE_DCHECK_LT(index, size()); - return elements_[index]; -} - -template -inline Element* RepeatedField::Mutable(int index) { - GOOGLE_DCHECK_LT(index, size()); - return elements_ + index; -} - -template -inline void RepeatedField::Set(int index, const Element& value) { - GOOGLE_DCHECK_LT(index, size()); - elements_[index] = value; -} - -template -inline void RepeatedField::Add(const Element& value) { - if (current_size_ == total_size_) Reserve(total_size_ + 1); - elements_[current_size_++] = value; -} - -template -inline Element* RepeatedField::Add() { - if (current_size_ == total_size_) Reserve(total_size_ + 1); - return &elements_[current_size_++]; -} - -template -inline void RepeatedField::RemoveLast() { - GOOGLE_DCHECK_GT(current_size_, 0); - --current_size_; -} - -template -void RepeatedField::ExtractSubrange( - int start, int num, Element* elements) { - GOOGLE_DCHECK_GE(start, 0); - GOOGLE_DCHECK_GE(num, 0); - GOOGLE_DCHECK_LE(start + num, this->size()); - - // Save the values of the removed elements if requested. - if (elements != NULL) { - for (int i = 0; i < num; ++i) - elements[i] = this->Get(i + start); - } - - // Slide remaining elements down to fill the gap. - if (num > 0) { - for (int i = start + num; i < this->size(); ++i) - this->Set(i - num, this->Get(i)); - this->Truncate(this->size() - num); - } -} - -template -inline void RepeatedField::Clear() { - current_size_ = 0; -} - -template -inline void RepeatedField::MergeFrom(const RepeatedField& other) { - if (other.current_size_ != 0) { - Reserve(current_size_ + other.current_size_); - CopyArray(elements_ + current_size_, other.elements_, other.current_size_); - current_size_ += other.current_size_; - } -} - -template -inline void RepeatedField::CopyFrom(const RepeatedField& other) { - Clear(); - MergeFrom(other); -} - -template -inline Element* RepeatedField::mutable_data() { - return elements_; -} - -template -inline const Element* RepeatedField::data() const { - return elements_; -} - - -template -void RepeatedField::Swap(RepeatedField* other) { - if (this == other) return; - Element* swap_elements = elements_; - int swap_current_size = current_size_; - int swap_total_size = total_size_; - - elements_ = other->elements_; - current_size_ = other->current_size_; - total_size_ = other->total_size_; - - other->elements_ = swap_elements; - other->current_size_ = swap_current_size; - other->total_size_ = swap_total_size; -} - -template -void RepeatedField::SwapElements(int index1, int index2) { - std::swap(elements_[index1], elements_[index2]); -} - -template -inline typename RepeatedField::iterator -RepeatedField::begin() { - return elements_; -} -template -inline typename RepeatedField::const_iterator -RepeatedField::begin() const { - return elements_; -} -template -inline typename RepeatedField::iterator -RepeatedField::end() { - return elements_ + current_size_; -} -template -inline typename RepeatedField::const_iterator -RepeatedField::end() const { - return elements_ + current_size_; -} - -template -inline int RepeatedField::SpaceUsedExcludingSelf() const { - return (elements_ != NULL) ? total_size_ * sizeof(elements_[0]) : 0; -} - -// Avoid inlining of Reserve(): new, copy, and delete[] lead to a significant -// amount of code bloat. -template -void RepeatedField::Reserve(int new_size) { - if (total_size_ >= new_size) return; - - Element* old_elements = elements_; - total_size_ = max(google::protobuf::internal::kMinRepeatedFieldAllocationSize, - max(total_size_ * 2, new_size)); - elements_ = new Element[total_size_]; - if (old_elements != NULL) { - MoveArray(elements_, old_elements, current_size_); - delete [] old_elements; - } -} - -template -inline void RepeatedField::Truncate(int new_size) { - GOOGLE_DCHECK_LE(new_size, current_size_); - current_size_ = new_size; -} - -template -inline void RepeatedField::MoveArray( - Element to[], Element from[], int array_size) { - CopyArray(to, from, array_size); -} - -template -inline void RepeatedField::CopyArray( - Element to[], const Element from[], int array_size) { - internal::ElementCopier()(to, from, array_size); -} - -namespace internal { - -template -void ElementCopier::operator()( - Element to[], const Element from[], int array_size) { - std::copy(from, from + array_size, to); -} - -template -struct ElementCopier { - void operator()(Element to[], const Element from[], int array_size) { - memcpy(to, from, array_size * sizeof(Element)); - } -}; - -} // namespace internal - - -// ------------------------------------------------------------------- - -namespace internal { - -inline RepeatedPtrFieldBase::RepeatedPtrFieldBase() - : elements_(NULL), - current_size_(0), - allocated_size_(0), - total_size_(kInitialSize) { -} - -template -void RepeatedPtrFieldBase::Destroy() { - for (int i = 0; i < allocated_size_; i++) { - TypeHandler::Delete(cast(elements_[i])); - } - delete [] elements_; -} - -inline int RepeatedPtrFieldBase::size() const { - return current_size_; -} - -template -inline const typename TypeHandler::Type& -RepeatedPtrFieldBase::Get(int index) const { - GOOGLE_DCHECK_LT(index, size()); - return *cast(elements_[index]); -} - - -template -inline typename TypeHandler::Type* -RepeatedPtrFieldBase::Mutable(int index) { - GOOGLE_DCHECK_LT(index, size()); - return cast(elements_[index]); -} - -template -inline typename TypeHandler::Type* RepeatedPtrFieldBase::Add() { - if (current_size_ < allocated_size_) { - return cast(elements_[current_size_++]); - } - if (allocated_size_ == total_size_) Reserve(total_size_ + 1); - ++allocated_size_; - typename TypeHandler::Type* result = TypeHandler::New(); - elements_[current_size_++] = result; - return result; -} - -template -inline void RepeatedPtrFieldBase::RemoveLast() { - GOOGLE_DCHECK_GT(current_size_, 0); - TypeHandler::Clear(cast(elements_[--current_size_])); -} - -template -void RepeatedPtrFieldBase::Clear() { - for (int i = 0; i < current_size_; i++) { - TypeHandler::Clear(cast(elements_[i])); - } - current_size_ = 0; -} - -template -inline void RepeatedPtrFieldBase::MergeFrom(const RepeatedPtrFieldBase& other) { - Reserve(current_size_ + other.current_size_); - for (int i = 0; i < other.current_size_; i++) { - TypeHandler::Merge(other.template Get(i), Add()); - } -} - -template -inline void RepeatedPtrFieldBase::CopyFrom(const RepeatedPtrFieldBase& other) { - RepeatedPtrFieldBase::Clear(); - RepeatedPtrFieldBase::MergeFrom(other); -} - -inline int RepeatedPtrFieldBase::Capacity() const { - return total_size_; -} - -inline void* const* RepeatedPtrFieldBase::raw_data() const { - return elements_; -} - -inline void** RepeatedPtrFieldBase::raw_mutable_data() const { - return elements_; -} - -template -inline typename TypeHandler::Type** RepeatedPtrFieldBase::mutable_data() { - // TODO(kenton): Breaks C++ aliasing rules. We should probably remove this - // method entirely. - return reinterpret_cast(elements_); -} - -template -inline const typename TypeHandler::Type* const* -RepeatedPtrFieldBase::data() const { - // TODO(kenton): Breaks C++ aliasing rules. We should probably remove this - // method entirely. - return reinterpret_cast(elements_); -} - -inline void RepeatedPtrFieldBase::SwapElements(int index1, int index2) { - std::swap(elements_[index1], elements_[index2]); -} - -template -inline int RepeatedPtrFieldBase::SpaceUsedExcludingSelf() const { - int allocated_bytes = - (elements_ != NULL) ? total_size_ * sizeof(elements_[0]) : 0; - for (int i = 0; i < allocated_size_; ++i) { - allocated_bytes += TypeHandler::SpaceUsed(*cast(elements_[i])); - } - return allocated_bytes; -} - -template -inline typename TypeHandler::Type* RepeatedPtrFieldBase::AddFromCleared() { - if (current_size_ < allocated_size_) { - return cast(elements_[current_size_++]); - } else { - return NULL; - } -} - -template -void RepeatedPtrFieldBase::AddAllocated( - typename TypeHandler::Type* value) { - // Make room for the new pointer. - if (current_size_ == total_size_) { - // The array is completely full with no cleared objects, so grow it. - Reserve(total_size_ + 1); - ++allocated_size_; - } else if (allocated_size_ == total_size_) { - // There is no more space in the pointer array because it contains some - // cleared objects awaiting reuse. We don't want to grow the array in this - // case because otherwise a loop calling AddAllocated() followed by Clear() - // would leak memory. - TypeHandler::Delete(cast(elements_[current_size_])); - } else if (current_size_ < allocated_size_) { - // We have some cleared objects. We don't care about their order, so we - // can just move the first one to the end to make space. - elements_[allocated_size_] = elements_[current_size_]; - ++allocated_size_; - } else { - // There are no cleared objects. - ++allocated_size_; - } - - elements_[current_size_++] = value; -} - -template -inline typename TypeHandler::Type* RepeatedPtrFieldBase::ReleaseLast() { - GOOGLE_DCHECK_GT(current_size_, 0); - typename TypeHandler::Type* result = - cast(elements_[--current_size_]); - --allocated_size_; - if (current_size_ < allocated_size_) { - // There are cleared elements on the end; replace the removed element - // with the last allocated element. - elements_[current_size_] = elements_[allocated_size_]; - } - return result; -} - -inline int RepeatedPtrFieldBase::ClearedCount() const { - return allocated_size_ - current_size_; -} - -template -inline void RepeatedPtrFieldBase::AddCleared( - typename TypeHandler::Type* value) { - if (allocated_size_ == total_size_) Reserve(total_size_ + 1); - elements_[allocated_size_++] = value; -} - -template -inline typename TypeHandler::Type* RepeatedPtrFieldBase::ReleaseCleared() { - GOOGLE_DCHECK_GT(allocated_size_, current_size_); - return cast(elements_[--allocated_size_]); -} - -} // namespace internal - -// ------------------------------------------------------------------- - -template -class RepeatedPtrField::TypeHandler - : public internal::GenericTypeHandler { -}; - -template <> -class RepeatedPtrField::TypeHandler - : public internal::StringTypeHandler { -}; - - -template -inline RepeatedPtrField::RepeatedPtrField() {} - -template -inline RepeatedPtrField::RepeatedPtrField( - const RepeatedPtrField& other) { - CopyFrom(other); -} - -template -template -inline RepeatedPtrField::RepeatedPtrField( - Iter begin, const Iter& end) { - for (; begin != end; ++begin) { - *Add() = *begin; - } -} - -template -RepeatedPtrField::~RepeatedPtrField() { - Destroy(); -} - -template -inline RepeatedPtrField& RepeatedPtrField::operator=( - const RepeatedPtrField& other) { - if (this != &other) - CopyFrom(other); - return *this; -} - -template -inline int RepeatedPtrField::size() const { - return RepeatedPtrFieldBase::size(); -} - -template -inline const Element& RepeatedPtrField::Get(int index) const { - return RepeatedPtrFieldBase::Get(index); -} - - -template -inline Element* RepeatedPtrField::Mutable(int index) { - return RepeatedPtrFieldBase::Mutable(index); -} - -template -inline Element* RepeatedPtrField::Add() { - return RepeatedPtrFieldBase::Add(); -} - -template -inline void RepeatedPtrField::RemoveLast() { - RepeatedPtrFieldBase::RemoveLast(); -} - -template -inline void RepeatedPtrField::DeleteSubrange(int start, int num) { - GOOGLE_DCHECK_GE(start, 0); - GOOGLE_DCHECK_GE(num, 0); - GOOGLE_DCHECK_LE(start + num, size()); - for (int i = 0; i < num; ++i) - delete RepeatedPtrFieldBase::Mutable(start + i); - ExtractSubrange(start, num, NULL); -} - -template -inline void RepeatedPtrField::ExtractSubrange( - int start, int num, Element** elements) { - GOOGLE_DCHECK_GE(start, 0); - GOOGLE_DCHECK_GE(num, 0); - GOOGLE_DCHECK_LE(start + num, size()); - - if (num > 0) { - // Save the values of the removed elements if requested. - if (elements != NULL) { - for (int i = 0; i < num; ++i) - elements[i] = RepeatedPtrFieldBase::Mutable(i + start); - } - CloseGap(start, num); - } -} - -template -inline void RepeatedPtrField::Clear() { - RepeatedPtrFieldBase::Clear(); -} - -template -inline void RepeatedPtrField::MergeFrom( - const RepeatedPtrField& other) { - RepeatedPtrFieldBase::MergeFrom(other); -} - -template -inline void RepeatedPtrField::CopyFrom( - const RepeatedPtrField& other) { - RepeatedPtrFieldBase::CopyFrom(other); -} - -template -inline Element** RepeatedPtrField::mutable_data() { - return RepeatedPtrFieldBase::mutable_data(); -} - -template -inline const Element* const* RepeatedPtrField::data() const { - return RepeatedPtrFieldBase::data(); -} - -template -void RepeatedPtrField::Swap(RepeatedPtrField* other) { - RepeatedPtrFieldBase::Swap(other); -} - -template -void RepeatedPtrField::SwapElements(int index1, int index2) { - RepeatedPtrFieldBase::SwapElements(index1, index2); -} - -template -inline int RepeatedPtrField::SpaceUsedExcludingSelf() const { - return RepeatedPtrFieldBase::SpaceUsedExcludingSelf(); -} - -template -inline void RepeatedPtrField::AddAllocated(Element* value) { - RepeatedPtrFieldBase::AddAllocated(value); -} - -template -inline Element* RepeatedPtrField::ReleaseLast() { - return RepeatedPtrFieldBase::ReleaseLast(); -} - - -template -inline int RepeatedPtrField::ClearedCount() const { - return RepeatedPtrFieldBase::ClearedCount(); -} - -template -inline void RepeatedPtrField::AddCleared(Element* value) { - return RepeatedPtrFieldBase::AddCleared(value); -} - -template -inline Element* RepeatedPtrField::ReleaseCleared() { - return RepeatedPtrFieldBase::ReleaseCleared(); -} - -template -inline void RepeatedPtrField::Reserve(int new_size) { - return RepeatedPtrFieldBase::Reserve(new_size); -} - -template -inline int RepeatedPtrField::Capacity() const { - return RepeatedPtrFieldBase::Capacity(); -} - -// ------------------------------------------------------------------- - -namespace internal { - -// STL-like iterator implementation for RepeatedPtrField. You should not -// refer to this class directly; use RepeatedPtrField::iterator instead. -// -// The iterator for RepeatedPtrField, RepeatedPtrIterator, is -// very similar to iterator_ptr in util/gtl/iterator_adaptors.h, -// but adds random-access operators and is modified to wrap a void** base -// iterator (since RepeatedPtrField stores its array as a void* array and -// casting void** to T** would violate C++ aliasing rules). -// -// This code based on net/proto/proto-array-internal.h by Jeffrey Yasskin -// (jyasskin@google.com). -template -class RepeatedPtrIterator - : public std::iterator< - std::random_access_iterator_tag, Element> { - public: - typedef RepeatedPtrIterator iterator; - typedef std::iterator< - std::random_access_iterator_tag, Element> superclass; - - // Let the compiler know that these are type names, so we don't have to - // write "typename" in front of them everywhere. - typedef typename superclass::reference reference; - typedef typename superclass::pointer pointer; - typedef typename superclass::difference_type difference_type; - - RepeatedPtrIterator() : it_(NULL) {} - explicit RepeatedPtrIterator(void* const* it) : it_(it) {} - - // Allow "upcasting" from RepeatedPtrIterator to - // RepeatedPtrIterator. - template - RepeatedPtrIterator(const RepeatedPtrIterator& other) - : it_(other.it_) { - // Force a compiler error if the other type is not convertible to ours. - if (false) { - implicit_cast(0); - } - } - - // dereferenceable - reference operator*() const { return *reinterpret_cast(*it_); } - pointer operator->() const { return &(operator*()); } - - // {inc,dec}rementable - iterator& operator++() { ++it_; return *this; } - iterator operator++(int) { return iterator(it_++); } - iterator& operator--() { --it_; return *this; } - iterator operator--(int) { return iterator(it_--); } - - // equality_comparable - bool operator==(const iterator& x) const { return it_ == x.it_; } - bool operator!=(const iterator& x) const { return it_ != x.it_; } - - // less_than_comparable - bool operator<(const iterator& x) const { return it_ < x.it_; } - bool operator<=(const iterator& x) const { return it_ <= x.it_; } - bool operator>(const iterator& x) const { return it_ > x.it_; } - bool operator>=(const iterator& x) const { return it_ >= x.it_; } - - // addable, subtractable - iterator& operator+=(difference_type d) { - it_ += d; - return *this; - } - friend iterator operator+(iterator it, difference_type d) { - it += d; - return it; - } - friend iterator operator+(difference_type d, iterator it) { - it += d; - return it; - } - iterator& operator-=(difference_type d) { - it_ -= d; - return *this; - } - friend iterator operator-(iterator it, difference_type d) { - it -= d; - return it; - } - - // indexable - reference operator[](difference_type d) const { return *(*this + d); } - - // random access iterator - difference_type operator-(const iterator& x) const { return it_ - x.it_; } - - private: - template - friend class RepeatedPtrIterator; - - // The internal iterator. - void* const* it_; -}; - -// Provide an iterator that operates on pointers to the underlying objects -// rather than the objects themselves as RepeatedPtrIterator does. -// Consider using this when working with stl algorithms that change -// the array. -// The VoidPtr template parameter holds the type-agnostic pointer value -// referenced by the iterator. It should either be "void *" for a mutable -// iterator, or "const void *" for a constant iterator. -template -class RepeatedPtrOverPtrsIterator - : public std::iterator { - public: - typedef RepeatedPtrOverPtrsIterator iterator; - typedef std::iterator< - std::random_access_iterator_tag, Element*> superclass; - - // Let the compiler know that these are type names, so we don't have to - // write "typename" in front of them everywhere. - typedef typename superclass::reference reference; - typedef typename superclass::pointer pointer; - typedef typename superclass::difference_type difference_type; - - RepeatedPtrOverPtrsIterator() : it_(NULL) {} - explicit RepeatedPtrOverPtrsIterator(VoidPtr* it) : it_(it) {} - - // dereferenceable - reference operator*() const { return *reinterpret_cast(it_); } - pointer operator->() const { return &(operator*()); } - - // {inc,dec}rementable - iterator& operator++() { ++it_; return *this; } - iterator operator++(int) { return iterator(it_++); } - iterator& operator--() { --it_; return *this; } - iterator operator--(int) { return iterator(it_--); } - - // equality_comparable - bool operator==(const iterator& x) const { return it_ == x.it_; } - bool operator!=(const iterator& x) const { return it_ != x.it_; } - - // less_than_comparable - bool operator<(const iterator& x) const { return it_ < x.it_; } - bool operator<=(const iterator& x) const { return it_ <= x.it_; } - bool operator>(const iterator& x) const { return it_ > x.it_; } - bool operator>=(const iterator& x) const { return it_ >= x.it_; } - - // addable, subtractable - iterator& operator+=(difference_type d) { - it_ += d; - return *this; - } - friend iterator operator+(iterator it, difference_type d) { - it += d; - return it; - } - friend iterator operator+(difference_type d, iterator it) { - it += d; - return it; - } - iterator& operator-=(difference_type d) { - it_ -= d; - return *this; - } - friend iterator operator-(iterator it, difference_type d) { - it -= d; - return it; - } - - // indexable - reference operator[](difference_type d) const { return *(*this + d); } - - // random access iterator - difference_type operator-(const iterator& x) const { return it_ - x.it_; } - - private: - template - friend class RepeatedPtrIterator; - - // The internal iterator. - VoidPtr* it_; -}; - -} // namespace internal - -template -inline typename RepeatedPtrField::iterator -RepeatedPtrField::begin() { - return iterator(raw_data()); -} -template -inline typename RepeatedPtrField::const_iterator -RepeatedPtrField::begin() const { - return iterator(raw_data()); -} -template -inline typename RepeatedPtrField::iterator -RepeatedPtrField::end() { - return iterator(raw_data() + size()); -} -template -inline typename RepeatedPtrField::const_iterator -RepeatedPtrField::end() const { - return iterator(raw_data() + size()); -} - -template -inline typename RepeatedPtrField::pointer_iterator -RepeatedPtrField::pointer_begin() { - return pointer_iterator(raw_mutable_data()); -} -template -inline typename RepeatedPtrField::const_pointer_iterator -RepeatedPtrField::pointer_begin() const { - return const_pointer_iterator(const_cast(raw_mutable_data())); -} -template -inline typename RepeatedPtrField::pointer_iterator -RepeatedPtrField::pointer_end() { - return pointer_iterator(raw_mutable_data() + size()); -} -template -inline typename RepeatedPtrField::const_pointer_iterator -RepeatedPtrField::pointer_end() const { - return const_pointer_iterator( - const_cast(raw_mutable_data() + size())); -} - - -// Iterators and helper functions that follow the spirit of the STL -// std::back_insert_iterator and std::back_inserter but are tailor-made -// for RepeatedField and RepatedPtrField. Typical usage would be: -// -// std::copy(some_sequence.begin(), some_sequence.end(), -// google::protobuf::RepeatedFieldBackInserter(proto.mutable_sequence())); -// -// Ported by johannes from util/gtl/proto-array-iterators.h - -namespace internal { -// A back inserter for RepeatedField objects. -template class RepeatedFieldBackInsertIterator - : public std::iterator { - public: - explicit RepeatedFieldBackInsertIterator( - RepeatedField* const mutable_field) - : field_(mutable_field) { - } - RepeatedFieldBackInsertIterator& operator=(const T& value) { - field_->Add(value); - return *this; - } - RepeatedFieldBackInsertIterator& operator*() { - return *this; - } - RepeatedFieldBackInsertIterator& operator++() { - return *this; - } - RepeatedFieldBackInsertIterator& operator++(int /* unused */) { - return *this; - } - - private: - RepeatedField* field_; -}; - -// A back inserter for RepeatedPtrField objects. -template class RepeatedPtrFieldBackInsertIterator - : public std::iterator { - public: - RepeatedPtrFieldBackInsertIterator( - RepeatedPtrField* const mutable_field) - : field_(mutable_field) { - } - RepeatedPtrFieldBackInsertIterator& operator=(const T& value) { - *field_->Add() = value; - return *this; - } - RepeatedPtrFieldBackInsertIterator& operator=( - const T* const ptr_to_value) { - *field_->Add() = *ptr_to_value; - return *this; - } - RepeatedPtrFieldBackInsertIterator& operator*() { - return *this; - } - RepeatedPtrFieldBackInsertIterator& operator++() { - return *this; - } - RepeatedPtrFieldBackInsertIterator& operator++(int /* unused */) { - return *this; - } - - private: - RepeatedPtrField* field_; -}; - -// A back inserter for RepeatedPtrFields that inserts by transfering ownership -// of a pointer. -template class AllocatedRepeatedPtrFieldBackInsertIterator - : public std::iterator { - public: - explicit AllocatedRepeatedPtrFieldBackInsertIterator( - RepeatedPtrField* const mutable_field) - : field_(mutable_field) { - } - AllocatedRepeatedPtrFieldBackInsertIterator& operator=( - T* const ptr_to_value) { - field_->AddAllocated(ptr_to_value); - return *this; - } - AllocatedRepeatedPtrFieldBackInsertIterator& operator*() { - return *this; - } - AllocatedRepeatedPtrFieldBackInsertIterator& operator++() { - return *this; - } - AllocatedRepeatedPtrFieldBackInsertIterator& operator++( - int /* unused */) { - return *this; - } - - private: - RepeatedPtrField* field_; -}; -} // namespace internal - -// Provides a back insert iterator for RepeatedField instances, -// similar to std::back_inserter(). -template internal::RepeatedFieldBackInsertIterator -RepeatedFieldBackInserter(RepeatedField* const mutable_field) { - return internal::RepeatedFieldBackInsertIterator(mutable_field); -} - -// Provides a back insert iterator for RepeatedPtrField instances, -// similar to std::back_inserter(). -template internal::RepeatedPtrFieldBackInsertIterator -RepeatedPtrFieldBackInserter(RepeatedPtrField* const mutable_field) { - return internal::RepeatedPtrFieldBackInsertIterator(mutable_field); -} - -// Special back insert iterator for RepeatedPtrField instances, just in -// case someone wants to write generic template code that can access both -// RepeatedFields and RepeatedPtrFields using a common name. -template internal::RepeatedPtrFieldBackInsertIterator -RepeatedFieldBackInserter(RepeatedPtrField* const mutable_field) { - return internal::RepeatedPtrFieldBackInsertIterator(mutable_field); -} - -// Provides a back insert iterator for RepeatedPtrField instances -// similar to std::back_inserter() which transfers the ownership while -// copying elements. -template internal::AllocatedRepeatedPtrFieldBackInsertIterator -AllocatedRepeatedPtrFieldBackInserter( - RepeatedPtrField* const mutable_field) { - return internal::AllocatedRepeatedPtrFieldBackInsertIterator( - mutable_field); -} - -} // namespace protobuf - -} // namespace google -#endif // GOOGLE_PROTOBUF_REPEATED_FIELD_H__ diff --git a/modules/dnn/3rdparty/protobuf/src/google/protobuf/repeated_field_reflection_unittest.cc b/modules/dnn/3rdparty/protobuf/src/google/protobuf/repeated_field_reflection_unittest.cc deleted file mode 100644 index a40162d0b..000000000 --- a/modules/dnn/3rdparty/protobuf/src/google/protobuf/repeated_field_reflection_unittest.cc +++ /dev/null @@ -1,195 +0,0 @@ -// Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// http://code.google.com/p/protobuf/ -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -// Author: tgs@google.com (Tom Szymanski) -// -// Test reflection methods for aggregate access to Repeated[Ptr]Fields. -// This test proto2 methods on a proto2 layout. - -#include -#include -#include -#include -#include - -namespace google { -namespace protobuf { - -using unittest::ForeignMessage; -using unittest::TestAllTypes; -using unittest::TestAllExtensions; - -namespace { - -static int Func(int i, int j) { - return i * j; -} - -static string StrFunc(int i, int j) { - string str; - SStringPrintf(&str, "%d", Func(i, 4)); - return str; -} - - -TEST(RepeatedFieldReflectionTest, RegularFields) { - TestAllTypes message; - const Reflection* refl = message.GetReflection(); - const Descriptor* desc = message.GetDescriptor(); - - for (int i = 0; i < 10; ++i) { - message.add_repeated_int32(Func(i, 1)); - message.add_repeated_double(Func(i, 2)); - message.add_repeated_string(StrFunc(i, 5)); - message.add_repeated_foreign_message()->set_c(Func(i, 6)); - } - - // Get FieldDescriptors for all the fields of interest. - const FieldDescriptor* fd_repeated_int32 = - desc->FindFieldByName("repeated_int32"); - const FieldDescriptor* fd_repeated_double = - desc->FindFieldByName("repeated_double"); - const FieldDescriptor* fd_repeated_string = - desc->FindFieldByName("repeated_string"); - const FieldDescriptor* fd_repeated_foreign_message = - desc->FindFieldByName("repeated_foreign_message"); - - // Get RepeatedField objects for all fields of interest. - const RepeatedField& rf_int32 = - refl->GetRepeatedField(message, fd_repeated_int32); - const RepeatedField& rf_double = - refl->GetRepeatedField(message, fd_repeated_double); - - // Get mutable RepeatedField objects for all fields of interest. - RepeatedField* mrf_int32 = - refl->MutableRepeatedField(&message, fd_repeated_int32); - RepeatedField* mrf_double = - refl->MutableRepeatedField(&message, fd_repeated_double); - - // Get RepeatedPtrField objects for all fields of interest. - const RepeatedPtrField& rpf_string = - refl->GetRepeatedPtrField(message, fd_repeated_string); - const RepeatedPtrField& rpf_foreign_message = - refl->GetRepeatedPtrField( - message, fd_repeated_foreign_message); - const RepeatedPtrField& rpf_message = - refl->GetRepeatedPtrField( - message, fd_repeated_foreign_message); - - // Get mutable RepeatedPtrField objects for all fields of interest. - RepeatedPtrField* mrpf_string = - refl->MutableRepeatedPtrField(&message, fd_repeated_string); - RepeatedPtrField* mrpf_foreign_message = - refl->MutableRepeatedPtrField( - &message, fd_repeated_foreign_message); - RepeatedPtrField* mrpf_message = - refl->MutableRepeatedPtrField( - &message, fd_repeated_foreign_message); - - // Make sure we can do get and sets through the Repeated[Ptr]Field objects. - for (int i = 0; i < 10; ++i) { - // Check gets through const objects. - EXPECT_EQ(rf_int32.Get(i), Func(i, 1)); - EXPECT_EQ(rf_double.Get(i), Func(i, 2)); - EXPECT_EQ(rpf_string.Get(i), StrFunc(i, 5)); - EXPECT_EQ(rpf_foreign_message.Get(i).c(), Func(i, 6)); - EXPECT_EQ(down_cast(&rpf_message.Get(i))->c(), - Func(i, 6)); - - // Check gets through mutable objects. - EXPECT_EQ(mrf_int32->Get(i), Func(i, 1)); - EXPECT_EQ(mrf_double->Get(i), Func(i, 2)); - EXPECT_EQ(mrpf_string->Get(i), StrFunc(i, 5)); - EXPECT_EQ(mrpf_foreign_message->Get(i).c(), Func(i, 6)); - EXPECT_EQ(down_cast(&mrpf_message->Get(i))->c(), - Func(i, 6)); - - // Check sets through mutable objects. - mrf_int32->Set(i, Func(i, -1)); - mrf_double->Set(i, Func(i, -2)); - mrpf_string->Mutable(i)->assign(StrFunc(i, -5)); - mrpf_foreign_message->Mutable(i)->set_c(Func(i, -6)); - EXPECT_EQ(message.repeated_int32(i), Func(i, -1)); - EXPECT_EQ(message.repeated_double(i), Func(i, -2)); - EXPECT_EQ(message.repeated_string(i), StrFunc(i, -5)); - EXPECT_EQ(message.repeated_foreign_message(i).c(), Func(i, -6)); - down_cast(mrpf_message->Mutable(i))->set_c(Func(i, 7)); - EXPECT_EQ(message.repeated_foreign_message(i).c(), Func(i, 7)); - } - -#ifdef PROTOBUF_HAS_DEATH_TEST - // Make sure types are checked correctly at runtime. - const FieldDescriptor* fd_optional_int32 = - desc->FindFieldByName("optional_int32"); - EXPECT_DEATH(refl->GetRepeatedField( - message, fd_optional_int32), "requires a repeated field"); - EXPECT_DEATH(refl->GetRepeatedField( - message, fd_repeated_int32), "not the right type"); - EXPECT_DEATH(refl->GetRepeatedPtrField( - message, fd_repeated_foreign_message), "wrong submessage type"); -#endif // PROTOBUF_HAS_DEATH_TEST -} - - - - -TEST(RepeatedFieldReflectionTest, ExtensionFields) { - TestAllExtensions extended_message; - const Reflection* refl = extended_message.GetReflection(); - const Descriptor* desc = extended_message.GetDescriptor(); - - for (int i = 0; i < 10; ++i) { - extended_message.AddExtension( - unittest::repeated_int64_extension, Func(i, 1)); - } - - const FieldDescriptor* fd_repeated_int64_extension = - desc->file()->FindExtensionByName("repeated_int64_extension"); - GOOGLE_CHECK(fd_repeated_int64_extension != NULL); - - const RepeatedField& rf_int64_extension = - refl->GetRepeatedField(extended_message, - fd_repeated_int64_extension); - - RepeatedField* mrf_int64_extension = - refl->MutableRepeatedField(&extended_message, - fd_repeated_int64_extension); - - for (int i = 0; i < 10; ++i) { - EXPECT_EQ(Func(i, 1), rf_int64_extension.Get(i)); - mrf_int64_extension->Set(i, Func(i, -1)); - EXPECT_EQ(Func(i, -1), - extended_message.GetExtension(unittest::repeated_int64_extension, i)); - } -} - -} // namespace -} // namespace protobuf -} // namespace google diff --git a/modules/dnn/3rdparty/protobuf/src/google/protobuf/repeated_field_unittest.cc b/modules/dnn/3rdparty/protobuf/src/google/protobuf/repeated_field_unittest.cc deleted file mode 100644 index 257701eb3..000000000 --- a/modules/dnn/3rdparty/protobuf/src/google/protobuf/repeated_field_unittest.cc +++ /dev/null @@ -1,1357 +0,0 @@ -// Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// http://code.google.com/p/protobuf/ -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -// Author: kenton@google.com (Kenton Varda) -// Based on original Protocol Buffers design by -// Sanjay Ghemawat, Jeff Dean, and others. -// -// TODO(kenton): Improve this unittest to bring it up to the standards of -// other proto2 unittests. - -#include -#include -#include -#include - -#include - -#include -#include -#include -#include -#include -#include - -namespace google { -using protobuf_unittest::TestAllTypes; - -namespace protobuf { -namespace { - -// Test operations on a small RepeatedField. -TEST(RepeatedField, Small) { - RepeatedField field; - - EXPECT_EQ(field.size(), 0); - - field.Add(5); - - EXPECT_EQ(field.size(), 1); - EXPECT_EQ(field.Get(0), 5); - - field.Add(42); - - EXPECT_EQ(field.size(), 2); - EXPECT_EQ(field.Get(0), 5); - EXPECT_EQ(field.Get(1), 42); - - field.Set(1, 23); - - EXPECT_EQ(field.size(), 2); - EXPECT_EQ(field.Get(0), 5); - EXPECT_EQ(field.Get(1), 23); - - field.RemoveLast(); - - EXPECT_EQ(field.size(), 1); - EXPECT_EQ(field.Get(0), 5); - - field.Clear(); - - EXPECT_EQ(field.size(), 0); - int expected_usage = 4 * sizeof(int); - EXPECT_EQ(field.SpaceUsedExcludingSelf(), expected_usage); -} - - -// Test operations on a RepeatedField which is large enough to allocate a -// separate array. -TEST(RepeatedField, Large) { - RepeatedField field; - - for (int i = 0; i < 16; i++) { - field.Add(i * i); - } - - EXPECT_EQ(field.size(), 16); - - for (int i = 0; i < 16; i++) { - EXPECT_EQ(field.Get(i), i * i); - } - - int expected_usage = 16 * sizeof(int); - EXPECT_GE(field.SpaceUsedExcludingSelf(), expected_usage); -} - -// Test swapping between various types of RepeatedFields. -TEST(RepeatedField, SwapSmallSmall) { - RepeatedField field1; - RepeatedField field2; - - field1.Add(5); - field1.Add(42); - - field1.Swap(&field2); - - EXPECT_EQ(field1.size(), 0); - EXPECT_EQ(field2.size(), 2); - EXPECT_EQ(field2.Get(0), 5); - EXPECT_EQ(field2.Get(1), 42); -} - -TEST(RepeatedField, SwapLargeSmall) { - RepeatedField field1; - RepeatedField field2; - - for (int i = 0; i < 16; i++) { - field1.Add(i * i); - } - field2.Add(5); - field2.Add(42); - field1.Swap(&field2); - - EXPECT_EQ(field1.size(), 2); - EXPECT_EQ(field1.Get(0), 5); - EXPECT_EQ(field1.Get(1), 42); - EXPECT_EQ(field2.size(), 16); - for (int i = 0; i < 16; i++) { - EXPECT_EQ(field2.Get(i), i * i); - } -} - -TEST(RepeatedField, SwapLargeLarge) { - RepeatedField field1; - RepeatedField field2; - - field1.Add(5); - field1.Add(42); - for (int i = 0; i < 16; i++) { - field1.Add(i); - field2.Add(i * i); - } - field2.Swap(&field1); - - EXPECT_EQ(field1.size(), 16); - for (int i = 0; i < 16; i++) { - EXPECT_EQ(field1.Get(i), i * i); - } - EXPECT_EQ(field2.size(), 18); - EXPECT_EQ(field2.Get(0), 5); - EXPECT_EQ(field2.Get(1), 42); - for (int i = 2; i < 18; i++) { - EXPECT_EQ(field2.Get(i), i - 2); - } -} - -// Determines how much space was reserved by the given field by adding elements -// to it until it re-allocates its space. -static int ReservedSpace(RepeatedField* field) { - const int* ptr = field->data(); - do { - field->Add(0); - } while (field->data() == ptr); - - return field->size() - 1; -} - -TEST(RepeatedField, ReserveMoreThanDouble) { - // Reserve more than double the previous space in the field and expect the - // field to reserve exactly the amount specified. - RepeatedField field; - field.Reserve(20); - - EXPECT_EQ(20, ReservedSpace(&field)); -} - -TEST(RepeatedField, ReserveLessThanDouble) { - // Reserve less than double the previous space in the field and expect the - // field to grow by double instead. - RepeatedField field; - field.Reserve(20); - field.Reserve(30); - - EXPECT_EQ(40, ReservedSpace(&field)); -} - -TEST(RepeatedField, ReserveLessThanExisting) { - // Reserve less than the previous space in the field and expect the - // field to not re-allocate at all. - RepeatedField field; - field.Reserve(20); - const int* previous_ptr = field.data(); - field.Reserve(10); - - EXPECT_EQ(previous_ptr, field.data()); - EXPECT_EQ(20, ReservedSpace(&field)); -} - -TEST(RepeatedField, MergeFrom) { - RepeatedField source, destination; - source.Add(4); - source.Add(5); - destination.Add(1); - destination.Add(2); - destination.Add(3); - - destination.MergeFrom(source); - - ASSERT_EQ(5, destination.size()); - EXPECT_EQ(1, destination.Get(0)); - EXPECT_EQ(2, destination.Get(1)); - EXPECT_EQ(3, destination.Get(2)); - EXPECT_EQ(4, destination.Get(3)); - EXPECT_EQ(5, destination.Get(4)); -} - -TEST(RepeatedField, CopyFrom) { - RepeatedField source, destination; - source.Add(4); - source.Add(5); - destination.Add(1); - destination.Add(2); - destination.Add(3); - - destination.CopyFrom(source); - - ASSERT_EQ(2, destination.size()); - EXPECT_EQ(4, destination.Get(0)); - EXPECT_EQ(5, destination.Get(1)); -} - -TEST(RepeatedField, CopyConstruct) { - RepeatedField source; - source.Add(1); - source.Add(2); - - RepeatedField destination(source); - - ASSERT_EQ(2, destination.size()); - EXPECT_EQ(1, destination.Get(0)); - EXPECT_EQ(2, destination.Get(1)); -} - -TEST(RepeatedField, IteratorConstruct) { - vector values; - values.push_back(1); - values.push_back(2); - - RepeatedField field(values.begin(), values.end()); - ASSERT_EQ(values.size(), field.size()); - EXPECT_EQ(values[0], field.Get(0)); - EXPECT_EQ(values[1], field.Get(1)); - - RepeatedField other(field.begin(), field.end()); - ASSERT_EQ(values.size(), other.size()); - EXPECT_EQ(values[0], other.Get(0)); - EXPECT_EQ(values[1], other.Get(1)); -} - -TEST(RepeatedField, CopyAssign) { - RepeatedField source, destination; - source.Add(4); - source.Add(5); - destination.Add(1); - destination.Add(2); - destination.Add(3); - - destination = source; - - ASSERT_EQ(2, destination.size()); - EXPECT_EQ(4, destination.Get(0)); - EXPECT_EQ(5, destination.Get(1)); -} - -TEST(RepeatedField, SelfAssign) { - // Verify that assignment to self does not destroy data. - RepeatedField source, *p; - p = &source; - source.Add(7); - source.Add(8); - - *p = source; - - ASSERT_EQ(2, source.size()); - EXPECT_EQ(7, source.Get(0)); - EXPECT_EQ(8, source.Get(1)); -} - -TEST(RepeatedField, MutableDataIsMutable) { - RepeatedField field; - field.Add(1); - EXPECT_EQ(1, field.Get(0)); - // The fact that this line compiles would be enough, but we'll check the - // value anyway. - *field.mutable_data() = 2; - EXPECT_EQ(2, field.Get(0)); -} - -TEST(RepeatedField, Truncate) { - RepeatedField field; - - field.Add(12); - field.Add(34); - field.Add(56); - field.Add(78); - EXPECT_EQ(4, field.size()); - - field.Truncate(3); - EXPECT_EQ(3, field.size()); - - field.Add(90); - EXPECT_EQ(4, field.size()); - EXPECT_EQ(90, field.Get(3)); - - // Truncations that don't change the size are allowed, but growing is not - // allowed. - field.Truncate(field.size()); -#ifdef PROTOBUF_HAS_DEATH_TEST - EXPECT_DEBUG_DEATH(field.Truncate(field.size() + 1), "new_size"); -#endif -} - - -TEST(RepeatedField, ExtractSubrange) { - // Exhaustively test every subrange in arrays of all sizes from 0 through 9. - for (int sz = 0; sz < 10; ++sz) { - for (int num = 0; num <= sz; ++num) { - for (int start = 0; start < sz - num; ++start) { - // Create RepeatedField with sz elements having values 0 through sz-1. - RepeatedField field; - for (int i = 0; i < sz; ++i) - field.Add(i); - EXPECT_EQ(field.size(), sz); - - // Create a catcher array and call ExtractSubrange. - int32 catcher[10]; - for (int i = 0; i < 10; ++i) - catcher[i] = -1; - field.ExtractSubrange(start, num, catcher); - - // Does the resulting array have the right size? - EXPECT_EQ(field.size(), sz - num); - - // Were the removed elements extracted into the catcher array? - for (int i = 0; i < num; ++i) - EXPECT_EQ(catcher[i], start + i); - EXPECT_EQ(catcher[num], -1); - - // Does the resulting array contain the right values? - for (int i = 0; i < start; ++i) - EXPECT_EQ(field.Get(i), i); - for (int i = start; i < field.size(); ++i) - EXPECT_EQ(field.Get(i), i + num); - } - } - } -} - -// =================================================================== -// RepeatedPtrField tests. These pretty much just mirror the RepeatedField -// tests above. - -TEST(RepeatedPtrField, Small) { - RepeatedPtrField field; - - EXPECT_EQ(field.size(), 0); - - field.Add()->assign("foo"); - - EXPECT_EQ(field.size(), 1); - EXPECT_EQ(field.Get(0), "foo"); - - field.Add()->assign("bar"); - - EXPECT_EQ(field.size(), 2); - EXPECT_EQ(field.Get(0), "foo"); - EXPECT_EQ(field.Get(1), "bar"); - - field.Mutable(1)->assign("baz"); - - EXPECT_EQ(field.size(), 2); - EXPECT_EQ(field.Get(0), "foo"); - EXPECT_EQ(field.Get(1), "baz"); - - field.RemoveLast(); - - EXPECT_EQ(field.size(), 1); - EXPECT_EQ(field.Get(0), "foo"); - - field.Clear(); - - EXPECT_EQ(field.size(), 0); -} - - -TEST(RepeatedPtrField, Large) { - RepeatedPtrField field; - - for (int i = 0; i < 16; i++) { - *field.Add() += 'a' + i; - } - - EXPECT_EQ(field.size(), 16); - - for (int i = 0; i < 16; i++) { - EXPECT_EQ(field.Get(i).size(), 1); - EXPECT_EQ(field.Get(i)[0], 'a' + i); - } - - int min_expected_usage = 16 * sizeof(string); - EXPECT_GE(field.SpaceUsedExcludingSelf(), min_expected_usage); -} - -TEST(RepeatedPtrField, SwapSmallSmall) { - RepeatedPtrField field1; - RepeatedPtrField field2; - - field1.Add()->assign("foo"); - field1.Add()->assign("bar"); - field1.Swap(&field2); - - EXPECT_EQ(field1.size(), 0); - EXPECT_EQ(field2.size(), 2); - EXPECT_EQ(field2.Get(0), "foo"); - EXPECT_EQ(field2.Get(1), "bar"); -} - -TEST(RepeatedPtrField, SwapLargeSmall) { - RepeatedPtrField field1; - RepeatedPtrField field2; - - field2.Add()->assign("foo"); - field2.Add()->assign("bar"); - for (int i = 0; i < 16; i++) { - *field1.Add() += 'a' + i; - } - field1.Swap(&field2); - - EXPECT_EQ(field1.size(), 2); - EXPECT_EQ(field1.Get(0), "foo"); - EXPECT_EQ(field1.Get(1), "bar"); - EXPECT_EQ(field2.size(), 16); - for (int i = 0; i < 16; i++) { - EXPECT_EQ(field2.Get(i).size(), 1); - EXPECT_EQ(field2.Get(i)[0], 'a' + i); - } -} - -TEST(RepeatedPtrField, SwapLargeLarge) { - RepeatedPtrField field1; - RepeatedPtrField field2; - - field1.Add()->assign("foo"); - field1.Add()->assign("bar"); - for (int i = 0; i < 16; i++) { - *field1.Add() += 'A' + i; - *field2.Add() += 'a' + i; - } - field2.Swap(&field1); - - EXPECT_EQ(field1.size(), 16); - for (int i = 0; i < 16; i++) { - EXPECT_EQ(field1.Get(i).size(), 1); - EXPECT_EQ(field1.Get(i)[0], 'a' + i); - } - EXPECT_EQ(field2.size(), 18); - EXPECT_EQ(field2.Get(0), "foo"); - EXPECT_EQ(field2.Get(1), "bar"); - for (int i = 2; i < 18; i++) { - EXPECT_EQ(field2.Get(i).size(), 1); - EXPECT_EQ(field2.Get(i)[0], 'A' + i - 2); - } -} - -static int ReservedSpace(RepeatedPtrField* field) { - const string* const* ptr = field->data(); - do { - field->Add(); - } while (field->data() == ptr); - - return field->size() - 1; -} - -TEST(RepeatedPtrField, ReserveMoreThanDouble) { - RepeatedPtrField field; - field.Reserve(20); - - EXPECT_EQ(20, ReservedSpace(&field)); -} - -TEST(RepeatedPtrField, ReserveLessThanDouble) { - RepeatedPtrField field; - field.Reserve(20); - field.Reserve(30); - - EXPECT_EQ(40, ReservedSpace(&field)); -} - -TEST(RepeatedPtrField, ReserveLessThanExisting) { - RepeatedPtrField field; - field.Reserve(20); - const string* const* previous_ptr = field.data(); - field.Reserve(10); - - EXPECT_EQ(previous_ptr, field.data()); - EXPECT_EQ(20, ReservedSpace(&field)); -} - -TEST(RepeatedPtrField, ReserveDoesntLoseAllocated) { - // Check that a bug is fixed: An earlier implementation of Reserve() - // failed to copy pointers to allocated-but-cleared objects, possibly - // leading to segfaults. - RepeatedPtrField field; - string* first = field.Add(); - field.RemoveLast(); - - field.Reserve(20); - EXPECT_EQ(first, field.Add()); -} - -// Clearing elements is tricky with RepeatedPtrFields since the memory for -// the elements is retained and reused. -TEST(RepeatedPtrField, ClearedElements) { - RepeatedPtrField field; - - string* original = field.Add(); - *original = "foo"; - - EXPECT_EQ(field.ClearedCount(), 0); - - field.RemoveLast(); - EXPECT_TRUE(original->empty()); - EXPECT_EQ(field.ClearedCount(), 1); - - EXPECT_EQ(field.Add(), original); // Should return same string for reuse. - - EXPECT_EQ(field.ReleaseLast(), original); // We take ownership. - EXPECT_EQ(field.ClearedCount(), 0); - - EXPECT_NE(field.Add(), original); // Should NOT return the same string. - EXPECT_EQ(field.ClearedCount(), 0); - - field.AddAllocated(original); // Give ownership back. - EXPECT_EQ(field.ClearedCount(), 0); - EXPECT_EQ(field.Mutable(1), original); - - field.Clear(); - EXPECT_EQ(field.ClearedCount(), 2); - EXPECT_EQ(field.ReleaseCleared(), original); // Take ownership again. - EXPECT_EQ(field.ClearedCount(), 1); - EXPECT_NE(field.Add(), original); - EXPECT_EQ(field.ClearedCount(), 0); - EXPECT_NE(field.Add(), original); - EXPECT_EQ(field.ClearedCount(), 0); - - field.AddCleared(original); // Give ownership back, but as a cleared object. - EXPECT_EQ(field.ClearedCount(), 1); - EXPECT_EQ(field.Add(), original); - EXPECT_EQ(field.ClearedCount(), 0); -} - -// Test all code paths in AddAllocated(). -TEST(RepeatedPtrField, AddAlocated) { - RepeatedPtrField field; - while (field.size() < field.Capacity()) { - field.Add()->assign("filler"); - } - - int index = field.size(); - - // First branch: Field is at capacity with no cleared objects. - string* foo = new string("foo"); - field.AddAllocated(foo); - EXPECT_EQ(index + 1, field.size()); - EXPECT_EQ(0, field.ClearedCount()); - EXPECT_EQ(foo, &field.Get(index)); - - // Last branch: Field is not at capacity and there are no cleared objects. - string* bar = new string("bar"); - field.AddAllocated(bar); - ++index; - EXPECT_EQ(index + 1, field.size()); - EXPECT_EQ(0, field.ClearedCount()); - EXPECT_EQ(bar, &field.Get(index)); - - // Third branch: Field is not at capacity and there are no cleared objects. - field.RemoveLast(); - string* baz = new string("baz"); - field.AddAllocated(baz); - EXPECT_EQ(index + 1, field.size()); - EXPECT_EQ(1, field.ClearedCount()); - EXPECT_EQ(baz, &field.Get(index)); - - // Second branch: Field is at capacity but has some cleared objects. - while (field.size() < field.Capacity()) { - field.Add()->assign("filler2"); - } - field.RemoveLast(); - index = field.size(); - string* qux = new string("qux"); - field.AddAllocated(qux); - EXPECT_EQ(index + 1, field.size()); - // We should have discarded the cleared object. - EXPECT_EQ(0, field.ClearedCount()); - EXPECT_EQ(qux, &field.Get(index)); -} - -TEST(RepeatedPtrField, MergeFrom) { - RepeatedPtrField source, destination; - source.Add()->assign("4"); - source.Add()->assign("5"); - destination.Add()->assign("1"); - destination.Add()->assign("2"); - destination.Add()->assign("3"); - - destination.MergeFrom(source); - - ASSERT_EQ(5, destination.size()); - EXPECT_EQ("1", destination.Get(0)); - EXPECT_EQ("2", destination.Get(1)); - EXPECT_EQ("3", destination.Get(2)); - EXPECT_EQ("4", destination.Get(3)); - EXPECT_EQ("5", destination.Get(4)); -} - -TEST(RepeatedPtrField, CopyFrom) { - RepeatedPtrField source, destination; - source.Add()->assign("4"); - source.Add()->assign("5"); - destination.Add()->assign("1"); - destination.Add()->assign("2"); - destination.Add()->assign("3"); - - destination.CopyFrom(source); - - ASSERT_EQ(2, destination.size()); - EXPECT_EQ("4", destination.Get(0)); - EXPECT_EQ("5", destination.Get(1)); -} - -TEST(RepeatedPtrField, CopyConstruct) { - RepeatedPtrField source; - source.Add()->assign("1"); - source.Add()->assign("2"); - - RepeatedPtrField destination(source); - - ASSERT_EQ(2, destination.size()); - EXPECT_EQ("1", destination.Get(0)); - EXPECT_EQ("2", destination.Get(1)); -} - -TEST(RepeatedPtrField, IteratorConstruct_String) { - vector values; - values.push_back("1"); - values.push_back("2"); - - RepeatedPtrField field(values.begin(), values.end()); - ASSERT_EQ(values.size(), field.size()); - EXPECT_EQ(values[0], field.Get(0)); - EXPECT_EQ(values[1], field.Get(1)); - - RepeatedPtrField other(field.begin(), field.end()); - ASSERT_EQ(values.size(), other.size()); - EXPECT_EQ(values[0], other.Get(0)); - EXPECT_EQ(values[1], other.Get(1)); -} - -TEST(RepeatedPtrField, IteratorConstruct_Proto) { - typedef TestAllTypes::NestedMessage Nested; - vector values; - values.push_back(Nested()); - values.back().set_bb(1); - values.push_back(Nested()); - values.back().set_bb(2); - - RepeatedPtrField field(values.begin(), values.end()); - ASSERT_EQ(values.size(), field.size()); - EXPECT_EQ(values[0].bb(), field.Get(0).bb()); - EXPECT_EQ(values[1].bb(), field.Get(1).bb()); - - RepeatedPtrField other(field.begin(), field.end()); - ASSERT_EQ(values.size(), other.size()); - EXPECT_EQ(values[0].bb(), other.Get(0).bb()); - EXPECT_EQ(values[1].bb(), other.Get(1).bb()); -} - -TEST(RepeatedPtrField, CopyAssign) { - RepeatedPtrField source, destination; - source.Add()->assign("4"); - source.Add()->assign("5"); - destination.Add()->assign("1"); - destination.Add()->assign("2"); - destination.Add()->assign("3"); - - destination = source; - - ASSERT_EQ(2, destination.size()); - EXPECT_EQ("4", destination.Get(0)); - EXPECT_EQ("5", destination.Get(1)); -} - -TEST(RepeatedPtrField, SelfAssign) { - // Verify that assignment to self does not destroy data. - RepeatedPtrField source, *p; - p = &source; - source.Add()->assign("7"); - source.Add()->assign("8"); - - *p = source; - - ASSERT_EQ(2, source.size()); - EXPECT_EQ("7", source.Get(0)); - EXPECT_EQ("8", source.Get(1)); -} - -TEST(RepeatedPtrField, MutableDataIsMutable) { - RepeatedPtrField field; - *field.Add() = "1"; - EXPECT_EQ("1", field.Get(0)); - // The fact that this line compiles would be enough, but we'll check the - // value anyway. - string** data = field.mutable_data(); - **data = "2"; - EXPECT_EQ("2", field.Get(0)); -} - -TEST(RepeatedPtrField, ExtractSubrange) { - // Exhaustively test every subrange in arrays of all sizes from 0 through 9 - // with 0 through 3 cleared elements at the end. - for (int sz = 0; sz < 10; ++sz) { - for (int num = 0; num <= sz; ++num) { - for (int start = 0; start < sz - num; ++start) { - for (int extra = 0; extra < 4; ++extra) { - vector subject; - - // Create an array with "sz" elements and "extra" cleared elements. - RepeatedPtrField field; - for (int i = 0; i < sz + extra; ++i) { - subject.push_back(new string()); - field.AddAllocated(subject[i]); - } - EXPECT_EQ(field.size(), sz + extra); - for (int i = 0; i < extra; ++i) - field.RemoveLast(); - EXPECT_EQ(field.size(), sz); - EXPECT_EQ(field.ClearedCount(), extra); - - // Create a catcher array and call ExtractSubrange. - string* catcher[10]; - for (int i = 0; i < 10; ++i) - catcher[i] = NULL; - field.ExtractSubrange(start, num, catcher); - - // Does the resulting array have the right size? - EXPECT_EQ(field.size(), sz - num); - - // Were the removed elements extracted into the catcher array? - for (int i = 0; i < num; ++i) - EXPECT_EQ(catcher[i], subject[start + i]); - EXPECT_EQ(NULL, catcher[num]); - - // Does the resulting array contain the right values? - for (int i = 0; i < start; ++i) - EXPECT_EQ(field.Mutable(i), subject[i]); - for (int i = start; i < field.size(); ++i) - EXPECT_EQ(field.Mutable(i), subject[i + num]); - - // Reinstate the cleared elements. - EXPECT_EQ(field.ClearedCount(), extra); - for (int i = 0; i < extra; ++i) - field.Add(); - EXPECT_EQ(field.ClearedCount(), 0); - EXPECT_EQ(field.size(), sz - num + extra); - - // Make sure the extra elements are all there (in some order). - for (int i = sz; i < sz + extra; ++i) { - int count = 0; - for (int j = sz; j < sz + extra; ++j) { - if (field.Mutable(j - num) == subject[i]) - count += 1; - } - EXPECT_EQ(count, 1); - } - - // Release the caught elements. - for (int i = 0; i < num; ++i) - delete catcher[i]; - } - } - } - } -} - -TEST(RepeatedPtrField, DeleteSubrange) { - // DeleteSubrange is a trivial extension of ExtendSubrange. -} - -// =================================================================== - -// Iterator tests stolen from net/proto/proto-array_unittest. -class RepeatedFieldIteratorTest : public testing::Test { - protected: - virtual void SetUp() { - for (int i = 0; i < 3; ++i) { - proto_array_.Add(i); - } - } - - RepeatedField proto_array_; -}; - -TEST_F(RepeatedFieldIteratorTest, Convertible) { - RepeatedField::iterator iter = proto_array_.begin(); - RepeatedField::const_iterator c_iter = iter; - RepeatedField::value_type value = *c_iter; - EXPECT_EQ(0, value); -} - -TEST_F(RepeatedFieldIteratorTest, MutableIteration) { - RepeatedField::iterator iter = proto_array_.begin(); - EXPECT_EQ(0, *iter); - ++iter; - EXPECT_EQ(1, *iter++); - EXPECT_EQ(2, *iter); - ++iter; - EXPECT_TRUE(proto_array_.end() == iter); - - EXPECT_EQ(2, *(proto_array_.end() - 1)); -} - -TEST_F(RepeatedFieldIteratorTest, ConstIteration) { - const RepeatedField& const_proto_array = proto_array_; - RepeatedField::const_iterator iter = const_proto_array.begin(); - EXPECT_EQ(0, *iter); - ++iter; - EXPECT_EQ(1, *iter++); - EXPECT_EQ(2, *iter); - ++iter; - EXPECT_TRUE(proto_array_.end() == iter); - EXPECT_EQ(2, *(proto_array_.end() - 1)); -} - -TEST_F(RepeatedFieldIteratorTest, Mutation) { - RepeatedField::iterator iter = proto_array_.begin(); - *iter = 7; - EXPECT_EQ(7, proto_array_.Get(0)); -} - -// ------------------------------------------------------------------- - -class RepeatedPtrFieldIteratorTest : public testing::Test { - protected: - virtual void SetUp() { - proto_array_.Add()->assign("foo"); - proto_array_.Add()->assign("bar"); - proto_array_.Add()->assign("baz"); - } - - RepeatedPtrField proto_array_; -}; - -TEST_F(RepeatedPtrFieldIteratorTest, Convertible) { - RepeatedPtrField::iterator iter = proto_array_.begin(); - RepeatedPtrField::const_iterator c_iter = iter; - RepeatedPtrField::value_type value = *c_iter; - EXPECT_EQ("foo", value); -} - -TEST_F(RepeatedPtrFieldIteratorTest, MutableIteration) { - RepeatedPtrField::iterator iter = proto_array_.begin(); - EXPECT_EQ("foo", *iter); - ++iter; - EXPECT_EQ("bar", *(iter++)); - EXPECT_EQ("baz", *iter); - ++iter; - EXPECT_TRUE(proto_array_.end() == iter); - EXPECT_EQ("baz", *(--proto_array_.end())); -} - -TEST_F(RepeatedPtrFieldIteratorTest, ConstIteration) { - const RepeatedPtrField& const_proto_array = proto_array_; - RepeatedPtrField::const_iterator iter = const_proto_array.begin(); - EXPECT_EQ("foo", *iter); - ++iter; - EXPECT_EQ("bar", *(iter++)); - EXPECT_EQ("baz", *iter); - ++iter; - EXPECT_TRUE(const_proto_array.end() == iter); - EXPECT_EQ("baz", *(--const_proto_array.end())); -} - -TEST_F(RepeatedPtrFieldIteratorTest, MutableReverseIteration) { - RepeatedPtrField::reverse_iterator iter = proto_array_.rbegin(); - EXPECT_EQ("baz", *iter); - ++iter; - EXPECT_EQ("bar", *(iter++)); - EXPECT_EQ("foo", *iter); - ++iter; - EXPECT_TRUE(proto_array_.rend() == iter); - EXPECT_EQ("foo", *(--proto_array_.rend())); -} - -TEST_F(RepeatedPtrFieldIteratorTest, ConstReverseIteration) { - const RepeatedPtrField& const_proto_array = proto_array_; - RepeatedPtrField::const_reverse_iterator iter - = const_proto_array.rbegin(); - EXPECT_EQ("baz", *iter); - ++iter; - EXPECT_EQ("bar", *(iter++)); - EXPECT_EQ("foo", *iter); - ++iter; - EXPECT_TRUE(const_proto_array.rend() == iter); - EXPECT_EQ("foo", *(--const_proto_array.rend())); -} - -TEST_F(RepeatedPtrFieldIteratorTest, RandomAccess) { - RepeatedPtrField::iterator iter = proto_array_.begin(); - RepeatedPtrField::iterator iter2 = iter; - ++iter2; - ++iter2; - EXPECT_TRUE(iter + 2 == iter2); - EXPECT_TRUE(iter == iter2 - 2); - EXPECT_EQ("baz", iter[2]); - EXPECT_EQ("baz", *(iter + 2)); - EXPECT_EQ(3, proto_array_.end() - proto_array_.begin()); -} - -TEST_F(RepeatedPtrFieldIteratorTest, Comparable) { - RepeatedPtrField::const_iterator iter = proto_array_.begin(); - RepeatedPtrField::const_iterator iter2 = iter + 1; - EXPECT_TRUE(iter == iter); - EXPECT_TRUE(iter != iter2); - EXPECT_TRUE(iter < iter2); - EXPECT_TRUE(iter <= iter2); - EXPECT_TRUE(iter <= iter); - EXPECT_TRUE(iter2 > iter); - EXPECT_TRUE(iter2 >= iter); - EXPECT_TRUE(iter >= iter); -} - -// Uninitialized iterator does not point to any of the RepeatedPtrField. -TEST_F(RepeatedPtrFieldIteratorTest, UninitializedIterator) { - RepeatedPtrField::iterator iter; - EXPECT_TRUE(iter != proto_array_.begin()); - EXPECT_TRUE(iter != proto_array_.begin() + 1); - EXPECT_TRUE(iter != proto_array_.begin() + 2); - EXPECT_TRUE(iter != proto_array_.begin() + 3); - EXPECT_TRUE(iter != proto_array_.end()); -} - -TEST_F(RepeatedPtrFieldIteratorTest, STLAlgorithms_lower_bound) { - proto_array_.Clear(); - proto_array_.Add()->assign("a"); - proto_array_.Add()->assign("c"); - proto_array_.Add()->assign("d"); - proto_array_.Add()->assign("n"); - proto_array_.Add()->assign("p"); - proto_array_.Add()->assign("x"); - proto_array_.Add()->assign("y"); - - string v = "f"; - RepeatedPtrField::const_iterator it = - lower_bound(proto_array_.begin(), proto_array_.end(), v); - - EXPECT_EQ(*it, "n"); - EXPECT_TRUE(it == proto_array_.begin() + 3); -} - -TEST_F(RepeatedPtrFieldIteratorTest, Mutation) { - RepeatedPtrField::iterator iter = proto_array_.begin(); - *iter = "qux"; - EXPECT_EQ("qux", proto_array_.Get(0)); -} - -// ------------------------------------------------------------------- - -class RepeatedPtrFieldPtrsIteratorTest : public testing::Test { - protected: - virtual void SetUp() { - proto_array_.Add()->assign("foo"); - proto_array_.Add()->assign("bar"); - proto_array_.Add()->assign("baz"); - const_proto_array_ = &proto_array_; - } - - RepeatedPtrField proto_array_; - const RepeatedPtrField* const_proto_array_; -}; - -TEST_F(RepeatedPtrFieldPtrsIteratorTest, ConvertiblePtr) { - RepeatedPtrField::pointer_iterator iter = - proto_array_.pointer_begin(); - (void) iter; -} - -TEST_F(RepeatedPtrFieldPtrsIteratorTest, ConvertibleConstPtr) { - RepeatedPtrField::const_pointer_iterator iter = - const_proto_array_->pointer_begin(); - (void) iter; -} - -TEST_F(RepeatedPtrFieldPtrsIteratorTest, MutablePtrIteration) { - RepeatedPtrField::pointer_iterator iter = - proto_array_.pointer_begin(); - EXPECT_EQ("foo", **iter); - ++iter; - EXPECT_EQ("bar", **(iter++)); - EXPECT_EQ("baz", **iter); - ++iter; - EXPECT_TRUE(proto_array_.pointer_end() == iter); - EXPECT_EQ("baz", **(--proto_array_.pointer_end())); -} - -TEST_F(RepeatedPtrFieldPtrsIteratorTest, MutableConstPtrIteration) { - RepeatedPtrField::const_pointer_iterator iter = - const_proto_array_->pointer_begin(); - EXPECT_EQ("foo", **iter); - ++iter; - EXPECT_EQ("bar", **(iter++)); - EXPECT_EQ("baz", **iter); - ++iter; - EXPECT_TRUE(const_proto_array_->pointer_end() == iter); - EXPECT_EQ("baz", **(--const_proto_array_->pointer_end())); -} - -TEST_F(RepeatedPtrFieldPtrsIteratorTest, RandomPtrAccess) { - RepeatedPtrField::pointer_iterator iter = - proto_array_.pointer_begin(); - RepeatedPtrField::pointer_iterator iter2 = iter; - ++iter2; - ++iter2; - EXPECT_TRUE(iter + 2 == iter2); - EXPECT_TRUE(iter == iter2 - 2); - EXPECT_EQ("baz", *iter[2]); - EXPECT_EQ("baz", **(iter + 2)); - EXPECT_EQ(3, proto_array_.end() - proto_array_.begin()); -} - -TEST_F(RepeatedPtrFieldPtrsIteratorTest, RandomConstPtrAccess) { - RepeatedPtrField::const_pointer_iterator iter = - const_proto_array_->pointer_begin(); - RepeatedPtrField::const_pointer_iterator iter2 = iter; - ++iter2; - ++iter2; - EXPECT_TRUE(iter + 2 == iter2); - EXPECT_TRUE(iter == iter2 - 2); - EXPECT_EQ("baz", *iter[2]); - EXPECT_EQ("baz", **(iter + 2)); - EXPECT_EQ(3, const_proto_array_->end() - const_proto_array_->begin()); -} - -TEST_F(RepeatedPtrFieldPtrsIteratorTest, ComparablePtr) { - RepeatedPtrField::pointer_iterator iter = - proto_array_.pointer_begin(); - RepeatedPtrField::pointer_iterator iter2 = iter + 1; - EXPECT_TRUE(iter == iter); - EXPECT_TRUE(iter != iter2); - EXPECT_TRUE(iter < iter2); - EXPECT_TRUE(iter <= iter2); - EXPECT_TRUE(iter <= iter); - EXPECT_TRUE(iter2 > iter); - EXPECT_TRUE(iter2 >= iter); - EXPECT_TRUE(iter >= iter); -} - -TEST_F(RepeatedPtrFieldPtrsIteratorTest, ComparableConstPtr) { - RepeatedPtrField::const_pointer_iterator iter = - const_proto_array_->pointer_begin(); - RepeatedPtrField::const_pointer_iterator iter2 = iter + 1; - EXPECT_TRUE(iter == iter); - EXPECT_TRUE(iter != iter2); - EXPECT_TRUE(iter < iter2); - EXPECT_TRUE(iter <= iter2); - EXPECT_TRUE(iter <= iter); - EXPECT_TRUE(iter2 > iter); - EXPECT_TRUE(iter2 >= iter); - EXPECT_TRUE(iter >= iter); -} - -// Uninitialized iterator does not point to any of the RepeatedPtrOverPtrs. -// Dereferencing an uninitialized iterator crashes the process. -TEST_F(RepeatedPtrFieldPtrsIteratorTest, UninitializedPtrIterator) { - RepeatedPtrField::pointer_iterator iter; - EXPECT_TRUE(iter != proto_array_.pointer_begin()); - EXPECT_TRUE(iter != proto_array_.pointer_begin() + 1); - EXPECT_TRUE(iter != proto_array_.pointer_begin() + 2); - EXPECT_TRUE(iter != proto_array_.pointer_begin() + 3); - EXPECT_TRUE(iter != proto_array_.pointer_end()); -} - -TEST_F(RepeatedPtrFieldPtrsIteratorTest, UninitializedConstPtrIterator) { - RepeatedPtrField::const_pointer_iterator iter; - EXPECT_TRUE(iter != const_proto_array_->pointer_begin()); - EXPECT_TRUE(iter != const_proto_array_->pointer_begin() + 1); - EXPECT_TRUE(iter != const_proto_array_->pointer_begin() + 2); - EXPECT_TRUE(iter != const_proto_array_->pointer_begin() + 3); - EXPECT_TRUE(iter != const_proto_array_->pointer_end()); -} - -// This comparison functor is required by the tests for RepeatedPtrOverPtrs. -// They operate on strings and need to compare strings as strings in -// any stl algorithm, even though the iterator returns a pointer to a string -// - i.e. *iter has type string*. -struct StringLessThan { - bool operator()(const string* z, const string& y) { - return *z < y; - } - bool operator()(const string* z, const string* y) { - return *z < *y; - } -}; - -TEST_F(RepeatedPtrFieldPtrsIteratorTest, PtrSTLAlgorithms_lower_bound) { - proto_array_.Clear(); - proto_array_.Add()->assign("a"); - proto_array_.Add()->assign("c"); - proto_array_.Add()->assign("d"); - proto_array_.Add()->assign("n"); - proto_array_.Add()->assign("p"); - proto_array_.Add()->assign("x"); - proto_array_.Add()->assign("y"); - - { - string v = "f"; - RepeatedPtrField::pointer_iterator it = - lower_bound(proto_array_.pointer_begin(), proto_array_.pointer_end(), - &v, StringLessThan()); - - GOOGLE_CHECK(*it != NULL); - - EXPECT_EQ(**it, "n"); - EXPECT_TRUE(it == proto_array_.pointer_begin() + 3); - } - { - string v = "f"; - RepeatedPtrField::const_pointer_iterator it = - lower_bound(const_proto_array_->pointer_begin(), - const_proto_array_->pointer_end(), - &v, StringLessThan()); - - GOOGLE_CHECK(*it != NULL); - - EXPECT_EQ(**it, "n"); - EXPECT_TRUE(it == const_proto_array_->pointer_begin() + 3); - } -} - -TEST_F(RepeatedPtrFieldPtrsIteratorTest, PtrMutation) { - RepeatedPtrField::pointer_iterator iter = - proto_array_.pointer_begin(); - **iter = "qux"; - EXPECT_EQ("qux", proto_array_.Get(0)); - - EXPECT_EQ("bar", proto_array_.Get(1)); - EXPECT_EQ("baz", proto_array_.Get(2)); - ++iter; - delete *iter; - *iter = new string("a"); - ++iter; - delete *iter; - *iter = new string("b"); - EXPECT_EQ("a", proto_array_.Get(1)); - EXPECT_EQ("b", proto_array_.Get(2)); -} - -TEST_F(RepeatedPtrFieldPtrsIteratorTest, Sort) { - proto_array_.Add()->assign("c"); - proto_array_.Add()->assign("d"); - proto_array_.Add()->assign("n"); - proto_array_.Add()->assign("p"); - proto_array_.Add()->assign("a"); - proto_array_.Add()->assign("y"); - proto_array_.Add()->assign("x"); - EXPECT_EQ("foo", proto_array_.Get(0)); - EXPECT_EQ("n", proto_array_.Get(5)); - EXPECT_EQ("x", proto_array_.Get(9)); - sort(proto_array_.pointer_begin(), - proto_array_.pointer_end(), - StringLessThan()); - EXPECT_EQ("a", proto_array_.Get(0)); - EXPECT_EQ("baz", proto_array_.Get(2)); - EXPECT_EQ("y", proto_array_.Get(9)); -} - - -// ----------------------------------------------------------------------------- -// Unit-tests for the insert iterators -// google::protobuf::RepeatedFieldBackInserter, -// google::protobuf::AllocatedRepeatedPtrFieldBackInserter -// Ported from util/gtl/proto-array-iterators_unittest. - -class RepeatedFieldInsertionIteratorsTest : public testing::Test { - protected: - std::list halves; - std::list fibonacci; - std::vector words; - typedef TestAllTypes::NestedMessage Nested; - Nested nesteds[2]; - std::vector nested_ptrs; - TestAllTypes protobuffer; - - virtual void SetUp() { - fibonacci.push_back(1); - fibonacci.push_back(1); - fibonacci.push_back(2); - fibonacci.push_back(3); - fibonacci.push_back(5); - fibonacci.push_back(8); - std::copy(fibonacci.begin(), fibonacci.end(), - RepeatedFieldBackInserter(protobuffer.mutable_repeated_int32())); - - halves.push_back(1.0); - halves.push_back(0.5); - halves.push_back(0.25); - halves.push_back(0.125); - halves.push_back(0.0625); - std::copy(halves.begin(), halves.end(), - RepeatedFieldBackInserter(protobuffer.mutable_repeated_double())); - - words.push_back("Able"); - words.push_back("was"); - words.push_back("I"); - words.push_back("ere"); - words.push_back("I"); - words.push_back("saw"); - words.push_back("Elba"); - std::copy(words.begin(), words.end(), - RepeatedFieldBackInserter(protobuffer.mutable_repeated_string())); - - nesteds[0].set_bb(17); - nesteds[1].set_bb(4711); - std::copy(&nesteds[0], &nesteds[2], - RepeatedFieldBackInserter( - protobuffer.mutable_repeated_nested_message())); - - nested_ptrs.push_back(new Nested); - nested_ptrs.back()->set_bb(170); - nested_ptrs.push_back(new Nested); - nested_ptrs.back()->set_bb(47110); - std::copy(nested_ptrs.begin(), nested_ptrs.end(), - RepeatedFieldBackInserter( - protobuffer.mutable_repeated_nested_message())); - - } - - virtual void TearDown() { - STLDeleteContainerPointers(nested_ptrs.begin(), nested_ptrs.end()); - } -}; - -TEST_F(RepeatedFieldInsertionIteratorsTest, Fibonacci) { - EXPECT_TRUE(std::equal(fibonacci.begin(), - fibonacci.end(), - protobuffer.repeated_int32().begin())); - EXPECT_TRUE(std::equal(protobuffer.repeated_int32().begin(), - protobuffer.repeated_int32().end(), - fibonacci.begin())); -} - -TEST_F(RepeatedFieldInsertionIteratorsTest, Halves) { - EXPECT_TRUE(std::equal(halves.begin(), - halves.end(), - protobuffer.repeated_double().begin())); - EXPECT_TRUE(std::equal(protobuffer.repeated_double().begin(), - protobuffer.repeated_double().end(), - halves.begin())); -} - -TEST_F(RepeatedFieldInsertionIteratorsTest, Words) { - ASSERT_EQ(words.size(), protobuffer.repeated_string_size()); - for (int i = 0; i < words.size(); ++i) - EXPECT_EQ(words.at(i), protobuffer.repeated_string(i)); -} - -TEST_F(RepeatedFieldInsertionIteratorsTest, Words2) { - words.clear(); - words.push_back("sing"); - words.push_back("a"); - words.push_back("song"); - words.push_back("of"); - words.push_back("six"); - words.push_back("pence"); - protobuffer.mutable_repeated_string()->Clear(); - std::copy(words.begin(), words.end(), RepeatedPtrFieldBackInserter( - protobuffer.mutable_repeated_string())); - ASSERT_EQ(words.size(), protobuffer.repeated_string_size()); - for (int i = 0; i < words.size(); ++i) - EXPECT_EQ(words.at(i), protobuffer.repeated_string(i)); -} - -TEST_F(RepeatedFieldInsertionIteratorsTest, Nesteds) { - ASSERT_EQ(protobuffer.repeated_nested_message_size(), 4); - EXPECT_EQ(protobuffer.repeated_nested_message(0).bb(), 17); - EXPECT_EQ(protobuffer.repeated_nested_message(1).bb(), 4711); - EXPECT_EQ(protobuffer.repeated_nested_message(2).bb(), 170); - EXPECT_EQ(protobuffer.repeated_nested_message(3).bb(), 47110); -} - -TEST_F(RepeatedFieldInsertionIteratorsTest, - AllocatedRepeatedPtrFieldWithStringIntData) { - vector data; - TestAllTypes goldenproto; - for (int i = 0; i < 10; ++i) { - Nested* new_data = new Nested; - new_data->set_bb(i); - data.push_back(new_data); - - new_data = goldenproto.add_repeated_nested_message(); - new_data->set_bb(i); - } - TestAllTypes testproto; - copy(data.begin(), data.end(), - AllocatedRepeatedPtrFieldBackInserter( - testproto.mutable_repeated_nested_message())); - EXPECT_EQ(testproto.DebugString(), goldenproto.DebugString()); -} - -TEST_F(RepeatedFieldInsertionIteratorsTest, - AllocatedRepeatedPtrFieldWithString) { - vector data; - TestAllTypes goldenproto; - for (int i = 0; i < 10; ++i) { - string* new_data = new string; - *new_data = "name-" + SimpleItoa(i); - data.push_back(new_data); - - new_data = goldenproto.add_repeated_string(); - *new_data = "name-" + SimpleItoa(i); - } - TestAllTypes testproto; - copy(data.begin(), data.end(), - AllocatedRepeatedPtrFieldBackInserter( - testproto.mutable_repeated_string())); - EXPECT_EQ(testproto.DebugString(), goldenproto.DebugString()); -} - -} // namespace - -} // namespace protobuf -} // namespace google diff --git a/modules/dnn/3rdparty/protobuf/src/google/protobuf/service.cc b/modules/dnn/3rdparty/protobuf/src/google/protobuf/service.cc deleted file mode 100644 index caf968ca5..000000000 --- a/modules/dnn/3rdparty/protobuf/src/google/protobuf/service.cc +++ /dev/null @@ -1,46 +0,0 @@ -// Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// http://code.google.com/p/protobuf/ -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -// Author: kenton@google.com (Kenton Varda) -// Based on original Protocol Buffers design by -// Sanjay Ghemawat, Jeff Dean, and others. - -#include - -namespace google { -namespace protobuf { - -Service::~Service() {} -RpcChannel::~RpcChannel() {} -RpcController::~RpcController() {} - -} // namespace protobuf - -} // namespace google diff --git a/modules/dnn/3rdparty/protobuf/src/google/protobuf/service.h b/modules/dnn/3rdparty/protobuf/src/google/protobuf/service.h deleted file mode 100644 index a6a7d16de..000000000 --- a/modules/dnn/3rdparty/protobuf/src/google/protobuf/service.h +++ /dev/null @@ -1,291 +0,0 @@ -// Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// http://code.google.com/p/protobuf/ -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -// Author: kenton@google.com (Kenton Varda) -// Based on original Protocol Buffers design by -// Sanjay Ghemawat, Jeff Dean, and others. -// -// DEPRECATED: This module declares the abstract interfaces underlying proto2 -// RPC services. These are intented to be independent of any particular RPC -// implementation, so that proto2 services can be used on top of a variety -// of implementations. Starting with version 2.3.0, RPC implementations should -// not try to build on these, but should instead provide code generator plugins -// which generate code specific to the particular RPC implementation. This way -// the generated code can be more appropriate for the implementation in use -// and can avoid unnecessary layers of indirection. -// -// -// When you use the protocol compiler to compile a service definition, it -// generates two classes: An abstract interface for the service (with -// methods matching the service definition) and a "stub" implementation. -// A stub is just a type-safe wrapper around an RpcChannel which emulates a -// local implementation of the service. -// -// For example, the service definition: -// service MyService { -// rpc Foo(MyRequest) returns(MyResponse); -// } -// will generate abstract interface "MyService" and class "MyService::Stub". -// You could implement a MyService as follows: -// class MyServiceImpl : public MyService { -// public: -// MyServiceImpl() {} -// ~MyServiceImpl() {} -// -// // implements MyService --------------------------------------- -// -// void Foo(google::protobuf::RpcController* controller, -// const MyRequest* request, -// MyResponse* response, -// Closure* done) { -// // ... read request and fill in response ... -// done->Run(); -// } -// }; -// You would then register an instance of MyServiceImpl with your RPC server -// implementation. (How to do that depends on the implementation.) -// -// To call a remote MyServiceImpl, first you need an RpcChannel connected to it. -// How to construct a channel depends, again, on your RPC implementation. -// Here we use a hypothentical "MyRpcChannel" as an example: -// MyRpcChannel channel("rpc:hostname:1234/myservice"); -// MyRpcController controller; -// MyServiceImpl::Stub stub(&channel); -// FooRequest request; -// FooRespnose response; -// -// // ... fill in request ... -// -// stub.Foo(&controller, request, &response, NewCallback(HandleResponse)); -// -// On Thread-Safety: -// -// Different RPC implementations may make different guarantees about what -// threads they may run callbacks on, and what threads the application is -// allowed to use to call the RPC system. Portable software should be ready -// for callbacks to be called on any thread, but should not try to call the -// RPC system from any thread except for the ones on which it received the -// callbacks. Realistically, though, simple software will probably want to -// use a single-threaded RPC system while high-end software will want to -// use multiple threads. RPC implementations should provide multiple -// choices. - -#ifndef GOOGLE_PROTOBUF_SERVICE_H__ -#define GOOGLE_PROTOBUF_SERVICE_H__ - -#include -#include - -namespace google { -namespace protobuf { - -// Defined in this file. -class Service; -class RpcController; -class RpcChannel; - -// Defined in other files. -class Descriptor; // descriptor.h -class ServiceDescriptor; // descriptor.h -class MethodDescriptor; // descriptor.h -class Message; // message.h - -// Abstract base interface for protocol-buffer-based RPC services. Services -// themselves are abstract interfaces (implemented either by servers or as -// stubs), but they subclass this base interface. The methods of this -// interface can be used to call the methods of the Service without knowing -// its exact type at compile time (analogous to Reflection). -class LIBPROTOBUF_EXPORT Service { - public: - inline Service() {} - virtual ~Service(); - - // When constructing a stub, you may pass STUB_OWNS_CHANNEL as the second - // parameter to the constructor to tell it to delete its RpcChannel when - // destroyed. - enum ChannelOwnership { - STUB_OWNS_CHANNEL, - STUB_DOESNT_OWN_CHANNEL - }; - - // Get the ServiceDescriptor describing this service and its methods. - virtual const ServiceDescriptor* GetDescriptor() = 0; - - // Call a method of the service specified by MethodDescriptor. This is - // normally implemented as a simple switch() that calls the standard - // definitions of the service's methods. - // - // Preconditions: - // * method->service() == GetDescriptor() - // * request and response are of the exact same classes as the objects - // returned by GetRequestPrototype(method) and - // GetResponsePrototype(method). - // * After the call has started, the request must not be modified and the - // response must not be accessed at all until "done" is called. - // * "controller" is of the correct type for the RPC implementation being - // used by this Service. For stubs, the "correct type" depends on the - // RpcChannel which the stub is using. Server-side Service - // implementations are expected to accept whatever type of RpcController - // the server-side RPC implementation uses. - // - // Postconditions: - // * "done" will be called when the method is complete. This may be - // before CallMethod() returns or it may be at some point in the future. - // * If the RPC succeeded, "response" contains the response returned by - // the server. - // * If the RPC failed, "response"'s contents are undefined. The - // RpcController can be queried to determine if an error occurred and - // possibly to get more information about the error. - virtual void CallMethod(const MethodDescriptor* method, - RpcController* controller, - const Message* request, - Message* response, - Closure* done) = 0; - - // CallMethod() requires that the request and response passed in are of a - // particular subclass of Message. GetRequestPrototype() and - // GetResponsePrototype() get the default instances of these required types. - // You can then call Message::New() on these instances to construct mutable - // objects which you can then pass to CallMethod(). - // - // Example: - // const MethodDescriptor* method = - // service->GetDescriptor()->FindMethodByName("Foo"); - // Message* request = stub->GetRequestPrototype (method)->New(); - // Message* response = stub->GetResponsePrototype(method)->New(); - // request->ParseFromString(input); - // service->CallMethod(method, *request, response, callback); - virtual const Message& GetRequestPrototype( - const MethodDescriptor* method) const = 0; - virtual const Message& GetResponsePrototype( - const MethodDescriptor* method) const = 0; - - private: - GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(Service); -}; - -// An RpcController mediates a single method call. The primary purpose of -// the controller is to provide a way to manipulate settings specific to the -// RPC implementation and to find out about RPC-level errors. -// -// The methods provided by the RpcController interface are intended to be a -// "least common denominator" set of features which we expect all -// implementations to support. Specific implementations may provide more -// advanced features (e.g. deadline propagation). -class LIBPROTOBUF_EXPORT RpcController { - public: - inline RpcController() {} - virtual ~RpcController(); - - // Client-side methods --------------------------------------------- - // These calls may be made from the client side only. Their results - // are undefined on the server side (may crash). - - // Resets the RpcController to its initial state so that it may be reused in - // a new call. Must not be called while an RPC is in progress. - virtual void Reset() = 0; - - // After a call has finished, returns true if the call failed. The possible - // reasons for failure depend on the RPC implementation. Failed() must not - // be called before a call has finished. If Failed() returns true, the - // contents of the response message are undefined. - virtual bool Failed() const = 0; - - // If Failed() is true, returns a human-readable description of the error. - virtual string ErrorText() const = 0; - - // Advises the RPC system that the caller desires that the RPC call be - // canceled. The RPC system may cancel it immediately, may wait awhile and - // then cancel it, or may not even cancel the call at all. If the call is - // canceled, the "done" callback will still be called and the RpcController - // will indicate that the call failed at that time. - virtual void StartCancel() = 0; - - // Server-side methods --------------------------------------------- - // These calls may be made from the server side only. Their results - // are undefined on the client side (may crash). - - // Causes Failed() to return true on the client side. "reason" will be - // incorporated into the message returned by ErrorText(). If you find - // you need to return machine-readable information about failures, you - // should incorporate it into your response protocol buffer and should - // NOT call SetFailed(). - virtual void SetFailed(const string& reason) = 0; - - // If true, indicates that the client canceled the RPC, so the server may - // as well give up on replying to it. The server should still call the - // final "done" callback. - virtual bool IsCanceled() const = 0; - - // Asks that the given callback be called when the RPC is canceled. The - // callback will always be called exactly once. If the RPC completes without - // being canceled, the callback will be called after completion. If the RPC - // has already been canceled when NotifyOnCancel() is called, the callback - // will be called immediately. - // - // NotifyOnCancel() must be called no more than once per request. - virtual void NotifyOnCancel(Closure* callback) = 0; - - private: - GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(RpcController); -}; - -// Abstract interface for an RPC channel. An RpcChannel represents a -// communication line to a Service which can be used to call that Service's -// methods. The Service may be running on another machine. Normally, you -// should not call an RpcChannel directly, but instead construct a stub Service -// wrapping it. Example: -// RpcChannel* channel = new MyRpcChannel("remotehost.example.com:1234"); -// MyService* service = new MyService::Stub(channel); -// service->MyMethod(request, &response, callback); -class LIBPROTOBUF_EXPORT RpcChannel { - public: - inline RpcChannel() {} - virtual ~RpcChannel(); - - // Call the given method of the remote service. The signature of this - // procedure looks the same as Service::CallMethod(), but the requirements - // are less strict in one important way: the request and response objects - // need not be of any specific class as long as their descriptors are - // method->input_type() and method->output_type(). - virtual void CallMethod(const MethodDescriptor* method, - RpcController* controller, - const Message* request, - Message* response, - Closure* done) = 0; - - private: - GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(RpcChannel); -}; - -} // namespace protobuf - -} // namespace google -#endif // GOOGLE_PROTOBUF_SERVICE_H__ diff --git a/modules/dnn/3rdparty/protobuf/src/google/protobuf/stubs/atomicops.h b/modules/dnn/3rdparty/protobuf/src/google/protobuf/stubs/atomicops.h deleted file mode 100644 index b8581fa27..000000000 --- a/modules/dnn/3rdparty/protobuf/src/google/protobuf/stubs/atomicops.h +++ /dev/null @@ -1,206 +0,0 @@ -// Protocol Buffers - Google's data interchange format -// Copyright 2012 Google Inc. All rights reserved. -// http://code.google.com/p/protobuf/ -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -// The routines exported by this module are subtle. If you use them, even if -// you get the code right, it will depend on careful reasoning about atomicity -// and memory ordering; it will be less readable, and harder to maintain. If -// you plan to use these routines, you should have a good reason, such as solid -// evidence that performance would otherwise suffer, or there being no -// alternative. You should assume only properties explicitly guaranteed by the -// specifications in this file. You are almost certainly _not_ writing code -// just for the x86; if you assume x86 semantics, x86 hardware bugs and -// implementations on other archtectures will cause your code to break. If you -// do not know what you are doing, avoid these routines, and use a Mutex. -// -// It is incorrect to make direct assignments to/from an atomic variable. -// You should use one of the Load or Store routines. The NoBarrier -// versions are provided when no barriers are needed: -// NoBarrier_Store() -// NoBarrier_Load() -// Although there are currently no compiler enforcement, you are encouraged -// to use these. - -// This header and the implementations for each platform (located in -// atomicops_internals_*) must be kept in sync with the upstream code (V8). - -#ifndef GOOGLE_PROTOBUF_ATOMICOPS_H_ -#define GOOGLE_PROTOBUF_ATOMICOPS_H_ - -// Don't include this file for people not concerned about thread safety. -#ifndef GOOGLE_PROTOBUF_NO_THREAD_SAFETY - -#include - -namespace google { -namespace protobuf { -namespace internal { - -typedef int32 Atomic32; -#ifdef GOOGLE_PROTOBUF_ARCH_64_BIT -// We need to be able to go between Atomic64 and AtomicWord implicitly. This -// means Atomic64 and AtomicWord should be the same type on 64-bit. -#if defined(GOOGLE_PROTOBUF_OS_NACL) -// NaCl's intptr_t is not actually 64-bits on 64-bit! -// http://code.google.com/p/nativeclient/issues/detail?id=1162 -typedef int64 Atomic64; -#else -typedef intptr_t Atomic64; -#endif -#endif - -// Use AtomicWord for a machine-sized pointer. It will use the Atomic32 or -// Atomic64 routines below, depending on your architecture. -typedef intptr_t AtomicWord; - -// Atomically execute: -// result = *ptr; -// if (*ptr == old_value) -// *ptr = new_value; -// return result; -// -// I.e., replace "*ptr" with "new_value" if "*ptr" used to be "old_value". -// Always return the old value of "*ptr" -// -// This routine implies no memory barriers. -Atomic32 NoBarrier_CompareAndSwap(volatile Atomic32* ptr, - Atomic32 old_value, - Atomic32 new_value); - -// Atomically store new_value into *ptr, returning the previous value held in -// *ptr. This routine implies no memory barriers. -Atomic32 NoBarrier_AtomicExchange(volatile Atomic32* ptr, Atomic32 new_value); - -// Atomically increment *ptr by "increment". Returns the new value of -// *ptr with the increment applied. This routine implies no memory barriers. -Atomic32 NoBarrier_AtomicIncrement(volatile Atomic32* ptr, Atomic32 increment); - -Atomic32 Barrier_AtomicIncrement(volatile Atomic32* ptr, - Atomic32 increment); - -// These following lower-level operations are typically useful only to people -// implementing higher-level synchronization operations like spinlocks, -// mutexes, and condition-variables. They combine CompareAndSwap(), a load, or -// a store with appropriate memory-ordering instructions. "Acquire" operations -// ensure that no later memory access can be reordered ahead of the operation. -// "Release" operations ensure that no previous memory access can be reordered -// after the operation. "Barrier" operations have both "Acquire" and "Release" -// semantics. A MemoryBarrier() has "Barrier" semantics, but does no memory -// access. -Atomic32 Acquire_CompareAndSwap(volatile Atomic32* ptr, - Atomic32 old_value, - Atomic32 new_value); -Atomic32 Release_CompareAndSwap(volatile Atomic32* ptr, - Atomic32 old_value, - Atomic32 new_value); - -void MemoryBarrier(); -void NoBarrier_Store(volatile Atomic32* ptr, Atomic32 value); -void Acquire_Store(volatile Atomic32* ptr, Atomic32 value); -void Release_Store(volatile Atomic32* ptr, Atomic32 value); - -Atomic32 NoBarrier_Load(volatile const Atomic32* ptr); -Atomic32 Acquire_Load(volatile const Atomic32* ptr); -Atomic32 Release_Load(volatile const Atomic32* ptr); - -// 64-bit atomic operations (only available on 64-bit processors). -#ifdef GOOGLE_PROTOBUF_ARCH_64_BIT -Atomic64 NoBarrier_CompareAndSwap(volatile Atomic64* ptr, - Atomic64 old_value, - Atomic64 new_value); -Atomic64 NoBarrier_AtomicExchange(volatile Atomic64* ptr, Atomic64 new_value); -Atomic64 NoBarrier_AtomicIncrement(volatile Atomic64* ptr, Atomic64 increment); -Atomic64 Barrier_AtomicIncrement(volatile Atomic64* ptr, Atomic64 increment); - -Atomic64 Acquire_CompareAndSwap(volatile Atomic64* ptr, - Atomic64 old_value, - Atomic64 new_value); -Atomic64 Release_CompareAndSwap(volatile Atomic64* ptr, - Atomic64 old_value, - Atomic64 new_value); -void NoBarrier_Store(volatile Atomic64* ptr, Atomic64 value); -void Acquire_Store(volatile Atomic64* ptr, Atomic64 value); -void Release_Store(volatile Atomic64* ptr, Atomic64 value); -Atomic64 NoBarrier_Load(volatile const Atomic64* ptr); -Atomic64 Acquire_Load(volatile const Atomic64* ptr); -Atomic64 Release_Load(volatile const Atomic64* ptr); -#endif // GOOGLE_PROTOBUF_ARCH_64_BIT - -} // namespace internal -} // namespace protobuf -} // namespace google - -// Include our platform specific implementation. -#define GOOGLE_PROTOBUF_ATOMICOPS_ERROR \ -#error "Atomic operations are not supported on your platform" - -// MSVC. -#if defined(_MSC_VER) -#if defined(GOOGLE_PROTOBUF_ARCH_IA32) || defined(GOOGLE_PROTOBUF_ARCH_X64) -#include -#else -GOOGLE_PROTOBUF_ATOMICOPS_ERROR -#endif - -// Apple. -#elif defined(GOOGLE_PROTOBUF_OS_APPLE) -#include - -// GCC. -#elif defined(__GNUC__) -#if defined(GOOGLE_PROTOBUF_ARCH_IA32) || defined(GOOGLE_PROTOBUF_ARCH_X64) -#include -#elif defined(GOOGLE_PROTOBUF_ARCH_ARM) -#include -#elif defined(GOOGLE_PROTOBUF_ARCH_ARM_QNX) -#include -#elif defined(GOOGLE_PROTOBUF_ARCH_MIPS) -#include -#elif defined(__pnacl__) -#include -#else -GOOGLE_PROTOBUF_ATOMICOPS_ERROR -#endif - -// Unknown. -#else -GOOGLE_PROTOBUF_ATOMICOPS_ERROR -#endif - -// On some platforms we need additional declarations to make AtomicWord -// compatible with our other Atomic* types. -#if defined(GOOGLE_PROTOBUF_OS_APPLE) -#include -#endif - -#undef GOOGLE_PROTOBUF_ATOMICOPS_ERROR - -#endif // GOOGLE_PROTOBUF_NO_THREAD_SAFETY - -#endif // GOOGLE_PROTOBUF_ATOMICOPS_H_ diff --git a/modules/dnn/3rdparty/protobuf/src/google/protobuf/stubs/atomicops_internals_arm_gcc.h b/modules/dnn/3rdparty/protobuf/src/google/protobuf/stubs/atomicops_internals_arm_gcc.h deleted file mode 100644 index 1f4dedc0f..000000000 --- a/modules/dnn/3rdparty/protobuf/src/google/protobuf/stubs/atomicops_internals_arm_gcc.h +++ /dev/null @@ -1,151 +0,0 @@ -// Protocol Buffers - Google's data interchange format -// Copyright 2012 Google Inc. All rights reserved. -// http://code.google.com/p/protobuf/ -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -// This file is an internal atomic implementation, use atomicops.h instead. -// -// LinuxKernelCmpxchg and Barrier_AtomicIncrement are from Google Gears. - -#ifndef GOOGLE_PROTOBUF_ATOMICOPS_INTERNALS_ARM_GCC_H_ -#define GOOGLE_PROTOBUF_ATOMICOPS_INTERNALS_ARM_GCC_H_ - -namespace google { -namespace protobuf { -namespace internal { - -// 0xffff0fc0 is the hard coded address of a function provided by -// the kernel which implements an atomic compare-exchange. On older -// ARM architecture revisions (pre-v6) this may be implemented using -// a syscall. This address is stable, and in active use (hard coded) -// by at least glibc-2.7 and the Android C library. -typedef Atomic32 (*LinuxKernelCmpxchgFunc)(Atomic32 old_value, - Atomic32 new_value, - volatile Atomic32* ptr); -LinuxKernelCmpxchgFunc pLinuxKernelCmpxchg __attribute__((weak)) = - (LinuxKernelCmpxchgFunc) 0xffff0fc0; - -typedef void (*LinuxKernelMemoryBarrierFunc)(void); -LinuxKernelMemoryBarrierFunc pLinuxKernelMemoryBarrier __attribute__((weak)) = - (LinuxKernelMemoryBarrierFunc) 0xffff0fa0; - - -inline Atomic32 NoBarrier_CompareAndSwap(volatile Atomic32* ptr, - Atomic32 old_value, - Atomic32 new_value) { - Atomic32 prev_value = *ptr; - do { - if (!pLinuxKernelCmpxchg(old_value, new_value, - const_cast(ptr))) { - return old_value; - } - prev_value = *ptr; - } while (prev_value == old_value); - return prev_value; -} - -inline Atomic32 NoBarrier_AtomicExchange(volatile Atomic32* ptr, - Atomic32 new_value) { - Atomic32 old_value; - do { - old_value = *ptr; - } while (pLinuxKernelCmpxchg(old_value, new_value, - const_cast(ptr))); - return old_value; -} - -inline Atomic32 NoBarrier_AtomicIncrement(volatile Atomic32* ptr, - Atomic32 increment) { - return Barrier_AtomicIncrement(ptr, increment); -} - -inline Atomic32 Barrier_AtomicIncrement(volatile Atomic32* ptr, - Atomic32 increment) { - for (;;) { - // Atomic exchange the old value with an incremented one. - Atomic32 old_value = *ptr; - Atomic32 new_value = old_value + increment; - if (pLinuxKernelCmpxchg(old_value, new_value, - const_cast(ptr)) == 0) { - // The exchange took place as expected. - return new_value; - } - // Otherwise, *ptr changed mid-loop and we need to retry. - } -} - -inline Atomic32 Acquire_CompareAndSwap(volatile Atomic32* ptr, - Atomic32 old_value, - Atomic32 new_value) { - return NoBarrier_CompareAndSwap(ptr, old_value, new_value); -} - -inline Atomic32 Release_CompareAndSwap(volatile Atomic32* ptr, - Atomic32 old_value, - Atomic32 new_value) { - return NoBarrier_CompareAndSwap(ptr, old_value, new_value); -} - -inline void NoBarrier_Store(volatile Atomic32* ptr, Atomic32 value) { - *ptr = value; -} - -inline void MemoryBarrier() { - pLinuxKernelMemoryBarrier(); -} - -inline void Acquire_Store(volatile Atomic32* ptr, Atomic32 value) { - *ptr = value; - MemoryBarrier(); -} - -inline void Release_Store(volatile Atomic32* ptr, Atomic32 value) { - MemoryBarrier(); - *ptr = value; -} - -inline Atomic32 NoBarrier_Load(volatile const Atomic32* ptr) { - return *ptr; -} - -inline Atomic32 Acquire_Load(volatile const Atomic32* ptr) { - Atomic32 value = *ptr; - MemoryBarrier(); - return value; -} - -inline Atomic32 Release_Load(volatile const Atomic32* ptr) { - MemoryBarrier(); - return *ptr; -} - -} // namespace internal -} // namespace protobuf -} // namespace google - -#endif // GOOGLE_PROTOBUF_ATOMICOPS_INTERNALS_ARM_GCC_H_ diff --git a/modules/dnn/3rdparty/protobuf/src/google/protobuf/stubs/atomicops_internals_arm_qnx.h b/modules/dnn/3rdparty/protobuf/src/google/protobuf/stubs/atomicops_internals_arm_qnx.h deleted file mode 100644 index f05076978..000000000 --- a/modules/dnn/3rdparty/protobuf/src/google/protobuf/stubs/atomicops_internals_arm_qnx.h +++ /dev/null @@ -1,146 +0,0 @@ -// Protocol Buffers - Google's data interchange format -// Copyright 2012 Google Inc. All rights reserved. -// http://code.google.com/p/protobuf/ -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -// This file is an internal atomic implementation, use atomicops.h instead. - -#ifndef GOOGLE_PROTOBUF_ATOMICOPS_INTERNALS_ARM_QNX_H_ -#define GOOGLE_PROTOBUF_ATOMICOPS_INTERNALS_ARM_QNX_H_ - -// For _smp_cmpxchg() -#include - -namespace google { -namespace protobuf { -namespace internal { - -inline Atomic32 QNXCmpxchg(Atomic32 old_value, - Atomic32 new_value, - volatile Atomic32* ptr) { - return static_cast( - _smp_cmpxchg((volatile unsigned *)ptr, - (unsigned)old_value, - (unsigned)new_value)); -} - - -inline Atomic32 NoBarrier_CompareAndSwap(volatile Atomic32* ptr, - Atomic32 old_value, - Atomic32 new_value) { - Atomic32 prev_value = *ptr; - do { - if (!QNXCmpxchg(old_value, new_value, - const_cast(ptr))) { - return old_value; - } - prev_value = *ptr; - } while (prev_value == old_value); - return prev_value; -} - -inline Atomic32 NoBarrier_AtomicExchange(volatile Atomic32* ptr, - Atomic32 new_value) { - Atomic32 old_value; - do { - old_value = *ptr; - } while (QNXCmpxchg(old_value, new_value, - const_cast(ptr))); - return old_value; -} - -inline Atomic32 NoBarrier_AtomicIncrement(volatile Atomic32* ptr, - Atomic32 increment) { - return Barrier_AtomicIncrement(ptr, increment); -} - -inline Atomic32 Barrier_AtomicIncrement(volatile Atomic32* ptr, - Atomic32 increment) { - for (;;) { - // Atomic exchange the old value with an incremented one. - Atomic32 old_value = *ptr; - Atomic32 new_value = old_value + increment; - if (QNXCmpxchg(old_value, new_value, - const_cast(ptr)) == 0) { - // The exchange took place as expected. - return new_value; - } - // Otherwise, *ptr changed mid-loop and we need to retry. - } -} - -inline Atomic32 Acquire_CompareAndSwap(volatile Atomic32* ptr, - Atomic32 old_value, - Atomic32 new_value) { - return NoBarrier_CompareAndSwap(ptr, old_value, new_value); -} - -inline Atomic32 Release_CompareAndSwap(volatile Atomic32* ptr, - Atomic32 old_value, - Atomic32 new_value) { - return NoBarrier_CompareAndSwap(ptr, old_value, new_value); -} - -inline void NoBarrier_Store(volatile Atomic32* ptr, Atomic32 value) { - *ptr = value; -} - -inline void MemoryBarrier() { - __sync_synchronize(); -} - -inline void Acquire_Store(volatile Atomic32* ptr, Atomic32 value) { - *ptr = value; - MemoryBarrier(); -} - -inline void Release_Store(volatile Atomic32* ptr, Atomic32 value) { - MemoryBarrier(); - *ptr = value; -} - -inline Atomic32 NoBarrier_Load(volatile const Atomic32* ptr) { - return *ptr; -} - -inline Atomic32 Acquire_Load(volatile const Atomic32* ptr) { - Atomic32 value = *ptr; - MemoryBarrier(); - return value; -} - -inline Atomic32 Release_Load(volatile const Atomic32* ptr) { - MemoryBarrier(); - return *ptr; -} - -} // namespace internal -} // namespace protobuf -} // namespace google - -#endif // GOOGLE_PROTOBUF_ATOMICOPS_INTERNALS_ARM_QNX_H_ diff --git a/modules/dnn/3rdparty/protobuf/src/google/protobuf/stubs/atomicops_internals_atomicword_compat.h b/modules/dnn/3rdparty/protobuf/src/google/protobuf/stubs/atomicops_internals_atomicword_compat.h deleted file mode 100644 index e9d86797b..000000000 --- a/modules/dnn/3rdparty/protobuf/src/google/protobuf/stubs/atomicops_internals_atomicword_compat.h +++ /dev/null @@ -1,122 +0,0 @@ -// Protocol Buffers - Google's data interchange format -// Copyright 2012 Google Inc. All rights reserved. -// http://code.google.com/p/protobuf/ -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -// This file is an internal atomic implementation, use atomicops.h instead. - -#ifndef GOOGLE_PROTOBUF_ATOMICOPS_INTERNALS_ATOMICWORD_COMPAT_H_ -#define GOOGLE_PROTOBUF_ATOMICOPS_INTERNALS_ATOMICWORD_COMPAT_H_ - -// AtomicWord is a synonym for intptr_t, and Atomic32 is a synonym for int32, -// which in turn means int. On some LP32 platforms, intptr_t is an int, but -// on others, it's a long. When AtomicWord and Atomic32 are based on different -// fundamental types, their pointers are incompatible. -// -// This file defines function overloads to allow both AtomicWord and Atomic32 -// data to be used with this interface. -// -// On LP64 platforms, AtomicWord and Atomic64 are both always long, -// so this problem doesn't occur. - -#if !defined(GOOGLE_PROTOBUF_ARCH_64_BIT) - -namespace google { -namespace protobuf { -namespace internal { - -inline AtomicWord NoBarrier_CompareAndSwap(volatile AtomicWord* ptr, - AtomicWord old_value, - AtomicWord new_value) { - return NoBarrier_CompareAndSwap( - reinterpret_cast(ptr), old_value, new_value); -} - -inline AtomicWord NoBarrier_AtomicExchange(volatile AtomicWord* ptr, - AtomicWord new_value) { - return NoBarrier_AtomicExchange( - reinterpret_cast(ptr), new_value); -} - -inline AtomicWord NoBarrier_AtomicIncrement(volatile AtomicWord* ptr, - AtomicWord increment) { - return NoBarrier_AtomicIncrement( - reinterpret_cast(ptr), increment); -} - -inline AtomicWord Barrier_AtomicIncrement(volatile AtomicWord* ptr, - AtomicWord increment) { - return Barrier_AtomicIncrement( - reinterpret_cast(ptr), increment); -} - -inline AtomicWord Acquire_CompareAndSwap(volatile AtomicWord* ptr, - AtomicWord old_value, - AtomicWord new_value) { - return Acquire_CompareAndSwap( - reinterpret_cast(ptr), old_value, new_value); -} - -inline AtomicWord Release_CompareAndSwap(volatile AtomicWord* ptr, - AtomicWord old_value, - AtomicWord new_value) { - return Release_CompareAndSwap( - reinterpret_cast(ptr), old_value, new_value); -} - -inline void NoBarrier_Store(volatile AtomicWord *ptr, AtomicWord value) { - NoBarrier_Store(reinterpret_cast(ptr), value); -} - -inline void Acquire_Store(volatile AtomicWord* ptr, AtomicWord value) { - return Acquire_Store(reinterpret_cast(ptr), value); -} - -inline void Release_Store(volatile AtomicWord* ptr, AtomicWord value) { - return Release_Store(reinterpret_cast(ptr), value); -} - -inline AtomicWord NoBarrier_Load(volatile const AtomicWord *ptr) { - return NoBarrier_Load(reinterpret_cast(ptr)); -} - -inline AtomicWord Acquire_Load(volatile const AtomicWord* ptr) { - return Acquire_Load(reinterpret_cast(ptr)); -} - -inline AtomicWord Release_Load(volatile const AtomicWord* ptr) { - return Release_Load(reinterpret_cast(ptr)); -} - -} // namespace internal -} // namespace protobuf -} // namespace google - -#endif // !defined(GOOGLE_PROTOBUF_ARCH_64_BIT) - -#endif // GOOGLE_PROTOBUF_ATOMICOPS_INTERNALS_ATOMICWORD_COMPAT_H_ diff --git a/modules/dnn/3rdparty/protobuf/src/google/protobuf/stubs/atomicops_internals_macosx.h b/modules/dnn/3rdparty/protobuf/src/google/protobuf/stubs/atomicops_internals_macosx.h deleted file mode 100644 index f9b7581ad..000000000 --- a/modules/dnn/3rdparty/protobuf/src/google/protobuf/stubs/atomicops_internals_macosx.h +++ /dev/null @@ -1,225 +0,0 @@ -// Protocol Buffers - Google's data interchange format -// Copyright 2012 Google Inc. All rights reserved. -// http://code.google.com/p/protobuf/ -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -// This file is an internal atomic implementation, use atomicops.h instead. - -#ifndef GOOGLE_PROTOBUF_ATOMICOPS_INTERNALS_MACOSX_H_ -#define GOOGLE_PROTOBUF_ATOMICOPS_INTERNALS_MACOSX_H_ - -#include - -namespace google { -namespace protobuf { -namespace internal { - -inline Atomic32 NoBarrier_CompareAndSwap(volatile Atomic32* ptr, - Atomic32 old_value, - Atomic32 new_value) { - Atomic32 prev_value; - do { - if (OSAtomicCompareAndSwap32(old_value, new_value, - const_cast(ptr))) { - return old_value; - } - prev_value = *ptr; - } while (prev_value == old_value); - return prev_value; -} - -inline Atomic32 NoBarrier_AtomicExchange(volatile Atomic32* ptr, - Atomic32 new_value) { - Atomic32 old_value; - do { - old_value = *ptr; - } while (!OSAtomicCompareAndSwap32(old_value, new_value, - const_cast(ptr))); - return old_value; -} - -inline Atomic32 NoBarrier_AtomicIncrement(volatile Atomic32* ptr, - Atomic32 increment) { - return OSAtomicAdd32(increment, const_cast(ptr)); -} - -inline Atomic32 Barrier_AtomicIncrement(volatile Atomic32* ptr, - Atomic32 increment) { - return OSAtomicAdd32Barrier(increment, const_cast(ptr)); -} - -inline void MemoryBarrier() { - OSMemoryBarrier(); -} - -inline Atomic32 Acquire_CompareAndSwap(volatile Atomic32* ptr, - Atomic32 old_value, - Atomic32 new_value) { - Atomic32 prev_value; - do { - if (OSAtomicCompareAndSwap32Barrier(old_value, new_value, - const_cast(ptr))) { - return old_value; - } - prev_value = *ptr; - } while (prev_value == old_value); - return prev_value; -} - -inline Atomic32 Release_CompareAndSwap(volatile Atomic32* ptr, - Atomic32 old_value, - Atomic32 new_value) { - return Acquire_CompareAndSwap(ptr, old_value, new_value); -} - -inline void NoBarrier_Store(volatile Atomic32* ptr, Atomic32 value) { - *ptr = value; -} - -inline void Acquire_Store(volatile Atomic32* ptr, Atomic32 value) { - *ptr = value; - MemoryBarrier(); -} - -inline void Release_Store(volatile Atomic32* ptr, Atomic32 value) { - MemoryBarrier(); - *ptr = value; -} - -inline Atomic32 NoBarrier_Load(volatile const Atomic32* ptr) { - return *ptr; -} - -inline Atomic32 Acquire_Load(volatile const Atomic32* ptr) { - Atomic32 value = *ptr; - MemoryBarrier(); - return value; -} - -inline Atomic32 Release_Load(volatile const Atomic32* ptr) { - MemoryBarrier(); - return *ptr; -} - -#ifdef __LP64__ - -// 64-bit implementation on 64-bit platform - -inline Atomic64 NoBarrier_CompareAndSwap(volatile Atomic64* ptr, - Atomic64 old_value, - Atomic64 new_value) { - Atomic64 prev_value; - do { - if (OSAtomicCompareAndSwap64(old_value, new_value, - reinterpret_cast(ptr))) { - return old_value; - } - prev_value = *ptr; - } while (prev_value == old_value); - return prev_value; -} - -inline Atomic64 NoBarrier_AtomicExchange(volatile Atomic64* ptr, - Atomic64 new_value) { - Atomic64 old_value; - do { - old_value = *ptr; - } while (!OSAtomicCompareAndSwap64(old_value, new_value, - reinterpret_cast(ptr))); - return old_value; -} - -inline Atomic64 NoBarrier_AtomicIncrement(volatile Atomic64* ptr, - Atomic64 increment) { - return OSAtomicAdd64(increment, reinterpret_cast(ptr)); -} - -inline Atomic64 Barrier_AtomicIncrement(volatile Atomic64* ptr, - Atomic64 increment) { - return OSAtomicAdd64Barrier(increment, - reinterpret_cast(ptr)); -} - -inline Atomic64 Acquire_CompareAndSwap(volatile Atomic64* ptr, - Atomic64 old_value, - Atomic64 new_value) { - Atomic64 prev_value; - do { - if (OSAtomicCompareAndSwap64Barrier( - old_value, new_value, reinterpret_cast(ptr))) { - return old_value; - } - prev_value = *ptr; - } while (prev_value == old_value); - return prev_value; -} - -inline Atomic64 Release_CompareAndSwap(volatile Atomic64* ptr, - Atomic64 old_value, - Atomic64 new_value) { - // The lib kern interface does not distinguish between - // Acquire and Release memory barriers; they are equivalent. - return Acquire_CompareAndSwap(ptr, old_value, new_value); -} - -inline void NoBarrier_Store(volatile Atomic64* ptr, Atomic64 value) { - *ptr = value; -} - -inline void Acquire_Store(volatile Atomic64* ptr, Atomic64 value) { - *ptr = value; - MemoryBarrier(); -} - -inline void Release_Store(volatile Atomic64* ptr, Atomic64 value) { - MemoryBarrier(); - *ptr = value; -} - -inline Atomic64 NoBarrier_Load(volatile const Atomic64* ptr) { - return *ptr; -} - -inline Atomic64 Acquire_Load(volatile const Atomic64* ptr) { - Atomic64 value = *ptr; - MemoryBarrier(); - return value; -} - -inline Atomic64 Release_Load(volatile const Atomic64* ptr) { - MemoryBarrier(); - return *ptr; -} - -#endif // defined(__LP64__) - -} // namespace internal -} // namespace protobuf -} // namespace google - -#endif // GOOGLE_PROTOBUF_ATOMICOPS_INTERNALS_MACOSX_H_ diff --git a/modules/dnn/3rdparty/protobuf/src/google/protobuf/stubs/atomicops_internals_mips_gcc.h b/modules/dnn/3rdparty/protobuf/src/google/protobuf/stubs/atomicops_internals_mips_gcc.h deleted file mode 100644 index dc468517a..000000000 --- a/modules/dnn/3rdparty/protobuf/src/google/protobuf/stubs/atomicops_internals_mips_gcc.h +++ /dev/null @@ -1,187 +0,0 @@ -// Protocol Buffers - Google's data interchange format -// Copyright 2012 Google Inc. All rights reserved. -// http://code.google.com/p/protobuf/ -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -// This file is an internal atomic implementation, use atomicops.h instead. - -#ifndef GOOGLE_PROTOBUF_ATOMICOPS_INTERNALS_MIPS_GCC_H_ -#define GOOGLE_PROTOBUF_ATOMICOPS_INTERNALS_MIPS_GCC_H_ - -#define ATOMICOPS_COMPILER_BARRIER() __asm__ __volatile__("" : : : "memory") - -namespace google { -namespace protobuf { -namespace internal { - -// Atomically execute: -// result = *ptr; -// if (*ptr == old_value) -// *ptr = new_value; -// return result; -// -// I.e., replace "*ptr" with "new_value" if "*ptr" used to be "old_value". -// Always return the old value of "*ptr" -// -// This routine implies no memory barriers. -inline Atomic32 NoBarrier_CompareAndSwap(volatile Atomic32* ptr, - Atomic32 old_value, - Atomic32 new_value) { - Atomic32 prev, tmp; - __asm__ __volatile__(".set push\n" - ".set noreorder\n" - "1:\n" - "ll %0, %5\n" // prev = *ptr - "bne %0, %3, 2f\n" // if (prev != old_value) goto 2 - "move %2, %4\n" // tmp = new_value - "sc %2, %1\n" // *ptr = tmp (with atomic check) - "beqz %2, 1b\n" // start again on atomic error - "nop\n" // delay slot nop - "2:\n" - ".set pop\n" - : "=&r" (prev), "=m" (*ptr), "=&r" (tmp) - : "Ir" (old_value), "r" (new_value), "m" (*ptr) - : "memory"); - return prev; -} - -// Atomically store new_value into *ptr, returning the previous value held in -// *ptr. This routine implies no memory barriers. -inline Atomic32 NoBarrier_AtomicExchange(volatile Atomic32* ptr, - Atomic32 new_value) { - Atomic32 temp, old; - __asm__ __volatile__(".set push\n" - ".set noreorder\n" - "1:\n" - "ll %1, %2\n" // old = *ptr - "move %0, %3\n" // temp = new_value - "sc %0, %2\n" // *ptr = temp (with atomic check) - "beqz %0, 1b\n" // start again on atomic error - "nop\n" // delay slot nop - ".set pop\n" - : "=&r" (temp), "=&r" (old), "=m" (*ptr) - : "r" (new_value), "m" (*ptr) - : "memory"); - - return old; -} - -// Atomically increment *ptr by "increment". Returns the new value of -// *ptr with the increment applied. This routine implies no memory barriers. -inline Atomic32 NoBarrier_AtomicIncrement(volatile Atomic32* ptr, - Atomic32 increment) { - Atomic32 temp, temp2; - - __asm__ __volatile__(".set push\n" - ".set noreorder\n" - "1:\n" - "ll %0, %2\n" // temp = *ptr - "addu %1, %0, %3\n" // temp2 = temp + increment - "sc %1, %2\n" // *ptr = temp2 (with atomic check) - "beqz %1, 1b\n" // start again on atomic error - "addu %1, %0, %3\n" // temp2 = temp + increment - ".set pop\n" - : "=&r" (temp), "=&r" (temp2), "=m" (*ptr) - : "Ir" (increment), "m" (*ptr) - : "memory"); - // temp2 now holds the final value. - return temp2; -} - -inline Atomic32 Barrier_AtomicIncrement(volatile Atomic32* ptr, - Atomic32 increment) { - ATOMICOPS_COMPILER_BARRIER(); - Atomic32 res = NoBarrier_AtomicIncrement(ptr, increment); - ATOMICOPS_COMPILER_BARRIER(); - return res; -} - -// "Acquire" operations -// ensure that no later memory access can be reordered ahead of the operation. -// "Release" operations ensure that no previous memory access can be reordered -// after the operation. "Barrier" operations have both "Acquire" and "Release" -// semantics. A MemoryBarrier() has "Barrier" semantics, but does no memory -// access. -inline Atomic32 Acquire_CompareAndSwap(volatile Atomic32* ptr, - Atomic32 old_value, - Atomic32 new_value) { - ATOMICOPS_COMPILER_BARRIER(); - Atomic32 res = NoBarrier_CompareAndSwap(ptr, old_value, new_value); - ATOMICOPS_COMPILER_BARRIER(); - return res; -} - -inline Atomic32 Release_CompareAndSwap(volatile Atomic32* ptr, - Atomic32 old_value, - Atomic32 new_value) { - ATOMICOPS_COMPILER_BARRIER(); - Atomic32 res = NoBarrier_CompareAndSwap(ptr, old_value, new_value); - ATOMICOPS_COMPILER_BARRIER(); - return res; -} - -inline void NoBarrier_Store(volatile Atomic32* ptr, Atomic32 value) { - *ptr = value; -} - -inline void MemoryBarrier() { - __asm__ __volatile__("sync" : : : "memory"); -} - -inline void Acquire_Store(volatile Atomic32* ptr, Atomic32 value) { - *ptr = value; - MemoryBarrier(); -} - -inline void Release_Store(volatile Atomic32* ptr, Atomic32 value) { - MemoryBarrier(); - *ptr = value; -} - -inline Atomic32 NoBarrier_Load(volatile const Atomic32* ptr) { - return *ptr; -} - -inline Atomic32 Acquire_Load(volatile const Atomic32* ptr) { - Atomic32 value = *ptr; - MemoryBarrier(); - return value; -} - -inline Atomic32 Release_Load(volatile const Atomic32* ptr) { - MemoryBarrier(); - return *ptr; -} - -} // namespace internal -} // namespace protobuf -} // namespace google - -#undef ATOMICOPS_COMPILER_BARRIER - -#endif // GOOGLE_PROTOBUF_ATOMICOPS_INTERNALS_MIPS_GCC_H_ diff --git a/modules/dnn/3rdparty/protobuf/src/google/protobuf/stubs/atomicops_internals_pnacl.h b/modules/dnn/3rdparty/protobuf/src/google/protobuf/stubs/atomicops_internals_pnacl.h deleted file mode 100644 index 04a91a83f..000000000 --- a/modules/dnn/3rdparty/protobuf/src/google/protobuf/stubs/atomicops_internals_pnacl.h +++ /dev/null @@ -1,73 +0,0 @@ -// Protocol Buffers - Google's data interchange format -// Copyright 2012 Google Inc. All rights reserved. -// http://code.google.com/p/protobuf/ -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -// This file is an internal atomic implementation, use atomicops.h instead. - -#ifndef GOOGLE_PROTOBUF_ATOMICOPS_INTERNALS_PNACL_H_ -#define GOOGLE_PROTOBUF_ATOMICOPS_INTERNALS_PNACL_H_ - -namespace google { -namespace protobuf { -namespace internal { - -inline Atomic32 NoBarrier_CompareAndSwap(volatile Atomic32* ptr, - Atomic32 old_value, - Atomic32 new_value) { - return __sync_val_compare_and_swap(ptr, old_value, new_value); -} - -inline void MemoryBarrier() { - __sync_synchronize(); -} - -inline Atomic32 Acquire_CompareAndSwap(volatile Atomic32* ptr, - Atomic32 old_value, - Atomic32 new_value) { - Atomic32 ret = NoBarrier_CompareAndSwap(ptr, old_value, new_value); - MemoryBarrier(); - return ret; -} - -inline void Release_Store(volatile Atomic32* ptr, Atomic32 value) { - MemoryBarrier(); - *ptr = value; -} - -inline Atomic32 Acquire_Load(volatile const Atomic32* ptr) { - Atomic32 value = *ptr; - MemoryBarrier(); - return value; -} - -} // namespace internal -} // namespace protobuf -} // namespace google - -#endif // GOOGLE_PROTOBUF_ATOMICOPS_INTERNALS_PNACL_H_ diff --git a/modules/dnn/3rdparty/protobuf/src/google/protobuf/stubs/atomicops_internals_x86_gcc.cc b/modules/dnn/3rdparty/protobuf/src/google/protobuf/stubs/atomicops_internals_x86_gcc.cc deleted file mode 100644 index 07748723f..000000000 --- a/modules/dnn/3rdparty/protobuf/src/google/protobuf/stubs/atomicops_internals_x86_gcc.cc +++ /dev/null @@ -1,137 +0,0 @@ -// Protocol Buffers - Google's data interchange format -// Copyright 2012 Google Inc. All rights reserved. -// http://code.google.com/p/protobuf/ -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -// This module gets enough CPU information to optimize the -// atomicops module on x86. - -#include - -#include - -// This file only makes sense with atomicops_internals_x86_gcc.h -- it -// depends on structs that are defined in that file. If atomicops.h -// doesn't sub-include that file, then we aren't needed, and shouldn't -// try to do anything. -#ifdef GOOGLE_PROTOBUF_ATOMICOPS_INTERNALS_X86_GCC_H_ - -// Inline cpuid instruction. In PIC compilations, %ebx contains the address -// of the global offset table. To avoid breaking such executables, this code -// must preserve that register's value across cpuid instructions. -#if defined(__i386__) -#define cpuid(a, b, c, d, inp) \ - asm("mov %%ebx, %%edi\n" \ - "cpuid\n" \ - "xchg %%edi, %%ebx\n" \ - : "=a" (a), "=D" (b), "=c" (c), "=d" (d) : "a" (inp)) -#elif defined(__x86_64__) -#define cpuid(a, b, c, d, inp) \ - asm("mov %%rbx, %%rdi\n" \ - "cpuid\n" \ - "xchg %%rdi, %%rbx\n" \ - : "=a" (a), "=D" (b), "=c" (c), "=d" (d) : "a" (inp)) -#endif - -#if defined(cpuid) // initialize the struct only on x86 - -namespace google { -namespace protobuf { -namespace internal { - -// Set the flags so that code will run correctly and conservatively, so even -// if we haven't been initialized yet, we're probably single threaded, and our -// default values should hopefully be pretty safe. -struct AtomicOps_x86CPUFeatureStruct AtomicOps_Internalx86CPUFeatures = { - false, // bug can't exist before process spawns multiple threads - false, // no SSE2 -}; - -namespace { - -// Initialize the AtomicOps_Internalx86CPUFeatures struct. -void AtomicOps_Internalx86CPUFeaturesInit() { - uint32_t eax; - uint32_t ebx; - uint32_t ecx; - uint32_t edx; - - // Get vendor string (issue CPUID with eax = 0) - cpuid(eax, ebx, ecx, edx, 0); - char vendor[13]; - memcpy(vendor, &ebx, 4); - memcpy(vendor + 4, &edx, 4); - memcpy(vendor + 8, &ecx, 4); - vendor[12] = 0; - - // get feature flags in ecx/edx, and family/model in eax - cpuid(eax, ebx, ecx, edx, 1); - - int family = (eax >> 8) & 0xf; // family and model fields - int model = (eax >> 4) & 0xf; - if (family == 0xf) { // use extended family and model fields - family += (eax >> 20) & 0xff; - model += ((eax >> 16) & 0xf) << 4; - } - - // Opteron Rev E has a bug in which on very rare occasions a locked - // instruction doesn't act as a read-acquire barrier if followed by a - // non-locked read-modify-write instruction. Rev F has this bug in - // pre-release versions, but not in versions released to customers, - // so we test only for Rev E, which is family 15, model 32..63 inclusive. - if (strcmp(vendor, "AuthenticAMD") == 0 && // AMD - family == 15 && - 32 <= model && model <= 63) { - AtomicOps_Internalx86CPUFeatures.has_amd_lock_mb_bug = true; - } else { - AtomicOps_Internalx86CPUFeatures.has_amd_lock_mb_bug = false; - } - - // edx bit 26 is SSE2 which we use to tell use whether we can use mfence - AtomicOps_Internalx86CPUFeatures.has_sse2 = ((edx >> 26) & 1); -} - -class AtomicOpsx86Initializer { - public: - AtomicOpsx86Initializer() { - AtomicOps_Internalx86CPUFeaturesInit(); - } -}; - -// A global to get use initialized on startup via static initialization :/ -AtomicOpsx86Initializer g_initer; - -} // namespace - -} // namespace internal -} // namespace protobuf -} // namespace google - -#endif // __i386__ - -#endif // GOOGLE_PROTOBUF_ATOMICOPS_INTERNALS_X86_GCC_H_ diff --git a/modules/dnn/3rdparty/protobuf/src/google/protobuf/stubs/atomicops_internals_x86_gcc.h b/modules/dnn/3rdparty/protobuf/src/google/protobuf/stubs/atomicops_internals_x86_gcc.h deleted file mode 100644 index 5324dfbcb..000000000 --- a/modules/dnn/3rdparty/protobuf/src/google/protobuf/stubs/atomicops_internals_x86_gcc.h +++ /dev/null @@ -1,293 +0,0 @@ -// Protocol Buffers - Google's data interchange format -// Copyright 2012 Google Inc. All rights reserved. -// http://code.google.com/p/protobuf/ -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -// This file is an internal atomic implementation, use atomicops.h instead. - -#ifndef GOOGLE_PROTOBUF_ATOMICOPS_INTERNALS_X86_GCC_H_ -#define GOOGLE_PROTOBUF_ATOMICOPS_INTERNALS_X86_GCC_H_ - -namespace google { -namespace protobuf { -namespace internal { - -// This struct is not part of the public API of this module; clients may not -// use it. -// Features of this x86. Values may not be correct before main() is run, -// but are set conservatively. -struct AtomicOps_x86CPUFeatureStruct { - bool has_amd_lock_mb_bug; // Processor has AMD memory-barrier bug; do lfence - // after acquire compare-and-swap. - bool has_sse2; // Processor has SSE2. -}; -extern struct AtomicOps_x86CPUFeatureStruct AtomicOps_Internalx86CPUFeatures; - -#define ATOMICOPS_COMPILER_BARRIER() __asm__ __volatile__("" : : : "memory") - -// 32-bit low-level operations on any platform. - -inline Atomic32 NoBarrier_CompareAndSwap(volatile Atomic32* ptr, - Atomic32 old_value, - Atomic32 new_value) { - Atomic32 prev; - __asm__ __volatile__("lock; cmpxchgl %1,%2" - : "=a" (prev) - : "q" (new_value), "m" (*ptr), "0" (old_value) - : "memory"); - return prev; -} - -inline Atomic32 NoBarrier_AtomicExchange(volatile Atomic32* ptr, - Atomic32 new_value) { - __asm__ __volatile__("xchgl %1,%0" // The lock prefix is implicit for xchg. - : "=r" (new_value) - : "m" (*ptr), "0" (new_value) - : "memory"); - return new_value; // Now it's the previous value. -} - -inline Atomic32 NoBarrier_AtomicIncrement(volatile Atomic32* ptr, - Atomic32 increment) { - Atomic32 temp = increment; - __asm__ __volatile__("lock; xaddl %0,%1" - : "+r" (temp), "+m" (*ptr) - : : "memory"); - // temp now holds the old value of *ptr - return temp + increment; -} - -inline Atomic32 Barrier_AtomicIncrement(volatile Atomic32* ptr, - Atomic32 increment) { - Atomic32 temp = increment; - __asm__ __volatile__("lock; xaddl %0,%1" - : "+r" (temp), "+m" (*ptr) - : : "memory"); - // temp now holds the old value of *ptr - if (AtomicOps_Internalx86CPUFeatures.has_amd_lock_mb_bug) { - __asm__ __volatile__("lfence" : : : "memory"); - } - return temp + increment; -} - -inline Atomic32 Acquire_CompareAndSwap(volatile Atomic32* ptr, - Atomic32 old_value, - Atomic32 new_value) { - Atomic32 x = NoBarrier_CompareAndSwap(ptr, old_value, new_value); - if (AtomicOps_Internalx86CPUFeatures.has_amd_lock_mb_bug) { - __asm__ __volatile__("lfence" : : : "memory"); - } - return x; -} - -inline Atomic32 Release_CompareAndSwap(volatile Atomic32* ptr, - Atomic32 old_value, - Atomic32 new_value) { - return NoBarrier_CompareAndSwap(ptr, old_value, new_value); -} - -inline void NoBarrier_Store(volatile Atomic32* ptr, Atomic32 value) { - *ptr = value; -} - -#if defined(__x86_64__) - -// 64-bit implementations of memory barrier can be simpler, because it -// "mfence" is guaranteed to exist. -inline void MemoryBarrier() { - __asm__ __volatile__("mfence" : : : "memory"); -} - -inline void Acquire_Store(volatile Atomic32* ptr, Atomic32 value) { - *ptr = value; - MemoryBarrier(); -} - -#else - -inline void MemoryBarrier() { - if (AtomicOps_Internalx86CPUFeatures.has_sse2) { - __asm__ __volatile__("mfence" : : : "memory"); - } else { // mfence is faster but not present on PIII - Atomic32 x = 0; - NoBarrier_AtomicExchange(&x, 0); // acts as a barrier on PIII - } -} - -inline void Acquire_Store(volatile Atomic32* ptr, Atomic32 value) { - if (AtomicOps_Internalx86CPUFeatures.has_sse2) { - *ptr = value; - __asm__ __volatile__("mfence" : : : "memory"); - } else { - NoBarrier_AtomicExchange(ptr, value); - // acts as a barrier on PIII - } -} -#endif - -inline void Release_Store(volatile Atomic32* ptr, Atomic32 value) { - ATOMICOPS_COMPILER_BARRIER(); - *ptr = value; // An x86 store acts as a release barrier. - // See comments in Atomic64 version of Release_Store(), below. -} - -inline Atomic32 NoBarrier_Load(volatile const Atomic32* ptr) { - return *ptr; -} - -inline Atomic32 Acquire_Load(volatile const Atomic32* ptr) { - Atomic32 value = *ptr; // An x86 load acts as a acquire barrier. - // See comments in Atomic64 version of Release_Store(), below. - ATOMICOPS_COMPILER_BARRIER(); - return value; -} - -inline Atomic32 Release_Load(volatile const Atomic32* ptr) { - MemoryBarrier(); - return *ptr; -} - -#if defined(__x86_64__) - -// 64-bit low-level operations on 64-bit platform. - -inline Atomic64 NoBarrier_CompareAndSwap(volatile Atomic64* ptr, - Atomic64 old_value, - Atomic64 new_value) { - Atomic64 prev; - __asm__ __volatile__("lock; cmpxchgq %1,%2" - : "=a" (prev) - : "q" (new_value), "m" (*ptr), "0" (old_value) - : "memory"); - return prev; -} - -inline Atomic64 NoBarrier_AtomicExchange(volatile Atomic64* ptr, - Atomic64 new_value) { - __asm__ __volatile__("xchgq %1,%0" // The lock prefix is implicit for xchg. - : "=r" (new_value) - : "m" (*ptr), "0" (new_value) - : "memory"); - return new_value; // Now it's the previous value. -} - -inline Atomic64 NoBarrier_AtomicIncrement(volatile Atomic64* ptr, - Atomic64 increment) { - Atomic64 temp = increment; - __asm__ __volatile__("lock; xaddq %0,%1" - : "+r" (temp), "+m" (*ptr) - : : "memory"); - // temp now contains the previous value of *ptr - return temp + increment; -} - -inline Atomic64 Barrier_AtomicIncrement(volatile Atomic64* ptr, - Atomic64 increment) { - Atomic64 temp = increment; - __asm__ __volatile__("lock; xaddq %0,%1" - : "+r" (temp), "+m" (*ptr) - : : "memory"); - // temp now contains the previous value of *ptr - if (AtomicOps_Internalx86CPUFeatures.has_amd_lock_mb_bug) { - __asm__ __volatile__("lfence" : : : "memory"); - } - return temp + increment; -} - -inline void NoBarrier_Store(volatile Atomic64* ptr, Atomic64 value) { - *ptr = value; -} - -inline void Acquire_Store(volatile Atomic64* ptr, Atomic64 value) { - *ptr = value; - MemoryBarrier(); -} - -inline void Release_Store(volatile Atomic64* ptr, Atomic64 value) { - ATOMICOPS_COMPILER_BARRIER(); - - *ptr = value; // An x86 store acts as a release barrier - // for current AMD/Intel chips as of Jan 2008. - // See also Acquire_Load(), below. - - // When new chips come out, check: - // IA-32 Intel Architecture Software Developer's Manual, Volume 3: - // System Programming Guide, Chatper 7: Multiple-processor management, - // Section 7.2, Memory Ordering. - // Last seen at: - // http://developer.intel.com/design/pentium4/manuals/index_new.htm - // - // x86 stores/loads fail to act as barriers for a few instructions (clflush - // maskmovdqu maskmovq movntdq movnti movntpd movntps movntq) but these are - // not generated by the compiler, and are rare. Users of these instructions - // need to know about cache behaviour in any case since all of these involve - // either flushing cache lines or non-temporal cache hints. -} - -inline Atomic64 NoBarrier_Load(volatile const Atomic64* ptr) { - return *ptr; -} - -inline Atomic64 Acquire_Load(volatile const Atomic64* ptr) { - Atomic64 value = *ptr; // An x86 load acts as a acquire barrier, - // for current AMD/Intel chips as of Jan 2008. - // See also Release_Store(), above. - ATOMICOPS_COMPILER_BARRIER(); - return value; -} - -inline Atomic64 Release_Load(volatile const Atomic64* ptr) { - MemoryBarrier(); - return *ptr; -} - -inline Atomic64 Acquire_CompareAndSwap(volatile Atomic64* ptr, - Atomic64 old_value, - Atomic64 new_value) { - Atomic64 x = NoBarrier_CompareAndSwap(ptr, old_value, new_value); - if (AtomicOps_Internalx86CPUFeatures.has_amd_lock_mb_bug) { - __asm__ __volatile__("lfence" : : : "memory"); - } - return x; -} - -inline Atomic64 Release_CompareAndSwap(volatile Atomic64* ptr, - Atomic64 old_value, - Atomic64 new_value) { - return NoBarrier_CompareAndSwap(ptr, old_value, new_value); -} - -#endif // defined(__x86_64__) - -} // namespace internal -} // namespace protobuf -} // namespace google - -#undef ATOMICOPS_COMPILER_BARRIER - -#endif // GOOGLE_PROTOBUF_ATOMICOPS_INTERNALS_X86_GCC_H_ diff --git a/modules/dnn/3rdparty/protobuf/src/google/protobuf/stubs/atomicops_internals_x86_msvc.cc b/modules/dnn/3rdparty/protobuf/src/google/protobuf/stubs/atomicops_internals_x86_msvc.cc deleted file mode 100644 index 0b359796e..000000000 --- a/modules/dnn/3rdparty/protobuf/src/google/protobuf/stubs/atomicops_internals_x86_msvc.cc +++ /dev/null @@ -1,112 +0,0 @@ -// Protocol Buffers - Google's data interchange format -// Copyright 2012 Google Inc. All rights reserved. -// http://code.google.com/p/protobuf/ -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -// The compilation of extension_set.cc fails when windows.h is included. -// Therefore we move the code depending on windows.h to this separate cc file. - -// Don't compile this file for people not concerned about thread safety. -#ifndef GOOGLE_PROTOBUF_NO_THREAD_SAFETY - -#include - -#ifdef GOOGLE_PROTOBUF_ATOMICOPS_INTERNALS_X86_MSVC_H_ - -#include - -namespace google { -namespace protobuf { -namespace internal { - -inline void MemoryBarrier() { - // We use MemoryBarrier from WinNT.h - ::MemoryBarrier(); -} - -Atomic32 NoBarrier_CompareAndSwap(volatile Atomic32* ptr, - Atomic32 old_value, - Atomic32 new_value) { - LONG result = InterlockedCompareExchange( - reinterpret_cast(ptr), - static_cast(new_value), - static_cast(old_value)); - return static_cast(result); -} - -Atomic32 NoBarrier_AtomicExchange(volatile Atomic32* ptr, - Atomic32 new_value) { - LONG result = InterlockedExchange( - reinterpret_cast(ptr), - static_cast(new_value)); - return static_cast(result); -} - -Atomic32 Barrier_AtomicIncrement(volatile Atomic32* ptr, - Atomic32 increment) { - return InterlockedExchangeAdd( - reinterpret_cast(ptr), - static_cast(increment)) + increment; -} - -#if defined(_WIN64) - -// 64-bit low-level operations on 64-bit platform. - -Atomic64 NoBarrier_CompareAndSwap(volatile Atomic64* ptr, - Atomic64 old_value, - Atomic64 new_value) { - PVOID result = InterlockedCompareExchangePointer( - reinterpret_cast(ptr), - reinterpret_cast(new_value), reinterpret_cast(old_value)); - return reinterpret_cast(result); -} - -Atomic64 NoBarrier_AtomicExchange(volatile Atomic64* ptr, - Atomic64 new_value) { - PVOID result = InterlockedExchangePointer( - reinterpret_cast(ptr), - reinterpret_cast(new_value)); - return reinterpret_cast(result); -} - -Atomic64 Barrier_AtomicIncrement(volatile Atomic64* ptr, - Atomic64 increment) { - return InterlockedExchangeAdd64( - reinterpret_cast(ptr), - static_cast(increment)) + increment; -} - -#endif // defined(_WIN64) - -} // namespace internal -} // namespace protobuf -} // namespace google - -#endif // GOOGLE_PROTOBUF_ATOMICOPS_INTERNALS_X86_MSVC_H_ -#endif // GOOGLE_PROTOBUF_NO_THREAD_SAFETY diff --git a/modules/dnn/3rdparty/protobuf/src/google/protobuf/stubs/atomicops_internals_x86_msvc.h b/modules/dnn/3rdparty/protobuf/src/google/protobuf/stubs/atomicops_internals_x86_msvc.h deleted file mode 100644 index 6f9869d1f..000000000 --- a/modules/dnn/3rdparty/protobuf/src/google/protobuf/stubs/atomicops_internals_x86_msvc.h +++ /dev/null @@ -1,150 +0,0 @@ -// Protocol Buffers - Google's data interchange format -// Copyright 2012 Google Inc. All rights reserved. -// http://code.google.com/p/protobuf/ -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -// This file is an internal atomic implementation, use atomicops.h instead. - -#ifndef GOOGLE_PROTOBUF_ATOMICOPS_INTERNALS_X86_MSVC_H_ -#define GOOGLE_PROTOBUF_ATOMICOPS_INTERNALS_X86_MSVC_H_ - -namespace google { -namespace protobuf { -namespace internal { - -inline Atomic32 NoBarrier_AtomicIncrement(volatile Atomic32* ptr, - Atomic32 increment) { - return Barrier_AtomicIncrement(ptr, increment); -} - -#if !(defined(_MSC_VER) && _MSC_VER >= 1400) -#error "We require at least vs2005 for MemoryBarrier" -#endif - -inline Atomic32 Acquire_CompareAndSwap(volatile Atomic32* ptr, - Atomic32 old_value, - Atomic32 new_value) { - return NoBarrier_CompareAndSwap(ptr, old_value, new_value); -} - -inline Atomic32 Release_CompareAndSwap(volatile Atomic32* ptr, - Atomic32 old_value, - Atomic32 new_value) { - return NoBarrier_CompareAndSwap(ptr, old_value, new_value); -} - -inline void NoBarrier_Store(volatile Atomic32* ptr, Atomic32 value) { - *ptr = value; -} - -inline void Acquire_Store(volatile Atomic32* ptr, Atomic32 value) { - NoBarrier_AtomicExchange(ptr, value); - // acts as a barrier in this implementation -} - -inline void Release_Store(volatile Atomic32* ptr, Atomic32 value) { - *ptr = value; // works w/o barrier for current Intel chips as of June 2005 - // See comments in Atomic64 version of Release_Store() below. -} - -inline Atomic32 NoBarrier_Load(volatile const Atomic32* ptr) { - return *ptr; -} - -inline Atomic32 Acquire_Load(volatile const Atomic32* ptr) { - Atomic32 value = *ptr; - return value; -} - -inline Atomic32 Release_Load(volatile const Atomic32* ptr) { - MemoryBarrier(); - return *ptr; -} - -#if defined(_WIN64) - -// 64-bit low-level operations on 64-bit platform. - -inline Atomic64 NoBarrier_AtomicIncrement(volatile Atomic64* ptr, - Atomic64 increment) { - return Barrier_AtomicIncrement(ptr, increment); -} - -inline void NoBarrier_Store(volatile Atomic64* ptr, Atomic64 value) { - *ptr = value; -} - -inline void Acquire_Store(volatile Atomic64* ptr, Atomic64 value) { - NoBarrier_AtomicExchange(ptr, value); - // acts as a barrier in this implementation -} - -inline void Release_Store(volatile Atomic64* ptr, Atomic64 value) { - *ptr = value; // works w/o barrier for current Intel chips as of June 2005 - - // When new chips come out, check: - // IA-32 Intel Architecture Software Developer's Manual, Volume 3: - // System Programming Guide, Chatper 7: Multiple-processor management, - // Section 7.2, Memory Ordering. - // Last seen at: - // http://developer.intel.com/design/pentium4/manuals/index_new.htm -} - -inline Atomic64 NoBarrier_Load(volatile const Atomic64* ptr) { - return *ptr; -} - -inline Atomic64 Acquire_Load(volatile const Atomic64* ptr) { - Atomic64 value = *ptr; - return value; -} - -inline Atomic64 Release_Load(volatile const Atomic64* ptr) { - MemoryBarrier(); - return *ptr; -} - -inline Atomic64 Acquire_CompareAndSwap(volatile Atomic64* ptr, - Atomic64 old_value, - Atomic64 new_value) { - return NoBarrier_CompareAndSwap(ptr, old_value, new_value); -} - -inline Atomic64 Release_CompareAndSwap(volatile Atomic64* ptr, - Atomic64 old_value, - Atomic64 new_value) { - return NoBarrier_CompareAndSwap(ptr, old_value, new_value); -} - -#endif // defined(_WIN64) - -} // namespace internal -} // namespace protobuf -} // namespace google - -#endif // GOOGLE_PROTOBUF_ATOMICOPS_INTERNALS_X86_MSVC_H_ diff --git a/modules/dnn/3rdparty/protobuf/src/google/protobuf/stubs/common.cc b/modules/dnn/3rdparty/protobuf/src/google/protobuf/stubs/common.cc deleted file mode 100644 index e60450267..000000000 --- a/modules/dnn/3rdparty/protobuf/src/google/protobuf/stubs/common.cc +++ /dev/null @@ -1,395 +0,0 @@ -// Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// http://code.google.com/p/protobuf/ -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -// Author: kenton@google.com (Kenton Varda) - -#include -#include -#include -#include -#include - -#include "config.h" - -#ifdef _WIN32 -#define WIN32_LEAN_AND_MEAN // We only need minimal includes -#include -#define snprintf _snprintf // see comment in strutil.cc -#elif defined(HAVE_PTHREAD) -#include -#else -#error "No suitable threading library available." -#endif - -namespace google { -namespace protobuf { - -namespace internal { - -void VerifyVersion(int headerVersion, - int minLibraryVersion, - const char* filename) { - if (GOOGLE_PROTOBUF_VERSION < minLibraryVersion) { - // Library is too old for headers. - GOOGLE_LOG(FATAL) - << "This program requires version " << VersionString(minLibraryVersion) - << " of the Protocol Buffer runtime library, but the installed version " - "is " << VersionString(GOOGLE_PROTOBUF_VERSION) << ". Please update " - "your library. If you compiled the program yourself, make sure that " - "your headers are from the same version of Protocol Buffers as your " - "link-time library. (Version verification failed in \"" - << filename << "\".)"; - } - if (headerVersion < kMinHeaderVersionForLibrary) { - // Headers are too old for library. - GOOGLE_LOG(FATAL) - << "This program was compiled against version " - << VersionString(headerVersion) << " of the Protocol Buffer runtime " - "library, which is not compatible with the installed version (" - << VersionString(GOOGLE_PROTOBUF_VERSION) << "). Contact the program " - "author for an update. If you compiled the program yourself, make " - "sure that your headers are from the same version of Protocol Buffers " - "as your link-time library. (Version verification failed in \"" - << filename << "\".)"; - } -} - -string VersionString(int version) { - int major = version / 1000000; - int minor = (version / 1000) % 1000; - int micro = version % 1000; - - // 128 bytes should always be enough, but we use snprintf() anyway to be - // safe. - char buffer[128]; - snprintf(buffer, sizeof(buffer), "%d.%d.%d", major, minor, micro); - - // Guard against broken MSVC snprintf(). - buffer[sizeof(buffer)-1] = '\0'; - - return buffer; -} - -} // namespace internal - -// =================================================================== -// emulates google3/base/logging.cc - -namespace internal { - -void DefaultLogHandler(LogLevel level, const char* filename, int line, - const string& message) { - static const char* level_names[] = { "INFO", "WARNING", "ERROR", "FATAL" }; - - // We use fprintf() instead of cerr because we want this to work at static - // initialization time. - fprintf(stderr, "[libprotobuf %s %s:%d] %s\n", - level_names[level], filename, line, message.c_str()); - fflush(stderr); // Needed on MSVC. -} - -void NullLogHandler(LogLevel level, const char* filename, int line, - const string& message) { - // Nothing. -} - -static LogHandler* log_handler_ = &DefaultLogHandler; -static int log_silencer_count_ = 0; - -static Mutex* log_silencer_count_mutex_ = NULL; -GOOGLE_PROTOBUF_DECLARE_ONCE(log_silencer_count_init_); - -void DeleteLogSilencerCount() { - delete log_silencer_count_mutex_; - log_silencer_count_mutex_ = NULL; -} -void InitLogSilencerCount() { - log_silencer_count_mutex_ = new Mutex; - OnShutdown(&DeleteLogSilencerCount); -} -void InitLogSilencerCountOnce() { - GoogleOnceInit(&log_silencer_count_init_, &InitLogSilencerCount); -} - -LogMessage& LogMessage::operator<<(const string& value) { - message_ += value; - return *this; -} - -LogMessage& LogMessage::operator<<(const char* value) { - message_ += value; - return *this; -} - -// Since this is just for logging, we don't care if the current locale changes -// the results -- in fact, we probably prefer that. So we use snprintf() -// instead of Simple*toa(). -#undef DECLARE_STREAM_OPERATOR -#define DECLARE_STREAM_OPERATOR(TYPE, FORMAT) \ - LogMessage& LogMessage::operator<<(TYPE value) { \ - /* 128 bytes should be big enough for any of the primitive */ \ - /* values which we print with this, but well use snprintf() */ \ - /* anyway to be extra safe. */ \ - char buffer[128]; \ - snprintf(buffer, sizeof(buffer), FORMAT, value); \ - /* Guard against broken MSVC snprintf(). */ \ - buffer[sizeof(buffer)-1] = '\0'; \ - message_ += buffer; \ - return *this; \ - } - -DECLARE_STREAM_OPERATOR(char , "%c" ) -DECLARE_STREAM_OPERATOR(int , "%d" ) -DECLARE_STREAM_OPERATOR(uint , "%u" ) -DECLARE_STREAM_OPERATOR(long , "%ld") -DECLARE_STREAM_OPERATOR(unsigned long, "%lu") -DECLARE_STREAM_OPERATOR(double , "%g" ) -#undef DECLARE_STREAM_OPERATOR - -LogMessage::LogMessage(LogLevel level, const char* filename, int line) - : level_(level), filename_(filename), line_(line) {} -LogMessage::~LogMessage() {} - -void LogMessage::Finish() { - bool suppress = false; - - if (level_ != LOGLEVEL_FATAL) { - InitLogSilencerCountOnce(); - MutexLock lock(log_silencer_count_mutex_); - suppress = log_silencer_count_ > 0; - } - - if (!suppress) { - log_handler_(level_, filename_, line_, message_); - } - - if (level_ == LOGLEVEL_FATAL) { -#if PROTOBUF_USE_EXCEPTIONS - throw FatalException(filename_, line_, message_); -#else - abort(); -#endif - } -} - -void LogFinisher::operator=(LogMessage& other) { - other.Finish(); -} - -} // namespace internal - -LogHandler* SetLogHandler(LogHandler* new_func) { - LogHandler* old = internal::log_handler_; - if (old == &internal::NullLogHandler) { - old = NULL; - } - if (new_func == NULL) { - internal::log_handler_ = &internal::NullLogHandler; - } else { - internal::log_handler_ = new_func; - } - return old; -} - -LogSilencer::LogSilencer() { - internal::InitLogSilencerCountOnce(); - MutexLock lock(internal::log_silencer_count_mutex_); - ++internal::log_silencer_count_; -}; - -LogSilencer::~LogSilencer() { - internal::InitLogSilencerCountOnce(); - MutexLock lock(internal::log_silencer_count_mutex_); - --internal::log_silencer_count_; -}; - -// =================================================================== -// emulates google3/base/callback.cc - -Closure::~Closure() {} - -namespace internal { FunctionClosure0::~FunctionClosure0() {} } - -void DoNothing() {} - -// =================================================================== -// emulates google3/base/mutex.cc - -#ifdef _WIN32 - -struct Mutex::Internal { - CRITICAL_SECTION mutex; -#ifndef NDEBUG - // Used only to implement AssertHeld(). - DWORD thread_id; -#endif -}; - -Mutex::Mutex() - : mInternal(new Internal) { - InitializeCriticalSection(&mInternal->mutex); -} - -Mutex::~Mutex() { - DeleteCriticalSection(&mInternal->mutex); - delete mInternal; -} - -void Mutex::Lock() { - EnterCriticalSection(&mInternal->mutex); -#ifndef NDEBUG - mInternal->thread_id = GetCurrentThreadId(); -#endif -} - -void Mutex::Unlock() { -#ifndef NDEBUG - mInternal->thread_id = 0; -#endif - LeaveCriticalSection(&mInternal->mutex); -} - -void Mutex::AssertHeld() { -#ifndef NDEBUG - GOOGLE_DCHECK_EQ(mInternal->thread_id, GetCurrentThreadId()); -#endif -} - -#elif defined(HAVE_PTHREAD) - -struct Mutex::Internal { - pthread_mutex_t mutex; -}; - -Mutex::Mutex() - : mInternal(new Internal) { - pthread_mutex_init(&mInternal->mutex, NULL); -} - -Mutex::~Mutex() { - pthread_mutex_destroy(&mInternal->mutex); - delete mInternal; -} - -void Mutex::Lock() { - int result = pthread_mutex_lock(&mInternal->mutex); - if (result != 0) { - GOOGLE_LOG(FATAL) << "pthread_mutex_lock: " << strerror(result); - } -} - -void Mutex::Unlock() { - int result = pthread_mutex_unlock(&mInternal->mutex); - if (result != 0) { - GOOGLE_LOG(FATAL) << "pthread_mutex_unlock: " << strerror(result); - } -} - -void Mutex::AssertHeld() { - // pthreads dosn't provide a way to check which thread holds the mutex. - // TODO(kenton): Maybe keep track of locking thread ID like with WIN32? -} - -#endif - -// =================================================================== -// emulates google3/util/endian/endian.h -// -// TODO(xiaofeng): PROTOBUF_LITTLE_ENDIAN is unfortunately defined in -// google/protobuf/io/coded_stream.h and therefore can not be used here. -// Maybe move that macro definition here in the furture. -uint32 ghtonl(uint32 x) { - union { - uint32 result; - uint8 result_array[4]; - }; - result_array[0] = static_cast(x >> 24); - result_array[1] = static_cast((x >> 16) & 0xFF); - result_array[2] = static_cast((x >> 8) & 0xFF); - result_array[3] = static_cast(x & 0xFF); - return result; -} - -// =================================================================== -// Shutdown support. - -namespace internal { - -typedef void OnShutdownFunc(); -vector* shutdown_functions = NULL; -Mutex* shutdown_functions_mutex = NULL; -GOOGLE_PROTOBUF_DECLARE_ONCE(shutdown_functions_init); - -void InitShutdownFunctions() { - shutdown_functions = new vector; - shutdown_functions_mutex = new Mutex; -} - -inline void InitShutdownFunctionsOnce() { - GoogleOnceInit(&shutdown_functions_init, &InitShutdownFunctions); -} - -void OnShutdown(void (*func)()) { - InitShutdownFunctionsOnce(); - MutexLock lock(shutdown_functions_mutex); - shutdown_functions->push_back(func); -} - -} // namespace internal - -void ShutdownProtobufLibrary() { - internal::InitShutdownFunctionsOnce(); - - // We don't need to lock shutdown_functions_mutex because it's up to the - // caller to make sure that no one is using the library before this is - // called. - - // Make it safe to call this multiple times. - if (internal::shutdown_functions == NULL) return; - - for (int i = 0; i < internal::shutdown_functions->size(); i++) { - internal::shutdown_functions->at(i)(); - } - delete internal::shutdown_functions; - internal::shutdown_functions = NULL; - delete internal::shutdown_functions_mutex; - internal::shutdown_functions_mutex = NULL; -} - -#if PROTOBUF_USE_EXCEPTIONS -FatalException::~FatalException() throw() {} - -const char* FatalException::what() const throw() { - return message_.c_str(); -} -#endif - -} // namespace protobuf -} // namespace google diff --git a/modules/dnn/3rdparty/protobuf/src/google/protobuf/stubs/common.h b/modules/dnn/3rdparty/protobuf/src/google/protobuf/stubs/common.h deleted file mode 100644 index f287ddfbc..000000000 --- a/modules/dnn/3rdparty/protobuf/src/google/protobuf/stubs/common.h +++ /dev/null @@ -1,1223 +0,0 @@ -// Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// http://code.google.com/p/protobuf/ -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -// Author: kenton@google.com (Kenton Varda) and others -// -// Contains basic types and utilities used by the rest of the library. - -#ifndef GOOGLE_PROTOBUF_COMMON_H__ -#define GOOGLE_PROTOBUF_COMMON_H__ - -#include -#include -#include -#include -#include -#if defined(__osf__) -// Tru64 lacks stdint.h, but has inttypes.h which defines a superset of -// what stdint.h would define. -#include -#elif !defined(_MSC_VER) -#include -#endif - -#ifndef PROTOBUF_USE_EXCEPTIONS -#if defined(_MSC_VER) && defined(_CPPUNWIND) - #define PROTOBUF_USE_EXCEPTIONS 1 -#elif defined(__EXCEPTIONS) - #define PROTOBUF_USE_EXCEPTIONS 1 -#else - #define PROTOBUF_USE_EXCEPTIONS 0 -#endif -#endif - -#if PROTOBUF_USE_EXCEPTIONS -#include -#endif - -#if defined(_WIN32) && defined(GetMessage) -// Allow GetMessage to be used as a valid method name in protobuf classes. -// windows.h defines GetMessage() as a macro. Let's re-define it as an inline -// function. The inline function should be equivalent for C++ users. -inline BOOL GetMessage_Win32( - LPMSG lpMsg, HWND hWnd, - UINT wMsgFilterMin, UINT wMsgFilterMax) { - return GetMessage(lpMsg, hWnd, wMsgFilterMin, wMsgFilterMax); -} -#undef GetMessage -inline BOOL GetMessage( - LPMSG lpMsg, HWND hWnd, - UINT wMsgFilterMin, UINT wMsgFilterMax) { - return GetMessage_Win32(lpMsg, hWnd, wMsgFilterMin, wMsgFilterMax); -} -#endif - - -namespace std {} - -namespace google { -namespace protobuf { - -#undef GOOGLE_DISALLOW_EVIL_CONSTRUCTORS -#define GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(TypeName) \ - TypeName(const TypeName&); \ - void operator=(const TypeName&) - -#if defined(_MSC_VER) && defined(PROTOBUF_USE_DLLS) - #ifdef LIBPROTOBUF_EXPORTS - #define LIBPROTOBUF_EXPORT __declspec(dllexport) - #else - #define LIBPROTOBUF_EXPORT __declspec(dllimport) - #endif - #ifdef LIBPROTOC_EXPORTS - #define LIBPROTOC_EXPORT __declspec(dllexport) - #else - #define LIBPROTOC_EXPORT __declspec(dllimport) - #endif -#else - #define LIBPROTOBUF_EXPORT - #define LIBPROTOC_EXPORT -#endif - -namespace internal { - -// Some of these constants are macros rather than const ints so that they can -// be used in #if directives. - -// The current version, represented as a single integer to make comparison -// easier: major * 10^6 + minor * 10^3 + micro -#define GOOGLE_PROTOBUF_VERSION 2005000 - -// The minimum library version which works with the current version of the -// headers. -#define GOOGLE_PROTOBUF_MIN_LIBRARY_VERSION 2005000 - -// The minimum header version which works with the current version of -// the library. This constant should only be used by protoc's C++ code -// generator. -static const int kMinHeaderVersionForLibrary = 2005000; - -// The minimum protoc version which works with the current version of the -// headers. -#define GOOGLE_PROTOBUF_MIN_PROTOC_VERSION 2005000 - -// The minimum header version which works with the current version of -// protoc. This constant should only be used in VerifyVersion(). -static const int kMinHeaderVersionForProtoc = 2005000; - -// Verifies that the headers and libraries are compatible. Use the macro -// below to call this. -void LIBPROTOBUF_EXPORT VerifyVersion(int headerVersion, int minLibraryVersion, - const char* filename); - -// Converts a numeric version number to a string. -std::string LIBPROTOBUF_EXPORT VersionString(int version); - -} // namespace internal - -// Place this macro in your main() function (or somewhere before you attempt -// to use the protobuf library) to verify that the version you link against -// matches the headers you compiled against. If a version mismatch is -// detected, the process will abort. -#define GOOGLE_PROTOBUF_VERIFY_VERSION \ - ::google::protobuf::internal::VerifyVersion( \ - GOOGLE_PROTOBUF_VERSION, GOOGLE_PROTOBUF_MIN_LIBRARY_VERSION, \ - __FILE__) - -// =================================================================== -// from google3/base/port.h - -typedef unsigned int uint; - -#ifdef _MSC_VER -typedef __int8 int8; -typedef __int16 int16; -typedef __int32 int32; -typedef __int64 int64; - -typedef unsigned __int8 uint8; -typedef unsigned __int16 uint16; -typedef unsigned __int32 uint32; -typedef unsigned __int64 uint64; -#else -typedef int8_t int8; -typedef int16_t int16; -typedef int32_t int32; -typedef int64_t int64; - -typedef uint8_t uint8; -typedef uint16_t uint16; -typedef uint32_t uint32; -typedef uint64_t uint64; -#endif - -// long long macros to be used because gcc and vc++ use different suffixes, -// and different size specifiers in format strings -#undef GOOGLE_LONGLONG -#undef GOOGLE_ULONGLONG -#undef GOOGLE_LL_FORMAT - -#ifdef _MSC_VER -#define GOOGLE_LONGLONG(x) x##I64 -#define GOOGLE_ULONGLONG(x) x##UI64 -#define GOOGLE_LL_FORMAT "I64" // As in printf("%I64d", ...) -#else -#define GOOGLE_LONGLONG(x) x##LL -#define GOOGLE_ULONGLONG(x) x##ULL -#define GOOGLE_LL_FORMAT "ll" // As in "%lld". Note that "q" is poor form also. -#endif - -static const int32 kint32max = 0x7FFFFFFF; -static const int32 kint32min = -kint32max - 1; -static const int64 kint64max = GOOGLE_LONGLONG(0x7FFFFFFFFFFFFFFF); -static const int64 kint64min = -kint64max - 1; -static const uint32 kuint32max = 0xFFFFFFFFu; -static const uint64 kuint64max = GOOGLE_ULONGLONG(0xFFFFFFFFFFFFFFFF); - -// ------------------------------------------------------------------- -// Annotations: Some parts of the code have been annotated in ways that might -// be useful to some compilers or tools, but are not supported universally. -// You can #define these annotations yourself if the default implementation -// is not right for you. - -#ifndef GOOGLE_ATTRIBUTE_ALWAYS_INLINE -#if defined(__GNUC__) && (__GNUC__ > 3 ||(__GNUC__ == 3 && __GNUC_MINOR__ >= 1)) -// For functions we want to force inline. -// Introduced in gcc 3.1. -#define GOOGLE_ATTRIBUTE_ALWAYS_INLINE __attribute__ ((always_inline)) -#else -// Other compilers will have to figure it out for themselves. -#define GOOGLE_ATTRIBUTE_ALWAYS_INLINE -#endif -#endif - -#ifndef GOOGLE_ATTRIBUTE_DEPRECATED -#ifdef __GNUC__ -// If the method/variable/type is used anywhere, produce a warning. -#define GOOGLE_ATTRIBUTE_DEPRECATED __attribute__((deprecated)) -#else -#define GOOGLE_ATTRIBUTE_DEPRECATED -#endif -#endif - -#ifndef GOOGLE_PREDICT_TRUE -#ifdef __GNUC__ -// Provided at least since GCC 3.0. -#define GOOGLE_PREDICT_TRUE(x) (__builtin_expect(!!(x), 1)) -#else -#define GOOGLE_PREDICT_TRUE -#endif -#endif - -// Delimits a block of code which may write to memory which is simultaneously -// written by other threads, but which has been determined to be thread-safe -// (e.g. because it is an idempotent write). -#ifndef GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN -#define GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN() -#endif -#ifndef GOOGLE_SAFE_CONCURRENT_WRITES_END -#define GOOGLE_SAFE_CONCURRENT_WRITES_END() -#endif - -// =================================================================== -// from google3/base/basictypes.h - -// The GOOGLE_ARRAYSIZE(arr) macro returns the # of elements in an array arr. -// The expression is a compile-time constant, and therefore can be -// used in defining new arrays, for example. -// -// GOOGLE_ARRAYSIZE catches a few type errors. If you see a compiler error -// -// "warning: division by zero in ..." -// -// when using GOOGLE_ARRAYSIZE, you are (wrongfully) giving it a pointer. -// You should only use GOOGLE_ARRAYSIZE on statically allocated arrays. -// -// The following comments are on the implementation details, and can -// be ignored by the users. -// -// ARRAYSIZE(arr) works by inspecting sizeof(arr) (the # of bytes in -// the array) and sizeof(*(arr)) (the # of bytes in one array -// element). If the former is divisible by the latter, perhaps arr is -// indeed an array, in which case the division result is the # of -// elements in the array. Otherwise, arr cannot possibly be an array, -// and we generate a compiler error to prevent the code from -// compiling. -// -// Since the size of bool is implementation-defined, we need to cast -// !(sizeof(a) & sizeof(*(a))) to size_t in order to ensure the final -// result has type size_t. -// -// This macro is not perfect as it wrongfully accepts certain -// pointers, namely where the pointer size is divisible by the pointee -// size. Since all our code has to go through a 32-bit compiler, -// where a pointer is 4 bytes, this means all pointers to a type whose -// size is 3 or greater than 4 will be (righteously) rejected. -// -// Kudos to Jorg Brown for this simple and elegant implementation. - -#undef GOOGLE_ARRAYSIZE -#define GOOGLE_ARRAYSIZE(a) \ - ((sizeof(a) / sizeof(*(a))) / \ - static_cast(!(sizeof(a) % sizeof(*(a))))) - -namespace internal { - -// Use implicit_cast as a safe version of static_cast or const_cast -// for upcasting in the type hierarchy (i.e. casting a pointer to Foo -// to a pointer to SuperclassOfFoo or casting a pointer to Foo to -// a const pointer to Foo). -// When you use implicit_cast, the compiler checks that the cast is safe. -// Such explicit implicit_casts are necessary in surprisingly many -// situations where C++ demands an exact type match instead of an -// argument type convertable to a target type. -// -// The From type can be inferred, so the preferred syntax for using -// implicit_cast is the same as for static_cast etc.: -// -// implicit_cast(expr) -// -// implicit_cast would have been part of the C++ standard library, -// but the proposal was submitted too late. It will probably make -// its way into the language in the future. -template -inline To implicit_cast(From const &f) { - return f; -} - -// When you upcast (that is, cast a pointer from type Foo to type -// SuperclassOfFoo), it's fine to use implicit_cast<>, since upcasts -// always succeed. When you downcast (that is, cast a pointer from -// type Foo to type SubclassOfFoo), static_cast<> isn't safe, because -// how do you know the pointer is really of type SubclassOfFoo? It -// could be a bare Foo, or of type DifferentSubclassOfFoo. Thus, -// when you downcast, you should use this macro. In debug mode, we -// use dynamic_cast<> to double-check the downcast is legal (we die -// if it's not). In normal mode, we do the efficient static_cast<> -// instead. Thus, it's important to test in debug mode to make sure -// the cast is legal! -// This is the only place in the code we should use dynamic_cast<>. -// In particular, you SHOULDN'T be using dynamic_cast<> in order to -// do RTTI (eg code like this: -// if (dynamic_cast(foo)) HandleASubclass1Object(foo); -// if (dynamic_cast(foo)) HandleASubclass2Object(foo); -// You should design the code some other way not to need this. - -template // use like this: down_cast(foo); -inline To down_cast(From* f) { // so we only accept pointers - // Ensures that To is a sub-type of From *. This test is here only - // for compile-time type checking, and has no overhead in an - // optimized build at run-time, as it will be optimized away - // completely. - if (false) { - implicit_cast(0); - } - -#if !defined(NDEBUG) && !defined(GOOGLE_PROTOBUF_NO_RTTI) - assert(f == NULL || dynamic_cast(f) != NULL); // RTTI: debug mode only! -#endif - return static_cast(f); -} - -} // namespace internal - -// We made these internal so that they would show up as such in the docs, -// but we don't want to stick "internal::" in front of them everywhere. -using internal::implicit_cast; -using internal::down_cast; - -// The COMPILE_ASSERT macro can be used to verify that a compile time -// expression is true. For example, you could use it to verify the -// size of a static array: -// -// COMPILE_ASSERT(ARRAYSIZE(content_type_names) == CONTENT_NUM_TYPES, -// content_type_names_incorrect_size); -// -// or to make sure a struct is smaller than a certain size: -// -// COMPILE_ASSERT(sizeof(foo) < 128, foo_too_large); -// -// The second argument to the macro is the name of the variable. If -// the expression is false, most compilers will issue a warning/error -// containing the name of the variable. - -namespace internal { - -template -struct CompileAssert { -}; - -} // namespace internal - -#undef GOOGLE_COMPILE_ASSERT -#define GOOGLE_COMPILE_ASSERT(expr, msg) \ - typedef ::google::protobuf::internal::CompileAssert<(bool(expr))> \ - msg[bool(expr) ? 1 : -1] - - -// Implementation details of COMPILE_ASSERT: -// -// - COMPILE_ASSERT works by defining an array type that has -1 -// elements (and thus is invalid) when the expression is false. -// -// - The simpler definition -// -// #define COMPILE_ASSERT(expr, msg) typedef char msg[(expr) ? 1 : -1] -// -// does not work, as gcc supports variable-length arrays whose sizes -// are determined at run-time (this is gcc's extension and not part -// of the C++ standard). As a result, gcc fails to reject the -// following code with the simple definition: -// -// int foo; -// COMPILE_ASSERT(foo, msg); // not supposed to compile as foo is -// // not a compile-time constant. -// -// - By using the type CompileAssert<(bool(expr))>, we ensures that -// expr is a compile-time constant. (Template arguments must be -// determined at compile-time.) -// -// - The outter parentheses in CompileAssert<(bool(expr))> are necessary -// to work around a bug in gcc 3.4.4 and 4.0.1. If we had written -// -// CompileAssert -// -// instead, these compilers will refuse to compile -// -// COMPILE_ASSERT(5 > 0, some_message); -// -// (They seem to think the ">" in "5 > 0" marks the end of the -// template argument list.) -// -// - The array size is (bool(expr) ? 1 : -1), instead of simply -// -// ((expr) ? 1 : -1). -// -// This is to avoid running into a bug in MS VC 7.1, which -// causes ((0.0) ? 1 : -1) to incorrectly evaluate to 1. - -// =================================================================== -// from google3/base/scoped_ptr.h - -namespace internal { - -// This is an implementation designed to match the anticipated future TR2 -// implementation of the scoped_ptr class, and its closely-related brethren, -// scoped_array, scoped_ptr_malloc, and make_scoped_ptr. - -template class scoped_ptr; -template class scoped_array; - -// A scoped_ptr is like a T*, except that the destructor of scoped_ptr -// automatically deletes the pointer it holds (if any). -// That is, scoped_ptr owns the T object that it points to. -// Like a T*, a scoped_ptr may hold either NULL or a pointer to a T object. -// -// The size of a scoped_ptr is small: -// sizeof(scoped_ptr) == sizeof(C*) -template -class scoped_ptr { - public: - - // The element type - typedef C element_type; - - // Constructor. Defaults to intializing with NULL. - // There is no way to create an uninitialized scoped_ptr. - // The input parameter must be allocated with new. - explicit scoped_ptr(C* p = NULL) : ptr_(p) { } - - // Destructor. If there is a C object, delete it. - // We don't need to test ptr_ == NULL because C++ does that for us. - ~scoped_ptr() { - enum { type_must_be_complete = sizeof(C) }; - delete ptr_; - } - - // Reset. Deletes the current owned object, if any. - // Then takes ownership of a new object, if given. - // this->reset(this->get()) works. - void reset(C* p = NULL) { - if (p != ptr_) { - enum { type_must_be_complete = sizeof(C) }; - delete ptr_; - ptr_ = p; - } - } - - // Accessors to get the owned object. - // operator* and operator-> will assert() if there is no current object. - C& operator*() const { - assert(ptr_ != NULL); - return *ptr_; - } - C* operator->() const { - assert(ptr_ != NULL); - return ptr_; - } - C* get() const { return ptr_; } - - // Comparison operators. - // These return whether two scoped_ptr refer to the same object, not just to - // two different but equal objects. - bool operator==(C* p) const { return ptr_ == p; } - bool operator!=(C* p) const { return ptr_ != p; } - - // Swap two scoped pointers. - void swap(scoped_ptr& p2) { - C* tmp = ptr_; - ptr_ = p2.ptr_; - p2.ptr_ = tmp; - } - - // Release a pointer. - // The return value is the current pointer held by this object. - // If this object holds a NULL pointer, the return value is NULL. - // After this operation, this object will hold a NULL pointer, - // and will not own the object any more. - C* release() { - C* retVal = ptr_; - ptr_ = NULL; - return retVal; - } - - private: - C* ptr_; - - // Forbid comparison of scoped_ptr types. If C2 != C, it totally doesn't - // make sense, and if C2 == C, it still doesn't make sense because you should - // never have the same object owned by two different scoped_ptrs. - template bool operator==(scoped_ptr const& p2) const; - template bool operator!=(scoped_ptr const& p2) const; - - // Disallow evil constructors - scoped_ptr(const scoped_ptr&); - void operator=(const scoped_ptr&); -}; - -// scoped_array is like scoped_ptr, except that the caller must allocate -// with new [] and the destructor deletes objects with delete []. -// -// As with scoped_ptr, a scoped_array either points to an object -// or is NULL. A scoped_array owns the object that it points to. -// -// Size: sizeof(scoped_array) == sizeof(C*) -template -class scoped_array { - public: - - // The element type - typedef C element_type; - - // Constructor. Defaults to intializing with NULL. - // There is no way to create an uninitialized scoped_array. - // The input parameter must be allocated with new []. - explicit scoped_array(C* p = NULL) : array_(p) { } - - // Destructor. If there is a C object, delete it. - // We don't need to test ptr_ == NULL because C++ does that for us. - ~scoped_array() { - enum { type_must_be_complete = sizeof(C) }; - delete[] array_; - } - - // Reset. Deletes the current owned object, if any. - // Then takes ownership of a new object, if given. - // this->reset(this->get()) works. - void reset(C* p = NULL) { - if (p != array_) { - enum { type_must_be_complete = sizeof(C) }; - delete[] array_; - array_ = p; - } - } - - // Get one element of the current object. - // Will assert() if there is no current object, or index i is negative. - C& operator[](std::ptrdiff_t i) const { - assert(i >= 0); - assert(array_ != NULL); - return array_[i]; - } - - // Get a pointer to the zeroth element of the current object. - // If there is no current object, return NULL. - C* get() const { - return array_; - } - - // Comparison operators. - // These return whether two scoped_array refer to the same object, not just to - // two different but equal objects. - bool operator==(C* p) const { return array_ == p; } - bool operator!=(C* p) const { return array_ != p; } - - // Swap two scoped arrays. - void swap(scoped_array& p2) { - C* tmp = array_; - array_ = p2.array_; - p2.array_ = tmp; - } - - // Release an array. - // The return value is the current pointer held by this object. - // If this object holds a NULL pointer, the return value is NULL. - // After this operation, this object will hold a NULL pointer, - // and will not own the object any more. - C* release() { - C* retVal = array_; - array_ = NULL; - return retVal; - } - - private: - C* array_; - - // Forbid comparison of different scoped_array types. - template bool operator==(scoped_array const& p2) const; - template bool operator!=(scoped_array const& p2) const; - - // Disallow evil constructors - scoped_array(const scoped_array&); - void operator=(const scoped_array&); -}; - -} // namespace internal - -// We made these internal so that they would show up as such in the docs, -// but we don't want to stick "internal::" in front of them everywhere. -using internal::scoped_ptr; -using internal::scoped_array; - -// =================================================================== -// emulates google3/base/logging.h - -enum LogLevel { - LOGLEVEL_INFO, // Informational. This is never actually used by - // libprotobuf. - LOGLEVEL_WARNING, // Warns about issues that, although not technically a - // problem now, could cause problems in the future. For - // example, a // warning will be printed when parsing a - // message that is near the message size limit. - LOGLEVEL_ERROR, // An error occurred which should never happen during - // normal use. - LOGLEVEL_FATAL, // An error occurred from which the library cannot - // recover. This usually indicates a programming error - // in the code which calls the library, especially when - // compiled in debug mode. - -#ifdef NDEBUG - LOGLEVEL_DFATAL = LOGLEVEL_ERROR -#else - LOGLEVEL_DFATAL = LOGLEVEL_FATAL -#endif -}; - -namespace internal { - -class LogFinisher; - -class LIBPROTOBUF_EXPORT LogMessage { - public: - LogMessage(LogLevel level, const char* filename, int line); - ~LogMessage(); - - LogMessage& operator<<(const std::string& value); - LogMessage& operator<<(const char* value); - LogMessage& operator<<(char value); - LogMessage& operator<<(int value); - LogMessage& operator<<(uint value); - LogMessage& operator<<(long value); - LogMessage& operator<<(unsigned long value); - LogMessage& operator<<(double value); - - private: - friend class LogFinisher; - void Finish(); - - LogLevel level_; - const char* filename_; - int line_; - std::string message_; -}; - -// Used to make the entire "LOG(BLAH) << etc." expression have a void return -// type and print a newline after each message. -class LIBPROTOBUF_EXPORT LogFinisher { - public: - void operator=(LogMessage& other); -}; - -} // namespace internal - -// Undef everything in case we're being mixed with some other Google library -// which already defined them itself. Presumably all Google libraries will -// support the same syntax for these so it should not be a big deal if they -// end up using our definitions instead. -#undef GOOGLE_LOG -#undef GOOGLE_LOG_IF - -#undef GOOGLE_CHECK -#undef GOOGLE_CHECK_EQ -#undef GOOGLE_CHECK_NE -#undef GOOGLE_CHECK_LT -#undef GOOGLE_CHECK_LE -#undef GOOGLE_CHECK_GT -#undef GOOGLE_CHECK_GE -#undef GOOGLE_CHECK_NOTNULL - -#undef GOOGLE_DLOG -#undef GOOGLE_DCHECK -#undef GOOGLE_DCHECK_EQ -#undef GOOGLE_DCHECK_NE -#undef GOOGLE_DCHECK_LT -#undef GOOGLE_DCHECK_LE -#undef GOOGLE_DCHECK_GT -#undef GOOGLE_DCHECK_GE - -#define GOOGLE_LOG(LEVEL) \ - ::google::protobuf::internal::LogFinisher() = \ - ::google::protobuf::internal::LogMessage( \ - ::google::protobuf::LOGLEVEL_##LEVEL, __FILE__, __LINE__) -#define GOOGLE_LOG_IF(LEVEL, CONDITION) \ - !(CONDITION) ? (void)0 : GOOGLE_LOG(LEVEL) - -#define GOOGLE_CHECK(EXPRESSION) \ - GOOGLE_LOG_IF(FATAL, !(EXPRESSION)) << "CHECK failed: " #EXPRESSION ": " -#define GOOGLE_CHECK_EQ(A, B) GOOGLE_CHECK((A) == (B)) -#define GOOGLE_CHECK_NE(A, B) GOOGLE_CHECK((A) != (B)) -#define GOOGLE_CHECK_LT(A, B) GOOGLE_CHECK((A) < (B)) -#define GOOGLE_CHECK_LE(A, B) GOOGLE_CHECK((A) <= (B)) -#define GOOGLE_CHECK_GT(A, B) GOOGLE_CHECK((A) > (B)) -#define GOOGLE_CHECK_GE(A, B) GOOGLE_CHECK((A) >= (B)) - -namespace internal { -template -T* CheckNotNull(const char *file, int line, const char *name, T* val) { - if (val == NULL) { - GOOGLE_LOG(FATAL) << name; - } - return val; -} -} // namespace internal -#define GOOGLE_CHECK_NOTNULL(A) \ - internal::CheckNotNull(__FILE__, __LINE__, "'" #A "' must not be NULL", (A)) - -#ifdef NDEBUG - -#define GOOGLE_DLOG GOOGLE_LOG_IF(INFO, false) - -#define GOOGLE_DCHECK(EXPRESSION) while(false) GOOGLE_CHECK(EXPRESSION) -#define GOOGLE_DCHECK_EQ(A, B) GOOGLE_DCHECK((A) == (B)) -#define GOOGLE_DCHECK_NE(A, B) GOOGLE_DCHECK((A) != (B)) -#define GOOGLE_DCHECK_LT(A, B) GOOGLE_DCHECK((A) < (B)) -#define GOOGLE_DCHECK_LE(A, B) GOOGLE_DCHECK((A) <= (B)) -#define GOOGLE_DCHECK_GT(A, B) GOOGLE_DCHECK((A) > (B)) -#define GOOGLE_DCHECK_GE(A, B) GOOGLE_DCHECK((A) >= (B)) - -#else // NDEBUG - -#define GOOGLE_DLOG GOOGLE_LOG - -#define GOOGLE_DCHECK GOOGLE_CHECK -#define GOOGLE_DCHECK_EQ GOOGLE_CHECK_EQ -#define GOOGLE_DCHECK_NE GOOGLE_CHECK_NE -#define GOOGLE_DCHECK_LT GOOGLE_CHECK_LT -#define GOOGLE_DCHECK_LE GOOGLE_CHECK_LE -#define GOOGLE_DCHECK_GT GOOGLE_CHECK_GT -#define GOOGLE_DCHECK_GE GOOGLE_CHECK_GE - -#endif // !NDEBUG - -typedef void LogHandler(LogLevel level, const char* filename, int line, - const std::string& message); - -// The protobuf library sometimes writes warning and error messages to -// stderr. These messages are primarily useful for developers, but may -// also help end users figure out a problem. If you would prefer that -// these messages be sent somewhere other than stderr, call SetLogHandler() -// to set your own handler. This returns the old handler. Set the handler -// to NULL to ignore log messages (but see also LogSilencer, below). -// -// Obviously, SetLogHandler is not thread-safe. You should only call it -// at initialization time, and probably not from library code. If you -// simply want to suppress log messages temporarily (e.g. because you -// have some code that tends to trigger them frequently and you know -// the warnings are not important to you), use the LogSilencer class -// below. -LIBPROTOBUF_EXPORT LogHandler* SetLogHandler(LogHandler* new_func); - -// Create a LogSilencer if you want to temporarily suppress all log -// messages. As long as any LogSilencer objects exist, non-fatal -// log messages will be discarded (the current LogHandler will *not* -// be called). Constructing a LogSilencer is thread-safe. You may -// accidentally suppress log messages occurring in another thread, but -// since messages are generally for debugging purposes only, this isn't -// a big deal. If you want to intercept log messages, use SetLogHandler(). -class LIBPROTOBUF_EXPORT LogSilencer { - public: - LogSilencer(); - ~LogSilencer(); -}; - -// =================================================================== -// emulates google3/base/callback.h - -// Abstract interface for a callback. When calling an RPC, you must provide -// a Closure to call when the procedure completes. See the Service interface -// in service.h. -// -// To automatically construct a Closure which calls a particular function or -// method with a particular set of parameters, use the NewCallback() function. -// Example: -// void FooDone(const FooResponse* response) { -// ... -// } -// -// void CallFoo() { -// ... -// // When done, call FooDone() and pass it a pointer to the response. -// Closure* callback = NewCallback(&FooDone, response); -// // Make the call. -// service->Foo(controller, request, response, callback); -// } -// -// Example that calls a method: -// class Handler { -// public: -// ... -// -// void FooDone(const FooResponse* response) { -// ... -// } -// -// void CallFoo() { -// ... -// // When done, call FooDone() and pass it a pointer to the response. -// Closure* callback = NewCallback(this, &Handler::FooDone, response); -// // Make the call. -// service->Foo(controller, request, response, callback); -// } -// }; -// -// Currently NewCallback() supports binding zero, one, or two arguments. -// -// Callbacks created with NewCallback() automatically delete themselves when -// executed. They should be used when a callback is to be called exactly -// once (usually the case with RPC callbacks). If a callback may be called -// a different number of times (including zero), create it with -// NewPermanentCallback() instead. You are then responsible for deleting the -// callback (using the "delete" keyword as normal). -// -// Note that NewCallback() is a bit touchy regarding argument types. Generally, -// the values you provide for the parameter bindings must exactly match the -// types accepted by the callback function. For example: -// void Foo(string s); -// NewCallback(&Foo, "foo"); // WON'T WORK: const char* != string -// NewCallback(&Foo, string("foo")); // WORKS -// Also note that the arguments cannot be references: -// void Foo(const string& s); -// string my_str; -// NewCallback(&Foo, my_str); // WON'T WORK: Can't use referecnes. -// However, correctly-typed pointers will work just fine. -class LIBPROTOBUF_EXPORT Closure { - public: - Closure() {} - virtual ~Closure(); - - virtual void Run() = 0; - - private: - GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(Closure); -}; - -namespace internal { - -class LIBPROTOBUF_EXPORT FunctionClosure0 : public Closure { - public: - typedef void (*FunctionType)(); - - FunctionClosure0(FunctionType function, bool self_deleting) - : function_(function), self_deleting_(self_deleting) {} - ~FunctionClosure0(); - - void Run() { - bool needs_delete = self_deleting_; // read in case callback deletes - function_(); - if (needs_delete) delete this; - } - - private: - FunctionType function_; - bool self_deleting_; -}; - -template -class MethodClosure0 : public Closure { - public: - typedef void (Class::*MethodType)(); - - MethodClosure0(Class* object, MethodType method, bool self_deleting) - : object_(object), method_(method), self_deleting_(self_deleting) {} - ~MethodClosure0() {} - - void Run() { - bool needs_delete = self_deleting_; // read in case callback deletes - (object_->*method_)(); - if (needs_delete) delete this; - } - - private: - Class* object_; - MethodType method_; - bool self_deleting_; -}; - -template -class FunctionClosure1 : public Closure { - public: - typedef void (*FunctionType)(Arg1 arg1); - - FunctionClosure1(FunctionType function, bool self_deleting, - Arg1 arg1) - : function_(function), self_deleting_(self_deleting), - arg1_(arg1) {} - ~FunctionClosure1() {} - - void Run() { - bool needs_delete = self_deleting_; // read in case callback deletes - function_(arg1_); - if (needs_delete) delete this; - } - - private: - FunctionType function_; - bool self_deleting_; - Arg1 arg1_; -}; - -template -class MethodClosure1 : public Closure { - public: - typedef void (Class::*MethodType)(Arg1 arg1); - - MethodClosure1(Class* object, MethodType method, bool self_deleting, - Arg1 arg1) - : object_(object), method_(method), self_deleting_(self_deleting), - arg1_(arg1) {} - ~MethodClosure1() {} - - void Run() { - bool needs_delete = self_deleting_; // read in case callback deletes - (object_->*method_)(arg1_); - if (needs_delete) delete this; - } - - private: - Class* object_; - MethodType method_; - bool self_deleting_; - Arg1 arg1_; -}; - -template -class FunctionClosure2 : public Closure { - public: - typedef void (*FunctionType)(Arg1 arg1, Arg2 arg2); - - FunctionClosure2(FunctionType function, bool self_deleting, - Arg1 arg1, Arg2 arg2) - : function_(function), self_deleting_(self_deleting), - arg1_(arg1), arg2_(arg2) {} - ~FunctionClosure2() {} - - void Run() { - bool needs_delete = self_deleting_; // read in case callback deletes - function_(arg1_, arg2_); - if (needs_delete) delete this; - } - - private: - FunctionType function_; - bool self_deleting_; - Arg1 arg1_; - Arg2 arg2_; -}; - -template -class MethodClosure2 : public Closure { - public: - typedef void (Class::*MethodType)(Arg1 arg1, Arg2 arg2); - - MethodClosure2(Class* object, MethodType method, bool self_deleting, - Arg1 arg1, Arg2 arg2) - : object_(object), method_(method), self_deleting_(self_deleting), - arg1_(arg1), arg2_(arg2) {} - ~MethodClosure2() {} - - void Run() { - bool needs_delete = self_deleting_; // read in case callback deletes - (object_->*method_)(arg1_, arg2_); - if (needs_delete) delete this; - } - - private: - Class* object_; - MethodType method_; - bool self_deleting_; - Arg1 arg1_; - Arg2 arg2_; -}; - -} // namespace internal - -// See Closure. -inline Closure* NewCallback(void (*function)()) { - return new internal::FunctionClosure0(function, true); -} - -// See Closure. -inline Closure* NewPermanentCallback(void (*function)()) { - return new internal::FunctionClosure0(function, false); -} - -// See Closure. -template -inline Closure* NewCallback(Class* object, void (Class::*method)()) { - return new internal::MethodClosure0(object, method, true); -} - -// See Closure. -template -inline Closure* NewPermanentCallback(Class* object, void (Class::*method)()) { - return new internal::MethodClosure0(object, method, false); -} - -// See Closure. -template -inline Closure* NewCallback(void (*function)(Arg1), - Arg1 arg1) { - return new internal::FunctionClosure1(function, true, arg1); -} - -// See Closure. -template -inline Closure* NewPermanentCallback(void (*function)(Arg1), - Arg1 arg1) { - return new internal::FunctionClosure1(function, false, arg1); -} - -// See Closure. -template -inline Closure* NewCallback(Class* object, void (Class::*method)(Arg1), - Arg1 arg1) { - return new internal::MethodClosure1(object, method, true, arg1); -} - -// See Closure. -template -inline Closure* NewPermanentCallback(Class* object, void (Class::*method)(Arg1), - Arg1 arg1) { - return new internal::MethodClosure1(object, method, false, arg1); -} - -// See Closure. -template -inline Closure* NewCallback(void (*function)(Arg1, Arg2), - Arg1 arg1, Arg2 arg2) { - return new internal::FunctionClosure2( - function, true, arg1, arg2); -} - -// See Closure. -template -inline Closure* NewPermanentCallback(void (*function)(Arg1, Arg2), - Arg1 arg1, Arg2 arg2) { - return new internal::FunctionClosure2( - function, false, arg1, arg2); -} - -// See Closure. -template -inline Closure* NewCallback(Class* object, void (Class::*method)(Arg1, Arg2), - Arg1 arg1, Arg2 arg2) { - return new internal::MethodClosure2( - object, method, true, arg1, arg2); -} - -// See Closure. -template -inline Closure* NewPermanentCallback( - Class* object, void (Class::*method)(Arg1, Arg2), - Arg1 arg1, Arg2 arg2) { - return new internal::MethodClosure2( - object, method, false, arg1, arg2); -} - -// A function which does nothing. Useful for creating no-op callbacks, e.g.: -// Closure* nothing = NewCallback(&DoNothing); -void LIBPROTOBUF_EXPORT DoNothing(); - -// =================================================================== -// emulates google3/base/mutex.h - -namespace internal { - -// A Mutex is a non-reentrant (aka non-recursive) mutex. At most one thread T -// may hold a mutex at a given time. If T attempts to Lock() the same Mutex -// while holding it, T will deadlock. -class LIBPROTOBUF_EXPORT Mutex { - public: - // Create a Mutex that is not held by anybody. - Mutex(); - - // Destructor - ~Mutex(); - - // Block if necessary until this Mutex is free, then acquire it exclusively. - void Lock(); - - // Release this Mutex. Caller must hold it exclusively. - void Unlock(); - - // Crash if this Mutex is not held exclusively by this thread. - // May fail to crash when it should; will never crash when it should not. - void AssertHeld(); - - private: - struct Internal; - Internal* mInternal; - - GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(Mutex); -}; - -// MutexLock(mu) acquires mu when constructed and releases it when destroyed. -class LIBPROTOBUF_EXPORT MutexLock { - public: - explicit MutexLock(Mutex *mu) : mu_(mu) { this->mu_->Lock(); } - ~MutexLock() { this->mu_->Unlock(); } - private: - Mutex *const mu_; - GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(MutexLock); -}; - -// TODO(kenton): Implement these? Hard to implement portably. -typedef MutexLock ReaderMutexLock; -typedef MutexLock WriterMutexLock; - -// MutexLockMaybe is like MutexLock, but is a no-op when mu is NULL. -class LIBPROTOBUF_EXPORT MutexLockMaybe { - public: - explicit MutexLockMaybe(Mutex *mu) : - mu_(mu) { if (this->mu_ != NULL) { this->mu_->Lock(); } } - ~MutexLockMaybe() { if (this->mu_ != NULL) { this->mu_->Unlock(); } } - private: - Mutex *const mu_; - GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(MutexLockMaybe); -}; - -} // namespace internal - -// We made these internal so that they would show up as such in the docs, -// but we don't want to stick "internal::" in front of them everywhere. -using internal::Mutex; -using internal::MutexLock; -using internal::ReaderMutexLock; -using internal::WriterMutexLock; -using internal::MutexLockMaybe; - -// =================================================================== -// from google3/util/utf8/public/unilib.h - -namespace internal { - -// Checks if the buffer contains structurally-valid UTF-8. Implemented in -// structurally_valid.cc. -LIBPROTOBUF_EXPORT bool IsStructurallyValidUTF8(const char* buf, int len); - -} // namespace internal - -// =================================================================== -// from google3/util/endian/endian.h -LIBPROTOBUF_EXPORT uint32 ghtonl(uint32 x); - -// =================================================================== -// Shutdown support. - -// Shut down the entire protocol buffers library, deleting all static-duration -// objects allocated by the library or by generated .pb.cc files. -// -// There are two reasons you might want to call this: -// * You use a draconian definition of "memory leak" in which you expect -// every single malloc() to have a corresponding free(), even for objects -// which live until program exit. -// * You are writing a dynamically-loaded library which needs to clean up -// after itself when the library is unloaded. -// -// It is safe to call this multiple times. However, it is not safe to use -// any other part of the protocol buffers library after -// ShutdownProtobufLibrary() has been called. -LIBPROTOBUF_EXPORT void ShutdownProtobufLibrary(); - -namespace internal { - -// Register a function to be called when ShutdownProtocolBuffers() is called. -LIBPROTOBUF_EXPORT void OnShutdown(void (*func)()); - -} // namespace internal - -#if PROTOBUF_USE_EXCEPTIONS -class FatalException : public std::exception { - public: - FatalException(const char* filename, int line, const std::string& message) - : filename_(filename), line_(line), message_(message) {} - virtual ~FatalException() throw(); - - virtual const char* what() const throw(); - - const char* filename() const { return filename_; } - int line() const { return line_; } - const std::string& message() const { return message_; } - - private: - const char* filename_; - const int line_; - const std::string message_; -}; -#endif - -// This is at the end of the file instead of the beginning to work around a bug -// in some versions of MSVC. -using namespace std; // Don't do this at home, kids. - -} // namespace protobuf -} // namespace google - -#endif // GOOGLE_PROTOBUF_COMMON_H__ diff --git a/modules/dnn/3rdparty/protobuf/src/google/protobuf/stubs/common_unittest.cc b/modules/dnn/3rdparty/protobuf/src/google/protobuf/stubs/common_unittest.cc deleted file mode 100644 index 43cd6d010..000000000 --- a/modules/dnn/3rdparty/protobuf/src/google/protobuf/stubs/common_unittest.cc +++ /dev/null @@ -1,357 +0,0 @@ -// Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// http://code.google.com/p/protobuf/ -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -// Author: kenton@google.com (Kenton Varda) - -#include -#include -#include -#include - -#include -#include - -#include "config.h" - -namespace google { -namespace protobuf { -namespace { - -// TODO(kenton): More tests. - -#ifdef PACKAGE_VERSION // only defined when using automake, not MSVC - -TEST(VersionTest, VersionMatchesConfig) { - // Verify that the version string specified in config.h matches the one - // in common.h. The config.h version is a string which may have a suffix - // like "beta" or "rc1", so we remove that. - string version = PACKAGE_VERSION; - int pos = 0; - while (pos < version.size() && - (ascii_isdigit(version[pos]) || version[pos] == '.')) { - ++pos; - } - version.erase(pos); - - EXPECT_EQ(version, internal::VersionString(GOOGLE_PROTOBUF_VERSION)); -} - -#endif // PACKAGE_VERSION - -TEST(CommonTest, IntMinMaxConstants) { - // kint32min was declared incorrectly in the first release of protobufs. - // Ugh. - EXPECT_LT(kint32min, kint32max); - EXPECT_EQ(static_cast(kint32min), static_cast(kint32max) + 1); - EXPECT_LT(kint64min, kint64max); - EXPECT_EQ(static_cast(kint64min), static_cast(kint64max) + 1); - EXPECT_EQ(0, kuint32max + 1); - EXPECT_EQ(0, kuint64max + 1); -} - -vector captured_messages_; - -void CaptureLog(LogLevel level, const char* filename, int line, - const string& message) { - captured_messages_.push_back( - strings::Substitute("$0 $1:$2: $3", - implicit_cast(level), filename, line, message)); -} - -TEST(LoggingTest, DefaultLogging) { - CaptureTestStderr(); - int line = __LINE__; - GOOGLE_LOG(INFO ) << "A message."; - GOOGLE_LOG(WARNING) << "A warning."; - GOOGLE_LOG(ERROR ) << "An error."; - - string text = GetCapturedTestStderr(); - EXPECT_EQ( - "[libprotobuf INFO "__FILE__":" + SimpleItoa(line + 1) + "] A message.\n" - "[libprotobuf WARNING "__FILE__":" + SimpleItoa(line + 2) + "] A warning.\n" - "[libprotobuf ERROR "__FILE__":" + SimpleItoa(line + 3) + "] An error.\n", - text); -} - -TEST(LoggingTest, NullLogging) { - LogHandler* old_handler = SetLogHandler(NULL); - - CaptureTestStderr(); - GOOGLE_LOG(INFO ) << "A message."; - GOOGLE_LOG(WARNING) << "A warning."; - GOOGLE_LOG(ERROR ) << "An error."; - - EXPECT_TRUE(SetLogHandler(old_handler) == NULL); - - string text = GetCapturedTestStderr(); - EXPECT_EQ("", text); -} - -TEST(LoggingTest, CaptureLogging) { - captured_messages_.clear(); - - LogHandler* old_handler = SetLogHandler(&CaptureLog); - - int start_line = __LINE__; - GOOGLE_LOG(ERROR) << "An error."; - GOOGLE_LOG(WARNING) << "A warning."; - - EXPECT_TRUE(SetLogHandler(old_handler) == &CaptureLog); - - ASSERT_EQ(2, captured_messages_.size()); - EXPECT_EQ( - "2 "__FILE__":" + SimpleItoa(start_line + 1) + ": An error.", - captured_messages_[0]); - EXPECT_EQ( - "1 "__FILE__":" + SimpleItoa(start_line + 2) + ": A warning.", - captured_messages_[1]); -} - -TEST(LoggingTest, SilenceLogging) { - captured_messages_.clear(); - - LogHandler* old_handler = SetLogHandler(&CaptureLog); - - int line1 = __LINE__; GOOGLE_LOG(INFO) << "Visible1"; - LogSilencer* silencer1 = new LogSilencer; - GOOGLE_LOG(INFO) << "Not visible."; - LogSilencer* silencer2 = new LogSilencer; - GOOGLE_LOG(INFO) << "Not visible."; - delete silencer1; - GOOGLE_LOG(INFO) << "Not visible."; - delete silencer2; - int line2 = __LINE__; GOOGLE_LOG(INFO) << "Visible2"; - - EXPECT_TRUE(SetLogHandler(old_handler) == &CaptureLog); - - ASSERT_EQ(2, captured_messages_.size()); - EXPECT_EQ( - "0 "__FILE__":" + SimpleItoa(line1) + ": Visible1", - captured_messages_[0]); - EXPECT_EQ( - "0 "__FILE__":" + SimpleItoa(line2) + ": Visible2", - captured_messages_[1]); -} - -class ClosureTest : public testing::Test { - public: - void SetA123Method() { a_ = 123; } - static void SetA123Function() { current_instance_->a_ = 123; } - - void SetAMethod(int a) { a_ = a; } - void SetCMethod(string c) { c_ = c; } - - static void SetAFunction(int a) { current_instance_->a_ = a; } - static void SetCFunction(string c) { current_instance_->c_ = c; } - - void SetABMethod(int a, const char* b) { a_ = a; b_ = b; } - static void SetABFunction(int a, const char* b) { - current_instance_->a_ = a; - current_instance_->b_ = b; - } - - virtual void SetUp() { - current_instance_ = this; - a_ = 0; - b_ = NULL; - c_.clear(); - permanent_closure_ = NULL; - } - - void DeleteClosureInCallback() { - delete permanent_closure_; - } - - int a_; - const char* b_; - string c_; - Closure* permanent_closure_; - - static ClosureTest* current_instance_; -}; - -ClosureTest* ClosureTest::current_instance_ = NULL; - -TEST_F(ClosureTest, TestClosureFunction0) { - Closure* closure = NewCallback(&SetA123Function); - EXPECT_NE(123, a_); - closure->Run(); - EXPECT_EQ(123, a_); -} - -TEST_F(ClosureTest, TestClosureMethod0) { - Closure* closure = NewCallback(current_instance_, - &ClosureTest::SetA123Method); - EXPECT_NE(123, a_); - closure->Run(); - EXPECT_EQ(123, a_); -} - -TEST_F(ClosureTest, TestClosureFunction1) { - Closure* closure = NewCallback(&SetAFunction, 456); - EXPECT_NE(456, a_); - closure->Run(); - EXPECT_EQ(456, a_); -} - -TEST_F(ClosureTest, TestClosureMethod1) { - Closure* closure = NewCallback(current_instance_, - &ClosureTest::SetAMethod, 456); - EXPECT_NE(456, a_); - closure->Run(); - EXPECT_EQ(456, a_); -} - -TEST_F(ClosureTest, TestClosureFunction1String) { - Closure* closure = NewCallback(&SetCFunction, string("test")); - EXPECT_NE("test", c_); - closure->Run(); - EXPECT_EQ("test", c_); -} - -TEST_F(ClosureTest, TestClosureMethod1String) { - Closure* closure = NewCallback(current_instance_, - &ClosureTest::SetCMethod, string("test")); - EXPECT_NE("test", c_); - closure->Run(); - EXPECT_EQ("test", c_); -} - -TEST_F(ClosureTest, TestClosureFunction2) { - const char* cstr = "hello"; - Closure* closure = NewCallback(&SetABFunction, 789, cstr); - EXPECT_NE(789, a_); - EXPECT_NE(cstr, b_); - closure->Run(); - EXPECT_EQ(789, a_); - EXPECT_EQ(cstr, b_); -} - -TEST_F(ClosureTest, TestClosureMethod2) { - const char* cstr = "hello"; - Closure* closure = NewCallback(current_instance_, - &ClosureTest::SetABMethod, 789, cstr); - EXPECT_NE(789, a_); - EXPECT_NE(cstr, b_); - closure->Run(); - EXPECT_EQ(789, a_); - EXPECT_EQ(cstr, b_); -} - -// Repeat all of the above with NewPermanentCallback() - -TEST_F(ClosureTest, TestPermanentClosureFunction0) { - Closure* closure = NewPermanentCallback(&SetA123Function); - EXPECT_NE(123, a_); - closure->Run(); - EXPECT_EQ(123, a_); - a_ = 0; - closure->Run(); - EXPECT_EQ(123, a_); - delete closure; -} - -TEST_F(ClosureTest, TestPermanentClosureMethod0) { - Closure* closure = NewPermanentCallback(current_instance_, - &ClosureTest::SetA123Method); - EXPECT_NE(123, a_); - closure->Run(); - EXPECT_EQ(123, a_); - a_ = 0; - closure->Run(); - EXPECT_EQ(123, a_); - delete closure; -} - -TEST_F(ClosureTest, TestPermanentClosureFunction1) { - Closure* closure = NewPermanentCallback(&SetAFunction, 456); - EXPECT_NE(456, a_); - closure->Run(); - EXPECT_EQ(456, a_); - a_ = 0; - closure->Run(); - EXPECT_EQ(456, a_); - delete closure; -} - -TEST_F(ClosureTest, TestPermanentClosureMethod1) { - Closure* closure = NewPermanentCallback(current_instance_, - &ClosureTest::SetAMethod, 456); - EXPECT_NE(456, a_); - closure->Run(); - EXPECT_EQ(456, a_); - a_ = 0; - closure->Run(); - EXPECT_EQ(456, a_); - delete closure; -} - -TEST_F(ClosureTest, TestPermanentClosureFunction2) { - const char* cstr = "hello"; - Closure* closure = NewPermanentCallback(&SetABFunction, 789, cstr); - EXPECT_NE(789, a_); - EXPECT_NE(cstr, b_); - closure->Run(); - EXPECT_EQ(789, a_); - EXPECT_EQ(cstr, b_); - a_ = 0; - b_ = NULL; - closure->Run(); - EXPECT_EQ(789, a_); - EXPECT_EQ(cstr, b_); - delete closure; -} - -TEST_F(ClosureTest, TestPermanentClosureMethod2) { - const char* cstr = "hello"; - Closure* closure = NewPermanentCallback(current_instance_, - &ClosureTest::SetABMethod, 789, cstr); - EXPECT_NE(789, a_); - EXPECT_NE(cstr, b_); - closure->Run(); - EXPECT_EQ(789, a_); - EXPECT_EQ(cstr, b_); - a_ = 0; - b_ = NULL; - closure->Run(); - EXPECT_EQ(789, a_); - EXPECT_EQ(cstr, b_); - delete closure; -} - -TEST_F(ClosureTest, TestPermanentClosureDeleteInCallback) { - permanent_closure_ = NewPermanentCallback((ClosureTest*) this, - &ClosureTest::DeleteClosureInCallback); - permanent_closure_->Run(); -} - -} // anonymous namespace -} // namespace protobuf -} // namespace google diff --git a/modules/dnn/3rdparty/protobuf/src/google/protobuf/stubs/hash.h b/modules/dnn/3rdparty/protobuf/src/google/protobuf/stubs/hash.h deleted file mode 100644 index f7d107127..000000000 --- a/modules/dnn/3rdparty/protobuf/src/google/protobuf/stubs/hash.h +++ /dev/null @@ -1,232 +0,0 @@ -// Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// http://code.google.com/p/protobuf/ -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -// Author: kenton@google.com (Kenton Varda) -// -// Deals with the fact that hash_map is not defined everywhere. - -#ifndef GOOGLE_PROTOBUF_STUBS_HASH_H__ -#define GOOGLE_PROTOBUF_STUBS_HASH_H__ - -#include -#include -#include "config.h" - -#if defined(HAVE_HASH_MAP) && defined(HAVE_HASH_SET) -#include HASH_MAP_H -#include HASH_SET_H -#else -#define MISSING_HASH -#include -#include -#endif - -namespace google { -namespace protobuf { - -#ifdef MISSING_HASH - -// This system doesn't have hash_map or hash_set. Emulate them using map and -// set. - -// Make hash be the same as less. Note that everywhere where custom -// hash functions are defined in the protobuf code, they are also defined such -// that they can be used as "less" functions, which is required by MSVC anyway. -template -struct hash { - // Dummy, just to make derivative hash functions compile. - int operator()(const Key& key) { - GOOGLE_LOG(FATAL) << "Should never be called."; - return 0; - } - - inline bool operator()(const Key& a, const Key& b) const { - return a < b; - } -}; - -// Make sure char* is compared by value. -template <> -struct hash { - // Dummy, just to make derivative hash functions compile. - int operator()(const char* key) { - GOOGLE_LOG(FATAL) << "Should never be called."; - return 0; - } - - inline bool operator()(const char* a, const char* b) const { - return strcmp(a, b) < 0; - } -}; - -template , - typename EqualKey = int > -class hash_map : public std::map { - public: - hash_map(int = 0) {} -}; - -template , - typename EqualKey = int > -class hash_set : public std::set { - public: - hash_set(int = 0) {} -}; - -#elif defined(_MSC_VER) && !defined(_STLPORT_VERSION) - -template -struct hash : public HASH_NAMESPACE::hash_compare { -}; - -// MSVC's hash_compare hashes based on the string contents but -// compares based on the string pointer. WTF? -class CstringLess { - public: - inline bool operator()(const char* a, const char* b) const { - return strcmp(a, b) < 0; - } -}; - -template <> -struct hash - : public HASH_NAMESPACE::hash_compare { -}; - -template , - typename EqualKey = int > -class hash_map : public HASH_NAMESPACE::hash_map< - Key, Data, HashFcn> { - public: - hash_map(int = 0) {} -}; - -template , - typename EqualKey = int > -class hash_set : public HASH_NAMESPACE::hash_set< - Key, HashFcn> { - public: - hash_set(int = 0) {} -}; - -#else - -template -struct hash : public HASH_NAMESPACE::hash { -}; - -template -struct hash { - inline size_t operator()(const Key* key) const { - return reinterpret_cast(key); - } -}; - -// Unlike the old SGI version, the TR1 "hash" does not special-case char*. So, -// we go ahead and provide our own implementation. -template <> -struct hash { - inline size_t operator()(const char* str) const { - size_t result = 0; - for (; *str != '\0'; str++) { - result = 5 * result + *str; - } - return result; - } -}; - -template , - typename EqualKey = std::equal_to > -class hash_map : public HASH_NAMESPACE::HASH_MAP_CLASS< - Key, Data, HashFcn, EqualKey> { - public: - hash_map(int = 0) {} -}; - -template , - typename EqualKey = std::equal_to > -class hash_set : public HASH_NAMESPACE::HASH_SET_CLASS< - Key, HashFcn, EqualKey> { - public: - hash_set(int = 0) {} -}; - -#endif - -template <> -struct hash { - inline size_t operator()(const string& key) const { - return hash()(key.c_str()); - } - - static const size_t bucket_size = 4; - static const size_t min_buckets = 8; - inline size_t operator()(const string& a, const string& b) const { - return a < b; - } -}; - -template -struct hash > { - inline size_t operator()(const pair& key) const { - size_t first_hash = hash()(key.first); - size_t second_hash = hash()(key.second); - - // FIXME(kenton): What is the best way to compute this hash? I have - // no idea! This seems a bit better than an XOR. - return first_hash * ((1 << 16) - 1) + second_hash; - } - - static const size_t bucket_size = 4; - static const size_t min_buckets = 8; - inline size_t operator()(const pair& a, - const pair& b) const { - return a < b; - } -}; - -// Used by GCC/SGI STL only. (Why isn't this provided by the standard -// library? :( ) -struct streq { - inline bool operator()(const char* a, const char* b) const { - return strcmp(a, b) == 0; - } -}; - -} // namespace protobuf -} // namespace google - -#endif // GOOGLE_PROTOBUF_STUBS_HASH_H__ diff --git a/modules/dnn/3rdparty/protobuf/src/google/protobuf/stubs/map-util.h b/modules/dnn/3rdparty/protobuf/src/google/protobuf/stubs/map-util.h deleted file mode 100644 index 775848b9c..000000000 --- a/modules/dnn/3rdparty/protobuf/src/google/protobuf/stubs/map-util.h +++ /dev/null @@ -1,143 +0,0 @@ -// Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// http://code.google.com/p/protobuf/ -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -// from google3/util/gtl/map-util.h -// Author: Anton Carver - -#ifndef GOOGLE_PROTOBUF_STUBS_MAP_UTIL_H__ -#define GOOGLE_PROTOBUF_STUBS_MAP_UTIL_H__ - -#include - -namespace google { -namespace protobuf { - -// Perform a lookup in a map or hash_map. -// If the key is present in the map then the value associated with that -// key is returned, otherwise the value passed as a default is returned. -template -const typename Collection::value_type::second_type& -FindWithDefault(const Collection& collection, - const typename Collection::value_type::first_type& key, - const typename Collection::value_type::second_type& value) { - typename Collection::const_iterator it = collection.find(key); - if (it == collection.end()) { - return value; - } - return it->second; -} - -// Perform a lookup in a map or hash_map. -// If the key is present a const pointer to the associated value is returned, -// otherwise a NULL pointer is returned. -template -const typename Collection::value_type::second_type* -FindOrNull(const Collection& collection, - const typename Collection::value_type::first_type& key) { - typename Collection::const_iterator it = collection.find(key); - if (it == collection.end()) { - return 0; - } - return &it->second; -} - -// Perform a lookup in a map or hash_map, assuming that the key exists. -// Crash if it does not. -// -// This is intended as a replacement for operator[] as an rvalue (for reading) -// when the key is guaranteed to exist. -// -// operator[] is discouraged for several reasons: -// * It has a side-effect of inserting missing keys -// * It is not thread-safe (even when it is not inserting, it can still -// choose to resize the underlying storage) -// * It invalidates iterators (when it chooses to resize) -// * It default constructs a value object even if it doesn't need to -// -// This version assumes the key is printable, and includes it in the fatal log -// message. -template -const typename Collection::value_type::second_type& -FindOrDie(const Collection& collection, - const typename Collection::value_type::first_type& key) { - typename Collection::const_iterator it = collection.find(key); - GOOGLE_CHECK(it != collection.end()) << "Map key not found: " << key; - return it->second; -} - -// Perform a lookup in a map or hash_map whose values are pointers. -// If the key is present a const pointer to the associated value is returned, -// otherwise a NULL pointer is returned. -// This function does not distinguish between a missing key and a key mapped -// to a NULL value. -template -const typename Collection::value_type::second_type -FindPtrOrNull(const Collection& collection, - const typename Collection::value_type::first_type& key) { - typename Collection::const_iterator it = collection.find(key); - if (it == collection.end()) { - return 0; - } - return it->second; -} - -// Change the value associated with a particular key in a map or hash_map. -// If the key is not present in the map the key and value are inserted, -// otherwise the value is updated to be a copy of the value provided. -// True indicates that an insert took place, false indicates an update. -template -bool InsertOrUpdate(Collection * const collection, - const Key& key, const Value& value) { - pair ret = - collection->insert(typename Collection::value_type(key, value)); - if (!ret.second) { - // update - ret.first->second = value; - return false; - } - return true; -} - -// Insert a new key and value into a map or hash_map. -// If the key is not present in the map the key and value are -// inserted, otherwise nothing happens. True indicates that an insert -// took place, false indicates the key was already present. -template -bool InsertIfNotPresent(Collection * const collection, - const Key& key, const Value& value) { - pair ret = - collection->insert(typename Collection::value_type(key, value)); - return ret.second; -} - -} // namespace protobuf -} // namespace google - -#endif // GOOGLE_PROTOBUF_STUBS_MAP_UTIL_H__ diff --git a/modules/dnn/3rdparty/protobuf/src/google/protobuf/stubs/once.cc b/modules/dnn/3rdparty/protobuf/src/google/protobuf/stubs/once.cc deleted file mode 100644 index 1e24b8552..000000000 --- a/modules/dnn/3rdparty/protobuf/src/google/protobuf/stubs/once.cc +++ /dev/null @@ -1,99 +0,0 @@ -// Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// http://code.google.com/p/protobuf/ -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -// Author: kenton@google.com (Kenton Varda) -// -// emulates google3/base/once.h -// -// This header is intended to be included only by internal .cc files and -// generated .pb.cc files. Users should not use this directly. - -#include - -#ifndef GOOGLE_PROTOBUF_NO_THREAD_SAFETY - -#ifdef _WIN32 -#include -#else -#include -#endif - -#include - -namespace google { -namespace protobuf { - -namespace { - -void SchedYield() { -#ifdef _WIN32 - Sleep(0); -#else // POSIX - sched_yield(); -#endif -} - -} // namespace - -void GoogleOnceInitImpl(ProtobufOnceType* once, Closure* closure) { - internal::AtomicWord state = internal::Acquire_Load(once); - // Fast path. The provided closure was already executed. - if (state == ONCE_STATE_DONE) { - return; - } - // The closure execution did not complete yet. The once object can be in one - // of the two following states: - // - UNINITIALIZED: We are the first thread calling this function. - // - EXECUTING_CLOSURE: Another thread is already executing the closure. - // - // First, try to change the state from UNINITIALIZED to EXECUTING_CLOSURE - // atomically. - state = internal::Acquire_CompareAndSwap( - once, ONCE_STATE_UNINITIALIZED, ONCE_STATE_EXECUTING_CLOSURE); - if (state == ONCE_STATE_UNINITIALIZED) { - // We are the first thread to call this function, so we have to call the - // closure. - closure->Run(); - internal::Release_Store(once, ONCE_STATE_DONE); - } else { - // Another thread has already started executing the closure. We need to - // wait until it completes the initialization. - while (state == ONCE_STATE_EXECUTING_CLOSURE) { - // Note that futex() could be used here on Linux as an improvement. - SchedYield(); - state = internal::Acquire_Load(once); - } - } -} - -} // namespace protobuf -} // namespace google - -#endif // GOOGLE_PROTOBUF_NO_THREAD_SAFETY diff --git a/modules/dnn/3rdparty/protobuf/src/google/protobuf/stubs/once.h b/modules/dnn/3rdparty/protobuf/src/google/protobuf/stubs/once.h deleted file mode 100644 index 7fbc117fe..000000000 --- a/modules/dnn/3rdparty/protobuf/src/google/protobuf/stubs/once.h +++ /dev/null @@ -1,148 +0,0 @@ -// Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// http://code.google.com/p/protobuf/ -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -// Author: kenton@google.com (Kenton Varda) -// -// emulates google3/base/once.h -// -// This header is intended to be included only by internal .cc files and -// generated .pb.cc files. Users should not use this directly. -// -// This is basically a portable version of pthread_once(). -// -// This header declares: -// * A type called ProtobufOnceType. -// * A macro GOOGLE_PROTOBUF_DECLARE_ONCE() which declares a variable of type -// ProtobufOnceType. This is the only legal way to declare such a variable. -// The macro may only be used at the global scope (you cannot create local or -// class member variables of this type). -// * A function GoogleOnceInit(ProtobufOnceType* once, void (*init_func)()). -// This function, when invoked multiple times given the same ProtobufOnceType -// object, will invoke init_func on the first call only, and will make sure -// none of the calls return before that first call to init_func has finished. -// * The user can provide a parameter which GoogleOnceInit() forwards to the -// user-provided function when it is called. Usage example: -// int a = 10; -// GoogleOnceInit(&my_once, &MyFunctionExpectingIntArgument, &a); -// * This implementation guarantees that ProtobufOnceType is a POD (i.e. no -// static initializer generated). -// -// This implements a way to perform lazy initialization. It's more efficient -// than using mutexes as no lock is needed if initialization has already -// happened. -// -// Example usage: -// void Init(); -// GOOGLE_PROTOBUF_DECLARE_ONCE(once_init); -// -// // Calls Init() exactly once. -// void InitOnce() { -// GoogleOnceInit(&once_init, &Init); -// } -// -// Note that if GoogleOnceInit() is called before main() has begun, it must -// only be called by the thread that will eventually call main() -- that is, -// the thread that performs dynamic initialization. In general this is a safe -// assumption since people don't usually construct threads before main() starts, -// but it is technically not guaranteed. Unfortunately, Win32 provides no way -// whatsoever to statically-initialize its synchronization primitives, so our -// only choice is to assume that dynamic initialization is single-threaded. - -#ifndef GOOGLE_PROTOBUF_STUBS_ONCE_H__ -#define GOOGLE_PROTOBUF_STUBS_ONCE_H__ - -#include -#include - -namespace google { -namespace protobuf { - -#ifdef GOOGLE_PROTOBUF_NO_THREAD_SAFETY - -typedef bool ProtobufOnceType; - -#define GOOGLE_PROTOBUF_ONCE_INIT false - -inline void GoogleOnceInit(ProtobufOnceType* once, void (*init_func)()) { - if (!*once) { - *once = true; - init_func(); - } -} - -template -inline void GoogleOnceInit(ProtobufOnceType* once, void (*init_func)(Arg), - Arg arg) { - if (!*once) { - *once = true; - init_func(arg); - } -} - -#else - -enum { - ONCE_STATE_UNINITIALIZED = 0, - ONCE_STATE_EXECUTING_CLOSURE = 1, - ONCE_STATE_DONE = 2 -}; - -typedef internal::AtomicWord ProtobufOnceType; - -#define GOOGLE_PROTOBUF_ONCE_INIT ::google::protobuf::ONCE_STATE_UNINITIALIZED - -LIBPROTOBUF_EXPORT -void GoogleOnceInitImpl(ProtobufOnceType* once, Closure* closure); - -inline void GoogleOnceInit(ProtobufOnceType* once, void (*init_func)()) { - if (internal::Acquire_Load(once) != ONCE_STATE_DONE) { - internal::FunctionClosure0 func(init_func, false); - GoogleOnceInitImpl(once, &func); - } -} - -template -inline void GoogleOnceInit(ProtobufOnceType* once, void (*init_func)(Arg*), - Arg* arg) { - if (internal::Acquire_Load(once) != ONCE_STATE_DONE) { - internal::FunctionClosure1 func(init_func, false, arg); - GoogleOnceInitImpl(once, &func); - } -} - -#endif // GOOGLE_PROTOBUF_NO_THREAD_SAFETY - -#define GOOGLE_PROTOBUF_DECLARE_ONCE(NAME) \ - ::google::protobuf::ProtobufOnceType NAME = GOOGLE_PROTOBUF_ONCE_INIT - -} // namespace protobuf -} // namespace google - -#endif // GOOGLE_PROTOBUF_STUBS_ONCE_H__ diff --git a/modules/dnn/3rdparty/protobuf/src/google/protobuf/stubs/once_unittest.cc b/modules/dnn/3rdparty/protobuf/src/google/protobuf/stubs/once_unittest.cc deleted file mode 100644 index b8f86a0fc..000000000 --- a/modules/dnn/3rdparty/protobuf/src/google/protobuf/stubs/once_unittest.cc +++ /dev/null @@ -1,253 +0,0 @@ -// Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// http://code.google.com/p/protobuf/ -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -// Author: kenton@google.com (Kenton Varda) - -#ifdef _WIN32 -#include -#else -#include -#include -#endif - -#include -#include -#include - -namespace google { -namespace protobuf { -namespace { - -class OnceInitTest : public testing::Test { - protected: - void SetUp() { - state_ = INIT_NOT_STARTED; - current_test_ = this; - } - - // Since ProtobufOnceType is only allowed to be allocated in static storage, - // each test must use a different pair of ProtobufOnceType objects which it - // must declare itself. - void SetOnces(ProtobufOnceType* once, ProtobufOnceType* recursive_once) { - once_ = once; - recursive_once_ = recursive_once; - } - - void InitOnce() { - GoogleOnceInit(once_, &InitStatic); - } - void InitRecursiveOnce() { - GoogleOnceInit(recursive_once_, &InitRecursiveStatic); - } - - void BlockInit() { init_blocker_.Lock(); } - void UnblockInit() { init_blocker_.Unlock(); } - - class TestThread { - public: - TestThread(Closure* callback) - : done_(false), joined_(false), callback_(callback) { -#ifdef _WIN32 - thread_ = CreateThread(NULL, 0, &Start, this, 0, NULL); -#else - pthread_create(&thread_, NULL, &Start, this); -#endif - } - ~TestThread() { - if (!joined_) Join(); - } - - bool IsDone() { - MutexLock lock(&done_mutex_); - return done_; - } - void Join() { - joined_ = true; -#ifdef _WIN32 - WaitForSingleObject(thread_, INFINITE); - CloseHandle(thread_); -#else - pthread_join(thread_, NULL); -#endif - } - - private: -#ifdef _WIN32 - HANDLE thread_; -#else - pthread_t thread_; -#endif - - Mutex done_mutex_; - bool done_; - bool joined_; - Closure* callback_; - -#ifdef _WIN32 - static DWORD WINAPI Start(LPVOID arg) { -#else - static void* Start(void* arg) { -#endif - reinterpret_cast(arg)->Run(); - return 0; - } - - void Run() { - callback_->Run(); - MutexLock lock(&done_mutex_); - done_ = true; - } - }; - - TestThread* RunInitOnceInNewThread() { - return new TestThread(NewCallback(this, &OnceInitTest::InitOnce)); - } - TestThread* RunInitRecursiveOnceInNewThread() { - return new TestThread(NewCallback(this, &OnceInitTest::InitRecursiveOnce)); - } - - enum State { - INIT_NOT_STARTED, - INIT_STARTED, - INIT_DONE - }; - State CurrentState() { - MutexLock lock(&mutex_); - return state_; - } - - void WaitABit() { -#ifdef _WIN32 - Sleep(1000); -#else - sleep(1); -#endif - } - - private: - Mutex mutex_; - Mutex init_blocker_; - State state_; - ProtobufOnceType* once_; - ProtobufOnceType* recursive_once_; - - void Init() { - MutexLock lock(&mutex_); - EXPECT_EQ(INIT_NOT_STARTED, state_); - state_ = INIT_STARTED; - mutex_.Unlock(); - init_blocker_.Lock(); - init_blocker_.Unlock(); - mutex_.Lock(); - state_ = INIT_DONE; - } - - static OnceInitTest* current_test_; - static void InitStatic() { current_test_->Init(); } - static void InitRecursiveStatic() { current_test_->InitOnce(); } -}; - -OnceInitTest* OnceInitTest::current_test_ = NULL; - -GOOGLE_PROTOBUF_DECLARE_ONCE(simple_once); - -TEST_F(OnceInitTest, Simple) { - SetOnces(&simple_once, NULL); - - EXPECT_EQ(INIT_NOT_STARTED, CurrentState()); - InitOnce(); - EXPECT_EQ(INIT_DONE, CurrentState()); - - // Calling again has no effect. - InitOnce(); - EXPECT_EQ(INIT_DONE, CurrentState()); -} - -GOOGLE_PROTOBUF_DECLARE_ONCE(recursive_once1); -GOOGLE_PROTOBUF_DECLARE_ONCE(recursive_once2); - -TEST_F(OnceInitTest, Recursive) { - SetOnces(&recursive_once1, &recursive_once2); - - EXPECT_EQ(INIT_NOT_STARTED, CurrentState()); - InitRecursiveOnce(); - EXPECT_EQ(INIT_DONE, CurrentState()); -} - -GOOGLE_PROTOBUF_DECLARE_ONCE(multiple_threads_once); - -TEST_F(OnceInitTest, MultipleThreads) { - SetOnces(&multiple_threads_once, NULL); - - scoped_ptr threads[4]; - EXPECT_EQ(INIT_NOT_STARTED, CurrentState()); - for (int i = 0; i < 4; i++) { - threads[i].reset(RunInitOnceInNewThread()); - } - for (int i = 0; i < 4; i++) { - threads[i]->Join(); - } - EXPECT_EQ(INIT_DONE, CurrentState()); -} - -GOOGLE_PROTOBUF_DECLARE_ONCE(multiple_threads_blocked_once1); -GOOGLE_PROTOBUF_DECLARE_ONCE(multiple_threads_blocked_once2); - -TEST_F(OnceInitTest, MultipleThreadsBlocked) { - SetOnces(&multiple_threads_blocked_once1, &multiple_threads_blocked_once2); - - scoped_ptr threads[8]; - EXPECT_EQ(INIT_NOT_STARTED, CurrentState()); - - BlockInit(); - for (int i = 0; i < 4; i++) { - threads[i].reset(RunInitOnceInNewThread()); - } - for (int i = 4; i < 8; i++) { - threads[i].reset(RunInitRecursiveOnceInNewThread()); - } - - WaitABit(); - - // We should now have one thread blocked inside Init(), four blocked waiting - // for Init() to complete, and three blocked waiting for InitRecursive() to - // complete. - EXPECT_EQ(INIT_STARTED, CurrentState()); - UnblockInit(); - - for (int i = 0; i < 8; i++) { - threads[i]->Join(); - } - EXPECT_EQ(INIT_DONE, CurrentState()); -} - -} // anonymous namespace -} // namespace protobuf -} // namespace google diff --git a/modules/dnn/3rdparty/protobuf/src/google/protobuf/stubs/platform_macros.h b/modules/dnn/3rdparty/protobuf/src/google/protobuf/stubs/platform_macros.h deleted file mode 100644 index b1df60e46..000000000 --- a/modules/dnn/3rdparty/protobuf/src/google/protobuf/stubs/platform_macros.h +++ /dev/null @@ -1,70 +0,0 @@ -// Protocol Buffers - Google's data interchange format -// Copyright 2012 Google Inc. All rights reserved. -// http://code.google.com/p/protobuf/ -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -#ifndef GOOGLE_PROTOBUF_PLATFORM_MACROS_H_ -#define GOOGLE_PROTOBUF_PLATFORM_MACROS_H_ - -#include - -// Processor architecture detection. For more info on what's defined, see: -// http://msdn.microsoft.com/en-us/library/b0084kay.aspx -// http://www.agner.org/optimize/calling_conventions.pdf -// or with gcc, run: "echo | gcc -E -dM -" -#if defined(_M_X64) || defined(__x86_64__) -#define GOOGLE_PROTOBUF_ARCH_X64 1 -#define GOOGLE_PROTOBUF_ARCH_64_BIT 1 -#elif defined(_M_IX86) || defined(__i386__) -#define GOOGLE_PROTOBUF_ARCH_IA32 1 -#define GOOGLE_PROTOBUF_ARCH_32_BIT 1 -#elif defined(__QNX__) -#define GOOGLE_PROTOBUF_ARCH_ARM_QNX 1 -#define GOOGLE_PROTOBUF_ARCH_32_BIT 1 -#elif defined(__ARMEL__) -#define GOOGLE_PROTOBUF_ARCH_ARM 1 -#define GOOGLE_PROTOBUF_ARCH_32_BIT 1 -#elif defined(__MIPSEL__) -#define GOOGLE_PROTOBUF_ARCH_MIPS 1 -#define GOOGLE_PROTOBUF_ARCH_32_BIT 1 -#elif defined(__pnacl__) -#define GOOGLE_PROTOBUF_ARCH_32_BIT 1 -#elif defined(__ppc__) -#define GOOGLE_PROTOBUF_ARCH_PPC 1 -#define GOOGLE_PROTOBUF_ARCH_32_BIT 1 -#else -#error Host architecture was not detected as supported by protobuf -#endif - -#if defined(__APPLE__) -#define GOOGLE_PROTOBUF_OS_APPLE -#elif defined(__native_client__) -#define GOOGLE_PROTOBUF_OS_NACL -#endif - -#endif // GOOGLE_PROTOBUF_PLATFORM_MACROS_H_ diff --git a/modules/dnn/3rdparty/protobuf/src/google/protobuf/stubs/stl_util.h b/modules/dnn/3rdparty/protobuf/src/google/protobuf/stubs/stl_util.h deleted file mode 100644 index 9021dada9..000000000 --- a/modules/dnn/3rdparty/protobuf/src/google/protobuf/stubs/stl_util.h +++ /dev/null @@ -1,121 +0,0 @@ -// Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// http://code.google.com/p/protobuf/ -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -// from google3/util/gtl/stl_util.h - -#ifndef GOOGLE_PROTOBUF_STUBS_STL_UTIL_H__ -#define GOOGLE_PROTOBUF_STUBS_STL_UTIL_H__ - -#include - -namespace google { -namespace protobuf { - -// STLDeleteContainerPointers() -// For a range within a container of pointers, calls delete -// (non-array version) on these pointers. -// NOTE: for these three functions, we could just implement a DeleteObject -// functor and then call for_each() on the range and functor, but this -// requires us to pull in all of algorithm.h, which seems expensive. -// For hash_[multi]set, it is important that this deletes behind the iterator -// because the hash_set may call the hash function on the iterator when it is -// advanced, which could result in the hash function trying to deference a -// stale pointer. -template -void STLDeleteContainerPointers(ForwardIterator begin, - ForwardIterator end) { - while (begin != end) { - ForwardIterator temp = begin; - ++begin; - delete *temp; - } -} - -// Inside Google, this function implements a horrible, disgusting hack in which -// we reach into the string's private implementation and resize it without -// initializing the new bytes. In some cases doing this can significantly -// improve performance. However, since it's totally non-portable it has no -// place in open source code. Feel free to fill this function in with your -// own disgusting hack if you want the perf boost. -inline void STLStringResizeUninitialized(string* s, size_t new_size) { - s->resize(new_size); -} - -// Return a mutable char* pointing to a string's internal buffer, -// which may not be null-terminated. Writing through this pointer will -// modify the string. -// -// string_as_array(&str)[i] is valid for 0 <= i < str.size() until the -// next call to a string method that invalidates iterators. -// -// As of 2006-04, there is no standard-blessed way of getting a -// mutable reference to a string's internal buffer. However, issue 530 -// (http://www.open-std.org/JTC1/SC22/WG21/docs/lwg-active.html#530) -// proposes this as the method. According to Matt Austern, this should -// already work on all current implementations. -inline char* string_as_array(string* str) { - // DO NOT USE const_cast(str->data())! See the unittest for why. - return str->empty() ? NULL : &*str->begin(); -} - -// STLDeleteElements() deletes all the elements in an STL container and clears -// the container. This function is suitable for use with a vector, set, -// hash_set, or any other STL container which defines sensible begin(), end(), -// and clear() methods. -// -// If container is NULL, this function is a no-op. -// -// As an alternative to calling STLDeleteElements() directly, consider -// ElementDeleter (defined below), which ensures that your container's elements -// are deleted when the ElementDeleter goes out of scope. -template -void STLDeleteElements(T *container) { - if (!container) return; - STLDeleteContainerPointers(container->begin(), container->end()); - container->clear(); -} - -// Given an STL container consisting of (key, value) pairs, STLDeleteValues -// deletes all the "value" components and clears the container. Does nothing -// in the case it's given a NULL pointer. - -template -void STLDeleteValues(T *v) { - if (!v) return; - for (typename T::iterator i = v->begin(); i != v->end(); ++i) { - delete i->second; - } - v->clear(); -} - -} // namespace protobuf -} // namespace google - -#endif // GOOGLE_PROTOBUF_STUBS_STL_UTIL_H__ diff --git a/modules/dnn/3rdparty/protobuf/src/google/protobuf/stubs/stringprintf.cc b/modules/dnn/3rdparty/protobuf/src/google/protobuf/stubs/stringprintf.cc deleted file mode 100644 index 4a5b85825..000000000 --- a/modules/dnn/3rdparty/protobuf/src/google/protobuf/stubs/stringprintf.cc +++ /dev/null @@ -1,175 +0,0 @@ -// Protocol Buffers - Google's data interchange format -// Copyright 2012 Google Inc. All rights reserved. -// http://code.google.com/p/protobuf/ -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -// from google3/base/stringprintf.cc - -#include - -#include -#include // For va_list and related operations -#include // MSVC requires this for _vsnprintf -#include -#include -#include - -namespace google { -namespace protobuf { - -#ifdef _MSC_VER -enum { IS_COMPILER_MSVC = 1 }; -#ifndef va_copy -// Define va_copy for MSVC. This is a hack, assuming va_list is simply a -// pointer into the stack and is safe to copy. -#define va_copy(dest, src) ((dest) = (src)) -#endif -#else -enum { IS_COMPILER_MSVC = 0 }; -#endif - -void StringAppendV(string* dst, const char* format, va_list ap) { - // First try with a small fixed size buffer - static const int kSpaceLength = 1024; - char space[kSpaceLength]; - - // It's possible for methods that use a va_list to invalidate - // the data in it upon use. The fix is to make a copy - // of the structure before using it and use that copy instead. - va_list backup_ap; - va_copy(backup_ap, ap); - int result = vsnprintf(space, kSpaceLength, format, backup_ap); - va_end(backup_ap); - - if (result < kSpaceLength) { - if (result >= 0) { - // Normal case -- everything fit. - dst->append(space, result); - return; - } - - if (IS_COMPILER_MSVC) { - // Error or MSVC running out of space. MSVC 8.0 and higher - // can be asked about space needed with the special idiom below: - va_copy(backup_ap, ap); - result = vsnprintf(NULL, 0, format, backup_ap); - va_end(backup_ap); - } - - if (result < 0) { - // Just an error. - return; - } - } - - // Increase the buffer size to the size requested by vsnprintf, - // plus one for the closing \0. - int length = result+1; - char* buf = new char[length]; - - // Restore the va_list before we use it again - va_copy(backup_ap, ap); - result = vsnprintf(buf, length, format, backup_ap); - va_end(backup_ap); - - if (result >= 0 && result < length) { - // It fit - dst->append(buf, result); - } - delete[] buf; -} - - -string StringPrintf(const char* format, ...) { - va_list ap; - va_start(ap, format); - string result; - StringAppendV(&result, format, ap); - va_end(ap); - return result; -} - -const string& SStringPrintf(string* dst, const char* format, ...) { - va_list ap; - va_start(ap, format); - dst->clear(); - StringAppendV(dst, format, ap); - va_end(ap); - return *dst; -} - -void StringAppendF(string* dst, const char* format, ...) { - va_list ap; - va_start(ap, format); - StringAppendV(dst, format, ap); - va_end(ap); -} - -// Max arguments supported by StringPrintVector -const int kStringPrintfVectorMaxArgs = 32; - -// An empty block of zero for filler arguments. This is const so that if -// printf tries to write to it (via %n) then the program gets a SIGSEGV -// and we can fix the problem or protect against an attack. -static const char string_printf_empty_block[256] = { '\0' }; - -string StringPrintfVector(const char* format, const vector& v) { - GOOGLE_CHECK_LE(v.size(), kStringPrintfVectorMaxArgs) - << "StringPrintfVector currently only supports up to " - << kStringPrintfVectorMaxArgs << " arguments. " - << "Feel free to add support for more if you need it."; - - // Add filler arguments so that bogus format+args have a harder time - // crashing the program, corrupting the program (%n), - // or displaying random chunks of memory to users. - - const char* cstr[kStringPrintfVectorMaxArgs]; - for (int i = 0; i < v.size(); ++i) { - cstr[i] = v[i].c_str(); - } - for (int i = v.size(); i < GOOGLE_ARRAYSIZE(cstr); ++i) { - cstr[i] = &string_printf_empty_block[0]; - } - - // I do not know any way to pass kStringPrintfVectorMaxArgs arguments, - // or any way to build a va_list by hand, or any API for printf - // that accepts an array of arguments. The best I can do is stick - // this COMPILE_ASSERT right next to the actual statement. - - GOOGLE_COMPILE_ASSERT(kStringPrintfVectorMaxArgs == 32, arg_count_mismatch); - return StringPrintf(format, - cstr[0], cstr[1], cstr[2], cstr[3], cstr[4], - cstr[5], cstr[6], cstr[7], cstr[8], cstr[9], - cstr[10], cstr[11], cstr[12], cstr[13], cstr[14], - cstr[15], cstr[16], cstr[17], cstr[18], cstr[19], - cstr[20], cstr[21], cstr[22], cstr[23], cstr[24], - cstr[25], cstr[26], cstr[27], cstr[28], cstr[29], - cstr[30], cstr[31]); -} -} // namespace protobuf -} // namespace google diff --git a/modules/dnn/3rdparty/protobuf/src/google/protobuf/stubs/stringprintf.h b/modules/dnn/3rdparty/protobuf/src/google/protobuf/stubs/stringprintf.h deleted file mode 100644 index 4a03e5ff9..000000000 --- a/modules/dnn/3rdparty/protobuf/src/google/protobuf/stubs/stringprintf.h +++ /dev/null @@ -1,76 +0,0 @@ -// Protocol Buffers - Google's data interchange format -// Copyright 2012 Google Inc. All rights reserved. -// http://code.google.com/p/protobuf/ -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -// from google3/base/stringprintf.h -// -// Printf variants that place their output in a C++ string. -// -// Usage: -// string result = StringPrintf("%d %s\n", 10, "hello"); -// SStringPrintf(&result, "%d %s\n", 10, "hello"); -// StringAppendF(&result, "%d %s\n", 20, "there"); - -#ifndef GOOGLE_PROTOBUF_STUBS_STRINGPRINTF_H -#define GOOGLE_PROTOBUF_STUBS_STRINGPRINTF_H - -#include -#include -#include - -#include - -namespace google { -namespace protobuf { - -// Return a C++ string -LIBPROTOBUF_EXPORT extern string StringPrintf(const char* format, ...); - -// Store result into a supplied string and return it -LIBPROTOBUF_EXPORT extern const string& SStringPrintf(string* dst, const char* format, ...); - -// Append result to a supplied string -LIBPROTOBUF_EXPORT extern void StringAppendF(string* dst, const char* format, ...); - -// Lower-level routine that takes a va_list and appends to a specified -// string. All other routines are just convenience wrappers around it. -LIBPROTOBUF_EXPORT extern void StringAppendV(string* dst, const char* format, va_list ap); - -// The max arguments supported by StringPrintfVector -LIBPROTOBUF_EXPORT extern const int kStringPrintfVectorMaxArgs; - -// You can use this version when all your arguments are strings, but -// you don't know how many arguments you'll have at compile time. -// StringPrintfVector will LOG(FATAL) if v.size() > kStringPrintfVectorMaxArgs -LIBPROTOBUF_EXPORT extern string StringPrintfVector(const char* format, const vector& v); - -} // namespace protobuf -} // namespace google - -#endif // GOOGLE_PROTOBUF_STUBS_STRINGPRINTF_H diff --git a/modules/dnn/3rdparty/protobuf/src/google/protobuf/stubs/stringprintf_unittest.cc b/modules/dnn/3rdparty/protobuf/src/google/protobuf/stubs/stringprintf_unittest.cc deleted file mode 100644 index de5ce59fa..000000000 --- a/modules/dnn/3rdparty/protobuf/src/google/protobuf/stubs/stringprintf_unittest.cc +++ /dev/null @@ -1,152 +0,0 @@ -// Protocol Buffers - Google's data interchange format -// Copyright 2012 Google Inc. All rights reserved. -// http://code.google.com/p/protobuf/ -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -// from google3/base/stringprintf_unittest.cc - -#include - -#include -#include - -#include -#include - -namespace google { -namespace protobuf { -namespace { - -TEST(StringPrintfTest, Empty) { -#if 0 - // gcc 2.95.3, gcc 4.1.0, and gcc 4.2.2 all warn about this: - // warning: zero-length printf format string. - // so we do not allow them in google3. - EXPECT_EQ("", StringPrintf("")); -#endif - EXPECT_EQ("", StringPrintf("%s", string().c_str())); - EXPECT_EQ("", StringPrintf("%s", "")); -} - -TEST(StringPrintfTest, Misc) { -// MSVC and mingw does not support $ format specifier. -#if !defined(_MSC_VER) && !defined(__MINGW32__) - EXPECT_EQ("123hello w", StringPrintf("%3$d%2$s %1$c", 'w', "hello", 123)); -#endif // !_MSC_VER -} - -TEST(StringAppendFTest, Empty) { - string value("Hello"); - const char* empty = ""; - StringAppendF(&value, "%s", empty); - EXPECT_EQ("Hello", value); -} - -TEST(StringAppendFTest, EmptyString) { - string value("Hello"); - StringAppendF(&value, "%s", ""); - EXPECT_EQ("Hello", value); -} - -TEST(StringAppendFTest, String) { - string value("Hello"); - StringAppendF(&value, " %s", "World"); - EXPECT_EQ("Hello World", value); -} - -TEST(StringAppendFTest, Int) { - string value("Hello"); - StringAppendF(&value, " %d", 123); - EXPECT_EQ("Hello 123", value); -} - -TEST(StringPrintfTest, Multibyte) { - // If we are in multibyte mode and feed invalid multibyte sequence, - // StringPrintf should return an empty string instead of running - // out of memory while trying to determine destination buffer size. - // see b/4194543. - - char* old_locale = setlocale(LC_CTYPE, NULL); - // Push locale with multibyte mode - setlocale(LC_CTYPE, "en_US.utf8"); - - const char kInvalidCodePoint[] = "\375\067s"; - string value = StringPrintf("%.*s", 3, kInvalidCodePoint); - - // In some versions of glibc (e.g. eglibc-2.11.1, aka GRTEv2), snprintf - // returns error given an invalid codepoint. Other versions - // (e.g. eglibc-2.15, aka pre-GRTEv3) emit the codepoint verbatim. - // We test that the output is one of the above. - EXPECT_TRUE(value.empty() || value == kInvalidCodePoint); - - // Repeat with longer string, to make sure that the dynamically - // allocated path in StringAppendV is handled correctly. - int n = 2048; - char* buf = new char[n+1]; - memset(buf, ' ', n-3); - memcpy(buf + n - 3, kInvalidCodePoint, 4); - value = StringPrintf("%.*s", n, buf); - // See GRTEv2 vs. GRTEv3 comment above. - EXPECT_TRUE(value.empty() || value == buf); - delete[] buf; - - setlocale(LC_CTYPE, old_locale); -} - -TEST(StringPrintfTest, NoMultibyte) { - // No multibyte handling, but the string contains funny chars. - char* old_locale = setlocale(LC_CTYPE, NULL); - setlocale(LC_CTYPE, "POSIX"); - string value = StringPrintf("%.*s", 3, "\375\067s"); - setlocale(LC_CTYPE, old_locale); - EXPECT_EQ("\375\067s", value); -} - -TEST(StringPrintfTest, DontOverwriteErrno) { - // Check that errno isn't overwritten unless we're printing - // something significantly larger than what people are normally - // printing in their badly written PLOG() statements. - errno = ECHILD; - string value = StringPrintf("Hello, %s!", "World"); - EXPECT_EQ(ECHILD, errno); -} - -TEST(StringPrintfTest, LargeBuf) { - // Check that the large buffer is handled correctly. - int n = 2048; - char* buf = new char[n+1]; - memset(buf, ' ', n); - buf[n] = 0; - string value = StringPrintf("%s", buf); - EXPECT_EQ(buf, value); - delete[] buf; -} - -} // anonymous namespace -} // namespace protobuf -} // namespace google diff --git a/modules/dnn/3rdparty/protobuf/src/google/protobuf/stubs/structurally_valid.cc b/modules/dnn/3rdparty/protobuf/src/google/protobuf/stubs/structurally_valid.cc deleted file mode 100644 index 0f6afe6dc..000000000 --- a/modules/dnn/3rdparty/protobuf/src/google/protobuf/stubs/structurally_valid.cc +++ /dev/null @@ -1,536 +0,0 @@ -// Copyright 2005-2008 Google Inc. All Rights Reserved. -// Author: jrm@google.com (Jim Meehan) - -#include - -namespace google { -namespace protobuf { -namespace internal { - -// These four-byte entries compactly encode how many bytes 0..255 to delete -// in making a string replacement, how many bytes to add 0..255, and the offset -// 0..64k-1 of the replacement string in remap_string. -struct RemapEntry { - uint8 delete_bytes; - uint8 add_bytes; - uint16 bytes_offset; -}; - -// Exit type codes for state tables. All but the first get stuffed into -// signed one-byte entries. The first is only generated by executable code. -// To distinguish from next-state entries, these must be contiguous and -// all <= kExitNone -typedef enum { - kExitDstSpaceFull = 239, - kExitIllegalStructure, // 240 - kExitOK, // 241 - kExitReject, // ... - kExitReplace1, - kExitReplace2, - kExitReplace3, - kExitReplace21, - kExitReplace31, - kExitReplace32, - kExitReplaceOffset1, - kExitReplaceOffset2, - kExitReplace1S0, - kExitSpecial, - kExitDoAgain, - kExitRejectAlt, - kExitNone // 255 -} ExitReason; - - -// This struct represents one entire state table. The three initialized byte -// areas are state_table, remap_base, and remap_string. state0 and state0_size -// give the byte offset and length within state_table of the initial state -- -// table lookups are expected to start and end in this state, but for -// truncated UTF-8 strings, may end in a different state. These allow a quick -// test for that condition. entry_shift is 8 for tables subscripted by a full -// byte value and 6 for space-optimized tables subscripted by only six -// significant bits in UTF-8 continuation bytes. -typedef struct { - const uint32 state0; - const uint32 state0_size; - const uint32 total_size; - const int max_expand; - const int entry_shift; - const int bytes_per_entry; - const uint32 losub; - const uint32 hiadd; - const uint8* state_table; - const RemapEntry* remap_base; - const uint8* remap_string; - const uint8* fast_state; -} UTF8StateMachineObj; - -typedef UTF8StateMachineObj UTF8ScanObj; - -#define X__ (kExitIllegalStructure) -#define RJ_ (kExitReject) -#define S1_ (kExitReplace1) -#define S2_ (kExitReplace2) -#define S3_ (kExitReplace3) -#define S21 (kExitReplace21) -#define S31 (kExitReplace31) -#define S32 (kExitReplace32) -#define T1_ (kExitReplaceOffset1) -#define T2_ (kExitReplaceOffset2) -#define S11 (kExitReplace1S0) -#define SP_ (kExitSpecial) -#define D__ (kExitDoAgain) -#define RJA (kExitRejectAlt) - -// Entire table has 9 state blocks of 256 entries each -static const unsigned int utf8acceptnonsurrogates_STATE0 = 0; // state[0] -static const unsigned int utf8acceptnonsurrogates_STATE0_SIZE = 256; // =[1] -static const unsigned int utf8acceptnonsurrogates_TOTAL_SIZE = 2304; -static const unsigned int utf8acceptnonsurrogates_MAX_EXPAND_X4 = 0; -static const unsigned int utf8acceptnonsurrogates_SHIFT = 8; -static const unsigned int utf8acceptnonsurrogates_BYTES = 1; -static const unsigned int utf8acceptnonsurrogates_LOSUB = 0x20202020; -static const unsigned int utf8acceptnonsurrogates_HIADD = 0x00000000; - -static const uint8 utf8acceptnonsurrogates[] = { -// state[0] 0x000000 Byte 1 - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - -X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, -X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, -X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, -X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, - -X__, X__, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 7, 3, 3, - 4, 5, 5, 5, 6, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, - -// state[1] 0x000080 Byte 2 of 2 -X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, -X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, -X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, -X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, - -X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, -X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, -X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, -X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - -X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, -X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, -X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, -X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, - -// state[2] 0x000000 Byte 2 of 3 -X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, -X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, -X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, -X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, - -X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, -X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, -X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, -X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, - -X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, -X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - -X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, -X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, -X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, -X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, - -// state[3] 0x001000 Byte 2 of 3 -X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, -X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, -X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, -X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, - -X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, -X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, -X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, -X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, - - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - -X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, -X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, -X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, -X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, - -// state[4] 0x000000 Byte 2 of 4 -X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, -X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, -X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, -X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, - -X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, -X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, -X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, -X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, - -X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, - 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, - 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, - 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, - -X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, -X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, -X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, -X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, - -// state[5] 0x040000 Byte 2 of 4 -X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, -X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, -X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, -X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, - -X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, -X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, -X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, -X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, - - 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, - 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, - 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, - 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, - -X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, -X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, -X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, -X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, - -// state[6] 0x100000 Byte 2 of 4 -X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, -X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, -X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, -X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, - -X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, -X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, -X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, -X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, - - 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, -X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, -X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, -X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, - -X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, -X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, -X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, -X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, - -// state[7] 0x00d000 Byte 2 of 3 -X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, -X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, -X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, -X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, - -X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, -X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, -X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, -X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, - - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - -X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, -X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, -X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, -X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, - -// state[8] 0x00d800 Byte 3 of 3 -X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, -X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, -X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, -X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, - -X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, -X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, -X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, -X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, - -RJ_, RJ_, RJ_, RJ_, RJ_, RJ_, RJ_, RJ_, RJ_, RJ_, RJ_, RJ_, RJ_, RJ_, RJ_, RJ_, -RJ_, RJ_, RJ_, RJ_, RJ_, RJ_, RJ_, RJ_, RJ_, RJ_, RJ_, RJ_, RJ_, RJ_, RJ_, RJ_, -RJ_, RJ_, RJ_, RJ_, RJ_, RJ_, RJ_, RJ_, RJ_, RJ_, RJ_, RJ_, RJ_, RJ_, RJ_, RJ_, -RJ_, RJ_, RJ_, RJ_, RJ_, RJ_, RJ_, RJ_, RJ_, RJ_, RJ_, RJ_, RJ_, RJ_, RJ_, RJ_, - -X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, -X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, -X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, -X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, X__, -}; - -// Remap base[0] = (del, add, string_offset) -static const RemapEntry utf8acceptnonsurrogates_remap_base[] = { -{0, 0, 0} }; - -// Remap string[0] -static const unsigned char utf8acceptnonsurrogates_remap_string[] = { -0 }; - -static const unsigned char utf8acceptnonsurrogates_fast[256] = { -0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - -0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - -1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, -1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, -1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, -1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - -1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, -1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, -1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, -1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, -}; - -static const UTF8ScanObj utf8acceptnonsurrogates_obj = { - utf8acceptnonsurrogates_STATE0, - utf8acceptnonsurrogates_STATE0_SIZE, - utf8acceptnonsurrogates_TOTAL_SIZE, - utf8acceptnonsurrogates_MAX_EXPAND_X4, - utf8acceptnonsurrogates_SHIFT, - utf8acceptnonsurrogates_BYTES, - utf8acceptnonsurrogates_LOSUB, - utf8acceptnonsurrogates_HIADD, - utf8acceptnonsurrogates, - utf8acceptnonsurrogates_remap_base, - utf8acceptnonsurrogates_remap_string, - utf8acceptnonsurrogates_fast -}; - - -#undef X__ -#undef RJ_ -#undef S1_ -#undef S2_ -#undef S3_ -#undef S21 -#undef S31 -#undef S32 -#undef T1_ -#undef T2_ -#undef S11 -#undef SP_ -#undef D__ -#undef RJA - -// Return true if current Tbl pointer is within state0 range -// Note that unsigned compare checks both ends of range simultaneously -static inline bool InStateZero(const UTF8ScanObj* st, const uint8* Tbl) { - const uint8* Tbl0 = &st->state_table[st->state0]; - return (static_cast(Tbl - Tbl0) < st->state0_size); -} - -// Scan a UTF-8 string based on state table. -// Always scan complete UTF-8 characters -// Set number of bytes scanned. Return reason for exiting -int UTF8GenericScan(const UTF8ScanObj* st, - const char * str, - int str_length, - int* bytes_consumed) { - *bytes_consumed = 0; - if (str_length == 0) return kExitOK; - - int eshift = st->entry_shift; - const uint8* isrc = reinterpret_cast(str); - const uint8* src = isrc; - const uint8* srclimit = isrc + str_length; - const uint8* srclimit8 = srclimit - 7; - const uint8* Tbl_0 = &st->state_table[st->state0]; - - DoAgain: - // Do state-table scan - int e = 0; - uint8 c; - const uint8* Tbl2 = &st->fast_state[0]; - const uint32 losub = st->losub; - const uint32 hiadd = st->hiadd; - // Check initial few bytes one at a time until 8-byte aligned - //---------------------------- - while ((((uintptr_t)src & 0x07) != 0) && - (src < srclimit) && - Tbl2[src[0]] == 0) { - src++; - } - if (((uintptr_t)src & 0x07) == 0) { - // Do fast for groups of 8 identity bytes. - // This covers a lot of 7-bit ASCII ~8x faster then the 1-byte loop, - // including slowing slightly on cr/lf/ht - //---------------------------- - while (src < srclimit8) { - uint32 s0123 = (reinterpret_cast(src))[0]; - uint32 s4567 = (reinterpret_cast(src))[1]; - src += 8; - // This is a fast range check for all bytes in [lowsub..0x80-hiadd) - uint32 temp = (s0123 - losub) | (s0123 + hiadd) | - (s4567 - losub) | (s4567 + hiadd); - if ((temp & 0x80808080) != 0) { - // We typically end up here on cr/lf/ht; src was incremented - int e0123 = (Tbl2[src[-8]] | Tbl2[src[-7]]) | - (Tbl2[src[-6]] | Tbl2[src[-5]]); - if (e0123 != 0) { - src -= 8; - break; - } // Exit on Non-interchange - e0123 = (Tbl2[src[-4]] | Tbl2[src[-3]]) | - (Tbl2[src[-2]] | Tbl2[src[-1]]); - if (e0123 != 0) { - src -= 4; - break; - } // Exit on Non-interchange - // Else OK, go around again - } - } - } - //---------------------------- - - // Byte-at-a-time scan - //---------------------------- - const uint8* Tbl = Tbl_0; - while (src < srclimit) { - c = *src; - e = Tbl[c]; - src++; - if (e >= kExitIllegalStructure) {break;} - Tbl = &Tbl_0[e << eshift]; - } - //---------------------------- - - - // Exit posibilities: - // Some exit code, !state0, back up over last char - // Some exit code, state0, back up one byte exactly - // source consumed, !state0, back up over partial char - // source consumed, state0, exit OK - // For illegal byte in state0, avoid backup up over PREVIOUS char - // For truncated last char, back up to beginning of it - - if (e >= kExitIllegalStructure) { - // Back up over exactly one byte of rejected/illegal UTF-8 character - src--; - // Back up more if needed - if (!InStateZero(st, Tbl)) { - do { - src--; - } while ((src > isrc) && ((src[0] & 0xc0) == 0x80)); - } - } else if (!InStateZero(st, Tbl)) { - // Back up over truncated UTF-8 character - e = kExitIllegalStructure; - do { - src--; - } while ((src > isrc) && ((src[0] & 0xc0) == 0x80)); - } else { - // Normal termination, source fully consumed - e = kExitOK; - } - - if (e == kExitDoAgain) { - // Loop back up to the fast scan - goto DoAgain; - } - - *bytes_consumed = src - isrc; - return e; -} - -int UTF8GenericScanFastAscii(const UTF8ScanObj* st, - const char * str, - int str_length, - int* bytes_consumed) { - *bytes_consumed = 0; - if (str_length == 0) return kExitOK; - - const uint8* isrc = reinterpret_cast(str); - const uint8* src = isrc; - const uint8* srclimit = isrc + str_length; - const uint8* srclimit8 = srclimit - 7; - int n; - int rest_consumed; - int exit_reason; - do { - // Check initial few bytes one at a time until 8-byte aligned - while ((((uintptr_t)src & 0x07) != 0) && - (src < srclimit) && (src[0] < 0x80)) { - src++; - } - if (((uintptr_t)src & 0x07) == 0) { - while ((src < srclimit8) && - (((reinterpret_cast(src)[0] | - reinterpret_cast(src)[1]) & 0x80808080) == 0)) { - src += 8; - } - } - while ((src < srclimit) && (src[0] < 0x80)) { - src++; - } - // Run state table on the rest - n = src - isrc; - exit_reason = UTF8GenericScan(st, str + n, str_length - n, &rest_consumed); - src += rest_consumed; - } while ( exit_reason == kExitDoAgain ); - - *bytes_consumed = src - isrc; - return exit_reason; -} - -// Hack: On some compilers the static tables are initialized at startup. -// We can't use them until they are initialized. However, some Protocol -// Buffer parsing happens at static init time and may try to validate -// UTF-8 strings. Since UTF-8 validation is only used for debugging -// anyway, we simply always return success if initialization hasn't -// occurred yet. -namespace { - -bool module_initialized_ = false; - -struct InitDetector { - InitDetector() { - module_initialized_ = true; - } -}; -InitDetector init_detector; - -} // namespace - -bool IsStructurallyValidUTF8(const char* buf, int len) { - if (!module_initialized_) return true; - - int bytes_consumed = 0; - UTF8GenericScanFastAscii(&utf8acceptnonsurrogates_obj, - buf, len, &bytes_consumed); - return (bytes_consumed == len); -} - -} // namespace internal -} // namespace protobuf -} // namespace google diff --git a/modules/dnn/3rdparty/protobuf/src/google/protobuf/stubs/structurally_valid_unittest.cc b/modules/dnn/3rdparty/protobuf/src/google/protobuf/stubs/structurally_valid_unittest.cc deleted file mode 100644 index 90888885a..000000000 --- a/modules/dnn/3rdparty/protobuf/src/google/protobuf/stubs/structurally_valid_unittest.cc +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright 2008 Google Inc. All Rights Reserved. -// Author: xpeng@google.com (Peter Peng) - -#include -#include - -namespace google { -namespace protobuf { -namespace internal { -namespace { - -TEST(StructurallyValidTest, ValidUTF8String) { - // On GCC, this string can be written as: - // "abcd 1234 - \u2014\u2013\u2212" - // MSVC seems to interpret \u differently. - string valid_str("abcd 1234 - \342\200\224\342\200\223\342\210\222 - xyz789"); - EXPECT_TRUE(IsStructurallyValidUTF8(valid_str.data(), - valid_str.size())); - // Additional check for pointer alignment - for (int i = 1; i < 8; ++i) { - EXPECT_TRUE(IsStructurallyValidUTF8(valid_str.data() + i, - valid_str.size() - i)); - } -} - -TEST(StructurallyValidTest, InvalidUTF8String) { - const string invalid_str("abcd\xA0\xB0\xA0\xB0\xA0\xB0 - xyz789"); - EXPECT_FALSE(IsStructurallyValidUTF8(invalid_str.data(), - invalid_str.size())); - // Additional check for pointer alignment - for (int i = 1; i < 8; ++i) { - EXPECT_FALSE(IsStructurallyValidUTF8(invalid_str.data() + i, - invalid_str.size() - i)); - } -} - -} // namespace -} // namespace internal -} // namespace protobuf -} // namespace google diff --git a/modules/dnn/3rdparty/protobuf/src/google/protobuf/stubs/strutil.cc b/modules/dnn/3rdparty/protobuf/src/google/protobuf/stubs/strutil.cc deleted file mode 100644 index 00d1bc633..000000000 --- a/modules/dnn/3rdparty/protobuf/src/google/protobuf/stubs/strutil.cc +++ /dev/null @@ -1,1204 +0,0 @@ -// Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// http://code.google.com/p/protobuf/ -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -// from google3/strings/strutil.cc - -#include -#include -#include // FLT_DIG and DBL_DIG -#include -#include -#include -#include - -#ifdef _WIN32 -// MSVC has only _snprintf, not snprintf. -// -// MinGW has both snprintf and _snprintf, but they appear to be different -// functions. The former is buggy. When invoked like so: -// char buffer[32]; -// snprintf(buffer, 32, "%.*g\n", FLT_DIG, 1.23e10f); -// it prints "1.23000e+10". This is plainly wrong: %g should never print -// trailing zeros after the decimal point. For some reason this bug only -// occurs with some input values, not all. In any case, _snprintf does the -// right thing, so we use it. -#define snprintf _snprintf -#endif - -namespace google { -namespace protobuf { - -inline bool IsNaN(double value) { - // NaN is never equal to anything, even itself. - return value != value; -} - -// These are defined as macros on some platforms. #undef them so that we can -// redefine them. -#undef isxdigit -#undef isprint - -// The definitions of these in ctype.h change based on locale. Since our -// string manipulation is all in relation to the protocol buffer and C++ -// languages, we always want to use the C locale. So, we re-define these -// exactly as we want them. -inline bool isxdigit(char c) { - return ('0' <= c && c <= '9') || - ('a' <= c && c <= 'f') || - ('A' <= c && c <= 'F'); -} - -inline bool isprint(char c) { - return c >= 0x20 && c <= 0x7E; -} - -// ---------------------------------------------------------------------- -// StripString -// Replaces any occurrence of the character 'remove' (or the characters -// in 'remove') with the character 'replacewith'. -// ---------------------------------------------------------------------- -void StripString(string* s, const char* remove, char replacewith) { - const char * str_start = s->c_str(); - const char * str = str_start; - for (str = strpbrk(str, remove); - str != NULL; - str = strpbrk(str + 1, remove)) { - (*s)[str - str_start] = replacewith; - } -} - -// ---------------------------------------------------------------------- -// StringReplace() -// Replace the "old" pattern with the "new" pattern in a string, -// and append the result to "res". If replace_all is false, -// it only replaces the first instance of "old." -// ---------------------------------------------------------------------- - -void StringReplace(const string& s, const string& oldsub, - const string& newsub, bool replace_all, - string* res) { - if (oldsub.empty()) { - res->append(s); // if empty, append the given string. - return; - } - - string::size_type start_pos = 0; - string::size_type pos; - do { - pos = s.find(oldsub, start_pos); - if (pos == string::npos) { - break; - } - res->append(s, start_pos, pos - start_pos); - res->append(newsub); - start_pos = pos + oldsub.size(); // start searching again after the "old" - } while (replace_all); - res->append(s, start_pos, s.length() - start_pos); -} - -// ---------------------------------------------------------------------- -// StringReplace() -// Give me a string and two patterns "old" and "new", and I replace -// the first instance of "old" in the string with "new", if it -// exists. If "global" is true; call this repeatedly until it -// fails. RETURN a new string, regardless of whether the replacement -// happened or not. -// ---------------------------------------------------------------------- - -string StringReplace(const string& s, const string& oldsub, - const string& newsub, bool replace_all) { - string ret; - StringReplace(s, oldsub, newsub, replace_all, &ret); - return ret; -} - -// ---------------------------------------------------------------------- -// SplitStringUsing() -// Split a string using a character delimiter. Append the components -// to 'result'. -// -// Note: For multi-character delimiters, this routine will split on *ANY* of -// the characters in the string, not the entire string as a single delimiter. -// ---------------------------------------------------------------------- -template -static inline -void SplitStringToIteratorUsing(const string& full, - const char* delim, - ITR& result) { - // Optimize the common case where delim is a single character. - if (delim[0] != '\0' && delim[1] == '\0') { - char c = delim[0]; - const char* p = full.data(); - const char* end = p + full.size(); - while (p != end) { - if (*p == c) { - ++p; - } else { - const char* start = p; - while (++p != end && *p != c); - *result++ = string(start, p - start); - } - } - return; - } - - string::size_type begin_index, end_index; - begin_index = full.find_first_not_of(delim); - while (begin_index != string::npos) { - end_index = full.find_first_of(delim, begin_index); - if (end_index == string::npos) { - *result++ = full.substr(begin_index); - return; - } - *result++ = full.substr(begin_index, (end_index - begin_index)); - begin_index = full.find_first_not_of(delim, end_index); - } -} - -void SplitStringUsing(const string& full, - const char* delim, - vector* result) { - back_insert_iterator< vector > it(*result); - SplitStringToIteratorUsing(full, delim, it); -} - -// Split a string using a character delimiter. Append the components -// to 'result'. If there are consecutive delimiters, this function -// will return corresponding empty strings. The string is split into -// at most the specified number of pieces greedily. This means that the -// last piece may possibly be split further. To split into as many pieces -// as possible, specify 0 as the number of pieces. -// -// If "full" is the empty string, yields an empty string as the only value. -// -// If "pieces" is negative for some reason, it returns the whole string -// ---------------------------------------------------------------------- -template -static inline -void SplitStringToIteratorAllowEmpty(const StringType& full, - const char* delim, - int pieces, - ITR& result) { - string::size_type begin_index, end_index; - begin_index = 0; - - for (int i = 0; (i < pieces-1) || (pieces == 0); i++) { - end_index = full.find_first_of(delim, begin_index); - if (end_index == string::npos) { - *result++ = full.substr(begin_index); - return; - } - *result++ = full.substr(begin_index, (end_index - begin_index)); - begin_index = end_index + 1; - } - *result++ = full.substr(begin_index); -} - -void SplitStringAllowEmpty(const string& full, const char* delim, - vector* result) { - back_insert_iterator > it(*result); - SplitStringToIteratorAllowEmpty(full, delim, 0, it); -} - -// ---------------------------------------------------------------------- -// JoinStrings() -// This merges a vector of string components with delim inserted -// as separaters between components. -// -// ---------------------------------------------------------------------- -template -static void JoinStringsIterator(const ITERATOR& start, - const ITERATOR& end, - const char* delim, - string* result) { - GOOGLE_CHECK(result != NULL); - result->clear(); - int delim_length = strlen(delim); - - // Precompute resulting length so we can reserve() memory in one shot. - int length = 0; - for (ITERATOR iter = start; iter != end; ++iter) { - if (iter != start) { - length += delim_length; - } - length += iter->size(); - } - result->reserve(length); - - // Now combine everything. - for (ITERATOR iter = start; iter != end; ++iter) { - if (iter != start) { - result->append(delim, delim_length); - } - result->append(iter->data(), iter->size()); - } -} - -void JoinStrings(const vector& components, - const char* delim, - string * result) { - JoinStringsIterator(components.begin(), components.end(), delim, result); -} - -// ---------------------------------------------------------------------- -// UnescapeCEscapeSequences() -// This does all the unescaping that C does: \ooo, \r, \n, etc -// Returns length of resulting string. -// The implementation of \x parses any positive number of hex digits, -// but it is an error if the value requires more than 8 bits, and the -// result is truncated to 8 bits. -// -// The second call stores its errors in a supplied string vector. -// If the string vector pointer is NULL, it reports the errors with LOG(). -// ---------------------------------------------------------------------- - -#define IS_OCTAL_DIGIT(c) (((c) >= '0') && ((c) <= '7')) - -inline int hex_digit_to_int(char c) { - /* Assume ASCII. */ - assert('0' == 0x30 && 'A' == 0x41 && 'a' == 0x61); - assert(isxdigit(c)); - int x = static_cast(c); - if (x > '9') { - x += 9; - } - return x & 0xf; -} - -// Protocol buffers doesn't ever care about errors, but I don't want to remove -// the code. -#define LOG_STRING(LEVEL, VECTOR) GOOGLE_LOG_IF(LEVEL, false) - -int UnescapeCEscapeSequences(const char* source, char* dest) { - return UnescapeCEscapeSequences(source, dest, NULL); -} - -int UnescapeCEscapeSequences(const char* source, char* dest, - vector *errors) { - GOOGLE_DCHECK(errors == NULL) << "Error reporting not implemented."; - - char* d = dest; - const char* p = source; - - // Small optimization for case where source = dest and there's no escaping - while ( p == d && *p != '\0' && *p != '\\' ) - p++, d++; - - while (*p != '\0') { - if (*p != '\\') { - *d++ = *p++; - } else { - switch ( *++p ) { // skip past the '\\' - case '\0': - LOG_STRING(ERROR, errors) << "String cannot end with \\"; - *d = '\0'; - return d - dest; // we're done with p - case 'a': *d++ = '\a'; break; - case 'b': *d++ = '\b'; break; - case 'f': *d++ = '\f'; break; - case 'n': *d++ = '\n'; break; - case 'r': *d++ = '\r'; break; - case 't': *d++ = '\t'; break; - case 'v': *d++ = '\v'; break; - case '\\': *d++ = '\\'; break; - case '?': *d++ = '\?'; break; // \? Who knew? - case '\'': *d++ = '\''; break; - case '"': *d++ = '\"'; break; - case '0': case '1': case '2': case '3': // octal digit: 1 to 3 digits - case '4': case '5': case '6': case '7': { - char ch = *p - '0'; - if ( IS_OCTAL_DIGIT(p[1]) ) - ch = ch * 8 + *++p - '0'; - if ( IS_OCTAL_DIGIT(p[1]) ) // safe (and easy) to do this twice - ch = ch * 8 + *++p - '0'; // now points at last digit - *d++ = ch; - break; - } - case 'x': case 'X': { - if (!isxdigit(p[1])) { - if (p[1] == '\0') { - LOG_STRING(ERROR, errors) << "String cannot end with \\x"; - } else { - LOG_STRING(ERROR, errors) << - "\\x cannot be followed by non-hex digit: \\" << *p << p[1]; - } - break; - } - unsigned int ch = 0; - const char *hex_start = p; - while (isxdigit(p[1])) // arbitrarily many hex digits - ch = (ch << 4) + hex_digit_to_int(*++p); - if (ch > 0xFF) - LOG_STRING(ERROR, errors) << "Value of " << - "\\" << string(hex_start, p+1-hex_start) << " exceeds 8 bits"; - *d++ = ch; - break; - } -#if 0 // TODO(kenton): Support \u and \U? Requires runetochar(). - case 'u': { - // \uhhhh => convert 4 hex digits to UTF-8 - char32 rune = 0; - const char *hex_start = p; - for (int i = 0; i < 4; ++i) { - if (isxdigit(p[1])) { // Look one char ahead. - rune = (rune << 4) + hex_digit_to_int(*++p); // Advance p. - } else { - LOG_STRING(ERROR, errors) - << "\\u must be followed by 4 hex digits: \\" - << string(hex_start, p+1-hex_start); - break; - } - } - d += runetochar(d, &rune); - break; - } - case 'U': { - // \Uhhhhhhhh => convert 8 hex digits to UTF-8 - char32 rune = 0; - const char *hex_start = p; - for (int i = 0; i < 8; ++i) { - if (isxdigit(p[1])) { // Look one char ahead. - // Don't change rune until we're sure this - // is within the Unicode limit, but do advance p. - char32 newrune = (rune << 4) + hex_digit_to_int(*++p); - if (newrune > 0x10FFFF) { - LOG_STRING(ERROR, errors) - << "Value of \\" - << string(hex_start, p + 1 - hex_start) - << " exceeds Unicode limit (0x10FFFF)"; - break; - } else { - rune = newrune; - } - } else { - LOG_STRING(ERROR, errors) - << "\\U must be followed by 8 hex digits: \\" - << string(hex_start, p+1-hex_start); - break; - } - } - d += runetochar(d, &rune); - break; - } -#endif - default: - LOG_STRING(ERROR, errors) << "Unknown escape sequence: \\" << *p; - } - p++; // read past letter we escaped - } - } - *d = '\0'; - return d - dest; -} - -// ---------------------------------------------------------------------- -// UnescapeCEscapeString() -// This does the same thing as UnescapeCEscapeSequences, but creates -// a new string. The caller does not need to worry about allocating -// a dest buffer. This should be used for non performance critical -// tasks such as printing debug messages. It is safe for src and dest -// to be the same. -// -// The second call stores its errors in a supplied string vector. -// If the string vector pointer is NULL, it reports the errors with LOG(). -// -// In the first and second calls, the length of dest is returned. In the -// the third call, the new string is returned. -// ---------------------------------------------------------------------- -int UnescapeCEscapeString(const string& src, string* dest) { - return UnescapeCEscapeString(src, dest, NULL); -} - -int UnescapeCEscapeString(const string& src, string* dest, - vector *errors) { - scoped_array unescaped(new char[src.size() + 1]); - int len = UnescapeCEscapeSequences(src.c_str(), unescaped.get(), errors); - GOOGLE_CHECK(dest); - dest->assign(unescaped.get(), len); - return len; -} - -string UnescapeCEscapeString(const string& src) { - scoped_array unescaped(new char[src.size() + 1]); - int len = UnescapeCEscapeSequences(src.c_str(), unescaped.get(), NULL); - return string(unescaped.get(), len); -} - -// ---------------------------------------------------------------------- -// CEscapeString() -// CHexEscapeString() -// Copies 'src' to 'dest', escaping dangerous characters using -// C-style escape sequences. This is very useful for preparing query -// flags. 'src' and 'dest' should not overlap. The 'Hex' version uses -// hexadecimal rather than octal sequences. -// Returns the number of bytes written to 'dest' (not including the \0) -// or -1 if there was insufficient space. -// -// Currently only \n, \r, \t, ", ', \ and !isprint() chars are escaped. -// ---------------------------------------------------------------------- -int CEscapeInternal(const char* src, int src_len, char* dest, - int dest_len, bool use_hex, bool utf8_safe) { - const char* src_end = src + src_len; - int used = 0; - bool last_hex_escape = false; // true if last output char was \xNN - - for (; src < src_end; src++) { - if (dest_len - used < 2) // Need space for two letter escape - return -1; - - bool is_hex_escape = false; - switch (*src) { - case '\n': dest[used++] = '\\'; dest[used++] = 'n'; break; - case '\r': dest[used++] = '\\'; dest[used++] = 'r'; break; - case '\t': dest[used++] = '\\'; dest[used++] = 't'; break; - case '\"': dest[used++] = '\\'; dest[used++] = '\"'; break; - case '\'': dest[used++] = '\\'; dest[used++] = '\''; break; - case '\\': dest[used++] = '\\'; dest[used++] = '\\'; break; - default: - // Note that if we emit \xNN and the src character after that is a hex - // digit then that digit must be escaped too to prevent it being - // interpreted as part of the character code by C. - if ((!utf8_safe || static_cast(*src) < 0x80) && - (!isprint(*src) || - (last_hex_escape && isxdigit(*src)))) { - if (dest_len - used < 4) // need space for 4 letter escape - return -1; - sprintf(dest + used, (use_hex ? "\\x%02x" : "\\%03o"), - static_cast(*src)); - is_hex_escape = use_hex; - used += 4; - } else { - dest[used++] = *src; break; - } - } - last_hex_escape = is_hex_escape; - } - - if (dest_len - used < 1) // make sure that there is room for \0 - return -1; - - dest[used] = '\0'; // doesn't count towards return value though - return used; -} - -int CEscapeString(const char* src, int src_len, char* dest, int dest_len) { - return CEscapeInternal(src, src_len, dest, dest_len, false, false); -} - -// ---------------------------------------------------------------------- -// CEscape() -// CHexEscape() -// Copies 'src' to result, escaping dangerous characters using -// C-style escape sequences. This is very useful for preparing query -// flags. 'src' and 'dest' should not overlap. The 'Hex' version -// hexadecimal rather than octal sequences. -// -// Currently only \n, \r, \t, ", ', \ and !isprint() chars are escaped. -// ---------------------------------------------------------------------- -string CEscape(const string& src) { - const int dest_length = src.size() * 4 + 1; // Maximum possible expansion - scoped_array dest(new char[dest_length]); - const int len = CEscapeInternal(src.data(), src.size(), - dest.get(), dest_length, false, false); - GOOGLE_DCHECK_GE(len, 0); - return string(dest.get(), len); -} - -namespace strings { - -string Utf8SafeCEscape(const string& src) { - const int dest_length = src.size() * 4 + 1; // Maximum possible expansion - scoped_array dest(new char[dest_length]); - const int len = CEscapeInternal(src.data(), src.size(), - dest.get(), dest_length, false, true); - GOOGLE_DCHECK_GE(len, 0); - return string(dest.get(), len); -} - -string CHexEscape(const string& src) { - const int dest_length = src.size() * 4 + 1; // Maximum possible expansion - scoped_array dest(new char[dest_length]); - const int len = CEscapeInternal(src.data(), src.size(), - dest.get(), dest_length, true, false); - GOOGLE_DCHECK_GE(len, 0); - return string(dest.get(), len); -} - -} // namespace strings - -// ---------------------------------------------------------------------- -// strto32_adaptor() -// strtou32_adaptor() -// Implementation of strto[u]l replacements that have identical -// overflow and underflow characteristics for both ILP-32 and LP-64 -// platforms, including errno preservation in error-free calls. -// ---------------------------------------------------------------------- - -int32 strto32_adaptor(const char *nptr, char **endptr, int base) { - const int saved_errno = errno; - errno = 0; - const long result = strtol(nptr, endptr, base); - if (errno == ERANGE && result == LONG_MIN) { - return kint32min; - } else if (errno == ERANGE && result == LONG_MAX) { - return kint32max; - } else if (errno == 0 && result < kint32min) { - errno = ERANGE; - return kint32min; - } else if (errno == 0 && result > kint32max) { - errno = ERANGE; - return kint32max; - } - if (errno == 0) - errno = saved_errno; - return static_cast(result); -} - -uint32 strtou32_adaptor(const char *nptr, char **endptr, int base) { - const int saved_errno = errno; - errno = 0; - const unsigned long result = strtoul(nptr, endptr, base); - if (errno == ERANGE && result == ULONG_MAX) { - return kuint32max; - } else if (errno == 0 && result > kuint32max) { - errno = ERANGE; - return kuint32max; - } - if (errno == 0) - errno = saved_errno; - return static_cast(result); -} - -// ---------------------------------------------------------------------- -// FastIntToBuffer() -// FastInt64ToBuffer() -// FastHexToBuffer() -// FastHex64ToBuffer() -// FastHex32ToBuffer() -// ---------------------------------------------------------------------- - -// Offset into buffer where FastInt64ToBuffer places the end of string -// null character. Also used by FastInt64ToBufferLeft. -static const int kFastInt64ToBufferOffset = 21; - -char *FastInt64ToBuffer(int64 i, char* buffer) { - // We could collapse the positive and negative sections, but that - // would be slightly slower for positive numbers... - // 22 bytes is enough to store -2**64, -18446744073709551616. - char* p = buffer + kFastInt64ToBufferOffset; - *p-- = '\0'; - if (i >= 0) { - do { - *p-- = '0' + i % 10; - i /= 10; - } while (i > 0); - return p + 1; - } else { - // On different platforms, % and / have different behaviors for - // negative numbers, so we need to jump through hoops to make sure - // we don't divide negative numbers. - if (i > -10) { - i = -i; - *p-- = '0' + i; - *p = '-'; - return p; - } else { - // Make sure we aren't at MIN_INT, in which case we can't say i = -i - i = i + 10; - i = -i; - *p-- = '0' + i % 10; - // Undo what we did a moment ago - i = i / 10 + 1; - do { - *p-- = '0' + i % 10; - i /= 10; - } while (i > 0); - *p = '-'; - return p; - } - } -} - -// Offset into buffer where FastInt32ToBuffer places the end of string -// null character. Also used by FastInt32ToBufferLeft -static const int kFastInt32ToBufferOffset = 11; - -// Yes, this is a duplicate of FastInt64ToBuffer. But, we need this for the -// compiler to generate 32 bit arithmetic instructions. It's much faster, at -// least with 32 bit binaries. -char *FastInt32ToBuffer(int32 i, char* buffer) { - // We could collapse the positive and negative sections, but that - // would be slightly slower for positive numbers... - // 12 bytes is enough to store -2**32, -4294967296. - char* p = buffer + kFastInt32ToBufferOffset; - *p-- = '\0'; - if (i >= 0) { - do { - *p-- = '0' + i % 10; - i /= 10; - } while (i > 0); - return p + 1; - } else { - // On different platforms, % and / have different behaviors for - // negative numbers, so we need to jump through hoops to make sure - // we don't divide negative numbers. - if (i > -10) { - i = -i; - *p-- = '0' + i; - *p = '-'; - return p; - } else { - // Make sure we aren't at MIN_INT, in which case we can't say i = -i - i = i + 10; - i = -i; - *p-- = '0' + i % 10; - // Undo what we did a moment ago - i = i / 10 + 1; - do { - *p-- = '0' + i % 10; - i /= 10; - } while (i > 0); - *p = '-'; - return p; - } - } -} - -char *FastHexToBuffer(int i, char* buffer) { - GOOGLE_CHECK(i >= 0) << "FastHexToBuffer() wants non-negative integers, not " << i; - - static const char *hexdigits = "0123456789abcdef"; - char *p = buffer + 21; - *p-- = '\0'; - do { - *p-- = hexdigits[i & 15]; // mod by 16 - i >>= 4; // divide by 16 - } while (i > 0); - return p + 1; -} - -char *InternalFastHexToBuffer(uint64 value, char* buffer, int num_byte) { - static const char *hexdigits = "0123456789abcdef"; - buffer[num_byte] = '\0'; - for (int i = num_byte - 1; i >= 0; i--) { -#ifdef _M_X64 - // MSVC x64 platform has a bug optimizing the uint32(value) in the #else - // block. Given that the uint32 cast was to improve performance on 32-bit - // platforms, we use 64-bit '&' directly. - buffer[i] = hexdigits[value & 0xf]; -#else - buffer[i] = hexdigits[uint32(value) & 0xf]; -#endif - value >>= 4; - } - return buffer; -} - -char *FastHex64ToBuffer(uint64 value, char* buffer) { - return InternalFastHexToBuffer(value, buffer, 16); -} - -char *FastHex32ToBuffer(uint32 value, char* buffer) { - return InternalFastHexToBuffer(value, buffer, 8); -} - -// ---------------------------------------------------------------------- -// FastInt32ToBufferLeft() -// FastUInt32ToBufferLeft() -// FastInt64ToBufferLeft() -// FastUInt64ToBufferLeft() -// -// Like the Fast*ToBuffer() functions above, these are intended for speed. -// Unlike the Fast*ToBuffer() functions, however, these functions write -// their output to the beginning of the buffer (hence the name, as the -// output is left-aligned). The caller is responsible for ensuring that -// the buffer has enough space to hold the output. -// -// Returns a pointer to the end of the string (i.e. the null character -// terminating the string). -// ---------------------------------------------------------------------- - -static const char two_ASCII_digits[100][2] = { - {'0','0'}, {'0','1'}, {'0','2'}, {'0','3'}, {'0','4'}, - {'0','5'}, {'0','6'}, {'0','7'}, {'0','8'}, {'0','9'}, - {'1','0'}, {'1','1'}, {'1','2'}, {'1','3'}, {'1','4'}, - {'1','5'}, {'1','6'}, {'1','7'}, {'1','8'}, {'1','9'}, - {'2','0'}, {'2','1'}, {'2','2'}, {'2','3'}, {'2','4'}, - {'2','5'}, {'2','6'}, {'2','7'}, {'2','8'}, {'2','9'}, - {'3','0'}, {'3','1'}, {'3','2'}, {'3','3'}, {'3','4'}, - {'3','5'}, {'3','6'}, {'3','7'}, {'3','8'}, {'3','9'}, - {'4','0'}, {'4','1'}, {'4','2'}, {'4','3'}, {'4','4'}, - {'4','5'}, {'4','6'}, {'4','7'}, {'4','8'}, {'4','9'}, - {'5','0'}, {'5','1'}, {'5','2'}, {'5','3'}, {'5','4'}, - {'5','5'}, {'5','6'}, {'5','7'}, {'5','8'}, {'5','9'}, - {'6','0'}, {'6','1'}, {'6','2'}, {'6','3'}, {'6','4'}, - {'6','5'}, {'6','6'}, {'6','7'}, {'6','8'}, {'6','9'}, - {'7','0'}, {'7','1'}, {'7','2'}, {'7','3'}, {'7','4'}, - {'7','5'}, {'7','6'}, {'7','7'}, {'7','8'}, {'7','9'}, - {'8','0'}, {'8','1'}, {'8','2'}, {'8','3'}, {'8','4'}, - {'8','5'}, {'8','6'}, {'8','7'}, {'8','8'}, {'8','9'}, - {'9','0'}, {'9','1'}, {'9','2'}, {'9','3'}, {'9','4'}, - {'9','5'}, {'9','6'}, {'9','7'}, {'9','8'}, {'9','9'} -}; - -char* FastUInt32ToBufferLeft(uint32 u, char* buffer) { - int digits; - const char *ASCII_digits = NULL; - // The idea of this implementation is to trim the number of divides to as few - // as possible by using multiplication and subtraction rather than mod (%), - // and by outputting two digits at a time rather than one. - // The huge-number case is first, in the hopes that the compiler will output - // that case in one branch-free block of code, and only output conditional - // branches into it from below. - if (u >= 1000000000) { // >= 1,000,000,000 - digits = u / 100000000; // 100,000,000 - ASCII_digits = two_ASCII_digits[digits]; - buffer[0] = ASCII_digits[0]; - buffer[1] = ASCII_digits[1]; - buffer += 2; -sublt100_000_000: - u -= digits * 100000000; // 100,000,000 -lt100_000_000: - digits = u / 1000000; // 1,000,000 - ASCII_digits = two_ASCII_digits[digits]; - buffer[0] = ASCII_digits[0]; - buffer[1] = ASCII_digits[1]; - buffer += 2; -sublt1_000_000: - u -= digits * 1000000; // 1,000,000 -lt1_000_000: - digits = u / 10000; // 10,000 - ASCII_digits = two_ASCII_digits[digits]; - buffer[0] = ASCII_digits[0]; - buffer[1] = ASCII_digits[1]; - buffer += 2; -sublt10_000: - u -= digits * 10000; // 10,000 -lt10_000: - digits = u / 100; - ASCII_digits = two_ASCII_digits[digits]; - buffer[0] = ASCII_digits[0]; - buffer[1] = ASCII_digits[1]; - buffer += 2; -sublt100: - u -= digits * 100; -lt100: - digits = u; - ASCII_digits = two_ASCII_digits[digits]; - buffer[0] = ASCII_digits[0]; - buffer[1] = ASCII_digits[1]; - buffer += 2; -done: - *buffer = 0; - return buffer; - } - - if (u < 100) { - digits = u; - if (u >= 10) goto lt100; - *buffer++ = '0' + digits; - goto done; - } - if (u < 10000) { // 10,000 - if (u >= 1000) goto lt10_000; - digits = u / 100; - *buffer++ = '0' + digits; - goto sublt100; - } - if (u < 1000000) { // 1,000,000 - if (u >= 100000) goto lt1_000_000; - digits = u / 10000; // 10,000 - *buffer++ = '0' + digits; - goto sublt10_000; - } - if (u < 100000000) { // 100,000,000 - if (u >= 10000000) goto lt100_000_000; - digits = u / 1000000; // 1,000,000 - *buffer++ = '0' + digits; - goto sublt1_000_000; - } - // we already know that u < 1,000,000,000 - digits = u / 100000000; // 100,000,000 - *buffer++ = '0' + digits; - goto sublt100_000_000; -} - -char* FastInt32ToBufferLeft(int32 i, char* buffer) { - uint32 u = i; - if (i < 0) { - *buffer++ = '-'; - u = -i; - } - return FastUInt32ToBufferLeft(u, buffer); -} - -char* FastUInt64ToBufferLeft(uint64 u64, char* buffer) { - int digits; - const char *ASCII_digits = NULL; - - uint32 u = static_cast(u64); - if (u == u64) return FastUInt32ToBufferLeft(u, buffer); - - uint64 top_11_digits = u64 / 1000000000; - buffer = FastUInt64ToBufferLeft(top_11_digits, buffer); - u = u64 - (top_11_digits * 1000000000); - - digits = u / 10000000; // 10,000,000 - GOOGLE_DCHECK_LT(digits, 100); - ASCII_digits = two_ASCII_digits[digits]; - buffer[0] = ASCII_digits[0]; - buffer[1] = ASCII_digits[1]; - buffer += 2; - u -= digits * 10000000; // 10,000,000 - digits = u / 100000; // 100,000 - ASCII_digits = two_ASCII_digits[digits]; - buffer[0] = ASCII_digits[0]; - buffer[1] = ASCII_digits[1]; - buffer += 2; - u -= digits * 100000; // 100,000 - digits = u / 1000; // 1,000 - ASCII_digits = two_ASCII_digits[digits]; - buffer[0] = ASCII_digits[0]; - buffer[1] = ASCII_digits[1]; - buffer += 2; - u -= digits * 1000; // 1,000 - digits = u / 10; - ASCII_digits = two_ASCII_digits[digits]; - buffer[0] = ASCII_digits[0]; - buffer[1] = ASCII_digits[1]; - buffer += 2; - u -= digits * 10; - digits = u; - *buffer++ = '0' + digits; - *buffer = 0; - return buffer; -} - -char* FastInt64ToBufferLeft(int64 i, char* buffer) { - uint64 u = i; - if (i < 0) { - *buffer++ = '-'; - u = -i; - } - return FastUInt64ToBufferLeft(u, buffer); -} - -// ---------------------------------------------------------------------- -// SimpleItoa() -// Description: converts an integer to a string. -// -// Return value: string -// ---------------------------------------------------------------------- - -string SimpleItoa(int i) { - char buffer[kFastToBufferSize]; - return (sizeof(i) == 4) ? - FastInt32ToBuffer(i, buffer) : - FastInt64ToBuffer(i, buffer); -} - -string SimpleItoa(unsigned int i) { - char buffer[kFastToBufferSize]; - return string(buffer, (sizeof(i) == 4) ? - FastUInt32ToBufferLeft(i, buffer) : - FastUInt64ToBufferLeft(i, buffer)); -} - -string SimpleItoa(long i) { - char buffer[kFastToBufferSize]; - return (sizeof(i) == 4) ? - FastInt32ToBuffer(i, buffer) : - FastInt64ToBuffer(i, buffer); -} - -string SimpleItoa(unsigned long i) { - char buffer[kFastToBufferSize]; - return string(buffer, (sizeof(i) == 4) ? - FastUInt32ToBufferLeft(i, buffer) : - FastUInt64ToBufferLeft(i, buffer)); -} - -string SimpleItoa(long long i) { - char buffer[kFastToBufferSize]; - return (sizeof(i) == 4) ? - FastInt32ToBuffer(i, buffer) : - FastInt64ToBuffer(i, buffer); -} - -string SimpleItoa(unsigned long long i) { - char buffer[kFastToBufferSize]; - return string(buffer, (sizeof(i) == 4) ? - FastUInt32ToBufferLeft(i, buffer) : - FastUInt64ToBufferLeft(i, buffer)); -} - -// ---------------------------------------------------------------------- -// SimpleDtoa() -// SimpleFtoa() -// DoubleToBuffer() -// FloatToBuffer() -// We want to print the value without losing precision, but we also do -// not want to print more digits than necessary. This turns out to be -// trickier than it sounds. Numbers like 0.2 cannot be represented -// exactly in binary. If we print 0.2 with a very large precision, -// e.g. "%.50g", we get "0.2000000000000000111022302462515654042363167". -// On the other hand, if we set the precision too low, we lose -// significant digits when printing numbers that actually need them. -// It turns out there is no precision value that does the right thing -// for all numbers. -// -// Our strategy is to first try printing with a precision that is never -// over-precise, then parse the result with strtod() to see if it -// matches. If not, we print again with a precision that will always -// give a precise result, but may use more digits than necessary. -// -// An arguably better strategy would be to use the algorithm described -// in "How to Print Floating-Point Numbers Accurately" by Steele & -// White, e.g. as implemented by David M. Gay's dtoa(). It turns out, -// however, that the following implementation is about as fast as -// DMG's code. Furthermore, DMG's code locks mutexes, which means it -// will not scale well on multi-core machines. DMG's code is slightly -// more accurate (in that it will never use more digits than -// necessary), but this is probably irrelevant for most users. -// -// Rob Pike and Ken Thompson also have an implementation of dtoa() in -// third_party/fmt/fltfmt.cc. Their implementation is similar to this -// one in that it makes guesses and then uses strtod() to check them. -// Their implementation is faster because they use their own code to -// generate the digits in the first place rather than use snprintf(), -// thus avoiding format string parsing overhead. However, this makes -// it considerably more complicated than the following implementation, -// and it is embedded in a larger library. If speed turns out to be -// an issue, we could re-implement this in terms of their -// implementation. -// ---------------------------------------------------------------------- - -string SimpleDtoa(double value) { - char buffer[kDoubleToBufferSize]; - return DoubleToBuffer(value, buffer); -} - -string SimpleFtoa(float value) { - char buffer[kFloatToBufferSize]; - return FloatToBuffer(value, buffer); -} - -static inline bool IsValidFloatChar(char c) { - return ('0' <= c && c <= '9') || - c == 'e' || c == 'E' || - c == '+' || c == '-'; -} - -void DelocalizeRadix(char* buffer) { - // Fast check: if the buffer has a normal decimal point, assume no - // translation is needed. - if (strchr(buffer, '.') != NULL) return; - - // Find the first unknown character. - while (IsValidFloatChar(*buffer)) ++buffer; - - if (*buffer == '\0') { - // No radix character found. - return; - } - - // We are now pointing at the locale-specific radix character. Replace it - // with '.'. - *buffer = '.'; - ++buffer; - - if (!IsValidFloatChar(*buffer) && *buffer != '\0') { - // It appears the radix was a multi-byte character. We need to remove the - // extra bytes. - char* target = buffer; - do { ++buffer; } while (!IsValidFloatChar(*buffer) && *buffer != '\0'); - memmove(target, buffer, strlen(buffer) + 1); - } -} - -char* DoubleToBuffer(double value, char* buffer) { - // DBL_DIG is 15 for IEEE-754 doubles, which are used on almost all - // platforms these days. Just in case some system exists where DBL_DIG - // is significantly larger -- and risks overflowing our buffer -- we have - // this assert. - GOOGLE_COMPILE_ASSERT(DBL_DIG < 20, DBL_DIG_is_too_big); - - if (value == numeric_limits::infinity()) { - strcpy(buffer, "inf"); - return buffer; - } else if (value == -numeric_limits::infinity()) { - strcpy(buffer, "-inf"); - return buffer; - } else if (IsNaN(value)) { - strcpy(buffer, "nan"); - return buffer; - } - - int snprintf_result = - snprintf(buffer, kDoubleToBufferSize, "%.*g", DBL_DIG, value); - - // The snprintf should never overflow because the buffer is significantly - // larger than the precision we asked for. - GOOGLE_DCHECK(snprintf_result > 0 && snprintf_result < kDoubleToBufferSize); - - // We need to make parsed_value volatile in order to force the compiler to - // write it out to the stack. Otherwise, it may keep the value in a - // register, and if it does that, it may keep it as a long double instead - // of a double. This long double may have extra bits that make it compare - // unequal to "value" even though it would be exactly equal if it were - // truncated to a double. - volatile double parsed_value = strtod(buffer, NULL); - if (parsed_value != value) { - int snprintf_result = - snprintf(buffer, kDoubleToBufferSize, "%.*g", DBL_DIG+2, value); - - // Should never overflow; see above. - GOOGLE_DCHECK(snprintf_result > 0 && snprintf_result < kDoubleToBufferSize); - } - - DelocalizeRadix(buffer); - return buffer; -} - -bool safe_strtof(const char* str, float* value) { - char* endptr; - errno = 0; // errno only gets set on errors -#if defined(_WIN32) || defined (__hpux) // has no strtof() - *value = strtod(str, &endptr); -#else - *value = strtof(str, &endptr); -#endif - return *str != 0 && *endptr == 0 && errno == 0; -} - -char* FloatToBuffer(float value, char* buffer) { - // FLT_DIG is 6 for IEEE-754 floats, which are used on almost all - // platforms these days. Just in case some system exists where FLT_DIG - // is significantly larger -- and risks overflowing our buffer -- we have - // this assert. - GOOGLE_COMPILE_ASSERT(FLT_DIG < 10, FLT_DIG_is_too_big); - - if (value == numeric_limits::infinity()) { - strcpy(buffer, "inf"); - return buffer; - } else if (value == -numeric_limits::infinity()) { - strcpy(buffer, "-inf"); - return buffer; - } else if (IsNaN(value)) { - strcpy(buffer, "nan"); - return buffer; - } - - int snprintf_result = - snprintf(buffer, kFloatToBufferSize, "%.*g", FLT_DIG, value); - - // The snprintf should never overflow because the buffer is significantly - // larger than the precision we asked for. - GOOGLE_DCHECK(snprintf_result > 0 && snprintf_result < kFloatToBufferSize); - - float parsed_value; - if (!safe_strtof(buffer, &parsed_value) || parsed_value != value) { - int snprintf_result = - snprintf(buffer, kFloatToBufferSize, "%.*g", FLT_DIG+2, value); - - // Should never overflow; see above. - GOOGLE_DCHECK(snprintf_result > 0 && snprintf_result < kFloatToBufferSize); - } - - DelocalizeRadix(buffer); - return buffer; -} - -// ---------------------------------------------------------------------- -// NoLocaleStrtod() -// This code will make you cry. -// ---------------------------------------------------------------------- - -// Returns a string identical to *input except that the character pointed to -// by radix_pos (which should be '.') is replaced with the locale-specific -// radix character. -string LocalizeRadix(const char* input, const char* radix_pos) { - // Determine the locale-specific radix character by calling sprintf() to - // print the number 1.5, then stripping off the digits. As far as I can - // tell, this is the only portable, thread-safe way to get the C library - // to divuldge the locale's radix character. No, localeconv() is NOT - // thread-safe. - char temp[16]; - int size = sprintf(temp, "%.1f", 1.5); - GOOGLE_CHECK_EQ(temp[0], '1'); - GOOGLE_CHECK_EQ(temp[size-1], '5'); - GOOGLE_CHECK_LE(size, 6); - - // Now replace the '.' in the input with it. - string result; - result.reserve(strlen(input) + size - 3); - result.append(input, radix_pos); - result.append(temp + 1, size - 2); - result.append(radix_pos + 1); - return result; -} - -double NoLocaleStrtod(const char* text, char** original_endptr) { - // We cannot simply set the locale to "C" temporarily with setlocale() - // as this is not thread-safe. Instead, we try to parse in the current - // locale first. If parsing stops at a '.' character, then this is a - // pretty good hint that we're actually in some other locale in which - // '.' is not the radix character. - - char* temp_endptr; - double result = strtod(text, &temp_endptr); - if (original_endptr != NULL) *original_endptr = temp_endptr; - if (*temp_endptr != '.') return result; - - // Parsing halted on a '.'. Perhaps we're in a different locale? Let's - // try to replace the '.' with a locale-specific radix character and - // try again. - string localized = LocalizeRadix(text, temp_endptr); - const char* localized_cstr = localized.c_str(); - char* localized_endptr; - result = strtod(localized_cstr, &localized_endptr); - if ((localized_endptr - localized_cstr) > - (temp_endptr - text)) { - // This attempt got further, so replacing the decimal must have helped. - // Update original_endptr to point at the right location. - if (original_endptr != NULL) { - // size_diff is non-zero if the localized radix has multiple bytes. - int size_diff = localized.size() - strlen(text); - // const_cast is necessary to match the strtod() interface. - *original_endptr = const_cast( - text + (localized_endptr - localized_cstr - size_diff)); - } - } - - return result; -} - -} // namespace protobuf -} // namespace google diff --git a/modules/dnn/3rdparty/protobuf/src/google/protobuf/stubs/strutil.h b/modules/dnn/3rdparty/protobuf/src/google/protobuf/stubs/strutil.h deleted file mode 100644 index a401c63a9..000000000 --- a/modules/dnn/3rdparty/protobuf/src/google/protobuf/stubs/strutil.h +++ /dev/null @@ -1,467 +0,0 @@ -// Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// http://code.google.com/p/protobuf/ -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -// from google3/strings/strutil.h - -#ifndef GOOGLE_PROTOBUF_STUBS_STRUTIL_H__ -#define GOOGLE_PROTOBUF_STUBS_STRUTIL_H__ - -#include -#include -#include - -namespace google { -namespace protobuf { - -#ifdef _MSC_VER -#define strtoll _strtoi64 -#define strtoull _strtoui64 -#elif defined(__DECCXX) && defined(__osf__) -// HP C++ on Tru64 does not have strtoll, but strtol is already 64-bit. -#define strtoll strtol -#define strtoull strtoul -#endif - -// ---------------------------------------------------------------------- -// ascii_isalnum() -// Check if an ASCII character is alphanumeric. We can't use ctype's -// isalnum() because it is affected by locale. This function is applied -// to identifiers in the protocol buffer language, not to natural-language -// strings, so locale should not be taken into account. -// ascii_isdigit() -// Like above, but only accepts digits. -// ---------------------------------------------------------------------- - -inline bool ascii_isalnum(char c) { - return ('a' <= c && c <= 'z') || - ('A' <= c && c <= 'Z') || - ('0' <= c && c <= '9'); -} - -inline bool ascii_isdigit(char c) { - return ('0' <= c && c <= '9'); -} - -// ---------------------------------------------------------------------- -// HasPrefixString() -// Check if a string begins with a given prefix. -// StripPrefixString() -// Given a string and a putative prefix, returns the string minus the -// prefix string if the prefix matches, otherwise the original -// string. -// ---------------------------------------------------------------------- -inline bool HasPrefixString(const string& str, - const string& prefix) { - return str.size() >= prefix.size() && - str.compare(0, prefix.size(), prefix) == 0; -} - -inline string StripPrefixString(const string& str, const string& prefix) { - if (HasPrefixString(str, prefix)) { - return str.substr(prefix.size()); - } else { - return str; - } -} - -// ---------------------------------------------------------------------- -// HasSuffixString() -// Return true if str ends in suffix. -// StripSuffixString() -// Given a string and a putative suffix, returns the string minus the -// suffix string if the suffix matches, otherwise the original -// string. -// ---------------------------------------------------------------------- -inline bool HasSuffixString(const string& str, - const string& suffix) { - return str.size() >= suffix.size() && - str.compare(str.size() - suffix.size(), suffix.size(), suffix) == 0; -} - -inline string StripSuffixString(const string& str, const string& suffix) { - if (HasSuffixString(str, suffix)) { - return str.substr(0, str.size() - suffix.size()); - } else { - return str; - } -} - -// ---------------------------------------------------------------------- -// StripString -// Replaces any occurrence of the character 'remove' (or the characters -// in 'remove') with the character 'replacewith'. -// Good for keeping html characters or protocol characters (\t) out -// of places where they might cause a problem. -// ---------------------------------------------------------------------- -LIBPROTOBUF_EXPORT void StripString(string* s, const char* remove, - char replacewith); - -// ---------------------------------------------------------------------- -// LowerString() -// UpperString() -// Convert the characters in "s" to lowercase or uppercase. ASCII-only: -// these functions intentionally ignore locale because they are applied to -// identifiers used in the Protocol Buffer language, not to natural-language -// strings. -// ---------------------------------------------------------------------- - -inline void LowerString(string * s) { - string::iterator end = s->end(); - for (string::iterator i = s->begin(); i != end; ++i) { - // tolower() changes based on locale. We don't want this! - if ('A' <= *i && *i <= 'Z') *i += 'a' - 'A'; - } -} - -inline void UpperString(string * s) { - string::iterator end = s->end(); - for (string::iterator i = s->begin(); i != end; ++i) { - // toupper() changes based on locale. We don't want this! - if ('a' <= *i && *i <= 'z') *i += 'A' - 'a'; - } -} - -// ---------------------------------------------------------------------- -// StringReplace() -// Give me a string and two patterns "old" and "new", and I replace -// the first instance of "old" in the string with "new", if it -// exists. RETURN a new string, regardless of whether the replacement -// happened or not. -// ---------------------------------------------------------------------- - -LIBPROTOBUF_EXPORT string StringReplace(const string& s, const string& oldsub, - const string& newsub, bool replace_all); - -// ---------------------------------------------------------------------- -// SplitStringUsing() -// Split a string using a character delimiter. Append the components -// to 'result'. If there are consecutive delimiters, this function skips -// over all of them. -// ---------------------------------------------------------------------- -LIBPROTOBUF_EXPORT void SplitStringUsing(const string& full, const char* delim, - vector* res); - -// Split a string using one or more byte delimiters, presented -// as a nul-terminated c string. Append the components to 'result'. -// If there are consecutive delimiters, this function will return -// corresponding empty strings. If you want to drop the empty -// strings, try SplitStringUsing(). -// -// If "full" is the empty string, yields an empty string as the only value. -// ---------------------------------------------------------------------- -LIBPROTOBUF_EXPORT void SplitStringAllowEmpty(const string& full, - const char* delim, - vector* result); - -// ---------------------------------------------------------------------- -// JoinStrings() -// These methods concatenate a vector of strings into a C++ string, using -// the C-string "delim" as a separator between components. There are two -// flavors of the function, one flavor returns the concatenated string, -// another takes a pointer to the target string. In the latter case the -// target string is cleared and overwritten. -// ---------------------------------------------------------------------- -LIBPROTOBUF_EXPORT void JoinStrings(const vector& components, - const char* delim, string* result); - -inline string JoinStrings(const vector& components, - const char* delim) { - string result; - JoinStrings(components, delim, &result); - return result; -} - -// ---------------------------------------------------------------------- -// UnescapeCEscapeSequences() -// Copies "source" to "dest", rewriting C-style escape sequences -// -- '\n', '\r', '\\', '\ooo', etc -- to their ASCII -// equivalents. "dest" must be sufficiently large to hold all -// the characters in the rewritten string (i.e. at least as large -// as strlen(source) + 1 should be safe, since the replacements -// are always shorter than the original escaped sequences). It's -// safe for source and dest to be the same. RETURNS the length -// of dest. -// -// It allows hex sequences \xhh, or generally \xhhhhh with an -// arbitrary number of hex digits, but all of them together must -// specify a value of a single byte (e.g. \x0045 is equivalent -// to \x45, and \x1234 is erroneous). -// -// It also allows escape sequences of the form \uhhhh (exactly four -// hex digits, upper or lower case) or \Uhhhhhhhh (exactly eight -// hex digits, upper or lower case) to specify a Unicode code -// point. The dest array will contain the UTF8-encoded version of -// that code-point (e.g., if source contains \u2019, then dest will -// contain the three bytes 0xE2, 0x80, and 0x99). -// -// Errors: In the first form of the call, errors are reported with -// LOG(ERROR). The same is true for the second form of the call if -// the pointer to the string vector is NULL; otherwise, error -// messages are stored in the vector. In either case, the effect on -// the dest array is not defined, but rest of the source will be -// processed. -// ---------------------------------------------------------------------- - -LIBPROTOBUF_EXPORT int UnescapeCEscapeSequences(const char* source, char* dest); -LIBPROTOBUF_EXPORT int UnescapeCEscapeSequences(const char* source, char* dest, - vector *errors); - -// ---------------------------------------------------------------------- -// UnescapeCEscapeString() -// This does the same thing as UnescapeCEscapeSequences, but creates -// a new string. The caller does not need to worry about allocating -// a dest buffer. This should be used for non performance critical -// tasks such as printing debug messages. It is safe for src and dest -// to be the same. -// -// The second call stores its errors in a supplied string vector. -// If the string vector pointer is NULL, it reports the errors with LOG(). -// -// In the first and second calls, the length of dest is returned. In the -// the third call, the new string is returned. -// ---------------------------------------------------------------------- - -LIBPROTOBUF_EXPORT int UnescapeCEscapeString(const string& src, string* dest); -LIBPROTOBUF_EXPORT int UnescapeCEscapeString(const string& src, string* dest, - vector *errors); -LIBPROTOBUF_EXPORT string UnescapeCEscapeString(const string& src); - -// ---------------------------------------------------------------------- -// CEscapeString() -// Copies 'src' to 'dest', escaping dangerous characters using -// C-style escape sequences. This is very useful for preparing query -// flags. 'src' and 'dest' should not overlap. -// Returns the number of bytes written to 'dest' (not including the \0) -// or -1 if there was insufficient space. -// -// Currently only \n, \r, \t, ", ', \ and !isprint() chars are escaped. -// ---------------------------------------------------------------------- -LIBPROTOBUF_EXPORT int CEscapeString(const char* src, int src_len, - char* dest, int dest_len); - -// ---------------------------------------------------------------------- -// CEscape() -// More convenient form of CEscapeString: returns result as a "string". -// This version is slower than CEscapeString() because it does more -// allocation. However, it is much more convenient to use in -// non-speed-critical code like logging messages etc. -// ---------------------------------------------------------------------- -LIBPROTOBUF_EXPORT string CEscape(const string& src); - -namespace strings { -// Like CEscape() but does not escape bytes with the upper bit set. -LIBPROTOBUF_EXPORT string Utf8SafeCEscape(const string& src); - -// Like CEscape() but uses hex (\x) escapes instead of octals. -LIBPROTOBUF_EXPORT string CHexEscape(const string& src); -} // namespace strings - -// ---------------------------------------------------------------------- -// strto32() -// strtou32() -// strto64() -// strtou64() -// Architecture-neutral plug compatible replacements for strtol() and -// strtoul(). Long's have different lengths on ILP-32 and LP-64 -// platforms, so using these is safer, from the point of view of -// overflow behavior, than using the standard libc functions. -// ---------------------------------------------------------------------- -LIBPROTOBUF_EXPORT int32 strto32_adaptor(const char *nptr, char **endptr, - int base); -LIBPROTOBUF_EXPORT uint32 strtou32_adaptor(const char *nptr, char **endptr, - int base); - -inline int32 strto32(const char *nptr, char **endptr, int base) { - if (sizeof(int32) == sizeof(long)) - return strtol(nptr, endptr, base); - else - return strto32_adaptor(nptr, endptr, base); -} - -inline uint32 strtou32(const char *nptr, char **endptr, int base) { - if (sizeof(uint32) == sizeof(unsigned long)) - return strtoul(nptr, endptr, base); - else - return strtou32_adaptor(nptr, endptr, base); -} - -// For now, long long is 64-bit on all the platforms we care about, so these -// functions can simply pass the call to strto[u]ll. -inline int64 strto64(const char *nptr, char **endptr, int base) { - GOOGLE_COMPILE_ASSERT(sizeof(int64) == sizeof(long long), - sizeof_int64_is_not_sizeof_long_long); - return strtoll(nptr, endptr, base); -} - -inline uint64 strtou64(const char *nptr, char **endptr, int base) { - GOOGLE_COMPILE_ASSERT(sizeof(uint64) == sizeof(unsigned long long), - sizeof_uint64_is_not_sizeof_long_long); - return strtoull(nptr, endptr, base); -} - -// ---------------------------------------------------------------------- -// FastIntToBuffer() -// FastHexToBuffer() -// FastHex64ToBuffer() -// FastHex32ToBuffer() -// FastTimeToBuffer() -// These are intended for speed. FastIntToBuffer() assumes the -// integer is non-negative. FastHexToBuffer() puts output in -// hex rather than decimal. FastTimeToBuffer() puts the output -// into RFC822 format. -// -// FastHex64ToBuffer() puts a 64-bit unsigned value in hex-format, -// padded to exactly 16 bytes (plus one byte for '\0') -// -// FastHex32ToBuffer() puts a 32-bit unsigned value in hex-format, -// padded to exactly 8 bytes (plus one byte for '\0') -// -// All functions take the output buffer as an arg. -// They all return a pointer to the beginning of the output, -// which may not be the beginning of the input buffer. -// ---------------------------------------------------------------------- - -// Suggested buffer size for FastToBuffer functions. Also works with -// DoubleToBuffer() and FloatToBuffer(). -static const int kFastToBufferSize = 32; - -LIBPROTOBUF_EXPORT char* FastInt32ToBuffer(int32 i, char* buffer); -LIBPROTOBUF_EXPORT char* FastInt64ToBuffer(int64 i, char* buffer); -char* FastUInt32ToBuffer(uint32 i, char* buffer); // inline below -char* FastUInt64ToBuffer(uint64 i, char* buffer); // inline below -LIBPROTOBUF_EXPORT char* FastHexToBuffer(int i, char* buffer); -LIBPROTOBUF_EXPORT char* FastHex64ToBuffer(uint64 i, char* buffer); -LIBPROTOBUF_EXPORT char* FastHex32ToBuffer(uint32 i, char* buffer); - -// at least 22 bytes long -inline char* FastIntToBuffer(int i, char* buffer) { - return (sizeof(i) == 4 ? - FastInt32ToBuffer(i, buffer) : FastInt64ToBuffer(i, buffer)); -} -inline char* FastUIntToBuffer(unsigned int i, char* buffer) { - return (sizeof(i) == 4 ? - FastUInt32ToBuffer(i, buffer) : FastUInt64ToBuffer(i, buffer)); -} -inline char* FastLongToBuffer(long i, char* buffer) { - return (sizeof(i) == 4 ? - FastInt32ToBuffer(i, buffer) : FastInt64ToBuffer(i, buffer)); -} -inline char* FastULongToBuffer(unsigned long i, char* buffer) { - return (sizeof(i) == 4 ? - FastUInt32ToBuffer(i, buffer) : FastUInt64ToBuffer(i, buffer)); -} - -// ---------------------------------------------------------------------- -// FastInt32ToBufferLeft() -// FastUInt32ToBufferLeft() -// FastInt64ToBufferLeft() -// FastUInt64ToBufferLeft() -// -// Like the Fast*ToBuffer() functions above, these are intended for speed. -// Unlike the Fast*ToBuffer() functions, however, these functions write -// their output to the beginning of the buffer (hence the name, as the -// output is left-aligned). The caller is responsible for ensuring that -// the buffer has enough space to hold the output. -// -// Returns a pointer to the end of the string (i.e. the null character -// terminating the string). -// ---------------------------------------------------------------------- - -LIBPROTOBUF_EXPORT char* FastInt32ToBufferLeft(int32 i, char* buffer); -LIBPROTOBUF_EXPORT char* FastUInt32ToBufferLeft(uint32 i, char* buffer); -LIBPROTOBUF_EXPORT char* FastInt64ToBufferLeft(int64 i, char* buffer); -LIBPROTOBUF_EXPORT char* FastUInt64ToBufferLeft(uint64 i, char* buffer); - -// Just define these in terms of the above. -inline char* FastUInt32ToBuffer(uint32 i, char* buffer) { - FastUInt32ToBufferLeft(i, buffer); - return buffer; -} -inline char* FastUInt64ToBuffer(uint64 i, char* buffer) { - FastUInt64ToBufferLeft(i, buffer); - return buffer; -} - -// ---------------------------------------------------------------------- -// SimpleItoa() -// Description: converts an integer to a string. -// -// Return value: string -// ---------------------------------------------------------------------- -LIBPROTOBUF_EXPORT string SimpleItoa(int i); -LIBPROTOBUF_EXPORT string SimpleItoa(unsigned int i); -LIBPROTOBUF_EXPORT string SimpleItoa(long i); -LIBPROTOBUF_EXPORT string SimpleItoa(unsigned long i); -LIBPROTOBUF_EXPORT string SimpleItoa(long long i); -LIBPROTOBUF_EXPORT string SimpleItoa(unsigned long long i); - -// ---------------------------------------------------------------------- -// SimpleDtoa() -// SimpleFtoa() -// DoubleToBuffer() -// FloatToBuffer() -// Description: converts a double or float to a string which, if -// passed to NoLocaleStrtod(), will produce the exact same original double -// (except in case of NaN; all NaNs are considered the same value). -// We try to keep the string short but it's not guaranteed to be as -// short as possible. -// -// DoubleToBuffer() and FloatToBuffer() write the text to the given -// buffer and return it. The buffer must be at least -// kDoubleToBufferSize bytes for doubles and kFloatToBufferSize -// bytes for floats. kFastToBufferSize is also guaranteed to be large -// enough to hold either. -// -// Return value: string -// ---------------------------------------------------------------------- -LIBPROTOBUF_EXPORT string SimpleDtoa(double value); -LIBPROTOBUF_EXPORT string SimpleFtoa(float value); - -LIBPROTOBUF_EXPORT char* DoubleToBuffer(double i, char* buffer); -LIBPROTOBUF_EXPORT char* FloatToBuffer(float i, char* buffer); - -// In practice, doubles should never need more than 24 bytes and floats -// should never need more than 14 (including null terminators), but we -// overestimate to be safe. -static const int kDoubleToBufferSize = 32; -static const int kFloatToBufferSize = 24; - -// ---------------------------------------------------------------------- -// NoLocaleStrtod() -// Exactly like strtod(), except it always behaves as if in the "C" -// locale (i.e. decimal points must be '.'s). -// ---------------------------------------------------------------------- - -LIBPROTOBUF_EXPORT double NoLocaleStrtod(const char* text, char** endptr); - -} // namespace protobuf -} // namespace google - -#endif // GOOGLE_PROTOBUF_STUBS_STRUTIL_H__ diff --git a/modules/dnn/3rdparty/protobuf/src/google/protobuf/stubs/strutil_unittest.cc b/modules/dnn/3rdparty/protobuf/src/google/protobuf/stubs/strutil_unittest.cc deleted file mode 100644 index b9c9253b0..000000000 --- a/modules/dnn/3rdparty/protobuf/src/google/protobuf/stubs/strutil_unittest.cc +++ /dev/null @@ -1,83 +0,0 @@ -// Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// http://code.google.com/p/protobuf/ -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -// Author: kenton@google.com (Kenton Varda) - -#include - -#include -#include -#include - -namespace google { -namespace protobuf { -namespace { - -// TODO(kenton): Copy strutil tests from google3? - -TEST(StringUtilityTest, ImmuneToLocales) { - // Remember the old locale. - char* old_locale_cstr = setlocale(LC_NUMERIC, NULL); - ASSERT_TRUE(old_locale_cstr != NULL); - string old_locale = old_locale_cstr; - - // Set the locale to "C". - ASSERT_TRUE(setlocale(LC_NUMERIC, "C") != NULL); - - EXPECT_EQ(1.5, NoLocaleStrtod("1.5", NULL)); - EXPECT_EQ("1.5", SimpleDtoa(1.5)); - EXPECT_EQ("1.5", SimpleFtoa(1.5)); - - // Verify that the endptr is set correctly even if not all text was parsed. - const char* text = "1.5f"; - char* endptr; - EXPECT_EQ(1.5, NoLocaleStrtod(text, &endptr)); - EXPECT_EQ(3, endptr - text); - - if (setlocale(LC_NUMERIC, "es_ES") == NULL && - setlocale(LC_NUMERIC, "es_ES.utf8") == NULL) { - // Some systems may not have the desired locale available. - GOOGLE_LOG(WARNING) - << "Couldn't set locale to es_ES. Skipping this test."; - } else { - EXPECT_EQ(1.5, NoLocaleStrtod("1.5", NULL)); - EXPECT_EQ("1.5", SimpleDtoa(1.5)); - EXPECT_EQ("1.5", SimpleFtoa(1.5)); - EXPECT_EQ(1.5, NoLocaleStrtod(text, &endptr)); - EXPECT_EQ(3, endptr - text); - } - - // Return to original locale. - setlocale(LC_NUMERIC, old_locale.c_str()); -} - -} // anonymous namespace -} // namespace protobuf -} // namespace google diff --git a/modules/dnn/3rdparty/protobuf/src/google/protobuf/stubs/substitute.cc b/modules/dnn/3rdparty/protobuf/src/google/protobuf/stubs/substitute.cc deleted file mode 100644 index 259245b3d..000000000 --- a/modules/dnn/3rdparty/protobuf/src/google/protobuf/stubs/substitute.cc +++ /dev/null @@ -1,134 +0,0 @@ -// Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// http://code.google.com/p/protobuf/ -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -// Author: kenton@google.com (Kenton Varda) - -#include -#include -#include - -namespace google { -namespace protobuf { -namespace strings { - -using internal::SubstituteArg; - -// Returns the number of args in arg_array which were passed explicitly -// to Substitute(). -static int CountSubstituteArgs(const SubstituteArg* const* args_array) { - int count = 0; - while (args_array[count] != NULL && args_array[count]->size() != -1) { - ++count; - } - return count; -} - -string Substitute( - const char* format, - const SubstituteArg& arg0, const SubstituteArg& arg1, - const SubstituteArg& arg2, const SubstituteArg& arg3, - const SubstituteArg& arg4, const SubstituteArg& arg5, - const SubstituteArg& arg6, const SubstituteArg& arg7, - const SubstituteArg& arg8, const SubstituteArg& arg9) { - string result; - SubstituteAndAppend(&result, format, arg0, arg1, arg2, arg3, arg4, - arg5, arg6, arg7, arg8, arg9); - return result; -} - -void SubstituteAndAppend( - string* output, const char* format, - const SubstituteArg& arg0, const SubstituteArg& arg1, - const SubstituteArg& arg2, const SubstituteArg& arg3, - const SubstituteArg& arg4, const SubstituteArg& arg5, - const SubstituteArg& arg6, const SubstituteArg& arg7, - const SubstituteArg& arg8, const SubstituteArg& arg9) { - const SubstituteArg* const args_array[] = { - &arg0, &arg1, &arg2, &arg3, &arg4, &arg5, &arg6, &arg7, &arg8, &arg9, NULL - }; - - // Determine total size needed. - int size = 0; - for (int i = 0; format[i] != '\0'; i++) { - if (format[i] == '$') { - if (ascii_isdigit(format[i+1])) { - int index = format[i+1] - '0'; - if (args_array[index]->size() == -1) { - GOOGLE_LOG(DFATAL) - << "strings::Substitute format string invalid: asked for \"$" - << index << "\", but only " << CountSubstituteArgs(args_array) - << " args were given. Full format string was: \"" - << CEscape(format) << "\"."; - return; - } - size += args_array[index]->size(); - ++i; // Skip next char. - } else if (format[i+1] == '$') { - ++size; - ++i; // Skip next char. - } else { - GOOGLE_LOG(DFATAL) - << "Invalid strings::Substitute() format string: \"" - << CEscape(format) << "\"."; - return; - } - } else { - ++size; - } - } - - if (size == 0) return; - - // Build the string. - int original_size = output->size(); - STLStringResizeUninitialized(output, original_size + size); - char* target = string_as_array(output) + original_size; - for (int i = 0; format[i] != '\0'; i++) { - if (format[i] == '$') { - if (ascii_isdigit(format[i+1])) { - const SubstituteArg* src = args_array[format[i+1] - '0']; - memcpy(target, src->data(), src->size()); - target += src->size(); - ++i; // Skip next char. - } else if (format[i+1] == '$') { - *target++ = '$'; - ++i; // Skip next char. - } - } else { - *target++ = format[i]; - } - } - - GOOGLE_DCHECK_EQ(target - output->data(), output->size()); -} - -} // namespace strings -} // namespace protobuf -} // namespace google diff --git a/modules/dnn/3rdparty/protobuf/src/google/protobuf/stubs/substitute.h b/modules/dnn/3rdparty/protobuf/src/google/protobuf/stubs/substitute.h deleted file mode 100644 index 2581793b5..000000000 --- a/modules/dnn/3rdparty/protobuf/src/google/protobuf/stubs/substitute.h +++ /dev/null @@ -1,170 +0,0 @@ -// Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// http://code.google.com/p/protobuf/ -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -// Author: kenton@google.com (Kenton Varda) -// from google3/strings/substitute.h - -#include -#include -#include - -#ifndef GOOGLE_PROTOBUF_STUBS_SUBSTITUTE_H_ -#define GOOGLE_PROTOBUF_STUBS_SUBSTITUTE_H_ - -namespace google { -namespace protobuf { -namespace strings { - -// ---------------------------------------------------------------------- -// strings::Substitute() -// strings::SubstituteAndAppend() -// Kind of like StringPrintf, but different. -// -// Example: -// string GetMessage(string first_name, string last_name, int age) { -// return strings::Substitute("My name is $0 $1 and I am $2 years old.", -// first_name, last_name, age); -// } -// -// Differences from StringPrintf: -// * The format string does not identify the types of arguments. -// Instead, the magic of C++ deals with this for us. See below -// for a list of accepted types. -// * Substitutions in the format string are identified by a '$' -// followed by a digit. So, you can use arguments out-of-order and -// use the same argument multiple times. -// * It's much faster than StringPrintf. -// -// Supported types: -// * Strings (const char*, const string&) -// * Note that this means you do not have to add .c_str() to all of -// your strings. In fact, you shouldn't; it will be slower. -// * int32, int64, uint32, uint64: Formatted using SimpleItoa(). -// * float, double: Formatted using SimpleFtoa() and SimpleDtoa(). -// * bool: Printed as "true" or "false". -// -// SubstituteAndAppend() is like Substitute() but appends the result to -// *output. Example: -// -// string str; -// strings::SubstituteAndAppend(&str, -// "My name is $0 $1 and I am $2 years old.", -// first_name, last_name, age); -// -// Substitute() is significantly faster than StringPrintf(). For very -// large strings, it may be orders of magnitude faster. -// ---------------------------------------------------------------------- - -namespace internal { // Implementation details. - -class SubstituteArg { - public: - inline SubstituteArg(const char* value) - : text_(value), size_(strlen(text_)) {} - inline SubstituteArg(const string& value) - : text_(value.data()), size_(value.size()) {} - - // Indicates that no argument was given. - inline explicit SubstituteArg() - : text_(NULL), size_(-1) {} - - // Primitives - // We don't overload for signed and unsigned char because if people are - // explicitly declaring their chars as signed or unsigned then they are - // probably actually using them as 8-bit integers and would probably - // prefer an integer representation. But, we don't really know. So, we - // make the caller decide what to do. - inline SubstituteArg(char value) - : text_(scratch_), size_(1) { scratch_[0] = value; } - inline SubstituteArg(short value) - : text_(FastInt32ToBuffer(value, scratch_)), size_(strlen(text_)) {} - inline SubstituteArg(unsigned short value) - : text_(FastUInt32ToBuffer(value, scratch_)), size_(strlen(text_)) {} - inline SubstituteArg(int value) - : text_(FastInt32ToBuffer(value, scratch_)), size_(strlen(text_)) {} - inline SubstituteArg(unsigned int value) - : text_(FastUInt32ToBuffer(value, scratch_)), size_(strlen(text_)) {} - inline SubstituteArg(long value) - : text_(FastLongToBuffer(value, scratch_)), size_(strlen(text_)) {} - inline SubstituteArg(unsigned long value) - : text_(FastULongToBuffer(value, scratch_)), size_(strlen(text_)) {} - inline SubstituteArg(long long value) - : text_(FastInt64ToBuffer(value, scratch_)), size_(strlen(text_)) {} - inline SubstituteArg(unsigned long long value) - : text_(FastUInt64ToBuffer(value, scratch_)), size_(strlen(text_)) {} - inline SubstituteArg(float value) - : text_(FloatToBuffer(value, scratch_)), size_(strlen(text_)) {} - inline SubstituteArg(double value) - : text_(DoubleToBuffer(value, scratch_)), size_(strlen(text_)) {} - inline SubstituteArg(bool value) - : text_(value ? "true" : "false"), size_(strlen(text_)) {} - - inline const char* data() const { return text_; } - inline int size() const { return size_; } - - private: - const char* text_; - int size_; - char scratch_[kFastToBufferSize]; -}; - -} // namespace internal - -LIBPROTOBUF_EXPORT string Substitute( - const char* format, - const internal::SubstituteArg& arg0 = internal::SubstituteArg(), - const internal::SubstituteArg& arg1 = internal::SubstituteArg(), - const internal::SubstituteArg& arg2 = internal::SubstituteArg(), - const internal::SubstituteArg& arg3 = internal::SubstituteArg(), - const internal::SubstituteArg& arg4 = internal::SubstituteArg(), - const internal::SubstituteArg& arg5 = internal::SubstituteArg(), - const internal::SubstituteArg& arg6 = internal::SubstituteArg(), - const internal::SubstituteArg& arg7 = internal::SubstituteArg(), - const internal::SubstituteArg& arg8 = internal::SubstituteArg(), - const internal::SubstituteArg& arg9 = internal::SubstituteArg()); - -LIBPROTOBUF_EXPORT void SubstituteAndAppend( - string* output, const char* format, - const internal::SubstituteArg& arg0 = internal::SubstituteArg(), - const internal::SubstituteArg& arg1 = internal::SubstituteArg(), - const internal::SubstituteArg& arg2 = internal::SubstituteArg(), - const internal::SubstituteArg& arg3 = internal::SubstituteArg(), - const internal::SubstituteArg& arg4 = internal::SubstituteArg(), - const internal::SubstituteArg& arg5 = internal::SubstituteArg(), - const internal::SubstituteArg& arg6 = internal::SubstituteArg(), - const internal::SubstituteArg& arg7 = internal::SubstituteArg(), - const internal::SubstituteArg& arg8 = internal::SubstituteArg(), - const internal::SubstituteArg& arg9 = internal::SubstituteArg()); - -} // namespace strings -} // namespace protobuf -} // namespace google - -#endif // GOOGLE_PROTOBUF_STUBS_SUBSTITUTE_H_ diff --git a/modules/dnn/3rdparty/protobuf/src/google/protobuf/stubs/template_util.h b/modules/dnn/3rdparty/protobuf/src/google/protobuf/stubs/template_util.h deleted file mode 100644 index 4f30ffa3b..000000000 --- a/modules/dnn/3rdparty/protobuf/src/google/protobuf/stubs/template_util.h +++ /dev/null @@ -1,138 +0,0 @@ -// Copyright 2005 Google Inc. -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -// ---- -// Author: lar@google.com (Laramie Leavitt) -// -// Template metaprogramming utility functions. -// -// This code is compiled directly on many platforms, including client -// platforms like Windows, Mac, and embedded systems. Before making -// any changes here, make sure that you're not breaking any platforms. -// -// -// The names choosen here reflect those used in tr1 and the boost::mpl -// library, there are similar operations used in the Loki library as -// well. I prefer the boost names for 2 reasons: -// 1. I think that portions of the Boost libraries are more likely to -// be included in the c++ standard. -// 2. It is not impossible that some of the boost libraries will be -// included in our own build in the future. -// Both of these outcomes means that we may be able to directly replace -// some of these with boost equivalents. -// -#ifndef GOOGLE_PROTOBUF_TEMPLATE_UTIL_H_ -#define GOOGLE_PROTOBUF_TEMPLATE_UTIL_H_ - -namespace google { -namespace protobuf { -namespace internal { - -// Types small_ and big_ are guaranteed such that sizeof(small_) < -// sizeof(big_) -typedef char small_; - -struct big_ { - char dummy[2]; -}; - -// Identity metafunction. -template -struct identity_ { - typedef T type; -}; - -// integral_constant, defined in tr1, is a wrapper for an integer -// value. We don't really need this generality; we could get away -// with hardcoding the integer type to bool. We use the fully -// general integer_constant for compatibility with tr1. - -template -struct integral_constant { - static const T value = v; - typedef T value_type; - typedef integral_constant type; -}; - -template const T integral_constant::value; - - -// Abbreviations: true_type and false_type are structs that represent boolean -// true and false values. Also define the boost::mpl versions of those names, -// true_ and false_. -typedef integral_constant true_type; -typedef integral_constant false_type; -typedef true_type true_; -typedef false_type false_; - -// if_ is a templatized conditional statement. -// if_ is a compile time evaluation of cond. -// if_<>::type contains A if cond is true, B otherwise. -template -struct if_{ - typedef A type; -}; - -template -struct if_ { - typedef B type; -}; - - -// type_equals_ is a template type comparator, similar to Loki IsSameType. -// type_equals_::value is true iff "A" is the same type as "B". -// -// New code should prefer base::is_same, defined in base/type_traits.h. -// It is functionally identical, but is_same is the standard spelling. -template -struct type_equals_ : public false_ { -}; - -template -struct type_equals_ : public true_ { -}; - -// and_ is a template && operator. -// and_::value evaluates "A::value && B::value". -template -struct and_ : public integral_constant { -}; - -// or_ is a template || operator. -// or_::value evaluates "A::value || B::value". -template -struct or_ : public integral_constant { -}; - - -} // namespace internal -} // namespace protobuf -} // namespace google - -#endif // GOOGLE_PROTOBUF_TEMPLATE_UTIL_H_ diff --git a/modules/dnn/3rdparty/protobuf/src/google/protobuf/stubs/template_util_unittest.cc b/modules/dnn/3rdparty/protobuf/src/google/protobuf/stubs/template_util_unittest.cc deleted file mode 100644 index b1745e2bf..000000000 --- a/modules/dnn/3rdparty/protobuf/src/google/protobuf/stubs/template_util_unittest.cc +++ /dev/null @@ -1,130 +0,0 @@ -// Copyright 2005 Google Inc. -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -// ---- -// Author: lar@google.com (Laramie Leavitt) -// -// These tests are really compile time tests. -// If you try to step through this in a debugger -// you will not see any evaluations, merely that -// value is assigned true or false sequentially. - -#include - -#include -#include - -namespace GOOGLE_NAMESPACE = google::protobuf::internal; - -namespace google { -namespace protobuf { -namespace internal { -namespace { - -TEST(TemplateUtilTest, TestSize) { - EXPECT_GT(sizeof(GOOGLE_NAMESPACE::big_), sizeof(GOOGLE_NAMESPACE::small_)); -} - -TEST(TemplateUtilTest, TestIntegralConstants) { - // test the built-in types. - EXPECT_TRUE(true_type::value); - EXPECT_FALSE(false_type::value); - - typedef integral_constant one_type; - EXPECT_EQ(1, one_type::value); -} - -TEST(TemplateUtilTest, TestTemplateIf) { - typedef if_::type if_true; - EXPECT_TRUE(if_true::value); - - typedef if_::type if_false; - EXPECT_FALSE(if_false::value); -} - -TEST(TemplateUtilTest, TestTemplateTypeEquals) { - // Check that the TemplateTypeEquals works correctly. - bool value = false; - - // Test the same type is true. - value = type_equals_::value; - EXPECT_TRUE(value); - - // Test different types are false. - value = type_equals_::value; - EXPECT_FALSE(value); - - // Test type aliasing. - typedef const int foo; - value = type_equals_::value; - EXPECT_TRUE(value); -} - -TEST(TemplateUtilTest, TestTemplateAndOr) { - // Check that the TemplateTypeEquals works correctly. - bool value = false; - - // Yes && Yes == true. - value = and_::value; - EXPECT_TRUE(value); - // Yes && No == false. - value = and_::value; - EXPECT_FALSE(value); - // No && Yes == false. - value = and_::value; - EXPECT_FALSE(value); - // No && No == false. - value = and_::value; - EXPECT_FALSE(value); - - // Yes || Yes == true. - value = or_::value; - EXPECT_TRUE(value); - // Yes || No == true. - value = or_::value; - EXPECT_TRUE(value); - // No || Yes == true. - value = or_::value; - EXPECT_TRUE(value); - // No || No == false. - value = or_::value; - EXPECT_FALSE(value); -} - -TEST(TemplateUtilTest, TestIdentity) { - EXPECT_TRUE( - (type_equals_::type, int>::value)); - EXPECT_TRUE( - (type_equals_::type, void>::value)); -} - -} // anonymous namespace -} // namespace internal -} // namespace protobuf -} // namespace google diff --git a/modules/dnn/3rdparty/protobuf/src/google/protobuf/stubs/type_traits.h b/modules/dnn/3rdparty/protobuf/src/google/protobuf/stubs/type_traits.h deleted file mode 100644 index e41f5e6f6..000000000 --- a/modules/dnn/3rdparty/protobuf/src/google/protobuf/stubs/type_traits.h +++ /dev/null @@ -1,336 +0,0 @@ -// Copyright (c) 2006, Google Inc. -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -// ---- -// Author: Matt Austern -// -// This code is compiled directly on many platforms, including client -// platforms like Windows, Mac, and embedded systems. Before making -// any changes here, make sure that you're not breaking any platforms. -// -// Define a small subset of tr1 type traits. The traits we define are: -// is_integral -// is_floating_point -// is_pointer -// is_enum -// is_reference -// is_pod -// has_trivial_constructor -// has_trivial_copy -// has_trivial_assign -// has_trivial_destructor -// remove_const -// remove_volatile -// remove_cv -// remove_reference -// add_reference -// remove_pointer -// is_same -// is_convertible -// We can add more type traits as required. - -#ifndef GOOGLE_PROTOBUF_TYPE_TRAITS_H_ -#define GOOGLE_PROTOBUF_TYPE_TRAITS_H_ - -#include // For pair - -#include // For true_type and false_type - -namespace google { -namespace protobuf { -namespace internal { - -template struct is_integral; -template struct is_floating_point; -template struct is_pointer; -// MSVC can't compile this correctly, and neither can gcc 3.3.5 (at least) -#if !defined(_MSC_VER) && !(defined(__GNUC__) && __GNUC__ <= 3) -// is_enum uses is_convertible, which is not available on MSVC. -template struct is_enum; -#endif -template struct is_reference; -template struct is_pod; -template struct has_trivial_constructor; -template struct has_trivial_copy; -template struct has_trivial_assign; -template struct has_trivial_destructor; -template struct remove_const; -template struct remove_volatile; -template struct remove_cv; -template struct remove_reference; -template struct add_reference; -template struct remove_pointer; -template struct is_same; -#if !defined(_MSC_VER) && !(defined(__GNUC__) && __GNUC__ <= 3) -template struct is_convertible; -#endif - -// is_integral is false except for the built-in integer types. A -// cv-qualified type is integral if and only if the underlying type is. -template struct is_integral : false_type { }; -template<> struct is_integral : true_type { }; -template<> struct is_integral : true_type { }; -template<> struct is_integral : true_type { }; -template<> struct is_integral : true_type { }; -#if defined(_MSC_VER) -// wchar_t is not by default a distinct type from unsigned short in -// Microsoft C. -// See http://msdn2.microsoft.com/en-us/library/dh8che7s(VS.80).aspx -template<> struct is_integral<__wchar_t> : true_type { }; -#else -template<> struct is_integral : true_type { }; -#endif -template<> struct is_integral : true_type { }; -template<> struct is_integral : true_type { }; -template<> struct is_integral : true_type { }; -template<> struct is_integral : true_type { }; -template<> struct is_integral : true_type { }; -template<> struct is_integral : true_type { }; -#ifdef HAVE_LONG_LONG -template<> struct is_integral : true_type { }; -template<> struct is_integral : true_type { }; -#endif -template struct is_integral : is_integral { }; -template struct is_integral : is_integral { }; -template struct is_integral : is_integral { }; - -// is_floating_point is false except for the built-in floating-point types. -// A cv-qualified type is integral if and only if the underlying type is. -template struct is_floating_point : false_type { }; -template<> struct is_floating_point : true_type { }; -template<> struct is_floating_point : true_type { }; -template<> struct is_floating_point : true_type { }; -template struct is_floating_point - : is_floating_point { }; -template struct is_floating_point - : is_floating_point { }; -template struct is_floating_point - : is_floating_point { }; - -// is_pointer is false except for pointer types. A cv-qualified type (e.g. -// "int* const", as opposed to "int const*") is cv-qualified if and only if -// the underlying type is. -template struct is_pointer : false_type { }; -template struct is_pointer : true_type { }; -template struct is_pointer : is_pointer { }; -template struct is_pointer : is_pointer { }; -template struct is_pointer : is_pointer { }; - -#if !defined(_MSC_VER) && !(defined(__GNUC__) && __GNUC__ <= 3) - -namespace internal { - -template struct is_class_or_union { - template static small_ tester(void (U::*)()); - template static big_ tester(...); - static const bool value = sizeof(tester(0)) == sizeof(small_); -}; - -// is_convertible chokes if the first argument is an array. That's why -// we use add_reference here. -template struct is_enum_impl - : is_convertible::type, int> { }; - -template struct is_enum_impl : false_type { }; - -} // namespace internal - -// Specified by TR1 [4.5.1] primary type categories. - -// Implementation note: -// -// Each type is either void, integral, floating point, array, pointer, -// reference, member object pointer, member function pointer, enum, -// union or class. Out of these, only integral, floating point, reference, -// class and enum types are potentially convertible to int. Therefore, -// if a type is not a reference, integral, floating point or class and -// is convertible to int, it's a enum. Adding cv-qualification to a type -// does not change whether it's an enum. -// -// Is-convertible-to-int check is done only if all other checks pass, -// because it can't be used with some types (e.g. void or classes with -// inaccessible conversion operators). -template struct is_enum - : internal::is_enum_impl< - is_same::value || - is_integral::value || - is_floating_point::value || - is_reference::value || - internal::is_class_or_union::value, - T> { }; - -template struct is_enum : is_enum { }; -template struct is_enum : is_enum { }; -template struct is_enum : is_enum { }; - -#endif - -// is_reference is false except for reference types. -template struct is_reference : false_type {}; -template struct is_reference : true_type {}; - - -// We can't get is_pod right without compiler help, so fail conservatively. -// We will assume it's false except for arithmetic types, enumerations, -// pointers and cv-qualified versions thereof. Note that std::pair -// is not a POD even if T and U are PODs. -template struct is_pod - : integral_constant::value || - is_floating_point::value || -#if !defined(_MSC_VER) && !(defined(__GNUC__) && __GNUC__ <= 3) - // is_enum is not available on MSVC. - is_enum::value || -#endif - is_pointer::value)> { }; -template struct is_pod : is_pod { }; -template struct is_pod : is_pod { }; -template struct is_pod : is_pod { }; - - -// We can't get has_trivial_constructor right without compiler help, so -// fail conservatively. We will assume it's false except for: (1) types -// for which is_pod is true. (2) std::pair of types with trivial -// constructors. (3) array of a type with a trivial constructor. -// (4) const versions thereof. -template struct has_trivial_constructor : is_pod { }; -template struct has_trivial_constructor > - : integral_constant::value && - has_trivial_constructor::value)> { }; -template struct has_trivial_constructor - : has_trivial_constructor { }; -template struct has_trivial_constructor - : has_trivial_constructor { }; - -// We can't get has_trivial_copy right without compiler help, so fail -// conservatively. We will assume it's false except for: (1) types -// for which is_pod is true. (2) std::pair of types with trivial copy -// constructors. (3) array of a type with a trivial copy constructor. -// (4) const versions thereof. -template struct has_trivial_copy : is_pod { }; -template struct has_trivial_copy > - : integral_constant::value && - has_trivial_copy::value)> { }; -template struct has_trivial_copy - : has_trivial_copy { }; -template struct has_trivial_copy : has_trivial_copy { }; - -// We can't get has_trivial_assign right without compiler help, so fail -// conservatively. We will assume it's false except for: (1) types -// for which is_pod is true. (2) std::pair of types with trivial copy -// constructors. (3) array of a type with a trivial assign constructor. -template struct has_trivial_assign : is_pod { }; -template struct has_trivial_assign > - : integral_constant::value && - has_trivial_assign::value)> { }; -template struct has_trivial_assign - : has_trivial_assign { }; - -// We can't get has_trivial_destructor right without compiler help, so -// fail conservatively. We will assume it's false except for: (1) types -// for which is_pod is true. (2) std::pair of types with trivial -// destructors. (3) array of a type with a trivial destructor. -// (4) const versions thereof. -template struct has_trivial_destructor : is_pod { }; -template struct has_trivial_destructor > - : integral_constant::value && - has_trivial_destructor::value)> { }; -template struct has_trivial_destructor - : has_trivial_destructor { }; -template struct has_trivial_destructor - : has_trivial_destructor { }; - -// Specified by TR1 [4.7.1] -template struct remove_const { typedef T type; }; -template struct remove_const { typedef T type; }; -template struct remove_volatile { typedef T type; }; -template struct remove_volatile { typedef T type; }; -template struct remove_cv { - typedef typename remove_const::type>::type type; -}; - - -// Specified by TR1 [4.7.2] Reference modifications. -template struct remove_reference { typedef T type; }; -template struct remove_reference { typedef T type; }; - -template struct add_reference { typedef T& type; }; -template struct add_reference { typedef T& type; }; - -// Specified by TR1 [4.7.4] Pointer modifications. -template struct remove_pointer { typedef T type; }; -template struct remove_pointer { typedef T type; }; -template struct remove_pointer { typedef T type; }; -template struct remove_pointer { typedef T type; }; -template struct remove_pointer { - typedef T type; }; - -// Specified by TR1 [4.6] Relationships between types -template struct is_same : public false_type { }; -template struct is_same : public true_type { }; - -// Specified by TR1 [4.6] Relationships between types -#if !defined(_MSC_VER) && !(defined(__GNUC__) && __GNUC__ <= 3) -namespace internal { - -// This class is an implementation detail for is_convertible, and you -// don't need to know how it works to use is_convertible. For those -// who care: we declare two different functions, one whose argument is -// of type To and one with a variadic argument list. We give them -// return types of different size, so we can use sizeof to trick the -// compiler into telling us which function it would have chosen if we -// had called it with an argument of type From. See Alexandrescu's -// _Modern C++ Design_ for more details on this sort of trick. - -template -struct ConvertHelper { - static small_ Test(To); - static big_ Test(...); - static From Create(); -}; -} // namespace internal - -// Inherits from true_type if From is convertible to To, false_type otherwise. -template -struct is_convertible - : integral_constant::Test( - internal::ConvertHelper::Create())) - == sizeof(small_)> { -}; -#endif - -} // namespace internal -} // namespace protobuf -} // namespace google - -#endif // GOOGLE_PROTOBUF_TYPE_TRAITS_H_ diff --git a/modules/dnn/3rdparty/protobuf/src/google/protobuf/stubs/type_traits_unittest.cc b/modules/dnn/3rdparty/protobuf/src/google/protobuf/stubs/type_traits_unittest.cc deleted file mode 100644 index 7a8cbfb8b..000000000 --- a/modules/dnn/3rdparty/protobuf/src/google/protobuf/stubs/type_traits_unittest.cc +++ /dev/null @@ -1,628 +0,0 @@ -// Copyright (c) 2006, Google Inc. -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -// ---- -// Author: Matt Austern - -#include - -#include // for exit() -#include -#include -#include - -#include -#include - -typedef int int32; -typedef long int64; - -using std::string; -using std::vector; -using std::pair; - - -// This assertion produces errors like "error: invalid use of -// incomplete type 'struct ::AssertTypesEq'" -// when it fails. -template struct AssertTypesEq; -template struct AssertTypesEq {}; -#define COMPILE_ASSERT_TYPES_EQ(T, U) static_cast(AssertTypesEq()) - -// A user-defined POD type. -struct A { - int n_; -}; - -// A user-defined non-POD type with a trivial copy constructor. -class B { - public: - explicit B(int n) : n_(n) { } - private: - int n_; -}; - -// Another user-defined non-POD type with a trivial copy constructor. -// We will explicitly declare C to have a trivial copy constructor -// by specializing has_trivial_copy. -class C { - public: - explicit C(int n) : n_(n) { } - private: - int n_; -}; - -namespace google { -namespace protobuf { -namespace internal { -template<> struct has_trivial_copy : true_type { }; -} // namespace internal -} // namespace protobuf -} // namespace google - -// Another user-defined non-POD type with a trivial assignment operator. -// We will explicitly declare C to have a trivial assignment operator -// by specializing has_trivial_assign. -class D { - public: - explicit D(int n) : n_(n) { } - private: - int n_; -}; - -namespace google { -namespace protobuf { -namespace internal { -template<> struct has_trivial_assign : true_type { }; -} // namespace internal -} // namespace protobuf -} // namespace google - -// Another user-defined non-POD type with a trivial constructor. -// We will explicitly declare E to have a trivial constructor -// by specializing has_trivial_constructor. -class E { - public: - int n_; -}; - -namespace google { -namespace protobuf { -namespace internal { -template<> struct has_trivial_constructor : true_type { }; -} // namespace internal -} // namespace protobuf -} // namespace google - -// Another user-defined non-POD type with a trivial destructor. -// We will explicitly declare E to have a trivial destructor -// by specializing has_trivial_destructor. -class F { - public: - explicit F(int n) : n_(n) { } - private: - int n_; -}; - -namespace google { -namespace protobuf { -namespace internal { -template<> struct has_trivial_destructor : true_type { }; -} // namespace internal -} // namespace protobuf -} // namespace google - -enum G {}; - -union H {}; - -class I { - public: - operator int() const; -}; - -class J { - private: - operator int() const; -}; - -namespace google { -namespace protobuf { -namespace internal { -namespace { - -// A base class and a derived class that inherits from it, used for -// testing conversion type traits. -class Base { - public: - virtual ~Base() { } -}; - -class Derived : public Base { -}; - -TEST(TypeTraitsTest, TestIsInteger) { - // Verify that is_integral is true for all integer types. - EXPECT_TRUE(is_integral::value); - EXPECT_TRUE(is_integral::value); - EXPECT_TRUE(is_integral::value); - EXPECT_TRUE(is_integral::value); - EXPECT_TRUE(is_integral::value); - EXPECT_TRUE(is_integral::value); - EXPECT_TRUE(is_integral::value); - EXPECT_TRUE(is_integral::value); - EXPECT_TRUE(is_integral::value); - EXPECT_TRUE(is_integral::value); - EXPECT_TRUE(is_integral::value); - - // Verify that is_integral is false for a few non-integer types. - EXPECT_FALSE(is_integral::value); - EXPECT_FALSE(is_integral::value); - EXPECT_FALSE(is_integral::value); - EXPECT_FALSE(is_integral::value); - EXPECT_FALSE(is_integral::value); - EXPECT_FALSE((is_integral >::value)); - - // Verify that cv-qualified integral types are still integral, and - // cv-qualified non-integral types are still non-integral. - EXPECT_TRUE(is_integral::value); - EXPECT_TRUE(is_integral::value); - EXPECT_TRUE(is_integral::value); - EXPECT_FALSE(is_integral::value); - EXPECT_FALSE(is_integral::value); - EXPECT_FALSE(is_integral::value); -} - -TEST(TypeTraitsTest, TestIsFloating) { - // Verify that is_floating_point is true for all floating-point types. - EXPECT_TRUE(is_floating_point::value); - EXPECT_TRUE(is_floating_point::value); - EXPECT_TRUE(is_floating_point::value); - - // Verify that is_floating_point is false for a few non-float types. - EXPECT_FALSE(is_floating_point::value); - EXPECT_FALSE(is_floating_point::value); - EXPECT_FALSE(is_floating_point::value); - EXPECT_FALSE(is_floating_point::value); - EXPECT_FALSE(is_floating_point::value); - EXPECT_FALSE((is_floating_point >::value)); - - // Verify that cv-qualified floating point types are still floating, and - // cv-qualified non-floating types are still non-floating. - EXPECT_TRUE(is_floating_point::value); - EXPECT_TRUE(is_floating_point::value); - EXPECT_TRUE(is_floating_point::value); - EXPECT_FALSE(is_floating_point::value); - EXPECT_FALSE(is_floating_point::value); - EXPECT_FALSE(is_floating_point::value); -} - -TEST(TypeTraitsTest, TestIsPointer) { - // Verify that is_pointer is true for some pointer types. - EXPECT_TRUE(is_pointer::value); - EXPECT_TRUE(is_pointer::value); - EXPECT_TRUE(is_pointer::value); - EXPECT_TRUE(is_pointer::value); - EXPECT_TRUE(is_pointer::value); - - // Verify that is_pointer is false for some non-pointer types. - EXPECT_FALSE(is_pointer::value); - EXPECT_FALSE(is_pointer::value); - EXPECT_FALSE(is_pointer::value); - EXPECT_FALSE(is_pointer >::value); - EXPECT_FALSE(is_pointer::value); - - // A function pointer is a pointer, but a function type, or a function - // reference type, is not. - EXPECT_TRUE(is_pointer::value); - EXPECT_FALSE(is_pointer::value); - EXPECT_FALSE(is_pointer::value); - - // Verify that is_pointer is true for some cv-qualified pointer types, - // and false for some cv-qualified non-pointer types. - EXPECT_TRUE(is_pointer::value); - EXPECT_TRUE(is_pointer::value); - EXPECT_TRUE(is_pointer::value); - EXPECT_FALSE(is_pointer::value); - EXPECT_FALSE(is_pointer >::value); - EXPECT_FALSE(is_pointer::value); -} - -TEST(TypeTraitsTest, TestIsEnum) { -// is_enum isn't supported on MSVC or gcc 3.x -#if !defined(_MSC_VER) && !(defined(__GNUC__) && __GNUC__ <= 3) - // Verify that is_enum is true for enum types. - EXPECT_TRUE(is_enum::value); - EXPECT_TRUE(is_enum::value); - EXPECT_TRUE(is_enum::value); - EXPECT_TRUE(is_enum::value); - - // Verify that is_enum is false for a few non-enum types. - EXPECT_FALSE(is_enum::value); - EXPECT_FALSE(is_enum::value); - EXPECT_FALSE(is_enum::value); - EXPECT_FALSE(is_enum::value); - EXPECT_FALSE(is_enum::value); - EXPECT_FALSE(is_enum::value); - EXPECT_FALSE(is_enum::value); - EXPECT_FALSE(is_enum::value); - EXPECT_FALSE(is_enum::value); - EXPECT_FALSE(is_enum::value); - EXPECT_FALSE(is_enum::value); - EXPECT_FALSE(is_enum::value); - EXPECT_FALSE(is_enum::value); - EXPECT_FALSE(is_enum::value); - EXPECT_FALSE(is_enum::value); - EXPECT_FALSE(is_enum::value); - EXPECT_FALSE(is_enum::value); -#endif -} - -TEST(TypeTraitsTest, TestIsReference) { - // Verifies that is_reference is true for all reference types. - typedef float& RefFloat; - EXPECT_TRUE(is_reference::value); - EXPECT_TRUE(is_reference::value); - EXPECT_TRUE(is_reference::value); - EXPECT_TRUE(is_reference::value); - EXPECT_TRUE(is_reference::value); - EXPECT_TRUE(is_reference::value); - EXPECT_TRUE(is_reference::value); - EXPECT_TRUE(is_reference::value); - - - // Verifies that is_reference is false for all non-reference types. - EXPECT_FALSE(is_reference::value); - EXPECT_FALSE(is_reference::value); - EXPECT_FALSE(is_reference::value); - EXPECT_FALSE(is_reference::value); - EXPECT_FALSE(is_reference::value); - EXPECT_FALSE(is_reference::value); - EXPECT_FALSE(is_reference::value); -} - -TEST(TypeTraitsTest, TestAddReference) { - COMPILE_ASSERT_TYPES_EQ(int&, add_reference::type); - COMPILE_ASSERT_TYPES_EQ(const int&, add_reference::type); - COMPILE_ASSERT_TYPES_EQ(volatile int&, - add_reference::type); - COMPILE_ASSERT_TYPES_EQ(const volatile int&, - add_reference::type); - COMPILE_ASSERT_TYPES_EQ(int&, add_reference::type); - COMPILE_ASSERT_TYPES_EQ(const int&, add_reference::type); - COMPILE_ASSERT_TYPES_EQ(volatile int&, - add_reference::type); - COMPILE_ASSERT_TYPES_EQ(const volatile int&, - add_reference::type); -} - -TEST(TypeTraitsTest, TestIsPod) { - // Verify that arithmetic types and pointers are marked as PODs. - EXPECT_TRUE(is_pod::value); - EXPECT_TRUE(is_pod::value); - EXPECT_TRUE(is_pod::value); - EXPECT_TRUE(is_pod::value); - EXPECT_TRUE(is_pod::value); - EXPECT_TRUE(is_pod::value); - EXPECT_TRUE(is_pod::value); - EXPECT_TRUE(is_pod::value); - EXPECT_TRUE(is_pod::value); - EXPECT_TRUE(is_pod::value); - EXPECT_TRUE(is_pod::value); - EXPECT_TRUE(is_pod::value); - EXPECT_TRUE(is_pod::value); - EXPECT_TRUE(is_pod::value); - EXPECT_TRUE(is_pod::value); - EXPECT_TRUE(is_pod::value); - EXPECT_TRUE(is_pod::value); - EXPECT_TRUE(is_pod::value); - EXPECT_TRUE(is_pod::value); - EXPECT_TRUE(is_pod::value); - EXPECT_TRUE(is_pod::value); -#if !defined(_MSC_VER) && !(defined(__GNUC__) && __GNUC__ <= 3) - EXPECT_TRUE(is_pod::value); - EXPECT_TRUE(is_pod::value); - EXPECT_TRUE(is_pod::value); - EXPECT_TRUE(is_pod::value); -#endif - - // Verify that some non-POD types are not marked as PODs. - EXPECT_FALSE(is_pod::value); - EXPECT_FALSE(is_pod::value); - EXPECT_FALSE((is_pod >::value)); - EXPECT_FALSE(is_pod::value); - EXPECT_FALSE(is_pod::value); - EXPECT_FALSE(is_pod::value); - EXPECT_FALSE(is_pod::value); - EXPECT_FALSE(is_pod::value); - EXPECT_FALSE(is_pod::value); -} - -TEST(TypeTraitsTest, TestHasTrivialConstructor) { - // Verify that arithmetic types and pointers have trivial constructors. - EXPECT_TRUE(has_trivial_constructor::value); - EXPECT_TRUE(has_trivial_constructor::value); - EXPECT_TRUE(has_trivial_constructor::value); - EXPECT_TRUE(has_trivial_constructor::value); - EXPECT_TRUE(has_trivial_constructor::value); - EXPECT_TRUE(has_trivial_constructor::value); - EXPECT_TRUE(has_trivial_constructor::value); - EXPECT_TRUE(has_trivial_constructor::value); - EXPECT_TRUE(has_trivial_constructor::value); - EXPECT_TRUE(has_trivial_constructor::value); - EXPECT_TRUE(has_trivial_constructor::value); - EXPECT_TRUE(has_trivial_constructor::value); - EXPECT_TRUE(has_trivial_constructor::value); - EXPECT_TRUE(has_trivial_constructor::value); - EXPECT_TRUE(has_trivial_constructor::value); - EXPECT_TRUE(has_trivial_constructor::value); - EXPECT_TRUE(has_trivial_constructor::value); - EXPECT_TRUE(has_trivial_constructor::value); - - // Verify that pairs and arrays of such types have trivial - // constructors. - typedef int int10[10]; - EXPECT_TRUE((has_trivial_constructor >::value)); - EXPECT_TRUE(has_trivial_constructor::value); - - // Verify that pairs of types without trivial constructors - // are not marked as trivial. - EXPECT_FALSE((has_trivial_constructor >::value)); - EXPECT_FALSE((has_trivial_constructor >::value)); - - // Verify that types without trivial constructors are - // correctly marked as such. - EXPECT_FALSE(has_trivial_constructor::value); - EXPECT_FALSE(has_trivial_constructor >::value); - - // Verify that E, which we have declared to have a trivial - // constructor, is correctly marked as such. - EXPECT_TRUE(has_trivial_constructor::value); -} - -TEST(TypeTraitsTest, TestHasTrivialCopy) { - // Verify that arithmetic types and pointers have trivial copy - // constructors. - EXPECT_TRUE(has_trivial_copy::value); - EXPECT_TRUE(has_trivial_copy::value); - EXPECT_TRUE(has_trivial_copy::value); - EXPECT_TRUE(has_trivial_copy::value); - EXPECT_TRUE(has_trivial_copy::value); - EXPECT_TRUE(has_trivial_copy::value); - EXPECT_TRUE(has_trivial_copy::value); - EXPECT_TRUE(has_trivial_copy::value); - EXPECT_TRUE(has_trivial_copy::value); - EXPECT_TRUE(has_trivial_copy::value); - EXPECT_TRUE(has_trivial_copy::value); - EXPECT_TRUE(has_trivial_copy::value); - EXPECT_TRUE(has_trivial_copy::value); - EXPECT_TRUE(has_trivial_copy::value); - EXPECT_TRUE(has_trivial_copy::value); - EXPECT_TRUE(has_trivial_copy::value); - EXPECT_TRUE(has_trivial_copy::value); - EXPECT_TRUE(has_trivial_copy::value); - - // Verify that pairs and arrays of such types have trivial - // copy constructors. - typedef int int10[10]; - EXPECT_TRUE((has_trivial_copy >::value)); - EXPECT_TRUE(has_trivial_copy::value); - - // Verify that pairs of types without trivial copy constructors - // are not marked as trivial. - EXPECT_FALSE((has_trivial_copy >::value)); - EXPECT_FALSE((has_trivial_copy >::value)); - - // Verify that types without trivial copy constructors are - // correctly marked as such. - EXPECT_FALSE(has_trivial_copy::value); - EXPECT_FALSE(has_trivial_copy >::value); - - // Verify that C, which we have declared to have a trivial - // copy constructor, is correctly marked as such. - EXPECT_TRUE(has_trivial_copy::value); -} - -TEST(TypeTraitsTest, TestHasTrivialAssign) { - // Verify that arithmetic types and pointers have trivial assignment - // operators. - EXPECT_TRUE(has_trivial_assign::value); - EXPECT_TRUE(has_trivial_assign::value); - EXPECT_TRUE(has_trivial_assign::value); - EXPECT_TRUE(has_trivial_assign::value); - EXPECT_TRUE(has_trivial_assign::value); - EXPECT_TRUE(has_trivial_assign::value); - EXPECT_TRUE(has_trivial_assign::value); - EXPECT_TRUE(has_trivial_assign::value); - EXPECT_TRUE(has_trivial_assign::value); - EXPECT_TRUE(has_trivial_assign::value); - EXPECT_TRUE(has_trivial_assign::value); - EXPECT_TRUE(has_trivial_assign::value); - EXPECT_TRUE(has_trivial_assign::value); - EXPECT_TRUE(has_trivial_assign::value); - EXPECT_TRUE(has_trivial_assign::value); - EXPECT_TRUE(has_trivial_assign::value); - EXPECT_TRUE(has_trivial_assign::value); - EXPECT_TRUE(has_trivial_assign::value); - - // Verify that pairs and arrays of such types have trivial - // assignment operators. - typedef int int10[10]; - EXPECT_TRUE((has_trivial_assign >::value)); - EXPECT_TRUE(has_trivial_assign::value); - - // Verify that pairs of types without trivial assignment operators - // are not marked as trivial. - EXPECT_FALSE((has_trivial_assign >::value)); - EXPECT_FALSE((has_trivial_assign >::value)); - - // Verify that types without trivial assignment operators are - // correctly marked as such. - EXPECT_FALSE(has_trivial_assign::value); - EXPECT_FALSE(has_trivial_assign >::value); - - // Verify that D, which we have declared to have a trivial - // assignment operator, is correctly marked as such. - EXPECT_TRUE(has_trivial_assign::value); -} - -TEST(TypeTraitsTest, TestHasTrivialDestructor) { - // Verify that arithmetic types and pointers have trivial destructors. - EXPECT_TRUE(has_trivial_destructor::value); - EXPECT_TRUE(has_trivial_destructor::value); - EXPECT_TRUE(has_trivial_destructor::value); - EXPECT_TRUE(has_trivial_destructor::value); - EXPECT_TRUE(has_trivial_destructor::value); - EXPECT_TRUE(has_trivial_destructor::value); - EXPECT_TRUE(has_trivial_destructor::value); - EXPECT_TRUE(has_trivial_destructor::value); - EXPECT_TRUE(has_trivial_destructor::value); - EXPECT_TRUE(has_trivial_destructor::value); - EXPECT_TRUE(has_trivial_destructor::value); - EXPECT_TRUE(has_trivial_destructor::value); - EXPECT_TRUE(has_trivial_destructor::value); - EXPECT_TRUE(has_trivial_destructor::value); - EXPECT_TRUE(has_trivial_destructor::value); - EXPECT_TRUE(has_trivial_destructor::value); - EXPECT_TRUE(has_trivial_destructor::value); - EXPECT_TRUE(has_trivial_destructor::value); - - // Verify that pairs and arrays of such types have trivial - // destructors. - typedef int int10[10]; - EXPECT_TRUE((has_trivial_destructor >::value)); - EXPECT_TRUE(has_trivial_destructor::value); - - // Verify that pairs of types without trivial destructors - // are not marked as trivial. - EXPECT_FALSE((has_trivial_destructor >::value)); - EXPECT_FALSE((has_trivial_destructor >::value)); - - // Verify that types without trivial destructors are - // correctly marked as such. - EXPECT_FALSE(has_trivial_destructor::value); - EXPECT_FALSE(has_trivial_destructor >::value); - - // Verify that F, which we have declared to have a trivial - // destructor, is correctly marked as such. - EXPECT_TRUE(has_trivial_destructor::value); -} - -// Tests remove_pointer. -TEST(TypeTraitsTest, TestRemovePointer) { - COMPILE_ASSERT_TYPES_EQ(int, remove_pointer::type); - COMPILE_ASSERT_TYPES_EQ(int, remove_pointer::type); - COMPILE_ASSERT_TYPES_EQ(const int, remove_pointer::type); - COMPILE_ASSERT_TYPES_EQ(int, remove_pointer::type); - COMPILE_ASSERT_TYPES_EQ(int, remove_pointer::type); -} - -TEST(TypeTraitsTest, TestRemoveConst) { - COMPILE_ASSERT_TYPES_EQ(int, remove_const::type); - COMPILE_ASSERT_TYPES_EQ(int, remove_const::type); - COMPILE_ASSERT_TYPES_EQ(int *, remove_const::type); - // TR1 examples. - COMPILE_ASSERT_TYPES_EQ(const int *, remove_const::type); - COMPILE_ASSERT_TYPES_EQ(volatile int, - remove_const::type); -} - -TEST(TypeTraitsTest, TestRemoveVolatile) { - COMPILE_ASSERT_TYPES_EQ(int, remove_volatile::type); - COMPILE_ASSERT_TYPES_EQ(int, remove_volatile::type); - COMPILE_ASSERT_TYPES_EQ(int *, remove_volatile::type); - // TR1 examples. - COMPILE_ASSERT_TYPES_EQ(volatile int *, - remove_volatile::type); - COMPILE_ASSERT_TYPES_EQ(const int, - remove_volatile::type); -} - -TEST(TypeTraitsTest, TestRemoveCV) { - COMPILE_ASSERT_TYPES_EQ(int, remove_cv::type); - COMPILE_ASSERT_TYPES_EQ(int, remove_cv::type); - COMPILE_ASSERT_TYPES_EQ(int, remove_cv::type); - COMPILE_ASSERT_TYPES_EQ(int *, remove_cv::type); - // TR1 examples. - COMPILE_ASSERT_TYPES_EQ(const volatile int *, - remove_cv::type); - COMPILE_ASSERT_TYPES_EQ(int, - remove_cv::type); -} - -TEST(TypeTraitsTest, TestRemoveReference) { - COMPILE_ASSERT_TYPES_EQ(int, remove_reference::type); - COMPILE_ASSERT_TYPES_EQ(int, remove_reference::type); - COMPILE_ASSERT_TYPES_EQ(const int, remove_reference::type); - COMPILE_ASSERT_TYPES_EQ(int*, remove_reference::type); -} - -TEST(TypeTraitsTest, TestIsSame) { - EXPECT_TRUE((is_same::value)); - EXPECT_FALSE((is_same::value)); - EXPECT_FALSE((is_same::value)); - EXPECT_FALSE((is_same::value)); - - EXPECT_TRUE((is_same::value)); - EXPECT_FALSE((is_same::value)); - EXPECT_FALSE((is_same::value)); - - EXPECT_TRUE((is_same::value)); - EXPECT_TRUE((is_same::value)); - EXPECT_FALSE((is_same::value)); - EXPECT_FALSE((is_same::value)); - EXPECT_FALSE((is_same::value)); - EXPECT_FALSE((is_same::value)); - - EXPECT_TRUE((is_same::value)); - EXPECT_TRUE((is_same::value)); - EXPECT_FALSE((is_same::value)); - EXPECT_FALSE((is_same::value)); -} - -TEST(TypeTraitsTest, TestConvertible) { -#if !defined(_MSC_VER) && !(defined(__GNUC__) && __GNUC__ <= 3) - EXPECT_TRUE((is_convertible::value)); - EXPECT_TRUE((is_convertible::value)); - EXPECT_TRUE((is_convertible::value)); - - EXPECT_TRUE((is_convertible::value)); - EXPECT_FALSE((is_convertible::value)); - - EXPECT_TRUE((is_convertible::value)); - EXPECT_FALSE((is_convertible::value)); - EXPECT_TRUE((is_convertible::value)); - EXPECT_FALSE((is_convertible::value)); -#endif -} - -} // anonymous namespace -} // namespace internal -} // namespace protobuf -} // namespace google diff --git a/modules/dnn/3rdparty/protobuf/src/google/protobuf/test_util.cc b/modules/dnn/3rdparty/protobuf/src/google/protobuf/test_util.cc deleted file mode 100644 index a9666fe40..000000000 --- a/modules/dnn/3rdparty/protobuf/src/google/protobuf/test_util.cc +++ /dev/null @@ -1,3047 +0,0 @@ -// Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// http://code.google.com/p/protobuf/ -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -// Author: kenton@google.com (Kenton Varda) -// Based on original Protocol Buffers design by -// Sanjay Ghemawat, Jeff Dean, and others. - -#ifdef _WIN32 -// Verify that #including windows.h does not break anything (e.g. because -// windows.h #defines GetMessage() as a macro). -#include -#endif - -#include -#include -#include - -#include -#include -#include - -namespace google { -namespace protobuf { - -void TestUtil::SetAllFields(unittest::TestAllTypes* message) { - SetOptionalFields(message); - AddRepeatedFields1(message); - AddRepeatedFields2(message); - SetDefaultFields(message); -} - -void TestUtil::SetOptionalFields(unittest::TestAllTypes* message) { - message->set_optional_int32 (101); - message->set_optional_int64 (102); - message->set_optional_uint32 (103); - message->set_optional_uint64 (104); - message->set_optional_sint32 (105); - message->set_optional_sint64 (106); - message->set_optional_fixed32 (107); - message->set_optional_fixed64 (108); - message->set_optional_sfixed32(109); - message->set_optional_sfixed64(110); - message->set_optional_float (111); - message->set_optional_double (112); - message->set_optional_bool (true); - message->set_optional_string ("115"); - message->set_optional_bytes ("116"); - - message->mutable_optionalgroup ()->set_a(117); - message->mutable_optional_nested_message ()->set_bb(118); - message->mutable_optional_foreign_message ()->set_c(119); - message->mutable_optional_import_message ()->set_d(120); - message->mutable_optional_public_import_message()->set_e(126); - message->mutable_optional_lazy_message ()->set_bb(127); - - message->set_optional_nested_enum (unittest::TestAllTypes::BAZ); - message->set_optional_foreign_enum(unittest::FOREIGN_BAZ ); - message->set_optional_import_enum (unittest_import::IMPORT_BAZ); - - // StringPiece and Cord fields are only accessible via reflection in the - // open source release; see comments in compiler/cpp/string_field.cc. -#ifndef PROTOBUF_TEST_NO_DESCRIPTORS - message->GetReflection()->SetString( - message, - message->GetDescriptor()->FindFieldByName("optional_string_piece"), - "124"); - message->GetReflection()->SetString( - message, - message->GetDescriptor()->FindFieldByName("optional_cord"), - "125"); -#endif // !PROTOBUF_TEST_NO_DESCRIPTORS -} - -// ------------------------------------------------------------------- - -void TestUtil::AddRepeatedFields1(unittest::TestAllTypes* message) { - message->add_repeated_int32 (201); - message->add_repeated_int64 (202); - message->add_repeated_uint32 (203); - message->add_repeated_uint64 (204); - message->add_repeated_sint32 (205); - message->add_repeated_sint64 (206); - message->add_repeated_fixed32 (207); - message->add_repeated_fixed64 (208); - message->add_repeated_sfixed32(209); - message->add_repeated_sfixed64(210); - message->add_repeated_float (211); - message->add_repeated_double (212); - message->add_repeated_bool (true); - message->add_repeated_string ("215"); - message->add_repeated_bytes ("216"); - - message->add_repeatedgroup ()->set_a(217); - message->add_repeated_nested_message ()->set_bb(218); - message->add_repeated_foreign_message()->set_c(219); - message->add_repeated_import_message ()->set_d(220); - message->add_repeated_lazy_message ()->set_bb(227); - - message->add_repeated_nested_enum (unittest::TestAllTypes::BAR); - message->add_repeated_foreign_enum(unittest::FOREIGN_BAR ); - message->add_repeated_import_enum (unittest_import::IMPORT_BAR); - -#ifndef PROTOBUF_TEST_NO_DESCRIPTORS - message->GetReflection()->AddString( - message, - message->GetDescriptor()->FindFieldByName("repeated_string_piece"), - "224"); - message->GetReflection()->AddString( - message, - message->GetDescriptor()->FindFieldByName("repeated_cord"), - "225"); -#endif // !PROTOBUF_TEST_NO_DESCRIPTORS -} - -void TestUtil::AddRepeatedFields2(unittest::TestAllTypes* message) { - // Add a second one of each field. - message->add_repeated_int32 (301); - message->add_repeated_int64 (302); - message->add_repeated_uint32 (303); - message->add_repeated_uint64 (304); - message->add_repeated_sint32 (305); - message->add_repeated_sint64 (306); - message->add_repeated_fixed32 (307); - message->add_repeated_fixed64 (308); - message->add_repeated_sfixed32(309); - message->add_repeated_sfixed64(310); - message->add_repeated_float (311); - message->add_repeated_double (312); - message->add_repeated_bool (false); - message->add_repeated_string ("315"); - message->add_repeated_bytes ("316"); - - message->add_repeatedgroup ()->set_a(317); - message->add_repeated_nested_message ()->set_bb(318); - message->add_repeated_foreign_message()->set_c(319); - message->add_repeated_import_message ()->set_d(320); - message->add_repeated_lazy_message ()->set_bb(327); - - message->add_repeated_nested_enum (unittest::TestAllTypes::BAZ); - message->add_repeated_foreign_enum(unittest::FOREIGN_BAZ ); - message->add_repeated_import_enum (unittest_import::IMPORT_BAZ); - -#ifndef PROTOBUF_TEST_NO_DESCRIPTORS - message->GetReflection()->AddString( - message, - message->GetDescriptor()->FindFieldByName("repeated_string_piece"), - "324"); - message->GetReflection()->AddString( - message, - message->GetDescriptor()->FindFieldByName("repeated_cord"), - "325"); -#endif // !PROTOBUF_TEST_NO_DESCRIPTORS -} - -// ------------------------------------------------------------------- - -void TestUtil::SetDefaultFields(unittest::TestAllTypes* message) { - message->set_default_int32 (401); - message->set_default_int64 (402); - message->set_default_uint32 (403); - message->set_default_uint64 (404); - message->set_default_sint32 (405); - message->set_default_sint64 (406); - message->set_default_fixed32 (407); - message->set_default_fixed64 (408); - message->set_default_sfixed32(409); - message->set_default_sfixed64(410); - message->set_default_float (411); - message->set_default_double (412); - message->set_default_bool (false); - message->set_default_string ("415"); - message->set_default_bytes ("416"); - - message->set_default_nested_enum (unittest::TestAllTypes::FOO); - message->set_default_foreign_enum(unittest::FOREIGN_FOO ); - message->set_default_import_enum (unittest_import::IMPORT_FOO); - -#ifndef PROTOBUF_TEST_NO_DESCRIPTORS - message->GetReflection()->SetString( - message, - message->GetDescriptor()->FindFieldByName("default_string_piece"), - "424"); - message->GetReflection()->SetString( - message, - message->GetDescriptor()->FindFieldByName("default_cord"), - "425"); -#endif // !PROTOBUF_TEST_NO_DESCRIPTORS -} - -// ------------------------------------------------------------------- - -void TestUtil::ModifyRepeatedFields(unittest::TestAllTypes* message) { - message->set_repeated_int32 (1, 501); - message->set_repeated_int64 (1, 502); - message->set_repeated_uint32 (1, 503); - message->set_repeated_uint64 (1, 504); - message->set_repeated_sint32 (1, 505); - message->set_repeated_sint64 (1, 506); - message->set_repeated_fixed32 (1, 507); - message->set_repeated_fixed64 (1, 508); - message->set_repeated_sfixed32(1, 509); - message->set_repeated_sfixed64(1, 510); - message->set_repeated_float (1, 511); - message->set_repeated_double (1, 512); - message->set_repeated_bool (1, true); - message->set_repeated_string (1, "515"); - message->set_repeated_bytes (1, "516"); - - message->mutable_repeatedgroup (1)->set_a(517); - message->mutable_repeated_nested_message (1)->set_bb(518); - message->mutable_repeated_foreign_message(1)->set_c(519); - message->mutable_repeated_import_message (1)->set_d(520); - message->mutable_repeated_lazy_message (1)->set_bb(527); - - message->set_repeated_nested_enum (1, unittest::TestAllTypes::FOO); - message->set_repeated_foreign_enum(1, unittest::FOREIGN_FOO ); - message->set_repeated_import_enum (1, unittest_import::IMPORT_FOO); - -#ifndef PROTOBUF_TEST_NO_DESCRIPTORS - message->GetReflection()->SetRepeatedString( - message, - message->GetDescriptor()->FindFieldByName("repeated_string_piece"), - 1, "524"); - message->GetReflection()->SetRepeatedString( - message, - message->GetDescriptor()->FindFieldByName("repeated_cord"), - 1, "525"); -#endif // !PROTOBUF_TEST_NO_DESCRIPTORS -} - -// ------------------------------------------------------------------- - -void TestUtil::ExpectAllFieldsSet(const unittest::TestAllTypes& message) { - EXPECT_TRUE(message.has_optional_int32 ()); - EXPECT_TRUE(message.has_optional_int64 ()); - EXPECT_TRUE(message.has_optional_uint32 ()); - EXPECT_TRUE(message.has_optional_uint64 ()); - EXPECT_TRUE(message.has_optional_sint32 ()); - EXPECT_TRUE(message.has_optional_sint64 ()); - EXPECT_TRUE(message.has_optional_fixed32 ()); - EXPECT_TRUE(message.has_optional_fixed64 ()); - EXPECT_TRUE(message.has_optional_sfixed32()); - EXPECT_TRUE(message.has_optional_sfixed64()); - EXPECT_TRUE(message.has_optional_float ()); - EXPECT_TRUE(message.has_optional_double ()); - EXPECT_TRUE(message.has_optional_bool ()); - EXPECT_TRUE(message.has_optional_string ()); - EXPECT_TRUE(message.has_optional_bytes ()); - - EXPECT_TRUE(message.has_optionalgroup ()); - EXPECT_TRUE(message.has_optional_nested_message ()); - EXPECT_TRUE(message.has_optional_foreign_message ()); - EXPECT_TRUE(message.has_optional_import_message ()); - EXPECT_TRUE(message.has_optional_public_import_message()); - EXPECT_TRUE(message.has_optional_lazy_message ()); - - EXPECT_TRUE(message.optionalgroup ().has_a()); - EXPECT_TRUE(message.optional_nested_message ().has_bb()); - EXPECT_TRUE(message.optional_foreign_message ().has_c()); - EXPECT_TRUE(message.optional_import_message ().has_d()); - EXPECT_TRUE(message.optional_public_import_message().has_e()); - EXPECT_TRUE(message.optional_lazy_message ().has_bb()); - - EXPECT_TRUE(message.has_optional_nested_enum ()); - EXPECT_TRUE(message.has_optional_foreign_enum()); - EXPECT_TRUE(message.has_optional_import_enum ()); - -#ifndef PROTOBUF_TEST_NO_DESCRIPTORS - EXPECT_TRUE(message.has_optional_string_piece()); - EXPECT_TRUE(message.has_optional_cord()); -#endif - - EXPECT_EQ(101 , message.optional_int32 ()); - EXPECT_EQ(102 , message.optional_int64 ()); - EXPECT_EQ(103 , message.optional_uint32 ()); - EXPECT_EQ(104 , message.optional_uint64 ()); - EXPECT_EQ(105 , message.optional_sint32 ()); - EXPECT_EQ(106 , message.optional_sint64 ()); - EXPECT_EQ(107 , message.optional_fixed32 ()); - EXPECT_EQ(108 , message.optional_fixed64 ()); - EXPECT_EQ(109 , message.optional_sfixed32()); - EXPECT_EQ(110 , message.optional_sfixed64()); - EXPECT_EQ(111 , message.optional_float ()); - EXPECT_EQ(112 , message.optional_double ()); - EXPECT_TRUE( message.optional_bool ()); - EXPECT_EQ("115", message.optional_string ()); - EXPECT_EQ("116", message.optional_bytes ()); - - EXPECT_EQ(117, message.optionalgroup ().a()); - EXPECT_EQ(118, message.optional_nested_message ().bb()); - EXPECT_EQ(119, message.optional_foreign_message ().c()); - EXPECT_EQ(120, message.optional_import_message ().d()); - EXPECT_EQ(126, message.optional_public_import_message ().e()); - EXPECT_EQ(127, message.optional_lazy_message ().bb()); - - EXPECT_EQ(unittest::TestAllTypes::BAZ, message.optional_nested_enum ()); - EXPECT_EQ(unittest::FOREIGN_BAZ , message.optional_foreign_enum()); - EXPECT_EQ(unittest_import::IMPORT_BAZ, message.optional_import_enum ()); - - - // ----------------------------------------------------------------- - - ASSERT_EQ(2, message.repeated_int32_size ()); - ASSERT_EQ(2, message.repeated_int64_size ()); - ASSERT_EQ(2, message.repeated_uint32_size ()); - ASSERT_EQ(2, message.repeated_uint64_size ()); - ASSERT_EQ(2, message.repeated_sint32_size ()); - ASSERT_EQ(2, message.repeated_sint64_size ()); - ASSERT_EQ(2, message.repeated_fixed32_size ()); - ASSERT_EQ(2, message.repeated_fixed64_size ()); - ASSERT_EQ(2, message.repeated_sfixed32_size()); - ASSERT_EQ(2, message.repeated_sfixed64_size()); - ASSERT_EQ(2, message.repeated_float_size ()); - ASSERT_EQ(2, message.repeated_double_size ()); - ASSERT_EQ(2, message.repeated_bool_size ()); - ASSERT_EQ(2, message.repeated_string_size ()); - ASSERT_EQ(2, message.repeated_bytes_size ()); - - ASSERT_EQ(2, message.repeatedgroup_size ()); - ASSERT_EQ(2, message.repeated_nested_message_size ()); - ASSERT_EQ(2, message.repeated_foreign_message_size()); - ASSERT_EQ(2, message.repeated_import_message_size ()); - ASSERT_EQ(2, message.repeated_lazy_message_size ()); - ASSERT_EQ(2, message.repeated_nested_enum_size ()); - ASSERT_EQ(2, message.repeated_foreign_enum_size ()); - ASSERT_EQ(2, message.repeated_import_enum_size ()); - -#ifndef PROTOBUF_TEST_NO_DESCRIPTORS - ASSERT_EQ(2, message.repeated_string_piece_size()); - ASSERT_EQ(2, message.repeated_cord_size()); -#endif - - EXPECT_EQ(201 , message.repeated_int32 (0)); - EXPECT_EQ(202 , message.repeated_int64 (0)); - EXPECT_EQ(203 , message.repeated_uint32 (0)); - EXPECT_EQ(204 , message.repeated_uint64 (0)); - EXPECT_EQ(205 , message.repeated_sint32 (0)); - EXPECT_EQ(206 , message.repeated_sint64 (0)); - EXPECT_EQ(207 , message.repeated_fixed32 (0)); - EXPECT_EQ(208 , message.repeated_fixed64 (0)); - EXPECT_EQ(209 , message.repeated_sfixed32(0)); - EXPECT_EQ(210 , message.repeated_sfixed64(0)); - EXPECT_EQ(211 , message.repeated_float (0)); - EXPECT_EQ(212 , message.repeated_double (0)); - EXPECT_TRUE( message.repeated_bool (0)); - EXPECT_EQ("215", message.repeated_string (0)); - EXPECT_EQ("216", message.repeated_bytes (0)); - - EXPECT_EQ(217, message.repeatedgroup (0).a()); - EXPECT_EQ(218, message.repeated_nested_message (0).bb()); - EXPECT_EQ(219, message.repeated_foreign_message(0).c()); - EXPECT_EQ(220, message.repeated_import_message (0).d()); - EXPECT_EQ(227, message.repeated_lazy_message (0).bb()); - - - EXPECT_EQ(unittest::TestAllTypes::BAR, message.repeated_nested_enum (0)); - EXPECT_EQ(unittest::FOREIGN_BAR , message.repeated_foreign_enum(0)); - EXPECT_EQ(unittest_import::IMPORT_BAR, message.repeated_import_enum (0)); - - EXPECT_EQ(301 , message.repeated_int32 (1)); - EXPECT_EQ(302 , message.repeated_int64 (1)); - EXPECT_EQ(303 , message.repeated_uint32 (1)); - EXPECT_EQ(304 , message.repeated_uint64 (1)); - EXPECT_EQ(305 , message.repeated_sint32 (1)); - EXPECT_EQ(306 , message.repeated_sint64 (1)); - EXPECT_EQ(307 , message.repeated_fixed32 (1)); - EXPECT_EQ(308 , message.repeated_fixed64 (1)); - EXPECT_EQ(309 , message.repeated_sfixed32(1)); - EXPECT_EQ(310 , message.repeated_sfixed64(1)); - EXPECT_EQ(311 , message.repeated_float (1)); - EXPECT_EQ(312 , message.repeated_double (1)); - EXPECT_FALSE( message.repeated_bool (1)); - EXPECT_EQ("315", message.repeated_string (1)); - EXPECT_EQ("316", message.repeated_bytes (1)); - - EXPECT_EQ(317, message.repeatedgroup (1).a()); - EXPECT_EQ(318, message.repeated_nested_message (1).bb()); - EXPECT_EQ(319, message.repeated_foreign_message(1).c()); - EXPECT_EQ(320, message.repeated_import_message (1).d()); - EXPECT_EQ(327, message.repeated_lazy_message (1).bb()); - - EXPECT_EQ(unittest::TestAllTypes::BAZ, message.repeated_nested_enum (1)); - EXPECT_EQ(unittest::FOREIGN_BAZ , message.repeated_foreign_enum(1)); - EXPECT_EQ(unittest_import::IMPORT_BAZ, message.repeated_import_enum (1)); - - - // ----------------------------------------------------------------- - - EXPECT_TRUE(message.has_default_int32 ()); - EXPECT_TRUE(message.has_default_int64 ()); - EXPECT_TRUE(message.has_default_uint32 ()); - EXPECT_TRUE(message.has_default_uint64 ()); - EXPECT_TRUE(message.has_default_sint32 ()); - EXPECT_TRUE(message.has_default_sint64 ()); - EXPECT_TRUE(message.has_default_fixed32 ()); - EXPECT_TRUE(message.has_default_fixed64 ()); - EXPECT_TRUE(message.has_default_sfixed32()); - EXPECT_TRUE(message.has_default_sfixed64()); - EXPECT_TRUE(message.has_default_float ()); - EXPECT_TRUE(message.has_default_double ()); - EXPECT_TRUE(message.has_default_bool ()); - EXPECT_TRUE(message.has_default_string ()); - EXPECT_TRUE(message.has_default_bytes ()); - - EXPECT_TRUE(message.has_default_nested_enum ()); - EXPECT_TRUE(message.has_default_foreign_enum()); - EXPECT_TRUE(message.has_default_import_enum ()); - - - EXPECT_EQ(401 , message.default_int32 ()); - EXPECT_EQ(402 , message.default_int64 ()); - EXPECT_EQ(403 , message.default_uint32 ()); - EXPECT_EQ(404 , message.default_uint64 ()); - EXPECT_EQ(405 , message.default_sint32 ()); - EXPECT_EQ(406 , message.default_sint64 ()); - EXPECT_EQ(407 , message.default_fixed32 ()); - EXPECT_EQ(408 , message.default_fixed64 ()); - EXPECT_EQ(409 , message.default_sfixed32()); - EXPECT_EQ(410 , message.default_sfixed64()); - EXPECT_EQ(411 , message.default_float ()); - EXPECT_EQ(412 , message.default_double ()); - EXPECT_FALSE( message.default_bool ()); - EXPECT_EQ("415", message.default_string ()); - EXPECT_EQ("416", message.default_bytes ()); - - EXPECT_EQ(unittest::TestAllTypes::FOO, message.default_nested_enum ()); - EXPECT_EQ(unittest::FOREIGN_FOO , message.default_foreign_enum()); - EXPECT_EQ(unittest_import::IMPORT_FOO, message.default_import_enum ()); - -} - -// ------------------------------------------------------------------- - -void TestUtil::ExpectClear(const unittest::TestAllTypes& message) { - // has_blah() should initially be false for all optional fields. - EXPECT_FALSE(message.has_optional_int32 ()); - EXPECT_FALSE(message.has_optional_int64 ()); - EXPECT_FALSE(message.has_optional_uint32 ()); - EXPECT_FALSE(message.has_optional_uint64 ()); - EXPECT_FALSE(message.has_optional_sint32 ()); - EXPECT_FALSE(message.has_optional_sint64 ()); - EXPECT_FALSE(message.has_optional_fixed32 ()); - EXPECT_FALSE(message.has_optional_fixed64 ()); - EXPECT_FALSE(message.has_optional_sfixed32()); - EXPECT_FALSE(message.has_optional_sfixed64()); - EXPECT_FALSE(message.has_optional_float ()); - EXPECT_FALSE(message.has_optional_double ()); - EXPECT_FALSE(message.has_optional_bool ()); - EXPECT_FALSE(message.has_optional_string ()); - EXPECT_FALSE(message.has_optional_bytes ()); - - EXPECT_FALSE(message.has_optionalgroup ()); - EXPECT_FALSE(message.has_optional_nested_message ()); - EXPECT_FALSE(message.has_optional_foreign_message ()); - EXPECT_FALSE(message.has_optional_import_message ()); - EXPECT_FALSE(message.has_optional_public_import_message()); - EXPECT_FALSE(message.has_optional_lazy_message ()); - - EXPECT_FALSE(message.has_optional_nested_enum ()); - EXPECT_FALSE(message.has_optional_foreign_enum()); - EXPECT_FALSE(message.has_optional_import_enum ()); - - EXPECT_FALSE(message.has_optional_string_piece()); - EXPECT_FALSE(message.has_optional_cord()); - - // Optional fields without defaults are set to zero or something like it. - EXPECT_EQ(0 , message.optional_int32 ()); - EXPECT_EQ(0 , message.optional_int64 ()); - EXPECT_EQ(0 , message.optional_uint32 ()); - EXPECT_EQ(0 , message.optional_uint64 ()); - EXPECT_EQ(0 , message.optional_sint32 ()); - EXPECT_EQ(0 , message.optional_sint64 ()); - EXPECT_EQ(0 , message.optional_fixed32 ()); - EXPECT_EQ(0 , message.optional_fixed64 ()); - EXPECT_EQ(0 , message.optional_sfixed32()); - EXPECT_EQ(0 , message.optional_sfixed64()); - EXPECT_EQ(0 , message.optional_float ()); - EXPECT_EQ(0 , message.optional_double ()); - EXPECT_FALSE( message.optional_bool ()); - EXPECT_EQ("" , message.optional_string ()); - EXPECT_EQ("" , message.optional_bytes ()); - - // Embedded messages should also be clear. - EXPECT_FALSE(message.optionalgroup ().has_a()); - EXPECT_FALSE(message.optional_nested_message ().has_bb()); - EXPECT_FALSE(message.optional_foreign_message ().has_c()); - EXPECT_FALSE(message.optional_import_message ().has_d()); - EXPECT_FALSE(message.optional_public_import_message().has_e()); - EXPECT_FALSE(message.optional_lazy_message ().has_bb()); - - EXPECT_EQ(0, message.optionalgroup ().a()); - EXPECT_EQ(0, message.optional_nested_message ().bb()); - EXPECT_EQ(0, message.optional_foreign_message ().c()); - EXPECT_EQ(0, message.optional_import_message ().d()); - EXPECT_EQ(0, message.optional_public_import_message().e()); - EXPECT_EQ(0, message.optional_lazy_message ().bb()); - - // Enums without defaults are set to the first value in the enum. - EXPECT_EQ(unittest::TestAllTypes::FOO, message.optional_nested_enum ()); - EXPECT_EQ(unittest::FOREIGN_FOO , message.optional_foreign_enum()); - EXPECT_EQ(unittest_import::IMPORT_FOO, message.optional_import_enum ()); - - - // Repeated fields are empty. - EXPECT_EQ(0, message.repeated_int32_size ()); - EXPECT_EQ(0, message.repeated_int64_size ()); - EXPECT_EQ(0, message.repeated_uint32_size ()); - EXPECT_EQ(0, message.repeated_uint64_size ()); - EXPECT_EQ(0, message.repeated_sint32_size ()); - EXPECT_EQ(0, message.repeated_sint64_size ()); - EXPECT_EQ(0, message.repeated_fixed32_size ()); - EXPECT_EQ(0, message.repeated_fixed64_size ()); - EXPECT_EQ(0, message.repeated_sfixed32_size()); - EXPECT_EQ(0, message.repeated_sfixed64_size()); - EXPECT_EQ(0, message.repeated_float_size ()); - EXPECT_EQ(0, message.repeated_double_size ()); - EXPECT_EQ(0, message.repeated_bool_size ()); - EXPECT_EQ(0, message.repeated_string_size ()); - EXPECT_EQ(0, message.repeated_bytes_size ()); - - EXPECT_EQ(0, message.repeatedgroup_size ()); - EXPECT_EQ(0, message.repeated_nested_message_size ()); - EXPECT_EQ(0, message.repeated_foreign_message_size()); - EXPECT_EQ(0, message.repeated_import_message_size ()); - EXPECT_EQ(0, message.repeated_lazy_message_size ()); - EXPECT_EQ(0, message.repeated_nested_enum_size ()); - EXPECT_EQ(0, message.repeated_foreign_enum_size ()); - EXPECT_EQ(0, message.repeated_import_enum_size ()); - - EXPECT_EQ(0, message.repeated_string_piece_size()); - EXPECT_EQ(0, message.repeated_cord_size()); - - // has_blah() should also be false for all default fields. - EXPECT_FALSE(message.has_default_int32 ()); - EXPECT_FALSE(message.has_default_int64 ()); - EXPECT_FALSE(message.has_default_uint32 ()); - EXPECT_FALSE(message.has_default_uint64 ()); - EXPECT_FALSE(message.has_default_sint32 ()); - EXPECT_FALSE(message.has_default_sint64 ()); - EXPECT_FALSE(message.has_default_fixed32 ()); - EXPECT_FALSE(message.has_default_fixed64 ()); - EXPECT_FALSE(message.has_default_sfixed32()); - EXPECT_FALSE(message.has_default_sfixed64()); - EXPECT_FALSE(message.has_default_float ()); - EXPECT_FALSE(message.has_default_double ()); - EXPECT_FALSE(message.has_default_bool ()); - EXPECT_FALSE(message.has_default_string ()); - EXPECT_FALSE(message.has_default_bytes ()); - - EXPECT_FALSE(message.has_default_nested_enum ()); - EXPECT_FALSE(message.has_default_foreign_enum()); - EXPECT_FALSE(message.has_default_import_enum ()); - - - // Fields with defaults have their default values (duh). - EXPECT_EQ( 41 , message.default_int32 ()); - EXPECT_EQ( 42 , message.default_int64 ()); - EXPECT_EQ( 43 , message.default_uint32 ()); - EXPECT_EQ( 44 , message.default_uint64 ()); - EXPECT_EQ(-45 , message.default_sint32 ()); - EXPECT_EQ( 46 , message.default_sint64 ()); - EXPECT_EQ( 47 , message.default_fixed32 ()); - EXPECT_EQ( 48 , message.default_fixed64 ()); - EXPECT_EQ( 49 , message.default_sfixed32()); - EXPECT_EQ(-50 , message.default_sfixed64()); - EXPECT_EQ( 51.5 , message.default_float ()); - EXPECT_EQ( 52e3 , message.default_double ()); - EXPECT_TRUE( message.default_bool ()); - EXPECT_EQ("hello", message.default_string ()); - EXPECT_EQ("world", message.default_bytes ()); - - EXPECT_EQ(unittest::TestAllTypes::BAR, message.default_nested_enum ()); - EXPECT_EQ(unittest::FOREIGN_BAR , message.default_foreign_enum()); - EXPECT_EQ(unittest_import::IMPORT_BAR, message.default_import_enum ()); - -} - -// ------------------------------------------------------------------- - -void TestUtil::ExpectRepeatedFieldsModified( - const unittest::TestAllTypes& message) { - // ModifyRepeatedFields only sets the second repeated element of each - // field. In addition to verifying this, we also verify that the first - // element and size were *not* modified. - ASSERT_EQ(2, message.repeated_int32_size ()); - ASSERT_EQ(2, message.repeated_int64_size ()); - ASSERT_EQ(2, message.repeated_uint32_size ()); - ASSERT_EQ(2, message.repeated_uint64_size ()); - ASSERT_EQ(2, message.repeated_sint32_size ()); - ASSERT_EQ(2, message.repeated_sint64_size ()); - ASSERT_EQ(2, message.repeated_fixed32_size ()); - ASSERT_EQ(2, message.repeated_fixed64_size ()); - ASSERT_EQ(2, message.repeated_sfixed32_size()); - ASSERT_EQ(2, message.repeated_sfixed64_size()); - ASSERT_EQ(2, message.repeated_float_size ()); - ASSERT_EQ(2, message.repeated_double_size ()); - ASSERT_EQ(2, message.repeated_bool_size ()); - ASSERT_EQ(2, message.repeated_string_size ()); - ASSERT_EQ(2, message.repeated_bytes_size ()); - - ASSERT_EQ(2, message.repeatedgroup_size ()); - ASSERT_EQ(2, message.repeated_nested_message_size ()); - ASSERT_EQ(2, message.repeated_foreign_message_size()); - ASSERT_EQ(2, message.repeated_import_message_size ()); - ASSERT_EQ(2, message.repeated_lazy_message_size ()); - ASSERT_EQ(2, message.repeated_nested_enum_size ()); - ASSERT_EQ(2, message.repeated_foreign_enum_size ()); - ASSERT_EQ(2, message.repeated_import_enum_size ()); - -#ifndef PROTOBUF_TEST_NO_DESCRIPTORS - ASSERT_EQ(2, message.repeated_string_piece_size()); - ASSERT_EQ(2, message.repeated_cord_size()); -#endif - - EXPECT_EQ(201 , message.repeated_int32 (0)); - EXPECT_EQ(202 , message.repeated_int64 (0)); - EXPECT_EQ(203 , message.repeated_uint32 (0)); - EXPECT_EQ(204 , message.repeated_uint64 (0)); - EXPECT_EQ(205 , message.repeated_sint32 (0)); - EXPECT_EQ(206 , message.repeated_sint64 (0)); - EXPECT_EQ(207 , message.repeated_fixed32 (0)); - EXPECT_EQ(208 , message.repeated_fixed64 (0)); - EXPECT_EQ(209 , message.repeated_sfixed32(0)); - EXPECT_EQ(210 , message.repeated_sfixed64(0)); - EXPECT_EQ(211 , message.repeated_float (0)); - EXPECT_EQ(212 , message.repeated_double (0)); - EXPECT_TRUE( message.repeated_bool (0)); - EXPECT_EQ("215", message.repeated_string (0)); - EXPECT_EQ("216", message.repeated_bytes (0)); - - EXPECT_EQ(217, message.repeatedgroup (0).a()); - EXPECT_EQ(218, message.repeated_nested_message (0).bb()); - EXPECT_EQ(219, message.repeated_foreign_message(0).c()); - EXPECT_EQ(220, message.repeated_import_message (0).d()); - EXPECT_EQ(227, message.repeated_lazy_message (0).bb()); - - EXPECT_EQ(unittest::TestAllTypes::BAR, message.repeated_nested_enum (0)); - EXPECT_EQ(unittest::FOREIGN_BAR , message.repeated_foreign_enum(0)); - EXPECT_EQ(unittest_import::IMPORT_BAR, message.repeated_import_enum (0)); - - - // Actually verify the second (modified) elements now. - EXPECT_EQ(501 , message.repeated_int32 (1)); - EXPECT_EQ(502 , message.repeated_int64 (1)); - EXPECT_EQ(503 , message.repeated_uint32 (1)); - EXPECT_EQ(504 , message.repeated_uint64 (1)); - EXPECT_EQ(505 , message.repeated_sint32 (1)); - EXPECT_EQ(506 , message.repeated_sint64 (1)); - EXPECT_EQ(507 , message.repeated_fixed32 (1)); - EXPECT_EQ(508 , message.repeated_fixed64 (1)); - EXPECT_EQ(509 , message.repeated_sfixed32(1)); - EXPECT_EQ(510 , message.repeated_sfixed64(1)); - EXPECT_EQ(511 , message.repeated_float (1)); - EXPECT_EQ(512 , message.repeated_double (1)); - EXPECT_TRUE( message.repeated_bool (1)); - EXPECT_EQ("515", message.repeated_string (1)); - EXPECT_EQ("516", message.repeated_bytes (1)); - - EXPECT_EQ(517, message.repeatedgroup (1).a()); - EXPECT_EQ(518, message.repeated_nested_message (1).bb()); - EXPECT_EQ(519, message.repeated_foreign_message(1).c()); - EXPECT_EQ(520, message.repeated_import_message (1).d()); - EXPECT_EQ(527, message.repeated_lazy_message (1).bb()); - - EXPECT_EQ(unittest::TestAllTypes::FOO, message.repeated_nested_enum (1)); - EXPECT_EQ(unittest::FOREIGN_FOO , message.repeated_foreign_enum(1)); - EXPECT_EQ(unittest_import::IMPORT_FOO, message.repeated_import_enum (1)); - -} - -// ------------------------------------------------------------------- - -void TestUtil::SetPackedFields(unittest::TestPackedTypes* message) { - message->add_packed_int32 (601); - message->add_packed_int64 (602); - message->add_packed_uint32 (603); - message->add_packed_uint64 (604); - message->add_packed_sint32 (605); - message->add_packed_sint64 (606); - message->add_packed_fixed32 (607); - message->add_packed_fixed64 (608); - message->add_packed_sfixed32(609); - message->add_packed_sfixed64(610); - message->add_packed_float (611); - message->add_packed_double (612); - message->add_packed_bool (true); - message->add_packed_enum (unittest::FOREIGN_BAR); - // add a second one of each field - message->add_packed_int32 (701); - message->add_packed_int64 (702); - message->add_packed_uint32 (703); - message->add_packed_uint64 (704); - message->add_packed_sint32 (705); - message->add_packed_sint64 (706); - message->add_packed_fixed32 (707); - message->add_packed_fixed64 (708); - message->add_packed_sfixed32(709); - message->add_packed_sfixed64(710); - message->add_packed_float (711); - message->add_packed_double (712); - message->add_packed_bool (false); - message->add_packed_enum (unittest::FOREIGN_BAZ); -} - -void TestUtil::SetUnpackedFields(unittest::TestUnpackedTypes* message) { - // The values applied here must match those of SetPackedFields. - - message->add_unpacked_int32 (601); - message->add_unpacked_int64 (602); - message->add_unpacked_uint32 (603); - message->add_unpacked_uint64 (604); - message->add_unpacked_sint32 (605); - message->add_unpacked_sint64 (606); - message->add_unpacked_fixed32 (607); - message->add_unpacked_fixed64 (608); - message->add_unpacked_sfixed32(609); - message->add_unpacked_sfixed64(610); - message->add_unpacked_float (611); - message->add_unpacked_double (612); - message->add_unpacked_bool (true); - message->add_unpacked_enum (unittest::FOREIGN_BAR); - // add a second one of each field - message->add_unpacked_int32 (701); - message->add_unpacked_int64 (702); - message->add_unpacked_uint32 (703); - message->add_unpacked_uint64 (704); - message->add_unpacked_sint32 (705); - message->add_unpacked_sint64 (706); - message->add_unpacked_fixed32 (707); - message->add_unpacked_fixed64 (708); - message->add_unpacked_sfixed32(709); - message->add_unpacked_sfixed64(710); - message->add_unpacked_float (711); - message->add_unpacked_double (712); - message->add_unpacked_bool (false); - message->add_unpacked_enum (unittest::FOREIGN_BAZ); -} - -// ------------------------------------------------------------------- - -void TestUtil::ModifyPackedFields(unittest::TestPackedTypes* message) { - message->set_packed_int32 (1, 801); - message->set_packed_int64 (1, 802); - message->set_packed_uint32 (1, 803); - message->set_packed_uint64 (1, 804); - message->set_packed_sint32 (1, 805); - message->set_packed_sint64 (1, 806); - message->set_packed_fixed32 (1, 807); - message->set_packed_fixed64 (1, 808); - message->set_packed_sfixed32(1, 809); - message->set_packed_sfixed64(1, 810); - message->set_packed_float (1, 811); - message->set_packed_double (1, 812); - message->set_packed_bool (1, true); - message->set_packed_enum (1, unittest::FOREIGN_FOO); -} - -// ------------------------------------------------------------------- - -void TestUtil::ExpectPackedFieldsSet(const unittest::TestPackedTypes& message) { - ASSERT_EQ(2, message.packed_int32_size ()); - ASSERT_EQ(2, message.packed_int64_size ()); - ASSERT_EQ(2, message.packed_uint32_size ()); - ASSERT_EQ(2, message.packed_uint64_size ()); - ASSERT_EQ(2, message.packed_sint32_size ()); - ASSERT_EQ(2, message.packed_sint64_size ()); - ASSERT_EQ(2, message.packed_fixed32_size ()); - ASSERT_EQ(2, message.packed_fixed64_size ()); - ASSERT_EQ(2, message.packed_sfixed32_size()); - ASSERT_EQ(2, message.packed_sfixed64_size()); - ASSERT_EQ(2, message.packed_float_size ()); - ASSERT_EQ(2, message.packed_double_size ()); - ASSERT_EQ(2, message.packed_bool_size ()); - ASSERT_EQ(2, message.packed_enum_size ()); - - EXPECT_EQ(601 , message.packed_int32 (0)); - EXPECT_EQ(602 , message.packed_int64 (0)); - EXPECT_EQ(603 , message.packed_uint32 (0)); - EXPECT_EQ(604 , message.packed_uint64 (0)); - EXPECT_EQ(605 , message.packed_sint32 (0)); - EXPECT_EQ(606 , message.packed_sint64 (0)); - EXPECT_EQ(607 , message.packed_fixed32 (0)); - EXPECT_EQ(608 , message.packed_fixed64 (0)); - EXPECT_EQ(609 , message.packed_sfixed32(0)); - EXPECT_EQ(610 , message.packed_sfixed64(0)); - EXPECT_EQ(611 , message.packed_float (0)); - EXPECT_EQ(612 , message.packed_double (0)); - EXPECT_TRUE( message.packed_bool (0)); - EXPECT_EQ(unittest::FOREIGN_BAR, message.packed_enum(0)); - - EXPECT_EQ(701 , message.packed_int32 (1)); - EXPECT_EQ(702 , message.packed_int64 (1)); - EXPECT_EQ(703 , message.packed_uint32 (1)); - EXPECT_EQ(704 , message.packed_uint64 (1)); - EXPECT_EQ(705 , message.packed_sint32 (1)); - EXPECT_EQ(706 , message.packed_sint64 (1)); - EXPECT_EQ(707 , message.packed_fixed32 (1)); - EXPECT_EQ(708 , message.packed_fixed64 (1)); - EXPECT_EQ(709 , message.packed_sfixed32(1)); - EXPECT_EQ(710 , message.packed_sfixed64(1)); - EXPECT_EQ(711 , message.packed_float (1)); - EXPECT_EQ(712 , message.packed_double (1)); - EXPECT_FALSE( message.packed_bool (1)); - EXPECT_EQ(unittest::FOREIGN_BAZ, message.packed_enum(1)); -} - -void TestUtil::ExpectUnpackedFieldsSet( - const unittest::TestUnpackedTypes& message) { - // The values expected here must match those of ExpectPackedFieldsSet. - - ASSERT_EQ(2, message.unpacked_int32_size ()); - ASSERT_EQ(2, message.unpacked_int64_size ()); - ASSERT_EQ(2, message.unpacked_uint32_size ()); - ASSERT_EQ(2, message.unpacked_uint64_size ()); - ASSERT_EQ(2, message.unpacked_sint32_size ()); - ASSERT_EQ(2, message.unpacked_sint64_size ()); - ASSERT_EQ(2, message.unpacked_fixed32_size ()); - ASSERT_EQ(2, message.unpacked_fixed64_size ()); - ASSERT_EQ(2, message.unpacked_sfixed32_size()); - ASSERT_EQ(2, message.unpacked_sfixed64_size()); - ASSERT_EQ(2, message.unpacked_float_size ()); - ASSERT_EQ(2, message.unpacked_double_size ()); - ASSERT_EQ(2, message.unpacked_bool_size ()); - ASSERT_EQ(2, message.unpacked_enum_size ()); - - EXPECT_EQ(601 , message.unpacked_int32 (0)); - EXPECT_EQ(602 , message.unpacked_int64 (0)); - EXPECT_EQ(603 , message.unpacked_uint32 (0)); - EXPECT_EQ(604 , message.unpacked_uint64 (0)); - EXPECT_EQ(605 , message.unpacked_sint32 (0)); - EXPECT_EQ(606 , message.unpacked_sint64 (0)); - EXPECT_EQ(607 , message.unpacked_fixed32 (0)); - EXPECT_EQ(608 , message.unpacked_fixed64 (0)); - EXPECT_EQ(609 , message.unpacked_sfixed32(0)); - EXPECT_EQ(610 , message.unpacked_sfixed64(0)); - EXPECT_EQ(611 , message.unpacked_float (0)); - EXPECT_EQ(612 , message.unpacked_double (0)); - EXPECT_TRUE( message.unpacked_bool (0)); - EXPECT_EQ(unittest::FOREIGN_BAR, message.unpacked_enum(0)); - - EXPECT_EQ(701 , message.unpacked_int32 (1)); - EXPECT_EQ(702 , message.unpacked_int64 (1)); - EXPECT_EQ(703 , message.unpacked_uint32 (1)); - EXPECT_EQ(704 , message.unpacked_uint64 (1)); - EXPECT_EQ(705 , message.unpacked_sint32 (1)); - EXPECT_EQ(706 , message.unpacked_sint64 (1)); - EXPECT_EQ(707 , message.unpacked_fixed32 (1)); - EXPECT_EQ(708 , message.unpacked_fixed64 (1)); - EXPECT_EQ(709 , message.unpacked_sfixed32(1)); - EXPECT_EQ(710 , message.unpacked_sfixed64(1)); - EXPECT_EQ(711 , message.unpacked_float (1)); - EXPECT_EQ(712 , message.unpacked_double (1)); - EXPECT_FALSE( message.unpacked_bool (1)); - EXPECT_EQ(unittest::FOREIGN_BAZ, message.unpacked_enum(1)); -} - -// ------------------------------------------------------------------- - -void TestUtil::ExpectPackedClear( - const unittest::TestPackedTypes& message) { - // Packed repeated fields are empty. - EXPECT_EQ(0, message.packed_int32_size ()); - EXPECT_EQ(0, message.packed_int64_size ()); - EXPECT_EQ(0, message.packed_uint32_size ()); - EXPECT_EQ(0, message.packed_uint64_size ()); - EXPECT_EQ(0, message.packed_sint32_size ()); - EXPECT_EQ(0, message.packed_sint64_size ()); - EXPECT_EQ(0, message.packed_fixed32_size ()); - EXPECT_EQ(0, message.packed_fixed64_size ()); - EXPECT_EQ(0, message.packed_sfixed32_size()); - EXPECT_EQ(0, message.packed_sfixed64_size()); - EXPECT_EQ(0, message.packed_float_size ()); - EXPECT_EQ(0, message.packed_double_size ()); - EXPECT_EQ(0, message.packed_bool_size ()); - EXPECT_EQ(0, message.packed_enum_size ()); -} - -// ------------------------------------------------------------------- - -void TestUtil::ExpectPackedFieldsModified( - const unittest::TestPackedTypes& message) { - // Do the same for packed repeated fields. - ASSERT_EQ(2, message.packed_int32_size ()); - ASSERT_EQ(2, message.packed_int64_size ()); - ASSERT_EQ(2, message.packed_uint32_size ()); - ASSERT_EQ(2, message.packed_uint64_size ()); - ASSERT_EQ(2, message.packed_sint32_size ()); - ASSERT_EQ(2, message.packed_sint64_size ()); - ASSERT_EQ(2, message.packed_fixed32_size ()); - ASSERT_EQ(2, message.packed_fixed64_size ()); - ASSERT_EQ(2, message.packed_sfixed32_size()); - ASSERT_EQ(2, message.packed_sfixed64_size()); - ASSERT_EQ(2, message.packed_float_size ()); - ASSERT_EQ(2, message.packed_double_size ()); - ASSERT_EQ(2, message.packed_bool_size ()); - ASSERT_EQ(2, message.packed_enum_size ()); - - EXPECT_EQ(601 , message.packed_int32 (0)); - EXPECT_EQ(602 , message.packed_int64 (0)); - EXPECT_EQ(603 , message.packed_uint32 (0)); - EXPECT_EQ(604 , message.packed_uint64 (0)); - EXPECT_EQ(605 , message.packed_sint32 (0)); - EXPECT_EQ(606 , message.packed_sint64 (0)); - EXPECT_EQ(607 , message.packed_fixed32 (0)); - EXPECT_EQ(608 , message.packed_fixed64 (0)); - EXPECT_EQ(609 , message.packed_sfixed32(0)); - EXPECT_EQ(610 , message.packed_sfixed64(0)); - EXPECT_EQ(611 , message.packed_float (0)); - EXPECT_EQ(612 , message.packed_double (0)); - EXPECT_TRUE( message.packed_bool (0)); - EXPECT_EQ(unittest::FOREIGN_BAR, message.packed_enum(0)); - // Actually verify the second (modified) elements now. - EXPECT_EQ(801 , message.packed_int32 (1)); - EXPECT_EQ(802 , message.packed_int64 (1)); - EXPECT_EQ(803 , message.packed_uint32 (1)); - EXPECT_EQ(804 , message.packed_uint64 (1)); - EXPECT_EQ(805 , message.packed_sint32 (1)); - EXPECT_EQ(806 , message.packed_sint64 (1)); - EXPECT_EQ(807 , message.packed_fixed32 (1)); - EXPECT_EQ(808 , message.packed_fixed64 (1)); - EXPECT_EQ(809 , message.packed_sfixed32(1)); - EXPECT_EQ(810 , message.packed_sfixed64(1)); - EXPECT_EQ(811 , message.packed_float (1)); - EXPECT_EQ(812 , message.packed_double (1)); - EXPECT_TRUE( message.packed_bool (1)); - EXPECT_EQ(unittest::FOREIGN_FOO, message.packed_enum(1)); -} - -// =================================================================== -// Extensions -// -// All this code is exactly equivalent to the above code except that it's -// manipulating extension fields instead of normal ones. -// -// I gave up on the 80-char limit here. Sorry. - -void TestUtil::SetAllExtensions(unittest::TestAllExtensions* message) { - message->SetExtension(unittest::optional_int32_extension , 101); - message->SetExtension(unittest::optional_int64_extension , 102); - message->SetExtension(unittest::optional_uint32_extension , 103); - message->SetExtension(unittest::optional_uint64_extension , 104); - message->SetExtension(unittest::optional_sint32_extension , 105); - message->SetExtension(unittest::optional_sint64_extension , 106); - message->SetExtension(unittest::optional_fixed32_extension , 107); - message->SetExtension(unittest::optional_fixed64_extension , 108); - message->SetExtension(unittest::optional_sfixed32_extension, 109); - message->SetExtension(unittest::optional_sfixed64_extension, 110); - message->SetExtension(unittest::optional_float_extension , 111); - message->SetExtension(unittest::optional_double_extension , 112); - message->SetExtension(unittest::optional_bool_extension , true); - message->SetExtension(unittest::optional_string_extension , "115"); - message->SetExtension(unittest::optional_bytes_extension , "116"); - - message->MutableExtension(unittest::optionalgroup_extension )->set_a(117); - message->MutableExtension(unittest::optional_nested_message_extension )->set_bb(118); - message->MutableExtension(unittest::optional_foreign_message_extension)->set_c(119); - message->MutableExtension(unittest::optional_import_message_extension )->set_d(120); - - message->SetExtension(unittest::optional_nested_enum_extension , unittest::TestAllTypes::BAZ); - message->SetExtension(unittest::optional_foreign_enum_extension, unittest::FOREIGN_BAZ ); - message->SetExtension(unittest::optional_import_enum_extension , unittest_import::IMPORT_BAZ); - - message->SetExtension(unittest::optional_string_piece_extension, "124"); - message->SetExtension(unittest::optional_cord_extension, "125"); - - message->MutableExtension(unittest::optional_public_import_message_extension)->set_e(126); - message->MutableExtension(unittest::optional_lazy_message_extension)->set_bb(127); - - // ----------------------------------------------------------------- - - message->AddExtension(unittest::repeated_int32_extension , 201); - message->AddExtension(unittest::repeated_int64_extension , 202); - message->AddExtension(unittest::repeated_uint32_extension , 203); - message->AddExtension(unittest::repeated_uint64_extension , 204); - message->AddExtension(unittest::repeated_sint32_extension , 205); - message->AddExtension(unittest::repeated_sint64_extension , 206); - message->AddExtension(unittest::repeated_fixed32_extension , 207); - message->AddExtension(unittest::repeated_fixed64_extension , 208); - message->AddExtension(unittest::repeated_sfixed32_extension, 209); - message->AddExtension(unittest::repeated_sfixed64_extension, 210); - message->AddExtension(unittest::repeated_float_extension , 211); - message->AddExtension(unittest::repeated_double_extension , 212); - message->AddExtension(unittest::repeated_bool_extension , true); - message->AddExtension(unittest::repeated_string_extension , "215"); - message->AddExtension(unittest::repeated_bytes_extension , "216"); - - message->AddExtension(unittest::repeatedgroup_extension )->set_a(217); - message->AddExtension(unittest::repeated_nested_message_extension )->set_bb(218); - message->AddExtension(unittest::repeated_foreign_message_extension)->set_c(219); - message->AddExtension(unittest::repeated_import_message_extension )->set_d(220); - message->AddExtension(unittest::repeated_lazy_message_extension )->set_bb(227); - - message->AddExtension(unittest::repeated_nested_enum_extension , unittest::TestAllTypes::BAR); - message->AddExtension(unittest::repeated_foreign_enum_extension, unittest::FOREIGN_BAR ); - message->AddExtension(unittest::repeated_import_enum_extension , unittest_import::IMPORT_BAR); - - message->AddExtension(unittest::repeated_string_piece_extension, "224"); - message->AddExtension(unittest::repeated_cord_extension, "225"); - - // Add a second one of each field. - message->AddExtension(unittest::repeated_int32_extension , 301); - message->AddExtension(unittest::repeated_int64_extension , 302); - message->AddExtension(unittest::repeated_uint32_extension , 303); - message->AddExtension(unittest::repeated_uint64_extension , 304); - message->AddExtension(unittest::repeated_sint32_extension , 305); - message->AddExtension(unittest::repeated_sint64_extension , 306); - message->AddExtension(unittest::repeated_fixed32_extension , 307); - message->AddExtension(unittest::repeated_fixed64_extension , 308); - message->AddExtension(unittest::repeated_sfixed32_extension, 309); - message->AddExtension(unittest::repeated_sfixed64_extension, 310); - message->AddExtension(unittest::repeated_float_extension , 311); - message->AddExtension(unittest::repeated_double_extension , 312); - message->AddExtension(unittest::repeated_bool_extension , false); - message->AddExtension(unittest::repeated_string_extension , "315"); - message->AddExtension(unittest::repeated_bytes_extension , "316"); - - message->AddExtension(unittest::repeatedgroup_extension )->set_a(317); - message->AddExtension(unittest::repeated_nested_message_extension )->set_bb(318); - message->AddExtension(unittest::repeated_foreign_message_extension)->set_c(319); - message->AddExtension(unittest::repeated_import_message_extension )->set_d(320); - message->AddExtension(unittest::repeated_lazy_message_extension )->set_bb(327); - - message->AddExtension(unittest::repeated_nested_enum_extension , unittest::TestAllTypes::BAZ); - message->AddExtension(unittest::repeated_foreign_enum_extension, unittest::FOREIGN_BAZ ); - message->AddExtension(unittest::repeated_import_enum_extension , unittest_import::IMPORT_BAZ); - - message->AddExtension(unittest::repeated_string_piece_extension, "324"); - message->AddExtension(unittest::repeated_cord_extension, "325"); - - // ----------------------------------------------------------------- - - message->SetExtension(unittest::default_int32_extension , 401); - message->SetExtension(unittest::default_int64_extension , 402); - message->SetExtension(unittest::default_uint32_extension , 403); - message->SetExtension(unittest::default_uint64_extension , 404); - message->SetExtension(unittest::default_sint32_extension , 405); - message->SetExtension(unittest::default_sint64_extension , 406); - message->SetExtension(unittest::default_fixed32_extension , 407); - message->SetExtension(unittest::default_fixed64_extension , 408); - message->SetExtension(unittest::default_sfixed32_extension, 409); - message->SetExtension(unittest::default_sfixed64_extension, 410); - message->SetExtension(unittest::default_float_extension , 411); - message->SetExtension(unittest::default_double_extension , 412); - message->SetExtension(unittest::default_bool_extension , false); - message->SetExtension(unittest::default_string_extension , "415"); - message->SetExtension(unittest::default_bytes_extension , "416"); - - message->SetExtension(unittest::default_nested_enum_extension , unittest::TestAllTypes::FOO); - message->SetExtension(unittest::default_foreign_enum_extension, unittest::FOREIGN_FOO ); - message->SetExtension(unittest::default_import_enum_extension , unittest_import::IMPORT_FOO); - - message->SetExtension(unittest::default_string_piece_extension, "424"); - message->SetExtension(unittest::default_cord_extension, "425"); -} - -// ------------------------------------------------------------------- - -void TestUtil::SetAllFieldsAndExtensions( - unittest::TestFieldOrderings* message) { - GOOGLE_CHECK(message); - message->set_my_int(1); - message->set_my_string("foo"); - message->set_my_float(1.0); - message->SetExtension(unittest::my_extension_int, 23); - message->SetExtension(unittest::my_extension_string, "bar"); -} - -// ------------------------------------------------------------------- - -void TestUtil::ModifyRepeatedExtensions(unittest::TestAllExtensions* message) { - message->SetExtension(unittest::repeated_int32_extension , 1, 501); - message->SetExtension(unittest::repeated_int64_extension , 1, 502); - message->SetExtension(unittest::repeated_uint32_extension , 1, 503); - message->SetExtension(unittest::repeated_uint64_extension , 1, 504); - message->SetExtension(unittest::repeated_sint32_extension , 1, 505); - message->SetExtension(unittest::repeated_sint64_extension , 1, 506); - message->SetExtension(unittest::repeated_fixed32_extension , 1, 507); - message->SetExtension(unittest::repeated_fixed64_extension , 1, 508); - message->SetExtension(unittest::repeated_sfixed32_extension, 1, 509); - message->SetExtension(unittest::repeated_sfixed64_extension, 1, 510); - message->SetExtension(unittest::repeated_float_extension , 1, 511); - message->SetExtension(unittest::repeated_double_extension , 1, 512); - message->SetExtension(unittest::repeated_bool_extension , 1, true); - message->SetExtension(unittest::repeated_string_extension , 1, "515"); - message->SetExtension(unittest::repeated_bytes_extension , 1, "516"); - - message->MutableExtension(unittest::repeatedgroup_extension , 1)->set_a(517); - message->MutableExtension(unittest::repeated_nested_message_extension , 1)->set_bb(518); - message->MutableExtension(unittest::repeated_foreign_message_extension, 1)->set_c(519); - message->MutableExtension(unittest::repeated_import_message_extension , 1)->set_d(520); - message->MutableExtension(unittest::repeated_lazy_message_extension , 1)->set_bb(527); - - message->SetExtension(unittest::repeated_nested_enum_extension , 1, unittest::TestAllTypes::FOO); - message->SetExtension(unittest::repeated_foreign_enum_extension, 1, unittest::FOREIGN_FOO ); - message->SetExtension(unittest::repeated_import_enum_extension , 1, unittest_import::IMPORT_FOO); - - message->SetExtension(unittest::repeated_string_piece_extension, 1, "524"); - message->SetExtension(unittest::repeated_cord_extension, 1, "525"); -} - -// ------------------------------------------------------------------- - -void TestUtil::ExpectAllExtensionsSet( - const unittest::TestAllExtensions& message) { - EXPECT_TRUE(message.HasExtension(unittest::optional_int32_extension )); - EXPECT_TRUE(message.HasExtension(unittest::optional_int64_extension )); - EXPECT_TRUE(message.HasExtension(unittest::optional_uint32_extension )); - EXPECT_TRUE(message.HasExtension(unittest::optional_uint64_extension )); - EXPECT_TRUE(message.HasExtension(unittest::optional_sint32_extension )); - EXPECT_TRUE(message.HasExtension(unittest::optional_sint64_extension )); - EXPECT_TRUE(message.HasExtension(unittest::optional_fixed32_extension )); - EXPECT_TRUE(message.HasExtension(unittest::optional_fixed64_extension )); - EXPECT_TRUE(message.HasExtension(unittest::optional_sfixed32_extension)); - EXPECT_TRUE(message.HasExtension(unittest::optional_sfixed64_extension)); - EXPECT_TRUE(message.HasExtension(unittest::optional_float_extension )); - EXPECT_TRUE(message.HasExtension(unittest::optional_double_extension )); - EXPECT_TRUE(message.HasExtension(unittest::optional_bool_extension )); - EXPECT_TRUE(message.HasExtension(unittest::optional_string_extension )); - EXPECT_TRUE(message.HasExtension(unittest::optional_bytes_extension )); - - EXPECT_TRUE(message.HasExtension(unittest::optionalgroup_extension )); - EXPECT_TRUE(message.HasExtension(unittest::optional_nested_message_extension )); - EXPECT_TRUE(message.HasExtension(unittest::optional_foreign_message_extension )); - EXPECT_TRUE(message.HasExtension(unittest::optional_import_message_extension )); - EXPECT_TRUE(message.HasExtension(unittest::optional_public_import_message_extension)); - EXPECT_TRUE(message.HasExtension(unittest::optional_lazy_message_extension )); - - EXPECT_TRUE(message.GetExtension(unittest::optionalgroup_extension ).has_a()); - EXPECT_TRUE(message.GetExtension(unittest::optional_nested_message_extension ).has_bb()); - EXPECT_TRUE(message.GetExtension(unittest::optional_foreign_message_extension ).has_c()); - EXPECT_TRUE(message.GetExtension(unittest::optional_import_message_extension ).has_d()); - EXPECT_TRUE(message.GetExtension(unittest::optional_public_import_message_extension).has_e()); - EXPECT_TRUE(message.GetExtension(unittest::optional_lazy_message_extension ).has_bb()); - - EXPECT_TRUE(message.HasExtension(unittest::optional_nested_enum_extension )); - EXPECT_TRUE(message.HasExtension(unittest::optional_foreign_enum_extension)); - EXPECT_TRUE(message.HasExtension(unittest::optional_import_enum_extension )); - - EXPECT_TRUE(message.HasExtension(unittest::optional_string_piece_extension)); - EXPECT_TRUE(message.HasExtension(unittest::optional_cord_extension)); - - EXPECT_EQ(101 , message.GetExtension(unittest::optional_int32_extension )); - EXPECT_EQ(102 , message.GetExtension(unittest::optional_int64_extension )); - EXPECT_EQ(103 , message.GetExtension(unittest::optional_uint32_extension )); - EXPECT_EQ(104 , message.GetExtension(unittest::optional_uint64_extension )); - EXPECT_EQ(105 , message.GetExtension(unittest::optional_sint32_extension )); - EXPECT_EQ(106 , message.GetExtension(unittest::optional_sint64_extension )); - EXPECT_EQ(107 , message.GetExtension(unittest::optional_fixed32_extension )); - EXPECT_EQ(108 , message.GetExtension(unittest::optional_fixed64_extension )); - EXPECT_EQ(109 , message.GetExtension(unittest::optional_sfixed32_extension)); - EXPECT_EQ(110 , message.GetExtension(unittest::optional_sfixed64_extension)); - EXPECT_EQ(111 , message.GetExtension(unittest::optional_float_extension )); - EXPECT_EQ(112 , message.GetExtension(unittest::optional_double_extension )); - EXPECT_TRUE( message.GetExtension(unittest::optional_bool_extension )); - EXPECT_EQ("115", message.GetExtension(unittest::optional_string_extension )); - EXPECT_EQ("116", message.GetExtension(unittest::optional_bytes_extension )); - - EXPECT_EQ(117, message.GetExtension(unittest::optionalgroup_extension ).a()); - EXPECT_EQ(118, message.GetExtension(unittest::optional_nested_message_extension ).bb()); - EXPECT_EQ(119, message.GetExtension(unittest::optional_foreign_message_extension).c()); - EXPECT_EQ(120, message.GetExtension(unittest::optional_import_message_extension ).d()); - - EXPECT_EQ(unittest::TestAllTypes::BAZ, message.GetExtension(unittest::optional_nested_enum_extension )); - EXPECT_EQ(unittest::FOREIGN_BAZ , message.GetExtension(unittest::optional_foreign_enum_extension)); - EXPECT_EQ(unittest_import::IMPORT_BAZ, message.GetExtension(unittest::optional_import_enum_extension )); - - EXPECT_EQ("124", message.GetExtension(unittest::optional_string_piece_extension)); - EXPECT_EQ("125", message.GetExtension(unittest::optional_cord_extension)); - EXPECT_EQ(126, message.GetExtension(unittest::optional_public_import_message_extension ).e()); - EXPECT_EQ(127, message.GetExtension(unittest::optional_lazy_message_extension).bb()); - - // ----------------------------------------------------------------- - - ASSERT_EQ(2, message.ExtensionSize(unittest::repeated_int32_extension )); - ASSERT_EQ(2, message.ExtensionSize(unittest::repeated_int64_extension )); - ASSERT_EQ(2, message.ExtensionSize(unittest::repeated_uint32_extension )); - ASSERT_EQ(2, message.ExtensionSize(unittest::repeated_uint64_extension )); - ASSERT_EQ(2, message.ExtensionSize(unittest::repeated_sint32_extension )); - ASSERT_EQ(2, message.ExtensionSize(unittest::repeated_sint64_extension )); - ASSERT_EQ(2, message.ExtensionSize(unittest::repeated_fixed32_extension )); - ASSERT_EQ(2, message.ExtensionSize(unittest::repeated_fixed64_extension )); - ASSERT_EQ(2, message.ExtensionSize(unittest::repeated_sfixed32_extension)); - ASSERT_EQ(2, message.ExtensionSize(unittest::repeated_sfixed64_extension)); - ASSERT_EQ(2, message.ExtensionSize(unittest::repeated_float_extension )); - ASSERT_EQ(2, message.ExtensionSize(unittest::repeated_double_extension )); - ASSERT_EQ(2, message.ExtensionSize(unittest::repeated_bool_extension )); - ASSERT_EQ(2, message.ExtensionSize(unittest::repeated_string_extension )); - ASSERT_EQ(2, message.ExtensionSize(unittest::repeated_bytes_extension )); - - ASSERT_EQ(2, message.ExtensionSize(unittest::repeatedgroup_extension )); - ASSERT_EQ(2, message.ExtensionSize(unittest::repeated_nested_message_extension )); - ASSERT_EQ(2, message.ExtensionSize(unittest::repeated_foreign_message_extension)); - ASSERT_EQ(2, message.ExtensionSize(unittest::repeated_import_message_extension )); - ASSERT_EQ(2, message.ExtensionSize(unittest::repeated_lazy_message_extension )); - ASSERT_EQ(2, message.ExtensionSize(unittest::repeated_nested_enum_extension )); - ASSERT_EQ(2, message.ExtensionSize(unittest::repeated_foreign_enum_extension )); - ASSERT_EQ(2, message.ExtensionSize(unittest::repeated_import_enum_extension )); - - ASSERT_EQ(2, message.ExtensionSize(unittest::repeated_string_piece_extension)); - ASSERT_EQ(2, message.ExtensionSize(unittest::repeated_cord_extension)); - - EXPECT_EQ(201 , message.GetExtension(unittest::repeated_int32_extension , 0)); - EXPECT_EQ(202 , message.GetExtension(unittest::repeated_int64_extension , 0)); - EXPECT_EQ(203 , message.GetExtension(unittest::repeated_uint32_extension , 0)); - EXPECT_EQ(204 , message.GetExtension(unittest::repeated_uint64_extension , 0)); - EXPECT_EQ(205 , message.GetExtension(unittest::repeated_sint32_extension , 0)); - EXPECT_EQ(206 , message.GetExtension(unittest::repeated_sint64_extension , 0)); - EXPECT_EQ(207 , message.GetExtension(unittest::repeated_fixed32_extension , 0)); - EXPECT_EQ(208 , message.GetExtension(unittest::repeated_fixed64_extension , 0)); - EXPECT_EQ(209 , message.GetExtension(unittest::repeated_sfixed32_extension, 0)); - EXPECT_EQ(210 , message.GetExtension(unittest::repeated_sfixed64_extension, 0)); - EXPECT_EQ(211 , message.GetExtension(unittest::repeated_float_extension , 0)); - EXPECT_EQ(212 , message.GetExtension(unittest::repeated_double_extension , 0)); - EXPECT_TRUE( message.GetExtension(unittest::repeated_bool_extension , 0)); - EXPECT_EQ("215", message.GetExtension(unittest::repeated_string_extension , 0)); - EXPECT_EQ("216", message.GetExtension(unittest::repeated_bytes_extension , 0)); - - EXPECT_EQ(217, message.GetExtension(unittest::repeatedgroup_extension , 0).a()); - EXPECT_EQ(218, message.GetExtension(unittest::repeated_nested_message_extension , 0).bb()); - EXPECT_EQ(219, message.GetExtension(unittest::repeated_foreign_message_extension, 0).c()); - EXPECT_EQ(220, message.GetExtension(unittest::repeated_import_message_extension , 0).d()); - EXPECT_EQ(227, message.GetExtension(unittest::repeated_lazy_message_extension , 0).bb()); - - EXPECT_EQ(unittest::TestAllTypes::BAR, message.GetExtension(unittest::repeated_nested_enum_extension , 0)); - EXPECT_EQ(unittest::FOREIGN_BAR , message.GetExtension(unittest::repeated_foreign_enum_extension, 0)); - EXPECT_EQ(unittest_import::IMPORT_BAR, message.GetExtension(unittest::repeated_import_enum_extension , 0)); - - EXPECT_EQ("224", message.GetExtension(unittest::repeated_string_piece_extension, 0)); - EXPECT_EQ("225", message.GetExtension(unittest::repeated_cord_extension, 0)); - - EXPECT_EQ(301 , message.GetExtension(unittest::repeated_int32_extension , 1)); - EXPECT_EQ(302 , message.GetExtension(unittest::repeated_int64_extension , 1)); - EXPECT_EQ(303 , message.GetExtension(unittest::repeated_uint32_extension , 1)); - EXPECT_EQ(304 , message.GetExtension(unittest::repeated_uint64_extension , 1)); - EXPECT_EQ(305 , message.GetExtension(unittest::repeated_sint32_extension , 1)); - EXPECT_EQ(306 , message.GetExtension(unittest::repeated_sint64_extension , 1)); - EXPECT_EQ(307 , message.GetExtension(unittest::repeated_fixed32_extension , 1)); - EXPECT_EQ(308 , message.GetExtension(unittest::repeated_fixed64_extension , 1)); - EXPECT_EQ(309 , message.GetExtension(unittest::repeated_sfixed32_extension, 1)); - EXPECT_EQ(310 , message.GetExtension(unittest::repeated_sfixed64_extension, 1)); - EXPECT_EQ(311 , message.GetExtension(unittest::repeated_float_extension , 1)); - EXPECT_EQ(312 , message.GetExtension(unittest::repeated_double_extension , 1)); - EXPECT_FALSE( message.GetExtension(unittest::repeated_bool_extension , 1)); - EXPECT_EQ("315", message.GetExtension(unittest::repeated_string_extension , 1)); - EXPECT_EQ("316", message.GetExtension(unittest::repeated_bytes_extension , 1)); - - EXPECT_EQ(317, message.GetExtension(unittest::repeatedgroup_extension , 1).a()); - EXPECT_EQ(318, message.GetExtension(unittest::repeated_nested_message_extension , 1).bb()); - EXPECT_EQ(319, message.GetExtension(unittest::repeated_foreign_message_extension, 1).c()); - EXPECT_EQ(320, message.GetExtension(unittest::repeated_import_message_extension , 1).d()); - EXPECT_EQ(327, message.GetExtension(unittest::repeated_lazy_message_extension , 1).bb()); - - EXPECT_EQ(unittest::TestAllTypes::BAZ, message.GetExtension(unittest::repeated_nested_enum_extension , 1)); - EXPECT_EQ(unittest::FOREIGN_BAZ , message.GetExtension(unittest::repeated_foreign_enum_extension, 1)); - EXPECT_EQ(unittest_import::IMPORT_BAZ, message.GetExtension(unittest::repeated_import_enum_extension , 1)); - - EXPECT_EQ("324", message.GetExtension(unittest::repeated_string_piece_extension, 1)); - EXPECT_EQ("325", message.GetExtension(unittest::repeated_cord_extension, 1)); - - // ----------------------------------------------------------------- - - EXPECT_TRUE(message.HasExtension(unittest::default_int32_extension )); - EXPECT_TRUE(message.HasExtension(unittest::default_int64_extension )); - EXPECT_TRUE(message.HasExtension(unittest::default_uint32_extension )); - EXPECT_TRUE(message.HasExtension(unittest::default_uint64_extension )); - EXPECT_TRUE(message.HasExtension(unittest::default_sint32_extension )); - EXPECT_TRUE(message.HasExtension(unittest::default_sint64_extension )); - EXPECT_TRUE(message.HasExtension(unittest::default_fixed32_extension )); - EXPECT_TRUE(message.HasExtension(unittest::default_fixed64_extension )); - EXPECT_TRUE(message.HasExtension(unittest::default_sfixed32_extension)); - EXPECT_TRUE(message.HasExtension(unittest::default_sfixed64_extension)); - EXPECT_TRUE(message.HasExtension(unittest::default_float_extension )); - EXPECT_TRUE(message.HasExtension(unittest::default_double_extension )); - EXPECT_TRUE(message.HasExtension(unittest::default_bool_extension )); - EXPECT_TRUE(message.HasExtension(unittest::default_string_extension )); - EXPECT_TRUE(message.HasExtension(unittest::default_bytes_extension )); - - EXPECT_TRUE(message.HasExtension(unittest::default_nested_enum_extension )); - EXPECT_TRUE(message.HasExtension(unittest::default_foreign_enum_extension)); - EXPECT_TRUE(message.HasExtension(unittest::default_import_enum_extension )); - - EXPECT_TRUE(message.HasExtension(unittest::default_string_piece_extension)); - EXPECT_TRUE(message.HasExtension(unittest::default_cord_extension)); - - EXPECT_EQ(401 , message.GetExtension(unittest::default_int32_extension )); - EXPECT_EQ(402 , message.GetExtension(unittest::default_int64_extension )); - EXPECT_EQ(403 , message.GetExtension(unittest::default_uint32_extension )); - EXPECT_EQ(404 , message.GetExtension(unittest::default_uint64_extension )); - EXPECT_EQ(405 , message.GetExtension(unittest::default_sint32_extension )); - EXPECT_EQ(406 , message.GetExtension(unittest::default_sint64_extension )); - EXPECT_EQ(407 , message.GetExtension(unittest::default_fixed32_extension )); - EXPECT_EQ(408 , message.GetExtension(unittest::default_fixed64_extension )); - EXPECT_EQ(409 , message.GetExtension(unittest::default_sfixed32_extension)); - EXPECT_EQ(410 , message.GetExtension(unittest::default_sfixed64_extension)); - EXPECT_EQ(411 , message.GetExtension(unittest::default_float_extension )); - EXPECT_EQ(412 , message.GetExtension(unittest::default_double_extension )); - EXPECT_FALSE( message.GetExtension(unittest::default_bool_extension )); - EXPECT_EQ("415", message.GetExtension(unittest::default_string_extension )); - EXPECT_EQ("416", message.GetExtension(unittest::default_bytes_extension )); - - EXPECT_EQ(unittest::TestAllTypes::FOO, message.GetExtension(unittest::default_nested_enum_extension )); - EXPECT_EQ(unittest::FOREIGN_FOO , message.GetExtension(unittest::default_foreign_enum_extension)); - EXPECT_EQ(unittest_import::IMPORT_FOO, message.GetExtension(unittest::default_import_enum_extension )); - - EXPECT_EQ("424", message.GetExtension(unittest::default_string_piece_extension)); - EXPECT_EQ("425", message.GetExtension(unittest::default_cord_extension)); -} - -// ------------------------------------------------------------------- - -void TestUtil::ExpectExtensionsClear( - const unittest::TestAllExtensions& message) { - string serialized; - ASSERT_TRUE(message.SerializeToString(&serialized)); - EXPECT_EQ("", serialized); - EXPECT_EQ(0, message.ByteSize()); - - // has_blah() should initially be false for all optional fields. - EXPECT_FALSE(message.HasExtension(unittest::optional_int32_extension )); - EXPECT_FALSE(message.HasExtension(unittest::optional_int64_extension )); - EXPECT_FALSE(message.HasExtension(unittest::optional_uint32_extension )); - EXPECT_FALSE(message.HasExtension(unittest::optional_uint64_extension )); - EXPECT_FALSE(message.HasExtension(unittest::optional_sint32_extension )); - EXPECT_FALSE(message.HasExtension(unittest::optional_sint64_extension )); - EXPECT_FALSE(message.HasExtension(unittest::optional_fixed32_extension )); - EXPECT_FALSE(message.HasExtension(unittest::optional_fixed64_extension )); - EXPECT_FALSE(message.HasExtension(unittest::optional_sfixed32_extension)); - EXPECT_FALSE(message.HasExtension(unittest::optional_sfixed64_extension)); - EXPECT_FALSE(message.HasExtension(unittest::optional_float_extension )); - EXPECT_FALSE(message.HasExtension(unittest::optional_double_extension )); - EXPECT_FALSE(message.HasExtension(unittest::optional_bool_extension )); - EXPECT_FALSE(message.HasExtension(unittest::optional_string_extension )); - EXPECT_FALSE(message.HasExtension(unittest::optional_bytes_extension )); - - EXPECT_FALSE(message.HasExtension(unittest::optionalgroup_extension )); - EXPECT_FALSE(message.HasExtension(unittest::optional_nested_message_extension )); - EXPECT_FALSE(message.HasExtension(unittest::optional_foreign_message_extension )); - EXPECT_FALSE(message.HasExtension(unittest::optional_import_message_extension )); - EXPECT_FALSE(message.HasExtension(unittest::optional_public_import_message_extension)); - EXPECT_FALSE(message.HasExtension(unittest::optional_lazy_message_extension )); - - EXPECT_FALSE(message.HasExtension(unittest::optional_nested_enum_extension )); - EXPECT_FALSE(message.HasExtension(unittest::optional_foreign_enum_extension)); - EXPECT_FALSE(message.HasExtension(unittest::optional_import_enum_extension )); - - EXPECT_FALSE(message.HasExtension(unittest::optional_string_piece_extension)); - EXPECT_FALSE(message.HasExtension(unittest::optional_cord_extension)); - - // Optional fields without defaults are set to zero or something like it. - EXPECT_EQ(0 , message.GetExtension(unittest::optional_int32_extension )); - EXPECT_EQ(0 , message.GetExtension(unittest::optional_int64_extension )); - EXPECT_EQ(0 , message.GetExtension(unittest::optional_uint32_extension )); - EXPECT_EQ(0 , message.GetExtension(unittest::optional_uint64_extension )); - EXPECT_EQ(0 , message.GetExtension(unittest::optional_sint32_extension )); - EXPECT_EQ(0 , message.GetExtension(unittest::optional_sint64_extension )); - EXPECT_EQ(0 , message.GetExtension(unittest::optional_fixed32_extension )); - EXPECT_EQ(0 , message.GetExtension(unittest::optional_fixed64_extension )); - EXPECT_EQ(0 , message.GetExtension(unittest::optional_sfixed32_extension)); - EXPECT_EQ(0 , message.GetExtension(unittest::optional_sfixed64_extension)); - EXPECT_EQ(0 , message.GetExtension(unittest::optional_float_extension )); - EXPECT_EQ(0 , message.GetExtension(unittest::optional_double_extension )); - EXPECT_FALSE( message.GetExtension(unittest::optional_bool_extension )); - EXPECT_EQ("" , message.GetExtension(unittest::optional_string_extension )); - EXPECT_EQ("" , message.GetExtension(unittest::optional_bytes_extension )); - - // Embedded messages should also be clear. - EXPECT_FALSE(message.GetExtension(unittest::optionalgroup_extension ).has_a()); - EXPECT_FALSE(message.GetExtension(unittest::optional_nested_message_extension ).has_bb()); - EXPECT_FALSE(message.GetExtension(unittest::optional_foreign_message_extension ).has_c()); - EXPECT_FALSE(message.GetExtension(unittest::optional_import_message_extension ).has_d()); - EXPECT_FALSE(message.GetExtension(unittest::optional_public_import_message_extension).has_e()); - EXPECT_FALSE(message.GetExtension(unittest::optional_lazy_message_extension ).has_bb()); - - EXPECT_EQ(0, message.GetExtension(unittest::optionalgroup_extension ).a()); - EXPECT_EQ(0, message.GetExtension(unittest::optional_nested_message_extension ).bb()); - EXPECT_EQ(0, message.GetExtension(unittest::optional_foreign_message_extension ).c()); - EXPECT_EQ(0, message.GetExtension(unittest::optional_import_message_extension ).d()); - EXPECT_EQ(0, message.GetExtension(unittest::optional_public_import_message_extension).e()); - EXPECT_EQ(0, message.GetExtension(unittest::optional_lazy_message_extension ).bb()); - - // Enums without defaults are set to the first value in the enum. - EXPECT_EQ(unittest::TestAllTypes::FOO, message.GetExtension(unittest::optional_nested_enum_extension )); - EXPECT_EQ(unittest::FOREIGN_FOO , message.GetExtension(unittest::optional_foreign_enum_extension)); - EXPECT_EQ(unittest_import::IMPORT_FOO, message.GetExtension(unittest::optional_import_enum_extension )); - - EXPECT_EQ("", message.GetExtension(unittest::optional_string_piece_extension)); - EXPECT_EQ("", message.GetExtension(unittest::optional_cord_extension)); - - // Repeated fields are empty. - EXPECT_EQ(0, message.ExtensionSize(unittest::repeated_int32_extension )); - EXPECT_EQ(0, message.ExtensionSize(unittest::repeated_int64_extension )); - EXPECT_EQ(0, message.ExtensionSize(unittest::repeated_uint32_extension )); - EXPECT_EQ(0, message.ExtensionSize(unittest::repeated_uint64_extension )); - EXPECT_EQ(0, message.ExtensionSize(unittest::repeated_sint32_extension )); - EXPECT_EQ(0, message.ExtensionSize(unittest::repeated_sint64_extension )); - EXPECT_EQ(0, message.ExtensionSize(unittest::repeated_fixed32_extension )); - EXPECT_EQ(0, message.ExtensionSize(unittest::repeated_fixed64_extension )); - EXPECT_EQ(0, message.ExtensionSize(unittest::repeated_sfixed32_extension)); - EXPECT_EQ(0, message.ExtensionSize(unittest::repeated_sfixed64_extension)); - EXPECT_EQ(0, message.ExtensionSize(unittest::repeated_float_extension )); - EXPECT_EQ(0, message.ExtensionSize(unittest::repeated_double_extension )); - EXPECT_EQ(0, message.ExtensionSize(unittest::repeated_bool_extension )); - EXPECT_EQ(0, message.ExtensionSize(unittest::repeated_string_extension )); - EXPECT_EQ(0, message.ExtensionSize(unittest::repeated_bytes_extension )); - - EXPECT_EQ(0, message.ExtensionSize(unittest::repeatedgroup_extension )); - EXPECT_EQ(0, message.ExtensionSize(unittest::repeated_nested_message_extension )); - EXPECT_EQ(0, message.ExtensionSize(unittest::repeated_foreign_message_extension)); - EXPECT_EQ(0, message.ExtensionSize(unittest::repeated_import_message_extension )); - EXPECT_EQ(0, message.ExtensionSize(unittest::repeated_lazy_message_extension )); - EXPECT_EQ(0, message.ExtensionSize(unittest::repeated_nested_enum_extension )); - EXPECT_EQ(0, message.ExtensionSize(unittest::repeated_foreign_enum_extension )); - EXPECT_EQ(0, message.ExtensionSize(unittest::repeated_import_enum_extension )); - - EXPECT_EQ(0, message.ExtensionSize(unittest::repeated_string_piece_extension)); - EXPECT_EQ(0, message.ExtensionSize(unittest::repeated_cord_extension)); - - // has_blah() should also be false for all default fields. - EXPECT_FALSE(message.HasExtension(unittest::default_int32_extension )); - EXPECT_FALSE(message.HasExtension(unittest::default_int64_extension )); - EXPECT_FALSE(message.HasExtension(unittest::default_uint32_extension )); - EXPECT_FALSE(message.HasExtension(unittest::default_uint64_extension )); - EXPECT_FALSE(message.HasExtension(unittest::default_sint32_extension )); - EXPECT_FALSE(message.HasExtension(unittest::default_sint64_extension )); - EXPECT_FALSE(message.HasExtension(unittest::default_fixed32_extension )); - EXPECT_FALSE(message.HasExtension(unittest::default_fixed64_extension )); - EXPECT_FALSE(message.HasExtension(unittest::default_sfixed32_extension)); - EXPECT_FALSE(message.HasExtension(unittest::default_sfixed64_extension)); - EXPECT_FALSE(message.HasExtension(unittest::default_float_extension )); - EXPECT_FALSE(message.HasExtension(unittest::default_double_extension )); - EXPECT_FALSE(message.HasExtension(unittest::default_bool_extension )); - EXPECT_FALSE(message.HasExtension(unittest::default_string_extension )); - EXPECT_FALSE(message.HasExtension(unittest::default_bytes_extension )); - - EXPECT_FALSE(message.HasExtension(unittest::default_nested_enum_extension )); - EXPECT_FALSE(message.HasExtension(unittest::default_foreign_enum_extension)); - EXPECT_FALSE(message.HasExtension(unittest::default_import_enum_extension )); - - EXPECT_FALSE(message.HasExtension(unittest::default_string_piece_extension)); - EXPECT_FALSE(message.HasExtension(unittest::default_cord_extension)); - - // Fields with defaults have their default values (duh). - EXPECT_EQ( 41 , message.GetExtension(unittest::default_int32_extension )); - EXPECT_EQ( 42 , message.GetExtension(unittest::default_int64_extension )); - EXPECT_EQ( 43 , message.GetExtension(unittest::default_uint32_extension )); - EXPECT_EQ( 44 , message.GetExtension(unittest::default_uint64_extension )); - EXPECT_EQ(-45 , message.GetExtension(unittest::default_sint32_extension )); - EXPECT_EQ( 46 , message.GetExtension(unittest::default_sint64_extension )); - EXPECT_EQ( 47 , message.GetExtension(unittest::default_fixed32_extension )); - EXPECT_EQ( 48 , message.GetExtension(unittest::default_fixed64_extension )); - EXPECT_EQ( 49 , message.GetExtension(unittest::default_sfixed32_extension)); - EXPECT_EQ(-50 , message.GetExtension(unittest::default_sfixed64_extension)); - EXPECT_EQ( 51.5 , message.GetExtension(unittest::default_float_extension )); - EXPECT_EQ( 52e3 , message.GetExtension(unittest::default_double_extension )); - EXPECT_TRUE( message.GetExtension(unittest::default_bool_extension )); - EXPECT_EQ("hello", message.GetExtension(unittest::default_string_extension )); - EXPECT_EQ("world", message.GetExtension(unittest::default_bytes_extension )); - - EXPECT_EQ(unittest::TestAllTypes::BAR, message.GetExtension(unittest::default_nested_enum_extension )); - EXPECT_EQ(unittest::FOREIGN_BAR , message.GetExtension(unittest::default_foreign_enum_extension)); - EXPECT_EQ(unittest_import::IMPORT_BAR, message.GetExtension(unittest::default_import_enum_extension )); - - EXPECT_EQ("abc", message.GetExtension(unittest::default_string_piece_extension)); - EXPECT_EQ("123", message.GetExtension(unittest::default_cord_extension)); -} - -// ------------------------------------------------------------------- - -void TestUtil::ExpectRepeatedExtensionsModified( - const unittest::TestAllExtensions& message) { - // ModifyRepeatedFields only sets the second repeated element of each - // field. In addition to verifying this, we also verify that the first - // element and size were *not* modified. - ASSERT_EQ(2, message.ExtensionSize(unittest::repeated_int32_extension )); - ASSERT_EQ(2, message.ExtensionSize(unittest::repeated_int64_extension )); - ASSERT_EQ(2, message.ExtensionSize(unittest::repeated_uint32_extension )); - ASSERT_EQ(2, message.ExtensionSize(unittest::repeated_uint64_extension )); - ASSERT_EQ(2, message.ExtensionSize(unittest::repeated_sint32_extension )); - ASSERT_EQ(2, message.ExtensionSize(unittest::repeated_sint64_extension )); - ASSERT_EQ(2, message.ExtensionSize(unittest::repeated_fixed32_extension )); - ASSERT_EQ(2, message.ExtensionSize(unittest::repeated_fixed64_extension )); - ASSERT_EQ(2, message.ExtensionSize(unittest::repeated_sfixed32_extension)); - ASSERT_EQ(2, message.ExtensionSize(unittest::repeated_sfixed64_extension)); - ASSERT_EQ(2, message.ExtensionSize(unittest::repeated_float_extension )); - ASSERT_EQ(2, message.ExtensionSize(unittest::repeated_double_extension )); - ASSERT_EQ(2, message.ExtensionSize(unittest::repeated_bool_extension )); - ASSERT_EQ(2, message.ExtensionSize(unittest::repeated_string_extension )); - ASSERT_EQ(2, message.ExtensionSize(unittest::repeated_bytes_extension )); - - ASSERT_EQ(2, message.ExtensionSize(unittest::repeatedgroup_extension )); - ASSERT_EQ(2, message.ExtensionSize(unittest::repeated_nested_message_extension )); - ASSERT_EQ(2, message.ExtensionSize(unittest::repeated_foreign_message_extension)); - ASSERT_EQ(2, message.ExtensionSize(unittest::repeated_import_message_extension )); - ASSERT_EQ(2, message.ExtensionSize(unittest::repeated_lazy_message_extension )); - ASSERT_EQ(2, message.ExtensionSize(unittest::repeated_nested_enum_extension )); - ASSERT_EQ(2, message.ExtensionSize(unittest::repeated_foreign_enum_extension )); - ASSERT_EQ(2, message.ExtensionSize(unittest::repeated_import_enum_extension )); - - ASSERT_EQ(2, message.ExtensionSize(unittest::repeated_string_piece_extension)); - ASSERT_EQ(2, message.ExtensionSize(unittest::repeated_cord_extension)); - - EXPECT_EQ(201 , message.GetExtension(unittest::repeated_int32_extension , 0)); - EXPECT_EQ(202 , message.GetExtension(unittest::repeated_int64_extension , 0)); - EXPECT_EQ(203 , message.GetExtension(unittest::repeated_uint32_extension , 0)); - EXPECT_EQ(204 , message.GetExtension(unittest::repeated_uint64_extension , 0)); - EXPECT_EQ(205 , message.GetExtension(unittest::repeated_sint32_extension , 0)); - EXPECT_EQ(206 , message.GetExtension(unittest::repeated_sint64_extension , 0)); - EXPECT_EQ(207 , message.GetExtension(unittest::repeated_fixed32_extension , 0)); - EXPECT_EQ(208 , message.GetExtension(unittest::repeated_fixed64_extension , 0)); - EXPECT_EQ(209 , message.GetExtension(unittest::repeated_sfixed32_extension, 0)); - EXPECT_EQ(210 , message.GetExtension(unittest::repeated_sfixed64_extension, 0)); - EXPECT_EQ(211 , message.GetExtension(unittest::repeated_float_extension , 0)); - EXPECT_EQ(212 , message.GetExtension(unittest::repeated_double_extension , 0)); - EXPECT_TRUE( message.GetExtension(unittest::repeated_bool_extension , 0)); - EXPECT_EQ("215", message.GetExtension(unittest::repeated_string_extension , 0)); - EXPECT_EQ("216", message.GetExtension(unittest::repeated_bytes_extension , 0)); - - EXPECT_EQ(217, message.GetExtension(unittest::repeatedgroup_extension , 0).a()); - EXPECT_EQ(218, message.GetExtension(unittest::repeated_nested_message_extension , 0).bb()); - EXPECT_EQ(219, message.GetExtension(unittest::repeated_foreign_message_extension, 0).c()); - EXPECT_EQ(220, message.GetExtension(unittest::repeated_import_message_extension , 0).d()); - EXPECT_EQ(227, message.GetExtension(unittest::repeated_lazy_message_extension , 0).bb()); - - EXPECT_EQ(unittest::TestAllTypes::BAR, message.GetExtension(unittest::repeated_nested_enum_extension , 0)); - EXPECT_EQ(unittest::FOREIGN_BAR , message.GetExtension(unittest::repeated_foreign_enum_extension, 0)); - EXPECT_EQ(unittest_import::IMPORT_BAR, message.GetExtension(unittest::repeated_import_enum_extension , 0)); - - EXPECT_EQ("224", message.GetExtension(unittest::repeated_string_piece_extension, 0)); - EXPECT_EQ("225", message.GetExtension(unittest::repeated_cord_extension, 0)); - - // Actually verify the second (modified) elements now. - EXPECT_EQ(501 , message.GetExtension(unittest::repeated_int32_extension , 1)); - EXPECT_EQ(502 , message.GetExtension(unittest::repeated_int64_extension , 1)); - EXPECT_EQ(503 , message.GetExtension(unittest::repeated_uint32_extension , 1)); - EXPECT_EQ(504 , message.GetExtension(unittest::repeated_uint64_extension , 1)); - EXPECT_EQ(505 , message.GetExtension(unittest::repeated_sint32_extension , 1)); - EXPECT_EQ(506 , message.GetExtension(unittest::repeated_sint64_extension , 1)); - EXPECT_EQ(507 , message.GetExtension(unittest::repeated_fixed32_extension , 1)); - EXPECT_EQ(508 , message.GetExtension(unittest::repeated_fixed64_extension , 1)); - EXPECT_EQ(509 , message.GetExtension(unittest::repeated_sfixed32_extension, 1)); - EXPECT_EQ(510 , message.GetExtension(unittest::repeated_sfixed64_extension, 1)); - EXPECT_EQ(511 , message.GetExtension(unittest::repeated_float_extension , 1)); - EXPECT_EQ(512 , message.GetExtension(unittest::repeated_double_extension , 1)); - EXPECT_TRUE( message.GetExtension(unittest::repeated_bool_extension , 1)); - EXPECT_EQ("515", message.GetExtension(unittest::repeated_string_extension , 1)); - EXPECT_EQ("516", message.GetExtension(unittest::repeated_bytes_extension , 1)); - - EXPECT_EQ(517, message.GetExtension(unittest::repeatedgroup_extension , 1).a()); - EXPECT_EQ(518, message.GetExtension(unittest::repeated_nested_message_extension , 1).bb()); - EXPECT_EQ(519, message.GetExtension(unittest::repeated_foreign_message_extension, 1).c()); - EXPECT_EQ(520, message.GetExtension(unittest::repeated_import_message_extension , 1).d()); - EXPECT_EQ(527, message.GetExtension(unittest::repeated_lazy_message_extension , 1).bb()); - - EXPECT_EQ(unittest::TestAllTypes::FOO, message.GetExtension(unittest::repeated_nested_enum_extension , 1)); - EXPECT_EQ(unittest::FOREIGN_FOO , message.GetExtension(unittest::repeated_foreign_enum_extension, 1)); - EXPECT_EQ(unittest_import::IMPORT_FOO, message.GetExtension(unittest::repeated_import_enum_extension , 1)); - - EXPECT_EQ("524", message.GetExtension(unittest::repeated_string_piece_extension, 1)); - EXPECT_EQ("525", message.GetExtension(unittest::repeated_cord_extension, 1)); -} - -// ------------------------------------------------------------------- - -void TestUtil::SetPackedExtensions(unittest::TestPackedExtensions* message) { - message->AddExtension(unittest::packed_int32_extension , 601); - message->AddExtension(unittest::packed_int64_extension , 602); - message->AddExtension(unittest::packed_uint32_extension , 603); - message->AddExtension(unittest::packed_uint64_extension , 604); - message->AddExtension(unittest::packed_sint32_extension , 605); - message->AddExtension(unittest::packed_sint64_extension , 606); - message->AddExtension(unittest::packed_fixed32_extension , 607); - message->AddExtension(unittest::packed_fixed64_extension , 608); - message->AddExtension(unittest::packed_sfixed32_extension, 609); - message->AddExtension(unittest::packed_sfixed64_extension, 610); - message->AddExtension(unittest::packed_float_extension , 611); - message->AddExtension(unittest::packed_double_extension , 612); - message->AddExtension(unittest::packed_bool_extension , true); - message->AddExtension(unittest::packed_enum_extension, unittest::FOREIGN_BAR); - // add a second one of each field - message->AddExtension(unittest::packed_int32_extension , 701); - message->AddExtension(unittest::packed_int64_extension , 702); - message->AddExtension(unittest::packed_uint32_extension , 703); - message->AddExtension(unittest::packed_uint64_extension , 704); - message->AddExtension(unittest::packed_sint32_extension , 705); - message->AddExtension(unittest::packed_sint64_extension , 706); - message->AddExtension(unittest::packed_fixed32_extension , 707); - message->AddExtension(unittest::packed_fixed64_extension , 708); - message->AddExtension(unittest::packed_sfixed32_extension, 709); - message->AddExtension(unittest::packed_sfixed64_extension, 710); - message->AddExtension(unittest::packed_float_extension , 711); - message->AddExtension(unittest::packed_double_extension , 712); - message->AddExtension(unittest::packed_bool_extension , false); - message->AddExtension(unittest::packed_enum_extension, unittest::FOREIGN_BAZ); -} - -// ------------------------------------------------------------------- - -void TestUtil::ModifyPackedExtensions(unittest::TestPackedExtensions* message) { - message->SetExtension(unittest::packed_int32_extension , 1, 801); - message->SetExtension(unittest::packed_int64_extension , 1, 802); - message->SetExtension(unittest::packed_uint32_extension , 1, 803); - message->SetExtension(unittest::packed_uint64_extension , 1, 804); - message->SetExtension(unittest::packed_sint32_extension , 1, 805); - message->SetExtension(unittest::packed_sint64_extension , 1, 806); - message->SetExtension(unittest::packed_fixed32_extension , 1, 807); - message->SetExtension(unittest::packed_fixed64_extension , 1, 808); - message->SetExtension(unittest::packed_sfixed32_extension, 1, 809); - message->SetExtension(unittest::packed_sfixed64_extension, 1, 810); - message->SetExtension(unittest::packed_float_extension , 1, 811); - message->SetExtension(unittest::packed_double_extension , 1, 812); - message->SetExtension(unittest::packed_bool_extension , 1, true); - message->SetExtension(unittest::packed_enum_extension , 1, - unittest::FOREIGN_FOO); -} - -// ------------------------------------------------------------------- - -void TestUtil::ExpectPackedExtensionsSet( - const unittest::TestPackedExtensions& message) { - ASSERT_EQ(2, message.ExtensionSize(unittest::packed_int32_extension )); - ASSERT_EQ(2, message.ExtensionSize(unittest::packed_int64_extension )); - ASSERT_EQ(2, message.ExtensionSize(unittest::packed_uint32_extension )); - ASSERT_EQ(2, message.ExtensionSize(unittest::packed_uint64_extension )); - ASSERT_EQ(2, message.ExtensionSize(unittest::packed_sint32_extension )); - ASSERT_EQ(2, message.ExtensionSize(unittest::packed_sint64_extension )); - ASSERT_EQ(2, message.ExtensionSize(unittest::packed_fixed32_extension )); - ASSERT_EQ(2, message.ExtensionSize(unittest::packed_fixed64_extension )); - ASSERT_EQ(2, message.ExtensionSize(unittest::packed_sfixed32_extension)); - ASSERT_EQ(2, message.ExtensionSize(unittest::packed_sfixed64_extension)); - ASSERT_EQ(2, message.ExtensionSize(unittest::packed_float_extension )); - ASSERT_EQ(2, message.ExtensionSize(unittest::packed_double_extension )); - ASSERT_EQ(2, message.ExtensionSize(unittest::packed_bool_extension )); - ASSERT_EQ(2, message.ExtensionSize(unittest::packed_enum_extension )); - - EXPECT_EQ(601 , message.GetExtension(unittest::packed_int32_extension , 0)); - EXPECT_EQ(602 , message.GetExtension(unittest::packed_int64_extension , 0)); - EXPECT_EQ(603 , message.GetExtension(unittest::packed_uint32_extension , 0)); - EXPECT_EQ(604 , message.GetExtension(unittest::packed_uint64_extension , 0)); - EXPECT_EQ(605 , message.GetExtension(unittest::packed_sint32_extension , 0)); - EXPECT_EQ(606 , message.GetExtension(unittest::packed_sint64_extension , 0)); - EXPECT_EQ(607 , message.GetExtension(unittest::packed_fixed32_extension , 0)); - EXPECT_EQ(608 , message.GetExtension(unittest::packed_fixed64_extension , 0)); - EXPECT_EQ(609 , message.GetExtension(unittest::packed_sfixed32_extension, 0)); - EXPECT_EQ(610 , message.GetExtension(unittest::packed_sfixed64_extension, 0)); - EXPECT_EQ(611 , message.GetExtension(unittest::packed_float_extension , 0)); - EXPECT_EQ(612 , message.GetExtension(unittest::packed_double_extension , 0)); - EXPECT_TRUE( message.GetExtension(unittest::packed_bool_extension , 0)); - EXPECT_EQ(unittest::FOREIGN_BAR, - message.GetExtension(unittest::packed_enum_extension, 0)); - EXPECT_EQ(701 , message.GetExtension(unittest::packed_int32_extension , 1)); - EXPECT_EQ(702 , message.GetExtension(unittest::packed_int64_extension , 1)); - EXPECT_EQ(703 , message.GetExtension(unittest::packed_uint32_extension , 1)); - EXPECT_EQ(704 , message.GetExtension(unittest::packed_uint64_extension , 1)); - EXPECT_EQ(705 , message.GetExtension(unittest::packed_sint32_extension , 1)); - EXPECT_EQ(706 , message.GetExtension(unittest::packed_sint64_extension , 1)); - EXPECT_EQ(707 , message.GetExtension(unittest::packed_fixed32_extension , 1)); - EXPECT_EQ(708 , message.GetExtension(unittest::packed_fixed64_extension , 1)); - EXPECT_EQ(709 , message.GetExtension(unittest::packed_sfixed32_extension, 1)); - EXPECT_EQ(710 , message.GetExtension(unittest::packed_sfixed64_extension, 1)); - EXPECT_EQ(711 , message.GetExtension(unittest::packed_float_extension , 1)); - EXPECT_EQ(712 , message.GetExtension(unittest::packed_double_extension , 1)); - EXPECT_FALSE( message.GetExtension(unittest::packed_bool_extension , 1)); - EXPECT_EQ(unittest::FOREIGN_BAZ, - message.GetExtension(unittest::packed_enum_extension, 1)); -} - -// ------------------------------------------------------------------- - -void TestUtil::ExpectPackedExtensionsClear( - const unittest::TestPackedExtensions& message) { - EXPECT_EQ(0, message.ExtensionSize(unittest::packed_int32_extension )); - EXPECT_EQ(0, message.ExtensionSize(unittest::packed_int64_extension )); - EXPECT_EQ(0, message.ExtensionSize(unittest::packed_uint32_extension )); - EXPECT_EQ(0, message.ExtensionSize(unittest::packed_uint64_extension )); - EXPECT_EQ(0, message.ExtensionSize(unittest::packed_sint32_extension )); - EXPECT_EQ(0, message.ExtensionSize(unittest::packed_sint64_extension )); - EXPECT_EQ(0, message.ExtensionSize(unittest::packed_fixed32_extension )); - EXPECT_EQ(0, message.ExtensionSize(unittest::packed_fixed64_extension )); - EXPECT_EQ(0, message.ExtensionSize(unittest::packed_sfixed32_extension)); - EXPECT_EQ(0, message.ExtensionSize(unittest::packed_sfixed64_extension)); - EXPECT_EQ(0, message.ExtensionSize(unittest::packed_float_extension )); - EXPECT_EQ(0, message.ExtensionSize(unittest::packed_double_extension )); - EXPECT_EQ(0, message.ExtensionSize(unittest::packed_bool_extension )); - EXPECT_EQ(0, message.ExtensionSize(unittest::packed_enum_extension )); -} - -// ------------------------------------------------------------------- - -void TestUtil::ExpectPackedExtensionsModified( - const unittest::TestPackedExtensions& message) { - ASSERT_EQ(2, message.ExtensionSize(unittest::packed_int32_extension )); - ASSERT_EQ(2, message.ExtensionSize(unittest::packed_int64_extension )); - ASSERT_EQ(2, message.ExtensionSize(unittest::packed_uint32_extension )); - ASSERT_EQ(2, message.ExtensionSize(unittest::packed_uint64_extension )); - ASSERT_EQ(2, message.ExtensionSize(unittest::packed_sint32_extension )); - ASSERT_EQ(2, message.ExtensionSize(unittest::packed_sint64_extension )); - ASSERT_EQ(2, message.ExtensionSize(unittest::packed_fixed32_extension )); - ASSERT_EQ(2, message.ExtensionSize(unittest::packed_fixed64_extension )); - ASSERT_EQ(2, message.ExtensionSize(unittest::packed_sfixed32_extension)); - ASSERT_EQ(2, message.ExtensionSize(unittest::packed_sfixed64_extension)); - ASSERT_EQ(2, message.ExtensionSize(unittest::packed_float_extension )); - ASSERT_EQ(2, message.ExtensionSize(unittest::packed_double_extension )); - ASSERT_EQ(2, message.ExtensionSize(unittest::packed_bool_extension )); - ASSERT_EQ(2, message.ExtensionSize(unittest::packed_enum_extension )); - EXPECT_EQ(601 , message.GetExtension(unittest::packed_int32_extension , 0)); - EXPECT_EQ(602 , message.GetExtension(unittest::packed_int64_extension , 0)); - EXPECT_EQ(603 , message.GetExtension(unittest::packed_uint32_extension , 0)); - EXPECT_EQ(604 , message.GetExtension(unittest::packed_uint64_extension , 0)); - EXPECT_EQ(605 , message.GetExtension(unittest::packed_sint32_extension , 0)); - EXPECT_EQ(606 , message.GetExtension(unittest::packed_sint64_extension , 0)); - EXPECT_EQ(607 , message.GetExtension(unittest::packed_fixed32_extension , 0)); - EXPECT_EQ(608 , message.GetExtension(unittest::packed_fixed64_extension , 0)); - EXPECT_EQ(609 , message.GetExtension(unittest::packed_sfixed32_extension, 0)); - EXPECT_EQ(610 , message.GetExtension(unittest::packed_sfixed64_extension, 0)); - EXPECT_EQ(611 , message.GetExtension(unittest::packed_float_extension , 0)); - EXPECT_EQ(612 , message.GetExtension(unittest::packed_double_extension , 0)); - EXPECT_TRUE( message.GetExtension(unittest::packed_bool_extension , 0)); - EXPECT_EQ(unittest::FOREIGN_BAR, - message.GetExtension(unittest::packed_enum_extension, 0)); - - // Actually verify the second (modified) elements now. - EXPECT_EQ(801 , message.GetExtension(unittest::packed_int32_extension , 1)); - EXPECT_EQ(802 , message.GetExtension(unittest::packed_int64_extension , 1)); - EXPECT_EQ(803 , message.GetExtension(unittest::packed_uint32_extension , 1)); - EXPECT_EQ(804 , message.GetExtension(unittest::packed_uint64_extension , 1)); - EXPECT_EQ(805 , message.GetExtension(unittest::packed_sint32_extension , 1)); - EXPECT_EQ(806 , message.GetExtension(unittest::packed_sint64_extension , 1)); - EXPECT_EQ(807 , message.GetExtension(unittest::packed_fixed32_extension , 1)); - EXPECT_EQ(808 , message.GetExtension(unittest::packed_fixed64_extension , 1)); - EXPECT_EQ(809 , message.GetExtension(unittest::packed_sfixed32_extension, 1)); - EXPECT_EQ(810 , message.GetExtension(unittest::packed_sfixed64_extension, 1)); - EXPECT_EQ(811 , message.GetExtension(unittest::packed_float_extension , 1)); - EXPECT_EQ(812 , message.GetExtension(unittest::packed_double_extension , 1)); - EXPECT_TRUE( message.GetExtension(unittest::packed_bool_extension , 1)); - EXPECT_EQ(unittest::FOREIGN_FOO, - message.GetExtension(unittest::packed_enum_extension, 1)); -} - -// ------------------------------------------------------------------- - -void TestUtil::ExpectAllFieldsAndExtensionsInOrder(const string& serialized) { - // We set each field individually, serialize separately, and concatenate all - // the strings in canonical order to determine the expected serialization. - string expected; - unittest::TestFieldOrderings message; - message.set_my_int(1); // Field 1. - message.AppendToString(&expected); - message.Clear(); - message.SetExtension(unittest::my_extension_int, 23); // Field 5. - message.AppendToString(&expected); - message.Clear(); - message.set_my_string("foo"); // Field 11. - message.AppendToString(&expected); - message.Clear(); - message.SetExtension(unittest::my_extension_string, "bar"); // Field 50. - message.AppendToString(&expected); - message.Clear(); - message.set_my_float(1.0); // Field 101. - message.AppendToString(&expected); - message.Clear(); - - // We don't EXPECT_EQ() since we don't want to print raw bytes to stdout. - EXPECT_TRUE(serialized == expected); -} - -void TestUtil::ExpectLastRepeatedsRemoved( - const unittest::TestAllTypes& message) { - ASSERT_EQ(1, message.repeated_int32_size ()); - ASSERT_EQ(1, message.repeated_int64_size ()); - ASSERT_EQ(1, message.repeated_uint32_size ()); - ASSERT_EQ(1, message.repeated_uint64_size ()); - ASSERT_EQ(1, message.repeated_sint32_size ()); - ASSERT_EQ(1, message.repeated_sint64_size ()); - ASSERT_EQ(1, message.repeated_fixed32_size ()); - ASSERT_EQ(1, message.repeated_fixed64_size ()); - ASSERT_EQ(1, message.repeated_sfixed32_size()); - ASSERT_EQ(1, message.repeated_sfixed64_size()); - ASSERT_EQ(1, message.repeated_float_size ()); - ASSERT_EQ(1, message.repeated_double_size ()); - ASSERT_EQ(1, message.repeated_bool_size ()); - ASSERT_EQ(1, message.repeated_string_size ()); - ASSERT_EQ(1, message.repeated_bytes_size ()); - - ASSERT_EQ(1, message.repeatedgroup_size ()); - ASSERT_EQ(1, message.repeated_nested_message_size ()); - ASSERT_EQ(1, message.repeated_foreign_message_size()); - ASSERT_EQ(1, message.repeated_import_message_size ()); - ASSERT_EQ(1, message.repeated_import_message_size ()); - ASSERT_EQ(1, message.repeated_nested_enum_size ()); - ASSERT_EQ(1, message.repeated_foreign_enum_size ()); - ASSERT_EQ(1, message.repeated_import_enum_size ()); - -#ifndef PROTOBUF_TEST_NO_DESCRIPTORS - ASSERT_EQ(1, message.repeated_string_piece_size()); - ASSERT_EQ(1, message.repeated_cord_size()); -#endif - - // Test that the remaining element is the correct one. - EXPECT_EQ(201 , message.repeated_int32 (0)); - EXPECT_EQ(202 , message.repeated_int64 (0)); - EXPECT_EQ(203 , message.repeated_uint32 (0)); - EXPECT_EQ(204 , message.repeated_uint64 (0)); - EXPECT_EQ(205 , message.repeated_sint32 (0)); - EXPECT_EQ(206 , message.repeated_sint64 (0)); - EXPECT_EQ(207 , message.repeated_fixed32 (0)); - EXPECT_EQ(208 , message.repeated_fixed64 (0)); - EXPECT_EQ(209 , message.repeated_sfixed32(0)); - EXPECT_EQ(210 , message.repeated_sfixed64(0)); - EXPECT_EQ(211 , message.repeated_float (0)); - EXPECT_EQ(212 , message.repeated_double (0)); - EXPECT_TRUE( message.repeated_bool (0)); - EXPECT_EQ("215", message.repeated_string (0)); - EXPECT_EQ("216", message.repeated_bytes (0)); - - EXPECT_EQ(217, message.repeatedgroup (0).a()); - EXPECT_EQ(218, message.repeated_nested_message (0).bb()); - EXPECT_EQ(219, message.repeated_foreign_message(0).c()); - EXPECT_EQ(220, message.repeated_import_message (0).d()); - EXPECT_EQ(220, message.repeated_import_message (0).d()); - - EXPECT_EQ(unittest::TestAllTypes::BAR, message.repeated_nested_enum (0)); - EXPECT_EQ(unittest::FOREIGN_BAR , message.repeated_foreign_enum(0)); - EXPECT_EQ(unittest_import::IMPORT_BAR, message.repeated_import_enum (0)); -} - -void TestUtil::ExpectLastRepeatedExtensionsRemoved( - const unittest::TestAllExtensions& message) { - - // Test that one element was removed. - ASSERT_EQ(1, message.ExtensionSize(unittest::repeated_int32_extension )); - ASSERT_EQ(1, message.ExtensionSize(unittest::repeated_int64_extension )); - ASSERT_EQ(1, message.ExtensionSize(unittest::repeated_uint32_extension )); - ASSERT_EQ(1, message.ExtensionSize(unittest::repeated_uint64_extension )); - ASSERT_EQ(1, message.ExtensionSize(unittest::repeated_sint32_extension )); - ASSERT_EQ(1, message.ExtensionSize(unittest::repeated_sint64_extension )); - ASSERT_EQ(1, message.ExtensionSize(unittest::repeated_fixed32_extension )); - ASSERT_EQ(1, message.ExtensionSize(unittest::repeated_fixed64_extension )); - ASSERT_EQ(1, message.ExtensionSize(unittest::repeated_sfixed32_extension)); - ASSERT_EQ(1, message.ExtensionSize(unittest::repeated_sfixed64_extension)); - ASSERT_EQ(1, message.ExtensionSize(unittest::repeated_float_extension )); - ASSERT_EQ(1, message.ExtensionSize(unittest::repeated_double_extension )); - ASSERT_EQ(1, message.ExtensionSize(unittest::repeated_bool_extension )); - ASSERT_EQ(1, message.ExtensionSize(unittest::repeated_string_extension )); - ASSERT_EQ(1, message.ExtensionSize(unittest::repeated_bytes_extension )); - - ASSERT_EQ(1, message.ExtensionSize(unittest::repeatedgroup_extension )); - ASSERT_EQ(1, message.ExtensionSize(unittest::repeated_nested_message_extension )); - ASSERT_EQ(1, message.ExtensionSize(unittest::repeated_foreign_message_extension)); - ASSERT_EQ(1, message.ExtensionSize(unittest::repeated_import_message_extension )); - ASSERT_EQ(1, message.ExtensionSize(unittest::repeated_lazy_message_extension )); - ASSERT_EQ(1, message.ExtensionSize(unittest::repeated_nested_enum_extension )); - ASSERT_EQ(1, message.ExtensionSize(unittest::repeated_foreign_enum_extension )); - ASSERT_EQ(1, message.ExtensionSize(unittest::repeated_import_enum_extension )); - - ASSERT_EQ(1, message.ExtensionSize(unittest::repeated_string_piece_extension)); - ASSERT_EQ(1, message.ExtensionSize(unittest::repeated_cord_extension)); - - // Test that the remaining element is the correct one. - EXPECT_EQ(201 , message.GetExtension(unittest::repeated_int32_extension , 0)); - EXPECT_EQ(202 , message.GetExtension(unittest::repeated_int64_extension , 0)); - EXPECT_EQ(203 , message.GetExtension(unittest::repeated_uint32_extension , 0)); - EXPECT_EQ(204 , message.GetExtension(unittest::repeated_uint64_extension , 0)); - EXPECT_EQ(205 , message.GetExtension(unittest::repeated_sint32_extension , 0)); - EXPECT_EQ(206 , message.GetExtension(unittest::repeated_sint64_extension , 0)); - EXPECT_EQ(207 , message.GetExtension(unittest::repeated_fixed32_extension , 0)); - EXPECT_EQ(208 , message.GetExtension(unittest::repeated_fixed64_extension , 0)); - EXPECT_EQ(209 , message.GetExtension(unittest::repeated_sfixed32_extension, 0)); - EXPECT_EQ(210 , message.GetExtension(unittest::repeated_sfixed64_extension, 0)); - EXPECT_EQ(211 , message.GetExtension(unittest::repeated_float_extension , 0)); - EXPECT_EQ(212 , message.GetExtension(unittest::repeated_double_extension , 0)); - EXPECT_TRUE( message.GetExtension(unittest::repeated_bool_extension , 0)); - EXPECT_EQ("215", message.GetExtension(unittest::repeated_string_extension , 0)); - EXPECT_EQ("216", message.GetExtension(unittest::repeated_bytes_extension , 0)); - - EXPECT_EQ(217, message.GetExtension(unittest::repeatedgroup_extension , 0).a()); - EXPECT_EQ(218, message.GetExtension(unittest::repeated_nested_message_extension , 0).bb()); - EXPECT_EQ(219, message.GetExtension(unittest::repeated_foreign_message_extension, 0).c()); - EXPECT_EQ(220, message.GetExtension(unittest::repeated_import_message_extension , 0).d()); - EXPECT_EQ(227, message.GetExtension(unittest::repeated_lazy_message_extension , 0).bb()); - - EXPECT_EQ(unittest::TestAllTypes::BAR, message.GetExtension(unittest::repeated_nested_enum_extension , 0)); - EXPECT_EQ(unittest::FOREIGN_BAR , message.GetExtension(unittest::repeated_foreign_enum_extension, 0)); - EXPECT_EQ(unittest_import::IMPORT_BAR, message.GetExtension(unittest::repeated_import_enum_extension , 0)); - - EXPECT_EQ("224", message.GetExtension(unittest::repeated_string_piece_extension, 0)); - EXPECT_EQ("225", message.GetExtension(unittest::repeated_cord_extension, 0)); -} - -void TestUtil::ExpectLastRepeatedsReleased( - const unittest::TestAllTypes& message) { - ASSERT_EQ(1, message.repeatedgroup_size ()); - ASSERT_EQ(1, message.repeated_nested_message_size ()); - ASSERT_EQ(1, message.repeated_foreign_message_size()); - ASSERT_EQ(1, message.repeated_import_message_size ()); - ASSERT_EQ(1, message.repeated_import_message_size ()); - - EXPECT_EQ(217, message.repeatedgroup (0).a()); - EXPECT_EQ(218, message.repeated_nested_message (0).bb()); - EXPECT_EQ(219, message.repeated_foreign_message(0).c()); - EXPECT_EQ(220, message.repeated_import_message (0).d()); - EXPECT_EQ(220, message.repeated_import_message (0).d()); -} - -void TestUtil::ExpectLastRepeatedExtensionsReleased( - const unittest::TestAllExtensions& message) { - ASSERT_EQ(1, message.ExtensionSize(unittest::repeatedgroup_extension )); - ASSERT_EQ(1, message.ExtensionSize(unittest::repeated_nested_message_extension )); - ASSERT_EQ(1, message.ExtensionSize(unittest::repeated_foreign_message_extension)); - ASSERT_EQ(1, message.ExtensionSize(unittest::repeated_import_message_extension )); - ASSERT_EQ(1, message.ExtensionSize(unittest::repeated_lazy_message_extension )); - - EXPECT_EQ(217, message.GetExtension(unittest::repeatedgroup_extension , 0).a()); - EXPECT_EQ(218, message.GetExtension(unittest::repeated_nested_message_extension , 0).bb()); - EXPECT_EQ(219, message.GetExtension(unittest::repeated_foreign_message_extension, 0).c()); - EXPECT_EQ(220, message.GetExtension(unittest::repeated_import_message_extension , 0).d()); - EXPECT_EQ(227, message.GetExtension(unittest::repeated_lazy_message_extension , 0).bb()); -} - -void TestUtil::ExpectRepeatedsSwapped( - const unittest::TestAllTypes& message) { - ASSERT_EQ(2, message.repeated_int32_size ()); - ASSERT_EQ(2, message.repeated_int64_size ()); - ASSERT_EQ(2, message.repeated_uint32_size ()); - ASSERT_EQ(2, message.repeated_uint64_size ()); - ASSERT_EQ(2, message.repeated_sint32_size ()); - ASSERT_EQ(2, message.repeated_sint64_size ()); - ASSERT_EQ(2, message.repeated_fixed32_size ()); - ASSERT_EQ(2, message.repeated_fixed64_size ()); - ASSERT_EQ(2, message.repeated_sfixed32_size()); - ASSERT_EQ(2, message.repeated_sfixed64_size()); - ASSERT_EQ(2, message.repeated_float_size ()); - ASSERT_EQ(2, message.repeated_double_size ()); - ASSERT_EQ(2, message.repeated_bool_size ()); - ASSERT_EQ(2, message.repeated_string_size ()); - ASSERT_EQ(2, message.repeated_bytes_size ()); - - ASSERT_EQ(2, message.repeatedgroup_size ()); - ASSERT_EQ(2, message.repeated_nested_message_size ()); - ASSERT_EQ(2, message.repeated_foreign_message_size()); - ASSERT_EQ(2, message.repeated_import_message_size ()); - ASSERT_EQ(2, message.repeated_import_message_size ()); - ASSERT_EQ(2, message.repeated_nested_enum_size ()); - ASSERT_EQ(2, message.repeated_foreign_enum_size ()); - ASSERT_EQ(2, message.repeated_import_enum_size ()); - -#ifndef PROTOBUF_TEST_NO_DESCRIPTORS - ASSERT_EQ(2, message.repeated_string_piece_size()); - ASSERT_EQ(2, message.repeated_cord_size()); -#endif - - // Test that the first element and second element are flipped. - EXPECT_EQ(201 , message.repeated_int32 (1)); - EXPECT_EQ(202 , message.repeated_int64 (1)); - EXPECT_EQ(203 , message.repeated_uint32 (1)); - EXPECT_EQ(204 , message.repeated_uint64 (1)); - EXPECT_EQ(205 , message.repeated_sint32 (1)); - EXPECT_EQ(206 , message.repeated_sint64 (1)); - EXPECT_EQ(207 , message.repeated_fixed32 (1)); - EXPECT_EQ(208 , message.repeated_fixed64 (1)); - EXPECT_EQ(209 , message.repeated_sfixed32(1)); - EXPECT_EQ(210 , message.repeated_sfixed64(1)); - EXPECT_EQ(211 , message.repeated_float (1)); - EXPECT_EQ(212 , message.repeated_double (1)); - EXPECT_TRUE( message.repeated_bool (1)); - EXPECT_EQ("215", message.repeated_string (1)); - EXPECT_EQ("216", message.repeated_bytes (1)); - - EXPECT_EQ(217, message.repeatedgroup (1).a()); - EXPECT_EQ(218, message.repeated_nested_message (1).bb()); - EXPECT_EQ(219, message.repeated_foreign_message(1).c()); - EXPECT_EQ(220, message.repeated_import_message (1).d()); - EXPECT_EQ(220, message.repeated_import_message (1).d()); - - EXPECT_EQ(unittest::TestAllTypes::BAR, message.repeated_nested_enum (1)); - EXPECT_EQ(unittest::FOREIGN_BAR , message.repeated_foreign_enum(1)); - EXPECT_EQ(unittest_import::IMPORT_BAR, message.repeated_import_enum (1)); - - EXPECT_EQ(301 , message.repeated_int32 (0)); - EXPECT_EQ(302 , message.repeated_int64 (0)); - EXPECT_EQ(303 , message.repeated_uint32 (0)); - EXPECT_EQ(304 , message.repeated_uint64 (0)); - EXPECT_EQ(305 , message.repeated_sint32 (0)); - EXPECT_EQ(306 , message.repeated_sint64 (0)); - EXPECT_EQ(307 , message.repeated_fixed32 (0)); - EXPECT_EQ(308 , message.repeated_fixed64 (0)); - EXPECT_EQ(309 , message.repeated_sfixed32(0)); - EXPECT_EQ(310 , message.repeated_sfixed64(0)); - EXPECT_EQ(311 , message.repeated_float (0)); - EXPECT_EQ(312 , message.repeated_double (0)); - EXPECT_FALSE( message.repeated_bool (0)); - EXPECT_EQ("315", message.repeated_string (0)); - EXPECT_EQ("316", message.repeated_bytes (0)); - - EXPECT_EQ(317, message.repeatedgroup (0).a()); - EXPECT_EQ(318, message.repeated_nested_message (0).bb()); - EXPECT_EQ(319, message.repeated_foreign_message(0).c()); - EXPECT_EQ(320, message.repeated_import_message (0).d()); - EXPECT_EQ(320, message.repeated_import_message (0).d()); - - EXPECT_EQ(unittest::TestAllTypes::BAZ, message.repeated_nested_enum (0)); - EXPECT_EQ(unittest::FOREIGN_BAZ , message.repeated_foreign_enum(0)); - EXPECT_EQ(unittest_import::IMPORT_BAZ, message.repeated_import_enum (0)); -} - -void TestUtil::ExpectRepeatedExtensionsSwapped( - const unittest::TestAllExtensions& message) { - - ASSERT_EQ(2, message.ExtensionSize(unittest::repeated_int32_extension )); - ASSERT_EQ(2, message.ExtensionSize(unittest::repeated_int64_extension )); - ASSERT_EQ(2, message.ExtensionSize(unittest::repeated_uint32_extension )); - ASSERT_EQ(2, message.ExtensionSize(unittest::repeated_uint64_extension )); - ASSERT_EQ(2, message.ExtensionSize(unittest::repeated_sint32_extension )); - ASSERT_EQ(2, message.ExtensionSize(unittest::repeated_sint64_extension )); - ASSERT_EQ(2, message.ExtensionSize(unittest::repeated_fixed32_extension )); - ASSERT_EQ(2, message.ExtensionSize(unittest::repeated_fixed64_extension )); - ASSERT_EQ(2, message.ExtensionSize(unittest::repeated_sfixed32_extension)); - ASSERT_EQ(2, message.ExtensionSize(unittest::repeated_sfixed64_extension)); - ASSERT_EQ(2, message.ExtensionSize(unittest::repeated_float_extension )); - ASSERT_EQ(2, message.ExtensionSize(unittest::repeated_double_extension )); - ASSERT_EQ(2, message.ExtensionSize(unittest::repeated_bool_extension )); - ASSERT_EQ(2, message.ExtensionSize(unittest::repeated_string_extension )); - ASSERT_EQ(2, message.ExtensionSize(unittest::repeated_bytes_extension )); - - ASSERT_EQ(2, message.ExtensionSize(unittest::repeatedgroup_extension )); - ASSERT_EQ(2, message.ExtensionSize(unittest::repeated_nested_message_extension )); - ASSERT_EQ(2, message.ExtensionSize(unittest::repeated_foreign_message_extension)); - ASSERT_EQ(2, message.ExtensionSize(unittest::repeated_import_message_extension )); - ASSERT_EQ(2, message.ExtensionSize(unittest::repeated_lazy_message_extension )); - ASSERT_EQ(2, message.ExtensionSize(unittest::repeated_nested_enum_extension )); - ASSERT_EQ(2, message.ExtensionSize(unittest::repeated_foreign_enum_extension )); - ASSERT_EQ(2, message.ExtensionSize(unittest::repeated_import_enum_extension )); - - ASSERT_EQ(2, message.ExtensionSize(unittest::repeated_string_piece_extension)); - ASSERT_EQ(2, message.ExtensionSize(unittest::repeated_cord_extension)); - - EXPECT_EQ(201 , message.GetExtension(unittest::repeated_int32_extension , 1)); - EXPECT_EQ(202 , message.GetExtension(unittest::repeated_int64_extension , 1)); - EXPECT_EQ(203 , message.GetExtension(unittest::repeated_uint32_extension , 1)); - EXPECT_EQ(204 , message.GetExtension(unittest::repeated_uint64_extension , 1)); - EXPECT_EQ(205 , message.GetExtension(unittest::repeated_sint32_extension , 1)); - EXPECT_EQ(206 , message.GetExtension(unittest::repeated_sint64_extension , 1)); - EXPECT_EQ(207 , message.GetExtension(unittest::repeated_fixed32_extension , 1)); - EXPECT_EQ(208 , message.GetExtension(unittest::repeated_fixed64_extension , 1)); - EXPECT_EQ(209 , message.GetExtension(unittest::repeated_sfixed32_extension, 1)); - EXPECT_EQ(210 , message.GetExtension(unittest::repeated_sfixed64_extension, 1)); - EXPECT_EQ(211 , message.GetExtension(unittest::repeated_float_extension , 1)); - EXPECT_EQ(212 , message.GetExtension(unittest::repeated_double_extension , 1)); - EXPECT_TRUE( message.GetExtension(unittest::repeated_bool_extension , 1)); - EXPECT_EQ("215", message.GetExtension(unittest::repeated_string_extension , 1)); - EXPECT_EQ("216", message.GetExtension(unittest::repeated_bytes_extension , 1)); - - EXPECT_EQ(217, message.GetExtension(unittest::repeatedgroup_extension , 1).a()); - EXPECT_EQ(218, message.GetExtension(unittest::repeated_nested_message_extension , 1).bb()); - EXPECT_EQ(219, message.GetExtension(unittest::repeated_foreign_message_extension, 1).c()); - EXPECT_EQ(220, message.GetExtension(unittest::repeated_import_message_extension , 1).d()); - EXPECT_EQ(227, message.GetExtension(unittest::repeated_lazy_message_extension , 1).bb()); - - EXPECT_EQ(unittest::TestAllTypes::BAR, message.GetExtension(unittest::repeated_nested_enum_extension , 1)); - EXPECT_EQ(unittest::FOREIGN_BAR , message.GetExtension(unittest::repeated_foreign_enum_extension, 1)); - EXPECT_EQ(unittest_import::IMPORT_BAR, message.GetExtension(unittest::repeated_import_enum_extension , 1)); - - EXPECT_EQ("224", message.GetExtension(unittest::repeated_string_piece_extension, 1)); - EXPECT_EQ("225", message.GetExtension(unittest::repeated_cord_extension, 1)); - - EXPECT_EQ(301 , message.GetExtension(unittest::repeated_int32_extension , 0)); - EXPECT_EQ(302 , message.GetExtension(unittest::repeated_int64_extension , 0)); - EXPECT_EQ(303 , message.GetExtension(unittest::repeated_uint32_extension , 0)); - EXPECT_EQ(304 , message.GetExtension(unittest::repeated_uint64_extension , 0)); - EXPECT_EQ(305 , message.GetExtension(unittest::repeated_sint32_extension , 0)); - EXPECT_EQ(306 , message.GetExtension(unittest::repeated_sint64_extension , 0)); - EXPECT_EQ(307 , message.GetExtension(unittest::repeated_fixed32_extension , 0)); - EXPECT_EQ(308 , message.GetExtension(unittest::repeated_fixed64_extension , 0)); - EXPECT_EQ(309 , message.GetExtension(unittest::repeated_sfixed32_extension, 0)); - EXPECT_EQ(310 , message.GetExtension(unittest::repeated_sfixed64_extension, 0)); - EXPECT_EQ(311 , message.GetExtension(unittest::repeated_float_extension , 0)); - EXPECT_EQ(312 , message.GetExtension(unittest::repeated_double_extension , 0)); - EXPECT_FALSE( message.GetExtension(unittest::repeated_bool_extension , 0)); - EXPECT_EQ("315", message.GetExtension(unittest::repeated_string_extension , 0)); - EXPECT_EQ("316", message.GetExtension(unittest::repeated_bytes_extension , 0)); - - EXPECT_EQ(317, message.GetExtension(unittest::repeatedgroup_extension , 0).a()); - EXPECT_EQ(318, message.GetExtension(unittest::repeated_nested_message_extension , 0).bb()); - EXPECT_EQ(319, message.GetExtension(unittest::repeated_foreign_message_extension, 0).c()); - EXPECT_EQ(320, message.GetExtension(unittest::repeated_import_message_extension , 0).d()); - EXPECT_EQ(327, message.GetExtension(unittest::repeated_lazy_message_extension , 0).bb()); - - EXPECT_EQ(unittest::TestAllTypes::BAZ, message.GetExtension(unittest::repeated_nested_enum_extension , 0)); - EXPECT_EQ(unittest::FOREIGN_BAZ , message.GetExtension(unittest::repeated_foreign_enum_extension, 0)); - EXPECT_EQ(unittest_import::IMPORT_BAZ, message.GetExtension(unittest::repeated_import_enum_extension , 0)); - - EXPECT_EQ("324", message.GetExtension(unittest::repeated_string_piece_extension, 0)); - EXPECT_EQ("325", message.GetExtension(unittest::repeated_cord_extension, 0)); -} - -// =================================================================== - -TestUtil::ReflectionTester::ReflectionTester( - const Descriptor* base_descriptor) - : base_descriptor_(base_descriptor) { - - const DescriptorPool* pool = base_descriptor->file()->pool(); - - nested_b_ = - pool->FindFieldByName("protobuf_unittest.TestAllTypes.NestedMessage.bb"); - foreign_c_ = - pool->FindFieldByName("protobuf_unittest.ForeignMessage.c"); - import_d_ = - pool->FindFieldByName("protobuf_unittest_import.ImportMessage.d"); - import_e_ = - pool->FindFieldByName("protobuf_unittest_import.PublicImportMessage.e"); - nested_foo_ = - pool->FindEnumValueByName("protobuf_unittest.TestAllTypes.FOO"); - nested_bar_ = - pool->FindEnumValueByName("protobuf_unittest.TestAllTypes.BAR"); - nested_baz_ = - pool->FindEnumValueByName("protobuf_unittest.TestAllTypes.BAZ"); - foreign_foo_ = - pool->FindEnumValueByName("protobuf_unittest.FOREIGN_FOO"); - foreign_bar_ = - pool->FindEnumValueByName("protobuf_unittest.FOREIGN_BAR"); - foreign_baz_ = - pool->FindEnumValueByName("protobuf_unittest.FOREIGN_BAZ"); - import_foo_ = - pool->FindEnumValueByName("protobuf_unittest_import.IMPORT_FOO"); - import_bar_ = - pool->FindEnumValueByName("protobuf_unittest_import.IMPORT_BAR"); - import_baz_ = - pool->FindEnumValueByName("protobuf_unittest_import.IMPORT_BAZ"); - - if (base_descriptor_->name() == "TestAllExtensions") { - group_a_ = - pool->FindFieldByName("protobuf_unittest.OptionalGroup_extension.a"); - repeated_group_a_ = - pool->FindFieldByName("protobuf_unittest.RepeatedGroup_extension.a"); - } else { - group_a_ = - pool->FindFieldByName("protobuf_unittest.TestAllTypes.OptionalGroup.a"); - repeated_group_a_ = - pool->FindFieldByName("protobuf_unittest.TestAllTypes.RepeatedGroup.a"); - } - - EXPECT_TRUE(group_a_ != NULL); - EXPECT_TRUE(repeated_group_a_ != NULL); - EXPECT_TRUE(nested_b_ != NULL); - EXPECT_TRUE(foreign_c_ != NULL); - EXPECT_TRUE(import_d_ != NULL); - EXPECT_TRUE(import_e_ != NULL); - EXPECT_TRUE(nested_foo_ != NULL); - EXPECT_TRUE(nested_bar_ != NULL); - EXPECT_TRUE(nested_baz_ != NULL); - EXPECT_TRUE(foreign_foo_ != NULL); - EXPECT_TRUE(foreign_bar_ != NULL); - EXPECT_TRUE(foreign_baz_ != NULL); - EXPECT_TRUE(import_foo_ != NULL); - EXPECT_TRUE(import_bar_ != NULL); - EXPECT_TRUE(import_baz_ != NULL); -} - -// Shorthand to get a FieldDescriptor for a field of unittest::TestAllTypes. -const FieldDescriptor* TestUtil::ReflectionTester::F(const string& name) { - const FieldDescriptor* result = NULL; - if (base_descriptor_->name() == "TestAllExtensions" || - base_descriptor_->name() == "TestPackedExtensions") { - result = base_descriptor_->file()->FindExtensionByName(name + "_extension"); - } else { - result = base_descriptor_->FindFieldByName(name); - } - GOOGLE_CHECK(result != NULL); - return result; -} - -// ------------------------------------------------------------------- - -void TestUtil::ReflectionTester::SetAllFieldsViaReflection(Message* message) { - const Reflection* reflection = message->GetReflection(); - Message* sub_message; - - reflection->SetInt32 (message, F("optional_int32" ), 101); - reflection->SetInt64 (message, F("optional_int64" ), 102); - reflection->SetUInt32(message, F("optional_uint32" ), 103); - reflection->SetUInt64(message, F("optional_uint64" ), 104); - reflection->SetInt32 (message, F("optional_sint32" ), 105); - reflection->SetInt64 (message, F("optional_sint64" ), 106); - reflection->SetUInt32(message, F("optional_fixed32" ), 107); - reflection->SetUInt64(message, F("optional_fixed64" ), 108); - reflection->SetInt32 (message, F("optional_sfixed32"), 109); - reflection->SetInt64 (message, F("optional_sfixed64"), 110); - reflection->SetFloat (message, F("optional_float" ), 111); - reflection->SetDouble(message, F("optional_double" ), 112); - reflection->SetBool (message, F("optional_bool" ), true); - reflection->SetString(message, F("optional_string" ), "115"); - reflection->SetString(message, F("optional_bytes" ), "116"); - - sub_message = reflection->MutableMessage(message, F("optionalgroup")); - sub_message->GetReflection()->SetInt32(sub_message, group_a_, 117); - sub_message = reflection->MutableMessage(message, F("optional_nested_message")); - sub_message->GetReflection()->SetInt32(sub_message, nested_b_, 118); - sub_message = reflection->MutableMessage(message, F("optional_foreign_message")); - sub_message->GetReflection()->SetInt32(sub_message, foreign_c_, 119); - sub_message = reflection->MutableMessage(message, F("optional_import_message")); - sub_message->GetReflection()->SetInt32(sub_message, import_d_, 120); - - reflection->SetEnum(message, F("optional_nested_enum" ), nested_baz_); - reflection->SetEnum(message, F("optional_foreign_enum"), foreign_baz_); - reflection->SetEnum(message, F("optional_import_enum" ), import_baz_); - - reflection->SetString(message, F("optional_string_piece"), "124"); - reflection->SetString(message, F("optional_cord"), "125"); - - sub_message = reflection->MutableMessage(message, F("optional_public_import_message")); - sub_message->GetReflection()->SetInt32(sub_message, import_e_, 126); - - sub_message = reflection->MutableMessage(message, F("optional_lazy_message")); - sub_message->GetReflection()->SetInt32(sub_message, nested_b_, 127); - - // ----------------------------------------------------------------- - - reflection->AddInt32 (message, F("repeated_int32" ), 201); - reflection->AddInt64 (message, F("repeated_int64" ), 202); - reflection->AddUInt32(message, F("repeated_uint32" ), 203); - reflection->AddUInt64(message, F("repeated_uint64" ), 204); - reflection->AddInt32 (message, F("repeated_sint32" ), 205); - reflection->AddInt64 (message, F("repeated_sint64" ), 206); - reflection->AddUInt32(message, F("repeated_fixed32" ), 207); - reflection->AddUInt64(message, F("repeated_fixed64" ), 208); - reflection->AddInt32 (message, F("repeated_sfixed32"), 209); - reflection->AddInt64 (message, F("repeated_sfixed64"), 210); - reflection->AddFloat (message, F("repeated_float" ), 211); - reflection->AddDouble(message, F("repeated_double" ), 212); - reflection->AddBool (message, F("repeated_bool" ), true); - reflection->AddString(message, F("repeated_string" ), "215"); - reflection->AddString(message, F("repeated_bytes" ), "216"); - - sub_message = reflection->AddMessage(message, F("repeatedgroup")); - sub_message->GetReflection()->SetInt32(sub_message, repeated_group_a_, 217); - sub_message = reflection->AddMessage(message, F("repeated_nested_message")); - sub_message->GetReflection()->SetInt32(sub_message, nested_b_, 218); - sub_message = reflection->AddMessage(message, F("repeated_foreign_message")); - sub_message->GetReflection()->SetInt32(sub_message, foreign_c_, 219); - sub_message = reflection->AddMessage(message, F("repeated_import_message")); - sub_message->GetReflection()->SetInt32(sub_message, import_d_, 220); - sub_message = reflection->AddMessage(message, F("repeated_lazy_message")); - sub_message->GetReflection()->SetInt32(sub_message, nested_b_, 227); - - reflection->AddEnum(message, F("repeated_nested_enum" ), nested_bar_); - reflection->AddEnum(message, F("repeated_foreign_enum"), foreign_bar_); - reflection->AddEnum(message, F("repeated_import_enum" ), import_bar_); - - reflection->AddString(message, F("repeated_string_piece"), "224"); - reflection->AddString(message, F("repeated_cord"), "225"); - - // Add a second one of each field. - reflection->AddInt32 (message, F("repeated_int32" ), 301); - reflection->AddInt64 (message, F("repeated_int64" ), 302); - reflection->AddUInt32(message, F("repeated_uint32" ), 303); - reflection->AddUInt64(message, F("repeated_uint64" ), 304); - reflection->AddInt32 (message, F("repeated_sint32" ), 305); - reflection->AddInt64 (message, F("repeated_sint64" ), 306); - reflection->AddUInt32(message, F("repeated_fixed32" ), 307); - reflection->AddUInt64(message, F("repeated_fixed64" ), 308); - reflection->AddInt32 (message, F("repeated_sfixed32"), 309); - reflection->AddInt64 (message, F("repeated_sfixed64"), 310); - reflection->AddFloat (message, F("repeated_float" ), 311); - reflection->AddDouble(message, F("repeated_double" ), 312); - reflection->AddBool (message, F("repeated_bool" ), false); - reflection->AddString(message, F("repeated_string" ), "315"); - reflection->AddString(message, F("repeated_bytes" ), "316"); - - sub_message = reflection->AddMessage(message, F("repeatedgroup")); - sub_message->GetReflection()->SetInt32(sub_message, repeated_group_a_, 317); - sub_message = reflection->AddMessage(message, F("repeated_nested_message")); - sub_message->GetReflection()->SetInt32(sub_message, nested_b_, 318); - sub_message = reflection->AddMessage(message, F("repeated_foreign_message")); - sub_message->GetReflection()->SetInt32(sub_message, foreign_c_, 319); - sub_message = reflection->AddMessage(message, F("repeated_import_message")); - sub_message->GetReflection()->SetInt32(sub_message, import_d_, 320); - sub_message = reflection->AddMessage(message, F("repeated_lazy_message")); - sub_message->GetReflection()->SetInt32(sub_message, nested_b_, 327); - - reflection->AddEnum(message, F("repeated_nested_enum" ), nested_baz_); - reflection->AddEnum(message, F("repeated_foreign_enum"), foreign_baz_); - reflection->AddEnum(message, F("repeated_import_enum" ), import_baz_); - - reflection->AddString(message, F("repeated_string_piece"), "324"); - reflection->AddString(message, F("repeated_cord"), "325"); - - // ----------------------------------------------------------------- - - reflection->SetInt32 (message, F("default_int32" ), 401); - reflection->SetInt64 (message, F("default_int64" ), 402); - reflection->SetUInt32(message, F("default_uint32" ), 403); - reflection->SetUInt64(message, F("default_uint64" ), 404); - reflection->SetInt32 (message, F("default_sint32" ), 405); - reflection->SetInt64 (message, F("default_sint64" ), 406); - reflection->SetUInt32(message, F("default_fixed32" ), 407); - reflection->SetUInt64(message, F("default_fixed64" ), 408); - reflection->SetInt32 (message, F("default_sfixed32"), 409); - reflection->SetInt64 (message, F("default_sfixed64"), 410); - reflection->SetFloat (message, F("default_float" ), 411); - reflection->SetDouble(message, F("default_double" ), 412); - reflection->SetBool (message, F("default_bool" ), false); - reflection->SetString(message, F("default_string" ), "415"); - reflection->SetString(message, F("default_bytes" ), "416"); - - reflection->SetEnum(message, F("default_nested_enum" ), nested_foo_); - reflection->SetEnum(message, F("default_foreign_enum"), foreign_foo_); - reflection->SetEnum(message, F("default_import_enum" ), import_foo_); - - reflection->SetString(message, F("default_string_piece"), "424"); - reflection->SetString(message, F("default_cord"), "425"); -} - -void TestUtil::ReflectionTester::SetPackedFieldsViaReflection( - Message* message) { - const Reflection* reflection = message->GetReflection(); - reflection->AddInt32 (message, F("packed_int32" ), 601); - reflection->AddInt64 (message, F("packed_int64" ), 602); - reflection->AddUInt32(message, F("packed_uint32" ), 603); - reflection->AddUInt64(message, F("packed_uint64" ), 604); - reflection->AddInt32 (message, F("packed_sint32" ), 605); - reflection->AddInt64 (message, F("packed_sint64" ), 606); - reflection->AddUInt32(message, F("packed_fixed32" ), 607); - reflection->AddUInt64(message, F("packed_fixed64" ), 608); - reflection->AddInt32 (message, F("packed_sfixed32"), 609); - reflection->AddInt64 (message, F("packed_sfixed64"), 610); - reflection->AddFloat (message, F("packed_float" ), 611); - reflection->AddDouble(message, F("packed_double" ), 612); - reflection->AddBool (message, F("packed_bool" ), true); - reflection->AddEnum (message, F("packed_enum" ), foreign_bar_); - - reflection->AddInt32 (message, F("packed_int32" ), 701); - reflection->AddInt64 (message, F("packed_int64" ), 702); - reflection->AddUInt32(message, F("packed_uint32" ), 703); - reflection->AddUInt64(message, F("packed_uint64" ), 704); - reflection->AddInt32 (message, F("packed_sint32" ), 705); - reflection->AddInt64 (message, F("packed_sint64" ), 706); - reflection->AddUInt32(message, F("packed_fixed32" ), 707); - reflection->AddUInt64(message, F("packed_fixed64" ), 708); - reflection->AddInt32 (message, F("packed_sfixed32"), 709); - reflection->AddInt64 (message, F("packed_sfixed64"), 710); - reflection->AddFloat (message, F("packed_float" ), 711); - reflection->AddDouble(message, F("packed_double" ), 712); - reflection->AddBool (message, F("packed_bool" ), false); - reflection->AddEnum (message, F("packed_enum" ), foreign_baz_); -} - -// ------------------------------------------------------------------- - -void TestUtil::ReflectionTester::ExpectAllFieldsSetViaReflection( - const Message& message) { - // We have to split this into three function otherwise it creates a stack - // frame so large that it triggers a warning. - ExpectAllFieldsSetViaReflection1(message); - ExpectAllFieldsSetViaReflection2(message); - ExpectAllFieldsSetViaReflection3(message); -} - -void TestUtil::ReflectionTester::ExpectAllFieldsSetViaReflection1( - const Message& message) { - const Reflection* reflection = message.GetReflection(); - string scratch; - const Message* sub_message; - - EXPECT_TRUE(reflection->HasField(message, F("optional_int32" ))); - EXPECT_TRUE(reflection->HasField(message, F("optional_int64" ))); - EXPECT_TRUE(reflection->HasField(message, F("optional_uint32" ))); - EXPECT_TRUE(reflection->HasField(message, F("optional_uint64" ))); - EXPECT_TRUE(reflection->HasField(message, F("optional_sint32" ))); - EXPECT_TRUE(reflection->HasField(message, F("optional_sint64" ))); - EXPECT_TRUE(reflection->HasField(message, F("optional_fixed32" ))); - EXPECT_TRUE(reflection->HasField(message, F("optional_fixed64" ))); - EXPECT_TRUE(reflection->HasField(message, F("optional_sfixed32"))); - EXPECT_TRUE(reflection->HasField(message, F("optional_sfixed64"))); - EXPECT_TRUE(reflection->HasField(message, F("optional_float" ))); - EXPECT_TRUE(reflection->HasField(message, F("optional_double" ))); - EXPECT_TRUE(reflection->HasField(message, F("optional_bool" ))); - EXPECT_TRUE(reflection->HasField(message, F("optional_string" ))); - EXPECT_TRUE(reflection->HasField(message, F("optional_bytes" ))); - - EXPECT_TRUE(reflection->HasField(message, F("optionalgroup" ))); - EXPECT_TRUE(reflection->HasField(message, F("optional_nested_message" ))); - EXPECT_TRUE(reflection->HasField(message, F("optional_foreign_message" ))); - EXPECT_TRUE(reflection->HasField(message, F("optional_import_message" ))); - EXPECT_TRUE(reflection->HasField(message, F("optional_public_import_message"))); - EXPECT_TRUE(reflection->HasField(message, F("optional_lazy_message" ))); - - sub_message = &reflection->GetMessage(message, F("optionalgroup")); - EXPECT_TRUE(sub_message->GetReflection()->HasField(*sub_message, group_a_)); - sub_message = &reflection->GetMessage(message, F("optional_nested_message")); - EXPECT_TRUE(sub_message->GetReflection()->HasField(*sub_message, nested_b_)); - sub_message = &reflection->GetMessage(message, F("optional_foreign_message")); - EXPECT_TRUE(sub_message->GetReflection()->HasField(*sub_message, foreign_c_)); - sub_message = &reflection->GetMessage(message, F("optional_import_message")); - EXPECT_TRUE(sub_message->GetReflection()->HasField(*sub_message, import_d_)); - sub_message = &reflection->GetMessage(message, F("optional_public_import_message")); - EXPECT_TRUE(sub_message->GetReflection()->HasField(*sub_message, import_e_)); - sub_message = &reflection->GetMessage(message, F("optional_lazy_message")); - EXPECT_TRUE(sub_message->GetReflection()->HasField(*sub_message, nested_b_)); - - EXPECT_TRUE(reflection->HasField(message, F("optional_nested_enum" ))); - EXPECT_TRUE(reflection->HasField(message, F("optional_foreign_enum"))); - EXPECT_TRUE(reflection->HasField(message, F("optional_import_enum" ))); - - EXPECT_TRUE(reflection->HasField(message, F("optional_string_piece"))); - EXPECT_TRUE(reflection->HasField(message, F("optional_cord"))); - - EXPECT_EQ(101 , reflection->GetInt32 (message, F("optional_int32" ))); - EXPECT_EQ(102 , reflection->GetInt64 (message, F("optional_int64" ))); - EXPECT_EQ(103 , reflection->GetUInt32(message, F("optional_uint32" ))); - EXPECT_EQ(104 , reflection->GetUInt64(message, F("optional_uint64" ))); - EXPECT_EQ(105 , reflection->GetInt32 (message, F("optional_sint32" ))); - EXPECT_EQ(106 , reflection->GetInt64 (message, F("optional_sint64" ))); - EXPECT_EQ(107 , reflection->GetUInt32(message, F("optional_fixed32" ))); - EXPECT_EQ(108 , reflection->GetUInt64(message, F("optional_fixed64" ))); - EXPECT_EQ(109 , reflection->GetInt32 (message, F("optional_sfixed32"))); - EXPECT_EQ(110 , reflection->GetInt64 (message, F("optional_sfixed64"))); - EXPECT_EQ(111 , reflection->GetFloat (message, F("optional_float" ))); - EXPECT_EQ(112 , reflection->GetDouble(message, F("optional_double" ))); - EXPECT_TRUE( reflection->GetBool (message, F("optional_bool" ))); - EXPECT_EQ("115", reflection->GetString(message, F("optional_string" ))); - EXPECT_EQ("116", reflection->GetString(message, F("optional_bytes" ))); - - EXPECT_EQ("115", reflection->GetStringReference(message, F("optional_string"), &scratch)); - EXPECT_EQ("116", reflection->GetStringReference(message, F("optional_bytes" ), &scratch)); - - sub_message = &reflection->GetMessage(message, F("optionalgroup")); - EXPECT_EQ(117, sub_message->GetReflection()->GetInt32(*sub_message, group_a_)); - sub_message = &reflection->GetMessage(message, F("optional_nested_message")); - EXPECT_EQ(118, sub_message->GetReflection()->GetInt32(*sub_message, nested_b_)); - sub_message = &reflection->GetMessage(message, F("optional_foreign_message")); - EXPECT_EQ(119, sub_message->GetReflection()->GetInt32(*sub_message, foreign_c_)); - sub_message = &reflection->GetMessage(message, F("optional_import_message")); - EXPECT_EQ(120, sub_message->GetReflection()->GetInt32(*sub_message, import_d_)); - sub_message = &reflection->GetMessage(message, F("optional_public_import_message")); - EXPECT_EQ(126, sub_message->GetReflection()->GetInt32(*sub_message, import_e_)); - sub_message = &reflection->GetMessage(message, F("optional_lazy_message")); - EXPECT_EQ(127, sub_message->GetReflection()->GetInt32(*sub_message, nested_b_)); - - EXPECT_EQ( nested_baz_, reflection->GetEnum(message, F("optional_nested_enum" ))); - EXPECT_EQ(foreign_baz_, reflection->GetEnum(message, F("optional_foreign_enum"))); - EXPECT_EQ( import_baz_, reflection->GetEnum(message, F("optional_import_enum" ))); - - EXPECT_EQ("124", reflection->GetString(message, F("optional_string_piece"))); - EXPECT_EQ("124", reflection->GetStringReference(message, F("optional_string_piece"), &scratch)); - - EXPECT_EQ("125", reflection->GetString(message, F("optional_cord"))); - EXPECT_EQ("125", reflection->GetStringReference(message, F("optional_cord"), &scratch)); - -} - -void TestUtil::ReflectionTester::ExpectAllFieldsSetViaReflection2( - const Message& message) { - const Reflection* reflection = message.GetReflection(); - string scratch; - const Message* sub_message; - - // ----------------------------------------------------------------- - - ASSERT_EQ(2, reflection->FieldSize(message, F("repeated_int32" ))); - ASSERT_EQ(2, reflection->FieldSize(message, F("repeated_int64" ))); - ASSERT_EQ(2, reflection->FieldSize(message, F("repeated_uint32" ))); - ASSERT_EQ(2, reflection->FieldSize(message, F("repeated_uint64" ))); - ASSERT_EQ(2, reflection->FieldSize(message, F("repeated_sint32" ))); - ASSERT_EQ(2, reflection->FieldSize(message, F("repeated_sint64" ))); - ASSERT_EQ(2, reflection->FieldSize(message, F("repeated_fixed32" ))); - ASSERT_EQ(2, reflection->FieldSize(message, F("repeated_fixed64" ))); - ASSERT_EQ(2, reflection->FieldSize(message, F("repeated_sfixed32"))); - ASSERT_EQ(2, reflection->FieldSize(message, F("repeated_sfixed64"))); - ASSERT_EQ(2, reflection->FieldSize(message, F("repeated_float" ))); - ASSERT_EQ(2, reflection->FieldSize(message, F("repeated_double" ))); - ASSERT_EQ(2, reflection->FieldSize(message, F("repeated_bool" ))); - ASSERT_EQ(2, reflection->FieldSize(message, F("repeated_string" ))); - ASSERT_EQ(2, reflection->FieldSize(message, F("repeated_bytes" ))); - - ASSERT_EQ(2, reflection->FieldSize(message, F("repeatedgroup" ))); - ASSERT_EQ(2, reflection->FieldSize(message, F("repeated_nested_message" ))); - ASSERT_EQ(2, reflection->FieldSize(message, F("repeated_foreign_message"))); - ASSERT_EQ(2, reflection->FieldSize(message, F("repeated_import_message" ))); - ASSERT_EQ(2, reflection->FieldSize(message, F("repeated_lazy_message" ))); - ASSERT_EQ(2, reflection->FieldSize(message, F("repeated_nested_enum" ))); - ASSERT_EQ(2, reflection->FieldSize(message, F("repeated_foreign_enum" ))); - ASSERT_EQ(2, reflection->FieldSize(message, F("repeated_import_enum" ))); - - ASSERT_EQ(2, reflection->FieldSize(message, F("repeated_string_piece"))); - ASSERT_EQ(2, reflection->FieldSize(message, F("repeated_cord"))); - - EXPECT_EQ(201 , reflection->GetRepeatedInt32 (message, F("repeated_int32" ), 0)); - EXPECT_EQ(202 , reflection->GetRepeatedInt64 (message, F("repeated_int64" ), 0)); - EXPECT_EQ(203 , reflection->GetRepeatedUInt32(message, F("repeated_uint32" ), 0)); - EXPECT_EQ(204 , reflection->GetRepeatedUInt64(message, F("repeated_uint64" ), 0)); - EXPECT_EQ(205 , reflection->GetRepeatedInt32 (message, F("repeated_sint32" ), 0)); - EXPECT_EQ(206 , reflection->GetRepeatedInt64 (message, F("repeated_sint64" ), 0)); - EXPECT_EQ(207 , reflection->GetRepeatedUInt32(message, F("repeated_fixed32" ), 0)); - EXPECT_EQ(208 , reflection->GetRepeatedUInt64(message, F("repeated_fixed64" ), 0)); - EXPECT_EQ(209 , reflection->GetRepeatedInt32 (message, F("repeated_sfixed32"), 0)); - EXPECT_EQ(210 , reflection->GetRepeatedInt64 (message, F("repeated_sfixed64"), 0)); - EXPECT_EQ(211 , reflection->GetRepeatedFloat (message, F("repeated_float" ), 0)); - EXPECT_EQ(212 , reflection->GetRepeatedDouble(message, F("repeated_double" ), 0)); - EXPECT_TRUE( reflection->GetRepeatedBool (message, F("repeated_bool" ), 0)); - EXPECT_EQ("215", reflection->GetRepeatedString(message, F("repeated_string" ), 0)); - EXPECT_EQ("216", reflection->GetRepeatedString(message, F("repeated_bytes" ), 0)); - - EXPECT_EQ("215", reflection->GetRepeatedStringReference(message, F("repeated_string"), 0, &scratch)); - EXPECT_EQ("216", reflection->GetRepeatedStringReference(message, F("repeated_bytes"), 0, &scratch)); - - sub_message = &reflection->GetRepeatedMessage(message, F("repeatedgroup"), 0); - EXPECT_EQ(217, sub_message->GetReflection()->GetInt32(*sub_message, repeated_group_a_)); - sub_message = &reflection->GetRepeatedMessage(message, F("repeated_nested_message"), 0); - EXPECT_EQ(218, sub_message->GetReflection()->GetInt32(*sub_message, nested_b_)); - sub_message = &reflection->GetRepeatedMessage(message, F("repeated_foreign_message"), 0); - EXPECT_EQ(219, sub_message->GetReflection()->GetInt32(*sub_message, foreign_c_)); - sub_message = &reflection->GetRepeatedMessage(message, F("repeated_import_message"), 0); - EXPECT_EQ(220, sub_message->GetReflection()->GetInt32(*sub_message, import_d_)); - sub_message = &reflection->GetRepeatedMessage(message, F("repeated_lazy_message"), 0); - EXPECT_EQ(227, sub_message->GetReflection()->GetInt32(*sub_message, nested_b_)); - - EXPECT_EQ( nested_bar_, reflection->GetRepeatedEnum(message, F("repeated_nested_enum" ),0)); - EXPECT_EQ(foreign_bar_, reflection->GetRepeatedEnum(message, F("repeated_foreign_enum"),0)); - EXPECT_EQ( import_bar_, reflection->GetRepeatedEnum(message, F("repeated_import_enum" ),0)); - - EXPECT_EQ("224", reflection->GetRepeatedString(message, F("repeated_string_piece"), 0)); - EXPECT_EQ("224", reflection->GetRepeatedStringReference( - message, F("repeated_string_piece"), 0, &scratch)); - - EXPECT_EQ("225", reflection->GetRepeatedString(message, F("repeated_cord"), 0)); - EXPECT_EQ("225", reflection->GetRepeatedStringReference( - message, F("repeated_cord"), 0, &scratch)); - - EXPECT_EQ(301 , reflection->GetRepeatedInt32 (message, F("repeated_int32" ), 1)); - EXPECT_EQ(302 , reflection->GetRepeatedInt64 (message, F("repeated_int64" ), 1)); - EXPECT_EQ(303 , reflection->GetRepeatedUInt32(message, F("repeated_uint32" ), 1)); - EXPECT_EQ(304 , reflection->GetRepeatedUInt64(message, F("repeated_uint64" ), 1)); - EXPECT_EQ(305 , reflection->GetRepeatedInt32 (message, F("repeated_sint32" ), 1)); - EXPECT_EQ(306 , reflection->GetRepeatedInt64 (message, F("repeated_sint64" ), 1)); - EXPECT_EQ(307 , reflection->GetRepeatedUInt32(message, F("repeated_fixed32" ), 1)); - EXPECT_EQ(308 , reflection->GetRepeatedUInt64(message, F("repeated_fixed64" ), 1)); - EXPECT_EQ(309 , reflection->GetRepeatedInt32 (message, F("repeated_sfixed32"), 1)); - EXPECT_EQ(310 , reflection->GetRepeatedInt64 (message, F("repeated_sfixed64"), 1)); - EXPECT_EQ(311 , reflection->GetRepeatedFloat (message, F("repeated_float" ), 1)); - EXPECT_EQ(312 , reflection->GetRepeatedDouble(message, F("repeated_double" ), 1)); - EXPECT_FALSE( reflection->GetRepeatedBool (message, F("repeated_bool" ), 1)); - EXPECT_EQ("315", reflection->GetRepeatedString(message, F("repeated_string" ), 1)); - EXPECT_EQ("316", reflection->GetRepeatedString(message, F("repeated_bytes" ), 1)); - - EXPECT_EQ("315", reflection->GetRepeatedStringReference(message, F("repeated_string"), - 1, &scratch)); - EXPECT_EQ("316", reflection->GetRepeatedStringReference(message, F("repeated_bytes"), - 1, &scratch)); - - sub_message = &reflection->GetRepeatedMessage(message, F("repeatedgroup"), 1); - EXPECT_EQ(317, sub_message->GetReflection()->GetInt32(*sub_message, repeated_group_a_)); - sub_message = &reflection->GetRepeatedMessage(message, F("repeated_nested_message"), 1); - EXPECT_EQ(318, sub_message->GetReflection()->GetInt32(*sub_message, nested_b_)); - sub_message = &reflection->GetRepeatedMessage(message, F("repeated_foreign_message"), 1); - EXPECT_EQ(319, sub_message->GetReflection()->GetInt32(*sub_message, foreign_c_)); - sub_message = &reflection->GetRepeatedMessage(message, F("repeated_import_message"), 1); - EXPECT_EQ(320, sub_message->GetReflection()->GetInt32(*sub_message, import_d_)); - sub_message = &reflection->GetRepeatedMessage(message, F("repeated_lazy_message"), 1); - EXPECT_EQ(327, sub_message->GetReflection()->GetInt32(*sub_message, nested_b_)); - - EXPECT_EQ( nested_baz_, reflection->GetRepeatedEnum(message, F("repeated_nested_enum" ),1)); - EXPECT_EQ(foreign_baz_, reflection->GetRepeatedEnum(message, F("repeated_foreign_enum"),1)); - EXPECT_EQ( import_baz_, reflection->GetRepeatedEnum(message, F("repeated_import_enum" ),1)); - - EXPECT_EQ("324", reflection->GetRepeatedString(message, F("repeated_string_piece"), 1)); - EXPECT_EQ("324", reflection->GetRepeatedStringReference( - message, F("repeated_string_piece"), 1, &scratch)); - - EXPECT_EQ("325", reflection->GetRepeatedString(message, F("repeated_cord"), 1)); - EXPECT_EQ("325", reflection->GetRepeatedStringReference( - message, F("repeated_cord"), 1, &scratch)); -} - -void TestUtil::ReflectionTester::ExpectAllFieldsSetViaReflection3( - const Message& message) { - const Reflection* reflection = message.GetReflection(); - string scratch; - - // ----------------------------------------------------------------- - - EXPECT_TRUE(reflection->HasField(message, F("default_int32" ))); - EXPECT_TRUE(reflection->HasField(message, F("default_int64" ))); - EXPECT_TRUE(reflection->HasField(message, F("default_uint32" ))); - EXPECT_TRUE(reflection->HasField(message, F("default_uint64" ))); - EXPECT_TRUE(reflection->HasField(message, F("default_sint32" ))); - EXPECT_TRUE(reflection->HasField(message, F("default_sint64" ))); - EXPECT_TRUE(reflection->HasField(message, F("default_fixed32" ))); - EXPECT_TRUE(reflection->HasField(message, F("default_fixed64" ))); - EXPECT_TRUE(reflection->HasField(message, F("default_sfixed32"))); - EXPECT_TRUE(reflection->HasField(message, F("default_sfixed64"))); - EXPECT_TRUE(reflection->HasField(message, F("default_float" ))); - EXPECT_TRUE(reflection->HasField(message, F("default_double" ))); - EXPECT_TRUE(reflection->HasField(message, F("default_bool" ))); - EXPECT_TRUE(reflection->HasField(message, F("default_string" ))); - EXPECT_TRUE(reflection->HasField(message, F("default_bytes" ))); - - EXPECT_TRUE(reflection->HasField(message, F("default_nested_enum" ))); - EXPECT_TRUE(reflection->HasField(message, F("default_foreign_enum"))); - EXPECT_TRUE(reflection->HasField(message, F("default_import_enum" ))); - - EXPECT_TRUE(reflection->HasField(message, F("default_string_piece"))); - EXPECT_TRUE(reflection->HasField(message, F("default_cord"))); - - EXPECT_EQ(401 , reflection->GetInt32 (message, F("default_int32" ))); - EXPECT_EQ(402 , reflection->GetInt64 (message, F("default_int64" ))); - EXPECT_EQ(403 , reflection->GetUInt32(message, F("default_uint32" ))); - EXPECT_EQ(404 , reflection->GetUInt64(message, F("default_uint64" ))); - EXPECT_EQ(405 , reflection->GetInt32 (message, F("default_sint32" ))); - EXPECT_EQ(406 , reflection->GetInt64 (message, F("default_sint64" ))); - EXPECT_EQ(407 , reflection->GetUInt32(message, F("default_fixed32" ))); - EXPECT_EQ(408 , reflection->GetUInt64(message, F("default_fixed64" ))); - EXPECT_EQ(409 , reflection->GetInt32 (message, F("default_sfixed32"))); - EXPECT_EQ(410 , reflection->GetInt64 (message, F("default_sfixed64"))); - EXPECT_EQ(411 , reflection->GetFloat (message, F("default_float" ))); - EXPECT_EQ(412 , reflection->GetDouble(message, F("default_double" ))); - EXPECT_FALSE( reflection->GetBool (message, F("default_bool" ))); - EXPECT_EQ("415", reflection->GetString(message, F("default_string" ))); - EXPECT_EQ("416", reflection->GetString(message, F("default_bytes" ))); - - EXPECT_EQ("415", reflection->GetStringReference(message, F("default_string"), &scratch)); - EXPECT_EQ("416", reflection->GetStringReference(message, F("default_bytes" ), &scratch)); - - EXPECT_EQ( nested_foo_, reflection->GetEnum(message, F("default_nested_enum" ))); - EXPECT_EQ(foreign_foo_, reflection->GetEnum(message, F("default_foreign_enum"))); - EXPECT_EQ( import_foo_, reflection->GetEnum(message, F("default_import_enum" ))); - - EXPECT_EQ("424", reflection->GetString(message, F("default_string_piece"))); - EXPECT_EQ("424", reflection->GetStringReference(message, F("default_string_piece"), - &scratch)); - - EXPECT_EQ("425", reflection->GetString(message, F("default_cord"))); - EXPECT_EQ("425", reflection->GetStringReference(message, F("default_cord"), &scratch)); -} - -void TestUtil::ReflectionTester::ExpectPackedFieldsSetViaReflection( - const Message& message) { - const Reflection* reflection = message.GetReflection(); - - ASSERT_EQ(2, reflection->FieldSize(message, F("packed_int32" ))); - ASSERT_EQ(2, reflection->FieldSize(message, F("packed_int64" ))); - ASSERT_EQ(2, reflection->FieldSize(message, F("packed_uint32" ))); - ASSERT_EQ(2, reflection->FieldSize(message, F("packed_uint64" ))); - ASSERT_EQ(2, reflection->FieldSize(message, F("packed_sint32" ))); - ASSERT_EQ(2, reflection->FieldSize(message, F("packed_sint64" ))); - ASSERT_EQ(2, reflection->FieldSize(message, F("packed_fixed32" ))); - ASSERT_EQ(2, reflection->FieldSize(message, F("packed_fixed64" ))); - ASSERT_EQ(2, reflection->FieldSize(message, F("packed_sfixed32"))); - ASSERT_EQ(2, reflection->FieldSize(message, F("packed_sfixed64"))); - ASSERT_EQ(2, reflection->FieldSize(message, F("packed_float" ))); - ASSERT_EQ(2, reflection->FieldSize(message, F("packed_double" ))); - ASSERT_EQ(2, reflection->FieldSize(message, F("packed_bool" ))); - ASSERT_EQ(2, reflection->FieldSize(message, F("packed_enum" ))); - - EXPECT_EQ(601 , reflection->GetRepeatedInt32 (message, F("packed_int32" ), 0)); - EXPECT_EQ(602 , reflection->GetRepeatedInt64 (message, F("packed_int64" ), 0)); - EXPECT_EQ(603 , reflection->GetRepeatedUInt32(message, F("packed_uint32" ), 0)); - EXPECT_EQ(604 , reflection->GetRepeatedUInt64(message, F("packed_uint64" ), 0)); - EXPECT_EQ(605 , reflection->GetRepeatedInt32 (message, F("packed_sint32" ), 0)); - EXPECT_EQ(606 , reflection->GetRepeatedInt64 (message, F("packed_sint64" ), 0)); - EXPECT_EQ(607 , reflection->GetRepeatedUInt32(message, F("packed_fixed32" ), 0)); - EXPECT_EQ(608 , reflection->GetRepeatedUInt64(message, F("packed_fixed64" ), 0)); - EXPECT_EQ(609 , reflection->GetRepeatedInt32 (message, F("packed_sfixed32"), 0)); - EXPECT_EQ(610 , reflection->GetRepeatedInt64 (message, F("packed_sfixed64"), 0)); - EXPECT_EQ(611 , reflection->GetRepeatedFloat (message, F("packed_float" ), 0)); - EXPECT_EQ(612 , reflection->GetRepeatedDouble(message, F("packed_double" ), 0)); - EXPECT_TRUE( reflection->GetRepeatedBool (message, F("packed_bool" ), 0)); - EXPECT_EQ(foreign_bar_, - reflection->GetRepeatedEnum(message, F("packed_enum"), 0)); - - EXPECT_EQ(701 , reflection->GetRepeatedInt32 (message, F("packed_int32" ), 1)); - EXPECT_EQ(702 , reflection->GetRepeatedInt64 (message, F("packed_int64" ), 1)); - EXPECT_EQ(703 , reflection->GetRepeatedUInt32(message, F("packed_uint32" ), 1)); - EXPECT_EQ(704 , reflection->GetRepeatedUInt64(message, F("packed_uint64" ), 1)); - EXPECT_EQ(705 , reflection->GetRepeatedInt32 (message, F("packed_sint32" ), 1)); - EXPECT_EQ(706 , reflection->GetRepeatedInt64 (message, F("packed_sint64" ), 1)); - EXPECT_EQ(707 , reflection->GetRepeatedUInt32(message, F("packed_fixed32" ), 1)); - EXPECT_EQ(708 , reflection->GetRepeatedUInt64(message, F("packed_fixed64" ), 1)); - EXPECT_EQ(709 , reflection->GetRepeatedInt32 (message, F("packed_sfixed32"), 1)); - EXPECT_EQ(710 , reflection->GetRepeatedInt64 (message, F("packed_sfixed64"), 1)); - EXPECT_EQ(711 , reflection->GetRepeatedFloat (message, F("packed_float" ), 1)); - EXPECT_EQ(712 , reflection->GetRepeatedDouble(message, F("packed_double" ), 1)); - EXPECT_FALSE( reflection->GetRepeatedBool (message, F("packed_bool" ), 1)); - EXPECT_EQ(foreign_baz_, - reflection->GetRepeatedEnum(message, F("packed_enum"), 1)); -} - -// ------------------------------------------------------------------- - -void TestUtil::ReflectionTester::ExpectClearViaReflection( - const Message& message) { - const Reflection* reflection = message.GetReflection(); - string scratch; - const Message* sub_message; - - // has_blah() should initially be false for all optional fields. - EXPECT_FALSE(reflection->HasField(message, F("optional_int32" ))); - EXPECT_FALSE(reflection->HasField(message, F("optional_int64" ))); - EXPECT_FALSE(reflection->HasField(message, F("optional_uint32" ))); - EXPECT_FALSE(reflection->HasField(message, F("optional_uint64" ))); - EXPECT_FALSE(reflection->HasField(message, F("optional_sint32" ))); - EXPECT_FALSE(reflection->HasField(message, F("optional_sint64" ))); - EXPECT_FALSE(reflection->HasField(message, F("optional_fixed32" ))); - EXPECT_FALSE(reflection->HasField(message, F("optional_fixed64" ))); - EXPECT_FALSE(reflection->HasField(message, F("optional_sfixed32"))); - EXPECT_FALSE(reflection->HasField(message, F("optional_sfixed64"))); - EXPECT_FALSE(reflection->HasField(message, F("optional_float" ))); - EXPECT_FALSE(reflection->HasField(message, F("optional_double" ))); - EXPECT_FALSE(reflection->HasField(message, F("optional_bool" ))); - EXPECT_FALSE(reflection->HasField(message, F("optional_string" ))); - EXPECT_FALSE(reflection->HasField(message, F("optional_bytes" ))); - - EXPECT_FALSE(reflection->HasField(message, F("optionalgroup" ))); - EXPECT_FALSE(reflection->HasField(message, F("optional_nested_message" ))); - EXPECT_FALSE(reflection->HasField(message, F("optional_foreign_message"))); - EXPECT_FALSE(reflection->HasField(message, F("optional_import_message" ))); - EXPECT_FALSE(reflection->HasField(message, F("optional_public_import_message"))); - EXPECT_FALSE(reflection->HasField(message, F("optional_lazy_message"))); - - EXPECT_FALSE(reflection->HasField(message, F("optional_nested_enum" ))); - EXPECT_FALSE(reflection->HasField(message, F("optional_foreign_enum"))); - EXPECT_FALSE(reflection->HasField(message, F("optional_import_enum" ))); - - EXPECT_FALSE(reflection->HasField(message, F("optional_string_piece"))); - EXPECT_FALSE(reflection->HasField(message, F("optional_cord"))); - - // Optional fields without defaults are set to zero or something like it. - EXPECT_EQ(0 , reflection->GetInt32 (message, F("optional_int32" ))); - EXPECT_EQ(0 , reflection->GetInt64 (message, F("optional_int64" ))); - EXPECT_EQ(0 , reflection->GetUInt32(message, F("optional_uint32" ))); - EXPECT_EQ(0 , reflection->GetUInt64(message, F("optional_uint64" ))); - EXPECT_EQ(0 , reflection->GetInt32 (message, F("optional_sint32" ))); - EXPECT_EQ(0 , reflection->GetInt64 (message, F("optional_sint64" ))); - EXPECT_EQ(0 , reflection->GetUInt32(message, F("optional_fixed32" ))); - EXPECT_EQ(0 , reflection->GetUInt64(message, F("optional_fixed64" ))); - EXPECT_EQ(0 , reflection->GetInt32 (message, F("optional_sfixed32"))); - EXPECT_EQ(0 , reflection->GetInt64 (message, F("optional_sfixed64"))); - EXPECT_EQ(0 , reflection->GetFloat (message, F("optional_float" ))); - EXPECT_EQ(0 , reflection->GetDouble(message, F("optional_double" ))); - EXPECT_FALSE( reflection->GetBool (message, F("optional_bool" ))); - EXPECT_EQ("" , reflection->GetString(message, F("optional_string" ))); - EXPECT_EQ("" , reflection->GetString(message, F("optional_bytes" ))); - - EXPECT_EQ("", reflection->GetStringReference(message, F("optional_string"), &scratch)); - EXPECT_EQ("", reflection->GetStringReference(message, F("optional_bytes" ), &scratch)); - - // Embedded messages should also be clear. - sub_message = &reflection->GetMessage(message, F("optionalgroup")); - EXPECT_FALSE(sub_message->GetReflection()->HasField(*sub_message, group_a_)); - EXPECT_EQ(0, sub_message->GetReflection()->GetInt32(*sub_message, group_a_)); - sub_message = &reflection->GetMessage(message, F("optional_nested_message")); - EXPECT_FALSE(sub_message->GetReflection()->HasField(*sub_message, nested_b_)); - EXPECT_EQ(0, sub_message->GetReflection()->GetInt32(*sub_message, nested_b_)); - sub_message = &reflection->GetMessage(message, F("optional_foreign_message")); - EXPECT_FALSE(sub_message->GetReflection()->HasField(*sub_message, foreign_c_)); - EXPECT_EQ(0, sub_message->GetReflection()->GetInt32(*sub_message, foreign_c_)); - sub_message = &reflection->GetMessage(message, F("optional_import_message")); - EXPECT_FALSE(sub_message->GetReflection()->HasField(*sub_message, import_d_)); - EXPECT_EQ(0, sub_message->GetReflection()->GetInt32(*sub_message, import_d_)); - sub_message = &reflection->GetMessage(message, F("optional_public_import_message")); - EXPECT_FALSE(sub_message->GetReflection()->HasField(*sub_message, import_e_)); - EXPECT_EQ(0, sub_message->GetReflection()->GetInt32(*sub_message, import_e_)); - sub_message = &reflection->GetMessage(message, F("optional_lazy_message")); - EXPECT_FALSE(sub_message->GetReflection()->HasField(*sub_message, nested_b_)); - EXPECT_EQ(0, sub_message->GetReflection()->GetInt32(*sub_message, nested_b_)); - - // Enums without defaults are set to the first value in the enum. - EXPECT_EQ( nested_foo_, reflection->GetEnum(message, F("optional_nested_enum" ))); - EXPECT_EQ(foreign_foo_, reflection->GetEnum(message, F("optional_foreign_enum"))); - EXPECT_EQ( import_foo_, reflection->GetEnum(message, F("optional_import_enum" ))); - - EXPECT_EQ("", reflection->GetString(message, F("optional_string_piece"))); - EXPECT_EQ("", reflection->GetStringReference(message, F("optional_string_piece"), &scratch)); - - EXPECT_EQ("", reflection->GetString(message, F("optional_cord"))); - EXPECT_EQ("", reflection->GetStringReference(message, F("optional_cord"), &scratch)); - - // Repeated fields are empty. - EXPECT_EQ(0, reflection->FieldSize(message, F("repeated_int32" ))); - EXPECT_EQ(0, reflection->FieldSize(message, F("repeated_int64" ))); - EXPECT_EQ(0, reflection->FieldSize(message, F("repeated_uint32" ))); - EXPECT_EQ(0, reflection->FieldSize(message, F("repeated_uint64" ))); - EXPECT_EQ(0, reflection->FieldSize(message, F("repeated_sint32" ))); - EXPECT_EQ(0, reflection->FieldSize(message, F("repeated_sint64" ))); - EXPECT_EQ(0, reflection->FieldSize(message, F("repeated_fixed32" ))); - EXPECT_EQ(0, reflection->FieldSize(message, F("repeated_fixed64" ))); - EXPECT_EQ(0, reflection->FieldSize(message, F("repeated_sfixed32"))); - EXPECT_EQ(0, reflection->FieldSize(message, F("repeated_sfixed64"))); - EXPECT_EQ(0, reflection->FieldSize(message, F("repeated_float" ))); - EXPECT_EQ(0, reflection->FieldSize(message, F("repeated_double" ))); - EXPECT_EQ(0, reflection->FieldSize(message, F("repeated_bool" ))); - EXPECT_EQ(0, reflection->FieldSize(message, F("repeated_string" ))); - EXPECT_EQ(0, reflection->FieldSize(message, F("repeated_bytes" ))); - - EXPECT_EQ(0, reflection->FieldSize(message, F("repeatedgroup" ))); - EXPECT_EQ(0, reflection->FieldSize(message, F("repeated_nested_message" ))); - EXPECT_EQ(0, reflection->FieldSize(message, F("repeated_foreign_message"))); - EXPECT_EQ(0, reflection->FieldSize(message, F("repeated_import_message" ))); - EXPECT_EQ(0, reflection->FieldSize(message, F("repeated_lazy_message" ))); - EXPECT_EQ(0, reflection->FieldSize(message, F("repeated_nested_enum" ))); - EXPECT_EQ(0, reflection->FieldSize(message, F("repeated_foreign_enum" ))); - EXPECT_EQ(0, reflection->FieldSize(message, F("repeated_import_enum" ))); - - EXPECT_EQ(0, reflection->FieldSize(message, F("repeated_string_piece"))); - EXPECT_EQ(0, reflection->FieldSize(message, F("repeated_cord"))); - - // has_blah() should also be false for all default fields. - EXPECT_FALSE(reflection->HasField(message, F("default_int32" ))); - EXPECT_FALSE(reflection->HasField(message, F("default_int64" ))); - EXPECT_FALSE(reflection->HasField(message, F("default_uint32" ))); - EXPECT_FALSE(reflection->HasField(message, F("default_uint64" ))); - EXPECT_FALSE(reflection->HasField(message, F("default_sint32" ))); - EXPECT_FALSE(reflection->HasField(message, F("default_sint64" ))); - EXPECT_FALSE(reflection->HasField(message, F("default_fixed32" ))); - EXPECT_FALSE(reflection->HasField(message, F("default_fixed64" ))); - EXPECT_FALSE(reflection->HasField(message, F("default_sfixed32"))); - EXPECT_FALSE(reflection->HasField(message, F("default_sfixed64"))); - EXPECT_FALSE(reflection->HasField(message, F("default_float" ))); - EXPECT_FALSE(reflection->HasField(message, F("default_double" ))); - EXPECT_FALSE(reflection->HasField(message, F("default_bool" ))); - EXPECT_FALSE(reflection->HasField(message, F("default_string" ))); - EXPECT_FALSE(reflection->HasField(message, F("default_bytes" ))); - - EXPECT_FALSE(reflection->HasField(message, F("default_nested_enum" ))); - EXPECT_FALSE(reflection->HasField(message, F("default_foreign_enum"))); - EXPECT_FALSE(reflection->HasField(message, F("default_import_enum" ))); - - EXPECT_FALSE(reflection->HasField(message, F("default_string_piece"))); - EXPECT_FALSE(reflection->HasField(message, F("default_cord"))); - - // Fields with defaults have their default values (duh). - EXPECT_EQ( 41 , reflection->GetInt32 (message, F("default_int32" ))); - EXPECT_EQ( 42 , reflection->GetInt64 (message, F("default_int64" ))); - EXPECT_EQ( 43 , reflection->GetUInt32(message, F("default_uint32" ))); - EXPECT_EQ( 44 , reflection->GetUInt64(message, F("default_uint64" ))); - EXPECT_EQ(-45 , reflection->GetInt32 (message, F("default_sint32" ))); - EXPECT_EQ( 46 , reflection->GetInt64 (message, F("default_sint64" ))); - EXPECT_EQ( 47 , reflection->GetUInt32(message, F("default_fixed32" ))); - EXPECT_EQ( 48 , reflection->GetUInt64(message, F("default_fixed64" ))); - EXPECT_EQ( 49 , reflection->GetInt32 (message, F("default_sfixed32"))); - EXPECT_EQ(-50 , reflection->GetInt64 (message, F("default_sfixed64"))); - EXPECT_EQ( 51.5 , reflection->GetFloat (message, F("default_float" ))); - EXPECT_EQ( 52e3 , reflection->GetDouble(message, F("default_double" ))); - EXPECT_TRUE( reflection->GetBool (message, F("default_bool" ))); - EXPECT_EQ("hello", reflection->GetString(message, F("default_string" ))); - EXPECT_EQ("world", reflection->GetString(message, F("default_bytes" ))); - - EXPECT_EQ("hello", reflection->GetStringReference(message, F("default_string"), &scratch)); - EXPECT_EQ("world", reflection->GetStringReference(message, F("default_bytes" ), &scratch)); - - EXPECT_EQ( nested_bar_, reflection->GetEnum(message, F("default_nested_enum" ))); - EXPECT_EQ(foreign_bar_, reflection->GetEnum(message, F("default_foreign_enum"))); - EXPECT_EQ( import_bar_, reflection->GetEnum(message, F("default_import_enum" ))); - - EXPECT_EQ("abc", reflection->GetString(message, F("default_string_piece"))); - EXPECT_EQ("abc", reflection->GetStringReference(message, F("default_string_piece"), &scratch)); - - EXPECT_EQ("123", reflection->GetString(message, F("default_cord"))); - EXPECT_EQ("123", reflection->GetStringReference(message, F("default_cord"), &scratch)); -} - -void TestUtil::ReflectionTester::ExpectPackedClearViaReflection( - const Message& message) { - const Reflection* reflection = message.GetReflection(); - - EXPECT_EQ(0, reflection->FieldSize(message, F("packed_int32" ))); - EXPECT_EQ(0, reflection->FieldSize(message, F("packed_int64" ))); - EXPECT_EQ(0, reflection->FieldSize(message, F("packed_uint32" ))); - EXPECT_EQ(0, reflection->FieldSize(message, F("packed_uint64" ))); - EXPECT_EQ(0, reflection->FieldSize(message, F("packed_sint32" ))); - EXPECT_EQ(0, reflection->FieldSize(message, F("packed_sint64" ))); - EXPECT_EQ(0, reflection->FieldSize(message, F("packed_fixed32" ))); - EXPECT_EQ(0, reflection->FieldSize(message, F("packed_fixed64" ))); - EXPECT_EQ(0, reflection->FieldSize(message, F("packed_sfixed32"))); - EXPECT_EQ(0, reflection->FieldSize(message, F("packed_sfixed64"))); - EXPECT_EQ(0, reflection->FieldSize(message, F("packed_float" ))); - EXPECT_EQ(0, reflection->FieldSize(message, F("packed_double" ))); - EXPECT_EQ(0, reflection->FieldSize(message, F("packed_bool" ))); - EXPECT_EQ(0, reflection->FieldSize(message, F("packed_enum" ))); -} - -// ------------------------------------------------------------------- - -void TestUtil::ReflectionTester::ModifyRepeatedFieldsViaReflection( - Message* message) { - const Reflection* reflection = message->GetReflection(); - Message* sub_message; - - reflection->SetRepeatedInt32 (message, F("repeated_int32" ), 1, 501); - reflection->SetRepeatedInt64 (message, F("repeated_int64" ), 1, 502); - reflection->SetRepeatedUInt32(message, F("repeated_uint32" ), 1, 503); - reflection->SetRepeatedUInt64(message, F("repeated_uint64" ), 1, 504); - reflection->SetRepeatedInt32 (message, F("repeated_sint32" ), 1, 505); - reflection->SetRepeatedInt64 (message, F("repeated_sint64" ), 1, 506); - reflection->SetRepeatedUInt32(message, F("repeated_fixed32" ), 1, 507); - reflection->SetRepeatedUInt64(message, F("repeated_fixed64" ), 1, 508); - reflection->SetRepeatedInt32 (message, F("repeated_sfixed32"), 1, 509); - reflection->SetRepeatedInt64 (message, F("repeated_sfixed64"), 1, 510); - reflection->SetRepeatedFloat (message, F("repeated_float" ), 1, 511); - reflection->SetRepeatedDouble(message, F("repeated_double" ), 1, 512); - reflection->SetRepeatedBool (message, F("repeated_bool" ), 1, true); - reflection->SetRepeatedString(message, F("repeated_string" ), 1, "515"); - reflection->SetRepeatedString(message, F("repeated_bytes" ), 1, "516"); - - sub_message = reflection->MutableRepeatedMessage(message, F("repeatedgroup"), 1); - sub_message->GetReflection()->SetInt32(sub_message, repeated_group_a_, 517); - sub_message = reflection->MutableRepeatedMessage(message, F("repeated_nested_message"), 1); - sub_message->GetReflection()->SetInt32(sub_message, nested_b_, 518); - sub_message = reflection->MutableRepeatedMessage(message, F("repeated_foreign_message"), 1); - sub_message->GetReflection()->SetInt32(sub_message, foreign_c_, 519); - sub_message = reflection->MutableRepeatedMessage(message, F("repeated_import_message"), 1); - sub_message->GetReflection()->SetInt32(sub_message, import_d_, 520); - sub_message = reflection->MutableRepeatedMessage(message, F("repeated_lazy_message"), 1); - sub_message->GetReflection()->SetInt32(sub_message, nested_b_, 527); - - reflection->SetRepeatedEnum(message, F("repeated_nested_enum" ), 1, nested_foo_); - reflection->SetRepeatedEnum(message, F("repeated_foreign_enum"), 1, foreign_foo_); - reflection->SetRepeatedEnum(message, F("repeated_import_enum" ), 1, import_foo_); - - reflection->SetRepeatedString(message, F("repeated_string_piece"), 1, "524"); - reflection->SetRepeatedString(message, F("repeated_cord"), 1, "525"); -} - -void TestUtil::ReflectionTester::ModifyPackedFieldsViaReflection( - Message* message) { - const Reflection* reflection = message->GetReflection(); - reflection->SetRepeatedInt32 (message, F("packed_int32" ), 1, 801); - reflection->SetRepeatedInt64 (message, F("packed_int64" ), 1, 802); - reflection->SetRepeatedUInt32(message, F("packed_uint32" ), 1, 803); - reflection->SetRepeatedUInt64(message, F("packed_uint64" ), 1, 804); - reflection->SetRepeatedInt32 (message, F("packed_sint32" ), 1, 805); - reflection->SetRepeatedInt64 (message, F("packed_sint64" ), 1, 806); - reflection->SetRepeatedUInt32(message, F("packed_fixed32" ), 1, 807); - reflection->SetRepeatedUInt64(message, F("packed_fixed64" ), 1, 808); - reflection->SetRepeatedInt32 (message, F("packed_sfixed32"), 1, 809); - reflection->SetRepeatedInt64 (message, F("packed_sfixed64"), 1, 810); - reflection->SetRepeatedFloat (message, F("packed_float" ), 1, 811); - reflection->SetRepeatedDouble(message, F("packed_double" ), 1, 812); - reflection->SetRepeatedBool (message, F("packed_bool" ), 1, true); - reflection->SetRepeatedEnum (message, F("packed_enum" ), 1, foreign_foo_); -} - -void TestUtil::ReflectionTester::RemoveLastRepeatedsViaReflection( - Message* message) { - const Reflection* reflection = message->GetReflection(); - - vector output; - reflection->ListFields(*message, &output); - for (int i=0; iis_repeated()) continue; - - reflection->RemoveLast(message, field); - } -} - -void TestUtil::ReflectionTester::ReleaseLastRepeatedsViaReflection( - Message* message, bool expect_extensions_notnull) { - const Reflection* reflection = message->GetReflection(); - - vector output; - reflection->ListFields(*message, &output); - for (int i=0; iis_repeated()) continue; - if (field->cpp_type() != FieldDescriptor::CPPTYPE_MESSAGE) continue; - - Message* released = reflection->ReleaseLast(message, field); - if (!field->is_extension() || expect_extensions_notnull) { - ASSERT_TRUE(released != NULL) << "ReleaseLast returned NULL for: " - << field->name(); - } - delete released; - } -} - -void TestUtil::ReflectionTester::SwapRepeatedsViaReflection(Message* message) { - const Reflection* reflection = message->GetReflection(); - - vector output; - reflection->ListFields(*message, &output); - for (int i=0; iis_repeated()) continue; - - reflection->SwapElements(message, field, 0, 1); - } -} - -void TestUtil::ReflectionTester::ExpectMessagesReleasedViaReflection( - Message* message, - TestUtil::ReflectionTester::MessageReleaseState expected_release_state) { - const Reflection* reflection = message->GetReflection(); - - static const char* fields[] = { - "optionalgroup", - "optional_nested_message", - "optional_foreign_message", - "optional_import_message", - }; - for (int i = 0; i < GOOGLE_ARRAYSIZE(fields); i++) { - const Message& sub_message = reflection->GetMessage(*message, F(fields[i])); - Message* released = reflection->ReleaseMessage(message, F(fields[i])); - switch (expected_release_state) { - case IS_NULL: - EXPECT_TRUE(released == NULL); - break; - case NOT_NULL: - EXPECT_TRUE(released != NULL); - EXPECT_EQ(&sub_message, released); - break; - case CAN_BE_NULL: - break; - } - delete released; - EXPECT_FALSE(reflection->HasField(*message, F(fields[i]))); - } -} - -} // namespace protobuf -} // namespace google diff --git a/modules/dnn/3rdparty/protobuf/src/google/protobuf/test_util.h b/modules/dnn/3rdparty/protobuf/src/google/protobuf/test_util.h deleted file mode 100644 index 455195734..000000000 --- a/modules/dnn/3rdparty/protobuf/src/google/protobuf/test_util.h +++ /dev/null @@ -1,193 +0,0 @@ -// Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// http://code.google.com/p/protobuf/ -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -// Author: kenton@google.com (Kenton Varda) -// Based on original Protocol Buffers design by -// Sanjay Ghemawat, Jeff Dean, and others. - -#ifndef GOOGLE_PROTOBUF_TEST_UTIL_H__ -#define GOOGLE_PROTOBUF_TEST_UTIL_H__ - -#include -#include -#include -#include - -namespace google { -namespace protobuf { - -namespace unittest = ::protobuf_unittest; -namespace unittest_import = protobuf_unittest_import; - -class TestUtil { - public: - // Set every field in the message to a unique value. - static void SetAllFields(unittest::TestAllTypes* message); - static void SetOptionalFields(unittest::TestAllTypes* message); - static void AddRepeatedFields1(unittest::TestAllTypes* message); - static void AddRepeatedFields2(unittest::TestAllTypes* message); - static void SetDefaultFields(unittest::TestAllTypes* message); - static void SetAllExtensions(unittest::TestAllExtensions* message); - static void SetAllFieldsAndExtensions(unittest::TestFieldOrderings* message); - static void SetPackedFields(unittest::TestPackedTypes* message); - static void SetPackedExtensions(unittest::TestPackedExtensions* message); - static void SetUnpackedFields(unittest::TestUnpackedTypes* message); - - // Use the repeated versions of the set_*() accessors to modify all the - // repeated fields of the messsage (which should already have been - // initialized with Set*Fields()). Set*Fields() itself only tests - // the add_*() accessors. - static void ModifyRepeatedFields(unittest::TestAllTypes* message); - static void ModifyRepeatedExtensions(unittest::TestAllExtensions* message); - static void ModifyPackedFields(unittest::TestPackedTypes* message); - static void ModifyPackedExtensions(unittest::TestPackedExtensions* message); - - // Check that all fields have the values that they should have after - // Set*Fields() is called. - static void ExpectAllFieldsSet(const unittest::TestAllTypes& message); - static void ExpectAllExtensionsSet( - const unittest::TestAllExtensions& message); - static void ExpectPackedFieldsSet(const unittest::TestPackedTypes& message); - static void ExpectPackedExtensionsSet( - const unittest::TestPackedExtensions& message); - static void ExpectUnpackedFieldsSet( - const unittest::TestUnpackedTypes& message); - - // Expect that the message is modified as would be expected from - // Modify*Fields(). - static void ExpectRepeatedFieldsModified( - const unittest::TestAllTypes& message); - static void ExpectRepeatedExtensionsModified( - const unittest::TestAllExtensions& message); - static void ExpectPackedFieldsModified( - const unittest::TestPackedTypes& message); - static void ExpectPackedExtensionsModified( - const unittest::TestPackedExtensions& message); - - // Check that all fields have their default values. - static void ExpectClear(const unittest::TestAllTypes& message); - static void ExpectExtensionsClear(const unittest::TestAllExtensions& message); - static void ExpectPackedClear(const unittest::TestPackedTypes& message); - static void ExpectPackedExtensionsClear( - const unittest::TestPackedExtensions& message); - - // Check that the passed-in serialization is the canonical serialization we - // expect for a TestFieldOrderings message filled in by - // SetAllFieldsAndExtensions(). - static void ExpectAllFieldsAndExtensionsInOrder(const string& serialized); - - // Check that all repeated fields have had their last elements removed. - static void ExpectLastRepeatedsRemoved( - const unittest::TestAllTypes& message); - static void ExpectLastRepeatedExtensionsRemoved( - const unittest::TestAllExtensions& message); - static void ExpectLastRepeatedsReleased( - const unittest::TestAllTypes& message); - static void ExpectLastRepeatedExtensionsReleased( - const unittest::TestAllExtensions& message); - - // Check that all repeated fields have had their first and last elements - // swapped. - static void ExpectRepeatedsSwapped(const unittest::TestAllTypes& message); - static void ExpectRepeatedExtensionsSwapped( - const unittest::TestAllExtensions& message); - - // Like above, but use the reflection interface. - class ReflectionTester { - public: - // base_descriptor must be a descriptor for TestAllTypes or - // TestAllExtensions. In the former case, ReflectionTester fetches from - // it the FieldDescriptors needed to use the reflection interface. In - // the latter case, ReflectionTester searches for extension fields in - // its file. - explicit ReflectionTester(const Descriptor* base_descriptor); - - void SetAllFieldsViaReflection(Message* message); - void ModifyRepeatedFieldsViaReflection(Message* message); - void ExpectAllFieldsSetViaReflection(const Message& message); - void ExpectClearViaReflection(const Message& message); - - void SetPackedFieldsViaReflection(Message* message); - void ModifyPackedFieldsViaReflection(Message* message); - void ExpectPackedFieldsSetViaReflection(const Message& message); - void ExpectPackedClearViaReflection(const Message& message); - - void RemoveLastRepeatedsViaReflection(Message* message); - void ReleaseLastRepeatedsViaReflection( - Message* message, bool expect_extensions_notnull); - void SwapRepeatedsViaReflection(Message* message); - - enum MessageReleaseState { - IS_NULL, - CAN_BE_NULL, - NOT_NULL, - }; - void ExpectMessagesReleasedViaReflection( - Message* message, MessageReleaseState expected_release_state); - - private: - const FieldDescriptor* F(const string& name); - - const Descriptor* base_descriptor_; - - const FieldDescriptor* group_a_; - const FieldDescriptor* repeated_group_a_; - const FieldDescriptor* nested_b_; - const FieldDescriptor* foreign_c_; - const FieldDescriptor* import_d_; - const FieldDescriptor* import_e_; - - const EnumValueDescriptor* nested_foo_; - const EnumValueDescriptor* nested_bar_; - const EnumValueDescriptor* nested_baz_; - const EnumValueDescriptor* foreign_foo_; - const EnumValueDescriptor* foreign_bar_; - const EnumValueDescriptor* foreign_baz_; - const EnumValueDescriptor* import_foo_; - const EnumValueDescriptor* import_bar_; - const EnumValueDescriptor* import_baz_; - - // We have to split this into three function otherwise it creates a stack - // frame so large that it triggers a warning. - void ExpectAllFieldsSetViaReflection1(const Message& message); - void ExpectAllFieldsSetViaReflection2(const Message& message); - void ExpectAllFieldsSetViaReflection3(const Message& message); - - GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ReflectionTester); - }; - - private: - GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(TestUtil); -}; - -} // namespace protobuf - -} // namespace google -#endif // GOOGLE_PROTOBUF_TEST_UTIL_H__ diff --git a/modules/dnn/3rdparty/protobuf/src/google/protobuf/test_util_lite.cc b/modules/dnn/3rdparty/protobuf/src/google/protobuf/test_util_lite.cc deleted file mode 100644 index 9099292ab..000000000 --- a/modules/dnn/3rdparty/protobuf/src/google/protobuf/test_util_lite.cc +++ /dev/null @@ -1,1548 +0,0 @@ -// Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// http://code.google.com/p/protobuf/ -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -// Author: kenton@google.com (Kenton Varda) -// Based on original Protocol Buffers design by -// Sanjay Ghemawat, Jeff Dean, and others. - -#include -#include - - -#define EXPECT_TRUE GOOGLE_CHECK -#define ASSERT_TRUE GOOGLE_CHECK -#define EXPECT_FALSE(COND) GOOGLE_CHECK(!(COND)) -#define EXPECT_EQ GOOGLE_CHECK_EQ -#define ASSERT_EQ GOOGLE_CHECK_EQ - -namespace google { -namespace protobuf { - -void TestUtilLite::SetAllFields(unittest::TestAllTypesLite* message) { - message->set_optional_int32 (101); - message->set_optional_int64 (102); - message->set_optional_uint32 (103); - message->set_optional_uint64 (104); - message->set_optional_sint32 (105); - message->set_optional_sint64 (106); - message->set_optional_fixed32 (107); - message->set_optional_fixed64 (108); - message->set_optional_sfixed32(109); - message->set_optional_sfixed64(110); - message->set_optional_float (111); - message->set_optional_double (112); - message->set_optional_bool (true); - message->set_optional_string ("115"); - message->set_optional_bytes ("116"); - - message->mutable_optionalgroup ()->set_a(117); - message->mutable_optional_nested_message ()->set_bb(118); - message->mutable_optional_foreign_message ()->set_c(119); - message->mutable_optional_import_message ()->set_d(120); - message->mutable_optional_public_import_message()->set_e(126); - message->mutable_optional_lazy_message ()->set_bb(127); - - message->set_optional_nested_enum (unittest::TestAllTypesLite::BAZ ); - message->set_optional_foreign_enum(unittest::FOREIGN_LITE_BAZ ); - message->set_optional_import_enum (unittest_import::IMPORT_LITE_BAZ); - - - // ----------------------------------------------------------------- - - message->add_repeated_int32 (201); - message->add_repeated_int64 (202); - message->add_repeated_uint32 (203); - message->add_repeated_uint64 (204); - message->add_repeated_sint32 (205); - message->add_repeated_sint64 (206); - message->add_repeated_fixed32 (207); - message->add_repeated_fixed64 (208); - message->add_repeated_sfixed32(209); - message->add_repeated_sfixed64(210); - message->add_repeated_float (211); - message->add_repeated_double (212); - message->add_repeated_bool (true); - message->add_repeated_string ("215"); - message->add_repeated_bytes ("216"); - - message->add_repeatedgroup ()->set_a(217); - message->add_repeated_nested_message ()->set_bb(218); - message->add_repeated_foreign_message()->set_c(219); - message->add_repeated_import_message ()->set_d(220); - message->add_repeated_lazy_message ()->set_bb(227); - - message->add_repeated_nested_enum (unittest::TestAllTypesLite::BAR ); - message->add_repeated_foreign_enum(unittest::FOREIGN_LITE_BAR ); - message->add_repeated_import_enum (unittest_import::IMPORT_LITE_BAR); - - - // Add a second one of each field. - message->add_repeated_int32 (301); - message->add_repeated_int64 (302); - message->add_repeated_uint32 (303); - message->add_repeated_uint64 (304); - message->add_repeated_sint32 (305); - message->add_repeated_sint64 (306); - message->add_repeated_fixed32 (307); - message->add_repeated_fixed64 (308); - message->add_repeated_sfixed32(309); - message->add_repeated_sfixed64(310); - message->add_repeated_float (311); - message->add_repeated_double (312); - message->add_repeated_bool (false); - message->add_repeated_string ("315"); - message->add_repeated_bytes ("316"); - - message->add_repeatedgroup ()->set_a(317); - message->add_repeated_nested_message ()->set_bb(318); - message->add_repeated_foreign_message()->set_c(319); - message->add_repeated_import_message ()->set_d(320); - message->add_repeated_lazy_message ()->set_bb(327); - - message->add_repeated_nested_enum (unittest::TestAllTypesLite::BAZ ); - message->add_repeated_foreign_enum(unittest::FOREIGN_LITE_BAZ ); - message->add_repeated_import_enum (unittest_import::IMPORT_LITE_BAZ); - - - // ----------------------------------------------------------------- - - message->set_default_int32 (401); - message->set_default_int64 (402); - message->set_default_uint32 (403); - message->set_default_uint64 (404); - message->set_default_sint32 (405); - message->set_default_sint64 (406); - message->set_default_fixed32 (407); - message->set_default_fixed64 (408); - message->set_default_sfixed32(409); - message->set_default_sfixed64(410); - message->set_default_float (411); - message->set_default_double (412); - message->set_default_bool (false); - message->set_default_string ("415"); - message->set_default_bytes ("416"); - - message->set_default_nested_enum (unittest::TestAllTypesLite::FOO ); - message->set_default_foreign_enum(unittest::FOREIGN_LITE_FOO ); - message->set_default_import_enum (unittest_import::IMPORT_LITE_FOO); - -} - -// ------------------------------------------------------------------- - -void TestUtilLite::ModifyRepeatedFields(unittest::TestAllTypesLite* message) { - message->set_repeated_int32 (1, 501); - message->set_repeated_int64 (1, 502); - message->set_repeated_uint32 (1, 503); - message->set_repeated_uint64 (1, 504); - message->set_repeated_sint32 (1, 505); - message->set_repeated_sint64 (1, 506); - message->set_repeated_fixed32 (1, 507); - message->set_repeated_fixed64 (1, 508); - message->set_repeated_sfixed32(1, 509); - message->set_repeated_sfixed64(1, 510); - message->set_repeated_float (1, 511); - message->set_repeated_double (1, 512); - message->set_repeated_bool (1, true); - message->set_repeated_string (1, "515"); - message->set_repeated_bytes (1, "516"); - - message->mutable_repeatedgroup (1)->set_a(517); - message->mutable_repeated_nested_message (1)->set_bb(518); - message->mutable_repeated_foreign_message(1)->set_c(519); - message->mutable_repeated_import_message (1)->set_d(520); - message->mutable_repeated_lazy_message (1)->set_bb(527); - - message->set_repeated_nested_enum (1, unittest::TestAllTypesLite::FOO ); - message->set_repeated_foreign_enum(1, unittest::FOREIGN_LITE_FOO ); - message->set_repeated_import_enum (1, unittest_import::IMPORT_LITE_FOO); - -} - -// ------------------------------------------------------------------- - -void TestUtilLite::ExpectAllFieldsSet( - const unittest::TestAllTypesLite& message) { - EXPECT_TRUE(message.has_optional_int32 ()); - EXPECT_TRUE(message.has_optional_int64 ()); - EXPECT_TRUE(message.has_optional_uint32 ()); - EXPECT_TRUE(message.has_optional_uint64 ()); - EXPECT_TRUE(message.has_optional_sint32 ()); - EXPECT_TRUE(message.has_optional_sint64 ()); - EXPECT_TRUE(message.has_optional_fixed32 ()); - EXPECT_TRUE(message.has_optional_fixed64 ()); - EXPECT_TRUE(message.has_optional_sfixed32()); - EXPECT_TRUE(message.has_optional_sfixed64()); - EXPECT_TRUE(message.has_optional_float ()); - EXPECT_TRUE(message.has_optional_double ()); - EXPECT_TRUE(message.has_optional_bool ()); - EXPECT_TRUE(message.has_optional_string ()); - EXPECT_TRUE(message.has_optional_bytes ()); - - EXPECT_TRUE(message.has_optionalgroup ()); - EXPECT_TRUE(message.has_optional_nested_message ()); - EXPECT_TRUE(message.has_optional_foreign_message ()); - EXPECT_TRUE(message.has_optional_import_message ()); - EXPECT_TRUE(message.has_optional_public_import_message()); - EXPECT_TRUE(message.has_optional_lazy_message ()); - - EXPECT_TRUE(message.optionalgroup ().has_a()); - EXPECT_TRUE(message.optional_nested_message ().has_bb()); - EXPECT_TRUE(message.optional_foreign_message ().has_c()); - EXPECT_TRUE(message.optional_import_message ().has_d()); - EXPECT_TRUE(message.optional_public_import_message().has_e()); - EXPECT_TRUE(message.optional_lazy_message ().has_bb()); - - EXPECT_TRUE(message.has_optional_nested_enum ()); - EXPECT_TRUE(message.has_optional_foreign_enum()); - EXPECT_TRUE(message.has_optional_import_enum ()); - - - EXPECT_EQ(101 , message.optional_int32 ()); - EXPECT_EQ(102 , message.optional_int64 ()); - EXPECT_EQ(103 , message.optional_uint32 ()); - EXPECT_EQ(104 , message.optional_uint64 ()); - EXPECT_EQ(105 , message.optional_sint32 ()); - EXPECT_EQ(106 , message.optional_sint64 ()); - EXPECT_EQ(107 , message.optional_fixed32 ()); - EXPECT_EQ(108 , message.optional_fixed64 ()); - EXPECT_EQ(109 , message.optional_sfixed32()); - EXPECT_EQ(110 , message.optional_sfixed64()); - EXPECT_EQ(111 , message.optional_float ()); - EXPECT_EQ(112 , message.optional_double ()); - EXPECT_EQ(true , message.optional_bool ()); - EXPECT_EQ("115", message.optional_string ()); - EXPECT_EQ("116", message.optional_bytes ()); - - EXPECT_EQ(117, message.optionalgroup ().a()); - EXPECT_EQ(118, message.optional_nested_message ().bb()); - EXPECT_EQ(119, message.optional_foreign_message ().c()); - EXPECT_EQ(120, message.optional_import_message ().d()); - EXPECT_EQ(126, message.optional_public_import_message().e()); - EXPECT_EQ(127, message.optional_lazy_message ().bb()); - - EXPECT_EQ(unittest::TestAllTypesLite::BAZ , message.optional_nested_enum ()); - EXPECT_EQ(unittest::FOREIGN_LITE_BAZ , message.optional_foreign_enum()); - EXPECT_EQ(unittest_import::IMPORT_LITE_BAZ, message.optional_import_enum ()); - - - // ----------------------------------------------------------------- - - ASSERT_EQ(2, message.repeated_int32_size ()); - ASSERT_EQ(2, message.repeated_int64_size ()); - ASSERT_EQ(2, message.repeated_uint32_size ()); - ASSERT_EQ(2, message.repeated_uint64_size ()); - ASSERT_EQ(2, message.repeated_sint32_size ()); - ASSERT_EQ(2, message.repeated_sint64_size ()); - ASSERT_EQ(2, message.repeated_fixed32_size ()); - ASSERT_EQ(2, message.repeated_fixed64_size ()); - ASSERT_EQ(2, message.repeated_sfixed32_size()); - ASSERT_EQ(2, message.repeated_sfixed64_size()); - ASSERT_EQ(2, message.repeated_float_size ()); - ASSERT_EQ(2, message.repeated_double_size ()); - ASSERT_EQ(2, message.repeated_bool_size ()); - ASSERT_EQ(2, message.repeated_string_size ()); - ASSERT_EQ(2, message.repeated_bytes_size ()); - - ASSERT_EQ(2, message.repeatedgroup_size ()); - ASSERT_EQ(2, message.repeated_nested_message_size ()); - ASSERT_EQ(2, message.repeated_foreign_message_size()); - ASSERT_EQ(2, message.repeated_import_message_size ()); - ASSERT_EQ(2, message.repeated_lazy_message_size ()); - ASSERT_EQ(2, message.repeated_nested_enum_size ()); - ASSERT_EQ(2, message.repeated_foreign_enum_size ()); - ASSERT_EQ(2, message.repeated_import_enum_size ()); - - - EXPECT_EQ(201 , message.repeated_int32 (0)); - EXPECT_EQ(202 , message.repeated_int64 (0)); - EXPECT_EQ(203 , message.repeated_uint32 (0)); - EXPECT_EQ(204 , message.repeated_uint64 (0)); - EXPECT_EQ(205 , message.repeated_sint32 (0)); - EXPECT_EQ(206 , message.repeated_sint64 (0)); - EXPECT_EQ(207 , message.repeated_fixed32 (0)); - EXPECT_EQ(208 , message.repeated_fixed64 (0)); - EXPECT_EQ(209 , message.repeated_sfixed32(0)); - EXPECT_EQ(210 , message.repeated_sfixed64(0)); - EXPECT_EQ(211 , message.repeated_float (0)); - EXPECT_EQ(212 , message.repeated_double (0)); - EXPECT_EQ(true , message.repeated_bool (0)); - EXPECT_EQ("215", message.repeated_string (0)); - EXPECT_EQ("216", message.repeated_bytes (0)); - - EXPECT_EQ(217, message.repeatedgroup (0).a()); - EXPECT_EQ(218, message.repeated_nested_message (0).bb()); - EXPECT_EQ(219, message.repeated_foreign_message(0).c()); - EXPECT_EQ(220, message.repeated_import_message (0).d()); - EXPECT_EQ(227, message.repeated_lazy_message (0).bb()); - - - EXPECT_EQ(unittest::TestAllTypesLite::BAR , message.repeated_nested_enum (0)); - EXPECT_EQ(unittest::FOREIGN_LITE_BAR , message.repeated_foreign_enum(0)); - EXPECT_EQ(unittest_import::IMPORT_LITE_BAR, message.repeated_import_enum (0)); - - EXPECT_EQ(301 , message.repeated_int32 (1)); - EXPECT_EQ(302 , message.repeated_int64 (1)); - EXPECT_EQ(303 , message.repeated_uint32 (1)); - EXPECT_EQ(304 , message.repeated_uint64 (1)); - EXPECT_EQ(305 , message.repeated_sint32 (1)); - EXPECT_EQ(306 , message.repeated_sint64 (1)); - EXPECT_EQ(307 , message.repeated_fixed32 (1)); - EXPECT_EQ(308 , message.repeated_fixed64 (1)); - EXPECT_EQ(309 , message.repeated_sfixed32(1)); - EXPECT_EQ(310 , message.repeated_sfixed64(1)); - EXPECT_EQ(311 , message.repeated_float (1)); - EXPECT_EQ(312 , message.repeated_double (1)); - EXPECT_EQ(false, message.repeated_bool (1)); - EXPECT_EQ("315", message.repeated_string (1)); - EXPECT_EQ("316", message.repeated_bytes (1)); - - EXPECT_EQ(317, message.repeatedgroup (1).a()); - EXPECT_EQ(318, message.repeated_nested_message (1).bb()); - EXPECT_EQ(319, message.repeated_foreign_message(1).c()); - EXPECT_EQ(320, message.repeated_import_message (1).d()); - EXPECT_EQ(327, message.repeated_lazy_message (1).bb()); - - EXPECT_EQ(unittest::TestAllTypesLite::BAZ , message.repeated_nested_enum (1)); - EXPECT_EQ(unittest::FOREIGN_LITE_BAZ , message.repeated_foreign_enum(1)); - EXPECT_EQ(unittest_import::IMPORT_LITE_BAZ, message.repeated_import_enum (1)); - - - // ----------------------------------------------------------------- - - EXPECT_TRUE(message.has_default_int32 ()); - EXPECT_TRUE(message.has_default_int64 ()); - EXPECT_TRUE(message.has_default_uint32 ()); - EXPECT_TRUE(message.has_default_uint64 ()); - EXPECT_TRUE(message.has_default_sint32 ()); - EXPECT_TRUE(message.has_default_sint64 ()); - EXPECT_TRUE(message.has_default_fixed32 ()); - EXPECT_TRUE(message.has_default_fixed64 ()); - EXPECT_TRUE(message.has_default_sfixed32()); - EXPECT_TRUE(message.has_default_sfixed64()); - EXPECT_TRUE(message.has_default_float ()); - EXPECT_TRUE(message.has_default_double ()); - EXPECT_TRUE(message.has_default_bool ()); - EXPECT_TRUE(message.has_default_string ()); - EXPECT_TRUE(message.has_default_bytes ()); - - EXPECT_TRUE(message.has_default_nested_enum ()); - EXPECT_TRUE(message.has_default_foreign_enum()); - EXPECT_TRUE(message.has_default_import_enum ()); - - - EXPECT_EQ(401 , message.default_int32 ()); - EXPECT_EQ(402 , message.default_int64 ()); - EXPECT_EQ(403 , message.default_uint32 ()); - EXPECT_EQ(404 , message.default_uint64 ()); - EXPECT_EQ(405 , message.default_sint32 ()); - EXPECT_EQ(406 , message.default_sint64 ()); - EXPECT_EQ(407 , message.default_fixed32 ()); - EXPECT_EQ(408 , message.default_fixed64 ()); - EXPECT_EQ(409 , message.default_sfixed32()); - EXPECT_EQ(410 , message.default_sfixed64()); - EXPECT_EQ(411 , message.default_float ()); - EXPECT_EQ(412 , message.default_double ()); - EXPECT_EQ(false, message.default_bool ()); - EXPECT_EQ("415", message.default_string ()); - EXPECT_EQ("416", message.default_bytes ()); - - EXPECT_EQ(unittest::TestAllTypesLite::FOO , message.default_nested_enum ()); - EXPECT_EQ(unittest::FOREIGN_LITE_FOO , message.default_foreign_enum()); - EXPECT_EQ(unittest_import::IMPORT_LITE_FOO, message.default_import_enum ()); - -} - -// ------------------------------------------------------------------- - -void TestUtilLite::ExpectClear(const unittest::TestAllTypesLite& message) { - // has_blah() should initially be false for all optional fields. - EXPECT_FALSE(message.has_optional_int32 ()); - EXPECT_FALSE(message.has_optional_int64 ()); - EXPECT_FALSE(message.has_optional_uint32 ()); - EXPECT_FALSE(message.has_optional_uint64 ()); - EXPECT_FALSE(message.has_optional_sint32 ()); - EXPECT_FALSE(message.has_optional_sint64 ()); - EXPECT_FALSE(message.has_optional_fixed32 ()); - EXPECT_FALSE(message.has_optional_fixed64 ()); - EXPECT_FALSE(message.has_optional_sfixed32()); - EXPECT_FALSE(message.has_optional_sfixed64()); - EXPECT_FALSE(message.has_optional_float ()); - EXPECT_FALSE(message.has_optional_double ()); - EXPECT_FALSE(message.has_optional_bool ()); - EXPECT_FALSE(message.has_optional_string ()); - EXPECT_FALSE(message.has_optional_bytes ()); - - EXPECT_FALSE(message.has_optionalgroup ()); - EXPECT_FALSE(message.has_optional_nested_message ()); - EXPECT_FALSE(message.has_optional_foreign_message ()); - EXPECT_FALSE(message.has_optional_import_message ()); - EXPECT_FALSE(message.has_optional_public_import_message()); - EXPECT_FALSE(message.has_optional_lazy_message ()); - - EXPECT_FALSE(message.has_optional_nested_enum ()); - EXPECT_FALSE(message.has_optional_foreign_enum()); - EXPECT_FALSE(message.has_optional_import_enum ()); - - - // Optional fields without defaults are set to zero or something like it. - EXPECT_EQ(0 , message.optional_int32 ()); - EXPECT_EQ(0 , message.optional_int64 ()); - EXPECT_EQ(0 , message.optional_uint32 ()); - EXPECT_EQ(0 , message.optional_uint64 ()); - EXPECT_EQ(0 , message.optional_sint32 ()); - EXPECT_EQ(0 , message.optional_sint64 ()); - EXPECT_EQ(0 , message.optional_fixed32 ()); - EXPECT_EQ(0 , message.optional_fixed64 ()); - EXPECT_EQ(0 , message.optional_sfixed32()); - EXPECT_EQ(0 , message.optional_sfixed64()); - EXPECT_EQ(0 , message.optional_float ()); - EXPECT_EQ(0 , message.optional_double ()); - EXPECT_EQ(false, message.optional_bool ()); - EXPECT_EQ("" , message.optional_string ()); - EXPECT_EQ("" , message.optional_bytes ()); - - // Embedded messages should also be clear. - EXPECT_FALSE(message.optionalgroup ().has_a()); - EXPECT_FALSE(message.optional_nested_message ().has_bb()); - EXPECT_FALSE(message.optional_foreign_message ().has_c()); - EXPECT_FALSE(message.optional_import_message ().has_d()); - EXPECT_FALSE(message.optional_public_import_message().has_e()); - EXPECT_FALSE(message.optional_lazy_message ().has_bb()); - - EXPECT_EQ(0, message.optionalgroup ().a()); - EXPECT_EQ(0, message.optional_nested_message ().bb()); - EXPECT_EQ(0, message.optional_foreign_message().c()); - EXPECT_EQ(0, message.optional_import_message ().d()); - - // Enums without defaults are set to the first value in the enum. - EXPECT_EQ(unittest::TestAllTypesLite::FOO , message.optional_nested_enum ()); - EXPECT_EQ(unittest::FOREIGN_LITE_FOO , message.optional_foreign_enum()); - EXPECT_EQ(unittest_import::IMPORT_LITE_FOO, message.optional_import_enum ()); - - - // Repeated fields are empty. - EXPECT_EQ(0, message.repeated_int32_size ()); - EXPECT_EQ(0, message.repeated_int64_size ()); - EXPECT_EQ(0, message.repeated_uint32_size ()); - EXPECT_EQ(0, message.repeated_uint64_size ()); - EXPECT_EQ(0, message.repeated_sint32_size ()); - EXPECT_EQ(0, message.repeated_sint64_size ()); - EXPECT_EQ(0, message.repeated_fixed32_size ()); - EXPECT_EQ(0, message.repeated_fixed64_size ()); - EXPECT_EQ(0, message.repeated_sfixed32_size()); - EXPECT_EQ(0, message.repeated_sfixed64_size()); - EXPECT_EQ(0, message.repeated_float_size ()); - EXPECT_EQ(0, message.repeated_double_size ()); - EXPECT_EQ(0, message.repeated_bool_size ()); - EXPECT_EQ(0, message.repeated_string_size ()); - EXPECT_EQ(0, message.repeated_bytes_size ()); - - EXPECT_EQ(0, message.repeatedgroup_size ()); - EXPECT_EQ(0, message.repeated_nested_message_size ()); - EXPECT_EQ(0, message.repeated_foreign_message_size()); - EXPECT_EQ(0, message.repeated_import_message_size ()); - EXPECT_EQ(0, message.repeated_lazy_message_size ()); - EXPECT_EQ(0, message.repeated_nested_enum_size ()); - EXPECT_EQ(0, message.repeated_foreign_enum_size ()); - EXPECT_EQ(0, message.repeated_import_enum_size ()); - - - // has_blah() should also be false for all default fields. - EXPECT_FALSE(message.has_default_int32 ()); - EXPECT_FALSE(message.has_default_int64 ()); - EXPECT_FALSE(message.has_default_uint32 ()); - EXPECT_FALSE(message.has_default_uint64 ()); - EXPECT_FALSE(message.has_default_sint32 ()); - EXPECT_FALSE(message.has_default_sint64 ()); - EXPECT_FALSE(message.has_default_fixed32 ()); - EXPECT_FALSE(message.has_default_fixed64 ()); - EXPECT_FALSE(message.has_default_sfixed32()); - EXPECT_FALSE(message.has_default_sfixed64()); - EXPECT_FALSE(message.has_default_float ()); - EXPECT_FALSE(message.has_default_double ()); - EXPECT_FALSE(message.has_default_bool ()); - EXPECT_FALSE(message.has_default_string ()); - EXPECT_FALSE(message.has_default_bytes ()); - - EXPECT_FALSE(message.has_default_nested_enum ()); - EXPECT_FALSE(message.has_default_foreign_enum()); - EXPECT_FALSE(message.has_default_import_enum ()); - - - // Fields with defaults have their default values (duh). - EXPECT_EQ( 41 , message.default_int32 ()); - EXPECT_EQ( 42 , message.default_int64 ()); - EXPECT_EQ( 43 , message.default_uint32 ()); - EXPECT_EQ( 44 , message.default_uint64 ()); - EXPECT_EQ(-45 , message.default_sint32 ()); - EXPECT_EQ( 46 , message.default_sint64 ()); - EXPECT_EQ( 47 , message.default_fixed32 ()); - EXPECT_EQ( 48 , message.default_fixed64 ()); - EXPECT_EQ( 49 , message.default_sfixed32()); - EXPECT_EQ(-50 , message.default_sfixed64()); - EXPECT_EQ( 51.5 , message.default_float ()); - EXPECT_EQ( 52e3 , message.default_double ()); - EXPECT_EQ(true , message.default_bool ()); - EXPECT_EQ("hello", message.default_string ()); - EXPECT_EQ("world", message.default_bytes ()); - - EXPECT_EQ(unittest::TestAllTypesLite::BAR , message.default_nested_enum ()); - EXPECT_EQ(unittest::FOREIGN_LITE_BAR , message.default_foreign_enum()); - EXPECT_EQ(unittest_import::IMPORT_LITE_BAR, message.default_import_enum ()); - -} - -// ------------------------------------------------------------------- - -void TestUtilLite::ExpectRepeatedFieldsModified( - const unittest::TestAllTypesLite& message) { - // ModifyRepeatedFields only sets the second repeated element of each - // field. In addition to verifying this, we also verify that the first - // element and size were *not* modified. - ASSERT_EQ(2, message.repeated_int32_size ()); - ASSERT_EQ(2, message.repeated_int64_size ()); - ASSERT_EQ(2, message.repeated_uint32_size ()); - ASSERT_EQ(2, message.repeated_uint64_size ()); - ASSERT_EQ(2, message.repeated_sint32_size ()); - ASSERT_EQ(2, message.repeated_sint64_size ()); - ASSERT_EQ(2, message.repeated_fixed32_size ()); - ASSERT_EQ(2, message.repeated_fixed64_size ()); - ASSERT_EQ(2, message.repeated_sfixed32_size()); - ASSERT_EQ(2, message.repeated_sfixed64_size()); - ASSERT_EQ(2, message.repeated_float_size ()); - ASSERT_EQ(2, message.repeated_double_size ()); - ASSERT_EQ(2, message.repeated_bool_size ()); - ASSERT_EQ(2, message.repeated_string_size ()); - ASSERT_EQ(2, message.repeated_bytes_size ()); - - ASSERT_EQ(2, message.repeatedgroup_size ()); - ASSERT_EQ(2, message.repeated_nested_message_size ()); - ASSERT_EQ(2, message.repeated_foreign_message_size()); - ASSERT_EQ(2, message.repeated_import_message_size ()); - ASSERT_EQ(2, message.repeated_lazy_message_size ()); - ASSERT_EQ(2, message.repeated_nested_enum_size ()); - ASSERT_EQ(2, message.repeated_foreign_enum_size ()); - ASSERT_EQ(2, message.repeated_import_enum_size ()); - - - EXPECT_EQ(201 , message.repeated_int32 (0)); - EXPECT_EQ(202 , message.repeated_int64 (0)); - EXPECT_EQ(203 , message.repeated_uint32 (0)); - EXPECT_EQ(204 , message.repeated_uint64 (0)); - EXPECT_EQ(205 , message.repeated_sint32 (0)); - EXPECT_EQ(206 , message.repeated_sint64 (0)); - EXPECT_EQ(207 , message.repeated_fixed32 (0)); - EXPECT_EQ(208 , message.repeated_fixed64 (0)); - EXPECT_EQ(209 , message.repeated_sfixed32(0)); - EXPECT_EQ(210 , message.repeated_sfixed64(0)); - EXPECT_EQ(211 , message.repeated_float (0)); - EXPECT_EQ(212 , message.repeated_double (0)); - EXPECT_EQ(true , message.repeated_bool (0)); - EXPECT_EQ("215", message.repeated_string (0)); - EXPECT_EQ("216", message.repeated_bytes (0)); - - EXPECT_EQ(217, message.repeatedgroup (0).a()); - EXPECT_EQ(218, message.repeated_nested_message (0).bb()); - EXPECT_EQ(219, message.repeated_foreign_message(0).c()); - EXPECT_EQ(220, message.repeated_import_message (0).d()); - EXPECT_EQ(227, message.repeated_lazy_message (0).bb()); - - EXPECT_EQ(unittest::TestAllTypesLite::BAR , message.repeated_nested_enum (0)); - EXPECT_EQ(unittest::FOREIGN_LITE_BAR , message.repeated_foreign_enum(0)); - EXPECT_EQ(unittest_import::IMPORT_LITE_BAR, message.repeated_import_enum (0)); - - - // Actually verify the second (modified) elements now. - EXPECT_EQ(501 , message.repeated_int32 (1)); - EXPECT_EQ(502 , message.repeated_int64 (1)); - EXPECT_EQ(503 , message.repeated_uint32 (1)); - EXPECT_EQ(504 , message.repeated_uint64 (1)); - EXPECT_EQ(505 , message.repeated_sint32 (1)); - EXPECT_EQ(506 , message.repeated_sint64 (1)); - EXPECT_EQ(507 , message.repeated_fixed32 (1)); - EXPECT_EQ(508 , message.repeated_fixed64 (1)); - EXPECT_EQ(509 , message.repeated_sfixed32(1)); - EXPECT_EQ(510 , message.repeated_sfixed64(1)); - EXPECT_EQ(511 , message.repeated_float (1)); - EXPECT_EQ(512 , message.repeated_double (1)); - EXPECT_EQ(true , message.repeated_bool (1)); - EXPECT_EQ("515", message.repeated_string (1)); - EXPECT_EQ("516", message.repeated_bytes (1)); - - EXPECT_EQ(517, message.repeatedgroup (1).a()); - EXPECT_EQ(518, message.repeated_nested_message (1).bb()); - EXPECT_EQ(519, message.repeated_foreign_message(1).c()); - EXPECT_EQ(520, message.repeated_import_message (1).d()); - EXPECT_EQ(527, message.repeated_lazy_message (1).bb()); - - EXPECT_EQ(unittest::TestAllTypesLite::FOO , message.repeated_nested_enum (1)); - EXPECT_EQ(unittest::FOREIGN_LITE_FOO , message.repeated_foreign_enum(1)); - EXPECT_EQ(unittest_import::IMPORT_LITE_FOO, message.repeated_import_enum (1)); - -} - -// ------------------------------------------------------------------- - -void TestUtilLite::SetPackedFields(unittest::TestPackedTypesLite* message) { - message->add_packed_int32 (601); - message->add_packed_int64 (602); - message->add_packed_uint32 (603); - message->add_packed_uint64 (604); - message->add_packed_sint32 (605); - message->add_packed_sint64 (606); - message->add_packed_fixed32 (607); - message->add_packed_fixed64 (608); - message->add_packed_sfixed32(609); - message->add_packed_sfixed64(610); - message->add_packed_float (611); - message->add_packed_double (612); - message->add_packed_bool (true); - message->add_packed_enum (unittest::FOREIGN_LITE_BAR); - // add a second one of each field - message->add_packed_int32 (701); - message->add_packed_int64 (702); - message->add_packed_uint32 (703); - message->add_packed_uint64 (704); - message->add_packed_sint32 (705); - message->add_packed_sint64 (706); - message->add_packed_fixed32 (707); - message->add_packed_fixed64 (708); - message->add_packed_sfixed32(709); - message->add_packed_sfixed64(710); - message->add_packed_float (711); - message->add_packed_double (712); - message->add_packed_bool (false); - message->add_packed_enum (unittest::FOREIGN_LITE_BAZ); -} - -// ------------------------------------------------------------------- - -void TestUtilLite::ModifyPackedFields(unittest::TestPackedTypesLite* message) { - message->set_packed_int32 (1, 801); - message->set_packed_int64 (1, 802); - message->set_packed_uint32 (1, 803); - message->set_packed_uint64 (1, 804); - message->set_packed_sint32 (1, 805); - message->set_packed_sint64 (1, 806); - message->set_packed_fixed32 (1, 807); - message->set_packed_fixed64 (1, 808); - message->set_packed_sfixed32(1, 809); - message->set_packed_sfixed64(1, 810); - message->set_packed_float (1, 811); - message->set_packed_double (1, 812); - message->set_packed_bool (1, true); - message->set_packed_enum (1, unittest::FOREIGN_LITE_FOO); -} - -// ------------------------------------------------------------------- - -void TestUtilLite::ExpectPackedFieldsSet( - const unittest::TestPackedTypesLite& message) { - ASSERT_EQ(2, message.packed_int32_size ()); - ASSERT_EQ(2, message.packed_int64_size ()); - ASSERT_EQ(2, message.packed_uint32_size ()); - ASSERT_EQ(2, message.packed_uint64_size ()); - ASSERT_EQ(2, message.packed_sint32_size ()); - ASSERT_EQ(2, message.packed_sint64_size ()); - ASSERT_EQ(2, message.packed_fixed32_size ()); - ASSERT_EQ(2, message.packed_fixed64_size ()); - ASSERT_EQ(2, message.packed_sfixed32_size()); - ASSERT_EQ(2, message.packed_sfixed64_size()); - ASSERT_EQ(2, message.packed_float_size ()); - ASSERT_EQ(2, message.packed_double_size ()); - ASSERT_EQ(2, message.packed_bool_size ()); - ASSERT_EQ(2, message.packed_enum_size ()); - - EXPECT_EQ(601 , message.packed_int32 (0)); - EXPECT_EQ(602 , message.packed_int64 (0)); - EXPECT_EQ(603 , message.packed_uint32 (0)); - EXPECT_EQ(604 , message.packed_uint64 (0)); - EXPECT_EQ(605 , message.packed_sint32 (0)); - EXPECT_EQ(606 , message.packed_sint64 (0)); - EXPECT_EQ(607 , message.packed_fixed32 (0)); - EXPECT_EQ(608 , message.packed_fixed64 (0)); - EXPECT_EQ(609 , message.packed_sfixed32(0)); - EXPECT_EQ(610 , message.packed_sfixed64(0)); - EXPECT_EQ(611 , message.packed_float (0)); - EXPECT_EQ(612 , message.packed_double (0)); - EXPECT_EQ(true , message.packed_bool (0)); - EXPECT_EQ(unittest::FOREIGN_LITE_BAR, message.packed_enum(0)); - - EXPECT_EQ(701 , message.packed_int32 (1)); - EXPECT_EQ(702 , message.packed_int64 (1)); - EXPECT_EQ(703 , message.packed_uint32 (1)); - EXPECT_EQ(704 , message.packed_uint64 (1)); - EXPECT_EQ(705 , message.packed_sint32 (1)); - EXPECT_EQ(706 , message.packed_sint64 (1)); - EXPECT_EQ(707 , message.packed_fixed32 (1)); - EXPECT_EQ(708 , message.packed_fixed64 (1)); - EXPECT_EQ(709 , message.packed_sfixed32(1)); - EXPECT_EQ(710 , message.packed_sfixed64(1)); - EXPECT_EQ(711 , message.packed_float (1)); - EXPECT_EQ(712 , message.packed_double (1)); - EXPECT_EQ(false, message.packed_bool (1)); - EXPECT_EQ(unittest::FOREIGN_LITE_BAZ, message.packed_enum(1)); -} - -// ------------------------------------------------------------------- - -void TestUtilLite::ExpectPackedClear( - const unittest::TestPackedTypesLite& message) { - // Packed repeated fields are empty. - EXPECT_EQ(0, message.packed_int32_size ()); - EXPECT_EQ(0, message.packed_int64_size ()); - EXPECT_EQ(0, message.packed_uint32_size ()); - EXPECT_EQ(0, message.packed_uint64_size ()); - EXPECT_EQ(0, message.packed_sint32_size ()); - EXPECT_EQ(0, message.packed_sint64_size ()); - EXPECT_EQ(0, message.packed_fixed32_size ()); - EXPECT_EQ(0, message.packed_fixed64_size ()); - EXPECT_EQ(0, message.packed_sfixed32_size()); - EXPECT_EQ(0, message.packed_sfixed64_size()); - EXPECT_EQ(0, message.packed_float_size ()); - EXPECT_EQ(0, message.packed_double_size ()); - EXPECT_EQ(0, message.packed_bool_size ()); - EXPECT_EQ(0, message.packed_enum_size ()); -} - -// ------------------------------------------------------------------- - -void TestUtilLite::ExpectPackedFieldsModified( - const unittest::TestPackedTypesLite& message) { - // Do the same for packed repeated fields. - ASSERT_EQ(2, message.packed_int32_size ()); - ASSERT_EQ(2, message.packed_int64_size ()); - ASSERT_EQ(2, message.packed_uint32_size ()); - ASSERT_EQ(2, message.packed_uint64_size ()); - ASSERT_EQ(2, message.packed_sint32_size ()); - ASSERT_EQ(2, message.packed_sint64_size ()); - ASSERT_EQ(2, message.packed_fixed32_size ()); - ASSERT_EQ(2, message.packed_fixed64_size ()); - ASSERT_EQ(2, message.packed_sfixed32_size()); - ASSERT_EQ(2, message.packed_sfixed64_size()); - ASSERT_EQ(2, message.packed_float_size ()); - ASSERT_EQ(2, message.packed_double_size ()); - ASSERT_EQ(2, message.packed_bool_size ()); - ASSERT_EQ(2, message.packed_enum_size ()); - - EXPECT_EQ(601 , message.packed_int32 (0)); - EXPECT_EQ(602 , message.packed_int64 (0)); - EXPECT_EQ(603 , message.packed_uint32 (0)); - EXPECT_EQ(604 , message.packed_uint64 (0)); - EXPECT_EQ(605 , message.packed_sint32 (0)); - EXPECT_EQ(606 , message.packed_sint64 (0)); - EXPECT_EQ(607 , message.packed_fixed32 (0)); - EXPECT_EQ(608 , message.packed_fixed64 (0)); - EXPECT_EQ(609 , message.packed_sfixed32(0)); - EXPECT_EQ(610 , message.packed_sfixed64(0)); - EXPECT_EQ(611 , message.packed_float (0)); - EXPECT_EQ(612 , message.packed_double (0)); - EXPECT_EQ(true , message.packed_bool (0)); - EXPECT_EQ(unittest::FOREIGN_LITE_BAR, message.packed_enum(0)); - // Actually verify the second (modified) elements now. - EXPECT_EQ(801 , message.packed_int32 (1)); - EXPECT_EQ(802 , message.packed_int64 (1)); - EXPECT_EQ(803 , message.packed_uint32 (1)); - EXPECT_EQ(804 , message.packed_uint64 (1)); - EXPECT_EQ(805 , message.packed_sint32 (1)); - EXPECT_EQ(806 , message.packed_sint64 (1)); - EXPECT_EQ(807 , message.packed_fixed32 (1)); - EXPECT_EQ(808 , message.packed_fixed64 (1)); - EXPECT_EQ(809 , message.packed_sfixed32(1)); - EXPECT_EQ(810 , message.packed_sfixed64(1)); - EXPECT_EQ(811 , message.packed_float (1)); - EXPECT_EQ(812 , message.packed_double (1)); - EXPECT_EQ(true , message.packed_bool (1)); - EXPECT_EQ(unittest::FOREIGN_LITE_FOO, message.packed_enum(1)); -} - -// =================================================================== -// Extensions -// -// All this code is exactly equivalent to the above code except that it's -// manipulating extension fields instead of normal ones. -// -// I gave up on the 80-char limit here. Sorry. - -void TestUtilLite::SetAllExtensions(unittest::TestAllExtensionsLite* message) { - message->SetExtension(unittest::optional_int32_extension_lite , 101); - message->SetExtension(unittest::optional_int64_extension_lite , 102); - message->SetExtension(unittest::optional_uint32_extension_lite , 103); - message->SetExtension(unittest::optional_uint64_extension_lite , 104); - message->SetExtension(unittest::optional_sint32_extension_lite , 105); - message->SetExtension(unittest::optional_sint64_extension_lite , 106); - message->SetExtension(unittest::optional_fixed32_extension_lite , 107); - message->SetExtension(unittest::optional_fixed64_extension_lite , 108); - message->SetExtension(unittest::optional_sfixed32_extension_lite, 109); - message->SetExtension(unittest::optional_sfixed64_extension_lite, 110); - message->SetExtension(unittest::optional_float_extension_lite , 111); - message->SetExtension(unittest::optional_double_extension_lite , 112); - message->SetExtension(unittest::optional_bool_extension_lite , true); - message->SetExtension(unittest::optional_string_extension_lite , "115"); - message->SetExtension(unittest::optional_bytes_extension_lite , "116"); - - message->MutableExtension(unittest::optionalgroup_extension_lite )->set_a(117); - message->MutableExtension(unittest::optional_nested_message_extension_lite )->set_bb(118); - message->MutableExtension(unittest::optional_foreign_message_extension_lite )->set_c(119); - message->MutableExtension(unittest::optional_import_message_extension_lite )->set_d(120); - message->MutableExtension(unittest::optional_public_import_message_extension_lite)->set_e(126); - message->MutableExtension(unittest::optional_lazy_message_extension_lite )->set_bb(127); - - message->SetExtension(unittest::optional_nested_enum_extension_lite , unittest::TestAllTypesLite::BAZ ); - message->SetExtension(unittest::optional_foreign_enum_extension_lite, unittest::FOREIGN_LITE_BAZ ); - message->SetExtension(unittest::optional_import_enum_extension_lite , unittest_import::IMPORT_LITE_BAZ); - - - // ----------------------------------------------------------------- - - message->AddExtension(unittest::repeated_int32_extension_lite , 201); - message->AddExtension(unittest::repeated_int64_extension_lite , 202); - message->AddExtension(unittest::repeated_uint32_extension_lite , 203); - message->AddExtension(unittest::repeated_uint64_extension_lite , 204); - message->AddExtension(unittest::repeated_sint32_extension_lite , 205); - message->AddExtension(unittest::repeated_sint64_extension_lite , 206); - message->AddExtension(unittest::repeated_fixed32_extension_lite , 207); - message->AddExtension(unittest::repeated_fixed64_extension_lite , 208); - message->AddExtension(unittest::repeated_sfixed32_extension_lite, 209); - message->AddExtension(unittest::repeated_sfixed64_extension_lite, 210); - message->AddExtension(unittest::repeated_float_extension_lite , 211); - message->AddExtension(unittest::repeated_double_extension_lite , 212); - message->AddExtension(unittest::repeated_bool_extension_lite , true); - message->AddExtension(unittest::repeated_string_extension_lite , "215"); - message->AddExtension(unittest::repeated_bytes_extension_lite , "216"); - - message->AddExtension(unittest::repeatedgroup_extension_lite )->set_a(217); - message->AddExtension(unittest::repeated_nested_message_extension_lite )->set_bb(218); - message->AddExtension(unittest::repeated_foreign_message_extension_lite)->set_c(219); - message->AddExtension(unittest::repeated_import_message_extension_lite )->set_d(220); - message->AddExtension(unittest::repeated_lazy_message_extension_lite )->set_bb(227); - - message->AddExtension(unittest::repeated_nested_enum_extension_lite , unittest::TestAllTypesLite::BAR ); - message->AddExtension(unittest::repeated_foreign_enum_extension_lite, unittest::FOREIGN_LITE_BAR ); - message->AddExtension(unittest::repeated_import_enum_extension_lite , unittest_import::IMPORT_LITE_BAR); - - - // Add a second one of each field. - message->AddExtension(unittest::repeated_int32_extension_lite , 301); - message->AddExtension(unittest::repeated_int64_extension_lite , 302); - message->AddExtension(unittest::repeated_uint32_extension_lite , 303); - message->AddExtension(unittest::repeated_uint64_extension_lite , 304); - message->AddExtension(unittest::repeated_sint32_extension_lite , 305); - message->AddExtension(unittest::repeated_sint64_extension_lite , 306); - message->AddExtension(unittest::repeated_fixed32_extension_lite , 307); - message->AddExtension(unittest::repeated_fixed64_extension_lite , 308); - message->AddExtension(unittest::repeated_sfixed32_extension_lite, 309); - message->AddExtension(unittest::repeated_sfixed64_extension_lite, 310); - message->AddExtension(unittest::repeated_float_extension_lite , 311); - message->AddExtension(unittest::repeated_double_extension_lite , 312); - message->AddExtension(unittest::repeated_bool_extension_lite , false); - message->AddExtension(unittest::repeated_string_extension_lite , "315"); - message->AddExtension(unittest::repeated_bytes_extension_lite , "316"); - - message->AddExtension(unittest::repeatedgroup_extension_lite )->set_a(317); - message->AddExtension(unittest::repeated_nested_message_extension_lite )->set_bb(318); - message->AddExtension(unittest::repeated_foreign_message_extension_lite)->set_c(319); - message->AddExtension(unittest::repeated_import_message_extension_lite )->set_d(320); - message->AddExtension(unittest::repeated_lazy_message_extension_lite )->set_bb(327); - - message->AddExtension(unittest::repeated_nested_enum_extension_lite , unittest::TestAllTypesLite::BAZ ); - message->AddExtension(unittest::repeated_foreign_enum_extension_lite, unittest::FOREIGN_LITE_BAZ ); - message->AddExtension(unittest::repeated_import_enum_extension_lite , unittest_import::IMPORT_LITE_BAZ); - - - // ----------------------------------------------------------------- - - message->SetExtension(unittest::default_int32_extension_lite , 401); - message->SetExtension(unittest::default_int64_extension_lite , 402); - message->SetExtension(unittest::default_uint32_extension_lite , 403); - message->SetExtension(unittest::default_uint64_extension_lite , 404); - message->SetExtension(unittest::default_sint32_extension_lite , 405); - message->SetExtension(unittest::default_sint64_extension_lite , 406); - message->SetExtension(unittest::default_fixed32_extension_lite , 407); - message->SetExtension(unittest::default_fixed64_extension_lite , 408); - message->SetExtension(unittest::default_sfixed32_extension_lite, 409); - message->SetExtension(unittest::default_sfixed64_extension_lite, 410); - message->SetExtension(unittest::default_float_extension_lite , 411); - message->SetExtension(unittest::default_double_extension_lite , 412); - message->SetExtension(unittest::default_bool_extension_lite , false); - message->SetExtension(unittest::default_string_extension_lite , "415"); - message->SetExtension(unittest::default_bytes_extension_lite , "416"); - - message->SetExtension(unittest::default_nested_enum_extension_lite , unittest::TestAllTypesLite::FOO ); - message->SetExtension(unittest::default_foreign_enum_extension_lite, unittest::FOREIGN_LITE_FOO ); - message->SetExtension(unittest::default_import_enum_extension_lite , unittest_import::IMPORT_LITE_FOO); - -} - -// ------------------------------------------------------------------- - -void TestUtilLite::ModifyRepeatedExtensions( - unittest::TestAllExtensionsLite* message) { - message->SetExtension(unittest::repeated_int32_extension_lite , 1, 501); - message->SetExtension(unittest::repeated_int64_extension_lite , 1, 502); - message->SetExtension(unittest::repeated_uint32_extension_lite , 1, 503); - message->SetExtension(unittest::repeated_uint64_extension_lite , 1, 504); - message->SetExtension(unittest::repeated_sint32_extension_lite , 1, 505); - message->SetExtension(unittest::repeated_sint64_extension_lite , 1, 506); - message->SetExtension(unittest::repeated_fixed32_extension_lite , 1, 507); - message->SetExtension(unittest::repeated_fixed64_extension_lite , 1, 508); - message->SetExtension(unittest::repeated_sfixed32_extension_lite, 1, 509); - message->SetExtension(unittest::repeated_sfixed64_extension_lite, 1, 510); - message->SetExtension(unittest::repeated_float_extension_lite , 1, 511); - message->SetExtension(unittest::repeated_double_extension_lite , 1, 512); - message->SetExtension(unittest::repeated_bool_extension_lite , 1, true); - message->SetExtension(unittest::repeated_string_extension_lite , 1, "515"); - message->SetExtension(unittest::repeated_bytes_extension_lite , 1, "516"); - - message->MutableExtension(unittest::repeatedgroup_extension_lite , 1)->set_a(517); - message->MutableExtension(unittest::repeated_nested_message_extension_lite , 1)->set_bb(518); - message->MutableExtension(unittest::repeated_foreign_message_extension_lite, 1)->set_c(519); - message->MutableExtension(unittest::repeated_import_message_extension_lite , 1)->set_d(520); - message->MutableExtension(unittest::repeated_lazy_message_extension_lite , 1)->set_bb(527); - - message->SetExtension(unittest::repeated_nested_enum_extension_lite , 1, unittest::TestAllTypesLite::FOO ); - message->SetExtension(unittest::repeated_foreign_enum_extension_lite, 1, unittest::FOREIGN_LITE_FOO ); - message->SetExtension(unittest::repeated_import_enum_extension_lite , 1, unittest_import::IMPORT_LITE_FOO); - -} - -// ------------------------------------------------------------------- - -void TestUtilLite::ExpectAllExtensionsSet( - const unittest::TestAllExtensionsLite& message) { - EXPECT_TRUE(message.HasExtension(unittest::optional_int32_extension_lite )); - EXPECT_TRUE(message.HasExtension(unittest::optional_int64_extension_lite )); - EXPECT_TRUE(message.HasExtension(unittest::optional_uint32_extension_lite )); - EXPECT_TRUE(message.HasExtension(unittest::optional_uint64_extension_lite )); - EXPECT_TRUE(message.HasExtension(unittest::optional_sint32_extension_lite )); - EXPECT_TRUE(message.HasExtension(unittest::optional_sint64_extension_lite )); - EXPECT_TRUE(message.HasExtension(unittest::optional_fixed32_extension_lite )); - EXPECT_TRUE(message.HasExtension(unittest::optional_fixed64_extension_lite )); - EXPECT_TRUE(message.HasExtension(unittest::optional_sfixed32_extension_lite)); - EXPECT_TRUE(message.HasExtension(unittest::optional_sfixed64_extension_lite)); - EXPECT_TRUE(message.HasExtension(unittest::optional_float_extension_lite )); - EXPECT_TRUE(message.HasExtension(unittest::optional_double_extension_lite )); - EXPECT_TRUE(message.HasExtension(unittest::optional_bool_extension_lite )); - EXPECT_TRUE(message.HasExtension(unittest::optional_string_extension_lite )); - EXPECT_TRUE(message.HasExtension(unittest::optional_bytes_extension_lite )); - - EXPECT_TRUE(message.HasExtension(unittest::optionalgroup_extension_lite )); - EXPECT_TRUE(message.HasExtension(unittest::optional_nested_message_extension_lite )); - EXPECT_TRUE(message.HasExtension(unittest::optional_foreign_message_extension_lite )); - EXPECT_TRUE(message.HasExtension(unittest::optional_import_message_extension_lite )); - EXPECT_TRUE(message.HasExtension(unittest::optional_public_import_message_extension_lite)); - EXPECT_TRUE(message.HasExtension(unittest::optional_lazy_message_extension_lite )); - - EXPECT_TRUE(message.GetExtension(unittest::optionalgroup_extension_lite ).has_a()); - EXPECT_TRUE(message.GetExtension(unittest::optional_nested_message_extension_lite ).has_bb()); - EXPECT_TRUE(message.GetExtension(unittest::optional_foreign_message_extension_lite ).has_c()); - EXPECT_TRUE(message.GetExtension(unittest::optional_import_message_extension_lite ).has_d()); - EXPECT_TRUE(message.GetExtension(unittest::optional_public_import_message_extension_lite).has_e()); - EXPECT_TRUE(message.GetExtension(unittest::optional_lazy_message_extension_lite ).has_bb()); - - EXPECT_TRUE(message.HasExtension(unittest::optional_nested_enum_extension_lite )); - EXPECT_TRUE(message.HasExtension(unittest::optional_foreign_enum_extension_lite)); - EXPECT_TRUE(message.HasExtension(unittest::optional_import_enum_extension_lite )); - - - EXPECT_EQ(101 , message.GetExtension(unittest::optional_int32_extension_lite )); - EXPECT_EQ(102 , message.GetExtension(unittest::optional_int64_extension_lite )); - EXPECT_EQ(103 , message.GetExtension(unittest::optional_uint32_extension_lite )); - EXPECT_EQ(104 , message.GetExtension(unittest::optional_uint64_extension_lite )); - EXPECT_EQ(105 , message.GetExtension(unittest::optional_sint32_extension_lite )); - EXPECT_EQ(106 , message.GetExtension(unittest::optional_sint64_extension_lite )); - EXPECT_EQ(107 , message.GetExtension(unittest::optional_fixed32_extension_lite )); - EXPECT_EQ(108 , message.GetExtension(unittest::optional_fixed64_extension_lite )); - EXPECT_EQ(109 , message.GetExtension(unittest::optional_sfixed32_extension_lite)); - EXPECT_EQ(110 , message.GetExtension(unittest::optional_sfixed64_extension_lite)); - EXPECT_EQ(111 , message.GetExtension(unittest::optional_float_extension_lite )); - EXPECT_EQ(112 , message.GetExtension(unittest::optional_double_extension_lite )); - EXPECT_EQ(true , message.GetExtension(unittest::optional_bool_extension_lite )); - EXPECT_EQ("115", message.GetExtension(unittest::optional_string_extension_lite )); - EXPECT_EQ("116", message.GetExtension(unittest::optional_bytes_extension_lite )); - - EXPECT_EQ(117, message.GetExtension(unittest::optionalgroup_extension_lite ).a()); - EXPECT_EQ(118, message.GetExtension(unittest::optional_nested_message_extension_lite ).bb()); - EXPECT_EQ(119, message.GetExtension(unittest::optional_foreign_message_extension_lite ).c()); - EXPECT_EQ(120, message.GetExtension(unittest::optional_import_message_extension_lite ).d()); - EXPECT_EQ(126, message.GetExtension(unittest::optional_public_import_message_extension_lite).e()); - EXPECT_EQ(127, message.GetExtension(unittest::optional_lazy_message_extension_lite ).bb()); - - EXPECT_EQ(unittest::TestAllTypesLite::BAZ , message.GetExtension(unittest::optional_nested_enum_extension_lite )); - EXPECT_EQ(unittest::FOREIGN_LITE_BAZ , message.GetExtension(unittest::optional_foreign_enum_extension_lite)); - EXPECT_EQ(unittest_import::IMPORT_LITE_BAZ, message.GetExtension(unittest::optional_import_enum_extension_lite )); - - - // ----------------------------------------------------------------- - - ASSERT_EQ(2, message.ExtensionSize(unittest::repeated_int32_extension_lite )); - ASSERT_EQ(2, message.ExtensionSize(unittest::repeated_int64_extension_lite )); - ASSERT_EQ(2, message.ExtensionSize(unittest::repeated_uint32_extension_lite )); - ASSERT_EQ(2, message.ExtensionSize(unittest::repeated_uint64_extension_lite )); - ASSERT_EQ(2, message.ExtensionSize(unittest::repeated_sint32_extension_lite )); - ASSERT_EQ(2, message.ExtensionSize(unittest::repeated_sint64_extension_lite )); - ASSERT_EQ(2, message.ExtensionSize(unittest::repeated_fixed32_extension_lite )); - ASSERT_EQ(2, message.ExtensionSize(unittest::repeated_fixed64_extension_lite )); - ASSERT_EQ(2, message.ExtensionSize(unittest::repeated_sfixed32_extension_lite)); - ASSERT_EQ(2, message.ExtensionSize(unittest::repeated_sfixed64_extension_lite)); - ASSERT_EQ(2, message.ExtensionSize(unittest::repeated_float_extension_lite )); - ASSERT_EQ(2, message.ExtensionSize(unittest::repeated_double_extension_lite )); - ASSERT_EQ(2, message.ExtensionSize(unittest::repeated_bool_extension_lite )); - ASSERT_EQ(2, message.ExtensionSize(unittest::repeated_string_extension_lite )); - ASSERT_EQ(2, message.ExtensionSize(unittest::repeated_bytes_extension_lite )); - - ASSERT_EQ(2, message.ExtensionSize(unittest::repeatedgroup_extension_lite )); - ASSERT_EQ(2, message.ExtensionSize(unittest::repeated_nested_message_extension_lite )); - ASSERT_EQ(2, message.ExtensionSize(unittest::repeated_foreign_message_extension_lite)); - ASSERT_EQ(2, message.ExtensionSize(unittest::repeated_import_message_extension_lite )); - ASSERT_EQ(2, message.ExtensionSize(unittest::repeated_lazy_message_extension_lite )); - ASSERT_EQ(2, message.ExtensionSize(unittest::repeated_nested_enum_extension_lite )); - ASSERT_EQ(2, message.ExtensionSize(unittest::repeated_foreign_enum_extension_lite )); - ASSERT_EQ(2, message.ExtensionSize(unittest::repeated_import_enum_extension_lite )); - - - EXPECT_EQ(201 , message.GetExtension(unittest::repeated_int32_extension_lite , 0)); - EXPECT_EQ(202 , message.GetExtension(unittest::repeated_int64_extension_lite , 0)); - EXPECT_EQ(203 , message.GetExtension(unittest::repeated_uint32_extension_lite , 0)); - EXPECT_EQ(204 , message.GetExtension(unittest::repeated_uint64_extension_lite , 0)); - EXPECT_EQ(205 , message.GetExtension(unittest::repeated_sint32_extension_lite , 0)); - EXPECT_EQ(206 , message.GetExtension(unittest::repeated_sint64_extension_lite , 0)); - EXPECT_EQ(207 , message.GetExtension(unittest::repeated_fixed32_extension_lite , 0)); - EXPECT_EQ(208 , message.GetExtension(unittest::repeated_fixed64_extension_lite , 0)); - EXPECT_EQ(209 , message.GetExtension(unittest::repeated_sfixed32_extension_lite, 0)); - EXPECT_EQ(210 , message.GetExtension(unittest::repeated_sfixed64_extension_lite, 0)); - EXPECT_EQ(211 , message.GetExtension(unittest::repeated_float_extension_lite , 0)); - EXPECT_EQ(212 , message.GetExtension(unittest::repeated_double_extension_lite , 0)); - EXPECT_EQ(true , message.GetExtension(unittest::repeated_bool_extension_lite , 0)); - EXPECT_EQ("215", message.GetExtension(unittest::repeated_string_extension_lite , 0)); - EXPECT_EQ("216", message.GetExtension(unittest::repeated_bytes_extension_lite , 0)); - - EXPECT_EQ(217, message.GetExtension(unittest::repeatedgroup_extension_lite , 0).a()); - EXPECT_EQ(218, message.GetExtension(unittest::repeated_nested_message_extension_lite , 0).bb()); - EXPECT_EQ(219, message.GetExtension(unittest::repeated_foreign_message_extension_lite, 0).c()); - EXPECT_EQ(220, message.GetExtension(unittest::repeated_import_message_extension_lite , 0).d()); - EXPECT_EQ(227, message.GetExtension(unittest::repeated_lazy_message_extension_lite , 0).bb()); - - EXPECT_EQ(unittest::TestAllTypesLite::BAR , message.GetExtension(unittest::repeated_nested_enum_extension_lite , 0)); - EXPECT_EQ(unittest::FOREIGN_LITE_BAR , message.GetExtension(unittest::repeated_foreign_enum_extension_lite, 0)); - EXPECT_EQ(unittest_import::IMPORT_LITE_BAR, message.GetExtension(unittest::repeated_import_enum_extension_lite , 0)); - - - EXPECT_EQ(301 , message.GetExtension(unittest::repeated_int32_extension_lite , 1)); - EXPECT_EQ(302 , message.GetExtension(unittest::repeated_int64_extension_lite , 1)); - EXPECT_EQ(303 , message.GetExtension(unittest::repeated_uint32_extension_lite , 1)); - EXPECT_EQ(304 , message.GetExtension(unittest::repeated_uint64_extension_lite , 1)); - EXPECT_EQ(305 , message.GetExtension(unittest::repeated_sint32_extension_lite , 1)); - EXPECT_EQ(306 , message.GetExtension(unittest::repeated_sint64_extension_lite , 1)); - EXPECT_EQ(307 , message.GetExtension(unittest::repeated_fixed32_extension_lite , 1)); - EXPECT_EQ(308 , message.GetExtension(unittest::repeated_fixed64_extension_lite , 1)); - EXPECT_EQ(309 , message.GetExtension(unittest::repeated_sfixed32_extension_lite, 1)); - EXPECT_EQ(310 , message.GetExtension(unittest::repeated_sfixed64_extension_lite, 1)); - EXPECT_EQ(311 , message.GetExtension(unittest::repeated_float_extension_lite , 1)); - EXPECT_EQ(312 , message.GetExtension(unittest::repeated_double_extension_lite , 1)); - EXPECT_EQ(false, message.GetExtension(unittest::repeated_bool_extension_lite , 1)); - EXPECT_EQ("315", message.GetExtension(unittest::repeated_string_extension_lite , 1)); - EXPECT_EQ("316", message.GetExtension(unittest::repeated_bytes_extension_lite , 1)); - - EXPECT_EQ(317, message.GetExtension(unittest::repeatedgroup_extension_lite , 1).a()); - EXPECT_EQ(318, message.GetExtension(unittest::repeated_nested_message_extension_lite , 1).bb()); - EXPECT_EQ(319, message.GetExtension(unittest::repeated_foreign_message_extension_lite, 1).c()); - EXPECT_EQ(320, message.GetExtension(unittest::repeated_import_message_extension_lite , 1).d()); - EXPECT_EQ(327, message.GetExtension(unittest::repeated_lazy_message_extension_lite , 1).bb()); - - EXPECT_EQ(unittest::TestAllTypesLite::BAZ , message.GetExtension(unittest::repeated_nested_enum_extension_lite , 1)); - EXPECT_EQ(unittest::FOREIGN_LITE_BAZ , message.GetExtension(unittest::repeated_foreign_enum_extension_lite, 1)); - EXPECT_EQ(unittest_import::IMPORT_LITE_BAZ, message.GetExtension(unittest::repeated_import_enum_extension_lite , 1)); - - - // ----------------------------------------------------------------- - - EXPECT_TRUE(message.HasExtension(unittest::default_int32_extension_lite )); - EXPECT_TRUE(message.HasExtension(unittest::default_int64_extension_lite )); - EXPECT_TRUE(message.HasExtension(unittest::default_uint32_extension_lite )); - EXPECT_TRUE(message.HasExtension(unittest::default_uint64_extension_lite )); - EXPECT_TRUE(message.HasExtension(unittest::default_sint32_extension_lite )); - EXPECT_TRUE(message.HasExtension(unittest::default_sint64_extension_lite )); - EXPECT_TRUE(message.HasExtension(unittest::default_fixed32_extension_lite )); - EXPECT_TRUE(message.HasExtension(unittest::default_fixed64_extension_lite )); - EXPECT_TRUE(message.HasExtension(unittest::default_sfixed32_extension_lite)); - EXPECT_TRUE(message.HasExtension(unittest::default_sfixed64_extension_lite)); - EXPECT_TRUE(message.HasExtension(unittest::default_float_extension_lite )); - EXPECT_TRUE(message.HasExtension(unittest::default_double_extension_lite )); - EXPECT_TRUE(message.HasExtension(unittest::default_bool_extension_lite )); - EXPECT_TRUE(message.HasExtension(unittest::default_string_extension_lite )); - EXPECT_TRUE(message.HasExtension(unittest::default_bytes_extension_lite )); - - EXPECT_TRUE(message.HasExtension(unittest::default_nested_enum_extension_lite )); - EXPECT_TRUE(message.HasExtension(unittest::default_foreign_enum_extension_lite)); - EXPECT_TRUE(message.HasExtension(unittest::default_import_enum_extension_lite )); - - - EXPECT_EQ(401 , message.GetExtension(unittest::default_int32_extension_lite )); - EXPECT_EQ(402 , message.GetExtension(unittest::default_int64_extension_lite )); - EXPECT_EQ(403 , message.GetExtension(unittest::default_uint32_extension_lite )); - EXPECT_EQ(404 , message.GetExtension(unittest::default_uint64_extension_lite )); - EXPECT_EQ(405 , message.GetExtension(unittest::default_sint32_extension_lite )); - EXPECT_EQ(406 , message.GetExtension(unittest::default_sint64_extension_lite )); - EXPECT_EQ(407 , message.GetExtension(unittest::default_fixed32_extension_lite )); - EXPECT_EQ(408 , message.GetExtension(unittest::default_fixed64_extension_lite )); - EXPECT_EQ(409 , message.GetExtension(unittest::default_sfixed32_extension_lite)); - EXPECT_EQ(410 , message.GetExtension(unittest::default_sfixed64_extension_lite)); - EXPECT_EQ(411 , message.GetExtension(unittest::default_float_extension_lite )); - EXPECT_EQ(412 , message.GetExtension(unittest::default_double_extension_lite )); - EXPECT_EQ(false, message.GetExtension(unittest::default_bool_extension_lite )); - EXPECT_EQ("415", message.GetExtension(unittest::default_string_extension_lite )); - EXPECT_EQ("416", message.GetExtension(unittest::default_bytes_extension_lite )); - - EXPECT_EQ(unittest::TestAllTypesLite::FOO , message.GetExtension(unittest::default_nested_enum_extension_lite )); - EXPECT_EQ(unittest::FOREIGN_LITE_FOO , message.GetExtension(unittest::default_foreign_enum_extension_lite)); - EXPECT_EQ(unittest_import::IMPORT_LITE_FOO, message.GetExtension(unittest::default_import_enum_extension_lite )); - -} - -// ------------------------------------------------------------------- - -void TestUtilLite::ExpectExtensionsClear( - const unittest::TestAllExtensionsLite& message) { - string serialized; - ASSERT_TRUE(message.SerializeToString(&serialized)); - EXPECT_EQ("", serialized); - EXPECT_EQ(0, message.ByteSize()); - - // has_blah() should initially be false for all optional fields. - EXPECT_FALSE(message.HasExtension(unittest::optional_int32_extension_lite )); - EXPECT_FALSE(message.HasExtension(unittest::optional_int64_extension_lite )); - EXPECT_FALSE(message.HasExtension(unittest::optional_uint32_extension_lite )); - EXPECT_FALSE(message.HasExtension(unittest::optional_uint64_extension_lite )); - EXPECT_FALSE(message.HasExtension(unittest::optional_sint32_extension_lite )); - EXPECT_FALSE(message.HasExtension(unittest::optional_sint64_extension_lite )); - EXPECT_FALSE(message.HasExtension(unittest::optional_fixed32_extension_lite )); - EXPECT_FALSE(message.HasExtension(unittest::optional_fixed64_extension_lite )); - EXPECT_FALSE(message.HasExtension(unittest::optional_sfixed32_extension_lite)); - EXPECT_FALSE(message.HasExtension(unittest::optional_sfixed64_extension_lite)); - EXPECT_FALSE(message.HasExtension(unittest::optional_float_extension_lite )); - EXPECT_FALSE(message.HasExtension(unittest::optional_double_extension_lite )); - EXPECT_FALSE(message.HasExtension(unittest::optional_bool_extension_lite )); - EXPECT_FALSE(message.HasExtension(unittest::optional_string_extension_lite )); - EXPECT_FALSE(message.HasExtension(unittest::optional_bytes_extension_lite )); - - EXPECT_FALSE(message.HasExtension(unittest::optionalgroup_extension_lite )); - EXPECT_FALSE(message.HasExtension(unittest::optional_nested_message_extension_lite )); - EXPECT_FALSE(message.HasExtension(unittest::optional_foreign_message_extension_lite )); - EXPECT_FALSE(message.HasExtension(unittest::optional_import_message_extension_lite )); - EXPECT_FALSE(message.HasExtension(unittest::optional_public_import_message_extension_lite)); - EXPECT_FALSE(message.HasExtension(unittest::optional_lazy_message_extension_lite )); - - EXPECT_FALSE(message.HasExtension(unittest::optional_nested_enum_extension_lite )); - EXPECT_FALSE(message.HasExtension(unittest::optional_foreign_enum_extension_lite)); - EXPECT_FALSE(message.HasExtension(unittest::optional_import_enum_extension_lite )); - - - // Optional fields without defaults are set to zero or something like it. - EXPECT_EQ(0 , message.GetExtension(unittest::optional_int32_extension_lite )); - EXPECT_EQ(0 , message.GetExtension(unittest::optional_int64_extension_lite )); - EXPECT_EQ(0 , message.GetExtension(unittest::optional_uint32_extension_lite )); - EXPECT_EQ(0 , message.GetExtension(unittest::optional_uint64_extension_lite )); - EXPECT_EQ(0 , message.GetExtension(unittest::optional_sint32_extension_lite )); - EXPECT_EQ(0 , message.GetExtension(unittest::optional_sint64_extension_lite )); - EXPECT_EQ(0 , message.GetExtension(unittest::optional_fixed32_extension_lite )); - EXPECT_EQ(0 , message.GetExtension(unittest::optional_fixed64_extension_lite )); - EXPECT_EQ(0 , message.GetExtension(unittest::optional_sfixed32_extension_lite)); - EXPECT_EQ(0 , message.GetExtension(unittest::optional_sfixed64_extension_lite)); - EXPECT_EQ(0 , message.GetExtension(unittest::optional_float_extension_lite )); - EXPECT_EQ(0 , message.GetExtension(unittest::optional_double_extension_lite )); - EXPECT_EQ(false, message.GetExtension(unittest::optional_bool_extension_lite )); - EXPECT_EQ("" , message.GetExtension(unittest::optional_string_extension_lite )); - EXPECT_EQ("" , message.GetExtension(unittest::optional_bytes_extension_lite )); - - // Embedded messages should also be clear. - EXPECT_FALSE(message.GetExtension(unittest::optionalgroup_extension_lite ).has_a()); - EXPECT_FALSE(message.GetExtension(unittest::optional_nested_message_extension_lite ).has_bb()); - EXPECT_FALSE(message.GetExtension(unittest::optional_foreign_message_extension_lite ).has_c()); - EXPECT_FALSE(message.GetExtension(unittest::optional_import_message_extension_lite ).has_d()); - EXPECT_FALSE(message.GetExtension(unittest::optional_public_import_message_extension_lite).has_e()); - EXPECT_FALSE(message.GetExtension(unittest::optional_lazy_message_extension_lite ).has_bb()); - - EXPECT_EQ(0, message.GetExtension(unittest::optionalgroup_extension_lite ).a()); - EXPECT_EQ(0, message.GetExtension(unittest::optional_nested_message_extension_lite ).bb()); - EXPECT_EQ(0, message.GetExtension(unittest::optional_foreign_message_extension_lite ).c()); - EXPECT_EQ(0, message.GetExtension(unittest::optional_import_message_extension_lite ).d()); - EXPECT_EQ(0, message.GetExtension(unittest::optional_public_import_message_extension_lite).e()); - EXPECT_EQ(0, message.GetExtension(unittest::optional_lazy_message_extension_lite ).bb()); - - // Enums without defaults are set to the first value in the enum. - EXPECT_EQ(unittest::TestAllTypesLite::FOO , message.GetExtension(unittest::optional_nested_enum_extension_lite )); - EXPECT_EQ(unittest::FOREIGN_LITE_FOO , message.GetExtension(unittest::optional_foreign_enum_extension_lite)); - EXPECT_EQ(unittest_import::IMPORT_LITE_FOO, message.GetExtension(unittest::optional_import_enum_extension_lite )); - - - // Repeated fields are empty. - EXPECT_EQ(0, message.ExtensionSize(unittest::repeated_int32_extension_lite )); - EXPECT_EQ(0, message.ExtensionSize(unittest::repeated_int64_extension_lite )); - EXPECT_EQ(0, message.ExtensionSize(unittest::repeated_uint32_extension_lite )); - EXPECT_EQ(0, message.ExtensionSize(unittest::repeated_uint64_extension_lite )); - EXPECT_EQ(0, message.ExtensionSize(unittest::repeated_sint32_extension_lite )); - EXPECT_EQ(0, message.ExtensionSize(unittest::repeated_sint64_extension_lite )); - EXPECT_EQ(0, message.ExtensionSize(unittest::repeated_fixed32_extension_lite )); - EXPECT_EQ(0, message.ExtensionSize(unittest::repeated_fixed64_extension_lite )); - EXPECT_EQ(0, message.ExtensionSize(unittest::repeated_sfixed32_extension_lite)); - EXPECT_EQ(0, message.ExtensionSize(unittest::repeated_sfixed64_extension_lite)); - EXPECT_EQ(0, message.ExtensionSize(unittest::repeated_float_extension_lite )); - EXPECT_EQ(0, message.ExtensionSize(unittest::repeated_double_extension_lite )); - EXPECT_EQ(0, message.ExtensionSize(unittest::repeated_bool_extension_lite )); - EXPECT_EQ(0, message.ExtensionSize(unittest::repeated_string_extension_lite )); - EXPECT_EQ(0, message.ExtensionSize(unittest::repeated_bytes_extension_lite )); - - EXPECT_EQ(0, message.ExtensionSize(unittest::repeatedgroup_extension_lite )); - EXPECT_EQ(0, message.ExtensionSize(unittest::repeated_nested_message_extension_lite )); - EXPECT_EQ(0, message.ExtensionSize(unittest::repeated_foreign_message_extension_lite)); - EXPECT_EQ(0, message.ExtensionSize(unittest::repeated_import_message_extension_lite )); - EXPECT_EQ(0, message.ExtensionSize(unittest::repeated_lazy_message_extension_lite )); - EXPECT_EQ(0, message.ExtensionSize(unittest::repeated_nested_enum_extension_lite )); - EXPECT_EQ(0, message.ExtensionSize(unittest::repeated_foreign_enum_extension_lite )); - EXPECT_EQ(0, message.ExtensionSize(unittest::repeated_import_enum_extension_lite )); - - - // has_blah() should also be false for all default fields. - EXPECT_FALSE(message.HasExtension(unittest::default_int32_extension_lite )); - EXPECT_FALSE(message.HasExtension(unittest::default_int64_extension_lite )); - EXPECT_FALSE(message.HasExtension(unittest::default_uint32_extension_lite )); - EXPECT_FALSE(message.HasExtension(unittest::default_uint64_extension_lite )); - EXPECT_FALSE(message.HasExtension(unittest::default_sint32_extension_lite )); - EXPECT_FALSE(message.HasExtension(unittest::default_sint64_extension_lite )); - EXPECT_FALSE(message.HasExtension(unittest::default_fixed32_extension_lite )); - EXPECT_FALSE(message.HasExtension(unittest::default_fixed64_extension_lite )); - EXPECT_FALSE(message.HasExtension(unittest::default_sfixed32_extension_lite)); - EXPECT_FALSE(message.HasExtension(unittest::default_sfixed64_extension_lite)); - EXPECT_FALSE(message.HasExtension(unittest::default_float_extension_lite )); - EXPECT_FALSE(message.HasExtension(unittest::default_double_extension_lite )); - EXPECT_FALSE(message.HasExtension(unittest::default_bool_extension_lite )); - EXPECT_FALSE(message.HasExtension(unittest::default_string_extension_lite )); - EXPECT_FALSE(message.HasExtension(unittest::default_bytes_extension_lite )); - - EXPECT_FALSE(message.HasExtension(unittest::default_nested_enum_extension_lite )); - EXPECT_FALSE(message.HasExtension(unittest::default_foreign_enum_extension_lite)); - EXPECT_FALSE(message.HasExtension(unittest::default_import_enum_extension_lite )); - - - // Fields with defaults have their default values (duh). - EXPECT_EQ( 41 , message.GetExtension(unittest::default_int32_extension_lite )); - EXPECT_EQ( 42 , message.GetExtension(unittest::default_int64_extension_lite )); - EXPECT_EQ( 43 , message.GetExtension(unittest::default_uint32_extension_lite )); - EXPECT_EQ( 44 , message.GetExtension(unittest::default_uint64_extension_lite )); - EXPECT_EQ(-45 , message.GetExtension(unittest::default_sint32_extension_lite )); - EXPECT_EQ( 46 , message.GetExtension(unittest::default_sint64_extension_lite )); - EXPECT_EQ( 47 , message.GetExtension(unittest::default_fixed32_extension_lite )); - EXPECT_EQ( 48 , message.GetExtension(unittest::default_fixed64_extension_lite )); - EXPECT_EQ( 49 , message.GetExtension(unittest::default_sfixed32_extension_lite)); - EXPECT_EQ(-50 , message.GetExtension(unittest::default_sfixed64_extension_lite)); - EXPECT_EQ( 51.5 , message.GetExtension(unittest::default_float_extension_lite )); - EXPECT_EQ( 52e3 , message.GetExtension(unittest::default_double_extension_lite )); - EXPECT_EQ(true , message.GetExtension(unittest::default_bool_extension_lite )); - EXPECT_EQ("hello", message.GetExtension(unittest::default_string_extension_lite )); - EXPECT_EQ("world", message.GetExtension(unittest::default_bytes_extension_lite )); - - EXPECT_EQ(unittest::TestAllTypesLite::BAR , message.GetExtension(unittest::default_nested_enum_extension_lite )); - EXPECT_EQ(unittest::FOREIGN_LITE_BAR , message.GetExtension(unittest::default_foreign_enum_extension_lite)); - EXPECT_EQ(unittest_import::IMPORT_LITE_BAR, message.GetExtension(unittest::default_import_enum_extension_lite )); - -} - -// ------------------------------------------------------------------- - -void TestUtilLite::ExpectRepeatedExtensionsModified( - const unittest::TestAllExtensionsLite& message) { - // ModifyRepeatedFields only sets the second repeated element of each - // field. In addition to verifying this, we also verify that the first - // element and size were *not* modified. - ASSERT_EQ(2, message.ExtensionSize(unittest::repeated_int32_extension_lite )); - ASSERT_EQ(2, message.ExtensionSize(unittest::repeated_int64_extension_lite )); - ASSERT_EQ(2, message.ExtensionSize(unittest::repeated_uint32_extension_lite )); - ASSERT_EQ(2, message.ExtensionSize(unittest::repeated_uint64_extension_lite )); - ASSERT_EQ(2, message.ExtensionSize(unittest::repeated_sint32_extension_lite )); - ASSERT_EQ(2, message.ExtensionSize(unittest::repeated_sint64_extension_lite )); - ASSERT_EQ(2, message.ExtensionSize(unittest::repeated_fixed32_extension_lite )); - ASSERT_EQ(2, message.ExtensionSize(unittest::repeated_fixed64_extension_lite )); - ASSERT_EQ(2, message.ExtensionSize(unittest::repeated_sfixed32_extension_lite)); - ASSERT_EQ(2, message.ExtensionSize(unittest::repeated_sfixed64_extension_lite)); - ASSERT_EQ(2, message.ExtensionSize(unittest::repeated_float_extension_lite )); - ASSERT_EQ(2, message.ExtensionSize(unittest::repeated_double_extension_lite )); - ASSERT_EQ(2, message.ExtensionSize(unittest::repeated_bool_extension_lite )); - ASSERT_EQ(2, message.ExtensionSize(unittest::repeated_string_extension_lite )); - ASSERT_EQ(2, message.ExtensionSize(unittest::repeated_bytes_extension_lite )); - - ASSERT_EQ(2, message.ExtensionSize(unittest::repeatedgroup_extension_lite )); - ASSERT_EQ(2, message.ExtensionSize(unittest::repeated_nested_message_extension_lite )); - ASSERT_EQ(2, message.ExtensionSize(unittest::repeated_foreign_message_extension_lite)); - ASSERT_EQ(2, message.ExtensionSize(unittest::repeated_import_message_extension_lite )); - ASSERT_EQ(2, message.ExtensionSize(unittest::repeated_lazy_message_extension_lite )); - ASSERT_EQ(2, message.ExtensionSize(unittest::repeated_nested_enum_extension_lite )); - ASSERT_EQ(2, message.ExtensionSize(unittest::repeated_foreign_enum_extension_lite )); - ASSERT_EQ(2, message.ExtensionSize(unittest::repeated_import_enum_extension_lite )); - - - EXPECT_EQ(201 , message.GetExtension(unittest::repeated_int32_extension_lite , 0)); - EXPECT_EQ(202 , message.GetExtension(unittest::repeated_int64_extension_lite , 0)); - EXPECT_EQ(203 , message.GetExtension(unittest::repeated_uint32_extension_lite , 0)); - EXPECT_EQ(204 , message.GetExtension(unittest::repeated_uint64_extension_lite , 0)); - EXPECT_EQ(205 , message.GetExtension(unittest::repeated_sint32_extension_lite , 0)); - EXPECT_EQ(206 , message.GetExtension(unittest::repeated_sint64_extension_lite , 0)); - EXPECT_EQ(207 , message.GetExtension(unittest::repeated_fixed32_extension_lite , 0)); - EXPECT_EQ(208 , message.GetExtension(unittest::repeated_fixed64_extension_lite , 0)); - EXPECT_EQ(209 , message.GetExtension(unittest::repeated_sfixed32_extension_lite, 0)); - EXPECT_EQ(210 , message.GetExtension(unittest::repeated_sfixed64_extension_lite, 0)); - EXPECT_EQ(211 , message.GetExtension(unittest::repeated_float_extension_lite , 0)); - EXPECT_EQ(212 , message.GetExtension(unittest::repeated_double_extension_lite , 0)); - EXPECT_EQ(true , message.GetExtension(unittest::repeated_bool_extension_lite , 0)); - EXPECT_EQ("215", message.GetExtension(unittest::repeated_string_extension_lite , 0)); - EXPECT_EQ("216", message.GetExtension(unittest::repeated_bytes_extension_lite , 0)); - - EXPECT_EQ(217, message.GetExtension(unittest::repeatedgroup_extension_lite , 0).a()); - EXPECT_EQ(218, message.GetExtension(unittest::repeated_nested_message_extension_lite , 0).bb()); - EXPECT_EQ(219, message.GetExtension(unittest::repeated_foreign_message_extension_lite, 0).c()); - EXPECT_EQ(220, message.GetExtension(unittest::repeated_import_message_extension_lite , 0).d()); - EXPECT_EQ(227, message.GetExtension(unittest::repeated_lazy_message_extension_lite , 0).bb()); - - EXPECT_EQ(unittest::TestAllTypesLite::BAR , message.GetExtension(unittest::repeated_nested_enum_extension_lite , 0)); - EXPECT_EQ(unittest::FOREIGN_LITE_BAR , message.GetExtension(unittest::repeated_foreign_enum_extension_lite, 0)); - EXPECT_EQ(unittest_import::IMPORT_LITE_BAR, message.GetExtension(unittest::repeated_import_enum_extension_lite , 0)); - - - // Actually verify the second (modified) elements now. - EXPECT_EQ(501 , message.GetExtension(unittest::repeated_int32_extension_lite , 1)); - EXPECT_EQ(502 , message.GetExtension(unittest::repeated_int64_extension_lite , 1)); - EXPECT_EQ(503 , message.GetExtension(unittest::repeated_uint32_extension_lite , 1)); - EXPECT_EQ(504 , message.GetExtension(unittest::repeated_uint64_extension_lite , 1)); - EXPECT_EQ(505 , message.GetExtension(unittest::repeated_sint32_extension_lite , 1)); - EXPECT_EQ(506 , message.GetExtension(unittest::repeated_sint64_extension_lite , 1)); - EXPECT_EQ(507 , message.GetExtension(unittest::repeated_fixed32_extension_lite , 1)); - EXPECT_EQ(508 , message.GetExtension(unittest::repeated_fixed64_extension_lite , 1)); - EXPECT_EQ(509 , message.GetExtension(unittest::repeated_sfixed32_extension_lite, 1)); - EXPECT_EQ(510 , message.GetExtension(unittest::repeated_sfixed64_extension_lite, 1)); - EXPECT_EQ(511 , message.GetExtension(unittest::repeated_float_extension_lite , 1)); - EXPECT_EQ(512 , message.GetExtension(unittest::repeated_double_extension_lite , 1)); - EXPECT_EQ(true , message.GetExtension(unittest::repeated_bool_extension_lite , 1)); - EXPECT_EQ("515", message.GetExtension(unittest::repeated_string_extension_lite , 1)); - EXPECT_EQ("516", message.GetExtension(unittest::repeated_bytes_extension_lite , 1)); - - EXPECT_EQ(517, message.GetExtension(unittest::repeatedgroup_extension_lite , 1).a()); - EXPECT_EQ(518, message.GetExtension(unittest::repeated_nested_message_extension_lite , 1).bb()); - EXPECT_EQ(519, message.GetExtension(unittest::repeated_foreign_message_extension_lite, 1).c()); - EXPECT_EQ(520, message.GetExtension(unittest::repeated_import_message_extension_lite , 1).d()); - EXPECT_EQ(527, message.GetExtension(unittest::repeated_lazy_message_extension_lite , 1).bb()); - - EXPECT_EQ(unittest::TestAllTypesLite::FOO , message.GetExtension(unittest::repeated_nested_enum_extension_lite , 1)); - EXPECT_EQ(unittest::FOREIGN_LITE_FOO , message.GetExtension(unittest::repeated_foreign_enum_extension_lite, 1)); - EXPECT_EQ(unittest_import::IMPORT_LITE_FOO, message.GetExtension(unittest::repeated_import_enum_extension_lite , 1)); - -} - -// ------------------------------------------------------------------- - -void TestUtilLite::SetPackedExtensions( - unittest::TestPackedExtensionsLite* message) { - message->AddExtension(unittest::packed_int32_extension_lite , 601); - message->AddExtension(unittest::packed_int64_extension_lite , 602); - message->AddExtension(unittest::packed_uint32_extension_lite , 603); - message->AddExtension(unittest::packed_uint64_extension_lite , 604); - message->AddExtension(unittest::packed_sint32_extension_lite , 605); - message->AddExtension(unittest::packed_sint64_extension_lite , 606); - message->AddExtension(unittest::packed_fixed32_extension_lite , 607); - message->AddExtension(unittest::packed_fixed64_extension_lite , 608); - message->AddExtension(unittest::packed_sfixed32_extension_lite, 609); - message->AddExtension(unittest::packed_sfixed64_extension_lite, 610); - message->AddExtension(unittest::packed_float_extension_lite , 611); - message->AddExtension(unittest::packed_double_extension_lite , 612); - message->AddExtension(unittest::packed_bool_extension_lite , true); - message->AddExtension(unittest::packed_enum_extension_lite, unittest::FOREIGN_LITE_BAR); - // add a second one of each field - message->AddExtension(unittest::packed_int32_extension_lite , 701); - message->AddExtension(unittest::packed_int64_extension_lite , 702); - message->AddExtension(unittest::packed_uint32_extension_lite , 703); - message->AddExtension(unittest::packed_uint64_extension_lite , 704); - message->AddExtension(unittest::packed_sint32_extension_lite , 705); - message->AddExtension(unittest::packed_sint64_extension_lite , 706); - message->AddExtension(unittest::packed_fixed32_extension_lite , 707); - message->AddExtension(unittest::packed_fixed64_extension_lite , 708); - message->AddExtension(unittest::packed_sfixed32_extension_lite, 709); - message->AddExtension(unittest::packed_sfixed64_extension_lite, 710); - message->AddExtension(unittest::packed_float_extension_lite , 711); - message->AddExtension(unittest::packed_double_extension_lite , 712); - message->AddExtension(unittest::packed_bool_extension_lite , false); - message->AddExtension(unittest::packed_enum_extension_lite, unittest::FOREIGN_LITE_BAZ); -} - -// ------------------------------------------------------------------- - -void TestUtilLite::ModifyPackedExtensions( - unittest::TestPackedExtensionsLite* message) { - message->SetExtension(unittest::packed_int32_extension_lite , 1, 801); - message->SetExtension(unittest::packed_int64_extension_lite , 1, 802); - message->SetExtension(unittest::packed_uint32_extension_lite , 1, 803); - message->SetExtension(unittest::packed_uint64_extension_lite , 1, 804); - message->SetExtension(unittest::packed_sint32_extension_lite , 1, 805); - message->SetExtension(unittest::packed_sint64_extension_lite , 1, 806); - message->SetExtension(unittest::packed_fixed32_extension_lite , 1, 807); - message->SetExtension(unittest::packed_fixed64_extension_lite , 1, 808); - message->SetExtension(unittest::packed_sfixed32_extension_lite, 1, 809); - message->SetExtension(unittest::packed_sfixed64_extension_lite, 1, 810); - message->SetExtension(unittest::packed_float_extension_lite , 1, 811); - message->SetExtension(unittest::packed_double_extension_lite , 1, 812); - message->SetExtension(unittest::packed_bool_extension_lite , 1, true); - message->SetExtension(unittest::packed_enum_extension_lite , 1, - unittest::FOREIGN_LITE_FOO); -} - -// ------------------------------------------------------------------- - -void TestUtilLite::ExpectPackedExtensionsSet( - const unittest::TestPackedExtensionsLite& message) { - ASSERT_EQ(2, message.ExtensionSize(unittest::packed_int32_extension_lite )); - ASSERT_EQ(2, message.ExtensionSize(unittest::packed_int64_extension_lite )); - ASSERT_EQ(2, message.ExtensionSize(unittest::packed_uint32_extension_lite )); - ASSERT_EQ(2, message.ExtensionSize(unittest::packed_uint64_extension_lite )); - ASSERT_EQ(2, message.ExtensionSize(unittest::packed_sint32_extension_lite )); - ASSERT_EQ(2, message.ExtensionSize(unittest::packed_sint64_extension_lite )); - ASSERT_EQ(2, message.ExtensionSize(unittest::packed_fixed32_extension_lite )); - ASSERT_EQ(2, message.ExtensionSize(unittest::packed_fixed64_extension_lite )); - ASSERT_EQ(2, message.ExtensionSize(unittest::packed_sfixed32_extension_lite)); - ASSERT_EQ(2, message.ExtensionSize(unittest::packed_sfixed64_extension_lite)); - ASSERT_EQ(2, message.ExtensionSize(unittest::packed_float_extension_lite )); - ASSERT_EQ(2, message.ExtensionSize(unittest::packed_double_extension_lite )); - ASSERT_EQ(2, message.ExtensionSize(unittest::packed_bool_extension_lite )); - ASSERT_EQ(2, message.ExtensionSize(unittest::packed_enum_extension_lite )); - - EXPECT_EQ(601 , message.GetExtension(unittest::packed_int32_extension_lite , 0)); - EXPECT_EQ(602 , message.GetExtension(unittest::packed_int64_extension_lite , 0)); - EXPECT_EQ(603 , message.GetExtension(unittest::packed_uint32_extension_lite , 0)); - EXPECT_EQ(604 , message.GetExtension(unittest::packed_uint64_extension_lite , 0)); - EXPECT_EQ(605 , message.GetExtension(unittest::packed_sint32_extension_lite , 0)); - EXPECT_EQ(606 , message.GetExtension(unittest::packed_sint64_extension_lite , 0)); - EXPECT_EQ(607 , message.GetExtension(unittest::packed_fixed32_extension_lite , 0)); - EXPECT_EQ(608 , message.GetExtension(unittest::packed_fixed64_extension_lite , 0)); - EXPECT_EQ(609 , message.GetExtension(unittest::packed_sfixed32_extension_lite, 0)); - EXPECT_EQ(610 , message.GetExtension(unittest::packed_sfixed64_extension_lite, 0)); - EXPECT_EQ(611 , message.GetExtension(unittest::packed_float_extension_lite , 0)); - EXPECT_EQ(612 , message.GetExtension(unittest::packed_double_extension_lite , 0)); - EXPECT_EQ(true , message.GetExtension(unittest::packed_bool_extension_lite , 0)); - EXPECT_EQ(unittest::FOREIGN_LITE_BAR, - message.GetExtension(unittest::packed_enum_extension_lite, 0)); - EXPECT_EQ(701 , message.GetExtension(unittest::packed_int32_extension_lite , 1)); - EXPECT_EQ(702 , message.GetExtension(unittest::packed_int64_extension_lite , 1)); - EXPECT_EQ(703 , message.GetExtension(unittest::packed_uint32_extension_lite , 1)); - EXPECT_EQ(704 , message.GetExtension(unittest::packed_uint64_extension_lite , 1)); - EXPECT_EQ(705 , message.GetExtension(unittest::packed_sint32_extension_lite , 1)); - EXPECT_EQ(706 , message.GetExtension(unittest::packed_sint64_extension_lite , 1)); - EXPECT_EQ(707 , message.GetExtension(unittest::packed_fixed32_extension_lite , 1)); - EXPECT_EQ(708 , message.GetExtension(unittest::packed_fixed64_extension_lite , 1)); - EXPECT_EQ(709 , message.GetExtension(unittest::packed_sfixed32_extension_lite, 1)); - EXPECT_EQ(710 , message.GetExtension(unittest::packed_sfixed64_extension_lite, 1)); - EXPECT_EQ(711 , message.GetExtension(unittest::packed_float_extension_lite , 1)); - EXPECT_EQ(712 , message.GetExtension(unittest::packed_double_extension_lite , 1)); - EXPECT_EQ(false, message.GetExtension(unittest::packed_bool_extension_lite , 1)); - EXPECT_EQ(unittest::FOREIGN_LITE_BAZ, - message.GetExtension(unittest::packed_enum_extension_lite, 1)); -} - -// ------------------------------------------------------------------- - -void TestUtilLite::ExpectPackedExtensionsClear( - const unittest::TestPackedExtensionsLite& message) { - EXPECT_EQ(0, message.ExtensionSize(unittest::packed_int32_extension_lite )); - EXPECT_EQ(0, message.ExtensionSize(unittest::packed_int64_extension_lite )); - EXPECT_EQ(0, message.ExtensionSize(unittest::packed_uint32_extension_lite )); - EXPECT_EQ(0, message.ExtensionSize(unittest::packed_uint64_extension_lite )); - EXPECT_EQ(0, message.ExtensionSize(unittest::packed_sint32_extension_lite )); - EXPECT_EQ(0, message.ExtensionSize(unittest::packed_sint64_extension_lite )); - EXPECT_EQ(0, message.ExtensionSize(unittest::packed_fixed32_extension_lite )); - EXPECT_EQ(0, message.ExtensionSize(unittest::packed_fixed64_extension_lite )); - EXPECT_EQ(0, message.ExtensionSize(unittest::packed_sfixed32_extension_lite)); - EXPECT_EQ(0, message.ExtensionSize(unittest::packed_sfixed64_extension_lite)); - EXPECT_EQ(0, message.ExtensionSize(unittest::packed_float_extension_lite )); - EXPECT_EQ(0, message.ExtensionSize(unittest::packed_double_extension_lite )); - EXPECT_EQ(0, message.ExtensionSize(unittest::packed_bool_extension_lite )); - EXPECT_EQ(0, message.ExtensionSize(unittest::packed_enum_extension_lite )); -} - -// ------------------------------------------------------------------- - -void TestUtilLite::ExpectPackedExtensionsModified( - const unittest::TestPackedExtensionsLite& message) { - ASSERT_EQ(2, message.ExtensionSize(unittest::packed_int32_extension_lite )); - ASSERT_EQ(2, message.ExtensionSize(unittest::packed_int64_extension_lite )); - ASSERT_EQ(2, message.ExtensionSize(unittest::packed_uint32_extension_lite )); - ASSERT_EQ(2, message.ExtensionSize(unittest::packed_uint64_extension_lite )); - ASSERT_EQ(2, message.ExtensionSize(unittest::packed_sint32_extension_lite )); - ASSERT_EQ(2, message.ExtensionSize(unittest::packed_sint64_extension_lite )); - ASSERT_EQ(2, message.ExtensionSize(unittest::packed_fixed32_extension_lite )); - ASSERT_EQ(2, message.ExtensionSize(unittest::packed_fixed64_extension_lite )); - ASSERT_EQ(2, message.ExtensionSize(unittest::packed_sfixed32_extension_lite)); - ASSERT_EQ(2, message.ExtensionSize(unittest::packed_sfixed64_extension_lite)); - ASSERT_EQ(2, message.ExtensionSize(unittest::packed_float_extension_lite )); - ASSERT_EQ(2, message.ExtensionSize(unittest::packed_double_extension_lite )); - ASSERT_EQ(2, message.ExtensionSize(unittest::packed_bool_extension_lite )); - ASSERT_EQ(2, message.ExtensionSize(unittest::packed_enum_extension_lite )); - EXPECT_EQ(601 , message.GetExtension(unittest::packed_int32_extension_lite , 0)); - EXPECT_EQ(602 , message.GetExtension(unittest::packed_int64_extension_lite , 0)); - EXPECT_EQ(603 , message.GetExtension(unittest::packed_uint32_extension_lite , 0)); - EXPECT_EQ(604 , message.GetExtension(unittest::packed_uint64_extension_lite , 0)); - EXPECT_EQ(605 , message.GetExtension(unittest::packed_sint32_extension_lite , 0)); - EXPECT_EQ(606 , message.GetExtension(unittest::packed_sint64_extension_lite , 0)); - EXPECT_EQ(607 , message.GetExtension(unittest::packed_fixed32_extension_lite , 0)); - EXPECT_EQ(608 , message.GetExtension(unittest::packed_fixed64_extension_lite , 0)); - EXPECT_EQ(609 , message.GetExtension(unittest::packed_sfixed32_extension_lite, 0)); - EXPECT_EQ(610 , message.GetExtension(unittest::packed_sfixed64_extension_lite, 0)); - EXPECT_EQ(611 , message.GetExtension(unittest::packed_float_extension_lite , 0)); - EXPECT_EQ(612 , message.GetExtension(unittest::packed_double_extension_lite , 0)); - EXPECT_EQ(true , message.GetExtension(unittest::packed_bool_extension_lite , 0)); - EXPECT_EQ(unittest::FOREIGN_LITE_BAR, - message.GetExtension(unittest::packed_enum_extension_lite, 0)); - - // Actually verify the second (modified) elements now. - EXPECT_EQ(801 , message.GetExtension(unittest::packed_int32_extension_lite , 1)); - EXPECT_EQ(802 , message.GetExtension(unittest::packed_int64_extension_lite , 1)); - EXPECT_EQ(803 , message.GetExtension(unittest::packed_uint32_extension_lite , 1)); - EXPECT_EQ(804 , message.GetExtension(unittest::packed_uint64_extension_lite , 1)); - EXPECT_EQ(805 , message.GetExtension(unittest::packed_sint32_extension_lite , 1)); - EXPECT_EQ(806 , message.GetExtension(unittest::packed_sint64_extension_lite , 1)); - EXPECT_EQ(807 , message.GetExtension(unittest::packed_fixed32_extension_lite , 1)); - EXPECT_EQ(808 , message.GetExtension(unittest::packed_fixed64_extension_lite , 1)); - EXPECT_EQ(809 , message.GetExtension(unittest::packed_sfixed32_extension_lite, 1)); - EXPECT_EQ(810 , message.GetExtension(unittest::packed_sfixed64_extension_lite, 1)); - EXPECT_EQ(811 , message.GetExtension(unittest::packed_float_extension_lite , 1)); - EXPECT_EQ(812 , message.GetExtension(unittest::packed_double_extension_lite , 1)); - EXPECT_EQ(true , message.GetExtension(unittest::packed_bool_extension_lite , 1)); - EXPECT_EQ(unittest::FOREIGN_LITE_FOO, - message.GetExtension(unittest::packed_enum_extension_lite, 1)); -} - -} // namespace protobuf -} // namespace google diff --git a/modules/dnn/3rdparty/protobuf/src/google/protobuf/test_util_lite.h b/modules/dnn/3rdparty/protobuf/src/google/protobuf/test_util_lite.h deleted file mode 100644 index ca35aaa47..000000000 --- a/modules/dnn/3rdparty/protobuf/src/google/protobuf/test_util_lite.h +++ /dev/null @@ -1,101 +0,0 @@ -// Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// http://code.google.com/p/protobuf/ -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -// Author: kenton@google.com (Kenton Varda) -// Based on original Protocol Buffers design by -// Sanjay Ghemawat, Jeff Dean, and others. - -#ifndef GOOGLE_PROTOBUF_TEST_UTIL_LITE_H__ -#define GOOGLE_PROTOBUF_TEST_UTIL_LITE_H__ - -#include - -namespace google { -namespace protobuf { - -namespace unittest = protobuf_unittest; -namespace unittest_import = protobuf_unittest_import; - -class TestUtilLite { - public: - // Set every field in the message to a unique value. - static void SetAllFields(unittest::TestAllTypesLite* message); - static void SetAllExtensions(unittest::TestAllExtensionsLite* message); - static void SetPackedFields(unittest::TestPackedTypesLite* message); - static void SetPackedExtensions(unittest::TestPackedExtensionsLite* message); - - // Use the repeated versions of the set_*() accessors to modify all the - // repeated fields of the messsage (which should already have been - // initialized with Set*Fields()). Set*Fields() itself only tests - // the add_*() accessors. - static void ModifyRepeatedFields(unittest::TestAllTypesLite* message); - static void ModifyRepeatedExtensions( - unittest::TestAllExtensionsLite* message); - static void ModifyPackedFields(unittest::TestPackedTypesLite* message); - static void ModifyPackedExtensions( - unittest::TestPackedExtensionsLite* message); - - // Check that all fields have the values that they should have after - // Set*Fields() is called. - static void ExpectAllFieldsSet(const unittest::TestAllTypesLite& message); - static void ExpectAllExtensionsSet( - const unittest::TestAllExtensionsLite& message); - static void ExpectPackedFieldsSet( - const unittest::TestPackedTypesLite& message); - static void ExpectPackedExtensionsSet( - const unittest::TestPackedExtensionsLite& message); - - // Expect that the message is modified as would be expected from - // Modify*Fields(). - static void ExpectRepeatedFieldsModified( - const unittest::TestAllTypesLite& message); - static void ExpectRepeatedExtensionsModified( - const unittest::TestAllExtensionsLite& message); - static void ExpectPackedFieldsModified( - const unittest::TestPackedTypesLite& message); - static void ExpectPackedExtensionsModified( - const unittest::TestPackedExtensionsLite& message); - - // Check that all fields have their default values. - static void ExpectClear(const unittest::TestAllTypesLite& message); - static void ExpectExtensionsClear( - const unittest::TestAllExtensionsLite& message); - static void ExpectPackedClear(const unittest::TestPackedTypesLite& message); - static void ExpectPackedExtensionsClear( - const unittest::TestPackedExtensionsLite& message); - - private: - GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(TestUtilLite); -}; - -} // namespace protobuf - -} // namespace google -#endif // GOOGLE_PROTOBUF_TEST_UTIL_LITE_H__ diff --git a/modules/dnn/3rdparty/protobuf/src/google/protobuf/testing/file.cc b/modules/dnn/3rdparty/protobuf/src/google/protobuf/testing/file.cc deleted file mode 100644 index e224781db..000000000 --- a/modules/dnn/3rdparty/protobuf/src/google/protobuf/testing/file.cc +++ /dev/null @@ -1,176 +0,0 @@ -// Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// http://code.google.com/p/protobuf/ -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -// Author: kenton@google.com (Kenton Varda) -// emulates google3/file/base/file.cc - -#include -#include -#include -#include -#ifdef _MSC_VER -#define WIN32_LEAN_AND_MEAN // yeah, right -#include // Find*File(). :( -#include -#include -#else -#include -#include -#endif -#include - -namespace google { -namespace protobuf { - -#ifdef _WIN32 -#define mkdir(name, mode) mkdir(name) -// Windows doesn't have symbolic links. -#define lstat stat -#ifndef F_OK -#define F_OK 00 // not defined by MSVC for whatever reason -#endif -#endif - -bool File::Exists(const string& name) { - return access(name.c_str(), F_OK) == 0; -} - -bool File::ReadFileToString(const string& name, string* output) { - char buffer[1024]; - FILE* file = fopen(name.c_str(), "rb"); - if (file == NULL) return false; - - while (true) { - size_t n = fread(buffer, 1, sizeof(buffer), file); - if (n <= 0) break; - output->append(buffer, n); - } - - int error = ferror(file); - if (fclose(file) != 0) return false; - return error == 0; -} - -void File::ReadFileToStringOrDie(const string& name, string* output) { - GOOGLE_CHECK(ReadFileToString(name, output)) << "Could not read: " << name; -} - -void File::WriteStringToFileOrDie(const string& contents, const string& name) { - FILE* file = fopen(name.c_str(), "wb"); - GOOGLE_CHECK(file != NULL) - << "fopen(" << name << ", \"wb\"): " << strerror(errno); - GOOGLE_CHECK_EQ(fwrite(contents.data(), 1, contents.size(), file), - contents.size()) - << "fwrite(" << name << "): " << strerror(errno); - GOOGLE_CHECK(fclose(file) == 0) - << "fclose(" << name << "): " << strerror(errno); -} - -bool File::CreateDir(const string& name, int mode) { - return mkdir(name.c_str(), mode) == 0; -} - -bool File::RecursivelyCreateDir(const string& path, int mode) { - if (CreateDir(path, mode)) return true; - - if (Exists(path)) return false; - - // Try creating the parent. - string::size_type slashpos = path.find_last_of('/'); - if (slashpos == string::npos) { - // No parent given. - return false; - } - - return RecursivelyCreateDir(path.substr(0, slashpos), mode) && - CreateDir(path, mode); -} - -void File::DeleteRecursively(const string& name, - void* dummy1, void* dummy2) { - // We don't care too much about error checking here since this is only used - // in tests to delete temporary directories that are under /tmp anyway. - -#ifdef _MSC_VER - // This interface is so weird. - WIN32_FIND_DATA find_data; - HANDLE find_handle = FindFirstFile((name + "/*").c_str(), &find_data); - if (find_handle == INVALID_HANDLE_VALUE) { - // Just delete it, whatever it is. - DeleteFile(name.c_str()); - RemoveDirectory(name.c_str()); - return; - } - - do { - string entry_name = find_data.cFileName; - if (entry_name != "." && entry_name != "..") { - string path = name + "/" + entry_name; - if (find_data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) { - DeleteRecursively(path, NULL, NULL); - RemoveDirectory(path.c_str()); - } else { - DeleteFile(path.c_str()); - } - } - } while(FindNextFile(find_handle, &find_data)); - FindClose(find_handle); - - RemoveDirectory(name.c_str()); -#else - // Use opendir()! Yay! - // lstat = Don't follow symbolic links. - struct stat stats; - if (lstat(name.c_str(), &stats) != 0) return; - - if (S_ISDIR(stats.st_mode)) { - DIR* dir = opendir(name.c_str()); - if (dir != NULL) { - while (true) { - struct dirent* entry = readdir(dir); - if (entry == NULL) break; - string entry_name = entry->d_name; - if (entry_name != "." && entry_name != "..") { - DeleteRecursively(name + "/" + entry_name, NULL, NULL); - } - } - } - - closedir(dir); - rmdir(name.c_str()); - - } else if (S_ISREG(stats.st_mode)) { - remove(name.c_str()); - } -#endif -} - -} // namespace protobuf -} // namespace google diff --git a/modules/dnn/3rdparty/protobuf/src/google/protobuf/testing/file.h b/modules/dnn/3rdparty/protobuf/src/google/protobuf/testing/file.h deleted file mode 100644 index a6b1c7641..000000000 --- a/modules/dnn/3rdparty/protobuf/src/google/protobuf/testing/file.h +++ /dev/null @@ -1,83 +0,0 @@ -// Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// http://code.google.com/p/protobuf/ -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -// Author: kenton@google.com (Kenton Varda) -// emulates google3/file/base/file.h - -#ifndef GOOGLE_PROTOBUF_TESTING_FILE_H__ -#define GOOGLE_PROTOBUF_TESTING_FILE_H__ - -#include - -namespace google { -namespace protobuf { - -const int DEFAULT_FILE_MODE = 0777; - -// Protocol buffer code only uses a couple static methods of File, and only -// in tests. -class File { - public: - // Check if the file exists. - static bool Exists(const string& name); - - // Read an entire file to a string. Return true if successful, false - // otherwise. - static bool ReadFileToString(const string& name, string* output); - - // Same as above, but crash on failure. - static void ReadFileToStringOrDie(const string& name, string* output); - - // Create a file and write a string to it. - static void WriteStringToFileOrDie(const string& contents, - const string& name); - - // Create a directory. - static bool CreateDir(const string& name, int mode); - - // Create a directory and all parent directories if necessary. - static bool RecursivelyCreateDir(const string& path, int mode); - - // If "name" is a file, we delete it. If it is a directory, we - // call DeleteRecursively() for each file or directory (other than - // dot and double-dot) within it, and then delete the directory itself. - // The "dummy" parameters have a meaning in the original version of this - // method but they are not used anywhere in protocol buffers. - static void DeleteRecursively(const string& name, - void* dummy1, void* dummy2); - - private: - GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(File); -}; - -} // namespace protobuf -} // namespace google - -#endif // GOOGLE_PROTOBUF_TESTING_FILE_H__ diff --git a/modules/dnn/3rdparty/protobuf/src/google/protobuf/testing/googletest.cc b/modules/dnn/3rdparty/protobuf/src/google/protobuf/testing/googletest.cc deleted file mode 100644 index a8da6b1d1..000000000 --- a/modules/dnn/3rdparty/protobuf/src/google/protobuf/testing/googletest.cc +++ /dev/null @@ -1,255 +0,0 @@ -// Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// http://code.google.com/p/protobuf/ -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -// Author: kenton@google.com (Kenton Varda) -// emulates google3/testing/base/public/googletest.cc - -#include -#include -#include -#include -#include -#include -#include -#ifdef _MSC_VER -#include -#include -#else -#include -#endif -#include -#include -#include -#include - -namespace google { -namespace protobuf { - -#ifdef _WIN32 -#define mkdir(name, mode) mkdir(name) -#endif - -#ifndef O_BINARY -#ifdef _O_BINARY -#define O_BINARY _O_BINARY -#else -#define O_BINARY 0 // If this isn't defined, the platform doesn't need it. -#endif -#endif - -string TestSourceDir() { -#ifdef _MSC_VER - // Look for the "src" directory. - string prefix = "."; - - while (!File::Exists(prefix + "/src/google/protobuf")) { - if (!File::Exists(prefix)) { - GOOGLE_LOG(FATAL) - << "Could not find protobuf source code. Please run tests from " - "somewhere within the protobuf source package."; - } - prefix += "/.."; - } - return prefix + "/src"; -#else - // automake sets the "srcdir" environment variable. - char* result = getenv("srcdir"); - if (result == NULL) { - // Otherwise, the test must be run from the source directory. - return "."; - } else { - return result; - } -#endif -} - -namespace { - -string GetTemporaryDirectoryName() { - // tmpnam() is generally not considered safe but we're only using it for - // testing. We cannot use tmpfile() or mkstemp() since we're creating a - // directory. - char b[L_tmpnam + 1]; // HPUX multithread return 0 if s is 0 - string result = tmpnam(b); -#ifdef _WIN32 - // On Win32, tmpnam() returns a file prefixed with '\', but which is supposed - // to be used in the current working directory. WTF? - if (HasPrefixString(result, "\\")) { - result.erase(0, 1); - } -#endif // _WIN32 - return result; -} - -// Creates a temporary directory on demand and deletes it when the process -// quits. -class TempDirDeleter { - public: - TempDirDeleter() {} - ~TempDirDeleter() { - if (!name_.empty()) { - File::DeleteRecursively(name_, NULL, NULL); - } - } - - string GetTempDir() { - if (name_.empty()) { - name_ = GetTemporaryDirectoryName(); - GOOGLE_CHECK(mkdir(name_.c_str(), 0777) == 0) << strerror(errno); - - // Stick a file in the directory that tells people what this is, in case - // we abort and don't get a chance to delete it. - File::WriteStringToFileOrDie("", name_ + "/TEMP_DIR_FOR_PROTOBUF_TESTS"); - } - return name_; - } - - private: - string name_; -}; - -TempDirDeleter temp_dir_deleter_; - -} // namespace - -string TestTempDir() { - return temp_dir_deleter_.GetTempDir(); -} - -// TODO(kenton): Share duplicated code below. Too busy/lazy for now. - -static string stdout_capture_filename_; -static string stderr_capture_filename_; -static int original_stdout_ = -1; -static int original_stderr_ = -1; - -void CaptureTestStdout() { - GOOGLE_CHECK_EQ(original_stdout_, -1) << "Already capturing."; - - stdout_capture_filename_ = TestTempDir() + "/captured_stdout"; - - int fd = open(stdout_capture_filename_.c_str(), - O_WRONLY | O_CREAT | O_EXCL | O_BINARY, 0777); - GOOGLE_CHECK(fd >= 0) << "open: " << strerror(errno); - - original_stdout_ = dup(1); - close(1); - dup2(fd, 1); - close(fd); -} - -void CaptureTestStderr() { - GOOGLE_CHECK_EQ(original_stderr_, -1) << "Already capturing."; - - stderr_capture_filename_ = TestTempDir() + "/captured_stderr"; - - int fd = open(stderr_capture_filename_.c_str(), - O_WRONLY | O_CREAT | O_EXCL | O_BINARY, 0777); - GOOGLE_CHECK(fd >= 0) << "open: " << strerror(errno); - - original_stderr_ = dup(2); - close(2); - dup2(fd, 2); - close(fd); -} - -string GetCapturedTestStdout() { - GOOGLE_CHECK_NE(original_stdout_, -1) << "Not capturing."; - - close(1); - dup2(original_stdout_, 1); - original_stdout_ = -1; - - string result; - File::ReadFileToStringOrDie(stdout_capture_filename_, &result); - - remove(stdout_capture_filename_.c_str()); - - return result; -} - -string GetCapturedTestStderr() { - GOOGLE_CHECK_NE(original_stderr_, -1) << "Not capturing."; - - close(2); - dup2(original_stderr_, 2); - original_stderr_ = -1; - - string result; - File::ReadFileToStringOrDie(stderr_capture_filename_, &result); - - remove(stderr_capture_filename_.c_str()); - - return result; -} - -ScopedMemoryLog* ScopedMemoryLog::active_log_ = NULL; - -ScopedMemoryLog::ScopedMemoryLog() { - GOOGLE_CHECK(active_log_ == NULL); - active_log_ = this; - old_handler_ = SetLogHandler(&HandleLog); -} - -ScopedMemoryLog::~ScopedMemoryLog() { - SetLogHandler(old_handler_); - active_log_ = NULL; -} - -const vector& ScopedMemoryLog::GetMessages(LogLevel level) { - GOOGLE_CHECK(level == ERROR || - level == WARNING); - return messages_[level]; -} - -void ScopedMemoryLog::HandleLog(LogLevel level, const char* filename, - int line, const string& message) { - GOOGLE_CHECK(active_log_ != NULL); - if (level == ERROR || level == WARNING) { - active_log_->messages_[level].push_back(message); - } -} - -namespace { - -// Force shutdown at process exit so that we can test for memory leaks. To -// actually check for leaks, I suggest using the heap checker included with -// google-perftools. Set it to "draconian" mode to ensure that every last -// call to malloc() has a corresponding free(). -struct ForceShutdown { - ~ForceShutdown() { - ShutdownProtobufLibrary(); - } -} force_shutdown; - -} // namespace - -} // namespace protobuf -} // namespace google diff --git a/modules/dnn/3rdparty/protobuf/src/google/protobuf/testing/googletest.h b/modules/dnn/3rdparty/protobuf/src/google/protobuf/testing/googletest.h deleted file mode 100644 index 003be1060..000000000 --- a/modules/dnn/3rdparty/protobuf/src/google/protobuf/testing/googletest.h +++ /dev/null @@ -1,102 +0,0 @@ -// Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// http://code.google.com/p/protobuf/ -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -// Author: kenton@google.com (Kenton Varda) -// emulates google3/testing/base/public/googletest.h - -#ifndef GOOGLE_PROTOBUF_GOOGLETEST_H__ -#define GOOGLE_PROTOBUF_GOOGLETEST_H__ - -#include -#include -#include - -// Disable death tests if we use exceptions in CHECK(). -#if !PROTOBUF_USE_EXCEPTIONS && defined(GTEST_HAS_DEATH_TEST) -#define PROTOBUF_HAS_DEATH_TEST -#endif - -namespace google { -namespace protobuf { - -// When running unittests, get the directory containing the source code. -string TestSourceDir(); - -// When running unittests, get a directory where temporary files may be -// placed. -string TestTempDir(); - -// Capture all text written to stdout or stderr. -void CaptureTestStdout(); -void CaptureTestStderr(); - -// Stop capturing stdout or stderr and return the text captured. -string GetCapturedTestStdout(); -string GetCapturedTestStderr(); - -// For use with ScopedMemoryLog::GetMessages(). Inside Google the LogLevel -// constants don't have the LOGLEVEL_ prefix, so the code that used -// ScopedMemoryLog refers to LOGLEVEL_ERROR as just ERROR. -#undef ERROR // defend against promiscuous windows.h -static const LogLevel ERROR = LOGLEVEL_ERROR; -static const LogLevel WARNING = LOGLEVEL_WARNING; - -// Receives copies of all LOG(ERROR) messages while in scope. Sample usage: -// { -// ScopedMemoryLog log; // constructor registers object as a log sink -// SomeRoutineThatMayLogMessages(); -// const vector& warnings = log.GetMessages(ERROR); -// } // destructor unregisters object as a log sink -// This is a dummy implementation which covers only what is used by protocol -// buffer unit tests. -class ScopedMemoryLog { - public: - ScopedMemoryLog(); - virtual ~ScopedMemoryLog(); - - // Fetches all messages with the given severity level. - const vector& GetMessages(LogLevel error); - - private: - map > messages_; - LogHandler* old_handler_; - - static void HandleLog(LogLevel level, const char* filename, int line, - const string& message); - - static ScopedMemoryLog* active_log_; - - GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ScopedMemoryLog); -}; - -} // namespace protobuf -} // namespace google - -#endif // GOOGLE_PROTOBUF_GOOGLETEST_H__ diff --git a/modules/dnn/3rdparty/protobuf/src/google/protobuf/testing/zcgunzip.cc b/modules/dnn/3rdparty/protobuf/src/google/protobuf/testing/zcgunzip.cc deleted file mode 100644 index a6197854b..000000000 --- a/modules/dnn/3rdparty/protobuf/src/google/protobuf/testing/zcgunzip.cc +++ /dev/null @@ -1,73 +0,0 @@ -// Protocol Buffers - Google's data interchange format -// Copyright 2009 Google Inc. All rights reserved. -// http://code.google.com/p/protobuf/ -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -// Author: brianolson@google.com (Brian Olson) -// Based on original Protocol Buffers design by -// Sanjay Ghemawat, Jeff Dean, and others. -// -// Test program to verify that GzipInputStream is compatible with command line -// gunzip or java.util.zip.GzipInputStream -// -// Reads gzip stream on standard input and writes decompressed data to standard -// output. - -#include "config.h" - -#include -#include -#include -#include - -#include -#include - -using google::protobuf::io::FileInputStream; -using google::protobuf::io::GzipInputStream; - -int main(int argc, const char** argv) { - FileInputStream fin(STDIN_FILENO); - GzipInputStream in(&fin); - - while (true) { - const void* inptr; - int inlen; - bool ok; - ok = in.Next(&inptr, &inlen); - if (!ok) { - break; - } - if (inlen > 0) { - int err = write(STDOUT_FILENO, inptr, inlen); - assert(err == inlen); - } - } - - return 0; -} diff --git a/modules/dnn/3rdparty/protobuf/src/google/protobuf/testing/zcgzip.cc b/modules/dnn/3rdparty/protobuf/src/google/protobuf/testing/zcgzip.cc deleted file mode 100644 index 9133275c8..000000000 --- a/modules/dnn/3rdparty/protobuf/src/google/protobuf/testing/zcgzip.cc +++ /dev/null @@ -1,79 +0,0 @@ -// Protocol Buffers - Google's data interchange format -// Copyright 2009 Google Inc. All rights reserved. -// http://code.google.com/p/protobuf/ -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -// Author: brianolson@google.com (Brian Olson) -// Based on original Protocol Buffers design by -// Sanjay Ghemawat, Jeff Dean, and others. -// -// Test program to verify that GzipOutputStream is compatible with command line -// gzip or java.util.zip.GzipOutputStream -// -// Reads data on standard input and writes compressed gzip stream to standard -// output. - -#include "config.h" - -#include -#include -#include - -#include -#include - -using google::protobuf::io::FileOutputStream; -using google::protobuf::io::GzipOutputStream; - -int main(int argc, const char** argv) { - FileOutputStream fout(STDOUT_FILENO); - GzipOutputStream out(&fout); - int readlen; - - while (true) { - void* outptr; - int outlen; - bool ok; - do { - ok = out.Next(&outptr, &outlen); - if (!ok) { - break; - } - } while (outlen <= 0); - readlen = read(STDIN_FILENO, outptr, outlen); - if (readlen <= 0) { - out.BackUp(outlen); - break; - } - if (readlen < outlen) { - out.BackUp(outlen - readlen); - } - } - - return 0; -} diff --git a/modules/dnn/3rdparty/protobuf/src/google/protobuf/text_format.cc b/modules/dnn/3rdparty/protobuf/src/google/protobuf/text_format.cc deleted file mode 100644 index cabb99ed9..000000000 --- a/modules/dnn/3rdparty/protobuf/src/google/protobuf/text_format.cc +++ /dev/null @@ -1,1521 +0,0 @@ -// Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// http://code.google.com/p/protobuf/ -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -// Author: jschorr@google.com (Joseph Schorr) -// Based on original Protocol Buffers design by -// Sanjay Ghemawat, Jeff Dean, and others. - -#include -#include -#include -#include -#include -#include - -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -namespace google { -namespace protobuf { - -string Message::DebugString() const { - string debug_string; - - TextFormat::PrintToString(*this, &debug_string); - - return debug_string; -} - -string Message::ShortDebugString() const { - string debug_string; - - TextFormat::Printer printer; - printer.SetSingleLineMode(true); - - printer.PrintToString(*this, &debug_string); - // Single line mode currently might have an extra space at the end. - if (debug_string.size() > 0 && - debug_string[debug_string.size() - 1] == ' ') { - debug_string.resize(debug_string.size() - 1); - } - - return debug_string; -} - -string Message::Utf8DebugString() const { - string debug_string; - - TextFormat::Printer printer; - printer.SetUseUtf8StringEscaping(true); - - printer.PrintToString(*this, &debug_string); - - return debug_string; -} - -void Message::PrintDebugString() const { - printf("%s", DebugString().c_str()); -} - - -// =========================================================================== -// Implementation of the parse information tree class. -TextFormat::ParseInfoTree::ParseInfoTree() { } - -TextFormat::ParseInfoTree::~ParseInfoTree() { - // Remove any nested information trees, as they are owned by this tree. - for (NestedMap::iterator it = nested_.begin(); it != nested_.end(); ++it) { - STLDeleteElements(&(it->second)); - } -} - -void TextFormat::ParseInfoTree::RecordLocation( - const FieldDescriptor* field, - TextFormat::ParseLocation location) { - locations_[field].push_back(location); -} - -TextFormat::ParseInfoTree* TextFormat::ParseInfoTree::CreateNested( - const FieldDescriptor* field) { - // Owned by us in the map. - TextFormat::ParseInfoTree* instance = new TextFormat::ParseInfoTree(); - vector* trees = &nested_[field]; - GOOGLE_CHECK(trees); - trees->push_back(instance); - return instance; -} - -void CheckFieldIndex(const FieldDescriptor* field, int index) { - if (field == NULL) { return; } - - if (field->is_repeated() && index == -1) { - GOOGLE_LOG(DFATAL) << "Index must be in range of repeated field values. " - << "Field: " << field->name(); - } else if (!field->is_repeated() && index != -1) { - GOOGLE_LOG(DFATAL) << "Index must be -1 for singular fields." - << "Field: " << field->name(); - } -} - -TextFormat::ParseLocation TextFormat::ParseInfoTree::GetLocation( - const FieldDescriptor* field, int index) const { - CheckFieldIndex(field, index); - if (index == -1) { index = 0; } - - const vector* locations = - FindOrNull(locations_, field); - if (locations == NULL || index >= locations->size()) { - return TextFormat::ParseLocation(); - } - - return (*locations)[index]; -} - -TextFormat::ParseInfoTree* TextFormat::ParseInfoTree::GetTreeForNested( - const FieldDescriptor* field, int index) const { - CheckFieldIndex(field, index); - if (index == -1) { index = 0; } - - const vector* trees = FindOrNull(nested_, field); - if (trees == NULL || index >= trees->size()) { - return NULL; - } - - return (*trees)[index]; -} - - -// =========================================================================== -// Internal class for parsing an ASCII representation of a Protocol Message. -// This class makes use of the Protocol Message compiler's tokenizer found -// in //google/protobuf/io/tokenizer.h. Note that class's Parse -// method is *not* thread-safe and should only be used in a single thread at -// a time. - -// Makes code slightly more readable. The meaning of "DO(foo)" is -// "Execute foo and fail if it fails.", where failure is indicated by -// returning false. Borrowed from parser.cc (Thanks Kenton!). -#define DO(STATEMENT) if (STATEMENT) {} else return false - -class TextFormat::Parser::ParserImpl { - public: - - // Determines if repeated values for a non-repeated field are - // permitted, e.g., the string "foo: 1 foo: 2" for a - // required/optional field named "foo". - enum SingularOverwritePolicy { - ALLOW_SINGULAR_OVERWRITES = 0, // the last value is retained - FORBID_SINGULAR_OVERWRITES = 1, // an error is issued - }; - - ParserImpl(const Descriptor* root_message_type, - io::ZeroCopyInputStream* input_stream, - io::ErrorCollector* error_collector, - TextFormat::Finder* finder, - ParseInfoTree* parse_info_tree, - SingularOverwritePolicy singular_overwrite_policy, - bool allow_unknown_field) - : error_collector_(error_collector), - finder_(finder), - parse_info_tree_(parse_info_tree), - tokenizer_error_collector_(this), - tokenizer_(input_stream, &tokenizer_error_collector_), - root_message_type_(root_message_type), - singular_overwrite_policy_(singular_overwrite_policy), - allow_unknown_field_(allow_unknown_field), - had_errors_(false) { - // For backwards-compatibility with proto1, we need to allow the 'f' suffix - // for floats. - tokenizer_.set_allow_f_after_float(true); - - // '#' starts a comment. - tokenizer_.set_comment_style(io::Tokenizer::SH_COMMENT_STYLE); - - // Consume the starting token. - tokenizer_.Next(); - } - ~ParserImpl() { } - - // Parses the ASCII representation specified in input and saves the - // information into the output pointer (a Message). Returns - // false if an error occurs (an error will also be logged to - // GOOGLE_LOG(ERROR)). - bool Parse(Message* output) { - // Consume fields until we cannot do so anymore. - while(true) { - if (LookingAtType(io::Tokenizer::TYPE_END)) { - return !had_errors_; - } - - DO(ConsumeField(output)); - } - } - - bool ParseField(const FieldDescriptor* field, Message* output) { - bool suc; - if (field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE) { - suc = ConsumeFieldMessage(output, output->GetReflection(), field); - } else { - suc = ConsumeFieldValue(output, output->GetReflection(), field); - } - return suc && LookingAtType(io::Tokenizer::TYPE_END); - } - - void ReportError(int line, int col, const string& message) { - had_errors_ = true; - if (error_collector_ == NULL) { - if (line >= 0) { - GOOGLE_LOG(ERROR) << "Error parsing text-format " - << root_message_type_->full_name() - << ": " << (line + 1) << ":" - << (col + 1) << ": " << message; - } else { - GOOGLE_LOG(ERROR) << "Error parsing text-format " - << root_message_type_->full_name() - << ": " << message; - } - } else { - error_collector_->AddError(line, col, message); - } - } - - void ReportWarning(int line, int col, const string& message) { - if (error_collector_ == NULL) { - if (line >= 0) { - GOOGLE_LOG(WARNING) << "Warning parsing text-format " - << root_message_type_->full_name() - << ": " << (line + 1) << ":" - << (col + 1) << ": " << message; - } else { - GOOGLE_LOG(WARNING) << "Warning parsing text-format " - << root_message_type_->full_name() - << ": " << message; - } - } else { - error_collector_->AddWarning(line, col, message); - } - } - - private: - GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ParserImpl); - - // Reports an error with the given message with information indicating - // the position (as derived from the current token). - void ReportError(const string& message) { - ReportError(tokenizer_.current().line, tokenizer_.current().column, - message); - } - - // Reports a warning with the given message with information indicating - // the position (as derived from the current token). - void ReportWarning(const string& message) { - ReportWarning(tokenizer_.current().line, tokenizer_.current().column, - message); - } - - // Consumes the specified message with the given starting delimeter. - // This method checks to see that the end delimeter at the conclusion of - // the consumption matches the starting delimeter passed in here. - bool ConsumeMessage(Message* message, const string delimeter) { - while (!LookingAt(">") && !LookingAt("}")) { - DO(ConsumeField(message)); - } - - // Confirm that we have a valid ending delimeter. - DO(Consume(delimeter)); - - return true; - } - - // Consumes the current field (as returned by the tokenizer) on the - // passed in message. - bool ConsumeField(Message* message) { - const Reflection* reflection = message->GetReflection(); - const Descriptor* descriptor = message->GetDescriptor(); - - string field_name; - - const FieldDescriptor* field = NULL; - int start_line = tokenizer_.current().line; - int start_column = tokenizer_.current().column; - - if (TryConsume("[")) { - // Extension. - DO(ConsumeIdentifier(&field_name)); - while (TryConsume(".")) { - string part; - DO(ConsumeIdentifier(&part)); - field_name += "."; - field_name += part; - } - DO(Consume("]")); - - field = (finder_ != NULL - ? finder_->FindExtension(message, field_name) - : reflection->FindKnownExtensionByName(field_name)); - - if (field == NULL) { - if (!allow_unknown_field_) { - ReportError("Extension \"" + field_name + "\" is not defined or " - "is not an extension of \"" + - descriptor->full_name() + "\"."); - return false; - } else { - ReportWarning("Extension \"" + field_name + "\" is not defined or " - "is not an extension of \"" + - descriptor->full_name() + "\"."); - } - } - } else { - DO(ConsumeIdentifier(&field_name)); - - field = descriptor->FindFieldByName(field_name); - // Group names are expected to be capitalized as they appear in the - // .proto file, which actually matches their type names, not their field - // names. - if (field == NULL) { - string lower_field_name = field_name; - LowerString(&lower_field_name); - field = descriptor->FindFieldByName(lower_field_name); - // If the case-insensitive match worked but the field is NOT a group, - if (field != NULL && field->type() != FieldDescriptor::TYPE_GROUP) { - field = NULL; - } - } - // Again, special-case group names as described above. - if (field != NULL && field->type() == FieldDescriptor::TYPE_GROUP - && field->message_type()->name() != field_name) { - field = NULL; - } - - if (field == NULL) { - if (!allow_unknown_field_) { - ReportError("Message type \"" + descriptor->full_name() + - "\" has no field named \"" + field_name + "\"."); - return false; - } else { - ReportWarning("Message type \"" + descriptor->full_name() + - "\" has no field named \"" + field_name + "\"."); - } - } - } - - // Skips unknown field. - if (field == NULL) { - GOOGLE_CHECK(allow_unknown_field_); - // Try to guess the type of this field. - // If this field is not a message, there should be a ":" between the - // field name and the field value and also the field value should not - // start with "{" or "<" which indicates the begining of a message body. - // If there is no ":" or there is a "{" or "<" after ":", this field has - // to be a message or the input is ill-formed. - if (TryConsume(":") && !LookingAt("{") && !LookingAt("<")) { - return SkipFieldValue(); - } else { - return SkipFieldMessage(); - } - } - - // Fail if the field is not repeated and it has already been specified. - if ((singular_overwrite_policy_ == FORBID_SINGULAR_OVERWRITES) && - !field->is_repeated() && reflection->HasField(*message, field)) { - ReportError("Non-repeated field \"" + field_name + - "\" is specified multiple times."); - return false; - } - - // Perform special handling for embedded message types. - if (field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE) { - // ':' is optional here. - TryConsume(":"); - DO(ConsumeFieldMessage(message, reflection, field)); - } else { - DO(Consume(":")); - if (field->is_repeated() && TryConsume("[")) { - // Short repeated format, e.g. "foo: [1, 2, 3]" - while (true) { - DO(ConsumeFieldValue(message, reflection, field)); - if (TryConsume("]")) { - break; - } - DO(Consume(",")); - } - } else { - DO(ConsumeFieldValue(message, reflection, field)); - } - } - - // For historical reasons, fields may optionally be separated by commas or - // semicolons. - TryConsume(";") || TryConsume(","); - - if (field->options().deprecated()) { - ReportWarning("text format contains deprecated field \"" - + field_name + "\""); - } - - // If a parse info tree exists, add the location for the parsed - // field. - if (parse_info_tree_ != NULL) { - RecordLocation(parse_info_tree_, field, - ParseLocation(start_line, start_column)); - } - - return true; - } - - // Skips the next field including the field's name and value. - bool SkipField() { - string field_name; - if (TryConsume("[")) { - // Extension name. - DO(ConsumeIdentifier(&field_name)); - while (TryConsume(".")) { - string part; - DO(ConsumeIdentifier(&part)); - field_name += "."; - field_name += part; - } - DO(Consume("]")); - } else { - DO(ConsumeIdentifier(&field_name)); - } - - // Try to guess the type of this field. - // If this field is not a message, there should be a ":" between the - // field name and the field value and also the field value should not - // start with "{" or "<" which indicates the begining of a message body. - // If there is no ":" or there is a "{" or "<" after ":", this field has - // to be a message or the input is ill-formed. - if (TryConsume(":") && !LookingAt("{") && !LookingAt("<")) { - DO(SkipFieldValue()); - } else { - DO(SkipFieldMessage()); - } - // For historical reasons, fields may optionally be separated by commas or - // semicolons. - TryConsume(";") || TryConsume(","); - return true; - } - - bool ConsumeFieldMessage(Message* message, - const Reflection* reflection, - const FieldDescriptor* field) { - - // If the parse information tree is not NULL, create a nested one - // for the nested message. - ParseInfoTree* parent = parse_info_tree_; - if (parent != NULL) { - parse_info_tree_ = CreateNested(parent, field); - } - - string delimeter; - if (TryConsume("<")) { - delimeter = ">"; - } else { - DO(Consume("{")); - delimeter = "}"; - } - - if (field->is_repeated()) { - DO(ConsumeMessage(reflection->AddMessage(message, field), delimeter)); - } else { - DO(ConsumeMessage(reflection->MutableMessage(message, field), - delimeter)); - } - - // Reset the parse information tree. - parse_info_tree_ = parent; - return true; - } - - // Skips the whole body of a message including the begining delimeter and - // the ending delimeter. - bool SkipFieldMessage() { - string delimeter; - if (TryConsume("<")) { - delimeter = ">"; - } else { - DO(Consume("{")); - delimeter = "}"; - } - while (!LookingAt(">") && !LookingAt("}")) { - DO(SkipField()); - } - DO(Consume(delimeter)); - return true; - } - - bool ConsumeFieldValue(Message* message, - const Reflection* reflection, - const FieldDescriptor* field) { - -// Define an easy to use macro for setting fields. This macro checks -// to see if the field is repeated (in which case we need to use the Add -// methods or not (in which case we need to use the Set methods). -#define SET_FIELD(CPPTYPE, VALUE) \ - if (field->is_repeated()) { \ - reflection->Add##CPPTYPE(message, field, VALUE); \ - } else { \ - reflection->Set##CPPTYPE(message, field, VALUE); \ - } \ - - switch(field->cpp_type()) { - case FieldDescriptor::CPPTYPE_INT32: { - int64 value; - DO(ConsumeSignedInteger(&value, kint32max)); - SET_FIELD(Int32, static_cast(value)); - break; - } - - case FieldDescriptor::CPPTYPE_UINT32: { - uint64 value; - DO(ConsumeUnsignedInteger(&value, kuint32max)); - SET_FIELD(UInt32, static_cast(value)); - break; - } - - case FieldDescriptor::CPPTYPE_INT64: { - int64 value; - DO(ConsumeSignedInteger(&value, kint64max)); - SET_FIELD(Int64, value); - break; - } - - case FieldDescriptor::CPPTYPE_UINT64: { - uint64 value; - DO(ConsumeUnsignedInteger(&value, kuint64max)); - SET_FIELD(UInt64, value); - break; - } - - case FieldDescriptor::CPPTYPE_FLOAT: { - double value; - DO(ConsumeDouble(&value)); - SET_FIELD(Float, static_cast(value)); - break; - } - - case FieldDescriptor::CPPTYPE_DOUBLE: { - double value; - DO(ConsumeDouble(&value)); - SET_FIELD(Double, value); - break; - } - - case FieldDescriptor::CPPTYPE_STRING: { - string value; - DO(ConsumeString(&value)); - SET_FIELD(String, value); - break; - } - - case FieldDescriptor::CPPTYPE_BOOL: { - if (LookingAtType(io::Tokenizer::TYPE_INTEGER)) { - uint64 value; - DO(ConsumeUnsignedInteger(&value, 1)); - SET_FIELD(Bool, value); - } else { - string value; - DO(ConsumeIdentifier(&value)); - if (value == "true" || value == "t") { - SET_FIELD(Bool, true); - } else if (value == "false" || value == "f") { - SET_FIELD(Bool, false); - } else { - ReportError("Invalid value for boolean field \"" + field->name() - + "\". Value: \"" + value + "\"."); - return false; - } - } - break; - } - - case FieldDescriptor::CPPTYPE_ENUM: { - string value; - const EnumDescriptor* enum_type = field->enum_type(); - const EnumValueDescriptor* enum_value = NULL; - - if (LookingAtType(io::Tokenizer::TYPE_IDENTIFIER)) { - DO(ConsumeIdentifier(&value)); - // Find the enumeration value. - enum_value = enum_type->FindValueByName(value); - - } else if (LookingAt("-") || - LookingAtType(io::Tokenizer::TYPE_INTEGER)) { - int64 int_value; - DO(ConsumeSignedInteger(&int_value, kint32max)); - value = SimpleItoa(int_value); // for error reporting - enum_value = enum_type->FindValueByNumber(int_value); - } else { - ReportError("Expected integer or identifier."); - return false; - } - - if (enum_value == NULL) { - ReportError("Unknown enumeration value of \"" + value + "\" for " - "field \"" + field->name() + "\"."); - return false; - } - - SET_FIELD(Enum, enum_value); - break; - } - - case FieldDescriptor::CPPTYPE_MESSAGE: { - // We should never get here. Put here instead of a default - // so that if new types are added, we get a nice compiler warning. - GOOGLE_LOG(FATAL) << "Reached an unintended state: CPPTYPE_MESSAGE"; - break; - } - } -#undef SET_FIELD - return true; - } - - bool SkipFieldValue() { - if (LookingAtType(io::Tokenizer::TYPE_STRING)) { - while (LookingAtType(io::Tokenizer::TYPE_STRING)) { - tokenizer_.Next(); - } - return true; - } - // Possible field values other than string: - // 12345 => TYPE_INTEGER - // -12345 => TYPE_SYMBOL + TYPE_INTEGER - // 1.2345 => TYPE_FLOAT - // -1.2345 => TYPE_SYMBOL + TYPE_FLOAT - // inf => TYPE_IDENTIFIER - // -inf => TYPE_SYMBOL + TYPE_IDENTIFIER - // TYPE_INTEGER => TYPE_IDENTIFIER - // Divides them into two group, one with TYPE_SYMBOL - // and the other without: - // Group one: - // 12345 => TYPE_INTEGER - // 1.2345 => TYPE_FLOAT - // inf => TYPE_IDENTIFIER - // TYPE_INTEGER => TYPE_IDENTIFIER - // Group two: - // -12345 => TYPE_SYMBOL + TYPE_INTEGER - // -1.2345 => TYPE_SYMBOL + TYPE_FLOAT - // -inf => TYPE_SYMBOL + TYPE_IDENTIFIER - // As we can see, the field value consists of an optional '-' and one of - // TYPE_INTEGER, TYPE_FLOAT and TYPE_IDENTIFIER. - bool has_minus = TryConsume("-"); - if (!LookingAtType(io::Tokenizer::TYPE_INTEGER) && - !LookingAtType(io::Tokenizer::TYPE_FLOAT) && - !LookingAtType(io::Tokenizer::TYPE_IDENTIFIER)) { - return false; - } - // Combination of '-' and TYPE_IDENTIFIER may result in an invalid field - // value while other combinations all generate valid values. - // We check if the value of this combination is valid here. - // TYPE_IDENTIFIER after a '-' should be one of the float values listed - // below: - // inf, inff, infinity, nan - if (has_minus && LookingAtType(io::Tokenizer::TYPE_IDENTIFIER)) { - string text = tokenizer_.current().text; - LowerString(&text); - if (text != "inf" && - text != "infinity" && - text != "nan") { - ReportError("Invalid float number: " + text); - return false; - } - } - tokenizer_.Next(); - return true; - } - - // Returns true if the current token's text is equal to that specified. - bool LookingAt(const string& text) { - return tokenizer_.current().text == text; - } - - // Returns true if the current token's type is equal to that specified. - bool LookingAtType(io::Tokenizer::TokenType token_type) { - return tokenizer_.current().type == token_type; - } - - // Consumes an identifier and saves its value in the identifier parameter. - // Returns false if the token is not of type IDENTFIER. - bool ConsumeIdentifier(string* identifier) { - if (!LookingAtType(io::Tokenizer::TYPE_IDENTIFIER)) { - ReportError("Expected identifier."); - return false; - } - - *identifier = tokenizer_.current().text; - - tokenizer_.Next(); - return true; - } - - // Consumes a string and saves its value in the text parameter. - // Returns false if the token is not of type STRING. - bool ConsumeString(string* text) { - if (!LookingAtType(io::Tokenizer::TYPE_STRING)) { - ReportError("Expected string."); - return false; - } - - text->clear(); - while (LookingAtType(io::Tokenizer::TYPE_STRING)) { - io::Tokenizer::ParseStringAppend(tokenizer_.current().text, text); - - tokenizer_.Next(); - } - - return true; - } - - // Consumes a uint64 and saves its value in the value parameter. - // Returns false if the token is not of type INTEGER. - bool ConsumeUnsignedInteger(uint64* value, uint64 max_value) { - if (!LookingAtType(io::Tokenizer::TYPE_INTEGER)) { - ReportError("Expected integer."); - return false; - } - - if (!io::Tokenizer::ParseInteger(tokenizer_.current().text, - max_value, value)) { - ReportError("Integer out of range."); - return false; - } - - tokenizer_.Next(); - return true; - } - - // Consumes an int64 and saves its value in the value parameter. - // Note that since the tokenizer does not support negative numbers, - // we actually may consume an additional token (for the minus sign) in this - // method. Returns false if the token is not an integer - // (signed or otherwise). - bool ConsumeSignedInteger(int64* value, uint64 max_value) { - bool negative = false; - - if (TryConsume("-")) { - negative = true; - // Two's complement always allows one more negative integer than - // positive. - ++max_value; - } - - uint64 unsigned_value; - - DO(ConsumeUnsignedInteger(&unsigned_value, max_value)); - - *value = static_cast(unsigned_value); - - if (negative) { - *value = -*value; - } - - return true; - } - - // Consumes a double and saves its value in the value parameter. - // Note that since the tokenizer does not support negative numbers, - // we actually may consume an additional token (for the minus sign) in this - // method. Returns false if the token is not a double - // (signed or otherwise). - bool ConsumeDouble(double* value) { - bool negative = false; - - if (TryConsume("-")) { - negative = true; - } - - // A double can actually be an integer, according to the tokenizer. - // Therefore, we must check both cases here. - if (LookingAtType(io::Tokenizer::TYPE_INTEGER)) { - // We have found an integer value for the double. - uint64 integer_value; - DO(ConsumeUnsignedInteger(&integer_value, kuint64max)); - - *value = static_cast(integer_value); - } else if (LookingAtType(io::Tokenizer::TYPE_FLOAT)) { - // We have found a float value for the double. - *value = io::Tokenizer::ParseFloat(tokenizer_.current().text); - - // Mark the current token as consumed. - tokenizer_.Next(); - } else if (LookingAtType(io::Tokenizer::TYPE_IDENTIFIER)) { - string text = tokenizer_.current().text; - LowerString(&text); - if (text == "inf" || - text == "infinity") { - *value = std::numeric_limits::infinity(); - tokenizer_.Next(); - } else if (text == "nan") { - *value = std::numeric_limits::quiet_NaN(); - tokenizer_.Next(); - } else { - ReportError("Expected double."); - return false; - } - } else { - ReportError("Expected double."); - return false; - } - - if (negative) { - *value = -*value; - } - - return true; - } - - // Consumes a token and confirms that it matches that specified in the - // value parameter. Returns false if the token found does not match that - // which was specified. - bool Consume(const string& value) { - const string& current_value = tokenizer_.current().text; - - if (current_value != value) { - ReportError("Expected \"" + value + "\", found \"" + current_value - + "\"."); - return false; - } - - tokenizer_.Next(); - - return true; - } - - // Attempts to consume the supplied value. Returns false if a the - // token found does not match the value specified. - bool TryConsume(const string& value) { - if (tokenizer_.current().text == value) { - tokenizer_.Next(); - return true; - } else { - return false; - } - } - - // An internal instance of the Tokenizer's error collector, used to - // collect any base-level parse errors and feed them to the ParserImpl. - class ParserErrorCollector : public io::ErrorCollector { - public: - explicit ParserErrorCollector(TextFormat::Parser::ParserImpl* parser) : - parser_(parser) { } - - virtual ~ParserErrorCollector() { }; - - virtual void AddError(int line, int column, const string& message) { - parser_->ReportError(line, column, message); - } - - virtual void AddWarning(int line, int column, const string& message) { - parser_->ReportWarning(line, column, message); - } - - private: - GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ParserErrorCollector); - TextFormat::Parser::ParserImpl* parser_; - }; - - io::ErrorCollector* error_collector_; - TextFormat::Finder* finder_; - ParseInfoTree* parse_info_tree_; - ParserErrorCollector tokenizer_error_collector_; - io::Tokenizer tokenizer_; - const Descriptor* root_message_type_; - SingularOverwritePolicy singular_overwrite_policy_; - bool allow_unknown_field_; - bool had_errors_; -}; - -#undef DO - -// =========================================================================== -// Internal class for writing text to the io::ZeroCopyOutputStream. Adapted -// from the Printer found in //google/protobuf/io/printer.h -class TextFormat::Printer::TextGenerator { - public: - explicit TextGenerator(io::ZeroCopyOutputStream* output, - int initial_indent_level) - : output_(output), - buffer_(NULL), - buffer_size_(0), - at_start_of_line_(true), - failed_(false), - indent_(""), - initial_indent_level_(initial_indent_level) { - indent_.resize(initial_indent_level_ * 2, ' '); - } - - ~TextGenerator() { - // Only BackUp() if we're sure we've successfully called Next() at least - // once. - if (!failed_ && buffer_size_ > 0) { - output_->BackUp(buffer_size_); - } - } - - // Indent text by two spaces. After calling Indent(), two spaces will be - // inserted at the beginning of each line of text. Indent() may be called - // multiple times to produce deeper indents. - void Indent() { - indent_ += " "; - } - - // Reduces the current indent level by two spaces, or crashes if the indent - // level is zero. - void Outdent() { - if (indent_.empty() || - indent_.size() < initial_indent_level_ * 2) { - GOOGLE_LOG(DFATAL) << " Outdent() without matching Indent()."; - return; - } - - indent_.resize(indent_.size() - 2); - } - - // Print text to the output stream. - void Print(const string& str) { - Print(str.data(), str.size()); - } - - // Print text to the output stream. - void Print(const char* text) { - Print(text, strlen(text)); - } - - // Print text to the output stream. - void Print(const char* text, int size) { - int pos = 0; // The number of bytes we've written so far. - - for (int i = 0; i < size; i++) { - if (text[i] == '\n') { - // Saw newline. If there is more text, we may need to insert an indent - // here. So, write what we have so far, including the '\n'. - Write(text + pos, i - pos + 1); - pos = i + 1; - - // Setting this true will cause the next Write() to insert an indent - // first. - at_start_of_line_ = true; - } - } - - // Write the rest. - Write(text + pos, size - pos); - } - - // True if any write to the underlying stream failed. (We don't just - // crash in this case because this is an I/O failure, not a programming - // error.) - bool failed() const { return failed_; } - - private: - GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(TextGenerator); - - void Write(const char* data, int size) { - if (failed_) return; - if (size == 0) return; - - if (at_start_of_line_) { - // Insert an indent. - at_start_of_line_ = false; - Write(indent_.data(), indent_.size()); - if (failed_) return; - } - - while (size > buffer_size_) { - // Data exceeds space in the buffer. Copy what we can and request a - // new buffer. - memcpy(buffer_, data, buffer_size_); - data += buffer_size_; - size -= buffer_size_; - void* void_buffer; - failed_ = !output_->Next(&void_buffer, &buffer_size_); - if (failed_) return; - buffer_ = reinterpret_cast(void_buffer); - } - - // Buffer is big enough to receive the data; copy it. - memcpy(buffer_, data, size); - buffer_ += size; - buffer_size_ -= size; - } - - io::ZeroCopyOutputStream* const output_; - char* buffer_; - int buffer_size_; - bool at_start_of_line_; - bool failed_; - - string indent_; - int initial_indent_level_; -}; - -// =========================================================================== - -TextFormat::Finder::~Finder() { -} - -TextFormat::Parser::Parser() - : error_collector_(NULL), - finder_(NULL), - parse_info_tree_(NULL), - allow_partial_(false), - allow_unknown_field_(false) { -} - -TextFormat::Parser::~Parser() {} - -bool TextFormat::Parser::Parse(io::ZeroCopyInputStream* input, - Message* output) { - output->Clear(); - ParserImpl parser(output->GetDescriptor(), input, error_collector_, - finder_, parse_info_tree_, - ParserImpl::FORBID_SINGULAR_OVERWRITES, - allow_unknown_field_); - return MergeUsingImpl(input, output, &parser); -} - -bool TextFormat::Parser::ParseFromString(const string& input, - Message* output) { - io::ArrayInputStream input_stream(input.data(), input.size()); - return Parse(&input_stream, output); -} - -bool TextFormat::Parser::Merge(io::ZeroCopyInputStream* input, - Message* output) { - ParserImpl parser(output->GetDescriptor(), input, error_collector_, - finder_, parse_info_tree_, - ParserImpl::ALLOW_SINGULAR_OVERWRITES, - allow_unknown_field_); - return MergeUsingImpl(input, output, &parser); -} - -bool TextFormat::Parser::MergeFromString(const string& input, - Message* output) { - io::ArrayInputStream input_stream(input.data(), input.size()); - return Merge(&input_stream, output); -} - -bool TextFormat::Parser::MergeUsingImpl(io::ZeroCopyInputStream* input, - Message* output, - ParserImpl* parser_impl) { - if (!parser_impl->Parse(output)) return false; - if (!allow_partial_ && !output->IsInitialized()) { - vector missing_fields; - output->FindInitializationErrors(&missing_fields); - parser_impl->ReportError(-1, 0, "Message missing required fields: " + - JoinStrings(missing_fields, ", ")); - return false; - } - return true; -} - -bool TextFormat::Parser::ParseFieldValueFromString( - const string& input, - const FieldDescriptor* field, - Message* output) { - io::ArrayInputStream input_stream(input.data(), input.size()); - ParserImpl parser(output->GetDescriptor(), &input_stream, error_collector_, - finder_, parse_info_tree_, - ParserImpl::ALLOW_SINGULAR_OVERWRITES, - allow_unknown_field_); - return parser.ParseField(field, output); -} - -/* static */ bool TextFormat::Parse(io::ZeroCopyInputStream* input, - Message* output) { - return Parser().Parse(input, output); -} - -/* static */ bool TextFormat::Merge(io::ZeroCopyInputStream* input, - Message* output) { - return Parser().Merge(input, output); -} - -/* static */ bool TextFormat::ParseFromString(const string& input, - Message* output) { - return Parser().ParseFromString(input, output); -} - -/* static */ bool TextFormat::MergeFromString(const string& input, - Message* output) { - return Parser().MergeFromString(input, output); -} - -// =========================================================================== - -TextFormat::Printer::Printer() - : initial_indent_level_(0), - single_line_mode_(false), - use_short_repeated_primitives_(false), - utf8_string_escaping_(false) {} - -TextFormat::Printer::~Printer() {} - -bool TextFormat::Printer::PrintToString(const Message& message, - string* output) const { - GOOGLE_DCHECK(output) << "output specified is NULL"; - - output->clear(); - io::StringOutputStream output_stream(output); - - bool result = Print(message, &output_stream); - - return result; -} - -bool TextFormat::Printer::PrintUnknownFieldsToString( - const UnknownFieldSet& unknown_fields, - string* output) const { - GOOGLE_DCHECK(output) << "output specified is NULL"; - - output->clear(); - io::StringOutputStream output_stream(output); - return PrintUnknownFields(unknown_fields, &output_stream); -} - -bool TextFormat::Printer::Print(const Message& message, - io::ZeroCopyOutputStream* output) const { - TextGenerator generator(output, initial_indent_level_); - - Print(message, generator); - - // Output false if the generator failed internally. - return !generator.failed(); -} - -bool TextFormat::Printer::PrintUnknownFields( - const UnknownFieldSet& unknown_fields, - io::ZeroCopyOutputStream* output) const { - TextGenerator generator(output, initial_indent_level_); - - PrintUnknownFields(unknown_fields, generator); - - // Output false if the generator failed internally. - return !generator.failed(); -} - -void TextFormat::Printer::Print(const Message& message, - TextGenerator& generator) const { - const Reflection* reflection = message.GetReflection(); - vector fields; - reflection->ListFields(message, &fields); - for (int i = 0; i < fields.size(); i++) { - PrintField(message, reflection, fields[i], generator); - } - PrintUnknownFields(reflection->GetUnknownFields(message), generator); -} - -void TextFormat::Printer::PrintFieldValueToString( - const Message& message, - const FieldDescriptor* field, - int index, - string* output) const { - - GOOGLE_DCHECK(output) << "output specified is NULL"; - - output->clear(); - io::StringOutputStream output_stream(output); - TextGenerator generator(&output_stream, initial_indent_level_); - - PrintFieldValue(message, message.GetReflection(), field, index, generator); -} - -void TextFormat::Printer::PrintField(const Message& message, - const Reflection* reflection, - const FieldDescriptor* field, - TextGenerator& generator) const { - if (use_short_repeated_primitives_ && - field->is_repeated() && - field->cpp_type() != FieldDescriptor::CPPTYPE_STRING && - field->cpp_type() != FieldDescriptor::CPPTYPE_MESSAGE) { - PrintShortRepeatedField(message, reflection, field, generator); - return; - } - - int count = 0; - - if (field->is_repeated()) { - count = reflection->FieldSize(message, field); - } else if (reflection->HasField(message, field)) { - count = 1; - } - - for (int j = 0; j < count; ++j) { - PrintFieldName(message, reflection, field, generator); - - if (field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE) { - if (single_line_mode_) { - generator.Print(" { "); - } else { - generator.Print(" {\n"); - generator.Indent(); - } - } else { - generator.Print(": "); - } - - // Write the field value. - int field_index = j; - if (!field->is_repeated()) { - field_index = -1; - } - - PrintFieldValue(message, reflection, field, field_index, generator); - - if (field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE) { - if (single_line_mode_) { - generator.Print("} "); - } else { - generator.Outdent(); - generator.Print("}\n"); - } - } else { - if (single_line_mode_) { - generator.Print(" "); - } else { - generator.Print("\n"); - } - } - } -} - -void TextFormat::Printer::PrintShortRepeatedField( - const Message& message, - const Reflection* reflection, - const FieldDescriptor* field, - TextGenerator& generator) const { - // Print primitive repeated field in short form. - PrintFieldName(message, reflection, field, generator); - - int size = reflection->FieldSize(message, field); - generator.Print(": ["); - for (int i = 0; i < size; i++) { - if (i > 0) generator.Print(", "); - PrintFieldValue(message, reflection, field, i, generator); - } - if (single_line_mode_) { - generator.Print("] "); - } else { - generator.Print("]\n"); - } -} - -void TextFormat::Printer::PrintFieldName(const Message& message, - const Reflection* reflection, - const FieldDescriptor* field, - TextGenerator& generator) const { - if (field->is_extension()) { - generator.Print("["); - // We special-case MessageSet elements for compatibility with proto1. - if (field->containing_type()->options().message_set_wire_format() - && field->type() == FieldDescriptor::TYPE_MESSAGE - && field->is_optional() - && field->extension_scope() == field->message_type()) { - generator.Print(field->message_type()->full_name()); - } else { - generator.Print(field->full_name()); - } - generator.Print("]"); - } else { - if (field->type() == FieldDescriptor::TYPE_GROUP) { - // Groups must be serialized with their original capitalization. - generator.Print(field->message_type()->name()); - } else { - generator.Print(field->name()); - } - } -} - -void TextFormat::Printer::PrintFieldValue( - const Message& message, - const Reflection* reflection, - const FieldDescriptor* field, - int index, - TextGenerator& generator) const { - GOOGLE_DCHECK(field->is_repeated() || (index == -1)) - << "Index must be -1 for non-repeated fields"; - - switch (field->cpp_type()) { -#define OUTPUT_FIELD(CPPTYPE, METHOD, TO_STRING) \ - case FieldDescriptor::CPPTYPE_##CPPTYPE: \ - generator.Print(TO_STRING(field->is_repeated() ? \ - reflection->GetRepeated##METHOD(message, field, index) : \ - reflection->Get##METHOD(message, field))); \ - break; \ - - OUTPUT_FIELD( INT32, Int32, SimpleItoa); - OUTPUT_FIELD( INT64, Int64, SimpleItoa); - OUTPUT_FIELD(UINT32, UInt32, SimpleItoa); - OUTPUT_FIELD(UINT64, UInt64, SimpleItoa); - OUTPUT_FIELD( FLOAT, Float, SimpleFtoa); - OUTPUT_FIELD(DOUBLE, Double, SimpleDtoa); -#undef OUTPUT_FIELD - - case FieldDescriptor::CPPTYPE_STRING: { - string scratch; - const string& value = field->is_repeated() ? - reflection->GetRepeatedStringReference( - message, field, index, &scratch) : - reflection->GetStringReference(message, field, &scratch); - - generator.Print("\""); - if (utf8_string_escaping_) { - generator.Print(strings::Utf8SafeCEscape(value)); - } else { - generator.Print(CEscape(value)); - } - generator.Print("\""); - - break; - } - - case FieldDescriptor::CPPTYPE_BOOL: - if (field->is_repeated()) { - generator.Print(reflection->GetRepeatedBool(message, field, index) - ? "true" : "false"); - } else { - generator.Print(reflection->GetBool(message, field) - ? "true" : "false"); - } - break; - - case FieldDescriptor::CPPTYPE_ENUM: - generator.Print(field->is_repeated() ? - reflection->GetRepeatedEnum(message, field, index)->name() : - reflection->GetEnum(message, field)->name()); - break; - - case FieldDescriptor::CPPTYPE_MESSAGE: - Print(field->is_repeated() ? - reflection->GetRepeatedMessage(message, field, index) : - reflection->GetMessage(message, field), - generator); - break; - } -} - -/* static */ bool TextFormat::Print(const Message& message, - io::ZeroCopyOutputStream* output) { - return Printer().Print(message, output); -} - -/* static */ bool TextFormat::PrintUnknownFields( - const UnknownFieldSet& unknown_fields, - io::ZeroCopyOutputStream* output) { - return Printer().PrintUnknownFields(unknown_fields, output); -} - -/* static */ bool TextFormat::PrintToString( - const Message& message, string* output) { - return Printer().PrintToString(message, output); -} - -/* static */ bool TextFormat::PrintUnknownFieldsToString( - const UnknownFieldSet& unknown_fields, string* output) { - return Printer().PrintUnknownFieldsToString(unknown_fields, output); -} - -/* static */ void TextFormat::PrintFieldValueToString( - const Message& message, - const FieldDescriptor* field, - int index, - string* output) { - return Printer().PrintFieldValueToString(message, field, index, output); -} - -/* static */ bool TextFormat::ParseFieldValueFromString( - const string& input, - const FieldDescriptor* field, - Message* message) { - return Parser().ParseFieldValueFromString(input, field, message); -} - -// Prints an integer as hex with a fixed number of digits dependent on the -// integer type. -template -static string PaddedHex(IntType value) { - string result; - result.reserve(sizeof(value) * 2); - for (int i = sizeof(value) * 2 - 1; i >= 0; i--) { - result.push_back(int_to_hex_digit(value >> (i*4) & 0x0F)); - } - return result; -} - -void TextFormat::Printer::PrintUnknownFields( - const UnknownFieldSet& unknown_fields, TextGenerator& generator) const { - for (int i = 0; i < unknown_fields.field_count(); i++) { - const UnknownField& field = unknown_fields.field(i); - string field_number = SimpleItoa(field.number()); - - switch (field.type()) { - case UnknownField::TYPE_VARINT: - generator.Print(field_number); - generator.Print(": "); - generator.Print(SimpleItoa(field.varint())); - if (single_line_mode_) { - generator.Print(" "); - } else { - generator.Print("\n"); - } - break; - case UnknownField::TYPE_FIXED32: { - generator.Print(field_number); - generator.Print(": 0x"); - char buffer[kFastToBufferSize]; - generator.Print(FastHex32ToBuffer(field.fixed32(), buffer)); - if (single_line_mode_) { - generator.Print(" "); - } else { - generator.Print("\n"); - } - break; - } - case UnknownField::TYPE_FIXED64: { - generator.Print(field_number); - generator.Print(": 0x"); - char buffer[kFastToBufferSize]; - generator.Print(FastHex64ToBuffer(field.fixed64(), buffer)); - if (single_line_mode_) { - generator.Print(" "); - } else { - generator.Print("\n"); - } - break; - } - case UnknownField::TYPE_LENGTH_DELIMITED: { - generator.Print(field_number); - const string& value = field.length_delimited(); - UnknownFieldSet embedded_unknown_fields; - if (!value.empty() && embedded_unknown_fields.ParseFromString(value)) { - // This field is parseable as a Message. - // So it is probably an embedded message. - if (single_line_mode_) { - generator.Print(" { "); - } else { - generator.Print(" {\n"); - generator.Indent(); - } - PrintUnknownFields(embedded_unknown_fields, generator); - if (single_line_mode_) { - generator.Print("} "); - } else { - generator.Outdent(); - generator.Print("}\n"); - } - } else { - // This field is not parseable as a Message. - // So it is probably just a plain string. - generator.Print(": \""); - generator.Print(CEscape(value)); - generator.Print("\""); - if (single_line_mode_) { - generator.Print(" "); - } else { - generator.Print("\n"); - } - } - break; - } - case UnknownField::TYPE_GROUP: - generator.Print(field_number); - if (single_line_mode_) { - generator.Print(" { "); - } else { - generator.Print(" {\n"); - generator.Indent(); - } - PrintUnknownFields(field.group(), generator); - if (single_line_mode_) { - generator.Print("} "); - } else { - generator.Outdent(); - generator.Print("}\n"); - } - break; - } - } -} - -} // namespace protobuf -} // namespace google diff --git a/modules/dnn/3rdparty/protobuf/src/google/protobuf/text_format.h b/modules/dnn/3rdparty/protobuf/src/google/protobuf/text_format.h deleted file mode 100644 index 01f3ffb08..000000000 --- a/modules/dnn/3rdparty/protobuf/src/google/protobuf/text_format.h +++ /dev/null @@ -1,369 +0,0 @@ -// Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// http://code.google.com/p/protobuf/ -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -// Author: jschorr@google.com (Joseph Schorr) -// Based on original Protocol Buffers design by -// Sanjay Ghemawat, Jeff Dean, and others. -// -// Utilities for printing and parsing protocol messages in a human-readable, -// text-based format. - -#ifndef GOOGLE_PROTOBUF_TEXT_FORMAT_H__ -#define GOOGLE_PROTOBUF_TEXT_FORMAT_H__ - -#include -#include -#include -#include -#include -#include - -namespace google { -namespace protobuf { - -namespace io { - class ErrorCollector; // tokenizer.h -} - -// This class implements protocol buffer text format. Printing and parsing -// protocol messages in text format is useful for debugging and human editing -// of messages. -// -// This class is really a namespace that contains only static methods. -class LIBPROTOBUF_EXPORT TextFormat { - public: - // Outputs a textual representation of the given message to the given - // output stream. - static bool Print(const Message& message, io::ZeroCopyOutputStream* output); - - // Print the fields in an UnknownFieldSet. They are printed by tag number - // only. Embedded messages are heuristically identified by attempting to - // parse them. - static bool PrintUnknownFields(const UnknownFieldSet& unknown_fields, - io::ZeroCopyOutputStream* output); - - // Like Print(), but outputs directly to a string. - static bool PrintToString(const Message& message, string* output); - - // Like PrintUnknownFields(), but outputs directly to a string. - static bool PrintUnknownFieldsToString(const UnknownFieldSet& unknown_fields, - string* output); - - // Outputs a textual representation of the value of the field supplied on - // the message supplied. For non-repeated fields, an index of -1 must - // be supplied. Note that this method will print the default value for a - // field if it is not set. - static void PrintFieldValueToString(const Message& message, - const FieldDescriptor* field, - int index, - string* output); - - // Class for those users which require more fine-grained control over how - // a protobuffer message is printed out. - class LIBPROTOBUF_EXPORT Printer { - public: - Printer(); - ~Printer(); - - // Like TextFormat::Print - bool Print(const Message& message, io::ZeroCopyOutputStream* output) const; - // Like TextFormat::PrintUnknownFields - bool PrintUnknownFields(const UnknownFieldSet& unknown_fields, - io::ZeroCopyOutputStream* output) const; - // Like TextFormat::PrintToString - bool PrintToString(const Message& message, string* output) const; - // Like TextFormat::PrintUnknownFieldsToString - bool PrintUnknownFieldsToString(const UnknownFieldSet& unknown_fields, - string* output) const; - // Like TextFormat::PrintFieldValueToString - void PrintFieldValueToString(const Message& message, - const FieldDescriptor* field, - int index, - string* output) const; - - // Adjust the initial indent level of all output. Each indent level is - // equal to two spaces. - void SetInitialIndentLevel(int indent_level) { - initial_indent_level_ = indent_level; - } - - // If printing in single line mode, then the entire message will be output - // on a single line with no line breaks. - void SetSingleLineMode(bool single_line_mode) { - single_line_mode_ = single_line_mode; - } - - // Set true to print repeated primitives in a format like: - // field_name: [1, 2, 3, 4] - // instead of printing each value on its own line. Short format applies - // only to primitive values -- i.e. everything except strings and - // sub-messages/groups. - void SetUseShortRepeatedPrimitives(bool use_short_repeated_primitives) { - use_short_repeated_primitives_ = use_short_repeated_primitives; - } - - // Set true to output UTF-8 instead of ASCII. The only difference - // is that bytes >= 0x80 in string fields will not be escaped, - // because they are assumed to be part of UTF-8 multi-byte - // sequences. - void SetUseUtf8StringEscaping(bool as_utf8) { - utf8_string_escaping_ = as_utf8; - } - - private: - // Forward declaration of an internal class used to print the text - // output to the OutputStream (see text_format.cc for implementation). - class TextGenerator; - - // Internal Print method, used for writing to the OutputStream via - // the TextGenerator class. - void Print(const Message& message, - TextGenerator& generator) const; - - // Print a single field. - void PrintField(const Message& message, - const Reflection* reflection, - const FieldDescriptor* field, - TextGenerator& generator) const; - - // Print a repeated primitive field in short form. - void PrintShortRepeatedField(const Message& message, - const Reflection* reflection, - const FieldDescriptor* field, - TextGenerator& generator) const; - - // Print the name of a field -- i.e. everything that comes before the - // ':' for a single name/value pair. - void PrintFieldName(const Message& message, - const Reflection* reflection, - const FieldDescriptor* field, - TextGenerator& generator) const; - - // Outputs a textual representation of the value of the field supplied on - // the message supplied or the default value if not set. - void PrintFieldValue(const Message& message, - const Reflection* reflection, - const FieldDescriptor* field, - int index, - TextGenerator& generator) const; - - // Print the fields in an UnknownFieldSet. They are printed by tag number - // only. Embedded messages are heuristically identified by attempting to - // parse them. - void PrintUnknownFields(const UnknownFieldSet& unknown_fields, - TextGenerator& generator) const; - - int initial_indent_level_; - - bool single_line_mode_; - - bool use_short_repeated_primitives_; - - bool utf8_string_escaping_; - }; - - // Parses a text-format protocol message from the given input stream to - // the given message object. This function parses the format written - // by Print(). - static bool Parse(io::ZeroCopyInputStream* input, Message* output); - // Like Parse(), but reads directly from a string. - static bool ParseFromString(const string& input, Message* output); - - // Like Parse(), but the data is merged into the given message, as if - // using Message::MergeFrom(). - static bool Merge(io::ZeroCopyInputStream* input, Message* output); - // Like Merge(), but reads directly from a string. - static bool MergeFromString(const string& input, Message* output); - - // Parse the given text as a single field value and store it into the - // given field of the given message. If the field is a repeated field, - // the new value will be added to the end - static bool ParseFieldValueFromString(const string& input, - const FieldDescriptor* field, - Message* message); - - // Interface that TextFormat::Parser can use to find extensions. - // This class may be extended in the future to find more information - // like fields, etc. - class LIBPROTOBUF_EXPORT Finder { - public: - virtual ~Finder(); - - // Try to find an extension of *message by fully-qualified field - // name. Returns NULL if no extension is known for this name or number. - virtual const FieldDescriptor* FindExtension( - Message* message, - const string& name) const = 0; - }; - - // A location in the parsed text. - struct ParseLocation { - int line; - int column; - - ParseLocation() : line(-1), column(-1) {} - ParseLocation(int line_param, int column_param) - : line(line_param), column(column_param) {} - }; - - // Data structure which is populated with the locations of each field - // value parsed from the text. - class LIBPROTOBUF_EXPORT ParseInfoTree { - public: - ParseInfoTree(); - ~ParseInfoTree(); - - // Returns the parse location for index-th value of the field in the parsed - // text. If none exists, returns a location with line = -1. Index should be - // -1 for not-repeated fields. - ParseLocation GetLocation(const FieldDescriptor* field, int index) const; - - // Returns the parse info tree for the given field, which must be a message - // type. The nested information tree is owned by the root tree and will be - // deleted when it is deleted. - ParseInfoTree* GetTreeForNested(const FieldDescriptor* field, - int index) const; - - private: - // Allow the text format parser to record information into the tree. - friend class TextFormat; - - // Records the starting location of a single value for a field. - void RecordLocation(const FieldDescriptor* field, ParseLocation location); - - // Create and records a nested tree for a nested message field. - ParseInfoTree* CreateNested(const FieldDescriptor* field); - - // Defines the map from the index-th field descriptor to its parse location. - typedef map > LocationMap; - - // Defines the map from the index-th field descriptor to the nested parse - // info tree. - typedef map > NestedMap; - - LocationMap locations_; - NestedMap nested_; - - GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ParseInfoTree); - }; - - // For more control over parsing, use this class. - class LIBPROTOBUF_EXPORT Parser { - public: - Parser(); - ~Parser(); - - // Like TextFormat::Parse(). - bool Parse(io::ZeroCopyInputStream* input, Message* output); - // Like TextFormat::ParseFromString(). - bool ParseFromString(const string& input, Message* output); - // Like TextFormat::Merge(). - bool Merge(io::ZeroCopyInputStream* input, Message* output); - // Like TextFormat::MergeFromString(). - bool MergeFromString(const string& input, Message* output); - - // Set where to report parse errors. If NULL (the default), errors will - // be printed to stderr. - void RecordErrorsTo(io::ErrorCollector* error_collector) { - error_collector_ = error_collector; - } - - // Set how parser finds extensions. If NULL (the default), the - // parser will use the standard Reflection object associated with - // the message being parsed. - void SetFinder(Finder* finder) { - finder_ = finder; - } - - // Sets where location information about the parse will be written. If NULL - // (the default), then no location will be written. - void WriteLocationsTo(ParseInfoTree* tree) { - parse_info_tree_ = tree; - } - - // Normally parsing fails if, after parsing, output->IsInitialized() - // returns false. Call AllowPartialMessage(true) to skip this check. - void AllowPartialMessage(bool allow) { - allow_partial_ = allow; - } - - // Like TextFormat::ParseFieldValueFromString - bool ParseFieldValueFromString(const string& input, - const FieldDescriptor* field, - Message* output); - - - private: - // Forward declaration of an internal class used to parse text - // representations (see text_format.cc for implementation). - class ParserImpl; - - // Like TextFormat::Merge(). The provided implementation is used - // to do the parsing. - bool MergeUsingImpl(io::ZeroCopyInputStream* input, - Message* output, - ParserImpl* parser_impl); - - io::ErrorCollector* error_collector_; - Finder* finder_; - ParseInfoTree* parse_info_tree_; - bool allow_partial_; - bool allow_unknown_field_; - }; - - private: - // Hack: ParseInfoTree declares TextFormat as a friend which should extend - // the friendship to TextFormat::Parser::ParserImpl, but unfortunately some - // old compilers (e.g. GCC 3.4.6) don't implement this correctly. We provide - // helpers for ParserImpl to call methods of ParseInfoTree. - static inline void RecordLocation(ParseInfoTree* info_tree, - const FieldDescriptor* field, - ParseLocation location); - static inline ParseInfoTree* CreateNested(ParseInfoTree* info_tree, - const FieldDescriptor* field); - - GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(TextFormat); -}; - -inline void TextFormat::RecordLocation(ParseInfoTree* info_tree, - const FieldDescriptor* field, - ParseLocation location) { - info_tree->RecordLocation(field, location); -} - -inline TextFormat::ParseInfoTree* TextFormat::CreateNested( - ParseInfoTree* info_tree, const FieldDescriptor* field) { - return info_tree->CreateNested(field); -} - -} // namespace protobuf - -} // namespace google -#endif // GOOGLE_PROTOBUF_TEXT_FORMAT_H__ diff --git a/modules/dnn/3rdparty/protobuf/src/google/protobuf/text_format_unittest.cc b/modules/dnn/3rdparty/protobuf/src/google/protobuf/text_format_unittest.cc deleted file mode 100644 index 304fb8440..000000000 --- a/modules/dnn/3rdparty/protobuf/src/google/protobuf/text_format_unittest.cc +++ /dev/null @@ -1,1248 +0,0 @@ -// Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// http://code.google.com/p/protobuf/ -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -// Author: jschorr@google.com (Joseph Schorr) -// Based on original Protocol Buffers design by -// Sanjay Ghemawat, Jeff Dean, and others. - -#include -#include -#include - -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include - -namespace google { -namespace protobuf { - -// Can't use an anonymous namespace here due to brokenness of Tru64 compiler. -namespace text_format_unittest { - -inline bool IsNaN(double value) { - // NaN is never equal to anything, even itself. - return value != value; -} - -// A basic string with different escapable characters for testing. -const string kEscapeTestString = - "\"A string with ' characters \n and \r newlines and \t tabs and \001 " - "slashes \\ and multiple spaces"; - -// A representation of the above string with all the characters escaped. -const string kEscapeTestStringEscaped = - "\"\\\"A string with \\' characters \\n and \\r newlines " - "and \\t tabs and \\001 slashes \\\\ and multiple spaces\""; - -class TextFormatTest : public testing::Test { - public: - static void SetUpTestCase() { - File::ReadFileToStringOrDie( - TestSourceDir() - + "/google/protobuf/testdata/text_format_unittest_data.txt", - &static_proto_debug_string_); - } - - TextFormatTest() : proto_debug_string_(static_proto_debug_string_) {} - - protected: - // Debug string read from text_format_unittest_data.txt. - const string proto_debug_string_; - unittest::TestAllTypes proto_; - - private: - static string static_proto_debug_string_; -}; -string TextFormatTest::static_proto_debug_string_; - -class TextFormatExtensionsTest : public testing::Test { - public: - static void SetUpTestCase() { - File::ReadFileToStringOrDie( - TestSourceDir() - + "/google/protobuf/testdata/" - "text_format_unittest_extensions_data.txt", - &static_proto_debug_string_); - } - - TextFormatExtensionsTest() - : proto_debug_string_(static_proto_debug_string_) {} - - protected: - // Debug string read from text_format_unittest_data.txt. - const string proto_debug_string_; - unittest::TestAllExtensions proto_; - - private: - static string static_proto_debug_string_; -}; -string TextFormatExtensionsTest::static_proto_debug_string_; - - -TEST_F(TextFormatTest, Basic) { - TestUtil::SetAllFields(&proto_); - EXPECT_EQ(proto_debug_string_, proto_.DebugString()); -} - -TEST_F(TextFormatExtensionsTest, Extensions) { - TestUtil::SetAllExtensions(&proto_); - EXPECT_EQ(proto_debug_string_, proto_.DebugString()); -} - -TEST_F(TextFormatTest, ShortDebugString) { - proto_.set_optional_int32(1); - proto_.set_optional_string("hello"); - proto_.mutable_optional_nested_message()->set_bb(2); - proto_.mutable_optional_foreign_message(); - - EXPECT_EQ("optional_int32: 1 optional_string: \"hello\" " - "optional_nested_message { bb: 2 } " - "optional_foreign_message { }", - proto_.ShortDebugString()); -} - -TEST_F(TextFormatTest, ShortPrimitiveRepeateds) { - proto_.set_optional_int32(123); - proto_.add_repeated_int32(456); - proto_.add_repeated_int32(789); - proto_.add_repeated_string("foo"); - proto_.add_repeated_string("bar"); - proto_.add_repeated_nested_message()->set_bb(2); - proto_.add_repeated_nested_message()->set_bb(3); - proto_.add_repeated_nested_enum(unittest::TestAllTypes::FOO); - proto_.add_repeated_nested_enum(unittest::TestAllTypes::BAR); - - TextFormat::Printer printer; - printer.SetUseShortRepeatedPrimitives(true); - string text; - printer.PrintToString(proto_, &text); - - EXPECT_EQ("optional_int32: 123\n" - "repeated_int32: [456, 789]\n" - "repeated_string: \"foo\"\n" - "repeated_string: \"bar\"\n" - "repeated_nested_message {\n bb: 2\n}\n" - "repeated_nested_message {\n bb: 3\n}\n" - "repeated_nested_enum: [FOO, BAR]\n", - text); - - // Try in single-line mode. - printer.SetSingleLineMode(true); - printer.PrintToString(proto_, &text); - - EXPECT_EQ("optional_int32: 123 " - "repeated_int32: [456, 789] " - "repeated_string: \"foo\" " - "repeated_string: \"bar\" " - "repeated_nested_message { bb: 2 } " - "repeated_nested_message { bb: 3 } " - "repeated_nested_enum: [FOO, BAR] ", - text); -} - - -TEST_F(TextFormatTest, StringEscape) { - // Set the string value to test. - proto_.set_optional_string(kEscapeTestString); - - // Get the DebugString from the proto. - string debug_string = proto_.DebugString(); - string utf8_debug_string = proto_.Utf8DebugString(); - - // Hardcode a correct value to test against. - string correct_string = "optional_string: " - + kEscapeTestStringEscaped - + "\n"; - - // Compare. - EXPECT_EQ(correct_string, debug_string); - // UTF-8 string is the same as non-UTF-8 because - // the protocol buffer contains no UTF-8 text. - EXPECT_EQ(correct_string, utf8_debug_string); - - string expected_short_debug_string = "optional_string: " - + kEscapeTestStringEscaped; - EXPECT_EQ(expected_short_debug_string, proto_.ShortDebugString()); -} - -TEST_F(TextFormatTest, Utf8DebugString) { - // Set the string value to test. - proto_.set_optional_string("\350\260\267\346\255\214"); - - // Get the DebugString from the proto. - string debug_string = proto_.DebugString(); - string utf8_debug_string = proto_.Utf8DebugString(); - - // Hardcode a correct value to test against. - string correct_utf8_string = "optional_string: " - "\"\350\260\267\346\255\214\"" - "\n"; - string correct_string = "optional_string: " - "\"\\350\\260\\267\\346\\255\\214\"" - "\n"; - - // Compare. - EXPECT_EQ(correct_utf8_string, utf8_debug_string); - EXPECT_EQ(correct_string, debug_string); -} - -TEST_F(TextFormatTest, PrintUnknownFields) { - // Test printing of unknown fields in a message. - - unittest::TestEmptyMessage message; - UnknownFieldSet* unknown_fields = message.mutable_unknown_fields(); - - unknown_fields->AddVarint(5, 1); - unknown_fields->AddFixed32(5, 2); - unknown_fields->AddFixed64(5, 3); - unknown_fields->AddLengthDelimited(5, "4"); - unknown_fields->AddGroup(5)->AddVarint(10, 5); - - unknown_fields->AddVarint(8, 1); - unknown_fields->AddVarint(8, 2); - unknown_fields->AddVarint(8, 3); - - EXPECT_EQ( - "5: 1\n" - "5: 0x00000002\n" - "5: 0x0000000000000003\n" - "5: \"4\"\n" - "5 {\n" - " 10: 5\n" - "}\n" - "8: 1\n" - "8: 2\n" - "8: 3\n", - message.DebugString()); -} - -TEST_F(TextFormatTest, PrintUnknownMessage) { - // Test heuristic printing of messages in an UnknownFieldSet. - - protobuf_unittest::TestAllTypes message; - - // Cases which should not be interpreted as sub-messages. - - // 'a' is a valid FIXED64 tag, so for the string to be parseable as a message - // it should be followed by 8 bytes. Since this string only has two - // subsequent bytes, it should be treated as a string. - message.add_repeated_string("abc"); - - // 'd' happens to be a valid ENDGROUP tag. So, - // UnknownFieldSet::MergeFromCodedStream() will successfully parse "def", but - // the ConsumedEntireMessage() check should fail. - message.add_repeated_string("def"); - - // A zero-length string should never be interpreted as a message even though - // it is technically valid as one. - message.add_repeated_string(""); - - // Case which should be interpreted as a sub-message. - - // An actual nested message with content should always be interpreted as a - // nested message. - message.add_repeated_nested_message()->set_bb(123); - - string data; - message.SerializeToString(&data); - - string text; - UnknownFieldSet unknown_fields; - EXPECT_TRUE(unknown_fields.ParseFromString(data)); - EXPECT_TRUE(TextFormat::PrintUnknownFieldsToString(unknown_fields, &text)); - EXPECT_EQ( - "44: \"abc\"\n" - "44: \"def\"\n" - "44: \"\"\n" - "48 {\n" - " 1: 123\n" - "}\n", - text); -} - -TEST_F(TextFormatTest, PrintMessageWithIndent) { - // Test adding an initial indent to printing. - - protobuf_unittest::TestAllTypes message; - - message.add_repeated_string("abc"); - message.add_repeated_string("def"); - message.add_repeated_nested_message()->set_bb(123); - - string text; - TextFormat::Printer printer; - printer.SetInitialIndentLevel(1); - EXPECT_TRUE(printer.PrintToString(message, &text)); - EXPECT_EQ( - " repeated_string: \"abc\"\n" - " repeated_string: \"def\"\n" - " repeated_nested_message {\n" - " bb: 123\n" - " }\n", - text); -} - -TEST_F(TextFormatTest, PrintMessageSingleLine) { - // Test printing a message on a single line. - - protobuf_unittest::TestAllTypes message; - - message.add_repeated_string("abc"); - message.add_repeated_string("def"); - message.add_repeated_nested_message()->set_bb(123); - - string text; - TextFormat::Printer printer; - printer.SetInitialIndentLevel(1); - printer.SetSingleLineMode(true); - EXPECT_TRUE(printer.PrintToString(message, &text)); - EXPECT_EQ( - " repeated_string: \"abc\" repeated_string: \"def\" " - "repeated_nested_message { bb: 123 } ", - text); -} - -TEST_F(TextFormatTest, PrintBufferTooSmall) { - // Test printing a message to a buffer that is too small. - - protobuf_unittest::TestAllTypes message; - - message.add_repeated_string("abc"); - message.add_repeated_string("def"); - - char buffer[1] = ""; - io::ArrayOutputStream output_stream(buffer, 1); - EXPECT_FALSE(TextFormat::Print(message, &output_stream)); - EXPECT_EQ(buffer[0], 'r'); - EXPECT_EQ(output_stream.ByteCount(), 1); -} - -TEST_F(TextFormatTest, ParseBasic) { - io::ArrayInputStream input_stream(proto_debug_string_.data(), - proto_debug_string_.size()); - TextFormat::Parse(&input_stream, &proto_); - TestUtil::ExpectAllFieldsSet(proto_); -} - -TEST_F(TextFormatExtensionsTest, ParseExtensions) { - io::ArrayInputStream input_stream(proto_debug_string_.data(), - proto_debug_string_.size()); - TextFormat::Parse(&input_stream, &proto_); - TestUtil::ExpectAllExtensionsSet(proto_); -} - -TEST_F(TextFormatTest, ParseEnumFieldFromNumber) { - // Create a parse string with a numerical value for an enum field. - string parse_string = strings::Substitute("optional_nested_enum: $0", - unittest::TestAllTypes::BAZ); - EXPECT_TRUE(TextFormat::ParseFromString(parse_string, &proto_)); - EXPECT_TRUE(proto_.has_optional_nested_enum()); - EXPECT_EQ(unittest::TestAllTypes::BAZ, proto_.optional_nested_enum()); -} - -TEST_F(TextFormatTest, ParseEnumFieldFromNegativeNumber) { - ASSERT_LT(unittest::SPARSE_E, 0); - string parse_string = strings::Substitute("sparse_enum: $0", - unittest::SPARSE_E); - unittest::SparseEnumMessage proto; - EXPECT_TRUE(TextFormat::ParseFromString(parse_string, &proto)); - EXPECT_TRUE(proto.has_sparse_enum()); - EXPECT_EQ(unittest::SPARSE_E, proto.sparse_enum()); -} - -TEST_F(TextFormatTest, ParseStringEscape) { - // Create a parse string with escpaed characters in it. - string parse_string = "optional_string: " - + kEscapeTestStringEscaped - + "\n"; - - io::ArrayInputStream input_stream(parse_string.data(), - parse_string.size()); - TextFormat::Parse(&input_stream, &proto_); - - // Compare. - EXPECT_EQ(kEscapeTestString, proto_.optional_string()); -} - -TEST_F(TextFormatTest, ParseConcatenatedString) { - // Create a parse string with multiple parts on one line. - string parse_string = "optional_string: \"foo\" \"bar\"\n"; - - io::ArrayInputStream input_stream1(parse_string.data(), - parse_string.size()); - TextFormat::Parse(&input_stream1, &proto_); - - // Compare. - EXPECT_EQ("foobar", proto_.optional_string()); - - // Create a parse string with multiple parts on seperate lines. - parse_string = "optional_string: \"foo\"\n" - "\"bar\"\n"; - - io::ArrayInputStream input_stream2(parse_string.data(), - parse_string.size()); - TextFormat::Parse(&input_stream2, &proto_); - - // Compare. - EXPECT_EQ("foobar", proto_.optional_string()); -} - -TEST_F(TextFormatTest, ParseFloatWithSuffix) { - // Test that we can parse a floating-point value with 'f' appended to the - // end. This is needed for backwards-compatibility with proto1. - - // Have it parse a float with the 'f' suffix. - string parse_string = "optional_float: 1.0f\n"; - - io::ArrayInputStream input_stream(parse_string.data(), - parse_string.size()); - - TextFormat::Parse(&input_stream, &proto_); - - // Compare. - EXPECT_EQ(1.0, proto_.optional_float()); -} - -TEST_F(TextFormatTest, ParseShortRepeatedForm) { - string parse_string = - // Mixed short-form and long-form are simply concatenated. - "repeated_int32: 1\n" - "repeated_int32: [456, 789]\n" - "repeated_nested_enum: [ FOO ,BAR, # comment\n" - " 3]\n" - // Note that while the printer won't print repeated strings in short-form, - // the parser will accept them. - "repeated_string: [ \"foo\", 'bar' ]\n"; - - ASSERT_TRUE(TextFormat::ParseFromString(parse_string, &proto_)); - - ASSERT_EQ(3, proto_.repeated_int32_size()); - EXPECT_EQ(1, proto_.repeated_int32(0)); - EXPECT_EQ(456, proto_.repeated_int32(1)); - EXPECT_EQ(789, proto_.repeated_int32(2)); - - ASSERT_EQ(3, proto_.repeated_nested_enum_size()); - EXPECT_EQ(unittest::TestAllTypes::FOO, proto_.repeated_nested_enum(0)); - EXPECT_EQ(unittest::TestAllTypes::BAR, proto_.repeated_nested_enum(1)); - EXPECT_EQ(unittest::TestAllTypes::BAZ, proto_.repeated_nested_enum(2)); - - ASSERT_EQ(2, proto_.repeated_string_size()); - EXPECT_EQ("foo", proto_.repeated_string(0)); - EXPECT_EQ("bar", proto_.repeated_string(1)); -} - -TEST_F(TextFormatTest, Comments) { - // Test that comments are ignored. - - string parse_string = "optional_int32: 1 # a comment\n" - "optional_int64: 2 # another comment"; - - io::ArrayInputStream input_stream(parse_string.data(), - parse_string.size()); - - TextFormat::Parse(&input_stream, &proto_); - - // Compare. - EXPECT_EQ(1, proto_.optional_int32()); - EXPECT_EQ(2, proto_.optional_int64()); -} - -TEST_F(TextFormatTest, OptionalColon) { - // Test that we can place a ':' after the field name of a nested message, - // even though we don't have to. - - string parse_string = "optional_nested_message: { bb: 1}\n"; - - io::ArrayInputStream input_stream(parse_string.data(), - parse_string.size()); - - TextFormat::Parse(&input_stream, &proto_); - - // Compare. - EXPECT_TRUE(proto_.has_optional_nested_message()); - EXPECT_EQ(1, proto_.optional_nested_message().bb()); -} - -// Some platforms (e.g. Windows) insist on padding the exponent to three -// digits when one or two would be just fine. -static string RemoveRedundantZeros(string text) { - text = StringReplace(text, "e+0", "e+", true); - text = StringReplace(text, "e-0", "e-", true); - return text; -} - -TEST_F(TextFormatTest, PrintExotic) { - unittest::TestAllTypes message; - - // Note: In C, a negative integer literal is actually the unary negation - // operator being applied to a positive integer literal, and - // 9223372036854775808 is outside the range of int64. However, it is not - // outside the range of uint64. Confusingly, this means that everything - // works if we make the literal unsigned, even though we are negating it. - message.add_repeated_int64(-GOOGLE_ULONGLONG(9223372036854775808)); - message.add_repeated_uint64(GOOGLE_ULONGLONG(18446744073709551615)); - message.add_repeated_double(123.456); - message.add_repeated_double(1.23e21); - message.add_repeated_double(1.23e-18); - message.add_repeated_double(std::numeric_limits::infinity()); - message.add_repeated_double(-std::numeric_limits::infinity()); - message.add_repeated_double(std::numeric_limits::quiet_NaN()); - message.add_repeated_string(string("\000\001\a\b\f\n\r\t\v\\\'\"", 12)); - - // Fun story: We used to use 1.23e22 instead of 1.23e21 above, but this - // seemed to trigger an odd case on MinGW/GCC 3.4.5 where GCC's parsing of - // the value differed from strtod()'s parsing. That is to say, the - // following assertion fails on MinGW: - // assert(1.23e22 == strtod("1.23e22", NULL)); - // As a result, SimpleDtoa() would print the value as - // "1.2300000000000001e+22" to make sure strtod() produce the exact same - // result. Our goal is to test runtime parsing, not compile-time parsing, - // so this wasn't our problem. It was found that using 1.23e21 did not - // have this problem, so we switched to that instead. - - EXPECT_EQ( - "repeated_int64: -9223372036854775808\n" - "repeated_uint64: 18446744073709551615\n" - "repeated_double: 123.456\n" - "repeated_double: 1.23e+21\n" - "repeated_double: 1.23e-18\n" - "repeated_double: inf\n" - "repeated_double: -inf\n" - "repeated_double: nan\n" - "repeated_string: \"\\000\\001\\007\\010\\014\\n\\r\\t\\013\\\\\\'\\\"\"\n", - RemoveRedundantZeros(message.DebugString())); -} - -TEST_F(TextFormatTest, PrintFloatPrecision) { - unittest::TestAllTypes message; - - message.add_repeated_float(1.2); - message.add_repeated_float(1.23); - message.add_repeated_float(1.234); - message.add_repeated_float(1.2345); - message.add_repeated_float(1.23456); - message.add_repeated_float(1.2e10); - message.add_repeated_float(1.23e10); - message.add_repeated_float(1.234e10); - message.add_repeated_float(1.2345e10); - message.add_repeated_float(1.23456e10); - message.add_repeated_double(1.2); - message.add_repeated_double(1.23); - message.add_repeated_double(1.234); - message.add_repeated_double(1.2345); - message.add_repeated_double(1.23456); - message.add_repeated_double(1.234567); - message.add_repeated_double(1.2345678); - message.add_repeated_double(1.23456789); - message.add_repeated_double(1.234567898); - message.add_repeated_double(1.2345678987); - message.add_repeated_double(1.23456789876); - message.add_repeated_double(1.234567898765); - message.add_repeated_double(1.2345678987654); - message.add_repeated_double(1.23456789876543); - message.add_repeated_double(1.2e100); - message.add_repeated_double(1.23e100); - message.add_repeated_double(1.234e100); - message.add_repeated_double(1.2345e100); - message.add_repeated_double(1.23456e100); - message.add_repeated_double(1.234567e100); - message.add_repeated_double(1.2345678e100); - message.add_repeated_double(1.23456789e100); - message.add_repeated_double(1.234567898e100); - message.add_repeated_double(1.2345678987e100); - message.add_repeated_double(1.23456789876e100); - message.add_repeated_double(1.234567898765e100); - message.add_repeated_double(1.2345678987654e100); - message.add_repeated_double(1.23456789876543e100); - - EXPECT_EQ( - "repeated_float: 1.2\n" - "repeated_float: 1.23\n" - "repeated_float: 1.234\n" - "repeated_float: 1.2345\n" - "repeated_float: 1.23456\n" - "repeated_float: 1.2e+10\n" - "repeated_float: 1.23e+10\n" - "repeated_float: 1.234e+10\n" - "repeated_float: 1.2345e+10\n" - "repeated_float: 1.23456e+10\n" - "repeated_double: 1.2\n" - "repeated_double: 1.23\n" - "repeated_double: 1.234\n" - "repeated_double: 1.2345\n" - "repeated_double: 1.23456\n" - "repeated_double: 1.234567\n" - "repeated_double: 1.2345678\n" - "repeated_double: 1.23456789\n" - "repeated_double: 1.234567898\n" - "repeated_double: 1.2345678987\n" - "repeated_double: 1.23456789876\n" - "repeated_double: 1.234567898765\n" - "repeated_double: 1.2345678987654\n" - "repeated_double: 1.23456789876543\n" - "repeated_double: 1.2e+100\n" - "repeated_double: 1.23e+100\n" - "repeated_double: 1.234e+100\n" - "repeated_double: 1.2345e+100\n" - "repeated_double: 1.23456e+100\n" - "repeated_double: 1.234567e+100\n" - "repeated_double: 1.2345678e+100\n" - "repeated_double: 1.23456789e+100\n" - "repeated_double: 1.234567898e+100\n" - "repeated_double: 1.2345678987e+100\n" - "repeated_double: 1.23456789876e+100\n" - "repeated_double: 1.234567898765e+100\n" - "repeated_double: 1.2345678987654e+100\n" - "repeated_double: 1.23456789876543e+100\n", - RemoveRedundantZeros(message.DebugString())); -} - - -TEST_F(TextFormatTest, AllowPartial) { - unittest::TestRequired message; - TextFormat::Parser parser; - parser.AllowPartialMessage(true); - EXPECT_TRUE(parser.ParseFromString("a: 1", &message)); - EXPECT_EQ(1, message.a()); - EXPECT_FALSE(message.has_b()); - EXPECT_FALSE(message.has_c()); -} - -TEST_F(TextFormatTest, ParseExotic) { - unittest::TestAllTypes message; - ASSERT_TRUE(TextFormat::ParseFromString( - "repeated_int32: -1\n" - "repeated_int32: -2147483648\n" - "repeated_int64: -1\n" - "repeated_int64: -9223372036854775808\n" - "repeated_uint32: 4294967295\n" - "repeated_uint32: 2147483648\n" - "repeated_uint64: 18446744073709551615\n" - "repeated_uint64: 9223372036854775808\n" - "repeated_double: 123.0\n" - "repeated_double: 123.5\n" - "repeated_double: 0.125\n" - "repeated_double: 1.23E17\n" - "repeated_double: 1.235E+22\n" - "repeated_double: 1.235e-18\n" - "repeated_double: 123.456789\n" - "repeated_double: inf\n" - "repeated_double: Infinity\n" - "repeated_double: -inf\n" - "repeated_double: -Infinity\n" - "repeated_double: nan\n" - "repeated_double: NaN\n" - "repeated_string: \"\\000\\001\\a\\b\\f\\n\\r\\t\\v\\\\\\'\\\"\"\n", - &message)); - - ASSERT_EQ(2, message.repeated_int32_size()); - EXPECT_EQ(-1, message.repeated_int32(0)); - // Note: In C, a negative integer literal is actually the unary negation - // operator being applied to a positive integer literal, and 2147483648 is - // outside the range of int32. However, it is not outside the range of - // uint32. Confusingly, this means that everything works if we make the - // literal unsigned, even though we are negating it. - EXPECT_EQ(-2147483648u, message.repeated_int32(1)); - - ASSERT_EQ(2, message.repeated_int64_size()); - EXPECT_EQ(-1, message.repeated_int64(0)); - // Note: In C, a negative integer literal is actually the unary negation - // operator being applied to a positive integer literal, and - // 9223372036854775808 is outside the range of int64. However, it is not - // outside the range of uint64. Confusingly, this means that everything - // works if we make the literal unsigned, even though we are negating it. - EXPECT_EQ(-GOOGLE_ULONGLONG(9223372036854775808), message.repeated_int64(1)); - - ASSERT_EQ(2, message.repeated_uint32_size()); - EXPECT_EQ(4294967295u, message.repeated_uint32(0)); - EXPECT_EQ(2147483648u, message.repeated_uint32(1)); - - ASSERT_EQ(2, message.repeated_uint64_size()); - EXPECT_EQ(GOOGLE_ULONGLONG(18446744073709551615), message.repeated_uint64(0)); - EXPECT_EQ(GOOGLE_ULONGLONG(9223372036854775808), message.repeated_uint64(1)); - - ASSERT_EQ(13, message.repeated_double_size()); - EXPECT_EQ(123.0 , message.repeated_double(0)); - EXPECT_EQ(123.5 , message.repeated_double(1)); - EXPECT_EQ(0.125 , message.repeated_double(2)); - EXPECT_EQ(1.23E17 , message.repeated_double(3)); - EXPECT_EQ(1.235E22 , message.repeated_double(4)); - EXPECT_EQ(1.235E-18 , message.repeated_double(5)); - EXPECT_EQ(123.456789, message.repeated_double(6)); - EXPECT_EQ(message.repeated_double(7), numeric_limits::infinity()); - EXPECT_EQ(message.repeated_double(8), numeric_limits::infinity()); - EXPECT_EQ(message.repeated_double(9), -numeric_limits::infinity()); - EXPECT_EQ(message.repeated_double(10), -numeric_limits::infinity()); - EXPECT_TRUE(IsNaN(message.repeated_double(11))); - EXPECT_TRUE(IsNaN(message.repeated_double(12))); - - // Note: Since these string literals have \0's in them, we must explicitly - // pass their sizes to string's constructor. - ASSERT_EQ(1, message.repeated_string_size()); - EXPECT_EQ(string("\000\001\a\b\f\n\r\t\v\\\'\"", 12), - message.repeated_string(0)); -} - -class TextFormatParserTest : public testing::Test { - protected: - void ExpectFailure(const string& input, const string& message, int line, - int col) { - scoped_ptr proto(new unittest::TestAllTypes); - ExpectFailure(input, message, line, col, proto.get()); - } - - void ExpectFailure(const string& input, const string& message, int line, - int col, Message* proto) { - ExpectMessage(input, message, line, col, proto, false); - } - - void ExpectMessage(const string& input, const string& message, int line, - int col, Message* proto, bool expected_result) { - TextFormat::Parser parser; - MockErrorCollector error_collector; - parser.RecordErrorsTo(&error_collector); - EXPECT_EQ(parser.ParseFromString(input, proto), expected_result); - EXPECT_EQ(SimpleItoa(line) + ":" + SimpleItoa(col) + ": " + message + "\n", - error_collector.text_); - } - - void ExpectSuccessAndTree(const string& input, Message* proto, - TextFormat::ParseInfoTree* info_tree) { - TextFormat::Parser parser; - MockErrorCollector error_collector; - parser.RecordErrorsTo(&error_collector); - parser.WriteLocationsTo(info_tree); - - EXPECT_TRUE(parser.ParseFromString(input, proto)); - } - - void ExpectLocation(TextFormat::ParseInfoTree* tree, - const Descriptor* d, const string& field_name, - int index, int line, int column) { - TextFormat::ParseLocation location = tree->GetLocation( - d->FindFieldByName(field_name), index); - EXPECT_EQ(line, location.line); - EXPECT_EQ(column, location.column); - } - - // An error collector which simply concatenates all its errors into a big - // block of text which can be checked. - class MockErrorCollector : public io::ErrorCollector { - public: - MockErrorCollector() {} - ~MockErrorCollector() {} - - string text_; - - // implements ErrorCollector ------------------------------------- - void AddError(int line, int column, const string& message) { - strings::SubstituteAndAppend(&text_, "$0:$1: $2\n", - line + 1, column + 1, message); - } - - void AddWarning(int line, int column, const string& message) { - AddError(line, column, "WARNING:" + message); - } - }; -}; - -TEST_F(TextFormatParserTest, ParseInfoTreeBuilding) { - scoped_ptr message(new unittest::TestAllTypes); - const Descriptor* d = message->GetDescriptor(); - - string stringData = - "optional_int32: 1\n" - "optional_int64: 2\n" - " optional_double: 2.4\n" - "repeated_int32: 5\n" - "repeated_int32: 10\n" - "optional_nested_message <\n" - " bb: 78\n" - ">\n" - "repeated_nested_message <\n" - " bb: 79\n" - ">\n" - "repeated_nested_message <\n" - " bb: 80\n" - ">"; - - - TextFormat::ParseInfoTree tree; - ExpectSuccessAndTree(stringData, message.get(), &tree); - - // Verify that the tree has the correct positions. - ExpectLocation(&tree, d, "optional_int32", -1, 0, 0); - ExpectLocation(&tree, d, "optional_int64", -1, 1, 0); - ExpectLocation(&tree, d, "optional_double", -1, 2, 2); - - ExpectLocation(&tree, d, "repeated_int32", 0, 3, 0); - ExpectLocation(&tree, d, "repeated_int32", 1, 4, 0); - - ExpectLocation(&tree, d, "optional_nested_message", -1, 5, 0); - ExpectLocation(&tree, d, "repeated_nested_message", 0, 8, 0); - ExpectLocation(&tree, d, "repeated_nested_message", 1, 11, 0); - - // Check for fields not set. For an invalid field, the location returned - // should be -1, -1. - ExpectLocation(&tree, d, "repeated_int64", 0, -1, -1); - ExpectLocation(&tree, d, "repeated_int32", 6, -1, -1); - ExpectLocation(&tree, d, "some_unknown_field", -1, -1, -1); - - // Verify inside the nested message. - const FieldDescriptor* nested_field = - d->FindFieldByName("optional_nested_message"); - - TextFormat::ParseInfoTree* nested_tree = - tree.GetTreeForNested(nested_field, -1); - ExpectLocation(nested_tree, nested_field->message_type(), "bb", -1, 6, 2); - - // Verify inside another nested message. - nested_field = d->FindFieldByName("repeated_nested_message"); - nested_tree = tree.GetTreeForNested(nested_field, 0); - ExpectLocation(nested_tree, nested_field->message_type(), "bb", -1, 9, 2); - - nested_tree = tree.GetTreeForNested(nested_field, 1); - ExpectLocation(nested_tree, nested_field->message_type(), "bb", -1, 12, 2); - - // Verify a NULL tree for an unknown nested field. - TextFormat::ParseInfoTree* unknown_nested_tree = - tree.GetTreeForNested(nested_field, 2); - - EXPECT_EQ(NULL, unknown_nested_tree); -} - -TEST_F(TextFormatParserTest, ParseFieldValueFromString) { - scoped_ptr message(new unittest::TestAllTypes); - const Descriptor* d = message->GetDescriptor(); - -#define EXPECT_FIELD(name, value, valuestring) \ - EXPECT_TRUE(TextFormat::ParseFieldValueFromString( \ - valuestring, d->FindFieldByName("optional_" #name), message.get())); \ - EXPECT_EQ(value, message->optional_##name()); \ - EXPECT_TRUE(message->has_optional_##name()); - -#define EXPECT_BOOL_FIELD(name, value, valuestring) \ - EXPECT_TRUE(TextFormat::ParseFieldValueFromString( \ - valuestring, d->FindFieldByName("optional_" #name), message.get())); \ - EXPECT_TRUE(message->optional_##name() == value); \ - EXPECT_TRUE(message->has_optional_##name()); - -#define EXPECT_FLOAT_FIELD(name, value, valuestring) \ - EXPECT_TRUE(TextFormat::ParseFieldValueFromString( \ - valuestring, d->FindFieldByName("optional_" #name), message.get())); \ - EXPECT_FLOAT_EQ(value, message->optional_##name()); \ - EXPECT_TRUE(message->has_optional_##name()); - -#define EXPECT_DOUBLE_FIELD(name, value, valuestring) \ - EXPECT_TRUE(TextFormat::ParseFieldValueFromString( \ - valuestring, d->FindFieldByName("optional_" #name), message.get())); \ - EXPECT_DOUBLE_EQ(value, message->optional_##name()); \ - EXPECT_TRUE(message->has_optional_##name()); - -#define EXPECT_INVALID(name, valuestring) \ - EXPECT_FALSE(TextFormat::ParseFieldValueFromString( \ - valuestring, d->FindFieldByName("optional_" #name), message.get())); - - // int32 - EXPECT_FIELD(int32, 1, "1"); - EXPECT_FIELD(int32, -1, "-1"); - EXPECT_FIELD(int32, 0x1234, "0x1234"); - EXPECT_INVALID(int32, "a"); - EXPECT_INVALID(int32, "999999999999999999999999999999999999"); - EXPECT_INVALID(int32, "1,2"); - - // int64 - EXPECT_FIELD(int64, 1, "1"); - EXPECT_FIELD(int64, -1, "-1"); - EXPECT_FIELD(int64, 0x1234567812345678LL, "0x1234567812345678"); - EXPECT_INVALID(int64, "a"); - EXPECT_INVALID(int64, "999999999999999999999999999999999999"); - EXPECT_INVALID(int64, "1,2"); - - // uint64 - EXPECT_FIELD(uint64, 1, "1"); - EXPECT_FIELD(uint64, 0xf234567812345678ULL, "0xf234567812345678"); - EXPECT_INVALID(uint64, "-1"); - EXPECT_INVALID(uint64, "a"); - EXPECT_INVALID(uint64, "999999999999999999999999999999999999"); - EXPECT_INVALID(uint64, "1,2"); - - // fixed32 - EXPECT_FIELD(fixed32, 1, "1"); - EXPECT_FIELD(fixed32, 0x12345678, "0x12345678"); - EXPECT_INVALID(fixed32, "-1"); - EXPECT_INVALID(fixed32, "a"); - EXPECT_INVALID(fixed32, "999999999999999999999999999999999999"); - EXPECT_INVALID(fixed32, "1,2"); - - // fixed64 - EXPECT_FIELD(fixed64, 1, "1"); - EXPECT_FIELD(fixed64, 0x1234567812345678ULL, "0x1234567812345678"); - EXPECT_INVALID(fixed64, "-1"); - EXPECT_INVALID(fixed64, "a"); - EXPECT_INVALID(fixed64, "999999999999999999999999999999999999"); - EXPECT_INVALID(fixed64, "1,2"); - - // bool - EXPECT_BOOL_FIELD(bool, true, "true"); - EXPECT_BOOL_FIELD(bool, false, "false"); - EXPECT_BOOL_FIELD(bool, true, "1"); - EXPECT_BOOL_FIELD(bool, true, "t"); - EXPECT_BOOL_FIELD(bool, false, "0"); - EXPECT_BOOL_FIELD(bool, false, "f"); - EXPECT_INVALID(bool, "2"); - EXPECT_INVALID(bool, "-0"); - EXPECT_INVALID(bool, "on"); - EXPECT_INVALID(bool, "a"); - EXPECT_INVALID(bool, "True"); - - // float - EXPECT_FIELD(float, 1, "1"); - EXPECT_FLOAT_FIELD(float, 1.5, "1.5"); - EXPECT_FLOAT_FIELD(float, 1.5e3, "1.5e3"); - EXPECT_FLOAT_FIELD(float, -4.55, "-4.55"); - EXPECT_INVALID(float, "a"); - EXPECT_INVALID(float, "1,2"); - - // double - EXPECT_FIELD(double, 1, "1"); - EXPECT_FIELD(double, -1, "-1"); - EXPECT_DOUBLE_FIELD(double, 2.3, "2.3"); - EXPECT_DOUBLE_FIELD(double, 3e5, "3e5"); - EXPECT_INVALID(double, "a"); - EXPECT_INVALID(double, "1,2"); - - // string - EXPECT_FIELD(string, "hello", "\"hello\""); - EXPECT_FIELD(string, "-1.87", "'-1.87'"); - EXPECT_INVALID(string, "hello"); // without quote for value - - // enum - EXPECT_FIELD(nested_enum, unittest::TestAllTypes::BAR, "BAR"); - EXPECT_FIELD(nested_enum, unittest::TestAllTypes::BAZ, - SimpleItoa(unittest::TestAllTypes::BAZ)); - EXPECT_INVALID(nested_enum, "FOOBAR"); - - // message - EXPECT_TRUE(TextFormat::ParseFieldValueFromString( - "", d->FindFieldByName("optional_nested_message"), message.get())); - EXPECT_EQ(12, message->optional_nested_message().bb()); \ - EXPECT_TRUE(message->has_optional_nested_message()); - EXPECT_INVALID(nested_message, "any"); - -#undef EXPECT_FIELD -#undef EXPECT_BOOL_FIELD -#undef EXPECT_FLOAT_FIELD -#undef EXPECT_DOUBLE_FIELD -#undef EXPECT_INVALID -} - - -TEST_F(TextFormatParserTest, InvalidToken) { - ExpectFailure("optional_bool: true\n-5\n", "Expected identifier.", - 2, 1); - - ExpectFailure("optional_bool: true!\n", "Expected identifier.", 1, 20); - ExpectFailure("\"some string\"", "Expected identifier.", 1, 1); -} - -TEST_F(TextFormatParserTest, InvalidFieldName) { - ExpectFailure( - "invalid_field: somevalue\n", - "Message type \"protobuf_unittest.TestAllTypes\" has no field named " - "\"invalid_field\".", - 1, 14); -} - -TEST_F(TextFormatParserTest, InvalidCapitalization) { - // We require that group names be exactly as they appear in the .proto. - ExpectFailure( - "optionalgroup {\na: 15\n}\n", - "Message type \"protobuf_unittest.TestAllTypes\" has no field named " - "\"optionalgroup\".", - 1, 15); - ExpectFailure( - "OPTIONALgroup {\na: 15\n}\n", - "Message type \"protobuf_unittest.TestAllTypes\" has no field named " - "\"OPTIONALgroup\".", - 1, 15); - ExpectFailure( - "Optional_Double: 10.0\n", - "Message type \"protobuf_unittest.TestAllTypes\" has no field named " - "\"Optional_Double\".", - 1, 16); -} - -TEST_F(TextFormatParserTest, InvalidFieldValues) { - // Invalid values for a double/float field. - ExpectFailure("optional_double: \"hello\"\n", "Expected double.", 1, 18); - ExpectFailure("optional_double: true\n", "Expected double.", 1, 18); - ExpectFailure("optional_double: !\n", "Expected double.", 1, 18); - ExpectFailure("optional_double {\n \n}\n", "Expected \":\", found \"{\".", - 1, 17); - - // Invalid values for a signed integer field. - ExpectFailure("optional_int32: \"hello\"\n", "Expected integer.", 1, 17); - ExpectFailure("optional_int32: true\n", "Expected integer.", 1, 17); - ExpectFailure("optional_int32: 4.5\n", "Expected integer.", 1, 17); - ExpectFailure("optional_int32: !\n", "Expected integer.", 1, 17); - ExpectFailure("optional_int32 {\n \n}\n", "Expected \":\", found \"{\".", - 1, 16); - ExpectFailure("optional_int32: 0x80000000\n", - "Integer out of range.", 1, 17); - ExpectFailure("optional_int64: 0x8000000000000000\n", - "Integer out of range.", 1, 17); - ExpectFailure("optional_int32: -0x80000001\n", - "Integer out of range.", 1, 18); - ExpectFailure("optional_int64: -0x8000000000000001\n", - "Integer out of range.", 1, 18); - - // Invalid values for an unsigned integer field. - ExpectFailure("optional_uint64: \"hello\"\n", "Expected integer.", 1, 18); - ExpectFailure("optional_uint64: true\n", "Expected integer.", 1, 18); - ExpectFailure("optional_uint64: 4.5\n", "Expected integer.", 1, 18); - ExpectFailure("optional_uint64: -5\n", "Expected integer.", 1, 18); - ExpectFailure("optional_uint64: !\n", "Expected integer.", 1, 18); - ExpectFailure("optional_uint64 {\n \n}\n", "Expected \":\", found \"{\".", - 1, 17); - ExpectFailure("optional_uint32: 0x100000000\n", - "Integer out of range.", 1, 18); - ExpectFailure("optional_uint64: 0x10000000000000000\n", - "Integer out of range.", 1, 18); - - // Invalid values for a boolean field. - ExpectFailure("optional_bool: \"hello\"\n", "Expected identifier.", 1, 16); - ExpectFailure("optional_bool: 5\n", "Integer out of range.", 1, 16); - ExpectFailure("optional_bool: -7.5\n", "Expected identifier.", 1, 16); - ExpectFailure("optional_bool: !\n", "Expected identifier.", 1, 16); - - ExpectFailure( - "optional_bool: meh\n", - "Invalid value for boolean field \"optional_bool\". Value: \"meh\".", - 2, 1); - - ExpectFailure("optional_bool {\n \n}\n", "Expected \":\", found \"{\".", - 1, 15); - - // Invalid values for a string field. - ExpectFailure("optional_string: true\n", "Expected string.", 1, 18); - ExpectFailure("optional_string: 5\n", "Expected string.", 1, 18); - ExpectFailure("optional_string: -7.5\n", "Expected string.", 1, 18); - ExpectFailure("optional_string: !\n", "Expected string.", 1, 18); - ExpectFailure("optional_string {\n \n}\n", "Expected \":\", found \"{\".", - 1, 17); - - // Invalid values for an enumeration field. - ExpectFailure("optional_nested_enum: \"hello\"\n", - "Expected integer or identifier.", 1, 23); - - // Valid token, but enum value is not defined. - ExpectFailure("optional_nested_enum: 5\n", - "Unknown enumeration value of \"5\" for field " - "\"optional_nested_enum\".", 2, 1); - // We consume the negative sign, so the error position starts one character - // later. - ExpectFailure("optional_nested_enum: -7.5\n", "Expected integer.", 1, 24); - ExpectFailure("optional_nested_enum: !\n", - "Expected integer or identifier.", 1, 23); - - ExpectFailure( - "optional_nested_enum: grah\n", - "Unknown enumeration value of \"grah\" for field " - "\"optional_nested_enum\".", 2, 1); - - ExpectFailure( - "optional_nested_enum {\n \n}\n", - "Expected \":\", found \"{\".", 1, 22); -} - -TEST_F(TextFormatParserTest, MessageDelimeters) { - // Non-matching delimeters. - ExpectFailure("OptionalGroup <\n \n}\n", "Expected \">\", found \"}\".", - 3, 1); - - // Invalid delimeters. - ExpectFailure("OptionalGroup [\n \n]\n", "Expected \"{\", found \"[\".", - 1, 15); - - // Unending message. - ExpectFailure("optional_nested_message {\n \nbb: 118\n", - "Expected identifier.", - 4, 1); -} - -TEST_F(TextFormatParserTest, UnknownExtension) { - // Non-matching delimeters. - ExpectFailure("[blahblah]: 123", - "Extension \"blahblah\" is not defined or is not an " - "extension of \"protobuf_unittest.TestAllTypes\".", - 1, 11); -} - -TEST_F(TextFormatParserTest, MissingRequired) { - unittest::TestRequired message; - ExpectFailure("a: 1", - "Message missing required fields: b, c", - 0, 1, &message); -} - -TEST_F(TextFormatParserTest, ParseDuplicateRequired) { - unittest::TestRequired message; - ExpectFailure("a: 1 b: 2 c: 3 a: 1", - "Non-repeated field \"a\" is specified multiple times.", - 1, 17, &message); -} - -TEST_F(TextFormatParserTest, ParseDuplicateOptional) { - unittest::ForeignMessage message; - ExpectFailure("c: 1 c: 2", - "Non-repeated field \"c\" is specified multiple times.", - 1, 7, &message); -} - -TEST_F(TextFormatParserTest, MergeDuplicateRequired) { - unittest::TestRequired message; - TextFormat::Parser parser; - EXPECT_TRUE(parser.MergeFromString("a: 1 b: 2 c: 3 a: 4", &message)); - EXPECT_EQ(4, message.a()); -} - -TEST_F(TextFormatParserTest, MergeDuplicateOptional) { - unittest::ForeignMessage message; - TextFormat::Parser parser; - EXPECT_TRUE(parser.MergeFromString("c: 1 c: 2", &message)); - EXPECT_EQ(2, message.c()); -} - -TEST_F(TextFormatParserTest, ExplicitDelimiters) { - unittest::TestRequired message; - EXPECT_TRUE(TextFormat::ParseFromString("a:1,b:2;c:3", &message)); - EXPECT_EQ(1, message.a()); - EXPECT_EQ(2, message.b()); - EXPECT_EQ(3, message.c()); -} - -TEST_F(TextFormatParserTest, PrintErrorsToStderr) { - vector errors; - - { - ScopedMemoryLog log; - unittest::TestAllTypes proto; - EXPECT_FALSE(TextFormat::ParseFromString("no_such_field: 1", &proto)); - errors = log.GetMessages(ERROR); - } - - ASSERT_EQ(1, errors.size()); - EXPECT_EQ("Error parsing text-format protobuf_unittest.TestAllTypes: " - "1:14: Message type \"protobuf_unittest.TestAllTypes\" has no field " - "named \"no_such_field\".", - errors[0]); -} - -TEST_F(TextFormatParserTest, FailsOnTokenizationError) { - vector errors; - - { - ScopedMemoryLog log; - unittest::TestAllTypes proto; - EXPECT_FALSE(TextFormat::ParseFromString("\020", &proto)); - errors = log.GetMessages(ERROR); - } - - ASSERT_EQ(1, errors.size()); - EXPECT_EQ("Error parsing text-format protobuf_unittest.TestAllTypes: " - "1:1: Invalid control characters encountered in text.", - errors[0]); -} - -TEST_F(TextFormatParserTest, ParseDeprecatedField) { - unittest::TestDeprecatedFields message; - ExpectMessage("deprecated_int32: 42", - "WARNING:text format contains deprecated field " - "\"deprecated_int32\"", 1, 21, &message, true); -} - -class TextFormatMessageSetTest : public testing::Test { - protected: - static const char proto_debug_string_[]; -}; -const char TextFormatMessageSetTest::proto_debug_string_[] = -"message_set {\n" -" [protobuf_unittest.TestMessageSetExtension1] {\n" -" i: 23\n" -" }\n" -" [protobuf_unittest.TestMessageSetExtension2] {\n" -" str: \"foo\"\n" -" }\n" -"}\n"; - - -TEST_F(TextFormatMessageSetTest, Serialize) { - protobuf_unittest::TestMessageSetContainer proto; - protobuf_unittest::TestMessageSetExtension1* item_a = - proto.mutable_message_set()->MutableExtension( - protobuf_unittest::TestMessageSetExtension1::message_set_extension); - item_a->set_i(23); - protobuf_unittest::TestMessageSetExtension2* item_b = - proto.mutable_message_set()->MutableExtension( - protobuf_unittest::TestMessageSetExtension2::message_set_extension); - item_b->set_str("foo"); - EXPECT_EQ(proto_debug_string_, proto.DebugString()); -} - -TEST_F(TextFormatMessageSetTest, Deserialize) { - protobuf_unittest::TestMessageSetContainer proto; - ASSERT_TRUE(TextFormat::ParseFromString(proto_debug_string_, &proto)); - EXPECT_EQ(23, proto.message_set().GetExtension( - protobuf_unittest::TestMessageSetExtension1::message_set_extension).i()); - EXPECT_EQ("foo", proto.message_set().GetExtension( - protobuf_unittest::TestMessageSetExtension2::message_set_extension).str()); - - // Ensure that these are the only entries present. - vector descriptors; - proto.message_set().GetReflection()->ListFields( - proto.message_set(), &descriptors); - EXPECT_EQ(2, descriptors.size()); -} - - -} // namespace text_format_unittest -} // namespace protobuf -} // namespace google diff --git a/modules/dnn/3rdparty/protobuf/src/google/protobuf/unknown_field_set.cc b/modules/dnn/3rdparty/protobuf/src/google/protobuf/unknown_field_set.cc deleted file mode 100644 index 841433d5d..000000000 --- a/modules/dnn/3rdparty/protobuf/src/google/protobuf/unknown_field_set.cc +++ /dev/null @@ -1,266 +0,0 @@ -// Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// http://code.google.com/p/protobuf/ -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -// Author: kenton@google.com (Kenton Varda) -// Based on original Protocol Buffers design by -// Sanjay Ghemawat, Jeff Dean, and others. - -#include - -#include -#include -#include -#include -#include -#include - -namespace google { -namespace protobuf { - -UnknownFieldSet::UnknownFieldSet() - : fields_(NULL) {} - -UnknownFieldSet::~UnknownFieldSet() { - Clear(); - delete fields_; -} - -void UnknownFieldSet::ClearFallback() { - GOOGLE_DCHECK(fields_ != NULL); - for (int i = 0; i < fields_->size(); i++) { - (*fields_)[i].Delete(); - } - fields_->clear(); -} - -void UnknownFieldSet::ClearAndFreeMemory() { - if (fields_ != NULL) { - Clear(); - delete fields_; - fields_ = NULL; - } -} - -void UnknownFieldSet::MergeFrom(const UnknownFieldSet& other) { - for (int i = 0; i < other.field_count(); i++) { - AddField(other.field(i)); - } -} - -int UnknownFieldSet::SpaceUsedExcludingSelf() const { - if (fields_ == NULL) return 0; - - int total_size = sizeof(*fields_) + sizeof(UnknownField) * fields_->size(); - for (int i = 0; i < fields_->size(); i++) { - const UnknownField& field = (*fields_)[i]; - switch (field.type()) { - case UnknownField::TYPE_LENGTH_DELIMITED: - total_size += sizeof(*field.length_delimited_.string_value_) + - internal::StringSpaceUsedExcludingSelf( - *field.length_delimited_.string_value_); - break; - case UnknownField::TYPE_GROUP: - total_size += field.group_->SpaceUsed(); - break; - default: - break; - } - } - return total_size; -} - -int UnknownFieldSet::SpaceUsed() const { - return sizeof(*this) + SpaceUsedExcludingSelf(); -} - -void UnknownFieldSet::AddVarint(int number, uint64 value) { - if (fields_ == NULL) fields_ = new vector; - UnknownField field; - field.number_ = number; - field.type_ = UnknownField::TYPE_VARINT; - field.varint_ = value; - fields_->push_back(field); -} - -void UnknownFieldSet::AddFixed32(int number, uint32 value) { - if (fields_ == NULL) fields_ = new vector; - UnknownField field; - field.number_ = number; - field.type_ = UnknownField::TYPE_FIXED32; - field.fixed32_ = value; - fields_->push_back(field); -} - -void UnknownFieldSet::AddFixed64(int number, uint64 value) { - if (fields_ == NULL) fields_ = new vector; - UnknownField field; - field.number_ = number; - field.type_ = UnknownField::TYPE_FIXED64; - field.fixed64_ = value; - fields_->push_back(field); -} - -string* UnknownFieldSet::AddLengthDelimited(int number) { - if (fields_ == NULL) fields_ = new vector; - UnknownField field; - field.number_ = number; - field.type_ = UnknownField::TYPE_LENGTH_DELIMITED; - field.length_delimited_.string_value_ = new string; - fields_->push_back(field); - return field.length_delimited_.string_value_; -} - - -UnknownFieldSet* UnknownFieldSet::AddGroup(int number) { - if (fields_ == NULL) fields_ = new vector; - UnknownField field; - field.number_ = number; - field.type_ = UnknownField::TYPE_GROUP; - field.group_ = new UnknownFieldSet; - fields_->push_back(field); - return field.group_; -} - -void UnknownFieldSet::AddField(const UnknownField& field) { - if (fields_ == NULL) fields_ = new vector; - fields_->push_back(field); - fields_->back().DeepCopy(); -} - -void UnknownFieldSet::DeleteSubrange(int start, int num) { - GOOGLE_DCHECK(fields_ != NULL); - // Delete the specified fields. - for (int i = 0; i < num; ++i) { - (*fields_)[i + start].Delete(); - } - // Slide down the remaining fields. - for (int i = start + num; i < fields_->size(); ++i) { - (*fields_)[i - num] = (*fields_)[i]; - } - // Pop off the # of deleted fields. - for (int i = 0; i < num; ++i) { - fields_->pop_back(); - } -} - -void UnknownFieldSet::DeleteByNumber(int number) { - if (fields_ == NULL) return; - int left = 0; // The number of fields left after deletion. - for (int i = 0; i < fields_->size(); ++i) { - UnknownField* field = &(*fields_)[i]; - if (field->number() == number) { - field->Delete(); - } else { - if (i != left) { - (*fields_)[left] = (*fields_)[i]; - } - ++left; - } - } - fields_->resize(left); -} - -bool UnknownFieldSet::MergeFromCodedStream(io::CodedInputStream* input) { - - UnknownFieldSet other; - if (internal::WireFormat::SkipMessage(input, &other) && - input->ConsumedEntireMessage()) { - MergeFrom(other); - return true; - } else { - return false; - } -} - -bool UnknownFieldSet::ParseFromCodedStream(io::CodedInputStream* input) { - Clear(); - return MergeFromCodedStream(input); -} - -bool UnknownFieldSet::ParseFromZeroCopyStream(io::ZeroCopyInputStream* input) { - io::CodedInputStream coded_input(input); - return ParseFromCodedStream(&coded_input) && - coded_input.ConsumedEntireMessage(); -} - -bool UnknownFieldSet::ParseFromArray(const void* data, int size) { - io::ArrayInputStream input(data, size); - return ParseFromZeroCopyStream(&input); -} - -void UnknownField::Delete() { - switch (type()) { - case UnknownField::TYPE_LENGTH_DELIMITED: - delete length_delimited_.string_value_; - break; - case UnknownField::TYPE_GROUP: - delete group_; - break; - default: - break; - } -} - -void UnknownField::DeepCopy() { - switch (type()) { - case UnknownField::TYPE_LENGTH_DELIMITED: - length_delimited_.string_value_ = new string( - *length_delimited_.string_value_); - break; - case UnknownField::TYPE_GROUP: { - UnknownFieldSet* group = new UnknownFieldSet; - group->MergeFrom(*group_); - group_ = group; - break; - } - default: - break; - } -} - - -void UnknownField::SerializeLengthDelimitedNoTag( - io::CodedOutputStream* output) const { - GOOGLE_DCHECK_EQ(TYPE_LENGTH_DELIMITED, type_); - const string& data = *length_delimited_.string_value_; - output->WriteVarint32(data.size()); - output->WriteString(data); -} - -uint8* UnknownField::SerializeLengthDelimitedNoTagToArray(uint8* target) const { - GOOGLE_DCHECK_EQ(TYPE_LENGTH_DELIMITED, type_); - const string& data = *length_delimited_.string_value_; - target = io::CodedOutputStream::WriteVarint32ToArray(data.size(), target); - target = io::CodedOutputStream::WriteStringToArray(data, target); - return target; -} - -} // namespace protobuf -} // namespace google diff --git a/modules/dnn/3rdparty/protobuf/src/google/protobuf/unknown_field_set.h b/modules/dnn/3rdparty/protobuf/src/google/protobuf/unknown_field_set.h deleted file mode 100644 index 825bba83a..000000000 --- a/modules/dnn/3rdparty/protobuf/src/google/protobuf/unknown_field_set.h +++ /dev/null @@ -1,311 +0,0 @@ -// Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// http://code.google.com/p/protobuf/ -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -// Author: kenton@google.com (Kenton Varda) -// Based on original Protocol Buffers design by -// Sanjay Ghemawat, Jeff Dean, and others. -// -// Contains classes used to keep track of unrecognized fields seen while -// parsing a protocol message. - -#ifndef GOOGLE_PROTOBUF_UNKNOWN_FIELD_SET_H__ -#define GOOGLE_PROTOBUF_UNKNOWN_FIELD_SET_H__ - -#include -#include -#include -#include -// TODO(jasonh): some people seem to rely on protobufs to include this for them! - -namespace google { -namespace protobuf { - namespace io { - class CodedInputStream; // coded_stream.h - class CodedOutputStream; // coded_stream.h - class ZeroCopyInputStream; // zero_copy_stream.h - } - namespace internal { - class WireFormat; // wire_format.h - class UnknownFieldSetFieldSkipperUsingCord; - // extension_set_heavy.cc - } - -class Message; // message.h -class UnknownField; // below - -// An UnknownFieldSet contains fields that were encountered while parsing a -// message but were not defined by its type. Keeping track of these can be -// useful, especially in that they may be written if the message is serialized -// again without being cleared in between. This means that software which -// simply receives messages and forwards them to other servers does not need -// to be updated every time a new field is added to the message definition. -// -// To get the UnknownFieldSet attached to any message, call -// Reflection::GetUnknownFields(). -// -// This class is necessarily tied to the protocol buffer wire format, unlike -// the Reflection interface which is independent of any serialization scheme. -class LIBPROTOBUF_EXPORT UnknownFieldSet { - public: - UnknownFieldSet(); - ~UnknownFieldSet(); - - // Remove all fields. - inline void Clear(); - - // Remove all fields and deallocate internal data objects - void ClearAndFreeMemory(); - - // Is this set empty? - inline bool empty() const; - - // Merge the contents of some other UnknownFieldSet with this one. - void MergeFrom(const UnknownFieldSet& other); - - // Swaps the contents of some other UnknownFieldSet with this one. - inline void Swap(UnknownFieldSet* x); - - // Computes (an estimate of) the total number of bytes currently used for - // storing the unknown fields in memory. Does NOT include - // sizeof(*this) in the calculation. - int SpaceUsedExcludingSelf() const; - - // Version of SpaceUsed() including sizeof(*this). - int SpaceUsed() const; - - // Returns the number of fields present in the UnknownFieldSet. - inline int field_count() const; - // Get a field in the set, where 0 <= index < field_count(). The fields - // appear in the order in which they were added. - inline const UnknownField& field(int index) const; - // Get a mutable pointer to a field in the set, where - // 0 <= index < field_count(). The fields appear in the order in which - // they were added. - inline UnknownField* mutable_field(int index); - - // Adding fields --------------------------------------------------- - - void AddVarint(int number, uint64 value); - void AddFixed32(int number, uint32 value); - void AddFixed64(int number, uint64 value); - void AddLengthDelimited(int number, const string& value); - string* AddLengthDelimited(int number); - UnknownFieldSet* AddGroup(int number); - - // Adds an unknown field from another set. - void AddField(const UnknownField& field); - - // Delete fields with indices in the range [start .. start+num-1]. - // Caution: implementation moves all fields with indices [start+num .. ]. - void DeleteSubrange(int start, int num); - - // Delete all fields with a specific field number. The order of left fields - // is preserved. - // Caution: implementation moves all fields after the first deleted field. - void DeleteByNumber(int number); - - // Parsing helpers ------------------------------------------------- - // These work exactly like the similarly-named methods of Message. - - bool MergeFromCodedStream(io::CodedInputStream* input); - bool ParseFromCodedStream(io::CodedInputStream* input); - bool ParseFromZeroCopyStream(io::ZeroCopyInputStream* input); - bool ParseFromArray(const void* data, int size); - inline bool ParseFromString(const string& data) { - return ParseFromArray(data.data(), data.size()); - } - - private: - - void ClearFallback(); - - vector* fields_; - - GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(UnknownFieldSet); -}; - -// Represents one field in an UnknownFieldSet. -class LIBPROTOBUF_EXPORT UnknownField { - public: - enum Type { - TYPE_VARINT, - TYPE_FIXED32, - TYPE_FIXED64, - TYPE_LENGTH_DELIMITED, - TYPE_GROUP - }; - - // The field's tag number, as seen on the wire. - inline int number() const; - - // The field type. - inline Type type() const; - - // Accessors ------------------------------------------------------- - // Each method works only for UnknownFields of the corresponding type. - - inline uint64 varint() const; - inline uint32 fixed32() const; - inline uint64 fixed64() const; - inline const string& length_delimited() const; - inline const UnknownFieldSet& group() const; - - inline void set_varint(uint64 value); - inline void set_fixed32(uint32 value); - inline void set_fixed64(uint64 value); - inline void set_length_delimited(const string& value); - inline string* mutable_length_delimited(); - inline UnknownFieldSet* mutable_group(); - - // Serialization API. - // These methods can take advantage of the underlying implementation and may - // archieve a better performance than using getters to retrieve the data and - // do the serialization yourself. - void SerializeLengthDelimitedNoTag(io::CodedOutputStream* output) const; - uint8* SerializeLengthDelimitedNoTagToArray(uint8* target) const; - - inline int GetLengthDelimitedSize() const; - - private: - friend class UnknownFieldSet; - - // If this UnknownField contains a pointer, delete it. - void Delete(); - - // Make a deep copy of any pointers in this UnknownField. - void DeepCopy(); - - - unsigned int number_ : 29; - unsigned int type_ : 3; - union { - uint64 varint_; - uint32 fixed32_; - uint64 fixed64_; - mutable union { - string* string_value_; - } length_delimited_; - UnknownFieldSet* group_; - }; -}; - -// =================================================================== -// inline implementations - -inline void UnknownFieldSet::Clear() { - if (fields_ != NULL) { - ClearFallback(); - } -} - -inline bool UnknownFieldSet::empty() const { - return fields_ == NULL || fields_->empty(); -} - -inline void UnknownFieldSet::Swap(UnknownFieldSet* x) { - std::swap(fields_, x->fields_); -} - -inline int UnknownFieldSet::field_count() const { - return (fields_ == NULL) ? 0 : fields_->size(); -} -inline const UnknownField& UnknownFieldSet::field(int index) const { - return (*fields_)[index]; -} -inline UnknownField* UnknownFieldSet::mutable_field(int index) { - return &(*fields_)[index]; -} - -inline void UnknownFieldSet::AddLengthDelimited( - int number, const string& value) { - AddLengthDelimited(number)->assign(value); -} - - -inline int UnknownField::number() const { return number_; } -inline UnknownField::Type UnknownField::type() const { - return static_cast(type_); -} - -inline uint64 UnknownField::varint () const { - assert(type_ == TYPE_VARINT); - return varint_; -} -inline uint32 UnknownField::fixed32() const { - assert(type_ == TYPE_FIXED32); - return fixed32_; -} -inline uint64 UnknownField::fixed64() const { - assert(type_ == TYPE_FIXED64); - return fixed64_; -} -inline const string& UnknownField::length_delimited() const { - assert(type_ == TYPE_LENGTH_DELIMITED); - return *length_delimited_.string_value_; -} -inline const UnknownFieldSet& UnknownField::group() const { - assert(type_ == TYPE_GROUP); - return *group_; -} - -inline void UnknownField::set_varint(uint64 value) { - assert(type_ == TYPE_VARINT); - varint_ = value; -} -inline void UnknownField::set_fixed32(uint32 value) { - assert(type_ == TYPE_FIXED32); - fixed32_ = value; -} -inline void UnknownField::set_fixed64(uint64 value) { - assert(type_ == TYPE_FIXED64); - fixed64_ = value; -} -inline void UnknownField::set_length_delimited(const string& value) { - assert(type_ == TYPE_LENGTH_DELIMITED); - length_delimited_.string_value_->assign(value); -} -inline string* UnknownField::mutable_length_delimited() { - assert(type_ == TYPE_LENGTH_DELIMITED); - return length_delimited_.string_value_; -} -inline UnknownFieldSet* UnknownField::mutable_group() { - assert(type_ == TYPE_GROUP); - return group_; -} - -inline int UnknownField::GetLengthDelimitedSize() const { - GOOGLE_DCHECK_EQ(TYPE_LENGTH_DELIMITED, type_); - return length_delimited_.string_value_->size(); -} - -} // namespace protobuf - -} // namespace google -#endif // GOOGLE_PROTOBUF_UNKNOWN_FIELD_SET_H__ diff --git a/modules/dnn/3rdparty/protobuf/src/google/protobuf/unknown_field_set_unittest.cc b/modules/dnn/3rdparty/protobuf/src/google/protobuf/unknown_field_set_unittest.cc deleted file mode 100644 index c6b8769f3..000000000 --- a/modules/dnn/3rdparty/protobuf/src/google/protobuf/unknown_field_set_unittest.cc +++ /dev/null @@ -1,594 +0,0 @@ -// Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// http://code.google.com/p/protobuf/ -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -// Author: kenton@google.com (Kenton Varda) -// Based on original Protocol Buffers design by -// Sanjay Ghemawat, Jeff Dean, and others. -// -// This test is testing a lot more than just the UnknownFieldSet class. It -// tests handling of unknown fields throughout the system. - -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include - -namespace google { -namespace protobuf { - -using internal::WireFormat; - -class UnknownFieldSetTest : public testing::Test { - protected: - virtual void SetUp() { - descriptor_ = unittest::TestAllTypes::descriptor(); - TestUtil::SetAllFields(&all_fields_); - all_fields_.SerializeToString(&all_fields_data_); - ASSERT_TRUE(empty_message_.ParseFromString(all_fields_data_)); - unknown_fields_ = empty_message_.mutable_unknown_fields(); - } - - const UnknownField* GetField(const string& name) { - const FieldDescriptor* field = descriptor_->FindFieldByName(name); - if (field == NULL) return NULL; - for (int i = 0; i < unknown_fields_->field_count(); i++) { - if (unknown_fields_->field(i).number() == field->number()) { - return &unknown_fields_->field(i); - } - } - return NULL; - } - - // Constructs a protocol buffer which contains fields with all the same - // numbers as all_fields_data_ except that each field is some other wire - // type. - string GetBizarroData() { - unittest::TestEmptyMessage bizarro_message; - UnknownFieldSet* bizarro_unknown_fields = - bizarro_message.mutable_unknown_fields(); - for (int i = 0; i < unknown_fields_->field_count(); i++) { - const UnknownField& unknown_field = unknown_fields_->field(i); - if (unknown_field.type() == UnknownField::TYPE_VARINT) { - bizarro_unknown_fields->AddFixed32(unknown_field.number(), 1); - } else { - bizarro_unknown_fields->AddVarint(unknown_field.number(), 1); - } - } - - string data; - EXPECT_TRUE(bizarro_message.SerializeToString(&data)); - return data; - } - - const Descriptor* descriptor_; - unittest::TestAllTypes all_fields_; - string all_fields_data_; - - // An empty message that has been parsed from all_fields_data_. So, it has - // unknown fields of every type. - unittest::TestEmptyMessage empty_message_; - UnknownFieldSet* unknown_fields_; -}; - -namespace { - -TEST_F(UnknownFieldSetTest, AllFieldsPresent) { - // All fields of TestAllTypes should be present, in numeric order (because - // that's the order we parsed them in). Fields that are not valid field - // numbers of TestAllTypes should NOT be present. - - int pos = 0; - - for (int i = 0; i < 1000; i++) { - const FieldDescriptor* field = descriptor_->FindFieldByNumber(i); - if (field != NULL) { - ASSERT_LT(pos, unknown_fields_->field_count()); - EXPECT_EQ(i, unknown_fields_->field(pos++).number()); - if (field->is_repeated()) { - // Should have a second instance. - ASSERT_LT(pos, unknown_fields_->field_count()); - EXPECT_EQ(i, unknown_fields_->field(pos++).number()); - } - } - } - EXPECT_EQ(unknown_fields_->field_count(), pos); -} - -TEST_F(UnknownFieldSetTest, Varint) { - const UnknownField* field = GetField("optional_int32"); - ASSERT_TRUE(field != NULL); - - ASSERT_EQ(UnknownField::TYPE_VARINT, field->type()); - EXPECT_EQ(all_fields_.optional_int32(), field->varint()); -} - -TEST_F(UnknownFieldSetTest, Fixed32) { - const UnknownField* field = GetField("optional_fixed32"); - ASSERT_TRUE(field != NULL); - - ASSERT_EQ(UnknownField::TYPE_FIXED32, field->type()); - EXPECT_EQ(all_fields_.optional_fixed32(), field->fixed32()); -} - -TEST_F(UnknownFieldSetTest, Fixed64) { - const UnknownField* field = GetField("optional_fixed64"); - ASSERT_TRUE(field != NULL); - - ASSERT_EQ(UnknownField::TYPE_FIXED64, field->type()); - EXPECT_EQ(all_fields_.optional_fixed64(), field->fixed64()); -} - -TEST_F(UnknownFieldSetTest, LengthDelimited) { - const UnknownField* field = GetField("optional_string"); - ASSERT_TRUE(field != NULL); - - ASSERT_EQ(UnknownField::TYPE_LENGTH_DELIMITED, field->type()); - EXPECT_EQ(all_fields_.optional_string(), field->length_delimited()); -} - -TEST_F(UnknownFieldSetTest, Group) { - const UnknownField* field = GetField("optionalgroup"); - ASSERT_TRUE(field != NULL); - - ASSERT_EQ(UnknownField::TYPE_GROUP, field->type()); - ASSERT_EQ(1, field->group().field_count()); - - const UnknownField& nested_field = field->group().field(0); - const FieldDescriptor* nested_field_descriptor = - unittest::TestAllTypes::OptionalGroup::descriptor()->FindFieldByName("a"); - ASSERT_TRUE(nested_field_descriptor != NULL); - - EXPECT_EQ(nested_field_descriptor->number(), nested_field.number()); - ASSERT_EQ(UnknownField::TYPE_VARINT, nested_field.type()); - EXPECT_EQ(all_fields_.optionalgroup().a(), nested_field.varint()); -} - -TEST_F(UnknownFieldSetTest, SerializeFastAndSlowAreEquivalent) { - int size = WireFormat::ComputeUnknownFieldsSize( - empty_message_.unknown_fields()); - string slow_buffer; - string fast_buffer; - slow_buffer.resize(size); - fast_buffer.resize(size); - - uint8* target = reinterpret_cast(string_as_array(&fast_buffer)); - uint8* result = WireFormat::SerializeUnknownFieldsToArray( - empty_message_.unknown_fields(), target); - EXPECT_EQ(size, result - target); - - { - io::ArrayOutputStream raw_stream(string_as_array(&slow_buffer), size, 1); - io::CodedOutputStream output_stream(&raw_stream); - WireFormat::SerializeUnknownFields(empty_message_.unknown_fields(), - &output_stream); - ASSERT_FALSE(output_stream.HadError()); - } - EXPECT_TRUE(fast_buffer == slow_buffer); -} - -TEST_F(UnknownFieldSetTest, Serialize) { - // Check that serializing the UnknownFieldSet produces the original data - // again. - - string data; - empty_message_.SerializeToString(&data); - - // Don't use EXPECT_EQ because we don't want to dump raw binary data to - // stdout. - EXPECT_TRUE(data == all_fields_data_); -} - -TEST_F(UnknownFieldSetTest, ParseViaReflection) { - // Make sure fields are properly parsed to the UnknownFieldSet when parsing - // via reflection. - - unittest::TestEmptyMessage message; - io::ArrayInputStream raw_input(all_fields_data_.data(), - all_fields_data_.size()); - io::CodedInputStream input(&raw_input); - ASSERT_TRUE(WireFormat::ParseAndMergePartial(&input, &message)); - - EXPECT_EQ(message.DebugString(), empty_message_.DebugString()); -} - -TEST_F(UnknownFieldSetTest, SerializeViaReflection) { - // Make sure fields are properly written from the UnknownFieldSet when - // serializing via reflection. - - string data; - - { - io::StringOutputStream raw_output(&data); - io::CodedOutputStream output(&raw_output); - int size = WireFormat::ByteSize(empty_message_); - WireFormat::SerializeWithCachedSizes(empty_message_, size, &output); - ASSERT_FALSE(output.HadError()); - } - - // Don't use EXPECT_EQ because we don't want to dump raw binary data to - // stdout. - EXPECT_TRUE(data == all_fields_data_); -} - -TEST_F(UnknownFieldSetTest, CopyFrom) { - unittest::TestEmptyMessage message; - - message.CopyFrom(empty_message_); - - EXPECT_EQ(empty_message_.DebugString(), message.DebugString()); -} - -TEST_F(UnknownFieldSetTest, Swap) { - unittest::TestEmptyMessage other_message; - ASSERT_TRUE(other_message.ParseFromString(GetBizarroData())); - - EXPECT_GT(empty_message_.unknown_fields().field_count(), 0); - EXPECT_GT(other_message.unknown_fields().field_count(), 0); - const string debug_string = empty_message_.DebugString(); - const string other_debug_string = other_message.DebugString(); - EXPECT_NE(debug_string, other_debug_string); - - empty_message_.Swap(&other_message); - EXPECT_EQ(debug_string, other_message.DebugString()); - EXPECT_EQ(other_debug_string, empty_message_.DebugString()); -} - -TEST_F(UnknownFieldSetTest, SwapWithSelf) { - const string debug_string = empty_message_.DebugString(); - EXPECT_GT(empty_message_.unknown_fields().field_count(), 0); - - empty_message_.Swap(&empty_message_); - EXPECT_GT(empty_message_.unknown_fields().field_count(), 0); - EXPECT_EQ(debug_string, empty_message_.DebugString()); -} - -TEST_F(UnknownFieldSetTest, MergeFrom) { - unittest::TestEmptyMessage source, destination; - - destination.mutable_unknown_fields()->AddVarint(1, 1); - destination.mutable_unknown_fields()->AddVarint(3, 2); - source.mutable_unknown_fields()->AddVarint(2, 3); - source.mutable_unknown_fields()->AddVarint(3, 4); - - destination.MergeFrom(source); - - EXPECT_EQ( - // Note: The ordering of fields here depends on the ordering of adds - // and merging, above. - "1: 1\n" - "3: 2\n" - "2: 3\n" - "3: 4\n", - destination.DebugString()); -} - - -TEST_F(UnknownFieldSetTest, Clear) { - // Clear the set. - empty_message_.Clear(); - EXPECT_EQ(0, unknown_fields_->field_count()); -} - -TEST_F(UnknownFieldSetTest, ClearAndFreeMemory) { - EXPECT_GT(unknown_fields_->field_count(), 0); - unknown_fields_->ClearAndFreeMemory(); - EXPECT_EQ(0, unknown_fields_->field_count()); - unknown_fields_->AddVarint(123456, 654321); - EXPECT_EQ(1, unknown_fields_->field_count()); -} - -TEST_F(UnknownFieldSetTest, ParseKnownAndUnknown) { - // Test mixing known and unknown fields when parsing. - - unittest::TestEmptyMessage source; - source.mutable_unknown_fields()->AddVarint(123456, 654321); - string data; - ASSERT_TRUE(source.SerializeToString(&data)); - - unittest::TestAllTypes destination; - ASSERT_TRUE(destination.ParseFromString(all_fields_data_ + data)); - - TestUtil::ExpectAllFieldsSet(destination); - ASSERT_EQ(1, destination.unknown_fields().field_count()); - ASSERT_EQ(UnknownField::TYPE_VARINT, - destination.unknown_fields().field(0).type()); - EXPECT_EQ(654321, destination.unknown_fields().field(0).varint()); -} - -TEST_F(UnknownFieldSetTest, WrongTypeTreatedAsUnknown) { - // Test that fields of the wrong wire type are treated like unknown fields - // when parsing. - - unittest::TestAllTypes all_types_message; - unittest::TestEmptyMessage empty_message; - string bizarro_data = GetBizarroData(); - ASSERT_TRUE(all_types_message.ParseFromString(bizarro_data)); - ASSERT_TRUE(empty_message.ParseFromString(bizarro_data)); - - // All fields should have been interpreted as unknown, so the debug strings - // should be the same. - EXPECT_EQ(empty_message.DebugString(), all_types_message.DebugString()); -} - -TEST_F(UnknownFieldSetTest, WrongTypeTreatedAsUnknownViaReflection) { - // Same as WrongTypeTreatedAsUnknown but via the reflection interface. - - unittest::TestAllTypes all_types_message; - unittest::TestEmptyMessage empty_message; - string bizarro_data = GetBizarroData(); - io::ArrayInputStream raw_input(bizarro_data.data(), bizarro_data.size()); - io::CodedInputStream input(&raw_input); - ASSERT_TRUE(WireFormat::ParseAndMergePartial(&input, &all_types_message)); - ASSERT_TRUE(empty_message.ParseFromString(bizarro_data)); - - EXPECT_EQ(empty_message.DebugString(), all_types_message.DebugString()); -} - -TEST_F(UnknownFieldSetTest, UnknownExtensions) { - // Make sure fields are properly parsed to the UnknownFieldSet even when - // they are declared as extension numbers. - - unittest::TestEmptyMessageWithExtensions message; - ASSERT_TRUE(message.ParseFromString(all_fields_data_)); - - EXPECT_EQ(message.DebugString(), empty_message_.DebugString()); -} - -TEST_F(UnknownFieldSetTest, UnknownExtensionsReflection) { - // Same as UnknownExtensions except parsing via reflection. - - unittest::TestEmptyMessageWithExtensions message; - io::ArrayInputStream raw_input(all_fields_data_.data(), - all_fields_data_.size()); - io::CodedInputStream input(&raw_input); - ASSERT_TRUE(WireFormat::ParseAndMergePartial(&input, &message)); - - EXPECT_EQ(message.DebugString(), empty_message_.DebugString()); -} - -TEST_F(UnknownFieldSetTest, WrongExtensionTypeTreatedAsUnknown) { - // Test that fields of the wrong wire type are treated like unknown fields - // when parsing extensions. - - unittest::TestAllExtensions all_extensions_message; - unittest::TestEmptyMessage empty_message; - string bizarro_data = GetBizarroData(); - ASSERT_TRUE(all_extensions_message.ParseFromString(bizarro_data)); - ASSERT_TRUE(empty_message.ParseFromString(bizarro_data)); - - // All fields should have been interpreted as unknown, so the debug strings - // should be the same. - EXPECT_EQ(empty_message.DebugString(), all_extensions_message.DebugString()); -} - -TEST_F(UnknownFieldSetTest, UnknownEnumValue) { - using unittest::TestAllTypes; - using unittest::TestAllExtensions; - using unittest::TestEmptyMessage; - - const FieldDescriptor* singular_field = - TestAllTypes::descriptor()->FindFieldByName("optional_nested_enum"); - const FieldDescriptor* repeated_field = - TestAllTypes::descriptor()->FindFieldByName("repeated_nested_enum"); - ASSERT_TRUE(singular_field != NULL); - ASSERT_TRUE(repeated_field != NULL); - - string data; - - { - TestEmptyMessage empty_message; - UnknownFieldSet* unknown_fields = empty_message.mutable_unknown_fields(); - unknown_fields->AddVarint(singular_field->number(), TestAllTypes::BAR); - unknown_fields->AddVarint(singular_field->number(), 5); // not valid - unknown_fields->AddVarint(repeated_field->number(), TestAllTypes::FOO); - unknown_fields->AddVarint(repeated_field->number(), 4); // not valid - unknown_fields->AddVarint(repeated_field->number(), TestAllTypes::BAZ); - unknown_fields->AddVarint(repeated_field->number(), 6); // not valid - empty_message.SerializeToString(&data); - } - - { - TestAllTypes message; - ASSERT_TRUE(message.ParseFromString(data)); - EXPECT_EQ(TestAllTypes::BAR, message.optional_nested_enum()); - ASSERT_EQ(2, message.repeated_nested_enum_size()); - EXPECT_EQ(TestAllTypes::FOO, message.repeated_nested_enum(0)); - EXPECT_EQ(TestAllTypes::BAZ, message.repeated_nested_enum(1)); - - const UnknownFieldSet& unknown_fields = message.unknown_fields(); - ASSERT_EQ(3, unknown_fields.field_count()); - - EXPECT_EQ(singular_field->number(), unknown_fields.field(0).number()); - ASSERT_EQ(UnknownField::TYPE_VARINT, unknown_fields.field(0).type()); - EXPECT_EQ(5, unknown_fields.field(0).varint()); - - EXPECT_EQ(repeated_field->number(), unknown_fields.field(1).number()); - ASSERT_EQ(UnknownField::TYPE_VARINT, unknown_fields.field(1).type()); - EXPECT_EQ(4, unknown_fields.field(1).varint()); - - EXPECT_EQ(repeated_field->number(), unknown_fields.field(2).number()); - ASSERT_EQ(UnknownField::TYPE_VARINT, unknown_fields.field(2).type()); - EXPECT_EQ(6, unknown_fields.field(2).varint()); - } - - { - using unittest::optional_nested_enum_extension; - using unittest::repeated_nested_enum_extension; - - TestAllExtensions message; - ASSERT_TRUE(message.ParseFromString(data)); - EXPECT_EQ(TestAllTypes::BAR, - message.GetExtension(optional_nested_enum_extension)); - ASSERT_EQ(2, message.ExtensionSize(repeated_nested_enum_extension)); - EXPECT_EQ(TestAllTypes::FOO, - message.GetExtension(repeated_nested_enum_extension, 0)); - EXPECT_EQ(TestAllTypes::BAZ, - message.GetExtension(repeated_nested_enum_extension, 1)); - - const UnknownFieldSet& unknown_fields = message.unknown_fields(); - ASSERT_EQ(3, unknown_fields.field_count()); - - EXPECT_EQ(singular_field->number(), unknown_fields.field(0).number()); - ASSERT_EQ(UnknownField::TYPE_VARINT, unknown_fields.field(0).type()); - EXPECT_EQ(5, unknown_fields.field(0).varint()); - - EXPECT_EQ(repeated_field->number(), unknown_fields.field(1).number()); - ASSERT_EQ(UnknownField::TYPE_VARINT, unknown_fields.field(1).type()); - EXPECT_EQ(4, unknown_fields.field(1).varint()); - - EXPECT_EQ(repeated_field->number(), unknown_fields.field(2).number()); - ASSERT_EQ(UnknownField::TYPE_VARINT, unknown_fields.field(2).type()); - EXPECT_EQ(6, unknown_fields.field(2).varint()); - } -} - -TEST_F(UnknownFieldSetTest, SpaceUsed) { - unittest::TestEmptyMessage empty_message; - - // Make sure an unknown field set has zero space used until a field is - // actually added. - int base_size = empty_message.SpaceUsed(); - UnknownFieldSet* unknown_fields = empty_message.mutable_unknown_fields(); - EXPECT_EQ(base_size, empty_message.SpaceUsed()); - - // Make sure each thing we add to the set increases the SpaceUsed(). - unknown_fields->AddVarint(1, 0); - EXPECT_LT(base_size, empty_message.SpaceUsed()); - base_size = empty_message.SpaceUsed(); - - string* str = unknown_fields->AddLengthDelimited(1); - EXPECT_LT(base_size, empty_message.SpaceUsed()); - base_size = empty_message.SpaceUsed(); - - str->assign(sizeof(string) + 1, 'x'); - EXPECT_LT(base_size, empty_message.SpaceUsed()); - base_size = empty_message.SpaceUsed(); - - UnknownFieldSet* group = unknown_fields->AddGroup(1); - EXPECT_LT(base_size, empty_message.SpaceUsed()); - base_size = empty_message.SpaceUsed(); - - group->AddVarint(1, 0); - EXPECT_LT(base_size, empty_message.SpaceUsed()); -} - - -TEST_F(UnknownFieldSetTest, Empty) { - UnknownFieldSet unknown_fields; - EXPECT_TRUE(unknown_fields.empty()); - unknown_fields.AddVarint(6, 123); - EXPECT_FALSE(unknown_fields.empty()); - unknown_fields.Clear(); - EXPECT_TRUE(unknown_fields.empty()); -} - -TEST_F(UnknownFieldSetTest, DeleteSubrange) { - // Exhaustively test the deletion of every possible subrange in arrays of all - // sizes from 0 through 9. - for (int size = 0; size < 10; ++size) { - for (int num = 0; num <= size; ++num) { - for (int start = 0; start < size - num; ++start) { - // Create a set with "size" fields. - UnknownFieldSet unknown; - for (int i = 0; i < size; ++i) { - unknown.AddFixed32(i, i); - } - // Delete the specified subrange. - unknown.DeleteSubrange(start, num); - // Make sure the resulting field values are still correct. - EXPECT_EQ(size - num, unknown.field_count()); - for (int i = 0; i < unknown.field_count(); ++i) { - if (i < start) { - EXPECT_EQ(i, unknown.field(i).fixed32()); - } else { - EXPECT_EQ(i + num, unknown.field(i).fixed32()); - } - } - } - } - } -} - -void CheckDeleteByNumber(const vector& field_numbers, int deleted_number, - const vector& expected_field_nubmers) { - UnknownFieldSet unknown_fields; - for (int i = 0; i < field_numbers.size(); ++i) { - unknown_fields.AddFixed32(field_numbers[i], i); - } - unknown_fields.DeleteByNumber(deleted_number); - ASSERT_EQ(expected_field_nubmers.size(), unknown_fields.field_count()); - for (int i = 0; i < expected_field_nubmers.size(); ++i) { - EXPECT_EQ(expected_field_nubmers[i], - unknown_fields.field(i).number()); - } -} - -#define MAKE_VECTOR(x) vector(x, x + GOOGLE_ARRAYSIZE(x)) -TEST_F(UnknownFieldSetTest, DeleteByNumber) { - CheckDeleteByNumber(vector(), 1, vector()); - static const int kTestFieldNumbers1[] = {1, 2, 3}; - static const int kFieldNumberToDelete1 = 1; - static const int kExpectedFieldNumbers1[] = {2, 3}; - CheckDeleteByNumber(MAKE_VECTOR(kTestFieldNumbers1), kFieldNumberToDelete1, - MAKE_VECTOR(kExpectedFieldNumbers1)); - static const int kTestFieldNumbers2[] = {1, 2, 3}; - static const int kFieldNumberToDelete2 = 2; - static const int kExpectedFieldNumbers2[] = {1, 3}; - CheckDeleteByNumber(MAKE_VECTOR(kTestFieldNumbers2), kFieldNumberToDelete2, - MAKE_VECTOR(kExpectedFieldNumbers2)); - static const int kTestFieldNumbers3[] = {1, 2, 3}; - static const int kFieldNumberToDelete3 = 3; - static const int kExpectedFieldNumbers3[] = {1, 2}; - CheckDeleteByNumber(MAKE_VECTOR(kTestFieldNumbers3), kFieldNumberToDelete3, - MAKE_VECTOR(kExpectedFieldNumbers3)); - static const int kTestFieldNumbers4[] = {1, 2, 1, 4, 1}; - static const int kFieldNumberToDelete4 = 1; - static const int kExpectedFieldNumbers4[] = {2, 4}; - CheckDeleteByNumber(MAKE_VECTOR(kTestFieldNumbers4), kFieldNumberToDelete4, - MAKE_VECTOR(kExpectedFieldNumbers4)); - static const int kTestFieldNumbers5[] = {1, 2, 3, 4, 5}; - static const int kFieldNumberToDelete5 = 6; - static const int kExpectedFieldNumbers5[] = {1, 2, 3, 4, 5}; - CheckDeleteByNumber(MAKE_VECTOR(kTestFieldNumbers5), kFieldNumberToDelete5, - MAKE_VECTOR(kExpectedFieldNumbers5)); -} -#undef MAKE_VECTOR -} // namespace - -} // namespace protobuf -} // namespace google diff --git a/modules/dnn/3rdparty/protobuf/src/google/protobuf/wire_format.cc b/modules/dnn/3rdparty/protobuf/src/google/protobuf/wire_format.cc deleted file mode 100644 index 7fe8e37ad..000000000 --- a/modules/dnn/3rdparty/protobuf/src/google/protobuf/wire_format.cc +++ /dev/null @@ -1,1054 +0,0 @@ -// Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// http://code.google.com/p/protobuf/ -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -// Author: kenton@google.com (Kenton Varda) -// Based on original Protocol Buffers design by -// Sanjay Ghemawat, Jeff Dean, and others. - -#include -#include -#include - -#include - -#include -#include -#include -#include -#include -#include -#include -#include - - - -namespace google { -namespace protobuf { -namespace internal { - -// =================================================================== - -bool UnknownFieldSetFieldSkipper::SkipField( - io::CodedInputStream* input, uint32 tag) { - return WireFormat::SkipField(input, tag, unknown_fields_); -} - -bool UnknownFieldSetFieldSkipper::SkipMessage(io::CodedInputStream* input) { - return WireFormat::SkipMessage(input, unknown_fields_); -} - -void UnknownFieldSetFieldSkipper::SkipUnknownEnum( - int field_number, int value) { - unknown_fields_->AddVarint(field_number, value); -} - -bool WireFormat::SkipField(io::CodedInputStream* input, uint32 tag, - UnknownFieldSet* unknown_fields) { - int number = WireFormatLite::GetTagFieldNumber(tag); - - switch (WireFormatLite::GetTagWireType(tag)) { - case WireFormatLite::WIRETYPE_VARINT: { - uint64 value; - if (!input->ReadVarint64(&value)) return false; - if (unknown_fields != NULL) unknown_fields->AddVarint(number, value); - return true; - } - case WireFormatLite::WIRETYPE_FIXED64: { - uint64 value; - if (!input->ReadLittleEndian64(&value)) return false; - if (unknown_fields != NULL) unknown_fields->AddFixed64(number, value); - return true; - } - case WireFormatLite::WIRETYPE_LENGTH_DELIMITED: { - uint32 length; - if (!input->ReadVarint32(&length)) return false; - if (unknown_fields == NULL) { - if (!input->Skip(length)) return false; - } else { - if (!input->ReadString(unknown_fields->AddLengthDelimited(number), - length)) { - return false; - } - } - return true; - } - case WireFormatLite::WIRETYPE_START_GROUP: { - if (!input->IncrementRecursionDepth()) return false; - if (!SkipMessage(input, (unknown_fields == NULL) ? - NULL : unknown_fields->AddGroup(number))) { - return false; - } - input->DecrementRecursionDepth(); - // Check that the ending tag matched the starting tag. - if (!input->LastTagWas(WireFormatLite::MakeTag( - WireFormatLite::GetTagFieldNumber(tag), - WireFormatLite::WIRETYPE_END_GROUP))) { - return false; - } - return true; - } - case WireFormatLite::WIRETYPE_END_GROUP: { - return false; - } - case WireFormatLite::WIRETYPE_FIXED32: { - uint32 value; - if (!input->ReadLittleEndian32(&value)) return false; - if (unknown_fields != NULL) unknown_fields->AddFixed32(number, value); - return true; - } - default: { - return false; - } - } -} - -bool WireFormat::SkipMessage(io::CodedInputStream* input, - UnknownFieldSet* unknown_fields) { - while(true) { - uint32 tag = input->ReadTag(); - if (tag == 0) { - // End of input. This is a valid place to end, so return true. - return true; - } - - WireFormatLite::WireType wire_type = WireFormatLite::GetTagWireType(tag); - - if (wire_type == WireFormatLite::WIRETYPE_END_GROUP) { - // Must be the end of the message. - return true; - } - - if (!SkipField(input, tag, unknown_fields)) return false; - } -} - -void WireFormat::SerializeUnknownFields(const UnknownFieldSet& unknown_fields, - io::CodedOutputStream* output) { - for (int i = 0; i < unknown_fields.field_count(); i++) { - const UnknownField& field = unknown_fields.field(i); - switch (field.type()) { - case UnknownField::TYPE_VARINT: - output->WriteVarint32(WireFormatLite::MakeTag(field.number(), - WireFormatLite::WIRETYPE_VARINT)); - output->WriteVarint64(field.varint()); - break; - case UnknownField::TYPE_FIXED32: - output->WriteVarint32(WireFormatLite::MakeTag(field.number(), - WireFormatLite::WIRETYPE_FIXED32)); - output->WriteLittleEndian32(field.fixed32()); - break; - case UnknownField::TYPE_FIXED64: - output->WriteVarint32(WireFormatLite::MakeTag(field.number(), - WireFormatLite::WIRETYPE_FIXED64)); - output->WriteLittleEndian64(field.fixed64()); - break; - case UnknownField::TYPE_LENGTH_DELIMITED: - output->WriteVarint32(WireFormatLite::MakeTag(field.number(), - WireFormatLite::WIRETYPE_LENGTH_DELIMITED)); - output->WriteVarint32(field.length_delimited().size()); - output->WriteString(field.length_delimited()); - break; - case UnknownField::TYPE_GROUP: - output->WriteVarint32(WireFormatLite::MakeTag(field.number(), - WireFormatLite::WIRETYPE_START_GROUP)); - SerializeUnknownFields(field.group(), output); - output->WriteVarint32(WireFormatLite::MakeTag(field.number(), - WireFormatLite::WIRETYPE_END_GROUP)); - break; - } - } -} - -uint8* WireFormat::SerializeUnknownFieldsToArray( - const UnknownFieldSet& unknown_fields, - uint8* target) { - for (int i = 0; i < unknown_fields.field_count(); i++) { - const UnknownField& field = unknown_fields.field(i); - - switch (field.type()) { - case UnknownField::TYPE_VARINT: - target = WireFormatLite::WriteInt64ToArray( - field.number(), field.varint(), target); - break; - case UnknownField::TYPE_FIXED32: - target = WireFormatLite::WriteFixed32ToArray( - field.number(), field.fixed32(), target); - break; - case UnknownField::TYPE_FIXED64: - target = WireFormatLite::WriteFixed64ToArray( - field.number(), field.fixed64(), target); - break; - case UnknownField::TYPE_LENGTH_DELIMITED: - target = WireFormatLite::WriteBytesToArray( - field.number(), field.length_delimited(), target); - break; - case UnknownField::TYPE_GROUP: - target = WireFormatLite::WriteTagToArray( - field.number(), WireFormatLite::WIRETYPE_START_GROUP, target); - target = SerializeUnknownFieldsToArray(field.group(), target); - target = WireFormatLite::WriteTagToArray( - field.number(), WireFormatLite::WIRETYPE_END_GROUP, target); - break; - } - } - return target; -} - -void WireFormat::SerializeUnknownMessageSetItems( - const UnknownFieldSet& unknown_fields, - io::CodedOutputStream* output) { - for (int i = 0; i < unknown_fields.field_count(); i++) { - const UnknownField& field = unknown_fields.field(i); - // The only unknown fields that are allowed to exist in a MessageSet are - // messages, which are length-delimited. - if (field.type() == UnknownField::TYPE_LENGTH_DELIMITED) { - // Start group. - output->WriteVarint32(WireFormatLite::kMessageSetItemStartTag); - - // Write type ID. - output->WriteVarint32(WireFormatLite::kMessageSetTypeIdTag); - output->WriteVarint32(field.number()); - - // Write message. - output->WriteVarint32(WireFormatLite::kMessageSetMessageTag); - field.SerializeLengthDelimitedNoTag(output); - - // End group. - output->WriteVarint32(WireFormatLite::kMessageSetItemEndTag); - } - } -} - -uint8* WireFormat::SerializeUnknownMessageSetItemsToArray( - const UnknownFieldSet& unknown_fields, - uint8* target) { - for (int i = 0; i < unknown_fields.field_count(); i++) { - const UnknownField& field = unknown_fields.field(i); - - // The only unknown fields that are allowed to exist in a MessageSet are - // messages, which are length-delimited. - if (field.type() == UnknownField::TYPE_LENGTH_DELIMITED) { - // Start group. - target = io::CodedOutputStream::WriteTagToArray( - WireFormatLite::kMessageSetItemStartTag, target); - - // Write type ID. - target = io::CodedOutputStream::WriteTagToArray( - WireFormatLite::kMessageSetTypeIdTag, target); - target = io::CodedOutputStream::WriteVarint32ToArray( - field.number(), target); - - // Write message. - target = io::CodedOutputStream::WriteTagToArray( - WireFormatLite::kMessageSetMessageTag, target); - target = field.SerializeLengthDelimitedNoTagToArray(target); - - // End group. - target = io::CodedOutputStream::WriteTagToArray( - WireFormatLite::kMessageSetItemEndTag, target); - } - } - - return target; -} - -int WireFormat::ComputeUnknownFieldsSize( - const UnknownFieldSet& unknown_fields) { - int size = 0; - for (int i = 0; i < unknown_fields.field_count(); i++) { - const UnknownField& field = unknown_fields.field(i); - - switch (field.type()) { - case UnknownField::TYPE_VARINT: - size += io::CodedOutputStream::VarintSize32( - WireFormatLite::MakeTag(field.number(), - WireFormatLite::WIRETYPE_VARINT)); - size += io::CodedOutputStream::VarintSize64(field.varint()); - break; - case UnknownField::TYPE_FIXED32: - size += io::CodedOutputStream::VarintSize32( - WireFormatLite::MakeTag(field.number(), - WireFormatLite::WIRETYPE_FIXED32)); - size += sizeof(int32); - break; - case UnknownField::TYPE_FIXED64: - size += io::CodedOutputStream::VarintSize32( - WireFormatLite::MakeTag(field.number(), - WireFormatLite::WIRETYPE_FIXED64)); - size += sizeof(int64); - break; - case UnknownField::TYPE_LENGTH_DELIMITED: - size += io::CodedOutputStream::VarintSize32( - WireFormatLite::MakeTag(field.number(), - WireFormatLite::WIRETYPE_LENGTH_DELIMITED)); - size += io::CodedOutputStream::VarintSize32( - field.length_delimited().size()); - size += field.length_delimited().size(); - break; - case UnknownField::TYPE_GROUP: - size += io::CodedOutputStream::VarintSize32( - WireFormatLite::MakeTag(field.number(), - WireFormatLite::WIRETYPE_START_GROUP)); - size += ComputeUnknownFieldsSize(field.group()); - size += io::CodedOutputStream::VarintSize32( - WireFormatLite::MakeTag(field.number(), - WireFormatLite::WIRETYPE_END_GROUP)); - break; - } - } - - return size; -} - -int WireFormat::ComputeUnknownMessageSetItemsSize( - const UnknownFieldSet& unknown_fields) { - int size = 0; - for (int i = 0; i < unknown_fields.field_count(); i++) { - const UnknownField& field = unknown_fields.field(i); - - // The only unknown fields that are allowed to exist in a MessageSet are - // messages, which are length-delimited. - if (field.type() == UnknownField::TYPE_LENGTH_DELIMITED) { - size += WireFormatLite::kMessageSetItemTagsSize; - size += io::CodedOutputStream::VarintSize32(field.number()); - - int field_size = field.GetLengthDelimitedSize(); - size += io::CodedOutputStream::VarintSize32(field_size); - size += field_size; - } - } - - return size; -} - -// =================================================================== - -bool WireFormat::ParseAndMergePartial(io::CodedInputStream* input, - Message* message) { - const Descriptor* descriptor = message->GetDescriptor(); - const Reflection* message_reflection = message->GetReflection(); - - while(true) { - uint32 tag = input->ReadTag(); - if (tag == 0) { - // End of input. This is a valid place to end, so return true. - return true; - } - - if (WireFormatLite::GetTagWireType(tag) == - WireFormatLite::WIRETYPE_END_GROUP) { - // Must be the end of the message. - return true; - } - - const FieldDescriptor* field = NULL; - - if (descriptor != NULL) { - int field_number = WireFormatLite::GetTagFieldNumber(tag); - field = descriptor->FindFieldByNumber(field_number); - - // If that failed, check if the field is an extension. - if (field == NULL && descriptor->IsExtensionNumber(field_number)) { - if (input->GetExtensionPool() == NULL) { - field = message_reflection->FindKnownExtensionByNumber(field_number); - } else { - field = input->GetExtensionPool() - ->FindExtensionByNumber(descriptor, field_number); - } - } - - // If that failed, but we're a MessageSet, and this is the tag for a - // MessageSet item, then parse that. - if (field == NULL && - descriptor->options().message_set_wire_format() && - tag == WireFormatLite::kMessageSetItemStartTag) { - if (!ParseAndMergeMessageSetItem(input, message)) { - return false; - } - continue; // Skip ParseAndMergeField(); already taken care of. - } - } - - if (!ParseAndMergeField(tag, field, message, input)) { - return false; - } - } -} - -bool WireFormat::ParseAndMergeField( - uint32 tag, - const FieldDescriptor* field, // May be NULL for unknown - Message* message, - io::CodedInputStream* input) { - const Reflection* message_reflection = message->GetReflection(); - - enum { UNKNOWN, NORMAL_FORMAT, PACKED_FORMAT } value_format; - - if (field == NULL) { - value_format = UNKNOWN; - } else if (WireFormatLite::GetTagWireType(tag) == - WireTypeForFieldType(field->type())) { - value_format = NORMAL_FORMAT; - } else if (field->is_packable() && - WireFormatLite::GetTagWireType(tag) == - WireFormatLite::WIRETYPE_LENGTH_DELIMITED) { - value_format = PACKED_FORMAT; - } else { - // We don't recognize this field. Either the field number is unknown - // or the wire type doesn't match. Put it in our unknown field set. - value_format = UNKNOWN; - } - - if (value_format == UNKNOWN) { - return SkipField(input, tag, - message_reflection->MutableUnknownFields(message)); - } else if (value_format == PACKED_FORMAT) { - uint32 length; - if (!input->ReadVarint32(&length)) return false; - io::CodedInputStream::Limit limit = input->PushLimit(length); - - switch (field->type()) { -#define HANDLE_PACKED_TYPE(TYPE, CPPTYPE, CPPTYPE_METHOD) \ - case FieldDescriptor::TYPE_##TYPE: { \ - while (input->BytesUntilLimit() > 0) { \ - CPPTYPE value; \ - if (!WireFormatLite::ReadPrimitive< \ - CPPTYPE, WireFormatLite::TYPE_##TYPE>(input, &value)) \ - return false; \ - message_reflection->Add##CPPTYPE_METHOD(message, field, value); \ - } \ - break; \ - } - - HANDLE_PACKED_TYPE( INT32, int32, Int32) - HANDLE_PACKED_TYPE( INT64, int64, Int64) - HANDLE_PACKED_TYPE(SINT32, int32, Int32) - HANDLE_PACKED_TYPE(SINT64, int64, Int64) - HANDLE_PACKED_TYPE(UINT32, uint32, UInt32) - HANDLE_PACKED_TYPE(UINT64, uint64, UInt64) - - HANDLE_PACKED_TYPE( FIXED32, uint32, UInt32) - HANDLE_PACKED_TYPE( FIXED64, uint64, UInt64) - HANDLE_PACKED_TYPE(SFIXED32, int32, Int32) - HANDLE_PACKED_TYPE(SFIXED64, int64, Int64) - - HANDLE_PACKED_TYPE(FLOAT , float , Float ) - HANDLE_PACKED_TYPE(DOUBLE, double, Double) - - HANDLE_PACKED_TYPE(BOOL, bool, Bool) -#undef HANDLE_PACKED_TYPE - - case FieldDescriptor::TYPE_ENUM: { - while (input->BytesUntilLimit() > 0) { - int value; - if (!WireFormatLite::ReadPrimitive( - input, &value)) return false; - const EnumValueDescriptor* enum_value = - field->enum_type()->FindValueByNumber(value); - if (enum_value != NULL) { - message_reflection->AddEnum(message, field, enum_value); - } - } - - break; - } - - case FieldDescriptor::TYPE_STRING: - case FieldDescriptor::TYPE_GROUP: - case FieldDescriptor::TYPE_MESSAGE: - case FieldDescriptor::TYPE_BYTES: - // Can't have packed fields of these types: these should be caught by - // the protocol compiler. - return false; - break; - } - - input->PopLimit(limit); - } else { - // Non-packed value (value_format == NORMAL_FORMAT) - switch (field->type()) { -#define HANDLE_TYPE(TYPE, CPPTYPE, CPPTYPE_METHOD) \ - case FieldDescriptor::TYPE_##TYPE: { \ - CPPTYPE value; \ - if (!WireFormatLite::ReadPrimitive< \ - CPPTYPE, WireFormatLite::TYPE_##TYPE>(input, &value)) \ - return false; \ - if (field->is_repeated()) { \ - message_reflection->Add##CPPTYPE_METHOD(message, field, value); \ - } else { \ - message_reflection->Set##CPPTYPE_METHOD(message, field, value); \ - } \ - break; \ - } - - HANDLE_TYPE( INT32, int32, Int32) - HANDLE_TYPE( INT64, int64, Int64) - HANDLE_TYPE(SINT32, int32, Int32) - HANDLE_TYPE(SINT64, int64, Int64) - HANDLE_TYPE(UINT32, uint32, UInt32) - HANDLE_TYPE(UINT64, uint64, UInt64) - - HANDLE_TYPE( FIXED32, uint32, UInt32) - HANDLE_TYPE( FIXED64, uint64, UInt64) - HANDLE_TYPE(SFIXED32, int32, Int32) - HANDLE_TYPE(SFIXED64, int64, Int64) - - HANDLE_TYPE(FLOAT , float , Float ) - HANDLE_TYPE(DOUBLE, double, Double) - - HANDLE_TYPE(BOOL, bool, Bool) -#undef HANDLE_TYPE - - case FieldDescriptor::TYPE_ENUM: { - int value; - if (!WireFormatLite::ReadPrimitive( - input, &value)) return false; - const EnumValueDescriptor* enum_value = - field->enum_type()->FindValueByNumber(value); - if (enum_value != NULL) { - if (field->is_repeated()) { - message_reflection->AddEnum(message, field, enum_value); - } else { - message_reflection->SetEnum(message, field, enum_value); - } - } else { - // The enum value is not one of the known values. Add it to the - // UnknownFieldSet. - int64 sign_extended_value = static_cast(value); - message_reflection->MutableUnknownFields(message) - ->AddVarint(WireFormatLite::GetTagFieldNumber(tag), - sign_extended_value); - } - break; - } - - // Handle strings separately so that we can optimize the ctype=CORD case. - case FieldDescriptor::TYPE_STRING: { - string value; - if (!WireFormatLite::ReadString(input, &value)) return false; - VerifyUTF8String(value.data(), value.length(), PARSE); - if (field->is_repeated()) { - message_reflection->AddString(message, field, value); - } else { - message_reflection->SetString(message, field, value); - } - break; - } - - case FieldDescriptor::TYPE_BYTES: { - string value; - if (!WireFormatLite::ReadBytes(input, &value)) return false; - if (field->is_repeated()) { - message_reflection->AddString(message, field, value); - } else { - message_reflection->SetString(message, field, value); - } - break; - } - - case FieldDescriptor::TYPE_GROUP: { - Message* sub_message; - if (field->is_repeated()) { - sub_message = message_reflection->AddMessage( - message, field, input->GetExtensionFactory()); - } else { - sub_message = message_reflection->MutableMessage( - message, field, input->GetExtensionFactory()); - } - - if (!WireFormatLite::ReadGroup(WireFormatLite::GetTagFieldNumber(tag), - input, sub_message)) - return false; - break; - } - - case FieldDescriptor::TYPE_MESSAGE: { - Message* sub_message; - if (field->is_repeated()) { - sub_message = message_reflection->AddMessage( - message, field, input->GetExtensionFactory()); - } else { - sub_message = message_reflection->MutableMessage( - message, field, input->GetExtensionFactory()); - } - - if (!WireFormatLite::ReadMessage(input, sub_message)) return false; - break; - } - } - } - - return true; -} - -bool WireFormat::ParseAndMergeMessageSetItem( - io::CodedInputStream* input, - Message* message) { - const Reflection* message_reflection = message->GetReflection(); - - // This method parses a group which should contain two fields: - // required int32 type_id = 2; - // required data message = 3; - - // Once we see a type_id, we'll construct a fake tag for this extension - // which is the tag it would have had under the proto2 extensions wire - // format. - uint32 fake_tag = 0; - - // Once we see a type_id, we'll look up the FieldDescriptor for the - // extension. - const FieldDescriptor* field = NULL; - - // If we see message data before the type_id, we'll append it to this so - // we can parse it later. - string message_data; - - while (true) { - uint32 tag = input->ReadTag(); - if (tag == 0) return false; - - switch (tag) { - case WireFormatLite::kMessageSetTypeIdTag: { - uint32 type_id; - if (!input->ReadVarint32(&type_id)) return false; - fake_tag = WireFormatLite::MakeTag( - type_id, WireFormatLite::WIRETYPE_LENGTH_DELIMITED); - field = message_reflection->FindKnownExtensionByNumber(type_id); - - if (!message_data.empty()) { - // We saw some message data before the type_id. Have to parse it - // now. - io::ArrayInputStream raw_input(message_data.data(), - message_data.size()); - io::CodedInputStream sub_input(&raw_input); - if (!ParseAndMergeField(fake_tag, field, message, - &sub_input)) { - return false; - } - message_data.clear(); - } - - break; - } - - case WireFormatLite::kMessageSetMessageTag: { - if (fake_tag == 0) { - // We haven't seen a type_id yet. Append this data to message_data. - string temp; - uint32 length; - if (!input->ReadVarint32(&length)) return false; - if (!input->ReadString(&temp, length)) return false; - io::StringOutputStream output_stream(&message_data); - io::CodedOutputStream coded_output(&output_stream); - coded_output.WriteVarint32(length); - coded_output.WriteString(temp); - } else { - // Already saw type_id, so we can parse this directly. - if (!ParseAndMergeField(fake_tag, field, message, input)) { - return false; - } - } - - break; - } - - case WireFormatLite::kMessageSetItemEndTag: { - return true; - } - - default: { - if (!SkipField(input, tag, NULL)) return false; - } - } - } -} - -// =================================================================== - -void WireFormat::SerializeWithCachedSizes( - const Message& message, - int size, io::CodedOutputStream* output) { - const Descriptor* descriptor = message.GetDescriptor(); - const Reflection* message_reflection = message.GetReflection(); - int expected_endpoint = output->ByteCount() + size; - - vector fields; - message_reflection->ListFields(message, &fields); - for (int i = 0; i < fields.size(); i++) { - SerializeFieldWithCachedSizes(fields[i], message, output); - } - - if (descriptor->options().message_set_wire_format()) { - SerializeUnknownMessageSetItems( - message_reflection->GetUnknownFields(message), output); - } else { - SerializeUnknownFields( - message_reflection->GetUnknownFields(message), output); - } - - GOOGLE_CHECK_EQ(output->ByteCount(), expected_endpoint) - << ": Protocol message serialized to a size different from what was " - "originally expected. Perhaps it was modified by another thread " - "during serialization?"; -} - -void WireFormat::SerializeFieldWithCachedSizes( - const FieldDescriptor* field, - const Message& message, - io::CodedOutputStream* output) { - const Reflection* message_reflection = message.GetReflection(); - - if (field->is_extension() && - field->containing_type()->options().message_set_wire_format() && - field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE && - !field->is_repeated()) { - SerializeMessageSetItemWithCachedSizes(field, message, output); - return; - } - - int count = 0; - - if (field->is_repeated()) { - count = message_reflection->FieldSize(message, field); - } else if (message_reflection->HasField(message, field)) { - count = 1; - } - - const bool is_packed = field->options().packed(); - if (is_packed && count > 0) { - WireFormatLite::WriteTag(field->number(), - WireFormatLite::WIRETYPE_LENGTH_DELIMITED, output); - const int data_size = FieldDataOnlyByteSize(field, message); - output->WriteVarint32(data_size); - } - - for (int j = 0; j < count; j++) { - switch (field->type()) { -#define HANDLE_PRIMITIVE_TYPE(TYPE, CPPTYPE, TYPE_METHOD, CPPTYPE_METHOD) \ - case FieldDescriptor::TYPE_##TYPE: { \ - const CPPTYPE value = field->is_repeated() ? \ - message_reflection->GetRepeated##CPPTYPE_METHOD( \ - message, field, j) : \ - message_reflection->Get##CPPTYPE_METHOD( \ - message, field); \ - if (is_packed) { \ - WireFormatLite::Write##TYPE_METHOD##NoTag(value, output); \ - } else { \ - WireFormatLite::Write##TYPE_METHOD(field->number(), value, output); \ - } \ - break; \ - } - - HANDLE_PRIMITIVE_TYPE( INT32, int32, Int32, Int32) - HANDLE_PRIMITIVE_TYPE( INT64, int64, Int64, Int64) - HANDLE_PRIMITIVE_TYPE(SINT32, int32, SInt32, Int32) - HANDLE_PRIMITIVE_TYPE(SINT64, int64, SInt64, Int64) - HANDLE_PRIMITIVE_TYPE(UINT32, uint32, UInt32, UInt32) - HANDLE_PRIMITIVE_TYPE(UINT64, uint64, UInt64, UInt64) - - HANDLE_PRIMITIVE_TYPE( FIXED32, uint32, Fixed32, UInt32) - HANDLE_PRIMITIVE_TYPE( FIXED64, uint64, Fixed64, UInt64) - HANDLE_PRIMITIVE_TYPE(SFIXED32, int32, SFixed32, Int32) - HANDLE_PRIMITIVE_TYPE(SFIXED64, int64, SFixed64, Int64) - - HANDLE_PRIMITIVE_TYPE(FLOAT , float , Float , Float ) - HANDLE_PRIMITIVE_TYPE(DOUBLE, double, Double, Double) - - HANDLE_PRIMITIVE_TYPE(BOOL, bool, Bool, Bool) -#undef HANDLE_PRIMITIVE_TYPE - -#define HANDLE_TYPE(TYPE, TYPE_METHOD, CPPTYPE_METHOD) \ - case FieldDescriptor::TYPE_##TYPE: \ - WireFormatLite::Write##TYPE_METHOD( \ - field->number(), \ - field->is_repeated() ? \ - message_reflection->GetRepeated##CPPTYPE_METHOD( \ - message, field, j) : \ - message_reflection->Get##CPPTYPE_METHOD(message, field), \ - output); \ - break; - - HANDLE_TYPE(GROUP , Group , Message) - HANDLE_TYPE(MESSAGE, Message, Message) -#undef HANDLE_TYPE - - case FieldDescriptor::TYPE_ENUM: { - const EnumValueDescriptor* value = field->is_repeated() ? - message_reflection->GetRepeatedEnum(message, field, j) : - message_reflection->GetEnum(message, field); - if (is_packed) { - WireFormatLite::WriteEnumNoTag(value->number(), output); - } else { - WireFormatLite::WriteEnum(field->number(), value->number(), output); - } - break; - } - - // Handle strings separately so that we can get string references - // instead of copying. - case FieldDescriptor::TYPE_STRING: { - string scratch; - const string& value = field->is_repeated() ? - message_reflection->GetRepeatedStringReference( - message, field, j, &scratch) : - message_reflection->GetStringReference(message, field, &scratch); - VerifyUTF8String(value.data(), value.length(), SERIALIZE); - WireFormatLite::WriteString(field->number(), value, output); - break; - } - - case FieldDescriptor::TYPE_BYTES: { - string scratch; - const string& value = field->is_repeated() ? - message_reflection->GetRepeatedStringReference( - message, field, j, &scratch) : - message_reflection->GetStringReference(message, field, &scratch); - WireFormatLite::WriteBytes(field->number(), value, output); - break; - } - } - } -} - -void WireFormat::SerializeMessageSetItemWithCachedSizes( - const FieldDescriptor* field, - const Message& message, - io::CodedOutputStream* output) { - const Reflection* message_reflection = message.GetReflection(); - - // Start group. - output->WriteVarint32(WireFormatLite::kMessageSetItemStartTag); - - // Write type ID. - output->WriteVarint32(WireFormatLite::kMessageSetTypeIdTag); - output->WriteVarint32(field->number()); - - // Write message. - output->WriteVarint32(WireFormatLite::kMessageSetMessageTag); - - const Message& sub_message = message_reflection->GetMessage(message, field); - output->WriteVarint32(sub_message.GetCachedSize()); - sub_message.SerializeWithCachedSizes(output); - - // End group. - output->WriteVarint32(WireFormatLite::kMessageSetItemEndTag); -} - -// =================================================================== - -int WireFormat::ByteSize(const Message& message) { - const Descriptor* descriptor = message.GetDescriptor(); - const Reflection* message_reflection = message.GetReflection(); - - int our_size = 0; - - vector fields; - message_reflection->ListFields(message, &fields); - for (int i = 0; i < fields.size(); i++) { - our_size += FieldByteSize(fields[i], message); - } - - if (descriptor->options().message_set_wire_format()) { - our_size += ComputeUnknownMessageSetItemsSize( - message_reflection->GetUnknownFields(message)); - } else { - our_size += ComputeUnknownFieldsSize( - message_reflection->GetUnknownFields(message)); - } - - return our_size; -} - -int WireFormat::FieldByteSize( - const FieldDescriptor* field, - const Message& message) { - const Reflection* message_reflection = message.GetReflection(); - - if (field->is_extension() && - field->containing_type()->options().message_set_wire_format() && - field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE && - !field->is_repeated()) { - return MessageSetItemByteSize(field, message); - } - - int count = 0; - if (field->is_repeated()) { - count = message_reflection->FieldSize(message, field); - } else if (message_reflection->HasField(message, field)) { - count = 1; - } - - const int data_size = FieldDataOnlyByteSize(field, message); - int our_size = data_size; - if (field->options().packed()) { - if (data_size > 0) { - // Packed fields get serialized like a string, not their native type. - // Technically this doesn't really matter; the size only changes if it's - // a GROUP - our_size += TagSize(field->number(), FieldDescriptor::TYPE_STRING); - our_size += io::CodedOutputStream::VarintSize32(data_size); - } - } else { - our_size += count * TagSize(field->number(), field->type()); - } - return our_size; -} - -int WireFormat::FieldDataOnlyByteSize( - const FieldDescriptor* field, - const Message& message) { - const Reflection* message_reflection = message.GetReflection(); - - int count = 0; - if (field->is_repeated()) { - count = message_reflection->FieldSize(message, field); - } else if (message_reflection->HasField(message, field)) { - count = 1; - } - - int data_size = 0; - switch (field->type()) { -#define HANDLE_TYPE(TYPE, TYPE_METHOD, CPPTYPE_METHOD) \ - case FieldDescriptor::TYPE_##TYPE: \ - if (field->is_repeated()) { \ - for (int j = 0; j < count; j++) { \ - data_size += WireFormatLite::TYPE_METHOD##Size( \ - message_reflection->GetRepeated##CPPTYPE_METHOD( \ - message, field, j)); \ - } \ - } else { \ - data_size += WireFormatLite::TYPE_METHOD##Size( \ - message_reflection->Get##CPPTYPE_METHOD(message, field)); \ - } \ - break; - -#define HANDLE_FIXED_TYPE(TYPE, TYPE_METHOD) \ - case FieldDescriptor::TYPE_##TYPE: \ - data_size += count * WireFormatLite::k##TYPE_METHOD##Size; \ - break; - - HANDLE_TYPE( INT32, Int32, Int32) - HANDLE_TYPE( INT64, Int64, Int64) - HANDLE_TYPE(SINT32, SInt32, Int32) - HANDLE_TYPE(SINT64, SInt64, Int64) - HANDLE_TYPE(UINT32, UInt32, UInt32) - HANDLE_TYPE(UINT64, UInt64, UInt64) - - HANDLE_FIXED_TYPE( FIXED32, Fixed32) - HANDLE_FIXED_TYPE( FIXED64, Fixed64) - HANDLE_FIXED_TYPE(SFIXED32, SFixed32) - HANDLE_FIXED_TYPE(SFIXED64, SFixed64) - - HANDLE_FIXED_TYPE(FLOAT , Float ) - HANDLE_FIXED_TYPE(DOUBLE, Double) - - HANDLE_FIXED_TYPE(BOOL, Bool) - - HANDLE_TYPE(GROUP , Group , Message) - HANDLE_TYPE(MESSAGE, Message, Message) -#undef HANDLE_TYPE -#undef HANDLE_FIXED_TYPE - - case FieldDescriptor::TYPE_ENUM: { - if (field->is_repeated()) { - for (int j = 0; j < count; j++) { - data_size += WireFormatLite::EnumSize( - message_reflection->GetRepeatedEnum(message, field, j)->number()); - } - } else { - data_size += WireFormatLite::EnumSize( - message_reflection->GetEnum(message, field)->number()); - } - break; - } - - // Handle strings separately so that we can get string references - // instead of copying. - case FieldDescriptor::TYPE_STRING: - case FieldDescriptor::TYPE_BYTES: { - for (int j = 0; j < count; j++) { - string scratch; - const string& value = field->is_repeated() ? - message_reflection->GetRepeatedStringReference( - message, field, j, &scratch) : - message_reflection->GetStringReference(message, field, &scratch); - data_size += WireFormatLite::StringSize(value); - } - break; - } - } - return data_size; -} - -int WireFormat::MessageSetItemByteSize( - const FieldDescriptor* field, - const Message& message) { - const Reflection* message_reflection = message.GetReflection(); - - int our_size = WireFormatLite::kMessageSetItemTagsSize; - - // type_id - our_size += io::CodedOutputStream::VarintSize32(field->number()); - - // message - const Message& sub_message = message_reflection->GetMessage(message, field); - int message_size = sub_message.ByteSize(); - - our_size += io::CodedOutputStream::VarintSize32(message_size); - our_size += message_size; - - return our_size; -} - -void WireFormat::VerifyUTF8StringFallback(const char* data, - int size, - Operation op) { - if (!IsStructurallyValidUTF8(data, size)) { - const char* operation_str = NULL; - switch (op) { - case PARSE: - operation_str = "parsing"; - break; - case SERIALIZE: - operation_str = "serializing"; - break; - // no default case: have the compiler warn if a case is not covered. - } - GOOGLE_LOG(ERROR) << "String field contains invalid UTF-8 data when " - << operation_str - << " a protocol buffer. Use the 'bytes' type if you intend to " - "send raw bytes."; - } -} - - -} // namespace internal -} // namespace protobuf -} // namespace google diff --git a/modules/dnn/3rdparty/protobuf/src/google/protobuf/wire_format.h b/modules/dnn/3rdparty/protobuf/src/google/protobuf/wire_format.h deleted file mode 100644 index 6cc900299..000000000 --- a/modules/dnn/3rdparty/protobuf/src/google/protobuf/wire_format.h +++ /dev/null @@ -1,308 +0,0 @@ -// Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// http://code.google.com/p/protobuf/ -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -// Author: kenton@google.com (Kenton Varda) -// atenasio@google.com (Chris Atenasio) (ZigZag transform) -// Based on original Protocol Buffers design by -// Sanjay Ghemawat, Jeff Dean, and others. -// -// This header is logically internal, but is made public because it is used -// from protocol-compiler-generated code, which may reside in other components. - -#ifndef GOOGLE_PROTOBUF_WIRE_FORMAT_H__ -#define GOOGLE_PROTOBUF_WIRE_FORMAT_H__ - -#include -#include -#include -#include -#include -#include - -// Do UTF-8 validation on string type in Debug build only -#ifndef NDEBUG -#define GOOGLE_PROTOBUF_UTF8_VALIDATION_ENABLED -#endif - -namespace google { -namespace protobuf { - namespace io { - class CodedInputStream; // coded_stream.h - class CodedOutputStream; // coded_stream.h - } - class UnknownFieldSet; // unknown_field_set.h -} - -namespace protobuf { -namespace internal { - -// This class is for internal use by the protocol buffer library and by -// protocol-complier-generated message classes. It must not be called -// directly by clients. -// -// This class contains code for implementing the binary protocol buffer -// wire format via reflection. The WireFormatLite class implements the -// non-reflection based routines. -// -// This class is really a namespace that contains only static methods -class LIBPROTOBUF_EXPORT WireFormat { - public: - - // Given a field return its WireType - static inline WireFormatLite::WireType WireTypeForField( - const FieldDescriptor* field); - - // Given a FieldSescriptor::Type return its WireType - static inline WireFormatLite::WireType WireTypeForFieldType( - FieldDescriptor::Type type); - - // Compute the byte size of a tag. For groups, this includes both the start - // and end tags. - static inline int TagSize(int field_number, FieldDescriptor::Type type); - - // These procedures can be used to implement the methods of Message which - // handle parsing and serialization of the protocol buffer wire format - // using only the Reflection interface. When you ask the protocol - // compiler to optimize for code size rather than speed, it will implement - // those methods in terms of these procedures. Of course, these are much - // slower than the specialized implementations which the protocol compiler - // generates when told to optimize for speed. - - // Read a message in protocol buffer wire format. - // - // This procedure reads either to the end of the input stream or through - // a WIRETYPE_END_GROUP tag ending the message, whichever comes first. - // It returns false if the input is invalid. - // - // Required fields are NOT checked by this method. You must call - // IsInitialized() on the resulting message yourself. - static bool ParseAndMergePartial(io::CodedInputStream* input, - Message* message); - - // Serialize a message in protocol buffer wire format. - // - // Any embedded messages within the message must have their correct sizes - // cached. However, the top-level message need not; its size is passed as - // a parameter to this procedure. - // - // These return false iff the underlying stream returns a write error. - static void SerializeWithCachedSizes( - const Message& message, - int size, io::CodedOutputStream* output); - - // Implements Message::ByteSize() via reflection. WARNING: The result - // of this method is *not* cached anywhere. However, all embedded messages - // will have their ByteSize() methods called, so their sizes will be cached. - // Therefore, calling this method is sufficient to allow you to call - // WireFormat::SerializeWithCachedSizes() on the same object. - static int ByteSize(const Message& message); - - // ----------------------------------------------------------------- - // Helpers for dealing with unknown fields - - // Skips a field value of the given WireType. The input should start - // positioned immediately after the tag. If unknown_fields is non-NULL, - // the contents of the field will be added to it. - static bool SkipField(io::CodedInputStream* input, uint32 tag, - UnknownFieldSet* unknown_fields); - - // Reads and ignores a message from the input. If unknown_fields is non-NULL, - // the contents will be added to it. - static bool SkipMessage(io::CodedInputStream* input, - UnknownFieldSet* unknown_fields); - - // Write the contents of an UnknownFieldSet to the output. - static void SerializeUnknownFields(const UnknownFieldSet& unknown_fields, - io::CodedOutputStream* output); - // Same as above, except writing directly to the provided buffer. - // Requires that the buffer have sufficient capacity for - // ComputeUnknownFieldsSize(unknown_fields). - // - // Returns a pointer past the last written byte. - static uint8* SerializeUnknownFieldsToArray( - const UnknownFieldSet& unknown_fields, - uint8* target); - - // Same thing except for messages that have the message_set_wire_format - // option. - static void SerializeUnknownMessageSetItems( - const UnknownFieldSet& unknown_fields, - io::CodedOutputStream* output); - // Same as above, except writing directly to the provided buffer. - // Requires that the buffer have sufficient capacity for - // ComputeUnknownMessageSetItemsSize(unknown_fields). - // - // Returns a pointer past the last written byte. - static uint8* SerializeUnknownMessageSetItemsToArray( - const UnknownFieldSet& unknown_fields, - uint8* target); - - // Compute the size of the UnknownFieldSet on the wire. - static int ComputeUnknownFieldsSize(const UnknownFieldSet& unknown_fields); - - // Same thing except for messages that have the message_set_wire_format - // option. - static int ComputeUnknownMessageSetItemsSize( - const UnknownFieldSet& unknown_fields); - - - // Helper functions for encoding and decoding tags. (Inlined below and in - // _inl.h) - // - // This is different from MakeTag(field->number(), field->type()) in the case - // of packed repeated fields. - static uint32 MakeTag(const FieldDescriptor* field); - - // Parse a single field. The input should start out positioned immidately - // after the tag. - static bool ParseAndMergeField( - uint32 tag, - const FieldDescriptor* field, // May be NULL for unknown - Message* message, - io::CodedInputStream* input); - - // Serialize a single field. - static void SerializeFieldWithCachedSizes( - const FieldDescriptor* field, // Cannot be NULL - const Message& message, - io::CodedOutputStream* output); - - // Compute size of a single field. If the field is a message type, this - // will call ByteSize() for the embedded message, insuring that it caches - // its size. - static int FieldByteSize( - const FieldDescriptor* field, // Cannot be NULL - const Message& message); - - // Parse/serialize a MessageSet::Item group. Used with messages that use - // opion message_set_wire_format = true. - static bool ParseAndMergeMessageSetItem( - io::CodedInputStream* input, - Message* message); - static void SerializeMessageSetItemWithCachedSizes( - const FieldDescriptor* field, - const Message& message, - io::CodedOutputStream* output); - static int MessageSetItemByteSize( - const FieldDescriptor* field, - const Message& message); - - // Computes the byte size of a field, excluding tags. For packed fields, it - // only includes the size of the raw data, and not the size of the total - // length, but for other length-delimited types, the size of the length is - // included. - static int FieldDataOnlyByteSize( - const FieldDescriptor* field, // Cannot be NULL - const Message& message); - - enum Operation { - PARSE, - SERIALIZE, - }; - - // Verifies that a string field is valid UTF8, logging an error if not. - static void VerifyUTF8String(const char* data, int size, Operation op); - - private: - // Verifies that a string field is valid UTF8, logging an error if not. - static void VerifyUTF8StringFallback( - const char* data, - int size, - Operation op); - - - - GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(WireFormat); -}; - -// Subclass of FieldSkipper which saves skipped fields to an UnknownFieldSet. -class LIBPROTOBUF_EXPORT UnknownFieldSetFieldSkipper : public FieldSkipper { - public: - UnknownFieldSetFieldSkipper(UnknownFieldSet* unknown_fields) - : unknown_fields_(unknown_fields) {} - virtual ~UnknownFieldSetFieldSkipper() {} - - // implements FieldSkipper ----------------------------------------- - virtual bool SkipField(io::CodedInputStream* input, uint32 tag); - virtual bool SkipMessage(io::CodedInputStream* input); - virtual void SkipUnknownEnum(int field_number, int value); - - protected: - UnknownFieldSet* unknown_fields_; -}; - -// inline methods ==================================================== - -inline WireFormatLite::WireType WireFormat::WireTypeForField( - const FieldDescriptor* field) { - if (field->options().packed()) { - return WireFormatLite::WIRETYPE_LENGTH_DELIMITED; - } else { - return WireTypeForFieldType(field->type()); - } -} - -inline WireFormatLite::WireType WireFormat::WireTypeForFieldType( - FieldDescriptor::Type type) { - // Some compilers don't like enum -> enum casts, so we implicit_cast to - // int first. - return WireFormatLite::WireTypeForFieldType( - static_cast( - implicit_cast(type))); -} - -inline uint32 WireFormat::MakeTag(const FieldDescriptor* field) { - return WireFormatLite::MakeTag(field->number(), WireTypeForField(field)); -} - -inline int WireFormat::TagSize(int field_number, FieldDescriptor::Type type) { - // Some compilers don't like enum -> enum casts, so we implicit_cast to - // int first. - return WireFormatLite::TagSize(field_number, - static_cast( - implicit_cast(type))); -} - -inline void WireFormat::VerifyUTF8String(const char* data, int size, - WireFormat::Operation op) { -#ifdef GOOGLE_PROTOBUF_UTF8_VALIDATION_ENABLED - WireFormat::VerifyUTF8StringFallback(data, size, op); -#else - // Avoid the compiler warning about unsued variables. - (void)data; (void)size; (void)op; -#endif -} - - -} // namespace internal -} // namespace protobuf - -} // namespace google -#endif // GOOGLE_PROTOBUF_WIRE_FORMAT_H__ diff --git a/modules/dnn/3rdparty/protobuf/src/google/protobuf/wire_format_lite.cc b/modules/dnn/3rdparty/protobuf/src/google/protobuf/wire_format_lite.cc deleted file mode 100644 index 738fc4214..000000000 --- a/modules/dnn/3rdparty/protobuf/src/google/protobuf/wire_format_lite.cc +++ /dev/null @@ -1,361 +0,0 @@ -// Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// http://code.google.com/p/protobuf/ -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -// Author: kenton@google.com (Kenton Varda) -// Based on original Protocol Buffers design by -// Sanjay Ghemawat, Jeff Dean, and others. - -#include - -#include -#include -#include -#include -#include -#include -#include - -namespace google { -namespace protobuf { -namespace internal { - -#ifndef _MSC_VER // MSVC doesn't like definitions of inline constants, GCC - // requires them. -const int WireFormatLite::kMessageSetItemStartTag; -const int WireFormatLite::kMessageSetItemEndTag; -const int WireFormatLite::kMessageSetTypeIdTag; -const int WireFormatLite::kMessageSetMessageTag; - -#endif - -const int WireFormatLite::kMessageSetItemTagsSize = - io::CodedOutputStream::StaticVarintSize32::value + - io::CodedOutputStream::StaticVarintSize32::value + - io::CodedOutputStream::StaticVarintSize32::value + - io::CodedOutputStream::StaticVarintSize32::value; - -const WireFormatLite::CppType -WireFormatLite::kFieldTypeToCppTypeMap[MAX_FIELD_TYPE + 1] = { - static_cast(0), // 0 is reserved for errors - - CPPTYPE_DOUBLE, // TYPE_DOUBLE - CPPTYPE_FLOAT, // TYPE_FLOAT - CPPTYPE_INT64, // TYPE_INT64 - CPPTYPE_UINT64, // TYPE_UINT64 - CPPTYPE_INT32, // TYPE_INT32 - CPPTYPE_UINT64, // TYPE_FIXED64 - CPPTYPE_UINT32, // TYPE_FIXED32 - CPPTYPE_BOOL, // TYPE_BOOL - CPPTYPE_STRING, // TYPE_STRING - CPPTYPE_MESSAGE, // TYPE_GROUP - CPPTYPE_MESSAGE, // TYPE_MESSAGE - CPPTYPE_STRING, // TYPE_BYTES - CPPTYPE_UINT32, // TYPE_UINT32 - CPPTYPE_ENUM, // TYPE_ENUM - CPPTYPE_INT32, // TYPE_SFIXED32 - CPPTYPE_INT64, // TYPE_SFIXED64 - CPPTYPE_INT32, // TYPE_SINT32 - CPPTYPE_INT64, // TYPE_SINT64 -}; - -const WireFormatLite::WireType -WireFormatLite::kWireTypeForFieldType[MAX_FIELD_TYPE + 1] = { - static_cast(-1), // invalid - WireFormatLite::WIRETYPE_FIXED64, // TYPE_DOUBLE - WireFormatLite::WIRETYPE_FIXED32, // TYPE_FLOAT - WireFormatLite::WIRETYPE_VARINT, // TYPE_INT64 - WireFormatLite::WIRETYPE_VARINT, // TYPE_UINT64 - WireFormatLite::WIRETYPE_VARINT, // TYPE_INT32 - WireFormatLite::WIRETYPE_FIXED64, // TYPE_FIXED64 - WireFormatLite::WIRETYPE_FIXED32, // TYPE_FIXED32 - WireFormatLite::WIRETYPE_VARINT, // TYPE_BOOL - WireFormatLite::WIRETYPE_LENGTH_DELIMITED, // TYPE_STRING - WireFormatLite::WIRETYPE_START_GROUP, // TYPE_GROUP - WireFormatLite::WIRETYPE_LENGTH_DELIMITED, // TYPE_MESSAGE - WireFormatLite::WIRETYPE_LENGTH_DELIMITED, // TYPE_BYTES - WireFormatLite::WIRETYPE_VARINT, // TYPE_UINT32 - WireFormatLite::WIRETYPE_VARINT, // TYPE_ENUM - WireFormatLite::WIRETYPE_FIXED32, // TYPE_SFIXED32 - WireFormatLite::WIRETYPE_FIXED64, // TYPE_SFIXED64 - WireFormatLite::WIRETYPE_VARINT, // TYPE_SINT32 - WireFormatLite::WIRETYPE_VARINT, // TYPE_SINT64 -}; - -bool WireFormatLite::SkipField( - io::CodedInputStream* input, uint32 tag) { - switch (WireFormatLite::GetTagWireType(tag)) { - case WireFormatLite::WIRETYPE_VARINT: { - uint64 value; - if (!input->ReadVarint64(&value)) return false; - return true; - } - case WireFormatLite::WIRETYPE_FIXED64: { - uint64 value; - if (!input->ReadLittleEndian64(&value)) return false; - return true; - } - case WireFormatLite::WIRETYPE_LENGTH_DELIMITED: { - uint32 length; - if (!input->ReadVarint32(&length)) return false; - if (!input->Skip(length)) return false; - return true; - } - case WireFormatLite::WIRETYPE_START_GROUP: { - if (!input->IncrementRecursionDepth()) return false; - if (!SkipMessage(input)) return false; - input->DecrementRecursionDepth(); - // Check that the ending tag matched the starting tag. - if (!input->LastTagWas(WireFormatLite::MakeTag( - WireFormatLite::GetTagFieldNumber(tag), - WireFormatLite::WIRETYPE_END_GROUP))) { - return false; - } - return true; - } - case WireFormatLite::WIRETYPE_END_GROUP: { - return false; - } - case WireFormatLite::WIRETYPE_FIXED32: { - uint32 value; - if (!input->ReadLittleEndian32(&value)) return false; - return true; - } - default: { - return false; - } - } -} - -bool WireFormatLite::SkipMessage(io::CodedInputStream* input) { - while(true) { - uint32 tag = input->ReadTag(); - if (tag == 0) { - // End of input. This is a valid place to end, so return true. - return true; - } - - WireFormatLite::WireType wire_type = WireFormatLite::GetTagWireType(tag); - - if (wire_type == WireFormatLite::WIRETYPE_END_GROUP) { - // Must be the end of the message. - return true; - } - - if (!SkipField(input, tag)) return false; - } -} - -bool FieldSkipper::SkipField( - io::CodedInputStream* input, uint32 tag) { - return WireFormatLite::SkipField(input, tag); -} - -bool FieldSkipper::SkipMessage(io::CodedInputStream* input) { - return WireFormatLite::SkipMessage(input); -} - -void FieldSkipper::SkipUnknownEnum( - int field_number, int value) { - // Nothing. -} - -bool WireFormatLite::ReadPackedEnumNoInline(io::CodedInputStream* input, - bool (*is_valid)(int), - RepeatedField* values) { - uint32 length; - if (!input->ReadVarint32(&length)) return false; - io::CodedInputStream::Limit limit = input->PushLimit(length); - while (input->BytesUntilLimit() > 0) { - int value; - if (!google::protobuf::internal::WireFormatLite::ReadPrimitive< - int, WireFormatLite::TYPE_ENUM>(input, &value)) { - return false; - } - if (is_valid(value)) { - values->Add(value); - } - } - input->PopLimit(limit); - return true; -} - -void WireFormatLite::WriteInt32(int field_number, int32 value, - io::CodedOutputStream* output) { - WriteTag(field_number, WIRETYPE_VARINT, output); - WriteInt32NoTag(value, output); -} -void WireFormatLite::WriteInt64(int field_number, int64 value, - io::CodedOutputStream* output) { - WriteTag(field_number, WIRETYPE_VARINT, output); - WriteInt64NoTag(value, output); -} -void WireFormatLite::WriteUInt32(int field_number, uint32 value, - io::CodedOutputStream* output) { - WriteTag(field_number, WIRETYPE_VARINT, output); - WriteUInt32NoTag(value, output); -} -void WireFormatLite::WriteUInt64(int field_number, uint64 value, - io::CodedOutputStream* output) { - WriteTag(field_number, WIRETYPE_VARINT, output); - WriteUInt64NoTag(value, output); -} -void WireFormatLite::WriteSInt32(int field_number, int32 value, - io::CodedOutputStream* output) { - WriteTag(field_number, WIRETYPE_VARINT, output); - WriteSInt32NoTag(value, output); -} -void WireFormatLite::WriteSInt64(int field_number, int64 value, - io::CodedOutputStream* output) { - WriteTag(field_number, WIRETYPE_VARINT, output); - WriteSInt64NoTag(value, output); -} -void WireFormatLite::WriteFixed32(int field_number, uint32 value, - io::CodedOutputStream* output) { - WriteTag(field_number, WIRETYPE_FIXED32, output); - WriteFixed32NoTag(value, output); -} -void WireFormatLite::WriteFixed64(int field_number, uint64 value, - io::CodedOutputStream* output) { - WriteTag(field_number, WIRETYPE_FIXED64, output); - WriteFixed64NoTag(value, output); -} -void WireFormatLite::WriteSFixed32(int field_number, int32 value, - io::CodedOutputStream* output) { - WriteTag(field_number, WIRETYPE_FIXED32, output); - WriteSFixed32NoTag(value, output); -} -void WireFormatLite::WriteSFixed64(int field_number, int64 value, - io::CodedOutputStream* output) { - WriteTag(field_number, WIRETYPE_FIXED64, output); - WriteSFixed64NoTag(value, output); -} -void WireFormatLite::WriteFloat(int field_number, float value, - io::CodedOutputStream* output) { - WriteTag(field_number, WIRETYPE_FIXED32, output); - WriteFloatNoTag(value, output); -} -void WireFormatLite::WriteDouble(int field_number, double value, - io::CodedOutputStream* output) { - WriteTag(field_number, WIRETYPE_FIXED64, output); - WriteDoubleNoTag(value, output); -} -void WireFormatLite::WriteBool(int field_number, bool value, - io::CodedOutputStream* output) { - WriteTag(field_number, WIRETYPE_VARINT, output); - WriteBoolNoTag(value, output); -} -void WireFormatLite::WriteEnum(int field_number, int value, - io::CodedOutputStream* output) { - WriteTag(field_number, WIRETYPE_VARINT, output); - WriteEnumNoTag(value, output); -} - -void WireFormatLite::WriteString(int field_number, const string& value, - io::CodedOutputStream* output) { - // String is for UTF-8 text only - WriteTag(field_number, WIRETYPE_LENGTH_DELIMITED, output); - GOOGLE_CHECK(value.size() <= kint32max); - output->WriteVarint32(value.size()); - output->WriteString(value); -} -void WireFormatLite::WriteBytes(int field_number, const string& value, - io::CodedOutputStream* output) { - WriteTag(field_number, WIRETYPE_LENGTH_DELIMITED, output); - GOOGLE_CHECK(value.size() <= kint32max); - output->WriteVarint32(value.size()); - output->WriteString(value); -} - - -void WireFormatLite::WriteGroup(int field_number, - const MessageLite& value, - io::CodedOutputStream* output) { - WriteTag(field_number, WIRETYPE_START_GROUP, output); - value.SerializeWithCachedSizes(output); - WriteTag(field_number, WIRETYPE_END_GROUP, output); -} - -void WireFormatLite::WriteMessage(int field_number, - const MessageLite& value, - io::CodedOutputStream* output) { - WriteTag(field_number, WIRETYPE_LENGTH_DELIMITED, output); - const int size = value.GetCachedSize(); - output->WriteVarint32(size); - value.SerializeWithCachedSizes(output); -} - -void WireFormatLite::WriteGroupMaybeToArray(int field_number, - const MessageLite& value, - io::CodedOutputStream* output) { - WriteTag(field_number, WIRETYPE_START_GROUP, output); - const int size = value.GetCachedSize(); - uint8* target = output->GetDirectBufferForNBytesAndAdvance(size); - if (target != NULL) { - uint8* end = value.SerializeWithCachedSizesToArray(target); - GOOGLE_DCHECK_EQ(end - target, size); - } else { - value.SerializeWithCachedSizes(output); - } - WriteTag(field_number, WIRETYPE_END_GROUP, output); -} - -void WireFormatLite::WriteMessageMaybeToArray(int field_number, - const MessageLite& value, - io::CodedOutputStream* output) { - WriteTag(field_number, WIRETYPE_LENGTH_DELIMITED, output); - const int size = value.GetCachedSize(); - output->WriteVarint32(size); - uint8* target = output->GetDirectBufferForNBytesAndAdvance(size); - if (target != NULL) { - uint8* end = value.SerializeWithCachedSizesToArray(target); - GOOGLE_DCHECK_EQ(end - target, size); - } else { - value.SerializeWithCachedSizes(output); - } -} - -bool WireFormatLite::ReadString(io::CodedInputStream* input, - string* value) { - // String is for UTF-8 text only - uint32 length; - if (!input->ReadVarint32(&length)) return false; - if (!input->InternalReadStringInline(value, length)) return false; - return true; -} -bool WireFormatLite::ReadBytes(io::CodedInputStream* input, - string* value) { - uint32 length; - if (!input->ReadVarint32(&length)) return false; - return input->InternalReadStringInline(value, length); -} - -} // namespace internal -} // namespace protobuf -} // namespace google diff --git a/modules/dnn/3rdparty/protobuf/src/google/protobuf/wire_format_lite.h b/modules/dnn/3rdparty/protobuf/src/google/protobuf/wire_format_lite.h deleted file mode 100644 index cb4fc918b..000000000 --- a/modules/dnn/3rdparty/protobuf/src/google/protobuf/wire_format_lite.h +++ /dev/null @@ -1,622 +0,0 @@ -// Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// http://code.google.com/p/protobuf/ -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -// Author: kenton@google.com (Kenton Varda) -// atenasio@google.com (Chris Atenasio) (ZigZag transform) -// wink@google.com (Wink Saville) (refactored from wire_format.h) -// Based on original Protocol Buffers design by -// Sanjay Ghemawat, Jeff Dean, and others. -// -// This header is logically internal, but is made public because it is used -// from protocol-compiler-generated code, which may reside in other components. - -#ifndef GOOGLE_PROTOBUF_WIRE_FORMAT_LITE_H__ -#define GOOGLE_PROTOBUF_WIRE_FORMAT_LITE_H__ - -#include -#include -#include -#include // for CodedOutputStream::Varint32Size - -namespace google { - -namespace protobuf { - template class RepeatedField; // repeated_field.h -} - -namespace protobuf { -namespace internal { - -class StringPieceField; - -// This class is for internal use by the protocol buffer library and by -// protocol-complier-generated message classes. It must not be called -// directly by clients. -// -// This class contains helpers for implementing the binary protocol buffer -// wire format without the need for reflection. Use WireFormat when using -// reflection. -// -// This class is really a namespace that contains only static methods. -class LIBPROTOBUF_EXPORT WireFormatLite { - public: - - // ----------------------------------------------------------------- - // Helper constants and functions related to the format. These are - // mostly meant for internal and generated code to use. - - // The wire format is composed of a sequence of tag/value pairs, each - // of which contains the value of one field (or one element of a repeated - // field). Each tag is encoded as a varint. The lower bits of the tag - // identify its wire type, which specifies the format of the data to follow. - // The rest of the bits contain the field number. Each type of field (as - // declared by FieldDescriptor::Type, in descriptor.h) maps to one of - // these wire types. Immediately following each tag is the field's value, - // encoded in the format specified by the wire type. Because the tag - // identifies the encoding of this data, it is possible to skip - // unrecognized fields for forwards compatibility. - - enum WireType { - WIRETYPE_VARINT = 0, - WIRETYPE_FIXED64 = 1, - WIRETYPE_LENGTH_DELIMITED = 2, - WIRETYPE_START_GROUP = 3, - WIRETYPE_END_GROUP = 4, - WIRETYPE_FIXED32 = 5, - }; - - // Lite alternative to FieldDescriptor::Type. Must be kept in sync. - enum FieldType { - TYPE_DOUBLE = 1, - TYPE_FLOAT = 2, - TYPE_INT64 = 3, - TYPE_UINT64 = 4, - TYPE_INT32 = 5, - TYPE_FIXED64 = 6, - TYPE_FIXED32 = 7, - TYPE_BOOL = 8, - TYPE_STRING = 9, - TYPE_GROUP = 10, - TYPE_MESSAGE = 11, - TYPE_BYTES = 12, - TYPE_UINT32 = 13, - TYPE_ENUM = 14, - TYPE_SFIXED32 = 15, - TYPE_SFIXED64 = 16, - TYPE_SINT32 = 17, - TYPE_SINT64 = 18, - MAX_FIELD_TYPE = 18, - }; - - // Lite alternative to FieldDescriptor::CppType. Must be kept in sync. - enum CppType { - CPPTYPE_INT32 = 1, - CPPTYPE_INT64 = 2, - CPPTYPE_UINT32 = 3, - CPPTYPE_UINT64 = 4, - CPPTYPE_DOUBLE = 5, - CPPTYPE_FLOAT = 6, - CPPTYPE_BOOL = 7, - CPPTYPE_ENUM = 8, - CPPTYPE_STRING = 9, - CPPTYPE_MESSAGE = 10, - MAX_CPPTYPE = 10, - }; - - // Helper method to get the CppType for a particular Type. - static CppType FieldTypeToCppType(FieldType type); - - // Given a FieldSescriptor::Type return its WireType - static inline WireFormatLite::WireType WireTypeForFieldType( - WireFormatLite::FieldType type) { - return kWireTypeForFieldType[type]; - } - - // Number of bits in a tag which identify the wire type. - static const int kTagTypeBits = 3; - // Mask for those bits. - static const uint32 kTagTypeMask = (1 << kTagTypeBits) - 1; - - // Helper functions for encoding and decoding tags. (Inlined below and in - // _inl.h) - // - // This is different from MakeTag(field->number(), field->type()) in the case - // of packed repeated fields. - static uint32 MakeTag(int field_number, WireType type); - static WireType GetTagWireType(uint32 tag); - static int GetTagFieldNumber(uint32 tag); - - // Compute the byte size of a tag. For groups, this includes both the start - // and end tags. - static inline int TagSize(int field_number, WireFormatLite::FieldType type); - - // Skips a field value with the given tag. The input should start - // positioned immediately after the tag. Skipped values are simply discarded, - // not recorded anywhere. See WireFormat::SkipField() for a version that - // records to an UnknownFieldSet. - static bool SkipField(io::CodedInputStream* input, uint32 tag); - - // Reads and ignores a message from the input. Skipped values are simply - // discarded, not recorded anywhere. See WireFormat::SkipMessage() for a - // version that records to an UnknownFieldSet. - static bool SkipMessage(io::CodedInputStream* input); - -// This macro does the same thing as WireFormatLite::MakeTag(), but the -// result is usable as a compile-time constant, which makes it usable -// as a switch case or a template input. WireFormatLite::MakeTag() is more -// type-safe, though, so prefer it if possible. -#define GOOGLE_PROTOBUF_WIRE_FORMAT_MAKE_TAG(FIELD_NUMBER, TYPE) \ - static_cast( \ - ((FIELD_NUMBER) << ::google::protobuf::internal::WireFormatLite::kTagTypeBits) \ - | (TYPE)) - - // These are the tags for the old MessageSet format, which was defined as: - // message MessageSet { - // repeated group Item = 1 { - // required int32 type_id = 2; - // required string message = 3; - // } - // } - static const int kMessageSetItemNumber = 1; - static const int kMessageSetTypeIdNumber = 2; - static const int kMessageSetMessageNumber = 3; - static const int kMessageSetItemStartTag = - GOOGLE_PROTOBUF_WIRE_FORMAT_MAKE_TAG(kMessageSetItemNumber, - WireFormatLite::WIRETYPE_START_GROUP); - static const int kMessageSetItemEndTag = - GOOGLE_PROTOBUF_WIRE_FORMAT_MAKE_TAG(kMessageSetItemNumber, - WireFormatLite::WIRETYPE_END_GROUP); - static const int kMessageSetTypeIdTag = - GOOGLE_PROTOBUF_WIRE_FORMAT_MAKE_TAG(kMessageSetTypeIdNumber, - WireFormatLite::WIRETYPE_VARINT); - static const int kMessageSetMessageTag = - GOOGLE_PROTOBUF_WIRE_FORMAT_MAKE_TAG(kMessageSetMessageNumber, - WireFormatLite::WIRETYPE_LENGTH_DELIMITED); - - // Byte size of all tags of a MessageSet::Item combined. - static const int kMessageSetItemTagsSize; - - // Helper functions for converting between floats/doubles and IEEE-754 - // uint32s/uint64s so that they can be written. (Assumes your platform - // uses IEEE-754 floats.) - static uint32 EncodeFloat(float value); - static float DecodeFloat(uint32 value); - static uint64 EncodeDouble(double value); - static double DecodeDouble(uint64 value); - - // Helper functions for mapping signed integers to unsigned integers in - // such a way that numbers with small magnitudes will encode to smaller - // varints. If you simply static_cast a negative number to an unsigned - // number and varint-encode it, it will always take 10 bytes, defeating - // the purpose of varint. So, for the "sint32" and "sint64" field types, - // we ZigZag-encode the values. - static uint32 ZigZagEncode32(int32 n); - static int32 ZigZagDecode32(uint32 n); - static uint64 ZigZagEncode64(int64 n); - static int64 ZigZagDecode64(uint64 n); - - // ================================================================= - // Methods for reading/writing individual field. The implementations - // of these methods are defined in wire_format_lite_inl.h; you must #include - // that file to use these. - -// Avoid ugly line wrapping -#define input io::CodedInputStream* input -#define output io::CodedOutputStream* output -#define field_number int field_number -#define INL GOOGLE_ATTRIBUTE_ALWAYS_INLINE - - // Read fields, not including tags. The assumption is that you already - // read the tag to determine what field to read. - - // For primitive fields, we just use a templatized routine parameterized by - // the represented type and the FieldType. These are specialized with the - // appropriate definition for each declared type. - template - static inline bool ReadPrimitive(input, CType* value) INL; - - // Reads repeated primitive values, with optimizations for repeats. - // tag_size and tag should both be compile-time constants provided by the - // protocol compiler. - template - static inline bool ReadRepeatedPrimitive(int tag_size, - uint32 tag, - input, - RepeatedField* value) INL; - - // Identical to ReadRepeatedPrimitive, except will not inline the - // implementation. - template - static bool ReadRepeatedPrimitiveNoInline(int tag_size, - uint32 tag, - input, - RepeatedField* value); - - // Reads a primitive value directly from the provided buffer. It returns a - // pointer past the segment of data that was read. - // - // This is only implemented for the types with fixed wire size, e.g. - // float, double, and the (s)fixed* types. - template - static inline const uint8* ReadPrimitiveFromArray(const uint8* buffer, - CType* value) INL; - - // Reads a primitive packed field. - // - // This is only implemented for packable types. - template - static inline bool ReadPackedPrimitive(input, - RepeatedField* value) INL; - - // Identical to ReadPackedPrimitive, except will not inline the - // implementation. - template - static bool ReadPackedPrimitiveNoInline(input, RepeatedField* value); - - // Read a packed enum field. Values for which is_valid() returns false are - // dropped. - static bool ReadPackedEnumNoInline(input, - bool (*is_valid)(int), - RepeatedField* value); - - static bool ReadString(input, string* value); - static bool ReadBytes (input, string* value); - - static inline bool ReadGroup (field_number, input, MessageLite* value); - static inline bool ReadMessage(input, MessageLite* value); - - // Like above, but de-virtualize the call to MergePartialFromCodedStream(). - // The pointer must point at an instance of MessageType, *not* a subclass (or - // the subclass must not override MergePartialFromCodedStream()). - template - static inline bool ReadGroupNoVirtual(field_number, input, - MessageType* value); - template - static inline bool ReadMessageNoVirtual(input, MessageType* value); - - // Write a tag. The Write*() functions typically include the tag, so - // normally there's no need to call this unless using the Write*NoTag() - // variants. - static inline void WriteTag(field_number, WireType type, output) INL; - - // Write fields, without tags. - static inline void WriteInt32NoTag (int32 value, output) INL; - static inline void WriteInt64NoTag (int64 value, output) INL; - static inline void WriteUInt32NoTag (uint32 value, output) INL; - static inline void WriteUInt64NoTag (uint64 value, output) INL; - static inline void WriteSInt32NoTag (int32 value, output) INL; - static inline void WriteSInt64NoTag (int64 value, output) INL; - static inline void WriteFixed32NoTag (uint32 value, output) INL; - static inline void WriteFixed64NoTag (uint64 value, output) INL; - static inline void WriteSFixed32NoTag(int32 value, output) INL; - static inline void WriteSFixed64NoTag(int64 value, output) INL; - static inline void WriteFloatNoTag (float value, output) INL; - static inline void WriteDoubleNoTag (double value, output) INL; - static inline void WriteBoolNoTag (bool value, output) INL; - static inline void WriteEnumNoTag (int value, output) INL; - - // Write fields, including tags. - static void WriteInt32 (field_number, int32 value, output); - static void WriteInt64 (field_number, int64 value, output); - static void WriteUInt32 (field_number, uint32 value, output); - static void WriteUInt64 (field_number, uint64 value, output); - static void WriteSInt32 (field_number, int32 value, output); - static void WriteSInt64 (field_number, int64 value, output); - static void WriteFixed32 (field_number, uint32 value, output); - static void WriteFixed64 (field_number, uint64 value, output); - static void WriteSFixed32(field_number, int32 value, output); - static void WriteSFixed64(field_number, int64 value, output); - static void WriteFloat (field_number, float value, output); - static void WriteDouble (field_number, double value, output); - static void WriteBool (field_number, bool value, output); - static void WriteEnum (field_number, int value, output); - - static void WriteString(field_number, const string& value, output); - static void WriteBytes (field_number, const string& value, output); - - static void WriteGroup( - field_number, const MessageLite& value, output); - static void WriteMessage( - field_number, const MessageLite& value, output); - // Like above, but these will check if the output stream has enough - // space to write directly to a flat array. - static void WriteGroupMaybeToArray( - field_number, const MessageLite& value, output); - static void WriteMessageMaybeToArray( - field_number, const MessageLite& value, output); - - // Like above, but de-virtualize the call to SerializeWithCachedSizes(). The - // pointer must point at an instance of MessageType, *not* a subclass (or - // the subclass must not override SerializeWithCachedSizes()). - template - static inline void WriteGroupNoVirtual( - field_number, const MessageType& value, output); - template - static inline void WriteMessageNoVirtual( - field_number, const MessageType& value, output); - -#undef output -#define output uint8* target - - // Like above, but use only *ToArray methods of CodedOutputStream. - static inline uint8* WriteTagToArray(field_number, WireType type, output) INL; - - // Write fields, without tags. - static inline uint8* WriteInt32NoTagToArray (int32 value, output) INL; - static inline uint8* WriteInt64NoTagToArray (int64 value, output) INL; - static inline uint8* WriteUInt32NoTagToArray (uint32 value, output) INL; - static inline uint8* WriteUInt64NoTagToArray (uint64 value, output) INL; - static inline uint8* WriteSInt32NoTagToArray (int32 value, output) INL; - static inline uint8* WriteSInt64NoTagToArray (int64 value, output) INL; - static inline uint8* WriteFixed32NoTagToArray (uint32 value, output) INL; - static inline uint8* WriteFixed64NoTagToArray (uint64 value, output) INL; - static inline uint8* WriteSFixed32NoTagToArray(int32 value, output) INL; - static inline uint8* WriteSFixed64NoTagToArray(int64 value, output) INL; - static inline uint8* WriteFloatNoTagToArray (float value, output) INL; - static inline uint8* WriteDoubleNoTagToArray (double value, output) INL; - static inline uint8* WriteBoolNoTagToArray (bool value, output) INL; - static inline uint8* WriteEnumNoTagToArray (int value, output) INL; - - // Write fields, including tags. - static inline uint8* WriteInt32ToArray( - field_number, int32 value, output) INL; - static inline uint8* WriteInt64ToArray( - field_number, int64 value, output) INL; - static inline uint8* WriteUInt32ToArray( - field_number, uint32 value, output) INL; - static inline uint8* WriteUInt64ToArray( - field_number, uint64 value, output) INL; - static inline uint8* WriteSInt32ToArray( - field_number, int32 value, output) INL; - static inline uint8* WriteSInt64ToArray( - field_number, int64 value, output) INL; - static inline uint8* WriteFixed32ToArray( - field_number, uint32 value, output) INL; - static inline uint8* WriteFixed64ToArray( - field_number, uint64 value, output) INL; - static inline uint8* WriteSFixed32ToArray( - field_number, int32 value, output) INL; - static inline uint8* WriteSFixed64ToArray( - field_number, int64 value, output) INL; - static inline uint8* WriteFloatToArray( - field_number, float value, output) INL; - static inline uint8* WriteDoubleToArray( - field_number, double value, output) INL; - static inline uint8* WriteBoolToArray( - field_number, bool value, output) INL; - static inline uint8* WriteEnumToArray( - field_number, int value, output) INL; - - static inline uint8* WriteStringToArray( - field_number, const string& value, output) INL; - static inline uint8* WriteBytesToArray( - field_number, const string& value, output) INL; - - static inline uint8* WriteGroupToArray( - field_number, const MessageLite& value, output) INL; - static inline uint8* WriteMessageToArray( - field_number, const MessageLite& value, output) INL; - - // Like above, but de-virtualize the call to SerializeWithCachedSizes(). The - // pointer must point at an instance of MessageType, *not* a subclass (or - // the subclass must not override SerializeWithCachedSizes()). - template - static inline uint8* WriteGroupNoVirtualToArray( - field_number, const MessageType& value, output) INL; - template - static inline uint8* WriteMessageNoVirtualToArray( - field_number, const MessageType& value, output) INL; - -#undef output -#undef input -#undef INL - -#undef field_number - - // Compute the byte size of a field. The XxSize() functions do NOT include - // the tag, so you must also call TagSize(). (This is because, for repeated - // fields, you should only call TagSize() once and multiply it by the element - // count, but you may have to call XxSize() for each individual element.) - static inline int Int32Size ( int32 value); - static inline int Int64Size ( int64 value); - static inline int UInt32Size (uint32 value); - static inline int UInt64Size (uint64 value); - static inline int SInt32Size ( int32 value); - static inline int SInt64Size ( int64 value); - static inline int EnumSize ( int value); - - // These types always have the same size. - static const int kFixed32Size = 4; - static const int kFixed64Size = 8; - static const int kSFixed32Size = 4; - static const int kSFixed64Size = 8; - static const int kFloatSize = 4; - static const int kDoubleSize = 8; - static const int kBoolSize = 1; - - static inline int StringSize(const string& value); - static inline int BytesSize (const string& value); - - static inline int GroupSize (const MessageLite& value); - static inline int MessageSize(const MessageLite& value); - - // Like above, but de-virtualize the call to ByteSize(). The - // pointer must point at an instance of MessageType, *not* a subclass (or - // the subclass must not override ByteSize()). - template - static inline int GroupSizeNoVirtual (const MessageType& value); - template - static inline int MessageSizeNoVirtual(const MessageType& value); - - // Given the length of data, calculate the byte size of the data on the - // wire if we encode the data as a length delimited field. - static inline int LengthDelimitedSize(int length); - - private: - // A helper method for the repeated primitive reader. This method has - // optimizations for primitive types that have fixed size on the wire, and - // can be read using potentially faster paths. - template - static inline bool ReadRepeatedFixedSizePrimitive( - int tag_size, - uint32 tag, - google::protobuf::io::CodedInputStream* input, - RepeatedField* value) GOOGLE_ATTRIBUTE_ALWAYS_INLINE; - - static const CppType kFieldTypeToCppTypeMap[]; - static const WireFormatLite::WireType kWireTypeForFieldType[]; - - GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(WireFormatLite); -}; - -// A class which deals with unknown values. The default implementation just -// discards them. WireFormat defines a subclass which writes to an -// UnknownFieldSet. This class is used by ExtensionSet::ParseField(), since -// ExtensionSet is part of the lite library but UnknownFieldSet is not. -class LIBPROTOBUF_EXPORT FieldSkipper { - public: - FieldSkipper() {} - virtual ~FieldSkipper() {} - - // Skip a field whose tag has already been consumed. - virtual bool SkipField(io::CodedInputStream* input, uint32 tag); - - // Skip an entire message or group, up to an end-group tag (which is consumed) - // or end-of-stream. - virtual bool SkipMessage(io::CodedInputStream* input); - - // Deal with an already-parsed unrecognized enum value. The default - // implementation does nothing, but the UnknownFieldSet-based implementation - // saves it as an unknown varint. - virtual void SkipUnknownEnum(int field_number, int value); -}; - -// inline methods ==================================================== - -inline WireFormatLite::CppType -WireFormatLite::FieldTypeToCppType(FieldType type) { - return kFieldTypeToCppTypeMap[type]; -} - -inline uint32 WireFormatLite::MakeTag(int field_number, WireType type) { - return GOOGLE_PROTOBUF_WIRE_FORMAT_MAKE_TAG(field_number, type); -} - -inline WireFormatLite::WireType WireFormatLite::GetTagWireType(uint32 tag) { - return static_cast(tag & kTagTypeMask); -} - -inline int WireFormatLite::GetTagFieldNumber(uint32 tag) { - return static_cast(tag >> kTagTypeBits); -} - -inline int WireFormatLite::TagSize(int field_number, - WireFormatLite::FieldType type) { - int result = io::CodedOutputStream::VarintSize32( - field_number << kTagTypeBits); - if (type == TYPE_GROUP) { - // Groups have both a start and an end tag. - return result * 2; - } else { - return result; - } -} - -inline uint32 WireFormatLite::EncodeFloat(float value) { - union {float f; uint32 i;}; - f = value; - return i; -} - -inline float WireFormatLite::DecodeFloat(uint32 value) { - union {float f; uint32 i;}; - i = value; - return f; -} - -inline uint64 WireFormatLite::EncodeDouble(double value) { - union {double f; uint64 i;}; - f = value; - return i; -} - -inline double WireFormatLite::DecodeDouble(uint64 value) { - union {double f; uint64 i;}; - i = value; - return f; -} - -// ZigZag Transform: Encodes signed integers so that they can be -// effectively used with varint encoding. -// -// varint operates on unsigned integers, encoding smaller numbers into -// fewer bytes. If you try to use it on a signed integer, it will treat -// this number as a very large unsigned integer, which means that even -// small signed numbers like -1 will take the maximum number of bytes -// (10) to encode. ZigZagEncode() maps signed integers to unsigned -// in such a way that those with a small absolute value will have smaller -// encoded values, making them appropriate for encoding using varint. -// -// int32 -> uint32 -// ------------------------- -// 0 -> 0 -// -1 -> 1 -// 1 -> 2 -// -2 -> 3 -// ... -> ... -// 2147483647 -> 4294967294 -// -2147483648 -> 4294967295 -// -// >> encode >> -// << decode << - -inline uint32 WireFormatLite::ZigZagEncode32(int32 n) { - // Note: the right-shift must be arithmetic - return (n << 1) ^ (n >> 31); -} - -inline int32 WireFormatLite::ZigZagDecode32(uint32 n) { - return (n >> 1) ^ -static_cast(n & 1); -} - -inline uint64 WireFormatLite::ZigZagEncode64(int64 n) { - // Note: the right-shift must be arithmetic - return (n << 1) ^ (n >> 63); -} - -inline int64 WireFormatLite::ZigZagDecode64(uint64 n) { - return (n >> 1) ^ -static_cast(n & 1); -} - -} // namespace internal -} // namespace protobuf - -} // namespace google -#endif // GOOGLE_PROTOBUF_WIRE_FORMAT_LITE_H__ diff --git a/modules/dnn/3rdparty/protobuf/src/google/protobuf/wire_format_lite_inl.h b/modules/dnn/3rdparty/protobuf/src/google/protobuf/wire_format_lite_inl.h deleted file mode 100644 index 89cb51bf9..000000000 --- a/modules/dnn/3rdparty/protobuf/src/google/protobuf/wire_format_lite_inl.h +++ /dev/null @@ -1,776 +0,0 @@ -// Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// http://code.google.com/p/protobuf/ -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -// Author: kenton@google.com (Kenton Varda) -// wink@google.com (Wink Saville) (refactored from wire_format.h) -// Based on original Protocol Buffers design by -// Sanjay Ghemawat, Jeff Dean, and others. - -#ifndef GOOGLE_PROTOBUF_WIRE_FORMAT_LITE_INL_H__ -#define GOOGLE_PROTOBUF_WIRE_FORMAT_LITE_INL_H__ - -#include -#include -#include -#include -#include -#include - - -namespace google { -namespace protobuf { -namespace internal { - -// Implementation details of ReadPrimitive. - -template <> -inline bool WireFormatLite::ReadPrimitive( - io::CodedInputStream* input, - int32* value) { - uint32 temp; - if (!input->ReadVarint32(&temp)) return false; - *value = static_cast(temp); - return true; -} -template <> -inline bool WireFormatLite::ReadPrimitive( - io::CodedInputStream* input, - int64* value) { - uint64 temp; - if (!input->ReadVarint64(&temp)) return false; - *value = static_cast(temp); - return true; -} -template <> -inline bool WireFormatLite::ReadPrimitive( - io::CodedInputStream* input, - uint32* value) { - return input->ReadVarint32(value); -} -template <> -inline bool WireFormatLite::ReadPrimitive( - io::CodedInputStream* input, - uint64* value) { - return input->ReadVarint64(value); -} -template <> -inline bool WireFormatLite::ReadPrimitive( - io::CodedInputStream* input, - int32* value) { - uint32 temp; - if (!input->ReadVarint32(&temp)) return false; - *value = ZigZagDecode32(temp); - return true; -} -template <> -inline bool WireFormatLite::ReadPrimitive( - io::CodedInputStream* input, - int64* value) { - uint64 temp; - if (!input->ReadVarint64(&temp)) return false; - *value = ZigZagDecode64(temp); - return true; -} -template <> -inline bool WireFormatLite::ReadPrimitive( - io::CodedInputStream* input, - uint32* value) { - return input->ReadLittleEndian32(value); -} -template <> -inline bool WireFormatLite::ReadPrimitive( - io::CodedInputStream* input, - uint64* value) { - return input->ReadLittleEndian64(value); -} -template <> -inline bool WireFormatLite::ReadPrimitive( - io::CodedInputStream* input, - int32* value) { - uint32 temp; - if (!input->ReadLittleEndian32(&temp)) return false; - *value = static_cast(temp); - return true; -} -template <> -inline bool WireFormatLite::ReadPrimitive( - io::CodedInputStream* input, - int64* value) { - uint64 temp; - if (!input->ReadLittleEndian64(&temp)) return false; - *value = static_cast(temp); - return true; -} -template <> -inline bool WireFormatLite::ReadPrimitive( - io::CodedInputStream* input, - float* value) { - uint32 temp; - if (!input->ReadLittleEndian32(&temp)) return false; - *value = DecodeFloat(temp); - return true; -} -template <> -inline bool WireFormatLite::ReadPrimitive( - io::CodedInputStream* input, - double* value) { - uint64 temp; - if (!input->ReadLittleEndian64(&temp)) return false; - *value = DecodeDouble(temp); - return true; -} -template <> -inline bool WireFormatLite::ReadPrimitive( - io::CodedInputStream* input, - bool* value) { - uint32 temp; - if (!input->ReadVarint32(&temp)) return false; - *value = temp != 0; - return true; -} -template <> -inline bool WireFormatLite::ReadPrimitive( - io::CodedInputStream* input, - int* value) { - uint32 temp; - if (!input->ReadVarint32(&temp)) return false; - *value = static_cast(temp); - return true; -} - -template <> -inline const uint8* WireFormatLite::ReadPrimitiveFromArray< - uint32, WireFormatLite::TYPE_FIXED32>( - const uint8* buffer, - uint32* value) { - return io::CodedInputStream::ReadLittleEndian32FromArray(buffer, value); -} -template <> -inline const uint8* WireFormatLite::ReadPrimitiveFromArray< - uint64, WireFormatLite::TYPE_FIXED64>( - const uint8* buffer, - uint64* value) { - return io::CodedInputStream::ReadLittleEndian64FromArray(buffer, value); -} -template <> -inline const uint8* WireFormatLite::ReadPrimitiveFromArray< - int32, WireFormatLite::TYPE_SFIXED32>( - const uint8* buffer, - int32* value) { - uint32 temp; - buffer = io::CodedInputStream::ReadLittleEndian32FromArray(buffer, &temp); - *value = static_cast(temp); - return buffer; -} -template <> -inline const uint8* WireFormatLite::ReadPrimitiveFromArray< - int64, WireFormatLite::TYPE_SFIXED64>( - const uint8* buffer, - int64* value) { - uint64 temp; - buffer = io::CodedInputStream::ReadLittleEndian64FromArray(buffer, &temp); - *value = static_cast(temp); - return buffer; -} -template <> -inline const uint8* WireFormatLite::ReadPrimitiveFromArray< - float, WireFormatLite::TYPE_FLOAT>( - const uint8* buffer, - float* value) { - uint32 temp; - buffer = io::CodedInputStream::ReadLittleEndian32FromArray(buffer, &temp); - *value = DecodeFloat(temp); - return buffer; -} -template <> -inline const uint8* WireFormatLite::ReadPrimitiveFromArray< - double, WireFormatLite::TYPE_DOUBLE>( - const uint8* buffer, - double* value) { - uint64 temp; - buffer = io::CodedInputStream::ReadLittleEndian64FromArray(buffer, &temp); - *value = DecodeDouble(temp); - return buffer; -} - -template -inline bool WireFormatLite::ReadRepeatedPrimitive(int, // tag_size, unused. - uint32 tag, - io::CodedInputStream* input, - RepeatedField* values) { - CType value; - if (!ReadPrimitive(input, &value)) return false; - values->Add(value); - int elements_already_reserved = values->Capacity() - values->size(); - while (elements_already_reserved > 0 && input->ExpectTag(tag)) { - if (!ReadPrimitive(input, &value)) return false; - values->AddAlreadyReserved(value); - elements_already_reserved--; - } - return true; -} - -template -inline bool WireFormatLite::ReadRepeatedFixedSizePrimitive( - int tag_size, - uint32 tag, - io::CodedInputStream* input, - RepeatedField* values) { - GOOGLE_DCHECK_EQ(UInt32Size(tag), tag_size); - CType value; - if (!ReadPrimitive(input, &value)) - return false; - values->Add(value); - - // For fixed size values, repeated values can be read more quickly by - // reading directly from a raw array. - // - // We can get a tight loop by only reading as many elements as can be - // added to the RepeatedField without having to do any resizing. Additionally, - // we only try to read as many elements as are available from the current - // buffer space. Doing so avoids having to perform boundary checks when - // reading the value: the maximum number of elements that can be read is - // known outside of the loop. - const void* void_pointer; - int size; - input->GetDirectBufferPointerInline(&void_pointer, &size); - if (size > 0) { - const uint8* buffer = reinterpret_cast(void_pointer); - // The number of bytes each type occupies on the wire. - const int per_value_size = tag_size + sizeof(value); - - int elements_available = min(values->Capacity() - values->size(), - size / per_value_size); - int num_read = 0; - while (num_read < elements_available && - (buffer = io::CodedInputStream::ExpectTagFromArray( - buffer, tag)) != NULL) { - buffer = ReadPrimitiveFromArray(buffer, &value); - values->AddAlreadyReserved(value); - ++num_read; - } - const int read_bytes = num_read * per_value_size; - if (read_bytes > 0) { - input->Skip(read_bytes); - } - } - return true; -} - -// Specializations of ReadRepeatedPrimitive for the fixed size types, which use -// the optimized code path. -#define READ_REPEATED_FIXED_SIZE_PRIMITIVE(CPPTYPE, DECLARED_TYPE) \ -template <> \ -inline bool WireFormatLite::ReadRepeatedPrimitive< \ - CPPTYPE, WireFormatLite::DECLARED_TYPE>( \ - int tag_size, \ - uint32 tag, \ - io::CodedInputStream* input, \ - RepeatedField* values) { \ - return ReadRepeatedFixedSizePrimitive< \ - CPPTYPE, WireFormatLite::DECLARED_TYPE>( \ - tag_size, tag, input, values); \ -} - -READ_REPEATED_FIXED_SIZE_PRIMITIVE(uint32, TYPE_FIXED32) -READ_REPEATED_FIXED_SIZE_PRIMITIVE(uint64, TYPE_FIXED64) -READ_REPEATED_FIXED_SIZE_PRIMITIVE(int32, TYPE_SFIXED32) -READ_REPEATED_FIXED_SIZE_PRIMITIVE(int64, TYPE_SFIXED64) -READ_REPEATED_FIXED_SIZE_PRIMITIVE(float, TYPE_FLOAT) -READ_REPEATED_FIXED_SIZE_PRIMITIVE(double, TYPE_DOUBLE) - -#undef READ_REPEATED_FIXED_SIZE_PRIMITIVE - -template -bool WireFormatLite::ReadRepeatedPrimitiveNoInline( - int tag_size, - uint32 tag, - io::CodedInputStream* input, - RepeatedField* value) { - return ReadRepeatedPrimitive( - tag_size, tag, input, value); -} - -template -inline bool WireFormatLite::ReadPackedPrimitive(io::CodedInputStream* input, - RepeatedField* values) { - uint32 length; - if (!input->ReadVarint32(&length)) return false; - io::CodedInputStream::Limit limit = input->PushLimit(length); - while (input->BytesUntilLimit() > 0) { - CType value; - if (!ReadPrimitive(input, &value)) return false; - values->Add(value); - } - input->PopLimit(limit); - return true; -} - -template -bool WireFormatLite::ReadPackedPrimitiveNoInline(io::CodedInputStream* input, - RepeatedField* values) { - return ReadPackedPrimitive(input, values); -} - - -inline bool WireFormatLite::ReadGroup(int field_number, - io::CodedInputStream* input, - MessageLite* value) { - if (!input->IncrementRecursionDepth()) return false; - if (!value->MergePartialFromCodedStream(input)) return false; - input->DecrementRecursionDepth(); - // Make sure the last thing read was an end tag for this group. - if (!input->LastTagWas(MakeTag(field_number, WIRETYPE_END_GROUP))) { - return false; - } - return true; -} -inline bool WireFormatLite::ReadMessage(io::CodedInputStream* input, - MessageLite* value) { - uint32 length; - if (!input->ReadVarint32(&length)) return false; - if (!input->IncrementRecursionDepth()) return false; - io::CodedInputStream::Limit limit = input->PushLimit(length); - if (!value->MergePartialFromCodedStream(input)) return false; - // Make sure that parsing stopped when the limit was hit, not at an endgroup - // tag. - if (!input->ConsumedEntireMessage()) return false; - input->PopLimit(limit); - input->DecrementRecursionDepth(); - return true; -} - -// We name the template parameter something long and extremely unlikely to occur -// elsewhere because a *qualified* member access expression designed to avoid -// virtual dispatch, C++03 [basic.lookup.classref] 3.4.5/4 requires that the -// name of the qualifying class to be looked up both in the context of the full -// expression (finding the template parameter) and in the context of the object -// whose member we are accessing. This could potentially find a nested type -// within that object. The standard goes on to require these names to refer to -// the same entity, which this collision would violate. The lack of a safe way -// to avoid this collision appears to be a defect in the standard, but until it -// is corrected, we choose the name to avoid accidental collisions. -template -inline bool WireFormatLite::ReadGroupNoVirtual( - int field_number, io::CodedInputStream* input, - MessageType_WorkAroundCppLookupDefect* value) { - if (!input->IncrementRecursionDepth()) return false; - if (!value-> - MessageType_WorkAroundCppLookupDefect::MergePartialFromCodedStream(input)) - return false; - input->DecrementRecursionDepth(); - // Make sure the last thing read was an end tag for this group. - if (!input->LastTagWas(MakeTag(field_number, WIRETYPE_END_GROUP))) { - return false; - } - return true; -} -template -inline bool WireFormatLite::ReadMessageNoVirtual( - io::CodedInputStream* input, MessageType_WorkAroundCppLookupDefect* value) { - uint32 length; - if (!input->ReadVarint32(&length)) return false; - if (!input->IncrementRecursionDepth()) return false; - io::CodedInputStream::Limit limit = input->PushLimit(length); - if (!value-> - MessageType_WorkAroundCppLookupDefect::MergePartialFromCodedStream(input)) - return false; - // Make sure that parsing stopped when the limit was hit, not at an endgroup - // tag. - if (!input->ConsumedEntireMessage()) return false; - input->PopLimit(limit); - input->DecrementRecursionDepth(); - return true; -} - -// =================================================================== - -inline void WireFormatLite::WriteTag(int field_number, WireType type, - io::CodedOutputStream* output) { - output->WriteTag(MakeTag(field_number, type)); -} - -inline void WireFormatLite::WriteInt32NoTag(int32 value, - io::CodedOutputStream* output) { - output->WriteVarint32SignExtended(value); -} -inline void WireFormatLite::WriteInt64NoTag(int64 value, - io::CodedOutputStream* output) { - output->WriteVarint64(static_cast(value)); -} -inline void WireFormatLite::WriteUInt32NoTag(uint32 value, - io::CodedOutputStream* output) { - output->WriteVarint32(value); -} -inline void WireFormatLite::WriteUInt64NoTag(uint64 value, - io::CodedOutputStream* output) { - output->WriteVarint64(value); -} -inline void WireFormatLite::WriteSInt32NoTag(int32 value, - io::CodedOutputStream* output) { - output->WriteVarint32(ZigZagEncode32(value)); -} -inline void WireFormatLite::WriteSInt64NoTag(int64 value, - io::CodedOutputStream* output) { - output->WriteVarint64(ZigZagEncode64(value)); -} -inline void WireFormatLite::WriteFixed32NoTag(uint32 value, - io::CodedOutputStream* output) { - output->WriteLittleEndian32(value); -} -inline void WireFormatLite::WriteFixed64NoTag(uint64 value, - io::CodedOutputStream* output) { - output->WriteLittleEndian64(value); -} -inline void WireFormatLite::WriteSFixed32NoTag(int32 value, - io::CodedOutputStream* output) { - output->WriteLittleEndian32(static_cast(value)); -} -inline void WireFormatLite::WriteSFixed64NoTag(int64 value, - io::CodedOutputStream* output) { - output->WriteLittleEndian64(static_cast(value)); -} -inline void WireFormatLite::WriteFloatNoTag(float value, - io::CodedOutputStream* output) { - output->WriteLittleEndian32(EncodeFloat(value)); -} -inline void WireFormatLite::WriteDoubleNoTag(double value, - io::CodedOutputStream* output) { - output->WriteLittleEndian64(EncodeDouble(value)); -} -inline void WireFormatLite::WriteBoolNoTag(bool value, - io::CodedOutputStream* output) { - output->WriteVarint32(value ? 1 : 0); -} -inline void WireFormatLite::WriteEnumNoTag(int value, - io::CodedOutputStream* output) { - output->WriteVarint32SignExtended(value); -} - -// See comment on ReadGroupNoVirtual to understand the need for this template -// parameter name. -template -inline void WireFormatLite::WriteGroupNoVirtual( - int field_number, const MessageType_WorkAroundCppLookupDefect& value, - io::CodedOutputStream* output) { - WriteTag(field_number, WIRETYPE_START_GROUP, output); - value.MessageType_WorkAroundCppLookupDefect::SerializeWithCachedSizes(output); - WriteTag(field_number, WIRETYPE_END_GROUP, output); -} -template -inline void WireFormatLite::WriteMessageNoVirtual( - int field_number, const MessageType_WorkAroundCppLookupDefect& value, - io::CodedOutputStream* output) { - WriteTag(field_number, WIRETYPE_LENGTH_DELIMITED, output); - output->WriteVarint32( - value.MessageType_WorkAroundCppLookupDefect::GetCachedSize()); - value.MessageType_WorkAroundCppLookupDefect::SerializeWithCachedSizes(output); -} - -// =================================================================== - -inline uint8* WireFormatLite::WriteTagToArray(int field_number, - WireType type, - uint8* target) { - return io::CodedOutputStream::WriteTagToArray(MakeTag(field_number, type), - target); -} - -inline uint8* WireFormatLite::WriteInt32NoTagToArray(int32 value, - uint8* target) { - return io::CodedOutputStream::WriteVarint32SignExtendedToArray(value, target); -} -inline uint8* WireFormatLite::WriteInt64NoTagToArray(int64 value, - uint8* target) { - return io::CodedOutputStream::WriteVarint64ToArray( - static_cast(value), target); -} -inline uint8* WireFormatLite::WriteUInt32NoTagToArray(uint32 value, - uint8* target) { - return io::CodedOutputStream::WriteVarint32ToArray(value, target); -} -inline uint8* WireFormatLite::WriteUInt64NoTagToArray(uint64 value, - uint8* target) { - return io::CodedOutputStream::WriteVarint64ToArray(value, target); -} -inline uint8* WireFormatLite::WriteSInt32NoTagToArray(int32 value, - uint8* target) { - return io::CodedOutputStream::WriteVarint32ToArray(ZigZagEncode32(value), - target); -} -inline uint8* WireFormatLite::WriteSInt64NoTagToArray(int64 value, - uint8* target) { - return io::CodedOutputStream::WriteVarint64ToArray(ZigZagEncode64(value), - target); -} -inline uint8* WireFormatLite::WriteFixed32NoTagToArray(uint32 value, - uint8* target) { - return io::CodedOutputStream::WriteLittleEndian32ToArray(value, target); -} -inline uint8* WireFormatLite::WriteFixed64NoTagToArray(uint64 value, - uint8* target) { - return io::CodedOutputStream::WriteLittleEndian64ToArray(value, target); -} -inline uint8* WireFormatLite::WriteSFixed32NoTagToArray(int32 value, - uint8* target) { - return io::CodedOutputStream::WriteLittleEndian32ToArray( - static_cast(value), target); -} -inline uint8* WireFormatLite::WriteSFixed64NoTagToArray(int64 value, - uint8* target) { - return io::CodedOutputStream::WriteLittleEndian64ToArray( - static_cast(value), target); -} -inline uint8* WireFormatLite::WriteFloatNoTagToArray(float value, - uint8* target) { - return io::CodedOutputStream::WriteLittleEndian32ToArray(EncodeFloat(value), - target); -} -inline uint8* WireFormatLite::WriteDoubleNoTagToArray(double value, - uint8* target) { - return io::CodedOutputStream::WriteLittleEndian64ToArray(EncodeDouble(value), - target); -} -inline uint8* WireFormatLite::WriteBoolNoTagToArray(bool value, - uint8* target) { - return io::CodedOutputStream::WriteVarint32ToArray(value ? 1 : 0, target); -} -inline uint8* WireFormatLite::WriteEnumNoTagToArray(int value, - uint8* target) { - return io::CodedOutputStream::WriteVarint32SignExtendedToArray(value, target); -} - -inline uint8* WireFormatLite::WriteInt32ToArray(int field_number, - int32 value, - uint8* target) { - target = WriteTagToArray(field_number, WIRETYPE_VARINT, target); - return WriteInt32NoTagToArray(value, target); -} -inline uint8* WireFormatLite::WriteInt64ToArray(int field_number, - int64 value, - uint8* target) { - target = WriteTagToArray(field_number, WIRETYPE_VARINT, target); - return WriteInt64NoTagToArray(value, target); -} -inline uint8* WireFormatLite::WriteUInt32ToArray(int field_number, - uint32 value, - uint8* target) { - target = WriteTagToArray(field_number, WIRETYPE_VARINT, target); - return WriteUInt32NoTagToArray(value, target); -} -inline uint8* WireFormatLite::WriteUInt64ToArray(int field_number, - uint64 value, - uint8* target) { - target = WriteTagToArray(field_number, WIRETYPE_VARINT, target); - return WriteUInt64NoTagToArray(value, target); -} -inline uint8* WireFormatLite::WriteSInt32ToArray(int field_number, - int32 value, - uint8* target) { - target = WriteTagToArray(field_number, WIRETYPE_VARINT, target); - return WriteSInt32NoTagToArray(value, target); -} -inline uint8* WireFormatLite::WriteSInt64ToArray(int field_number, - int64 value, - uint8* target) { - target = WriteTagToArray(field_number, WIRETYPE_VARINT, target); - return WriteSInt64NoTagToArray(value, target); -} -inline uint8* WireFormatLite::WriteFixed32ToArray(int field_number, - uint32 value, - uint8* target) { - target = WriteTagToArray(field_number, WIRETYPE_FIXED32, target); - return WriteFixed32NoTagToArray(value, target); -} -inline uint8* WireFormatLite::WriteFixed64ToArray(int field_number, - uint64 value, - uint8* target) { - target = WriteTagToArray(field_number, WIRETYPE_FIXED64, target); - return WriteFixed64NoTagToArray(value, target); -} -inline uint8* WireFormatLite::WriteSFixed32ToArray(int field_number, - int32 value, - uint8* target) { - target = WriteTagToArray(field_number, WIRETYPE_FIXED32, target); - return WriteSFixed32NoTagToArray(value, target); -} -inline uint8* WireFormatLite::WriteSFixed64ToArray(int field_number, - int64 value, - uint8* target) { - target = WriteTagToArray(field_number, WIRETYPE_FIXED64, target); - return WriteSFixed64NoTagToArray(value, target); -} -inline uint8* WireFormatLite::WriteFloatToArray(int field_number, - float value, - uint8* target) { - target = WriteTagToArray(field_number, WIRETYPE_FIXED32, target); - return WriteFloatNoTagToArray(value, target); -} -inline uint8* WireFormatLite::WriteDoubleToArray(int field_number, - double value, - uint8* target) { - target = WriteTagToArray(field_number, WIRETYPE_FIXED64, target); - return WriteDoubleNoTagToArray(value, target); -} -inline uint8* WireFormatLite::WriteBoolToArray(int field_number, - bool value, - uint8* target) { - target = WriteTagToArray(field_number, WIRETYPE_VARINT, target); - return WriteBoolNoTagToArray(value, target); -} -inline uint8* WireFormatLite::WriteEnumToArray(int field_number, - int value, - uint8* target) { - target = WriteTagToArray(field_number, WIRETYPE_VARINT, target); - return WriteEnumNoTagToArray(value, target); -} - -inline uint8* WireFormatLite::WriteStringToArray(int field_number, - const string& value, - uint8* target) { - // String is for UTF-8 text only - // WARNING: In wire_format.cc, both strings and bytes are handled by - // WriteString() to avoid code duplication. If the implementations become - // different, you will need to update that usage. - target = WriteTagToArray(field_number, WIRETYPE_LENGTH_DELIMITED, target); - target = io::CodedOutputStream::WriteVarint32ToArray(value.size(), target); - return io::CodedOutputStream::WriteStringToArray(value, target); -} -inline uint8* WireFormatLite::WriteBytesToArray(int field_number, - const string& value, - uint8* target) { - target = WriteTagToArray(field_number, WIRETYPE_LENGTH_DELIMITED, target); - target = io::CodedOutputStream::WriteVarint32ToArray(value.size(), target); - return io::CodedOutputStream::WriteStringToArray(value, target); -} - - -inline uint8* WireFormatLite::WriteGroupToArray(int field_number, - const MessageLite& value, - uint8* target) { - target = WriteTagToArray(field_number, WIRETYPE_START_GROUP, target); - target = value.SerializeWithCachedSizesToArray(target); - return WriteTagToArray(field_number, WIRETYPE_END_GROUP, target); -} -inline uint8* WireFormatLite::WriteMessageToArray(int field_number, - const MessageLite& value, - uint8* target) { - target = WriteTagToArray(field_number, WIRETYPE_LENGTH_DELIMITED, target); - target = io::CodedOutputStream::WriteVarint32ToArray( - value.GetCachedSize(), target); - return value.SerializeWithCachedSizesToArray(target); -} - -// See comment on ReadGroupNoVirtual to understand the need for this template -// parameter name. -template -inline uint8* WireFormatLite::WriteGroupNoVirtualToArray( - int field_number, const MessageType_WorkAroundCppLookupDefect& value, - uint8* target) { - target = WriteTagToArray(field_number, WIRETYPE_START_GROUP, target); - target = value.MessageType_WorkAroundCppLookupDefect - ::SerializeWithCachedSizesToArray(target); - return WriteTagToArray(field_number, WIRETYPE_END_GROUP, target); -} -template -inline uint8* WireFormatLite::WriteMessageNoVirtualToArray( - int field_number, const MessageType_WorkAroundCppLookupDefect& value, - uint8* target) { - target = WriteTagToArray(field_number, WIRETYPE_LENGTH_DELIMITED, target); - target = io::CodedOutputStream::WriteVarint32ToArray( - value.MessageType_WorkAroundCppLookupDefect::GetCachedSize(), target); - return value.MessageType_WorkAroundCppLookupDefect - ::SerializeWithCachedSizesToArray(target); -} - -// =================================================================== - -inline int WireFormatLite::Int32Size(int32 value) { - return io::CodedOutputStream::VarintSize32SignExtended(value); -} -inline int WireFormatLite::Int64Size(int64 value) { - return io::CodedOutputStream::VarintSize64(static_cast(value)); -} -inline int WireFormatLite::UInt32Size(uint32 value) { - return io::CodedOutputStream::VarintSize32(value); -} -inline int WireFormatLite::UInt64Size(uint64 value) { - return io::CodedOutputStream::VarintSize64(value); -} -inline int WireFormatLite::SInt32Size(int32 value) { - return io::CodedOutputStream::VarintSize32(ZigZagEncode32(value)); -} -inline int WireFormatLite::SInt64Size(int64 value) { - return io::CodedOutputStream::VarintSize64(ZigZagEncode64(value)); -} -inline int WireFormatLite::EnumSize(int value) { - return io::CodedOutputStream::VarintSize32SignExtended(value); -} - -inline int WireFormatLite::StringSize(const string& value) { - return io::CodedOutputStream::VarintSize32(value.size()) + - value.size(); -} -inline int WireFormatLite::BytesSize(const string& value) { - return io::CodedOutputStream::VarintSize32(value.size()) + - value.size(); -} - - -inline int WireFormatLite::GroupSize(const MessageLite& value) { - return value.ByteSize(); -} -inline int WireFormatLite::MessageSize(const MessageLite& value) { - return LengthDelimitedSize(value.ByteSize()); -} - -// See comment on ReadGroupNoVirtual to understand the need for this template -// parameter name. -template -inline int WireFormatLite::GroupSizeNoVirtual( - const MessageType_WorkAroundCppLookupDefect& value) { - return value.MessageType_WorkAroundCppLookupDefect::ByteSize(); -} -template -inline int WireFormatLite::MessageSizeNoVirtual( - const MessageType_WorkAroundCppLookupDefect& value) { - return LengthDelimitedSize( - value.MessageType_WorkAroundCppLookupDefect::ByteSize()); -} - -inline int WireFormatLite::LengthDelimitedSize(int length) { - return io::CodedOutputStream::VarintSize32(length) + length; -} - -} // namespace internal -} // namespace protobuf - -} // namespace google -#endif // GOOGLE_PROTOBUF_WIRE_FORMAT_LITE_INL_H__ diff --git a/modules/dnn/3rdparty/protobuf/src/google/protobuf/wire_format_unittest.cc b/modules/dnn/3rdparty/protobuf/src/google/protobuf/wire_format_unittest.cc deleted file mode 100644 index 9822828b1..000000000 --- a/modules/dnn/3rdparty/protobuf/src/google/protobuf/wire_format_unittest.cc +++ /dev/null @@ -1,978 +0,0 @@ -// Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// http://code.google.com/p/protobuf/ -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -// Author: kenton@google.com (Kenton Varda) -// Based on original Protocol Buffers design by -// Sanjay Ghemawat, Jeff Dean, and others. - -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include - -namespace google { -namespace protobuf { -namespace internal { -namespace { - -TEST(WireFormatTest, EnumsInSync) { - // Verify that WireFormatLite::FieldType and WireFormatLite::CppType match - // FieldDescriptor::Type and FieldDescriptor::CppType. - - EXPECT_EQ(implicit_cast(FieldDescriptor::MAX_TYPE), - implicit_cast(WireFormatLite::MAX_FIELD_TYPE)); - EXPECT_EQ(implicit_cast(FieldDescriptor::MAX_CPPTYPE), - implicit_cast(WireFormatLite::MAX_CPPTYPE)); - - for (int i = 1; i <= WireFormatLite::MAX_FIELD_TYPE; i++) { - EXPECT_EQ( - implicit_cast(FieldDescriptor::TypeToCppType( - static_cast(i))), - implicit_cast(WireFormatLite::FieldTypeToCppType( - static_cast(i)))); - } -} - -TEST(WireFormatTest, MaxFieldNumber) { - // Make sure the max field number constant is accurate. - EXPECT_EQ((1 << (32 - WireFormatLite::kTagTypeBits)) - 1, - FieldDescriptor::kMaxNumber); -} - -TEST(WireFormatTest, Parse) { - unittest::TestAllTypes source, dest; - string data; - - // Serialize using the generated code. - TestUtil::SetAllFields(&source); - source.SerializeToString(&data); - - // Parse using WireFormat. - io::ArrayInputStream raw_input(data.data(), data.size()); - io::CodedInputStream input(&raw_input); - WireFormat::ParseAndMergePartial(&input, &dest); - - // Check. - TestUtil::ExpectAllFieldsSet(dest); -} - -TEST(WireFormatTest, ParseExtensions) { - unittest::TestAllExtensions source, dest; - string data; - - // Serialize using the generated code. - TestUtil::SetAllExtensions(&source); - source.SerializeToString(&data); - - // Parse using WireFormat. - io::ArrayInputStream raw_input(data.data(), data.size()); - io::CodedInputStream input(&raw_input); - WireFormat::ParseAndMergePartial(&input, &dest); - - // Check. - TestUtil::ExpectAllExtensionsSet(dest); -} - -TEST(WireFormatTest, ParsePacked) { - unittest::TestPackedTypes source, dest; - string data; - - // Serialize using the generated code. - TestUtil::SetPackedFields(&source); - source.SerializeToString(&data); - - // Parse using WireFormat. - io::ArrayInputStream raw_input(data.data(), data.size()); - io::CodedInputStream input(&raw_input); - WireFormat::ParseAndMergePartial(&input, &dest); - - // Check. - TestUtil::ExpectPackedFieldsSet(dest); -} - -TEST(WireFormatTest, ParsePackedFromUnpacked) { - // Serialize using the generated code. - unittest::TestUnpackedTypes source; - TestUtil::SetUnpackedFields(&source); - string data = source.SerializeAsString(); - - // Parse using WireFormat. - unittest::TestPackedTypes dest; - io::ArrayInputStream raw_input(data.data(), data.size()); - io::CodedInputStream input(&raw_input); - WireFormat::ParseAndMergePartial(&input, &dest); - - // Check. - TestUtil::ExpectPackedFieldsSet(dest); -} - -TEST(WireFormatTest, ParseUnpackedFromPacked) { - // Serialize using the generated code. - unittest::TestPackedTypes source; - TestUtil::SetPackedFields(&source); - string data = source.SerializeAsString(); - - // Parse using WireFormat. - unittest::TestUnpackedTypes dest; - io::ArrayInputStream raw_input(data.data(), data.size()); - io::CodedInputStream input(&raw_input); - WireFormat::ParseAndMergePartial(&input, &dest); - - // Check. - TestUtil::ExpectUnpackedFieldsSet(dest); -} - -TEST(WireFormatTest, ParsePackedExtensions) { - unittest::TestPackedExtensions source, dest; - string data; - - // Serialize using the generated code. - TestUtil::SetPackedExtensions(&source); - source.SerializeToString(&data); - - // Parse using WireFormat. - io::ArrayInputStream raw_input(data.data(), data.size()); - io::CodedInputStream input(&raw_input); - WireFormat::ParseAndMergePartial(&input, &dest); - - // Check. - TestUtil::ExpectPackedExtensionsSet(dest); -} - -TEST(WireFormatTest, ByteSize) { - unittest::TestAllTypes message; - TestUtil::SetAllFields(&message); - - EXPECT_EQ(message.ByteSize(), WireFormat::ByteSize(message)); - message.Clear(); - EXPECT_EQ(0, message.ByteSize()); - EXPECT_EQ(0, WireFormat::ByteSize(message)); -} - -TEST(WireFormatTest, ByteSizeExtensions) { - unittest::TestAllExtensions message; - TestUtil::SetAllExtensions(&message); - - EXPECT_EQ(message.ByteSize(), - WireFormat::ByteSize(message)); - message.Clear(); - EXPECT_EQ(0, message.ByteSize()); - EXPECT_EQ(0, WireFormat::ByteSize(message)); -} - -TEST(WireFormatTest, ByteSizePacked) { - unittest::TestPackedTypes message; - TestUtil::SetPackedFields(&message); - - EXPECT_EQ(message.ByteSize(), WireFormat::ByteSize(message)); - message.Clear(); - EXPECT_EQ(0, message.ByteSize()); - EXPECT_EQ(0, WireFormat::ByteSize(message)); -} - -TEST(WireFormatTest, ByteSizePackedExtensions) { - unittest::TestPackedExtensions message; - TestUtil::SetPackedExtensions(&message); - - EXPECT_EQ(message.ByteSize(), - WireFormat::ByteSize(message)); - message.Clear(); - EXPECT_EQ(0, message.ByteSize()); - EXPECT_EQ(0, WireFormat::ByteSize(message)); -} - -TEST(WireFormatTest, Serialize) { - unittest::TestAllTypes message; - string generated_data; - string dynamic_data; - - TestUtil::SetAllFields(&message); - int size = message.ByteSize(); - - // Serialize using the generated code. - { - io::StringOutputStream raw_output(&generated_data); - io::CodedOutputStream output(&raw_output); - message.SerializeWithCachedSizes(&output); - ASSERT_FALSE(output.HadError()); - } - - // Serialize using WireFormat. - { - io::StringOutputStream raw_output(&dynamic_data); - io::CodedOutputStream output(&raw_output); - WireFormat::SerializeWithCachedSizes(message, size, &output); - ASSERT_FALSE(output.HadError()); - } - - // Should be the same. - // Don't use EXPECT_EQ here because we're comparing raw binary data and - // we really don't want it dumped to stdout on failure. - EXPECT_TRUE(dynamic_data == generated_data); -} - -TEST(WireFormatTest, SerializeExtensions) { - unittest::TestAllExtensions message; - string generated_data; - string dynamic_data; - - TestUtil::SetAllExtensions(&message); - int size = message.ByteSize(); - - // Serialize using the generated code. - { - io::StringOutputStream raw_output(&generated_data); - io::CodedOutputStream output(&raw_output); - message.SerializeWithCachedSizes(&output); - ASSERT_FALSE(output.HadError()); - } - - // Serialize using WireFormat. - { - io::StringOutputStream raw_output(&dynamic_data); - io::CodedOutputStream output(&raw_output); - WireFormat::SerializeWithCachedSizes(message, size, &output); - ASSERT_FALSE(output.HadError()); - } - - // Should be the same. - // Don't use EXPECT_EQ here because we're comparing raw binary data and - // we really don't want it dumped to stdout on failure. - EXPECT_TRUE(dynamic_data == generated_data); -} - -TEST(WireFormatTest, SerializeFieldsAndExtensions) { - unittest::TestFieldOrderings message; - string generated_data; - string dynamic_data; - - TestUtil::SetAllFieldsAndExtensions(&message); - int size = message.ByteSize(); - - // Serialize using the generated code. - { - io::StringOutputStream raw_output(&generated_data); - io::CodedOutputStream output(&raw_output); - message.SerializeWithCachedSizes(&output); - ASSERT_FALSE(output.HadError()); - } - - // Serialize using WireFormat. - { - io::StringOutputStream raw_output(&dynamic_data); - io::CodedOutputStream output(&raw_output); - WireFormat::SerializeWithCachedSizes(message, size, &output); - ASSERT_FALSE(output.HadError()); - } - - // Should be the same. - // Don't use EXPECT_EQ here because we're comparing raw binary data and - // we really don't want it dumped to stdout on failure. - EXPECT_TRUE(dynamic_data == generated_data); - - // Should output in canonical order. - TestUtil::ExpectAllFieldsAndExtensionsInOrder(dynamic_data); - TestUtil::ExpectAllFieldsAndExtensionsInOrder(generated_data); -} - -TEST(WireFormatTest, ParseMultipleExtensionRanges) { - // Make sure we can parse a message that contains multiple extensions ranges. - unittest::TestFieldOrderings source; - string data; - - TestUtil::SetAllFieldsAndExtensions(&source); - source.SerializeToString(&data); - - { - unittest::TestFieldOrderings dest; - EXPECT_TRUE(dest.ParseFromString(data)); - EXPECT_EQ(source.DebugString(), dest.DebugString()); - } - - // Also test using reflection-based parsing. - { - unittest::TestFieldOrderings dest; - io::ArrayInputStream raw_input(data.data(), data.size()); - io::CodedInputStream coded_input(&raw_input); - EXPECT_TRUE(WireFormat::ParseAndMergePartial(&coded_input, &dest)); - EXPECT_EQ(source.DebugString(), dest.DebugString()); - } -} - -const int kUnknownTypeId = 1550055; - -TEST(WireFormatTest, SerializeMessageSet) { - // Set up a TestMessageSet with two known messages and an unknown one. - unittest::TestMessageSet message_set; - message_set.MutableExtension( - unittest::TestMessageSetExtension1::message_set_extension)->set_i(123); - message_set.MutableExtension( - unittest::TestMessageSetExtension2::message_set_extension)->set_str("foo"); - message_set.mutable_unknown_fields()->AddLengthDelimited( - kUnknownTypeId, "bar"); - - string data; - ASSERT_TRUE(message_set.SerializeToString(&data)); - - // Parse back using RawMessageSet and check the contents. - unittest::RawMessageSet raw; - ASSERT_TRUE(raw.ParseFromString(data)); - - EXPECT_EQ(0, raw.unknown_fields().field_count()); - - ASSERT_EQ(3, raw.item_size()); - EXPECT_EQ( - unittest::TestMessageSetExtension1::descriptor()->extension(0)->number(), - raw.item(0).type_id()); - EXPECT_EQ( - unittest::TestMessageSetExtension2::descriptor()->extension(0)->number(), - raw.item(1).type_id()); - EXPECT_EQ(kUnknownTypeId, raw.item(2).type_id()); - - unittest::TestMessageSetExtension1 message1; - EXPECT_TRUE(message1.ParseFromString(raw.item(0).message())); - EXPECT_EQ(123, message1.i()); - - unittest::TestMessageSetExtension2 message2; - EXPECT_TRUE(message2.ParseFromString(raw.item(1).message())); - EXPECT_EQ("foo", message2.str()); - - EXPECT_EQ("bar", raw.item(2).message()); -} - -TEST(WireFormatTest, SerializeMessageSetVariousWaysAreEqual) { - // Serialize a MessageSet to a stream and to a flat array using generated - // code, and also using WireFormat, and check that the results are equal. - // Set up a TestMessageSet with two known messages and an unknown one, as - // above. - - unittest::TestMessageSet message_set; - message_set.MutableExtension( - unittest::TestMessageSetExtension1::message_set_extension)->set_i(123); - message_set.MutableExtension( - unittest::TestMessageSetExtension2::message_set_extension)->set_str("foo"); - message_set.mutable_unknown_fields()->AddLengthDelimited( - kUnknownTypeId, "bar"); - - int size = message_set.ByteSize(); - EXPECT_EQ(size, message_set.GetCachedSize()); - ASSERT_EQ(size, WireFormat::ByteSize(message_set)); - - string flat_data; - string stream_data; - string dynamic_data; - flat_data.resize(size); - stream_data.resize(size); - - // Serialize to flat array - { - uint8* target = reinterpret_cast(string_as_array(&flat_data)); - uint8* end = message_set.SerializeWithCachedSizesToArray(target); - EXPECT_EQ(size, end - target); - } - - // Serialize to buffer - { - io::ArrayOutputStream array_stream(string_as_array(&stream_data), size, 1); - io::CodedOutputStream output_stream(&array_stream); - message_set.SerializeWithCachedSizes(&output_stream); - ASSERT_FALSE(output_stream.HadError()); - } - - // Serialize to buffer with WireFormat. - { - io::StringOutputStream string_stream(&dynamic_data); - io::CodedOutputStream output_stream(&string_stream); - WireFormat::SerializeWithCachedSizes(message_set, size, &output_stream); - ASSERT_FALSE(output_stream.HadError()); - } - - EXPECT_TRUE(flat_data == stream_data); - EXPECT_TRUE(flat_data == dynamic_data); -} - -TEST(WireFormatTest, ParseMessageSet) { - // Set up a RawMessageSet with two known messages and an unknown one. - unittest::RawMessageSet raw; - - { - unittest::RawMessageSet::Item* item = raw.add_item(); - item->set_type_id( - unittest::TestMessageSetExtension1::descriptor()->extension(0)->number()); - unittest::TestMessageSetExtension1 message; - message.set_i(123); - message.SerializeToString(item->mutable_message()); - } - - { - unittest::RawMessageSet::Item* item = raw.add_item(); - item->set_type_id( - unittest::TestMessageSetExtension2::descriptor()->extension(0)->number()); - unittest::TestMessageSetExtension2 message; - message.set_str("foo"); - message.SerializeToString(item->mutable_message()); - } - - { - unittest::RawMessageSet::Item* item = raw.add_item(); - item->set_type_id(kUnknownTypeId); - item->set_message("bar"); - } - - string data; - ASSERT_TRUE(raw.SerializeToString(&data)); - - // Parse as a TestMessageSet and check the contents. - unittest::TestMessageSet message_set; - ASSERT_TRUE(message_set.ParseFromString(data)); - - EXPECT_EQ(123, message_set.GetExtension( - unittest::TestMessageSetExtension1::message_set_extension).i()); - EXPECT_EQ("foo", message_set.GetExtension( - unittest::TestMessageSetExtension2::message_set_extension).str()); - - ASSERT_EQ(1, message_set.unknown_fields().field_count()); - ASSERT_EQ(UnknownField::TYPE_LENGTH_DELIMITED, - message_set.unknown_fields().field(0).type()); - EXPECT_EQ("bar", message_set.unknown_fields().field(0).length_delimited()); - - // Also parse using WireFormat. - unittest::TestMessageSet dynamic_message_set; - io::CodedInputStream input(reinterpret_cast(data.data()), - data.size()); - ASSERT_TRUE(WireFormat::ParseAndMergePartial(&input, &dynamic_message_set)); - EXPECT_EQ(message_set.DebugString(), dynamic_message_set.DebugString()); -} - -TEST(WireFormatTest, ParseMessageSetWithReverseTagOrder) { - string data; - { - unittest::TestMessageSetExtension1 message; - message.set_i(123); - // Build a MessageSet manually with its message content put before its - // type_id. - io::StringOutputStream output_stream(&data); - io::CodedOutputStream coded_output(&output_stream); - coded_output.WriteTag(WireFormatLite::kMessageSetItemStartTag); - // Write the message content first. - WireFormatLite::WriteTag(WireFormatLite::kMessageSetMessageNumber, - WireFormatLite::WIRETYPE_LENGTH_DELIMITED, - &coded_output); - coded_output.WriteVarint32(message.ByteSize()); - message.SerializeWithCachedSizes(&coded_output); - // Write the type id. - uint32 type_id = message.GetDescriptor()->extension(0)->number(); - WireFormatLite::WriteUInt32(WireFormatLite::kMessageSetTypeIdNumber, - type_id, &coded_output); - coded_output.WriteTag(WireFormatLite::kMessageSetItemEndTag); - } - { - unittest::TestMessageSet message_set; - ASSERT_TRUE(message_set.ParseFromString(data)); - - EXPECT_EQ(123, message_set.GetExtension( - unittest::TestMessageSetExtension1::message_set_extension).i()); - } - { - // Test parse the message via Reflection. - unittest::TestMessageSet message_set; - io::CodedInputStream input( - reinterpret_cast(data.data()), data.size()); - EXPECT_TRUE(WireFormat::ParseAndMergePartial(&input, &message_set)); - EXPECT_TRUE(input.ConsumedEntireMessage()); - - EXPECT_EQ(123, message_set.GetExtension( - unittest::TestMessageSetExtension1::message_set_extension).i()); - } -} - -TEST(WireFormatTest, ParseBrokenMessageSet) { - unittest::TestMessageSet message_set; - string input("goodbye"); // Invalid wire format data. - EXPECT_FALSE(message_set.ParseFromString(input)); -} - -TEST(WireFormatTest, RecursionLimit) { - unittest::TestRecursiveMessage message; - message.mutable_a()->mutable_a()->mutable_a()->mutable_a()->set_i(1); - string data; - message.SerializeToString(&data); - - { - io::ArrayInputStream raw_input(data.data(), data.size()); - io::CodedInputStream input(&raw_input); - input.SetRecursionLimit(4); - unittest::TestRecursiveMessage message2; - EXPECT_TRUE(message2.ParseFromCodedStream(&input)); - } - - { - io::ArrayInputStream raw_input(data.data(), data.size()); - io::CodedInputStream input(&raw_input); - input.SetRecursionLimit(3); - unittest::TestRecursiveMessage message2; - EXPECT_FALSE(message2.ParseFromCodedStream(&input)); - } -} - -TEST(WireFormatTest, UnknownFieldRecursionLimit) { - unittest::TestEmptyMessage message; - message.mutable_unknown_fields() - ->AddGroup(1234) - ->AddGroup(1234) - ->AddGroup(1234) - ->AddGroup(1234) - ->AddVarint(1234, 123); - string data; - message.SerializeToString(&data); - - { - io::ArrayInputStream raw_input(data.data(), data.size()); - io::CodedInputStream input(&raw_input); - input.SetRecursionLimit(4); - unittest::TestEmptyMessage message2; - EXPECT_TRUE(message2.ParseFromCodedStream(&input)); - } - - { - io::ArrayInputStream raw_input(data.data(), data.size()); - io::CodedInputStream input(&raw_input); - input.SetRecursionLimit(3); - unittest::TestEmptyMessage message2; - EXPECT_FALSE(message2.ParseFromCodedStream(&input)); - } -} - -TEST(WireFormatTest, ZigZag) { -// avoid line-wrapping -#define LL(x) GOOGLE_LONGLONG(x) -#define ULL(x) GOOGLE_ULONGLONG(x) -#define ZigZagEncode32(x) WireFormatLite::ZigZagEncode32(x) -#define ZigZagDecode32(x) WireFormatLite::ZigZagDecode32(x) -#define ZigZagEncode64(x) WireFormatLite::ZigZagEncode64(x) -#define ZigZagDecode64(x) WireFormatLite::ZigZagDecode64(x) - - EXPECT_EQ(0u, ZigZagEncode32( 0)); - EXPECT_EQ(1u, ZigZagEncode32(-1)); - EXPECT_EQ(2u, ZigZagEncode32( 1)); - EXPECT_EQ(3u, ZigZagEncode32(-2)); - EXPECT_EQ(0x7FFFFFFEu, ZigZagEncode32(0x3FFFFFFF)); - EXPECT_EQ(0x7FFFFFFFu, ZigZagEncode32(0xC0000000)); - EXPECT_EQ(0xFFFFFFFEu, ZigZagEncode32(0x7FFFFFFF)); - EXPECT_EQ(0xFFFFFFFFu, ZigZagEncode32(0x80000000)); - - EXPECT_EQ( 0, ZigZagDecode32(0u)); - EXPECT_EQ(-1, ZigZagDecode32(1u)); - EXPECT_EQ( 1, ZigZagDecode32(2u)); - EXPECT_EQ(-2, ZigZagDecode32(3u)); - EXPECT_EQ(0x3FFFFFFF, ZigZagDecode32(0x7FFFFFFEu)); - EXPECT_EQ(0xC0000000, ZigZagDecode32(0x7FFFFFFFu)); - EXPECT_EQ(0x7FFFFFFF, ZigZagDecode32(0xFFFFFFFEu)); - EXPECT_EQ(0x80000000, ZigZagDecode32(0xFFFFFFFFu)); - - EXPECT_EQ(0u, ZigZagEncode64( 0)); - EXPECT_EQ(1u, ZigZagEncode64(-1)); - EXPECT_EQ(2u, ZigZagEncode64( 1)); - EXPECT_EQ(3u, ZigZagEncode64(-2)); - EXPECT_EQ(ULL(0x000000007FFFFFFE), ZigZagEncode64(LL(0x000000003FFFFFFF))); - EXPECT_EQ(ULL(0x000000007FFFFFFF), ZigZagEncode64(LL(0xFFFFFFFFC0000000))); - EXPECT_EQ(ULL(0x00000000FFFFFFFE), ZigZagEncode64(LL(0x000000007FFFFFFF))); - EXPECT_EQ(ULL(0x00000000FFFFFFFF), ZigZagEncode64(LL(0xFFFFFFFF80000000))); - EXPECT_EQ(ULL(0xFFFFFFFFFFFFFFFE), ZigZagEncode64(LL(0x7FFFFFFFFFFFFFFF))); - EXPECT_EQ(ULL(0xFFFFFFFFFFFFFFFF), ZigZagEncode64(LL(0x8000000000000000))); - - EXPECT_EQ( 0, ZigZagDecode64(0u)); - EXPECT_EQ(-1, ZigZagDecode64(1u)); - EXPECT_EQ( 1, ZigZagDecode64(2u)); - EXPECT_EQ(-2, ZigZagDecode64(3u)); - EXPECT_EQ(LL(0x000000003FFFFFFF), ZigZagDecode64(ULL(0x000000007FFFFFFE))); - EXPECT_EQ(LL(0xFFFFFFFFC0000000), ZigZagDecode64(ULL(0x000000007FFFFFFF))); - EXPECT_EQ(LL(0x000000007FFFFFFF), ZigZagDecode64(ULL(0x00000000FFFFFFFE))); - EXPECT_EQ(LL(0xFFFFFFFF80000000), ZigZagDecode64(ULL(0x00000000FFFFFFFF))); - EXPECT_EQ(LL(0x7FFFFFFFFFFFFFFF), ZigZagDecode64(ULL(0xFFFFFFFFFFFFFFFE))); - EXPECT_EQ(LL(0x8000000000000000), ZigZagDecode64(ULL(0xFFFFFFFFFFFFFFFF))); - - // Some easier-to-verify round-trip tests. The inputs (other than 0, 1, -1) - // were chosen semi-randomly via keyboard bashing. - EXPECT_EQ( 0, ZigZagDecode32(ZigZagEncode32( 0))); - EXPECT_EQ( 1, ZigZagDecode32(ZigZagEncode32( 1))); - EXPECT_EQ( -1, ZigZagDecode32(ZigZagEncode32( -1))); - EXPECT_EQ(14927, ZigZagDecode32(ZigZagEncode32(14927))); - EXPECT_EQ(-3612, ZigZagDecode32(ZigZagEncode32(-3612))); - - EXPECT_EQ( 0, ZigZagDecode64(ZigZagEncode64( 0))); - EXPECT_EQ( 1, ZigZagDecode64(ZigZagEncode64( 1))); - EXPECT_EQ( -1, ZigZagDecode64(ZigZagEncode64( -1))); - EXPECT_EQ(14927, ZigZagDecode64(ZigZagEncode64(14927))); - EXPECT_EQ(-3612, ZigZagDecode64(ZigZagEncode64(-3612))); - - EXPECT_EQ(LL(856912304801416), ZigZagDecode64(ZigZagEncode64( - LL(856912304801416)))); - EXPECT_EQ(LL(-75123905439571256), ZigZagDecode64(ZigZagEncode64( - LL(-75123905439571256)))); -} - -TEST(WireFormatTest, RepeatedScalarsDifferentTagSizes) { - // At one point checks would trigger when parsing repeated fixed scalar - // fields. - protobuf_unittest::TestRepeatedScalarDifferentTagSizes msg1, msg2; - for (int i = 0; i < 100; ++i) { - msg1.add_repeated_fixed32(i); - msg1.add_repeated_int32(i); - msg1.add_repeated_fixed64(i); - msg1.add_repeated_int64(i); - msg1.add_repeated_float(i); - msg1.add_repeated_uint64(i); - } - - // Make sure that we have a variety of tag sizes. - const google::protobuf::Descriptor* desc = msg1.GetDescriptor(); - const google::protobuf::FieldDescriptor* field; - field = desc->FindFieldByName("repeated_fixed32"); - ASSERT_TRUE(field != NULL); - ASSERT_EQ(1, WireFormat::TagSize(field->number(), field->type())); - field = desc->FindFieldByName("repeated_int32"); - ASSERT_TRUE(field != NULL); - ASSERT_EQ(1, WireFormat::TagSize(field->number(), field->type())); - field = desc->FindFieldByName("repeated_fixed64"); - ASSERT_TRUE(field != NULL); - ASSERT_EQ(2, WireFormat::TagSize(field->number(), field->type())); - field = desc->FindFieldByName("repeated_int64"); - ASSERT_TRUE(field != NULL); - ASSERT_EQ(2, WireFormat::TagSize(field->number(), field->type())); - field = desc->FindFieldByName("repeated_float"); - ASSERT_TRUE(field != NULL); - ASSERT_EQ(3, WireFormat::TagSize(field->number(), field->type())); - field = desc->FindFieldByName("repeated_uint64"); - ASSERT_TRUE(field != NULL); - ASSERT_EQ(3, WireFormat::TagSize(field->number(), field->type())); - - EXPECT_TRUE(msg2.ParseFromString(msg1.SerializeAsString())); - EXPECT_EQ(msg1.DebugString(), msg2.DebugString()); -} - -class WireFormatInvalidInputTest : public testing::Test { - protected: - // Make a serialized TestAllTypes in which the field optional_nested_message - // contains exactly the given bytes, which may be invalid. - string MakeInvalidEmbeddedMessage(const char* bytes, int size) { - const FieldDescriptor* field = - unittest::TestAllTypes::descriptor()->FindFieldByName( - "optional_nested_message"); - GOOGLE_CHECK(field != NULL); - - string result; - - { - io::StringOutputStream raw_output(&result); - io::CodedOutputStream output(&raw_output); - - WireFormatLite::WriteBytes(field->number(), string(bytes, size), &output); - } - - return result; - } - - // Make a serialized TestAllTypes in which the field optionalgroup - // contains exactly the given bytes -- which may be invalid -- and - // possibly no end tag. - string MakeInvalidGroup(const char* bytes, int size, bool include_end_tag) { - const FieldDescriptor* field = - unittest::TestAllTypes::descriptor()->FindFieldByName( - "optionalgroup"); - GOOGLE_CHECK(field != NULL); - - string result; - - { - io::StringOutputStream raw_output(&result); - io::CodedOutputStream output(&raw_output); - - output.WriteVarint32(WireFormat::MakeTag(field)); - output.WriteString(string(bytes, size)); - if (include_end_tag) { - output.WriteVarint32(WireFormatLite::MakeTag( - field->number(), WireFormatLite::WIRETYPE_END_GROUP)); - } - } - - return result; - } -}; - -TEST_F(WireFormatInvalidInputTest, InvalidSubMessage) { - unittest::TestAllTypes message; - - // Control case. - EXPECT_TRUE(message.ParseFromString(MakeInvalidEmbeddedMessage("", 0))); - - // The byte is a valid varint, but not a valid tag (zero). - EXPECT_FALSE(message.ParseFromString(MakeInvalidEmbeddedMessage("\0", 1))); - - // The byte is a malformed varint. - EXPECT_FALSE(message.ParseFromString(MakeInvalidEmbeddedMessage("\200", 1))); - - // The byte is an endgroup tag, but we aren't parsing a group. - EXPECT_FALSE(message.ParseFromString(MakeInvalidEmbeddedMessage("\014", 1))); - - // The byte is a valid varint but not a valid tag (bad wire type). - EXPECT_FALSE(message.ParseFromString(MakeInvalidEmbeddedMessage("\017", 1))); -} - -TEST_F(WireFormatInvalidInputTest, InvalidGroup) { - unittest::TestAllTypes message; - - // Control case. - EXPECT_TRUE(message.ParseFromString(MakeInvalidGroup("", 0, true))); - - // Missing end tag. Groups cannot end at EOF. - EXPECT_FALSE(message.ParseFromString(MakeInvalidGroup("", 0, false))); - - // The byte is a valid varint, but not a valid tag (zero). - EXPECT_FALSE(message.ParseFromString(MakeInvalidGroup("\0", 1, false))); - - // The byte is a malformed varint. - EXPECT_FALSE(message.ParseFromString(MakeInvalidGroup("\200", 1, false))); - - // The byte is an endgroup tag, but not the right one for this group. - EXPECT_FALSE(message.ParseFromString(MakeInvalidGroup("\014", 1, false))); - - // The byte is a valid varint but not a valid tag (bad wire type). - EXPECT_FALSE(message.ParseFromString(MakeInvalidGroup("\017", 1, true))); -} - -TEST_F(WireFormatInvalidInputTest, InvalidUnknownGroup) { - // Use TestEmptyMessage so that the group made by MakeInvalidGroup will not - // be a known tag number. - unittest::TestEmptyMessage message; - - // Control case. - EXPECT_TRUE(message.ParseFromString(MakeInvalidGroup("", 0, true))); - - // Missing end tag. Groups cannot end at EOF. - EXPECT_FALSE(message.ParseFromString(MakeInvalidGroup("", 0, false))); - - // The byte is a valid varint, but not a valid tag (zero). - EXPECT_FALSE(message.ParseFromString(MakeInvalidGroup("\0", 1, false))); - - // The byte is a malformed varint. - EXPECT_FALSE(message.ParseFromString(MakeInvalidGroup("\200", 1, false))); - - // The byte is an endgroup tag, but not the right one for this group. - EXPECT_FALSE(message.ParseFromString(MakeInvalidGroup("\014", 1, false))); - - // The byte is a valid varint but not a valid tag (bad wire type). - EXPECT_FALSE(message.ParseFromString(MakeInvalidGroup("\017", 1, true))); -} - -TEST_F(WireFormatInvalidInputTest, InvalidStringInUnknownGroup) { - // Test a bug fix: SkipMessage should fail if the message contains a string - // whose length would extend beyond the message end. - - unittest::TestAllTypes message; - message.set_optional_string("foo foo foo foo"); - string data; - message.SerializeToString(&data); - - // Chop some bytes off the end. - data.resize(data.size() - 4); - - // Try to skip it. Note that the bug was only present when parsing to an - // UnknownFieldSet. - io::ArrayInputStream raw_input(data.data(), data.size()); - io::CodedInputStream coded_input(&raw_input); - UnknownFieldSet unknown_fields; - EXPECT_FALSE(WireFormat::SkipMessage(&coded_input, &unknown_fields)); -} - -// Test differences between string and bytes. -// Value of a string type must be valid UTF-8 string. When UTF-8 -// validation is enabled (GOOGLE_PROTOBUF_UTF8_VALIDATION_ENABLED): -// WriteInvalidUTF8String: see error message. -// ReadInvalidUTF8String: see error message. -// WriteValidUTF8String: fine. -// ReadValidUTF8String: fine. -// WriteAnyBytes: fine. -// ReadAnyBytes: fine. -const char * kInvalidUTF8String = "Invalid UTF-8: \xA0\xB0\xC0\xD0"; -// This used to be "Valid UTF-8: \x01\x02\u8C37\u6B4C", but MSVC seems to -// interpret \u differently from GCC. -const char * kValidUTF8String = "Valid UTF-8: \x01\x02\350\260\267\346\255\214"; - -template -bool WriteMessage(const char *value, T *message, string *wire_buffer) { - message->set_data(value); - wire_buffer->clear(); - message->AppendToString(wire_buffer); - return (wire_buffer->size() > 0); -} - -template -bool ReadMessage(const string &wire_buffer, T *message) { - return message->ParseFromArray(wire_buffer.data(), wire_buffer.size()); -} - -bool StartsWith(const string& s, const string& prefix) { - return s.substr(0, prefix.length()) == prefix; -} - -TEST(Utf8ValidationTest, WriteInvalidUTF8String) { - string wire_buffer; - protobuf_unittest::OneString input; - vector errors; - { - ScopedMemoryLog log; - WriteMessage(kInvalidUTF8String, &input, &wire_buffer); - errors = log.GetMessages(ERROR); - } -#ifdef GOOGLE_PROTOBUF_UTF8_VALIDATION_ENABLED - ASSERT_EQ(1, errors.size()); - EXPECT_TRUE(StartsWith(errors[0], - "String field contains invalid UTF-8 data when " - "serializing a protocol buffer. Use the " - "'bytes' type if you intend to send raw bytes.")); -#else - ASSERT_EQ(0, errors.size()); -#endif // GOOGLE_PROTOBUF_UTF8_VALIDATION_ENABLED -} - -TEST(Utf8ValidationTest, ReadInvalidUTF8String) { - string wire_buffer; - protobuf_unittest::OneString input; - WriteMessage(kInvalidUTF8String, &input, &wire_buffer); - protobuf_unittest::OneString output; - vector errors; - { - ScopedMemoryLog log; - ReadMessage(wire_buffer, &output); - errors = log.GetMessages(ERROR); - } -#ifdef GOOGLE_PROTOBUF_UTF8_VALIDATION_ENABLED - ASSERT_EQ(1, errors.size()); - EXPECT_TRUE(StartsWith(errors[0], - "String field contains invalid UTF-8 data when " - "parsing a protocol buffer. Use the " - "'bytes' type if you intend to send raw bytes.")); - -#else - ASSERT_EQ(0, errors.size()); -#endif // GOOGLE_PROTOBUF_UTF8_VALIDATION_ENABLED -} - -TEST(Utf8ValidationTest, WriteValidUTF8String) { - string wire_buffer; - protobuf_unittest::OneString input; - vector errors; - { - ScopedMemoryLog log; - WriteMessage(kValidUTF8String, &input, &wire_buffer); - errors = log.GetMessages(ERROR); - } - ASSERT_EQ(0, errors.size()); -} - -TEST(Utf8ValidationTest, ReadValidUTF8String) { - string wire_buffer; - protobuf_unittest::OneString input; - WriteMessage(kValidUTF8String, &input, &wire_buffer); - protobuf_unittest::OneString output; - vector errors; - { - ScopedMemoryLog log; - ReadMessage(wire_buffer, &output); - errors = log.GetMessages(ERROR); - } - ASSERT_EQ(0, errors.size()); - EXPECT_EQ(input.data(), output.data()); -} - -// Bytes: anything can pass as bytes, use invalid UTF-8 string to test -TEST(Utf8ValidationTest, WriteArbitraryBytes) { - string wire_buffer; - protobuf_unittest::OneBytes input; - vector errors; - { - ScopedMemoryLog log; - WriteMessage(kInvalidUTF8String, &input, &wire_buffer); - errors = log.GetMessages(ERROR); - } - ASSERT_EQ(0, errors.size()); -} - -TEST(Utf8ValidationTest, ReadArbitraryBytes) { - string wire_buffer; - protobuf_unittest::OneBytes input; - WriteMessage(kInvalidUTF8String, &input, &wire_buffer); - protobuf_unittest::OneBytes output; - vector errors; - { - ScopedMemoryLog log; - ReadMessage(wire_buffer, &output); - errors = log.GetMessages(ERROR); - } - ASSERT_EQ(0, errors.size()); - EXPECT_EQ(input.data(), output.data()); -} - -TEST(Utf8ValidationTest, ParseRepeatedString) { - protobuf_unittest::MoreBytes input; - input.add_data(kValidUTF8String); - input.add_data(kInvalidUTF8String); - input.add_data(kInvalidUTF8String); - string wire_buffer = input.SerializeAsString(); - - protobuf_unittest::MoreString output; - vector errors; - { - ScopedMemoryLog log; - ReadMessage(wire_buffer, &output); - errors = log.GetMessages(ERROR); - } -#ifdef GOOGLE_PROTOBUF_UTF8_VALIDATION_ENABLED - ASSERT_EQ(2, errors.size()); -#else - ASSERT_EQ(0, errors.size()); -#endif // GOOGLE_PROTOBUF_UTF8_VALIDATION_ENABLED - EXPECT_EQ(wire_buffer, output.SerializeAsString()); -} - -} // namespace -} // namespace internal -} // namespace protobuf -} // namespace google From 57d63db9c37e32106502c5ae58f1bcf6be095f93 Mon Sep 17 00:00:00 2001 From: Alexander Alekhin Date: Tue, 22 Nov 2016 02:04:39 +0300 Subject: [PATCH 2/3] 3rdparty: libprotobuf v3.1.0 --- modules/dnn/3rdparty/protobuf/CMakeLists.txt | 195 +++++++----------- modules/dnn/CMakeLists.txt | 6 +- modules/dnn/cmake/OpenCVFindLibProtobuf.cmake | 66 +++--- modules/dnn/cmake/download_protobuf.cmake | 51 +++++ 4 files changed, 172 insertions(+), 146 deletions(-) create mode 100644 modules/dnn/cmake/download_protobuf.cmake diff --git a/modules/dnn/3rdparty/protobuf/CMakeLists.txt b/modules/dnn/3rdparty/protobuf/CMakeLists.txt index db6cbd29e..54d549117 100644 --- a/modules/dnn/3rdparty/protobuf/CMakeLists.txt +++ b/modules/dnn/3rdparty/protobuf/CMakeLists.txt @@ -1,106 +1,25 @@ project(libprotobuf) include(CheckIncludeFiles) -include(cmake/CheckCxxHashset.cmake) -include(cmake/CheckCxxHashmap.cmake) -check_include_files("pthread.h" HAVE_PTHREAD) - -if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID STREQUAL "Clang") - include(CheckIncludeFileCXX) - set(CMAKE_REQUIRED_FLAGS "-std=c++11") - check_include_file_cxx("unordered_map" HAVE_UNORDERED_MAP) - check_include_file_cxx("tr1/unordered_map" HAVE_TR1_UNORDERED_MAP) - set(CMAKE_REQUIRED_FLAGS ) - - if(HAVE_UNORDERED_MAP) - add_definitions("-std=c++11") # For unordered_map - set(HASH_MAP_H "") - set(HASH_MAP_CLASS "unordered_map") - set(HASH_NAMESPACE "std") - set(HAVE_HASH_MAP 1) - elseif(HAVE_TR1_UNORDERED_MAP) - add_definitions("-std=c++11") # For unordered_map - set(HASH_MAP_H "") - set(HASH_MAP_CLASS "unordered_map") - set(HASH_NAMESPACE "std::tr1") - set(HAVE_HASH_MAP 1) - else() - CHECK_HASHMAP() - if(HAVE_GNU_EXT_HASH_MAP) - set(HASH_MAP_H "") - set(HASH_NAMESPACE "__gnu_cxx") - set(HASH_MAP_CLASS "hash_map") - set(HAVE_HASH_MAP 1) - elseif(HAVE_STD_EXT_HASH_MAP) - set(HASH_MAP_H "") - set(HASH_NAMESPACE "std") - set(HASH_MAP_CLASS "hash_map") - set(HAVE_HASH_MAP 1) - elseif(HAVE_GLOBAL_HASH_MAP) - set(HASH_MAP_H "") - set(HASH_NAMESPACE "") - set(HASH_MAP_CLASS "hash_map") - set(HAVE_HASH_MAP 1) - else() - set(HAVE_HASH_MAP 0) - endif() - endif() - - set(CMAKE_REQUIRED_FLAGS "-std=c++11") - check_include_file_cxx("unordered_set" HAVE_UNORDERED_SET) - check_include_file_cxx("tr1/unordered_set" HAVE_TR1_UNORDERED_SET) - set(CMAKE_REQUIRED_FLAGS ) - - if(HAVE_UNORDERED_SET) - set(HASH_SET_H "") - set(HASH_SET_CLASS "unordered_set") - set(HAVE_HASH_SET 1) - elseif(HAVE_TR1_UNORDERED_SET) - add_definitions("-std=c++11") - set(HASH_SET_H "") - set(HASH_SET_CLASS "unordered_set") - set(HAVE_HASH_SET 1) - else() - CHECK_HASHSET() - if(HAVE_GNU_EXT_HASH_SET) - set(HASH_SET_H "") - set(HASH_NAMESPACE "__gnu_cxx") - set(HASH_SET_CLASS "hash_set") - set(HAVE_HASH_SET 1) - elseif(HAVE_STD_EXT_HASH_SET) - set(HASH_SET_H "") - set(HASH_NAMESPACE "std") - set(HASH_SET_CLASS "hash_set") - set(HAVE_HASH_SET 1) - elseif(HAVE_GLOBAL_HASH_SET) - set(HASH_SET_H "") - set(HASH_NAMESPACE "") - set(HASH_SET_CLASS "hash_set") - set(HAVE_HASH_SET 1) - else() - set(HAVE_HASH_SET 0) - endif() +if(NOT MSVC) + check_include_files("pthread.h" HAVE_PTHREAD) + if(HAVE_PTHREAD) + add_definitions(-DHAVE_PTHREAD=1) endif() endif() -if(WIN32 AND BUILD_SHARED_LIBS AND MSVC) - add_definitions(-DPROTOBUF_USE_DLLS) - add_definitions(-DLIBPROTOBUF_EXPORTS) -endif() - -#add_definitions( -DGOOGLE_PROTOBUF_NO_THREAD_SAFETY ) #we don't need thread safety -add_definitions( -D_GNU_SOURCE=1 ) #it's maybe useful -add_definitions( -DHAVE_CONFIG_H ) #we will use config.h -configure_file("cmake/config.h.in" "config.h") - if(MSVC) add_definitions( -D_CRT_SECURE_NO_WARNINGS=1 ) - ocv_warnings_disable(CMAKE_CXX_FLAGS /wd4244 /wd4267 /wd4018 /wd4355 /wd4800 /wd4251 /wd4996 /wd4146 /wd4305 /wd4127 /wd4100 /wd4512 /wd4125 /wd4389 /wd4510 /wd4610 /wd4702) - ocv_warnings_disable(CMAKE_CXX_FLAGS /wd4456) # VS 2015 + ocv_warnings_disable(CMAKE_CXX_FLAGS /wd4244 /wd4267 /wd4018 /wd4355 /wd4800 /wd4251 /wd4996 /wd4146 + /wd4305 /wd4127 /wd4100 /wd4512 /wd4125 /wd4389 /wd4510 /wd4610 + /wd4702 /wd4456 /wd4457 /wd4065 /wd4310 /wd4661 /wd4506 + ) else() - ocv_warnings_disable(CMAKE_CXX_FLAGS -Wno-deprecated -Wmissing-prototypes -Wmissing-declarations -Wshadow -Wunused-parameter -Wunused-local-typedefs -Wsign-compare -Wsign-promo -Wundef) - ocv_warnings_disable(CMAKE_CXX_FLAGS -Wtautological-undefined-compare) + ocv_warnings_disable(CMAKE_CXX_FLAGS -Wno-deprecated -Wmissing-prototypes -Wmissing-declarations -Wshadow -Wunused-parameter -Wunused-local-typedefs -Wsign-compare -Wsign-promo -Wundef + -Wtautological-undefined-compare + -Wignored-qualifiers -Wextra -Wunused-function -Wunused-const-variable + ) endif() # Easier to support different versions of protobufs @@ -116,7 +35,7 @@ function(append_if_exist OUTPUT_LIST) set(${OUTPUT_LIST} ${${OUTPUT_LIST}} PARENT_SCOPE) endfunction() -set(PROTOBUF_ROOT ${CMAKE_CURRENT_SOURCE_DIR}) +set(PROTOBUF_ROOT ${CMAKE_CURRENT_SOURCE_DIR}/sources/protobuf-3.1.0) if(MSVC) set(ATOMICOPS_INTERNALS ${PROTOBUF_ROOT}/src/google/protobuf/stubs/atomicops_internals_x86_msvc.cc) @@ -124,61 +43,103 @@ else() set(ATOMICOPS_INTERNALS ${PROTOBUF_ROOT}/src/google/protobuf/stubs/atomicops_internals_x86_gcc.cc) endif() + append_if_exist(PROTOBUF_SRCS - ${PROTOBUF_ROOT}/src/google/protobuf/compiler/importer.cc - ${PROTOBUF_ROOT}/src/google/protobuf/compiler/parser.cc - ${PROTOBUF_ROOT}/src/google/protobuf/descriptor.cc - ${PROTOBUF_ROOT}/src/google/protobuf/descriptor.pb.cc - ${PROTOBUF_ROOT}/src/google/protobuf/descriptor_database.cc - ${PROTOBUF_ROOT}/src/google/protobuf/dynamic_message.cc +# libprotobuf-lite + ${PROTOBUF_ROOT}/src/google/protobuf/arena.cc + ${PROTOBUF_ROOT}/src/google/protobuf/arenastring.cc ${PROTOBUF_ROOT}/src/google/protobuf/extension_set.cc - ${PROTOBUF_ROOT}/src/google/protobuf/extension_set_heavy.cc - ${PROTOBUF_ROOT}/src/google/protobuf/generated_message_reflection.cc ${PROTOBUF_ROOT}/src/google/protobuf/generated_message_util.cc ${PROTOBUF_ROOT}/src/google/protobuf/io/coded_stream.cc - ${PROTOBUF_ROOT}/src/google/protobuf/io/gzip_stream.cc - ${PROTOBUF_ROOT}/src/google/protobuf/io/printer.cc - ${PROTOBUF_ROOT}/src/google/protobuf/io/tokenizer.cc ${PROTOBUF_ROOT}/src/google/protobuf/io/zero_copy_stream.cc - ${PROTOBUF_ROOT}/src/google/protobuf/io/zero_copy_stream_impl.cc ${PROTOBUF_ROOT}/src/google/protobuf/io/zero_copy_stream_impl_lite.cc - ${PROTOBUF_ROOT}/src/google/protobuf/message.cc ${PROTOBUF_ROOT}/src/google/protobuf/message_lite.cc - ${PROTOBUF_ROOT}/src/google/protobuf/reflection_ops.cc ${PROTOBUF_ROOT}/src/google/protobuf/repeated_field.cc - ${PROTOBUF_ROOT}/src/google/protobuf/service.cc ${ATOMICOPS_INTERNALS} + ${PROTOBUF_ROOT}/src/google/protobuf/stubs/bytestream.cc ${PROTOBUF_ROOT}/src/google/protobuf/stubs/common.cc + ${PROTOBUF_ROOT}/src/google/protobuf/stubs/int128.cc ${PROTOBUF_ROOT}/src/google/protobuf/stubs/once.cc + ${PROTOBUF_ROOT}/src/google/protobuf/stubs/status.cc + ${PROTOBUF_ROOT}/src/google/protobuf/stubs/statusor.cc + ${PROTOBUF_ROOT}/src/google/protobuf/stubs/stringpiece.cc ${PROTOBUF_ROOT}/src/google/protobuf/stubs/stringprintf.cc ${PROTOBUF_ROOT}/src/google/protobuf/stubs/structurally_valid.cc ${PROTOBUF_ROOT}/src/google/protobuf/stubs/strutil.cc + ${PROTOBUF_ROOT}/src/google/protobuf/stubs/time.cc + ${PROTOBUF_ROOT}/src/google/protobuf/wire_format_lite.cc +# libprotobuf + ${PROTOBUF_ROOT}/src/google/protobuf/any.cc + ${PROTOBUF_ROOT}/src/google/protobuf/any.pb.cc + ${PROTOBUF_ROOT}/src/google/protobuf/api.pb.cc +# ${PROTOBUF_ROOT}/src/google/protobuf/compiler/importer.cc +# ${PROTOBUF_ROOT}/src/google/protobuf/compiler/parser.cc + ${PROTOBUF_ROOT}/src/google/protobuf/descriptor.cc + ${PROTOBUF_ROOT}/src/google/protobuf/descriptor.pb.cc + ${PROTOBUF_ROOT}/src/google/protobuf/descriptor_database.cc + ${PROTOBUF_ROOT}/src/google/protobuf/duration.pb.cc + ${PROTOBUF_ROOT}/src/google/protobuf/dynamic_message.cc + ${PROTOBUF_ROOT}/src/google/protobuf/empty.pb.cc + ${PROTOBUF_ROOT}/src/google/protobuf/extension_set_heavy.cc + ${PROTOBUF_ROOT}/src/google/protobuf/field_mask.pb.cc + ${PROTOBUF_ROOT}/src/google/protobuf/generated_message_reflection.cc + ${PROTOBUF_ROOT}/src/google/protobuf/io/gzip_stream.cc + ${PROTOBUF_ROOT}/src/google/protobuf/io/printer.cc + ${PROTOBUF_ROOT}/src/google/protobuf/io/strtod.cc + ${PROTOBUF_ROOT}/src/google/protobuf/io/tokenizer.cc + ${PROTOBUF_ROOT}/src/google/protobuf/io/zero_copy_stream_impl.cc + ${PROTOBUF_ROOT}/src/google/protobuf/map_field.cc + ${PROTOBUF_ROOT}/src/google/protobuf/message.cc + ${PROTOBUF_ROOT}/src/google/protobuf/reflection_ops.cc + ${PROTOBUF_ROOT}/src/google/protobuf/service.cc + ${PROTOBUF_ROOT}/src/google/protobuf/source_context.pb.cc + ${PROTOBUF_ROOT}/src/google/protobuf/struct.pb.cc + ${PROTOBUF_ROOT}/src/google/protobuf/stubs/mathlimits.cc ${PROTOBUF_ROOT}/src/google/protobuf/stubs/substitute.cc ${PROTOBUF_ROOT}/src/google/protobuf/text_format.cc + ${PROTOBUF_ROOT}/src/google/protobuf/timestamp.pb.cc + ${PROTOBUF_ROOT}/src/google/protobuf/type.pb.cc ${PROTOBUF_ROOT}/src/google/protobuf/unknown_field_set.cc + ${PROTOBUF_ROOT}/src/google/protobuf/util/field_comparator.cc + ${PROTOBUF_ROOT}/src/google/protobuf/util/field_mask_util.cc + ${PROTOBUF_ROOT}/src/google/protobuf/util/internal/datapiece.cc + ${PROTOBUF_ROOT}/src/google/protobuf/util/internal/default_value_objectwriter.cc +# ${PROTOBUF_ROOT}/src/google/protobuf/util/internal/error_listener.cc + ${PROTOBUF_ROOT}/src/google/protobuf/util/internal/field_mask_utility.cc + ${PROTOBUF_ROOT}/src/google/protobuf/util/internal/json_escaping.cc + ${PROTOBUF_ROOT}/src/google/protobuf/util/internal/json_objectwriter.cc + ${PROTOBUF_ROOT}/src/google/protobuf/util/internal/json_stream_parser.cc + ${PROTOBUF_ROOT}/src/google/protobuf/util/internal/object_writer.cc + ${PROTOBUF_ROOT}/src/google/protobuf/util/internal/proto_writer.cc + ${PROTOBUF_ROOT}/src/google/protobuf/util/internal/protostream_objectsource.cc + ${PROTOBUF_ROOT}/src/google/protobuf/util/internal/protostream_objectwriter.cc + ${PROTOBUF_ROOT}/src/google/protobuf/util/internal/type_info.cc +# ${PROTOBUF_ROOT}/src/google/protobuf/util/internal/type_info_test_helper.cc + ${PROTOBUF_ROOT}/src/google/protobuf/util/internal/utility.cc + ${PROTOBUF_ROOT}/src/google/protobuf/util/json_util.cc + ${PROTOBUF_ROOT}/src/google/protobuf/util/message_differencer.cc + ${PROTOBUF_ROOT}/src/google/protobuf/util/time_util.cc + ${PROTOBUF_ROOT}/src/google/protobuf/util/type_resolver_util.cc ${PROTOBUF_ROOT}/src/google/protobuf/wire_format.cc - ${PROTOBUF_ROOT}/src/google/protobuf/wire_format_lite.cc - #${PROTOBUF_ROOT}/src/google/protobuf/stubs/hash.cc + ${PROTOBUF_ROOT}/src/google/protobuf/wrappers.pb.cc ) -if(UNIX AND (CMAKE_COMPILER_IS_GNUCXX OR CV_ICC)) +if(CMAKE_VERSION VERSION_LESS 2.8.9 AND UNIX) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC") endif() add_library(libprotobuf STATIC ${PROTOBUF_SRCS}) -include_directories(${PROTOBUF_ROOT}/src ${CMAKE_CURRENT_BINARY_DIR}) +include_directories(${PROTOBUF_ROOT}/src) set_target_properties(libprotobuf PROPERTIES + FOLDER "3rdparty" + POSITION_INDEPENDENT_CODE 1 # CMake 2.8.9+ OUTPUT_NAME libprotobuf DEBUG_POSTFIX "${OPENCV_DEBUG_POSTFIX}" ARCHIVE_OUTPUT_DIRECTORY ${3P_LIBRARY_OUTPUT_PATH} ) -if(ENABLE_SOLUTION_FOLDERS) - set_target_properties(libprotobuf PROPERTIES FOLDER "3rdparty") -endif() - if(NOT BUILD_SHARED_LIBS) ocv_install_target(libprotobuf EXPORT OpenCVModules ARCHIVE DESTINATION ${OPENCV_3P_LIB_INSTALL_PATH} COMPONENT dev) endif() diff --git a/modules/dnn/CMakeLists.txt b/modules/dnn/CMakeLists.txt index 0dd5f379e..c61c97b79 100644 --- a/modules/dnn/CMakeLists.txt +++ b/modules/dnn/CMakeLists.txt @@ -10,8 +10,10 @@ set(the_description "Deep neural network module. It allows to load models from d set(OPENCV_MODULE_IS_PART_OF_WORLD OFF) ocv_add_module(dnn opencv_core opencv_imgproc WRAP python matlab) -ocv_warnings_disable(CMAKE_CXX_FLAGS -Wno-shadow -Wno-parentheses -Wmaybe-uninitialized -Wsign-promo -Wmissing-declarations -Wmissing-prototypes) -ocv_warnings_disable(CMAKE_CXX_FLAGS /wd4701) +ocv_warnings_disable(CMAKE_CXX_FLAGS -Wno-shadow -Wno-parentheses -Wmaybe-uninitialized -Wsign-promo + -Wmissing-declarations -Wmissing-prototypes +) +ocv_warnings_disable(CMAKE_CXX_FLAGS /wd4701 /wd4100) # ---------------------------------------------------------------------------- # Resolve libprotobuf dependency diff --git a/modules/dnn/cmake/OpenCVFindLibProtobuf.cmake b/modules/dnn/cmake/OpenCVFindLibProtobuf.cmake index a28dc5768..02d521eb5 100644 --- a/modules/dnn/cmake/OpenCVFindLibProtobuf.cmake +++ b/modules/dnn/cmake/OpenCVFindLibProtobuf.cmake @@ -1,34 +1,46 @@ -OCV_OPTION(BUILD_LIBPROTOBUF_FROM_SOURCES "Force to build libprotobuf from sources (don't try to find it in system)" OFF) +# By default, we use built-in protobuf sources and pre-generated .proto files +# Note: In case of .proto model updates these variables should be used: +# - PROTOBUF_PROTOC_EXECUTABLE (required) +# - PROTOBUF_INCLUDE_DIR +# - PROTOBUF_LIBRARIES or PROTOBUF_LIBRARY / PROTOBUF_LIBRARY_DEBUG for find_package() +OCV_OPTION(BUILD_PROTOBUF "Force to build libprotobuf from sources" ON) +OCV_OPTION(UPDATE_PROTO_FILES "Force to rebuild .proto files" OFF) -if(NOT BUILD_LIBPROTOBUF_FROM_SOURCES) - find_package(Protobuf) -endif() - -if(NOT BUILD_LIBPROTOBUF_FROM_SOURCES AND PROTOBUF_FOUND AND EXISTS ${PROTOBUF_PROTOC_EXECUTABLE}) - message(STATUS "The protocol buffer compiler and libprotobuf were found") - PROTOBUF_GENERATE_CPP(PROTOBUF_HDRS PROTOBUF_SRCS src/caffe/caffe.proto) - add_definitions(-DHAVE_PROTOBUF=1) -else() - message(STATUS "Build libprotobuf from sources:") - if(NOT PROTOBUF_FOUND) - message(STATUS " libprotobuf not found into system") +if(UPDATE_PROTO_FILES) + if(NOT DEFINED PROTOBUF_PROTOC_EXECUTABLE) + find_package(Protobuf QUIET) endif() - if(NOT EXISTS ${PROTOBUF_PROTOC_EXECUTABLE}) - message(STATUS " The protocol buffer compiler not found") + if(DEFINED PROTOBUF_PROTOC_EXECUTABLE AND EXISTS ${PROTOBUF_PROTOC_EXECUTABLE}) + message(STATUS "The protocol buffer compiler is found (${PROTOBUF_PROTOC_EXECUTABLE})") + PROTOBUF_GENERATE_CPP(PROTOBUF_HDRS PROTOBUF_SRCS + src/caffe/caffe.proto + ) + else() + message(FATAL_ERROR "The protocol buffer compiler is not found (PROTOBUF_PROTOC_EXECUTABLE='${PROTOBUF_PROTOC_EXECUTABLE}')") endif() +endif() - #take into account OpenCV two-pass module addition scheme - if(NOT OPENCV_INITIAL_PASS) #TODO: it looks like a hack - add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/3rdparty/protobuf) - endif() +if(NOT BUILD_PROTOBUF AND NOT (DEFINED PROTOBUF_INCLUDE_DIR AND DEFINED PROTOBUF_LIBRARIES)) + find_package(Protobuf QUIET) +endif() +if(PROTOBUF_FOUND) + # nothing +else() + include(${CMAKE_CURRENT_LIST_DIR}/download_protobuf.cmake) + add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/3rdparty/protobuf) set(PROTOBUF_LIBRARIES libprotobuf) - set(PROTOBUF_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/3rdparty/protobuf/src ${CMAKE_CURRENT_SOURCE_DIR}/misc/caffe) - set(PROTOBUF_SRCS ${CMAKE_CURRENT_SOURCE_DIR}/misc/caffe/caffe.pb.cc) - set(PROTOBUF_HDRS ${CMAKE_CURRENT_SOURCE_DIR}/misc/caffe/caffe.pb.h) - add_definitions(-DHAVE_PROTOBUF=1) + set(PROTOBUF_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/3rdparty/protobuf/sources/protobuf-3.1.0/src) +endif() + +if(NOT UPDATE_PROTO_FILES) + list(APPEND PROTOBUF_SRCS ${CMAKE_CURRENT_SOURCE_DIR}/misc/caffe/caffe.pb.cc) + list(APPEND PROTOBUF_HDRS ${CMAKE_CURRENT_SOURCE_DIR}/misc/caffe/caffe.pb.h) + list(APPEND PROTOBUF_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/misc/caffe) +endif() + +add_definitions(-DHAVE_PROTOBUF=1) - #supress warnings in autogenerated caffe.pb.* files - ocv_warnings_disable(CMAKE_CXX_FLAGS -Wunused-parameter) - ocv_warnings_disable(CMAKE_CXX_FLAGS /wd4125 /wd4267 /wd4127 /wd4244 /wd4512 /wd4702) -endif() \ No newline at end of file +#supress warnings in autogenerated caffe.pb.* files +ocv_warnings_disable(CMAKE_CXX_FLAGS -Wunused-parameter -Wundef) +ocv_warnings_disable(CMAKE_CXX_FLAGS /wd4125 /wd4267 /wd4127 /wd4244 /wd4512 /wd4702) diff --git a/modules/dnn/cmake/download_protobuf.cmake b/modules/dnn/cmake/download_protobuf.cmake new file mode 100644 index 000000000..b365a464a --- /dev/null +++ b/modules/dnn/cmake/download_protobuf.cmake @@ -0,0 +1,51 @@ +set(PROTOBUF_CPP_NAME "libprotobuf") +set(PROTOBUF_CPP_DOWNLOAD_HASH "bd5e3eed635a8d32e2b99658633815ef") +set(PROTOBUF_CPP_PATH "${CMAKE_CURRENT_SOURCE_DIR}/3rdparty/protobuf/sources") # /protobuf-3.1.0 subdirectory + +set(OPENCV_PROTOBUF_CPP_DOWNLOAD_URL ${OPENCV_PROTOBUF_URL};$ENV{OPENCV_PROTOBUF_URL};https://github.com/google/protobuf/releases/download/) + +function(ocv_protobuf_download file ID) + if(DEFINED ${ID}_DOWNLOADED_HASH + AND ${ID}_DOWNLOADED_HASH STREQUAL ${ID}_DOWNLOAD_HASH + AND EXISTS ${${ID}_PATH}) + # Files have been downloaded and checked by the previous CMake run + return() + else() + if(EXISTS ${${ID}_PATH}) + message(STATUS "${${ID}_NAME}: Removing previous unpacked files: ${${ID}_PATH}") + file(REMOVE_RECURSE ${${ID}_PATH}) + endif() + endif() + unset(${ID}_DOWNLOADED_HASH CACHE) + + file(MAKE_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/.download) + file(WRITE "${CMAKE_CURRENT_SOURCE_DIR}/.download/.gitignore" "*\n") + ocv_download(PACKAGE ${file} + HASH ${${ID}_DOWNLOAD_HASH} + URL ${OPENCV_${ID}_DOWNLOAD_URL} + DOWNLOAD_DIR ${CMAKE_CURRENT_SOURCE_DIR}/.download) + set(${ID}_ARCHIVE "${DOWNLOAD_PACKAGE_LOCATION}") + + ocv_assert(EXISTS "${${ID}_ARCHIVE}") + ocv_assert(NOT EXISTS "${${ID}_PATH}") + file(MAKE_DIRECTORY ${${ID}_PATH}) + ocv_assert(EXISTS "${${ID}_PATH}") + file(WRITE "${${ID}_PATH}/.gitignore" "*\n") + + message(STATUS "${${ID}_NAME}: Unpacking ${file} to ${${ID}_PATH}...") + execute_process(COMMAND ${CMAKE_COMMAND} -E tar xz "${${ID}_ARCHIVE}" + WORKING_DIRECTORY "${${ID}_PATH}" + RESULT_VARIABLE __result) + + if(NOT __result EQUAL 0) + message(FATAL_ERROR "${${ID}_NAME}: Failed to unpack ${ID} archive from ${${ID}_ARCHIVE} to ${${ID}_PATH} with error ${__result}") + endif() + + ocv_assert(EXISTS "${${ID}_PATH}") + + set(${ID}_DOWNLOADED_HASH "${${ID}_DOWNLOAD_HASH}" CACHE INTERNAL "${ID} hash") + + #message(STATUS "${${ID}_NAME}: Successfully downloaded") +endfunction() + +ocv_protobuf_download(v3.1.0/protobuf-cpp-3.1.0.tar.gz PROTOBUF_CPP) From b7ce1ec369b16feb9684b3074ba6673e3b2cb1ac Mon Sep 17 00:00:00 2001 From: Alexander Alekhin Date: Tue, 22 Nov 2016 02:38:54 +0300 Subject: [PATCH 3/3] dnn: rebuild caffe.proto with protobuf 3.1.0 --- modules/dnn/misc/caffe/caffe.pb.cc | 34891 +++++++++++++++++++-------- modules/dnn/misc/caffe/caffe.pb.h | 11240 +++++---- 2 files changed, 32161 insertions(+), 13970 deletions(-) diff --git a/modules/dnn/misc/caffe/caffe.pb.cc b/modules/dnn/misc/caffe/caffe.pb.cc index cc4c48778..7bd91f1b8 100644 --- a/modules/dnn/misc/caffe/caffe.pb.cc +++ b/modules/dnn/misc/caffe/caffe.pb.cc @@ -7,6 +7,7 @@ #include #include +#include #include #include #include @@ -218,6 +219,7 @@ const ::google::protobuf::EnumDescriptor* Phase_descriptor_ = NULL; } // namespace +void protobuf_AssignDesc_caffe_2eproto() GOOGLE_ATTRIBUTE_COLD; void protobuf_AssignDesc_caffe_2eproto() { protobuf_AddDesc_caffe_2eproto(); const ::google::protobuf::FileDescriptor* file = @@ -229,16 +231,15 @@ void protobuf_AssignDesc_caffe_2eproto() { GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(BlobShape, dim_), }; BlobShape_reflection_ = - new ::google::protobuf::internal::GeneratedMessageReflection( + ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection( BlobShape_descriptor_, - BlobShape::default_instance_, + BlobShape::internal_default_instance(), BlobShape_offsets_, - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(BlobShape, _has_bits_[0]), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(BlobShape, _unknown_fields_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(BlobShape, _has_bits_), -1, - ::google::protobuf::DescriptorPool::generated_pool(), - ::google::protobuf::MessageFactory::generated_factory(), - sizeof(BlobShape)); + -1, + sizeof(BlobShape), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(BlobShape, _internal_metadata_)); BlobProto_descriptor_ = file->message_type(1); static const int BlobProto_offsets_[7] = { GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(BlobProto, shape_), @@ -250,62 +251,58 @@ void protobuf_AssignDesc_caffe_2eproto() { GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(BlobProto, width_), }; BlobProto_reflection_ = - new ::google::protobuf::internal::GeneratedMessageReflection( + ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection( BlobProto_descriptor_, - BlobProto::default_instance_, + BlobProto::internal_default_instance(), BlobProto_offsets_, - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(BlobProto, _has_bits_[0]), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(BlobProto, _unknown_fields_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(BlobProto, _has_bits_), + -1, -1, - ::google::protobuf::DescriptorPool::generated_pool(), - ::google::protobuf::MessageFactory::generated_factory(), - sizeof(BlobProto)); + sizeof(BlobProto), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(BlobProto, _internal_metadata_)); BlobProtoVector_descriptor_ = file->message_type(2); static const int BlobProtoVector_offsets_[1] = { GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(BlobProtoVector, blobs_), }; BlobProtoVector_reflection_ = - new ::google::protobuf::internal::GeneratedMessageReflection( + ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection( BlobProtoVector_descriptor_, - BlobProtoVector::default_instance_, + BlobProtoVector::internal_default_instance(), BlobProtoVector_offsets_, - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(BlobProtoVector, _has_bits_[0]), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(BlobProtoVector, _unknown_fields_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(BlobProtoVector, _has_bits_), -1, - ::google::protobuf::DescriptorPool::generated_pool(), - ::google::protobuf::MessageFactory::generated_factory(), - sizeof(BlobProtoVector)); + -1, + sizeof(BlobProtoVector), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(BlobProtoVector, _internal_metadata_)); CropParameter_descriptor_ = file->message_type(3); static const int CropParameter_offsets_[2] = { GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(CropParameter, axis_), GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(CropParameter, offset_), }; CropParameter_reflection_ = - new ::google::protobuf::internal::GeneratedMessageReflection( + ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection( CropParameter_descriptor_, - CropParameter::default_instance_, + CropParameter::internal_default_instance(), CropParameter_offsets_, - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(CropParameter, _has_bits_[0]), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(CropParameter, _unknown_fields_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(CropParameter, _has_bits_), + -1, -1, - ::google::protobuf::DescriptorPool::generated_pool(), - ::google::protobuf::MessageFactory::generated_factory(), - sizeof(CropParameter)); + sizeof(CropParameter), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(CropParameter, _internal_metadata_)); PermuteParameter_descriptor_ = file->message_type(4); static const int PermuteParameter_offsets_[1] = { GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(PermuteParameter, order_), }; PermuteParameter_reflection_ = - new ::google::protobuf::internal::GeneratedMessageReflection( + ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection( PermuteParameter_descriptor_, - PermuteParameter::default_instance_, + PermuteParameter::internal_default_instance(), PermuteParameter_offsets_, - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(PermuteParameter, _has_bits_[0]), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(PermuteParameter, _unknown_fields_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(PermuteParameter, _has_bits_), -1, - ::google::protobuf::DescriptorPool::generated_pool(), - ::google::protobuf::MessageFactory::generated_factory(), - sizeof(PermuteParameter)); + -1, + sizeof(PermuteParameter), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(PermuteParameter, _internal_metadata_)); NormalizeBBoxParameter_descriptor_ = file->message_type(5); static const int NormalizeBBoxParameter_offsets_[4] = { GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(NormalizeBBoxParameter, across_spatial_), @@ -314,16 +311,15 @@ void protobuf_AssignDesc_caffe_2eproto() { GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(NormalizeBBoxParameter, eps_), }; NormalizeBBoxParameter_reflection_ = - new ::google::protobuf::internal::GeneratedMessageReflection( + ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection( NormalizeBBoxParameter_descriptor_, - NormalizeBBoxParameter::default_instance_, + NormalizeBBoxParameter::internal_default_instance(), NormalizeBBoxParameter_offsets_, - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(NormalizeBBoxParameter, _has_bits_[0]), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(NormalizeBBoxParameter, _unknown_fields_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(NormalizeBBoxParameter, _has_bits_), + -1, -1, - ::google::protobuf::DescriptorPool::generated_pool(), - ::google::protobuf::MessageFactory::generated_factory(), - sizeof(NormalizeBBoxParameter)); + sizeof(NormalizeBBoxParameter), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(NormalizeBBoxParameter, _internal_metadata_)); PriorBoxParameter_descriptor_ = file->message_type(6); static const int PriorBoxParameter_offsets_[6] = { GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(PriorBoxParameter, min_size_), @@ -334,16 +330,15 @@ void protobuf_AssignDesc_caffe_2eproto() { GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(PriorBoxParameter, variance_), }; PriorBoxParameter_reflection_ = - new ::google::protobuf::internal::GeneratedMessageReflection( + ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection( PriorBoxParameter_descriptor_, - PriorBoxParameter::default_instance_, + PriorBoxParameter::internal_default_instance(), PriorBoxParameter_offsets_, - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(PriorBoxParameter, _has_bits_[0]), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(PriorBoxParameter, _unknown_fields_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(PriorBoxParameter, _has_bits_), -1, - ::google::protobuf::DescriptorPool::generated_pool(), - ::google::protobuf::MessageFactory::generated_factory(), - sizeof(PriorBoxParameter)); + -1, + sizeof(PriorBoxParameter), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(PriorBoxParameter, _internal_metadata_)); PriorBoxParameter_CodeType_descriptor_ = PriorBoxParameter_descriptor_->enum_type(0); DetectionOutputParameter_descriptor_ = file->message_type(7); static const int DetectionOutputParameter_offsets_[9] = { @@ -358,16 +353,15 @@ void protobuf_AssignDesc_caffe_2eproto() { GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DetectionOutputParameter, top_k_), }; DetectionOutputParameter_reflection_ = - new ::google::protobuf::internal::GeneratedMessageReflection( + ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection( DetectionOutputParameter_descriptor_, - DetectionOutputParameter::default_instance_, + DetectionOutputParameter::internal_default_instance(), DetectionOutputParameter_offsets_, - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DetectionOutputParameter, _has_bits_[0]), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DetectionOutputParameter, _unknown_fields_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DetectionOutputParameter, _has_bits_), + -1, -1, - ::google::protobuf::DescriptorPool::generated_pool(), - ::google::protobuf::MessageFactory::generated_factory(), - sizeof(DetectionOutputParameter)); + sizeof(DetectionOutputParameter), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DetectionOutputParameter, _internal_metadata_)); Datum_descriptor_ = file->message_type(8); static const int Datum_offsets_[7] = { GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Datum, channels_), @@ -379,16 +373,15 @@ void protobuf_AssignDesc_caffe_2eproto() { GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Datum, encoded_), }; Datum_reflection_ = - new ::google::protobuf::internal::GeneratedMessageReflection( + ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection( Datum_descriptor_, - Datum::default_instance_, + Datum::internal_default_instance(), Datum_offsets_, - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Datum, _has_bits_[0]), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Datum, _unknown_fields_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Datum, _has_bits_), -1, - ::google::protobuf::DescriptorPool::generated_pool(), - ::google::protobuf::MessageFactory::generated_factory(), - sizeof(Datum)); + -1, + sizeof(Datum), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Datum, _internal_metadata_)); FillerParameter_descriptor_ = file->message_type(9); static const int FillerParameter_offsets_[8] = { GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FillerParameter, type_), @@ -401,16 +394,15 @@ void protobuf_AssignDesc_caffe_2eproto() { GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FillerParameter, variance_norm_), }; FillerParameter_reflection_ = - new ::google::protobuf::internal::GeneratedMessageReflection( + ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection( FillerParameter_descriptor_, - FillerParameter::default_instance_, + FillerParameter::internal_default_instance(), FillerParameter_offsets_, - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FillerParameter, _has_bits_[0]), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FillerParameter, _unknown_fields_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FillerParameter, _has_bits_), + -1, -1, - ::google::protobuf::DescriptorPool::generated_pool(), - ::google::protobuf::MessageFactory::generated_factory(), - sizeof(FillerParameter)); + sizeof(FillerParameter), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FillerParameter, _internal_metadata_)); FillerParameter_VarianceNorm_descriptor_ = FillerParameter_descriptor_->enum_type(0); NetParameter_descriptor_ = file->message_type(10); static const int NetParameter_offsets_[9] = { @@ -425,16 +417,15 @@ void protobuf_AssignDesc_caffe_2eproto() { GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(NetParameter, layers_), }; NetParameter_reflection_ = - new ::google::protobuf::internal::GeneratedMessageReflection( + ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection( NetParameter_descriptor_, - NetParameter::default_instance_, + NetParameter::internal_default_instance(), NetParameter_offsets_, - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(NetParameter, _has_bits_[0]), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(NetParameter, _unknown_fields_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(NetParameter, _has_bits_), -1, - ::google::protobuf::DescriptorPool::generated_pool(), - ::google::protobuf::MessageFactory::generated_factory(), - sizeof(NetParameter)); + -1, + sizeof(NetParameter), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(NetParameter, _internal_metadata_)); SolverParameter_descriptor_ = file->message_type(11); static const int SolverParameter_offsets_[36] = { GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(SolverParameter, net_), @@ -475,16 +466,15 @@ void protobuf_AssignDesc_caffe_2eproto() { GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(SolverParameter, snapshot_after_train_), }; SolverParameter_reflection_ = - new ::google::protobuf::internal::GeneratedMessageReflection( + ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection( SolverParameter_descriptor_, - SolverParameter::default_instance_, + SolverParameter::internal_default_instance(), SolverParameter_offsets_, - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(SolverParameter, _has_bits_[0]), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(SolverParameter, _unknown_fields_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(SolverParameter, _has_bits_), + -1, -1, - ::google::protobuf::DescriptorPool::generated_pool(), - ::google::protobuf::MessageFactory::generated_factory(), - sizeof(SolverParameter)); + sizeof(SolverParameter), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(SolverParameter, _internal_metadata_)); SolverParameter_SolverMode_descriptor_ = SolverParameter_descriptor_->enum_type(0); SolverParameter_SolverType_descriptor_ = SolverParameter_descriptor_->enum_type(1); SolverState_descriptor_ = file->message_type(12); @@ -495,16 +485,15 @@ void protobuf_AssignDesc_caffe_2eproto() { GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(SolverState, current_step_), }; SolverState_reflection_ = - new ::google::protobuf::internal::GeneratedMessageReflection( + ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection( SolverState_descriptor_, - SolverState::default_instance_, + SolverState::internal_default_instance(), SolverState_offsets_, - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(SolverState, _has_bits_[0]), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(SolverState, _unknown_fields_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(SolverState, _has_bits_), -1, - ::google::protobuf::DescriptorPool::generated_pool(), - ::google::protobuf::MessageFactory::generated_factory(), - sizeof(SolverState)); + -1, + sizeof(SolverState), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(SolverState, _internal_metadata_)); NetState_descriptor_ = file->message_type(13); static const int NetState_offsets_[3] = { GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(NetState, phase_), @@ -512,16 +501,15 @@ void protobuf_AssignDesc_caffe_2eproto() { GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(NetState, stage_), }; NetState_reflection_ = - new ::google::protobuf::internal::GeneratedMessageReflection( + ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection( NetState_descriptor_, - NetState::default_instance_, + NetState::internal_default_instance(), NetState_offsets_, - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(NetState, _has_bits_[0]), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(NetState, _unknown_fields_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(NetState, _has_bits_), + -1, -1, - ::google::protobuf::DescriptorPool::generated_pool(), - ::google::protobuf::MessageFactory::generated_factory(), - sizeof(NetState)); + sizeof(NetState), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(NetState, _internal_metadata_)); NetStateRule_descriptor_ = file->message_type(14); static const int NetStateRule_offsets_[5] = { GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(NetStateRule, phase_), @@ -531,16 +519,15 @@ void protobuf_AssignDesc_caffe_2eproto() { GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(NetStateRule, not_stage_), }; NetStateRule_reflection_ = - new ::google::protobuf::internal::GeneratedMessageReflection( + ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection( NetStateRule_descriptor_, - NetStateRule::default_instance_, + NetStateRule::internal_default_instance(), NetStateRule_offsets_, - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(NetStateRule, _has_bits_[0]), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(NetStateRule, _unknown_fields_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(NetStateRule, _has_bits_), -1, - ::google::protobuf::DescriptorPool::generated_pool(), - ::google::protobuf::MessageFactory::generated_factory(), - sizeof(NetStateRule)); + -1, + sizeof(NetStateRule), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(NetStateRule, _internal_metadata_)); ParamSpec_descriptor_ = file->message_type(15); static const int ParamSpec_offsets_[4] = { GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ParamSpec, name_), @@ -549,16 +536,15 @@ void protobuf_AssignDesc_caffe_2eproto() { GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ParamSpec, decay_mult_), }; ParamSpec_reflection_ = - new ::google::protobuf::internal::GeneratedMessageReflection( + ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection( ParamSpec_descriptor_, - ParamSpec::default_instance_, + ParamSpec::internal_default_instance(), ParamSpec_offsets_, - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ParamSpec, _has_bits_[0]), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ParamSpec, _unknown_fields_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ParamSpec, _has_bits_), + -1, -1, - ::google::protobuf::DescriptorPool::generated_pool(), - ::google::protobuf::MessageFactory::generated_factory(), - sizeof(ParamSpec)); + sizeof(ParamSpec), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ParamSpec, _internal_metadata_)); ParamSpec_DimCheckMode_descriptor_ = ParamSpec_descriptor_->enum_type(0); LayerParameter_descriptor_ = file->message_type(16); static const int LayerParameter_offsets_[53] = { @@ -617,16 +603,15 @@ void protobuf_AssignDesc_caffe_2eproto() { GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(LayerParameter, window_data_param_), }; LayerParameter_reflection_ = - new ::google::protobuf::internal::GeneratedMessageReflection( + ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection( LayerParameter_descriptor_, - LayerParameter::default_instance_, + LayerParameter::internal_default_instance(), LayerParameter_offsets_, - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(LayerParameter, _has_bits_[0]), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(LayerParameter, _unknown_fields_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(LayerParameter, _has_bits_), -1, - ::google::protobuf::DescriptorPool::generated_pool(), - ::google::protobuf::MessageFactory::generated_factory(), - sizeof(LayerParameter)); + -1, + sizeof(LayerParameter), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(LayerParameter, _internal_metadata_)); TransformationParameter_descriptor_ = file->message_type(17); static const int TransformationParameter_offsets_[7] = { GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(TransformationParameter, scale_), @@ -638,32 +623,30 @@ void protobuf_AssignDesc_caffe_2eproto() { GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(TransformationParameter, force_gray_), }; TransformationParameter_reflection_ = - new ::google::protobuf::internal::GeneratedMessageReflection( + ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection( TransformationParameter_descriptor_, - TransformationParameter::default_instance_, + TransformationParameter::internal_default_instance(), TransformationParameter_offsets_, - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(TransformationParameter, _has_bits_[0]), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(TransformationParameter, _unknown_fields_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(TransformationParameter, _has_bits_), + -1, -1, - ::google::protobuf::DescriptorPool::generated_pool(), - ::google::protobuf::MessageFactory::generated_factory(), - sizeof(TransformationParameter)); + sizeof(TransformationParameter), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(TransformationParameter, _internal_metadata_)); LossParameter_descriptor_ = file->message_type(18); static const int LossParameter_offsets_[2] = { GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(LossParameter, ignore_label_), GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(LossParameter, normalize_), }; LossParameter_reflection_ = - new ::google::protobuf::internal::GeneratedMessageReflection( + ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection( LossParameter_descriptor_, - LossParameter::default_instance_, + LossParameter::internal_default_instance(), LossParameter_offsets_, - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(LossParameter, _has_bits_[0]), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(LossParameter, _unknown_fields_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(LossParameter, _has_bits_), -1, - ::google::protobuf::DescriptorPool::generated_pool(), - ::google::protobuf::MessageFactory::generated_factory(), - sizeof(LossParameter)); + -1, + sizeof(LossParameter), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(LossParameter, _internal_metadata_)); AccuracyParameter_descriptor_ = file->message_type(19); static const int AccuracyParameter_offsets_[3] = { GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(AccuracyParameter, top_k_), @@ -671,64 +654,60 @@ void protobuf_AssignDesc_caffe_2eproto() { GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(AccuracyParameter, ignore_label_), }; AccuracyParameter_reflection_ = - new ::google::protobuf::internal::GeneratedMessageReflection( + ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection( AccuracyParameter_descriptor_, - AccuracyParameter::default_instance_, + AccuracyParameter::internal_default_instance(), AccuracyParameter_offsets_, - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(AccuracyParameter, _has_bits_[0]), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(AccuracyParameter, _unknown_fields_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(AccuracyParameter, _has_bits_), + -1, -1, - ::google::protobuf::DescriptorPool::generated_pool(), - ::google::protobuf::MessageFactory::generated_factory(), - sizeof(AccuracyParameter)); + sizeof(AccuracyParameter), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(AccuracyParameter, _internal_metadata_)); ArgMaxParameter_descriptor_ = file->message_type(20); static const int ArgMaxParameter_offsets_[2] = { GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ArgMaxParameter, out_max_val_), GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ArgMaxParameter, top_k_), }; ArgMaxParameter_reflection_ = - new ::google::protobuf::internal::GeneratedMessageReflection( + ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection( ArgMaxParameter_descriptor_, - ArgMaxParameter::default_instance_, + ArgMaxParameter::internal_default_instance(), ArgMaxParameter_offsets_, - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ArgMaxParameter, _has_bits_[0]), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ArgMaxParameter, _unknown_fields_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ArgMaxParameter, _has_bits_), -1, - ::google::protobuf::DescriptorPool::generated_pool(), - ::google::protobuf::MessageFactory::generated_factory(), - sizeof(ArgMaxParameter)); + -1, + sizeof(ArgMaxParameter), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ArgMaxParameter, _internal_metadata_)); ConcatParameter_descriptor_ = file->message_type(21); static const int ConcatParameter_offsets_[2] = { GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ConcatParameter, axis_), GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ConcatParameter, concat_dim_), }; ConcatParameter_reflection_ = - new ::google::protobuf::internal::GeneratedMessageReflection( + ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection( ConcatParameter_descriptor_, - ConcatParameter::default_instance_, + ConcatParameter::internal_default_instance(), ConcatParameter_offsets_, - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ConcatParameter, _has_bits_[0]), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ConcatParameter, _unknown_fields_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ConcatParameter, _has_bits_), + -1, -1, - ::google::protobuf::DescriptorPool::generated_pool(), - ::google::protobuf::MessageFactory::generated_factory(), - sizeof(ConcatParameter)); + sizeof(ConcatParameter), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ConcatParameter, _internal_metadata_)); ContrastiveLossParameter_descriptor_ = file->message_type(22); static const int ContrastiveLossParameter_offsets_[2] = { GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ContrastiveLossParameter, margin_), GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ContrastiveLossParameter, legacy_version_), }; ContrastiveLossParameter_reflection_ = - new ::google::protobuf::internal::GeneratedMessageReflection( + ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection( ContrastiveLossParameter_descriptor_, - ContrastiveLossParameter::default_instance_, + ContrastiveLossParameter::internal_default_instance(), ContrastiveLossParameter_offsets_, - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ContrastiveLossParameter, _has_bits_[0]), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ContrastiveLossParameter, _unknown_fields_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ContrastiveLossParameter, _has_bits_), -1, - ::google::protobuf::DescriptorPool::generated_pool(), - ::google::protobuf::MessageFactory::generated_factory(), - sizeof(ContrastiveLossParameter)); + -1, + sizeof(ContrastiveLossParameter), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ContrastiveLossParameter, _internal_metadata_)); ConvolutionParameter_descriptor_ = file->message_type(23); static const int ConvolutionParameter_offsets_[18] = { GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ConvolutionParameter, num_output_), @@ -751,16 +730,15 @@ void protobuf_AssignDesc_caffe_2eproto() { GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ConvolutionParameter, dilation_), }; ConvolutionParameter_reflection_ = - new ::google::protobuf::internal::GeneratedMessageReflection( + ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection( ConvolutionParameter_descriptor_, - ConvolutionParameter::default_instance_, + ConvolutionParameter::internal_default_instance(), ConvolutionParameter_offsets_, - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ConvolutionParameter, _has_bits_[0]), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ConvolutionParameter, _unknown_fields_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ConvolutionParameter, _has_bits_), + -1, -1, - ::google::protobuf::DescriptorPool::generated_pool(), - ::google::protobuf::MessageFactory::generated_factory(), - sizeof(ConvolutionParameter)); + sizeof(ConvolutionParameter), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ConvolutionParameter, _internal_metadata_)); ConvolutionParameter_Engine_descriptor_ = ConvolutionParameter_descriptor_->enum_type(0); DataParameter_descriptor_ = file->message_type(24); static const int DataParameter_offsets_[9] = { @@ -775,32 +753,30 @@ void protobuf_AssignDesc_caffe_2eproto() { GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DataParameter, force_encoded_color_), }; DataParameter_reflection_ = - new ::google::protobuf::internal::GeneratedMessageReflection( + ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection( DataParameter_descriptor_, - DataParameter::default_instance_, + DataParameter::internal_default_instance(), DataParameter_offsets_, - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DataParameter, _has_bits_[0]), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DataParameter, _unknown_fields_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DataParameter, _has_bits_), -1, - ::google::protobuf::DescriptorPool::generated_pool(), - ::google::protobuf::MessageFactory::generated_factory(), - sizeof(DataParameter)); + -1, + sizeof(DataParameter), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DataParameter, _internal_metadata_)); DataParameter_DB_descriptor_ = DataParameter_descriptor_->enum_type(0); DropoutParameter_descriptor_ = file->message_type(25); static const int DropoutParameter_offsets_[1] = { GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DropoutParameter, dropout_ratio_), }; DropoutParameter_reflection_ = - new ::google::protobuf::internal::GeneratedMessageReflection( + ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection( DropoutParameter_descriptor_, - DropoutParameter::default_instance_, + DropoutParameter::internal_default_instance(), DropoutParameter_offsets_, - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DropoutParameter, _has_bits_[0]), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DropoutParameter, _unknown_fields_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DropoutParameter, _has_bits_), + -1, -1, - ::google::protobuf::DescriptorPool::generated_pool(), - ::google::protobuf::MessageFactory::generated_factory(), - sizeof(DropoutParameter)); + sizeof(DropoutParameter), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DropoutParameter, _internal_metadata_)); DummyDataParameter_descriptor_ = file->message_type(26); static const int DummyDataParameter_offsets_[6] = { GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DummyDataParameter, data_filler_), @@ -811,16 +787,15 @@ void protobuf_AssignDesc_caffe_2eproto() { GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DummyDataParameter, width_), }; DummyDataParameter_reflection_ = - new ::google::protobuf::internal::GeneratedMessageReflection( + ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection( DummyDataParameter_descriptor_, - DummyDataParameter::default_instance_, + DummyDataParameter::internal_default_instance(), DummyDataParameter_offsets_, - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DummyDataParameter, _has_bits_[0]), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DummyDataParameter, _unknown_fields_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DummyDataParameter, _has_bits_), -1, - ::google::protobuf::DescriptorPool::generated_pool(), - ::google::protobuf::MessageFactory::generated_factory(), - sizeof(DummyDataParameter)); + -1, + sizeof(DummyDataParameter), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DummyDataParameter, _internal_metadata_)); EltwiseParameter_descriptor_ = file->message_type(27); static const int EltwiseParameter_offsets_[3] = { GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(EltwiseParameter, operation_), @@ -828,16 +803,15 @@ void protobuf_AssignDesc_caffe_2eproto() { GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(EltwiseParameter, stable_prod_grad_), }; EltwiseParameter_reflection_ = - new ::google::protobuf::internal::GeneratedMessageReflection( + ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection( EltwiseParameter_descriptor_, - EltwiseParameter::default_instance_, + EltwiseParameter::internal_default_instance(), EltwiseParameter_offsets_, - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(EltwiseParameter, _has_bits_[0]), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(EltwiseParameter, _unknown_fields_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(EltwiseParameter, _has_bits_), + -1, -1, - ::google::protobuf::DescriptorPool::generated_pool(), - ::google::protobuf::MessageFactory::generated_factory(), - sizeof(EltwiseParameter)); + sizeof(EltwiseParameter), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(EltwiseParameter, _internal_metadata_)); EltwiseParameter_EltwiseOp_descriptor_ = EltwiseParameter_descriptor_->enum_type(0); ExpParameter_descriptor_ = file->message_type(28); static const int ExpParameter_offsets_[3] = { @@ -846,32 +820,30 @@ void protobuf_AssignDesc_caffe_2eproto() { GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ExpParameter, shift_), }; ExpParameter_reflection_ = - new ::google::protobuf::internal::GeneratedMessageReflection( + ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection( ExpParameter_descriptor_, - ExpParameter::default_instance_, + ExpParameter::internal_default_instance(), ExpParameter_offsets_, - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ExpParameter, _has_bits_[0]), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ExpParameter, _unknown_fields_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ExpParameter, _has_bits_), -1, - ::google::protobuf::DescriptorPool::generated_pool(), - ::google::protobuf::MessageFactory::generated_factory(), - sizeof(ExpParameter)); + -1, + sizeof(ExpParameter), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ExpParameter, _internal_metadata_)); FlattenParameter_descriptor_ = file->message_type(29); static const int FlattenParameter_offsets_[2] = { GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FlattenParameter, axis_), GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FlattenParameter, end_axis_), }; FlattenParameter_reflection_ = - new ::google::protobuf::internal::GeneratedMessageReflection( + ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection( FlattenParameter_descriptor_, - FlattenParameter::default_instance_, + FlattenParameter::internal_default_instance(), FlattenParameter_offsets_, - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FlattenParameter, _has_bits_[0]), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FlattenParameter, _unknown_fields_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FlattenParameter, _has_bits_), + -1, -1, - ::google::protobuf::DescriptorPool::generated_pool(), - ::google::protobuf::MessageFactory::generated_factory(), - sizeof(FlattenParameter)); + sizeof(FlattenParameter), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FlattenParameter, _internal_metadata_)); HDF5DataParameter_descriptor_ = file->message_type(30); static const int HDF5DataParameter_offsets_[3] = { GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(HDF5DataParameter, source_), @@ -879,46 +851,43 @@ void protobuf_AssignDesc_caffe_2eproto() { GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(HDF5DataParameter, shuffle_), }; HDF5DataParameter_reflection_ = - new ::google::protobuf::internal::GeneratedMessageReflection( + ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection( HDF5DataParameter_descriptor_, - HDF5DataParameter::default_instance_, + HDF5DataParameter::internal_default_instance(), HDF5DataParameter_offsets_, - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(HDF5DataParameter, _has_bits_[0]), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(HDF5DataParameter, _unknown_fields_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(HDF5DataParameter, _has_bits_), -1, - ::google::protobuf::DescriptorPool::generated_pool(), - ::google::protobuf::MessageFactory::generated_factory(), - sizeof(HDF5DataParameter)); + -1, + sizeof(HDF5DataParameter), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(HDF5DataParameter, _internal_metadata_)); HDF5OutputParameter_descriptor_ = file->message_type(31); static const int HDF5OutputParameter_offsets_[1] = { GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(HDF5OutputParameter, file_name_), }; HDF5OutputParameter_reflection_ = - new ::google::protobuf::internal::GeneratedMessageReflection( + ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection( HDF5OutputParameter_descriptor_, - HDF5OutputParameter::default_instance_, + HDF5OutputParameter::internal_default_instance(), HDF5OutputParameter_offsets_, - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(HDF5OutputParameter, _has_bits_[0]), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(HDF5OutputParameter, _unknown_fields_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(HDF5OutputParameter, _has_bits_), + -1, -1, - ::google::protobuf::DescriptorPool::generated_pool(), - ::google::protobuf::MessageFactory::generated_factory(), - sizeof(HDF5OutputParameter)); + sizeof(HDF5OutputParameter), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(HDF5OutputParameter, _internal_metadata_)); HingeLossParameter_descriptor_ = file->message_type(32); static const int HingeLossParameter_offsets_[1] = { GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(HingeLossParameter, norm_), }; HingeLossParameter_reflection_ = - new ::google::protobuf::internal::GeneratedMessageReflection( + ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection( HingeLossParameter_descriptor_, - HingeLossParameter::default_instance_, + HingeLossParameter::internal_default_instance(), HingeLossParameter_offsets_, - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(HingeLossParameter, _has_bits_[0]), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(HingeLossParameter, _unknown_fields_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(HingeLossParameter, _has_bits_), -1, - ::google::protobuf::DescriptorPool::generated_pool(), - ::google::protobuf::MessageFactory::generated_factory(), - sizeof(HingeLossParameter)); + -1, + sizeof(HingeLossParameter), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(HingeLossParameter, _internal_metadata_)); HingeLossParameter_Norm_descriptor_ = HingeLossParameter_descriptor_->enum_type(0); ImageDataParameter_descriptor_ = file->message_type(33); static const int ImageDataParameter_offsets_[12] = { @@ -936,31 +905,29 @@ void protobuf_AssignDesc_caffe_2eproto() { GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ImageDataParameter, root_folder_), }; ImageDataParameter_reflection_ = - new ::google::protobuf::internal::GeneratedMessageReflection( + ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection( ImageDataParameter_descriptor_, - ImageDataParameter::default_instance_, + ImageDataParameter::internal_default_instance(), ImageDataParameter_offsets_, - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ImageDataParameter, _has_bits_[0]), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ImageDataParameter, _unknown_fields_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ImageDataParameter, _has_bits_), + -1, -1, - ::google::protobuf::DescriptorPool::generated_pool(), - ::google::protobuf::MessageFactory::generated_factory(), - sizeof(ImageDataParameter)); + sizeof(ImageDataParameter), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ImageDataParameter, _internal_metadata_)); InfogainLossParameter_descriptor_ = file->message_type(34); static const int InfogainLossParameter_offsets_[1] = { GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(InfogainLossParameter, source_), }; InfogainLossParameter_reflection_ = - new ::google::protobuf::internal::GeneratedMessageReflection( + ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection( InfogainLossParameter_descriptor_, - InfogainLossParameter::default_instance_, + InfogainLossParameter::internal_default_instance(), InfogainLossParameter_offsets_, - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(InfogainLossParameter, _has_bits_[0]), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(InfogainLossParameter, _unknown_fields_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(InfogainLossParameter, _has_bits_), -1, - ::google::protobuf::DescriptorPool::generated_pool(), - ::google::protobuf::MessageFactory::generated_factory(), - sizeof(InfogainLossParameter)); + -1, + sizeof(InfogainLossParameter), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(InfogainLossParameter, _internal_metadata_)); InnerProductParameter_descriptor_ = file->message_type(35); static const int InnerProductParameter_offsets_[5] = { GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(InnerProductParameter, num_output_), @@ -970,16 +937,15 @@ void protobuf_AssignDesc_caffe_2eproto() { GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(InnerProductParameter, axis_), }; InnerProductParameter_reflection_ = - new ::google::protobuf::internal::GeneratedMessageReflection( + ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection( InnerProductParameter_descriptor_, - InnerProductParameter::default_instance_, + InnerProductParameter::internal_default_instance(), InnerProductParameter_offsets_, - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(InnerProductParameter, _has_bits_[0]), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(InnerProductParameter, _unknown_fields_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(InnerProductParameter, _has_bits_), + -1, -1, - ::google::protobuf::DescriptorPool::generated_pool(), - ::google::protobuf::MessageFactory::generated_factory(), - sizeof(InnerProductParameter)); + sizeof(InnerProductParameter), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(InnerProductParameter, _internal_metadata_)); LogParameter_descriptor_ = file->message_type(36); static const int LogParameter_offsets_[3] = { GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(LogParameter, base_), @@ -987,16 +953,15 @@ void protobuf_AssignDesc_caffe_2eproto() { GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(LogParameter, shift_), }; LogParameter_reflection_ = - new ::google::protobuf::internal::GeneratedMessageReflection( + ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection( LogParameter_descriptor_, - LogParameter::default_instance_, + LogParameter::internal_default_instance(), LogParameter_offsets_, - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(LogParameter, _has_bits_[0]), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(LogParameter, _unknown_fields_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(LogParameter, _has_bits_), -1, - ::google::protobuf::DescriptorPool::generated_pool(), - ::google::protobuf::MessageFactory::generated_factory(), - sizeof(LogParameter)); + -1, + sizeof(LogParameter), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(LogParameter, _internal_metadata_)); LRNParameter_descriptor_ = file->message_type(37); static const int LRNParameter_offsets_[5] = { GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(LRNParameter, local_size_), @@ -1006,16 +971,15 @@ void protobuf_AssignDesc_caffe_2eproto() { GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(LRNParameter, k_), }; LRNParameter_reflection_ = - new ::google::protobuf::internal::GeneratedMessageReflection( + ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection( LRNParameter_descriptor_, - LRNParameter::default_instance_, + LRNParameter::internal_default_instance(), LRNParameter_offsets_, - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(LRNParameter, _has_bits_[0]), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(LRNParameter, _unknown_fields_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(LRNParameter, _has_bits_), + -1, -1, - ::google::protobuf::DescriptorPool::generated_pool(), - ::google::protobuf::MessageFactory::generated_factory(), - sizeof(LRNParameter)); + sizeof(LRNParameter), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(LRNParameter, _internal_metadata_)); LRNParameter_NormRegion_descriptor_ = LRNParameter_descriptor_->enum_type(0); MemoryDataParameter_descriptor_ = file->message_type(38); static const int MemoryDataParameter_offsets_[4] = { @@ -1025,16 +989,15 @@ void protobuf_AssignDesc_caffe_2eproto() { GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MemoryDataParameter, width_), }; MemoryDataParameter_reflection_ = - new ::google::protobuf::internal::GeneratedMessageReflection( + ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection( MemoryDataParameter_descriptor_, - MemoryDataParameter::default_instance_, + MemoryDataParameter::internal_default_instance(), MemoryDataParameter_offsets_, - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MemoryDataParameter, _has_bits_[0]), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MemoryDataParameter, _unknown_fields_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MemoryDataParameter, _has_bits_), -1, - ::google::protobuf::DescriptorPool::generated_pool(), - ::google::protobuf::MessageFactory::generated_factory(), - sizeof(MemoryDataParameter)); + -1, + sizeof(MemoryDataParameter), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MemoryDataParameter, _internal_metadata_)); MVNParameter_descriptor_ = file->message_type(39); static const int MVNParameter_offsets_[3] = { GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MVNParameter, normalize_variance_), @@ -1042,16 +1005,15 @@ void protobuf_AssignDesc_caffe_2eproto() { GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MVNParameter, eps_), }; MVNParameter_reflection_ = - new ::google::protobuf::internal::GeneratedMessageReflection( + ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection( MVNParameter_descriptor_, - MVNParameter::default_instance_, + MVNParameter::internal_default_instance(), MVNParameter_offsets_, - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MVNParameter, _has_bits_[0]), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MVNParameter, _unknown_fields_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MVNParameter, _has_bits_), + -1, -1, - ::google::protobuf::DescriptorPool::generated_pool(), - ::google::protobuf::MessageFactory::generated_factory(), - sizeof(MVNParameter)); + sizeof(MVNParameter), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MVNParameter, _internal_metadata_)); PoolingParameter_descriptor_ = file->message_type(40); static const int PoolingParameter_offsets_[12] = { GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(PoolingParameter, pool_), @@ -1068,16 +1030,15 @@ void protobuf_AssignDesc_caffe_2eproto() { GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(PoolingParameter, global_pooling_), }; PoolingParameter_reflection_ = - new ::google::protobuf::internal::GeneratedMessageReflection( + ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection( PoolingParameter_descriptor_, - PoolingParameter::default_instance_, + PoolingParameter::internal_default_instance(), PoolingParameter_offsets_, - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(PoolingParameter, _has_bits_[0]), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(PoolingParameter, _unknown_fields_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(PoolingParameter, _has_bits_), -1, - ::google::protobuf::DescriptorPool::generated_pool(), - ::google::protobuf::MessageFactory::generated_factory(), - sizeof(PoolingParameter)); + -1, + sizeof(PoolingParameter), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(PoolingParameter, _internal_metadata_)); PoolingParameter_PoolMethod_descriptor_ = PoolingParameter_descriptor_->enum_type(0); PoolingParameter_Engine_descriptor_ = PoolingParameter_descriptor_->enum_type(1); PowerParameter_descriptor_ = file->message_type(41); @@ -1087,32 +1048,30 @@ void protobuf_AssignDesc_caffe_2eproto() { GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(PowerParameter, shift_), }; PowerParameter_reflection_ = - new ::google::protobuf::internal::GeneratedMessageReflection( + ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection( PowerParameter_descriptor_, - PowerParameter::default_instance_, + PowerParameter::internal_default_instance(), PowerParameter_offsets_, - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(PowerParameter, _has_bits_[0]), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(PowerParameter, _unknown_fields_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(PowerParameter, _has_bits_), + -1, -1, - ::google::protobuf::DescriptorPool::generated_pool(), - ::google::protobuf::MessageFactory::generated_factory(), - sizeof(PowerParameter)); + sizeof(PowerParameter), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(PowerParameter, _internal_metadata_)); PythonParameter_descriptor_ = file->message_type(42); static const int PythonParameter_offsets_[2] = { GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(PythonParameter, module_), GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(PythonParameter, layer_), }; PythonParameter_reflection_ = - new ::google::protobuf::internal::GeneratedMessageReflection( + ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection( PythonParameter_descriptor_, - PythonParameter::default_instance_, + PythonParameter::internal_default_instance(), PythonParameter_offsets_, - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(PythonParameter, _has_bits_[0]), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(PythonParameter, _unknown_fields_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(PythonParameter, _has_bits_), -1, - ::google::protobuf::DescriptorPool::generated_pool(), - ::google::protobuf::MessageFactory::generated_factory(), - sizeof(PythonParameter)); + -1, + sizeof(PythonParameter), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(PythonParameter, _internal_metadata_)); ReductionParameter_descriptor_ = file->message_type(43); static const int ReductionParameter_offsets_[3] = { GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ReductionParameter, operation_), @@ -1120,16 +1079,15 @@ void protobuf_AssignDesc_caffe_2eproto() { GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ReductionParameter, coeff_), }; ReductionParameter_reflection_ = - new ::google::protobuf::internal::GeneratedMessageReflection( + ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection( ReductionParameter_descriptor_, - ReductionParameter::default_instance_, + ReductionParameter::internal_default_instance(), ReductionParameter_offsets_, - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ReductionParameter, _has_bits_[0]), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ReductionParameter, _unknown_fields_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ReductionParameter, _has_bits_), + -1, -1, - ::google::protobuf::DescriptorPool::generated_pool(), - ::google::protobuf::MessageFactory::generated_factory(), - sizeof(ReductionParameter)); + sizeof(ReductionParameter), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ReductionParameter, _internal_metadata_)); ReductionParameter_ReductionOp_descriptor_ = ReductionParameter_descriptor_->enum_type(0); ReLUParameter_descriptor_ = file->message_type(44); static const int ReLUParameter_offsets_[2] = { @@ -1137,16 +1095,15 @@ void protobuf_AssignDesc_caffe_2eproto() { GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ReLUParameter, engine_), }; ReLUParameter_reflection_ = - new ::google::protobuf::internal::GeneratedMessageReflection( + ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection( ReLUParameter_descriptor_, - ReLUParameter::default_instance_, + ReLUParameter::internal_default_instance(), ReLUParameter_offsets_, - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ReLUParameter, _has_bits_[0]), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ReLUParameter, _unknown_fields_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ReLUParameter, _has_bits_), -1, - ::google::protobuf::DescriptorPool::generated_pool(), - ::google::protobuf::MessageFactory::generated_factory(), - sizeof(ReLUParameter)); + -1, + sizeof(ReLUParameter), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ReLUParameter, _internal_metadata_)); ReLUParameter_Engine_descriptor_ = ReLUParameter_descriptor_->enum_type(0); ReshapeParameter_descriptor_ = file->message_type(45); static const int ReshapeParameter_offsets_[3] = { @@ -1155,31 +1112,29 @@ void protobuf_AssignDesc_caffe_2eproto() { GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ReshapeParameter, num_axes_), }; ReshapeParameter_reflection_ = - new ::google::protobuf::internal::GeneratedMessageReflection( + ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection( ReshapeParameter_descriptor_, - ReshapeParameter::default_instance_, + ReshapeParameter::internal_default_instance(), ReshapeParameter_offsets_, - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ReshapeParameter, _has_bits_[0]), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ReshapeParameter, _unknown_fields_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ReshapeParameter, _has_bits_), + -1, -1, - ::google::protobuf::DescriptorPool::generated_pool(), - ::google::protobuf::MessageFactory::generated_factory(), - sizeof(ReshapeParameter)); + sizeof(ReshapeParameter), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ReshapeParameter, _internal_metadata_)); SigmoidParameter_descriptor_ = file->message_type(46); static const int SigmoidParameter_offsets_[1] = { GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(SigmoidParameter, engine_), }; SigmoidParameter_reflection_ = - new ::google::protobuf::internal::GeneratedMessageReflection( + ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection( SigmoidParameter_descriptor_, - SigmoidParameter::default_instance_, + SigmoidParameter::internal_default_instance(), SigmoidParameter_offsets_, - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(SigmoidParameter, _has_bits_[0]), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(SigmoidParameter, _unknown_fields_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(SigmoidParameter, _has_bits_), -1, - ::google::protobuf::DescriptorPool::generated_pool(), - ::google::protobuf::MessageFactory::generated_factory(), - sizeof(SigmoidParameter)); + -1, + sizeof(SigmoidParameter), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(SigmoidParameter, _internal_metadata_)); SigmoidParameter_Engine_descriptor_ = SigmoidParameter_descriptor_->enum_type(0); SliceParameter_descriptor_ = file->message_type(47); static const int SliceParameter_offsets_[3] = { @@ -1188,64 +1143,60 @@ void protobuf_AssignDesc_caffe_2eproto() { GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(SliceParameter, slice_dim_), }; SliceParameter_reflection_ = - new ::google::protobuf::internal::GeneratedMessageReflection( + ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection( SliceParameter_descriptor_, - SliceParameter::default_instance_, + SliceParameter::internal_default_instance(), SliceParameter_offsets_, - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(SliceParameter, _has_bits_[0]), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(SliceParameter, _unknown_fields_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(SliceParameter, _has_bits_), + -1, -1, - ::google::protobuf::DescriptorPool::generated_pool(), - ::google::protobuf::MessageFactory::generated_factory(), - sizeof(SliceParameter)); + sizeof(SliceParameter), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(SliceParameter, _internal_metadata_)); SoftmaxParameter_descriptor_ = file->message_type(48); static const int SoftmaxParameter_offsets_[2] = { GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(SoftmaxParameter, engine_), GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(SoftmaxParameter, axis_), }; SoftmaxParameter_reflection_ = - new ::google::protobuf::internal::GeneratedMessageReflection( + ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection( SoftmaxParameter_descriptor_, - SoftmaxParameter::default_instance_, + SoftmaxParameter::internal_default_instance(), SoftmaxParameter_offsets_, - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(SoftmaxParameter, _has_bits_[0]), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(SoftmaxParameter, _unknown_fields_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(SoftmaxParameter, _has_bits_), -1, - ::google::protobuf::DescriptorPool::generated_pool(), - ::google::protobuf::MessageFactory::generated_factory(), - sizeof(SoftmaxParameter)); + -1, + sizeof(SoftmaxParameter), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(SoftmaxParameter, _internal_metadata_)); SoftmaxParameter_Engine_descriptor_ = SoftmaxParameter_descriptor_->enum_type(0); TanHParameter_descriptor_ = file->message_type(49); static const int TanHParameter_offsets_[1] = { GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(TanHParameter, engine_), }; TanHParameter_reflection_ = - new ::google::protobuf::internal::GeneratedMessageReflection( + ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection( TanHParameter_descriptor_, - TanHParameter::default_instance_, + TanHParameter::internal_default_instance(), TanHParameter_offsets_, - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(TanHParameter, _has_bits_[0]), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(TanHParameter, _unknown_fields_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(TanHParameter, _has_bits_), + -1, -1, - ::google::protobuf::DescriptorPool::generated_pool(), - ::google::protobuf::MessageFactory::generated_factory(), - sizeof(TanHParameter)); + sizeof(TanHParameter), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(TanHParameter, _internal_metadata_)); TanHParameter_Engine_descriptor_ = TanHParameter_descriptor_->enum_type(0); ThresholdParameter_descriptor_ = file->message_type(50); static const int ThresholdParameter_offsets_[1] = { GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ThresholdParameter, threshold_), }; ThresholdParameter_reflection_ = - new ::google::protobuf::internal::GeneratedMessageReflection( + ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection( ThresholdParameter_descriptor_, - ThresholdParameter::default_instance_, + ThresholdParameter::internal_default_instance(), ThresholdParameter_offsets_, - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ThresholdParameter, _has_bits_[0]), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ThresholdParameter, _unknown_fields_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ThresholdParameter, _has_bits_), -1, - ::google::protobuf::DescriptorPool::generated_pool(), - ::google::protobuf::MessageFactory::generated_factory(), - sizeof(ThresholdParameter)); + -1, + sizeof(ThresholdParameter), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ThresholdParameter, _internal_metadata_)); WindowDataParameter_descriptor_ = file->message_type(51); static const int WindowDataParameter_offsets_[13] = { GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(WindowDataParameter, source_), @@ -1263,16 +1214,15 @@ void protobuf_AssignDesc_caffe_2eproto() { GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(WindowDataParameter, root_folder_), }; WindowDataParameter_reflection_ = - new ::google::protobuf::internal::GeneratedMessageReflection( + ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection( WindowDataParameter_descriptor_, - WindowDataParameter::default_instance_, + WindowDataParameter::internal_default_instance(), WindowDataParameter_offsets_, - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(WindowDataParameter, _has_bits_[0]), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(WindowDataParameter, _unknown_fields_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(WindowDataParameter, _has_bits_), + -1, -1, - ::google::protobuf::DescriptorPool::generated_pool(), - ::google::protobuf::MessageFactory::generated_factory(), - sizeof(WindowDataParameter)); + sizeof(WindowDataParameter), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(WindowDataParameter, _internal_metadata_)); SPPParameter_descriptor_ = file->message_type(52); static const int SPPParameter_offsets_[3] = { GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(SPPParameter, pyramid_height_), @@ -1280,16 +1230,15 @@ void protobuf_AssignDesc_caffe_2eproto() { GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(SPPParameter, engine_), }; SPPParameter_reflection_ = - new ::google::protobuf::internal::GeneratedMessageReflection( + ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection( SPPParameter_descriptor_, - SPPParameter::default_instance_, + SPPParameter::internal_default_instance(), SPPParameter_offsets_, - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(SPPParameter, _has_bits_[0]), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(SPPParameter, _unknown_fields_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(SPPParameter, _has_bits_), -1, - ::google::protobuf::DescriptorPool::generated_pool(), - ::google::protobuf::MessageFactory::generated_factory(), - sizeof(SPPParameter)); + -1, + sizeof(SPPParameter), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(SPPParameter, _internal_metadata_)); SPPParameter_PoolMethod_descriptor_ = SPPParameter_descriptor_->enum_type(0); SPPParameter_Engine_descriptor_ = SPPParameter_descriptor_->enum_type(1); V1LayerParameter_descriptor_ = file->message_type(53); @@ -1339,16 +1288,15 @@ void protobuf_AssignDesc_caffe_2eproto() { GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(V1LayerParameter, layer_), }; V1LayerParameter_reflection_ = - new ::google::protobuf::internal::GeneratedMessageReflection( + ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection( V1LayerParameter_descriptor_, - V1LayerParameter::default_instance_, + V1LayerParameter::internal_default_instance(), V1LayerParameter_offsets_, - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(V1LayerParameter, _has_bits_[0]), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(V1LayerParameter, _unknown_fields_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(V1LayerParameter, _has_bits_), + -1, -1, - ::google::protobuf::DescriptorPool::generated_pool(), - ::google::protobuf::MessageFactory::generated_factory(), - sizeof(V1LayerParameter)); + sizeof(V1LayerParameter), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(V1LayerParameter, _internal_metadata_)); V1LayerParameter_LayerType_descriptor_ = V1LayerParameter_descriptor_->enum_type(0); V1LayerParameter_DimCheckMode_descriptor_ = V1LayerParameter_descriptor_->enum_type(1); V0LayerParameter_descriptor_ = file->message_type(54); @@ -1393,16 +1341,15 @@ void protobuf_AssignDesc_caffe_2eproto() { GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(V0LayerParameter, hdf5_output_param_), }; V0LayerParameter_reflection_ = - new ::google::protobuf::internal::GeneratedMessageReflection( + ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection( V0LayerParameter_descriptor_, - V0LayerParameter::default_instance_, + V0LayerParameter::internal_default_instance(), V0LayerParameter_offsets_, - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(V0LayerParameter, _has_bits_[0]), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(V0LayerParameter, _unknown_fields_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(V0LayerParameter, _has_bits_), -1, - ::google::protobuf::DescriptorPool::generated_pool(), - ::google::protobuf::MessageFactory::generated_factory(), - sizeof(V0LayerParameter)); + -1, + sizeof(V0LayerParameter), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(V0LayerParameter, _internal_metadata_)); V0LayerParameter_PoolMethod_descriptor_ = V0LayerParameter_descriptor_->enum_type(0); PReLUParameter_descriptor_ = file->message_type(55); static const int PReLUParameter_offsets_[2] = { @@ -1410,16 +1357,15 @@ void protobuf_AssignDesc_caffe_2eproto() { GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(PReLUParameter, channel_shared_), }; PReLUParameter_reflection_ = - new ::google::protobuf::internal::GeneratedMessageReflection( + ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection( PReLUParameter_descriptor_, - PReLUParameter::default_instance_, + PReLUParameter::internal_default_instance(), PReLUParameter_offsets_, - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(PReLUParameter, _has_bits_[0]), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(PReLUParameter, _unknown_fields_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(PReLUParameter, _has_bits_), + -1, -1, - ::google::protobuf::DescriptorPool::generated_pool(), - ::google::protobuf::MessageFactory::generated_factory(), - sizeof(PReLUParameter)); + sizeof(PReLUParameter), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(PReLUParameter, _internal_metadata_)); NormalizedBBox_descriptor_ = file->message_type(56); static const int NormalizedBBox_offsets_[8] = { GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(NormalizedBBox, xmin_), @@ -1432,274 +1378,423 @@ void protobuf_AssignDesc_caffe_2eproto() { GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(NormalizedBBox, size_), }; NormalizedBBox_reflection_ = - new ::google::protobuf::internal::GeneratedMessageReflection( + ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection( NormalizedBBox_descriptor_, - NormalizedBBox::default_instance_, + NormalizedBBox::internal_default_instance(), NormalizedBBox_offsets_, - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(NormalizedBBox, _has_bits_[0]), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(NormalizedBBox, _unknown_fields_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(NormalizedBBox, _has_bits_), -1, - ::google::protobuf::DescriptorPool::generated_pool(), - ::google::protobuf::MessageFactory::generated_factory(), - sizeof(NormalizedBBox)); + -1, + sizeof(NormalizedBBox), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(NormalizedBBox, _internal_metadata_)); Phase_descriptor_ = file->enum_type(0); } namespace { GOOGLE_PROTOBUF_DECLARE_ONCE(protobuf_AssignDescriptors_once_); -inline void protobuf_AssignDescriptorsOnce() { +void protobuf_AssignDescriptorsOnce() { ::google::protobuf::GoogleOnceInit(&protobuf_AssignDescriptors_once_, &protobuf_AssignDesc_caffe_2eproto); } +void protobuf_RegisterTypes(const ::std::string&) GOOGLE_ATTRIBUTE_COLD; void protobuf_RegisterTypes(const ::std::string&) { protobuf_AssignDescriptorsOnce(); ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - BlobShape_descriptor_, &BlobShape::default_instance()); + BlobShape_descriptor_, BlobShape::internal_default_instance()); ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - BlobProto_descriptor_, &BlobProto::default_instance()); + BlobProto_descriptor_, BlobProto::internal_default_instance()); ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - BlobProtoVector_descriptor_, &BlobProtoVector::default_instance()); + BlobProtoVector_descriptor_, BlobProtoVector::internal_default_instance()); ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - CropParameter_descriptor_, &CropParameter::default_instance()); + CropParameter_descriptor_, CropParameter::internal_default_instance()); ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - PermuteParameter_descriptor_, &PermuteParameter::default_instance()); + PermuteParameter_descriptor_, PermuteParameter::internal_default_instance()); ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - NormalizeBBoxParameter_descriptor_, &NormalizeBBoxParameter::default_instance()); + NormalizeBBoxParameter_descriptor_, NormalizeBBoxParameter::internal_default_instance()); ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - PriorBoxParameter_descriptor_, &PriorBoxParameter::default_instance()); + PriorBoxParameter_descriptor_, PriorBoxParameter::internal_default_instance()); ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - DetectionOutputParameter_descriptor_, &DetectionOutputParameter::default_instance()); + DetectionOutputParameter_descriptor_, DetectionOutputParameter::internal_default_instance()); ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - Datum_descriptor_, &Datum::default_instance()); + Datum_descriptor_, Datum::internal_default_instance()); ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - FillerParameter_descriptor_, &FillerParameter::default_instance()); + FillerParameter_descriptor_, FillerParameter::internal_default_instance()); ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - NetParameter_descriptor_, &NetParameter::default_instance()); + NetParameter_descriptor_, NetParameter::internal_default_instance()); ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - SolverParameter_descriptor_, &SolverParameter::default_instance()); + SolverParameter_descriptor_, SolverParameter::internal_default_instance()); ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - SolverState_descriptor_, &SolverState::default_instance()); + SolverState_descriptor_, SolverState::internal_default_instance()); ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - NetState_descriptor_, &NetState::default_instance()); + NetState_descriptor_, NetState::internal_default_instance()); ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - NetStateRule_descriptor_, &NetStateRule::default_instance()); + NetStateRule_descriptor_, NetStateRule::internal_default_instance()); ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - ParamSpec_descriptor_, &ParamSpec::default_instance()); + ParamSpec_descriptor_, ParamSpec::internal_default_instance()); ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - LayerParameter_descriptor_, &LayerParameter::default_instance()); + LayerParameter_descriptor_, LayerParameter::internal_default_instance()); ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - TransformationParameter_descriptor_, &TransformationParameter::default_instance()); + TransformationParameter_descriptor_, TransformationParameter::internal_default_instance()); ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - LossParameter_descriptor_, &LossParameter::default_instance()); + LossParameter_descriptor_, LossParameter::internal_default_instance()); ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - AccuracyParameter_descriptor_, &AccuracyParameter::default_instance()); + AccuracyParameter_descriptor_, AccuracyParameter::internal_default_instance()); ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - ArgMaxParameter_descriptor_, &ArgMaxParameter::default_instance()); + ArgMaxParameter_descriptor_, ArgMaxParameter::internal_default_instance()); ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - ConcatParameter_descriptor_, &ConcatParameter::default_instance()); + ConcatParameter_descriptor_, ConcatParameter::internal_default_instance()); ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - ContrastiveLossParameter_descriptor_, &ContrastiveLossParameter::default_instance()); + ContrastiveLossParameter_descriptor_, ContrastiveLossParameter::internal_default_instance()); ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - ConvolutionParameter_descriptor_, &ConvolutionParameter::default_instance()); + ConvolutionParameter_descriptor_, ConvolutionParameter::internal_default_instance()); ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - DataParameter_descriptor_, &DataParameter::default_instance()); + DataParameter_descriptor_, DataParameter::internal_default_instance()); ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - DropoutParameter_descriptor_, &DropoutParameter::default_instance()); + DropoutParameter_descriptor_, DropoutParameter::internal_default_instance()); ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - DummyDataParameter_descriptor_, &DummyDataParameter::default_instance()); + DummyDataParameter_descriptor_, DummyDataParameter::internal_default_instance()); ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - EltwiseParameter_descriptor_, &EltwiseParameter::default_instance()); + EltwiseParameter_descriptor_, EltwiseParameter::internal_default_instance()); ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - ExpParameter_descriptor_, &ExpParameter::default_instance()); + ExpParameter_descriptor_, ExpParameter::internal_default_instance()); ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - FlattenParameter_descriptor_, &FlattenParameter::default_instance()); + FlattenParameter_descriptor_, FlattenParameter::internal_default_instance()); ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - HDF5DataParameter_descriptor_, &HDF5DataParameter::default_instance()); + HDF5DataParameter_descriptor_, HDF5DataParameter::internal_default_instance()); ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - HDF5OutputParameter_descriptor_, &HDF5OutputParameter::default_instance()); + HDF5OutputParameter_descriptor_, HDF5OutputParameter::internal_default_instance()); ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - HingeLossParameter_descriptor_, &HingeLossParameter::default_instance()); + HingeLossParameter_descriptor_, HingeLossParameter::internal_default_instance()); ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - ImageDataParameter_descriptor_, &ImageDataParameter::default_instance()); + ImageDataParameter_descriptor_, ImageDataParameter::internal_default_instance()); ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - InfogainLossParameter_descriptor_, &InfogainLossParameter::default_instance()); + InfogainLossParameter_descriptor_, InfogainLossParameter::internal_default_instance()); ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - InnerProductParameter_descriptor_, &InnerProductParameter::default_instance()); + InnerProductParameter_descriptor_, InnerProductParameter::internal_default_instance()); ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - LogParameter_descriptor_, &LogParameter::default_instance()); + LogParameter_descriptor_, LogParameter::internal_default_instance()); ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - LRNParameter_descriptor_, &LRNParameter::default_instance()); + LRNParameter_descriptor_, LRNParameter::internal_default_instance()); ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - MemoryDataParameter_descriptor_, &MemoryDataParameter::default_instance()); + MemoryDataParameter_descriptor_, MemoryDataParameter::internal_default_instance()); ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - MVNParameter_descriptor_, &MVNParameter::default_instance()); + MVNParameter_descriptor_, MVNParameter::internal_default_instance()); ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - PoolingParameter_descriptor_, &PoolingParameter::default_instance()); + PoolingParameter_descriptor_, PoolingParameter::internal_default_instance()); ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - PowerParameter_descriptor_, &PowerParameter::default_instance()); + PowerParameter_descriptor_, PowerParameter::internal_default_instance()); ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - PythonParameter_descriptor_, &PythonParameter::default_instance()); + PythonParameter_descriptor_, PythonParameter::internal_default_instance()); ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - ReductionParameter_descriptor_, &ReductionParameter::default_instance()); + ReductionParameter_descriptor_, ReductionParameter::internal_default_instance()); ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - ReLUParameter_descriptor_, &ReLUParameter::default_instance()); + ReLUParameter_descriptor_, ReLUParameter::internal_default_instance()); ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - ReshapeParameter_descriptor_, &ReshapeParameter::default_instance()); + ReshapeParameter_descriptor_, ReshapeParameter::internal_default_instance()); ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - SigmoidParameter_descriptor_, &SigmoidParameter::default_instance()); + SigmoidParameter_descriptor_, SigmoidParameter::internal_default_instance()); ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - SliceParameter_descriptor_, &SliceParameter::default_instance()); + SliceParameter_descriptor_, SliceParameter::internal_default_instance()); ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - SoftmaxParameter_descriptor_, &SoftmaxParameter::default_instance()); + SoftmaxParameter_descriptor_, SoftmaxParameter::internal_default_instance()); ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - TanHParameter_descriptor_, &TanHParameter::default_instance()); + TanHParameter_descriptor_, TanHParameter::internal_default_instance()); ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - ThresholdParameter_descriptor_, &ThresholdParameter::default_instance()); + ThresholdParameter_descriptor_, ThresholdParameter::internal_default_instance()); ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - WindowDataParameter_descriptor_, &WindowDataParameter::default_instance()); + WindowDataParameter_descriptor_, WindowDataParameter::internal_default_instance()); ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - SPPParameter_descriptor_, &SPPParameter::default_instance()); + SPPParameter_descriptor_, SPPParameter::internal_default_instance()); ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - V1LayerParameter_descriptor_, &V1LayerParameter::default_instance()); + V1LayerParameter_descriptor_, V1LayerParameter::internal_default_instance()); ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - V0LayerParameter_descriptor_, &V0LayerParameter::default_instance()); + V0LayerParameter_descriptor_, V0LayerParameter::internal_default_instance()); ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - PReLUParameter_descriptor_, &PReLUParameter::default_instance()); + PReLUParameter_descriptor_, PReLUParameter::internal_default_instance()); ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - NormalizedBBox_descriptor_, &NormalizedBBox::default_instance()); + NormalizedBBox_descriptor_, NormalizedBBox::internal_default_instance()); } } // namespace void protobuf_ShutdownFile_caffe_2eproto() { - delete BlobShape::default_instance_; + BlobShape_default_instance_.Shutdown(); delete BlobShape_reflection_; - delete BlobProto::default_instance_; + BlobProto_default_instance_.Shutdown(); delete BlobProto_reflection_; - delete BlobProtoVector::default_instance_; + BlobProtoVector_default_instance_.Shutdown(); delete BlobProtoVector_reflection_; - delete CropParameter::default_instance_; + CropParameter_default_instance_.Shutdown(); delete CropParameter_reflection_; - delete PermuteParameter::default_instance_; + PermuteParameter_default_instance_.Shutdown(); delete PermuteParameter_reflection_; - delete NormalizeBBoxParameter::default_instance_; + NormalizeBBoxParameter_default_instance_.Shutdown(); delete NormalizeBBoxParameter_reflection_; - delete PriorBoxParameter::default_instance_; + PriorBoxParameter_default_instance_.Shutdown(); delete PriorBoxParameter_reflection_; - delete DetectionOutputParameter::default_instance_; + DetectionOutputParameter_default_instance_.Shutdown(); delete DetectionOutputParameter_reflection_; - delete Datum::default_instance_; + Datum_default_instance_.Shutdown(); delete Datum_reflection_; - delete FillerParameter::default_instance_; + FillerParameter_default_instance_.Shutdown(); delete FillerParameter_reflection_; delete FillerParameter::_default_type_; - delete NetParameter::default_instance_; + NetParameter_default_instance_.Shutdown(); delete NetParameter_reflection_; - delete SolverParameter::default_instance_; + SolverParameter_default_instance_.Shutdown(); delete SolverParameter_reflection_; delete SolverParameter::_default_regularization_type_; - delete SolverState::default_instance_; + SolverState_default_instance_.Shutdown(); delete SolverState_reflection_; - delete NetState::default_instance_; + NetState_default_instance_.Shutdown(); delete NetState_reflection_; - delete NetStateRule::default_instance_; + NetStateRule_default_instance_.Shutdown(); delete NetStateRule_reflection_; - delete ParamSpec::default_instance_; + ParamSpec_default_instance_.Shutdown(); delete ParamSpec_reflection_; - delete LayerParameter::default_instance_; + LayerParameter_default_instance_.Shutdown(); delete LayerParameter_reflection_; - delete TransformationParameter::default_instance_; + TransformationParameter_default_instance_.Shutdown(); delete TransformationParameter_reflection_; - delete LossParameter::default_instance_; + LossParameter_default_instance_.Shutdown(); delete LossParameter_reflection_; - delete AccuracyParameter::default_instance_; + AccuracyParameter_default_instance_.Shutdown(); delete AccuracyParameter_reflection_; - delete ArgMaxParameter::default_instance_; + ArgMaxParameter_default_instance_.Shutdown(); delete ArgMaxParameter_reflection_; - delete ConcatParameter::default_instance_; + ConcatParameter_default_instance_.Shutdown(); delete ConcatParameter_reflection_; - delete ContrastiveLossParameter::default_instance_; + ContrastiveLossParameter_default_instance_.Shutdown(); delete ContrastiveLossParameter_reflection_; - delete ConvolutionParameter::default_instance_; + ConvolutionParameter_default_instance_.Shutdown(); delete ConvolutionParameter_reflection_; - delete DataParameter::default_instance_; + DataParameter_default_instance_.Shutdown(); delete DataParameter_reflection_; - delete DropoutParameter::default_instance_; + DropoutParameter_default_instance_.Shutdown(); delete DropoutParameter_reflection_; - delete DummyDataParameter::default_instance_; + DummyDataParameter_default_instance_.Shutdown(); delete DummyDataParameter_reflection_; - delete EltwiseParameter::default_instance_; + EltwiseParameter_default_instance_.Shutdown(); delete EltwiseParameter_reflection_; - delete ExpParameter::default_instance_; + ExpParameter_default_instance_.Shutdown(); delete ExpParameter_reflection_; - delete FlattenParameter::default_instance_; + FlattenParameter_default_instance_.Shutdown(); delete FlattenParameter_reflection_; - delete HDF5DataParameter::default_instance_; + HDF5DataParameter_default_instance_.Shutdown(); delete HDF5DataParameter_reflection_; - delete HDF5OutputParameter::default_instance_; + HDF5OutputParameter_default_instance_.Shutdown(); delete HDF5OutputParameter_reflection_; - delete HingeLossParameter::default_instance_; + HingeLossParameter_default_instance_.Shutdown(); delete HingeLossParameter_reflection_; - delete ImageDataParameter::default_instance_; + ImageDataParameter_default_instance_.Shutdown(); delete ImageDataParameter_reflection_; - delete InfogainLossParameter::default_instance_; + InfogainLossParameter_default_instance_.Shutdown(); delete InfogainLossParameter_reflection_; - delete InnerProductParameter::default_instance_; + InnerProductParameter_default_instance_.Shutdown(); delete InnerProductParameter_reflection_; - delete LogParameter::default_instance_; + LogParameter_default_instance_.Shutdown(); delete LogParameter_reflection_; - delete LRNParameter::default_instance_; + LRNParameter_default_instance_.Shutdown(); delete LRNParameter_reflection_; - delete MemoryDataParameter::default_instance_; + MemoryDataParameter_default_instance_.Shutdown(); delete MemoryDataParameter_reflection_; - delete MVNParameter::default_instance_; + MVNParameter_default_instance_.Shutdown(); delete MVNParameter_reflection_; - delete PoolingParameter::default_instance_; + PoolingParameter_default_instance_.Shutdown(); delete PoolingParameter_reflection_; - delete PowerParameter::default_instance_; + PowerParameter_default_instance_.Shutdown(); delete PowerParameter_reflection_; - delete PythonParameter::default_instance_; + PythonParameter_default_instance_.Shutdown(); delete PythonParameter_reflection_; - delete ReductionParameter::default_instance_; + ReductionParameter_default_instance_.Shutdown(); delete ReductionParameter_reflection_; - delete ReLUParameter::default_instance_; + ReLUParameter_default_instance_.Shutdown(); delete ReLUParameter_reflection_; - delete ReshapeParameter::default_instance_; + ReshapeParameter_default_instance_.Shutdown(); delete ReshapeParameter_reflection_; - delete SigmoidParameter::default_instance_; + SigmoidParameter_default_instance_.Shutdown(); delete SigmoidParameter_reflection_; - delete SliceParameter::default_instance_; + SliceParameter_default_instance_.Shutdown(); delete SliceParameter_reflection_; - delete SoftmaxParameter::default_instance_; + SoftmaxParameter_default_instance_.Shutdown(); delete SoftmaxParameter_reflection_; - delete TanHParameter::default_instance_; + TanHParameter_default_instance_.Shutdown(); delete TanHParameter_reflection_; - delete ThresholdParameter::default_instance_; + ThresholdParameter_default_instance_.Shutdown(); delete ThresholdParameter_reflection_; - delete WindowDataParameter::default_instance_; + WindowDataParameter_default_instance_.Shutdown(); delete WindowDataParameter_reflection_; delete WindowDataParameter::_default_crop_mode_; - delete SPPParameter::default_instance_; + SPPParameter_default_instance_.Shutdown(); delete SPPParameter_reflection_; - delete V1LayerParameter::default_instance_; + V1LayerParameter_default_instance_.Shutdown(); delete V1LayerParameter_reflection_; - delete V0LayerParameter::default_instance_; + V0LayerParameter_default_instance_.Shutdown(); delete V0LayerParameter_reflection_; delete V0LayerParameter::_default_det_crop_mode_; - delete PReLUParameter::default_instance_; + PReLUParameter_default_instance_.Shutdown(); delete PReLUParameter_reflection_; - delete NormalizedBBox::default_instance_; + NormalizedBBox_default_instance_.Shutdown(); delete NormalizedBBox_reflection_; } -void protobuf_AddDesc_caffe_2eproto() { - static bool already_here = false; - if (already_here) return; - already_here = true; +void protobuf_InitDefaults_caffe_2eproto_impl() { + GOOGLE_PROTOBUF_VERIFY_VERSION; + + BlobShape_default_instance_.DefaultConstruct(); + BlobProto_default_instance_.DefaultConstruct(); + BlobProtoVector_default_instance_.DefaultConstruct(); + CropParameter_default_instance_.DefaultConstruct(); + PermuteParameter_default_instance_.DefaultConstruct(); + NormalizeBBoxParameter_default_instance_.DefaultConstruct(); + PriorBoxParameter_default_instance_.DefaultConstruct(); + DetectionOutputParameter_default_instance_.DefaultConstruct(); + ::google::protobuf::internal::GetEmptyString(); + Datum_default_instance_.DefaultConstruct(); + ::google::protobuf::internal::GetEmptyString(); + FillerParameter::_default_type_ = + new ::std::string("constant", 8); + FillerParameter_default_instance_.DefaultConstruct(); + ::google::protobuf::internal::GetEmptyString(); + NetParameter_default_instance_.DefaultConstruct(); + ::google::protobuf::internal::GetEmptyString(); + SolverParameter::_default_regularization_type_ = + new ::std::string("L2", 2); + SolverParameter_default_instance_.DefaultConstruct(); + ::google::protobuf::internal::GetEmptyString(); + SolverState_default_instance_.DefaultConstruct(); + ::google::protobuf::internal::GetEmptyString(); + NetState_default_instance_.DefaultConstruct(); + ::google::protobuf::internal::GetEmptyString(); + NetStateRule_default_instance_.DefaultConstruct(); + ::google::protobuf::internal::GetEmptyString(); + ParamSpec_default_instance_.DefaultConstruct(); + ::google::protobuf::internal::GetEmptyString(); + LayerParameter_default_instance_.DefaultConstruct(); + ::google::protobuf::internal::GetEmptyString(); + TransformationParameter_default_instance_.DefaultConstruct(); + LossParameter_default_instance_.DefaultConstruct(); + AccuracyParameter_default_instance_.DefaultConstruct(); + ArgMaxParameter_default_instance_.DefaultConstruct(); + ConcatParameter_default_instance_.DefaultConstruct(); + ContrastiveLossParameter_default_instance_.DefaultConstruct(); + ConvolutionParameter_default_instance_.DefaultConstruct(); + ::google::protobuf::internal::GetEmptyString(); + DataParameter_default_instance_.DefaultConstruct(); + DropoutParameter_default_instance_.DefaultConstruct(); + DummyDataParameter_default_instance_.DefaultConstruct(); + EltwiseParameter_default_instance_.DefaultConstruct(); + ExpParameter_default_instance_.DefaultConstruct(); + FlattenParameter_default_instance_.DefaultConstruct(); + ::google::protobuf::internal::GetEmptyString(); + HDF5DataParameter_default_instance_.DefaultConstruct(); + ::google::protobuf::internal::GetEmptyString(); + HDF5OutputParameter_default_instance_.DefaultConstruct(); + HingeLossParameter_default_instance_.DefaultConstruct(); + ::google::protobuf::internal::GetEmptyString(); + ImageDataParameter_default_instance_.DefaultConstruct(); + ::google::protobuf::internal::GetEmptyString(); + InfogainLossParameter_default_instance_.DefaultConstruct(); + InnerProductParameter_default_instance_.DefaultConstruct(); + LogParameter_default_instance_.DefaultConstruct(); + LRNParameter_default_instance_.DefaultConstruct(); + MemoryDataParameter_default_instance_.DefaultConstruct(); + MVNParameter_default_instance_.DefaultConstruct(); + PoolingParameter_default_instance_.DefaultConstruct(); + PowerParameter_default_instance_.DefaultConstruct(); + ::google::protobuf::internal::GetEmptyString(); + PythonParameter_default_instance_.DefaultConstruct(); + ReductionParameter_default_instance_.DefaultConstruct(); + ReLUParameter_default_instance_.DefaultConstruct(); + ReshapeParameter_default_instance_.DefaultConstruct(); + SigmoidParameter_default_instance_.DefaultConstruct(); + SliceParameter_default_instance_.DefaultConstruct(); + SoftmaxParameter_default_instance_.DefaultConstruct(); + TanHParameter_default_instance_.DefaultConstruct(); + ThresholdParameter_default_instance_.DefaultConstruct(); + ::google::protobuf::internal::GetEmptyString(); + WindowDataParameter::_default_crop_mode_ = + new ::std::string("warp", 4); + WindowDataParameter_default_instance_.DefaultConstruct(); + SPPParameter_default_instance_.DefaultConstruct(); + ::google::protobuf::internal::GetEmptyString(); + V1LayerParameter_default_instance_.DefaultConstruct(); + ::google::protobuf::internal::GetEmptyString(); + V0LayerParameter::_default_det_crop_mode_ = + new ::std::string("warp", 4); + V0LayerParameter_default_instance_.DefaultConstruct(); + PReLUParameter_default_instance_.DefaultConstruct(); + NormalizedBBox_default_instance_.DefaultConstruct(); + BlobShape_default_instance_.get_mutable()->InitAsDefaultInstance(); + BlobProto_default_instance_.get_mutable()->InitAsDefaultInstance(); + BlobProtoVector_default_instance_.get_mutable()->InitAsDefaultInstance(); + CropParameter_default_instance_.get_mutable()->InitAsDefaultInstance(); + PermuteParameter_default_instance_.get_mutable()->InitAsDefaultInstance(); + NormalizeBBoxParameter_default_instance_.get_mutable()->InitAsDefaultInstance(); + PriorBoxParameter_default_instance_.get_mutable()->InitAsDefaultInstance(); + DetectionOutputParameter_default_instance_.get_mutable()->InitAsDefaultInstance(); + Datum_default_instance_.get_mutable()->InitAsDefaultInstance(); + FillerParameter_default_instance_.get_mutable()->InitAsDefaultInstance(); + NetParameter_default_instance_.get_mutable()->InitAsDefaultInstance(); + SolverParameter_default_instance_.get_mutable()->InitAsDefaultInstance(); + SolverState_default_instance_.get_mutable()->InitAsDefaultInstance(); + NetState_default_instance_.get_mutable()->InitAsDefaultInstance(); + NetStateRule_default_instance_.get_mutable()->InitAsDefaultInstance(); + ParamSpec_default_instance_.get_mutable()->InitAsDefaultInstance(); + LayerParameter_default_instance_.get_mutable()->InitAsDefaultInstance(); + TransformationParameter_default_instance_.get_mutable()->InitAsDefaultInstance(); + LossParameter_default_instance_.get_mutable()->InitAsDefaultInstance(); + AccuracyParameter_default_instance_.get_mutable()->InitAsDefaultInstance(); + ArgMaxParameter_default_instance_.get_mutable()->InitAsDefaultInstance(); + ConcatParameter_default_instance_.get_mutable()->InitAsDefaultInstance(); + ContrastiveLossParameter_default_instance_.get_mutable()->InitAsDefaultInstance(); + ConvolutionParameter_default_instance_.get_mutable()->InitAsDefaultInstance(); + DataParameter_default_instance_.get_mutable()->InitAsDefaultInstance(); + DropoutParameter_default_instance_.get_mutable()->InitAsDefaultInstance(); + DummyDataParameter_default_instance_.get_mutable()->InitAsDefaultInstance(); + EltwiseParameter_default_instance_.get_mutable()->InitAsDefaultInstance(); + ExpParameter_default_instance_.get_mutable()->InitAsDefaultInstance(); + FlattenParameter_default_instance_.get_mutable()->InitAsDefaultInstance(); + HDF5DataParameter_default_instance_.get_mutable()->InitAsDefaultInstance(); + HDF5OutputParameter_default_instance_.get_mutable()->InitAsDefaultInstance(); + HingeLossParameter_default_instance_.get_mutable()->InitAsDefaultInstance(); + ImageDataParameter_default_instance_.get_mutable()->InitAsDefaultInstance(); + InfogainLossParameter_default_instance_.get_mutable()->InitAsDefaultInstance(); + InnerProductParameter_default_instance_.get_mutable()->InitAsDefaultInstance(); + LogParameter_default_instance_.get_mutable()->InitAsDefaultInstance(); + LRNParameter_default_instance_.get_mutable()->InitAsDefaultInstance(); + MemoryDataParameter_default_instance_.get_mutable()->InitAsDefaultInstance(); + MVNParameter_default_instance_.get_mutable()->InitAsDefaultInstance(); + PoolingParameter_default_instance_.get_mutable()->InitAsDefaultInstance(); + PowerParameter_default_instance_.get_mutable()->InitAsDefaultInstance(); + PythonParameter_default_instance_.get_mutable()->InitAsDefaultInstance(); + ReductionParameter_default_instance_.get_mutable()->InitAsDefaultInstance(); + ReLUParameter_default_instance_.get_mutable()->InitAsDefaultInstance(); + ReshapeParameter_default_instance_.get_mutable()->InitAsDefaultInstance(); + SigmoidParameter_default_instance_.get_mutable()->InitAsDefaultInstance(); + SliceParameter_default_instance_.get_mutable()->InitAsDefaultInstance(); + SoftmaxParameter_default_instance_.get_mutable()->InitAsDefaultInstance(); + TanHParameter_default_instance_.get_mutable()->InitAsDefaultInstance(); + ThresholdParameter_default_instance_.get_mutable()->InitAsDefaultInstance(); + WindowDataParameter_default_instance_.get_mutable()->InitAsDefaultInstance(); + SPPParameter_default_instance_.get_mutable()->InitAsDefaultInstance(); + V1LayerParameter_default_instance_.get_mutable()->InitAsDefaultInstance(); + V0LayerParameter_default_instance_.get_mutable()->InitAsDefaultInstance(); + PReLUParameter_default_instance_.get_mutable()->InitAsDefaultInstance(); + NormalizedBBox_default_instance_.get_mutable()->InitAsDefaultInstance(); +} + +GOOGLE_PROTOBUF_DECLARE_ONCE(protobuf_InitDefaults_caffe_2eproto_once_); +void protobuf_InitDefaults_caffe_2eproto() { + ::google::protobuf::GoogleOnceInit(&protobuf_InitDefaults_caffe_2eproto_once_, + &protobuf_InitDefaults_caffe_2eproto_impl); +} +void protobuf_AddDesc_caffe_2eproto_impl() { GOOGLE_PROTOBUF_VERIFY_VERSION; + protobuf_InitDefaults_caffe_2eproto(); ::google::protobuf::DescriptorPool::InternalAddGeneratedFile( "\n\013caffe.proto\022\005caffe\"\034\n\tBlobShape\022\017\n\003dim" "\030\001 \003(\003B\002\020\001\"\232\001\n\tBlobProto\022\037\n\005shape\030\007 \001(\0132" @@ -2065,131 +2160,14 @@ void protobuf_AddDesc_caffe_2eproto() { "EST\020\001", 14445); ::google::protobuf::MessageFactory::InternalRegisterGeneratedFile( "caffe.proto", &protobuf_RegisterTypes); - BlobShape::default_instance_ = new BlobShape(); - BlobProto::default_instance_ = new BlobProto(); - BlobProtoVector::default_instance_ = new BlobProtoVector(); - CropParameter::default_instance_ = new CropParameter(); - PermuteParameter::default_instance_ = new PermuteParameter(); - NormalizeBBoxParameter::default_instance_ = new NormalizeBBoxParameter(); - PriorBoxParameter::default_instance_ = new PriorBoxParameter(); - DetectionOutputParameter::default_instance_ = new DetectionOutputParameter(); - Datum::default_instance_ = new Datum(); - FillerParameter::_default_type_ = - new ::std::string("constant", 8); - FillerParameter::default_instance_ = new FillerParameter(); - NetParameter::default_instance_ = new NetParameter(); - SolverParameter::_default_regularization_type_ = - new ::std::string("L2", 2); - SolverParameter::default_instance_ = new SolverParameter(); - SolverState::default_instance_ = new SolverState(); - NetState::default_instance_ = new NetState(); - NetStateRule::default_instance_ = new NetStateRule(); - ParamSpec::default_instance_ = new ParamSpec(); - LayerParameter::default_instance_ = new LayerParameter(); - TransformationParameter::default_instance_ = new TransformationParameter(); - LossParameter::default_instance_ = new LossParameter(); - AccuracyParameter::default_instance_ = new AccuracyParameter(); - ArgMaxParameter::default_instance_ = new ArgMaxParameter(); - ConcatParameter::default_instance_ = new ConcatParameter(); - ContrastiveLossParameter::default_instance_ = new ContrastiveLossParameter(); - ConvolutionParameter::default_instance_ = new ConvolutionParameter(); - DataParameter::default_instance_ = new DataParameter(); - DropoutParameter::default_instance_ = new DropoutParameter(); - DummyDataParameter::default_instance_ = new DummyDataParameter(); - EltwiseParameter::default_instance_ = new EltwiseParameter(); - ExpParameter::default_instance_ = new ExpParameter(); - FlattenParameter::default_instance_ = new FlattenParameter(); - HDF5DataParameter::default_instance_ = new HDF5DataParameter(); - HDF5OutputParameter::default_instance_ = new HDF5OutputParameter(); - HingeLossParameter::default_instance_ = new HingeLossParameter(); - ImageDataParameter::default_instance_ = new ImageDataParameter(); - InfogainLossParameter::default_instance_ = new InfogainLossParameter(); - InnerProductParameter::default_instance_ = new InnerProductParameter(); - LogParameter::default_instance_ = new LogParameter(); - LRNParameter::default_instance_ = new LRNParameter(); - MemoryDataParameter::default_instance_ = new MemoryDataParameter(); - MVNParameter::default_instance_ = new MVNParameter(); - PoolingParameter::default_instance_ = new PoolingParameter(); - PowerParameter::default_instance_ = new PowerParameter(); - PythonParameter::default_instance_ = new PythonParameter(); - ReductionParameter::default_instance_ = new ReductionParameter(); - ReLUParameter::default_instance_ = new ReLUParameter(); - ReshapeParameter::default_instance_ = new ReshapeParameter(); - SigmoidParameter::default_instance_ = new SigmoidParameter(); - SliceParameter::default_instance_ = new SliceParameter(); - SoftmaxParameter::default_instance_ = new SoftmaxParameter(); - TanHParameter::default_instance_ = new TanHParameter(); - ThresholdParameter::default_instance_ = new ThresholdParameter(); - WindowDataParameter::_default_crop_mode_ = - new ::std::string("warp", 4); - WindowDataParameter::default_instance_ = new WindowDataParameter(); - SPPParameter::default_instance_ = new SPPParameter(); - V1LayerParameter::default_instance_ = new V1LayerParameter(); - V0LayerParameter::_default_det_crop_mode_ = - new ::std::string("warp", 4); - V0LayerParameter::default_instance_ = new V0LayerParameter(); - PReLUParameter::default_instance_ = new PReLUParameter(); - NormalizedBBox::default_instance_ = new NormalizedBBox(); - BlobShape::default_instance_->InitAsDefaultInstance(); - BlobProto::default_instance_->InitAsDefaultInstance(); - BlobProtoVector::default_instance_->InitAsDefaultInstance(); - CropParameter::default_instance_->InitAsDefaultInstance(); - PermuteParameter::default_instance_->InitAsDefaultInstance(); - NormalizeBBoxParameter::default_instance_->InitAsDefaultInstance(); - PriorBoxParameter::default_instance_->InitAsDefaultInstance(); - DetectionOutputParameter::default_instance_->InitAsDefaultInstance(); - Datum::default_instance_->InitAsDefaultInstance(); - FillerParameter::default_instance_->InitAsDefaultInstance(); - NetParameter::default_instance_->InitAsDefaultInstance(); - SolverParameter::default_instance_->InitAsDefaultInstance(); - SolverState::default_instance_->InitAsDefaultInstance(); - NetState::default_instance_->InitAsDefaultInstance(); - NetStateRule::default_instance_->InitAsDefaultInstance(); - ParamSpec::default_instance_->InitAsDefaultInstance(); - LayerParameter::default_instance_->InitAsDefaultInstance(); - TransformationParameter::default_instance_->InitAsDefaultInstance(); - LossParameter::default_instance_->InitAsDefaultInstance(); - AccuracyParameter::default_instance_->InitAsDefaultInstance(); - ArgMaxParameter::default_instance_->InitAsDefaultInstance(); - ConcatParameter::default_instance_->InitAsDefaultInstance(); - ContrastiveLossParameter::default_instance_->InitAsDefaultInstance(); - ConvolutionParameter::default_instance_->InitAsDefaultInstance(); - DataParameter::default_instance_->InitAsDefaultInstance(); - DropoutParameter::default_instance_->InitAsDefaultInstance(); - DummyDataParameter::default_instance_->InitAsDefaultInstance(); - EltwiseParameter::default_instance_->InitAsDefaultInstance(); - ExpParameter::default_instance_->InitAsDefaultInstance(); - FlattenParameter::default_instance_->InitAsDefaultInstance(); - HDF5DataParameter::default_instance_->InitAsDefaultInstance(); - HDF5OutputParameter::default_instance_->InitAsDefaultInstance(); - HingeLossParameter::default_instance_->InitAsDefaultInstance(); - ImageDataParameter::default_instance_->InitAsDefaultInstance(); - InfogainLossParameter::default_instance_->InitAsDefaultInstance(); - InnerProductParameter::default_instance_->InitAsDefaultInstance(); - LogParameter::default_instance_->InitAsDefaultInstance(); - LRNParameter::default_instance_->InitAsDefaultInstance(); - MemoryDataParameter::default_instance_->InitAsDefaultInstance(); - MVNParameter::default_instance_->InitAsDefaultInstance(); - PoolingParameter::default_instance_->InitAsDefaultInstance(); - PowerParameter::default_instance_->InitAsDefaultInstance(); - PythonParameter::default_instance_->InitAsDefaultInstance(); - ReductionParameter::default_instance_->InitAsDefaultInstance(); - ReLUParameter::default_instance_->InitAsDefaultInstance(); - ReshapeParameter::default_instance_->InitAsDefaultInstance(); - SigmoidParameter::default_instance_->InitAsDefaultInstance(); - SliceParameter::default_instance_->InitAsDefaultInstance(); - SoftmaxParameter::default_instance_->InitAsDefaultInstance(); - TanHParameter::default_instance_->InitAsDefaultInstance(); - ThresholdParameter::default_instance_->InitAsDefaultInstance(); - WindowDataParameter::default_instance_->InitAsDefaultInstance(); - SPPParameter::default_instance_->InitAsDefaultInstance(); - V1LayerParameter::default_instance_->InitAsDefaultInstance(); - V0LayerParameter::default_instance_->InitAsDefaultInstance(); - PReLUParameter::default_instance_->InitAsDefaultInstance(); - NormalizedBBox::default_instance_->InitAsDefaultInstance(); ::google::protobuf::internal::OnShutdown(&protobuf_ShutdownFile_caffe_2eproto); } +GOOGLE_PROTOBUF_DECLARE_ONCE(protobuf_AddDesc_caffe_2eproto_once_); +void protobuf_AddDesc_caffe_2eproto() { + ::google::protobuf::GoogleOnceInit(&protobuf_AddDesc_caffe_2eproto_once_, + &protobuf_AddDesc_caffe_2eproto_impl); +} // Force AddDescriptors() to be called at static initialization time. struct StaticDescriptorInitializer_caffe_2eproto { StaticDescriptorInitializer_caffe_2eproto() { @@ -2201,7 +2179,7 @@ const ::google::protobuf::EnumDescriptor* Phase_descriptor() { return Phase_descriptor_; } bool Phase_IsValid(int value) { - switch(value) { + switch (value) { case 0: case 1: return true; @@ -2211,38 +2189,50 @@ bool Phase_IsValid(int value) { } +namespace { + +static void MergeFromFail(int line) GOOGLE_ATTRIBUTE_COLD GOOGLE_ATTRIBUTE_NORETURN; +static void MergeFromFail(int line) { + ::google::protobuf::internal::MergeFromFail(__FILE__, line); +} + +} // namespace + + // =================================================================== -#ifndef _MSC_VER +#if !defined(_MSC_VER) || _MSC_VER >= 1900 const int BlobShape::kDimFieldNumber; -#endif // !_MSC_VER +#endif // !defined(_MSC_VER) || _MSC_VER >= 1900 BlobShape::BlobShape() - : ::google::protobuf::Message() { + : ::google::protobuf::Message(), _internal_metadata_(NULL) { + if (this != internal_default_instance()) protobuf_InitDefaults_caffe_2eproto(); SharedCtor(); + // @@protoc_insertion_point(constructor:caffe.BlobShape) } void BlobShape::InitAsDefaultInstance() { } BlobShape::BlobShape(const BlobShape& from) - : ::google::protobuf::Message() { + : ::google::protobuf::Message(), + _internal_metadata_(NULL) { SharedCtor(); - MergeFrom(from); + UnsafeMergeFrom(from); + // @@protoc_insertion_point(copy_constructor:caffe.BlobShape) } void BlobShape::SharedCtor() { _cached_size_ = 0; - ::memset(_has_bits_, 0, sizeof(_has_bits_)); } BlobShape::~BlobShape() { + // @@protoc_insertion_point(destructor:caffe.BlobShape) SharedDtor(); } void BlobShape::SharedDtor() { - if (this != default_instance_) { - } } void BlobShape::SetCachedSize(int size) const { @@ -2256,53 +2246,62 @@ const ::google::protobuf::Descriptor* BlobShape::descriptor() { } const BlobShape& BlobShape::default_instance() { - if (default_instance_ == NULL) protobuf_AddDesc_caffe_2eproto(); - return *default_instance_; + protobuf_InitDefaults_caffe_2eproto(); + return *internal_default_instance(); } -BlobShape* BlobShape::default_instance_ = NULL; +::google::protobuf::internal::ExplicitlyConstructed BlobShape_default_instance_; -BlobShape* BlobShape::New() const { - return new BlobShape; +BlobShape* BlobShape::New(::google::protobuf::Arena* arena) const { + BlobShape* n = new BlobShape; + if (arena != NULL) { + arena->Own(n); + } + return n; } void BlobShape::Clear() { +// @@protoc_insertion_point(message_clear_start:caffe.BlobShape) dim_.Clear(); - ::memset(_has_bits_, 0, sizeof(_has_bits_)); - mutable_unknown_fields()->Clear(); + _has_bits_.Clear(); + if (_internal_metadata_.have_unknown_fields()) { + mutable_unknown_fields()->Clear(); + } } bool BlobShape::MergePartialFromCodedStream( ::google::protobuf::io::CodedInputStream* input) { -#define DO_(EXPRESSION) if (!(EXPRESSION)) return false +#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure ::google::protobuf::uint32 tag; - while ((tag = input->ReadTag()) != 0) { + // @@protoc_insertion_point(parse_start:caffe.BlobShape) + for (;;) { + ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127); + tag = p.first; + if (!p.second) goto handle_unusual; switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { // repeated int64 dim = 1 [packed = true]; case 1: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) { + if (tag == 10) { DO_((::google::protobuf::internal::WireFormatLite::ReadPackedPrimitive< ::google::protobuf::int64, ::google::protobuf::internal::WireFormatLite::TYPE_INT64>( input, this->mutable_dim()))); - } else if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) - == ::google::protobuf::internal::WireFormatLite:: - WIRETYPE_VARINT) { + } else if (tag == 8) { DO_((::google::protobuf::internal::WireFormatLite::ReadRepeatedPrimitiveNoInline< ::google::protobuf::int64, ::google::protobuf::internal::WireFormatLite::TYPE_INT64>( 1, 10, input, this->mutable_dim()))); } else { - goto handle_uninterpreted; + goto handle_unusual; } - if (input->ExpectAtEnd()) return true; + if (input->ExpectAtEnd()) goto success; break; } default: { - handle_uninterpreted: - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == + handle_unusual: + if (tag == 0 || + ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) { - return true; + goto success; } DO_(::google::protobuf::internal::WireFormat::SkipField( input, tag, mutable_unknown_fields())); @@ -2310,12 +2309,18 @@ bool BlobShape::MergePartialFromCodedStream( } } } +success: + // @@protoc_insertion_point(parse_success:caffe.BlobShape) return true; +failure: + // @@protoc_insertion_point(parse_failure:caffe.BlobShape) + return false; #undef DO_ } void BlobShape::SerializeWithCachedSizes( ::google::protobuf::io::CodedOutputStream* output) const { + // @@protoc_insertion_point(serialize_start:caffe.BlobShape) // repeated int64 dim = 1 [packed = true]; if (this->dim_size() > 0) { ::google::protobuf::internal::WireFormatLite::WriteTag(1, ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED, output); @@ -2326,14 +2331,17 @@ void BlobShape::SerializeWithCachedSizes( this->dim(i), output); } - if (!unknown_fields().empty()) { + if (_internal_metadata_.have_unknown_fields()) { ::google::protobuf::internal::WireFormat::SerializeUnknownFields( unknown_fields(), output); } + // @@protoc_insertion_point(serialize_end:caffe.BlobShape) } -::google::protobuf::uint8* BlobShape::SerializeWithCachedSizesToArray( - ::google::protobuf::uint8* target) const { +::google::protobuf::uint8* BlobShape::InternalSerializeWithCachedSizesToArray( + bool deterministic, ::google::protobuf::uint8* target) const { + (void)deterministic; // Unused + // @@protoc_insertion_point(serialize_to_array_start:caffe.BlobShape) // repeated int64 dim = 1 [packed = true]; if (this->dim_size() > 0) { target = ::google::protobuf::internal::WireFormatLite::WriteTagToArray( @@ -2348,20 +2356,23 @@ void BlobShape::SerializeWithCachedSizes( WriteInt64NoTagToArray(this->dim(i), target); } - if (!unknown_fields().empty()) { + if (_internal_metadata_.have_unknown_fields()) { target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray( unknown_fields(), target); } + // @@protoc_insertion_point(serialize_to_array_end:caffe.BlobShape) return target; } -int BlobShape::ByteSize() const { - int total_size = 0; +size_t BlobShape::ByteSizeLong() const { +// @@protoc_insertion_point(message_byte_size_start:caffe.BlobShape) + size_t total_size = 0; // repeated int64 dim = 1 [packed = true]; { - int data_size = 0; - for (int i = 0; i < this->dim_size(); i++) { + size_t data_size = 0; + unsigned int count = this->dim_size(); + for (unsigned int i = 0; i < count; i++) { data_size += ::google::protobuf::internal::WireFormatLite:: Int64Size(this->dim(i)); } @@ -2369,51 +2380,70 @@ int BlobShape::ByteSize() const { total_size += 1 + ::google::protobuf::internal::WireFormatLite::Int32Size(data_size); } + int cached_size = ::google::protobuf::internal::ToCachedSize(data_size); GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); - _dim_cached_byte_size_ = data_size; + _dim_cached_byte_size_ = cached_size; GOOGLE_SAFE_CONCURRENT_WRITES_END(); total_size += data_size; } - if (!unknown_fields().empty()) { + if (_internal_metadata_.have_unknown_fields()) { total_size += ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( unknown_fields()); } + int cached_size = ::google::protobuf::internal::ToCachedSize(total_size); GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); - _cached_size_ = total_size; + _cached_size_ = cached_size; GOOGLE_SAFE_CONCURRENT_WRITES_END(); return total_size; } void BlobShape::MergeFrom(const ::google::protobuf::Message& from) { - GOOGLE_CHECK_NE(&from, this); +// @@protoc_insertion_point(generalized_merge_from_start:caffe.BlobShape) + if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__); const BlobShape* source = - ::google::protobuf::internal::dynamic_cast_if_available( - &from); + ::google::protobuf::internal::DynamicCastToGenerated( + &from); if (source == NULL) { + // @@protoc_insertion_point(generalized_merge_from_cast_fail:caffe.BlobShape) ::google::protobuf::internal::ReflectionOps::Merge(from, this); } else { - MergeFrom(*source); + // @@protoc_insertion_point(generalized_merge_from_cast_success:caffe.BlobShape) + UnsafeMergeFrom(*source); } } void BlobShape::MergeFrom(const BlobShape& from) { - GOOGLE_CHECK_NE(&from, this); - dim_.MergeFrom(from.dim_); - mutable_unknown_fields()->MergeFrom(from.unknown_fields()); +// @@protoc_insertion_point(class_specific_merge_from_start:caffe.BlobShape) + if (GOOGLE_PREDICT_TRUE(&from != this)) { + UnsafeMergeFrom(from); + } else { + MergeFromFail(__LINE__); + } +} + +void BlobShape::UnsafeMergeFrom(const BlobShape& from) { + GOOGLE_DCHECK(&from != this); + dim_.UnsafeMergeFrom(from.dim_); + if (from._internal_metadata_.have_unknown_fields()) { + ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata( + from.unknown_fields(), &_internal_metadata_); + } } void BlobShape::CopyFrom(const ::google::protobuf::Message& from) { +// @@protoc_insertion_point(generalized_copy_from_start:caffe.BlobShape) if (&from == this) return; Clear(); MergeFrom(from); } void BlobShape::CopyFrom(const BlobShape& from) { +// @@protoc_insertion_point(class_specific_copy_from_start:caffe.BlobShape) if (&from == this) return; Clear(); - MergeFrom(from); + UnsafeMergeFrom(from); } bool BlobShape::IsInitialized() const { @@ -2422,12 +2452,14 @@ bool BlobShape::IsInitialized() const { } void BlobShape::Swap(BlobShape* other) { - if (other != this) { - dim_.Swap(&other->dim_); - std::swap(_has_bits_[0], other->_has_bits_[0]); - _unknown_fields_.Swap(&other->_unknown_fields_); - std::swap(_cached_size_, other->_cached_size_); - } + if (other == this) return; + InternalSwap(other); +} +void BlobShape::InternalSwap(BlobShape* other) { + dim_.UnsafeArenaSwap(&other->dim_); + std::swap(_has_bits_[0], other->_has_bits_[0]); + _internal_metadata_.Swap(&other->_internal_metadata_); + std::swap(_cached_size_, other->_cached_size_); } ::google::protobuf::Metadata BlobShape::GetMetadata() const { @@ -2438,10 +2470,47 @@ void BlobShape::Swap(BlobShape* other) { return metadata; } +#if PROTOBUF_INLINE_NOT_IN_HEADERS +// BlobShape + +// repeated int64 dim = 1 [packed = true]; +int BlobShape::dim_size() const { + return dim_.size(); +} +void BlobShape::clear_dim() { + dim_.Clear(); +} +::google::protobuf::int64 BlobShape::dim(int index) const { + // @@protoc_insertion_point(field_get:caffe.BlobShape.dim) + return dim_.Get(index); +} +void BlobShape::set_dim(int index, ::google::protobuf::int64 value) { + dim_.Set(index, value); + // @@protoc_insertion_point(field_set:caffe.BlobShape.dim) +} +void BlobShape::add_dim(::google::protobuf::int64 value) { + dim_.Add(value); + // @@protoc_insertion_point(field_add:caffe.BlobShape.dim) +} +const ::google::protobuf::RepeatedField< ::google::protobuf::int64 >& +BlobShape::dim() const { + // @@protoc_insertion_point(field_list:caffe.BlobShape.dim) + return dim_; +} +::google::protobuf::RepeatedField< ::google::protobuf::int64 >* +BlobShape::mutable_dim() { + // @@protoc_insertion_point(field_mutable_list:caffe.BlobShape.dim) + return &dim_; +} + +inline const BlobShape* BlobShape::internal_default_instance() { + return &BlobShape_default_instance_.get(); +} +#endif // PROTOBUF_INLINE_NOT_IN_HEADERS // =================================================================== -#ifndef _MSC_VER +#if !defined(_MSC_VER) || _MSC_VER >= 1900 const int BlobProto::kShapeFieldNumber; const int BlobProto::kDataFieldNumber; const int BlobProto::kDiffFieldNumber; @@ -2449,39 +2518,42 @@ const int BlobProto::kNumFieldNumber; const int BlobProto::kChannelsFieldNumber; const int BlobProto::kHeightFieldNumber; const int BlobProto::kWidthFieldNumber; -#endif // !_MSC_VER +#endif // !defined(_MSC_VER) || _MSC_VER >= 1900 BlobProto::BlobProto() - : ::google::protobuf::Message() { + : ::google::protobuf::Message(), _internal_metadata_(NULL) { + if (this != internal_default_instance()) protobuf_InitDefaults_caffe_2eproto(); SharedCtor(); + // @@protoc_insertion_point(constructor:caffe.BlobProto) } void BlobProto::InitAsDefaultInstance() { - shape_ = const_cast< ::caffe::BlobShape*>(&::caffe::BlobShape::default_instance()); + shape_ = const_cast< ::caffe::BlobShape*>( + ::caffe::BlobShape::internal_default_instance()); } BlobProto::BlobProto(const BlobProto& from) - : ::google::protobuf::Message() { + : ::google::protobuf::Message(), + _internal_metadata_(NULL) { SharedCtor(); - MergeFrom(from); + UnsafeMergeFrom(from); + // @@protoc_insertion_point(copy_constructor:caffe.BlobProto) } void BlobProto::SharedCtor() { _cached_size_ = 0; shape_ = NULL; - num_ = 0; - channels_ = 0; - height_ = 0; - width_ = 0; - ::memset(_has_bits_, 0, sizeof(_has_bits_)); + ::memset(&num_, 0, reinterpret_cast(&width_) - + reinterpret_cast(&num_) + sizeof(width_)); } BlobProto::~BlobProto() { + // @@protoc_insertion_point(destructor:caffe.BlobProto) SharedDtor(); } void BlobProto::SharedDtor() { - if (this != default_instance_) { + if (this != &BlobProto_default_instance_.get()) { delete shape_; } } @@ -2497,48 +2569,75 @@ const ::google::protobuf::Descriptor* BlobProto::descriptor() { } const BlobProto& BlobProto::default_instance() { - if (default_instance_ == NULL) protobuf_AddDesc_caffe_2eproto(); - return *default_instance_; + protobuf_InitDefaults_caffe_2eproto(); + return *internal_default_instance(); } -BlobProto* BlobProto::default_instance_ = NULL; +::google::protobuf::internal::ExplicitlyConstructed BlobProto_default_instance_; -BlobProto* BlobProto::New() const { - return new BlobProto; +BlobProto* BlobProto::New(::google::protobuf::Arena* arena) const { + BlobProto* n = new BlobProto; + if (arena != NULL) { + arena->Own(n); + } + return n; } void BlobProto::Clear() { - if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) { +// @@protoc_insertion_point(message_clear_start:caffe.BlobProto) +#if defined(__clang__) +#define ZR_HELPER_(f) \ + _Pragma("clang diagnostic push") \ + _Pragma("clang diagnostic ignored \"-Winvalid-offsetof\"") \ + __builtin_offsetof(BlobProto, f) \ + _Pragma("clang diagnostic pop") +#else +#define ZR_HELPER_(f) reinterpret_cast(\ + &reinterpret_cast(16)->f) +#endif + +#define ZR_(first, last) do {\ + ::memset(&(first), 0,\ + ZR_HELPER_(last) - ZR_HELPER_(first) + sizeof(last));\ +} while (0) + + if (_has_bits_[0 / 32] & 121u) { + ZR_(num_, width_); if (has_shape()) { if (shape_ != NULL) shape_->::caffe::BlobShape::Clear(); } - num_ = 0; - channels_ = 0; - height_ = 0; - width_ = 0; } + +#undef ZR_HELPER_ +#undef ZR_ + data_.Clear(); diff_.Clear(); - ::memset(_has_bits_, 0, sizeof(_has_bits_)); - mutable_unknown_fields()->Clear(); + _has_bits_.Clear(); + if (_internal_metadata_.have_unknown_fields()) { + mutable_unknown_fields()->Clear(); + } } bool BlobProto::MergePartialFromCodedStream( ::google::protobuf::io::CodedInputStream* input) { -#define DO_(EXPRESSION) if (!(EXPRESSION)) return false +#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure ::google::protobuf::uint32 tag; - while ((tag = input->ReadTag()) != 0) { + // @@protoc_insertion_point(parse_start:caffe.BlobProto) + for (;;) { + ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127); + tag = p.first; + if (!p.second) goto handle_unusual; switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { // optional int32 num = 1 [default = 0]; case 1: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) { + if (tag == 8) { + set_has_num(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>( input, &num_))); - set_has_num(); } else { - goto handle_uninterpreted; + goto handle_unusual; } if (input->ExpectTag(16)) goto parse_channels; break; @@ -2546,15 +2645,14 @@ bool BlobProto::MergePartialFromCodedStream( // optional int32 channels = 2 [default = 0]; case 2: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) { + if (tag == 16) { parse_channels: + set_has_channels(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>( input, &channels_))); - set_has_channels(); } else { - goto handle_uninterpreted; + goto handle_unusual; } if (input->ExpectTag(24)) goto parse_height; break; @@ -2562,15 +2660,14 @@ bool BlobProto::MergePartialFromCodedStream( // optional int32 height = 3 [default = 0]; case 3: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) { + if (tag == 24) { parse_height: + set_has_height(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>( input, &height_))); - set_has_height(); } else { - goto handle_uninterpreted; + goto handle_unusual; } if (input->ExpectTag(32)) goto parse_width; break; @@ -2578,15 +2675,14 @@ bool BlobProto::MergePartialFromCodedStream( // optional int32 width = 4 [default = 0]; case 4: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) { + if (tag == 32) { parse_width: + set_has_width(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>( input, &width_))); - set_has_width(); } else { - goto handle_uninterpreted; + goto handle_unusual; } if (input->ExpectTag(42)) goto parse_data; break; @@ -2594,20 +2690,17 @@ bool BlobProto::MergePartialFromCodedStream( // repeated float data = 5 [packed = true]; case 5: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) { + if (tag == 42) { parse_data: DO_((::google::protobuf::internal::WireFormatLite::ReadPackedPrimitive< float, ::google::protobuf::internal::WireFormatLite::TYPE_FLOAT>( input, this->mutable_data()))); - } else if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) - == ::google::protobuf::internal::WireFormatLite:: - WIRETYPE_FIXED32) { + } else if (tag == 45) { DO_((::google::protobuf::internal::WireFormatLite::ReadRepeatedPrimitiveNoInline< float, ::google::protobuf::internal::WireFormatLite::TYPE_FLOAT>( 1, 42, input, this->mutable_data()))); } else { - goto handle_uninterpreted; + goto handle_unusual; } if (input->ExpectTag(50)) goto parse_diff; break; @@ -2615,20 +2708,17 @@ bool BlobProto::MergePartialFromCodedStream( // repeated float diff = 6 [packed = true]; case 6: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) { + if (tag == 50) { parse_diff: DO_((::google::protobuf::internal::WireFormatLite::ReadPackedPrimitive< float, ::google::protobuf::internal::WireFormatLite::TYPE_FLOAT>( input, this->mutable_diff()))); - } else if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) - == ::google::protobuf::internal::WireFormatLite:: - WIRETYPE_FIXED32) { + } else if (tag == 53) { DO_((::google::protobuf::internal::WireFormatLite::ReadRepeatedPrimitiveNoInline< float, ::google::protobuf::internal::WireFormatLite::TYPE_FLOAT>( 1, 50, input, this->mutable_diff()))); } else { - goto handle_uninterpreted; + goto handle_unusual; } if (input->ExpectTag(58)) goto parse_shape; break; @@ -2636,23 +2726,23 @@ bool BlobProto::MergePartialFromCodedStream( // optional .caffe.BlobShape shape = 7; case 7: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) { + if (tag == 58) { parse_shape: DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual( input, mutable_shape())); } else { - goto handle_uninterpreted; + goto handle_unusual; } - if (input->ExpectAtEnd()) return true; + if (input->ExpectAtEnd()) goto success; break; } default: { - handle_uninterpreted: - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == + handle_unusual: + if (tag == 0 || + ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) { - return true; + goto success; } DO_(::google::protobuf::internal::WireFormat::SkipField( input, tag, mutable_unknown_fields())); @@ -2660,12 +2750,18 @@ bool BlobProto::MergePartialFromCodedStream( } } } +success: + // @@protoc_insertion_point(parse_success:caffe.BlobProto) return true; +failure: + // @@protoc_insertion_point(parse_failure:caffe.BlobProto) + return false; #undef DO_ } void BlobProto::SerializeWithCachedSizes( ::google::protobuf::io::CodedOutputStream* output) const { + // @@protoc_insertion_point(serialize_start:caffe.BlobProto) // optional int32 num = 1 [default = 0]; if (has_num()) { ::google::protobuf::internal::WireFormatLite::WriteInt32(1, this->num(), output); @@ -2709,17 +2805,20 @@ void BlobProto::SerializeWithCachedSizes( // optional .caffe.BlobShape shape = 7; if (has_shape()) { ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( - 7, this->shape(), output); + 7, *this->shape_, output); } - if (!unknown_fields().empty()) { + if (_internal_metadata_.have_unknown_fields()) { ::google::protobuf::internal::WireFormat::SerializeUnknownFields( unknown_fields(), output); } + // @@protoc_insertion_point(serialize_end:caffe.BlobProto) } -::google::protobuf::uint8* BlobProto::SerializeWithCachedSizesToArray( - ::google::protobuf::uint8* target) const { +::google::protobuf::uint8* BlobProto::InternalSerializeWithCachedSizesToArray( + bool deterministic, ::google::protobuf::uint8* target) const { + (void)deterministic; // Unused + // @@protoc_insertion_point(serialize_to_array_start:caffe.BlobProto) // optional int32 num = 1 [default = 0]; if (has_num()) { target = ::google::protobuf::internal::WireFormatLite::WriteInt32ToArray(1, this->num(), target); @@ -2771,26 +2870,28 @@ void BlobProto::SerializeWithCachedSizes( // optional .caffe.BlobShape shape = 7; if (has_shape()) { target = ::google::protobuf::internal::WireFormatLite:: - WriteMessageNoVirtualToArray( - 7, this->shape(), target); + InternalWriteMessageNoVirtualToArray( + 7, *this->shape_, false, target); } - if (!unknown_fields().empty()) { + if (_internal_metadata_.have_unknown_fields()) { target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray( unknown_fields(), target); } + // @@protoc_insertion_point(serialize_to_array_end:caffe.BlobProto) return target; } -int BlobProto::ByteSize() const { - int total_size = 0; +size_t BlobProto::ByteSizeLong() const { +// @@protoc_insertion_point(message_byte_size_start:caffe.BlobProto) + size_t total_size = 0; - if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) { + if (_has_bits_[0 / 32] & 121u) { // optional .caffe.BlobShape shape = 7; if (has_shape()) { total_size += 1 + ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( - this->shape()); + *this->shape_); } // optional int32 num = 1 [default = 0]; @@ -2824,59 +2925,76 @@ int BlobProto::ByteSize() const { } // repeated float data = 5 [packed = true]; { - int data_size = 0; - data_size = 4 * this->data_size(); + size_t data_size = 0; + unsigned int count = this->data_size(); + data_size = 4UL * count; if (data_size > 0) { total_size += 1 + ::google::protobuf::internal::WireFormatLite::Int32Size(data_size); } + int cached_size = ::google::protobuf::internal::ToCachedSize(data_size); GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); - _data_cached_byte_size_ = data_size; + _data_cached_byte_size_ = cached_size; GOOGLE_SAFE_CONCURRENT_WRITES_END(); total_size += data_size; } // repeated float diff = 6 [packed = true]; { - int data_size = 0; - data_size = 4 * this->diff_size(); + size_t data_size = 0; + unsigned int count = this->diff_size(); + data_size = 4UL * count; if (data_size > 0) { total_size += 1 + ::google::protobuf::internal::WireFormatLite::Int32Size(data_size); } + int cached_size = ::google::protobuf::internal::ToCachedSize(data_size); GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); - _diff_cached_byte_size_ = data_size; + _diff_cached_byte_size_ = cached_size; GOOGLE_SAFE_CONCURRENT_WRITES_END(); total_size += data_size; } - if (!unknown_fields().empty()) { + if (_internal_metadata_.have_unknown_fields()) { total_size += ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( unknown_fields()); } + int cached_size = ::google::protobuf::internal::ToCachedSize(total_size); GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); - _cached_size_ = total_size; + _cached_size_ = cached_size; GOOGLE_SAFE_CONCURRENT_WRITES_END(); return total_size; } void BlobProto::MergeFrom(const ::google::protobuf::Message& from) { - GOOGLE_CHECK_NE(&from, this); +// @@protoc_insertion_point(generalized_merge_from_start:caffe.BlobProto) + if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__); const BlobProto* source = - ::google::protobuf::internal::dynamic_cast_if_available( - &from); + ::google::protobuf::internal::DynamicCastToGenerated( + &from); if (source == NULL) { + // @@protoc_insertion_point(generalized_merge_from_cast_fail:caffe.BlobProto) ::google::protobuf::internal::ReflectionOps::Merge(from, this); } else { - MergeFrom(*source); + // @@protoc_insertion_point(generalized_merge_from_cast_success:caffe.BlobProto) + UnsafeMergeFrom(*source); } } void BlobProto::MergeFrom(const BlobProto& from) { - GOOGLE_CHECK_NE(&from, this); - data_.MergeFrom(from.data_); - diff_.MergeFrom(from.diff_); +// @@protoc_insertion_point(class_specific_merge_from_start:caffe.BlobProto) + if (GOOGLE_PREDICT_TRUE(&from != this)) { + UnsafeMergeFrom(from); + } else { + MergeFromFail(__LINE__); + } +} + +void BlobProto::UnsafeMergeFrom(const BlobProto& from) { + GOOGLE_DCHECK(&from != this); + data_.UnsafeMergeFrom(from.data_); + diff_.UnsafeMergeFrom(from.diff_); if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) { if (from.has_shape()) { mutable_shape()->::caffe::BlobShape::MergeFrom(from.shape()); @@ -2894,19 +3012,24 @@ void BlobProto::MergeFrom(const BlobProto& from) { set_width(from.width()); } } - mutable_unknown_fields()->MergeFrom(from.unknown_fields()); + if (from._internal_metadata_.have_unknown_fields()) { + ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata( + from.unknown_fields(), &_internal_metadata_); + } } void BlobProto::CopyFrom(const ::google::protobuf::Message& from) { +// @@protoc_insertion_point(generalized_copy_from_start:caffe.BlobProto) if (&from == this) return; Clear(); MergeFrom(from); } void BlobProto::CopyFrom(const BlobProto& from) { +// @@protoc_insertion_point(class_specific_copy_from_start:caffe.BlobProto) if (&from == this) return; Clear(); - MergeFrom(from); + UnsafeMergeFrom(from); } bool BlobProto::IsInitialized() const { @@ -2915,18 +3038,20 @@ bool BlobProto::IsInitialized() const { } void BlobProto::Swap(BlobProto* other) { - if (other != this) { - std::swap(shape_, other->shape_); - data_.Swap(&other->data_); - diff_.Swap(&other->diff_); - std::swap(num_, other->num_); - std::swap(channels_, other->channels_); - std::swap(height_, other->height_); - std::swap(width_, other->width_); - std::swap(_has_bits_[0], other->_has_bits_[0]); - _unknown_fields_.Swap(&other->_unknown_fields_); - std::swap(_cached_size_, other->_cached_size_); - } + if (other == this) return; + InternalSwap(other); +} +void BlobProto::InternalSwap(BlobProto* other) { + std::swap(shape_, other->shape_); + data_.UnsafeArenaSwap(&other->data_); + diff_.UnsafeArenaSwap(&other->diff_); + std::swap(num_, other->num_); + std::swap(channels_, other->channels_); + std::swap(height_, other->height_); + std::swap(width_, other->width_); + std::swap(_has_bits_[0], other->_has_bits_[0]); + _internal_metadata_.Swap(&other->_internal_metadata_); + std::swap(_cached_size_, other->_cached_size_); } ::google::protobuf::Metadata BlobProto::GetMetadata() const { @@ -2937,39 +3062,249 @@ void BlobProto::Swap(BlobProto* other) { return metadata; } +#if PROTOBUF_INLINE_NOT_IN_HEADERS +// BlobProto + +// optional .caffe.BlobShape shape = 7; +bool BlobProto::has_shape() const { + return (_has_bits_[0] & 0x00000001u) != 0; +} +void BlobProto::set_has_shape() { + _has_bits_[0] |= 0x00000001u; +} +void BlobProto::clear_has_shape() { + _has_bits_[0] &= ~0x00000001u; +} +void BlobProto::clear_shape() { + if (shape_ != NULL) shape_->::caffe::BlobShape::Clear(); + clear_has_shape(); +} +const ::caffe::BlobShape& BlobProto::shape() const { + // @@protoc_insertion_point(field_get:caffe.BlobProto.shape) + return shape_ != NULL ? *shape_ + : *::caffe::BlobShape::internal_default_instance(); +} +::caffe::BlobShape* BlobProto::mutable_shape() { + set_has_shape(); + if (shape_ == NULL) { + shape_ = new ::caffe::BlobShape; + } + // @@protoc_insertion_point(field_mutable:caffe.BlobProto.shape) + return shape_; +} +::caffe::BlobShape* BlobProto::release_shape() { + // @@protoc_insertion_point(field_release:caffe.BlobProto.shape) + clear_has_shape(); + ::caffe::BlobShape* temp = shape_; + shape_ = NULL; + return temp; +} +void BlobProto::set_allocated_shape(::caffe::BlobShape* shape) { + delete shape_; + shape_ = shape; + if (shape) { + set_has_shape(); + } else { + clear_has_shape(); + } + // @@protoc_insertion_point(field_set_allocated:caffe.BlobProto.shape) +} + +// repeated float data = 5 [packed = true]; +int BlobProto::data_size() const { + return data_.size(); +} +void BlobProto::clear_data() { + data_.Clear(); +} +float BlobProto::data(int index) const { + // @@protoc_insertion_point(field_get:caffe.BlobProto.data) + return data_.Get(index); +} +void BlobProto::set_data(int index, float value) { + data_.Set(index, value); + // @@protoc_insertion_point(field_set:caffe.BlobProto.data) +} +void BlobProto::add_data(float value) { + data_.Add(value); + // @@protoc_insertion_point(field_add:caffe.BlobProto.data) +} +const ::google::protobuf::RepeatedField< float >& +BlobProto::data() const { + // @@protoc_insertion_point(field_list:caffe.BlobProto.data) + return data_; +} +::google::protobuf::RepeatedField< float >* +BlobProto::mutable_data() { + // @@protoc_insertion_point(field_mutable_list:caffe.BlobProto.data) + return &data_; +} + +// repeated float diff = 6 [packed = true]; +int BlobProto::diff_size() const { + return diff_.size(); +} +void BlobProto::clear_diff() { + diff_.Clear(); +} +float BlobProto::diff(int index) const { + // @@protoc_insertion_point(field_get:caffe.BlobProto.diff) + return diff_.Get(index); +} +void BlobProto::set_diff(int index, float value) { + diff_.Set(index, value); + // @@protoc_insertion_point(field_set:caffe.BlobProto.diff) +} +void BlobProto::add_diff(float value) { + diff_.Add(value); + // @@protoc_insertion_point(field_add:caffe.BlobProto.diff) +} +const ::google::protobuf::RepeatedField< float >& +BlobProto::diff() const { + // @@protoc_insertion_point(field_list:caffe.BlobProto.diff) + return diff_; +} +::google::protobuf::RepeatedField< float >* +BlobProto::mutable_diff() { + // @@protoc_insertion_point(field_mutable_list:caffe.BlobProto.diff) + return &diff_; +} + +// optional int32 num = 1 [default = 0]; +bool BlobProto::has_num() const { + return (_has_bits_[0] & 0x00000008u) != 0; +} +void BlobProto::set_has_num() { + _has_bits_[0] |= 0x00000008u; +} +void BlobProto::clear_has_num() { + _has_bits_[0] &= ~0x00000008u; +} +void BlobProto::clear_num() { + num_ = 0; + clear_has_num(); +} +::google::protobuf::int32 BlobProto::num() const { + // @@protoc_insertion_point(field_get:caffe.BlobProto.num) + return num_; +} +void BlobProto::set_num(::google::protobuf::int32 value) { + set_has_num(); + num_ = value; + // @@protoc_insertion_point(field_set:caffe.BlobProto.num) +} + +// optional int32 channels = 2 [default = 0]; +bool BlobProto::has_channels() const { + return (_has_bits_[0] & 0x00000010u) != 0; +} +void BlobProto::set_has_channels() { + _has_bits_[0] |= 0x00000010u; +} +void BlobProto::clear_has_channels() { + _has_bits_[0] &= ~0x00000010u; +} +void BlobProto::clear_channels() { + channels_ = 0; + clear_has_channels(); +} +::google::protobuf::int32 BlobProto::channels() const { + // @@protoc_insertion_point(field_get:caffe.BlobProto.channels) + return channels_; +} +void BlobProto::set_channels(::google::protobuf::int32 value) { + set_has_channels(); + channels_ = value; + // @@protoc_insertion_point(field_set:caffe.BlobProto.channels) +} + +// optional int32 height = 3 [default = 0]; +bool BlobProto::has_height() const { + return (_has_bits_[0] & 0x00000020u) != 0; +} +void BlobProto::set_has_height() { + _has_bits_[0] |= 0x00000020u; +} +void BlobProto::clear_has_height() { + _has_bits_[0] &= ~0x00000020u; +} +void BlobProto::clear_height() { + height_ = 0; + clear_has_height(); +} +::google::protobuf::int32 BlobProto::height() const { + // @@protoc_insertion_point(field_get:caffe.BlobProto.height) + return height_; +} +void BlobProto::set_height(::google::protobuf::int32 value) { + set_has_height(); + height_ = value; + // @@protoc_insertion_point(field_set:caffe.BlobProto.height) +} + +// optional int32 width = 4 [default = 0]; +bool BlobProto::has_width() const { + return (_has_bits_[0] & 0x00000040u) != 0; +} +void BlobProto::set_has_width() { + _has_bits_[0] |= 0x00000040u; +} +void BlobProto::clear_has_width() { + _has_bits_[0] &= ~0x00000040u; +} +void BlobProto::clear_width() { + width_ = 0; + clear_has_width(); +} +::google::protobuf::int32 BlobProto::width() const { + // @@protoc_insertion_point(field_get:caffe.BlobProto.width) + return width_; +} +void BlobProto::set_width(::google::protobuf::int32 value) { + set_has_width(); + width_ = value; + // @@protoc_insertion_point(field_set:caffe.BlobProto.width) +} + +inline const BlobProto* BlobProto::internal_default_instance() { + return &BlobProto_default_instance_.get(); +} +#endif // PROTOBUF_INLINE_NOT_IN_HEADERS // =================================================================== -#ifndef _MSC_VER +#if !defined(_MSC_VER) || _MSC_VER >= 1900 const int BlobProtoVector::kBlobsFieldNumber; -#endif // !_MSC_VER +#endif // !defined(_MSC_VER) || _MSC_VER >= 1900 BlobProtoVector::BlobProtoVector() - : ::google::protobuf::Message() { + : ::google::protobuf::Message(), _internal_metadata_(NULL) { + if (this != internal_default_instance()) protobuf_InitDefaults_caffe_2eproto(); SharedCtor(); + // @@protoc_insertion_point(constructor:caffe.BlobProtoVector) } void BlobProtoVector::InitAsDefaultInstance() { } BlobProtoVector::BlobProtoVector(const BlobProtoVector& from) - : ::google::protobuf::Message() { + : ::google::protobuf::Message(), + _internal_metadata_(NULL) { SharedCtor(); - MergeFrom(from); + UnsafeMergeFrom(from); + // @@protoc_insertion_point(copy_constructor:caffe.BlobProtoVector) } void BlobProtoVector::SharedCtor() { _cached_size_ = 0; - ::memset(_has_bits_, 0, sizeof(_has_bits_)); } BlobProtoVector::~BlobProtoVector() { + // @@protoc_insertion_point(destructor:caffe.BlobProtoVector) SharedDtor(); } void BlobProtoVector::SharedDtor() { - if (this != default_instance_) { - } } void BlobProtoVector::SetCachedSize(int size) const { @@ -2983,48 +3318,61 @@ const ::google::protobuf::Descriptor* BlobProtoVector::descriptor() { } const BlobProtoVector& BlobProtoVector::default_instance() { - if (default_instance_ == NULL) protobuf_AddDesc_caffe_2eproto(); - return *default_instance_; + protobuf_InitDefaults_caffe_2eproto(); + return *internal_default_instance(); } -BlobProtoVector* BlobProtoVector::default_instance_ = NULL; +::google::protobuf::internal::ExplicitlyConstructed BlobProtoVector_default_instance_; -BlobProtoVector* BlobProtoVector::New() const { - return new BlobProtoVector; +BlobProtoVector* BlobProtoVector::New(::google::protobuf::Arena* arena) const { + BlobProtoVector* n = new BlobProtoVector; + if (arena != NULL) { + arena->Own(n); + } + return n; } void BlobProtoVector::Clear() { +// @@protoc_insertion_point(message_clear_start:caffe.BlobProtoVector) blobs_.Clear(); - ::memset(_has_bits_, 0, sizeof(_has_bits_)); - mutable_unknown_fields()->Clear(); + _has_bits_.Clear(); + if (_internal_metadata_.have_unknown_fields()) { + mutable_unknown_fields()->Clear(); + } } bool BlobProtoVector::MergePartialFromCodedStream( ::google::protobuf::io::CodedInputStream* input) { -#define DO_(EXPRESSION) if (!(EXPRESSION)) return false +#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure ::google::protobuf::uint32 tag; - while ((tag = input->ReadTag()) != 0) { + // @@protoc_insertion_point(parse_start:caffe.BlobProtoVector) + for (;;) { + ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127); + tag = p.first; + if (!p.second) goto handle_unusual; switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { // repeated .caffe.BlobProto blobs = 1; case 1: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) { - parse_blobs: - DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual( + if (tag == 10) { + DO_(input->IncrementRecursionDepth()); + parse_loop_blobs: + DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtualNoRecursionDepth( input, add_blobs())); } else { - goto handle_uninterpreted; + goto handle_unusual; } - if (input->ExpectTag(10)) goto parse_blobs; - if (input->ExpectAtEnd()) return true; + if (input->ExpectTag(10)) goto parse_loop_blobs; + input->UnsafeDecrementRecursionDepth(); + if (input->ExpectAtEnd()) goto success; break; } default: { - handle_uninterpreted: - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == + handle_unusual: + if (tag == 0 || + ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) { - return true; + goto success; } DO_(::google::protobuf::internal::WireFormat::SkipField( input, tag, mutable_unknown_fields())); @@ -3032,90 +3380,122 @@ bool BlobProtoVector::MergePartialFromCodedStream( } } } +success: + // @@protoc_insertion_point(parse_success:caffe.BlobProtoVector) return true; +failure: + // @@protoc_insertion_point(parse_failure:caffe.BlobProtoVector) + return false; #undef DO_ } void BlobProtoVector::SerializeWithCachedSizes( ::google::protobuf::io::CodedOutputStream* output) const { + // @@protoc_insertion_point(serialize_start:caffe.BlobProtoVector) // repeated .caffe.BlobProto blobs = 1; - for (int i = 0; i < this->blobs_size(); i++) { + for (unsigned int i = 0, n = this->blobs_size(); i < n; i++) { ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( 1, this->blobs(i), output); } - if (!unknown_fields().empty()) { + if (_internal_metadata_.have_unknown_fields()) { ::google::protobuf::internal::WireFormat::SerializeUnknownFields( unknown_fields(), output); } + // @@protoc_insertion_point(serialize_end:caffe.BlobProtoVector) } -::google::protobuf::uint8* BlobProtoVector::SerializeWithCachedSizesToArray( - ::google::protobuf::uint8* target) const { +::google::protobuf::uint8* BlobProtoVector::InternalSerializeWithCachedSizesToArray( + bool deterministic, ::google::protobuf::uint8* target) const { + (void)deterministic; // Unused + // @@protoc_insertion_point(serialize_to_array_start:caffe.BlobProtoVector) // repeated .caffe.BlobProto blobs = 1; - for (int i = 0; i < this->blobs_size(); i++) { + for (unsigned int i = 0, n = this->blobs_size(); i < n; i++) { target = ::google::protobuf::internal::WireFormatLite:: - WriteMessageNoVirtualToArray( - 1, this->blobs(i), target); + InternalWriteMessageNoVirtualToArray( + 1, this->blobs(i), false, target); } - if (!unknown_fields().empty()) { + if (_internal_metadata_.have_unknown_fields()) { target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray( unknown_fields(), target); } + // @@protoc_insertion_point(serialize_to_array_end:caffe.BlobProtoVector) return target; } -int BlobProtoVector::ByteSize() const { - int total_size = 0; +size_t BlobProtoVector::ByteSizeLong() const { +// @@protoc_insertion_point(message_byte_size_start:caffe.BlobProtoVector) + size_t total_size = 0; // repeated .caffe.BlobProto blobs = 1; - total_size += 1 * this->blobs_size(); - for (int i = 0; i < this->blobs_size(); i++) { - total_size += - ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( - this->blobs(i)); + { + unsigned int count = this->blobs_size(); + total_size += 1UL * count; + for (unsigned int i = 0; i < count; i++) { + total_size += + ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( + this->blobs(i)); + } } - if (!unknown_fields().empty()) { + if (_internal_metadata_.have_unknown_fields()) { total_size += ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( unknown_fields()); } + int cached_size = ::google::protobuf::internal::ToCachedSize(total_size); GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); - _cached_size_ = total_size; + _cached_size_ = cached_size; GOOGLE_SAFE_CONCURRENT_WRITES_END(); return total_size; } void BlobProtoVector::MergeFrom(const ::google::protobuf::Message& from) { - GOOGLE_CHECK_NE(&from, this); +// @@protoc_insertion_point(generalized_merge_from_start:caffe.BlobProtoVector) + if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__); const BlobProtoVector* source = - ::google::protobuf::internal::dynamic_cast_if_available( - &from); + ::google::protobuf::internal::DynamicCastToGenerated( + &from); if (source == NULL) { + // @@protoc_insertion_point(generalized_merge_from_cast_fail:caffe.BlobProtoVector) ::google::protobuf::internal::ReflectionOps::Merge(from, this); } else { - MergeFrom(*source); + // @@protoc_insertion_point(generalized_merge_from_cast_success:caffe.BlobProtoVector) + UnsafeMergeFrom(*source); } } void BlobProtoVector::MergeFrom(const BlobProtoVector& from) { - GOOGLE_CHECK_NE(&from, this); +// @@protoc_insertion_point(class_specific_merge_from_start:caffe.BlobProtoVector) + if (GOOGLE_PREDICT_TRUE(&from != this)) { + UnsafeMergeFrom(from); + } else { + MergeFromFail(__LINE__); + } +} + +void BlobProtoVector::UnsafeMergeFrom(const BlobProtoVector& from) { + GOOGLE_DCHECK(&from != this); blobs_.MergeFrom(from.blobs_); - mutable_unknown_fields()->MergeFrom(from.unknown_fields()); + if (from._internal_metadata_.have_unknown_fields()) { + ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata( + from.unknown_fields(), &_internal_metadata_); + } } void BlobProtoVector::CopyFrom(const ::google::protobuf::Message& from) { +// @@protoc_insertion_point(generalized_copy_from_start:caffe.BlobProtoVector) if (&from == this) return; Clear(); MergeFrom(from); } void BlobProtoVector::CopyFrom(const BlobProtoVector& from) { +// @@protoc_insertion_point(class_specific_copy_from_start:caffe.BlobProtoVector) if (&from == this) return; Clear(); - MergeFrom(from); + UnsafeMergeFrom(from); } bool BlobProtoVector::IsInitialized() const { @@ -3124,12 +3504,14 @@ bool BlobProtoVector::IsInitialized() const { } void BlobProtoVector::Swap(BlobProtoVector* other) { - if (other != this) { - blobs_.Swap(&other->blobs_); - std::swap(_has_bits_[0], other->_has_bits_[0]); - _unknown_fields_.Swap(&other->_unknown_fields_); - std::swap(_cached_size_, other->_cached_size_); - } + if (other == this) return; + InternalSwap(other); +} +void BlobProtoVector::InternalSwap(BlobProtoVector* other) { + blobs_.UnsafeArenaSwap(&other->blobs_); + std::swap(_has_bits_[0], other->_has_bits_[0]); + _internal_metadata_.Swap(&other->_internal_metadata_); + std::swap(_cached_size_, other->_cached_size_); } ::google::protobuf::Metadata BlobProtoVector::GetMetadata() const { @@ -3140,41 +3522,80 @@ void BlobProtoVector::Swap(BlobProtoVector* other) { return metadata; } +#if PROTOBUF_INLINE_NOT_IN_HEADERS +// BlobProtoVector + +// repeated .caffe.BlobProto blobs = 1; +int BlobProtoVector::blobs_size() const { + return blobs_.size(); +} +void BlobProtoVector::clear_blobs() { + blobs_.Clear(); +} +const ::caffe::BlobProto& BlobProtoVector::blobs(int index) const { + // @@protoc_insertion_point(field_get:caffe.BlobProtoVector.blobs) + return blobs_.Get(index); +} +::caffe::BlobProto* BlobProtoVector::mutable_blobs(int index) { + // @@protoc_insertion_point(field_mutable:caffe.BlobProtoVector.blobs) + return blobs_.Mutable(index); +} +::caffe::BlobProto* BlobProtoVector::add_blobs() { + // @@protoc_insertion_point(field_add:caffe.BlobProtoVector.blobs) + return blobs_.Add(); +} +::google::protobuf::RepeatedPtrField< ::caffe::BlobProto >* +BlobProtoVector::mutable_blobs() { + // @@protoc_insertion_point(field_mutable_list:caffe.BlobProtoVector.blobs) + return &blobs_; +} +const ::google::protobuf::RepeatedPtrField< ::caffe::BlobProto >& +BlobProtoVector::blobs() const { + // @@protoc_insertion_point(field_list:caffe.BlobProtoVector.blobs) + return blobs_; +} + +inline const BlobProtoVector* BlobProtoVector::internal_default_instance() { + return &BlobProtoVector_default_instance_.get(); +} +#endif // PROTOBUF_INLINE_NOT_IN_HEADERS // =================================================================== -#ifndef _MSC_VER +#if !defined(_MSC_VER) || _MSC_VER >= 1900 const int CropParameter::kAxisFieldNumber; const int CropParameter::kOffsetFieldNumber; -#endif // !_MSC_VER +#endif // !defined(_MSC_VER) || _MSC_VER >= 1900 CropParameter::CropParameter() - : ::google::protobuf::Message() { + : ::google::protobuf::Message(), _internal_metadata_(NULL) { + if (this != internal_default_instance()) protobuf_InitDefaults_caffe_2eproto(); SharedCtor(); + // @@protoc_insertion_point(constructor:caffe.CropParameter) } void CropParameter::InitAsDefaultInstance() { } CropParameter::CropParameter(const CropParameter& from) - : ::google::protobuf::Message() { + : ::google::protobuf::Message(), + _internal_metadata_(NULL) { SharedCtor(); - MergeFrom(from); + UnsafeMergeFrom(from); + // @@protoc_insertion_point(copy_constructor:caffe.CropParameter) } void CropParameter::SharedCtor() { _cached_size_ = 0; axis_ = 2; - ::memset(_has_bits_, 0, sizeof(_has_bits_)); } CropParameter::~CropParameter() { + // @@protoc_insertion_point(destructor:caffe.CropParameter) SharedDtor(); } void CropParameter::SharedDtor() { - if (this != default_instance_) { - } } void CropParameter::SetCachedSize(int size) const { @@ -3188,41 +3609,49 @@ const ::google::protobuf::Descriptor* CropParameter::descriptor() { } const CropParameter& CropParameter::default_instance() { - if (default_instance_ == NULL) protobuf_AddDesc_caffe_2eproto(); - return *default_instance_; + protobuf_InitDefaults_caffe_2eproto(); + return *internal_default_instance(); } -CropParameter* CropParameter::default_instance_ = NULL; +::google::protobuf::internal::ExplicitlyConstructed CropParameter_default_instance_; -CropParameter* CropParameter::New() const { - return new CropParameter; +CropParameter* CropParameter::New(::google::protobuf::Arena* arena) const { + CropParameter* n = new CropParameter; + if (arena != NULL) { + arena->Own(n); + } + return n; } void CropParameter::Clear() { - if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) { - axis_ = 2; - } +// @@protoc_insertion_point(message_clear_start:caffe.CropParameter) + axis_ = 2; offset_.Clear(); - ::memset(_has_bits_, 0, sizeof(_has_bits_)); - mutable_unknown_fields()->Clear(); + _has_bits_.Clear(); + if (_internal_metadata_.have_unknown_fields()) { + mutable_unknown_fields()->Clear(); + } } bool CropParameter::MergePartialFromCodedStream( ::google::protobuf::io::CodedInputStream* input) { -#define DO_(EXPRESSION) if (!(EXPRESSION)) return false +#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure ::google::protobuf::uint32 tag; - while ((tag = input->ReadTag()) != 0) { + // @@protoc_insertion_point(parse_start:caffe.CropParameter) + for (;;) { + ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127); + tag = p.first; + if (!p.second) goto handle_unusual; switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { // optional int32 axis = 1 [default = 2]; case 1: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) { + if (tag == 8) { + set_has_axis(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>( input, &axis_))); - set_has_axis(); } else { - goto handle_uninterpreted; + goto handle_unusual; } if (input->ExpectTag(16)) goto parse_offset; break; @@ -3230,31 +3659,29 @@ bool CropParameter::MergePartialFromCodedStream( // repeated uint32 offset = 2; case 2: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) { + if (tag == 16) { parse_offset: DO_((::google::protobuf::internal::WireFormatLite::ReadRepeatedPrimitive< ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>( 1, 16, input, this->mutable_offset()))); - } else if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) - == ::google::protobuf::internal::WireFormatLite:: - WIRETYPE_LENGTH_DELIMITED) { + } else if (tag == 18) { DO_((::google::protobuf::internal::WireFormatLite::ReadPackedPrimitiveNoInline< ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>( input, this->mutable_offset()))); } else { - goto handle_uninterpreted; + goto handle_unusual; } if (input->ExpectTag(16)) goto parse_offset; - if (input->ExpectAtEnd()) return true; + if (input->ExpectAtEnd()) goto success; break; } default: { - handle_uninterpreted: - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == + handle_unusual: + if (tag == 0 || + ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) { - return true; + goto success; } DO_(::google::protobuf::internal::WireFormat::SkipField( input, tag, mutable_unknown_fields())); @@ -3262,12 +3689,18 @@ bool CropParameter::MergePartialFromCodedStream( } } } +success: + // @@protoc_insertion_point(parse_success:caffe.CropParameter) return true; +failure: + // @@protoc_insertion_point(parse_failure:caffe.CropParameter) + return false; #undef DO_ } void CropParameter::SerializeWithCachedSizes( ::google::protobuf::io::CodedOutputStream* output) const { + // @@protoc_insertion_point(serialize_start:caffe.CropParameter) // optional int32 axis = 1 [default = 2]; if (has_axis()) { ::google::protobuf::internal::WireFormatLite::WriteInt32(1, this->axis(), output); @@ -3279,14 +3712,17 @@ void CropParameter::SerializeWithCachedSizes( 2, this->offset(i), output); } - if (!unknown_fields().empty()) { + if (_internal_metadata_.have_unknown_fields()) { ::google::protobuf::internal::WireFormat::SerializeUnknownFields( unknown_fields(), output); } + // @@protoc_insertion_point(serialize_end:caffe.CropParameter) } -::google::protobuf::uint8* CropParameter::SerializeWithCachedSizesToArray( - ::google::protobuf::uint8* target) const { +::google::protobuf::uint8* CropParameter::InternalSerializeWithCachedSizesToArray( + bool deterministic, ::google::protobuf::uint8* target) const { + (void)deterministic; // Unused + // @@protoc_insertion_point(serialize_to_array_start:caffe.CropParameter) // optional int32 axis = 1 [default = 2]; if (has_axis()) { target = ::google::protobuf::internal::WireFormatLite::WriteInt32ToArray(1, this->axis(), target); @@ -3298,79 +3734,100 @@ void CropParameter::SerializeWithCachedSizes( WriteUInt32ToArray(2, this->offset(i), target); } - if (!unknown_fields().empty()) { + if (_internal_metadata_.have_unknown_fields()) { target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray( unknown_fields(), target); } + // @@protoc_insertion_point(serialize_to_array_end:caffe.CropParameter) return target; } -int CropParameter::ByteSize() const { - int total_size = 0; - - if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) { - // optional int32 axis = 1 [default = 2]; - if (has_axis()) { - total_size += 1 + - ::google::protobuf::internal::WireFormatLite::Int32Size( - this->axis()); - } +size_t CropParameter::ByteSizeLong() const { +// @@protoc_insertion_point(message_byte_size_start:caffe.CropParameter) + size_t total_size = 0; + // optional int32 axis = 1 [default = 2]; + if (has_axis()) { + total_size += 1 + + ::google::protobuf::internal::WireFormatLite::Int32Size( + this->axis()); } + // repeated uint32 offset = 2; { - int data_size = 0; - for (int i = 0; i < this->offset_size(); i++) { + size_t data_size = 0; + unsigned int count = this->offset_size(); + for (unsigned int i = 0; i < count; i++) { data_size += ::google::protobuf::internal::WireFormatLite:: UInt32Size(this->offset(i)); } - total_size += 1 * this->offset_size() + data_size; + total_size += 1 * + ::google::protobuf::internal::FromIntSize(this->offset_size()); + total_size += data_size; } - if (!unknown_fields().empty()) { + if (_internal_metadata_.have_unknown_fields()) { total_size += ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( unknown_fields()); } + int cached_size = ::google::protobuf::internal::ToCachedSize(total_size); GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); - _cached_size_ = total_size; + _cached_size_ = cached_size; GOOGLE_SAFE_CONCURRENT_WRITES_END(); return total_size; } void CropParameter::MergeFrom(const ::google::protobuf::Message& from) { - GOOGLE_CHECK_NE(&from, this); +// @@protoc_insertion_point(generalized_merge_from_start:caffe.CropParameter) + if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__); const CropParameter* source = - ::google::protobuf::internal::dynamic_cast_if_available( - &from); + ::google::protobuf::internal::DynamicCastToGenerated( + &from); if (source == NULL) { + // @@protoc_insertion_point(generalized_merge_from_cast_fail:caffe.CropParameter) ::google::protobuf::internal::ReflectionOps::Merge(from, this); } else { - MergeFrom(*source); + // @@protoc_insertion_point(generalized_merge_from_cast_success:caffe.CropParameter) + UnsafeMergeFrom(*source); } } void CropParameter::MergeFrom(const CropParameter& from) { - GOOGLE_CHECK_NE(&from, this); - offset_.MergeFrom(from.offset_); +// @@protoc_insertion_point(class_specific_merge_from_start:caffe.CropParameter) + if (GOOGLE_PREDICT_TRUE(&from != this)) { + UnsafeMergeFrom(from); + } else { + MergeFromFail(__LINE__); + } +} + +void CropParameter::UnsafeMergeFrom(const CropParameter& from) { + GOOGLE_DCHECK(&from != this); + offset_.UnsafeMergeFrom(from.offset_); if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) { if (from.has_axis()) { set_axis(from.axis()); } } - mutable_unknown_fields()->MergeFrom(from.unknown_fields()); + if (from._internal_metadata_.have_unknown_fields()) { + ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata( + from.unknown_fields(), &_internal_metadata_); + } } void CropParameter::CopyFrom(const ::google::protobuf::Message& from) { +// @@protoc_insertion_point(generalized_copy_from_start:caffe.CropParameter) if (&from == this) return; Clear(); MergeFrom(from); } void CropParameter::CopyFrom(const CropParameter& from) { +// @@protoc_insertion_point(class_specific_copy_from_start:caffe.CropParameter) if (&from == this) return; Clear(); - MergeFrom(from); + UnsafeMergeFrom(from); } bool CropParameter::IsInitialized() const { @@ -3379,13 +3836,15 @@ bool CropParameter::IsInitialized() const { } void CropParameter::Swap(CropParameter* other) { - if (other != this) { - std::swap(axis_, other->axis_); - offset_.Swap(&other->offset_); - std::swap(_has_bits_[0], other->_has_bits_[0]); - _unknown_fields_.Swap(&other->_unknown_fields_); - std::swap(_cached_size_, other->_cached_size_); - } + if (other == this) return; + InternalSwap(other); +} +void CropParameter::InternalSwap(CropParameter* other) { + std::swap(axis_, other->axis_); + offset_.UnsafeArenaSwap(&other->offset_); + std::swap(_has_bits_[0], other->_has_bits_[0]); + _internal_metadata_.Swap(&other->_internal_metadata_); + std::swap(_cached_size_, other->_cached_size_); } ::google::protobuf::Metadata CropParameter::GetMetadata() const { @@ -3396,39 +3855,102 @@ void CropParameter::Swap(CropParameter* other) { return metadata; } +#if PROTOBUF_INLINE_NOT_IN_HEADERS +// CropParameter + +// optional int32 axis = 1 [default = 2]; +bool CropParameter::has_axis() const { + return (_has_bits_[0] & 0x00000001u) != 0; +} +void CropParameter::set_has_axis() { + _has_bits_[0] |= 0x00000001u; +} +void CropParameter::clear_has_axis() { + _has_bits_[0] &= ~0x00000001u; +} +void CropParameter::clear_axis() { + axis_ = 2; + clear_has_axis(); +} +::google::protobuf::int32 CropParameter::axis() const { + // @@protoc_insertion_point(field_get:caffe.CropParameter.axis) + return axis_; +} +void CropParameter::set_axis(::google::protobuf::int32 value) { + set_has_axis(); + axis_ = value; + // @@protoc_insertion_point(field_set:caffe.CropParameter.axis) +} + +// repeated uint32 offset = 2; +int CropParameter::offset_size() const { + return offset_.size(); +} +void CropParameter::clear_offset() { + offset_.Clear(); +} +::google::protobuf::uint32 CropParameter::offset(int index) const { + // @@protoc_insertion_point(field_get:caffe.CropParameter.offset) + return offset_.Get(index); +} +void CropParameter::set_offset(int index, ::google::protobuf::uint32 value) { + offset_.Set(index, value); + // @@protoc_insertion_point(field_set:caffe.CropParameter.offset) +} +void CropParameter::add_offset(::google::protobuf::uint32 value) { + offset_.Add(value); + // @@protoc_insertion_point(field_add:caffe.CropParameter.offset) +} +const ::google::protobuf::RepeatedField< ::google::protobuf::uint32 >& +CropParameter::offset() const { + // @@protoc_insertion_point(field_list:caffe.CropParameter.offset) + return offset_; +} +::google::protobuf::RepeatedField< ::google::protobuf::uint32 >* +CropParameter::mutable_offset() { + // @@protoc_insertion_point(field_mutable_list:caffe.CropParameter.offset) + return &offset_; +} + +inline const CropParameter* CropParameter::internal_default_instance() { + return &CropParameter_default_instance_.get(); +} +#endif // PROTOBUF_INLINE_NOT_IN_HEADERS + +// =================================================================== + +#if !defined(_MSC_VER) || _MSC_VER >= 1900 +const int PermuteParameter::kOrderFieldNumber; +#endif // !defined(_MSC_VER) || _MSC_VER >= 1900 -// =================================================================== - -#ifndef _MSC_VER -const int PermuteParameter::kOrderFieldNumber; -#endif // !_MSC_VER - PermuteParameter::PermuteParameter() - : ::google::protobuf::Message() { + : ::google::protobuf::Message(), _internal_metadata_(NULL) { + if (this != internal_default_instance()) protobuf_InitDefaults_caffe_2eproto(); SharedCtor(); + // @@protoc_insertion_point(constructor:caffe.PermuteParameter) } void PermuteParameter::InitAsDefaultInstance() { } PermuteParameter::PermuteParameter(const PermuteParameter& from) - : ::google::protobuf::Message() { + : ::google::protobuf::Message(), + _internal_metadata_(NULL) { SharedCtor(); - MergeFrom(from); + UnsafeMergeFrom(from); + // @@protoc_insertion_point(copy_constructor:caffe.PermuteParameter) } void PermuteParameter::SharedCtor() { _cached_size_ = 0; - ::memset(_has_bits_, 0, sizeof(_has_bits_)); } PermuteParameter::~PermuteParameter() { + // @@protoc_insertion_point(destructor:caffe.PermuteParameter) SharedDtor(); } void PermuteParameter::SharedDtor() { - if (this != default_instance_) { - } } void PermuteParameter::SetCachedSize(int size) const { @@ -3442,55 +3964,64 @@ const ::google::protobuf::Descriptor* PermuteParameter::descriptor() { } const PermuteParameter& PermuteParameter::default_instance() { - if (default_instance_ == NULL) protobuf_AddDesc_caffe_2eproto(); - return *default_instance_; + protobuf_InitDefaults_caffe_2eproto(); + return *internal_default_instance(); } -PermuteParameter* PermuteParameter::default_instance_ = NULL; +::google::protobuf::internal::ExplicitlyConstructed PermuteParameter_default_instance_; -PermuteParameter* PermuteParameter::New() const { - return new PermuteParameter; +PermuteParameter* PermuteParameter::New(::google::protobuf::Arena* arena) const { + PermuteParameter* n = new PermuteParameter; + if (arena != NULL) { + arena->Own(n); + } + return n; } void PermuteParameter::Clear() { +// @@protoc_insertion_point(message_clear_start:caffe.PermuteParameter) order_.Clear(); - ::memset(_has_bits_, 0, sizeof(_has_bits_)); - mutable_unknown_fields()->Clear(); + _has_bits_.Clear(); + if (_internal_metadata_.have_unknown_fields()) { + mutable_unknown_fields()->Clear(); + } } bool PermuteParameter::MergePartialFromCodedStream( ::google::protobuf::io::CodedInputStream* input) { -#define DO_(EXPRESSION) if (!(EXPRESSION)) return false +#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure ::google::protobuf::uint32 tag; - while ((tag = input->ReadTag()) != 0) { + // @@protoc_insertion_point(parse_start:caffe.PermuteParameter) + for (;;) { + ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127); + tag = p.first; + if (!p.second) goto handle_unusual; switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { // repeated uint32 order = 1; case 1: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) { + if (tag == 8) { parse_order: DO_((::google::protobuf::internal::WireFormatLite::ReadRepeatedPrimitive< ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>( 1, 8, input, this->mutable_order()))); - } else if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) - == ::google::protobuf::internal::WireFormatLite:: - WIRETYPE_LENGTH_DELIMITED) { + } else if (tag == 10) { DO_((::google::protobuf::internal::WireFormatLite::ReadPackedPrimitiveNoInline< ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>( input, this->mutable_order()))); } else { - goto handle_uninterpreted; + goto handle_unusual; } if (input->ExpectTag(8)) goto parse_order; - if (input->ExpectAtEnd()) return true; + if (input->ExpectAtEnd()) goto success; break; } default: { - handle_uninterpreted: - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == + handle_unusual: + if (tag == 0 || + ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) { - return true; + goto success; } DO_(::google::protobuf::internal::WireFormat::SkipField( input, tag, mutable_unknown_fields())); @@ -3498,91 +4029,123 @@ bool PermuteParameter::MergePartialFromCodedStream( } } } +success: + // @@protoc_insertion_point(parse_success:caffe.PermuteParameter) return true; +failure: + // @@protoc_insertion_point(parse_failure:caffe.PermuteParameter) + return false; #undef DO_ } void PermuteParameter::SerializeWithCachedSizes( ::google::protobuf::io::CodedOutputStream* output) const { + // @@protoc_insertion_point(serialize_start:caffe.PermuteParameter) // repeated uint32 order = 1; for (int i = 0; i < this->order_size(); i++) { ::google::protobuf::internal::WireFormatLite::WriteUInt32( 1, this->order(i), output); } - if (!unknown_fields().empty()) { + if (_internal_metadata_.have_unknown_fields()) { ::google::protobuf::internal::WireFormat::SerializeUnknownFields( unknown_fields(), output); } + // @@protoc_insertion_point(serialize_end:caffe.PermuteParameter) } -::google::protobuf::uint8* PermuteParameter::SerializeWithCachedSizesToArray( - ::google::protobuf::uint8* target) const { +::google::protobuf::uint8* PermuteParameter::InternalSerializeWithCachedSizesToArray( + bool deterministic, ::google::protobuf::uint8* target) const { + (void)deterministic; // Unused + // @@protoc_insertion_point(serialize_to_array_start:caffe.PermuteParameter) // repeated uint32 order = 1; for (int i = 0; i < this->order_size(); i++) { target = ::google::protobuf::internal::WireFormatLite:: WriteUInt32ToArray(1, this->order(i), target); } - if (!unknown_fields().empty()) { + if (_internal_metadata_.have_unknown_fields()) { target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray( unknown_fields(), target); } + // @@protoc_insertion_point(serialize_to_array_end:caffe.PermuteParameter) return target; } -int PermuteParameter::ByteSize() const { - int total_size = 0; +size_t PermuteParameter::ByteSizeLong() const { +// @@protoc_insertion_point(message_byte_size_start:caffe.PermuteParameter) + size_t total_size = 0; // repeated uint32 order = 1; { - int data_size = 0; - for (int i = 0; i < this->order_size(); i++) { + size_t data_size = 0; + unsigned int count = this->order_size(); + for (unsigned int i = 0; i < count; i++) { data_size += ::google::protobuf::internal::WireFormatLite:: UInt32Size(this->order(i)); } - total_size += 1 * this->order_size() + data_size; + total_size += 1 * + ::google::protobuf::internal::FromIntSize(this->order_size()); + total_size += data_size; } - if (!unknown_fields().empty()) { + if (_internal_metadata_.have_unknown_fields()) { total_size += ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( unknown_fields()); } + int cached_size = ::google::protobuf::internal::ToCachedSize(total_size); GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); - _cached_size_ = total_size; + _cached_size_ = cached_size; GOOGLE_SAFE_CONCURRENT_WRITES_END(); return total_size; } void PermuteParameter::MergeFrom(const ::google::protobuf::Message& from) { - GOOGLE_CHECK_NE(&from, this); +// @@protoc_insertion_point(generalized_merge_from_start:caffe.PermuteParameter) + if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__); const PermuteParameter* source = - ::google::protobuf::internal::dynamic_cast_if_available( - &from); + ::google::protobuf::internal::DynamicCastToGenerated( + &from); if (source == NULL) { + // @@protoc_insertion_point(generalized_merge_from_cast_fail:caffe.PermuteParameter) ::google::protobuf::internal::ReflectionOps::Merge(from, this); } else { - MergeFrom(*source); + // @@protoc_insertion_point(generalized_merge_from_cast_success:caffe.PermuteParameter) + UnsafeMergeFrom(*source); } } void PermuteParameter::MergeFrom(const PermuteParameter& from) { - GOOGLE_CHECK_NE(&from, this); - order_.MergeFrom(from.order_); - mutable_unknown_fields()->MergeFrom(from.unknown_fields()); +// @@protoc_insertion_point(class_specific_merge_from_start:caffe.PermuteParameter) + if (GOOGLE_PREDICT_TRUE(&from != this)) { + UnsafeMergeFrom(from); + } else { + MergeFromFail(__LINE__); + } +} + +void PermuteParameter::UnsafeMergeFrom(const PermuteParameter& from) { + GOOGLE_DCHECK(&from != this); + order_.UnsafeMergeFrom(from.order_); + if (from._internal_metadata_.have_unknown_fields()) { + ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata( + from.unknown_fields(), &_internal_metadata_); + } } void PermuteParameter::CopyFrom(const ::google::protobuf::Message& from) { +// @@protoc_insertion_point(generalized_copy_from_start:caffe.PermuteParameter) if (&from == this) return; Clear(); MergeFrom(from); } void PermuteParameter::CopyFrom(const PermuteParameter& from) { +// @@protoc_insertion_point(class_specific_copy_from_start:caffe.PermuteParameter) if (&from == this) return; Clear(); - MergeFrom(from); + UnsafeMergeFrom(from); } bool PermuteParameter::IsInitialized() const { @@ -3591,12 +4154,14 @@ bool PermuteParameter::IsInitialized() const { } void PermuteParameter::Swap(PermuteParameter* other) { - if (other != this) { - order_.Swap(&other->order_); - std::swap(_has_bits_[0], other->_has_bits_[0]); - _unknown_fields_.Swap(&other->_unknown_fields_); - std::swap(_cached_size_, other->_cached_size_); - } + if (other == this) return; + InternalSwap(other); +} +void PermuteParameter::InternalSwap(PermuteParameter* other) { + order_.UnsafeArenaSwap(&other->order_); + std::swap(_has_bits_[0], other->_has_bits_[0]); + _internal_metadata_.Swap(&other->_internal_metadata_); + std::swap(_cached_size_, other->_cached_size_); } ::google::protobuf::Metadata PermuteParameter::GetMetadata() const { @@ -3607,46 +4172,88 @@ void PermuteParameter::Swap(PermuteParameter* other) { return metadata; } +#if PROTOBUF_INLINE_NOT_IN_HEADERS +// PermuteParameter + +// repeated uint32 order = 1; +int PermuteParameter::order_size() const { + return order_.size(); +} +void PermuteParameter::clear_order() { + order_.Clear(); +} +::google::protobuf::uint32 PermuteParameter::order(int index) const { + // @@protoc_insertion_point(field_get:caffe.PermuteParameter.order) + return order_.Get(index); +} +void PermuteParameter::set_order(int index, ::google::protobuf::uint32 value) { + order_.Set(index, value); + // @@protoc_insertion_point(field_set:caffe.PermuteParameter.order) +} +void PermuteParameter::add_order(::google::protobuf::uint32 value) { + order_.Add(value); + // @@protoc_insertion_point(field_add:caffe.PermuteParameter.order) +} +const ::google::protobuf::RepeatedField< ::google::protobuf::uint32 >& +PermuteParameter::order() const { + // @@protoc_insertion_point(field_list:caffe.PermuteParameter.order) + return order_; +} +::google::protobuf::RepeatedField< ::google::protobuf::uint32 >* +PermuteParameter::mutable_order() { + // @@protoc_insertion_point(field_mutable_list:caffe.PermuteParameter.order) + return &order_; +} + +inline const PermuteParameter* PermuteParameter::internal_default_instance() { + return &PermuteParameter_default_instance_.get(); +} +#endif // PROTOBUF_INLINE_NOT_IN_HEADERS // =================================================================== -#ifndef _MSC_VER +#if !defined(_MSC_VER) || _MSC_VER >= 1900 const int NormalizeBBoxParameter::kAcrossSpatialFieldNumber; const int NormalizeBBoxParameter::kScaleFillerFieldNumber; const int NormalizeBBoxParameter::kChannelSharedFieldNumber; const int NormalizeBBoxParameter::kEpsFieldNumber; -#endif // !_MSC_VER +#endif // !defined(_MSC_VER) || _MSC_VER >= 1900 NormalizeBBoxParameter::NormalizeBBoxParameter() - : ::google::protobuf::Message() { + : ::google::protobuf::Message(), _internal_metadata_(NULL) { + if (this != internal_default_instance()) protobuf_InitDefaults_caffe_2eproto(); SharedCtor(); + // @@protoc_insertion_point(constructor:caffe.NormalizeBBoxParameter) } void NormalizeBBoxParameter::InitAsDefaultInstance() { - scale_filler_ = const_cast< ::caffe::FillerParameter*>(&::caffe::FillerParameter::default_instance()); + scale_filler_ = const_cast< ::caffe::FillerParameter*>( + ::caffe::FillerParameter::internal_default_instance()); } NormalizeBBoxParameter::NormalizeBBoxParameter(const NormalizeBBoxParameter& from) - : ::google::protobuf::Message() { + : ::google::protobuf::Message(), + _internal_metadata_(NULL) { SharedCtor(); - MergeFrom(from); + UnsafeMergeFrom(from); + // @@protoc_insertion_point(copy_constructor:caffe.NormalizeBBoxParameter) } void NormalizeBBoxParameter::SharedCtor() { _cached_size_ = 0; - across_spatial_ = true; scale_filler_ = NULL; + across_spatial_ = true; channel_shared_ = true; eps_ = 1e-10f; - ::memset(_has_bits_, 0, sizeof(_has_bits_)); } NormalizeBBoxParameter::~NormalizeBBoxParameter() { + // @@protoc_insertion_point(destructor:caffe.NormalizeBBoxParameter) SharedDtor(); } void NormalizeBBoxParameter::SharedDtor() { - if (this != default_instance_) { + if (this != &NormalizeBBoxParameter_default_instance_.get()) { delete scale_filler_; } } @@ -3662,18 +4269,23 @@ const ::google::protobuf::Descriptor* NormalizeBBoxParameter::descriptor() { } const NormalizeBBoxParameter& NormalizeBBoxParameter::default_instance() { - if (default_instance_ == NULL) protobuf_AddDesc_caffe_2eproto(); - return *default_instance_; + protobuf_InitDefaults_caffe_2eproto(); + return *internal_default_instance(); } -NormalizeBBoxParameter* NormalizeBBoxParameter::default_instance_ = NULL; +::google::protobuf::internal::ExplicitlyConstructed NormalizeBBoxParameter_default_instance_; -NormalizeBBoxParameter* NormalizeBBoxParameter::New() const { - return new NormalizeBBoxParameter; +NormalizeBBoxParameter* NormalizeBBoxParameter::New(::google::protobuf::Arena* arena) const { + NormalizeBBoxParameter* n = new NormalizeBBoxParameter; + if (arena != NULL) { + arena->Own(n); + } + return n; } void NormalizeBBoxParameter::Clear() { - if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) { +// @@protoc_insertion_point(message_clear_start:caffe.NormalizeBBoxParameter) + if (_has_bits_[0 / 32] & 15u) { across_spatial_ = true; if (has_scale_filler()) { if (scale_filler_ != NULL) scale_filler_->::caffe::FillerParameter::Clear(); @@ -3681,26 +4293,31 @@ void NormalizeBBoxParameter::Clear() { channel_shared_ = true; eps_ = 1e-10f; } - ::memset(_has_bits_, 0, sizeof(_has_bits_)); - mutable_unknown_fields()->Clear(); + _has_bits_.Clear(); + if (_internal_metadata_.have_unknown_fields()) { + mutable_unknown_fields()->Clear(); + } } bool NormalizeBBoxParameter::MergePartialFromCodedStream( ::google::protobuf::io::CodedInputStream* input) { -#define DO_(EXPRESSION) if (!(EXPRESSION)) return false +#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure ::google::protobuf::uint32 tag; - while ((tag = input->ReadTag()) != 0) { + // @@protoc_insertion_point(parse_start:caffe.NormalizeBBoxParameter) + for (;;) { + ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127); + tag = p.first; + if (!p.second) goto handle_unusual; switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { // optional bool across_spatial = 1 [default = true]; case 1: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) { + if (tag == 8) { + set_has_across_spatial(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>( input, &across_spatial_))); - set_has_across_spatial(); } else { - goto handle_uninterpreted; + goto handle_unusual; } if (input->ExpectTag(18)) goto parse_scale_filler; break; @@ -3708,13 +4325,12 @@ bool NormalizeBBoxParameter::MergePartialFromCodedStream( // optional .caffe.FillerParameter scale_filler = 2; case 2: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) { + if (tag == 18) { parse_scale_filler: DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual( input, mutable_scale_filler())); } else { - goto handle_uninterpreted; + goto handle_unusual; } if (input->ExpectTag(24)) goto parse_channel_shared; break; @@ -3722,15 +4338,14 @@ bool NormalizeBBoxParameter::MergePartialFromCodedStream( // optional bool channel_shared = 3 [default = true]; case 3: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) { + if (tag == 24) { parse_channel_shared: + set_has_channel_shared(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>( input, &channel_shared_))); - set_has_channel_shared(); } else { - goto handle_uninterpreted; + goto handle_unusual; } if (input->ExpectTag(37)) goto parse_eps; break; @@ -3738,25 +4353,25 @@ bool NormalizeBBoxParameter::MergePartialFromCodedStream( // optional float eps = 4 [default = 1e-10]; case 4: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_FIXED32) { + if (tag == 37) { parse_eps: + set_has_eps(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< float, ::google::protobuf::internal::WireFormatLite::TYPE_FLOAT>( input, &eps_))); - set_has_eps(); } else { - goto handle_uninterpreted; + goto handle_unusual; } - if (input->ExpectAtEnd()) return true; + if (input->ExpectAtEnd()) goto success; break; } default: { - handle_uninterpreted: - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == + handle_unusual: + if (tag == 0 || + ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) { - return true; + goto success; } DO_(::google::protobuf::internal::WireFormat::SkipField( input, tag, mutable_unknown_fields())); @@ -3764,12 +4379,18 @@ bool NormalizeBBoxParameter::MergePartialFromCodedStream( } } } +success: + // @@protoc_insertion_point(parse_success:caffe.NormalizeBBoxParameter) return true; +failure: + // @@protoc_insertion_point(parse_failure:caffe.NormalizeBBoxParameter) + return false; #undef DO_ } void NormalizeBBoxParameter::SerializeWithCachedSizes( ::google::protobuf::io::CodedOutputStream* output) const { + // @@protoc_insertion_point(serialize_start:caffe.NormalizeBBoxParameter) // optional bool across_spatial = 1 [default = true]; if (has_across_spatial()) { ::google::protobuf::internal::WireFormatLite::WriteBool(1, this->across_spatial(), output); @@ -3778,7 +4399,7 @@ void NormalizeBBoxParameter::SerializeWithCachedSizes( // optional .caffe.FillerParameter scale_filler = 2; if (has_scale_filler()) { ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( - 2, this->scale_filler(), output); + 2, *this->scale_filler_, output); } // optional bool channel_shared = 3 [default = true]; @@ -3791,14 +4412,17 @@ void NormalizeBBoxParameter::SerializeWithCachedSizes( ::google::protobuf::internal::WireFormatLite::WriteFloat(4, this->eps(), output); } - if (!unknown_fields().empty()) { + if (_internal_metadata_.have_unknown_fields()) { ::google::protobuf::internal::WireFormat::SerializeUnknownFields( unknown_fields(), output); } + // @@protoc_insertion_point(serialize_end:caffe.NormalizeBBoxParameter) } -::google::protobuf::uint8* NormalizeBBoxParameter::SerializeWithCachedSizesToArray( - ::google::protobuf::uint8* target) const { +::google::protobuf::uint8* NormalizeBBoxParameter::InternalSerializeWithCachedSizesToArray( + bool deterministic, ::google::protobuf::uint8* target) const { + (void)deterministic; // Unused + // @@protoc_insertion_point(serialize_to_array_start:caffe.NormalizeBBoxParameter) // optional bool across_spatial = 1 [default = true]; if (has_across_spatial()) { target = ::google::protobuf::internal::WireFormatLite::WriteBoolToArray(1, this->across_spatial(), target); @@ -3807,8 +4431,8 @@ void NormalizeBBoxParameter::SerializeWithCachedSizes( // optional .caffe.FillerParameter scale_filler = 2; if (has_scale_filler()) { target = ::google::protobuf::internal::WireFormatLite:: - WriteMessageNoVirtualToArray( - 2, this->scale_filler(), target); + InternalWriteMessageNoVirtualToArray( + 2, *this->scale_filler_, false, target); } // optional bool channel_shared = 3 [default = true]; @@ -3821,17 +4445,19 @@ void NormalizeBBoxParameter::SerializeWithCachedSizes( target = ::google::protobuf::internal::WireFormatLite::WriteFloatToArray(4, this->eps(), target); } - if (!unknown_fields().empty()) { + if (_internal_metadata_.have_unknown_fields()) { target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray( unknown_fields(), target); } + // @@protoc_insertion_point(serialize_to_array_end:caffe.NormalizeBBoxParameter) return target; } -int NormalizeBBoxParameter::ByteSize() const { - int total_size = 0; +size_t NormalizeBBoxParameter::ByteSizeLong() const { +// @@protoc_insertion_point(message_byte_size_start:caffe.NormalizeBBoxParameter) + size_t total_size = 0; - if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) { + if (_has_bits_[0 / 32] & 15u) { // optional bool across_spatial = 1 [default = true]; if (has_across_spatial()) { total_size += 1 + 1; @@ -3841,7 +4467,7 @@ int NormalizeBBoxParameter::ByteSize() const { if (has_scale_filler()) { total_size += 1 + ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( - this->scale_filler()); + *this->scale_filler_); } // optional bool channel_shared = 3 [default = true]; @@ -3855,31 +4481,44 @@ int NormalizeBBoxParameter::ByteSize() const { } } - if (!unknown_fields().empty()) { + if (_internal_metadata_.have_unknown_fields()) { total_size += ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( unknown_fields()); } + int cached_size = ::google::protobuf::internal::ToCachedSize(total_size); GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); - _cached_size_ = total_size; + _cached_size_ = cached_size; GOOGLE_SAFE_CONCURRENT_WRITES_END(); return total_size; } void NormalizeBBoxParameter::MergeFrom(const ::google::protobuf::Message& from) { - GOOGLE_CHECK_NE(&from, this); +// @@protoc_insertion_point(generalized_merge_from_start:caffe.NormalizeBBoxParameter) + if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__); const NormalizeBBoxParameter* source = - ::google::protobuf::internal::dynamic_cast_if_available( - &from); + ::google::protobuf::internal::DynamicCastToGenerated( + &from); if (source == NULL) { + // @@protoc_insertion_point(generalized_merge_from_cast_fail:caffe.NormalizeBBoxParameter) ::google::protobuf::internal::ReflectionOps::Merge(from, this); } else { - MergeFrom(*source); + // @@protoc_insertion_point(generalized_merge_from_cast_success:caffe.NormalizeBBoxParameter) + UnsafeMergeFrom(*source); } } void NormalizeBBoxParameter::MergeFrom(const NormalizeBBoxParameter& from) { - GOOGLE_CHECK_NE(&from, this); +// @@protoc_insertion_point(class_specific_merge_from_start:caffe.NormalizeBBoxParameter) + if (GOOGLE_PREDICT_TRUE(&from != this)) { + UnsafeMergeFrom(from); + } else { + MergeFromFail(__LINE__); + } +} + +void NormalizeBBoxParameter::UnsafeMergeFrom(const NormalizeBBoxParameter& from) { + GOOGLE_DCHECK(&from != this); if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) { if (from.has_across_spatial()) { set_across_spatial(from.across_spatial()); @@ -3894,19 +4533,24 @@ void NormalizeBBoxParameter::MergeFrom(const NormalizeBBoxParameter& from) { set_eps(from.eps()); } } - mutable_unknown_fields()->MergeFrom(from.unknown_fields()); + if (from._internal_metadata_.have_unknown_fields()) { + ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata( + from.unknown_fields(), &_internal_metadata_); + } } void NormalizeBBoxParameter::CopyFrom(const ::google::protobuf::Message& from) { +// @@protoc_insertion_point(generalized_copy_from_start:caffe.NormalizeBBoxParameter) if (&from == this) return; Clear(); MergeFrom(from); } void NormalizeBBoxParameter::CopyFrom(const NormalizeBBoxParameter& from) { +// @@protoc_insertion_point(class_specific_copy_from_start:caffe.NormalizeBBoxParameter) if (&from == this) return; Clear(); - MergeFrom(from); + UnsafeMergeFrom(from); } bool NormalizeBBoxParameter::IsInitialized() const { @@ -3915,15 +4559,17 @@ bool NormalizeBBoxParameter::IsInitialized() const { } void NormalizeBBoxParameter::Swap(NormalizeBBoxParameter* other) { - if (other != this) { - std::swap(across_spatial_, other->across_spatial_); - std::swap(scale_filler_, other->scale_filler_); - std::swap(channel_shared_, other->channel_shared_); - std::swap(eps_, other->eps_); - std::swap(_has_bits_[0], other->_has_bits_[0]); - _unknown_fields_.Swap(&other->_unknown_fields_); - std::swap(_cached_size_, other->_cached_size_); - } + if (other == this) return; + InternalSwap(other); +} +void NormalizeBBoxParameter::InternalSwap(NormalizeBBoxParameter* other) { + std::swap(across_spatial_, other->across_spatial_); + std::swap(scale_filler_, other->scale_filler_); + std::swap(channel_shared_, other->channel_shared_); + std::swap(eps_, other->eps_); + std::swap(_has_bits_[0], other->_has_bits_[0]); + _internal_metadata_.Swap(&other->_internal_metadata_); + std::swap(_cached_size_, other->_cached_size_); } ::google::protobuf::Metadata NormalizeBBoxParameter::GetMetadata() const { @@ -3934,6 +4580,130 @@ void NormalizeBBoxParameter::Swap(NormalizeBBoxParameter* other) { return metadata; } +#if PROTOBUF_INLINE_NOT_IN_HEADERS +// NormalizeBBoxParameter + +// optional bool across_spatial = 1 [default = true]; +bool NormalizeBBoxParameter::has_across_spatial() const { + return (_has_bits_[0] & 0x00000001u) != 0; +} +void NormalizeBBoxParameter::set_has_across_spatial() { + _has_bits_[0] |= 0x00000001u; +} +void NormalizeBBoxParameter::clear_has_across_spatial() { + _has_bits_[0] &= ~0x00000001u; +} +void NormalizeBBoxParameter::clear_across_spatial() { + across_spatial_ = true; + clear_has_across_spatial(); +} +bool NormalizeBBoxParameter::across_spatial() const { + // @@protoc_insertion_point(field_get:caffe.NormalizeBBoxParameter.across_spatial) + return across_spatial_; +} +void NormalizeBBoxParameter::set_across_spatial(bool value) { + set_has_across_spatial(); + across_spatial_ = value; + // @@protoc_insertion_point(field_set:caffe.NormalizeBBoxParameter.across_spatial) +} + +// optional .caffe.FillerParameter scale_filler = 2; +bool NormalizeBBoxParameter::has_scale_filler() const { + return (_has_bits_[0] & 0x00000002u) != 0; +} +void NormalizeBBoxParameter::set_has_scale_filler() { + _has_bits_[0] |= 0x00000002u; +} +void NormalizeBBoxParameter::clear_has_scale_filler() { + _has_bits_[0] &= ~0x00000002u; +} +void NormalizeBBoxParameter::clear_scale_filler() { + if (scale_filler_ != NULL) scale_filler_->::caffe::FillerParameter::Clear(); + clear_has_scale_filler(); +} +const ::caffe::FillerParameter& NormalizeBBoxParameter::scale_filler() const { + // @@protoc_insertion_point(field_get:caffe.NormalizeBBoxParameter.scale_filler) + return scale_filler_ != NULL ? *scale_filler_ + : *::caffe::FillerParameter::internal_default_instance(); +} +::caffe::FillerParameter* NormalizeBBoxParameter::mutable_scale_filler() { + set_has_scale_filler(); + if (scale_filler_ == NULL) { + scale_filler_ = new ::caffe::FillerParameter; + } + // @@protoc_insertion_point(field_mutable:caffe.NormalizeBBoxParameter.scale_filler) + return scale_filler_; +} +::caffe::FillerParameter* NormalizeBBoxParameter::release_scale_filler() { + // @@protoc_insertion_point(field_release:caffe.NormalizeBBoxParameter.scale_filler) + clear_has_scale_filler(); + ::caffe::FillerParameter* temp = scale_filler_; + scale_filler_ = NULL; + return temp; +} +void NormalizeBBoxParameter::set_allocated_scale_filler(::caffe::FillerParameter* scale_filler) { + delete scale_filler_; + scale_filler_ = scale_filler; + if (scale_filler) { + set_has_scale_filler(); + } else { + clear_has_scale_filler(); + } + // @@protoc_insertion_point(field_set_allocated:caffe.NormalizeBBoxParameter.scale_filler) +} + +// optional bool channel_shared = 3 [default = true]; +bool NormalizeBBoxParameter::has_channel_shared() const { + return (_has_bits_[0] & 0x00000004u) != 0; +} +void NormalizeBBoxParameter::set_has_channel_shared() { + _has_bits_[0] |= 0x00000004u; +} +void NormalizeBBoxParameter::clear_has_channel_shared() { + _has_bits_[0] &= ~0x00000004u; +} +void NormalizeBBoxParameter::clear_channel_shared() { + channel_shared_ = true; + clear_has_channel_shared(); +} +bool NormalizeBBoxParameter::channel_shared() const { + // @@protoc_insertion_point(field_get:caffe.NormalizeBBoxParameter.channel_shared) + return channel_shared_; +} +void NormalizeBBoxParameter::set_channel_shared(bool value) { + set_has_channel_shared(); + channel_shared_ = value; + // @@protoc_insertion_point(field_set:caffe.NormalizeBBoxParameter.channel_shared) +} + +// optional float eps = 4 [default = 1e-10]; +bool NormalizeBBoxParameter::has_eps() const { + return (_has_bits_[0] & 0x00000008u) != 0; +} +void NormalizeBBoxParameter::set_has_eps() { + _has_bits_[0] |= 0x00000008u; +} +void NormalizeBBoxParameter::clear_has_eps() { + _has_bits_[0] &= ~0x00000008u; +} +void NormalizeBBoxParameter::clear_eps() { + eps_ = 1e-10f; + clear_has_eps(); +} +float NormalizeBBoxParameter::eps() const { + // @@protoc_insertion_point(field_get:caffe.NormalizeBBoxParameter.eps) + return eps_; +} +void NormalizeBBoxParameter::set_eps(float value) { + set_has_eps(); + eps_ = value; + // @@protoc_insertion_point(field_set:caffe.NormalizeBBoxParameter.eps) +} + +inline const NormalizeBBoxParameter* NormalizeBBoxParameter::internal_default_instance() { + return &NormalizeBBoxParameter_default_instance_.get(); +} +#endif // PROTOBUF_INLINE_NOT_IN_HEADERS // =================================================================== @@ -3942,7 +4712,7 @@ const ::google::protobuf::EnumDescriptor* PriorBoxParameter_CodeType_descriptor( return PriorBoxParameter_CodeType_descriptor_; } bool PriorBoxParameter_CodeType_IsValid(int value) { - switch(value) { + switch (value) { case 1: case 2: return true; @@ -3951,52 +4721,54 @@ bool PriorBoxParameter_CodeType_IsValid(int value) { } } -#ifndef _MSC_VER +#if !defined(_MSC_VER) || _MSC_VER >= 1900 const PriorBoxParameter_CodeType PriorBoxParameter::CORNER; const PriorBoxParameter_CodeType PriorBoxParameter::CENTER_SIZE; const PriorBoxParameter_CodeType PriorBoxParameter::CodeType_MIN; const PriorBoxParameter_CodeType PriorBoxParameter::CodeType_MAX; const int PriorBoxParameter::CodeType_ARRAYSIZE; -#endif // _MSC_VER -#ifndef _MSC_VER +#endif // !defined(_MSC_VER) || _MSC_VER >= 1900 +#if !defined(_MSC_VER) || _MSC_VER >= 1900 const int PriorBoxParameter::kMinSizeFieldNumber; const int PriorBoxParameter::kMaxSizeFieldNumber; const int PriorBoxParameter::kAspectRatioFieldNumber; const int PriorBoxParameter::kFlipFieldNumber; const int PriorBoxParameter::kClipFieldNumber; const int PriorBoxParameter::kVarianceFieldNumber; -#endif // !_MSC_VER +#endif // !defined(_MSC_VER) || _MSC_VER >= 1900 PriorBoxParameter::PriorBoxParameter() - : ::google::protobuf::Message() { + : ::google::protobuf::Message(), _internal_metadata_(NULL) { + if (this != internal_default_instance()) protobuf_InitDefaults_caffe_2eproto(); SharedCtor(); + // @@protoc_insertion_point(constructor:caffe.PriorBoxParameter) } void PriorBoxParameter::InitAsDefaultInstance() { } PriorBoxParameter::PriorBoxParameter(const PriorBoxParameter& from) - : ::google::protobuf::Message() { + : ::google::protobuf::Message(), + _internal_metadata_(NULL) { SharedCtor(); - MergeFrom(from); + UnsafeMergeFrom(from); + // @@protoc_insertion_point(copy_constructor:caffe.PriorBoxParameter) } void PriorBoxParameter::SharedCtor() { _cached_size_ = 0; - min_size_ = 0; - max_size_ = 0; + ::memset(&min_size_, 0, reinterpret_cast(&max_size_) - + reinterpret_cast(&min_size_) + sizeof(max_size_)); flip_ = true; clip_ = true; - ::memset(_has_bits_, 0, sizeof(_has_bits_)); } PriorBoxParameter::~PriorBoxParameter() { + // @@protoc_insertion_point(destructor:caffe.PriorBoxParameter) SharedDtor(); } void PriorBoxParameter::SharedDtor() { - if (this != default_instance_) { - } } void PriorBoxParameter::SetCachedSize(int size) const { @@ -4010,45 +4782,74 @@ const ::google::protobuf::Descriptor* PriorBoxParameter::descriptor() { } const PriorBoxParameter& PriorBoxParameter::default_instance() { - if (default_instance_ == NULL) protobuf_AddDesc_caffe_2eproto(); - return *default_instance_; + protobuf_InitDefaults_caffe_2eproto(); + return *internal_default_instance(); } -PriorBoxParameter* PriorBoxParameter::default_instance_ = NULL; +::google::protobuf::internal::ExplicitlyConstructed PriorBoxParameter_default_instance_; -PriorBoxParameter* PriorBoxParameter::New() const { - return new PriorBoxParameter; +PriorBoxParameter* PriorBoxParameter::New(::google::protobuf::Arena* arena) const { + PriorBoxParameter* n = new PriorBoxParameter; + if (arena != NULL) { + arena->Own(n); + } + return n; } void PriorBoxParameter::Clear() { - if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) { - min_size_ = 0; - max_size_ = 0; +// @@protoc_insertion_point(message_clear_start:caffe.PriorBoxParameter) +#if defined(__clang__) +#define ZR_HELPER_(f) \ + _Pragma("clang diagnostic push") \ + _Pragma("clang diagnostic ignored \"-Winvalid-offsetof\"") \ + __builtin_offsetof(PriorBoxParameter, f) \ + _Pragma("clang diagnostic pop") +#else +#define ZR_HELPER_(f) reinterpret_cast(\ + &reinterpret_cast(16)->f) +#endif + +#define ZR_(first, last) do {\ + ::memset(&(first), 0,\ + ZR_HELPER_(last) - ZR_HELPER_(first) + sizeof(last));\ +} while (0) + + if (_has_bits_[0 / 32] & 27u) { + ZR_(min_size_, max_size_); flip_ = true; clip_ = true; } + +#undef ZR_HELPER_ +#undef ZR_ + aspect_ratio_.Clear(); variance_.Clear(); - ::memset(_has_bits_, 0, sizeof(_has_bits_)); - mutable_unknown_fields()->Clear(); + _has_bits_.Clear(); + if (_internal_metadata_.have_unknown_fields()) { + mutable_unknown_fields()->Clear(); + } } bool PriorBoxParameter::MergePartialFromCodedStream( ::google::protobuf::io::CodedInputStream* input) { -#define DO_(EXPRESSION) if (!(EXPRESSION)) return false +#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure ::google::protobuf::uint32 tag; - while ((tag = input->ReadTag()) != 0) { + // @@protoc_insertion_point(parse_start:caffe.PriorBoxParameter) + for (;;) { + ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127); + tag = p.first; + if (!p.second) goto handle_unusual; switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { // optional float min_size = 1; case 1: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_FIXED32) { + if (tag == 13) { + set_has_min_size(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< float, ::google::protobuf::internal::WireFormatLite::TYPE_FLOAT>( input, &min_size_))); - set_has_min_size(); } else { - goto handle_uninterpreted; + goto handle_unusual; } if (input->ExpectTag(21)) goto parse_max_size; break; @@ -4056,15 +4857,14 @@ bool PriorBoxParameter::MergePartialFromCodedStream( // optional float max_size = 2; case 2: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_FIXED32) { + if (tag == 21) { parse_max_size: + set_has_max_size(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< float, ::google::protobuf::internal::WireFormatLite::TYPE_FLOAT>( input, &max_size_))); - set_has_max_size(); } else { - goto handle_uninterpreted; + goto handle_unusual; } if (input->ExpectTag(29)) goto parse_aspect_ratio; break; @@ -4072,20 +4872,17 @@ bool PriorBoxParameter::MergePartialFromCodedStream( // repeated float aspect_ratio = 3; case 3: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_FIXED32) { + if (tag == 29) { parse_aspect_ratio: DO_((::google::protobuf::internal::WireFormatLite::ReadRepeatedPrimitive< float, ::google::protobuf::internal::WireFormatLite::TYPE_FLOAT>( 1, 29, input, this->mutable_aspect_ratio()))); - } else if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) - == ::google::protobuf::internal::WireFormatLite:: - WIRETYPE_LENGTH_DELIMITED) { + } else if (tag == 26) { DO_((::google::protobuf::internal::WireFormatLite::ReadPackedPrimitiveNoInline< float, ::google::protobuf::internal::WireFormatLite::TYPE_FLOAT>( input, this->mutable_aspect_ratio()))); } else { - goto handle_uninterpreted; + goto handle_unusual; } if (input->ExpectTag(29)) goto parse_aspect_ratio; if (input->ExpectTag(32)) goto parse_flip; @@ -4094,15 +4891,14 @@ bool PriorBoxParameter::MergePartialFromCodedStream( // optional bool flip = 4 [default = true]; case 4: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) { + if (tag == 32) { parse_flip: + set_has_flip(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>( input, &flip_))); - set_has_flip(); } else { - goto handle_uninterpreted; + goto handle_unusual; } if (input->ExpectTag(40)) goto parse_clip; break; @@ -4110,15 +4906,14 @@ bool PriorBoxParameter::MergePartialFromCodedStream( // optional bool clip = 5 [default = true]; case 5: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) { + if (tag == 40) { parse_clip: + set_has_clip(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>( input, &clip_))); - set_has_clip(); } else { - goto handle_uninterpreted; + goto handle_unusual; } if (input->ExpectTag(53)) goto parse_variance; break; @@ -4126,31 +4921,29 @@ bool PriorBoxParameter::MergePartialFromCodedStream( // repeated float variance = 6; case 6: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_FIXED32) { + if (tag == 53) { parse_variance: DO_((::google::protobuf::internal::WireFormatLite::ReadRepeatedPrimitive< float, ::google::protobuf::internal::WireFormatLite::TYPE_FLOAT>( 1, 53, input, this->mutable_variance()))); - } else if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) - == ::google::protobuf::internal::WireFormatLite:: - WIRETYPE_LENGTH_DELIMITED) { + } else if (tag == 50) { DO_((::google::protobuf::internal::WireFormatLite::ReadPackedPrimitiveNoInline< float, ::google::protobuf::internal::WireFormatLite::TYPE_FLOAT>( input, this->mutable_variance()))); } else { - goto handle_uninterpreted; + goto handle_unusual; } if (input->ExpectTag(53)) goto parse_variance; - if (input->ExpectAtEnd()) return true; + if (input->ExpectAtEnd()) goto success; break; } default: { - handle_uninterpreted: - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == + handle_unusual: + if (tag == 0 || + ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) { - return true; + goto success; } DO_(::google::protobuf::internal::WireFormat::SkipField( input, tag, mutable_unknown_fields())); @@ -4158,12 +4951,18 @@ bool PriorBoxParameter::MergePartialFromCodedStream( } } } +success: + // @@protoc_insertion_point(parse_success:caffe.PriorBoxParameter) return true; +failure: + // @@protoc_insertion_point(parse_failure:caffe.PriorBoxParameter) + return false; #undef DO_ } void PriorBoxParameter::SerializeWithCachedSizes( ::google::protobuf::io::CodedOutputStream* output) const { + // @@protoc_insertion_point(serialize_start:caffe.PriorBoxParameter) // optional float min_size = 1; if (has_min_size()) { ::google::protobuf::internal::WireFormatLite::WriteFloat(1, this->min_size(), output); @@ -4196,14 +4995,17 @@ void PriorBoxParameter::SerializeWithCachedSizes( 6, this->variance(i), output); } - if (!unknown_fields().empty()) { + if (_internal_metadata_.have_unknown_fields()) { ::google::protobuf::internal::WireFormat::SerializeUnknownFields( unknown_fields(), output); } + // @@protoc_insertion_point(serialize_end:caffe.PriorBoxParameter) } -::google::protobuf::uint8* PriorBoxParameter::SerializeWithCachedSizesToArray( - ::google::protobuf::uint8* target) const { +::google::protobuf::uint8* PriorBoxParameter::InternalSerializeWithCachedSizesToArray( + bool deterministic, ::google::protobuf::uint8* target) const { + (void)deterministic; // Unused + // @@protoc_insertion_point(serialize_to_array_start:caffe.PriorBoxParameter) // optional float min_size = 1; if (has_min_size()) { target = ::google::protobuf::internal::WireFormatLite::WriteFloatToArray(1, this->min_size(), target); @@ -4236,17 +5038,19 @@ void PriorBoxParameter::SerializeWithCachedSizes( WriteFloatToArray(6, this->variance(i), target); } - if (!unknown_fields().empty()) { + if (_internal_metadata_.have_unknown_fields()) { target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray( unknown_fields(), target); } + // @@protoc_insertion_point(serialize_to_array_end:caffe.PriorBoxParameter) return target; } -int PriorBoxParameter::ByteSize() const { - int total_size = 0; +size_t PriorBoxParameter::ByteSizeLong() const { +// @@protoc_insertion_point(message_byte_size_start:caffe.PriorBoxParameter) + size_t total_size = 0; - if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) { + if (_has_bits_[0 / 32] & 27u) { // optional float min_size = 1; if (has_min_size()) { total_size += 1 + 4; @@ -4270,45 +5074,64 @@ int PriorBoxParameter::ByteSize() const { } // repeated float aspect_ratio = 3; { - int data_size = 0; - data_size = 4 * this->aspect_ratio_size(); - total_size += 1 * this->aspect_ratio_size() + data_size; + size_t data_size = 0; + unsigned int count = this->aspect_ratio_size(); + data_size = 4UL * count; + total_size += 1 * + ::google::protobuf::internal::FromIntSize(this->aspect_ratio_size()); + total_size += data_size; } // repeated float variance = 6; { - int data_size = 0; - data_size = 4 * this->variance_size(); - total_size += 1 * this->variance_size() + data_size; + size_t data_size = 0; + unsigned int count = this->variance_size(); + data_size = 4UL * count; + total_size += 1 * + ::google::protobuf::internal::FromIntSize(this->variance_size()); + total_size += data_size; } - if (!unknown_fields().empty()) { + if (_internal_metadata_.have_unknown_fields()) { total_size += ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( unknown_fields()); } + int cached_size = ::google::protobuf::internal::ToCachedSize(total_size); GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); - _cached_size_ = total_size; + _cached_size_ = cached_size; GOOGLE_SAFE_CONCURRENT_WRITES_END(); return total_size; } void PriorBoxParameter::MergeFrom(const ::google::protobuf::Message& from) { - GOOGLE_CHECK_NE(&from, this); +// @@protoc_insertion_point(generalized_merge_from_start:caffe.PriorBoxParameter) + if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__); const PriorBoxParameter* source = - ::google::protobuf::internal::dynamic_cast_if_available( - &from); + ::google::protobuf::internal::DynamicCastToGenerated( + &from); if (source == NULL) { + // @@protoc_insertion_point(generalized_merge_from_cast_fail:caffe.PriorBoxParameter) ::google::protobuf::internal::ReflectionOps::Merge(from, this); } else { - MergeFrom(*source); + // @@protoc_insertion_point(generalized_merge_from_cast_success:caffe.PriorBoxParameter) + UnsafeMergeFrom(*source); } } void PriorBoxParameter::MergeFrom(const PriorBoxParameter& from) { - GOOGLE_CHECK_NE(&from, this); - aspect_ratio_.MergeFrom(from.aspect_ratio_); - variance_.MergeFrom(from.variance_); +// @@protoc_insertion_point(class_specific_merge_from_start:caffe.PriorBoxParameter) + if (GOOGLE_PREDICT_TRUE(&from != this)) { + UnsafeMergeFrom(from); + } else { + MergeFromFail(__LINE__); + } +} + +void PriorBoxParameter::UnsafeMergeFrom(const PriorBoxParameter& from) { + GOOGLE_DCHECK(&from != this); + aspect_ratio_.UnsafeMergeFrom(from.aspect_ratio_); + variance_.UnsafeMergeFrom(from.variance_); if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) { if (from.has_min_size()) { set_min_size(from.min_size()); @@ -4323,19 +5146,24 @@ void PriorBoxParameter::MergeFrom(const PriorBoxParameter& from) { set_clip(from.clip()); } } - mutable_unknown_fields()->MergeFrom(from.unknown_fields()); + if (from._internal_metadata_.have_unknown_fields()) { + ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata( + from.unknown_fields(), &_internal_metadata_); + } } void PriorBoxParameter::CopyFrom(const ::google::protobuf::Message& from) { +// @@protoc_insertion_point(generalized_copy_from_start:caffe.PriorBoxParameter) if (&from == this) return; Clear(); MergeFrom(from); } void PriorBoxParameter::CopyFrom(const PriorBoxParameter& from) { +// @@protoc_insertion_point(class_specific_copy_from_start:caffe.PriorBoxParameter) if (&from == this) return; Clear(); - MergeFrom(from); + UnsafeMergeFrom(from); } bool PriorBoxParameter::IsInitialized() const { @@ -4344,17 +5172,19 @@ bool PriorBoxParameter::IsInitialized() const { } void PriorBoxParameter::Swap(PriorBoxParameter* other) { - if (other != this) { - std::swap(min_size_, other->min_size_); - std::swap(max_size_, other->max_size_); - aspect_ratio_.Swap(&other->aspect_ratio_); - std::swap(flip_, other->flip_); - std::swap(clip_, other->clip_); - variance_.Swap(&other->variance_); - std::swap(_has_bits_[0], other->_has_bits_[0]); - _unknown_fields_.Swap(&other->_unknown_fields_); - std::swap(_cached_size_, other->_cached_size_); - } + if (other == this) return; + InternalSwap(other); +} +void PriorBoxParameter::InternalSwap(PriorBoxParameter* other) { + std::swap(min_size_, other->min_size_); + std::swap(max_size_, other->max_size_); + aspect_ratio_.UnsafeArenaSwap(&other->aspect_ratio_); + std::swap(flip_, other->flip_); + std::swap(clip_, other->clip_); + variance_.UnsafeArenaSwap(&other->variance_); + std::swap(_has_bits_[0], other->_has_bits_[0]); + _internal_metadata_.Swap(&other->_internal_metadata_); + std::swap(_cached_size_, other->_cached_size_); } ::google::protobuf::Metadata PriorBoxParameter::GetMetadata() const { @@ -4365,10 +5195,173 @@ void PriorBoxParameter::Swap(PriorBoxParameter* other) { return metadata; } +#if PROTOBUF_INLINE_NOT_IN_HEADERS +// PriorBoxParameter + +// optional float min_size = 1; +bool PriorBoxParameter::has_min_size() const { + return (_has_bits_[0] & 0x00000001u) != 0; +} +void PriorBoxParameter::set_has_min_size() { + _has_bits_[0] |= 0x00000001u; +} +void PriorBoxParameter::clear_has_min_size() { + _has_bits_[0] &= ~0x00000001u; +} +void PriorBoxParameter::clear_min_size() { + min_size_ = 0; + clear_has_min_size(); +} +float PriorBoxParameter::min_size() const { + // @@protoc_insertion_point(field_get:caffe.PriorBoxParameter.min_size) + return min_size_; +} +void PriorBoxParameter::set_min_size(float value) { + set_has_min_size(); + min_size_ = value; + // @@protoc_insertion_point(field_set:caffe.PriorBoxParameter.min_size) +} + +// optional float max_size = 2; +bool PriorBoxParameter::has_max_size() const { + return (_has_bits_[0] & 0x00000002u) != 0; +} +void PriorBoxParameter::set_has_max_size() { + _has_bits_[0] |= 0x00000002u; +} +void PriorBoxParameter::clear_has_max_size() { + _has_bits_[0] &= ~0x00000002u; +} +void PriorBoxParameter::clear_max_size() { + max_size_ = 0; + clear_has_max_size(); +} +float PriorBoxParameter::max_size() const { + // @@protoc_insertion_point(field_get:caffe.PriorBoxParameter.max_size) + return max_size_; +} +void PriorBoxParameter::set_max_size(float value) { + set_has_max_size(); + max_size_ = value; + // @@protoc_insertion_point(field_set:caffe.PriorBoxParameter.max_size) +} + +// repeated float aspect_ratio = 3; +int PriorBoxParameter::aspect_ratio_size() const { + return aspect_ratio_.size(); +} +void PriorBoxParameter::clear_aspect_ratio() { + aspect_ratio_.Clear(); +} +float PriorBoxParameter::aspect_ratio(int index) const { + // @@protoc_insertion_point(field_get:caffe.PriorBoxParameter.aspect_ratio) + return aspect_ratio_.Get(index); +} +void PriorBoxParameter::set_aspect_ratio(int index, float value) { + aspect_ratio_.Set(index, value); + // @@protoc_insertion_point(field_set:caffe.PriorBoxParameter.aspect_ratio) +} +void PriorBoxParameter::add_aspect_ratio(float value) { + aspect_ratio_.Add(value); + // @@protoc_insertion_point(field_add:caffe.PriorBoxParameter.aspect_ratio) +} +const ::google::protobuf::RepeatedField< float >& +PriorBoxParameter::aspect_ratio() const { + // @@protoc_insertion_point(field_list:caffe.PriorBoxParameter.aspect_ratio) + return aspect_ratio_; +} +::google::protobuf::RepeatedField< float >* +PriorBoxParameter::mutable_aspect_ratio() { + // @@protoc_insertion_point(field_mutable_list:caffe.PriorBoxParameter.aspect_ratio) + return &aspect_ratio_; +} + +// optional bool flip = 4 [default = true]; +bool PriorBoxParameter::has_flip() const { + return (_has_bits_[0] & 0x00000008u) != 0; +} +void PriorBoxParameter::set_has_flip() { + _has_bits_[0] |= 0x00000008u; +} +void PriorBoxParameter::clear_has_flip() { + _has_bits_[0] &= ~0x00000008u; +} +void PriorBoxParameter::clear_flip() { + flip_ = true; + clear_has_flip(); +} +bool PriorBoxParameter::flip() const { + // @@protoc_insertion_point(field_get:caffe.PriorBoxParameter.flip) + return flip_; +} +void PriorBoxParameter::set_flip(bool value) { + set_has_flip(); + flip_ = value; + // @@protoc_insertion_point(field_set:caffe.PriorBoxParameter.flip) +} + +// optional bool clip = 5 [default = true]; +bool PriorBoxParameter::has_clip() const { + return (_has_bits_[0] & 0x00000010u) != 0; +} +void PriorBoxParameter::set_has_clip() { + _has_bits_[0] |= 0x00000010u; +} +void PriorBoxParameter::clear_has_clip() { + _has_bits_[0] &= ~0x00000010u; +} +void PriorBoxParameter::clear_clip() { + clip_ = true; + clear_has_clip(); +} +bool PriorBoxParameter::clip() const { + // @@protoc_insertion_point(field_get:caffe.PriorBoxParameter.clip) + return clip_; +} +void PriorBoxParameter::set_clip(bool value) { + set_has_clip(); + clip_ = value; + // @@protoc_insertion_point(field_set:caffe.PriorBoxParameter.clip) +} + +// repeated float variance = 6; +int PriorBoxParameter::variance_size() const { + return variance_.size(); +} +void PriorBoxParameter::clear_variance() { + variance_.Clear(); +} +float PriorBoxParameter::variance(int index) const { + // @@protoc_insertion_point(field_get:caffe.PriorBoxParameter.variance) + return variance_.Get(index); +} +void PriorBoxParameter::set_variance(int index, float value) { + variance_.Set(index, value); + // @@protoc_insertion_point(field_set:caffe.PriorBoxParameter.variance) +} +void PriorBoxParameter::add_variance(float value) { + variance_.Add(value); + // @@protoc_insertion_point(field_add:caffe.PriorBoxParameter.variance) +} +const ::google::protobuf::RepeatedField< float >& +PriorBoxParameter::variance() const { + // @@protoc_insertion_point(field_list:caffe.PriorBoxParameter.variance) + return variance_; +} +::google::protobuf::RepeatedField< float >* +PriorBoxParameter::mutable_variance() { + // @@protoc_insertion_point(field_mutable_list:caffe.PriorBoxParameter.variance) + return &variance_; +} + +inline const PriorBoxParameter* PriorBoxParameter::internal_default_instance() { + return &PriorBoxParameter_default_instance_.get(); +} +#endif // PROTOBUF_INLINE_NOT_IN_HEADERS // =================================================================== -#ifndef _MSC_VER +#if !defined(_MSC_VER) || _MSC_VER >= 1900 const int DetectionOutputParameter::kNumClassesFieldNumber; const int DetectionOutputParameter::kShareLocationFieldNumber; const int DetectionOutputParameter::kBackgroundLabelIdFieldNumber; @@ -4378,43 +5371,42 @@ const int DetectionOutputParameter::kKeepTopKFieldNumber; const int DetectionOutputParameter::kConfidenceThresholdFieldNumber; const int DetectionOutputParameter::kNmsThresholdFieldNumber; const int DetectionOutputParameter::kTopKFieldNumber; -#endif // !_MSC_VER +#endif // !defined(_MSC_VER) || _MSC_VER >= 1900 DetectionOutputParameter::DetectionOutputParameter() - : ::google::protobuf::Message() { + : ::google::protobuf::Message(), _internal_metadata_(NULL) { + if (this != internal_default_instance()) protobuf_InitDefaults_caffe_2eproto(); SharedCtor(); + // @@protoc_insertion_point(constructor:caffe.DetectionOutputParameter) } void DetectionOutputParameter::InitAsDefaultInstance() { } DetectionOutputParameter::DetectionOutputParameter(const DetectionOutputParameter& from) - : ::google::protobuf::Message() { + : ::google::protobuf::Message(), + _internal_metadata_(NULL) { SharedCtor(); - MergeFrom(from); + UnsafeMergeFrom(from); + // @@protoc_insertion_point(copy_constructor:caffe.DetectionOutputParameter) } void DetectionOutputParameter::SharedCtor() { _cached_size_ = 0; - num_classes_ = 0u; + ::memset(&num_classes_, 0, reinterpret_cast(&top_k_) - + reinterpret_cast(&num_classes_) + sizeof(top_k_)); share_location_ = true; - background_label_id_ = 0; code_type_ = 1; - variance_encoded_in_target_ = false; keep_top_k_ = -1; - confidence_threshold_ = 0; nms_threshold_ = 0.3f; - top_k_ = 0; - ::memset(_has_bits_, 0, sizeof(_has_bits_)); } DetectionOutputParameter::~DetectionOutputParameter() { + // @@protoc_insertion_point(destructor:caffe.DetectionOutputParameter) SharedDtor(); } void DetectionOutputParameter::SharedDtor() { - if (this != default_instance_) { - } } void DetectionOutputParameter::SetCachedSize(int size) const { @@ -4428,50 +5420,75 @@ const ::google::protobuf::Descriptor* DetectionOutputParameter::descriptor() { } const DetectionOutputParameter& DetectionOutputParameter::default_instance() { - if (default_instance_ == NULL) protobuf_AddDesc_caffe_2eproto(); - return *default_instance_; + protobuf_InitDefaults_caffe_2eproto(); + return *internal_default_instance(); } -DetectionOutputParameter* DetectionOutputParameter::default_instance_ = NULL; +::google::protobuf::internal::ExplicitlyConstructed DetectionOutputParameter_default_instance_; -DetectionOutputParameter* DetectionOutputParameter::New() const { - return new DetectionOutputParameter; +DetectionOutputParameter* DetectionOutputParameter::New(::google::protobuf::Arena* arena) const { + DetectionOutputParameter* n = new DetectionOutputParameter; + if (arena != NULL) { + arena->Own(n); + } + return n; } void DetectionOutputParameter::Clear() { - if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) { - num_classes_ = 0u; +// @@protoc_insertion_point(message_clear_start:caffe.DetectionOutputParameter) +#if defined(__clang__) +#define ZR_HELPER_(f) \ + _Pragma("clang diagnostic push") \ + _Pragma("clang diagnostic ignored \"-Winvalid-offsetof\"") \ + __builtin_offsetof(DetectionOutputParameter, f) \ + _Pragma("clang diagnostic pop") +#else +#define ZR_HELPER_(f) reinterpret_cast(\ + &reinterpret_cast(16)->f) +#endif + +#define ZR_(first, last) do {\ + ::memset(&(first), 0,\ + ZR_HELPER_(last) - ZR_HELPER_(first) + sizeof(last));\ +} while (0) + + if (_has_bits_[0 / 32] & 255u) { + ZR_(num_classes_, confidence_threshold_); share_location_ = true; - background_label_id_ = 0; code_type_ = 1; - variance_encoded_in_target_ = false; keep_top_k_ = -1; - confidence_threshold_ = 0; nms_threshold_ = 0.3f; } - if (_has_bits_[8 / 32] & (0xffu << (8 % 32))) { - top_k_ = 0; + top_k_ = 0; + +#undef ZR_HELPER_ +#undef ZR_ + + _has_bits_.Clear(); + if (_internal_metadata_.have_unknown_fields()) { + mutable_unknown_fields()->Clear(); } - ::memset(_has_bits_, 0, sizeof(_has_bits_)); - mutable_unknown_fields()->Clear(); } bool DetectionOutputParameter::MergePartialFromCodedStream( ::google::protobuf::io::CodedInputStream* input) { -#define DO_(EXPRESSION) if (!(EXPRESSION)) return false +#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure ::google::protobuf::uint32 tag; - while ((tag = input->ReadTag()) != 0) { + // @@protoc_insertion_point(parse_start:caffe.DetectionOutputParameter) + for (;;) { + ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127); + tag = p.first; + if (!p.second) goto handle_unusual; switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { // optional uint32 num_classes = 1; case 1: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) { + if (tag == 8) { + set_has_num_classes(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>( input, &num_classes_))); - set_has_num_classes(); } else { - goto handle_uninterpreted; + goto handle_unusual; } if (input->ExpectTag(16)) goto parse_share_location; break; @@ -4479,15 +5496,14 @@ bool DetectionOutputParameter::MergePartialFromCodedStream( // optional bool share_location = 2 [default = true]; case 2: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) { + if (tag == 16) { parse_share_location: + set_has_share_location(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>( input, &share_location_))); - set_has_share_location(); } else { - goto handle_uninterpreted; + goto handle_unusual; } if (input->ExpectTag(24)) goto parse_background_label_id; break; @@ -4495,15 +5511,14 @@ bool DetectionOutputParameter::MergePartialFromCodedStream( // optional int32 background_label_id = 3 [default = 0]; case 3: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) { + if (tag == 24) { parse_background_label_id: + set_has_background_label_id(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>( input, &background_label_id_))); - set_has_background_label_id(); } else { - goto handle_uninterpreted; + goto handle_unusual; } if (input->ExpectTag(48)) goto parse_code_type; break; @@ -4511,8 +5526,7 @@ bool DetectionOutputParameter::MergePartialFromCodedStream( // optional .caffe.PriorBoxParameter.CodeType code_type = 6 [default = CORNER]; case 6: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) { + if (tag == 48) { parse_code_type: int value; DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< @@ -4524,7 +5538,7 @@ bool DetectionOutputParameter::MergePartialFromCodedStream( mutable_unknown_fields()->AddVarint(6, value); } } else { - goto handle_uninterpreted; + goto handle_unusual; } if (input->ExpectTag(56)) goto parse_keep_top_k; break; @@ -4532,15 +5546,14 @@ bool DetectionOutputParameter::MergePartialFromCodedStream( // optional int32 keep_top_k = 7 [default = -1]; case 7: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) { + if (tag == 56) { parse_keep_top_k: + set_has_keep_top_k(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>( input, &keep_top_k_))); - set_has_keep_top_k(); } else { - goto handle_uninterpreted; + goto handle_unusual; } if (input->ExpectTag(64)) goto parse_variance_encoded_in_target; break; @@ -4548,15 +5561,14 @@ bool DetectionOutputParameter::MergePartialFromCodedStream( // optional bool variance_encoded_in_target = 8 [default = false]; case 8: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) { + if (tag == 64) { parse_variance_encoded_in_target: + set_has_variance_encoded_in_target(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>( input, &variance_encoded_in_target_))); - set_has_variance_encoded_in_target(); } else { - goto handle_uninterpreted; + goto handle_unusual; } if (input->ExpectTag(77)) goto parse_confidence_threshold; break; @@ -4564,15 +5576,14 @@ bool DetectionOutputParameter::MergePartialFromCodedStream( // optional float confidence_threshold = 9; case 9: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_FIXED32) { + if (tag == 77) { parse_confidence_threshold: + set_has_confidence_threshold(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< float, ::google::protobuf::internal::WireFormatLite::TYPE_FLOAT>( input, &confidence_threshold_))); - set_has_confidence_threshold(); } else { - goto handle_uninterpreted; + goto handle_unusual; } if (input->ExpectTag(85)) goto parse_nms_threshold; break; @@ -4580,15 +5591,14 @@ bool DetectionOutputParameter::MergePartialFromCodedStream( // optional float nms_threshold = 10 [default = 0.3]; case 10: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_FIXED32) { + if (tag == 85) { parse_nms_threshold: + set_has_nms_threshold(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< float, ::google::protobuf::internal::WireFormatLite::TYPE_FLOAT>( input, &nms_threshold_))); - set_has_nms_threshold(); } else { - goto handle_uninterpreted; + goto handle_unusual; } if (input->ExpectTag(88)) goto parse_top_k; break; @@ -4596,25 +5606,25 @@ bool DetectionOutputParameter::MergePartialFromCodedStream( // optional int32 top_k = 11; case 11: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) { + if (tag == 88) { parse_top_k: + set_has_top_k(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>( input, &top_k_))); - set_has_top_k(); } else { - goto handle_uninterpreted; + goto handle_unusual; } - if (input->ExpectAtEnd()) return true; + if (input->ExpectAtEnd()) goto success; break; } default: { - handle_uninterpreted: - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == + handle_unusual: + if (tag == 0 || + ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) { - return true; + goto success; } DO_(::google::protobuf::internal::WireFormat::SkipField( input, tag, mutable_unknown_fields())); @@ -4622,12 +5632,18 @@ bool DetectionOutputParameter::MergePartialFromCodedStream( } } } +success: + // @@protoc_insertion_point(parse_success:caffe.DetectionOutputParameter) return true; +failure: + // @@protoc_insertion_point(parse_failure:caffe.DetectionOutputParameter) + return false; #undef DO_ } void DetectionOutputParameter::SerializeWithCachedSizes( ::google::protobuf::io::CodedOutputStream* output) const { + // @@protoc_insertion_point(serialize_start:caffe.DetectionOutputParameter) // optional uint32 num_classes = 1; if (has_num_classes()) { ::google::protobuf::internal::WireFormatLite::WriteUInt32(1, this->num_classes(), output); @@ -4674,14 +5690,17 @@ void DetectionOutputParameter::SerializeWithCachedSizes( ::google::protobuf::internal::WireFormatLite::WriteInt32(11, this->top_k(), output); } - if (!unknown_fields().empty()) { + if (_internal_metadata_.have_unknown_fields()) { ::google::protobuf::internal::WireFormat::SerializeUnknownFields( unknown_fields(), output); } + // @@protoc_insertion_point(serialize_end:caffe.DetectionOutputParameter) } -::google::protobuf::uint8* DetectionOutputParameter::SerializeWithCachedSizesToArray( - ::google::protobuf::uint8* target) const { +::google::protobuf::uint8* DetectionOutputParameter::InternalSerializeWithCachedSizesToArray( + bool deterministic, ::google::protobuf::uint8* target) const { + (void)deterministic; // Unused + // @@protoc_insertion_point(serialize_to_array_start:caffe.DetectionOutputParameter) // optional uint32 num_classes = 1; if (has_num_classes()) { target = ::google::protobuf::internal::WireFormatLite::WriteUInt32ToArray(1, this->num_classes(), target); @@ -4728,17 +5747,19 @@ void DetectionOutputParameter::SerializeWithCachedSizes( target = ::google::protobuf::internal::WireFormatLite::WriteInt32ToArray(11, this->top_k(), target); } - if (!unknown_fields().empty()) { + if (_internal_metadata_.have_unknown_fields()) { target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray( unknown_fields(), target); } + // @@protoc_insertion_point(serialize_to_array_end:caffe.DetectionOutputParameter) return target; } -int DetectionOutputParameter::ByteSize() const { - int total_size = 0; +size_t DetectionOutputParameter::ByteSizeLong() const { +// @@protoc_insertion_point(message_byte_size_start:caffe.DetectionOutputParameter) + size_t total_size = 0; - if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) { + if (_has_bits_[0 / 32] & 255u) { // optional uint32 num_classes = 1; if (has_num_classes()) { total_size += 1 + @@ -4787,40 +5808,51 @@ int DetectionOutputParameter::ByteSize() const { } } - if (_has_bits_[8 / 32] & (0xffu << (8 % 32))) { - // optional int32 top_k = 11; - if (has_top_k()) { - total_size += 1 + - ::google::protobuf::internal::WireFormatLite::Int32Size( - this->top_k()); - } - + // optional int32 top_k = 11; + if (has_top_k()) { + total_size += 1 + + ::google::protobuf::internal::WireFormatLite::Int32Size( + this->top_k()); } - if (!unknown_fields().empty()) { + + if (_internal_metadata_.have_unknown_fields()) { total_size += ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( unknown_fields()); } + int cached_size = ::google::protobuf::internal::ToCachedSize(total_size); GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); - _cached_size_ = total_size; + _cached_size_ = cached_size; GOOGLE_SAFE_CONCURRENT_WRITES_END(); return total_size; } void DetectionOutputParameter::MergeFrom(const ::google::protobuf::Message& from) { - GOOGLE_CHECK_NE(&from, this); +// @@protoc_insertion_point(generalized_merge_from_start:caffe.DetectionOutputParameter) + if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__); const DetectionOutputParameter* source = - ::google::protobuf::internal::dynamic_cast_if_available( - &from); + ::google::protobuf::internal::DynamicCastToGenerated( + &from); if (source == NULL) { + // @@protoc_insertion_point(generalized_merge_from_cast_fail:caffe.DetectionOutputParameter) ::google::protobuf::internal::ReflectionOps::Merge(from, this); } else { - MergeFrom(*source); + // @@protoc_insertion_point(generalized_merge_from_cast_success:caffe.DetectionOutputParameter) + UnsafeMergeFrom(*source); } } void DetectionOutputParameter::MergeFrom(const DetectionOutputParameter& from) { - GOOGLE_CHECK_NE(&from, this); +// @@protoc_insertion_point(class_specific_merge_from_start:caffe.DetectionOutputParameter) + if (GOOGLE_PREDICT_TRUE(&from != this)) { + UnsafeMergeFrom(from); + } else { + MergeFromFail(__LINE__); + } +} + +void DetectionOutputParameter::UnsafeMergeFrom(const DetectionOutputParameter& from) { + GOOGLE_DCHECK(&from != this); if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) { if (from.has_num_classes()) { set_num_classes(from.num_classes()); @@ -4852,19 +5884,24 @@ void DetectionOutputParameter::MergeFrom(const DetectionOutputParameter& from) { set_top_k(from.top_k()); } } - mutable_unknown_fields()->MergeFrom(from.unknown_fields()); + if (from._internal_metadata_.have_unknown_fields()) { + ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata( + from.unknown_fields(), &_internal_metadata_); + } } void DetectionOutputParameter::CopyFrom(const ::google::protobuf::Message& from) { +// @@protoc_insertion_point(generalized_copy_from_start:caffe.DetectionOutputParameter) if (&from == this) return; Clear(); MergeFrom(from); } void DetectionOutputParameter::CopyFrom(const DetectionOutputParameter& from) { +// @@protoc_insertion_point(class_specific_copy_from_start:caffe.DetectionOutputParameter) if (&from == this) return; Clear(); - MergeFrom(from); + UnsafeMergeFrom(from); } bool DetectionOutputParameter::IsInitialized() const { @@ -4873,20 +5910,22 @@ bool DetectionOutputParameter::IsInitialized() const { } void DetectionOutputParameter::Swap(DetectionOutputParameter* other) { - if (other != this) { - std::swap(num_classes_, other->num_classes_); - std::swap(share_location_, other->share_location_); - std::swap(background_label_id_, other->background_label_id_); - std::swap(code_type_, other->code_type_); - std::swap(variance_encoded_in_target_, other->variance_encoded_in_target_); - std::swap(keep_top_k_, other->keep_top_k_); - std::swap(confidence_threshold_, other->confidence_threshold_); - std::swap(nms_threshold_, other->nms_threshold_); - std::swap(top_k_, other->top_k_); - std::swap(_has_bits_[0], other->_has_bits_[0]); - _unknown_fields_.Swap(&other->_unknown_fields_); - std::swap(_cached_size_, other->_cached_size_); - } + if (other == this) return; + InternalSwap(other); +} +void DetectionOutputParameter::InternalSwap(DetectionOutputParameter* other) { + std::swap(num_classes_, other->num_classes_); + std::swap(share_location_, other->share_location_); + std::swap(background_label_id_, other->background_label_id_); + std::swap(code_type_, other->code_type_); + std::swap(variance_encoded_in_target_, other->variance_encoded_in_target_); + std::swap(keep_top_k_, other->keep_top_k_); + std::swap(confidence_threshold_, other->confidence_threshold_); + std::swap(nms_threshold_, other->nms_threshold_); + std::swap(top_k_, other->top_k_); + std::swap(_has_bits_[0], other->_has_bits_[0]); + _internal_metadata_.Swap(&other->_internal_metadata_); + std::swap(_cached_size_, other->_cached_size_); } ::google::protobuf::Metadata DetectionOutputParameter::GetMetadata() const { @@ -4897,54 +5936,275 @@ void DetectionOutputParameter::Swap(DetectionOutputParameter* other) { return metadata; } +#if PROTOBUF_INLINE_NOT_IN_HEADERS +// DetectionOutputParameter -// =================================================================== - -#ifndef _MSC_VER -const int Datum::kChannelsFieldNumber; -const int Datum::kHeightFieldNumber; -const int Datum::kWidthFieldNumber; -const int Datum::kDataFieldNumber; -const int Datum::kLabelFieldNumber; -const int Datum::kFloatDataFieldNumber; -const int Datum::kEncodedFieldNumber; -#endif // !_MSC_VER - -Datum::Datum() - : ::google::protobuf::Message() { - SharedCtor(); +// optional uint32 num_classes = 1; +bool DetectionOutputParameter::has_num_classes() const { + return (_has_bits_[0] & 0x00000001u) != 0; } - -void Datum::InitAsDefaultInstance() { +void DetectionOutputParameter::set_has_num_classes() { + _has_bits_[0] |= 0x00000001u; } - -Datum::Datum(const Datum& from) - : ::google::protobuf::Message() { - SharedCtor(); - MergeFrom(from); +void DetectionOutputParameter::clear_has_num_classes() { + _has_bits_[0] &= ~0x00000001u; } - -void Datum::SharedCtor() { - _cached_size_ = 0; - channels_ = 0; - height_ = 0; - width_ = 0; - data_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); - label_ = 0; - encoded_ = false; - ::memset(_has_bits_, 0, sizeof(_has_bits_)); +void DetectionOutputParameter::clear_num_classes() { + num_classes_ = 0u; + clear_has_num_classes(); } - -Datum::~Datum() { - SharedDtor(); +::google::protobuf::uint32 DetectionOutputParameter::num_classes() const { + // @@protoc_insertion_point(field_get:caffe.DetectionOutputParameter.num_classes) + return num_classes_; +} +void DetectionOutputParameter::set_num_classes(::google::protobuf::uint32 value) { + set_has_num_classes(); + num_classes_ = value; + // @@protoc_insertion_point(field_set:caffe.DetectionOutputParameter.num_classes) +} + +// optional bool share_location = 2 [default = true]; +bool DetectionOutputParameter::has_share_location() const { + return (_has_bits_[0] & 0x00000002u) != 0; +} +void DetectionOutputParameter::set_has_share_location() { + _has_bits_[0] |= 0x00000002u; +} +void DetectionOutputParameter::clear_has_share_location() { + _has_bits_[0] &= ~0x00000002u; +} +void DetectionOutputParameter::clear_share_location() { + share_location_ = true; + clear_has_share_location(); +} +bool DetectionOutputParameter::share_location() const { + // @@protoc_insertion_point(field_get:caffe.DetectionOutputParameter.share_location) + return share_location_; +} +void DetectionOutputParameter::set_share_location(bool value) { + set_has_share_location(); + share_location_ = value; + // @@protoc_insertion_point(field_set:caffe.DetectionOutputParameter.share_location) +} + +// optional int32 background_label_id = 3 [default = 0]; +bool DetectionOutputParameter::has_background_label_id() const { + return (_has_bits_[0] & 0x00000004u) != 0; +} +void DetectionOutputParameter::set_has_background_label_id() { + _has_bits_[0] |= 0x00000004u; +} +void DetectionOutputParameter::clear_has_background_label_id() { + _has_bits_[0] &= ~0x00000004u; +} +void DetectionOutputParameter::clear_background_label_id() { + background_label_id_ = 0; + clear_has_background_label_id(); +} +::google::protobuf::int32 DetectionOutputParameter::background_label_id() const { + // @@protoc_insertion_point(field_get:caffe.DetectionOutputParameter.background_label_id) + return background_label_id_; +} +void DetectionOutputParameter::set_background_label_id(::google::protobuf::int32 value) { + set_has_background_label_id(); + background_label_id_ = value; + // @@protoc_insertion_point(field_set:caffe.DetectionOutputParameter.background_label_id) +} + +// optional .caffe.PriorBoxParameter.CodeType code_type = 6 [default = CORNER]; +bool DetectionOutputParameter::has_code_type() const { + return (_has_bits_[0] & 0x00000008u) != 0; +} +void DetectionOutputParameter::set_has_code_type() { + _has_bits_[0] |= 0x00000008u; +} +void DetectionOutputParameter::clear_has_code_type() { + _has_bits_[0] &= ~0x00000008u; +} +void DetectionOutputParameter::clear_code_type() { + code_type_ = 1; + clear_has_code_type(); +} +::caffe::PriorBoxParameter_CodeType DetectionOutputParameter::code_type() const { + // @@protoc_insertion_point(field_get:caffe.DetectionOutputParameter.code_type) + return static_cast< ::caffe::PriorBoxParameter_CodeType >(code_type_); +} +void DetectionOutputParameter::set_code_type(::caffe::PriorBoxParameter_CodeType value) { + assert(::caffe::PriorBoxParameter_CodeType_IsValid(value)); + set_has_code_type(); + code_type_ = value; + // @@protoc_insertion_point(field_set:caffe.DetectionOutputParameter.code_type) +} + +// optional bool variance_encoded_in_target = 8 [default = false]; +bool DetectionOutputParameter::has_variance_encoded_in_target() const { + return (_has_bits_[0] & 0x00000010u) != 0; +} +void DetectionOutputParameter::set_has_variance_encoded_in_target() { + _has_bits_[0] |= 0x00000010u; +} +void DetectionOutputParameter::clear_has_variance_encoded_in_target() { + _has_bits_[0] &= ~0x00000010u; +} +void DetectionOutputParameter::clear_variance_encoded_in_target() { + variance_encoded_in_target_ = false; + clear_has_variance_encoded_in_target(); +} +bool DetectionOutputParameter::variance_encoded_in_target() const { + // @@protoc_insertion_point(field_get:caffe.DetectionOutputParameter.variance_encoded_in_target) + return variance_encoded_in_target_; +} +void DetectionOutputParameter::set_variance_encoded_in_target(bool value) { + set_has_variance_encoded_in_target(); + variance_encoded_in_target_ = value; + // @@protoc_insertion_point(field_set:caffe.DetectionOutputParameter.variance_encoded_in_target) +} + +// optional int32 keep_top_k = 7 [default = -1]; +bool DetectionOutputParameter::has_keep_top_k() const { + return (_has_bits_[0] & 0x00000020u) != 0; +} +void DetectionOutputParameter::set_has_keep_top_k() { + _has_bits_[0] |= 0x00000020u; +} +void DetectionOutputParameter::clear_has_keep_top_k() { + _has_bits_[0] &= ~0x00000020u; +} +void DetectionOutputParameter::clear_keep_top_k() { + keep_top_k_ = -1; + clear_has_keep_top_k(); +} +::google::protobuf::int32 DetectionOutputParameter::keep_top_k() const { + // @@protoc_insertion_point(field_get:caffe.DetectionOutputParameter.keep_top_k) + return keep_top_k_; +} +void DetectionOutputParameter::set_keep_top_k(::google::protobuf::int32 value) { + set_has_keep_top_k(); + keep_top_k_ = value; + // @@protoc_insertion_point(field_set:caffe.DetectionOutputParameter.keep_top_k) +} + +// optional float confidence_threshold = 9; +bool DetectionOutputParameter::has_confidence_threshold() const { + return (_has_bits_[0] & 0x00000040u) != 0; +} +void DetectionOutputParameter::set_has_confidence_threshold() { + _has_bits_[0] |= 0x00000040u; +} +void DetectionOutputParameter::clear_has_confidence_threshold() { + _has_bits_[0] &= ~0x00000040u; +} +void DetectionOutputParameter::clear_confidence_threshold() { + confidence_threshold_ = 0; + clear_has_confidence_threshold(); +} +float DetectionOutputParameter::confidence_threshold() const { + // @@protoc_insertion_point(field_get:caffe.DetectionOutputParameter.confidence_threshold) + return confidence_threshold_; +} +void DetectionOutputParameter::set_confidence_threshold(float value) { + set_has_confidence_threshold(); + confidence_threshold_ = value; + // @@protoc_insertion_point(field_set:caffe.DetectionOutputParameter.confidence_threshold) +} + +// optional float nms_threshold = 10 [default = 0.3]; +bool DetectionOutputParameter::has_nms_threshold() const { + return (_has_bits_[0] & 0x00000080u) != 0; +} +void DetectionOutputParameter::set_has_nms_threshold() { + _has_bits_[0] |= 0x00000080u; +} +void DetectionOutputParameter::clear_has_nms_threshold() { + _has_bits_[0] &= ~0x00000080u; +} +void DetectionOutputParameter::clear_nms_threshold() { + nms_threshold_ = 0.3f; + clear_has_nms_threshold(); +} +float DetectionOutputParameter::nms_threshold() const { + // @@protoc_insertion_point(field_get:caffe.DetectionOutputParameter.nms_threshold) + return nms_threshold_; +} +void DetectionOutputParameter::set_nms_threshold(float value) { + set_has_nms_threshold(); + nms_threshold_ = value; + // @@protoc_insertion_point(field_set:caffe.DetectionOutputParameter.nms_threshold) +} + +// optional int32 top_k = 11; +bool DetectionOutputParameter::has_top_k() const { + return (_has_bits_[0] & 0x00000100u) != 0; +} +void DetectionOutputParameter::set_has_top_k() { + _has_bits_[0] |= 0x00000100u; +} +void DetectionOutputParameter::clear_has_top_k() { + _has_bits_[0] &= ~0x00000100u; +} +void DetectionOutputParameter::clear_top_k() { + top_k_ = 0; + clear_has_top_k(); +} +::google::protobuf::int32 DetectionOutputParameter::top_k() const { + // @@protoc_insertion_point(field_get:caffe.DetectionOutputParameter.top_k) + return top_k_; +} +void DetectionOutputParameter::set_top_k(::google::protobuf::int32 value) { + set_has_top_k(); + top_k_ = value; + // @@protoc_insertion_point(field_set:caffe.DetectionOutputParameter.top_k) +} + +inline const DetectionOutputParameter* DetectionOutputParameter::internal_default_instance() { + return &DetectionOutputParameter_default_instance_.get(); +} +#endif // PROTOBUF_INLINE_NOT_IN_HEADERS + +// =================================================================== + +#if !defined(_MSC_VER) || _MSC_VER >= 1900 +const int Datum::kChannelsFieldNumber; +const int Datum::kHeightFieldNumber; +const int Datum::kWidthFieldNumber; +const int Datum::kDataFieldNumber; +const int Datum::kLabelFieldNumber; +const int Datum::kFloatDataFieldNumber; +const int Datum::kEncodedFieldNumber; +#endif // !defined(_MSC_VER) || _MSC_VER >= 1900 + +Datum::Datum() + : ::google::protobuf::Message(), _internal_metadata_(NULL) { + if (this != internal_default_instance()) protobuf_InitDefaults_caffe_2eproto(); + SharedCtor(); + // @@protoc_insertion_point(constructor:caffe.Datum) +} + +void Datum::InitAsDefaultInstance() { +} + +Datum::Datum(const Datum& from) + : ::google::protobuf::Message(), + _internal_metadata_(NULL) { + SharedCtor(); + UnsafeMergeFrom(from); + // @@protoc_insertion_point(copy_constructor:caffe.Datum) +} + +void Datum::SharedCtor() { + _cached_size_ = 0; + data_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + ::memset(&channels_, 0, reinterpret_cast(&encoded_) - + reinterpret_cast(&channels_) + sizeof(encoded_)); +} + +Datum::~Datum() { + // @@protoc_insertion_point(destructor:caffe.Datum) + SharedDtor(); } void Datum::SharedDtor() { - if (data_ != &::google::protobuf::internal::kEmptyString) { - delete data_; - } - if (this != default_instance_) { - } + data_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } void Datum::SetCachedSize(int size) const { @@ -4958,50 +6218,74 @@ const ::google::protobuf::Descriptor* Datum::descriptor() { } const Datum& Datum::default_instance() { - if (default_instance_ == NULL) protobuf_AddDesc_caffe_2eproto(); - return *default_instance_; + protobuf_InitDefaults_caffe_2eproto(); + return *internal_default_instance(); } -Datum* Datum::default_instance_ = NULL; +::google::protobuf::internal::ExplicitlyConstructed Datum_default_instance_; -Datum* Datum::New() const { - return new Datum; +Datum* Datum::New(::google::protobuf::Arena* arena) const { + Datum* n = new Datum; + if (arena != NULL) { + arena->Own(n); + } + return n; } void Datum::Clear() { - if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) { - channels_ = 0; - height_ = 0; - width_ = 0; +// @@protoc_insertion_point(message_clear_start:caffe.Datum) +#if defined(__clang__) +#define ZR_HELPER_(f) \ + _Pragma("clang diagnostic push") \ + _Pragma("clang diagnostic ignored \"-Winvalid-offsetof\"") \ + __builtin_offsetof(Datum, f) \ + _Pragma("clang diagnostic pop") +#else +#define ZR_HELPER_(f) reinterpret_cast(\ + &reinterpret_cast(16)->f) +#endif + +#define ZR_(first, last) do {\ + ::memset(&(first), 0,\ + ZR_HELPER_(last) - ZR_HELPER_(first) + sizeof(last));\ +} while (0) + + if (_has_bits_[0 / 32] & 95u) { + ZR_(channels_, encoded_); if (has_data()) { - if (data_ != &::google::protobuf::internal::kEmptyString) { - data_->clear(); - } + data_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - label_ = 0; - encoded_ = false; } + +#undef ZR_HELPER_ +#undef ZR_ + float_data_.Clear(); - ::memset(_has_bits_, 0, sizeof(_has_bits_)); - mutable_unknown_fields()->Clear(); + _has_bits_.Clear(); + if (_internal_metadata_.have_unknown_fields()) { + mutable_unknown_fields()->Clear(); + } } bool Datum::MergePartialFromCodedStream( ::google::protobuf::io::CodedInputStream* input) { -#define DO_(EXPRESSION) if (!(EXPRESSION)) return false +#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure ::google::protobuf::uint32 tag; - while ((tag = input->ReadTag()) != 0) { + // @@protoc_insertion_point(parse_start:caffe.Datum) + for (;;) { + ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127); + tag = p.first; + if (!p.second) goto handle_unusual; switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { // optional int32 channels = 1; case 1: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) { + if (tag == 8) { + set_has_channels(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>( input, &channels_))); - set_has_channels(); } else { - goto handle_uninterpreted; + goto handle_unusual; } if (input->ExpectTag(16)) goto parse_height; break; @@ -5009,15 +6293,14 @@ bool Datum::MergePartialFromCodedStream( // optional int32 height = 2; case 2: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) { + if (tag == 16) { parse_height: + set_has_height(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>( input, &height_))); - set_has_height(); } else { - goto handle_uninterpreted; + goto handle_unusual; } if (input->ExpectTag(24)) goto parse_width; break; @@ -5025,15 +6308,14 @@ bool Datum::MergePartialFromCodedStream( // optional int32 width = 3; case 3: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) { + if (tag == 24) { parse_width: + set_has_width(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>( input, &width_))); - set_has_width(); } else { - goto handle_uninterpreted; + goto handle_unusual; } if (input->ExpectTag(34)) goto parse_data; break; @@ -5041,13 +6323,12 @@ bool Datum::MergePartialFromCodedStream( // optional bytes data = 4; case 4: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) { + if (tag == 34) { parse_data: DO_(::google::protobuf::internal::WireFormatLite::ReadBytes( input, this->mutable_data())); } else { - goto handle_uninterpreted; + goto handle_unusual; } if (input->ExpectTag(40)) goto parse_label; break; @@ -5055,15 +6336,14 @@ bool Datum::MergePartialFromCodedStream( // optional int32 label = 5; case 5: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) { + if (tag == 40) { parse_label: + set_has_label(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>( input, &label_))); - set_has_label(); } else { - goto handle_uninterpreted; + goto handle_unusual; } if (input->ExpectTag(53)) goto parse_float_data; break; @@ -5071,20 +6351,17 @@ bool Datum::MergePartialFromCodedStream( // repeated float float_data = 6; case 6: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_FIXED32) { + if (tag == 53) { parse_float_data: DO_((::google::protobuf::internal::WireFormatLite::ReadRepeatedPrimitive< float, ::google::protobuf::internal::WireFormatLite::TYPE_FLOAT>( 1, 53, input, this->mutable_float_data()))); - } else if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) - == ::google::protobuf::internal::WireFormatLite:: - WIRETYPE_LENGTH_DELIMITED) { + } else if (tag == 50) { DO_((::google::protobuf::internal::WireFormatLite::ReadPackedPrimitiveNoInline< float, ::google::protobuf::internal::WireFormatLite::TYPE_FLOAT>( input, this->mutable_float_data()))); } else { - goto handle_uninterpreted; + goto handle_unusual; } if (input->ExpectTag(53)) goto parse_float_data; if (input->ExpectTag(56)) goto parse_encoded; @@ -5093,25 +6370,25 @@ bool Datum::MergePartialFromCodedStream( // optional bool encoded = 7 [default = false]; case 7: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) { + if (tag == 56) { parse_encoded: + set_has_encoded(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>( input, &encoded_))); - set_has_encoded(); } else { - goto handle_uninterpreted; + goto handle_unusual; } - if (input->ExpectAtEnd()) return true; + if (input->ExpectAtEnd()) goto success; break; } default: { - handle_uninterpreted: - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == + handle_unusual: + if (tag == 0 || + ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) { - return true; + goto success; } DO_(::google::protobuf::internal::WireFormat::SkipField( input, tag, mutable_unknown_fields())); @@ -5119,12 +6396,18 @@ bool Datum::MergePartialFromCodedStream( } } } +success: + // @@protoc_insertion_point(parse_success:caffe.Datum) return true; +failure: + // @@protoc_insertion_point(parse_failure:caffe.Datum) + return false; #undef DO_ } void Datum::SerializeWithCachedSizes( ::google::protobuf::io::CodedOutputStream* output) const { + // @@protoc_insertion_point(serialize_start:caffe.Datum) // optional int32 channels = 1; if (has_channels()) { ::google::protobuf::internal::WireFormatLite::WriteInt32(1, this->channels(), output); @@ -5142,7 +6425,7 @@ void Datum::SerializeWithCachedSizes( // optional bytes data = 4; if (has_data()) { - ::google::protobuf::internal::WireFormatLite::WriteBytes( + ::google::protobuf::internal::WireFormatLite::WriteBytesMaybeAliased( 4, this->data(), output); } @@ -5162,14 +6445,17 @@ void Datum::SerializeWithCachedSizes( ::google::protobuf::internal::WireFormatLite::WriteBool(7, this->encoded(), output); } - if (!unknown_fields().empty()) { + if (_internal_metadata_.have_unknown_fields()) { ::google::protobuf::internal::WireFormat::SerializeUnknownFields( unknown_fields(), output); } + // @@protoc_insertion_point(serialize_end:caffe.Datum) } -::google::protobuf::uint8* Datum::SerializeWithCachedSizesToArray( - ::google::protobuf::uint8* target) const { +::google::protobuf::uint8* Datum::InternalSerializeWithCachedSizesToArray( + bool deterministic, ::google::protobuf::uint8* target) const { + (void)deterministic; // Unused + // @@protoc_insertion_point(serialize_to_array_start:caffe.Datum) // optional int32 channels = 1; if (has_channels()) { target = ::google::protobuf::internal::WireFormatLite::WriteInt32ToArray(1, this->channels(), target); @@ -5208,17 +6494,19 @@ void Datum::SerializeWithCachedSizes( target = ::google::protobuf::internal::WireFormatLite::WriteBoolToArray(7, this->encoded(), target); } - if (!unknown_fields().empty()) { + if (_internal_metadata_.have_unknown_fields()) { target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray( unknown_fields(), target); } + // @@protoc_insertion_point(serialize_to_array_end:caffe.Datum) return target; } -int Datum::ByteSize() const { - int total_size = 0; +size_t Datum::ByteSizeLong() const { +// @@protoc_insertion_point(message_byte_size_start:caffe.Datum) + size_t total_size = 0; - if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) { + if (_has_bits_[0 / 32] & 95u) { // optional int32 channels = 1; if (has_channels()) { total_size += 1 + @@ -5262,37 +6550,53 @@ int Datum::ByteSize() const { } // repeated float float_data = 6; { - int data_size = 0; - data_size = 4 * this->float_data_size(); - total_size += 1 * this->float_data_size() + data_size; + size_t data_size = 0; + unsigned int count = this->float_data_size(); + data_size = 4UL * count; + total_size += 1 * + ::google::protobuf::internal::FromIntSize(this->float_data_size()); + total_size += data_size; } - if (!unknown_fields().empty()) { + if (_internal_metadata_.have_unknown_fields()) { total_size += ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( unknown_fields()); } + int cached_size = ::google::protobuf::internal::ToCachedSize(total_size); GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); - _cached_size_ = total_size; + _cached_size_ = cached_size; GOOGLE_SAFE_CONCURRENT_WRITES_END(); return total_size; } void Datum::MergeFrom(const ::google::protobuf::Message& from) { - GOOGLE_CHECK_NE(&from, this); +// @@protoc_insertion_point(generalized_merge_from_start:caffe.Datum) + if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__); const Datum* source = - ::google::protobuf::internal::dynamic_cast_if_available( - &from); + ::google::protobuf::internal::DynamicCastToGenerated( + &from); if (source == NULL) { + // @@protoc_insertion_point(generalized_merge_from_cast_fail:caffe.Datum) ::google::protobuf::internal::ReflectionOps::Merge(from, this); } else { - MergeFrom(*source); + // @@protoc_insertion_point(generalized_merge_from_cast_success:caffe.Datum) + UnsafeMergeFrom(*source); } } void Datum::MergeFrom(const Datum& from) { - GOOGLE_CHECK_NE(&from, this); - float_data_.MergeFrom(from.float_data_); +// @@protoc_insertion_point(class_specific_merge_from_start:caffe.Datum) + if (GOOGLE_PREDICT_TRUE(&from != this)) { + UnsafeMergeFrom(from); + } else { + MergeFromFail(__LINE__); + } +} + +void Datum::UnsafeMergeFrom(const Datum& from) { + GOOGLE_DCHECK(&from != this); + float_data_.UnsafeMergeFrom(from.float_data_); if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) { if (from.has_channels()) { set_channels(from.channels()); @@ -5304,7 +6608,8 @@ void Datum::MergeFrom(const Datum& from) { set_width(from.width()); } if (from.has_data()) { - set_data(from.data()); + set_has_data(); + data_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.data_); } if (from.has_label()) { set_label(from.label()); @@ -5313,19 +6618,24 @@ void Datum::MergeFrom(const Datum& from) { set_encoded(from.encoded()); } } - mutable_unknown_fields()->MergeFrom(from.unknown_fields()); + if (from._internal_metadata_.have_unknown_fields()) { + ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata( + from.unknown_fields(), &_internal_metadata_); + } } void Datum::CopyFrom(const ::google::protobuf::Message& from) { +// @@protoc_insertion_point(generalized_copy_from_start:caffe.Datum) if (&from == this) return; Clear(); MergeFrom(from); } void Datum::CopyFrom(const Datum& from) { +// @@protoc_insertion_point(class_specific_copy_from_start:caffe.Datum) if (&from == this) return; Clear(); - MergeFrom(from); + UnsafeMergeFrom(from); } bool Datum::IsInitialized() const { @@ -5334,18 +6644,20 @@ bool Datum::IsInitialized() const { } void Datum::Swap(Datum* other) { - if (other != this) { - std::swap(channels_, other->channels_); - std::swap(height_, other->height_); - std::swap(width_, other->width_); - std::swap(data_, other->data_); - std::swap(label_, other->label_); - float_data_.Swap(&other->float_data_); - std::swap(encoded_, other->encoded_); - std::swap(_has_bits_[0], other->_has_bits_[0]); - _unknown_fields_.Swap(&other->_unknown_fields_); - std::swap(_cached_size_, other->_cached_size_); - } + if (other == this) return; + InternalSwap(other); +} +void Datum::InternalSwap(Datum* other) { + std::swap(channels_, other->channels_); + std::swap(height_, other->height_); + std::swap(width_, other->width_); + data_.Swap(&other->data_); + std::swap(label_, other->label_); + float_data_.UnsafeArenaSwap(&other->float_data_); + std::swap(encoded_, other->encoded_); + std::swap(_has_bits_[0], other->_has_bits_[0]); + _internal_metadata_.Swap(&other->_internal_metadata_); + std::swap(_cached_size_, other->_cached_size_); } ::google::protobuf::Metadata Datum::GetMetadata() const { @@ -5356,6 +6668,217 @@ void Datum::Swap(Datum* other) { return metadata; } +#if PROTOBUF_INLINE_NOT_IN_HEADERS +// Datum + +// optional int32 channels = 1; +bool Datum::has_channels() const { + return (_has_bits_[0] & 0x00000001u) != 0; +} +void Datum::set_has_channels() { + _has_bits_[0] |= 0x00000001u; +} +void Datum::clear_has_channels() { + _has_bits_[0] &= ~0x00000001u; +} +void Datum::clear_channels() { + channels_ = 0; + clear_has_channels(); +} +::google::protobuf::int32 Datum::channels() const { + // @@protoc_insertion_point(field_get:caffe.Datum.channels) + return channels_; +} +void Datum::set_channels(::google::protobuf::int32 value) { + set_has_channels(); + channels_ = value; + // @@protoc_insertion_point(field_set:caffe.Datum.channels) +} + +// optional int32 height = 2; +bool Datum::has_height() const { + return (_has_bits_[0] & 0x00000002u) != 0; +} +void Datum::set_has_height() { + _has_bits_[0] |= 0x00000002u; +} +void Datum::clear_has_height() { + _has_bits_[0] &= ~0x00000002u; +} +void Datum::clear_height() { + height_ = 0; + clear_has_height(); +} +::google::protobuf::int32 Datum::height() const { + // @@protoc_insertion_point(field_get:caffe.Datum.height) + return height_; +} +void Datum::set_height(::google::protobuf::int32 value) { + set_has_height(); + height_ = value; + // @@protoc_insertion_point(field_set:caffe.Datum.height) +} + +// optional int32 width = 3; +bool Datum::has_width() const { + return (_has_bits_[0] & 0x00000004u) != 0; +} +void Datum::set_has_width() { + _has_bits_[0] |= 0x00000004u; +} +void Datum::clear_has_width() { + _has_bits_[0] &= ~0x00000004u; +} +void Datum::clear_width() { + width_ = 0; + clear_has_width(); +} +::google::protobuf::int32 Datum::width() const { + // @@protoc_insertion_point(field_get:caffe.Datum.width) + return width_; +} +void Datum::set_width(::google::protobuf::int32 value) { + set_has_width(); + width_ = value; + // @@protoc_insertion_point(field_set:caffe.Datum.width) +} + +// optional bytes data = 4; +bool Datum::has_data() const { + return (_has_bits_[0] & 0x00000008u) != 0; +} +void Datum::set_has_data() { + _has_bits_[0] |= 0x00000008u; +} +void Datum::clear_has_data() { + _has_bits_[0] &= ~0x00000008u; +} +void Datum::clear_data() { + data_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + clear_has_data(); +} +const ::std::string& Datum::data() const { + // @@protoc_insertion_point(field_get:caffe.Datum.data) + return data_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); +} +void Datum::set_data(const ::std::string& value) { + set_has_data(); + data_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); + // @@protoc_insertion_point(field_set:caffe.Datum.data) +} +void Datum::set_data(const char* value) { + set_has_data(); + data_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); + // @@protoc_insertion_point(field_set_char:caffe.Datum.data) +} +void Datum::set_data(const void* value, size_t size) { + set_has_data(); + data_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), + ::std::string(reinterpret_cast(value), size)); + // @@protoc_insertion_point(field_set_pointer:caffe.Datum.data) +} +::std::string* Datum::mutable_data() { + set_has_data(); + // @@protoc_insertion_point(field_mutable:caffe.Datum.data) + return data_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); +} +::std::string* Datum::release_data() { + // @@protoc_insertion_point(field_release:caffe.Datum.data) + clear_has_data(); + return data_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); +} +void Datum::set_allocated_data(::std::string* data) { + if (data != NULL) { + set_has_data(); + } else { + clear_has_data(); + } + data_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), data); + // @@protoc_insertion_point(field_set_allocated:caffe.Datum.data) +} + +// optional int32 label = 5; +bool Datum::has_label() const { + return (_has_bits_[0] & 0x00000010u) != 0; +} +void Datum::set_has_label() { + _has_bits_[0] |= 0x00000010u; +} +void Datum::clear_has_label() { + _has_bits_[0] &= ~0x00000010u; +} +void Datum::clear_label() { + label_ = 0; + clear_has_label(); +} +::google::protobuf::int32 Datum::label() const { + // @@protoc_insertion_point(field_get:caffe.Datum.label) + return label_; +} +void Datum::set_label(::google::protobuf::int32 value) { + set_has_label(); + label_ = value; + // @@protoc_insertion_point(field_set:caffe.Datum.label) +} + +// repeated float float_data = 6; +int Datum::float_data_size() const { + return float_data_.size(); +} +void Datum::clear_float_data() { + float_data_.Clear(); +} +float Datum::float_data(int index) const { + // @@protoc_insertion_point(field_get:caffe.Datum.float_data) + return float_data_.Get(index); +} +void Datum::set_float_data(int index, float value) { + float_data_.Set(index, value); + // @@protoc_insertion_point(field_set:caffe.Datum.float_data) +} +void Datum::add_float_data(float value) { + float_data_.Add(value); + // @@protoc_insertion_point(field_add:caffe.Datum.float_data) +} +const ::google::protobuf::RepeatedField< float >& +Datum::float_data() const { + // @@protoc_insertion_point(field_list:caffe.Datum.float_data) + return float_data_; +} +::google::protobuf::RepeatedField< float >* +Datum::mutable_float_data() { + // @@protoc_insertion_point(field_mutable_list:caffe.Datum.float_data) + return &float_data_; +} + +// optional bool encoded = 7 [default = false]; +bool Datum::has_encoded() const { + return (_has_bits_[0] & 0x00000040u) != 0; +} +void Datum::set_has_encoded() { + _has_bits_[0] |= 0x00000040u; +} +void Datum::clear_has_encoded() { + _has_bits_[0] &= ~0x00000040u; +} +void Datum::clear_encoded() { + encoded_ = false; + clear_has_encoded(); +} +bool Datum::encoded() const { + // @@protoc_insertion_point(field_get:caffe.Datum.encoded) + return encoded_; +} +void Datum::set_encoded(bool value) { + set_has_encoded(); + encoded_ = value; + // @@protoc_insertion_point(field_set:caffe.Datum.encoded) +} + +inline const Datum* Datum::internal_default_instance() { + return &Datum_default_instance_.get(); +} +#endif // PROTOBUF_INLINE_NOT_IN_HEADERS // =================================================================== @@ -5364,7 +6887,7 @@ const ::google::protobuf::EnumDescriptor* FillerParameter_VarianceNorm_descripto return FillerParameter_VarianceNorm_descriptor_; } bool FillerParameter_VarianceNorm_IsValid(int value) { - switch(value) { + switch (value) { case 0: case 1: case 2: @@ -5374,16 +6897,16 @@ bool FillerParameter_VarianceNorm_IsValid(int value) { } } -#ifndef _MSC_VER +#if !defined(_MSC_VER) || _MSC_VER >= 1900 const FillerParameter_VarianceNorm FillerParameter::FAN_IN; const FillerParameter_VarianceNorm FillerParameter::FAN_OUT; const FillerParameter_VarianceNorm FillerParameter::AVERAGE; const FillerParameter_VarianceNorm FillerParameter::VarianceNorm_MIN; const FillerParameter_VarianceNorm FillerParameter::VarianceNorm_MAX; const int FillerParameter::VarianceNorm_ARRAYSIZE; -#endif // _MSC_VER +#endif // !defined(_MSC_VER) || _MSC_VER >= 1900 ::std::string* FillerParameter::_default_type_ = NULL; -#ifndef _MSC_VER +#if !defined(_MSC_VER) || _MSC_VER >= 1900 const int FillerParameter::kTypeFieldNumber; const int FillerParameter::kValueFieldNumber; const int FillerParameter::kMinFieldNumber; @@ -5392,45 +6915,43 @@ const int FillerParameter::kMeanFieldNumber; const int FillerParameter::kStdFieldNumber; const int FillerParameter::kSparseFieldNumber; const int FillerParameter::kVarianceNormFieldNumber; -#endif // !_MSC_VER +#endif // !defined(_MSC_VER) || _MSC_VER >= 1900 FillerParameter::FillerParameter() - : ::google::protobuf::Message() { + : ::google::protobuf::Message(), _internal_metadata_(NULL) { + if (this != internal_default_instance()) protobuf_InitDefaults_caffe_2eproto(); SharedCtor(); + // @@protoc_insertion_point(constructor:caffe.FillerParameter) } void FillerParameter::InitAsDefaultInstance() { } FillerParameter::FillerParameter(const FillerParameter& from) - : ::google::protobuf::Message() { + : ::google::protobuf::Message(), + _internal_metadata_(NULL) { SharedCtor(); - MergeFrom(from); + UnsafeMergeFrom(from); + // @@protoc_insertion_point(copy_constructor:caffe.FillerParameter) } void FillerParameter::SharedCtor() { _cached_size_ = 0; - type_ = const_cast< ::std::string*>(_default_type_); - value_ = 0; - min_ = 0; + type_.UnsafeSetDefault(_default_type_); + ::memset(&value_, 0, reinterpret_cast(&variance_norm_) - + reinterpret_cast(&value_) + sizeof(variance_norm_)); + sparse_ = -1; max_ = 1; - mean_ = 0; std_ = 1; - sparse_ = -1; - variance_norm_ = 0; - ::memset(_has_bits_, 0, sizeof(_has_bits_)); } FillerParameter::~FillerParameter() { + // @@protoc_insertion_point(destructor:caffe.FillerParameter) SharedDtor(); } void FillerParameter::SharedDtor() { - if (type_ != _default_type_) { - delete type_; - } - if (this != default_instance_) { - } + type_.DestroyNoArena(_default_type_); } void FillerParameter::SetCachedSize(int size) const { @@ -5444,52 +6965,78 @@ const ::google::protobuf::Descriptor* FillerParameter::descriptor() { } const FillerParameter& FillerParameter::default_instance() { - if (default_instance_ == NULL) protobuf_AddDesc_caffe_2eproto(); - return *default_instance_; + protobuf_InitDefaults_caffe_2eproto(); + return *internal_default_instance(); } -FillerParameter* FillerParameter::default_instance_ = NULL; +::google::protobuf::internal::ExplicitlyConstructed FillerParameter_default_instance_; -FillerParameter* FillerParameter::New() const { - return new FillerParameter; +FillerParameter* FillerParameter::New(::google::protobuf::Arena* arena) const { + FillerParameter* n = new FillerParameter; + if (arena != NULL) { + arena->Own(n); + } + return n; } void FillerParameter::Clear() { - if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) { +// @@protoc_insertion_point(message_clear_start:caffe.FillerParameter) +#if defined(__clang__) +#define ZR_HELPER_(f) \ + _Pragma("clang diagnostic push") \ + _Pragma("clang diagnostic ignored \"-Winvalid-offsetof\"") \ + __builtin_offsetof(FillerParameter, f) \ + _Pragma("clang diagnostic pop") +#else +#define ZR_HELPER_(f) reinterpret_cast(\ + &reinterpret_cast(16)->f) +#endif + +#define ZR_(first, last) do {\ + ::memset(&(first), 0,\ + ZR_HELPER_(last) - ZR_HELPER_(first) + sizeof(last));\ +} while (0) + + if (_has_bits_[0 / 32] & 255u) { + ZR_(value_, variance_norm_); if (has_type()) { - if (type_ != _default_type_) { - type_->assign(*_default_type_); - } + type_.ClearToDefaultNoArena(_default_type_); } - value_ = 0; - min_ = 0; max_ = 1; - mean_ = 0; std_ = 1; sparse_ = -1; - variance_norm_ = 0; } - ::memset(_has_bits_, 0, sizeof(_has_bits_)); - mutable_unknown_fields()->Clear(); + +#undef ZR_HELPER_ +#undef ZR_ + + _has_bits_.Clear(); + if (_internal_metadata_.have_unknown_fields()) { + mutable_unknown_fields()->Clear(); + } } bool FillerParameter::MergePartialFromCodedStream( ::google::protobuf::io::CodedInputStream* input) { -#define DO_(EXPRESSION) if (!(EXPRESSION)) return false +#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure ::google::protobuf::uint32 tag; - while ((tag = input->ReadTag()) != 0) { + // @@protoc_insertion_point(parse_start:caffe.FillerParameter) + for (;;) { + ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127); + tag = p.first; + if (!p.second) goto handle_unusual; switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { // optional string type = 1 [default = "constant"]; case 1: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) { + if (tag == 10) { DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->mutable_type())); - ::google::protobuf::internal::WireFormat::VerifyUTF8String( + ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( this->type().data(), this->type().length(), - ::google::protobuf::internal::WireFormat::PARSE); + ::google::protobuf::internal::WireFormat::PARSE, + "caffe.FillerParameter.type"); } else { - goto handle_uninterpreted; + goto handle_unusual; } if (input->ExpectTag(21)) goto parse_value; break; @@ -5497,15 +7044,14 @@ bool FillerParameter::MergePartialFromCodedStream( // optional float value = 2 [default = 0]; case 2: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_FIXED32) { + if (tag == 21) { parse_value: + set_has_value(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< float, ::google::protobuf::internal::WireFormatLite::TYPE_FLOAT>( input, &value_))); - set_has_value(); } else { - goto handle_uninterpreted; + goto handle_unusual; } if (input->ExpectTag(29)) goto parse_min; break; @@ -5513,15 +7059,14 @@ bool FillerParameter::MergePartialFromCodedStream( // optional float min = 3 [default = 0]; case 3: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_FIXED32) { + if (tag == 29) { parse_min: + set_has_min(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< float, ::google::protobuf::internal::WireFormatLite::TYPE_FLOAT>( input, &min_))); - set_has_min(); } else { - goto handle_uninterpreted; + goto handle_unusual; } if (input->ExpectTag(37)) goto parse_max; break; @@ -5529,15 +7074,14 @@ bool FillerParameter::MergePartialFromCodedStream( // optional float max = 4 [default = 1]; case 4: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_FIXED32) { + if (tag == 37) { parse_max: + set_has_max(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< float, ::google::protobuf::internal::WireFormatLite::TYPE_FLOAT>( input, &max_))); - set_has_max(); } else { - goto handle_uninterpreted; + goto handle_unusual; } if (input->ExpectTag(45)) goto parse_mean; break; @@ -5545,15 +7089,14 @@ bool FillerParameter::MergePartialFromCodedStream( // optional float mean = 5 [default = 0]; case 5: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_FIXED32) { + if (tag == 45) { parse_mean: + set_has_mean(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< float, ::google::protobuf::internal::WireFormatLite::TYPE_FLOAT>( input, &mean_))); - set_has_mean(); } else { - goto handle_uninterpreted; + goto handle_unusual; } if (input->ExpectTag(53)) goto parse_std; break; @@ -5561,15 +7104,14 @@ bool FillerParameter::MergePartialFromCodedStream( // optional float std = 6 [default = 1]; case 6: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_FIXED32) { + if (tag == 53) { parse_std: + set_has_std(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< float, ::google::protobuf::internal::WireFormatLite::TYPE_FLOAT>( input, &std_))); - set_has_std(); } else { - goto handle_uninterpreted; + goto handle_unusual; } if (input->ExpectTag(56)) goto parse_sparse; break; @@ -5577,15 +7119,14 @@ bool FillerParameter::MergePartialFromCodedStream( // optional int32 sparse = 7 [default = -1]; case 7: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) { + if (tag == 56) { parse_sparse: + set_has_sparse(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>( input, &sparse_))); - set_has_sparse(); } else { - goto handle_uninterpreted; + goto handle_unusual; } if (input->ExpectTag(64)) goto parse_variance_norm; break; @@ -5593,8 +7134,7 @@ bool FillerParameter::MergePartialFromCodedStream( // optional .caffe.FillerParameter.VarianceNorm variance_norm = 8 [default = FAN_IN]; case 8: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) { + if (tag == 64) { parse_variance_norm: int value; DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< @@ -5606,17 +7146,18 @@ bool FillerParameter::MergePartialFromCodedStream( mutable_unknown_fields()->AddVarint(8, value); } } else { - goto handle_uninterpreted; + goto handle_unusual; } - if (input->ExpectAtEnd()) return true; + if (input->ExpectAtEnd()) goto success; break; } default: { - handle_uninterpreted: - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == + handle_unusual: + if (tag == 0 || + ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) { - return true; + goto success; } DO_(::google::protobuf::internal::WireFormat::SkipField( input, tag, mutable_unknown_fields())); @@ -5624,18 +7165,25 @@ bool FillerParameter::MergePartialFromCodedStream( } } } +success: + // @@protoc_insertion_point(parse_success:caffe.FillerParameter) return true; +failure: + // @@protoc_insertion_point(parse_failure:caffe.FillerParameter) + return false; #undef DO_ } void FillerParameter::SerializeWithCachedSizes( ::google::protobuf::io::CodedOutputStream* output) const { + // @@protoc_insertion_point(serialize_start:caffe.FillerParameter) // optional string type = 1 [default = "constant"]; if (has_type()) { - ::google::protobuf::internal::WireFormat::VerifyUTF8String( + ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( this->type().data(), this->type().length(), - ::google::protobuf::internal::WireFormat::SERIALIZE); - ::google::protobuf::internal::WireFormatLite::WriteString( + ::google::protobuf::internal::WireFormat::SERIALIZE, + "caffe.FillerParameter.type"); + ::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased( 1, this->type(), output); } @@ -5675,19 +7223,23 @@ void FillerParameter::SerializeWithCachedSizes( 8, this->variance_norm(), output); } - if (!unknown_fields().empty()) { + if (_internal_metadata_.have_unknown_fields()) { ::google::protobuf::internal::WireFormat::SerializeUnknownFields( unknown_fields(), output); } + // @@protoc_insertion_point(serialize_end:caffe.FillerParameter) } -::google::protobuf::uint8* FillerParameter::SerializeWithCachedSizesToArray( - ::google::protobuf::uint8* target) const { +::google::protobuf::uint8* FillerParameter::InternalSerializeWithCachedSizesToArray( + bool deterministic, ::google::protobuf::uint8* target) const { + (void)deterministic; // Unused + // @@protoc_insertion_point(serialize_to_array_start:caffe.FillerParameter) // optional string type = 1 [default = "constant"]; if (has_type()) { - ::google::protobuf::internal::WireFormat::VerifyUTF8String( + ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( this->type().data(), this->type().length(), - ::google::protobuf::internal::WireFormat::SERIALIZE); + ::google::protobuf::internal::WireFormat::SERIALIZE, + "caffe.FillerParameter.type"); target = ::google::protobuf::internal::WireFormatLite::WriteStringToArray( 1, this->type(), target); @@ -5729,17 +7281,19 @@ void FillerParameter::SerializeWithCachedSizes( 8, this->variance_norm(), target); } - if (!unknown_fields().empty()) { + if (_internal_metadata_.have_unknown_fields()) { target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray( unknown_fields(), target); } + // @@protoc_insertion_point(serialize_to_array_end:caffe.FillerParameter) return target; } -int FillerParameter::ByteSize() const { - int total_size = 0; +size_t FillerParameter::ByteSizeLong() const { +// @@protoc_insertion_point(message_byte_size_start:caffe.FillerParameter) + size_t total_size = 0; - if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) { + if (_has_bits_[0 / 32] & 255u) { // optional string type = 1 [default = "constant"]; if (has_type()) { total_size += 1 + @@ -5786,34 +7340,48 @@ int FillerParameter::ByteSize() const { } } - if (!unknown_fields().empty()) { + if (_internal_metadata_.have_unknown_fields()) { total_size += ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( unknown_fields()); } + int cached_size = ::google::protobuf::internal::ToCachedSize(total_size); GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); - _cached_size_ = total_size; + _cached_size_ = cached_size; GOOGLE_SAFE_CONCURRENT_WRITES_END(); return total_size; } void FillerParameter::MergeFrom(const ::google::protobuf::Message& from) { - GOOGLE_CHECK_NE(&from, this); +// @@protoc_insertion_point(generalized_merge_from_start:caffe.FillerParameter) + if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__); const FillerParameter* source = - ::google::protobuf::internal::dynamic_cast_if_available( - &from); + ::google::protobuf::internal::DynamicCastToGenerated( + &from); if (source == NULL) { + // @@protoc_insertion_point(generalized_merge_from_cast_fail:caffe.FillerParameter) ::google::protobuf::internal::ReflectionOps::Merge(from, this); } else { - MergeFrom(*source); + // @@protoc_insertion_point(generalized_merge_from_cast_success:caffe.FillerParameter) + UnsafeMergeFrom(*source); } } void FillerParameter::MergeFrom(const FillerParameter& from) { - GOOGLE_CHECK_NE(&from, this); +// @@protoc_insertion_point(class_specific_merge_from_start:caffe.FillerParameter) + if (GOOGLE_PREDICT_TRUE(&from != this)) { + UnsafeMergeFrom(from); + } else { + MergeFromFail(__LINE__); + } +} + +void FillerParameter::UnsafeMergeFrom(const FillerParameter& from) { + GOOGLE_DCHECK(&from != this); if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) { if (from.has_type()) { - set_type(from.type()); + set_has_type(); + type_.AssignWithDefault(_default_type_, from.type_); } if (from.has_value()) { set_value(from.value()); @@ -5837,19 +7405,24 @@ void FillerParameter::MergeFrom(const FillerParameter& from) { set_variance_norm(from.variance_norm()); } } - mutable_unknown_fields()->MergeFrom(from.unknown_fields()); + if (from._internal_metadata_.have_unknown_fields()) { + ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata( + from.unknown_fields(), &_internal_metadata_); + } } void FillerParameter::CopyFrom(const ::google::protobuf::Message& from) { +// @@protoc_insertion_point(generalized_copy_from_start:caffe.FillerParameter) if (&from == this) return; Clear(); MergeFrom(from); } void FillerParameter::CopyFrom(const FillerParameter& from) { +// @@protoc_insertion_point(class_specific_copy_from_start:caffe.FillerParameter) if (&from == this) return; Clear(); - MergeFrom(from); + UnsafeMergeFrom(from); } bool FillerParameter::IsInitialized() const { @@ -5858,19 +7431,21 @@ bool FillerParameter::IsInitialized() const { } void FillerParameter::Swap(FillerParameter* other) { - if (other != this) { - std::swap(type_, other->type_); - std::swap(value_, other->value_); - std::swap(min_, other->min_); - std::swap(max_, other->max_); - std::swap(mean_, other->mean_); - std::swap(std_, other->std_); - std::swap(sparse_, other->sparse_); - std::swap(variance_norm_, other->variance_norm_); - std::swap(_has_bits_[0], other->_has_bits_[0]); - _unknown_fields_.Swap(&other->_unknown_fields_); - std::swap(_cached_size_, other->_cached_size_); - } + if (other == this) return; + InternalSwap(other); +} +void FillerParameter::InternalSwap(FillerParameter* other) { + type_.Swap(&other->type_); + std::swap(value_, other->value_); + std::swap(min_, other->min_); + std::swap(max_, other->max_); + std::swap(mean_, other->mean_); + std::swap(std_, other->std_); + std::swap(sparse_, other->sparse_); + std::swap(variance_norm_, other->variance_norm_); + std::swap(_has_bits_[0], other->_has_bits_[0]); + _internal_metadata_.Swap(&other->_internal_metadata_); + std::swap(_cached_size_, other->_cached_size_); } ::google::protobuf::Metadata FillerParameter::GetMetadata() const { @@ -5881,58 +7456,291 @@ void FillerParameter::Swap(FillerParameter* other) { return metadata; } +#if PROTOBUF_INLINE_NOT_IN_HEADERS +// FillerParameter -// =================================================================== - -#ifndef _MSC_VER -const int NetParameter::kNameFieldNumber; -const int NetParameter::kInputFieldNumber; -const int NetParameter::kInputShapeFieldNumber; -const int NetParameter::kInputDimFieldNumber; -const int NetParameter::kForceBackwardFieldNumber; -const int NetParameter::kStateFieldNumber; -const int NetParameter::kDebugInfoFieldNumber; -const int NetParameter::kLayerFieldNumber; -const int NetParameter::kLayersFieldNumber; -#endif // !_MSC_VER - -NetParameter::NetParameter() - : ::google::protobuf::Message() { - SharedCtor(); +// optional string type = 1 [default = "constant"]; +bool FillerParameter::has_type() const { + return (_has_bits_[0] & 0x00000001u) != 0; } - -void NetParameter::InitAsDefaultInstance() { - state_ = const_cast< ::caffe::NetState*>(&::caffe::NetState::default_instance()); +void FillerParameter::set_has_type() { + _has_bits_[0] |= 0x00000001u; } - -NetParameter::NetParameter(const NetParameter& from) - : ::google::protobuf::Message() { - SharedCtor(); - MergeFrom(from); +void FillerParameter::clear_has_type() { + _has_bits_[0] &= ~0x00000001u; } - -void NetParameter::SharedCtor() { - _cached_size_ = 0; - name_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); - force_backward_ = false; - state_ = NULL; - debug_info_ = false; - ::memset(_has_bits_, 0, sizeof(_has_bits_)); +void FillerParameter::clear_type() { + type_.ClearToDefaultNoArena(_default_type_); + clear_has_type(); } - -NetParameter::~NetParameter() { - SharedDtor(); +const ::std::string& FillerParameter::type() const { + // @@protoc_insertion_point(field_get:caffe.FillerParameter.type) + return type_.GetNoArena(_default_type_); } - -void NetParameter::SharedDtor() { - if (name_ != &::google::protobuf::internal::kEmptyString) { - delete name_; - } - if (this != default_instance_) { - delete state_; - } +void FillerParameter::set_type(const ::std::string& value) { + set_has_type(); + type_.SetNoArena(_default_type_, value); + // @@protoc_insertion_point(field_set:caffe.FillerParameter.type) } - +void FillerParameter::set_type(const char* value) { + set_has_type(); + type_.SetNoArena(_default_type_, ::std::string(value)); + // @@protoc_insertion_point(field_set_char:caffe.FillerParameter.type) +} +void FillerParameter::set_type(const char* value, size_t size) { + set_has_type(); + type_.SetNoArena(_default_type_, + ::std::string(reinterpret_cast(value), size)); + // @@protoc_insertion_point(field_set_pointer:caffe.FillerParameter.type) +} +::std::string* FillerParameter::mutable_type() { + set_has_type(); + // @@protoc_insertion_point(field_mutable:caffe.FillerParameter.type) + return type_.MutableNoArena(_default_type_); +} +::std::string* FillerParameter::release_type() { + // @@protoc_insertion_point(field_release:caffe.FillerParameter.type) + clear_has_type(); + return type_.ReleaseNoArena(_default_type_); +} +void FillerParameter::set_allocated_type(::std::string* type) { + if (type != NULL) { + set_has_type(); + } else { + clear_has_type(); + } + type_.SetAllocatedNoArena(_default_type_, type); + // @@protoc_insertion_point(field_set_allocated:caffe.FillerParameter.type) +} + +// optional float value = 2 [default = 0]; +bool FillerParameter::has_value() const { + return (_has_bits_[0] & 0x00000002u) != 0; +} +void FillerParameter::set_has_value() { + _has_bits_[0] |= 0x00000002u; +} +void FillerParameter::clear_has_value() { + _has_bits_[0] &= ~0x00000002u; +} +void FillerParameter::clear_value() { + value_ = 0; + clear_has_value(); +} +float FillerParameter::value() const { + // @@protoc_insertion_point(field_get:caffe.FillerParameter.value) + return value_; +} +void FillerParameter::set_value(float value) { + set_has_value(); + value_ = value; + // @@protoc_insertion_point(field_set:caffe.FillerParameter.value) +} + +// optional float min = 3 [default = 0]; +bool FillerParameter::has_min() const { + return (_has_bits_[0] & 0x00000004u) != 0; +} +void FillerParameter::set_has_min() { + _has_bits_[0] |= 0x00000004u; +} +void FillerParameter::clear_has_min() { + _has_bits_[0] &= ~0x00000004u; +} +void FillerParameter::clear_min() { + min_ = 0; + clear_has_min(); +} +float FillerParameter::min() const { + // @@protoc_insertion_point(field_get:caffe.FillerParameter.min) + return min_; +} +void FillerParameter::set_min(float value) { + set_has_min(); + min_ = value; + // @@protoc_insertion_point(field_set:caffe.FillerParameter.min) +} + +// optional float max = 4 [default = 1]; +bool FillerParameter::has_max() const { + return (_has_bits_[0] & 0x00000008u) != 0; +} +void FillerParameter::set_has_max() { + _has_bits_[0] |= 0x00000008u; +} +void FillerParameter::clear_has_max() { + _has_bits_[0] &= ~0x00000008u; +} +void FillerParameter::clear_max() { + max_ = 1; + clear_has_max(); +} +float FillerParameter::max() const { + // @@protoc_insertion_point(field_get:caffe.FillerParameter.max) + return max_; +} +void FillerParameter::set_max(float value) { + set_has_max(); + max_ = value; + // @@protoc_insertion_point(field_set:caffe.FillerParameter.max) +} + +// optional float mean = 5 [default = 0]; +bool FillerParameter::has_mean() const { + return (_has_bits_[0] & 0x00000010u) != 0; +} +void FillerParameter::set_has_mean() { + _has_bits_[0] |= 0x00000010u; +} +void FillerParameter::clear_has_mean() { + _has_bits_[0] &= ~0x00000010u; +} +void FillerParameter::clear_mean() { + mean_ = 0; + clear_has_mean(); +} +float FillerParameter::mean() const { + // @@protoc_insertion_point(field_get:caffe.FillerParameter.mean) + return mean_; +} +void FillerParameter::set_mean(float value) { + set_has_mean(); + mean_ = value; + // @@protoc_insertion_point(field_set:caffe.FillerParameter.mean) +} + +// optional float std = 6 [default = 1]; +bool FillerParameter::has_std() const { + return (_has_bits_[0] & 0x00000020u) != 0; +} +void FillerParameter::set_has_std() { + _has_bits_[0] |= 0x00000020u; +} +void FillerParameter::clear_has_std() { + _has_bits_[0] &= ~0x00000020u; +} +void FillerParameter::clear_std() { + std_ = 1; + clear_has_std(); +} +float FillerParameter::std() const { + // @@protoc_insertion_point(field_get:caffe.FillerParameter.std) + return std_; +} +void FillerParameter::set_std(float value) { + set_has_std(); + std_ = value; + // @@protoc_insertion_point(field_set:caffe.FillerParameter.std) +} + +// optional int32 sparse = 7 [default = -1]; +bool FillerParameter::has_sparse() const { + return (_has_bits_[0] & 0x00000040u) != 0; +} +void FillerParameter::set_has_sparse() { + _has_bits_[0] |= 0x00000040u; +} +void FillerParameter::clear_has_sparse() { + _has_bits_[0] &= ~0x00000040u; +} +void FillerParameter::clear_sparse() { + sparse_ = -1; + clear_has_sparse(); +} +::google::protobuf::int32 FillerParameter::sparse() const { + // @@protoc_insertion_point(field_get:caffe.FillerParameter.sparse) + return sparse_; +} +void FillerParameter::set_sparse(::google::protobuf::int32 value) { + set_has_sparse(); + sparse_ = value; + // @@protoc_insertion_point(field_set:caffe.FillerParameter.sparse) +} + +// optional .caffe.FillerParameter.VarianceNorm variance_norm = 8 [default = FAN_IN]; +bool FillerParameter::has_variance_norm() const { + return (_has_bits_[0] & 0x00000080u) != 0; +} +void FillerParameter::set_has_variance_norm() { + _has_bits_[0] |= 0x00000080u; +} +void FillerParameter::clear_has_variance_norm() { + _has_bits_[0] &= ~0x00000080u; +} +void FillerParameter::clear_variance_norm() { + variance_norm_ = 0; + clear_has_variance_norm(); +} +::caffe::FillerParameter_VarianceNorm FillerParameter::variance_norm() const { + // @@protoc_insertion_point(field_get:caffe.FillerParameter.variance_norm) + return static_cast< ::caffe::FillerParameter_VarianceNorm >(variance_norm_); +} +void FillerParameter::set_variance_norm(::caffe::FillerParameter_VarianceNorm value) { + assert(::caffe::FillerParameter_VarianceNorm_IsValid(value)); + set_has_variance_norm(); + variance_norm_ = value; + // @@protoc_insertion_point(field_set:caffe.FillerParameter.variance_norm) +} + +inline const FillerParameter* FillerParameter::internal_default_instance() { + return &FillerParameter_default_instance_.get(); +} +#endif // PROTOBUF_INLINE_NOT_IN_HEADERS + +// =================================================================== + +#if !defined(_MSC_VER) || _MSC_VER >= 1900 +const int NetParameter::kNameFieldNumber; +const int NetParameter::kInputFieldNumber; +const int NetParameter::kInputShapeFieldNumber; +const int NetParameter::kInputDimFieldNumber; +const int NetParameter::kForceBackwardFieldNumber; +const int NetParameter::kStateFieldNumber; +const int NetParameter::kDebugInfoFieldNumber; +const int NetParameter::kLayerFieldNumber; +const int NetParameter::kLayersFieldNumber; +#endif // !defined(_MSC_VER) || _MSC_VER >= 1900 + +NetParameter::NetParameter() + : ::google::protobuf::Message(), _internal_metadata_(NULL) { + if (this != internal_default_instance()) protobuf_InitDefaults_caffe_2eproto(); + SharedCtor(); + // @@protoc_insertion_point(constructor:caffe.NetParameter) +} + +void NetParameter::InitAsDefaultInstance() { + state_ = const_cast< ::caffe::NetState*>( + ::caffe::NetState::internal_default_instance()); +} + +NetParameter::NetParameter(const NetParameter& from) + : ::google::protobuf::Message(), + _internal_metadata_(NULL) { + SharedCtor(); + UnsafeMergeFrom(from); + // @@protoc_insertion_point(copy_constructor:caffe.NetParameter) +} + +void NetParameter::SharedCtor() { + _cached_size_ = 0; + name_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + state_ = NULL; + ::memset(&force_backward_, 0, reinterpret_cast(&debug_info_) - + reinterpret_cast(&force_backward_) + sizeof(debug_info_)); +} + +NetParameter::~NetParameter() { + // @@protoc_insertion_point(destructor:caffe.NetParameter) + SharedDtor(); +} + +void NetParameter::SharedDtor() { + name_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + if (this != &NetParameter_default_instance_.get()) { + delete state_; + } +} + void NetParameter::SetCachedSize(int size) const { GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); _cached_size_ = size; @@ -5944,55 +7752,83 @@ const ::google::protobuf::Descriptor* NetParameter::descriptor() { } const NetParameter& NetParameter::default_instance() { - if (default_instance_ == NULL) protobuf_AddDesc_caffe_2eproto(); - return *default_instance_; + protobuf_InitDefaults_caffe_2eproto(); + return *internal_default_instance(); } -NetParameter* NetParameter::default_instance_ = NULL; +::google::protobuf::internal::ExplicitlyConstructed NetParameter_default_instance_; -NetParameter* NetParameter::New() const { - return new NetParameter; +NetParameter* NetParameter::New(::google::protobuf::Arena* arena) const { + NetParameter* n = new NetParameter; + if (arena != NULL) { + arena->Own(n); + } + return n; } void NetParameter::Clear() { - if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) { +// @@protoc_insertion_point(message_clear_start:caffe.NetParameter) +#if defined(__clang__) +#define ZR_HELPER_(f) \ + _Pragma("clang diagnostic push") \ + _Pragma("clang diagnostic ignored \"-Winvalid-offsetof\"") \ + __builtin_offsetof(NetParameter, f) \ + _Pragma("clang diagnostic pop") +#else +#define ZR_HELPER_(f) reinterpret_cast(\ + &reinterpret_cast(16)->f) +#endif + +#define ZR_(first, last) do {\ + ::memset(&(first), 0,\ + ZR_HELPER_(last) - ZR_HELPER_(first) + sizeof(last));\ +} while (0) + + if (_has_bits_[0 / 32] & 113u) { + ZR_(force_backward_, debug_info_); if (has_name()) { - if (name_ != &::google::protobuf::internal::kEmptyString) { - name_->clear(); - } + name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - force_backward_ = false; if (has_state()) { if (state_ != NULL) state_->::caffe::NetState::Clear(); } - debug_info_ = false; } + +#undef ZR_HELPER_ +#undef ZR_ + input_.Clear(); input_shape_.Clear(); input_dim_.Clear(); layer_.Clear(); layers_.Clear(); - ::memset(_has_bits_, 0, sizeof(_has_bits_)); - mutable_unknown_fields()->Clear(); + _has_bits_.Clear(); + if (_internal_metadata_.have_unknown_fields()) { + mutable_unknown_fields()->Clear(); + } } bool NetParameter::MergePartialFromCodedStream( ::google::protobuf::io::CodedInputStream* input) { -#define DO_(EXPRESSION) if (!(EXPRESSION)) return false +#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure ::google::protobuf::uint32 tag; - while ((tag = input->ReadTag()) != 0) { + // @@protoc_insertion_point(parse_start:caffe.NetParameter) + for (;;) { + ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(16383); + tag = p.first; + if (!p.second) goto handle_unusual; switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { // optional string name = 1; case 1: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) { + if (tag == 10) { DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->mutable_name())); - ::google::protobuf::internal::WireFormat::VerifyUTF8String( + ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( this->name().data(), this->name().length(), - ::google::protobuf::internal::WireFormat::PARSE); + ::google::protobuf::internal::WireFormat::PARSE, + "caffe.NetParameter.name"); } else { - goto handle_uninterpreted; + goto handle_unusual; } if (input->ExpectTag(18)) goto parse_layers; break; @@ -6000,32 +7836,34 @@ bool NetParameter::MergePartialFromCodedStream( // repeated .caffe.V1LayerParameter layers = 2; case 2: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) { + if (tag == 18) { parse_layers: - DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual( + DO_(input->IncrementRecursionDepth()); + parse_loop_layers: + DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtualNoRecursionDepth( input, add_layers())); } else { - goto handle_uninterpreted; + goto handle_unusual; } - if (input->ExpectTag(18)) goto parse_layers; + if (input->ExpectTag(18)) goto parse_loop_layers; + input->UnsafeDecrementRecursionDepth(); if (input->ExpectTag(26)) goto parse_input; break; } // repeated string input = 3; case 3: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) { + if (tag == 26) { parse_input: DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->add_input())); - ::google::protobuf::internal::WireFormat::VerifyUTF8String( + ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( this->input(this->input_size() - 1).data(), this->input(this->input_size() - 1).length(), - ::google::protobuf::internal::WireFormat::PARSE); + ::google::protobuf::internal::WireFormat::PARSE, + "caffe.NetParameter.input"); } else { - goto handle_uninterpreted; + goto handle_unusual; } if (input->ExpectTag(26)) goto parse_input; if (input->ExpectTag(32)) goto parse_input_dim; @@ -6034,20 +7872,17 @@ bool NetParameter::MergePartialFromCodedStream( // repeated int32 input_dim = 4; case 4: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) { + if (tag == 32) { parse_input_dim: DO_((::google::protobuf::internal::WireFormatLite::ReadRepeatedPrimitive< ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>( 1, 32, input, this->mutable_input_dim()))); - } else if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) - == ::google::protobuf::internal::WireFormatLite:: - WIRETYPE_LENGTH_DELIMITED) { + } else if (tag == 34) { DO_((::google::protobuf::internal::WireFormatLite::ReadPackedPrimitiveNoInline< ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>( input, this->mutable_input_dim()))); } else { - goto handle_uninterpreted; + goto handle_unusual; } if (input->ExpectTag(32)) goto parse_input_dim; if (input->ExpectTag(40)) goto parse_force_backward; @@ -6056,15 +7891,14 @@ bool NetParameter::MergePartialFromCodedStream( // optional bool force_backward = 5 [default = false]; case 5: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) { + if (tag == 40) { parse_force_backward: + set_has_force_backward(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>( input, &force_backward_))); - set_has_force_backward(); } else { - goto handle_uninterpreted; + goto handle_unusual; } if (input->ExpectTag(50)) goto parse_state; break; @@ -6072,13 +7906,12 @@ bool NetParameter::MergePartialFromCodedStream( // optional .caffe.NetState state = 6; case 6: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) { + if (tag == 50) { parse_state: DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual( input, mutable_state())); } else { - goto handle_uninterpreted; + goto handle_unusual; } if (input->ExpectTag(56)) goto parse_debug_info; break; @@ -6086,15 +7919,14 @@ bool NetParameter::MergePartialFromCodedStream( // optional bool debug_info = 7 [default = false]; case 7: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) { + if (tag == 56) { parse_debug_info: + set_has_debug_info(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>( input, &debug_info_))); - set_has_debug_info(); } else { - goto handle_uninterpreted; + goto handle_unusual; } if (input->ExpectTag(66)) goto parse_input_shape; break; @@ -6102,39 +7934,43 @@ bool NetParameter::MergePartialFromCodedStream( // repeated .caffe.BlobShape input_shape = 8; case 8: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) { + if (tag == 66) { parse_input_shape: - DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual( + DO_(input->IncrementRecursionDepth()); + parse_loop_input_shape: + DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtualNoRecursionDepth( input, add_input_shape())); } else { - goto handle_uninterpreted; + goto handle_unusual; } - if (input->ExpectTag(66)) goto parse_input_shape; - if (input->ExpectTag(802)) goto parse_layer; + if (input->ExpectTag(66)) goto parse_loop_input_shape; + if (input->ExpectTag(802)) goto parse_loop_layer; + input->UnsafeDecrementRecursionDepth(); break; } // repeated .caffe.LayerParameter layer = 100; case 100: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) { - parse_layer: - DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual( + if (tag == 802) { + DO_(input->IncrementRecursionDepth()); + parse_loop_layer: + DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtualNoRecursionDepth( input, add_layer())); } else { - goto handle_uninterpreted; + goto handle_unusual; } - if (input->ExpectTag(802)) goto parse_layer; - if (input->ExpectAtEnd()) return true; + if (input->ExpectTag(802)) goto parse_loop_layer; + input->UnsafeDecrementRecursionDepth(); + if (input->ExpectAtEnd()) goto success; break; } default: { - handle_uninterpreted: - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == + handle_unusual: + if (tag == 0 || + ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) { - return true; + goto success; } DO_(::google::protobuf::internal::WireFormat::SkipField( input, tag, mutable_unknown_fields())); @@ -6142,32 +7978,40 @@ bool NetParameter::MergePartialFromCodedStream( } } } +success: + // @@protoc_insertion_point(parse_success:caffe.NetParameter) return true; +failure: + // @@protoc_insertion_point(parse_failure:caffe.NetParameter) + return false; #undef DO_ } void NetParameter::SerializeWithCachedSizes( ::google::protobuf::io::CodedOutputStream* output) const { + // @@protoc_insertion_point(serialize_start:caffe.NetParameter) // optional string name = 1; if (has_name()) { - ::google::protobuf::internal::WireFormat::VerifyUTF8String( + ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( this->name().data(), this->name().length(), - ::google::protobuf::internal::WireFormat::SERIALIZE); - ::google::protobuf::internal::WireFormatLite::WriteString( + ::google::protobuf::internal::WireFormat::SERIALIZE, + "caffe.NetParameter.name"); + ::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased( 1, this->name(), output); } // repeated .caffe.V1LayerParameter layers = 2; - for (int i = 0; i < this->layers_size(); i++) { + for (unsigned int i = 0, n = this->layers_size(); i < n; i++) { ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( 2, this->layers(i), output); } // repeated string input = 3; for (int i = 0; i < this->input_size(); i++) { - ::google::protobuf::internal::WireFormat::VerifyUTF8String( - this->input(i).data(), this->input(i).length(), - ::google::protobuf::internal::WireFormat::SERIALIZE); + ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( + this->input(i).data(), this->input(i).length(), + ::google::protobuf::internal::WireFormat::SERIALIZE, + "caffe.NetParameter.input"); ::google::protobuf::internal::WireFormatLite::WriteString( 3, this->input(i), output); } @@ -6186,7 +8030,7 @@ void NetParameter::SerializeWithCachedSizes( // optional .caffe.NetState state = 6; if (has_state()) { ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( - 6, this->state(), output); + 6, *this->state_, output); } // optional bool debug_info = 7 [default = false]; @@ -6195,47 +8039,52 @@ void NetParameter::SerializeWithCachedSizes( } // repeated .caffe.BlobShape input_shape = 8; - for (int i = 0; i < this->input_shape_size(); i++) { + for (unsigned int i = 0, n = this->input_shape_size(); i < n; i++) { ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( 8, this->input_shape(i), output); } // repeated .caffe.LayerParameter layer = 100; - for (int i = 0; i < this->layer_size(); i++) { + for (unsigned int i = 0, n = this->layer_size(); i < n; i++) { ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( 100, this->layer(i), output); } - if (!unknown_fields().empty()) { + if (_internal_metadata_.have_unknown_fields()) { ::google::protobuf::internal::WireFormat::SerializeUnknownFields( unknown_fields(), output); } + // @@protoc_insertion_point(serialize_end:caffe.NetParameter) } -::google::protobuf::uint8* NetParameter::SerializeWithCachedSizesToArray( - ::google::protobuf::uint8* target) const { +::google::protobuf::uint8* NetParameter::InternalSerializeWithCachedSizesToArray( + bool deterministic, ::google::protobuf::uint8* target) const { + (void)deterministic; // Unused + // @@protoc_insertion_point(serialize_to_array_start:caffe.NetParameter) // optional string name = 1; if (has_name()) { - ::google::protobuf::internal::WireFormat::VerifyUTF8String( + ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( this->name().data(), this->name().length(), - ::google::protobuf::internal::WireFormat::SERIALIZE); + ::google::protobuf::internal::WireFormat::SERIALIZE, + "caffe.NetParameter.name"); target = ::google::protobuf::internal::WireFormatLite::WriteStringToArray( 1, this->name(), target); } // repeated .caffe.V1LayerParameter layers = 2; - for (int i = 0; i < this->layers_size(); i++) { + for (unsigned int i = 0, n = this->layers_size(); i < n; i++) { target = ::google::protobuf::internal::WireFormatLite:: - WriteMessageNoVirtualToArray( - 2, this->layers(i), target); + InternalWriteMessageNoVirtualToArray( + 2, this->layers(i), false, target); } // repeated string input = 3; for (int i = 0; i < this->input_size(); i++) { - ::google::protobuf::internal::WireFormat::VerifyUTF8String( + ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( this->input(i).data(), this->input(i).length(), - ::google::protobuf::internal::WireFormat::SERIALIZE); + ::google::protobuf::internal::WireFormat::SERIALIZE, + "caffe.NetParameter.input"); target = ::google::protobuf::internal::WireFormatLite:: WriteStringToArray(3, this->input(i), target); } @@ -6254,8 +8103,8 @@ void NetParameter::SerializeWithCachedSizes( // optional .caffe.NetState state = 6; if (has_state()) { target = ::google::protobuf::internal::WireFormatLite:: - WriteMessageNoVirtualToArray( - 6, this->state(), target); + InternalWriteMessageNoVirtualToArray( + 6, *this->state_, false, target); } // optional bool debug_info = 7 [default = false]; @@ -6264,30 +8113,32 @@ void NetParameter::SerializeWithCachedSizes( } // repeated .caffe.BlobShape input_shape = 8; - for (int i = 0; i < this->input_shape_size(); i++) { + for (unsigned int i = 0, n = this->input_shape_size(); i < n; i++) { target = ::google::protobuf::internal::WireFormatLite:: - WriteMessageNoVirtualToArray( - 8, this->input_shape(i), target); + InternalWriteMessageNoVirtualToArray( + 8, this->input_shape(i), false, target); } // repeated .caffe.LayerParameter layer = 100; - for (int i = 0; i < this->layer_size(); i++) { + for (unsigned int i = 0, n = this->layer_size(); i < n; i++) { target = ::google::protobuf::internal::WireFormatLite:: - WriteMessageNoVirtualToArray( - 100, this->layer(i), target); + InternalWriteMessageNoVirtualToArray( + 100, this->layer(i), false, target); } - if (!unknown_fields().empty()) { + if (_internal_metadata_.have_unknown_fields()) { target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray( unknown_fields(), target); } + // @@protoc_insertion_point(serialize_to_array_end:caffe.NetParameter) return target; } -int NetParameter::ByteSize() const { - int total_size = 0; +size_t NetParameter::ByteSizeLong() const { +// @@protoc_insertion_point(message_byte_size_start:caffe.NetParameter) + size_t total_size = 0; - if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) { + if (_has_bits_[0 / 32] & 113u) { // optional string name = 1; if (has_name()) { total_size += 1 + @@ -6304,7 +8155,7 @@ int NetParameter::ByteSize() const { if (has_state()) { total_size += 1 + ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( - this->state()); + *this->state_); } // optional bool debug_info = 7 [default = false]; @@ -6314,79 +8165,106 @@ int NetParameter::ByteSize() const { } // repeated string input = 3; - total_size += 1 * this->input_size(); + total_size += 1 * + ::google::protobuf::internal::FromIntSize(this->input_size()); for (int i = 0; i < this->input_size(); i++) { total_size += ::google::protobuf::internal::WireFormatLite::StringSize( this->input(i)); } // repeated .caffe.BlobShape input_shape = 8; - total_size += 1 * this->input_shape_size(); - for (int i = 0; i < this->input_shape_size(); i++) { - total_size += - ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( - this->input_shape(i)); + { + unsigned int count = this->input_shape_size(); + total_size += 1UL * count; + for (unsigned int i = 0; i < count; i++) { + total_size += + ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( + this->input_shape(i)); + } } // repeated int32 input_dim = 4; { - int data_size = 0; - for (int i = 0; i < this->input_dim_size(); i++) { + size_t data_size = 0; + unsigned int count = this->input_dim_size(); + for (unsigned int i = 0; i < count; i++) { data_size += ::google::protobuf::internal::WireFormatLite:: Int32Size(this->input_dim(i)); } - total_size += 1 * this->input_dim_size() + data_size; + total_size += 1 * + ::google::protobuf::internal::FromIntSize(this->input_dim_size()); + total_size += data_size; } // repeated .caffe.LayerParameter layer = 100; - total_size += 2 * this->layer_size(); - for (int i = 0; i < this->layer_size(); i++) { - total_size += - ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( - this->layer(i)); + { + unsigned int count = this->layer_size(); + total_size += 2UL * count; + for (unsigned int i = 0; i < count; i++) { + total_size += + ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( + this->layer(i)); + } } // repeated .caffe.V1LayerParameter layers = 2; - total_size += 1 * this->layers_size(); - for (int i = 0; i < this->layers_size(); i++) { - total_size += - ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( - this->layers(i)); + { + unsigned int count = this->layers_size(); + total_size += 1UL * count; + for (unsigned int i = 0; i < count; i++) { + total_size += + ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( + this->layers(i)); + } } - if (!unknown_fields().empty()) { + if (_internal_metadata_.have_unknown_fields()) { total_size += ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( unknown_fields()); } + int cached_size = ::google::protobuf::internal::ToCachedSize(total_size); GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); - _cached_size_ = total_size; + _cached_size_ = cached_size; GOOGLE_SAFE_CONCURRENT_WRITES_END(); return total_size; } void NetParameter::MergeFrom(const ::google::protobuf::Message& from) { - GOOGLE_CHECK_NE(&from, this); +// @@protoc_insertion_point(generalized_merge_from_start:caffe.NetParameter) + if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__); const NetParameter* source = - ::google::protobuf::internal::dynamic_cast_if_available( - &from); + ::google::protobuf::internal::DynamicCastToGenerated( + &from); if (source == NULL) { + // @@protoc_insertion_point(generalized_merge_from_cast_fail:caffe.NetParameter) ::google::protobuf::internal::ReflectionOps::Merge(from, this); } else { - MergeFrom(*source); + // @@protoc_insertion_point(generalized_merge_from_cast_success:caffe.NetParameter) + UnsafeMergeFrom(*source); } } void NetParameter::MergeFrom(const NetParameter& from) { - GOOGLE_CHECK_NE(&from, this); - input_.MergeFrom(from.input_); +// @@protoc_insertion_point(class_specific_merge_from_start:caffe.NetParameter) + if (GOOGLE_PREDICT_TRUE(&from != this)) { + UnsafeMergeFrom(from); + } else { + MergeFromFail(__LINE__); + } +} + +void NetParameter::UnsafeMergeFrom(const NetParameter& from) { + GOOGLE_DCHECK(&from != this); + input_.UnsafeMergeFrom(from.input_); input_shape_.MergeFrom(from.input_shape_); - input_dim_.MergeFrom(from.input_dim_); + input_dim_.UnsafeMergeFrom(from.input_dim_); layer_.MergeFrom(from.layer_); layers_.MergeFrom(from.layers_); if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) { if (from.has_name()) { - set_name(from.name()); + set_has_name(); + name_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.name_); } if (from.has_force_backward()) { set_force_backward(from.force_backward()); @@ -6398,19 +8276,24 @@ void NetParameter::MergeFrom(const NetParameter& from) { set_debug_info(from.debug_info()); } } - mutable_unknown_fields()->MergeFrom(from.unknown_fields()); + if (from._internal_metadata_.have_unknown_fields()) { + ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata( + from.unknown_fields(), &_internal_metadata_); + } } void NetParameter::CopyFrom(const ::google::protobuf::Message& from) { +// @@protoc_insertion_point(generalized_copy_from_start:caffe.NetParameter) if (&from == this) return; Clear(); MergeFrom(from); } void NetParameter::CopyFrom(const NetParameter& from) { +// @@protoc_insertion_point(class_specific_copy_from_start:caffe.NetParameter) if (&from == this) return; Clear(); - MergeFrom(from); + UnsafeMergeFrom(from); } bool NetParameter::IsInitialized() const { @@ -6419,20 +8302,22 @@ bool NetParameter::IsInitialized() const { } void NetParameter::Swap(NetParameter* other) { - if (other != this) { - std::swap(name_, other->name_); - input_.Swap(&other->input_); - input_shape_.Swap(&other->input_shape_); - input_dim_.Swap(&other->input_dim_); - std::swap(force_backward_, other->force_backward_); - std::swap(state_, other->state_); - std::swap(debug_info_, other->debug_info_); - layer_.Swap(&other->layer_); - layers_.Swap(&other->layers_); - std::swap(_has_bits_[0], other->_has_bits_[0]); - _unknown_fields_.Swap(&other->_unknown_fields_); - std::swap(_cached_size_, other->_cached_size_); - } + if (other == this) return; + InternalSwap(other); +} +void NetParameter::InternalSwap(NetParameter* other) { + name_.Swap(&other->name_); + input_.UnsafeArenaSwap(&other->input_); + input_shape_.UnsafeArenaSwap(&other->input_shape_); + input_dim_.UnsafeArenaSwap(&other->input_dim_); + std::swap(force_backward_, other->force_backward_); + std::swap(state_, other->state_); + std::swap(debug_info_, other->debug_info_); + layer_.UnsafeArenaSwap(&other->layer_); + layers_.UnsafeArenaSwap(&other->layers_); + std::swap(_has_bits_[0], other->_has_bits_[0]); + _internal_metadata_.Swap(&other->_internal_metadata_); + std::swap(_cached_size_, other->_cached_size_); } ::google::protobuf::Metadata NetParameter::GetMetadata() const { @@ -6443,6 +8328,335 @@ void NetParameter::Swap(NetParameter* other) { return metadata; } +#if PROTOBUF_INLINE_NOT_IN_HEADERS +// NetParameter + +// optional string name = 1; +bool NetParameter::has_name() const { + return (_has_bits_[0] & 0x00000001u) != 0; +} +void NetParameter::set_has_name() { + _has_bits_[0] |= 0x00000001u; +} +void NetParameter::clear_has_name() { + _has_bits_[0] &= ~0x00000001u; +} +void NetParameter::clear_name() { + name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + clear_has_name(); +} +const ::std::string& NetParameter::name() const { + // @@protoc_insertion_point(field_get:caffe.NetParameter.name) + return name_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); +} +void NetParameter::set_name(const ::std::string& value) { + set_has_name(); + name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); + // @@protoc_insertion_point(field_set:caffe.NetParameter.name) +} +void NetParameter::set_name(const char* value) { + set_has_name(); + name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); + // @@protoc_insertion_point(field_set_char:caffe.NetParameter.name) +} +void NetParameter::set_name(const char* value, size_t size) { + set_has_name(); + name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), + ::std::string(reinterpret_cast(value), size)); + // @@protoc_insertion_point(field_set_pointer:caffe.NetParameter.name) +} +::std::string* NetParameter::mutable_name() { + set_has_name(); + // @@protoc_insertion_point(field_mutable:caffe.NetParameter.name) + return name_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); +} +::std::string* NetParameter::release_name() { + // @@protoc_insertion_point(field_release:caffe.NetParameter.name) + clear_has_name(); + return name_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); +} +void NetParameter::set_allocated_name(::std::string* name) { + if (name != NULL) { + set_has_name(); + } else { + clear_has_name(); + } + name_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), name); + // @@protoc_insertion_point(field_set_allocated:caffe.NetParameter.name) +} + +// repeated string input = 3; +int NetParameter::input_size() const { + return input_.size(); +} +void NetParameter::clear_input() { + input_.Clear(); +} +const ::std::string& NetParameter::input(int index) const { + // @@protoc_insertion_point(field_get:caffe.NetParameter.input) + return input_.Get(index); +} +::std::string* NetParameter::mutable_input(int index) { + // @@protoc_insertion_point(field_mutable:caffe.NetParameter.input) + return input_.Mutable(index); +} +void NetParameter::set_input(int index, const ::std::string& value) { + // @@protoc_insertion_point(field_set:caffe.NetParameter.input) + input_.Mutable(index)->assign(value); +} +void NetParameter::set_input(int index, const char* value) { + input_.Mutable(index)->assign(value); + // @@protoc_insertion_point(field_set_char:caffe.NetParameter.input) +} +void NetParameter::set_input(int index, const char* value, size_t size) { + input_.Mutable(index)->assign( + reinterpret_cast(value), size); + // @@protoc_insertion_point(field_set_pointer:caffe.NetParameter.input) +} +::std::string* NetParameter::add_input() { + // @@protoc_insertion_point(field_add_mutable:caffe.NetParameter.input) + return input_.Add(); +} +void NetParameter::add_input(const ::std::string& value) { + input_.Add()->assign(value); + // @@protoc_insertion_point(field_add:caffe.NetParameter.input) +} +void NetParameter::add_input(const char* value) { + input_.Add()->assign(value); + // @@protoc_insertion_point(field_add_char:caffe.NetParameter.input) +} +void NetParameter::add_input(const char* value, size_t size) { + input_.Add()->assign(reinterpret_cast(value), size); + // @@protoc_insertion_point(field_add_pointer:caffe.NetParameter.input) +} +const ::google::protobuf::RepeatedPtrField< ::std::string>& +NetParameter::input() const { + // @@protoc_insertion_point(field_list:caffe.NetParameter.input) + return input_; +} +::google::protobuf::RepeatedPtrField< ::std::string>* +NetParameter::mutable_input() { + // @@protoc_insertion_point(field_mutable_list:caffe.NetParameter.input) + return &input_; +} + +// repeated .caffe.BlobShape input_shape = 8; +int NetParameter::input_shape_size() const { + return input_shape_.size(); +} +void NetParameter::clear_input_shape() { + input_shape_.Clear(); +} +const ::caffe::BlobShape& NetParameter::input_shape(int index) const { + // @@protoc_insertion_point(field_get:caffe.NetParameter.input_shape) + return input_shape_.Get(index); +} +::caffe::BlobShape* NetParameter::mutable_input_shape(int index) { + // @@protoc_insertion_point(field_mutable:caffe.NetParameter.input_shape) + return input_shape_.Mutable(index); +} +::caffe::BlobShape* NetParameter::add_input_shape() { + // @@protoc_insertion_point(field_add:caffe.NetParameter.input_shape) + return input_shape_.Add(); +} +::google::protobuf::RepeatedPtrField< ::caffe::BlobShape >* +NetParameter::mutable_input_shape() { + // @@protoc_insertion_point(field_mutable_list:caffe.NetParameter.input_shape) + return &input_shape_; +} +const ::google::protobuf::RepeatedPtrField< ::caffe::BlobShape >& +NetParameter::input_shape() const { + // @@protoc_insertion_point(field_list:caffe.NetParameter.input_shape) + return input_shape_; +} + +// repeated int32 input_dim = 4; +int NetParameter::input_dim_size() const { + return input_dim_.size(); +} +void NetParameter::clear_input_dim() { + input_dim_.Clear(); +} +::google::protobuf::int32 NetParameter::input_dim(int index) const { + // @@protoc_insertion_point(field_get:caffe.NetParameter.input_dim) + return input_dim_.Get(index); +} +void NetParameter::set_input_dim(int index, ::google::protobuf::int32 value) { + input_dim_.Set(index, value); + // @@protoc_insertion_point(field_set:caffe.NetParameter.input_dim) +} +void NetParameter::add_input_dim(::google::protobuf::int32 value) { + input_dim_.Add(value); + // @@protoc_insertion_point(field_add:caffe.NetParameter.input_dim) +} +const ::google::protobuf::RepeatedField< ::google::protobuf::int32 >& +NetParameter::input_dim() const { + // @@protoc_insertion_point(field_list:caffe.NetParameter.input_dim) + return input_dim_; +} +::google::protobuf::RepeatedField< ::google::protobuf::int32 >* +NetParameter::mutable_input_dim() { + // @@protoc_insertion_point(field_mutable_list:caffe.NetParameter.input_dim) + return &input_dim_; +} + +// optional bool force_backward = 5 [default = false]; +bool NetParameter::has_force_backward() const { + return (_has_bits_[0] & 0x00000010u) != 0; +} +void NetParameter::set_has_force_backward() { + _has_bits_[0] |= 0x00000010u; +} +void NetParameter::clear_has_force_backward() { + _has_bits_[0] &= ~0x00000010u; +} +void NetParameter::clear_force_backward() { + force_backward_ = false; + clear_has_force_backward(); +} +bool NetParameter::force_backward() const { + // @@protoc_insertion_point(field_get:caffe.NetParameter.force_backward) + return force_backward_; +} +void NetParameter::set_force_backward(bool value) { + set_has_force_backward(); + force_backward_ = value; + // @@protoc_insertion_point(field_set:caffe.NetParameter.force_backward) +} + +// optional .caffe.NetState state = 6; +bool NetParameter::has_state() const { + return (_has_bits_[0] & 0x00000020u) != 0; +} +void NetParameter::set_has_state() { + _has_bits_[0] |= 0x00000020u; +} +void NetParameter::clear_has_state() { + _has_bits_[0] &= ~0x00000020u; +} +void NetParameter::clear_state() { + if (state_ != NULL) state_->::caffe::NetState::Clear(); + clear_has_state(); +} +const ::caffe::NetState& NetParameter::state() const { + // @@protoc_insertion_point(field_get:caffe.NetParameter.state) + return state_ != NULL ? *state_ + : *::caffe::NetState::internal_default_instance(); +} +::caffe::NetState* NetParameter::mutable_state() { + set_has_state(); + if (state_ == NULL) { + state_ = new ::caffe::NetState; + } + // @@protoc_insertion_point(field_mutable:caffe.NetParameter.state) + return state_; +} +::caffe::NetState* NetParameter::release_state() { + // @@protoc_insertion_point(field_release:caffe.NetParameter.state) + clear_has_state(); + ::caffe::NetState* temp = state_; + state_ = NULL; + return temp; +} +void NetParameter::set_allocated_state(::caffe::NetState* state) { + delete state_; + state_ = state; + if (state) { + set_has_state(); + } else { + clear_has_state(); + } + // @@protoc_insertion_point(field_set_allocated:caffe.NetParameter.state) +} + +// optional bool debug_info = 7 [default = false]; +bool NetParameter::has_debug_info() const { + return (_has_bits_[0] & 0x00000040u) != 0; +} +void NetParameter::set_has_debug_info() { + _has_bits_[0] |= 0x00000040u; +} +void NetParameter::clear_has_debug_info() { + _has_bits_[0] &= ~0x00000040u; +} +void NetParameter::clear_debug_info() { + debug_info_ = false; + clear_has_debug_info(); +} +bool NetParameter::debug_info() const { + // @@protoc_insertion_point(field_get:caffe.NetParameter.debug_info) + return debug_info_; +} +void NetParameter::set_debug_info(bool value) { + set_has_debug_info(); + debug_info_ = value; + // @@protoc_insertion_point(field_set:caffe.NetParameter.debug_info) +} + +// repeated .caffe.LayerParameter layer = 100; +int NetParameter::layer_size() const { + return layer_.size(); +} +void NetParameter::clear_layer() { + layer_.Clear(); +} +const ::caffe::LayerParameter& NetParameter::layer(int index) const { + // @@protoc_insertion_point(field_get:caffe.NetParameter.layer) + return layer_.Get(index); +} +::caffe::LayerParameter* NetParameter::mutable_layer(int index) { + // @@protoc_insertion_point(field_mutable:caffe.NetParameter.layer) + return layer_.Mutable(index); +} +::caffe::LayerParameter* NetParameter::add_layer() { + // @@protoc_insertion_point(field_add:caffe.NetParameter.layer) + return layer_.Add(); +} +::google::protobuf::RepeatedPtrField< ::caffe::LayerParameter >* +NetParameter::mutable_layer() { + // @@protoc_insertion_point(field_mutable_list:caffe.NetParameter.layer) + return &layer_; +} +const ::google::protobuf::RepeatedPtrField< ::caffe::LayerParameter >& +NetParameter::layer() const { + // @@protoc_insertion_point(field_list:caffe.NetParameter.layer) + return layer_; +} + +// repeated .caffe.V1LayerParameter layers = 2; +int NetParameter::layers_size() const { + return layers_.size(); +} +void NetParameter::clear_layers() { + layers_.Clear(); +} +const ::caffe::V1LayerParameter& NetParameter::layers(int index) const { + // @@protoc_insertion_point(field_get:caffe.NetParameter.layers) + return layers_.Get(index); +} +::caffe::V1LayerParameter* NetParameter::mutable_layers(int index) { + // @@protoc_insertion_point(field_mutable:caffe.NetParameter.layers) + return layers_.Mutable(index); +} +::caffe::V1LayerParameter* NetParameter::add_layers() { + // @@protoc_insertion_point(field_add:caffe.NetParameter.layers) + return layers_.Add(); +} +::google::protobuf::RepeatedPtrField< ::caffe::V1LayerParameter >* +NetParameter::mutable_layers() { + // @@protoc_insertion_point(field_mutable_list:caffe.NetParameter.layers) + return &layers_; +} +const ::google::protobuf::RepeatedPtrField< ::caffe::V1LayerParameter >& +NetParameter::layers() const { + // @@protoc_insertion_point(field_list:caffe.NetParameter.layers) + return layers_; +} + +inline const NetParameter* NetParameter::internal_default_instance() { + return &NetParameter_default_instance_.get(); +} +#endif // PROTOBUF_INLINE_NOT_IN_HEADERS // =================================================================== @@ -6451,7 +8665,7 @@ const ::google::protobuf::EnumDescriptor* SolverParameter_SolverMode_descriptor( return SolverParameter_SolverMode_descriptor_; } bool SolverParameter_SolverMode_IsValid(int value) { - switch(value) { + switch (value) { case 0: case 1: return true; @@ -6460,19 +8674,19 @@ bool SolverParameter_SolverMode_IsValid(int value) { } } -#ifndef _MSC_VER +#if !defined(_MSC_VER) || _MSC_VER >= 1900 const SolverParameter_SolverMode SolverParameter::CPU; const SolverParameter_SolverMode SolverParameter::GPU; const SolverParameter_SolverMode SolverParameter::SolverMode_MIN; const SolverParameter_SolverMode SolverParameter::SolverMode_MAX; const int SolverParameter::SolverMode_ARRAYSIZE; -#endif // _MSC_VER +#endif // !defined(_MSC_VER) || _MSC_VER >= 1900 const ::google::protobuf::EnumDescriptor* SolverParameter_SolverType_descriptor() { protobuf_AssignDescriptorsOnce(); return SolverParameter_SolverType_descriptor_; } bool SolverParameter_SolverType_IsValid(int value) { - switch(value) { + switch (value) { case 0: case 1: case 2: @@ -6482,16 +8696,16 @@ bool SolverParameter_SolverType_IsValid(int value) { } } -#ifndef _MSC_VER +#if !defined(_MSC_VER) || _MSC_VER >= 1900 const SolverParameter_SolverType SolverParameter::SGD; const SolverParameter_SolverType SolverParameter::NESTEROV; const SolverParameter_SolverType SolverParameter::ADAGRAD; const SolverParameter_SolverType SolverParameter::SolverType_MIN; const SolverParameter_SolverType SolverParameter::SolverType_MAX; const int SolverParameter::SolverType_ARRAYSIZE; -#endif // _MSC_VER +#endif // !defined(_MSC_VER) || _MSC_VER >= 1900 ::std::string* SolverParameter::_default_regularization_type_ = NULL; -#ifndef _MSC_VER +#if !defined(_MSC_VER) || _MSC_VER >= 1900 const int SolverParameter::kNetFieldNumber; const int SolverParameter::kNetParamFieldNumber; const int SolverParameter::kTrainNetFieldNumber; @@ -6528,82 +8742,66 @@ const int SolverParameter::kSolverTypeFieldNumber; const int SolverParameter::kDeltaFieldNumber; const int SolverParameter::kDebugInfoFieldNumber; const int SolverParameter::kSnapshotAfterTrainFieldNumber; -#endif // !_MSC_VER +#endif // !defined(_MSC_VER) || _MSC_VER >= 1900 SolverParameter::SolverParameter() - : ::google::protobuf::Message() { + : ::google::protobuf::Message(), _internal_metadata_(NULL) { + if (this != internal_default_instance()) protobuf_InitDefaults_caffe_2eproto(); SharedCtor(); + // @@protoc_insertion_point(constructor:caffe.SolverParameter) } void SolverParameter::InitAsDefaultInstance() { - net_param_ = const_cast< ::caffe::NetParameter*>(&::caffe::NetParameter::default_instance()); - train_net_param_ = const_cast< ::caffe::NetParameter*>(&::caffe::NetParameter::default_instance()); - train_state_ = const_cast< ::caffe::NetState*>(&::caffe::NetState::default_instance()); + net_param_ = const_cast< ::caffe::NetParameter*>( + ::caffe::NetParameter::internal_default_instance()); + train_net_param_ = const_cast< ::caffe::NetParameter*>( + ::caffe::NetParameter::internal_default_instance()); + train_state_ = const_cast< ::caffe::NetState*>( + ::caffe::NetState::internal_default_instance()); } SolverParameter::SolverParameter(const SolverParameter& from) - : ::google::protobuf::Message() { + : ::google::protobuf::Message(), + _internal_metadata_(NULL) { SharedCtor(); - MergeFrom(from); + UnsafeMergeFrom(from); + // @@protoc_insertion_point(copy_constructor:caffe.SolverParameter) } void SolverParameter::SharedCtor() { - _cached_size_ = 0; - net_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); + net_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + train_net_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + lr_policy_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + regularization_type_.UnsafeSetDefault(_default_regularization_type_); + snapshot_prefix_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); net_param_ = NULL; - train_net_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); train_net_param_ = NULL; train_state_ = NULL; - test_interval_ = 0; - test_compute_loss_ = false; - test_initialization_ = true; - base_lr_ = 0; - display_ = 0; + ::memset(&test_interval_, 0, reinterpret_cast(&solver_type_) - + reinterpret_cast(&test_interval_) + sizeof(solver_type_)); average_loss_ = 1; - max_iter_ = 0; iter_size_ = 1; - lr_policy_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); - gamma_ = 0; - power_ = 0; - momentum_ = 0; - weight_decay_ = 0; - regularization_type_ = const_cast< ::std::string*>(_default_regularization_type_); - stepsize_ = 0; + test_initialization_ = true; + snapshot_after_train_ = true; clip_gradients_ = -1; - snapshot_ = 0; - snapshot_prefix_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); - snapshot_diff_ = false; - solver_mode_ = 1; - device_id_ = 0; random_seed_ = GOOGLE_LONGLONG(-1); - solver_type_ = 0; + solver_mode_ = 1; delta_ = 1e-08f; - debug_info_ = false; - snapshot_after_train_ = true; - ::memset(_has_bits_, 0, sizeof(_has_bits_)); + _cached_size_ = 0; } SolverParameter::~SolverParameter() { + // @@protoc_insertion_point(destructor:caffe.SolverParameter) SharedDtor(); } void SolverParameter::SharedDtor() { - if (net_ != &::google::protobuf::internal::kEmptyString) { - delete net_; - } - if (train_net_ != &::google::protobuf::internal::kEmptyString) { - delete train_net_; - } - if (lr_policy_ != &::google::protobuf::internal::kEmptyString) { - delete lr_policy_; - } - if (regularization_type_ != _default_regularization_type_) { - delete regularization_type_; - } - if (snapshot_prefix_ != &::google::protobuf::internal::kEmptyString) { - delete snapshot_prefix_; - } - if (this != default_instance_) { + net_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + train_net_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + lr_policy_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + regularization_type_.DestroyNoArena(_default_regularization_type_); + snapshot_prefix_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + if (this != &SolverParameter_default_instance_.get()) { delete net_param_; delete train_net_param_; delete train_state_; @@ -6621,30 +8819,47 @@ const ::google::protobuf::Descriptor* SolverParameter::descriptor() { } const SolverParameter& SolverParameter::default_instance() { - if (default_instance_ == NULL) protobuf_AddDesc_caffe_2eproto(); - return *default_instance_; + protobuf_InitDefaults_caffe_2eproto(); + return *internal_default_instance(); } -SolverParameter* SolverParameter::default_instance_ = NULL; +::google::protobuf::internal::ExplicitlyConstructed SolverParameter_default_instance_; -SolverParameter* SolverParameter::New() const { - return new SolverParameter; +SolverParameter* SolverParameter::New(::google::protobuf::Arena* arena) const { + SolverParameter* n = new SolverParameter; + if (arena != NULL) { + arena->Own(n); + } + return n; } void SolverParameter::Clear() { - if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) { +// @@protoc_insertion_point(message_clear_start:caffe.SolverParameter) +#if defined(__clang__) +#define ZR_HELPER_(f) \ + _Pragma("clang diagnostic push") \ + _Pragma("clang diagnostic ignored \"-Winvalid-offsetof\"") \ + __builtin_offsetof(SolverParameter, f) \ + _Pragma("clang diagnostic pop") +#else +#define ZR_HELPER_(f) reinterpret_cast(\ + &reinterpret_cast(16)->f) +#endif + +#define ZR_(first, last) do {\ + ::memset(&(first), 0,\ + ZR_HELPER_(last) - ZR_HELPER_(first) + sizeof(last));\ +} while (0) + + if (_has_bits_[0 / 32] & 87u) { if (has_net()) { - if (net_ != &::google::protobuf::internal::kEmptyString) { - net_->clear(); - } + net_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } if (has_net_param()) { if (net_param_ != NULL) net_param_->::caffe::NetParameter::Clear(); } if (has_train_net()) { - if (train_net_ != &::google::protobuf::internal::kEmptyString) { - train_net_->clear(); - } + train_net_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } if (has_train_net_param()) { if (train_net_param_ != NULL) train_net_param_->::caffe::NetParameter::Clear(); @@ -6653,78 +8868,74 @@ void SolverParameter::Clear() { if (train_state_ != NULL) train_state_->::caffe::NetState::Clear(); } } - if (_has_bits_[9 / 32] & (0xffu << (9 % 32))) { - test_interval_ = 0; + if (_has_bits_[8 / 32] & 65024u) { + ZR_(test_interval_, max_iter_); test_compute_loss_ = false; test_initialization_ = true; - base_lr_ = 0; - display_ = 0; average_loss_ = 1; - max_iter_ = 0; } - if (_has_bits_[16 / 32] & (0xffu << (16 % 32))) { + if (_has_bits_[16 / 32] & 16711680u) { + ZR_(gamma_, stepsize_); iter_size_ = 1; if (has_lr_policy()) { - if (lr_policy_ != &::google::protobuf::internal::kEmptyString) { - lr_policy_->clear(); - } + lr_policy_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - gamma_ = 0; - power_ = 0; - momentum_ = 0; - weight_decay_ = 0; if (has_regularization_type()) { - if (regularization_type_ != _default_regularization_type_) { - regularization_type_->assign(*_default_regularization_type_); - } + regularization_type_.ClearToDefaultNoArena(_default_regularization_type_); } - stepsize_ = 0; } - if (_has_bits_[25 / 32] & (0xffu << (25 % 32))) { + if (_has_bits_[24 / 32] & 4261412864u) { + ZR_(snapshot_, device_id_); clip_gradients_ = -1; - snapshot_ = 0; if (has_snapshot_prefix()) { - if (snapshot_prefix_ != &::google::protobuf::internal::kEmptyString) { - snapshot_prefix_->clear(); - } + snapshot_prefix_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } snapshot_diff_ = false; solver_mode_ = 1; - device_id_ = 0; random_seed_ = GOOGLE_LONGLONG(-1); } - if (_has_bits_[32 / 32] & (0xffu << (32 % 32))) { + if (_has_bits_[32 / 32] & 15u) { solver_type_ = 0; delta_ = 1e-08f; debug_info_ = false; snapshot_after_train_ = true; } + +#undef ZR_HELPER_ +#undef ZR_ + test_net_.Clear(); test_net_param_.Clear(); test_state_.Clear(); test_iter_.Clear(); stepvalue_.Clear(); - ::memset(_has_bits_, 0, sizeof(_has_bits_)); - mutable_unknown_fields()->Clear(); + _has_bits_.Clear(); + if (_internal_metadata_.have_unknown_fields()) { + mutable_unknown_fields()->Clear(); + } } bool SolverParameter::MergePartialFromCodedStream( ::google::protobuf::io::CodedInputStream* input) { -#define DO_(EXPRESSION) if (!(EXPRESSION)) return false +#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure ::google::protobuf::uint32 tag; - while ((tag = input->ReadTag()) != 0) { + // @@protoc_insertion_point(parse_start:caffe.SolverParameter) + for (;;) { + ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(16383); + tag = p.first; + if (!p.second) goto handle_unusual; switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { // optional string train_net = 1; case 1: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) { + if (tag == 10) { DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->mutable_train_net())); - ::google::protobuf::internal::WireFormat::VerifyUTF8String( + ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( this->train_net().data(), this->train_net().length(), - ::google::protobuf::internal::WireFormat::PARSE); + ::google::protobuf::internal::WireFormat::PARSE, + "caffe.SolverParameter.train_net"); } else { - goto handle_uninterpreted; + goto handle_unusual; } if (input->ExpectTag(18)) goto parse_test_net; break; @@ -6732,17 +8943,17 @@ bool SolverParameter::MergePartialFromCodedStream( // repeated string test_net = 2; case 2: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) { + if (tag == 18) { parse_test_net: DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->add_test_net())); - ::google::protobuf::internal::WireFormat::VerifyUTF8String( + ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( this->test_net(this->test_net_size() - 1).data(), this->test_net(this->test_net_size() - 1).length(), - ::google::protobuf::internal::WireFormat::PARSE); + ::google::protobuf::internal::WireFormat::PARSE, + "caffe.SolverParameter.test_net"); } else { - goto handle_uninterpreted; + goto handle_unusual; } if (input->ExpectTag(18)) goto parse_test_net; if (input->ExpectTag(24)) goto parse_test_iter; @@ -6751,20 +8962,17 @@ bool SolverParameter::MergePartialFromCodedStream( // repeated int32 test_iter = 3; case 3: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) { + if (tag == 24) { parse_test_iter: DO_((::google::protobuf::internal::WireFormatLite::ReadRepeatedPrimitive< ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>( 1, 24, input, this->mutable_test_iter()))); - } else if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) - == ::google::protobuf::internal::WireFormatLite:: - WIRETYPE_LENGTH_DELIMITED) { + } else if (tag == 26) { DO_((::google::protobuf::internal::WireFormatLite::ReadPackedPrimitiveNoInline< ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>( input, this->mutable_test_iter()))); } else { - goto handle_uninterpreted; + goto handle_unusual; } if (input->ExpectTag(24)) goto parse_test_iter; if (input->ExpectTag(32)) goto parse_test_interval; @@ -6773,15 +8981,14 @@ bool SolverParameter::MergePartialFromCodedStream( // optional int32 test_interval = 4 [default = 0]; case 4: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) { + if (tag == 32) { parse_test_interval: + set_has_test_interval(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>( input, &test_interval_))); - set_has_test_interval(); } else { - goto handle_uninterpreted; + goto handle_unusual; } if (input->ExpectTag(45)) goto parse_base_lr; break; @@ -6789,15 +8996,14 @@ bool SolverParameter::MergePartialFromCodedStream( // optional float base_lr = 5; case 5: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_FIXED32) { + if (tag == 45) { parse_base_lr: + set_has_base_lr(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< float, ::google::protobuf::internal::WireFormatLite::TYPE_FLOAT>( input, &base_lr_))); - set_has_base_lr(); } else { - goto handle_uninterpreted; + goto handle_unusual; } if (input->ExpectTag(48)) goto parse_display; break; @@ -6805,15 +9011,14 @@ bool SolverParameter::MergePartialFromCodedStream( // optional int32 display = 6; case 6: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) { + if (tag == 48) { parse_display: + set_has_display(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>( input, &display_))); - set_has_display(); } else { - goto handle_uninterpreted; + goto handle_unusual; } if (input->ExpectTag(56)) goto parse_max_iter; break; @@ -6821,15 +9026,14 @@ bool SolverParameter::MergePartialFromCodedStream( // optional int32 max_iter = 7; case 7: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) { + if (tag == 56) { parse_max_iter: + set_has_max_iter(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>( input, &max_iter_))); - set_has_max_iter(); } else { - goto handle_uninterpreted; + goto handle_unusual; } if (input->ExpectTag(66)) goto parse_lr_policy; break; @@ -6837,16 +9041,16 @@ bool SolverParameter::MergePartialFromCodedStream( // optional string lr_policy = 8; case 8: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) { + if (tag == 66) { parse_lr_policy: DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->mutable_lr_policy())); - ::google::protobuf::internal::WireFormat::VerifyUTF8String( + ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( this->lr_policy().data(), this->lr_policy().length(), - ::google::protobuf::internal::WireFormat::PARSE); + ::google::protobuf::internal::WireFormat::PARSE, + "caffe.SolverParameter.lr_policy"); } else { - goto handle_uninterpreted; + goto handle_unusual; } if (input->ExpectTag(77)) goto parse_gamma; break; @@ -6854,15 +9058,14 @@ bool SolverParameter::MergePartialFromCodedStream( // optional float gamma = 9; case 9: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_FIXED32) { + if (tag == 77) { parse_gamma: + set_has_gamma(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< float, ::google::protobuf::internal::WireFormatLite::TYPE_FLOAT>( input, &gamma_))); - set_has_gamma(); } else { - goto handle_uninterpreted; + goto handle_unusual; } if (input->ExpectTag(85)) goto parse_power; break; @@ -6870,15 +9073,14 @@ bool SolverParameter::MergePartialFromCodedStream( // optional float power = 10; case 10: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_FIXED32) { + if (tag == 85) { parse_power: + set_has_power(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< float, ::google::protobuf::internal::WireFormatLite::TYPE_FLOAT>( input, &power_))); - set_has_power(); } else { - goto handle_uninterpreted; + goto handle_unusual; } if (input->ExpectTag(93)) goto parse_momentum; break; @@ -6886,15 +9088,14 @@ bool SolverParameter::MergePartialFromCodedStream( // optional float momentum = 11; case 11: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_FIXED32) { + if (tag == 93) { parse_momentum: + set_has_momentum(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< float, ::google::protobuf::internal::WireFormatLite::TYPE_FLOAT>( input, &momentum_))); - set_has_momentum(); } else { - goto handle_uninterpreted; + goto handle_unusual; } if (input->ExpectTag(101)) goto parse_weight_decay; break; @@ -6902,15 +9103,14 @@ bool SolverParameter::MergePartialFromCodedStream( // optional float weight_decay = 12; case 12: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_FIXED32) { + if (tag == 101) { parse_weight_decay: + set_has_weight_decay(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< float, ::google::protobuf::internal::WireFormatLite::TYPE_FLOAT>( input, &weight_decay_))); - set_has_weight_decay(); } else { - goto handle_uninterpreted; + goto handle_unusual; } if (input->ExpectTag(104)) goto parse_stepsize; break; @@ -6918,15 +9118,14 @@ bool SolverParameter::MergePartialFromCodedStream( // optional int32 stepsize = 13; case 13: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) { + if (tag == 104) { parse_stepsize: + set_has_stepsize(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>( input, &stepsize_))); - set_has_stepsize(); } else { - goto handle_uninterpreted; + goto handle_unusual; } if (input->ExpectTag(112)) goto parse_snapshot; break; @@ -6934,15 +9133,14 @@ bool SolverParameter::MergePartialFromCodedStream( // optional int32 snapshot = 14 [default = 0]; case 14: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) { + if (tag == 112) { parse_snapshot: + set_has_snapshot(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>( input, &snapshot_))); - set_has_snapshot(); } else { - goto handle_uninterpreted; + goto handle_unusual; } if (input->ExpectTag(122)) goto parse_snapshot_prefix; break; @@ -6950,16 +9148,16 @@ bool SolverParameter::MergePartialFromCodedStream( // optional string snapshot_prefix = 15; case 15: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) { + if (tag == 122) { parse_snapshot_prefix: DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->mutable_snapshot_prefix())); - ::google::protobuf::internal::WireFormat::VerifyUTF8String( + ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( this->snapshot_prefix().data(), this->snapshot_prefix().length(), - ::google::protobuf::internal::WireFormat::PARSE); + ::google::protobuf::internal::WireFormat::PARSE, + "caffe.SolverParameter.snapshot_prefix"); } else { - goto handle_uninterpreted; + goto handle_unusual; } if (input->ExpectTag(128)) goto parse_snapshot_diff; break; @@ -6967,15 +9165,14 @@ bool SolverParameter::MergePartialFromCodedStream( // optional bool snapshot_diff = 16 [default = false]; case 16: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) { + if (tag == 128) { parse_snapshot_diff: + set_has_snapshot_diff(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>( input, &snapshot_diff_))); - set_has_snapshot_diff(); } else { - goto handle_uninterpreted; + goto handle_unusual; } if (input->ExpectTag(136)) goto parse_solver_mode; break; @@ -6983,8 +9180,7 @@ bool SolverParameter::MergePartialFromCodedStream( // optional .caffe.SolverParameter.SolverMode solver_mode = 17 [default = GPU]; case 17: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) { + if (tag == 136) { parse_solver_mode: int value; DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< @@ -6996,7 +9192,7 @@ bool SolverParameter::MergePartialFromCodedStream( mutable_unknown_fields()->AddVarint(17, value); } } else { - goto handle_uninterpreted; + goto handle_unusual; } if (input->ExpectTag(144)) goto parse_device_id; break; @@ -7004,15 +9200,14 @@ bool SolverParameter::MergePartialFromCodedStream( // optional int32 device_id = 18 [default = 0]; case 18: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) { + if (tag == 144) { parse_device_id: + set_has_device_id(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>( input, &device_id_))); - set_has_device_id(); } else { - goto handle_uninterpreted; + goto handle_unusual; } if (input->ExpectTag(152)) goto parse_test_compute_loss; break; @@ -7020,15 +9215,14 @@ bool SolverParameter::MergePartialFromCodedStream( // optional bool test_compute_loss = 19 [default = false]; case 19: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) { + if (tag == 152) { parse_test_compute_loss: + set_has_test_compute_loss(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>( input, &test_compute_loss_))); - set_has_test_compute_loss(); } else { - goto handle_uninterpreted; + goto handle_unusual; } if (input->ExpectTag(160)) goto parse_random_seed; break; @@ -7036,15 +9230,14 @@ bool SolverParameter::MergePartialFromCodedStream( // optional int64 random_seed = 20 [default = -1]; case 20: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) { + if (tag == 160) { parse_random_seed: + set_has_random_seed(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< ::google::protobuf::int64, ::google::protobuf::internal::WireFormatLite::TYPE_INT64>( input, &random_seed_))); - set_has_random_seed(); } else { - goto handle_uninterpreted; + goto handle_unusual; } if (input->ExpectTag(170)) goto parse_train_net_param; break; @@ -7052,13 +9245,12 @@ bool SolverParameter::MergePartialFromCodedStream( // optional .caffe.NetParameter train_net_param = 21; case 21: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) { + if (tag == 170) { parse_train_net_param: DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual( input, mutable_train_net_param())); } else { - goto handle_uninterpreted; + goto handle_unusual; } if (input->ExpectTag(178)) goto parse_test_net_param; break; @@ -7066,30 +9258,31 @@ bool SolverParameter::MergePartialFromCodedStream( // repeated .caffe.NetParameter test_net_param = 22; case 22: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) { + if (tag == 178) { parse_test_net_param: - DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual( + DO_(input->IncrementRecursionDepth()); + parse_loop_test_net_param: + DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtualNoRecursionDepth( input, add_test_net_param())); } else { - goto handle_uninterpreted; + goto handle_unusual; } - if (input->ExpectTag(178)) goto parse_test_net_param; + if (input->ExpectTag(178)) goto parse_loop_test_net_param; + input->UnsafeDecrementRecursionDepth(); if (input->ExpectTag(184)) goto parse_debug_info; break; } // optional bool debug_info = 23 [default = false]; case 23: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) { + if (tag == 184) { parse_debug_info: + set_has_debug_info(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>( input, &debug_info_))); - set_has_debug_info(); } else { - goto handle_uninterpreted; + goto handle_unusual; } if (input->ExpectTag(194)) goto parse_net; break; @@ -7097,16 +9290,16 @@ bool SolverParameter::MergePartialFromCodedStream( // optional string net = 24; case 24: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) { + if (tag == 194) { parse_net: DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->mutable_net())); - ::google::protobuf::internal::WireFormat::VerifyUTF8String( + ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( this->net().data(), this->net().length(), - ::google::protobuf::internal::WireFormat::PARSE); + ::google::protobuf::internal::WireFormat::PARSE, + "caffe.SolverParameter.net"); } else { - goto handle_uninterpreted; + goto handle_unusual; } if (input->ExpectTag(202)) goto parse_net_param; break; @@ -7114,13 +9307,12 @@ bool SolverParameter::MergePartialFromCodedStream( // optional .caffe.NetParameter net_param = 25; case 25: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) { + if (tag == 202) { parse_net_param: DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual( input, mutable_net_param())); } else { - goto handle_uninterpreted; + goto handle_unusual; } if (input->ExpectTag(210)) goto parse_train_state; break; @@ -7128,13 +9320,12 @@ bool SolverParameter::MergePartialFromCodedStream( // optional .caffe.NetState train_state = 26; case 26: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) { + if (tag == 210) { parse_train_state: DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual( input, mutable_train_state())); } else { - goto handle_uninterpreted; + goto handle_unusual; } if (input->ExpectTag(218)) goto parse_test_state; break; @@ -7142,30 +9333,31 @@ bool SolverParameter::MergePartialFromCodedStream( // repeated .caffe.NetState test_state = 27; case 27: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) { + if (tag == 218) { parse_test_state: - DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual( + DO_(input->IncrementRecursionDepth()); + parse_loop_test_state: + DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtualNoRecursionDepth( input, add_test_state())); } else { - goto handle_uninterpreted; + goto handle_unusual; } - if (input->ExpectTag(218)) goto parse_test_state; + if (input->ExpectTag(218)) goto parse_loop_test_state; + input->UnsafeDecrementRecursionDepth(); if (input->ExpectTag(224)) goto parse_snapshot_after_train; break; } // optional bool snapshot_after_train = 28 [default = true]; case 28: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) { + if (tag == 224) { parse_snapshot_after_train: + set_has_snapshot_after_train(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>( input, &snapshot_after_train_))); - set_has_snapshot_after_train(); } else { - goto handle_uninterpreted; + goto handle_unusual; } if (input->ExpectTag(234)) goto parse_regularization_type; break; @@ -7173,16 +9365,16 @@ bool SolverParameter::MergePartialFromCodedStream( // optional string regularization_type = 29 [default = "L2"]; case 29: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) { + if (tag == 234) { parse_regularization_type: DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->mutable_regularization_type())); - ::google::protobuf::internal::WireFormat::VerifyUTF8String( + ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( this->regularization_type().data(), this->regularization_type().length(), - ::google::protobuf::internal::WireFormat::PARSE); + ::google::protobuf::internal::WireFormat::PARSE, + "caffe.SolverParameter.regularization_type"); } else { - goto handle_uninterpreted; + goto handle_unusual; } if (input->ExpectTag(240)) goto parse_solver_type; break; @@ -7190,8 +9382,7 @@ bool SolverParameter::MergePartialFromCodedStream( // optional .caffe.SolverParameter.SolverType solver_type = 30 [default = SGD]; case 30: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) { + if (tag == 240) { parse_solver_type: int value; DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< @@ -7203,7 +9394,7 @@ bool SolverParameter::MergePartialFromCodedStream( mutable_unknown_fields()->AddVarint(30, value); } } else { - goto handle_uninterpreted; + goto handle_unusual; } if (input->ExpectTag(253)) goto parse_delta; break; @@ -7211,15 +9402,14 @@ bool SolverParameter::MergePartialFromCodedStream( // optional float delta = 31 [default = 1e-08]; case 31: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_FIXED32) { + if (tag == 253) { parse_delta: + set_has_delta(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< float, ::google::protobuf::internal::WireFormatLite::TYPE_FLOAT>( input, &delta_))); - set_has_delta(); } else { - goto handle_uninterpreted; + goto handle_unusual; } if (input->ExpectTag(256)) goto parse_test_initialization; break; @@ -7227,15 +9417,14 @@ bool SolverParameter::MergePartialFromCodedStream( // optional bool test_initialization = 32 [default = true]; case 32: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) { + if (tag == 256) { parse_test_initialization: + set_has_test_initialization(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>( input, &test_initialization_))); - set_has_test_initialization(); } else { - goto handle_uninterpreted; + goto handle_unusual; } if (input->ExpectTag(264)) goto parse_average_loss; break; @@ -7243,15 +9432,14 @@ bool SolverParameter::MergePartialFromCodedStream( // optional int32 average_loss = 33 [default = 1]; case 33: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) { + if (tag == 264) { parse_average_loss: + set_has_average_loss(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>( input, &average_loss_))); - set_has_average_loss(); } else { - goto handle_uninterpreted; + goto handle_unusual; } if (input->ExpectTag(272)) goto parse_stepvalue; break; @@ -7259,20 +9447,17 @@ bool SolverParameter::MergePartialFromCodedStream( // repeated int32 stepvalue = 34; case 34: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) { + if (tag == 272) { parse_stepvalue: DO_((::google::protobuf::internal::WireFormatLite::ReadRepeatedPrimitive< ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>( 2, 272, input, this->mutable_stepvalue()))); - } else if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) - == ::google::protobuf::internal::WireFormatLite:: - WIRETYPE_LENGTH_DELIMITED) { + } else if (tag == 274) { DO_((::google::protobuf::internal::WireFormatLite::ReadPackedPrimitiveNoInline< ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>( input, this->mutable_stepvalue()))); } else { - goto handle_uninterpreted; + goto handle_unusual; } if (input->ExpectTag(272)) goto parse_stepvalue; if (input->ExpectTag(285)) goto parse_clip_gradients; @@ -7281,15 +9466,14 @@ bool SolverParameter::MergePartialFromCodedStream( // optional float clip_gradients = 35 [default = -1]; case 35: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_FIXED32) { + if (tag == 285) { parse_clip_gradients: + set_has_clip_gradients(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< float, ::google::protobuf::internal::WireFormatLite::TYPE_FLOAT>( input, &clip_gradients_))); - set_has_clip_gradients(); } else { - goto handle_uninterpreted; + goto handle_unusual; } if (input->ExpectTag(288)) goto parse_iter_size; break; @@ -7297,25 +9481,25 @@ bool SolverParameter::MergePartialFromCodedStream( // optional int32 iter_size = 36 [default = 1]; case 36: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) { + if (tag == 288) { parse_iter_size: + set_has_iter_size(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>( input, &iter_size_))); - set_has_iter_size(); } else { - goto handle_uninterpreted; + goto handle_unusual; } - if (input->ExpectAtEnd()) return true; + if (input->ExpectAtEnd()) goto success; break; } default: { - handle_uninterpreted: - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == + handle_unusual: + if (tag == 0 || + ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) { - return true; + goto success; } DO_(::google::protobuf::internal::WireFormat::SkipField( input, tag, mutable_unknown_fields())); @@ -7323,26 +9507,34 @@ bool SolverParameter::MergePartialFromCodedStream( } } } +success: + // @@protoc_insertion_point(parse_success:caffe.SolverParameter) return true; +failure: + // @@protoc_insertion_point(parse_failure:caffe.SolverParameter) + return false; #undef DO_ } void SolverParameter::SerializeWithCachedSizes( ::google::protobuf::io::CodedOutputStream* output) const { + // @@protoc_insertion_point(serialize_start:caffe.SolverParameter) // optional string train_net = 1; if (has_train_net()) { - ::google::protobuf::internal::WireFormat::VerifyUTF8String( + ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( this->train_net().data(), this->train_net().length(), - ::google::protobuf::internal::WireFormat::SERIALIZE); - ::google::protobuf::internal::WireFormatLite::WriteString( + ::google::protobuf::internal::WireFormat::SERIALIZE, + "caffe.SolverParameter.train_net"); + ::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased( 1, this->train_net(), output); } // repeated string test_net = 2; for (int i = 0; i < this->test_net_size(); i++) { - ::google::protobuf::internal::WireFormat::VerifyUTF8String( - this->test_net(i).data(), this->test_net(i).length(), - ::google::protobuf::internal::WireFormat::SERIALIZE); + ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( + this->test_net(i).data(), this->test_net(i).length(), + ::google::protobuf::internal::WireFormat::SERIALIZE, + "caffe.SolverParameter.test_net"); ::google::protobuf::internal::WireFormatLite::WriteString( 2, this->test_net(i), output); } @@ -7375,10 +9567,11 @@ void SolverParameter::SerializeWithCachedSizes( // optional string lr_policy = 8; if (has_lr_policy()) { - ::google::protobuf::internal::WireFormat::VerifyUTF8String( + ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( this->lr_policy().data(), this->lr_policy().length(), - ::google::protobuf::internal::WireFormat::SERIALIZE); - ::google::protobuf::internal::WireFormatLite::WriteString( + ::google::protobuf::internal::WireFormat::SERIALIZE, + "caffe.SolverParameter.lr_policy"); + ::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased( 8, this->lr_policy(), output); } @@ -7414,10 +9607,11 @@ void SolverParameter::SerializeWithCachedSizes( // optional string snapshot_prefix = 15; if (has_snapshot_prefix()) { - ::google::protobuf::internal::WireFormat::VerifyUTF8String( + ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( this->snapshot_prefix().data(), this->snapshot_prefix().length(), - ::google::protobuf::internal::WireFormat::SERIALIZE); - ::google::protobuf::internal::WireFormatLite::WriteString( + ::google::protobuf::internal::WireFormat::SERIALIZE, + "caffe.SolverParameter.snapshot_prefix"); + ::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased( 15, this->snapshot_prefix(), output); } @@ -7450,11 +9644,11 @@ void SolverParameter::SerializeWithCachedSizes( // optional .caffe.NetParameter train_net_param = 21; if (has_train_net_param()) { ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( - 21, this->train_net_param(), output); + 21, *this->train_net_param_, output); } // repeated .caffe.NetParameter test_net_param = 22; - for (int i = 0; i < this->test_net_param_size(); i++) { + for (unsigned int i = 0, n = this->test_net_param_size(); i < n; i++) { ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( 22, this->test_net_param(i), output); } @@ -7466,27 +9660,28 @@ void SolverParameter::SerializeWithCachedSizes( // optional string net = 24; if (has_net()) { - ::google::protobuf::internal::WireFormat::VerifyUTF8String( + ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( this->net().data(), this->net().length(), - ::google::protobuf::internal::WireFormat::SERIALIZE); - ::google::protobuf::internal::WireFormatLite::WriteString( + ::google::protobuf::internal::WireFormat::SERIALIZE, + "caffe.SolverParameter.net"); + ::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased( 24, this->net(), output); } // optional .caffe.NetParameter net_param = 25; if (has_net_param()) { ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( - 25, this->net_param(), output); + 25, *this->net_param_, output); } // optional .caffe.NetState train_state = 26; if (has_train_state()) { ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( - 26, this->train_state(), output); + 26, *this->train_state_, output); } // repeated .caffe.NetState test_state = 27; - for (int i = 0; i < this->test_state_size(); i++) { + for (unsigned int i = 0, n = this->test_state_size(); i < n; i++) { ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( 27, this->test_state(i), output); } @@ -7498,10 +9693,11 @@ void SolverParameter::SerializeWithCachedSizes( // optional string regularization_type = 29 [default = "L2"]; if (has_regularization_type()) { - ::google::protobuf::internal::WireFormat::VerifyUTF8String( + ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( this->regularization_type().data(), this->regularization_type().length(), - ::google::protobuf::internal::WireFormat::SERIALIZE); - ::google::protobuf::internal::WireFormatLite::WriteString( + ::google::protobuf::internal::WireFormat::SERIALIZE, + "caffe.SolverParameter.regularization_type"); + ::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased( 29, this->regularization_type(), output); } @@ -7542,19 +9738,23 @@ void SolverParameter::SerializeWithCachedSizes( ::google::protobuf::internal::WireFormatLite::WriteInt32(36, this->iter_size(), output); } - if (!unknown_fields().empty()) { + if (_internal_metadata_.have_unknown_fields()) { ::google::protobuf::internal::WireFormat::SerializeUnknownFields( unknown_fields(), output); } + // @@protoc_insertion_point(serialize_end:caffe.SolverParameter) } -::google::protobuf::uint8* SolverParameter::SerializeWithCachedSizesToArray( - ::google::protobuf::uint8* target) const { +::google::protobuf::uint8* SolverParameter::InternalSerializeWithCachedSizesToArray( + bool deterministic, ::google::protobuf::uint8* target) const { + (void)deterministic; // Unused + // @@protoc_insertion_point(serialize_to_array_start:caffe.SolverParameter) // optional string train_net = 1; if (has_train_net()) { - ::google::protobuf::internal::WireFormat::VerifyUTF8String( + ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( this->train_net().data(), this->train_net().length(), - ::google::protobuf::internal::WireFormat::SERIALIZE); + ::google::protobuf::internal::WireFormat::SERIALIZE, + "caffe.SolverParameter.train_net"); target = ::google::protobuf::internal::WireFormatLite::WriteStringToArray( 1, this->train_net(), target); @@ -7562,9 +9762,10 @@ void SolverParameter::SerializeWithCachedSizes( // repeated string test_net = 2; for (int i = 0; i < this->test_net_size(); i++) { - ::google::protobuf::internal::WireFormat::VerifyUTF8String( + ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( this->test_net(i).data(), this->test_net(i).length(), - ::google::protobuf::internal::WireFormat::SERIALIZE); + ::google::protobuf::internal::WireFormat::SERIALIZE, + "caffe.SolverParameter.test_net"); target = ::google::protobuf::internal::WireFormatLite:: WriteStringToArray(2, this->test_net(i), target); } @@ -7597,9 +9798,10 @@ void SolverParameter::SerializeWithCachedSizes( // optional string lr_policy = 8; if (has_lr_policy()) { - ::google::protobuf::internal::WireFormat::VerifyUTF8String( + ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( this->lr_policy().data(), this->lr_policy().length(), - ::google::protobuf::internal::WireFormat::SERIALIZE); + ::google::protobuf::internal::WireFormat::SERIALIZE, + "caffe.SolverParameter.lr_policy"); target = ::google::protobuf::internal::WireFormatLite::WriteStringToArray( 8, this->lr_policy(), target); @@ -7637,9 +9839,10 @@ void SolverParameter::SerializeWithCachedSizes( // optional string snapshot_prefix = 15; if (has_snapshot_prefix()) { - ::google::protobuf::internal::WireFormat::VerifyUTF8String( + ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( this->snapshot_prefix().data(), this->snapshot_prefix().length(), - ::google::protobuf::internal::WireFormat::SERIALIZE); + ::google::protobuf::internal::WireFormat::SERIALIZE, + "caffe.SolverParameter.snapshot_prefix"); target = ::google::protobuf::internal::WireFormatLite::WriteStringToArray( 15, this->snapshot_prefix(), target); @@ -7674,15 +9877,15 @@ void SolverParameter::SerializeWithCachedSizes( // optional .caffe.NetParameter train_net_param = 21; if (has_train_net_param()) { target = ::google::protobuf::internal::WireFormatLite:: - WriteMessageNoVirtualToArray( - 21, this->train_net_param(), target); + InternalWriteMessageNoVirtualToArray( + 21, *this->train_net_param_, false, target); } // repeated .caffe.NetParameter test_net_param = 22; - for (int i = 0; i < this->test_net_param_size(); i++) { + for (unsigned int i = 0, n = this->test_net_param_size(); i < n; i++) { target = ::google::protobuf::internal::WireFormatLite:: - WriteMessageNoVirtualToArray( - 22, this->test_net_param(i), target); + InternalWriteMessageNoVirtualToArray( + 22, this->test_net_param(i), false, target); } // optional bool debug_info = 23 [default = false]; @@ -7692,9 +9895,10 @@ void SolverParameter::SerializeWithCachedSizes( // optional string net = 24; if (has_net()) { - ::google::protobuf::internal::WireFormat::VerifyUTF8String( + ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( this->net().data(), this->net().length(), - ::google::protobuf::internal::WireFormat::SERIALIZE); + ::google::protobuf::internal::WireFormat::SERIALIZE, + "caffe.SolverParameter.net"); target = ::google::protobuf::internal::WireFormatLite::WriteStringToArray( 24, this->net(), target); @@ -7703,22 +9907,22 @@ void SolverParameter::SerializeWithCachedSizes( // optional .caffe.NetParameter net_param = 25; if (has_net_param()) { target = ::google::protobuf::internal::WireFormatLite:: - WriteMessageNoVirtualToArray( - 25, this->net_param(), target); + InternalWriteMessageNoVirtualToArray( + 25, *this->net_param_, false, target); } // optional .caffe.NetState train_state = 26; if (has_train_state()) { target = ::google::protobuf::internal::WireFormatLite:: - WriteMessageNoVirtualToArray( - 26, this->train_state(), target); + InternalWriteMessageNoVirtualToArray( + 26, *this->train_state_, false, target); } // repeated .caffe.NetState test_state = 27; - for (int i = 0; i < this->test_state_size(); i++) { + for (unsigned int i = 0, n = this->test_state_size(); i < n; i++) { target = ::google::protobuf::internal::WireFormatLite:: - WriteMessageNoVirtualToArray( - 27, this->test_state(i), target); + InternalWriteMessageNoVirtualToArray( + 27, this->test_state(i), false, target); } // optional bool snapshot_after_train = 28 [default = true]; @@ -7728,9 +9932,10 @@ void SolverParameter::SerializeWithCachedSizes( // optional string regularization_type = 29 [default = "L2"]; if (has_regularization_type()) { - ::google::protobuf::internal::WireFormat::VerifyUTF8String( + ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( this->regularization_type().data(), this->regularization_type().length(), - ::google::protobuf::internal::WireFormat::SERIALIZE); + ::google::protobuf::internal::WireFormat::SERIALIZE, + "caffe.SolverParameter.regularization_type"); target = ::google::protobuf::internal::WireFormatLite::WriteStringToArray( 29, this->regularization_type(), target); @@ -7773,17 +9978,19 @@ void SolverParameter::SerializeWithCachedSizes( target = ::google::protobuf::internal::WireFormatLite::WriteInt32ToArray(36, this->iter_size(), target); } - if (!unknown_fields().empty()) { + if (_internal_metadata_.have_unknown_fields()) { target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray( unknown_fields(), target); } + // @@protoc_insertion_point(serialize_to_array_end:caffe.SolverParameter) return target; } -int SolverParameter::ByteSize() const { - int total_size = 0; +size_t SolverParameter::ByteSizeLong() const { +// @@protoc_insertion_point(message_byte_size_start:caffe.SolverParameter) + size_t total_size = 0; - if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) { + if (_has_bits_[0 / 32] & 87u) { // optional string net = 24; if (has_net()) { total_size += 2 + @@ -7795,7 +10002,7 @@ int SolverParameter::ByteSize() const { if (has_net_param()) { total_size += 2 + ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( - this->net_param()); + *this->net_param_); } // optional string train_net = 1; @@ -7809,18 +10016,18 @@ int SolverParameter::ByteSize() const { if (has_train_net_param()) { total_size += 2 + ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( - this->train_net_param()); + *this->train_net_param_); } // optional .caffe.NetState train_state = 26; if (has_train_state()) { total_size += 2 + ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( - this->train_state()); + *this->train_state_); } } - if (_has_bits_[9 / 32] & (0xffu << (9 % 32))) { + if (_has_bits_[9 / 32] & 65024u) { // optional int32 test_interval = 4 [default = 0]; if (has_test_interval()) { total_size += 1 + @@ -7865,7 +10072,7 @@ int SolverParameter::ByteSize() const { } } - if (_has_bits_[16 / 32] & (0xffu << (16 % 32))) { + if (_has_bits_[16 / 32] & 16711680u) { // optional int32 iter_size = 36 [default = 1]; if (has_iter_size()) { total_size += 2 + @@ -7915,7 +10122,7 @@ int SolverParameter::ByteSize() const { } } - if (_has_bits_[25 / 32] & (0xffu << (25 % 32))) { + if (_has_bits_[25 / 32] & 4261412864u) { // optional float clip_gradients = 35 [default = -1]; if (has_clip_gradients()) { total_size += 2 + 4; @@ -7961,7 +10168,7 @@ int SolverParameter::ByteSize() const { } } - if (_has_bits_[32 / 32] & (0xffu << (32 % 32))) { + if (_has_bits_[32 / 32] & 15u) { // optional .caffe.SolverParameter.SolverType solver_type = 30 [default = SGD]; if (has_solver_type()) { total_size += 2 + @@ -7985,87 +10192,115 @@ int SolverParameter::ByteSize() const { } // repeated string test_net = 2; - total_size += 1 * this->test_net_size(); + total_size += 1 * + ::google::protobuf::internal::FromIntSize(this->test_net_size()); for (int i = 0; i < this->test_net_size(); i++) { total_size += ::google::protobuf::internal::WireFormatLite::StringSize( this->test_net(i)); } // repeated .caffe.NetParameter test_net_param = 22; - total_size += 2 * this->test_net_param_size(); - for (int i = 0; i < this->test_net_param_size(); i++) { - total_size += - ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( - this->test_net_param(i)); + { + unsigned int count = this->test_net_param_size(); + total_size += 2UL * count; + for (unsigned int i = 0; i < count; i++) { + total_size += + ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( + this->test_net_param(i)); + } } // repeated .caffe.NetState test_state = 27; - total_size += 2 * this->test_state_size(); - for (int i = 0; i < this->test_state_size(); i++) { - total_size += - ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( - this->test_state(i)); + { + unsigned int count = this->test_state_size(); + total_size += 2UL * count; + for (unsigned int i = 0; i < count; i++) { + total_size += + ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( + this->test_state(i)); + } } // repeated int32 test_iter = 3; { - int data_size = 0; - for (int i = 0; i < this->test_iter_size(); i++) { + size_t data_size = 0; + unsigned int count = this->test_iter_size(); + for (unsigned int i = 0; i < count; i++) { data_size += ::google::protobuf::internal::WireFormatLite:: Int32Size(this->test_iter(i)); } - total_size += 1 * this->test_iter_size() + data_size; + total_size += 1 * + ::google::protobuf::internal::FromIntSize(this->test_iter_size()); + total_size += data_size; } // repeated int32 stepvalue = 34; { - int data_size = 0; - for (int i = 0; i < this->stepvalue_size(); i++) { + size_t data_size = 0; + unsigned int count = this->stepvalue_size(); + for (unsigned int i = 0; i < count; i++) { data_size += ::google::protobuf::internal::WireFormatLite:: Int32Size(this->stepvalue(i)); } - total_size += 2 * this->stepvalue_size() + data_size; + total_size += 2 * + ::google::protobuf::internal::FromIntSize(this->stepvalue_size()); + total_size += data_size; } - if (!unknown_fields().empty()) { + if (_internal_metadata_.have_unknown_fields()) { total_size += ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( unknown_fields()); } + int cached_size = ::google::protobuf::internal::ToCachedSize(total_size); GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); - _cached_size_ = total_size; + _cached_size_ = cached_size; GOOGLE_SAFE_CONCURRENT_WRITES_END(); return total_size; } void SolverParameter::MergeFrom(const ::google::protobuf::Message& from) { - GOOGLE_CHECK_NE(&from, this); +// @@protoc_insertion_point(generalized_merge_from_start:caffe.SolverParameter) + if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__); const SolverParameter* source = - ::google::protobuf::internal::dynamic_cast_if_available( - &from); + ::google::protobuf::internal::DynamicCastToGenerated( + &from); if (source == NULL) { + // @@protoc_insertion_point(generalized_merge_from_cast_fail:caffe.SolverParameter) ::google::protobuf::internal::ReflectionOps::Merge(from, this); } else { - MergeFrom(*source); + // @@protoc_insertion_point(generalized_merge_from_cast_success:caffe.SolverParameter) + UnsafeMergeFrom(*source); } } void SolverParameter::MergeFrom(const SolverParameter& from) { - GOOGLE_CHECK_NE(&from, this); - test_net_.MergeFrom(from.test_net_); +// @@protoc_insertion_point(class_specific_merge_from_start:caffe.SolverParameter) + if (GOOGLE_PREDICT_TRUE(&from != this)) { + UnsafeMergeFrom(from); + } else { + MergeFromFail(__LINE__); + } +} + +void SolverParameter::UnsafeMergeFrom(const SolverParameter& from) { + GOOGLE_DCHECK(&from != this); + test_net_.UnsafeMergeFrom(from.test_net_); test_net_param_.MergeFrom(from.test_net_param_); test_state_.MergeFrom(from.test_state_); - test_iter_.MergeFrom(from.test_iter_); - stepvalue_.MergeFrom(from.stepvalue_); + test_iter_.UnsafeMergeFrom(from.test_iter_); + stepvalue_.UnsafeMergeFrom(from.stepvalue_); if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) { if (from.has_net()) { - set_net(from.net()); + set_has_net(); + net_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.net_); } if (from.has_net_param()) { mutable_net_param()->::caffe::NetParameter::MergeFrom(from.net_param()); } if (from.has_train_net()) { - set_train_net(from.train_net()); + set_has_train_net(); + train_net_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.train_net_); } if (from.has_train_net_param()) { mutable_train_net_param()->::caffe::NetParameter::MergeFrom(from.train_net_param()); @@ -8102,7 +10337,8 @@ void SolverParameter::MergeFrom(const SolverParameter& from) { set_iter_size(from.iter_size()); } if (from.has_lr_policy()) { - set_lr_policy(from.lr_policy()); + set_has_lr_policy(); + lr_policy_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.lr_policy_); } if (from.has_gamma()) { set_gamma(from.gamma()); @@ -8117,7 +10353,8 @@ void SolverParameter::MergeFrom(const SolverParameter& from) { set_weight_decay(from.weight_decay()); } if (from.has_regularization_type()) { - set_regularization_type(from.regularization_type()); + set_has_regularization_type(); + regularization_type_.AssignWithDefault(_default_regularization_type_, from.regularization_type_); } if (from.has_stepsize()) { set_stepsize(from.stepsize()); @@ -8131,7 +10368,8 @@ void SolverParameter::MergeFrom(const SolverParameter& from) { set_snapshot(from.snapshot()); } if (from.has_snapshot_prefix()) { - set_snapshot_prefix(from.snapshot_prefix()); + set_has_snapshot_prefix(); + snapshot_prefix_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.snapshot_prefix_); } if (from.has_snapshot_diff()) { set_snapshot_diff(from.snapshot_diff()); @@ -8160,19 +10398,24 @@ void SolverParameter::MergeFrom(const SolverParameter& from) { set_snapshot_after_train(from.snapshot_after_train()); } } - mutable_unknown_fields()->MergeFrom(from.unknown_fields()); + if (from._internal_metadata_.have_unknown_fields()) { + ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata( + from.unknown_fields(), &_internal_metadata_); + } } void SolverParameter::CopyFrom(const ::google::protobuf::Message& from) { +// @@protoc_insertion_point(generalized_copy_from_start:caffe.SolverParameter) if (&from == this) return; Clear(); MergeFrom(from); } void SolverParameter::CopyFrom(const SolverParameter& from) { +// @@protoc_insertion_point(class_specific_copy_from_start:caffe.SolverParameter) if (&from == this) return; Clear(); - MergeFrom(from); + UnsafeMergeFrom(from); } bool SolverParameter::IsInitialized() const { @@ -8181,48 +10424,50 @@ bool SolverParameter::IsInitialized() const { } void SolverParameter::Swap(SolverParameter* other) { - if (other != this) { - std::swap(net_, other->net_); - std::swap(net_param_, other->net_param_); - std::swap(train_net_, other->train_net_); - test_net_.Swap(&other->test_net_); - std::swap(train_net_param_, other->train_net_param_); - test_net_param_.Swap(&other->test_net_param_); - std::swap(train_state_, other->train_state_); - test_state_.Swap(&other->test_state_); - test_iter_.Swap(&other->test_iter_); - std::swap(test_interval_, other->test_interval_); - std::swap(test_compute_loss_, other->test_compute_loss_); - std::swap(test_initialization_, other->test_initialization_); - std::swap(base_lr_, other->base_lr_); - std::swap(display_, other->display_); - std::swap(average_loss_, other->average_loss_); - std::swap(max_iter_, other->max_iter_); - std::swap(iter_size_, other->iter_size_); - std::swap(lr_policy_, other->lr_policy_); - std::swap(gamma_, other->gamma_); - std::swap(power_, other->power_); - std::swap(momentum_, other->momentum_); - std::swap(weight_decay_, other->weight_decay_); - std::swap(regularization_type_, other->regularization_type_); - std::swap(stepsize_, other->stepsize_); - stepvalue_.Swap(&other->stepvalue_); - std::swap(clip_gradients_, other->clip_gradients_); - std::swap(snapshot_, other->snapshot_); - std::swap(snapshot_prefix_, other->snapshot_prefix_); - std::swap(snapshot_diff_, other->snapshot_diff_); - std::swap(solver_mode_, other->solver_mode_); - std::swap(device_id_, other->device_id_); - std::swap(random_seed_, other->random_seed_); - std::swap(solver_type_, other->solver_type_); - std::swap(delta_, other->delta_); - std::swap(debug_info_, other->debug_info_); - std::swap(snapshot_after_train_, other->snapshot_after_train_); - std::swap(_has_bits_[0], other->_has_bits_[0]); - std::swap(_has_bits_[1], other->_has_bits_[1]); - _unknown_fields_.Swap(&other->_unknown_fields_); - std::swap(_cached_size_, other->_cached_size_); - } + if (other == this) return; + InternalSwap(other); +} +void SolverParameter::InternalSwap(SolverParameter* other) { + net_.Swap(&other->net_); + std::swap(net_param_, other->net_param_); + train_net_.Swap(&other->train_net_); + test_net_.UnsafeArenaSwap(&other->test_net_); + std::swap(train_net_param_, other->train_net_param_); + test_net_param_.UnsafeArenaSwap(&other->test_net_param_); + std::swap(train_state_, other->train_state_); + test_state_.UnsafeArenaSwap(&other->test_state_); + test_iter_.UnsafeArenaSwap(&other->test_iter_); + std::swap(test_interval_, other->test_interval_); + std::swap(test_compute_loss_, other->test_compute_loss_); + std::swap(test_initialization_, other->test_initialization_); + std::swap(base_lr_, other->base_lr_); + std::swap(display_, other->display_); + std::swap(average_loss_, other->average_loss_); + std::swap(max_iter_, other->max_iter_); + std::swap(iter_size_, other->iter_size_); + lr_policy_.Swap(&other->lr_policy_); + std::swap(gamma_, other->gamma_); + std::swap(power_, other->power_); + std::swap(momentum_, other->momentum_); + std::swap(weight_decay_, other->weight_decay_); + regularization_type_.Swap(&other->regularization_type_); + std::swap(stepsize_, other->stepsize_); + stepvalue_.UnsafeArenaSwap(&other->stepvalue_); + std::swap(clip_gradients_, other->clip_gradients_); + std::swap(snapshot_, other->snapshot_); + snapshot_prefix_.Swap(&other->snapshot_prefix_); + std::swap(snapshot_diff_, other->snapshot_diff_); + std::swap(solver_mode_, other->solver_mode_); + std::swap(device_id_, other->device_id_); + std::swap(random_seed_, other->random_seed_); + std::swap(solver_type_, other->solver_type_); + std::swap(delta_, other->delta_); + std::swap(debug_info_, other->debug_info_); + std::swap(snapshot_after_train_, other->snapshot_after_train_); + std::swap(_has_bits_[0], other->_has_bits_[0]); + std::swap(_has_bits_[1], other->_has_bits_[1]); + _internal_metadata_.Swap(&other->_internal_metadata_); + std::swap(_cached_size_, other->_cached_size_); } ::google::protobuf::Metadata SolverParameter::GetMetadata() const { @@ -8233,487 +10478,1330 @@ void SolverParameter::Swap(SolverParameter* other) { return metadata; } +#if PROTOBUF_INLINE_NOT_IN_HEADERS +// SolverParameter -// =================================================================== - -#ifndef _MSC_VER -const int SolverState::kIterFieldNumber; -const int SolverState::kLearnedNetFieldNumber; -const int SolverState::kHistoryFieldNumber; -const int SolverState::kCurrentStepFieldNumber; -#endif // !_MSC_VER +// optional string net = 24; +bool SolverParameter::has_net() const { + return (_has_bits_[0] & 0x00000001u) != 0; +} +void SolverParameter::set_has_net() { + _has_bits_[0] |= 0x00000001u; +} +void SolverParameter::clear_has_net() { + _has_bits_[0] &= ~0x00000001u; +} +void SolverParameter::clear_net() { + net_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + clear_has_net(); +} +const ::std::string& SolverParameter::net() const { + // @@protoc_insertion_point(field_get:caffe.SolverParameter.net) + return net_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); +} +void SolverParameter::set_net(const ::std::string& value) { + set_has_net(); + net_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); + // @@protoc_insertion_point(field_set:caffe.SolverParameter.net) +} +void SolverParameter::set_net(const char* value) { + set_has_net(); + net_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); + // @@protoc_insertion_point(field_set_char:caffe.SolverParameter.net) +} +void SolverParameter::set_net(const char* value, size_t size) { + set_has_net(); + net_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), + ::std::string(reinterpret_cast(value), size)); + // @@protoc_insertion_point(field_set_pointer:caffe.SolverParameter.net) +} +::std::string* SolverParameter::mutable_net() { + set_has_net(); + // @@protoc_insertion_point(field_mutable:caffe.SolverParameter.net) + return net_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); +} +::std::string* SolverParameter::release_net() { + // @@protoc_insertion_point(field_release:caffe.SolverParameter.net) + clear_has_net(); + return net_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); +} +void SolverParameter::set_allocated_net(::std::string* net) { + if (net != NULL) { + set_has_net(); + } else { + clear_has_net(); + } + net_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), net); + // @@protoc_insertion_point(field_set_allocated:caffe.SolverParameter.net) +} -SolverState::SolverState() - : ::google::protobuf::Message() { - SharedCtor(); +// optional .caffe.NetParameter net_param = 25; +bool SolverParameter::has_net_param() const { + return (_has_bits_[0] & 0x00000002u) != 0; +} +void SolverParameter::set_has_net_param() { + _has_bits_[0] |= 0x00000002u; +} +void SolverParameter::clear_has_net_param() { + _has_bits_[0] &= ~0x00000002u; +} +void SolverParameter::clear_net_param() { + if (net_param_ != NULL) net_param_->::caffe::NetParameter::Clear(); + clear_has_net_param(); +} +const ::caffe::NetParameter& SolverParameter::net_param() const { + // @@protoc_insertion_point(field_get:caffe.SolverParameter.net_param) + return net_param_ != NULL ? *net_param_ + : *::caffe::NetParameter::internal_default_instance(); +} +::caffe::NetParameter* SolverParameter::mutable_net_param() { + set_has_net_param(); + if (net_param_ == NULL) { + net_param_ = new ::caffe::NetParameter; + } + // @@protoc_insertion_point(field_mutable:caffe.SolverParameter.net_param) + return net_param_; +} +::caffe::NetParameter* SolverParameter::release_net_param() { + // @@protoc_insertion_point(field_release:caffe.SolverParameter.net_param) + clear_has_net_param(); + ::caffe::NetParameter* temp = net_param_; + net_param_ = NULL; + return temp; +} +void SolverParameter::set_allocated_net_param(::caffe::NetParameter* net_param) { + delete net_param_; + net_param_ = net_param; + if (net_param) { + set_has_net_param(); + } else { + clear_has_net_param(); + } + // @@protoc_insertion_point(field_set_allocated:caffe.SolverParameter.net_param) } -void SolverState::InitAsDefaultInstance() { +// optional string train_net = 1; +bool SolverParameter::has_train_net() const { + return (_has_bits_[0] & 0x00000004u) != 0; +} +void SolverParameter::set_has_train_net() { + _has_bits_[0] |= 0x00000004u; +} +void SolverParameter::clear_has_train_net() { + _has_bits_[0] &= ~0x00000004u; +} +void SolverParameter::clear_train_net() { + train_net_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + clear_has_train_net(); +} +const ::std::string& SolverParameter::train_net() const { + // @@protoc_insertion_point(field_get:caffe.SolverParameter.train_net) + return train_net_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); +} +void SolverParameter::set_train_net(const ::std::string& value) { + set_has_train_net(); + train_net_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); + // @@protoc_insertion_point(field_set:caffe.SolverParameter.train_net) +} +void SolverParameter::set_train_net(const char* value) { + set_has_train_net(); + train_net_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); + // @@protoc_insertion_point(field_set_char:caffe.SolverParameter.train_net) +} +void SolverParameter::set_train_net(const char* value, size_t size) { + set_has_train_net(); + train_net_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), + ::std::string(reinterpret_cast(value), size)); + // @@protoc_insertion_point(field_set_pointer:caffe.SolverParameter.train_net) +} +::std::string* SolverParameter::mutable_train_net() { + set_has_train_net(); + // @@protoc_insertion_point(field_mutable:caffe.SolverParameter.train_net) + return train_net_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); +} +::std::string* SolverParameter::release_train_net() { + // @@protoc_insertion_point(field_release:caffe.SolverParameter.train_net) + clear_has_train_net(); + return train_net_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); +} +void SolverParameter::set_allocated_train_net(::std::string* train_net) { + if (train_net != NULL) { + set_has_train_net(); + } else { + clear_has_train_net(); + } + train_net_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), train_net); + // @@protoc_insertion_point(field_set_allocated:caffe.SolverParameter.train_net) } -SolverState::SolverState(const SolverState& from) - : ::google::protobuf::Message() { - SharedCtor(); - MergeFrom(from); +// repeated string test_net = 2; +int SolverParameter::test_net_size() const { + return test_net_.size(); +} +void SolverParameter::clear_test_net() { + test_net_.Clear(); +} +const ::std::string& SolverParameter::test_net(int index) const { + // @@protoc_insertion_point(field_get:caffe.SolverParameter.test_net) + return test_net_.Get(index); +} +::std::string* SolverParameter::mutable_test_net(int index) { + // @@protoc_insertion_point(field_mutable:caffe.SolverParameter.test_net) + return test_net_.Mutable(index); +} +void SolverParameter::set_test_net(int index, const ::std::string& value) { + // @@protoc_insertion_point(field_set:caffe.SolverParameter.test_net) + test_net_.Mutable(index)->assign(value); +} +void SolverParameter::set_test_net(int index, const char* value) { + test_net_.Mutable(index)->assign(value); + // @@protoc_insertion_point(field_set_char:caffe.SolverParameter.test_net) +} +void SolverParameter::set_test_net(int index, const char* value, size_t size) { + test_net_.Mutable(index)->assign( + reinterpret_cast(value), size); + // @@protoc_insertion_point(field_set_pointer:caffe.SolverParameter.test_net) +} +::std::string* SolverParameter::add_test_net() { + // @@protoc_insertion_point(field_add_mutable:caffe.SolverParameter.test_net) + return test_net_.Add(); +} +void SolverParameter::add_test_net(const ::std::string& value) { + test_net_.Add()->assign(value); + // @@protoc_insertion_point(field_add:caffe.SolverParameter.test_net) +} +void SolverParameter::add_test_net(const char* value) { + test_net_.Add()->assign(value); + // @@protoc_insertion_point(field_add_char:caffe.SolverParameter.test_net) +} +void SolverParameter::add_test_net(const char* value, size_t size) { + test_net_.Add()->assign(reinterpret_cast(value), size); + // @@protoc_insertion_point(field_add_pointer:caffe.SolverParameter.test_net) +} +const ::google::protobuf::RepeatedPtrField< ::std::string>& +SolverParameter::test_net() const { + // @@protoc_insertion_point(field_list:caffe.SolverParameter.test_net) + return test_net_; +} +::google::protobuf::RepeatedPtrField< ::std::string>* +SolverParameter::mutable_test_net() { + // @@protoc_insertion_point(field_mutable_list:caffe.SolverParameter.test_net) + return &test_net_; } -void SolverState::SharedCtor() { - _cached_size_ = 0; - iter_ = 0; - learned_net_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); - current_step_ = 0; - ::memset(_has_bits_, 0, sizeof(_has_bits_)); +// optional .caffe.NetParameter train_net_param = 21; +bool SolverParameter::has_train_net_param() const { + return (_has_bits_[0] & 0x00000010u) != 0; +} +void SolverParameter::set_has_train_net_param() { + _has_bits_[0] |= 0x00000010u; +} +void SolverParameter::clear_has_train_net_param() { + _has_bits_[0] &= ~0x00000010u; +} +void SolverParameter::clear_train_net_param() { + if (train_net_param_ != NULL) train_net_param_->::caffe::NetParameter::Clear(); + clear_has_train_net_param(); +} +const ::caffe::NetParameter& SolverParameter::train_net_param() const { + // @@protoc_insertion_point(field_get:caffe.SolverParameter.train_net_param) + return train_net_param_ != NULL ? *train_net_param_ + : *::caffe::NetParameter::internal_default_instance(); +} +::caffe::NetParameter* SolverParameter::mutable_train_net_param() { + set_has_train_net_param(); + if (train_net_param_ == NULL) { + train_net_param_ = new ::caffe::NetParameter; + } + // @@protoc_insertion_point(field_mutable:caffe.SolverParameter.train_net_param) + return train_net_param_; +} +::caffe::NetParameter* SolverParameter::release_train_net_param() { + // @@protoc_insertion_point(field_release:caffe.SolverParameter.train_net_param) + clear_has_train_net_param(); + ::caffe::NetParameter* temp = train_net_param_; + train_net_param_ = NULL; + return temp; +} +void SolverParameter::set_allocated_train_net_param(::caffe::NetParameter* train_net_param) { + delete train_net_param_; + train_net_param_ = train_net_param; + if (train_net_param) { + set_has_train_net_param(); + } else { + clear_has_train_net_param(); + } + // @@protoc_insertion_point(field_set_allocated:caffe.SolverParameter.train_net_param) } -SolverState::~SolverState() { - SharedDtor(); +// repeated .caffe.NetParameter test_net_param = 22; +int SolverParameter::test_net_param_size() const { + return test_net_param_.size(); +} +void SolverParameter::clear_test_net_param() { + test_net_param_.Clear(); +} +const ::caffe::NetParameter& SolverParameter::test_net_param(int index) const { + // @@protoc_insertion_point(field_get:caffe.SolverParameter.test_net_param) + return test_net_param_.Get(index); +} +::caffe::NetParameter* SolverParameter::mutable_test_net_param(int index) { + // @@protoc_insertion_point(field_mutable:caffe.SolverParameter.test_net_param) + return test_net_param_.Mutable(index); +} +::caffe::NetParameter* SolverParameter::add_test_net_param() { + // @@protoc_insertion_point(field_add:caffe.SolverParameter.test_net_param) + return test_net_param_.Add(); +} +::google::protobuf::RepeatedPtrField< ::caffe::NetParameter >* +SolverParameter::mutable_test_net_param() { + // @@protoc_insertion_point(field_mutable_list:caffe.SolverParameter.test_net_param) + return &test_net_param_; +} +const ::google::protobuf::RepeatedPtrField< ::caffe::NetParameter >& +SolverParameter::test_net_param() const { + // @@protoc_insertion_point(field_list:caffe.SolverParameter.test_net_param) + return test_net_param_; } -void SolverState::SharedDtor() { - if (learned_net_ != &::google::protobuf::internal::kEmptyString) { - delete learned_net_; +// optional .caffe.NetState train_state = 26; +bool SolverParameter::has_train_state() const { + return (_has_bits_[0] & 0x00000040u) != 0; +} +void SolverParameter::set_has_train_state() { + _has_bits_[0] |= 0x00000040u; +} +void SolverParameter::clear_has_train_state() { + _has_bits_[0] &= ~0x00000040u; +} +void SolverParameter::clear_train_state() { + if (train_state_ != NULL) train_state_->::caffe::NetState::Clear(); + clear_has_train_state(); +} +const ::caffe::NetState& SolverParameter::train_state() const { + // @@protoc_insertion_point(field_get:caffe.SolverParameter.train_state) + return train_state_ != NULL ? *train_state_ + : *::caffe::NetState::internal_default_instance(); +} +::caffe::NetState* SolverParameter::mutable_train_state() { + set_has_train_state(); + if (train_state_ == NULL) { + train_state_ = new ::caffe::NetState; } - if (this != default_instance_) { + // @@protoc_insertion_point(field_mutable:caffe.SolverParameter.train_state) + return train_state_; +} +::caffe::NetState* SolverParameter::release_train_state() { + // @@protoc_insertion_point(field_release:caffe.SolverParameter.train_state) + clear_has_train_state(); + ::caffe::NetState* temp = train_state_; + train_state_ = NULL; + return temp; +} +void SolverParameter::set_allocated_train_state(::caffe::NetState* train_state) { + delete train_state_; + train_state_ = train_state; + if (train_state) { + set_has_train_state(); + } else { + clear_has_train_state(); } + // @@protoc_insertion_point(field_set_allocated:caffe.SolverParameter.train_state) } -void SolverState::SetCachedSize(int size) const { - GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); - _cached_size_ = size; - GOOGLE_SAFE_CONCURRENT_WRITES_END(); +// repeated .caffe.NetState test_state = 27; +int SolverParameter::test_state_size() const { + return test_state_.size(); } -const ::google::protobuf::Descriptor* SolverState::descriptor() { - protobuf_AssignDescriptorsOnce(); - return SolverState_descriptor_; +void SolverParameter::clear_test_state() { + test_state_.Clear(); +} +const ::caffe::NetState& SolverParameter::test_state(int index) const { + // @@protoc_insertion_point(field_get:caffe.SolverParameter.test_state) + return test_state_.Get(index); +} +::caffe::NetState* SolverParameter::mutable_test_state(int index) { + // @@protoc_insertion_point(field_mutable:caffe.SolverParameter.test_state) + return test_state_.Mutable(index); +} +::caffe::NetState* SolverParameter::add_test_state() { + // @@protoc_insertion_point(field_add:caffe.SolverParameter.test_state) + return test_state_.Add(); +} +::google::protobuf::RepeatedPtrField< ::caffe::NetState >* +SolverParameter::mutable_test_state() { + // @@protoc_insertion_point(field_mutable_list:caffe.SolverParameter.test_state) + return &test_state_; +} +const ::google::protobuf::RepeatedPtrField< ::caffe::NetState >& +SolverParameter::test_state() const { + // @@protoc_insertion_point(field_list:caffe.SolverParameter.test_state) + return test_state_; } -const SolverState& SolverState::default_instance() { - if (default_instance_ == NULL) protobuf_AddDesc_caffe_2eproto(); - return *default_instance_; +// repeated int32 test_iter = 3; +int SolverParameter::test_iter_size() const { + return test_iter_.size(); +} +void SolverParameter::clear_test_iter() { + test_iter_.Clear(); +} +::google::protobuf::int32 SolverParameter::test_iter(int index) const { + // @@protoc_insertion_point(field_get:caffe.SolverParameter.test_iter) + return test_iter_.Get(index); +} +void SolverParameter::set_test_iter(int index, ::google::protobuf::int32 value) { + test_iter_.Set(index, value); + // @@protoc_insertion_point(field_set:caffe.SolverParameter.test_iter) +} +void SolverParameter::add_test_iter(::google::protobuf::int32 value) { + test_iter_.Add(value); + // @@protoc_insertion_point(field_add:caffe.SolverParameter.test_iter) +} +const ::google::protobuf::RepeatedField< ::google::protobuf::int32 >& +SolverParameter::test_iter() const { + // @@protoc_insertion_point(field_list:caffe.SolverParameter.test_iter) + return test_iter_; +} +::google::protobuf::RepeatedField< ::google::protobuf::int32 >* +SolverParameter::mutable_test_iter() { + // @@protoc_insertion_point(field_mutable_list:caffe.SolverParameter.test_iter) + return &test_iter_; } -SolverState* SolverState::default_instance_ = NULL; +// optional int32 test_interval = 4 [default = 0]; +bool SolverParameter::has_test_interval() const { + return (_has_bits_[0] & 0x00000200u) != 0; +} +void SolverParameter::set_has_test_interval() { + _has_bits_[0] |= 0x00000200u; +} +void SolverParameter::clear_has_test_interval() { + _has_bits_[0] &= ~0x00000200u; +} +void SolverParameter::clear_test_interval() { + test_interval_ = 0; + clear_has_test_interval(); +} +::google::protobuf::int32 SolverParameter::test_interval() const { + // @@protoc_insertion_point(field_get:caffe.SolverParameter.test_interval) + return test_interval_; +} +void SolverParameter::set_test_interval(::google::protobuf::int32 value) { + set_has_test_interval(); + test_interval_ = value; + // @@protoc_insertion_point(field_set:caffe.SolverParameter.test_interval) +} -SolverState* SolverState::New() const { - return new SolverState; +// optional bool test_compute_loss = 19 [default = false]; +bool SolverParameter::has_test_compute_loss() const { + return (_has_bits_[0] & 0x00000400u) != 0; +} +void SolverParameter::set_has_test_compute_loss() { + _has_bits_[0] |= 0x00000400u; +} +void SolverParameter::clear_has_test_compute_loss() { + _has_bits_[0] &= ~0x00000400u; +} +void SolverParameter::clear_test_compute_loss() { + test_compute_loss_ = false; + clear_has_test_compute_loss(); +} +bool SolverParameter::test_compute_loss() const { + // @@protoc_insertion_point(field_get:caffe.SolverParameter.test_compute_loss) + return test_compute_loss_; +} +void SolverParameter::set_test_compute_loss(bool value) { + set_has_test_compute_loss(); + test_compute_loss_ = value; + // @@protoc_insertion_point(field_set:caffe.SolverParameter.test_compute_loss) } -void SolverState::Clear() { - if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) { - iter_ = 0; - if (has_learned_net()) { - if (learned_net_ != &::google::protobuf::internal::kEmptyString) { - learned_net_->clear(); - } - } - current_step_ = 0; - } - history_.Clear(); - ::memset(_has_bits_, 0, sizeof(_has_bits_)); - mutable_unknown_fields()->Clear(); +// optional bool test_initialization = 32 [default = true]; +bool SolverParameter::has_test_initialization() const { + return (_has_bits_[0] & 0x00000800u) != 0; +} +void SolverParameter::set_has_test_initialization() { + _has_bits_[0] |= 0x00000800u; +} +void SolverParameter::clear_has_test_initialization() { + _has_bits_[0] &= ~0x00000800u; +} +void SolverParameter::clear_test_initialization() { + test_initialization_ = true; + clear_has_test_initialization(); +} +bool SolverParameter::test_initialization() const { + // @@protoc_insertion_point(field_get:caffe.SolverParameter.test_initialization) + return test_initialization_; +} +void SolverParameter::set_test_initialization(bool value) { + set_has_test_initialization(); + test_initialization_ = value; + // @@protoc_insertion_point(field_set:caffe.SolverParameter.test_initialization) } -bool SolverState::MergePartialFromCodedStream( - ::google::protobuf::io::CodedInputStream* input) { -#define DO_(EXPRESSION) if (!(EXPRESSION)) return false - ::google::protobuf::uint32 tag; - while ((tag = input->ReadTag()) != 0) { - switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { - // optional int32 iter = 1; - case 1: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) { - DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< - ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>( - input, &iter_))); - set_has_iter(); - } else { - goto handle_uninterpreted; - } - if (input->ExpectTag(18)) goto parse_learned_net; - break; - } +// optional float base_lr = 5; +bool SolverParameter::has_base_lr() const { + return (_has_bits_[0] & 0x00001000u) != 0; +} +void SolverParameter::set_has_base_lr() { + _has_bits_[0] |= 0x00001000u; +} +void SolverParameter::clear_has_base_lr() { + _has_bits_[0] &= ~0x00001000u; +} +void SolverParameter::clear_base_lr() { + base_lr_ = 0; + clear_has_base_lr(); +} +float SolverParameter::base_lr() const { + // @@protoc_insertion_point(field_get:caffe.SolverParameter.base_lr) + return base_lr_; +} +void SolverParameter::set_base_lr(float value) { + set_has_base_lr(); + base_lr_ = value; + // @@protoc_insertion_point(field_set:caffe.SolverParameter.base_lr) +} - // optional string learned_net = 2; - case 2: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) { - parse_learned_net: - DO_(::google::protobuf::internal::WireFormatLite::ReadString( - input, this->mutable_learned_net())); - ::google::protobuf::internal::WireFormat::VerifyUTF8String( - this->learned_net().data(), this->learned_net().length(), - ::google::protobuf::internal::WireFormat::PARSE); - } else { - goto handle_uninterpreted; - } - if (input->ExpectTag(26)) goto parse_history; - break; - } - - // repeated .caffe.BlobProto history = 3; - case 3: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) { - parse_history: - DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual( - input, add_history())); - } else { - goto handle_uninterpreted; - } - if (input->ExpectTag(26)) goto parse_history; - if (input->ExpectTag(32)) goto parse_current_step; - break; - } - - // optional int32 current_step = 4 [default = 0]; - case 4: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) { - parse_current_step: - DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< - ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>( - input, ¤t_step_))); - set_has_current_step(); - } else { - goto handle_uninterpreted; - } - if (input->ExpectAtEnd()) return true; - break; - } - - default: { - handle_uninterpreted: - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) { - return true; - } - DO_(::google::protobuf::internal::WireFormat::SkipField( - input, tag, mutable_unknown_fields())); - break; - } - } - } - return true; -#undef DO_ +// optional int32 display = 6; +bool SolverParameter::has_display() const { + return (_has_bits_[0] & 0x00002000u) != 0; } - -void SolverState::SerializeWithCachedSizes( - ::google::protobuf::io::CodedOutputStream* output) const { - // optional int32 iter = 1; - if (has_iter()) { - ::google::protobuf::internal::WireFormatLite::WriteInt32(1, this->iter(), output); - } - - // optional string learned_net = 2; - if (has_learned_net()) { - ::google::protobuf::internal::WireFormat::VerifyUTF8String( - this->learned_net().data(), this->learned_net().length(), - ::google::protobuf::internal::WireFormat::SERIALIZE); - ::google::protobuf::internal::WireFormatLite::WriteString( - 2, this->learned_net(), output); - } - - // repeated .caffe.BlobProto history = 3; - for (int i = 0; i < this->history_size(); i++) { - ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( - 3, this->history(i), output); - } - - // optional int32 current_step = 4 [default = 0]; - if (has_current_step()) { - ::google::protobuf::internal::WireFormatLite::WriteInt32(4, this->current_step(), output); - } - - if (!unknown_fields().empty()) { - ::google::protobuf::internal::WireFormat::SerializeUnknownFields( - unknown_fields(), output); - } +void SolverParameter::set_has_display() { + _has_bits_[0] |= 0x00002000u; } - -::google::protobuf::uint8* SolverState::SerializeWithCachedSizesToArray( - ::google::protobuf::uint8* target) const { - // optional int32 iter = 1; - if (has_iter()) { - target = ::google::protobuf::internal::WireFormatLite::WriteInt32ToArray(1, this->iter(), target); - } - - // optional string learned_net = 2; - if (has_learned_net()) { - ::google::protobuf::internal::WireFormat::VerifyUTF8String( - this->learned_net().data(), this->learned_net().length(), - ::google::protobuf::internal::WireFormat::SERIALIZE); - target = - ::google::protobuf::internal::WireFormatLite::WriteStringToArray( - 2, this->learned_net(), target); - } - - // repeated .caffe.BlobProto history = 3; - for (int i = 0; i < this->history_size(); i++) { - target = ::google::protobuf::internal::WireFormatLite:: - WriteMessageNoVirtualToArray( - 3, this->history(i), target); - } - - // optional int32 current_step = 4 [default = 0]; - if (has_current_step()) { - target = ::google::protobuf::internal::WireFormatLite::WriteInt32ToArray(4, this->current_step(), target); - } - - if (!unknown_fields().empty()) { - target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray( - unknown_fields(), target); - } - return target; +void SolverParameter::clear_has_display() { + _has_bits_[0] &= ~0x00002000u; +} +void SolverParameter::clear_display() { + display_ = 0; + clear_has_display(); +} +::google::protobuf::int32 SolverParameter::display() const { + // @@protoc_insertion_point(field_get:caffe.SolverParameter.display) + return display_; +} +void SolverParameter::set_display(::google::protobuf::int32 value) { + set_has_display(); + display_ = value; + // @@protoc_insertion_point(field_set:caffe.SolverParameter.display) } -int SolverState::ByteSize() const { - int total_size = 0; - - if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) { - // optional int32 iter = 1; - if (has_iter()) { - total_size += 1 + - ::google::protobuf::internal::WireFormatLite::Int32Size( - this->iter()); - } - - // optional string learned_net = 2; - if (has_learned_net()) { - total_size += 1 + - ::google::protobuf::internal::WireFormatLite::StringSize( - this->learned_net()); - } - - // optional int32 current_step = 4 [default = 0]; - if (has_current_step()) { - total_size += 1 + - ::google::protobuf::internal::WireFormatLite::Int32Size( - this->current_step()); - } +// optional int32 average_loss = 33 [default = 1]; +bool SolverParameter::has_average_loss() const { + return (_has_bits_[0] & 0x00004000u) != 0; +} +void SolverParameter::set_has_average_loss() { + _has_bits_[0] |= 0x00004000u; +} +void SolverParameter::clear_has_average_loss() { + _has_bits_[0] &= ~0x00004000u; +} +void SolverParameter::clear_average_loss() { + average_loss_ = 1; + clear_has_average_loss(); +} +::google::protobuf::int32 SolverParameter::average_loss() const { + // @@protoc_insertion_point(field_get:caffe.SolverParameter.average_loss) + return average_loss_; +} +void SolverParameter::set_average_loss(::google::protobuf::int32 value) { + set_has_average_loss(); + average_loss_ = value; + // @@protoc_insertion_point(field_set:caffe.SolverParameter.average_loss) +} - } - // repeated .caffe.BlobProto history = 3; - total_size += 1 * this->history_size(); - for (int i = 0; i < this->history_size(); i++) { - total_size += - ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( - this->history(i)); - } +// optional int32 max_iter = 7; +bool SolverParameter::has_max_iter() const { + return (_has_bits_[0] & 0x00008000u) != 0; +} +void SolverParameter::set_has_max_iter() { + _has_bits_[0] |= 0x00008000u; +} +void SolverParameter::clear_has_max_iter() { + _has_bits_[0] &= ~0x00008000u; +} +void SolverParameter::clear_max_iter() { + max_iter_ = 0; + clear_has_max_iter(); +} +::google::protobuf::int32 SolverParameter::max_iter() const { + // @@protoc_insertion_point(field_get:caffe.SolverParameter.max_iter) + return max_iter_; +} +void SolverParameter::set_max_iter(::google::protobuf::int32 value) { + set_has_max_iter(); + max_iter_ = value; + // @@protoc_insertion_point(field_set:caffe.SolverParameter.max_iter) +} - if (!unknown_fields().empty()) { - total_size += - ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( - unknown_fields()); - } - GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); - _cached_size_ = total_size; - GOOGLE_SAFE_CONCURRENT_WRITES_END(); - return total_size; +// optional int32 iter_size = 36 [default = 1]; +bool SolverParameter::has_iter_size() const { + return (_has_bits_[0] & 0x00010000u) != 0; +} +void SolverParameter::set_has_iter_size() { + _has_bits_[0] |= 0x00010000u; +} +void SolverParameter::clear_has_iter_size() { + _has_bits_[0] &= ~0x00010000u; +} +void SolverParameter::clear_iter_size() { + iter_size_ = 1; + clear_has_iter_size(); +} +::google::protobuf::int32 SolverParameter::iter_size() const { + // @@protoc_insertion_point(field_get:caffe.SolverParameter.iter_size) + return iter_size_; +} +void SolverParameter::set_iter_size(::google::protobuf::int32 value) { + set_has_iter_size(); + iter_size_ = value; + // @@protoc_insertion_point(field_set:caffe.SolverParameter.iter_size) } -void SolverState::MergeFrom(const ::google::protobuf::Message& from) { - GOOGLE_CHECK_NE(&from, this); - const SolverState* source = - ::google::protobuf::internal::dynamic_cast_if_available( - &from); - if (source == NULL) { - ::google::protobuf::internal::ReflectionOps::Merge(from, this); +// optional string lr_policy = 8; +bool SolverParameter::has_lr_policy() const { + return (_has_bits_[0] & 0x00020000u) != 0; +} +void SolverParameter::set_has_lr_policy() { + _has_bits_[0] |= 0x00020000u; +} +void SolverParameter::clear_has_lr_policy() { + _has_bits_[0] &= ~0x00020000u; +} +void SolverParameter::clear_lr_policy() { + lr_policy_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + clear_has_lr_policy(); +} +const ::std::string& SolverParameter::lr_policy() const { + // @@protoc_insertion_point(field_get:caffe.SolverParameter.lr_policy) + return lr_policy_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); +} +void SolverParameter::set_lr_policy(const ::std::string& value) { + set_has_lr_policy(); + lr_policy_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); + // @@protoc_insertion_point(field_set:caffe.SolverParameter.lr_policy) +} +void SolverParameter::set_lr_policy(const char* value) { + set_has_lr_policy(); + lr_policy_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); + // @@protoc_insertion_point(field_set_char:caffe.SolverParameter.lr_policy) +} +void SolverParameter::set_lr_policy(const char* value, size_t size) { + set_has_lr_policy(); + lr_policy_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), + ::std::string(reinterpret_cast(value), size)); + // @@protoc_insertion_point(field_set_pointer:caffe.SolverParameter.lr_policy) +} +::std::string* SolverParameter::mutable_lr_policy() { + set_has_lr_policy(); + // @@protoc_insertion_point(field_mutable:caffe.SolverParameter.lr_policy) + return lr_policy_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); +} +::std::string* SolverParameter::release_lr_policy() { + // @@protoc_insertion_point(field_release:caffe.SolverParameter.lr_policy) + clear_has_lr_policy(); + return lr_policy_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); +} +void SolverParameter::set_allocated_lr_policy(::std::string* lr_policy) { + if (lr_policy != NULL) { + set_has_lr_policy(); } else { - MergeFrom(*source); + clear_has_lr_policy(); } + lr_policy_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), lr_policy); + // @@protoc_insertion_point(field_set_allocated:caffe.SolverParameter.lr_policy) } -void SolverState::MergeFrom(const SolverState& from) { - GOOGLE_CHECK_NE(&from, this); - history_.MergeFrom(from.history_); - if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) { - if (from.has_iter()) { - set_iter(from.iter()); - } - if (from.has_learned_net()) { - set_learned_net(from.learned_net()); - } - if (from.has_current_step()) { - set_current_step(from.current_step()); - } - } - mutable_unknown_fields()->MergeFrom(from.unknown_fields()); +// optional float gamma = 9; +bool SolverParameter::has_gamma() const { + return (_has_bits_[0] & 0x00040000u) != 0; } - -void SolverState::CopyFrom(const ::google::protobuf::Message& from) { - if (&from == this) return; - Clear(); - MergeFrom(from); +void SolverParameter::set_has_gamma() { + _has_bits_[0] |= 0x00040000u; } - -void SolverState::CopyFrom(const SolverState& from) { - if (&from == this) return; - Clear(); - MergeFrom(from); +void SolverParameter::clear_has_gamma() { + _has_bits_[0] &= ~0x00040000u; } - -bool SolverState::IsInitialized() const { - - return true; +void SolverParameter::clear_gamma() { + gamma_ = 0; + clear_has_gamma(); } - -void SolverState::Swap(SolverState* other) { - if (other != this) { - std::swap(iter_, other->iter_); - std::swap(learned_net_, other->learned_net_); - history_.Swap(&other->history_); - std::swap(current_step_, other->current_step_); - std::swap(_has_bits_[0], other->_has_bits_[0]); - _unknown_fields_.Swap(&other->_unknown_fields_); - std::swap(_cached_size_, other->_cached_size_); - } +float SolverParameter::gamma() const { + // @@protoc_insertion_point(field_get:caffe.SolverParameter.gamma) + return gamma_; } - -::google::protobuf::Metadata SolverState::GetMetadata() const { - protobuf_AssignDescriptorsOnce(); - ::google::protobuf::Metadata metadata; - metadata.descriptor = SolverState_descriptor_; - metadata.reflection = SolverState_reflection_; - return metadata; +void SolverParameter::set_gamma(float value) { + set_has_gamma(); + gamma_ = value; + // @@protoc_insertion_point(field_set:caffe.SolverParameter.gamma) } - -// =================================================================== - -#ifndef _MSC_VER -const int NetState::kPhaseFieldNumber; -const int NetState::kLevelFieldNumber; -const int NetState::kStageFieldNumber; -#endif // !_MSC_VER - -NetState::NetState() - : ::google::protobuf::Message() { - SharedCtor(); +// optional float power = 10; +bool SolverParameter::has_power() const { + return (_has_bits_[0] & 0x00080000u) != 0; } - -void NetState::InitAsDefaultInstance() { +void SolverParameter::set_has_power() { + _has_bits_[0] |= 0x00080000u; } - -NetState::NetState(const NetState& from) - : ::google::protobuf::Message() { - SharedCtor(); - MergeFrom(from); +void SolverParameter::clear_has_power() { + _has_bits_[0] &= ~0x00080000u; } - -void NetState::SharedCtor() { - _cached_size_ = 0; - phase_ = 1; - level_ = 0; - ::memset(_has_bits_, 0, sizeof(_has_bits_)); +void SolverParameter::clear_power() { + power_ = 0; + clear_has_power(); } - -NetState::~NetState() { - SharedDtor(); +float SolverParameter::power() const { + // @@protoc_insertion_point(field_get:caffe.SolverParameter.power) + return power_; } - -void NetState::SharedDtor() { - if (this != default_instance_) { - } +void SolverParameter::set_power(float value) { + set_has_power(); + power_ = value; + // @@protoc_insertion_point(field_set:caffe.SolverParameter.power) } -void NetState::SetCachedSize(int size) const { - GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); - _cached_size_ = size; - GOOGLE_SAFE_CONCURRENT_WRITES_END(); +// optional float momentum = 11; +bool SolverParameter::has_momentum() const { + return (_has_bits_[0] & 0x00100000u) != 0; } -const ::google::protobuf::Descriptor* NetState::descriptor() { - protobuf_AssignDescriptorsOnce(); - return NetState_descriptor_; +void SolverParameter::set_has_momentum() { + _has_bits_[0] |= 0x00100000u; } - -const NetState& NetState::default_instance() { - if (default_instance_ == NULL) protobuf_AddDesc_caffe_2eproto(); - return *default_instance_; +void SolverParameter::clear_has_momentum() { + _has_bits_[0] &= ~0x00100000u; } - -NetState* NetState::default_instance_ = NULL; - -NetState* NetState::New() const { - return new NetState; +void SolverParameter::clear_momentum() { + momentum_ = 0; + clear_has_momentum(); +} +float SolverParameter::momentum() const { + // @@protoc_insertion_point(field_get:caffe.SolverParameter.momentum) + return momentum_; +} +void SolverParameter::set_momentum(float value) { + set_has_momentum(); + momentum_ = value; + // @@protoc_insertion_point(field_set:caffe.SolverParameter.momentum) } -void NetState::Clear() { - if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) { - phase_ = 1; - level_ = 0; - } - stage_.Clear(); - ::memset(_has_bits_, 0, sizeof(_has_bits_)); - mutable_unknown_fields()->Clear(); +// optional float weight_decay = 12; +bool SolverParameter::has_weight_decay() const { + return (_has_bits_[0] & 0x00200000u) != 0; +} +void SolverParameter::set_has_weight_decay() { + _has_bits_[0] |= 0x00200000u; +} +void SolverParameter::clear_has_weight_decay() { + _has_bits_[0] &= ~0x00200000u; +} +void SolverParameter::clear_weight_decay() { + weight_decay_ = 0; + clear_has_weight_decay(); +} +float SolverParameter::weight_decay() const { + // @@protoc_insertion_point(field_get:caffe.SolverParameter.weight_decay) + return weight_decay_; +} +void SolverParameter::set_weight_decay(float value) { + set_has_weight_decay(); + weight_decay_ = value; + // @@protoc_insertion_point(field_set:caffe.SolverParameter.weight_decay) } -bool NetState::MergePartialFromCodedStream( +// optional string regularization_type = 29 [default = "L2"]; +bool SolverParameter::has_regularization_type() const { + return (_has_bits_[0] & 0x00400000u) != 0; +} +void SolverParameter::set_has_regularization_type() { + _has_bits_[0] |= 0x00400000u; +} +void SolverParameter::clear_has_regularization_type() { + _has_bits_[0] &= ~0x00400000u; +} +void SolverParameter::clear_regularization_type() { + regularization_type_.ClearToDefaultNoArena(_default_regularization_type_); + clear_has_regularization_type(); +} +const ::std::string& SolverParameter::regularization_type() const { + // @@protoc_insertion_point(field_get:caffe.SolverParameter.regularization_type) + return regularization_type_.GetNoArena(_default_regularization_type_); +} +void SolverParameter::set_regularization_type(const ::std::string& value) { + set_has_regularization_type(); + regularization_type_.SetNoArena(_default_regularization_type_, value); + // @@protoc_insertion_point(field_set:caffe.SolverParameter.regularization_type) +} +void SolverParameter::set_regularization_type(const char* value) { + set_has_regularization_type(); + regularization_type_.SetNoArena(_default_regularization_type_, ::std::string(value)); + // @@protoc_insertion_point(field_set_char:caffe.SolverParameter.regularization_type) +} +void SolverParameter::set_regularization_type(const char* value, size_t size) { + set_has_regularization_type(); + regularization_type_.SetNoArena(_default_regularization_type_, + ::std::string(reinterpret_cast(value), size)); + // @@protoc_insertion_point(field_set_pointer:caffe.SolverParameter.regularization_type) +} +::std::string* SolverParameter::mutable_regularization_type() { + set_has_regularization_type(); + // @@protoc_insertion_point(field_mutable:caffe.SolverParameter.regularization_type) + return regularization_type_.MutableNoArena(_default_regularization_type_); +} +::std::string* SolverParameter::release_regularization_type() { + // @@protoc_insertion_point(field_release:caffe.SolverParameter.regularization_type) + clear_has_regularization_type(); + return regularization_type_.ReleaseNoArena(_default_regularization_type_); +} +void SolverParameter::set_allocated_regularization_type(::std::string* regularization_type) { + if (regularization_type != NULL) { + set_has_regularization_type(); + } else { + clear_has_regularization_type(); + } + regularization_type_.SetAllocatedNoArena(_default_regularization_type_, regularization_type); + // @@protoc_insertion_point(field_set_allocated:caffe.SolverParameter.regularization_type) +} + +// optional int32 stepsize = 13; +bool SolverParameter::has_stepsize() const { + return (_has_bits_[0] & 0x00800000u) != 0; +} +void SolverParameter::set_has_stepsize() { + _has_bits_[0] |= 0x00800000u; +} +void SolverParameter::clear_has_stepsize() { + _has_bits_[0] &= ~0x00800000u; +} +void SolverParameter::clear_stepsize() { + stepsize_ = 0; + clear_has_stepsize(); +} +::google::protobuf::int32 SolverParameter::stepsize() const { + // @@protoc_insertion_point(field_get:caffe.SolverParameter.stepsize) + return stepsize_; +} +void SolverParameter::set_stepsize(::google::protobuf::int32 value) { + set_has_stepsize(); + stepsize_ = value; + // @@protoc_insertion_point(field_set:caffe.SolverParameter.stepsize) +} + +// repeated int32 stepvalue = 34; +int SolverParameter::stepvalue_size() const { + return stepvalue_.size(); +} +void SolverParameter::clear_stepvalue() { + stepvalue_.Clear(); +} +::google::protobuf::int32 SolverParameter::stepvalue(int index) const { + // @@protoc_insertion_point(field_get:caffe.SolverParameter.stepvalue) + return stepvalue_.Get(index); +} +void SolverParameter::set_stepvalue(int index, ::google::protobuf::int32 value) { + stepvalue_.Set(index, value); + // @@protoc_insertion_point(field_set:caffe.SolverParameter.stepvalue) +} +void SolverParameter::add_stepvalue(::google::protobuf::int32 value) { + stepvalue_.Add(value); + // @@protoc_insertion_point(field_add:caffe.SolverParameter.stepvalue) +} +const ::google::protobuf::RepeatedField< ::google::protobuf::int32 >& +SolverParameter::stepvalue() const { + // @@protoc_insertion_point(field_list:caffe.SolverParameter.stepvalue) + return stepvalue_; +} +::google::protobuf::RepeatedField< ::google::protobuf::int32 >* +SolverParameter::mutable_stepvalue() { + // @@protoc_insertion_point(field_mutable_list:caffe.SolverParameter.stepvalue) + return &stepvalue_; +} + +// optional float clip_gradients = 35 [default = -1]; +bool SolverParameter::has_clip_gradients() const { + return (_has_bits_[0] & 0x02000000u) != 0; +} +void SolverParameter::set_has_clip_gradients() { + _has_bits_[0] |= 0x02000000u; +} +void SolverParameter::clear_has_clip_gradients() { + _has_bits_[0] &= ~0x02000000u; +} +void SolverParameter::clear_clip_gradients() { + clip_gradients_ = -1; + clear_has_clip_gradients(); +} +float SolverParameter::clip_gradients() const { + // @@protoc_insertion_point(field_get:caffe.SolverParameter.clip_gradients) + return clip_gradients_; +} +void SolverParameter::set_clip_gradients(float value) { + set_has_clip_gradients(); + clip_gradients_ = value; + // @@protoc_insertion_point(field_set:caffe.SolverParameter.clip_gradients) +} + +// optional int32 snapshot = 14 [default = 0]; +bool SolverParameter::has_snapshot() const { + return (_has_bits_[0] & 0x04000000u) != 0; +} +void SolverParameter::set_has_snapshot() { + _has_bits_[0] |= 0x04000000u; +} +void SolverParameter::clear_has_snapshot() { + _has_bits_[0] &= ~0x04000000u; +} +void SolverParameter::clear_snapshot() { + snapshot_ = 0; + clear_has_snapshot(); +} +::google::protobuf::int32 SolverParameter::snapshot() const { + // @@protoc_insertion_point(field_get:caffe.SolverParameter.snapshot) + return snapshot_; +} +void SolverParameter::set_snapshot(::google::protobuf::int32 value) { + set_has_snapshot(); + snapshot_ = value; + // @@protoc_insertion_point(field_set:caffe.SolverParameter.snapshot) +} + +// optional string snapshot_prefix = 15; +bool SolverParameter::has_snapshot_prefix() const { + return (_has_bits_[0] & 0x08000000u) != 0; +} +void SolverParameter::set_has_snapshot_prefix() { + _has_bits_[0] |= 0x08000000u; +} +void SolverParameter::clear_has_snapshot_prefix() { + _has_bits_[0] &= ~0x08000000u; +} +void SolverParameter::clear_snapshot_prefix() { + snapshot_prefix_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + clear_has_snapshot_prefix(); +} +const ::std::string& SolverParameter::snapshot_prefix() const { + // @@protoc_insertion_point(field_get:caffe.SolverParameter.snapshot_prefix) + return snapshot_prefix_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); +} +void SolverParameter::set_snapshot_prefix(const ::std::string& value) { + set_has_snapshot_prefix(); + snapshot_prefix_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); + // @@protoc_insertion_point(field_set:caffe.SolverParameter.snapshot_prefix) +} +void SolverParameter::set_snapshot_prefix(const char* value) { + set_has_snapshot_prefix(); + snapshot_prefix_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); + // @@protoc_insertion_point(field_set_char:caffe.SolverParameter.snapshot_prefix) +} +void SolverParameter::set_snapshot_prefix(const char* value, size_t size) { + set_has_snapshot_prefix(); + snapshot_prefix_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), + ::std::string(reinterpret_cast(value), size)); + // @@protoc_insertion_point(field_set_pointer:caffe.SolverParameter.snapshot_prefix) +} +::std::string* SolverParameter::mutable_snapshot_prefix() { + set_has_snapshot_prefix(); + // @@protoc_insertion_point(field_mutable:caffe.SolverParameter.snapshot_prefix) + return snapshot_prefix_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); +} +::std::string* SolverParameter::release_snapshot_prefix() { + // @@protoc_insertion_point(field_release:caffe.SolverParameter.snapshot_prefix) + clear_has_snapshot_prefix(); + return snapshot_prefix_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); +} +void SolverParameter::set_allocated_snapshot_prefix(::std::string* snapshot_prefix) { + if (snapshot_prefix != NULL) { + set_has_snapshot_prefix(); + } else { + clear_has_snapshot_prefix(); + } + snapshot_prefix_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), snapshot_prefix); + // @@protoc_insertion_point(field_set_allocated:caffe.SolverParameter.snapshot_prefix) +} + +// optional bool snapshot_diff = 16 [default = false]; +bool SolverParameter::has_snapshot_diff() const { + return (_has_bits_[0] & 0x10000000u) != 0; +} +void SolverParameter::set_has_snapshot_diff() { + _has_bits_[0] |= 0x10000000u; +} +void SolverParameter::clear_has_snapshot_diff() { + _has_bits_[0] &= ~0x10000000u; +} +void SolverParameter::clear_snapshot_diff() { + snapshot_diff_ = false; + clear_has_snapshot_diff(); +} +bool SolverParameter::snapshot_diff() const { + // @@protoc_insertion_point(field_get:caffe.SolverParameter.snapshot_diff) + return snapshot_diff_; +} +void SolverParameter::set_snapshot_diff(bool value) { + set_has_snapshot_diff(); + snapshot_diff_ = value; + // @@protoc_insertion_point(field_set:caffe.SolverParameter.snapshot_diff) +} + +// optional .caffe.SolverParameter.SolverMode solver_mode = 17 [default = GPU]; +bool SolverParameter::has_solver_mode() const { + return (_has_bits_[0] & 0x20000000u) != 0; +} +void SolverParameter::set_has_solver_mode() { + _has_bits_[0] |= 0x20000000u; +} +void SolverParameter::clear_has_solver_mode() { + _has_bits_[0] &= ~0x20000000u; +} +void SolverParameter::clear_solver_mode() { + solver_mode_ = 1; + clear_has_solver_mode(); +} +::caffe::SolverParameter_SolverMode SolverParameter::solver_mode() const { + // @@protoc_insertion_point(field_get:caffe.SolverParameter.solver_mode) + return static_cast< ::caffe::SolverParameter_SolverMode >(solver_mode_); +} +void SolverParameter::set_solver_mode(::caffe::SolverParameter_SolverMode value) { + assert(::caffe::SolverParameter_SolverMode_IsValid(value)); + set_has_solver_mode(); + solver_mode_ = value; + // @@protoc_insertion_point(field_set:caffe.SolverParameter.solver_mode) +} + +// optional int32 device_id = 18 [default = 0]; +bool SolverParameter::has_device_id() const { + return (_has_bits_[0] & 0x40000000u) != 0; +} +void SolverParameter::set_has_device_id() { + _has_bits_[0] |= 0x40000000u; +} +void SolverParameter::clear_has_device_id() { + _has_bits_[0] &= ~0x40000000u; +} +void SolverParameter::clear_device_id() { + device_id_ = 0; + clear_has_device_id(); +} +::google::protobuf::int32 SolverParameter::device_id() const { + // @@protoc_insertion_point(field_get:caffe.SolverParameter.device_id) + return device_id_; +} +void SolverParameter::set_device_id(::google::protobuf::int32 value) { + set_has_device_id(); + device_id_ = value; + // @@protoc_insertion_point(field_set:caffe.SolverParameter.device_id) +} + +// optional int64 random_seed = 20 [default = -1]; +bool SolverParameter::has_random_seed() const { + return (_has_bits_[0] & 0x80000000u) != 0; +} +void SolverParameter::set_has_random_seed() { + _has_bits_[0] |= 0x80000000u; +} +void SolverParameter::clear_has_random_seed() { + _has_bits_[0] &= ~0x80000000u; +} +void SolverParameter::clear_random_seed() { + random_seed_ = GOOGLE_LONGLONG(-1); + clear_has_random_seed(); +} +::google::protobuf::int64 SolverParameter::random_seed() const { + // @@protoc_insertion_point(field_get:caffe.SolverParameter.random_seed) + return random_seed_; +} +void SolverParameter::set_random_seed(::google::protobuf::int64 value) { + set_has_random_seed(); + random_seed_ = value; + // @@protoc_insertion_point(field_set:caffe.SolverParameter.random_seed) +} + +// optional .caffe.SolverParameter.SolverType solver_type = 30 [default = SGD]; +bool SolverParameter::has_solver_type() const { + return (_has_bits_[1] & 0x00000001u) != 0; +} +void SolverParameter::set_has_solver_type() { + _has_bits_[1] |= 0x00000001u; +} +void SolverParameter::clear_has_solver_type() { + _has_bits_[1] &= ~0x00000001u; +} +void SolverParameter::clear_solver_type() { + solver_type_ = 0; + clear_has_solver_type(); +} +::caffe::SolverParameter_SolverType SolverParameter::solver_type() const { + // @@protoc_insertion_point(field_get:caffe.SolverParameter.solver_type) + return static_cast< ::caffe::SolverParameter_SolverType >(solver_type_); +} +void SolverParameter::set_solver_type(::caffe::SolverParameter_SolverType value) { + assert(::caffe::SolverParameter_SolverType_IsValid(value)); + set_has_solver_type(); + solver_type_ = value; + // @@protoc_insertion_point(field_set:caffe.SolverParameter.solver_type) +} + +// optional float delta = 31 [default = 1e-08]; +bool SolverParameter::has_delta() const { + return (_has_bits_[1] & 0x00000002u) != 0; +} +void SolverParameter::set_has_delta() { + _has_bits_[1] |= 0x00000002u; +} +void SolverParameter::clear_has_delta() { + _has_bits_[1] &= ~0x00000002u; +} +void SolverParameter::clear_delta() { + delta_ = 1e-08f; + clear_has_delta(); +} +float SolverParameter::delta() const { + // @@protoc_insertion_point(field_get:caffe.SolverParameter.delta) + return delta_; +} +void SolverParameter::set_delta(float value) { + set_has_delta(); + delta_ = value; + // @@protoc_insertion_point(field_set:caffe.SolverParameter.delta) +} + +// optional bool debug_info = 23 [default = false]; +bool SolverParameter::has_debug_info() const { + return (_has_bits_[1] & 0x00000004u) != 0; +} +void SolverParameter::set_has_debug_info() { + _has_bits_[1] |= 0x00000004u; +} +void SolverParameter::clear_has_debug_info() { + _has_bits_[1] &= ~0x00000004u; +} +void SolverParameter::clear_debug_info() { + debug_info_ = false; + clear_has_debug_info(); +} +bool SolverParameter::debug_info() const { + // @@protoc_insertion_point(field_get:caffe.SolverParameter.debug_info) + return debug_info_; +} +void SolverParameter::set_debug_info(bool value) { + set_has_debug_info(); + debug_info_ = value; + // @@protoc_insertion_point(field_set:caffe.SolverParameter.debug_info) +} + +// optional bool snapshot_after_train = 28 [default = true]; +bool SolverParameter::has_snapshot_after_train() const { + return (_has_bits_[1] & 0x00000008u) != 0; +} +void SolverParameter::set_has_snapshot_after_train() { + _has_bits_[1] |= 0x00000008u; +} +void SolverParameter::clear_has_snapshot_after_train() { + _has_bits_[1] &= ~0x00000008u; +} +void SolverParameter::clear_snapshot_after_train() { + snapshot_after_train_ = true; + clear_has_snapshot_after_train(); +} +bool SolverParameter::snapshot_after_train() const { + // @@protoc_insertion_point(field_get:caffe.SolverParameter.snapshot_after_train) + return snapshot_after_train_; +} +void SolverParameter::set_snapshot_after_train(bool value) { + set_has_snapshot_after_train(); + snapshot_after_train_ = value; + // @@protoc_insertion_point(field_set:caffe.SolverParameter.snapshot_after_train) +} + +inline const SolverParameter* SolverParameter::internal_default_instance() { + return &SolverParameter_default_instance_.get(); +} +#endif // PROTOBUF_INLINE_NOT_IN_HEADERS + +// =================================================================== + +#if !defined(_MSC_VER) || _MSC_VER >= 1900 +const int SolverState::kIterFieldNumber; +const int SolverState::kLearnedNetFieldNumber; +const int SolverState::kHistoryFieldNumber; +const int SolverState::kCurrentStepFieldNumber; +#endif // !defined(_MSC_VER) || _MSC_VER >= 1900 + +SolverState::SolverState() + : ::google::protobuf::Message(), _internal_metadata_(NULL) { + if (this != internal_default_instance()) protobuf_InitDefaults_caffe_2eproto(); + SharedCtor(); + // @@protoc_insertion_point(constructor:caffe.SolverState) +} + +void SolverState::InitAsDefaultInstance() { +} + +SolverState::SolverState(const SolverState& from) + : ::google::protobuf::Message(), + _internal_metadata_(NULL) { + SharedCtor(); + UnsafeMergeFrom(from); + // @@protoc_insertion_point(copy_constructor:caffe.SolverState) +} + +void SolverState::SharedCtor() { + _cached_size_ = 0; + learned_net_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + ::memset(&iter_, 0, reinterpret_cast(¤t_step_) - + reinterpret_cast(&iter_) + sizeof(current_step_)); +} + +SolverState::~SolverState() { + // @@protoc_insertion_point(destructor:caffe.SolverState) + SharedDtor(); +} + +void SolverState::SharedDtor() { + learned_net_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); +} + +void SolverState::SetCachedSize(int size) const { + GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); + _cached_size_ = size; + GOOGLE_SAFE_CONCURRENT_WRITES_END(); +} +const ::google::protobuf::Descriptor* SolverState::descriptor() { + protobuf_AssignDescriptorsOnce(); + return SolverState_descriptor_; +} + +const SolverState& SolverState::default_instance() { + protobuf_InitDefaults_caffe_2eproto(); + return *internal_default_instance(); +} + +::google::protobuf::internal::ExplicitlyConstructed SolverState_default_instance_; + +SolverState* SolverState::New(::google::protobuf::Arena* arena) const { + SolverState* n = new SolverState; + if (arena != NULL) { + arena->Own(n); + } + return n; +} + +void SolverState::Clear() { +// @@protoc_insertion_point(message_clear_start:caffe.SolverState) +#if defined(__clang__) +#define ZR_HELPER_(f) \ + _Pragma("clang diagnostic push") \ + _Pragma("clang diagnostic ignored \"-Winvalid-offsetof\"") \ + __builtin_offsetof(SolverState, f) \ + _Pragma("clang diagnostic pop") +#else +#define ZR_HELPER_(f) reinterpret_cast(\ + &reinterpret_cast(16)->f) +#endif + +#define ZR_(first, last) do {\ + ::memset(&(first), 0,\ + ZR_HELPER_(last) - ZR_HELPER_(first) + sizeof(last));\ +} while (0) + + if (_has_bits_[0 / 32] & 11u) { + ZR_(iter_, current_step_); + if (has_learned_net()) { + learned_net_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + } + } + +#undef ZR_HELPER_ +#undef ZR_ + + history_.Clear(); + _has_bits_.Clear(); + if (_internal_metadata_.have_unknown_fields()) { + mutable_unknown_fields()->Clear(); + } +} + +bool SolverState::MergePartialFromCodedStream( ::google::protobuf::io::CodedInputStream* input) { -#define DO_(EXPRESSION) if (!(EXPRESSION)) return false +#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure ::google::protobuf::uint32 tag; - while ((tag = input->ReadTag()) != 0) { + // @@protoc_insertion_point(parse_start:caffe.SolverState) + for (;;) { + ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127); + tag = p.first; + if (!p.second) goto handle_unusual; switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { - // optional .caffe.Phase phase = 1 [default = TEST]; + // optional int32 iter = 1; case 1: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) { - int value; + if (tag == 8) { + set_has_iter(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< - int, ::google::protobuf::internal::WireFormatLite::TYPE_ENUM>( - input, &value))); - if (::caffe::Phase_IsValid(value)) { - set_phase(static_cast< ::caffe::Phase >(value)); - } else { - mutable_unknown_fields()->AddVarint(1, value); - } + ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>( + input, &iter_))); } else { - goto handle_uninterpreted; + goto handle_unusual; } - if (input->ExpectTag(16)) goto parse_level; + if (input->ExpectTag(18)) goto parse_learned_net; break; } - // optional int32 level = 2 [default = 0]; + // optional string learned_net = 2; case 2: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) { - parse_level: - DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< - ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>( - input, &level_))); - set_has_level(); + if (tag == 18) { + parse_learned_net: + DO_(::google::protobuf::internal::WireFormatLite::ReadString( + input, this->mutable_learned_net())); + ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( + this->learned_net().data(), this->learned_net().length(), + ::google::protobuf::internal::WireFormat::PARSE, + "caffe.SolverState.learned_net"); } else { - goto handle_uninterpreted; + goto handle_unusual; } - if (input->ExpectTag(26)) goto parse_stage; + if (input->ExpectTag(26)) goto parse_history; break; } - // repeated string stage = 3; + // repeated .caffe.BlobProto history = 3; case 3: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) { - parse_stage: - DO_(::google::protobuf::internal::WireFormatLite::ReadString( - input, this->add_stage())); - ::google::protobuf::internal::WireFormat::VerifyUTF8String( - this->stage(this->stage_size() - 1).data(), - this->stage(this->stage_size() - 1).length(), - ::google::protobuf::internal::WireFormat::PARSE); + if (tag == 26) { + parse_history: + DO_(input->IncrementRecursionDepth()); + parse_loop_history: + DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtualNoRecursionDepth( + input, add_history())); } else { - goto handle_uninterpreted; + goto handle_unusual; } - if (input->ExpectTag(26)) goto parse_stage; - if (input->ExpectAtEnd()) return true; + if (input->ExpectTag(26)) goto parse_loop_history; + input->UnsafeDecrementRecursionDepth(); + if (input->ExpectTag(32)) goto parse_current_step; + break; + } + + // optional int32 current_step = 4 [default = 0]; + case 4: { + if (tag == 32) { + parse_current_step: + set_has_current_step(); + DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< + ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>( + input, ¤t_step_))); + } else { + goto handle_unusual; + } + if (input->ExpectAtEnd()) goto success; break; } default: { - handle_uninterpreted: - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == + handle_unusual: + if (tag == 0 || + ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) { - return true; + goto success; } DO_(::google::protobuf::internal::WireFormat::SkipField( input, tag, mutable_unknown_fields())); @@ -8721,250 +11809,458 @@ bool NetState::MergePartialFromCodedStream( } } } +success: + // @@protoc_insertion_point(parse_success:caffe.SolverState) return true; +failure: + // @@protoc_insertion_point(parse_failure:caffe.SolverState) + return false; #undef DO_ } -void NetState::SerializeWithCachedSizes( +void SolverState::SerializeWithCachedSizes( ::google::protobuf::io::CodedOutputStream* output) const { - // optional .caffe.Phase phase = 1 [default = TEST]; - if (has_phase()) { - ::google::protobuf::internal::WireFormatLite::WriteEnum( - 1, this->phase(), output); + // @@protoc_insertion_point(serialize_start:caffe.SolverState) + // optional int32 iter = 1; + if (has_iter()) { + ::google::protobuf::internal::WireFormatLite::WriteInt32(1, this->iter(), output); } - // optional int32 level = 2 [default = 0]; - if (has_level()) { - ::google::protobuf::internal::WireFormatLite::WriteInt32(2, this->level(), output); + // optional string learned_net = 2; + if (has_learned_net()) { + ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( + this->learned_net().data(), this->learned_net().length(), + ::google::protobuf::internal::WireFormat::SERIALIZE, + "caffe.SolverState.learned_net"); + ::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased( + 2, this->learned_net(), output); } - // repeated string stage = 3; - for (int i = 0; i < this->stage_size(); i++) { - ::google::protobuf::internal::WireFormat::VerifyUTF8String( - this->stage(i).data(), this->stage(i).length(), - ::google::protobuf::internal::WireFormat::SERIALIZE); - ::google::protobuf::internal::WireFormatLite::WriteString( - 3, this->stage(i), output); + // repeated .caffe.BlobProto history = 3; + for (unsigned int i = 0, n = this->history_size(); i < n; i++) { + ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( + 3, this->history(i), output); + } + + // optional int32 current_step = 4 [default = 0]; + if (has_current_step()) { + ::google::protobuf::internal::WireFormatLite::WriteInt32(4, this->current_step(), output); } - if (!unknown_fields().empty()) { + if (_internal_metadata_.have_unknown_fields()) { ::google::protobuf::internal::WireFormat::SerializeUnknownFields( unknown_fields(), output); } + // @@protoc_insertion_point(serialize_end:caffe.SolverState) } -::google::protobuf::uint8* NetState::SerializeWithCachedSizesToArray( - ::google::protobuf::uint8* target) const { - // optional .caffe.Phase phase = 1 [default = TEST]; - if (has_phase()) { - target = ::google::protobuf::internal::WireFormatLite::WriteEnumToArray( - 1, this->phase(), target); +::google::protobuf::uint8* SolverState::InternalSerializeWithCachedSizesToArray( + bool deterministic, ::google::protobuf::uint8* target) const { + (void)deterministic; // Unused + // @@protoc_insertion_point(serialize_to_array_start:caffe.SolverState) + // optional int32 iter = 1; + if (has_iter()) { + target = ::google::protobuf::internal::WireFormatLite::WriteInt32ToArray(1, this->iter(), target); } - // optional int32 level = 2 [default = 0]; - if (has_level()) { - target = ::google::protobuf::internal::WireFormatLite::WriteInt32ToArray(2, this->level(), target); + // optional string learned_net = 2; + if (has_learned_net()) { + ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( + this->learned_net().data(), this->learned_net().length(), + ::google::protobuf::internal::WireFormat::SERIALIZE, + "caffe.SolverState.learned_net"); + target = + ::google::protobuf::internal::WireFormatLite::WriteStringToArray( + 2, this->learned_net(), target); } - // repeated string stage = 3; - for (int i = 0; i < this->stage_size(); i++) { - ::google::protobuf::internal::WireFormat::VerifyUTF8String( - this->stage(i).data(), this->stage(i).length(), - ::google::protobuf::internal::WireFormat::SERIALIZE); + // repeated .caffe.BlobProto history = 3; + for (unsigned int i = 0, n = this->history_size(); i < n; i++) { target = ::google::protobuf::internal::WireFormatLite:: - WriteStringToArray(3, this->stage(i), target); + InternalWriteMessageNoVirtualToArray( + 3, this->history(i), false, target); + } + + // optional int32 current_step = 4 [default = 0]; + if (has_current_step()) { + target = ::google::protobuf::internal::WireFormatLite::WriteInt32ToArray(4, this->current_step(), target); } - if (!unknown_fields().empty()) { + if (_internal_metadata_.have_unknown_fields()) { target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray( unknown_fields(), target); } + // @@protoc_insertion_point(serialize_to_array_end:caffe.SolverState) return target; } -int NetState::ByteSize() const { - int total_size = 0; +size_t SolverState::ByteSizeLong() const { +// @@protoc_insertion_point(message_byte_size_start:caffe.SolverState) + size_t total_size = 0; - if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) { - // optional .caffe.Phase phase = 1 [default = TEST]; - if (has_phase()) { + if (_has_bits_[0 / 32] & 11u) { + // optional int32 iter = 1; + if (has_iter()) { total_size += 1 + - ::google::protobuf::internal::WireFormatLite::EnumSize(this->phase()); + ::google::protobuf::internal::WireFormatLite::Int32Size( + this->iter()); } - // optional int32 level = 2 [default = 0]; - if (has_level()) { + // optional string learned_net = 2; + if (has_learned_net()) { + total_size += 1 + + ::google::protobuf::internal::WireFormatLite::StringSize( + this->learned_net()); + } + + // optional int32 current_step = 4 [default = 0]; + if (has_current_step()) { total_size += 1 + ::google::protobuf::internal::WireFormatLite::Int32Size( - this->level()); + this->current_step()); } } - // repeated string stage = 3; - total_size += 1 * this->stage_size(); - for (int i = 0; i < this->stage_size(); i++) { - total_size += ::google::protobuf::internal::WireFormatLite::StringSize( - this->stage(i)); + // repeated .caffe.BlobProto history = 3; + { + unsigned int count = this->history_size(); + total_size += 1UL * count; + for (unsigned int i = 0; i < count; i++) { + total_size += + ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( + this->history(i)); + } } - if (!unknown_fields().empty()) { + if (_internal_metadata_.have_unknown_fields()) { total_size += ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( unknown_fields()); } + int cached_size = ::google::protobuf::internal::ToCachedSize(total_size); GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); - _cached_size_ = total_size; + _cached_size_ = cached_size; GOOGLE_SAFE_CONCURRENT_WRITES_END(); return total_size; } -void NetState::MergeFrom(const ::google::protobuf::Message& from) { - GOOGLE_CHECK_NE(&from, this); - const NetState* source = - ::google::protobuf::internal::dynamic_cast_if_available( - &from); +void SolverState::MergeFrom(const ::google::protobuf::Message& from) { +// @@protoc_insertion_point(generalized_merge_from_start:caffe.SolverState) + if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__); + const SolverState* source = + ::google::protobuf::internal::DynamicCastToGenerated( + &from); if (source == NULL) { + // @@protoc_insertion_point(generalized_merge_from_cast_fail:caffe.SolverState) ::google::protobuf::internal::ReflectionOps::Merge(from, this); } else { - MergeFrom(*source); + // @@protoc_insertion_point(generalized_merge_from_cast_success:caffe.SolverState) + UnsafeMergeFrom(*source); } } -void NetState::MergeFrom(const NetState& from) { - GOOGLE_CHECK_NE(&from, this); - stage_.MergeFrom(from.stage_); +void SolverState::MergeFrom(const SolverState& from) { +// @@protoc_insertion_point(class_specific_merge_from_start:caffe.SolverState) + if (GOOGLE_PREDICT_TRUE(&from != this)) { + UnsafeMergeFrom(from); + } else { + MergeFromFail(__LINE__); + } +} + +void SolverState::UnsafeMergeFrom(const SolverState& from) { + GOOGLE_DCHECK(&from != this); + history_.MergeFrom(from.history_); if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) { - if (from.has_phase()) { - set_phase(from.phase()); + if (from.has_iter()) { + set_iter(from.iter()); } - if (from.has_level()) { - set_level(from.level()); + if (from.has_learned_net()) { + set_has_learned_net(); + learned_net_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.learned_net_); } + if (from.has_current_step()) { + set_current_step(from.current_step()); + } + } + if (from._internal_metadata_.have_unknown_fields()) { + ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata( + from.unknown_fields(), &_internal_metadata_); } - mutable_unknown_fields()->MergeFrom(from.unknown_fields()); } -void NetState::CopyFrom(const ::google::protobuf::Message& from) { +void SolverState::CopyFrom(const ::google::protobuf::Message& from) { +// @@protoc_insertion_point(generalized_copy_from_start:caffe.SolverState) if (&from == this) return; Clear(); MergeFrom(from); } -void NetState::CopyFrom(const NetState& from) { +void SolverState::CopyFrom(const SolverState& from) { +// @@protoc_insertion_point(class_specific_copy_from_start:caffe.SolverState) if (&from == this) return; Clear(); - MergeFrom(from); + UnsafeMergeFrom(from); } -bool NetState::IsInitialized() const { +bool SolverState::IsInitialized() const { return true; } -void NetState::Swap(NetState* other) { - if (other != this) { - std::swap(phase_, other->phase_); - std::swap(level_, other->level_); - stage_.Swap(&other->stage_); - std::swap(_has_bits_[0], other->_has_bits_[0]); - _unknown_fields_.Swap(&other->_unknown_fields_); - std::swap(_cached_size_, other->_cached_size_); - } +void SolverState::Swap(SolverState* other) { + if (other == this) return; + InternalSwap(other); +} +void SolverState::InternalSwap(SolverState* other) { + std::swap(iter_, other->iter_); + learned_net_.Swap(&other->learned_net_); + history_.UnsafeArenaSwap(&other->history_); + std::swap(current_step_, other->current_step_); + std::swap(_has_bits_[0], other->_has_bits_[0]); + _internal_metadata_.Swap(&other->_internal_metadata_); + std::swap(_cached_size_, other->_cached_size_); } -::google::protobuf::Metadata NetState::GetMetadata() const { +::google::protobuf::Metadata SolverState::GetMetadata() const { protobuf_AssignDescriptorsOnce(); ::google::protobuf::Metadata metadata; - metadata.descriptor = NetState_descriptor_; - metadata.reflection = NetState_reflection_; + metadata.descriptor = SolverState_descriptor_; + metadata.reflection = SolverState_reflection_; return metadata; } +#if PROTOBUF_INLINE_NOT_IN_HEADERS +// SolverState + +// optional int32 iter = 1; +bool SolverState::has_iter() const { + return (_has_bits_[0] & 0x00000001u) != 0; +} +void SolverState::set_has_iter() { + _has_bits_[0] |= 0x00000001u; +} +void SolverState::clear_has_iter() { + _has_bits_[0] &= ~0x00000001u; +} +void SolverState::clear_iter() { + iter_ = 0; + clear_has_iter(); +} +::google::protobuf::int32 SolverState::iter() const { + // @@protoc_insertion_point(field_get:caffe.SolverState.iter) + return iter_; +} +void SolverState::set_iter(::google::protobuf::int32 value) { + set_has_iter(); + iter_ = value; + // @@protoc_insertion_point(field_set:caffe.SolverState.iter) +} + +// optional string learned_net = 2; +bool SolverState::has_learned_net() const { + return (_has_bits_[0] & 0x00000002u) != 0; +} +void SolverState::set_has_learned_net() { + _has_bits_[0] |= 0x00000002u; +} +void SolverState::clear_has_learned_net() { + _has_bits_[0] &= ~0x00000002u; +} +void SolverState::clear_learned_net() { + learned_net_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + clear_has_learned_net(); +} +const ::std::string& SolverState::learned_net() const { + // @@protoc_insertion_point(field_get:caffe.SolverState.learned_net) + return learned_net_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); +} +void SolverState::set_learned_net(const ::std::string& value) { + set_has_learned_net(); + learned_net_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); + // @@protoc_insertion_point(field_set:caffe.SolverState.learned_net) +} +void SolverState::set_learned_net(const char* value) { + set_has_learned_net(); + learned_net_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); + // @@protoc_insertion_point(field_set_char:caffe.SolverState.learned_net) +} +void SolverState::set_learned_net(const char* value, size_t size) { + set_has_learned_net(); + learned_net_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), + ::std::string(reinterpret_cast(value), size)); + // @@protoc_insertion_point(field_set_pointer:caffe.SolverState.learned_net) +} +::std::string* SolverState::mutable_learned_net() { + set_has_learned_net(); + // @@protoc_insertion_point(field_mutable:caffe.SolverState.learned_net) + return learned_net_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); +} +::std::string* SolverState::release_learned_net() { + // @@protoc_insertion_point(field_release:caffe.SolverState.learned_net) + clear_has_learned_net(); + return learned_net_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); +} +void SolverState::set_allocated_learned_net(::std::string* learned_net) { + if (learned_net != NULL) { + set_has_learned_net(); + } else { + clear_has_learned_net(); + } + learned_net_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), learned_net); + // @@protoc_insertion_point(field_set_allocated:caffe.SolverState.learned_net) +} + +// repeated .caffe.BlobProto history = 3; +int SolverState::history_size() const { + return history_.size(); +} +void SolverState::clear_history() { + history_.Clear(); +} +const ::caffe::BlobProto& SolverState::history(int index) const { + // @@protoc_insertion_point(field_get:caffe.SolverState.history) + return history_.Get(index); +} +::caffe::BlobProto* SolverState::mutable_history(int index) { + // @@protoc_insertion_point(field_mutable:caffe.SolverState.history) + return history_.Mutable(index); +} +::caffe::BlobProto* SolverState::add_history() { + // @@protoc_insertion_point(field_add:caffe.SolverState.history) + return history_.Add(); +} +::google::protobuf::RepeatedPtrField< ::caffe::BlobProto >* +SolverState::mutable_history() { + // @@protoc_insertion_point(field_mutable_list:caffe.SolverState.history) + return &history_; +} +const ::google::protobuf::RepeatedPtrField< ::caffe::BlobProto >& +SolverState::history() const { + // @@protoc_insertion_point(field_list:caffe.SolverState.history) + return history_; +} + +// optional int32 current_step = 4 [default = 0]; +bool SolverState::has_current_step() const { + return (_has_bits_[0] & 0x00000008u) != 0; +} +void SolverState::set_has_current_step() { + _has_bits_[0] |= 0x00000008u; +} +void SolverState::clear_has_current_step() { + _has_bits_[0] &= ~0x00000008u; +} +void SolverState::clear_current_step() { + current_step_ = 0; + clear_has_current_step(); +} +::google::protobuf::int32 SolverState::current_step() const { + // @@protoc_insertion_point(field_get:caffe.SolverState.current_step) + return current_step_; +} +void SolverState::set_current_step(::google::protobuf::int32 value) { + set_has_current_step(); + current_step_ = value; + // @@protoc_insertion_point(field_set:caffe.SolverState.current_step) +} + +inline const SolverState* SolverState::internal_default_instance() { + return &SolverState_default_instance_.get(); +} +#endif // PROTOBUF_INLINE_NOT_IN_HEADERS // =================================================================== -#ifndef _MSC_VER -const int NetStateRule::kPhaseFieldNumber; -const int NetStateRule::kMinLevelFieldNumber; -const int NetStateRule::kMaxLevelFieldNumber; -const int NetStateRule::kStageFieldNumber; -const int NetStateRule::kNotStageFieldNumber; -#endif // !_MSC_VER +#if !defined(_MSC_VER) || _MSC_VER >= 1900 +const int NetState::kPhaseFieldNumber; +const int NetState::kLevelFieldNumber; +const int NetState::kStageFieldNumber; +#endif // !defined(_MSC_VER) || _MSC_VER >= 1900 -NetStateRule::NetStateRule() - : ::google::protobuf::Message() { +NetState::NetState() + : ::google::protobuf::Message(), _internal_metadata_(NULL) { + if (this != internal_default_instance()) protobuf_InitDefaults_caffe_2eproto(); SharedCtor(); + // @@protoc_insertion_point(constructor:caffe.NetState) } -void NetStateRule::InitAsDefaultInstance() { +void NetState::InitAsDefaultInstance() { } -NetStateRule::NetStateRule(const NetStateRule& from) - : ::google::protobuf::Message() { +NetState::NetState(const NetState& from) + : ::google::protobuf::Message(), + _internal_metadata_(NULL) { SharedCtor(); - MergeFrom(from); + UnsafeMergeFrom(from); + // @@protoc_insertion_point(copy_constructor:caffe.NetState) } -void NetStateRule::SharedCtor() { +void NetState::SharedCtor() { _cached_size_ = 0; - phase_ = 0; - min_level_ = 0; - max_level_ = 0; - ::memset(_has_bits_, 0, sizeof(_has_bits_)); + level_ = 0; + phase_ = 1; } -NetStateRule::~NetStateRule() { +NetState::~NetState() { + // @@protoc_insertion_point(destructor:caffe.NetState) SharedDtor(); } -void NetStateRule::SharedDtor() { - if (this != default_instance_) { - } +void NetState::SharedDtor() { } -void NetStateRule::SetCachedSize(int size) const { +void NetState::SetCachedSize(int size) const { GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); _cached_size_ = size; GOOGLE_SAFE_CONCURRENT_WRITES_END(); } -const ::google::protobuf::Descriptor* NetStateRule::descriptor() { +const ::google::protobuf::Descriptor* NetState::descriptor() { protobuf_AssignDescriptorsOnce(); - return NetStateRule_descriptor_; + return NetState_descriptor_; } -const NetStateRule& NetStateRule::default_instance() { - if (default_instance_ == NULL) protobuf_AddDesc_caffe_2eproto(); - return *default_instance_; +const NetState& NetState::default_instance() { + protobuf_InitDefaults_caffe_2eproto(); + return *internal_default_instance(); } -NetStateRule* NetStateRule::default_instance_ = NULL; +::google::protobuf::internal::ExplicitlyConstructed NetState_default_instance_; -NetStateRule* NetStateRule::New() const { - return new NetStateRule; +NetState* NetState::New(::google::protobuf::Arena* arena) const { + NetState* n = new NetState; + if (arena != NULL) { + arena->Own(n); + } + return n; } -void NetStateRule::Clear() { - if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) { - phase_ = 0; - min_level_ = 0; - max_level_ = 0; +void NetState::Clear() { +// @@protoc_insertion_point(message_clear_start:caffe.NetState) + if (_has_bits_[0 / 32] & 3u) { + phase_ = 1; + level_ = 0; } stage_.Clear(); - not_stage_.Clear(); - ::memset(_has_bits_, 0, sizeof(_has_bits_)); - mutable_unknown_fields()->Clear(); + _has_bits_.Clear(); + if (_internal_metadata_.have_unknown_fields()) { + mutable_unknown_fields()->Clear(); + } } -bool NetStateRule::MergePartialFromCodedStream( +bool NetState::MergePartialFromCodedStream( ::google::protobuf::io::CodedInputStream* input) { -#define DO_(EXPRESSION) if (!(EXPRESSION)) return false +#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure ::google::protobuf::uint32 tag; - while ((tag = input->ReadTag()) != 0) { + // @@protoc_insertion_point(parse_start:caffe.NetState) + for (;;) { + ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127); + tag = p.first; + if (!p.second) goto handle_unusual; switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { - // optional .caffe.Phase phase = 1; + // optional .caffe.Phase phase = 1 [default = TEST]; case 1: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) { + if (tag == 8) { int value; DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< int, ::google::protobuf::internal::WireFormatLite::TYPE_ENUM>( @@ -8975,87 +12271,52 @@ bool NetStateRule::MergePartialFromCodedStream( mutable_unknown_fields()->AddVarint(1, value); } } else { - goto handle_uninterpreted; + goto handle_unusual; } - if (input->ExpectTag(16)) goto parse_min_level; + if (input->ExpectTag(16)) goto parse_level; break; } - // optional int32 min_level = 2; + // optional int32 level = 2 [default = 0]; case 2: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) { - parse_min_level: + if (tag == 16) { + parse_level: + set_has_level(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>( - input, &min_level_))); - set_has_min_level(); + input, &level_))); } else { - goto handle_uninterpreted; + goto handle_unusual; } - if (input->ExpectTag(24)) goto parse_max_level; + if (input->ExpectTag(26)) goto parse_stage; break; } - // optional int32 max_level = 3; + // repeated string stage = 3; case 3: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) { - parse_max_level: - DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< - ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>( - input, &max_level_))); - set_has_max_level(); - } else { - goto handle_uninterpreted; - } - if (input->ExpectTag(34)) goto parse_stage; - break; - } - - // repeated string stage = 4; - case 4: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) { + if (tag == 26) { parse_stage: DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->add_stage())); - ::google::protobuf::internal::WireFormat::VerifyUTF8String( + ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( this->stage(this->stage_size() - 1).data(), this->stage(this->stage_size() - 1).length(), - ::google::protobuf::internal::WireFormat::PARSE); - } else { - goto handle_uninterpreted; - } - if (input->ExpectTag(34)) goto parse_stage; - if (input->ExpectTag(42)) goto parse_not_stage; - break; - } - - // repeated string not_stage = 5; - case 5: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) { - parse_not_stage: - DO_(::google::protobuf::internal::WireFormatLite::ReadString( - input, this->add_not_stage())); - ::google::protobuf::internal::WireFormat::VerifyUTF8String( - this->not_stage(this->not_stage_size() - 1).data(), - this->not_stage(this->not_stage_size() - 1).length(), - ::google::protobuf::internal::WireFormat::PARSE); + ::google::protobuf::internal::WireFormat::PARSE, + "caffe.NetState.stage"); } else { - goto handle_uninterpreted; + goto handle_unusual; } - if (input->ExpectTag(42)) goto parse_not_stage; - if (input->ExpectAtEnd()) return true; + if (input->ExpectTag(26)) goto parse_stage; + if (input->ExpectAtEnd()) goto success; break; } default: { - handle_uninterpreted: - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == + handle_unusual: + if (tag == 0 || + ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) { - return true; + goto success; } DO_(::google::protobuf::internal::WireFormat::SkipField( input, tag, mutable_unknown_fields())); @@ -9063,395 +12324,512 @@ bool NetStateRule::MergePartialFromCodedStream( } } } +success: + // @@protoc_insertion_point(parse_success:caffe.NetState) return true; +failure: + // @@protoc_insertion_point(parse_failure:caffe.NetState) + return false; #undef DO_ } -void NetStateRule::SerializeWithCachedSizes( +void NetState::SerializeWithCachedSizes( ::google::protobuf::io::CodedOutputStream* output) const { - // optional .caffe.Phase phase = 1; + // @@protoc_insertion_point(serialize_start:caffe.NetState) + // optional .caffe.Phase phase = 1 [default = TEST]; if (has_phase()) { ::google::protobuf::internal::WireFormatLite::WriteEnum( 1, this->phase(), output); } - // optional int32 min_level = 2; - if (has_min_level()) { - ::google::protobuf::internal::WireFormatLite::WriteInt32(2, this->min_level(), output); - } - - // optional int32 max_level = 3; - if (has_max_level()) { - ::google::protobuf::internal::WireFormatLite::WriteInt32(3, this->max_level(), output); + // optional int32 level = 2 [default = 0]; + if (has_level()) { + ::google::protobuf::internal::WireFormatLite::WriteInt32(2, this->level(), output); } - // repeated string stage = 4; + // repeated string stage = 3; for (int i = 0; i < this->stage_size(); i++) { - ::google::protobuf::internal::WireFormat::VerifyUTF8String( - this->stage(i).data(), this->stage(i).length(), - ::google::protobuf::internal::WireFormat::SERIALIZE); + ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( + this->stage(i).data(), this->stage(i).length(), + ::google::protobuf::internal::WireFormat::SERIALIZE, + "caffe.NetState.stage"); ::google::protobuf::internal::WireFormatLite::WriteString( - 4, this->stage(i), output); + 3, this->stage(i), output); } - // repeated string not_stage = 5; - for (int i = 0; i < this->not_stage_size(); i++) { - ::google::protobuf::internal::WireFormat::VerifyUTF8String( - this->not_stage(i).data(), this->not_stage(i).length(), - ::google::protobuf::internal::WireFormat::SERIALIZE); - ::google::protobuf::internal::WireFormatLite::WriteString( - 5, this->not_stage(i), output); - } - - if (!unknown_fields().empty()) { + if (_internal_metadata_.have_unknown_fields()) { ::google::protobuf::internal::WireFormat::SerializeUnknownFields( unknown_fields(), output); } + // @@protoc_insertion_point(serialize_end:caffe.NetState) } -::google::protobuf::uint8* NetStateRule::SerializeWithCachedSizesToArray( - ::google::protobuf::uint8* target) const { - // optional .caffe.Phase phase = 1; +::google::protobuf::uint8* NetState::InternalSerializeWithCachedSizesToArray( + bool deterministic, ::google::protobuf::uint8* target) const { + (void)deterministic; // Unused + // @@protoc_insertion_point(serialize_to_array_start:caffe.NetState) + // optional .caffe.Phase phase = 1 [default = TEST]; if (has_phase()) { target = ::google::protobuf::internal::WireFormatLite::WriteEnumToArray( 1, this->phase(), target); } - // optional int32 min_level = 2; - if (has_min_level()) { - target = ::google::protobuf::internal::WireFormatLite::WriteInt32ToArray(2, this->min_level(), target); - } - - // optional int32 max_level = 3; - if (has_max_level()) { - target = ::google::protobuf::internal::WireFormatLite::WriteInt32ToArray(3, this->max_level(), target); + // optional int32 level = 2 [default = 0]; + if (has_level()) { + target = ::google::protobuf::internal::WireFormatLite::WriteInt32ToArray(2, this->level(), target); } - // repeated string stage = 4; + // repeated string stage = 3; for (int i = 0; i < this->stage_size(); i++) { - ::google::protobuf::internal::WireFormat::VerifyUTF8String( + ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( this->stage(i).data(), this->stage(i).length(), - ::google::protobuf::internal::WireFormat::SERIALIZE); - target = ::google::protobuf::internal::WireFormatLite:: - WriteStringToArray(4, this->stage(i), target); - } - - // repeated string not_stage = 5; - for (int i = 0; i < this->not_stage_size(); i++) { - ::google::protobuf::internal::WireFormat::VerifyUTF8String( - this->not_stage(i).data(), this->not_stage(i).length(), - ::google::protobuf::internal::WireFormat::SERIALIZE); + ::google::protobuf::internal::WireFormat::SERIALIZE, + "caffe.NetState.stage"); target = ::google::protobuf::internal::WireFormatLite:: - WriteStringToArray(5, this->not_stage(i), target); + WriteStringToArray(3, this->stage(i), target); } - if (!unknown_fields().empty()) { + if (_internal_metadata_.have_unknown_fields()) { target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray( unknown_fields(), target); } + // @@protoc_insertion_point(serialize_to_array_end:caffe.NetState) return target; } -int NetStateRule::ByteSize() const { - int total_size = 0; +size_t NetState::ByteSizeLong() const { +// @@protoc_insertion_point(message_byte_size_start:caffe.NetState) + size_t total_size = 0; - if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) { - // optional .caffe.Phase phase = 1; + if (_has_bits_[0 / 32] & 3u) { + // optional .caffe.Phase phase = 1 [default = TEST]; if (has_phase()) { total_size += 1 + ::google::protobuf::internal::WireFormatLite::EnumSize(this->phase()); } - // optional int32 min_level = 2; - if (has_min_level()) { - total_size += 1 + - ::google::protobuf::internal::WireFormatLite::Int32Size( - this->min_level()); - } - - // optional int32 max_level = 3; - if (has_max_level()) { + // optional int32 level = 2 [default = 0]; + if (has_level()) { total_size += 1 + ::google::protobuf::internal::WireFormatLite::Int32Size( - this->max_level()); + this->level()); } } - // repeated string stage = 4; - total_size += 1 * this->stage_size(); + // repeated string stage = 3; + total_size += 1 * + ::google::protobuf::internal::FromIntSize(this->stage_size()); for (int i = 0; i < this->stage_size(); i++) { total_size += ::google::protobuf::internal::WireFormatLite::StringSize( this->stage(i)); } - // repeated string not_stage = 5; - total_size += 1 * this->not_stage_size(); - for (int i = 0; i < this->not_stage_size(); i++) { - total_size += ::google::protobuf::internal::WireFormatLite::StringSize( - this->not_stage(i)); - } - - if (!unknown_fields().empty()) { + if (_internal_metadata_.have_unknown_fields()) { total_size += ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( unknown_fields()); } + int cached_size = ::google::protobuf::internal::ToCachedSize(total_size); GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); - _cached_size_ = total_size; + _cached_size_ = cached_size; GOOGLE_SAFE_CONCURRENT_WRITES_END(); return total_size; } -void NetStateRule::MergeFrom(const ::google::protobuf::Message& from) { - GOOGLE_CHECK_NE(&from, this); - const NetStateRule* source = - ::google::protobuf::internal::dynamic_cast_if_available( - &from); +void NetState::MergeFrom(const ::google::protobuf::Message& from) { +// @@protoc_insertion_point(generalized_merge_from_start:caffe.NetState) + if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__); + const NetState* source = + ::google::protobuf::internal::DynamicCastToGenerated( + &from); if (source == NULL) { + // @@protoc_insertion_point(generalized_merge_from_cast_fail:caffe.NetState) ::google::protobuf::internal::ReflectionOps::Merge(from, this); } else { - MergeFrom(*source); + // @@protoc_insertion_point(generalized_merge_from_cast_success:caffe.NetState) + UnsafeMergeFrom(*source); } } -void NetStateRule::MergeFrom(const NetStateRule& from) { - GOOGLE_CHECK_NE(&from, this); - stage_.MergeFrom(from.stage_); - not_stage_.MergeFrom(from.not_stage_); +void NetState::MergeFrom(const NetState& from) { +// @@protoc_insertion_point(class_specific_merge_from_start:caffe.NetState) + if (GOOGLE_PREDICT_TRUE(&from != this)) { + UnsafeMergeFrom(from); + } else { + MergeFromFail(__LINE__); + } +} + +void NetState::UnsafeMergeFrom(const NetState& from) { + GOOGLE_DCHECK(&from != this); + stage_.UnsafeMergeFrom(from.stage_); if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) { if (from.has_phase()) { set_phase(from.phase()); } - if (from.has_min_level()) { - set_min_level(from.min_level()); - } - if (from.has_max_level()) { - set_max_level(from.max_level()); + if (from.has_level()) { + set_level(from.level()); } } - mutable_unknown_fields()->MergeFrom(from.unknown_fields()); + if (from._internal_metadata_.have_unknown_fields()) { + ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata( + from.unknown_fields(), &_internal_metadata_); + } } -void NetStateRule::CopyFrom(const ::google::protobuf::Message& from) { +void NetState::CopyFrom(const ::google::protobuf::Message& from) { +// @@protoc_insertion_point(generalized_copy_from_start:caffe.NetState) if (&from == this) return; Clear(); MergeFrom(from); } -void NetStateRule::CopyFrom(const NetStateRule& from) { +void NetState::CopyFrom(const NetState& from) { +// @@protoc_insertion_point(class_specific_copy_from_start:caffe.NetState) if (&from == this) return; Clear(); - MergeFrom(from); + UnsafeMergeFrom(from); } -bool NetStateRule::IsInitialized() const { +bool NetState::IsInitialized() const { return true; } -void NetStateRule::Swap(NetStateRule* other) { - if (other != this) { - std::swap(phase_, other->phase_); - std::swap(min_level_, other->min_level_); - std::swap(max_level_, other->max_level_); - stage_.Swap(&other->stage_); - not_stage_.Swap(&other->not_stage_); - std::swap(_has_bits_[0], other->_has_bits_[0]); - _unknown_fields_.Swap(&other->_unknown_fields_); - std::swap(_cached_size_, other->_cached_size_); - } +void NetState::Swap(NetState* other) { + if (other == this) return; + InternalSwap(other); +} +void NetState::InternalSwap(NetState* other) { + std::swap(phase_, other->phase_); + std::swap(level_, other->level_); + stage_.UnsafeArenaSwap(&other->stage_); + std::swap(_has_bits_[0], other->_has_bits_[0]); + _internal_metadata_.Swap(&other->_internal_metadata_); + std::swap(_cached_size_, other->_cached_size_); } -::google::protobuf::Metadata NetStateRule::GetMetadata() const { +::google::protobuf::Metadata NetState::GetMetadata() const { protobuf_AssignDescriptorsOnce(); ::google::protobuf::Metadata metadata; - metadata.descriptor = NetStateRule_descriptor_; - metadata.reflection = NetStateRule_reflection_; + metadata.descriptor = NetState_descriptor_; + metadata.reflection = NetState_reflection_; return metadata; } +#if PROTOBUF_INLINE_NOT_IN_HEADERS +// NetState -// =================================================================== +// optional .caffe.Phase phase = 1 [default = TEST]; +bool NetState::has_phase() const { + return (_has_bits_[0] & 0x00000001u) != 0; +} +void NetState::set_has_phase() { + _has_bits_[0] |= 0x00000001u; +} +void NetState::clear_has_phase() { + _has_bits_[0] &= ~0x00000001u; +} +void NetState::clear_phase() { + phase_ = 1; + clear_has_phase(); +} +::caffe::Phase NetState::phase() const { + // @@protoc_insertion_point(field_get:caffe.NetState.phase) + return static_cast< ::caffe::Phase >(phase_); +} +void NetState::set_phase(::caffe::Phase value) { + assert(::caffe::Phase_IsValid(value)); + set_has_phase(); + phase_ = value; + // @@protoc_insertion_point(field_set:caffe.NetState.phase) +} -const ::google::protobuf::EnumDescriptor* ParamSpec_DimCheckMode_descriptor() { - protobuf_AssignDescriptorsOnce(); - return ParamSpec_DimCheckMode_descriptor_; +// optional int32 level = 2 [default = 0]; +bool NetState::has_level() const { + return (_has_bits_[0] & 0x00000002u) != 0; } -bool ParamSpec_DimCheckMode_IsValid(int value) { - switch(value) { - case 0: - case 1: - return true; - default: - return false; - } +void NetState::set_has_level() { + _has_bits_[0] |= 0x00000002u; +} +void NetState::clear_has_level() { + _has_bits_[0] &= ~0x00000002u; +} +void NetState::clear_level() { + level_ = 0; + clear_has_level(); +} +::google::protobuf::int32 NetState::level() const { + // @@protoc_insertion_point(field_get:caffe.NetState.level) + return level_; +} +void NetState::set_level(::google::protobuf::int32 value) { + set_has_level(); + level_ = value; + // @@protoc_insertion_point(field_set:caffe.NetState.level) } -#ifndef _MSC_VER -const ParamSpec_DimCheckMode ParamSpec::STRICT; -const ParamSpec_DimCheckMode ParamSpec::PERMISSIVE; -const ParamSpec_DimCheckMode ParamSpec::DimCheckMode_MIN; -const ParamSpec_DimCheckMode ParamSpec::DimCheckMode_MAX; -const int ParamSpec::DimCheckMode_ARRAYSIZE; -#endif // _MSC_VER -#ifndef _MSC_VER -const int ParamSpec::kNameFieldNumber; -const int ParamSpec::kShareModeFieldNumber; -const int ParamSpec::kLrMultFieldNumber; -const int ParamSpec::kDecayMultFieldNumber; -#endif // !_MSC_VER +// repeated string stage = 3; +int NetState::stage_size() const { + return stage_.size(); +} +void NetState::clear_stage() { + stage_.Clear(); +} +const ::std::string& NetState::stage(int index) const { + // @@protoc_insertion_point(field_get:caffe.NetState.stage) + return stage_.Get(index); +} +::std::string* NetState::mutable_stage(int index) { + // @@protoc_insertion_point(field_mutable:caffe.NetState.stage) + return stage_.Mutable(index); +} +void NetState::set_stage(int index, const ::std::string& value) { + // @@protoc_insertion_point(field_set:caffe.NetState.stage) + stage_.Mutable(index)->assign(value); +} +void NetState::set_stage(int index, const char* value) { + stage_.Mutable(index)->assign(value); + // @@protoc_insertion_point(field_set_char:caffe.NetState.stage) +} +void NetState::set_stage(int index, const char* value, size_t size) { + stage_.Mutable(index)->assign( + reinterpret_cast(value), size); + // @@protoc_insertion_point(field_set_pointer:caffe.NetState.stage) +} +::std::string* NetState::add_stage() { + // @@protoc_insertion_point(field_add_mutable:caffe.NetState.stage) + return stage_.Add(); +} +void NetState::add_stage(const ::std::string& value) { + stage_.Add()->assign(value); + // @@protoc_insertion_point(field_add:caffe.NetState.stage) +} +void NetState::add_stage(const char* value) { + stage_.Add()->assign(value); + // @@protoc_insertion_point(field_add_char:caffe.NetState.stage) +} +void NetState::add_stage(const char* value, size_t size) { + stage_.Add()->assign(reinterpret_cast(value), size); + // @@protoc_insertion_point(field_add_pointer:caffe.NetState.stage) +} +const ::google::protobuf::RepeatedPtrField< ::std::string>& +NetState::stage() const { + // @@protoc_insertion_point(field_list:caffe.NetState.stage) + return stage_; +} +::google::protobuf::RepeatedPtrField< ::std::string>* +NetState::mutable_stage() { + // @@protoc_insertion_point(field_mutable_list:caffe.NetState.stage) + return &stage_; +} -ParamSpec::ParamSpec() - : ::google::protobuf::Message() { +inline const NetState* NetState::internal_default_instance() { + return &NetState_default_instance_.get(); +} +#endif // PROTOBUF_INLINE_NOT_IN_HEADERS + +// =================================================================== + +#if !defined(_MSC_VER) || _MSC_VER >= 1900 +const int NetStateRule::kPhaseFieldNumber; +const int NetStateRule::kMinLevelFieldNumber; +const int NetStateRule::kMaxLevelFieldNumber; +const int NetStateRule::kStageFieldNumber; +const int NetStateRule::kNotStageFieldNumber; +#endif // !defined(_MSC_VER) || _MSC_VER >= 1900 + +NetStateRule::NetStateRule() + : ::google::protobuf::Message(), _internal_metadata_(NULL) { + if (this != internal_default_instance()) protobuf_InitDefaults_caffe_2eproto(); SharedCtor(); + // @@protoc_insertion_point(constructor:caffe.NetStateRule) } -void ParamSpec::InitAsDefaultInstance() { +void NetStateRule::InitAsDefaultInstance() { } -ParamSpec::ParamSpec(const ParamSpec& from) - : ::google::protobuf::Message() { +NetStateRule::NetStateRule(const NetStateRule& from) + : ::google::protobuf::Message(), + _internal_metadata_(NULL) { SharedCtor(); - MergeFrom(from); + UnsafeMergeFrom(from); + // @@protoc_insertion_point(copy_constructor:caffe.NetStateRule) } -void ParamSpec::SharedCtor() { +void NetStateRule::SharedCtor() { _cached_size_ = 0; - name_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); - share_mode_ = 0; - lr_mult_ = 1; - decay_mult_ = 1; - ::memset(_has_bits_, 0, sizeof(_has_bits_)); + ::memset(&phase_, 0, reinterpret_cast(&max_level_) - + reinterpret_cast(&phase_) + sizeof(max_level_)); } -ParamSpec::~ParamSpec() { +NetStateRule::~NetStateRule() { + // @@protoc_insertion_point(destructor:caffe.NetStateRule) SharedDtor(); } -void ParamSpec::SharedDtor() { - if (name_ != &::google::protobuf::internal::kEmptyString) { - delete name_; - } - if (this != default_instance_) { - } +void NetStateRule::SharedDtor() { } -void ParamSpec::SetCachedSize(int size) const { +void NetStateRule::SetCachedSize(int size) const { GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); _cached_size_ = size; GOOGLE_SAFE_CONCURRENT_WRITES_END(); } -const ::google::protobuf::Descriptor* ParamSpec::descriptor() { +const ::google::protobuf::Descriptor* NetStateRule::descriptor() { protobuf_AssignDescriptorsOnce(); - return ParamSpec_descriptor_; + return NetStateRule_descriptor_; } -const ParamSpec& ParamSpec::default_instance() { - if (default_instance_ == NULL) protobuf_AddDesc_caffe_2eproto(); - return *default_instance_; +const NetStateRule& NetStateRule::default_instance() { + protobuf_InitDefaults_caffe_2eproto(); + return *internal_default_instance(); } -ParamSpec* ParamSpec::default_instance_ = NULL; +::google::protobuf::internal::ExplicitlyConstructed NetStateRule_default_instance_; -ParamSpec* ParamSpec::New() const { - return new ParamSpec; +NetStateRule* NetStateRule::New(::google::protobuf::Arena* arena) const { + NetStateRule* n = new NetStateRule; + if (arena != NULL) { + arena->Own(n); + } + return n; } -void ParamSpec::Clear() { - if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) { - if (has_name()) { - if (name_ != &::google::protobuf::internal::kEmptyString) { - name_->clear(); - } - } - share_mode_ = 0; - lr_mult_ = 1; - decay_mult_ = 1; +void NetStateRule::Clear() { +// @@protoc_insertion_point(message_clear_start:caffe.NetStateRule) +#if defined(__clang__) +#define ZR_HELPER_(f) \ + _Pragma("clang diagnostic push") \ + _Pragma("clang diagnostic ignored \"-Winvalid-offsetof\"") \ + __builtin_offsetof(NetStateRule, f) \ + _Pragma("clang diagnostic pop") +#else +#define ZR_HELPER_(f) reinterpret_cast(\ + &reinterpret_cast(16)->f) +#endif + +#define ZR_(first, last) do {\ + ::memset(&(first), 0,\ + ZR_HELPER_(last) - ZR_HELPER_(first) + sizeof(last));\ +} while (0) + + ZR_(phase_, max_level_); + +#undef ZR_HELPER_ +#undef ZR_ + + stage_.Clear(); + not_stage_.Clear(); + _has_bits_.Clear(); + if (_internal_metadata_.have_unknown_fields()) { + mutable_unknown_fields()->Clear(); } - ::memset(_has_bits_, 0, sizeof(_has_bits_)); - mutable_unknown_fields()->Clear(); } -bool ParamSpec::MergePartialFromCodedStream( +bool NetStateRule::MergePartialFromCodedStream( ::google::protobuf::io::CodedInputStream* input) { -#define DO_(EXPRESSION) if (!(EXPRESSION)) return false +#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure ::google::protobuf::uint32 tag; - while ((tag = input->ReadTag()) != 0) { + // @@protoc_insertion_point(parse_start:caffe.NetStateRule) + for (;;) { + ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127); + tag = p.first; + if (!p.second) goto handle_unusual; switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { - // optional string name = 1; + // optional .caffe.Phase phase = 1; case 1: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) { - DO_(::google::protobuf::internal::WireFormatLite::ReadString( - input, this->mutable_name())); - ::google::protobuf::internal::WireFormat::VerifyUTF8String( - this->name().data(), this->name().length(), - ::google::protobuf::internal::WireFormat::PARSE); + if (tag == 8) { + int value; + DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< + int, ::google::protobuf::internal::WireFormatLite::TYPE_ENUM>( + input, &value))); + if (::caffe::Phase_IsValid(value)) { + set_phase(static_cast< ::caffe::Phase >(value)); + } else { + mutable_unknown_fields()->AddVarint(1, value); + } } else { - goto handle_uninterpreted; + goto handle_unusual; } - if (input->ExpectTag(16)) goto parse_share_mode; + if (input->ExpectTag(16)) goto parse_min_level; break; } - // optional .caffe.ParamSpec.DimCheckMode share_mode = 2; + // optional int32 min_level = 2; case 2: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) { - parse_share_mode: - int value; + if (tag == 16) { + parse_min_level: + set_has_min_level(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< - int, ::google::protobuf::internal::WireFormatLite::TYPE_ENUM>( - input, &value))); - if (::caffe::ParamSpec_DimCheckMode_IsValid(value)) { - set_share_mode(static_cast< ::caffe::ParamSpec_DimCheckMode >(value)); - } else { - mutable_unknown_fields()->AddVarint(2, value); - } + ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>( + input, &min_level_))); } else { - goto handle_uninterpreted; + goto handle_unusual; } - if (input->ExpectTag(29)) goto parse_lr_mult; + if (input->ExpectTag(24)) goto parse_max_level; break; } - // optional float lr_mult = 3 [default = 1]; + // optional int32 max_level = 3; case 3: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_FIXED32) { - parse_lr_mult: + if (tag == 24) { + parse_max_level: + set_has_max_level(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< - float, ::google::protobuf::internal::WireFormatLite::TYPE_FLOAT>( - input, &lr_mult_))); - set_has_lr_mult(); + ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>( + input, &max_level_))); } else { - goto handle_uninterpreted; + goto handle_unusual; } - if (input->ExpectTag(37)) goto parse_decay_mult; + if (input->ExpectTag(34)) goto parse_stage; break; } - // optional float decay_mult = 4 [default = 1]; + // repeated string stage = 4; case 4: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_FIXED32) { - parse_decay_mult: - DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< - float, ::google::protobuf::internal::WireFormatLite::TYPE_FLOAT>( - input, &decay_mult_))); - set_has_decay_mult(); + if (tag == 34) { + parse_stage: + DO_(::google::protobuf::internal::WireFormatLite::ReadString( + input, this->add_stage())); + ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( + this->stage(this->stage_size() - 1).data(), + this->stage(this->stage_size() - 1).length(), + ::google::protobuf::internal::WireFormat::PARSE, + "caffe.NetStateRule.stage"); + } else { + goto handle_unusual; + } + if (input->ExpectTag(34)) goto parse_stage; + if (input->ExpectTag(42)) goto parse_not_stage; + break; + } + + // repeated string not_stage = 5; + case 5: { + if (tag == 42) { + parse_not_stage: + DO_(::google::protobuf::internal::WireFormatLite::ReadString( + input, this->add_not_stage())); + ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( + this->not_stage(this->not_stage_size() - 1).data(), + this->not_stage(this->not_stage_size() - 1).length(), + ::google::protobuf::internal::WireFormat::PARSE, + "caffe.NetStateRule.not_stage"); } else { - goto handle_uninterpreted; + goto handle_unusual; } - if (input->ExpectAtEnd()) return true; + if (input->ExpectTag(42)) goto parse_not_stage; + if (input->ExpectAtEnd()) goto success; break; } default: { - handle_uninterpreted: - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == + handle_unusual: + if (tag == 0 || + ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) { - return true; + goto success; } DO_(::google::protobuf::internal::WireFormat::SkipField( input, tag, mutable_unknown_fields())); @@ -9459,663 +12837,1510 @@ bool ParamSpec::MergePartialFromCodedStream( } } } +success: + // @@protoc_insertion_point(parse_success:caffe.NetStateRule) return true; +failure: + // @@protoc_insertion_point(parse_failure:caffe.NetStateRule) + return false; #undef DO_ } -void ParamSpec::SerializeWithCachedSizes( +void NetStateRule::SerializeWithCachedSizes( ::google::protobuf::io::CodedOutputStream* output) const { - // optional string name = 1; - if (has_name()) { - ::google::protobuf::internal::WireFormat::VerifyUTF8String( - this->name().data(), this->name().length(), - ::google::protobuf::internal::WireFormat::SERIALIZE); - ::google::protobuf::internal::WireFormatLite::WriteString( - 1, this->name(), output); + // @@protoc_insertion_point(serialize_start:caffe.NetStateRule) + // optional .caffe.Phase phase = 1; + if (has_phase()) { + ::google::protobuf::internal::WireFormatLite::WriteEnum( + 1, this->phase(), output); } - // optional .caffe.ParamSpec.DimCheckMode share_mode = 2; - if (has_share_mode()) { - ::google::protobuf::internal::WireFormatLite::WriteEnum( - 2, this->share_mode(), output); + // optional int32 min_level = 2; + if (has_min_level()) { + ::google::protobuf::internal::WireFormatLite::WriteInt32(2, this->min_level(), output); } - // optional float lr_mult = 3 [default = 1]; - if (has_lr_mult()) { - ::google::protobuf::internal::WireFormatLite::WriteFloat(3, this->lr_mult(), output); + // optional int32 max_level = 3; + if (has_max_level()) { + ::google::protobuf::internal::WireFormatLite::WriteInt32(3, this->max_level(), output); } - // optional float decay_mult = 4 [default = 1]; - if (has_decay_mult()) { - ::google::protobuf::internal::WireFormatLite::WriteFloat(4, this->decay_mult(), output); + // repeated string stage = 4; + for (int i = 0; i < this->stage_size(); i++) { + ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( + this->stage(i).data(), this->stage(i).length(), + ::google::protobuf::internal::WireFormat::SERIALIZE, + "caffe.NetStateRule.stage"); + ::google::protobuf::internal::WireFormatLite::WriteString( + 4, this->stage(i), output); + } + + // repeated string not_stage = 5; + for (int i = 0; i < this->not_stage_size(); i++) { + ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( + this->not_stage(i).data(), this->not_stage(i).length(), + ::google::protobuf::internal::WireFormat::SERIALIZE, + "caffe.NetStateRule.not_stage"); + ::google::protobuf::internal::WireFormatLite::WriteString( + 5, this->not_stage(i), output); } - if (!unknown_fields().empty()) { + if (_internal_metadata_.have_unknown_fields()) { ::google::protobuf::internal::WireFormat::SerializeUnknownFields( unknown_fields(), output); } + // @@protoc_insertion_point(serialize_end:caffe.NetStateRule) } -::google::protobuf::uint8* ParamSpec::SerializeWithCachedSizesToArray( - ::google::protobuf::uint8* target) const { - // optional string name = 1; - if (has_name()) { - ::google::protobuf::internal::WireFormat::VerifyUTF8String( - this->name().data(), this->name().length(), - ::google::protobuf::internal::WireFormat::SERIALIZE); - target = - ::google::protobuf::internal::WireFormatLite::WriteStringToArray( - 1, this->name(), target); +::google::protobuf::uint8* NetStateRule::InternalSerializeWithCachedSizesToArray( + bool deterministic, ::google::protobuf::uint8* target) const { + (void)deterministic; // Unused + // @@protoc_insertion_point(serialize_to_array_start:caffe.NetStateRule) + // optional .caffe.Phase phase = 1; + if (has_phase()) { + target = ::google::protobuf::internal::WireFormatLite::WriteEnumToArray( + 1, this->phase(), target); } - // optional .caffe.ParamSpec.DimCheckMode share_mode = 2; - if (has_share_mode()) { - target = ::google::protobuf::internal::WireFormatLite::WriteEnumToArray( - 2, this->share_mode(), target); + // optional int32 min_level = 2; + if (has_min_level()) { + target = ::google::protobuf::internal::WireFormatLite::WriteInt32ToArray(2, this->min_level(), target); } - // optional float lr_mult = 3 [default = 1]; - if (has_lr_mult()) { - target = ::google::protobuf::internal::WireFormatLite::WriteFloatToArray(3, this->lr_mult(), target); + // optional int32 max_level = 3; + if (has_max_level()) { + target = ::google::protobuf::internal::WireFormatLite::WriteInt32ToArray(3, this->max_level(), target); } - // optional float decay_mult = 4 [default = 1]; - if (has_decay_mult()) { - target = ::google::protobuf::internal::WireFormatLite::WriteFloatToArray(4, this->decay_mult(), target); + // repeated string stage = 4; + for (int i = 0; i < this->stage_size(); i++) { + ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( + this->stage(i).data(), this->stage(i).length(), + ::google::protobuf::internal::WireFormat::SERIALIZE, + "caffe.NetStateRule.stage"); + target = ::google::protobuf::internal::WireFormatLite:: + WriteStringToArray(4, this->stage(i), target); + } + + // repeated string not_stage = 5; + for (int i = 0; i < this->not_stage_size(); i++) { + ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( + this->not_stage(i).data(), this->not_stage(i).length(), + ::google::protobuf::internal::WireFormat::SERIALIZE, + "caffe.NetStateRule.not_stage"); + target = ::google::protobuf::internal::WireFormatLite:: + WriteStringToArray(5, this->not_stage(i), target); } - if (!unknown_fields().empty()) { + if (_internal_metadata_.have_unknown_fields()) { target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray( unknown_fields(), target); } + // @@protoc_insertion_point(serialize_to_array_end:caffe.NetStateRule) return target; } -int ParamSpec::ByteSize() const { - int total_size = 0; +size_t NetStateRule::ByteSizeLong() const { +// @@protoc_insertion_point(message_byte_size_start:caffe.NetStateRule) + size_t total_size = 0; - if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) { - // optional string name = 1; - if (has_name()) { + if (_has_bits_[0 / 32] & 7u) { + // optional .caffe.Phase phase = 1; + if (has_phase()) { total_size += 1 + - ::google::protobuf::internal::WireFormatLite::StringSize( - this->name()); + ::google::protobuf::internal::WireFormatLite::EnumSize(this->phase()); } - // optional .caffe.ParamSpec.DimCheckMode share_mode = 2; - if (has_share_mode()) { + // optional int32 min_level = 2; + if (has_min_level()) { total_size += 1 + - ::google::protobuf::internal::WireFormatLite::EnumSize(this->share_mode()); + ::google::protobuf::internal::WireFormatLite::Int32Size( + this->min_level()); } - // optional float lr_mult = 3 [default = 1]; - if (has_lr_mult()) { - total_size += 1 + 4; + // optional int32 max_level = 3; + if (has_max_level()) { + total_size += 1 + + ::google::protobuf::internal::WireFormatLite::Int32Size( + this->max_level()); } - // optional float decay_mult = 4 [default = 1]; - if (has_decay_mult()) { - total_size += 1 + 4; - } + } + // repeated string stage = 4; + total_size += 1 * + ::google::protobuf::internal::FromIntSize(this->stage_size()); + for (int i = 0; i < this->stage_size(); i++) { + total_size += ::google::protobuf::internal::WireFormatLite::StringSize( + this->stage(i)); + } + // repeated string not_stage = 5; + total_size += 1 * + ::google::protobuf::internal::FromIntSize(this->not_stage_size()); + for (int i = 0; i < this->not_stage_size(); i++) { + total_size += ::google::protobuf::internal::WireFormatLite::StringSize( + this->not_stage(i)); } - if (!unknown_fields().empty()) { + + if (_internal_metadata_.have_unknown_fields()) { total_size += ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( unknown_fields()); } + int cached_size = ::google::protobuf::internal::ToCachedSize(total_size); GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); - _cached_size_ = total_size; + _cached_size_ = cached_size; GOOGLE_SAFE_CONCURRENT_WRITES_END(); return total_size; } -void ParamSpec::MergeFrom(const ::google::protobuf::Message& from) { - GOOGLE_CHECK_NE(&from, this); - const ParamSpec* source = - ::google::protobuf::internal::dynamic_cast_if_available( - &from); +void NetStateRule::MergeFrom(const ::google::protobuf::Message& from) { +// @@protoc_insertion_point(generalized_merge_from_start:caffe.NetStateRule) + if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__); + const NetStateRule* source = + ::google::protobuf::internal::DynamicCastToGenerated( + &from); if (source == NULL) { + // @@protoc_insertion_point(generalized_merge_from_cast_fail:caffe.NetStateRule) ::google::protobuf::internal::ReflectionOps::Merge(from, this); } else { - MergeFrom(*source); + // @@protoc_insertion_point(generalized_merge_from_cast_success:caffe.NetStateRule) + UnsafeMergeFrom(*source); } } -void ParamSpec::MergeFrom(const ParamSpec& from) { - GOOGLE_CHECK_NE(&from, this); +void NetStateRule::MergeFrom(const NetStateRule& from) { +// @@protoc_insertion_point(class_specific_merge_from_start:caffe.NetStateRule) + if (GOOGLE_PREDICT_TRUE(&from != this)) { + UnsafeMergeFrom(from); + } else { + MergeFromFail(__LINE__); + } +} + +void NetStateRule::UnsafeMergeFrom(const NetStateRule& from) { + GOOGLE_DCHECK(&from != this); + stage_.UnsafeMergeFrom(from.stage_); + not_stage_.UnsafeMergeFrom(from.not_stage_); if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) { - if (from.has_name()) { - set_name(from.name()); - } - if (from.has_share_mode()) { - set_share_mode(from.share_mode()); + if (from.has_phase()) { + set_phase(from.phase()); } - if (from.has_lr_mult()) { - set_lr_mult(from.lr_mult()); + if (from.has_min_level()) { + set_min_level(from.min_level()); } - if (from.has_decay_mult()) { - set_decay_mult(from.decay_mult()); + if (from.has_max_level()) { + set_max_level(from.max_level()); } } - mutable_unknown_fields()->MergeFrom(from.unknown_fields()); + if (from._internal_metadata_.have_unknown_fields()) { + ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata( + from.unknown_fields(), &_internal_metadata_); + } } -void ParamSpec::CopyFrom(const ::google::protobuf::Message& from) { +void NetStateRule::CopyFrom(const ::google::protobuf::Message& from) { +// @@protoc_insertion_point(generalized_copy_from_start:caffe.NetStateRule) if (&from == this) return; Clear(); MergeFrom(from); } -void ParamSpec::CopyFrom(const ParamSpec& from) { +void NetStateRule::CopyFrom(const NetStateRule& from) { +// @@protoc_insertion_point(class_specific_copy_from_start:caffe.NetStateRule) if (&from == this) return; Clear(); - MergeFrom(from); + UnsafeMergeFrom(from); } -bool ParamSpec::IsInitialized() const { +bool NetStateRule::IsInitialized() const { return true; } -void ParamSpec::Swap(ParamSpec* other) { - if (other != this) { - std::swap(name_, other->name_); - std::swap(share_mode_, other->share_mode_); - std::swap(lr_mult_, other->lr_mult_); - std::swap(decay_mult_, other->decay_mult_); - std::swap(_has_bits_[0], other->_has_bits_[0]); - _unknown_fields_.Swap(&other->_unknown_fields_); - std::swap(_cached_size_, other->_cached_size_); - } +void NetStateRule::Swap(NetStateRule* other) { + if (other == this) return; + InternalSwap(other); +} +void NetStateRule::InternalSwap(NetStateRule* other) { + std::swap(phase_, other->phase_); + std::swap(min_level_, other->min_level_); + std::swap(max_level_, other->max_level_); + stage_.UnsafeArenaSwap(&other->stage_); + not_stage_.UnsafeArenaSwap(&other->not_stage_); + std::swap(_has_bits_[0], other->_has_bits_[0]); + _internal_metadata_.Swap(&other->_internal_metadata_); + std::swap(_cached_size_, other->_cached_size_); } -::google::protobuf::Metadata ParamSpec::GetMetadata() const { +::google::protobuf::Metadata NetStateRule::GetMetadata() const { protobuf_AssignDescriptorsOnce(); ::google::protobuf::Metadata metadata; - metadata.descriptor = ParamSpec_descriptor_; - metadata.reflection = ParamSpec_reflection_; + metadata.descriptor = NetStateRule_descriptor_; + metadata.reflection = NetStateRule_reflection_; return metadata; } +#if PROTOBUF_INLINE_NOT_IN_HEADERS +// NetStateRule -// =================================================================== - -#ifndef _MSC_VER -const int LayerParameter::kNameFieldNumber; -const int LayerParameter::kTypeFieldNumber; -const int LayerParameter::kBottomFieldNumber; -const int LayerParameter::kTopFieldNumber; -const int LayerParameter::kPhaseFieldNumber; -const int LayerParameter::kLossWeightFieldNumber; -const int LayerParameter::kParamFieldNumber; -const int LayerParameter::kBlobsFieldNumber; -const int LayerParameter::kPropagateDownFieldNumber; -const int LayerParameter::kIncludeFieldNumber; -const int LayerParameter::kExcludeFieldNumber; -const int LayerParameter::kTransformParamFieldNumber; -const int LayerParameter::kLossParamFieldNumber; -const int LayerParameter::kAccuracyParamFieldNumber; -const int LayerParameter::kArgmaxParamFieldNumber; -const int LayerParameter::kConcatParamFieldNumber; -const int LayerParameter::kContrastiveLossParamFieldNumber; -const int LayerParameter::kConvolutionParamFieldNumber; -const int LayerParameter::kCropParamFieldNumber; -const int LayerParameter::kDataParamFieldNumber; -const int LayerParameter::kDetectionOutputParamFieldNumber; -const int LayerParameter::kDropoutParamFieldNumber; -const int LayerParameter::kDummyDataParamFieldNumber; -const int LayerParameter::kEltwiseParamFieldNumber; -const int LayerParameter::kExpParamFieldNumber; -const int LayerParameter::kFlattenParamFieldNumber; -const int LayerParameter::kHdf5DataParamFieldNumber; -const int LayerParameter::kHdf5OutputParamFieldNumber; -const int LayerParameter::kHingeLossParamFieldNumber; -const int LayerParameter::kImageDataParamFieldNumber; -const int LayerParameter::kInfogainLossParamFieldNumber; -const int LayerParameter::kInnerProductParamFieldNumber; -const int LayerParameter::kLogParamFieldNumber; -const int LayerParameter::kLrnParamFieldNumber; -const int LayerParameter::kMemoryDataParamFieldNumber; -const int LayerParameter::kMvnParamFieldNumber; -const int LayerParameter::kNormalizeBboxParamFieldNumber; -const int LayerParameter::kPermuteParamFieldNumber; -const int LayerParameter::kPoolingParamFieldNumber; -const int LayerParameter::kPowerParamFieldNumber; -const int LayerParameter::kPreluParamFieldNumber; -const int LayerParameter::kPriorBoxParamFieldNumber; -const int LayerParameter::kPythonParamFieldNumber; -const int LayerParameter::kReductionParamFieldNumber; -const int LayerParameter::kReluParamFieldNumber; -const int LayerParameter::kReshapeParamFieldNumber; -const int LayerParameter::kSigmoidParamFieldNumber; -const int LayerParameter::kSliceParamFieldNumber; -const int LayerParameter::kSoftmaxParamFieldNumber; -const int LayerParameter::kSppParamFieldNumber; -const int LayerParameter::kTanhParamFieldNumber; -const int LayerParameter::kThresholdParamFieldNumber; -const int LayerParameter::kWindowDataParamFieldNumber; -#endif // !_MSC_VER +// optional .caffe.Phase phase = 1; +bool NetStateRule::has_phase() const { + return (_has_bits_[0] & 0x00000001u) != 0; +} +void NetStateRule::set_has_phase() { + _has_bits_[0] |= 0x00000001u; +} +void NetStateRule::clear_has_phase() { + _has_bits_[0] &= ~0x00000001u; +} +void NetStateRule::clear_phase() { + phase_ = 0; + clear_has_phase(); +} +::caffe::Phase NetStateRule::phase() const { + // @@protoc_insertion_point(field_get:caffe.NetStateRule.phase) + return static_cast< ::caffe::Phase >(phase_); +} +void NetStateRule::set_phase(::caffe::Phase value) { + assert(::caffe::Phase_IsValid(value)); + set_has_phase(); + phase_ = value; + // @@protoc_insertion_point(field_set:caffe.NetStateRule.phase) +} -LayerParameter::LayerParameter() - : ::google::protobuf::Message() { - SharedCtor(); +// optional int32 min_level = 2; +bool NetStateRule::has_min_level() const { + return (_has_bits_[0] & 0x00000002u) != 0; +} +void NetStateRule::set_has_min_level() { + _has_bits_[0] |= 0x00000002u; +} +void NetStateRule::clear_has_min_level() { + _has_bits_[0] &= ~0x00000002u; +} +void NetStateRule::clear_min_level() { + min_level_ = 0; + clear_has_min_level(); +} +::google::protobuf::int32 NetStateRule::min_level() const { + // @@protoc_insertion_point(field_get:caffe.NetStateRule.min_level) + return min_level_; +} +void NetStateRule::set_min_level(::google::protobuf::int32 value) { + set_has_min_level(); + min_level_ = value; + // @@protoc_insertion_point(field_set:caffe.NetStateRule.min_level) } -void LayerParameter::InitAsDefaultInstance() { - transform_param_ = const_cast< ::caffe::TransformationParameter*>(&::caffe::TransformationParameter::default_instance()); - loss_param_ = const_cast< ::caffe::LossParameter*>(&::caffe::LossParameter::default_instance()); - accuracy_param_ = const_cast< ::caffe::AccuracyParameter*>(&::caffe::AccuracyParameter::default_instance()); - argmax_param_ = const_cast< ::caffe::ArgMaxParameter*>(&::caffe::ArgMaxParameter::default_instance()); - concat_param_ = const_cast< ::caffe::ConcatParameter*>(&::caffe::ConcatParameter::default_instance()); - contrastive_loss_param_ = const_cast< ::caffe::ContrastiveLossParameter*>(&::caffe::ContrastiveLossParameter::default_instance()); - convolution_param_ = const_cast< ::caffe::ConvolutionParameter*>(&::caffe::ConvolutionParameter::default_instance()); - crop_param_ = const_cast< ::caffe::CropParameter*>(&::caffe::CropParameter::default_instance()); - data_param_ = const_cast< ::caffe::DataParameter*>(&::caffe::DataParameter::default_instance()); - detection_output_param_ = const_cast< ::caffe::DetectionOutputParameter*>(&::caffe::DetectionOutputParameter::default_instance()); - dropout_param_ = const_cast< ::caffe::DropoutParameter*>(&::caffe::DropoutParameter::default_instance()); - dummy_data_param_ = const_cast< ::caffe::DummyDataParameter*>(&::caffe::DummyDataParameter::default_instance()); - eltwise_param_ = const_cast< ::caffe::EltwiseParameter*>(&::caffe::EltwiseParameter::default_instance()); - exp_param_ = const_cast< ::caffe::ExpParameter*>(&::caffe::ExpParameter::default_instance()); - flatten_param_ = const_cast< ::caffe::FlattenParameter*>(&::caffe::FlattenParameter::default_instance()); - hdf5_data_param_ = const_cast< ::caffe::HDF5DataParameter*>(&::caffe::HDF5DataParameter::default_instance()); - hdf5_output_param_ = const_cast< ::caffe::HDF5OutputParameter*>(&::caffe::HDF5OutputParameter::default_instance()); - hinge_loss_param_ = const_cast< ::caffe::HingeLossParameter*>(&::caffe::HingeLossParameter::default_instance()); - image_data_param_ = const_cast< ::caffe::ImageDataParameter*>(&::caffe::ImageDataParameter::default_instance()); - infogain_loss_param_ = const_cast< ::caffe::InfogainLossParameter*>(&::caffe::InfogainLossParameter::default_instance()); - inner_product_param_ = const_cast< ::caffe::InnerProductParameter*>(&::caffe::InnerProductParameter::default_instance()); - log_param_ = const_cast< ::caffe::LogParameter*>(&::caffe::LogParameter::default_instance()); - lrn_param_ = const_cast< ::caffe::LRNParameter*>(&::caffe::LRNParameter::default_instance()); - memory_data_param_ = const_cast< ::caffe::MemoryDataParameter*>(&::caffe::MemoryDataParameter::default_instance()); - mvn_param_ = const_cast< ::caffe::MVNParameter*>(&::caffe::MVNParameter::default_instance()); - normalize_bbox_param_ = const_cast< ::caffe::NormalizeBBoxParameter*>(&::caffe::NormalizeBBoxParameter::default_instance()); - permute_param_ = const_cast< ::caffe::PermuteParameter*>(&::caffe::PermuteParameter::default_instance()); - pooling_param_ = const_cast< ::caffe::PoolingParameter*>(&::caffe::PoolingParameter::default_instance()); - power_param_ = const_cast< ::caffe::PowerParameter*>(&::caffe::PowerParameter::default_instance()); - prelu_param_ = const_cast< ::caffe::PReLUParameter*>(&::caffe::PReLUParameter::default_instance()); - prior_box_param_ = const_cast< ::caffe::PriorBoxParameter*>(&::caffe::PriorBoxParameter::default_instance()); - python_param_ = const_cast< ::caffe::PythonParameter*>(&::caffe::PythonParameter::default_instance()); - reduction_param_ = const_cast< ::caffe::ReductionParameter*>(&::caffe::ReductionParameter::default_instance()); - relu_param_ = const_cast< ::caffe::ReLUParameter*>(&::caffe::ReLUParameter::default_instance()); - reshape_param_ = const_cast< ::caffe::ReshapeParameter*>(&::caffe::ReshapeParameter::default_instance()); - sigmoid_param_ = const_cast< ::caffe::SigmoidParameter*>(&::caffe::SigmoidParameter::default_instance()); - slice_param_ = const_cast< ::caffe::SliceParameter*>(&::caffe::SliceParameter::default_instance()); - softmax_param_ = const_cast< ::caffe::SoftmaxParameter*>(&::caffe::SoftmaxParameter::default_instance()); - spp_param_ = const_cast< ::caffe::SPPParameter*>(&::caffe::SPPParameter::default_instance()); - tanh_param_ = const_cast< ::caffe::TanHParameter*>(&::caffe::TanHParameter::default_instance()); - threshold_param_ = const_cast< ::caffe::ThresholdParameter*>(&::caffe::ThresholdParameter::default_instance()); - window_data_param_ = const_cast< ::caffe::WindowDataParameter*>(&::caffe::WindowDataParameter::default_instance()); +// optional int32 max_level = 3; +bool NetStateRule::has_max_level() const { + return (_has_bits_[0] & 0x00000004u) != 0; +} +void NetStateRule::set_has_max_level() { + _has_bits_[0] |= 0x00000004u; +} +void NetStateRule::clear_has_max_level() { + _has_bits_[0] &= ~0x00000004u; +} +void NetStateRule::clear_max_level() { + max_level_ = 0; + clear_has_max_level(); +} +::google::protobuf::int32 NetStateRule::max_level() const { + // @@protoc_insertion_point(field_get:caffe.NetStateRule.max_level) + return max_level_; +} +void NetStateRule::set_max_level(::google::protobuf::int32 value) { + set_has_max_level(); + max_level_ = value; + // @@protoc_insertion_point(field_set:caffe.NetStateRule.max_level) } -LayerParameter::LayerParameter(const LayerParameter& from) - : ::google::protobuf::Message() { - SharedCtor(); - MergeFrom(from); +// repeated string stage = 4; +int NetStateRule::stage_size() const { + return stage_.size(); +} +void NetStateRule::clear_stage() { + stage_.Clear(); +} +const ::std::string& NetStateRule::stage(int index) const { + // @@protoc_insertion_point(field_get:caffe.NetStateRule.stage) + return stage_.Get(index); +} +::std::string* NetStateRule::mutable_stage(int index) { + // @@protoc_insertion_point(field_mutable:caffe.NetStateRule.stage) + return stage_.Mutable(index); +} +void NetStateRule::set_stage(int index, const ::std::string& value) { + // @@protoc_insertion_point(field_set:caffe.NetStateRule.stage) + stage_.Mutable(index)->assign(value); +} +void NetStateRule::set_stage(int index, const char* value) { + stage_.Mutable(index)->assign(value); + // @@protoc_insertion_point(field_set_char:caffe.NetStateRule.stage) +} +void NetStateRule::set_stage(int index, const char* value, size_t size) { + stage_.Mutable(index)->assign( + reinterpret_cast(value), size); + // @@protoc_insertion_point(field_set_pointer:caffe.NetStateRule.stage) +} +::std::string* NetStateRule::add_stage() { + // @@protoc_insertion_point(field_add_mutable:caffe.NetStateRule.stage) + return stage_.Add(); +} +void NetStateRule::add_stage(const ::std::string& value) { + stage_.Add()->assign(value); + // @@protoc_insertion_point(field_add:caffe.NetStateRule.stage) +} +void NetStateRule::add_stage(const char* value) { + stage_.Add()->assign(value); + // @@protoc_insertion_point(field_add_char:caffe.NetStateRule.stage) +} +void NetStateRule::add_stage(const char* value, size_t size) { + stage_.Add()->assign(reinterpret_cast(value), size); + // @@protoc_insertion_point(field_add_pointer:caffe.NetStateRule.stage) +} +const ::google::protobuf::RepeatedPtrField< ::std::string>& +NetStateRule::stage() const { + // @@protoc_insertion_point(field_list:caffe.NetStateRule.stage) + return stage_; +} +::google::protobuf::RepeatedPtrField< ::std::string>* +NetStateRule::mutable_stage() { + // @@protoc_insertion_point(field_mutable_list:caffe.NetStateRule.stage) + return &stage_; } -void LayerParameter::SharedCtor() { - _cached_size_ = 0; - name_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); - type_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); - phase_ = 0; - transform_param_ = NULL; - loss_param_ = NULL; - accuracy_param_ = NULL; - argmax_param_ = NULL; - concat_param_ = NULL; - contrastive_loss_param_ = NULL; - convolution_param_ = NULL; - crop_param_ = NULL; - data_param_ = NULL; - detection_output_param_ = NULL; - dropout_param_ = NULL; - dummy_data_param_ = NULL; - eltwise_param_ = NULL; - exp_param_ = NULL; - flatten_param_ = NULL; - hdf5_data_param_ = NULL; - hdf5_output_param_ = NULL; - hinge_loss_param_ = NULL; - image_data_param_ = NULL; - infogain_loss_param_ = NULL; - inner_product_param_ = NULL; - log_param_ = NULL; - lrn_param_ = NULL; - memory_data_param_ = NULL; - mvn_param_ = NULL; - normalize_bbox_param_ = NULL; - permute_param_ = NULL; - pooling_param_ = NULL; - power_param_ = NULL; - prelu_param_ = NULL; - prior_box_param_ = NULL; - python_param_ = NULL; - reduction_param_ = NULL; - relu_param_ = NULL; - reshape_param_ = NULL; - sigmoid_param_ = NULL; - slice_param_ = NULL; - softmax_param_ = NULL; - spp_param_ = NULL; - tanh_param_ = NULL; - threshold_param_ = NULL; - window_data_param_ = NULL; - ::memset(_has_bits_, 0, sizeof(_has_bits_)); +// repeated string not_stage = 5; +int NetStateRule::not_stage_size() const { + return not_stage_.size(); +} +void NetStateRule::clear_not_stage() { + not_stage_.Clear(); +} +const ::std::string& NetStateRule::not_stage(int index) const { + // @@protoc_insertion_point(field_get:caffe.NetStateRule.not_stage) + return not_stage_.Get(index); +} +::std::string* NetStateRule::mutable_not_stage(int index) { + // @@protoc_insertion_point(field_mutable:caffe.NetStateRule.not_stage) + return not_stage_.Mutable(index); +} +void NetStateRule::set_not_stage(int index, const ::std::string& value) { + // @@protoc_insertion_point(field_set:caffe.NetStateRule.not_stage) + not_stage_.Mutable(index)->assign(value); +} +void NetStateRule::set_not_stage(int index, const char* value) { + not_stage_.Mutable(index)->assign(value); + // @@protoc_insertion_point(field_set_char:caffe.NetStateRule.not_stage) +} +void NetStateRule::set_not_stage(int index, const char* value, size_t size) { + not_stage_.Mutable(index)->assign( + reinterpret_cast(value), size); + // @@protoc_insertion_point(field_set_pointer:caffe.NetStateRule.not_stage) +} +::std::string* NetStateRule::add_not_stage() { + // @@protoc_insertion_point(field_add_mutable:caffe.NetStateRule.not_stage) + return not_stage_.Add(); +} +void NetStateRule::add_not_stage(const ::std::string& value) { + not_stage_.Add()->assign(value); + // @@protoc_insertion_point(field_add:caffe.NetStateRule.not_stage) +} +void NetStateRule::add_not_stage(const char* value) { + not_stage_.Add()->assign(value); + // @@protoc_insertion_point(field_add_char:caffe.NetStateRule.not_stage) +} +void NetStateRule::add_not_stage(const char* value, size_t size) { + not_stage_.Add()->assign(reinterpret_cast(value), size); + // @@protoc_insertion_point(field_add_pointer:caffe.NetStateRule.not_stage) +} +const ::google::protobuf::RepeatedPtrField< ::std::string>& +NetStateRule::not_stage() const { + // @@protoc_insertion_point(field_list:caffe.NetStateRule.not_stage) + return not_stage_; +} +::google::protobuf::RepeatedPtrField< ::std::string>* +NetStateRule::mutable_not_stage() { + // @@protoc_insertion_point(field_mutable_list:caffe.NetStateRule.not_stage) + return ¬_stage_; } -LayerParameter::~LayerParameter() { - SharedDtor(); +inline const NetStateRule* NetStateRule::internal_default_instance() { + return &NetStateRule_default_instance_.get(); } +#endif // PROTOBUF_INLINE_NOT_IN_HEADERS -void LayerParameter::SharedDtor() { - if (name_ != &::google::protobuf::internal::kEmptyString) { - delete name_; - } - if (type_ != &::google::protobuf::internal::kEmptyString) { - delete type_; - } - if (this != default_instance_) { - delete transform_param_; - delete loss_param_; - delete accuracy_param_; - delete argmax_param_; - delete concat_param_; - delete contrastive_loss_param_; - delete convolution_param_; - delete crop_param_; - delete data_param_; - delete detection_output_param_; - delete dropout_param_; - delete dummy_data_param_; - delete eltwise_param_; - delete exp_param_; - delete flatten_param_; - delete hdf5_data_param_; - delete hdf5_output_param_; - delete hinge_loss_param_; - delete image_data_param_; - delete infogain_loss_param_; - delete inner_product_param_; - delete log_param_; - delete lrn_param_; - delete memory_data_param_; - delete mvn_param_; - delete normalize_bbox_param_; - delete permute_param_; - delete pooling_param_; - delete power_param_; - delete prelu_param_; - delete prior_box_param_; - delete python_param_; - delete reduction_param_; - delete relu_param_; - delete reshape_param_; - delete sigmoid_param_; - delete slice_param_; - delete softmax_param_; - delete spp_param_; - delete tanh_param_; - delete threshold_param_; - delete window_data_param_; +// =================================================================== + +const ::google::protobuf::EnumDescriptor* ParamSpec_DimCheckMode_descriptor() { + protobuf_AssignDescriptorsOnce(); + return ParamSpec_DimCheckMode_descriptor_; +} +bool ParamSpec_DimCheckMode_IsValid(int value) { + switch (value) { + case 0: + case 1: + return true; + default: + return false; } } -void LayerParameter::SetCachedSize(int size) const { +#if !defined(_MSC_VER) || _MSC_VER >= 1900 +const ParamSpec_DimCheckMode ParamSpec::STRICT; +const ParamSpec_DimCheckMode ParamSpec::PERMISSIVE; +const ParamSpec_DimCheckMode ParamSpec::DimCheckMode_MIN; +const ParamSpec_DimCheckMode ParamSpec::DimCheckMode_MAX; +const int ParamSpec::DimCheckMode_ARRAYSIZE; +#endif // !defined(_MSC_VER) || _MSC_VER >= 1900 +#if !defined(_MSC_VER) || _MSC_VER >= 1900 +const int ParamSpec::kNameFieldNumber; +const int ParamSpec::kShareModeFieldNumber; +const int ParamSpec::kLrMultFieldNumber; +const int ParamSpec::kDecayMultFieldNumber; +#endif // !defined(_MSC_VER) || _MSC_VER >= 1900 + +ParamSpec::ParamSpec() + : ::google::protobuf::Message(), _internal_metadata_(NULL) { + if (this != internal_default_instance()) protobuf_InitDefaults_caffe_2eproto(); + SharedCtor(); + // @@protoc_insertion_point(constructor:caffe.ParamSpec) +} + +void ParamSpec::InitAsDefaultInstance() { +} + +ParamSpec::ParamSpec(const ParamSpec& from) + : ::google::protobuf::Message(), + _internal_metadata_(NULL) { + SharedCtor(); + UnsafeMergeFrom(from); + // @@protoc_insertion_point(copy_constructor:caffe.ParamSpec) +} + +void ParamSpec::SharedCtor() { + _cached_size_ = 0; + name_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + share_mode_ = 0; + lr_mult_ = 1; + decay_mult_ = 1; +} + +ParamSpec::~ParamSpec() { + // @@protoc_insertion_point(destructor:caffe.ParamSpec) + SharedDtor(); +} + +void ParamSpec::SharedDtor() { + name_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); +} + +void ParamSpec::SetCachedSize(int size) const { GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); _cached_size_ = size; GOOGLE_SAFE_CONCURRENT_WRITES_END(); } -const ::google::protobuf::Descriptor* LayerParameter::descriptor() { +const ::google::protobuf::Descriptor* ParamSpec::descriptor() { protobuf_AssignDescriptorsOnce(); - return LayerParameter_descriptor_; + return ParamSpec_descriptor_; } -const LayerParameter& LayerParameter::default_instance() { - if (default_instance_ == NULL) protobuf_AddDesc_caffe_2eproto(); - return *default_instance_; +const ParamSpec& ParamSpec::default_instance() { + protobuf_InitDefaults_caffe_2eproto(); + return *internal_default_instance(); } -LayerParameter* LayerParameter::default_instance_ = NULL; +::google::protobuf::internal::ExplicitlyConstructed ParamSpec_default_instance_; -LayerParameter* LayerParameter::New() const { - return new LayerParameter; +ParamSpec* ParamSpec::New(::google::protobuf::Arena* arena) const { + ParamSpec* n = new ParamSpec; + if (arena != NULL) { + arena->Own(n); + } + return n; } -void LayerParameter::Clear() { - if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) { +void ParamSpec::Clear() { +// @@protoc_insertion_point(message_clear_start:caffe.ParamSpec) + if (_has_bits_[0 / 32] & 15u) { if (has_name()) { - if (name_ != &::google::protobuf::internal::kEmptyString) { - name_->clear(); - } + name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - if (has_type()) { - if (type_ != &::google::protobuf::internal::kEmptyString) { - type_->clear(); + share_mode_ = 0; + lr_mult_ = 1; + decay_mult_ = 1; + } + _has_bits_.Clear(); + if (_internal_metadata_.have_unknown_fields()) { + mutable_unknown_fields()->Clear(); + } +} + +bool ParamSpec::MergePartialFromCodedStream( + ::google::protobuf::io::CodedInputStream* input) { +#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure + ::google::protobuf::uint32 tag; + // @@protoc_insertion_point(parse_start:caffe.ParamSpec) + for (;;) { + ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127); + tag = p.first; + if (!p.second) goto handle_unusual; + switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { + // optional string name = 1; + case 1: { + if (tag == 10) { + DO_(::google::protobuf::internal::WireFormatLite::ReadString( + input, this->mutable_name())); + ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( + this->name().data(), this->name().length(), + ::google::protobuf::internal::WireFormat::PARSE, + "caffe.ParamSpec.name"); + } else { + goto handle_unusual; + } + if (input->ExpectTag(16)) goto parse_share_mode; + break; + } + + // optional .caffe.ParamSpec.DimCheckMode share_mode = 2; + case 2: { + if (tag == 16) { + parse_share_mode: + int value; + DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< + int, ::google::protobuf::internal::WireFormatLite::TYPE_ENUM>( + input, &value))); + if (::caffe::ParamSpec_DimCheckMode_IsValid(value)) { + set_share_mode(static_cast< ::caffe::ParamSpec_DimCheckMode >(value)); + } else { + mutable_unknown_fields()->AddVarint(2, value); + } + } else { + goto handle_unusual; + } + if (input->ExpectTag(29)) goto parse_lr_mult; + break; + } + + // optional float lr_mult = 3 [default = 1]; + case 3: { + if (tag == 29) { + parse_lr_mult: + set_has_lr_mult(); + DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< + float, ::google::protobuf::internal::WireFormatLite::TYPE_FLOAT>( + input, &lr_mult_))); + } else { + goto handle_unusual; + } + if (input->ExpectTag(37)) goto parse_decay_mult; + break; + } + + // optional float decay_mult = 4 [default = 1]; + case 4: { + if (tag == 37) { + parse_decay_mult: + set_has_decay_mult(); + DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< + float, ::google::protobuf::internal::WireFormatLite::TYPE_FLOAT>( + input, &decay_mult_))); + } else { + goto handle_unusual; + } + if (input->ExpectAtEnd()) goto success; + break; + } + + default: { + handle_unusual: + if (tag == 0 || + ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == + ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) { + goto success; + } + DO_(::google::protobuf::internal::WireFormat::SkipField( + input, tag, mutable_unknown_fields())); + break; } } - phase_ = 0; } - if (_has_bits_[11 / 32] & (0xffu << (11 % 32))) { - if (has_transform_param()) { - if (transform_param_ != NULL) transform_param_->::caffe::TransformationParameter::Clear(); - } - if (has_loss_param()) { - if (loss_param_ != NULL) loss_param_->::caffe::LossParameter::Clear(); - } - if (has_accuracy_param()) { - if (accuracy_param_ != NULL) accuracy_param_->::caffe::AccuracyParameter::Clear(); - } - if (has_argmax_param()) { - if (argmax_param_ != NULL) argmax_param_->::caffe::ArgMaxParameter::Clear(); - } - if (has_concat_param()) { - if (concat_param_ != NULL) concat_param_->::caffe::ConcatParameter::Clear(); - } +success: + // @@protoc_insertion_point(parse_success:caffe.ParamSpec) + return true; +failure: + // @@protoc_insertion_point(parse_failure:caffe.ParamSpec) + return false; +#undef DO_ +} + +void ParamSpec::SerializeWithCachedSizes( + ::google::protobuf::io::CodedOutputStream* output) const { + // @@protoc_insertion_point(serialize_start:caffe.ParamSpec) + // optional string name = 1; + if (has_name()) { + ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( + this->name().data(), this->name().length(), + ::google::protobuf::internal::WireFormat::SERIALIZE, + "caffe.ParamSpec.name"); + ::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased( + 1, this->name(), output); } - if (_has_bits_[16 / 32] & (0xffu << (16 % 32))) { - if (has_contrastive_loss_param()) { - if (contrastive_loss_param_ != NULL) contrastive_loss_param_->::caffe::ContrastiveLossParameter::Clear(); - } - if (has_convolution_param()) { - if (convolution_param_ != NULL) convolution_param_->::caffe::ConvolutionParameter::Clear(); - } - if (has_crop_param()) { - if (crop_param_ != NULL) crop_param_->::caffe::CropParameter::Clear(); - } - if (has_data_param()) { - if (data_param_ != NULL) data_param_->::caffe::DataParameter::Clear(); - } - if (has_detection_output_param()) { - if (detection_output_param_ != NULL) detection_output_param_->::caffe::DetectionOutputParameter::Clear(); - } - if (has_dropout_param()) { - if (dropout_param_ != NULL) dropout_param_->::caffe::DropoutParameter::Clear(); - } - if (has_dummy_data_param()) { - if (dummy_data_param_ != NULL) dummy_data_param_->::caffe::DummyDataParameter::Clear(); - } - if (has_eltwise_param()) { - if (eltwise_param_ != NULL) eltwise_param_->::caffe::EltwiseParameter::Clear(); - } + + // optional .caffe.ParamSpec.DimCheckMode share_mode = 2; + if (has_share_mode()) { + ::google::protobuf::internal::WireFormatLite::WriteEnum( + 2, this->share_mode(), output); } - if (_has_bits_[24 / 32] & (0xffu << (24 % 32))) { - if (has_exp_param()) { - if (exp_param_ != NULL) exp_param_->::caffe::ExpParameter::Clear(); - } - if (has_flatten_param()) { - if (flatten_param_ != NULL) flatten_param_->::caffe::FlattenParameter::Clear(); - } - if (has_hdf5_data_param()) { - if (hdf5_data_param_ != NULL) hdf5_data_param_->::caffe::HDF5DataParameter::Clear(); - } - if (has_hdf5_output_param()) { - if (hdf5_output_param_ != NULL) hdf5_output_param_->::caffe::HDF5OutputParameter::Clear(); - } - if (has_hinge_loss_param()) { - if (hinge_loss_param_ != NULL) hinge_loss_param_->::caffe::HingeLossParameter::Clear(); - } - if (has_image_data_param()) { - if (image_data_param_ != NULL) image_data_param_->::caffe::ImageDataParameter::Clear(); - } - if (has_infogain_loss_param()) { - if (infogain_loss_param_ != NULL) infogain_loss_param_->::caffe::InfogainLossParameter::Clear(); - } - if (has_inner_product_param()) { - if (inner_product_param_ != NULL) inner_product_param_->::caffe::InnerProductParameter::Clear(); - } + + // optional float lr_mult = 3 [default = 1]; + if (has_lr_mult()) { + ::google::protobuf::internal::WireFormatLite::WriteFloat(3, this->lr_mult(), output); } - if (_has_bits_[32 / 32] & (0xffu << (32 % 32))) { - if (has_log_param()) { - if (log_param_ != NULL) log_param_->::caffe::LogParameter::Clear(); - } - if (has_lrn_param()) { - if (lrn_param_ != NULL) lrn_param_->::caffe::LRNParameter::Clear(); - } - if (has_memory_data_param()) { - if (memory_data_param_ != NULL) memory_data_param_->::caffe::MemoryDataParameter::Clear(); - } - if (has_mvn_param()) { - if (mvn_param_ != NULL) mvn_param_->::caffe::MVNParameter::Clear(); - } - if (has_normalize_bbox_param()) { - if (normalize_bbox_param_ != NULL) normalize_bbox_param_->::caffe::NormalizeBBoxParameter::Clear(); - } - if (has_permute_param()) { - if (permute_param_ != NULL) permute_param_->::caffe::PermuteParameter::Clear(); - } - if (has_pooling_param()) { - if (pooling_param_ != NULL) pooling_param_->::caffe::PoolingParameter::Clear(); - } - if (has_power_param()) { - if (power_param_ != NULL) power_param_->::caffe::PowerParameter::Clear(); - } + + // optional float decay_mult = 4 [default = 1]; + if (has_decay_mult()) { + ::google::protobuf::internal::WireFormatLite::WriteFloat(4, this->decay_mult(), output); } - if (_has_bits_[40 / 32] & (0xffu << (40 % 32))) { - if (has_prelu_param()) { - if (prelu_param_ != NULL) prelu_param_->::caffe::PReLUParameter::Clear(); - } - if (has_prior_box_param()) { - if (prior_box_param_ != NULL) prior_box_param_->::caffe::PriorBoxParameter::Clear(); - } - if (has_python_param()) { - if (python_param_ != NULL) python_param_->::caffe::PythonParameter::Clear(); - } - if (has_reduction_param()) { - if (reduction_param_ != NULL) reduction_param_->::caffe::ReductionParameter::Clear(); - } - if (has_relu_param()) { - if (relu_param_ != NULL) relu_param_->::caffe::ReLUParameter::Clear(); + + if (_internal_metadata_.have_unknown_fields()) { + ::google::protobuf::internal::WireFormat::SerializeUnknownFields( + unknown_fields(), output); + } + // @@protoc_insertion_point(serialize_end:caffe.ParamSpec) +} + +::google::protobuf::uint8* ParamSpec::InternalSerializeWithCachedSizesToArray( + bool deterministic, ::google::protobuf::uint8* target) const { + (void)deterministic; // Unused + // @@protoc_insertion_point(serialize_to_array_start:caffe.ParamSpec) + // optional string name = 1; + if (has_name()) { + ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( + this->name().data(), this->name().length(), + ::google::protobuf::internal::WireFormat::SERIALIZE, + "caffe.ParamSpec.name"); + target = + ::google::protobuf::internal::WireFormatLite::WriteStringToArray( + 1, this->name(), target); + } + + // optional .caffe.ParamSpec.DimCheckMode share_mode = 2; + if (has_share_mode()) { + target = ::google::protobuf::internal::WireFormatLite::WriteEnumToArray( + 2, this->share_mode(), target); + } + + // optional float lr_mult = 3 [default = 1]; + if (has_lr_mult()) { + target = ::google::protobuf::internal::WireFormatLite::WriteFloatToArray(3, this->lr_mult(), target); + } + + // optional float decay_mult = 4 [default = 1]; + if (has_decay_mult()) { + target = ::google::protobuf::internal::WireFormatLite::WriteFloatToArray(4, this->decay_mult(), target); + } + + if (_internal_metadata_.have_unknown_fields()) { + target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray( + unknown_fields(), target); + } + // @@protoc_insertion_point(serialize_to_array_end:caffe.ParamSpec) + return target; +} + +size_t ParamSpec::ByteSizeLong() const { +// @@protoc_insertion_point(message_byte_size_start:caffe.ParamSpec) + size_t total_size = 0; + + if (_has_bits_[0 / 32] & 15u) { + // optional string name = 1; + if (has_name()) { + total_size += 1 + + ::google::protobuf::internal::WireFormatLite::StringSize( + this->name()); } - if (has_reshape_param()) { - if (reshape_param_ != NULL) reshape_param_->::caffe::ReshapeParameter::Clear(); + + // optional .caffe.ParamSpec.DimCheckMode share_mode = 2; + if (has_share_mode()) { + total_size += 1 + + ::google::protobuf::internal::WireFormatLite::EnumSize(this->share_mode()); } - if (has_sigmoid_param()) { - if (sigmoid_param_ != NULL) sigmoid_param_->::caffe::SigmoidParameter::Clear(); + + // optional float lr_mult = 3 [default = 1]; + if (has_lr_mult()) { + total_size += 1 + 4; } - if (has_slice_param()) { - if (slice_param_ != NULL) slice_param_->::caffe::SliceParameter::Clear(); + + // optional float decay_mult = 4 [default = 1]; + if (has_decay_mult()) { + total_size += 1 + 4; } + } - if (_has_bits_[48 / 32] & (0xffu << (48 % 32))) { - if (has_softmax_param()) { - if (softmax_param_ != NULL) softmax_param_->::caffe::SoftmaxParameter::Clear(); - } - if (has_spp_param()) { - if (spp_param_ != NULL) spp_param_->::caffe::SPPParameter::Clear(); + if (_internal_metadata_.have_unknown_fields()) { + total_size += + ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( + unknown_fields()); + } + int cached_size = ::google::protobuf::internal::ToCachedSize(total_size); + GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); + _cached_size_ = cached_size; + GOOGLE_SAFE_CONCURRENT_WRITES_END(); + return total_size; +} + +void ParamSpec::MergeFrom(const ::google::protobuf::Message& from) { +// @@protoc_insertion_point(generalized_merge_from_start:caffe.ParamSpec) + if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__); + const ParamSpec* source = + ::google::protobuf::internal::DynamicCastToGenerated( + &from); + if (source == NULL) { + // @@protoc_insertion_point(generalized_merge_from_cast_fail:caffe.ParamSpec) + ::google::protobuf::internal::ReflectionOps::Merge(from, this); + } else { + // @@protoc_insertion_point(generalized_merge_from_cast_success:caffe.ParamSpec) + UnsafeMergeFrom(*source); + } +} + +void ParamSpec::MergeFrom(const ParamSpec& from) { +// @@protoc_insertion_point(class_specific_merge_from_start:caffe.ParamSpec) + if (GOOGLE_PREDICT_TRUE(&from != this)) { + UnsafeMergeFrom(from); + } else { + MergeFromFail(__LINE__); + } +} + +void ParamSpec::UnsafeMergeFrom(const ParamSpec& from) { + GOOGLE_DCHECK(&from != this); + if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) { + if (from.has_name()) { + set_has_name(); + name_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.name_); } - if (has_tanh_param()) { - if (tanh_param_ != NULL) tanh_param_->::caffe::TanHParameter::Clear(); + if (from.has_share_mode()) { + set_share_mode(from.share_mode()); } - if (has_threshold_param()) { - if (threshold_param_ != NULL) threshold_param_->::caffe::ThresholdParameter::Clear(); + if (from.has_lr_mult()) { + set_lr_mult(from.lr_mult()); } - if (has_window_data_param()) { - if (window_data_param_ != NULL) window_data_param_->::caffe::WindowDataParameter::Clear(); + if (from.has_decay_mult()) { + set_decay_mult(from.decay_mult()); } } - bottom_.Clear(); - top_.Clear(); - loss_weight_.Clear(); - param_.Clear(); - blobs_.Clear(); - propagate_down_.Clear(); - include_.Clear(); - exclude_.Clear(); - ::memset(_has_bits_, 0, sizeof(_has_bits_)); - mutable_unknown_fields()->Clear(); + if (from._internal_metadata_.have_unknown_fields()) { + ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata( + from.unknown_fields(), &_internal_metadata_); + } } -bool LayerParameter::MergePartialFromCodedStream( - ::google::protobuf::io::CodedInputStream* input) { -#define DO_(EXPRESSION) if (!(EXPRESSION)) return false - ::google::protobuf::uint32 tag; - while ((tag = input->ReadTag()) != 0) { - switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { - // optional string name = 1; - case 1: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) { - DO_(::google::protobuf::internal::WireFormatLite::ReadString( - input, this->mutable_name())); - ::google::protobuf::internal::WireFormat::VerifyUTF8String( - this->name().data(), this->name().length(), - ::google::protobuf::internal::WireFormat::PARSE); - } else { - goto handle_uninterpreted; - } - if (input->ExpectTag(18)) goto parse_type; - break; - } +void ParamSpec::CopyFrom(const ::google::protobuf::Message& from) { +// @@protoc_insertion_point(generalized_copy_from_start:caffe.ParamSpec) + if (&from == this) return; + Clear(); + MergeFrom(from); +} - // optional string type = 2; - case 2: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) { - parse_type: - DO_(::google::protobuf::internal::WireFormatLite::ReadString( - input, this->mutable_type())); - ::google::protobuf::internal::WireFormat::VerifyUTF8String( - this->type().data(), this->type().length(), - ::google::protobuf::internal::WireFormat::PARSE); - } else { - goto handle_uninterpreted; - } - if (input->ExpectTag(26)) goto parse_bottom; - break; - } +void ParamSpec::CopyFrom(const ParamSpec& from) { +// @@protoc_insertion_point(class_specific_copy_from_start:caffe.ParamSpec) + if (&from == this) return; + Clear(); + UnsafeMergeFrom(from); +} - // repeated string bottom = 3; - case 3: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) { - parse_bottom: - DO_(::google::protobuf::internal::WireFormatLite::ReadString( - input, this->add_bottom())); - ::google::protobuf::internal::WireFormat::VerifyUTF8String( - this->bottom(this->bottom_size() - 1).data(), - this->bottom(this->bottom_size() - 1).length(), - ::google::protobuf::internal::WireFormat::PARSE); - } else { - goto handle_uninterpreted; - } - if (input->ExpectTag(26)) goto parse_bottom; - if (input->ExpectTag(34)) goto parse_top; - break; - } +bool ParamSpec::IsInitialized() const { - // repeated string top = 4; - case 4: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) { + return true; +} + +void ParamSpec::Swap(ParamSpec* other) { + if (other == this) return; + InternalSwap(other); +} +void ParamSpec::InternalSwap(ParamSpec* other) { + name_.Swap(&other->name_); + std::swap(share_mode_, other->share_mode_); + std::swap(lr_mult_, other->lr_mult_); + std::swap(decay_mult_, other->decay_mult_); + std::swap(_has_bits_[0], other->_has_bits_[0]); + _internal_metadata_.Swap(&other->_internal_metadata_); + std::swap(_cached_size_, other->_cached_size_); +} + +::google::protobuf::Metadata ParamSpec::GetMetadata() const { + protobuf_AssignDescriptorsOnce(); + ::google::protobuf::Metadata metadata; + metadata.descriptor = ParamSpec_descriptor_; + metadata.reflection = ParamSpec_reflection_; + return metadata; +} + +#if PROTOBUF_INLINE_NOT_IN_HEADERS +// ParamSpec + +// optional string name = 1; +bool ParamSpec::has_name() const { + return (_has_bits_[0] & 0x00000001u) != 0; +} +void ParamSpec::set_has_name() { + _has_bits_[0] |= 0x00000001u; +} +void ParamSpec::clear_has_name() { + _has_bits_[0] &= ~0x00000001u; +} +void ParamSpec::clear_name() { + name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + clear_has_name(); +} +const ::std::string& ParamSpec::name() const { + // @@protoc_insertion_point(field_get:caffe.ParamSpec.name) + return name_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); +} +void ParamSpec::set_name(const ::std::string& value) { + set_has_name(); + name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); + // @@protoc_insertion_point(field_set:caffe.ParamSpec.name) +} +void ParamSpec::set_name(const char* value) { + set_has_name(); + name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); + // @@protoc_insertion_point(field_set_char:caffe.ParamSpec.name) +} +void ParamSpec::set_name(const char* value, size_t size) { + set_has_name(); + name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), + ::std::string(reinterpret_cast(value), size)); + // @@protoc_insertion_point(field_set_pointer:caffe.ParamSpec.name) +} +::std::string* ParamSpec::mutable_name() { + set_has_name(); + // @@protoc_insertion_point(field_mutable:caffe.ParamSpec.name) + return name_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); +} +::std::string* ParamSpec::release_name() { + // @@protoc_insertion_point(field_release:caffe.ParamSpec.name) + clear_has_name(); + return name_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); +} +void ParamSpec::set_allocated_name(::std::string* name) { + if (name != NULL) { + set_has_name(); + } else { + clear_has_name(); + } + name_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), name); + // @@protoc_insertion_point(field_set_allocated:caffe.ParamSpec.name) +} + +// optional .caffe.ParamSpec.DimCheckMode share_mode = 2; +bool ParamSpec::has_share_mode() const { + return (_has_bits_[0] & 0x00000002u) != 0; +} +void ParamSpec::set_has_share_mode() { + _has_bits_[0] |= 0x00000002u; +} +void ParamSpec::clear_has_share_mode() { + _has_bits_[0] &= ~0x00000002u; +} +void ParamSpec::clear_share_mode() { + share_mode_ = 0; + clear_has_share_mode(); +} +::caffe::ParamSpec_DimCheckMode ParamSpec::share_mode() const { + // @@protoc_insertion_point(field_get:caffe.ParamSpec.share_mode) + return static_cast< ::caffe::ParamSpec_DimCheckMode >(share_mode_); +} +void ParamSpec::set_share_mode(::caffe::ParamSpec_DimCheckMode value) { + assert(::caffe::ParamSpec_DimCheckMode_IsValid(value)); + set_has_share_mode(); + share_mode_ = value; + // @@protoc_insertion_point(field_set:caffe.ParamSpec.share_mode) +} + +// optional float lr_mult = 3 [default = 1]; +bool ParamSpec::has_lr_mult() const { + return (_has_bits_[0] & 0x00000004u) != 0; +} +void ParamSpec::set_has_lr_mult() { + _has_bits_[0] |= 0x00000004u; +} +void ParamSpec::clear_has_lr_mult() { + _has_bits_[0] &= ~0x00000004u; +} +void ParamSpec::clear_lr_mult() { + lr_mult_ = 1; + clear_has_lr_mult(); +} +float ParamSpec::lr_mult() const { + // @@protoc_insertion_point(field_get:caffe.ParamSpec.lr_mult) + return lr_mult_; +} +void ParamSpec::set_lr_mult(float value) { + set_has_lr_mult(); + lr_mult_ = value; + // @@protoc_insertion_point(field_set:caffe.ParamSpec.lr_mult) +} + +// optional float decay_mult = 4 [default = 1]; +bool ParamSpec::has_decay_mult() const { + return (_has_bits_[0] & 0x00000008u) != 0; +} +void ParamSpec::set_has_decay_mult() { + _has_bits_[0] |= 0x00000008u; +} +void ParamSpec::clear_has_decay_mult() { + _has_bits_[0] &= ~0x00000008u; +} +void ParamSpec::clear_decay_mult() { + decay_mult_ = 1; + clear_has_decay_mult(); +} +float ParamSpec::decay_mult() const { + // @@protoc_insertion_point(field_get:caffe.ParamSpec.decay_mult) + return decay_mult_; +} +void ParamSpec::set_decay_mult(float value) { + set_has_decay_mult(); + decay_mult_ = value; + // @@protoc_insertion_point(field_set:caffe.ParamSpec.decay_mult) +} + +inline const ParamSpec* ParamSpec::internal_default_instance() { + return &ParamSpec_default_instance_.get(); +} +#endif // PROTOBUF_INLINE_NOT_IN_HEADERS + +// =================================================================== + +#if !defined(_MSC_VER) || _MSC_VER >= 1900 +const int LayerParameter::kNameFieldNumber; +const int LayerParameter::kTypeFieldNumber; +const int LayerParameter::kBottomFieldNumber; +const int LayerParameter::kTopFieldNumber; +const int LayerParameter::kPhaseFieldNumber; +const int LayerParameter::kLossWeightFieldNumber; +const int LayerParameter::kParamFieldNumber; +const int LayerParameter::kBlobsFieldNumber; +const int LayerParameter::kPropagateDownFieldNumber; +const int LayerParameter::kIncludeFieldNumber; +const int LayerParameter::kExcludeFieldNumber; +const int LayerParameter::kTransformParamFieldNumber; +const int LayerParameter::kLossParamFieldNumber; +const int LayerParameter::kAccuracyParamFieldNumber; +const int LayerParameter::kArgmaxParamFieldNumber; +const int LayerParameter::kConcatParamFieldNumber; +const int LayerParameter::kContrastiveLossParamFieldNumber; +const int LayerParameter::kConvolutionParamFieldNumber; +const int LayerParameter::kCropParamFieldNumber; +const int LayerParameter::kDataParamFieldNumber; +const int LayerParameter::kDetectionOutputParamFieldNumber; +const int LayerParameter::kDropoutParamFieldNumber; +const int LayerParameter::kDummyDataParamFieldNumber; +const int LayerParameter::kEltwiseParamFieldNumber; +const int LayerParameter::kExpParamFieldNumber; +const int LayerParameter::kFlattenParamFieldNumber; +const int LayerParameter::kHdf5DataParamFieldNumber; +const int LayerParameter::kHdf5OutputParamFieldNumber; +const int LayerParameter::kHingeLossParamFieldNumber; +const int LayerParameter::kImageDataParamFieldNumber; +const int LayerParameter::kInfogainLossParamFieldNumber; +const int LayerParameter::kInnerProductParamFieldNumber; +const int LayerParameter::kLogParamFieldNumber; +const int LayerParameter::kLrnParamFieldNumber; +const int LayerParameter::kMemoryDataParamFieldNumber; +const int LayerParameter::kMvnParamFieldNumber; +const int LayerParameter::kNormalizeBboxParamFieldNumber; +const int LayerParameter::kPermuteParamFieldNumber; +const int LayerParameter::kPoolingParamFieldNumber; +const int LayerParameter::kPowerParamFieldNumber; +const int LayerParameter::kPreluParamFieldNumber; +const int LayerParameter::kPriorBoxParamFieldNumber; +const int LayerParameter::kPythonParamFieldNumber; +const int LayerParameter::kReductionParamFieldNumber; +const int LayerParameter::kReluParamFieldNumber; +const int LayerParameter::kReshapeParamFieldNumber; +const int LayerParameter::kSigmoidParamFieldNumber; +const int LayerParameter::kSliceParamFieldNumber; +const int LayerParameter::kSoftmaxParamFieldNumber; +const int LayerParameter::kSppParamFieldNumber; +const int LayerParameter::kTanhParamFieldNumber; +const int LayerParameter::kThresholdParamFieldNumber; +const int LayerParameter::kWindowDataParamFieldNumber; +#endif // !defined(_MSC_VER) || _MSC_VER >= 1900 + +LayerParameter::LayerParameter() + : ::google::protobuf::Message(), _internal_metadata_(NULL) { + if (this != internal_default_instance()) protobuf_InitDefaults_caffe_2eproto(); + SharedCtor(); + // @@protoc_insertion_point(constructor:caffe.LayerParameter) +} + +void LayerParameter::InitAsDefaultInstance() { + transform_param_ = const_cast< ::caffe::TransformationParameter*>( + ::caffe::TransformationParameter::internal_default_instance()); + loss_param_ = const_cast< ::caffe::LossParameter*>( + ::caffe::LossParameter::internal_default_instance()); + accuracy_param_ = const_cast< ::caffe::AccuracyParameter*>( + ::caffe::AccuracyParameter::internal_default_instance()); + argmax_param_ = const_cast< ::caffe::ArgMaxParameter*>( + ::caffe::ArgMaxParameter::internal_default_instance()); + concat_param_ = const_cast< ::caffe::ConcatParameter*>( + ::caffe::ConcatParameter::internal_default_instance()); + contrastive_loss_param_ = const_cast< ::caffe::ContrastiveLossParameter*>( + ::caffe::ContrastiveLossParameter::internal_default_instance()); + convolution_param_ = const_cast< ::caffe::ConvolutionParameter*>( + ::caffe::ConvolutionParameter::internal_default_instance()); + crop_param_ = const_cast< ::caffe::CropParameter*>( + ::caffe::CropParameter::internal_default_instance()); + data_param_ = const_cast< ::caffe::DataParameter*>( + ::caffe::DataParameter::internal_default_instance()); + detection_output_param_ = const_cast< ::caffe::DetectionOutputParameter*>( + ::caffe::DetectionOutputParameter::internal_default_instance()); + dropout_param_ = const_cast< ::caffe::DropoutParameter*>( + ::caffe::DropoutParameter::internal_default_instance()); + dummy_data_param_ = const_cast< ::caffe::DummyDataParameter*>( + ::caffe::DummyDataParameter::internal_default_instance()); + eltwise_param_ = const_cast< ::caffe::EltwiseParameter*>( + ::caffe::EltwiseParameter::internal_default_instance()); + exp_param_ = const_cast< ::caffe::ExpParameter*>( + ::caffe::ExpParameter::internal_default_instance()); + flatten_param_ = const_cast< ::caffe::FlattenParameter*>( + ::caffe::FlattenParameter::internal_default_instance()); + hdf5_data_param_ = const_cast< ::caffe::HDF5DataParameter*>( + ::caffe::HDF5DataParameter::internal_default_instance()); + hdf5_output_param_ = const_cast< ::caffe::HDF5OutputParameter*>( + ::caffe::HDF5OutputParameter::internal_default_instance()); + hinge_loss_param_ = const_cast< ::caffe::HingeLossParameter*>( + ::caffe::HingeLossParameter::internal_default_instance()); + image_data_param_ = const_cast< ::caffe::ImageDataParameter*>( + ::caffe::ImageDataParameter::internal_default_instance()); + infogain_loss_param_ = const_cast< ::caffe::InfogainLossParameter*>( + ::caffe::InfogainLossParameter::internal_default_instance()); + inner_product_param_ = const_cast< ::caffe::InnerProductParameter*>( + ::caffe::InnerProductParameter::internal_default_instance()); + log_param_ = const_cast< ::caffe::LogParameter*>( + ::caffe::LogParameter::internal_default_instance()); + lrn_param_ = const_cast< ::caffe::LRNParameter*>( + ::caffe::LRNParameter::internal_default_instance()); + memory_data_param_ = const_cast< ::caffe::MemoryDataParameter*>( + ::caffe::MemoryDataParameter::internal_default_instance()); + mvn_param_ = const_cast< ::caffe::MVNParameter*>( + ::caffe::MVNParameter::internal_default_instance()); + normalize_bbox_param_ = const_cast< ::caffe::NormalizeBBoxParameter*>( + ::caffe::NormalizeBBoxParameter::internal_default_instance()); + permute_param_ = const_cast< ::caffe::PermuteParameter*>( + ::caffe::PermuteParameter::internal_default_instance()); + pooling_param_ = const_cast< ::caffe::PoolingParameter*>( + ::caffe::PoolingParameter::internal_default_instance()); + power_param_ = const_cast< ::caffe::PowerParameter*>( + ::caffe::PowerParameter::internal_default_instance()); + prelu_param_ = const_cast< ::caffe::PReLUParameter*>( + ::caffe::PReLUParameter::internal_default_instance()); + prior_box_param_ = const_cast< ::caffe::PriorBoxParameter*>( + ::caffe::PriorBoxParameter::internal_default_instance()); + python_param_ = const_cast< ::caffe::PythonParameter*>( + ::caffe::PythonParameter::internal_default_instance()); + reduction_param_ = const_cast< ::caffe::ReductionParameter*>( + ::caffe::ReductionParameter::internal_default_instance()); + relu_param_ = const_cast< ::caffe::ReLUParameter*>( + ::caffe::ReLUParameter::internal_default_instance()); + reshape_param_ = const_cast< ::caffe::ReshapeParameter*>( + ::caffe::ReshapeParameter::internal_default_instance()); + sigmoid_param_ = const_cast< ::caffe::SigmoidParameter*>( + ::caffe::SigmoidParameter::internal_default_instance()); + slice_param_ = const_cast< ::caffe::SliceParameter*>( + ::caffe::SliceParameter::internal_default_instance()); + softmax_param_ = const_cast< ::caffe::SoftmaxParameter*>( + ::caffe::SoftmaxParameter::internal_default_instance()); + spp_param_ = const_cast< ::caffe::SPPParameter*>( + ::caffe::SPPParameter::internal_default_instance()); + tanh_param_ = const_cast< ::caffe::TanHParameter*>( + ::caffe::TanHParameter::internal_default_instance()); + threshold_param_ = const_cast< ::caffe::ThresholdParameter*>( + ::caffe::ThresholdParameter::internal_default_instance()); + window_data_param_ = const_cast< ::caffe::WindowDataParameter*>( + ::caffe::WindowDataParameter::internal_default_instance()); +} + +LayerParameter::LayerParameter(const LayerParameter& from) + : ::google::protobuf::Message(), + _internal_metadata_(NULL) { + SharedCtor(); + UnsafeMergeFrom(from); + // @@protoc_insertion_point(copy_constructor:caffe.LayerParameter) +} + +void LayerParameter::SharedCtor() { + name_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + type_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + transform_param_ = NULL; + loss_param_ = NULL; + accuracy_param_ = NULL; + argmax_param_ = NULL; + concat_param_ = NULL; + contrastive_loss_param_ = NULL; + convolution_param_ = NULL; + crop_param_ = NULL; + data_param_ = NULL; + detection_output_param_ = NULL; + dropout_param_ = NULL; + dummy_data_param_ = NULL; + eltwise_param_ = NULL; + exp_param_ = NULL; + flatten_param_ = NULL; + hdf5_data_param_ = NULL; + hdf5_output_param_ = NULL; + hinge_loss_param_ = NULL; + image_data_param_ = NULL; + infogain_loss_param_ = NULL; + inner_product_param_ = NULL; + log_param_ = NULL; + lrn_param_ = NULL; + memory_data_param_ = NULL; + mvn_param_ = NULL; + normalize_bbox_param_ = NULL; + permute_param_ = NULL; + pooling_param_ = NULL; + power_param_ = NULL; + prelu_param_ = NULL; + prior_box_param_ = NULL; + python_param_ = NULL; + reduction_param_ = NULL; + relu_param_ = NULL; + reshape_param_ = NULL; + sigmoid_param_ = NULL; + slice_param_ = NULL; + softmax_param_ = NULL; + spp_param_ = NULL; + tanh_param_ = NULL; + threshold_param_ = NULL; + window_data_param_ = NULL; + phase_ = 0; + _cached_size_ = 0; +} + +LayerParameter::~LayerParameter() { + // @@protoc_insertion_point(destructor:caffe.LayerParameter) + SharedDtor(); +} + +void LayerParameter::SharedDtor() { + name_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + type_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + if (this != &LayerParameter_default_instance_.get()) { + delete transform_param_; + delete loss_param_; + delete accuracy_param_; + delete argmax_param_; + delete concat_param_; + delete contrastive_loss_param_; + delete convolution_param_; + delete crop_param_; + delete data_param_; + delete detection_output_param_; + delete dropout_param_; + delete dummy_data_param_; + delete eltwise_param_; + delete exp_param_; + delete flatten_param_; + delete hdf5_data_param_; + delete hdf5_output_param_; + delete hinge_loss_param_; + delete image_data_param_; + delete infogain_loss_param_; + delete inner_product_param_; + delete log_param_; + delete lrn_param_; + delete memory_data_param_; + delete mvn_param_; + delete normalize_bbox_param_; + delete permute_param_; + delete pooling_param_; + delete power_param_; + delete prelu_param_; + delete prior_box_param_; + delete python_param_; + delete reduction_param_; + delete relu_param_; + delete reshape_param_; + delete sigmoid_param_; + delete slice_param_; + delete softmax_param_; + delete spp_param_; + delete tanh_param_; + delete threshold_param_; + delete window_data_param_; + } +} + +void LayerParameter::SetCachedSize(int size) const { + GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); + _cached_size_ = size; + GOOGLE_SAFE_CONCURRENT_WRITES_END(); +} +const ::google::protobuf::Descriptor* LayerParameter::descriptor() { + protobuf_AssignDescriptorsOnce(); + return LayerParameter_descriptor_; +} + +const LayerParameter& LayerParameter::default_instance() { + protobuf_InitDefaults_caffe_2eproto(); + return *internal_default_instance(); +} + +::google::protobuf::internal::ExplicitlyConstructed LayerParameter_default_instance_; + +LayerParameter* LayerParameter::New(::google::protobuf::Arena* arena) const { + LayerParameter* n = new LayerParameter; + if (arena != NULL) { + arena->Own(n); + } + return n; +} + +void LayerParameter::Clear() { +// @@protoc_insertion_point(message_clear_start:caffe.LayerParameter) + if (_has_bits_[0 / 32] & 19u) { + if (has_name()) { + name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + } + if (has_type()) { + type_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + } + phase_ = 0; + } + if (_has_bits_[8 / 32] & 63488u) { + if (has_transform_param()) { + if (transform_param_ != NULL) transform_param_->::caffe::TransformationParameter::Clear(); + } + if (has_loss_param()) { + if (loss_param_ != NULL) loss_param_->::caffe::LossParameter::Clear(); + } + if (has_accuracy_param()) { + if (accuracy_param_ != NULL) accuracy_param_->::caffe::AccuracyParameter::Clear(); + } + if (has_argmax_param()) { + if (argmax_param_ != NULL) argmax_param_->::caffe::ArgMaxParameter::Clear(); + } + if (has_concat_param()) { + if (concat_param_ != NULL) concat_param_->::caffe::ConcatParameter::Clear(); + } + } + if (_has_bits_[16 / 32] & 16711680u) { + if (has_contrastive_loss_param()) { + if (contrastive_loss_param_ != NULL) contrastive_loss_param_->::caffe::ContrastiveLossParameter::Clear(); + } + if (has_convolution_param()) { + if (convolution_param_ != NULL) convolution_param_->::caffe::ConvolutionParameter::Clear(); + } + if (has_crop_param()) { + if (crop_param_ != NULL) crop_param_->::caffe::CropParameter::Clear(); + } + if (has_data_param()) { + if (data_param_ != NULL) data_param_->::caffe::DataParameter::Clear(); + } + if (has_detection_output_param()) { + if (detection_output_param_ != NULL) detection_output_param_->::caffe::DetectionOutputParameter::Clear(); + } + if (has_dropout_param()) { + if (dropout_param_ != NULL) dropout_param_->::caffe::DropoutParameter::Clear(); + } + if (has_dummy_data_param()) { + if (dummy_data_param_ != NULL) dummy_data_param_->::caffe::DummyDataParameter::Clear(); + } + if (has_eltwise_param()) { + if (eltwise_param_ != NULL) eltwise_param_->::caffe::EltwiseParameter::Clear(); + } + } + if (_has_bits_[24 / 32] & 4278190080u) { + if (has_exp_param()) { + if (exp_param_ != NULL) exp_param_->::caffe::ExpParameter::Clear(); + } + if (has_flatten_param()) { + if (flatten_param_ != NULL) flatten_param_->::caffe::FlattenParameter::Clear(); + } + if (has_hdf5_data_param()) { + if (hdf5_data_param_ != NULL) hdf5_data_param_->::caffe::HDF5DataParameter::Clear(); + } + if (has_hdf5_output_param()) { + if (hdf5_output_param_ != NULL) hdf5_output_param_->::caffe::HDF5OutputParameter::Clear(); + } + if (has_hinge_loss_param()) { + if (hinge_loss_param_ != NULL) hinge_loss_param_->::caffe::HingeLossParameter::Clear(); + } + if (has_image_data_param()) { + if (image_data_param_ != NULL) image_data_param_->::caffe::ImageDataParameter::Clear(); + } + if (has_infogain_loss_param()) { + if (infogain_loss_param_ != NULL) infogain_loss_param_->::caffe::InfogainLossParameter::Clear(); + } + if (has_inner_product_param()) { + if (inner_product_param_ != NULL) inner_product_param_->::caffe::InnerProductParameter::Clear(); + } + } + if (_has_bits_[32 / 32] & 255u) { + if (has_log_param()) { + if (log_param_ != NULL) log_param_->::caffe::LogParameter::Clear(); + } + if (has_lrn_param()) { + if (lrn_param_ != NULL) lrn_param_->::caffe::LRNParameter::Clear(); + } + if (has_memory_data_param()) { + if (memory_data_param_ != NULL) memory_data_param_->::caffe::MemoryDataParameter::Clear(); + } + if (has_mvn_param()) { + if (mvn_param_ != NULL) mvn_param_->::caffe::MVNParameter::Clear(); + } + if (has_normalize_bbox_param()) { + if (normalize_bbox_param_ != NULL) normalize_bbox_param_->::caffe::NormalizeBBoxParameter::Clear(); + } + if (has_permute_param()) { + if (permute_param_ != NULL) permute_param_->::caffe::PermuteParameter::Clear(); + } + if (has_pooling_param()) { + if (pooling_param_ != NULL) pooling_param_->::caffe::PoolingParameter::Clear(); + } + if (has_power_param()) { + if (power_param_ != NULL) power_param_->::caffe::PowerParameter::Clear(); + } + } + if (_has_bits_[40 / 32] & 65280u) { + if (has_prelu_param()) { + if (prelu_param_ != NULL) prelu_param_->::caffe::PReLUParameter::Clear(); + } + if (has_prior_box_param()) { + if (prior_box_param_ != NULL) prior_box_param_->::caffe::PriorBoxParameter::Clear(); + } + if (has_python_param()) { + if (python_param_ != NULL) python_param_->::caffe::PythonParameter::Clear(); + } + if (has_reduction_param()) { + if (reduction_param_ != NULL) reduction_param_->::caffe::ReductionParameter::Clear(); + } + if (has_relu_param()) { + if (relu_param_ != NULL) relu_param_->::caffe::ReLUParameter::Clear(); + } + if (has_reshape_param()) { + if (reshape_param_ != NULL) reshape_param_->::caffe::ReshapeParameter::Clear(); + } + if (has_sigmoid_param()) { + if (sigmoid_param_ != NULL) sigmoid_param_->::caffe::SigmoidParameter::Clear(); + } + if (has_slice_param()) { + if (slice_param_ != NULL) slice_param_->::caffe::SliceParameter::Clear(); + } + } + if (_has_bits_[48 / 32] & 2031616u) { + if (has_softmax_param()) { + if (softmax_param_ != NULL) softmax_param_->::caffe::SoftmaxParameter::Clear(); + } + if (has_spp_param()) { + if (spp_param_ != NULL) spp_param_->::caffe::SPPParameter::Clear(); + } + if (has_tanh_param()) { + if (tanh_param_ != NULL) tanh_param_->::caffe::TanHParameter::Clear(); + } + if (has_threshold_param()) { + if (threshold_param_ != NULL) threshold_param_->::caffe::ThresholdParameter::Clear(); + } + if (has_window_data_param()) { + if (window_data_param_ != NULL) window_data_param_->::caffe::WindowDataParameter::Clear(); + } + } + bottom_.Clear(); + top_.Clear(); + loss_weight_.Clear(); + param_.Clear(); + blobs_.Clear(); + propagate_down_.Clear(); + include_.Clear(); + exclude_.Clear(); + _has_bits_.Clear(); + if (_internal_metadata_.have_unknown_fields()) { + mutable_unknown_fields()->Clear(); + } +} + +bool LayerParameter::MergePartialFromCodedStream( + ::google::protobuf::io::CodedInputStream* input) { +#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure + ::google::protobuf::uint32 tag; + // @@protoc_insertion_point(parse_start:caffe.LayerParameter) + for (;;) { + ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(16383); + tag = p.first; + if (!p.second) goto handle_unusual; + switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { + // optional string name = 1; + case 1: { + if (tag == 10) { + DO_(::google::protobuf::internal::WireFormatLite::ReadString( + input, this->mutable_name())); + ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( + this->name().data(), this->name().length(), + ::google::protobuf::internal::WireFormat::PARSE, + "caffe.LayerParameter.name"); + } else { + goto handle_unusual; + } + if (input->ExpectTag(18)) goto parse_type; + break; + } + + // optional string type = 2; + case 2: { + if (tag == 18) { + parse_type: + DO_(::google::protobuf::internal::WireFormatLite::ReadString( + input, this->mutable_type())); + ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( + this->type().data(), this->type().length(), + ::google::protobuf::internal::WireFormat::PARSE, + "caffe.LayerParameter.type"); + } else { + goto handle_unusual; + } + if (input->ExpectTag(26)) goto parse_bottom; + break; + } + + // repeated string bottom = 3; + case 3: { + if (tag == 26) { + parse_bottom: + DO_(::google::protobuf::internal::WireFormatLite::ReadString( + input, this->add_bottom())); + ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( + this->bottom(this->bottom_size() - 1).data(), + this->bottom(this->bottom_size() - 1).length(), + ::google::protobuf::internal::WireFormat::PARSE, + "caffe.LayerParameter.bottom"); + } else { + goto handle_unusual; + } + if (input->ExpectTag(26)) goto parse_bottom; + if (input->ExpectTag(34)) goto parse_top; + break; + } + + // repeated string top = 4; + case 4: { + if (tag == 34) { parse_top: DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->add_top())); - ::google::protobuf::internal::WireFormat::VerifyUTF8String( + ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( this->top(this->top_size() - 1).data(), this->top(this->top_size() - 1).length(), - ::google::protobuf::internal::WireFormat::PARSE); + ::google::protobuf::internal::WireFormat::PARSE, + "caffe.LayerParameter.top"); } else { - goto handle_uninterpreted; + goto handle_unusual; } if (input->ExpectTag(34)) goto parse_top; if (input->ExpectTag(45)) goto parse_loss_weight; @@ -10124,20 +14349,17 @@ bool LayerParameter::MergePartialFromCodedStream( // repeated float loss_weight = 5; case 5: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_FIXED32) { + if (tag == 45) { parse_loss_weight: DO_((::google::protobuf::internal::WireFormatLite::ReadRepeatedPrimitive< float, ::google::protobuf::internal::WireFormatLite::TYPE_FLOAT>( 1, 45, input, this->mutable_loss_weight()))); - } else if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) - == ::google::protobuf::internal::WireFormatLite:: - WIRETYPE_LENGTH_DELIMITED) { + } else if (tag == 42) { DO_((::google::protobuf::internal::WireFormatLite::ReadPackedPrimitiveNoInline< float, ::google::protobuf::internal::WireFormatLite::TYPE_FLOAT>( input, this->mutable_loss_weight()))); } else { - goto handle_uninterpreted; + goto handle_unusual; } if (input->ExpectTag(45)) goto parse_loss_weight; if (input->ExpectTag(50)) goto parse_param; @@ -10146,68 +14368,72 @@ bool LayerParameter::MergePartialFromCodedStream( // repeated .caffe.ParamSpec param = 6; case 6: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) { + if (tag == 50) { parse_param: - DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual( + DO_(input->IncrementRecursionDepth()); + parse_loop_param: + DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtualNoRecursionDepth( input, add_param())); } else { - goto handle_uninterpreted; + goto handle_unusual; } - if (input->ExpectTag(50)) goto parse_param; - if (input->ExpectTag(58)) goto parse_blobs; + if (input->ExpectTag(50)) goto parse_loop_param; + if (input->ExpectTag(58)) goto parse_loop_blobs; + input->UnsafeDecrementRecursionDepth(); break; } // repeated .caffe.BlobProto blobs = 7; case 7: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) { - parse_blobs: - DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual( + if (tag == 58) { + DO_(input->IncrementRecursionDepth()); + parse_loop_blobs: + DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtualNoRecursionDepth( input, add_blobs())); } else { - goto handle_uninterpreted; + goto handle_unusual; } - if (input->ExpectTag(58)) goto parse_blobs; - if (input->ExpectTag(66)) goto parse_include; + if (input->ExpectTag(58)) goto parse_loop_blobs; + if (input->ExpectTag(66)) goto parse_loop_include; + input->UnsafeDecrementRecursionDepth(); break; } // repeated .caffe.NetStateRule include = 8; case 8: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) { - parse_include: - DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual( + if (tag == 66) { + DO_(input->IncrementRecursionDepth()); + parse_loop_include: + DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtualNoRecursionDepth( input, add_include())); } else { - goto handle_uninterpreted; + goto handle_unusual; } - if (input->ExpectTag(66)) goto parse_include; - if (input->ExpectTag(74)) goto parse_exclude; + if (input->ExpectTag(66)) goto parse_loop_include; + if (input->ExpectTag(74)) goto parse_loop_exclude; + input->UnsafeDecrementRecursionDepth(); break; } // repeated .caffe.NetStateRule exclude = 9; case 9: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) { - parse_exclude: - DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual( + if (tag == 74) { + DO_(input->IncrementRecursionDepth()); + parse_loop_exclude: + DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtualNoRecursionDepth( input, add_exclude())); } else { - goto handle_uninterpreted; + goto handle_unusual; } - if (input->ExpectTag(74)) goto parse_exclude; + if (input->ExpectTag(74)) goto parse_loop_exclude; + input->UnsafeDecrementRecursionDepth(); if (input->ExpectTag(80)) goto parse_phase; break; } // optional .caffe.Phase phase = 10; case 10: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) { + if (tag == 80) { parse_phase: int value; DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< @@ -10219,7 +14445,7 @@ bool LayerParameter::MergePartialFromCodedStream( mutable_unknown_fields()->AddVarint(10, value); } } else { - goto handle_uninterpreted; + goto handle_unusual; } if (input->ExpectTag(88)) goto parse_propagate_down; break; @@ -10227,20 +14453,17 @@ bool LayerParameter::MergePartialFromCodedStream( // repeated bool propagate_down = 11; case 11: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) { + if (tag == 88) { parse_propagate_down: DO_((::google::protobuf::internal::WireFormatLite::ReadRepeatedPrimitive< bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>( 1, 88, input, this->mutable_propagate_down()))); - } else if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) - == ::google::protobuf::internal::WireFormatLite:: - WIRETYPE_LENGTH_DELIMITED) { + } else if (tag == 90) { DO_((::google::protobuf::internal::WireFormatLite::ReadPackedPrimitiveNoInline< bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>( input, this->mutable_propagate_down()))); } else { - goto handle_uninterpreted; + goto handle_unusual; } if (input->ExpectTag(88)) goto parse_propagate_down; if (input->ExpectTag(802)) goto parse_transform_param; @@ -10249,13 +14472,12 @@ bool LayerParameter::MergePartialFromCodedStream( // optional .caffe.TransformationParameter transform_param = 100; case 100: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) { + if (tag == 802) { parse_transform_param: DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual( input, mutable_transform_param())); } else { - goto handle_uninterpreted; + goto handle_unusual; } if (input->ExpectTag(810)) goto parse_loss_param; break; @@ -10263,13 +14485,12 @@ bool LayerParameter::MergePartialFromCodedStream( // optional .caffe.LossParameter loss_param = 101; case 101: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) { + if (tag == 810) { parse_loss_param: DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual( input, mutable_loss_param())); } else { - goto handle_uninterpreted; + goto handle_unusual; } if (input->ExpectTag(818)) goto parse_accuracy_param; break; @@ -10277,13 +14498,12 @@ bool LayerParameter::MergePartialFromCodedStream( // optional .caffe.AccuracyParameter accuracy_param = 102; case 102: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) { + if (tag == 818) { parse_accuracy_param: DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual( input, mutable_accuracy_param())); } else { - goto handle_uninterpreted; + goto handle_unusual; } if (input->ExpectTag(826)) goto parse_argmax_param; break; @@ -10291,13 +14511,12 @@ bool LayerParameter::MergePartialFromCodedStream( // optional .caffe.ArgMaxParameter argmax_param = 103; case 103: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) { + if (tag == 826) { parse_argmax_param: DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual( input, mutable_argmax_param())); } else { - goto handle_uninterpreted; + goto handle_unusual; } if (input->ExpectTag(834)) goto parse_concat_param; break; @@ -10305,13 +14524,12 @@ bool LayerParameter::MergePartialFromCodedStream( // optional .caffe.ConcatParameter concat_param = 104; case 104: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) { + if (tag == 834) { parse_concat_param: DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual( input, mutable_concat_param())); } else { - goto handle_uninterpreted; + goto handle_unusual; } if (input->ExpectTag(842)) goto parse_contrastive_loss_param; break; @@ -10319,13 +14537,12 @@ bool LayerParameter::MergePartialFromCodedStream( // optional .caffe.ContrastiveLossParameter contrastive_loss_param = 105; case 105: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) { + if (tag == 842) { parse_contrastive_loss_param: DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual( input, mutable_contrastive_loss_param())); } else { - goto handle_uninterpreted; + goto handle_unusual; } if (input->ExpectTag(850)) goto parse_convolution_param; break; @@ -10333,13 +14550,12 @@ bool LayerParameter::MergePartialFromCodedStream( // optional .caffe.ConvolutionParameter convolution_param = 106; case 106: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) { + if (tag == 850) { parse_convolution_param: DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual( input, mutable_convolution_param())); } else { - goto handle_uninterpreted; + goto handle_unusual; } if (input->ExpectTag(858)) goto parse_data_param; break; @@ -10347,13 +14563,12 @@ bool LayerParameter::MergePartialFromCodedStream( // optional .caffe.DataParameter data_param = 107; case 107: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) { + if (tag == 858) { parse_data_param: DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual( input, mutable_data_param())); } else { - goto handle_uninterpreted; + goto handle_unusual; } if (input->ExpectTag(866)) goto parse_dropout_param; break; @@ -10361,13 +14576,12 @@ bool LayerParameter::MergePartialFromCodedStream( // optional .caffe.DropoutParameter dropout_param = 108; case 108: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) { + if (tag == 866) { parse_dropout_param: DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual( input, mutable_dropout_param())); } else { - goto handle_uninterpreted; + goto handle_unusual; } if (input->ExpectTag(874)) goto parse_dummy_data_param; break; @@ -10375,13 +14589,12 @@ bool LayerParameter::MergePartialFromCodedStream( // optional .caffe.DummyDataParameter dummy_data_param = 109; case 109: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) { + if (tag == 874) { parse_dummy_data_param: DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual( input, mutable_dummy_data_param())); } else { - goto handle_uninterpreted; + goto handle_unusual; } if (input->ExpectTag(882)) goto parse_eltwise_param; break; @@ -10389,13 +14602,12 @@ bool LayerParameter::MergePartialFromCodedStream( // optional .caffe.EltwiseParameter eltwise_param = 110; case 110: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) { + if (tag == 882) { parse_eltwise_param: DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual( input, mutable_eltwise_param())); } else { - goto handle_uninterpreted; + goto handle_unusual; } if (input->ExpectTag(890)) goto parse_exp_param; break; @@ -10403,13 +14615,12 @@ bool LayerParameter::MergePartialFromCodedStream( // optional .caffe.ExpParameter exp_param = 111; case 111: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) { + if (tag == 890) { parse_exp_param: DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual( input, mutable_exp_param())); } else { - goto handle_uninterpreted; + goto handle_unusual; } if (input->ExpectTag(898)) goto parse_hdf5_data_param; break; @@ -10417,13 +14628,12 @@ bool LayerParameter::MergePartialFromCodedStream( // optional .caffe.HDF5DataParameter hdf5_data_param = 112; case 112: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) { + if (tag == 898) { parse_hdf5_data_param: DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual( input, mutable_hdf5_data_param())); } else { - goto handle_uninterpreted; + goto handle_unusual; } if (input->ExpectTag(906)) goto parse_hdf5_output_param; break; @@ -10431,13 +14641,12 @@ bool LayerParameter::MergePartialFromCodedStream( // optional .caffe.HDF5OutputParameter hdf5_output_param = 113; case 113: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) { + if (tag == 906) { parse_hdf5_output_param: DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual( input, mutable_hdf5_output_param())); } else { - goto handle_uninterpreted; + goto handle_unusual; } if (input->ExpectTag(914)) goto parse_hinge_loss_param; break; @@ -10445,13 +14654,12 @@ bool LayerParameter::MergePartialFromCodedStream( // optional .caffe.HingeLossParameter hinge_loss_param = 114; case 114: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) { + if (tag == 914) { parse_hinge_loss_param: DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual( input, mutable_hinge_loss_param())); } else { - goto handle_uninterpreted; + goto handle_unusual; } if (input->ExpectTag(922)) goto parse_image_data_param; break; @@ -10459,13 +14667,12 @@ bool LayerParameter::MergePartialFromCodedStream( // optional .caffe.ImageDataParameter image_data_param = 115; case 115: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) { + if (tag == 922) { parse_image_data_param: DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual( input, mutable_image_data_param())); } else { - goto handle_uninterpreted; + goto handle_unusual; } if (input->ExpectTag(930)) goto parse_infogain_loss_param; break; @@ -10473,13 +14680,12 @@ bool LayerParameter::MergePartialFromCodedStream( // optional .caffe.InfogainLossParameter infogain_loss_param = 116; case 116: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) { + if (tag == 930) { parse_infogain_loss_param: DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual( input, mutable_infogain_loss_param())); } else { - goto handle_uninterpreted; + goto handle_unusual; } if (input->ExpectTag(938)) goto parse_inner_product_param; break; @@ -10487,13 +14693,12 @@ bool LayerParameter::MergePartialFromCodedStream( // optional .caffe.InnerProductParameter inner_product_param = 117; case 117: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) { + if (tag == 938) { parse_inner_product_param: DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual( input, mutable_inner_product_param())); } else { - goto handle_uninterpreted; + goto handle_unusual; } if (input->ExpectTag(946)) goto parse_lrn_param; break; @@ -10501,13 +14706,12 @@ bool LayerParameter::MergePartialFromCodedStream( // optional .caffe.LRNParameter lrn_param = 118; case 118: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) { + if (tag == 946) { parse_lrn_param: DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual( input, mutable_lrn_param())); } else { - goto handle_uninterpreted; + goto handle_unusual; } if (input->ExpectTag(954)) goto parse_memory_data_param; break; @@ -10515,13 +14719,12 @@ bool LayerParameter::MergePartialFromCodedStream( // optional .caffe.MemoryDataParameter memory_data_param = 119; case 119: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) { + if (tag == 954) { parse_memory_data_param: DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual( input, mutable_memory_data_param())); } else { - goto handle_uninterpreted; + goto handle_unusual; } if (input->ExpectTag(962)) goto parse_mvn_param; break; @@ -10529,13 +14732,12 @@ bool LayerParameter::MergePartialFromCodedStream( // optional .caffe.MVNParameter mvn_param = 120; case 120: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) { + if (tag == 962) { parse_mvn_param: DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual( input, mutable_mvn_param())); } else { - goto handle_uninterpreted; + goto handle_unusual; } if (input->ExpectTag(970)) goto parse_pooling_param; break; @@ -10543,13 +14745,12 @@ bool LayerParameter::MergePartialFromCodedStream( // optional .caffe.PoolingParameter pooling_param = 121; case 121: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) { + if (tag == 970) { parse_pooling_param: DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual( input, mutable_pooling_param())); } else { - goto handle_uninterpreted; + goto handle_unusual; } if (input->ExpectTag(978)) goto parse_power_param; break; @@ -10557,13 +14758,12 @@ bool LayerParameter::MergePartialFromCodedStream( // optional .caffe.PowerParameter power_param = 122; case 122: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) { + if (tag == 978) { parse_power_param: DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual( input, mutable_power_param())); } else { - goto handle_uninterpreted; + goto handle_unusual; } if (input->ExpectTag(986)) goto parse_relu_param; break; @@ -10571,13 +14771,12 @@ bool LayerParameter::MergePartialFromCodedStream( // optional .caffe.ReLUParameter relu_param = 123; case 123: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) { + if (tag == 986) { parse_relu_param: DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual( input, mutable_relu_param())); } else { - goto handle_uninterpreted; + goto handle_unusual; } if (input->ExpectTag(994)) goto parse_sigmoid_param; break; @@ -10585,13 +14784,12 @@ bool LayerParameter::MergePartialFromCodedStream( // optional .caffe.SigmoidParameter sigmoid_param = 124; case 124: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) { + if (tag == 994) { parse_sigmoid_param: DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual( input, mutable_sigmoid_param())); } else { - goto handle_uninterpreted; + goto handle_unusual; } if (input->ExpectTag(1002)) goto parse_softmax_param; break; @@ -10599,13 +14797,12 @@ bool LayerParameter::MergePartialFromCodedStream( // optional .caffe.SoftmaxParameter softmax_param = 125; case 125: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) { + if (tag == 1002) { parse_softmax_param: DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual( input, mutable_softmax_param())); } else { - goto handle_uninterpreted; + goto handle_unusual; } if (input->ExpectTag(1010)) goto parse_slice_param; break; @@ -10613,13 +14810,12 @@ bool LayerParameter::MergePartialFromCodedStream( // optional .caffe.SliceParameter slice_param = 126; case 126: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) { + if (tag == 1010) { parse_slice_param: DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual( input, mutable_slice_param())); } else { - goto handle_uninterpreted; + goto handle_unusual; } if (input->ExpectTag(1018)) goto parse_tanh_param; break; @@ -10627,13 +14823,12 @@ bool LayerParameter::MergePartialFromCodedStream( // optional .caffe.TanHParameter tanh_param = 127; case 127: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) { + if (tag == 1018) { parse_tanh_param: DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual( input, mutable_tanh_param())); } else { - goto handle_uninterpreted; + goto handle_unusual; } if (input->ExpectTag(1026)) goto parse_threshold_param; break; @@ -10641,13 +14836,12 @@ bool LayerParameter::MergePartialFromCodedStream( // optional .caffe.ThresholdParameter threshold_param = 128; case 128: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) { + if (tag == 1026) { parse_threshold_param: DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual( input, mutable_threshold_param())); } else { - goto handle_uninterpreted; + goto handle_unusual; } if (input->ExpectTag(1034)) goto parse_window_data_param; break; @@ -10655,13 +14849,12 @@ bool LayerParameter::MergePartialFromCodedStream( // optional .caffe.WindowDataParameter window_data_param = 129; case 129: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) { + if (tag == 1034) { parse_window_data_param: DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual( input, mutable_window_data_param())); } else { - goto handle_uninterpreted; + goto handle_unusual; } if (input->ExpectTag(1042)) goto parse_python_param; break; @@ -10669,13 +14862,12 @@ bool LayerParameter::MergePartialFromCodedStream( // optional .caffe.PythonParameter python_param = 130; case 130: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) { + if (tag == 1042) { parse_python_param: DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual( input, mutable_python_param())); } else { - goto handle_uninterpreted; + goto handle_unusual; } if (input->ExpectTag(1050)) goto parse_prelu_param; break; @@ -10683,13 +14875,12 @@ bool LayerParameter::MergePartialFromCodedStream( // optional .caffe.PReLUParameter prelu_param = 131; case 131: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) { + if (tag == 1050) { parse_prelu_param: DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual( input, mutable_prelu_param())); } else { - goto handle_uninterpreted; + goto handle_unusual; } if (input->ExpectTag(1058)) goto parse_spp_param; break; @@ -10697,13 +14888,12 @@ bool LayerParameter::MergePartialFromCodedStream( // optional .caffe.SPPParameter spp_param = 132; case 132: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) { + if (tag == 1058) { parse_spp_param: DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual( input, mutable_spp_param())); } else { - goto handle_uninterpreted; + goto handle_unusual; } if (input->ExpectTag(1066)) goto parse_reshape_param; break; @@ -10711,13 +14901,12 @@ bool LayerParameter::MergePartialFromCodedStream( // optional .caffe.ReshapeParameter reshape_param = 133; case 133: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) { + if (tag == 1066) { parse_reshape_param: DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual( input, mutable_reshape_param())); } else { - goto handle_uninterpreted; + goto handle_unusual; } if (input->ExpectTag(1074)) goto parse_log_param; break; @@ -10725,13 +14914,12 @@ bool LayerParameter::MergePartialFromCodedStream( // optional .caffe.LogParameter log_param = 134; case 134: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) { + if (tag == 1074) { parse_log_param: DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual( input, mutable_log_param())); } else { - goto handle_uninterpreted; + goto handle_unusual; } if (input->ExpectTag(1082)) goto parse_flatten_param; break; @@ -10739,13 +14927,12 @@ bool LayerParameter::MergePartialFromCodedStream( // optional .caffe.FlattenParameter flatten_param = 135; case 135: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) { + if (tag == 1082) { parse_flatten_param: DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual( input, mutable_flatten_param())); } else { - goto handle_uninterpreted; + goto handle_unusual; } if (input->ExpectTag(1090)) goto parse_reduction_param; break; @@ -10753,13 +14940,12 @@ bool LayerParameter::MergePartialFromCodedStream( // optional .caffe.ReductionParameter reduction_param = 136; case 136: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) { + if (tag == 1090) { parse_reduction_param: DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual( input, mutable_reduction_param())); } else { - goto handle_uninterpreted; + goto handle_unusual; } if (input->ExpectTag(1098)) goto parse_crop_param; break; @@ -10767,13 +14953,12 @@ bool LayerParameter::MergePartialFromCodedStream( // optional .caffe.CropParameter crop_param = 137; case 137: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) { + if (tag == 1098) { parse_crop_param: DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual( input, mutable_crop_param())); } else { - goto handle_uninterpreted; + goto handle_unusual; } if (input->ExpectTag(1106)) goto parse_permute_param; break; @@ -10781,13 +14966,12 @@ bool LayerParameter::MergePartialFromCodedStream( // optional .caffe.PermuteParameter permute_param = 138; case 138: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) { + if (tag == 1106) { parse_permute_param: DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual( input, mutable_permute_param())); } else { - goto handle_uninterpreted; + goto handle_unusual; } if (input->ExpectTag(1114)) goto parse_normalize_bbox_param; break; @@ -10795,13 +14979,12 @@ bool LayerParameter::MergePartialFromCodedStream( // optional .caffe.NormalizeBBoxParameter normalize_bbox_param = 139; case 139: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) { + if (tag == 1114) { parse_normalize_bbox_param: DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual( input, mutable_normalize_bbox_param())); } else { - goto handle_uninterpreted; + goto handle_unusual; } if (input->ExpectTag(1122)) goto parse_prior_box_param; break; @@ -10809,13 +14992,12 @@ bool LayerParameter::MergePartialFromCodedStream( // optional .caffe.PriorBoxParameter prior_box_param = 140; case 140: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) { + if (tag == 1122) { parse_prior_box_param: DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual( input, mutable_prior_box_param())); } else { - goto handle_uninterpreted; + goto handle_unusual; } if (input->ExpectTag(1130)) goto parse_detection_output_param; break; @@ -10823,23 +15005,23 @@ bool LayerParameter::MergePartialFromCodedStream( // optional .caffe.DetectionOutputParameter detection_output_param = 141; case 141: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) { + if (tag == 1130) { parse_detection_output_param: DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual( input, mutable_detection_output_param())); } else { - goto handle_uninterpreted; + goto handle_unusual; } - if (input->ExpectAtEnd()) return true; + if (input->ExpectAtEnd()) goto success; break; } default: { - handle_uninterpreted: - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == + handle_unusual: + if (tag == 0 || + ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) { - return true; + goto success; } DO_(::google::protobuf::internal::WireFormat::SkipField( input, tag, mutable_unknown_fields())); @@ -10847,44 +15029,54 @@ bool LayerParameter::MergePartialFromCodedStream( } } } +success: + // @@protoc_insertion_point(parse_success:caffe.LayerParameter) return true; +failure: + // @@protoc_insertion_point(parse_failure:caffe.LayerParameter) + return false; #undef DO_ } void LayerParameter::SerializeWithCachedSizes( ::google::protobuf::io::CodedOutputStream* output) const { + // @@protoc_insertion_point(serialize_start:caffe.LayerParameter) // optional string name = 1; if (has_name()) { - ::google::protobuf::internal::WireFormat::VerifyUTF8String( + ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( this->name().data(), this->name().length(), - ::google::protobuf::internal::WireFormat::SERIALIZE); - ::google::protobuf::internal::WireFormatLite::WriteString( + ::google::protobuf::internal::WireFormat::SERIALIZE, + "caffe.LayerParameter.name"); + ::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased( 1, this->name(), output); } // optional string type = 2; if (has_type()) { - ::google::protobuf::internal::WireFormat::VerifyUTF8String( + ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( this->type().data(), this->type().length(), - ::google::protobuf::internal::WireFormat::SERIALIZE); - ::google::protobuf::internal::WireFormatLite::WriteString( + ::google::protobuf::internal::WireFormat::SERIALIZE, + "caffe.LayerParameter.type"); + ::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased( 2, this->type(), output); } // repeated string bottom = 3; for (int i = 0; i < this->bottom_size(); i++) { - ::google::protobuf::internal::WireFormat::VerifyUTF8String( - this->bottom(i).data(), this->bottom(i).length(), - ::google::protobuf::internal::WireFormat::SERIALIZE); + ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( + this->bottom(i).data(), this->bottom(i).length(), + ::google::protobuf::internal::WireFormat::SERIALIZE, + "caffe.LayerParameter.bottom"); ::google::protobuf::internal::WireFormatLite::WriteString( 3, this->bottom(i), output); } // repeated string top = 4; for (int i = 0; i < this->top_size(); i++) { - ::google::protobuf::internal::WireFormat::VerifyUTF8String( - this->top(i).data(), this->top(i).length(), - ::google::protobuf::internal::WireFormat::SERIALIZE); + ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( + this->top(i).data(), this->top(i).length(), + ::google::protobuf::internal::WireFormat::SERIALIZE, + "caffe.LayerParameter.top"); ::google::protobuf::internal::WireFormatLite::WriteString( 4, this->top(i), output); } @@ -10896,25 +15088,25 @@ void LayerParameter::SerializeWithCachedSizes( } // repeated .caffe.ParamSpec param = 6; - for (int i = 0; i < this->param_size(); i++) { + for (unsigned int i = 0, n = this->param_size(); i < n; i++) { ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( 6, this->param(i), output); } // repeated .caffe.BlobProto blobs = 7; - for (int i = 0; i < this->blobs_size(); i++) { + for (unsigned int i = 0, n = this->blobs_size(); i < n; i++) { ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( 7, this->blobs(i), output); } // repeated .caffe.NetStateRule include = 8; - for (int i = 0; i < this->include_size(); i++) { + for (unsigned int i = 0, n = this->include_size(); i < n; i++) { ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( 8, this->include(i), output); } // repeated .caffe.NetStateRule exclude = 9; - for (int i = 0; i < this->exclude_size(); i++) { + for (unsigned int i = 0, n = this->exclude_size(); i < n; i++) { ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( 9, this->exclude(i), output); } @@ -10934,268 +15126,272 @@ void LayerParameter::SerializeWithCachedSizes( // optional .caffe.TransformationParameter transform_param = 100; if (has_transform_param()) { ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( - 100, this->transform_param(), output); + 100, *this->transform_param_, output); } // optional .caffe.LossParameter loss_param = 101; if (has_loss_param()) { ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( - 101, this->loss_param(), output); + 101, *this->loss_param_, output); } // optional .caffe.AccuracyParameter accuracy_param = 102; if (has_accuracy_param()) { ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( - 102, this->accuracy_param(), output); + 102, *this->accuracy_param_, output); } // optional .caffe.ArgMaxParameter argmax_param = 103; if (has_argmax_param()) { ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( - 103, this->argmax_param(), output); + 103, *this->argmax_param_, output); } // optional .caffe.ConcatParameter concat_param = 104; if (has_concat_param()) { ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( - 104, this->concat_param(), output); + 104, *this->concat_param_, output); } // optional .caffe.ContrastiveLossParameter contrastive_loss_param = 105; if (has_contrastive_loss_param()) { ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( - 105, this->contrastive_loss_param(), output); + 105, *this->contrastive_loss_param_, output); } // optional .caffe.ConvolutionParameter convolution_param = 106; if (has_convolution_param()) { ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( - 106, this->convolution_param(), output); + 106, *this->convolution_param_, output); } // optional .caffe.DataParameter data_param = 107; if (has_data_param()) { ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( - 107, this->data_param(), output); + 107, *this->data_param_, output); } // optional .caffe.DropoutParameter dropout_param = 108; if (has_dropout_param()) { ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( - 108, this->dropout_param(), output); + 108, *this->dropout_param_, output); } // optional .caffe.DummyDataParameter dummy_data_param = 109; if (has_dummy_data_param()) { ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( - 109, this->dummy_data_param(), output); + 109, *this->dummy_data_param_, output); } // optional .caffe.EltwiseParameter eltwise_param = 110; if (has_eltwise_param()) { ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( - 110, this->eltwise_param(), output); + 110, *this->eltwise_param_, output); } // optional .caffe.ExpParameter exp_param = 111; if (has_exp_param()) { ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( - 111, this->exp_param(), output); + 111, *this->exp_param_, output); } // optional .caffe.HDF5DataParameter hdf5_data_param = 112; if (has_hdf5_data_param()) { ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( - 112, this->hdf5_data_param(), output); + 112, *this->hdf5_data_param_, output); } // optional .caffe.HDF5OutputParameter hdf5_output_param = 113; if (has_hdf5_output_param()) { ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( - 113, this->hdf5_output_param(), output); + 113, *this->hdf5_output_param_, output); } // optional .caffe.HingeLossParameter hinge_loss_param = 114; if (has_hinge_loss_param()) { ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( - 114, this->hinge_loss_param(), output); + 114, *this->hinge_loss_param_, output); } // optional .caffe.ImageDataParameter image_data_param = 115; if (has_image_data_param()) { ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( - 115, this->image_data_param(), output); + 115, *this->image_data_param_, output); } // optional .caffe.InfogainLossParameter infogain_loss_param = 116; if (has_infogain_loss_param()) { ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( - 116, this->infogain_loss_param(), output); + 116, *this->infogain_loss_param_, output); } // optional .caffe.InnerProductParameter inner_product_param = 117; if (has_inner_product_param()) { ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( - 117, this->inner_product_param(), output); + 117, *this->inner_product_param_, output); } // optional .caffe.LRNParameter lrn_param = 118; if (has_lrn_param()) { ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( - 118, this->lrn_param(), output); + 118, *this->lrn_param_, output); } // optional .caffe.MemoryDataParameter memory_data_param = 119; if (has_memory_data_param()) { ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( - 119, this->memory_data_param(), output); + 119, *this->memory_data_param_, output); } // optional .caffe.MVNParameter mvn_param = 120; if (has_mvn_param()) { ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( - 120, this->mvn_param(), output); + 120, *this->mvn_param_, output); } // optional .caffe.PoolingParameter pooling_param = 121; if (has_pooling_param()) { ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( - 121, this->pooling_param(), output); + 121, *this->pooling_param_, output); } // optional .caffe.PowerParameter power_param = 122; if (has_power_param()) { ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( - 122, this->power_param(), output); + 122, *this->power_param_, output); } // optional .caffe.ReLUParameter relu_param = 123; if (has_relu_param()) { ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( - 123, this->relu_param(), output); + 123, *this->relu_param_, output); } // optional .caffe.SigmoidParameter sigmoid_param = 124; if (has_sigmoid_param()) { ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( - 124, this->sigmoid_param(), output); + 124, *this->sigmoid_param_, output); } // optional .caffe.SoftmaxParameter softmax_param = 125; if (has_softmax_param()) { ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( - 125, this->softmax_param(), output); + 125, *this->softmax_param_, output); } // optional .caffe.SliceParameter slice_param = 126; if (has_slice_param()) { ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( - 126, this->slice_param(), output); + 126, *this->slice_param_, output); } // optional .caffe.TanHParameter tanh_param = 127; if (has_tanh_param()) { ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( - 127, this->tanh_param(), output); + 127, *this->tanh_param_, output); } // optional .caffe.ThresholdParameter threshold_param = 128; if (has_threshold_param()) { ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( - 128, this->threshold_param(), output); + 128, *this->threshold_param_, output); } // optional .caffe.WindowDataParameter window_data_param = 129; if (has_window_data_param()) { ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( - 129, this->window_data_param(), output); + 129, *this->window_data_param_, output); } // optional .caffe.PythonParameter python_param = 130; if (has_python_param()) { ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( - 130, this->python_param(), output); + 130, *this->python_param_, output); } // optional .caffe.PReLUParameter prelu_param = 131; if (has_prelu_param()) { ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( - 131, this->prelu_param(), output); + 131, *this->prelu_param_, output); } // optional .caffe.SPPParameter spp_param = 132; if (has_spp_param()) { ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( - 132, this->spp_param(), output); + 132, *this->spp_param_, output); } // optional .caffe.ReshapeParameter reshape_param = 133; if (has_reshape_param()) { ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( - 133, this->reshape_param(), output); + 133, *this->reshape_param_, output); } // optional .caffe.LogParameter log_param = 134; if (has_log_param()) { ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( - 134, this->log_param(), output); + 134, *this->log_param_, output); } // optional .caffe.FlattenParameter flatten_param = 135; if (has_flatten_param()) { ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( - 135, this->flatten_param(), output); + 135, *this->flatten_param_, output); } // optional .caffe.ReductionParameter reduction_param = 136; if (has_reduction_param()) { ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( - 136, this->reduction_param(), output); + 136, *this->reduction_param_, output); } // optional .caffe.CropParameter crop_param = 137; if (has_crop_param()) { ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( - 137, this->crop_param(), output); + 137, *this->crop_param_, output); } // optional .caffe.PermuteParameter permute_param = 138; if (has_permute_param()) { ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( - 138, this->permute_param(), output); + 138, *this->permute_param_, output); } // optional .caffe.NormalizeBBoxParameter normalize_bbox_param = 139; if (has_normalize_bbox_param()) { ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( - 139, this->normalize_bbox_param(), output); + 139, *this->normalize_bbox_param_, output); } // optional .caffe.PriorBoxParameter prior_box_param = 140; if (has_prior_box_param()) { ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( - 140, this->prior_box_param(), output); + 140, *this->prior_box_param_, output); } // optional .caffe.DetectionOutputParameter detection_output_param = 141; if (has_detection_output_param()) { ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( - 141, this->detection_output_param(), output); + 141, *this->detection_output_param_, output); } - if (!unknown_fields().empty()) { + if (_internal_metadata_.have_unknown_fields()) { ::google::protobuf::internal::WireFormat::SerializeUnknownFields( unknown_fields(), output); } + // @@protoc_insertion_point(serialize_end:caffe.LayerParameter) } -::google::protobuf::uint8* LayerParameter::SerializeWithCachedSizesToArray( - ::google::protobuf::uint8* target) const { +::google::protobuf::uint8* LayerParameter::InternalSerializeWithCachedSizesToArray( + bool deterministic, ::google::protobuf::uint8* target) const { + (void)deterministic; // Unused + // @@protoc_insertion_point(serialize_to_array_start:caffe.LayerParameter) // optional string name = 1; if (has_name()) { - ::google::protobuf::internal::WireFormat::VerifyUTF8String( + ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( this->name().data(), this->name().length(), - ::google::protobuf::internal::WireFormat::SERIALIZE); + ::google::protobuf::internal::WireFormat::SERIALIZE, + "caffe.LayerParameter.name"); target = ::google::protobuf::internal::WireFormatLite::WriteStringToArray( 1, this->name(), target); @@ -11203,9 +15399,10 @@ void LayerParameter::SerializeWithCachedSizes( // optional string type = 2; if (has_type()) { - ::google::protobuf::internal::WireFormat::VerifyUTF8String( + ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( this->type().data(), this->type().length(), - ::google::protobuf::internal::WireFormat::SERIALIZE); + ::google::protobuf::internal::WireFormat::SERIALIZE, + "caffe.LayerParameter.type"); target = ::google::protobuf::internal::WireFormatLite::WriteStringToArray( 2, this->type(), target); @@ -11213,18 +15410,20 @@ void LayerParameter::SerializeWithCachedSizes( // repeated string bottom = 3; for (int i = 0; i < this->bottom_size(); i++) { - ::google::protobuf::internal::WireFormat::VerifyUTF8String( + ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( this->bottom(i).data(), this->bottom(i).length(), - ::google::protobuf::internal::WireFormat::SERIALIZE); + ::google::protobuf::internal::WireFormat::SERIALIZE, + "caffe.LayerParameter.bottom"); target = ::google::protobuf::internal::WireFormatLite:: WriteStringToArray(3, this->bottom(i), target); } // repeated string top = 4; for (int i = 0; i < this->top_size(); i++) { - ::google::protobuf::internal::WireFormat::VerifyUTF8String( + ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( this->top(i).data(), this->top(i).length(), - ::google::protobuf::internal::WireFormat::SERIALIZE); + ::google::protobuf::internal::WireFormat::SERIALIZE, + "caffe.LayerParameter.top"); target = ::google::protobuf::internal::WireFormatLite:: WriteStringToArray(4, this->top(i), target); } @@ -11236,31 +15435,31 @@ void LayerParameter::SerializeWithCachedSizes( } // repeated .caffe.ParamSpec param = 6; - for (int i = 0; i < this->param_size(); i++) { + for (unsigned int i = 0, n = this->param_size(); i < n; i++) { target = ::google::protobuf::internal::WireFormatLite:: - WriteMessageNoVirtualToArray( - 6, this->param(i), target); + InternalWriteMessageNoVirtualToArray( + 6, this->param(i), false, target); } // repeated .caffe.BlobProto blobs = 7; - for (int i = 0; i < this->blobs_size(); i++) { + for (unsigned int i = 0, n = this->blobs_size(); i < n; i++) { target = ::google::protobuf::internal::WireFormatLite:: - WriteMessageNoVirtualToArray( - 7, this->blobs(i), target); + InternalWriteMessageNoVirtualToArray( + 7, this->blobs(i), false, target); } // repeated .caffe.NetStateRule include = 8; - for (int i = 0; i < this->include_size(); i++) { + for (unsigned int i = 0, n = this->include_size(); i < n; i++) { target = ::google::protobuf::internal::WireFormatLite:: - WriteMessageNoVirtualToArray( - 8, this->include(i), target); + InternalWriteMessageNoVirtualToArray( + 8, this->include(i), false, target); } // repeated .caffe.NetStateRule exclude = 9; - for (int i = 0; i < this->exclude_size(); i++) { + for (unsigned int i = 0, n = this->exclude_size(); i < n; i++) { target = ::google::protobuf::internal::WireFormatLite:: - WriteMessageNoVirtualToArray( - 9, this->exclude(i), target); + InternalWriteMessageNoVirtualToArray( + 9, this->exclude(i), false, target); } // optional .caffe.Phase phase = 10; @@ -11278,308 +15477,310 @@ void LayerParameter::SerializeWithCachedSizes( // optional .caffe.TransformationParameter transform_param = 100; if (has_transform_param()) { target = ::google::protobuf::internal::WireFormatLite:: - WriteMessageNoVirtualToArray( - 100, this->transform_param(), target); + InternalWriteMessageNoVirtualToArray( + 100, *this->transform_param_, false, target); } // optional .caffe.LossParameter loss_param = 101; if (has_loss_param()) { target = ::google::protobuf::internal::WireFormatLite:: - WriteMessageNoVirtualToArray( - 101, this->loss_param(), target); + InternalWriteMessageNoVirtualToArray( + 101, *this->loss_param_, false, target); } // optional .caffe.AccuracyParameter accuracy_param = 102; if (has_accuracy_param()) { target = ::google::protobuf::internal::WireFormatLite:: - WriteMessageNoVirtualToArray( - 102, this->accuracy_param(), target); + InternalWriteMessageNoVirtualToArray( + 102, *this->accuracy_param_, false, target); } // optional .caffe.ArgMaxParameter argmax_param = 103; if (has_argmax_param()) { target = ::google::protobuf::internal::WireFormatLite:: - WriteMessageNoVirtualToArray( - 103, this->argmax_param(), target); + InternalWriteMessageNoVirtualToArray( + 103, *this->argmax_param_, false, target); } // optional .caffe.ConcatParameter concat_param = 104; if (has_concat_param()) { target = ::google::protobuf::internal::WireFormatLite:: - WriteMessageNoVirtualToArray( - 104, this->concat_param(), target); + InternalWriteMessageNoVirtualToArray( + 104, *this->concat_param_, false, target); } // optional .caffe.ContrastiveLossParameter contrastive_loss_param = 105; if (has_contrastive_loss_param()) { target = ::google::protobuf::internal::WireFormatLite:: - WriteMessageNoVirtualToArray( - 105, this->contrastive_loss_param(), target); + InternalWriteMessageNoVirtualToArray( + 105, *this->contrastive_loss_param_, false, target); } // optional .caffe.ConvolutionParameter convolution_param = 106; if (has_convolution_param()) { target = ::google::protobuf::internal::WireFormatLite:: - WriteMessageNoVirtualToArray( - 106, this->convolution_param(), target); + InternalWriteMessageNoVirtualToArray( + 106, *this->convolution_param_, false, target); } // optional .caffe.DataParameter data_param = 107; if (has_data_param()) { target = ::google::protobuf::internal::WireFormatLite:: - WriteMessageNoVirtualToArray( - 107, this->data_param(), target); + InternalWriteMessageNoVirtualToArray( + 107, *this->data_param_, false, target); } // optional .caffe.DropoutParameter dropout_param = 108; if (has_dropout_param()) { target = ::google::protobuf::internal::WireFormatLite:: - WriteMessageNoVirtualToArray( - 108, this->dropout_param(), target); + InternalWriteMessageNoVirtualToArray( + 108, *this->dropout_param_, false, target); } // optional .caffe.DummyDataParameter dummy_data_param = 109; if (has_dummy_data_param()) { target = ::google::protobuf::internal::WireFormatLite:: - WriteMessageNoVirtualToArray( - 109, this->dummy_data_param(), target); + InternalWriteMessageNoVirtualToArray( + 109, *this->dummy_data_param_, false, target); } // optional .caffe.EltwiseParameter eltwise_param = 110; if (has_eltwise_param()) { target = ::google::protobuf::internal::WireFormatLite:: - WriteMessageNoVirtualToArray( - 110, this->eltwise_param(), target); + InternalWriteMessageNoVirtualToArray( + 110, *this->eltwise_param_, false, target); } // optional .caffe.ExpParameter exp_param = 111; if (has_exp_param()) { target = ::google::protobuf::internal::WireFormatLite:: - WriteMessageNoVirtualToArray( - 111, this->exp_param(), target); + InternalWriteMessageNoVirtualToArray( + 111, *this->exp_param_, false, target); } // optional .caffe.HDF5DataParameter hdf5_data_param = 112; if (has_hdf5_data_param()) { target = ::google::protobuf::internal::WireFormatLite:: - WriteMessageNoVirtualToArray( - 112, this->hdf5_data_param(), target); + InternalWriteMessageNoVirtualToArray( + 112, *this->hdf5_data_param_, false, target); } // optional .caffe.HDF5OutputParameter hdf5_output_param = 113; if (has_hdf5_output_param()) { target = ::google::protobuf::internal::WireFormatLite:: - WriteMessageNoVirtualToArray( - 113, this->hdf5_output_param(), target); + InternalWriteMessageNoVirtualToArray( + 113, *this->hdf5_output_param_, false, target); } // optional .caffe.HingeLossParameter hinge_loss_param = 114; if (has_hinge_loss_param()) { target = ::google::protobuf::internal::WireFormatLite:: - WriteMessageNoVirtualToArray( - 114, this->hinge_loss_param(), target); + InternalWriteMessageNoVirtualToArray( + 114, *this->hinge_loss_param_, false, target); } // optional .caffe.ImageDataParameter image_data_param = 115; if (has_image_data_param()) { target = ::google::protobuf::internal::WireFormatLite:: - WriteMessageNoVirtualToArray( - 115, this->image_data_param(), target); + InternalWriteMessageNoVirtualToArray( + 115, *this->image_data_param_, false, target); } // optional .caffe.InfogainLossParameter infogain_loss_param = 116; if (has_infogain_loss_param()) { target = ::google::protobuf::internal::WireFormatLite:: - WriteMessageNoVirtualToArray( - 116, this->infogain_loss_param(), target); + InternalWriteMessageNoVirtualToArray( + 116, *this->infogain_loss_param_, false, target); } // optional .caffe.InnerProductParameter inner_product_param = 117; if (has_inner_product_param()) { target = ::google::protobuf::internal::WireFormatLite:: - WriteMessageNoVirtualToArray( - 117, this->inner_product_param(), target); + InternalWriteMessageNoVirtualToArray( + 117, *this->inner_product_param_, false, target); } // optional .caffe.LRNParameter lrn_param = 118; if (has_lrn_param()) { target = ::google::protobuf::internal::WireFormatLite:: - WriteMessageNoVirtualToArray( - 118, this->lrn_param(), target); + InternalWriteMessageNoVirtualToArray( + 118, *this->lrn_param_, false, target); } // optional .caffe.MemoryDataParameter memory_data_param = 119; if (has_memory_data_param()) { target = ::google::protobuf::internal::WireFormatLite:: - WriteMessageNoVirtualToArray( - 119, this->memory_data_param(), target); + InternalWriteMessageNoVirtualToArray( + 119, *this->memory_data_param_, false, target); } // optional .caffe.MVNParameter mvn_param = 120; if (has_mvn_param()) { target = ::google::protobuf::internal::WireFormatLite:: - WriteMessageNoVirtualToArray( - 120, this->mvn_param(), target); + InternalWriteMessageNoVirtualToArray( + 120, *this->mvn_param_, false, target); } // optional .caffe.PoolingParameter pooling_param = 121; if (has_pooling_param()) { target = ::google::protobuf::internal::WireFormatLite:: - WriteMessageNoVirtualToArray( - 121, this->pooling_param(), target); + InternalWriteMessageNoVirtualToArray( + 121, *this->pooling_param_, false, target); } // optional .caffe.PowerParameter power_param = 122; if (has_power_param()) { target = ::google::protobuf::internal::WireFormatLite:: - WriteMessageNoVirtualToArray( - 122, this->power_param(), target); + InternalWriteMessageNoVirtualToArray( + 122, *this->power_param_, false, target); } // optional .caffe.ReLUParameter relu_param = 123; if (has_relu_param()) { target = ::google::protobuf::internal::WireFormatLite:: - WriteMessageNoVirtualToArray( - 123, this->relu_param(), target); + InternalWriteMessageNoVirtualToArray( + 123, *this->relu_param_, false, target); } // optional .caffe.SigmoidParameter sigmoid_param = 124; if (has_sigmoid_param()) { target = ::google::protobuf::internal::WireFormatLite:: - WriteMessageNoVirtualToArray( - 124, this->sigmoid_param(), target); + InternalWriteMessageNoVirtualToArray( + 124, *this->sigmoid_param_, false, target); } // optional .caffe.SoftmaxParameter softmax_param = 125; if (has_softmax_param()) { target = ::google::protobuf::internal::WireFormatLite:: - WriteMessageNoVirtualToArray( - 125, this->softmax_param(), target); + InternalWriteMessageNoVirtualToArray( + 125, *this->softmax_param_, false, target); } // optional .caffe.SliceParameter slice_param = 126; if (has_slice_param()) { target = ::google::protobuf::internal::WireFormatLite:: - WriteMessageNoVirtualToArray( - 126, this->slice_param(), target); + InternalWriteMessageNoVirtualToArray( + 126, *this->slice_param_, false, target); } // optional .caffe.TanHParameter tanh_param = 127; if (has_tanh_param()) { target = ::google::protobuf::internal::WireFormatLite:: - WriteMessageNoVirtualToArray( - 127, this->tanh_param(), target); + InternalWriteMessageNoVirtualToArray( + 127, *this->tanh_param_, false, target); } // optional .caffe.ThresholdParameter threshold_param = 128; if (has_threshold_param()) { target = ::google::protobuf::internal::WireFormatLite:: - WriteMessageNoVirtualToArray( - 128, this->threshold_param(), target); + InternalWriteMessageNoVirtualToArray( + 128, *this->threshold_param_, false, target); } // optional .caffe.WindowDataParameter window_data_param = 129; if (has_window_data_param()) { target = ::google::protobuf::internal::WireFormatLite:: - WriteMessageNoVirtualToArray( - 129, this->window_data_param(), target); + InternalWriteMessageNoVirtualToArray( + 129, *this->window_data_param_, false, target); } // optional .caffe.PythonParameter python_param = 130; if (has_python_param()) { target = ::google::protobuf::internal::WireFormatLite:: - WriteMessageNoVirtualToArray( - 130, this->python_param(), target); + InternalWriteMessageNoVirtualToArray( + 130, *this->python_param_, false, target); } // optional .caffe.PReLUParameter prelu_param = 131; if (has_prelu_param()) { target = ::google::protobuf::internal::WireFormatLite:: - WriteMessageNoVirtualToArray( - 131, this->prelu_param(), target); + InternalWriteMessageNoVirtualToArray( + 131, *this->prelu_param_, false, target); } // optional .caffe.SPPParameter spp_param = 132; if (has_spp_param()) { target = ::google::protobuf::internal::WireFormatLite:: - WriteMessageNoVirtualToArray( - 132, this->spp_param(), target); + InternalWriteMessageNoVirtualToArray( + 132, *this->spp_param_, false, target); } // optional .caffe.ReshapeParameter reshape_param = 133; if (has_reshape_param()) { target = ::google::protobuf::internal::WireFormatLite:: - WriteMessageNoVirtualToArray( - 133, this->reshape_param(), target); + InternalWriteMessageNoVirtualToArray( + 133, *this->reshape_param_, false, target); } // optional .caffe.LogParameter log_param = 134; if (has_log_param()) { target = ::google::protobuf::internal::WireFormatLite:: - WriteMessageNoVirtualToArray( - 134, this->log_param(), target); + InternalWriteMessageNoVirtualToArray( + 134, *this->log_param_, false, target); } // optional .caffe.FlattenParameter flatten_param = 135; if (has_flatten_param()) { target = ::google::protobuf::internal::WireFormatLite:: - WriteMessageNoVirtualToArray( - 135, this->flatten_param(), target); + InternalWriteMessageNoVirtualToArray( + 135, *this->flatten_param_, false, target); } // optional .caffe.ReductionParameter reduction_param = 136; if (has_reduction_param()) { target = ::google::protobuf::internal::WireFormatLite:: - WriteMessageNoVirtualToArray( - 136, this->reduction_param(), target); + InternalWriteMessageNoVirtualToArray( + 136, *this->reduction_param_, false, target); } // optional .caffe.CropParameter crop_param = 137; if (has_crop_param()) { target = ::google::protobuf::internal::WireFormatLite:: - WriteMessageNoVirtualToArray( - 137, this->crop_param(), target); + InternalWriteMessageNoVirtualToArray( + 137, *this->crop_param_, false, target); } // optional .caffe.PermuteParameter permute_param = 138; if (has_permute_param()) { target = ::google::protobuf::internal::WireFormatLite:: - WriteMessageNoVirtualToArray( - 138, this->permute_param(), target); + InternalWriteMessageNoVirtualToArray( + 138, *this->permute_param_, false, target); } // optional .caffe.NormalizeBBoxParameter normalize_bbox_param = 139; if (has_normalize_bbox_param()) { target = ::google::protobuf::internal::WireFormatLite:: - WriteMessageNoVirtualToArray( - 139, this->normalize_bbox_param(), target); + InternalWriteMessageNoVirtualToArray( + 139, *this->normalize_bbox_param_, false, target); } // optional .caffe.PriorBoxParameter prior_box_param = 140; if (has_prior_box_param()) { target = ::google::protobuf::internal::WireFormatLite:: - WriteMessageNoVirtualToArray( - 140, this->prior_box_param(), target); + InternalWriteMessageNoVirtualToArray( + 140, *this->prior_box_param_, false, target); } // optional .caffe.DetectionOutputParameter detection_output_param = 141; if (has_detection_output_param()) { target = ::google::protobuf::internal::WireFormatLite:: - WriteMessageNoVirtualToArray( - 141, this->detection_output_param(), target); + InternalWriteMessageNoVirtualToArray( + 141, *this->detection_output_param_, false, target); } - if (!unknown_fields().empty()) { + if (_internal_metadata_.have_unknown_fields()) { target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray( unknown_fields(), target); } + // @@protoc_insertion_point(serialize_to_array_end:caffe.LayerParameter) return target; } -int LayerParameter::ByteSize() const { - int total_size = 0; +size_t LayerParameter::ByteSizeLong() const { +// @@protoc_insertion_point(message_byte_size_start:caffe.LayerParameter) + size_t total_size = 0; - if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) { + if (_has_bits_[0 / 32] & 19u) { // optional string name = 1; if (has_name()) { total_size += 1 + @@ -11601,648 +15802,3010 @@ int LayerParameter::ByteSize() const { } } - if (_has_bits_[11 / 32] & (0xffu << (11 % 32))) { + if (_has_bits_[11 / 32] & 63488u) { // optional .caffe.TransformationParameter transform_param = 100; if (has_transform_param()) { total_size += 2 + ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( - this->transform_param()); + *this->transform_param_); + } + + // optional .caffe.LossParameter loss_param = 101; + if (has_loss_param()) { + total_size += 2 + + ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( + *this->loss_param_); + } + + // optional .caffe.AccuracyParameter accuracy_param = 102; + if (has_accuracy_param()) { + total_size += 2 + + ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( + *this->accuracy_param_); + } + + // optional .caffe.ArgMaxParameter argmax_param = 103; + if (has_argmax_param()) { + total_size += 2 + + ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( + *this->argmax_param_); + } + + // optional .caffe.ConcatParameter concat_param = 104; + if (has_concat_param()) { + total_size += 2 + + ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( + *this->concat_param_); + } + + } + if (_has_bits_[16 / 32] & 16711680u) { + // optional .caffe.ContrastiveLossParameter contrastive_loss_param = 105; + if (has_contrastive_loss_param()) { + total_size += 2 + + ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( + *this->contrastive_loss_param_); + } + + // optional .caffe.ConvolutionParameter convolution_param = 106; + if (has_convolution_param()) { + total_size += 2 + + ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( + *this->convolution_param_); + } + + // optional .caffe.CropParameter crop_param = 137; + if (has_crop_param()) { + total_size += 2 + + ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( + *this->crop_param_); + } + + // optional .caffe.DataParameter data_param = 107; + if (has_data_param()) { + total_size += 2 + + ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( + *this->data_param_); + } + + // optional .caffe.DetectionOutputParameter detection_output_param = 141; + if (has_detection_output_param()) { + total_size += 2 + + ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( + *this->detection_output_param_); + } + + // optional .caffe.DropoutParameter dropout_param = 108; + if (has_dropout_param()) { + total_size += 2 + + ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( + *this->dropout_param_); + } + + // optional .caffe.DummyDataParameter dummy_data_param = 109; + if (has_dummy_data_param()) { + total_size += 2 + + ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( + *this->dummy_data_param_); + } + + // optional .caffe.EltwiseParameter eltwise_param = 110; + if (has_eltwise_param()) { + total_size += 2 + + ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( + *this->eltwise_param_); + } + + } + if (_has_bits_[24 / 32] & 4278190080u) { + // optional .caffe.ExpParameter exp_param = 111; + if (has_exp_param()) { + total_size += 2 + + ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( + *this->exp_param_); + } + + // optional .caffe.FlattenParameter flatten_param = 135; + if (has_flatten_param()) { + total_size += 2 + + ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( + *this->flatten_param_); + } + + // optional .caffe.HDF5DataParameter hdf5_data_param = 112; + if (has_hdf5_data_param()) { + total_size += 2 + + ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( + *this->hdf5_data_param_); + } + + // optional .caffe.HDF5OutputParameter hdf5_output_param = 113; + if (has_hdf5_output_param()) { + total_size += 2 + + ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( + *this->hdf5_output_param_); + } + + // optional .caffe.HingeLossParameter hinge_loss_param = 114; + if (has_hinge_loss_param()) { + total_size += 2 + + ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( + *this->hinge_loss_param_); + } + + // optional .caffe.ImageDataParameter image_data_param = 115; + if (has_image_data_param()) { + total_size += 2 + + ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( + *this->image_data_param_); + } + + // optional .caffe.InfogainLossParameter infogain_loss_param = 116; + if (has_infogain_loss_param()) { + total_size += 2 + + ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( + *this->infogain_loss_param_); + } + + // optional .caffe.InnerProductParameter inner_product_param = 117; + if (has_inner_product_param()) { + total_size += 2 + + ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( + *this->inner_product_param_); + } + + } + if (_has_bits_[32 / 32] & 255u) { + // optional .caffe.LogParameter log_param = 134; + if (has_log_param()) { + total_size += 2 + + ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( + *this->log_param_); + } + + // optional .caffe.LRNParameter lrn_param = 118; + if (has_lrn_param()) { + total_size += 2 + + ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( + *this->lrn_param_); + } + + // optional .caffe.MemoryDataParameter memory_data_param = 119; + if (has_memory_data_param()) { + total_size += 2 + + ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( + *this->memory_data_param_); + } + + // optional .caffe.MVNParameter mvn_param = 120; + if (has_mvn_param()) { + total_size += 2 + + ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( + *this->mvn_param_); + } + + // optional .caffe.NormalizeBBoxParameter normalize_bbox_param = 139; + if (has_normalize_bbox_param()) { + total_size += 2 + + ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( + *this->normalize_bbox_param_); + } + + // optional .caffe.PermuteParameter permute_param = 138; + if (has_permute_param()) { + total_size += 2 + + ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( + *this->permute_param_); + } + + // optional .caffe.PoolingParameter pooling_param = 121; + if (has_pooling_param()) { + total_size += 2 + + ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( + *this->pooling_param_); + } + + // optional .caffe.PowerParameter power_param = 122; + if (has_power_param()) { + total_size += 2 + + ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( + *this->power_param_); + } + + } + if (_has_bits_[40 / 32] & 65280u) { + // optional .caffe.PReLUParameter prelu_param = 131; + if (has_prelu_param()) { + total_size += 2 + + ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( + *this->prelu_param_); + } + + // optional .caffe.PriorBoxParameter prior_box_param = 140; + if (has_prior_box_param()) { + total_size += 2 + + ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( + *this->prior_box_param_); + } + + // optional .caffe.PythonParameter python_param = 130; + if (has_python_param()) { + total_size += 2 + + ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( + *this->python_param_); + } + + // optional .caffe.ReductionParameter reduction_param = 136; + if (has_reduction_param()) { + total_size += 2 + + ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( + *this->reduction_param_); + } + + // optional .caffe.ReLUParameter relu_param = 123; + if (has_relu_param()) { + total_size += 2 + + ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( + *this->relu_param_); + } + + // optional .caffe.ReshapeParameter reshape_param = 133; + if (has_reshape_param()) { + total_size += 2 + + ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( + *this->reshape_param_); + } + + // optional .caffe.SigmoidParameter sigmoid_param = 124; + if (has_sigmoid_param()) { + total_size += 2 + + ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( + *this->sigmoid_param_); + } + + // optional .caffe.SliceParameter slice_param = 126; + if (has_slice_param()) { + total_size += 2 + + ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( + *this->slice_param_); + } + + } + if (_has_bits_[48 / 32] & 2031616u) { + // optional .caffe.SoftmaxParameter softmax_param = 125; + if (has_softmax_param()) { + total_size += 2 + + ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( + *this->softmax_param_); } - // optional .caffe.LossParameter loss_param = 101; - if (has_loss_param()) { + // optional .caffe.SPPParameter spp_param = 132; + if (has_spp_param()) { total_size += 2 + ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( - this->loss_param()); + *this->spp_param_); } - // optional .caffe.AccuracyParameter accuracy_param = 102; - if (has_accuracy_param()) { + // optional .caffe.TanHParameter tanh_param = 127; + if (has_tanh_param()) { total_size += 2 + ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( - this->accuracy_param()); + *this->tanh_param_); } - // optional .caffe.ArgMaxParameter argmax_param = 103; - if (has_argmax_param()) { + // optional .caffe.ThresholdParameter threshold_param = 128; + if (has_threshold_param()) { total_size += 2 + ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( - this->argmax_param()); + *this->threshold_param_); } - // optional .caffe.ConcatParameter concat_param = 104; - if (has_concat_param()) { + // optional .caffe.WindowDataParameter window_data_param = 129; + if (has_window_data_param()) { total_size += 2 + ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( - this->concat_param()); + *this->window_data_param_); } } - if (_has_bits_[16 / 32] & (0xffu << (16 % 32))) { - // optional .caffe.ContrastiveLossParameter contrastive_loss_param = 105; - if (has_contrastive_loss_param()) { - total_size += 2 + + // repeated string bottom = 3; + total_size += 1 * + ::google::protobuf::internal::FromIntSize(this->bottom_size()); + for (int i = 0; i < this->bottom_size(); i++) { + total_size += ::google::protobuf::internal::WireFormatLite::StringSize( + this->bottom(i)); + } + + // repeated string top = 4; + total_size += 1 * + ::google::protobuf::internal::FromIntSize(this->top_size()); + for (int i = 0; i < this->top_size(); i++) { + total_size += ::google::protobuf::internal::WireFormatLite::StringSize( + this->top(i)); + } + + // repeated float loss_weight = 5; + { + size_t data_size = 0; + unsigned int count = this->loss_weight_size(); + data_size = 4UL * count; + total_size += 1 * + ::google::protobuf::internal::FromIntSize(this->loss_weight_size()); + total_size += data_size; + } + + // repeated .caffe.ParamSpec param = 6; + { + unsigned int count = this->param_size(); + total_size += 1UL * count; + for (unsigned int i = 0; i < count; i++) { + total_size += ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( - this->contrastive_loss_param()); + this->param(i)); } + } - // optional .caffe.ConvolutionParameter convolution_param = 106; - if (has_convolution_param()) { - total_size += 2 + + // repeated .caffe.BlobProto blobs = 7; + { + unsigned int count = this->blobs_size(); + total_size += 1UL * count; + for (unsigned int i = 0; i < count; i++) { + total_size += ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( - this->convolution_param()); + this->blobs(i)); } + } - // optional .caffe.CropParameter crop_param = 137; - if (has_crop_param()) { - total_size += 2 + + // repeated bool propagate_down = 11; + { + size_t data_size = 0; + unsigned int count = this->propagate_down_size(); + data_size = 1UL * count; + total_size += 1 * + ::google::protobuf::internal::FromIntSize(this->propagate_down_size()); + total_size += data_size; + } + + // repeated .caffe.NetStateRule include = 8; + { + unsigned int count = this->include_size(); + total_size += 1UL * count; + for (unsigned int i = 0; i < count; i++) { + total_size += ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( - this->crop_param()); + this->include(i)); } + } - // optional .caffe.DataParameter data_param = 107; - if (has_data_param()) { - total_size += 2 + + // repeated .caffe.NetStateRule exclude = 9; + { + unsigned int count = this->exclude_size(); + total_size += 1UL * count; + for (unsigned int i = 0; i < count; i++) { + total_size += ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( - this->data_param()); + this->exclude(i)); + } + } + + if (_internal_metadata_.have_unknown_fields()) { + total_size += + ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( + unknown_fields()); + } + int cached_size = ::google::protobuf::internal::ToCachedSize(total_size); + GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); + _cached_size_ = cached_size; + GOOGLE_SAFE_CONCURRENT_WRITES_END(); + return total_size; +} + +void LayerParameter::MergeFrom(const ::google::protobuf::Message& from) { +// @@protoc_insertion_point(generalized_merge_from_start:caffe.LayerParameter) + if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__); + const LayerParameter* source = + ::google::protobuf::internal::DynamicCastToGenerated( + &from); + if (source == NULL) { + // @@protoc_insertion_point(generalized_merge_from_cast_fail:caffe.LayerParameter) + ::google::protobuf::internal::ReflectionOps::Merge(from, this); + } else { + // @@protoc_insertion_point(generalized_merge_from_cast_success:caffe.LayerParameter) + UnsafeMergeFrom(*source); + } +} + +void LayerParameter::MergeFrom(const LayerParameter& from) { +// @@protoc_insertion_point(class_specific_merge_from_start:caffe.LayerParameter) + if (GOOGLE_PREDICT_TRUE(&from != this)) { + UnsafeMergeFrom(from); + } else { + MergeFromFail(__LINE__); + } +} + +void LayerParameter::UnsafeMergeFrom(const LayerParameter& from) { + GOOGLE_DCHECK(&from != this); + bottom_.UnsafeMergeFrom(from.bottom_); + top_.UnsafeMergeFrom(from.top_); + loss_weight_.UnsafeMergeFrom(from.loss_weight_); + param_.MergeFrom(from.param_); + blobs_.MergeFrom(from.blobs_); + propagate_down_.UnsafeMergeFrom(from.propagate_down_); + include_.MergeFrom(from.include_); + exclude_.MergeFrom(from.exclude_); + if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) { + if (from.has_name()) { + set_has_name(); + name_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.name_); + } + if (from.has_type()) { + set_has_type(); + type_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.type_); + } + if (from.has_phase()) { + set_phase(from.phase()); + } + } + if (from._has_bits_[11 / 32] & (0xffu << (11 % 32))) { + if (from.has_transform_param()) { + mutable_transform_param()->::caffe::TransformationParameter::MergeFrom(from.transform_param()); + } + if (from.has_loss_param()) { + mutable_loss_param()->::caffe::LossParameter::MergeFrom(from.loss_param()); + } + if (from.has_accuracy_param()) { + mutable_accuracy_param()->::caffe::AccuracyParameter::MergeFrom(from.accuracy_param()); + } + if (from.has_argmax_param()) { + mutable_argmax_param()->::caffe::ArgMaxParameter::MergeFrom(from.argmax_param()); + } + if (from.has_concat_param()) { + mutable_concat_param()->::caffe::ConcatParameter::MergeFrom(from.concat_param()); + } + } + if (from._has_bits_[16 / 32] & (0xffu << (16 % 32))) { + if (from.has_contrastive_loss_param()) { + mutable_contrastive_loss_param()->::caffe::ContrastiveLossParameter::MergeFrom(from.contrastive_loss_param()); + } + if (from.has_convolution_param()) { + mutable_convolution_param()->::caffe::ConvolutionParameter::MergeFrom(from.convolution_param()); + } + if (from.has_crop_param()) { + mutable_crop_param()->::caffe::CropParameter::MergeFrom(from.crop_param()); } + if (from.has_data_param()) { + mutable_data_param()->::caffe::DataParameter::MergeFrom(from.data_param()); + } + if (from.has_detection_output_param()) { + mutable_detection_output_param()->::caffe::DetectionOutputParameter::MergeFrom(from.detection_output_param()); + } + if (from.has_dropout_param()) { + mutable_dropout_param()->::caffe::DropoutParameter::MergeFrom(from.dropout_param()); + } + if (from.has_dummy_data_param()) { + mutable_dummy_data_param()->::caffe::DummyDataParameter::MergeFrom(from.dummy_data_param()); + } + if (from.has_eltwise_param()) { + mutable_eltwise_param()->::caffe::EltwiseParameter::MergeFrom(from.eltwise_param()); + } + } + if (from._has_bits_[24 / 32] & (0xffu << (24 % 32))) { + if (from.has_exp_param()) { + mutable_exp_param()->::caffe::ExpParameter::MergeFrom(from.exp_param()); + } + if (from.has_flatten_param()) { + mutable_flatten_param()->::caffe::FlattenParameter::MergeFrom(from.flatten_param()); + } + if (from.has_hdf5_data_param()) { + mutable_hdf5_data_param()->::caffe::HDF5DataParameter::MergeFrom(from.hdf5_data_param()); + } + if (from.has_hdf5_output_param()) { + mutable_hdf5_output_param()->::caffe::HDF5OutputParameter::MergeFrom(from.hdf5_output_param()); + } + if (from.has_hinge_loss_param()) { + mutable_hinge_loss_param()->::caffe::HingeLossParameter::MergeFrom(from.hinge_loss_param()); + } + if (from.has_image_data_param()) { + mutable_image_data_param()->::caffe::ImageDataParameter::MergeFrom(from.image_data_param()); + } + if (from.has_infogain_loss_param()) { + mutable_infogain_loss_param()->::caffe::InfogainLossParameter::MergeFrom(from.infogain_loss_param()); + } + if (from.has_inner_product_param()) { + mutable_inner_product_param()->::caffe::InnerProductParameter::MergeFrom(from.inner_product_param()); + } + } + if (from._has_bits_[32 / 32] & (0xffu << (32 % 32))) { + if (from.has_log_param()) { + mutable_log_param()->::caffe::LogParameter::MergeFrom(from.log_param()); + } + if (from.has_lrn_param()) { + mutable_lrn_param()->::caffe::LRNParameter::MergeFrom(from.lrn_param()); + } + if (from.has_memory_data_param()) { + mutable_memory_data_param()->::caffe::MemoryDataParameter::MergeFrom(from.memory_data_param()); + } + if (from.has_mvn_param()) { + mutable_mvn_param()->::caffe::MVNParameter::MergeFrom(from.mvn_param()); + } + if (from.has_normalize_bbox_param()) { + mutable_normalize_bbox_param()->::caffe::NormalizeBBoxParameter::MergeFrom(from.normalize_bbox_param()); + } + if (from.has_permute_param()) { + mutable_permute_param()->::caffe::PermuteParameter::MergeFrom(from.permute_param()); + } + if (from.has_pooling_param()) { + mutable_pooling_param()->::caffe::PoolingParameter::MergeFrom(from.pooling_param()); + } + if (from.has_power_param()) { + mutable_power_param()->::caffe::PowerParameter::MergeFrom(from.power_param()); + } + } + if (from._has_bits_[40 / 32] & (0xffu << (40 % 32))) { + if (from.has_prelu_param()) { + mutable_prelu_param()->::caffe::PReLUParameter::MergeFrom(from.prelu_param()); + } + if (from.has_prior_box_param()) { + mutable_prior_box_param()->::caffe::PriorBoxParameter::MergeFrom(from.prior_box_param()); + } + if (from.has_python_param()) { + mutable_python_param()->::caffe::PythonParameter::MergeFrom(from.python_param()); + } + if (from.has_reduction_param()) { + mutable_reduction_param()->::caffe::ReductionParameter::MergeFrom(from.reduction_param()); + } + if (from.has_relu_param()) { + mutable_relu_param()->::caffe::ReLUParameter::MergeFrom(from.relu_param()); + } + if (from.has_reshape_param()) { + mutable_reshape_param()->::caffe::ReshapeParameter::MergeFrom(from.reshape_param()); + } + if (from.has_sigmoid_param()) { + mutable_sigmoid_param()->::caffe::SigmoidParameter::MergeFrom(from.sigmoid_param()); + } + if (from.has_slice_param()) { + mutable_slice_param()->::caffe::SliceParameter::MergeFrom(from.slice_param()); + } + } + if (from._has_bits_[48 / 32] & (0xffu << (48 % 32))) { + if (from.has_softmax_param()) { + mutable_softmax_param()->::caffe::SoftmaxParameter::MergeFrom(from.softmax_param()); + } + if (from.has_spp_param()) { + mutable_spp_param()->::caffe::SPPParameter::MergeFrom(from.spp_param()); + } + if (from.has_tanh_param()) { + mutable_tanh_param()->::caffe::TanHParameter::MergeFrom(from.tanh_param()); + } + if (from.has_threshold_param()) { + mutable_threshold_param()->::caffe::ThresholdParameter::MergeFrom(from.threshold_param()); + } + if (from.has_window_data_param()) { + mutable_window_data_param()->::caffe::WindowDataParameter::MergeFrom(from.window_data_param()); + } + } + if (from._internal_metadata_.have_unknown_fields()) { + ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata( + from.unknown_fields(), &_internal_metadata_); + } +} + +void LayerParameter::CopyFrom(const ::google::protobuf::Message& from) { +// @@protoc_insertion_point(generalized_copy_from_start:caffe.LayerParameter) + if (&from == this) return; + Clear(); + MergeFrom(from); +} + +void LayerParameter::CopyFrom(const LayerParameter& from) { +// @@protoc_insertion_point(class_specific_copy_from_start:caffe.LayerParameter) + if (&from == this) return; + Clear(); + UnsafeMergeFrom(from); +} + +bool LayerParameter::IsInitialized() const { + + return true; +} - // optional .caffe.DetectionOutputParameter detection_output_param = 141; - if (has_detection_output_param()) { - total_size += 2 + - ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( - this->detection_output_param()); - } +void LayerParameter::Swap(LayerParameter* other) { + if (other == this) return; + InternalSwap(other); +} +void LayerParameter::InternalSwap(LayerParameter* other) { + name_.Swap(&other->name_); + type_.Swap(&other->type_); + bottom_.UnsafeArenaSwap(&other->bottom_); + top_.UnsafeArenaSwap(&other->top_); + std::swap(phase_, other->phase_); + loss_weight_.UnsafeArenaSwap(&other->loss_weight_); + param_.UnsafeArenaSwap(&other->param_); + blobs_.UnsafeArenaSwap(&other->blobs_); + propagate_down_.UnsafeArenaSwap(&other->propagate_down_); + include_.UnsafeArenaSwap(&other->include_); + exclude_.UnsafeArenaSwap(&other->exclude_); + std::swap(transform_param_, other->transform_param_); + std::swap(loss_param_, other->loss_param_); + std::swap(accuracy_param_, other->accuracy_param_); + std::swap(argmax_param_, other->argmax_param_); + std::swap(concat_param_, other->concat_param_); + std::swap(contrastive_loss_param_, other->contrastive_loss_param_); + std::swap(convolution_param_, other->convolution_param_); + std::swap(crop_param_, other->crop_param_); + std::swap(data_param_, other->data_param_); + std::swap(detection_output_param_, other->detection_output_param_); + std::swap(dropout_param_, other->dropout_param_); + std::swap(dummy_data_param_, other->dummy_data_param_); + std::swap(eltwise_param_, other->eltwise_param_); + std::swap(exp_param_, other->exp_param_); + std::swap(flatten_param_, other->flatten_param_); + std::swap(hdf5_data_param_, other->hdf5_data_param_); + std::swap(hdf5_output_param_, other->hdf5_output_param_); + std::swap(hinge_loss_param_, other->hinge_loss_param_); + std::swap(image_data_param_, other->image_data_param_); + std::swap(infogain_loss_param_, other->infogain_loss_param_); + std::swap(inner_product_param_, other->inner_product_param_); + std::swap(log_param_, other->log_param_); + std::swap(lrn_param_, other->lrn_param_); + std::swap(memory_data_param_, other->memory_data_param_); + std::swap(mvn_param_, other->mvn_param_); + std::swap(normalize_bbox_param_, other->normalize_bbox_param_); + std::swap(permute_param_, other->permute_param_); + std::swap(pooling_param_, other->pooling_param_); + std::swap(power_param_, other->power_param_); + std::swap(prelu_param_, other->prelu_param_); + std::swap(prior_box_param_, other->prior_box_param_); + std::swap(python_param_, other->python_param_); + std::swap(reduction_param_, other->reduction_param_); + std::swap(relu_param_, other->relu_param_); + std::swap(reshape_param_, other->reshape_param_); + std::swap(sigmoid_param_, other->sigmoid_param_); + std::swap(slice_param_, other->slice_param_); + std::swap(softmax_param_, other->softmax_param_); + std::swap(spp_param_, other->spp_param_); + std::swap(tanh_param_, other->tanh_param_); + std::swap(threshold_param_, other->threshold_param_); + std::swap(window_data_param_, other->window_data_param_); + std::swap(_has_bits_[0], other->_has_bits_[0]); + std::swap(_has_bits_[1], other->_has_bits_[1]); + _internal_metadata_.Swap(&other->_internal_metadata_); + std::swap(_cached_size_, other->_cached_size_); +} - // optional .caffe.DropoutParameter dropout_param = 108; - if (has_dropout_param()) { - total_size += 2 + - ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( - this->dropout_param()); - } +::google::protobuf::Metadata LayerParameter::GetMetadata() const { + protobuf_AssignDescriptorsOnce(); + ::google::protobuf::Metadata metadata; + metadata.descriptor = LayerParameter_descriptor_; + metadata.reflection = LayerParameter_reflection_; + return metadata; +} - // optional .caffe.DummyDataParameter dummy_data_param = 109; - if (has_dummy_data_param()) { - total_size += 2 + - ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( - this->dummy_data_param()); - } +#if PROTOBUF_INLINE_NOT_IN_HEADERS +// LayerParameter - // optional .caffe.EltwiseParameter eltwise_param = 110; - if (has_eltwise_param()) { - total_size += 2 + - ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( - this->eltwise_param()); - } +// optional string name = 1; +bool LayerParameter::has_name() const { + return (_has_bits_[0] & 0x00000001u) != 0; +} +void LayerParameter::set_has_name() { + _has_bits_[0] |= 0x00000001u; +} +void LayerParameter::clear_has_name() { + _has_bits_[0] &= ~0x00000001u; +} +void LayerParameter::clear_name() { + name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + clear_has_name(); +} +const ::std::string& LayerParameter::name() const { + // @@protoc_insertion_point(field_get:caffe.LayerParameter.name) + return name_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); +} +void LayerParameter::set_name(const ::std::string& value) { + set_has_name(); + name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); + // @@protoc_insertion_point(field_set:caffe.LayerParameter.name) +} +void LayerParameter::set_name(const char* value) { + set_has_name(); + name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); + // @@protoc_insertion_point(field_set_char:caffe.LayerParameter.name) +} +void LayerParameter::set_name(const char* value, size_t size) { + set_has_name(); + name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), + ::std::string(reinterpret_cast(value), size)); + // @@protoc_insertion_point(field_set_pointer:caffe.LayerParameter.name) +} +::std::string* LayerParameter::mutable_name() { + set_has_name(); + // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.name) + return name_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); +} +::std::string* LayerParameter::release_name() { + // @@protoc_insertion_point(field_release:caffe.LayerParameter.name) + clear_has_name(); + return name_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); +} +void LayerParameter::set_allocated_name(::std::string* name) { + if (name != NULL) { + set_has_name(); + } else { + clear_has_name(); + } + name_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), name); + // @@protoc_insertion_point(field_set_allocated:caffe.LayerParameter.name) +} +// optional string type = 2; +bool LayerParameter::has_type() const { + return (_has_bits_[0] & 0x00000002u) != 0; +} +void LayerParameter::set_has_type() { + _has_bits_[0] |= 0x00000002u; +} +void LayerParameter::clear_has_type() { + _has_bits_[0] &= ~0x00000002u; +} +void LayerParameter::clear_type() { + type_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + clear_has_type(); +} +const ::std::string& LayerParameter::type() const { + // @@protoc_insertion_point(field_get:caffe.LayerParameter.type) + return type_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); +} +void LayerParameter::set_type(const ::std::string& value) { + set_has_type(); + type_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); + // @@protoc_insertion_point(field_set:caffe.LayerParameter.type) +} +void LayerParameter::set_type(const char* value) { + set_has_type(); + type_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); + // @@protoc_insertion_point(field_set_char:caffe.LayerParameter.type) +} +void LayerParameter::set_type(const char* value, size_t size) { + set_has_type(); + type_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), + ::std::string(reinterpret_cast(value), size)); + // @@protoc_insertion_point(field_set_pointer:caffe.LayerParameter.type) +} +::std::string* LayerParameter::mutable_type() { + set_has_type(); + // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.type) + return type_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); +} +::std::string* LayerParameter::release_type() { + // @@protoc_insertion_point(field_release:caffe.LayerParameter.type) + clear_has_type(); + return type_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); +} +void LayerParameter::set_allocated_type(::std::string* type) { + if (type != NULL) { + set_has_type(); + } else { + clear_has_type(); } - if (_has_bits_[24 / 32] & (0xffu << (24 % 32))) { - // optional .caffe.ExpParameter exp_param = 111; - if (has_exp_param()) { - total_size += 2 + - ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( - this->exp_param()); - } + type_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), type); + // @@protoc_insertion_point(field_set_allocated:caffe.LayerParameter.type) +} - // optional .caffe.FlattenParameter flatten_param = 135; - if (has_flatten_param()) { - total_size += 2 + - ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( - this->flatten_param()); - } +// repeated string bottom = 3; +int LayerParameter::bottom_size() const { + return bottom_.size(); +} +void LayerParameter::clear_bottom() { + bottom_.Clear(); +} +const ::std::string& LayerParameter::bottom(int index) const { + // @@protoc_insertion_point(field_get:caffe.LayerParameter.bottom) + return bottom_.Get(index); +} +::std::string* LayerParameter::mutable_bottom(int index) { + // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.bottom) + return bottom_.Mutable(index); +} +void LayerParameter::set_bottom(int index, const ::std::string& value) { + // @@protoc_insertion_point(field_set:caffe.LayerParameter.bottom) + bottom_.Mutable(index)->assign(value); +} +void LayerParameter::set_bottom(int index, const char* value) { + bottom_.Mutable(index)->assign(value); + // @@protoc_insertion_point(field_set_char:caffe.LayerParameter.bottom) +} +void LayerParameter::set_bottom(int index, const char* value, size_t size) { + bottom_.Mutable(index)->assign( + reinterpret_cast(value), size); + // @@protoc_insertion_point(field_set_pointer:caffe.LayerParameter.bottom) +} +::std::string* LayerParameter::add_bottom() { + // @@protoc_insertion_point(field_add_mutable:caffe.LayerParameter.bottom) + return bottom_.Add(); +} +void LayerParameter::add_bottom(const ::std::string& value) { + bottom_.Add()->assign(value); + // @@protoc_insertion_point(field_add:caffe.LayerParameter.bottom) +} +void LayerParameter::add_bottom(const char* value) { + bottom_.Add()->assign(value); + // @@protoc_insertion_point(field_add_char:caffe.LayerParameter.bottom) +} +void LayerParameter::add_bottom(const char* value, size_t size) { + bottom_.Add()->assign(reinterpret_cast(value), size); + // @@protoc_insertion_point(field_add_pointer:caffe.LayerParameter.bottom) +} +const ::google::protobuf::RepeatedPtrField< ::std::string>& +LayerParameter::bottom() const { + // @@protoc_insertion_point(field_list:caffe.LayerParameter.bottom) + return bottom_; +} +::google::protobuf::RepeatedPtrField< ::std::string>* +LayerParameter::mutable_bottom() { + // @@protoc_insertion_point(field_mutable_list:caffe.LayerParameter.bottom) + return &bottom_; +} - // optional .caffe.HDF5DataParameter hdf5_data_param = 112; - if (has_hdf5_data_param()) { - total_size += 2 + - ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( - this->hdf5_data_param()); - } +// repeated string top = 4; +int LayerParameter::top_size() const { + return top_.size(); +} +void LayerParameter::clear_top() { + top_.Clear(); +} +const ::std::string& LayerParameter::top(int index) const { + // @@protoc_insertion_point(field_get:caffe.LayerParameter.top) + return top_.Get(index); +} +::std::string* LayerParameter::mutable_top(int index) { + // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.top) + return top_.Mutable(index); +} +void LayerParameter::set_top(int index, const ::std::string& value) { + // @@protoc_insertion_point(field_set:caffe.LayerParameter.top) + top_.Mutable(index)->assign(value); +} +void LayerParameter::set_top(int index, const char* value) { + top_.Mutable(index)->assign(value); + // @@protoc_insertion_point(field_set_char:caffe.LayerParameter.top) +} +void LayerParameter::set_top(int index, const char* value, size_t size) { + top_.Mutable(index)->assign( + reinterpret_cast(value), size); + // @@protoc_insertion_point(field_set_pointer:caffe.LayerParameter.top) +} +::std::string* LayerParameter::add_top() { + // @@protoc_insertion_point(field_add_mutable:caffe.LayerParameter.top) + return top_.Add(); +} +void LayerParameter::add_top(const ::std::string& value) { + top_.Add()->assign(value); + // @@protoc_insertion_point(field_add:caffe.LayerParameter.top) +} +void LayerParameter::add_top(const char* value) { + top_.Add()->assign(value); + // @@protoc_insertion_point(field_add_char:caffe.LayerParameter.top) +} +void LayerParameter::add_top(const char* value, size_t size) { + top_.Add()->assign(reinterpret_cast(value), size); + // @@protoc_insertion_point(field_add_pointer:caffe.LayerParameter.top) +} +const ::google::protobuf::RepeatedPtrField< ::std::string>& +LayerParameter::top() const { + // @@protoc_insertion_point(field_list:caffe.LayerParameter.top) + return top_; +} +::google::protobuf::RepeatedPtrField< ::std::string>* +LayerParameter::mutable_top() { + // @@protoc_insertion_point(field_mutable_list:caffe.LayerParameter.top) + return &top_; +} - // optional .caffe.HDF5OutputParameter hdf5_output_param = 113; - if (has_hdf5_output_param()) { - total_size += 2 + - ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( - this->hdf5_output_param()); - } +// optional .caffe.Phase phase = 10; +bool LayerParameter::has_phase() const { + return (_has_bits_[0] & 0x00000010u) != 0; +} +void LayerParameter::set_has_phase() { + _has_bits_[0] |= 0x00000010u; +} +void LayerParameter::clear_has_phase() { + _has_bits_[0] &= ~0x00000010u; +} +void LayerParameter::clear_phase() { + phase_ = 0; + clear_has_phase(); +} +::caffe::Phase LayerParameter::phase() const { + // @@protoc_insertion_point(field_get:caffe.LayerParameter.phase) + return static_cast< ::caffe::Phase >(phase_); +} +void LayerParameter::set_phase(::caffe::Phase value) { + assert(::caffe::Phase_IsValid(value)); + set_has_phase(); + phase_ = value; + // @@protoc_insertion_point(field_set:caffe.LayerParameter.phase) +} - // optional .caffe.HingeLossParameter hinge_loss_param = 114; - if (has_hinge_loss_param()) { - total_size += 2 + - ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( - this->hinge_loss_param()); - } +// repeated float loss_weight = 5; +int LayerParameter::loss_weight_size() const { + return loss_weight_.size(); +} +void LayerParameter::clear_loss_weight() { + loss_weight_.Clear(); +} +float LayerParameter::loss_weight(int index) const { + // @@protoc_insertion_point(field_get:caffe.LayerParameter.loss_weight) + return loss_weight_.Get(index); +} +void LayerParameter::set_loss_weight(int index, float value) { + loss_weight_.Set(index, value); + // @@protoc_insertion_point(field_set:caffe.LayerParameter.loss_weight) +} +void LayerParameter::add_loss_weight(float value) { + loss_weight_.Add(value); + // @@protoc_insertion_point(field_add:caffe.LayerParameter.loss_weight) +} +const ::google::protobuf::RepeatedField< float >& +LayerParameter::loss_weight() const { + // @@protoc_insertion_point(field_list:caffe.LayerParameter.loss_weight) + return loss_weight_; +} +::google::protobuf::RepeatedField< float >* +LayerParameter::mutable_loss_weight() { + // @@protoc_insertion_point(field_mutable_list:caffe.LayerParameter.loss_weight) + return &loss_weight_; +} - // optional .caffe.ImageDataParameter image_data_param = 115; - if (has_image_data_param()) { - total_size += 2 + - ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( - this->image_data_param()); - } +// repeated .caffe.ParamSpec param = 6; +int LayerParameter::param_size() const { + return param_.size(); +} +void LayerParameter::clear_param() { + param_.Clear(); +} +const ::caffe::ParamSpec& LayerParameter::param(int index) const { + // @@protoc_insertion_point(field_get:caffe.LayerParameter.param) + return param_.Get(index); +} +::caffe::ParamSpec* LayerParameter::mutable_param(int index) { + // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.param) + return param_.Mutable(index); +} +::caffe::ParamSpec* LayerParameter::add_param() { + // @@protoc_insertion_point(field_add:caffe.LayerParameter.param) + return param_.Add(); +} +::google::protobuf::RepeatedPtrField< ::caffe::ParamSpec >* +LayerParameter::mutable_param() { + // @@protoc_insertion_point(field_mutable_list:caffe.LayerParameter.param) + return ¶m_; +} +const ::google::protobuf::RepeatedPtrField< ::caffe::ParamSpec >& +LayerParameter::param() const { + // @@protoc_insertion_point(field_list:caffe.LayerParameter.param) + return param_; +} - // optional .caffe.InfogainLossParameter infogain_loss_param = 116; - if (has_infogain_loss_param()) { - total_size += 2 + - ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( - this->infogain_loss_param()); - } +// repeated .caffe.BlobProto blobs = 7; +int LayerParameter::blobs_size() const { + return blobs_.size(); +} +void LayerParameter::clear_blobs() { + blobs_.Clear(); +} +const ::caffe::BlobProto& LayerParameter::blobs(int index) const { + // @@protoc_insertion_point(field_get:caffe.LayerParameter.blobs) + return blobs_.Get(index); +} +::caffe::BlobProto* LayerParameter::mutable_blobs(int index) { + // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.blobs) + return blobs_.Mutable(index); +} +::caffe::BlobProto* LayerParameter::add_blobs() { + // @@protoc_insertion_point(field_add:caffe.LayerParameter.blobs) + return blobs_.Add(); +} +::google::protobuf::RepeatedPtrField< ::caffe::BlobProto >* +LayerParameter::mutable_blobs() { + // @@protoc_insertion_point(field_mutable_list:caffe.LayerParameter.blobs) + return &blobs_; +} +const ::google::protobuf::RepeatedPtrField< ::caffe::BlobProto >& +LayerParameter::blobs() const { + // @@protoc_insertion_point(field_list:caffe.LayerParameter.blobs) + return blobs_; +} - // optional .caffe.InnerProductParameter inner_product_param = 117; - if (has_inner_product_param()) { - total_size += 2 + - ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( - this->inner_product_param()); - } +// repeated bool propagate_down = 11; +int LayerParameter::propagate_down_size() const { + return propagate_down_.size(); +} +void LayerParameter::clear_propagate_down() { + propagate_down_.Clear(); +} +bool LayerParameter::propagate_down(int index) const { + // @@protoc_insertion_point(field_get:caffe.LayerParameter.propagate_down) + return propagate_down_.Get(index); +} +void LayerParameter::set_propagate_down(int index, bool value) { + propagate_down_.Set(index, value); + // @@protoc_insertion_point(field_set:caffe.LayerParameter.propagate_down) +} +void LayerParameter::add_propagate_down(bool value) { + propagate_down_.Add(value); + // @@protoc_insertion_point(field_add:caffe.LayerParameter.propagate_down) +} +const ::google::protobuf::RepeatedField< bool >& +LayerParameter::propagate_down() const { + // @@protoc_insertion_point(field_list:caffe.LayerParameter.propagate_down) + return propagate_down_; +} +::google::protobuf::RepeatedField< bool >* +LayerParameter::mutable_propagate_down() { + // @@protoc_insertion_point(field_mutable_list:caffe.LayerParameter.propagate_down) + return &propagate_down_; +} + +// repeated .caffe.NetStateRule include = 8; +int LayerParameter::include_size() const { + return include_.size(); +} +void LayerParameter::clear_include() { + include_.Clear(); +} +const ::caffe::NetStateRule& LayerParameter::include(int index) const { + // @@protoc_insertion_point(field_get:caffe.LayerParameter.include) + return include_.Get(index); +} +::caffe::NetStateRule* LayerParameter::mutable_include(int index) { + // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.include) + return include_.Mutable(index); +} +::caffe::NetStateRule* LayerParameter::add_include() { + // @@protoc_insertion_point(field_add:caffe.LayerParameter.include) + return include_.Add(); +} +::google::protobuf::RepeatedPtrField< ::caffe::NetStateRule >* +LayerParameter::mutable_include() { + // @@protoc_insertion_point(field_mutable_list:caffe.LayerParameter.include) + return &include_; +} +const ::google::protobuf::RepeatedPtrField< ::caffe::NetStateRule >& +LayerParameter::include() const { + // @@protoc_insertion_point(field_list:caffe.LayerParameter.include) + return include_; +} + +// repeated .caffe.NetStateRule exclude = 9; +int LayerParameter::exclude_size() const { + return exclude_.size(); +} +void LayerParameter::clear_exclude() { + exclude_.Clear(); +} +const ::caffe::NetStateRule& LayerParameter::exclude(int index) const { + // @@protoc_insertion_point(field_get:caffe.LayerParameter.exclude) + return exclude_.Get(index); +} +::caffe::NetStateRule* LayerParameter::mutable_exclude(int index) { + // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.exclude) + return exclude_.Mutable(index); +} +::caffe::NetStateRule* LayerParameter::add_exclude() { + // @@protoc_insertion_point(field_add:caffe.LayerParameter.exclude) + return exclude_.Add(); +} +::google::protobuf::RepeatedPtrField< ::caffe::NetStateRule >* +LayerParameter::mutable_exclude() { + // @@protoc_insertion_point(field_mutable_list:caffe.LayerParameter.exclude) + return &exclude_; +} +const ::google::protobuf::RepeatedPtrField< ::caffe::NetStateRule >& +LayerParameter::exclude() const { + // @@protoc_insertion_point(field_list:caffe.LayerParameter.exclude) + return exclude_; +} +// optional .caffe.TransformationParameter transform_param = 100; +bool LayerParameter::has_transform_param() const { + return (_has_bits_[0] & 0x00000800u) != 0; +} +void LayerParameter::set_has_transform_param() { + _has_bits_[0] |= 0x00000800u; +} +void LayerParameter::clear_has_transform_param() { + _has_bits_[0] &= ~0x00000800u; +} +void LayerParameter::clear_transform_param() { + if (transform_param_ != NULL) transform_param_->::caffe::TransformationParameter::Clear(); + clear_has_transform_param(); +} +const ::caffe::TransformationParameter& LayerParameter::transform_param() const { + // @@protoc_insertion_point(field_get:caffe.LayerParameter.transform_param) + return transform_param_ != NULL ? *transform_param_ + : *::caffe::TransformationParameter::internal_default_instance(); +} +::caffe::TransformationParameter* LayerParameter::mutable_transform_param() { + set_has_transform_param(); + if (transform_param_ == NULL) { + transform_param_ = new ::caffe::TransformationParameter; } - if (_has_bits_[32 / 32] & (0xffu << (32 % 32))) { - // optional .caffe.LogParameter log_param = 134; - if (has_log_param()) { - total_size += 2 + - ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( - this->log_param()); - } + // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.transform_param) + return transform_param_; +} +::caffe::TransformationParameter* LayerParameter::release_transform_param() { + // @@protoc_insertion_point(field_release:caffe.LayerParameter.transform_param) + clear_has_transform_param(); + ::caffe::TransformationParameter* temp = transform_param_; + transform_param_ = NULL; + return temp; +} +void LayerParameter::set_allocated_transform_param(::caffe::TransformationParameter* transform_param) { + delete transform_param_; + transform_param_ = transform_param; + if (transform_param) { + set_has_transform_param(); + } else { + clear_has_transform_param(); + } + // @@protoc_insertion_point(field_set_allocated:caffe.LayerParameter.transform_param) +} - // optional .caffe.LRNParameter lrn_param = 118; - if (has_lrn_param()) { - total_size += 2 + - ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( - this->lrn_param()); - } +// optional .caffe.LossParameter loss_param = 101; +bool LayerParameter::has_loss_param() const { + return (_has_bits_[0] & 0x00001000u) != 0; +} +void LayerParameter::set_has_loss_param() { + _has_bits_[0] |= 0x00001000u; +} +void LayerParameter::clear_has_loss_param() { + _has_bits_[0] &= ~0x00001000u; +} +void LayerParameter::clear_loss_param() { + if (loss_param_ != NULL) loss_param_->::caffe::LossParameter::Clear(); + clear_has_loss_param(); +} +const ::caffe::LossParameter& LayerParameter::loss_param() const { + // @@protoc_insertion_point(field_get:caffe.LayerParameter.loss_param) + return loss_param_ != NULL ? *loss_param_ + : *::caffe::LossParameter::internal_default_instance(); +} +::caffe::LossParameter* LayerParameter::mutable_loss_param() { + set_has_loss_param(); + if (loss_param_ == NULL) { + loss_param_ = new ::caffe::LossParameter; + } + // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.loss_param) + return loss_param_; +} +::caffe::LossParameter* LayerParameter::release_loss_param() { + // @@protoc_insertion_point(field_release:caffe.LayerParameter.loss_param) + clear_has_loss_param(); + ::caffe::LossParameter* temp = loss_param_; + loss_param_ = NULL; + return temp; +} +void LayerParameter::set_allocated_loss_param(::caffe::LossParameter* loss_param) { + delete loss_param_; + loss_param_ = loss_param; + if (loss_param) { + set_has_loss_param(); + } else { + clear_has_loss_param(); + } + // @@protoc_insertion_point(field_set_allocated:caffe.LayerParameter.loss_param) +} - // optional .caffe.MemoryDataParameter memory_data_param = 119; - if (has_memory_data_param()) { - total_size += 2 + - ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( - this->memory_data_param()); - } +// optional .caffe.AccuracyParameter accuracy_param = 102; +bool LayerParameter::has_accuracy_param() const { + return (_has_bits_[0] & 0x00002000u) != 0; +} +void LayerParameter::set_has_accuracy_param() { + _has_bits_[0] |= 0x00002000u; +} +void LayerParameter::clear_has_accuracy_param() { + _has_bits_[0] &= ~0x00002000u; +} +void LayerParameter::clear_accuracy_param() { + if (accuracy_param_ != NULL) accuracy_param_->::caffe::AccuracyParameter::Clear(); + clear_has_accuracy_param(); +} +const ::caffe::AccuracyParameter& LayerParameter::accuracy_param() const { + // @@protoc_insertion_point(field_get:caffe.LayerParameter.accuracy_param) + return accuracy_param_ != NULL ? *accuracy_param_ + : *::caffe::AccuracyParameter::internal_default_instance(); +} +::caffe::AccuracyParameter* LayerParameter::mutable_accuracy_param() { + set_has_accuracy_param(); + if (accuracy_param_ == NULL) { + accuracy_param_ = new ::caffe::AccuracyParameter; + } + // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.accuracy_param) + return accuracy_param_; +} +::caffe::AccuracyParameter* LayerParameter::release_accuracy_param() { + // @@protoc_insertion_point(field_release:caffe.LayerParameter.accuracy_param) + clear_has_accuracy_param(); + ::caffe::AccuracyParameter* temp = accuracy_param_; + accuracy_param_ = NULL; + return temp; +} +void LayerParameter::set_allocated_accuracy_param(::caffe::AccuracyParameter* accuracy_param) { + delete accuracy_param_; + accuracy_param_ = accuracy_param; + if (accuracy_param) { + set_has_accuracy_param(); + } else { + clear_has_accuracy_param(); + } + // @@protoc_insertion_point(field_set_allocated:caffe.LayerParameter.accuracy_param) +} - // optional .caffe.MVNParameter mvn_param = 120; - if (has_mvn_param()) { - total_size += 2 + - ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( - this->mvn_param()); - } +// optional .caffe.ArgMaxParameter argmax_param = 103; +bool LayerParameter::has_argmax_param() const { + return (_has_bits_[0] & 0x00004000u) != 0; +} +void LayerParameter::set_has_argmax_param() { + _has_bits_[0] |= 0x00004000u; +} +void LayerParameter::clear_has_argmax_param() { + _has_bits_[0] &= ~0x00004000u; +} +void LayerParameter::clear_argmax_param() { + if (argmax_param_ != NULL) argmax_param_->::caffe::ArgMaxParameter::Clear(); + clear_has_argmax_param(); +} +const ::caffe::ArgMaxParameter& LayerParameter::argmax_param() const { + // @@protoc_insertion_point(field_get:caffe.LayerParameter.argmax_param) + return argmax_param_ != NULL ? *argmax_param_ + : *::caffe::ArgMaxParameter::internal_default_instance(); +} +::caffe::ArgMaxParameter* LayerParameter::mutable_argmax_param() { + set_has_argmax_param(); + if (argmax_param_ == NULL) { + argmax_param_ = new ::caffe::ArgMaxParameter; + } + // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.argmax_param) + return argmax_param_; +} +::caffe::ArgMaxParameter* LayerParameter::release_argmax_param() { + // @@protoc_insertion_point(field_release:caffe.LayerParameter.argmax_param) + clear_has_argmax_param(); + ::caffe::ArgMaxParameter* temp = argmax_param_; + argmax_param_ = NULL; + return temp; +} +void LayerParameter::set_allocated_argmax_param(::caffe::ArgMaxParameter* argmax_param) { + delete argmax_param_; + argmax_param_ = argmax_param; + if (argmax_param) { + set_has_argmax_param(); + } else { + clear_has_argmax_param(); + } + // @@protoc_insertion_point(field_set_allocated:caffe.LayerParameter.argmax_param) +} - // optional .caffe.NormalizeBBoxParameter normalize_bbox_param = 139; - if (has_normalize_bbox_param()) { - total_size += 2 + - ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( - this->normalize_bbox_param()); - } +// optional .caffe.ConcatParameter concat_param = 104; +bool LayerParameter::has_concat_param() const { + return (_has_bits_[0] & 0x00008000u) != 0; +} +void LayerParameter::set_has_concat_param() { + _has_bits_[0] |= 0x00008000u; +} +void LayerParameter::clear_has_concat_param() { + _has_bits_[0] &= ~0x00008000u; +} +void LayerParameter::clear_concat_param() { + if (concat_param_ != NULL) concat_param_->::caffe::ConcatParameter::Clear(); + clear_has_concat_param(); +} +const ::caffe::ConcatParameter& LayerParameter::concat_param() const { + // @@protoc_insertion_point(field_get:caffe.LayerParameter.concat_param) + return concat_param_ != NULL ? *concat_param_ + : *::caffe::ConcatParameter::internal_default_instance(); +} +::caffe::ConcatParameter* LayerParameter::mutable_concat_param() { + set_has_concat_param(); + if (concat_param_ == NULL) { + concat_param_ = new ::caffe::ConcatParameter; + } + // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.concat_param) + return concat_param_; +} +::caffe::ConcatParameter* LayerParameter::release_concat_param() { + // @@protoc_insertion_point(field_release:caffe.LayerParameter.concat_param) + clear_has_concat_param(); + ::caffe::ConcatParameter* temp = concat_param_; + concat_param_ = NULL; + return temp; +} +void LayerParameter::set_allocated_concat_param(::caffe::ConcatParameter* concat_param) { + delete concat_param_; + concat_param_ = concat_param; + if (concat_param) { + set_has_concat_param(); + } else { + clear_has_concat_param(); + } + // @@protoc_insertion_point(field_set_allocated:caffe.LayerParameter.concat_param) +} - // optional .caffe.PermuteParameter permute_param = 138; - if (has_permute_param()) { - total_size += 2 + - ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( - this->permute_param()); - } +// optional .caffe.ContrastiveLossParameter contrastive_loss_param = 105; +bool LayerParameter::has_contrastive_loss_param() const { + return (_has_bits_[0] & 0x00010000u) != 0; +} +void LayerParameter::set_has_contrastive_loss_param() { + _has_bits_[0] |= 0x00010000u; +} +void LayerParameter::clear_has_contrastive_loss_param() { + _has_bits_[0] &= ~0x00010000u; +} +void LayerParameter::clear_contrastive_loss_param() { + if (contrastive_loss_param_ != NULL) contrastive_loss_param_->::caffe::ContrastiveLossParameter::Clear(); + clear_has_contrastive_loss_param(); +} +const ::caffe::ContrastiveLossParameter& LayerParameter::contrastive_loss_param() const { + // @@protoc_insertion_point(field_get:caffe.LayerParameter.contrastive_loss_param) + return contrastive_loss_param_ != NULL ? *contrastive_loss_param_ + : *::caffe::ContrastiveLossParameter::internal_default_instance(); +} +::caffe::ContrastiveLossParameter* LayerParameter::mutable_contrastive_loss_param() { + set_has_contrastive_loss_param(); + if (contrastive_loss_param_ == NULL) { + contrastive_loss_param_ = new ::caffe::ContrastiveLossParameter; + } + // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.contrastive_loss_param) + return contrastive_loss_param_; +} +::caffe::ContrastiveLossParameter* LayerParameter::release_contrastive_loss_param() { + // @@protoc_insertion_point(field_release:caffe.LayerParameter.contrastive_loss_param) + clear_has_contrastive_loss_param(); + ::caffe::ContrastiveLossParameter* temp = contrastive_loss_param_; + contrastive_loss_param_ = NULL; + return temp; +} +void LayerParameter::set_allocated_contrastive_loss_param(::caffe::ContrastiveLossParameter* contrastive_loss_param) { + delete contrastive_loss_param_; + contrastive_loss_param_ = contrastive_loss_param; + if (contrastive_loss_param) { + set_has_contrastive_loss_param(); + } else { + clear_has_contrastive_loss_param(); + } + // @@protoc_insertion_point(field_set_allocated:caffe.LayerParameter.contrastive_loss_param) +} - // optional .caffe.PoolingParameter pooling_param = 121; - if (has_pooling_param()) { - total_size += 2 + - ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( - this->pooling_param()); - } +// optional .caffe.ConvolutionParameter convolution_param = 106; +bool LayerParameter::has_convolution_param() const { + return (_has_bits_[0] & 0x00020000u) != 0; +} +void LayerParameter::set_has_convolution_param() { + _has_bits_[0] |= 0x00020000u; +} +void LayerParameter::clear_has_convolution_param() { + _has_bits_[0] &= ~0x00020000u; +} +void LayerParameter::clear_convolution_param() { + if (convolution_param_ != NULL) convolution_param_->::caffe::ConvolutionParameter::Clear(); + clear_has_convolution_param(); +} +const ::caffe::ConvolutionParameter& LayerParameter::convolution_param() const { + // @@protoc_insertion_point(field_get:caffe.LayerParameter.convolution_param) + return convolution_param_ != NULL ? *convolution_param_ + : *::caffe::ConvolutionParameter::internal_default_instance(); +} +::caffe::ConvolutionParameter* LayerParameter::mutable_convolution_param() { + set_has_convolution_param(); + if (convolution_param_ == NULL) { + convolution_param_ = new ::caffe::ConvolutionParameter; + } + // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.convolution_param) + return convolution_param_; +} +::caffe::ConvolutionParameter* LayerParameter::release_convolution_param() { + // @@protoc_insertion_point(field_release:caffe.LayerParameter.convolution_param) + clear_has_convolution_param(); + ::caffe::ConvolutionParameter* temp = convolution_param_; + convolution_param_ = NULL; + return temp; +} +void LayerParameter::set_allocated_convolution_param(::caffe::ConvolutionParameter* convolution_param) { + delete convolution_param_; + convolution_param_ = convolution_param; + if (convolution_param) { + set_has_convolution_param(); + } else { + clear_has_convolution_param(); + } + // @@protoc_insertion_point(field_set_allocated:caffe.LayerParameter.convolution_param) +} - // optional .caffe.PowerParameter power_param = 122; - if (has_power_param()) { - total_size += 2 + - ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( - this->power_param()); - } +// optional .caffe.CropParameter crop_param = 137; +bool LayerParameter::has_crop_param() const { + return (_has_bits_[0] & 0x00040000u) != 0; +} +void LayerParameter::set_has_crop_param() { + _has_bits_[0] |= 0x00040000u; +} +void LayerParameter::clear_has_crop_param() { + _has_bits_[0] &= ~0x00040000u; +} +void LayerParameter::clear_crop_param() { + if (crop_param_ != NULL) crop_param_->::caffe::CropParameter::Clear(); + clear_has_crop_param(); +} +const ::caffe::CropParameter& LayerParameter::crop_param() const { + // @@protoc_insertion_point(field_get:caffe.LayerParameter.crop_param) + return crop_param_ != NULL ? *crop_param_ + : *::caffe::CropParameter::internal_default_instance(); +} +::caffe::CropParameter* LayerParameter::mutable_crop_param() { + set_has_crop_param(); + if (crop_param_ == NULL) { + crop_param_ = new ::caffe::CropParameter; + } + // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.crop_param) + return crop_param_; +} +::caffe::CropParameter* LayerParameter::release_crop_param() { + // @@protoc_insertion_point(field_release:caffe.LayerParameter.crop_param) + clear_has_crop_param(); + ::caffe::CropParameter* temp = crop_param_; + crop_param_ = NULL; + return temp; +} +void LayerParameter::set_allocated_crop_param(::caffe::CropParameter* crop_param) { + delete crop_param_; + crop_param_ = crop_param; + if (crop_param) { + set_has_crop_param(); + } else { + clear_has_crop_param(); + } + // @@protoc_insertion_point(field_set_allocated:caffe.LayerParameter.crop_param) +} +// optional .caffe.DataParameter data_param = 107; +bool LayerParameter::has_data_param() const { + return (_has_bits_[0] & 0x00080000u) != 0; +} +void LayerParameter::set_has_data_param() { + _has_bits_[0] |= 0x00080000u; +} +void LayerParameter::clear_has_data_param() { + _has_bits_[0] &= ~0x00080000u; +} +void LayerParameter::clear_data_param() { + if (data_param_ != NULL) data_param_->::caffe::DataParameter::Clear(); + clear_has_data_param(); +} +const ::caffe::DataParameter& LayerParameter::data_param() const { + // @@protoc_insertion_point(field_get:caffe.LayerParameter.data_param) + return data_param_ != NULL ? *data_param_ + : *::caffe::DataParameter::internal_default_instance(); +} +::caffe::DataParameter* LayerParameter::mutable_data_param() { + set_has_data_param(); + if (data_param_ == NULL) { + data_param_ = new ::caffe::DataParameter; } - if (_has_bits_[40 / 32] & (0xffu << (40 % 32))) { - // optional .caffe.PReLUParameter prelu_param = 131; - if (has_prelu_param()) { - total_size += 2 + - ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( - this->prelu_param()); - } + // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.data_param) + return data_param_; +} +::caffe::DataParameter* LayerParameter::release_data_param() { + // @@protoc_insertion_point(field_release:caffe.LayerParameter.data_param) + clear_has_data_param(); + ::caffe::DataParameter* temp = data_param_; + data_param_ = NULL; + return temp; +} +void LayerParameter::set_allocated_data_param(::caffe::DataParameter* data_param) { + delete data_param_; + data_param_ = data_param; + if (data_param) { + set_has_data_param(); + } else { + clear_has_data_param(); + } + // @@protoc_insertion_point(field_set_allocated:caffe.LayerParameter.data_param) +} - // optional .caffe.PriorBoxParameter prior_box_param = 140; - if (has_prior_box_param()) { - total_size += 2 + - ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( - this->prior_box_param()); - } +// optional .caffe.DetectionOutputParameter detection_output_param = 141; +bool LayerParameter::has_detection_output_param() const { + return (_has_bits_[0] & 0x00100000u) != 0; +} +void LayerParameter::set_has_detection_output_param() { + _has_bits_[0] |= 0x00100000u; +} +void LayerParameter::clear_has_detection_output_param() { + _has_bits_[0] &= ~0x00100000u; +} +void LayerParameter::clear_detection_output_param() { + if (detection_output_param_ != NULL) detection_output_param_->::caffe::DetectionOutputParameter::Clear(); + clear_has_detection_output_param(); +} +const ::caffe::DetectionOutputParameter& LayerParameter::detection_output_param() const { + // @@protoc_insertion_point(field_get:caffe.LayerParameter.detection_output_param) + return detection_output_param_ != NULL ? *detection_output_param_ + : *::caffe::DetectionOutputParameter::internal_default_instance(); +} +::caffe::DetectionOutputParameter* LayerParameter::mutable_detection_output_param() { + set_has_detection_output_param(); + if (detection_output_param_ == NULL) { + detection_output_param_ = new ::caffe::DetectionOutputParameter; + } + // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.detection_output_param) + return detection_output_param_; +} +::caffe::DetectionOutputParameter* LayerParameter::release_detection_output_param() { + // @@protoc_insertion_point(field_release:caffe.LayerParameter.detection_output_param) + clear_has_detection_output_param(); + ::caffe::DetectionOutputParameter* temp = detection_output_param_; + detection_output_param_ = NULL; + return temp; +} +void LayerParameter::set_allocated_detection_output_param(::caffe::DetectionOutputParameter* detection_output_param) { + delete detection_output_param_; + detection_output_param_ = detection_output_param; + if (detection_output_param) { + set_has_detection_output_param(); + } else { + clear_has_detection_output_param(); + } + // @@protoc_insertion_point(field_set_allocated:caffe.LayerParameter.detection_output_param) +} - // optional .caffe.PythonParameter python_param = 130; - if (has_python_param()) { - total_size += 2 + - ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( - this->python_param()); - } +// optional .caffe.DropoutParameter dropout_param = 108; +bool LayerParameter::has_dropout_param() const { + return (_has_bits_[0] & 0x00200000u) != 0; +} +void LayerParameter::set_has_dropout_param() { + _has_bits_[0] |= 0x00200000u; +} +void LayerParameter::clear_has_dropout_param() { + _has_bits_[0] &= ~0x00200000u; +} +void LayerParameter::clear_dropout_param() { + if (dropout_param_ != NULL) dropout_param_->::caffe::DropoutParameter::Clear(); + clear_has_dropout_param(); +} +const ::caffe::DropoutParameter& LayerParameter::dropout_param() const { + // @@protoc_insertion_point(field_get:caffe.LayerParameter.dropout_param) + return dropout_param_ != NULL ? *dropout_param_ + : *::caffe::DropoutParameter::internal_default_instance(); +} +::caffe::DropoutParameter* LayerParameter::mutable_dropout_param() { + set_has_dropout_param(); + if (dropout_param_ == NULL) { + dropout_param_ = new ::caffe::DropoutParameter; + } + // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.dropout_param) + return dropout_param_; +} +::caffe::DropoutParameter* LayerParameter::release_dropout_param() { + // @@protoc_insertion_point(field_release:caffe.LayerParameter.dropout_param) + clear_has_dropout_param(); + ::caffe::DropoutParameter* temp = dropout_param_; + dropout_param_ = NULL; + return temp; +} +void LayerParameter::set_allocated_dropout_param(::caffe::DropoutParameter* dropout_param) { + delete dropout_param_; + dropout_param_ = dropout_param; + if (dropout_param) { + set_has_dropout_param(); + } else { + clear_has_dropout_param(); + } + // @@protoc_insertion_point(field_set_allocated:caffe.LayerParameter.dropout_param) +} - // optional .caffe.ReductionParameter reduction_param = 136; - if (has_reduction_param()) { - total_size += 2 + - ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( - this->reduction_param()); - } +// optional .caffe.DummyDataParameter dummy_data_param = 109; +bool LayerParameter::has_dummy_data_param() const { + return (_has_bits_[0] & 0x00400000u) != 0; +} +void LayerParameter::set_has_dummy_data_param() { + _has_bits_[0] |= 0x00400000u; +} +void LayerParameter::clear_has_dummy_data_param() { + _has_bits_[0] &= ~0x00400000u; +} +void LayerParameter::clear_dummy_data_param() { + if (dummy_data_param_ != NULL) dummy_data_param_->::caffe::DummyDataParameter::Clear(); + clear_has_dummy_data_param(); +} +const ::caffe::DummyDataParameter& LayerParameter::dummy_data_param() const { + // @@protoc_insertion_point(field_get:caffe.LayerParameter.dummy_data_param) + return dummy_data_param_ != NULL ? *dummy_data_param_ + : *::caffe::DummyDataParameter::internal_default_instance(); +} +::caffe::DummyDataParameter* LayerParameter::mutable_dummy_data_param() { + set_has_dummy_data_param(); + if (dummy_data_param_ == NULL) { + dummy_data_param_ = new ::caffe::DummyDataParameter; + } + // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.dummy_data_param) + return dummy_data_param_; +} +::caffe::DummyDataParameter* LayerParameter::release_dummy_data_param() { + // @@protoc_insertion_point(field_release:caffe.LayerParameter.dummy_data_param) + clear_has_dummy_data_param(); + ::caffe::DummyDataParameter* temp = dummy_data_param_; + dummy_data_param_ = NULL; + return temp; +} +void LayerParameter::set_allocated_dummy_data_param(::caffe::DummyDataParameter* dummy_data_param) { + delete dummy_data_param_; + dummy_data_param_ = dummy_data_param; + if (dummy_data_param) { + set_has_dummy_data_param(); + } else { + clear_has_dummy_data_param(); + } + // @@protoc_insertion_point(field_set_allocated:caffe.LayerParameter.dummy_data_param) +} - // optional .caffe.ReLUParameter relu_param = 123; - if (has_relu_param()) { - total_size += 2 + - ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( - this->relu_param()); - } +// optional .caffe.EltwiseParameter eltwise_param = 110; +bool LayerParameter::has_eltwise_param() const { + return (_has_bits_[0] & 0x00800000u) != 0; +} +void LayerParameter::set_has_eltwise_param() { + _has_bits_[0] |= 0x00800000u; +} +void LayerParameter::clear_has_eltwise_param() { + _has_bits_[0] &= ~0x00800000u; +} +void LayerParameter::clear_eltwise_param() { + if (eltwise_param_ != NULL) eltwise_param_->::caffe::EltwiseParameter::Clear(); + clear_has_eltwise_param(); +} +const ::caffe::EltwiseParameter& LayerParameter::eltwise_param() const { + // @@protoc_insertion_point(field_get:caffe.LayerParameter.eltwise_param) + return eltwise_param_ != NULL ? *eltwise_param_ + : *::caffe::EltwiseParameter::internal_default_instance(); +} +::caffe::EltwiseParameter* LayerParameter::mutable_eltwise_param() { + set_has_eltwise_param(); + if (eltwise_param_ == NULL) { + eltwise_param_ = new ::caffe::EltwiseParameter; + } + // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.eltwise_param) + return eltwise_param_; +} +::caffe::EltwiseParameter* LayerParameter::release_eltwise_param() { + // @@protoc_insertion_point(field_release:caffe.LayerParameter.eltwise_param) + clear_has_eltwise_param(); + ::caffe::EltwiseParameter* temp = eltwise_param_; + eltwise_param_ = NULL; + return temp; +} +void LayerParameter::set_allocated_eltwise_param(::caffe::EltwiseParameter* eltwise_param) { + delete eltwise_param_; + eltwise_param_ = eltwise_param; + if (eltwise_param) { + set_has_eltwise_param(); + } else { + clear_has_eltwise_param(); + } + // @@protoc_insertion_point(field_set_allocated:caffe.LayerParameter.eltwise_param) +} - // optional .caffe.ReshapeParameter reshape_param = 133; - if (has_reshape_param()) { - total_size += 2 + - ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( - this->reshape_param()); - } +// optional .caffe.ExpParameter exp_param = 111; +bool LayerParameter::has_exp_param() const { + return (_has_bits_[0] & 0x01000000u) != 0; +} +void LayerParameter::set_has_exp_param() { + _has_bits_[0] |= 0x01000000u; +} +void LayerParameter::clear_has_exp_param() { + _has_bits_[0] &= ~0x01000000u; +} +void LayerParameter::clear_exp_param() { + if (exp_param_ != NULL) exp_param_->::caffe::ExpParameter::Clear(); + clear_has_exp_param(); +} +const ::caffe::ExpParameter& LayerParameter::exp_param() const { + // @@protoc_insertion_point(field_get:caffe.LayerParameter.exp_param) + return exp_param_ != NULL ? *exp_param_ + : *::caffe::ExpParameter::internal_default_instance(); +} +::caffe::ExpParameter* LayerParameter::mutable_exp_param() { + set_has_exp_param(); + if (exp_param_ == NULL) { + exp_param_ = new ::caffe::ExpParameter; + } + // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.exp_param) + return exp_param_; +} +::caffe::ExpParameter* LayerParameter::release_exp_param() { + // @@protoc_insertion_point(field_release:caffe.LayerParameter.exp_param) + clear_has_exp_param(); + ::caffe::ExpParameter* temp = exp_param_; + exp_param_ = NULL; + return temp; +} +void LayerParameter::set_allocated_exp_param(::caffe::ExpParameter* exp_param) { + delete exp_param_; + exp_param_ = exp_param; + if (exp_param) { + set_has_exp_param(); + } else { + clear_has_exp_param(); + } + // @@protoc_insertion_point(field_set_allocated:caffe.LayerParameter.exp_param) +} - // optional .caffe.SigmoidParameter sigmoid_param = 124; - if (has_sigmoid_param()) { - total_size += 2 + - ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( - this->sigmoid_param()); - } +// optional .caffe.FlattenParameter flatten_param = 135; +bool LayerParameter::has_flatten_param() const { + return (_has_bits_[0] & 0x02000000u) != 0; +} +void LayerParameter::set_has_flatten_param() { + _has_bits_[0] |= 0x02000000u; +} +void LayerParameter::clear_has_flatten_param() { + _has_bits_[0] &= ~0x02000000u; +} +void LayerParameter::clear_flatten_param() { + if (flatten_param_ != NULL) flatten_param_->::caffe::FlattenParameter::Clear(); + clear_has_flatten_param(); +} +const ::caffe::FlattenParameter& LayerParameter::flatten_param() const { + // @@protoc_insertion_point(field_get:caffe.LayerParameter.flatten_param) + return flatten_param_ != NULL ? *flatten_param_ + : *::caffe::FlattenParameter::internal_default_instance(); +} +::caffe::FlattenParameter* LayerParameter::mutable_flatten_param() { + set_has_flatten_param(); + if (flatten_param_ == NULL) { + flatten_param_ = new ::caffe::FlattenParameter; + } + // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.flatten_param) + return flatten_param_; +} +::caffe::FlattenParameter* LayerParameter::release_flatten_param() { + // @@protoc_insertion_point(field_release:caffe.LayerParameter.flatten_param) + clear_has_flatten_param(); + ::caffe::FlattenParameter* temp = flatten_param_; + flatten_param_ = NULL; + return temp; +} +void LayerParameter::set_allocated_flatten_param(::caffe::FlattenParameter* flatten_param) { + delete flatten_param_; + flatten_param_ = flatten_param; + if (flatten_param) { + set_has_flatten_param(); + } else { + clear_has_flatten_param(); + } + // @@protoc_insertion_point(field_set_allocated:caffe.LayerParameter.flatten_param) +} - // optional .caffe.SliceParameter slice_param = 126; - if (has_slice_param()) { - total_size += 2 + - ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( - this->slice_param()); - } +// optional .caffe.HDF5DataParameter hdf5_data_param = 112; +bool LayerParameter::has_hdf5_data_param() const { + return (_has_bits_[0] & 0x04000000u) != 0; +} +void LayerParameter::set_has_hdf5_data_param() { + _has_bits_[0] |= 0x04000000u; +} +void LayerParameter::clear_has_hdf5_data_param() { + _has_bits_[0] &= ~0x04000000u; +} +void LayerParameter::clear_hdf5_data_param() { + if (hdf5_data_param_ != NULL) hdf5_data_param_->::caffe::HDF5DataParameter::Clear(); + clear_has_hdf5_data_param(); +} +const ::caffe::HDF5DataParameter& LayerParameter::hdf5_data_param() const { + // @@protoc_insertion_point(field_get:caffe.LayerParameter.hdf5_data_param) + return hdf5_data_param_ != NULL ? *hdf5_data_param_ + : *::caffe::HDF5DataParameter::internal_default_instance(); +} +::caffe::HDF5DataParameter* LayerParameter::mutable_hdf5_data_param() { + set_has_hdf5_data_param(); + if (hdf5_data_param_ == NULL) { + hdf5_data_param_ = new ::caffe::HDF5DataParameter; + } + // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.hdf5_data_param) + return hdf5_data_param_; +} +::caffe::HDF5DataParameter* LayerParameter::release_hdf5_data_param() { + // @@protoc_insertion_point(field_release:caffe.LayerParameter.hdf5_data_param) + clear_has_hdf5_data_param(); + ::caffe::HDF5DataParameter* temp = hdf5_data_param_; + hdf5_data_param_ = NULL; + return temp; +} +void LayerParameter::set_allocated_hdf5_data_param(::caffe::HDF5DataParameter* hdf5_data_param) { + delete hdf5_data_param_; + hdf5_data_param_ = hdf5_data_param; + if (hdf5_data_param) { + set_has_hdf5_data_param(); + } else { + clear_has_hdf5_data_param(); + } + // @@protoc_insertion_point(field_set_allocated:caffe.LayerParameter.hdf5_data_param) +} +// optional .caffe.HDF5OutputParameter hdf5_output_param = 113; +bool LayerParameter::has_hdf5_output_param() const { + return (_has_bits_[0] & 0x08000000u) != 0; +} +void LayerParameter::set_has_hdf5_output_param() { + _has_bits_[0] |= 0x08000000u; +} +void LayerParameter::clear_has_hdf5_output_param() { + _has_bits_[0] &= ~0x08000000u; +} +void LayerParameter::clear_hdf5_output_param() { + if (hdf5_output_param_ != NULL) hdf5_output_param_->::caffe::HDF5OutputParameter::Clear(); + clear_has_hdf5_output_param(); +} +const ::caffe::HDF5OutputParameter& LayerParameter::hdf5_output_param() const { + // @@protoc_insertion_point(field_get:caffe.LayerParameter.hdf5_output_param) + return hdf5_output_param_ != NULL ? *hdf5_output_param_ + : *::caffe::HDF5OutputParameter::internal_default_instance(); +} +::caffe::HDF5OutputParameter* LayerParameter::mutable_hdf5_output_param() { + set_has_hdf5_output_param(); + if (hdf5_output_param_ == NULL) { + hdf5_output_param_ = new ::caffe::HDF5OutputParameter; } - if (_has_bits_[48 / 32] & (0xffu << (48 % 32))) { - // optional .caffe.SoftmaxParameter softmax_param = 125; - if (has_softmax_param()) { - total_size += 2 + - ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( - this->softmax_param()); - } + // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.hdf5_output_param) + return hdf5_output_param_; +} +::caffe::HDF5OutputParameter* LayerParameter::release_hdf5_output_param() { + // @@protoc_insertion_point(field_release:caffe.LayerParameter.hdf5_output_param) + clear_has_hdf5_output_param(); + ::caffe::HDF5OutputParameter* temp = hdf5_output_param_; + hdf5_output_param_ = NULL; + return temp; +} +void LayerParameter::set_allocated_hdf5_output_param(::caffe::HDF5OutputParameter* hdf5_output_param) { + delete hdf5_output_param_; + hdf5_output_param_ = hdf5_output_param; + if (hdf5_output_param) { + set_has_hdf5_output_param(); + } else { + clear_has_hdf5_output_param(); + } + // @@protoc_insertion_point(field_set_allocated:caffe.LayerParameter.hdf5_output_param) +} - // optional .caffe.SPPParameter spp_param = 132; - if (has_spp_param()) { - total_size += 2 + - ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( - this->spp_param()); - } +// optional .caffe.HingeLossParameter hinge_loss_param = 114; +bool LayerParameter::has_hinge_loss_param() const { + return (_has_bits_[0] & 0x10000000u) != 0; +} +void LayerParameter::set_has_hinge_loss_param() { + _has_bits_[0] |= 0x10000000u; +} +void LayerParameter::clear_has_hinge_loss_param() { + _has_bits_[0] &= ~0x10000000u; +} +void LayerParameter::clear_hinge_loss_param() { + if (hinge_loss_param_ != NULL) hinge_loss_param_->::caffe::HingeLossParameter::Clear(); + clear_has_hinge_loss_param(); +} +const ::caffe::HingeLossParameter& LayerParameter::hinge_loss_param() const { + // @@protoc_insertion_point(field_get:caffe.LayerParameter.hinge_loss_param) + return hinge_loss_param_ != NULL ? *hinge_loss_param_ + : *::caffe::HingeLossParameter::internal_default_instance(); +} +::caffe::HingeLossParameter* LayerParameter::mutable_hinge_loss_param() { + set_has_hinge_loss_param(); + if (hinge_loss_param_ == NULL) { + hinge_loss_param_ = new ::caffe::HingeLossParameter; + } + // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.hinge_loss_param) + return hinge_loss_param_; +} +::caffe::HingeLossParameter* LayerParameter::release_hinge_loss_param() { + // @@protoc_insertion_point(field_release:caffe.LayerParameter.hinge_loss_param) + clear_has_hinge_loss_param(); + ::caffe::HingeLossParameter* temp = hinge_loss_param_; + hinge_loss_param_ = NULL; + return temp; +} +void LayerParameter::set_allocated_hinge_loss_param(::caffe::HingeLossParameter* hinge_loss_param) { + delete hinge_loss_param_; + hinge_loss_param_ = hinge_loss_param; + if (hinge_loss_param) { + set_has_hinge_loss_param(); + } else { + clear_has_hinge_loss_param(); + } + // @@protoc_insertion_point(field_set_allocated:caffe.LayerParameter.hinge_loss_param) +} - // optional .caffe.TanHParameter tanh_param = 127; - if (has_tanh_param()) { - total_size += 2 + - ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( - this->tanh_param()); - } +// optional .caffe.ImageDataParameter image_data_param = 115; +bool LayerParameter::has_image_data_param() const { + return (_has_bits_[0] & 0x20000000u) != 0; +} +void LayerParameter::set_has_image_data_param() { + _has_bits_[0] |= 0x20000000u; +} +void LayerParameter::clear_has_image_data_param() { + _has_bits_[0] &= ~0x20000000u; +} +void LayerParameter::clear_image_data_param() { + if (image_data_param_ != NULL) image_data_param_->::caffe::ImageDataParameter::Clear(); + clear_has_image_data_param(); +} +const ::caffe::ImageDataParameter& LayerParameter::image_data_param() const { + // @@protoc_insertion_point(field_get:caffe.LayerParameter.image_data_param) + return image_data_param_ != NULL ? *image_data_param_ + : *::caffe::ImageDataParameter::internal_default_instance(); +} +::caffe::ImageDataParameter* LayerParameter::mutable_image_data_param() { + set_has_image_data_param(); + if (image_data_param_ == NULL) { + image_data_param_ = new ::caffe::ImageDataParameter; + } + // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.image_data_param) + return image_data_param_; +} +::caffe::ImageDataParameter* LayerParameter::release_image_data_param() { + // @@protoc_insertion_point(field_release:caffe.LayerParameter.image_data_param) + clear_has_image_data_param(); + ::caffe::ImageDataParameter* temp = image_data_param_; + image_data_param_ = NULL; + return temp; +} +void LayerParameter::set_allocated_image_data_param(::caffe::ImageDataParameter* image_data_param) { + delete image_data_param_; + image_data_param_ = image_data_param; + if (image_data_param) { + set_has_image_data_param(); + } else { + clear_has_image_data_param(); + } + // @@protoc_insertion_point(field_set_allocated:caffe.LayerParameter.image_data_param) +} - // optional .caffe.ThresholdParameter threshold_param = 128; - if (has_threshold_param()) { - total_size += 2 + - ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( - this->threshold_param()); - } +// optional .caffe.InfogainLossParameter infogain_loss_param = 116; +bool LayerParameter::has_infogain_loss_param() const { + return (_has_bits_[0] & 0x40000000u) != 0; +} +void LayerParameter::set_has_infogain_loss_param() { + _has_bits_[0] |= 0x40000000u; +} +void LayerParameter::clear_has_infogain_loss_param() { + _has_bits_[0] &= ~0x40000000u; +} +void LayerParameter::clear_infogain_loss_param() { + if (infogain_loss_param_ != NULL) infogain_loss_param_->::caffe::InfogainLossParameter::Clear(); + clear_has_infogain_loss_param(); +} +const ::caffe::InfogainLossParameter& LayerParameter::infogain_loss_param() const { + // @@protoc_insertion_point(field_get:caffe.LayerParameter.infogain_loss_param) + return infogain_loss_param_ != NULL ? *infogain_loss_param_ + : *::caffe::InfogainLossParameter::internal_default_instance(); +} +::caffe::InfogainLossParameter* LayerParameter::mutable_infogain_loss_param() { + set_has_infogain_loss_param(); + if (infogain_loss_param_ == NULL) { + infogain_loss_param_ = new ::caffe::InfogainLossParameter; + } + // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.infogain_loss_param) + return infogain_loss_param_; +} +::caffe::InfogainLossParameter* LayerParameter::release_infogain_loss_param() { + // @@protoc_insertion_point(field_release:caffe.LayerParameter.infogain_loss_param) + clear_has_infogain_loss_param(); + ::caffe::InfogainLossParameter* temp = infogain_loss_param_; + infogain_loss_param_ = NULL; + return temp; +} +void LayerParameter::set_allocated_infogain_loss_param(::caffe::InfogainLossParameter* infogain_loss_param) { + delete infogain_loss_param_; + infogain_loss_param_ = infogain_loss_param; + if (infogain_loss_param) { + set_has_infogain_loss_param(); + } else { + clear_has_infogain_loss_param(); + } + // @@protoc_insertion_point(field_set_allocated:caffe.LayerParameter.infogain_loss_param) +} - // optional .caffe.WindowDataParameter window_data_param = 129; - if (has_window_data_param()) { - total_size += 2 + - ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( - this->window_data_param()); - } +// optional .caffe.InnerProductParameter inner_product_param = 117; +bool LayerParameter::has_inner_product_param() const { + return (_has_bits_[0] & 0x80000000u) != 0; +} +void LayerParameter::set_has_inner_product_param() { + _has_bits_[0] |= 0x80000000u; +} +void LayerParameter::clear_has_inner_product_param() { + _has_bits_[0] &= ~0x80000000u; +} +void LayerParameter::clear_inner_product_param() { + if (inner_product_param_ != NULL) inner_product_param_->::caffe::InnerProductParameter::Clear(); + clear_has_inner_product_param(); +} +const ::caffe::InnerProductParameter& LayerParameter::inner_product_param() const { + // @@protoc_insertion_point(field_get:caffe.LayerParameter.inner_product_param) + return inner_product_param_ != NULL ? *inner_product_param_ + : *::caffe::InnerProductParameter::internal_default_instance(); +} +::caffe::InnerProductParameter* LayerParameter::mutable_inner_product_param() { + set_has_inner_product_param(); + if (inner_product_param_ == NULL) { + inner_product_param_ = new ::caffe::InnerProductParameter; + } + // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.inner_product_param) + return inner_product_param_; +} +::caffe::InnerProductParameter* LayerParameter::release_inner_product_param() { + // @@protoc_insertion_point(field_release:caffe.LayerParameter.inner_product_param) + clear_has_inner_product_param(); + ::caffe::InnerProductParameter* temp = inner_product_param_; + inner_product_param_ = NULL; + return temp; +} +void LayerParameter::set_allocated_inner_product_param(::caffe::InnerProductParameter* inner_product_param) { + delete inner_product_param_; + inner_product_param_ = inner_product_param; + if (inner_product_param) { + set_has_inner_product_param(); + } else { + clear_has_inner_product_param(); + } + // @@protoc_insertion_point(field_set_allocated:caffe.LayerParameter.inner_product_param) +} +// optional .caffe.LogParameter log_param = 134; +bool LayerParameter::has_log_param() const { + return (_has_bits_[1] & 0x00000001u) != 0; +} +void LayerParameter::set_has_log_param() { + _has_bits_[1] |= 0x00000001u; +} +void LayerParameter::clear_has_log_param() { + _has_bits_[1] &= ~0x00000001u; +} +void LayerParameter::clear_log_param() { + if (log_param_ != NULL) log_param_->::caffe::LogParameter::Clear(); + clear_has_log_param(); +} +const ::caffe::LogParameter& LayerParameter::log_param() const { + // @@protoc_insertion_point(field_get:caffe.LayerParameter.log_param) + return log_param_ != NULL ? *log_param_ + : *::caffe::LogParameter::internal_default_instance(); +} +::caffe::LogParameter* LayerParameter::mutable_log_param() { + set_has_log_param(); + if (log_param_ == NULL) { + log_param_ = new ::caffe::LogParameter; } - // repeated string bottom = 3; - total_size += 1 * this->bottom_size(); - for (int i = 0; i < this->bottom_size(); i++) { - total_size += ::google::protobuf::internal::WireFormatLite::StringSize( - this->bottom(i)); + // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.log_param) + return log_param_; +} +::caffe::LogParameter* LayerParameter::release_log_param() { + // @@protoc_insertion_point(field_release:caffe.LayerParameter.log_param) + clear_has_log_param(); + ::caffe::LogParameter* temp = log_param_; + log_param_ = NULL; + return temp; +} +void LayerParameter::set_allocated_log_param(::caffe::LogParameter* log_param) { + delete log_param_; + log_param_ = log_param; + if (log_param) { + set_has_log_param(); + } else { + clear_has_log_param(); } + // @@protoc_insertion_point(field_set_allocated:caffe.LayerParameter.log_param) +} - // repeated string top = 4; - total_size += 1 * this->top_size(); - for (int i = 0; i < this->top_size(); i++) { - total_size += ::google::protobuf::internal::WireFormatLite::StringSize( - this->top(i)); +// optional .caffe.LRNParameter lrn_param = 118; +bool LayerParameter::has_lrn_param() const { + return (_has_bits_[1] & 0x00000002u) != 0; +} +void LayerParameter::set_has_lrn_param() { + _has_bits_[1] |= 0x00000002u; +} +void LayerParameter::clear_has_lrn_param() { + _has_bits_[1] &= ~0x00000002u; +} +void LayerParameter::clear_lrn_param() { + if (lrn_param_ != NULL) lrn_param_->::caffe::LRNParameter::Clear(); + clear_has_lrn_param(); +} +const ::caffe::LRNParameter& LayerParameter::lrn_param() const { + // @@protoc_insertion_point(field_get:caffe.LayerParameter.lrn_param) + return lrn_param_ != NULL ? *lrn_param_ + : *::caffe::LRNParameter::internal_default_instance(); +} +::caffe::LRNParameter* LayerParameter::mutable_lrn_param() { + set_has_lrn_param(); + if (lrn_param_ == NULL) { + lrn_param_ = new ::caffe::LRNParameter; + } + // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.lrn_param) + return lrn_param_; +} +::caffe::LRNParameter* LayerParameter::release_lrn_param() { + // @@protoc_insertion_point(field_release:caffe.LayerParameter.lrn_param) + clear_has_lrn_param(); + ::caffe::LRNParameter* temp = lrn_param_; + lrn_param_ = NULL; + return temp; +} +void LayerParameter::set_allocated_lrn_param(::caffe::LRNParameter* lrn_param) { + delete lrn_param_; + lrn_param_ = lrn_param; + if (lrn_param) { + set_has_lrn_param(); + } else { + clear_has_lrn_param(); } + // @@protoc_insertion_point(field_set_allocated:caffe.LayerParameter.lrn_param) +} - // repeated float loss_weight = 5; - { - int data_size = 0; - data_size = 4 * this->loss_weight_size(); - total_size += 1 * this->loss_weight_size() + data_size; +// optional .caffe.MemoryDataParameter memory_data_param = 119; +bool LayerParameter::has_memory_data_param() const { + return (_has_bits_[1] & 0x00000004u) != 0; +} +void LayerParameter::set_has_memory_data_param() { + _has_bits_[1] |= 0x00000004u; +} +void LayerParameter::clear_has_memory_data_param() { + _has_bits_[1] &= ~0x00000004u; +} +void LayerParameter::clear_memory_data_param() { + if (memory_data_param_ != NULL) memory_data_param_->::caffe::MemoryDataParameter::Clear(); + clear_has_memory_data_param(); +} +const ::caffe::MemoryDataParameter& LayerParameter::memory_data_param() const { + // @@protoc_insertion_point(field_get:caffe.LayerParameter.memory_data_param) + return memory_data_param_ != NULL ? *memory_data_param_ + : *::caffe::MemoryDataParameter::internal_default_instance(); +} +::caffe::MemoryDataParameter* LayerParameter::mutable_memory_data_param() { + set_has_memory_data_param(); + if (memory_data_param_ == NULL) { + memory_data_param_ = new ::caffe::MemoryDataParameter; + } + // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.memory_data_param) + return memory_data_param_; +} +::caffe::MemoryDataParameter* LayerParameter::release_memory_data_param() { + // @@protoc_insertion_point(field_release:caffe.LayerParameter.memory_data_param) + clear_has_memory_data_param(); + ::caffe::MemoryDataParameter* temp = memory_data_param_; + memory_data_param_ = NULL; + return temp; +} +void LayerParameter::set_allocated_memory_data_param(::caffe::MemoryDataParameter* memory_data_param) { + delete memory_data_param_; + memory_data_param_ = memory_data_param; + if (memory_data_param) { + set_has_memory_data_param(); + } else { + clear_has_memory_data_param(); } + // @@protoc_insertion_point(field_set_allocated:caffe.LayerParameter.memory_data_param) +} - // repeated .caffe.ParamSpec param = 6; - total_size += 1 * this->param_size(); - for (int i = 0; i < this->param_size(); i++) { - total_size += - ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( - this->param(i)); +// optional .caffe.MVNParameter mvn_param = 120; +bool LayerParameter::has_mvn_param() const { + return (_has_bits_[1] & 0x00000008u) != 0; +} +void LayerParameter::set_has_mvn_param() { + _has_bits_[1] |= 0x00000008u; +} +void LayerParameter::clear_has_mvn_param() { + _has_bits_[1] &= ~0x00000008u; +} +void LayerParameter::clear_mvn_param() { + if (mvn_param_ != NULL) mvn_param_->::caffe::MVNParameter::Clear(); + clear_has_mvn_param(); +} +const ::caffe::MVNParameter& LayerParameter::mvn_param() const { + // @@protoc_insertion_point(field_get:caffe.LayerParameter.mvn_param) + return mvn_param_ != NULL ? *mvn_param_ + : *::caffe::MVNParameter::internal_default_instance(); +} +::caffe::MVNParameter* LayerParameter::mutable_mvn_param() { + set_has_mvn_param(); + if (mvn_param_ == NULL) { + mvn_param_ = new ::caffe::MVNParameter; } + // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.mvn_param) + return mvn_param_; +} +::caffe::MVNParameter* LayerParameter::release_mvn_param() { + // @@protoc_insertion_point(field_release:caffe.LayerParameter.mvn_param) + clear_has_mvn_param(); + ::caffe::MVNParameter* temp = mvn_param_; + mvn_param_ = NULL; + return temp; +} +void LayerParameter::set_allocated_mvn_param(::caffe::MVNParameter* mvn_param) { + delete mvn_param_; + mvn_param_ = mvn_param; + if (mvn_param) { + set_has_mvn_param(); + } else { + clear_has_mvn_param(); + } + // @@protoc_insertion_point(field_set_allocated:caffe.LayerParameter.mvn_param) +} - // repeated .caffe.BlobProto blobs = 7; - total_size += 1 * this->blobs_size(); - for (int i = 0; i < this->blobs_size(); i++) { - total_size += - ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( - this->blobs(i)); +// optional .caffe.NormalizeBBoxParameter normalize_bbox_param = 139; +bool LayerParameter::has_normalize_bbox_param() const { + return (_has_bits_[1] & 0x00000010u) != 0; +} +void LayerParameter::set_has_normalize_bbox_param() { + _has_bits_[1] |= 0x00000010u; +} +void LayerParameter::clear_has_normalize_bbox_param() { + _has_bits_[1] &= ~0x00000010u; +} +void LayerParameter::clear_normalize_bbox_param() { + if (normalize_bbox_param_ != NULL) normalize_bbox_param_->::caffe::NormalizeBBoxParameter::Clear(); + clear_has_normalize_bbox_param(); +} +const ::caffe::NormalizeBBoxParameter& LayerParameter::normalize_bbox_param() const { + // @@protoc_insertion_point(field_get:caffe.LayerParameter.normalize_bbox_param) + return normalize_bbox_param_ != NULL ? *normalize_bbox_param_ + : *::caffe::NormalizeBBoxParameter::internal_default_instance(); +} +::caffe::NormalizeBBoxParameter* LayerParameter::mutable_normalize_bbox_param() { + set_has_normalize_bbox_param(); + if (normalize_bbox_param_ == NULL) { + normalize_bbox_param_ = new ::caffe::NormalizeBBoxParameter; + } + // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.normalize_bbox_param) + return normalize_bbox_param_; +} +::caffe::NormalizeBBoxParameter* LayerParameter::release_normalize_bbox_param() { + // @@protoc_insertion_point(field_release:caffe.LayerParameter.normalize_bbox_param) + clear_has_normalize_bbox_param(); + ::caffe::NormalizeBBoxParameter* temp = normalize_bbox_param_; + normalize_bbox_param_ = NULL; + return temp; +} +void LayerParameter::set_allocated_normalize_bbox_param(::caffe::NormalizeBBoxParameter* normalize_bbox_param) { + delete normalize_bbox_param_; + normalize_bbox_param_ = normalize_bbox_param; + if (normalize_bbox_param) { + set_has_normalize_bbox_param(); + } else { + clear_has_normalize_bbox_param(); } + // @@protoc_insertion_point(field_set_allocated:caffe.LayerParameter.normalize_bbox_param) +} - // repeated bool propagate_down = 11; - { - int data_size = 0; - data_size = 1 * this->propagate_down_size(); - total_size += 1 * this->propagate_down_size() + data_size; +// optional .caffe.PermuteParameter permute_param = 138; +bool LayerParameter::has_permute_param() const { + return (_has_bits_[1] & 0x00000020u) != 0; +} +void LayerParameter::set_has_permute_param() { + _has_bits_[1] |= 0x00000020u; +} +void LayerParameter::clear_has_permute_param() { + _has_bits_[1] &= ~0x00000020u; +} +void LayerParameter::clear_permute_param() { + if (permute_param_ != NULL) permute_param_->::caffe::PermuteParameter::Clear(); + clear_has_permute_param(); +} +const ::caffe::PermuteParameter& LayerParameter::permute_param() const { + // @@protoc_insertion_point(field_get:caffe.LayerParameter.permute_param) + return permute_param_ != NULL ? *permute_param_ + : *::caffe::PermuteParameter::internal_default_instance(); +} +::caffe::PermuteParameter* LayerParameter::mutable_permute_param() { + set_has_permute_param(); + if (permute_param_ == NULL) { + permute_param_ = new ::caffe::PermuteParameter; + } + // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.permute_param) + return permute_param_; +} +::caffe::PermuteParameter* LayerParameter::release_permute_param() { + // @@protoc_insertion_point(field_release:caffe.LayerParameter.permute_param) + clear_has_permute_param(); + ::caffe::PermuteParameter* temp = permute_param_; + permute_param_ = NULL; + return temp; +} +void LayerParameter::set_allocated_permute_param(::caffe::PermuteParameter* permute_param) { + delete permute_param_; + permute_param_ = permute_param; + if (permute_param) { + set_has_permute_param(); + } else { + clear_has_permute_param(); } + // @@protoc_insertion_point(field_set_allocated:caffe.LayerParameter.permute_param) +} - // repeated .caffe.NetStateRule include = 8; - total_size += 1 * this->include_size(); - for (int i = 0; i < this->include_size(); i++) { - total_size += - ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( - this->include(i)); +// optional .caffe.PoolingParameter pooling_param = 121; +bool LayerParameter::has_pooling_param() const { + return (_has_bits_[1] & 0x00000040u) != 0; +} +void LayerParameter::set_has_pooling_param() { + _has_bits_[1] |= 0x00000040u; +} +void LayerParameter::clear_has_pooling_param() { + _has_bits_[1] &= ~0x00000040u; +} +void LayerParameter::clear_pooling_param() { + if (pooling_param_ != NULL) pooling_param_->::caffe::PoolingParameter::Clear(); + clear_has_pooling_param(); +} +const ::caffe::PoolingParameter& LayerParameter::pooling_param() const { + // @@protoc_insertion_point(field_get:caffe.LayerParameter.pooling_param) + return pooling_param_ != NULL ? *pooling_param_ + : *::caffe::PoolingParameter::internal_default_instance(); +} +::caffe::PoolingParameter* LayerParameter::mutable_pooling_param() { + set_has_pooling_param(); + if (pooling_param_ == NULL) { + pooling_param_ = new ::caffe::PoolingParameter; + } + // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.pooling_param) + return pooling_param_; +} +::caffe::PoolingParameter* LayerParameter::release_pooling_param() { + // @@protoc_insertion_point(field_release:caffe.LayerParameter.pooling_param) + clear_has_pooling_param(); + ::caffe::PoolingParameter* temp = pooling_param_; + pooling_param_ = NULL; + return temp; +} +void LayerParameter::set_allocated_pooling_param(::caffe::PoolingParameter* pooling_param) { + delete pooling_param_; + pooling_param_ = pooling_param; + if (pooling_param) { + set_has_pooling_param(); + } else { + clear_has_pooling_param(); } + // @@protoc_insertion_point(field_set_allocated:caffe.LayerParameter.pooling_param) +} - // repeated .caffe.NetStateRule exclude = 9; - total_size += 1 * this->exclude_size(); - for (int i = 0; i < this->exclude_size(); i++) { - total_size += - ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( - this->exclude(i)); +// optional .caffe.PowerParameter power_param = 122; +bool LayerParameter::has_power_param() const { + return (_has_bits_[1] & 0x00000080u) != 0; +} +void LayerParameter::set_has_power_param() { + _has_bits_[1] |= 0x00000080u; +} +void LayerParameter::clear_has_power_param() { + _has_bits_[1] &= ~0x00000080u; +} +void LayerParameter::clear_power_param() { + if (power_param_ != NULL) power_param_->::caffe::PowerParameter::Clear(); + clear_has_power_param(); +} +const ::caffe::PowerParameter& LayerParameter::power_param() const { + // @@protoc_insertion_point(field_get:caffe.LayerParameter.power_param) + return power_param_ != NULL ? *power_param_ + : *::caffe::PowerParameter::internal_default_instance(); +} +::caffe::PowerParameter* LayerParameter::mutable_power_param() { + set_has_power_param(); + if (power_param_ == NULL) { + power_param_ = new ::caffe::PowerParameter; + } + // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.power_param) + return power_param_; +} +::caffe::PowerParameter* LayerParameter::release_power_param() { + // @@protoc_insertion_point(field_release:caffe.LayerParameter.power_param) + clear_has_power_param(); + ::caffe::PowerParameter* temp = power_param_; + power_param_ = NULL; + return temp; +} +void LayerParameter::set_allocated_power_param(::caffe::PowerParameter* power_param) { + delete power_param_; + power_param_ = power_param; + if (power_param) { + set_has_power_param(); + } else { + clear_has_power_param(); } + // @@protoc_insertion_point(field_set_allocated:caffe.LayerParameter.power_param) +} - if (!unknown_fields().empty()) { - total_size += - ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( - unknown_fields()); +// optional .caffe.PReLUParameter prelu_param = 131; +bool LayerParameter::has_prelu_param() const { + return (_has_bits_[1] & 0x00000100u) != 0; +} +void LayerParameter::set_has_prelu_param() { + _has_bits_[1] |= 0x00000100u; +} +void LayerParameter::clear_has_prelu_param() { + _has_bits_[1] &= ~0x00000100u; +} +void LayerParameter::clear_prelu_param() { + if (prelu_param_ != NULL) prelu_param_->::caffe::PReLUParameter::Clear(); + clear_has_prelu_param(); +} +const ::caffe::PReLUParameter& LayerParameter::prelu_param() const { + // @@protoc_insertion_point(field_get:caffe.LayerParameter.prelu_param) + return prelu_param_ != NULL ? *prelu_param_ + : *::caffe::PReLUParameter::internal_default_instance(); +} +::caffe::PReLUParameter* LayerParameter::mutable_prelu_param() { + set_has_prelu_param(); + if (prelu_param_ == NULL) { + prelu_param_ = new ::caffe::PReLUParameter; } - GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); - _cached_size_ = total_size; - GOOGLE_SAFE_CONCURRENT_WRITES_END(); - return total_size; + // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.prelu_param) + return prelu_param_; +} +::caffe::PReLUParameter* LayerParameter::release_prelu_param() { + // @@protoc_insertion_point(field_release:caffe.LayerParameter.prelu_param) + clear_has_prelu_param(); + ::caffe::PReLUParameter* temp = prelu_param_; + prelu_param_ = NULL; + return temp; +} +void LayerParameter::set_allocated_prelu_param(::caffe::PReLUParameter* prelu_param) { + delete prelu_param_; + prelu_param_ = prelu_param; + if (prelu_param) { + set_has_prelu_param(); + } else { + clear_has_prelu_param(); + } + // @@protoc_insertion_point(field_set_allocated:caffe.LayerParameter.prelu_param) } -void LayerParameter::MergeFrom(const ::google::protobuf::Message& from) { - GOOGLE_CHECK_NE(&from, this); - const LayerParameter* source = - ::google::protobuf::internal::dynamic_cast_if_available( - &from); - if (source == NULL) { - ::google::protobuf::internal::ReflectionOps::Merge(from, this); +// optional .caffe.PriorBoxParameter prior_box_param = 140; +bool LayerParameter::has_prior_box_param() const { + return (_has_bits_[1] & 0x00000200u) != 0; +} +void LayerParameter::set_has_prior_box_param() { + _has_bits_[1] |= 0x00000200u; +} +void LayerParameter::clear_has_prior_box_param() { + _has_bits_[1] &= ~0x00000200u; +} +void LayerParameter::clear_prior_box_param() { + if (prior_box_param_ != NULL) prior_box_param_->::caffe::PriorBoxParameter::Clear(); + clear_has_prior_box_param(); +} +const ::caffe::PriorBoxParameter& LayerParameter::prior_box_param() const { + // @@protoc_insertion_point(field_get:caffe.LayerParameter.prior_box_param) + return prior_box_param_ != NULL ? *prior_box_param_ + : *::caffe::PriorBoxParameter::internal_default_instance(); +} +::caffe::PriorBoxParameter* LayerParameter::mutable_prior_box_param() { + set_has_prior_box_param(); + if (prior_box_param_ == NULL) { + prior_box_param_ = new ::caffe::PriorBoxParameter; + } + // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.prior_box_param) + return prior_box_param_; +} +::caffe::PriorBoxParameter* LayerParameter::release_prior_box_param() { + // @@protoc_insertion_point(field_release:caffe.LayerParameter.prior_box_param) + clear_has_prior_box_param(); + ::caffe::PriorBoxParameter* temp = prior_box_param_; + prior_box_param_ = NULL; + return temp; +} +void LayerParameter::set_allocated_prior_box_param(::caffe::PriorBoxParameter* prior_box_param) { + delete prior_box_param_; + prior_box_param_ = prior_box_param; + if (prior_box_param) { + set_has_prior_box_param(); } else { - MergeFrom(*source); + clear_has_prior_box_param(); } + // @@protoc_insertion_point(field_set_allocated:caffe.LayerParameter.prior_box_param) } -void LayerParameter::MergeFrom(const LayerParameter& from) { - GOOGLE_CHECK_NE(&from, this); - bottom_.MergeFrom(from.bottom_); - top_.MergeFrom(from.top_); - loss_weight_.MergeFrom(from.loss_weight_); - param_.MergeFrom(from.param_); - blobs_.MergeFrom(from.blobs_); - propagate_down_.MergeFrom(from.propagate_down_); - include_.MergeFrom(from.include_); - exclude_.MergeFrom(from.exclude_); - if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) { - if (from.has_name()) { - set_name(from.name()); - } - if (from.has_type()) { - set_type(from.type()); - } - if (from.has_phase()) { - set_phase(from.phase()); - } +// optional .caffe.PythonParameter python_param = 130; +bool LayerParameter::has_python_param() const { + return (_has_bits_[1] & 0x00000400u) != 0; +} +void LayerParameter::set_has_python_param() { + _has_bits_[1] |= 0x00000400u; +} +void LayerParameter::clear_has_python_param() { + _has_bits_[1] &= ~0x00000400u; +} +void LayerParameter::clear_python_param() { + if (python_param_ != NULL) python_param_->::caffe::PythonParameter::Clear(); + clear_has_python_param(); +} +const ::caffe::PythonParameter& LayerParameter::python_param() const { + // @@protoc_insertion_point(field_get:caffe.LayerParameter.python_param) + return python_param_ != NULL ? *python_param_ + : *::caffe::PythonParameter::internal_default_instance(); +} +::caffe::PythonParameter* LayerParameter::mutable_python_param() { + set_has_python_param(); + if (python_param_ == NULL) { + python_param_ = new ::caffe::PythonParameter; } - if (from._has_bits_[11 / 32] & (0xffu << (11 % 32))) { - if (from.has_transform_param()) { - mutable_transform_param()->::caffe::TransformationParameter::MergeFrom(from.transform_param()); - } - if (from.has_loss_param()) { - mutable_loss_param()->::caffe::LossParameter::MergeFrom(from.loss_param()); - } - if (from.has_accuracy_param()) { - mutable_accuracy_param()->::caffe::AccuracyParameter::MergeFrom(from.accuracy_param()); - } - if (from.has_argmax_param()) { - mutable_argmax_param()->::caffe::ArgMaxParameter::MergeFrom(from.argmax_param()); - } - if (from.has_concat_param()) { - mutable_concat_param()->::caffe::ConcatParameter::MergeFrom(from.concat_param()); - } + // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.python_param) + return python_param_; +} +::caffe::PythonParameter* LayerParameter::release_python_param() { + // @@protoc_insertion_point(field_release:caffe.LayerParameter.python_param) + clear_has_python_param(); + ::caffe::PythonParameter* temp = python_param_; + python_param_ = NULL; + return temp; +} +void LayerParameter::set_allocated_python_param(::caffe::PythonParameter* python_param) { + delete python_param_; + python_param_ = python_param; + if (python_param) { + set_has_python_param(); + } else { + clear_has_python_param(); } - if (from._has_bits_[16 / 32] & (0xffu << (16 % 32))) { - if (from.has_contrastive_loss_param()) { - mutable_contrastive_loss_param()->::caffe::ContrastiveLossParameter::MergeFrom(from.contrastive_loss_param()); - } - if (from.has_convolution_param()) { - mutable_convolution_param()->::caffe::ConvolutionParameter::MergeFrom(from.convolution_param()); - } - if (from.has_crop_param()) { - mutable_crop_param()->::caffe::CropParameter::MergeFrom(from.crop_param()); - } - if (from.has_data_param()) { - mutable_data_param()->::caffe::DataParameter::MergeFrom(from.data_param()); - } - if (from.has_detection_output_param()) { - mutable_detection_output_param()->::caffe::DetectionOutputParameter::MergeFrom(from.detection_output_param()); - } - if (from.has_dropout_param()) { - mutable_dropout_param()->::caffe::DropoutParameter::MergeFrom(from.dropout_param()); - } - if (from.has_dummy_data_param()) { - mutable_dummy_data_param()->::caffe::DummyDataParameter::MergeFrom(from.dummy_data_param()); - } - if (from.has_eltwise_param()) { - mutable_eltwise_param()->::caffe::EltwiseParameter::MergeFrom(from.eltwise_param()); - } + // @@protoc_insertion_point(field_set_allocated:caffe.LayerParameter.python_param) +} + +// optional .caffe.ReductionParameter reduction_param = 136; +bool LayerParameter::has_reduction_param() const { + return (_has_bits_[1] & 0x00000800u) != 0; +} +void LayerParameter::set_has_reduction_param() { + _has_bits_[1] |= 0x00000800u; +} +void LayerParameter::clear_has_reduction_param() { + _has_bits_[1] &= ~0x00000800u; +} +void LayerParameter::clear_reduction_param() { + if (reduction_param_ != NULL) reduction_param_->::caffe::ReductionParameter::Clear(); + clear_has_reduction_param(); +} +const ::caffe::ReductionParameter& LayerParameter::reduction_param() const { + // @@protoc_insertion_point(field_get:caffe.LayerParameter.reduction_param) + return reduction_param_ != NULL ? *reduction_param_ + : *::caffe::ReductionParameter::internal_default_instance(); +} +::caffe::ReductionParameter* LayerParameter::mutable_reduction_param() { + set_has_reduction_param(); + if (reduction_param_ == NULL) { + reduction_param_ = new ::caffe::ReductionParameter; } - if (from._has_bits_[24 / 32] & (0xffu << (24 % 32))) { - if (from.has_exp_param()) { - mutable_exp_param()->::caffe::ExpParameter::MergeFrom(from.exp_param()); - } - if (from.has_flatten_param()) { - mutable_flatten_param()->::caffe::FlattenParameter::MergeFrom(from.flatten_param()); - } - if (from.has_hdf5_data_param()) { - mutable_hdf5_data_param()->::caffe::HDF5DataParameter::MergeFrom(from.hdf5_data_param()); - } - if (from.has_hdf5_output_param()) { - mutable_hdf5_output_param()->::caffe::HDF5OutputParameter::MergeFrom(from.hdf5_output_param()); - } - if (from.has_hinge_loss_param()) { - mutable_hinge_loss_param()->::caffe::HingeLossParameter::MergeFrom(from.hinge_loss_param()); - } - if (from.has_image_data_param()) { - mutable_image_data_param()->::caffe::ImageDataParameter::MergeFrom(from.image_data_param()); - } - if (from.has_infogain_loss_param()) { - mutable_infogain_loss_param()->::caffe::InfogainLossParameter::MergeFrom(from.infogain_loss_param()); - } - if (from.has_inner_product_param()) { - mutable_inner_product_param()->::caffe::InnerProductParameter::MergeFrom(from.inner_product_param()); - } + // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.reduction_param) + return reduction_param_; +} +::caffe::ReductionParameter* LayerParameter::release_reduction_param() { + // @@protoc_insertion_point(field_release:caffe.LayerParameter.reduction_param) + clear_has_reduction_param(); + ::caffe::ReductionParameter* temp = reduction_param_; + reduction_param_ = NULL; + return temp; +} +void LayerParameter::set_allocated_reduction_param(::caffe::ReductionParameter* reduction_param) { + delete reduction_param_; + reduction_param_ = reduction_param; + if (reduction_param) { + set_has_reduction_param(); + } else { + clear_has_reduction_param(); } - if (from._has_bits_[32 / 32] & (0xffu << (32 % 32))) { - if (from.has_log_param()) { - mutable_log_param()->::caffe::LogParameter::MergeFrom(from.log_param()); - } - if (from.has_lrn_param()) { - mutable_lrn_param()->::caffe::LRNParameter::MergeFrom(from.lrn_param()); - } - if (from.has_memory_data_param()) { - mutable_memory_data_param()->::caffe::MemoryDataParameter::MergeFrom(from.memory_data_param()); - } - if (from.has_mvn_param()) { - mutable_mvn_param()->::caffe::MVNParameter::MergeFrom(from.mvn_param()); - } - if (from.has_normalize_bbox_param()) { - mutable_normalize_bbox_param()->::caffe::NormalizeBBoxParameter::MergeFrom(from.normalize_bbox_param()); - } - if (from.has_permute_param()) { - mutable_permute_param()->::caffe::PermuteParameter::MergeFrom(from.permute_param()); - } - if (from.has_pooling_param()) { - mutable_pooling_param()->::caffe::PoolingParameter::MergeFrom(from.pooling_param()); - } - if (from.has_power_param()) { - mutable_power_param()->::caffe::PowerParameter::MergeFrom(from.power_param()); - } + // @@protoc_insertion_point(field_set_allocated:caffe.LayerParameter.reduction_param) +} + +// optional .caffe.ReLUParameter relu_param = 123; +bool LayerParameter::has_relu_param() const { + return (_has_bits_[1] & 0x00001000u) != 0; +} +void LayerParameter::set_has_relu_param() { + _has_bits_[1] |= 0x00001000u; +} +void LayerParameter::clear_has_relu_param() { + _has_bits_[1] &= ~0x00001000u; +} +void LayerParameter::clear_relu_param() { + if (relu_param_ != NULL) relu_param_->::caffe::ReLUParameter::Clear(); + clear_has_relu_param(); +} +const ::caffe::ReLUParameter& LayerParameter::relu_param() const { + // @@protoc_insertion_point(field_get:caffe.LayerParameter.relu_param) + return relu_param_ != NULL ? *relu_param_ + : *::caffe::ReLUParameter::internal_default_instance(); +} +::caffe::ReLUParameter* LayerParameter::mutable_relu_param() { + set_has_relu_param(); + if (relu_param_ == NULL) { + relu_param_ = new ::caffe::ReLUParameter; } - if (from._has_bits_[40 / 32] & (0xffu << (40 % 32))) { - if (from.has_prelu_param()) { - mutable_prelu_param()->::caffe::PReLUParameter::MergeFrom(from.prelu_param()); - } - if (from.has_prior_box_param()) { - mutable_prior_box_param()->::caffe::PriorBoxParameter::MergeFrom(from.prior_box_param()); - } - if (from.has_python_param()) { - mutable_python_param()->::caffe::PythonParameter::MergeFrom(from.python_param()); - } - if (from.has_reduction_param()) { - mutable_reduction_param()->::caffe::ReductionParameter::MergeFrom(from.reduction_param()); - } - if (from.has_relu_param()) { - mutable_relu_param()->::caffe::ReLUParameter::MergeFrom(from.relu_param()); - } - if (from.has_reshape_param()) { - mutable_reshape_param()->::caffe::ReshapeParameter::MergeFrom(from.reshape_param()); - } - if (from.has_sigmoid_param()) { - mutable_sigmoid_param()->::caffe::SigmoidParameter::MergeFrom(from.sigmoid_param()); - } - if (from.has_slice_param()) { - mutable_slice_param()->::caffe::SliceParameter::MergeFrom(from.slice_param()); - } + // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.relu_param) + return relu_param_; +} +::caffe::ReLUParameter* LayerParameter::release_relu_param() { + // @@protoc_insertion_point(field_release:caffe.LayerParameter.relu_param) + clear_has_relu_param(); + ::caffe::ReLUParameter* temp = relu_param_; + relu_param_ = NULL; + return temp; +} +void LayerParameter::set_allocated_relu_param(::caffe::ReLUParameter* relu_param) { + delete relu_param_; + relu_param_ = relu_param; + if (relu_param) { + set_has_relu_param(); + } else { + clear_has_relu_param(); } - if (from._has_bits_[48 / 32] & (0xffu << (48 % 32))) { - if (from.has_softmax_param()) { - mutable_softmax_param()->::caffe::SoftmaxParameter::MergeFrom(from.softmax_param()); - } - if (from.has_spp_param()) { - mutable_spp_param()->::caffe::SPPParameter::MergeFrom(from.spp_param()); - } - if (from.has_tanh_param()) { - mutable_tanh_param()->::caffe::TanHParameter::MergeFrom(from.tanh_param()); - } - if (from.has_threshold_param()) { - mutable_threshold_param()->::caffe::ThresholdParameter::MergeFrom(from.threshold_param()); - } - if (from.has_window_data_param()) { - mutable_window_data_param()->::caffe::WindowDataParameter::MergeFrom(from.window_data_param()); - } + // @@protoc_insertion_point(field_set_allocated:caffe.LayerParameter.relu_param) +} + +// optional .caffe.ReshapeParameter reshape_param = 133; +bool LayerParameter::has_reshape_param() const { + return (_has_bits_[1] & 0x00002000u) != 0; +} +void LayerParameter::set_has_reshape_param() { + _has_bits_[1] |= 0x00002000u; +} +void LayerParameter::clear_has_reshape_param() { + _has_bits_[1] &= ~0x00002000u; +} +void LayerParameter::clear_reshape_param() { + if (reshape_param_ != NULL) reshape_param_->::caffe::ReshapeParameter::Clear(); + clear_has_reshape_param(); +} +const ::caffe::ReshapeParameter& LayerParameter::reshape_param() const { + // @@protoc_insertion_point(field_get:caffe.LayerParameter.reshape_param) + return reshape_param_ != NULL ? *reshape_param_ + : *::caffe::ReshapeParameter::internal_default_instance(); +} +::caffe::ReshapeParameter* LayerParameter::mutable_reshape_param() { + set_has_reshape_param(); + if (reshape_param_ == NULL) { + reshape_param_ = new ::caffe::ReshapeParameter; + } + // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.reshape_param) + return reshape_param_; +} +::caffe::ReshapeParameter* LayerParameter::release_reshape_param() { + // @@protoc_insertion_point(field_release:caffe.LayerParameter.reshape_param) + clear_has_reshape_param(); + ::caffe::ReshapeParameter* temp = reshape_param_; + reshape_param_ = NULL; + return temp; +} +void LayerParameter::set_allocated_reshape_param(::caffe::ReshapeParameter* reshape_param) { + delete reshape_param_; + reshape_param_ = reshape_param; + if (reshape_param) { + set_has_reshape_param(); + } else { + clear_has_reshape_param(); } - mutable_unknown_fields()->MergeFrom(from.unknown_fields()); + // @@protoc_insertion_point(field_set_allocated:caffe.LayerParameter.reshape_param) } -void LayerParameter::CopyFrom(const ::google::protobuf::Message& from) { - if (&from == this) return; - Clear(); - MergeFrom(from); +// optional .caffe.SigmoidParameter sigmoid_param = 124; +bool LayerParameter::has_sigmoid_param() const { + return (_has_bits_[1] & 0x00004000u) != 0; +} +void LayerParameter::set_has_sigmoid_param() { + _has_bits_[1] |= 0x00004000u; +} +void LayerParameter::clear_has_sigmoid_param() { + _has_bits_[1] &= ~0x00004000u; +} +void LayerParameter::clear_sigmoid_param() { + if (sigmoid_param_ != NULL) sigmoid_param_->::caffe::SigmoidParameter::Clear(); + clear_has_sigmoid_param(); +} +const ::caffe::SigmoidParameter& LayerParameter::sigmoid_param() const { + // @@protoc_insertion_point(field_get:caffe.LayerParameter.sigmoid_param) + return sigmoid_param_ != NULL ? *sigmoid_param_ + : *::caffe::SigmoidParameter::internal_default_instance(); +} +::caffe::SigmoidParameter* LayerParameter::mutable_sigmoid_param() { + set_has_sigmoid_param(); + if (sigmoid_param_ == NULL) { + sigmoid_param_ = new ::caffe::SigmoidParameter; + } + // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.sigmoid_param) + return sigmoid_param_; +} +::caffe::SigmoidParameter* LayerParameter::release_sigmoid_param() { + // @@protoc_insertion_point(field_release:caffe.LayerParameter.sigmoid_param) + clear_has_sigmoid_param(); + ::caffe::SigmoidParameter* temp = sigmoid_param_; + sigmoid_param_ = NULL; + return temp; +} +void LayerParameter::set_allocated_sigmoid_param(::caffe::SigmoidParameter* sigmoid_param) { + delete sigmoid_param_; + sigmoid_param_ = sigmoid_param; + if (sigmoid_param) { + set_has_sigmoid_param(); + } else { + clear_has_sigmoid_param(); + } + // @@protoc_insertion_point(field_set_allocated:caffe.LayerParameter.sigmoid_param) } -void LayerParameter::CopyFrom(const LayerParameter& from) { - if (&from == this) return; - Clear(); - MergeFrom(from); +// optional .caffe.SliceParameter slice_param = 126; +bool LayerParameter::has_slice_param() const { + return (_has_bits_[1] & 0x00008000u) != 0; +} +void LayerParameter::set_has_slice_param() { + _has_bits_[1] |= 0x00008000u; +} +void LayerParameter::clear_has_slice_param() { + _has_bits_[1] &= ~0x00008000u; +} +void LayerParameter::clear_slice_param() { + if (slice_param_ != NULL) slice_param_->::caffe::SliceParameter::Clear(); + clear_has_slice_param(); +} +const ::caffe::SliceParameter& LayerParameter::slice_param() const { + // @@protoc_insertion_point(field_get:caffe.LayerParameter.slice_param) + return slice_param_ != NULL ? *slice_param_ + : *::caffe::SliceParameter::internal_default_instance(); +} +::caffe::SliceParameter* LayerParameter::mutable_slice_param() { + set_has_slice_param(); + if (slice_param_ == NULL) { + slice_param_ = new ::caffe::SliceParameter; + } + // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.slice_param) + return slice_param_; +} +::caffe::SliceParameter* LayerParameter::release_slice_param() { + // @@protoc_insertion_point(field_release:caffe.LayerParameter.slice_param) + clear_has_slice_param(); + ::caffe::SliceParameter* temp = slice_param_; + slice_param_ = NULL; + return temp; +} +void LayerParameter::set_allocated_slice_param(::caffe::SliceParameter* slice_param) { + delete slice_param_; + slice_param_ = slice_param; + if (slice_param) { + set_has_slice_param(); + } else { + clear_has_slice_param(); + } + // @@protoc_insertion_point(field_set_allocated:caffe.LayerParameter.slice_param) } -bool LayerParameter::IsInitialized() const { +// optional .caffe.SoftmaxParameter softmax_param = 125; +bool LayerParameter::has_softmax_param() const { + return (_has_bits_[1] & 0x00010000u) != 0; +} +void LayerParameter::set_has_softmax_param() { + _has_bits_[1] |= 0x00010000u; +} +void LayerParameter::clear_has_softmax_param() { + _has_bits_[1] &= ~0x00010000u; +} +void LayerParameter::clear_softmax_param() { + if (softmax_param_ != NULL) softmax_param_->::caffe::SoftmaxParameter::Clear(); + clear_has_softmax_param(); +} +const ::caffe::SoftmaxParameter& LayerParameter::softmax_param() const { + // @@protoc_insertion_point(field_get:caffe.LayerParameter.softmax_param) + return softmax_param_ != NULL ? *softmax_param_ + : *::caffe::SoftmaxParameter::internal_default_instance(); +} +::caffe::SoftmaxParameter* LayerParameter::mutable_softmax_param() { + set_has_softmax_param(); + if (softmax_param_ == NULL) { + softmax_param_ = new ::caffe::SoftmaxParameter; + } + // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.softmax_param) + return softmax_param_; +} +::caffe::SoftmaxParameter* LayerParameter::release_softmax_param() { + // @@protoc_insertion_point(field_release:caffe.LayerParameter.softmax_param) + clear_has_softmax_param(); + ::caffe::SoftmaxParameter* temp = softmax_param_; + softmax_param_ = NULL; + return temp; +} +void LayerParameter::set_allocated_softmax_param(::caffe::SoftmaxParameter* softmax_param) { + delete softmax_param_; + softmax_param_ = softmax_param; + if (softmax_param) { + set_has_softmax_param(); + } else { + clear_has_softmax_param(); + } + // @@protoc_insertion_point(field_set_allocated:caffe.LayerParameter.softmax_param) +} - return true; +// optional .caffe.SPPParameter spp_param = 132; +bool LayerParameter::has_spp_param() const { + return (_has_bits_[1] & 0x00020000u) != 0; +} +void LayerParameter::set_has_spp_param() { + _has_bits_[1] |= 0x00020000u; +} +void LayerParameter::clear_has_spp_param() { + _has_bits_[1] &= ~0x00020000u; +} +void LayerParameter::clear_spp_param() { + if (spp_param_ != NULL) spp_param_->::caffe::SPPParameter::Clear(); + clear_has_spp_param(); +} +const ::caffe::SPPParameter& LayerParameter::spp_param() const { + // @@protoc_insertion_point(field_get:caffe.LayerParameter.spp_param) + return spp_param_ != NULL ? *spp_param_ + : *::caffe::SPPParameter::internal_default_instance(); +} +::caffe::SPPParameter* LayerParameter::mutable_spp_param() { + set_has_spp_param(); + if (spp_param_ == NULL) { + spp_param_ = new ::caffe::SPPParameter; + } + // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.spp_param) + return spp_param_; +} +::caffe::SPPParameter* LayerParameter::release_spp_param() { + // @@protoc_insertion_point(field_release:caffe.LayerParameter.spp_param) + clear_has_spp_param(); + ::caffe::SPPParameter* temp = spp_param_; + spp_param_ = NULL; + return temp; +} +void LayerParameter::set_allocated_spp_param(::caffe::SPPParameter* spp_param) { + delete spp_param_; + spp_param_ = spp_param; + if (spp_param) { + set_has_spp_param(); + } else { + clear_has_spp_param(); + } + // @@protoc_insertion_point(field_set_allocated:caffe.LayerParameter.spp_param) } -void LayerParameter::Swap(LayerParameter* other) { - if (other != this) { - std::swap(name_, other->name_); - std::swap(type_, other->type_); - bottom_.Swap(&other->bottom_); - top_.Swap(&other->top_); - std::swap(phase_, other->phase_); - loss_weight_.Swap(&other->loss_weight_); - param_.Swap(&other->param_); - blobs_.Swap(&other->blobs_); - propagate_down_.Swap(&other->propagate_down_); - include_.Swap(&other->include_); - exclude_.Swap(&other->exclude_); - std::swap(transform_param_, other->transform_param_); - std::swap(loss_param_, other->loss_param_); - std::swap(accuracy_param_, other->accuracy_param_); - std::swap(argmax_param_, other->argmax_param_); - std::swap(concat_param_, other->concat_param_); - std::swap(contrastive_loss_param_, other->contrastive_loss_param_); - std::swap(convolution_param_, other->convolution_param_); - std::swap(crop_param_, other->crop_param_); - std::swap(data_param_, other->data_param_); - std::swap(detection_output_param_, other->detection_output_param_); - std::swap(dropout_param_, other->dropout_param_); - std::swap(dummy_data_param_, other->dummy_data_param_); - std::swap(eltwise_param_, other->eltwise_param_); - std::swap(exp_param_, other->exp_param_); - std::swap(flatten_param_, other->flatten_param_); - std::swap(hdf5_data_param_, other->hdf5_data_param_); - std::swap(hdf5_output_param_, other->hdf5_output_param_); - std::swap(hinge_loss_param_, other->hinge_loss_param_); - std::swap(image_data_param_, other->image_data_param_); - std::swap(infogain_loss_param_, other->infogain_loss_param_); - std::swap(inner_product_param_, other->inner_product_param_); - std::swap(log_param_, other->log_param_); - std::swap(lrn_param_, other->lrn_param_); - std::swap(memory_data_param_, other->memory_data_param_); - std::swap(mvn_param_, other->mvn_param_); - std::swap(normalize_bbox_param_, other->normalize_bbox_param_); - std::swap(permute_param_, other->permute_param_); - std::swap(pooling_param_, other->pooling_param_); - std::swap(power_param_, other->power_param_); - std::swap(prelu_param_, other->prelu_param_); - std::swap(prior_box_param_, other->prior_box_param_); - std::swap(python_param_, other->python_param_); - std::swap(reduction_param_, other->reduction_param_); - std::swap(relu_param_, other->relu_param_); - std::swap(reshape_param_, other->reshape_param_); - std::swap(sigmoid_param_, other->sigmoid_param_); - std::swap(slice_param_, other->slice_param_); - std::swap(softmax_param_, other->softmax_param_); - std::swap(spp_param_, other->spp_param_); - std::swap(tanh_param_, other->tanh_param_); - std::swap(threshold_param_, other->threshold_param_); - std::swap(window_data_param_, other->window_data_param_); - std::swap(_has_bits_[0], other->_has_bits_[0]); - std::swap(_has_bits_[1], other->_has_bits_[1]); - _unknown_fields_.Swap(&other->_unknown_fields_); - std::swap(_cached_size_, other->_cached_size_); +// optional .caffe.TanHParameter tanh_param = 127; +bool LayerParameter::has_tanh_param() const { + return (_has_bits_[1] & 0x00040000u) != 0; +} +void LayerParameter::set_has_tanh_param() { + _has_bits_[1] |= 0x00040000u; +} +void LayerParameter::clear_has_tanh_param() { + _has_bits_[1] &= ~0x00040000u; +} +void LayerParameter::clear_tanh_param() { + if (tanh_param_ != NULL) tanh_param_->::caffe::TanHParameter::Clear(); + clear_has_tanh_param(); +} +const ::caffe::TanHParameter& LayerParameter::tanh_param() const { + // @@protoc_insertion_point(field_get:caffe.LayerParameter.tanh_param) + return tanh_param_ != NULL ? *tanh_param_ + : *::caffe::TanHParameter::internal_default_instance(); +} +::caffe::TanHParameter* LayerParameter::mutable_tanh_param() { + set_has_tanh_param(); + if (tanh_param_ == NULL) { + tanh_param_ = new ::caffe::TanHParameter; + } + // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.tanh_param) + return tanh_param_; +} +::caffe::TanHParameter* LayerParameter::release_tanh_param() { + // @@protoc_insertion_point(field_release:caffe.LayerParameter.tanh_param) + clear_has_tanh_param(); + ::caffe::TanHParameter* temp = tanh_param_; + tanh_param_ = NULL; + return temp; +} +void LayerParameter::set_allocated_tanh_param(::caffe::TanHParameter* tanh_param) { + delete tanh_param_; + tanh_param_ = tanh_param; + if (tanh_param) { + set_has_tanh_param(); + } else { + clear_has_tanh_param(); } + // @@protoc_insertion_point(field_set_allocated:caffe.LayerParameter.tanh_param) } -::google::protobuf::Metadata LayerParameter::GetMetadata() const { - protobuf_AssignDescriptorsOnce(); - ::google::protobuf::Metadata metadata; - metadata.descriptor = LayerParameter_descriptor_; - metadata.reflection = LayerParameter_reflection_; - return metadata; +// optional .caffe.ThresholdParameter threshold_param = 128; +bool LayerParameter::has_threshold_param() const { + return (_has_bits_[1] & 0x00080000u) != 0; +} +void LayerParameter::set_has_threshold_param() { + _has_bits_[1] |= 0x00080000u; +} +void LayerParameter::clear_has_threshold_param() { + _has_bits_[1] &= ~0x00080000u; +} +void LayerParameter::clear_threshold_param() { + if (threshold_param_ != NULL) threshold_param_->::caffe::ThresholdParameter::Clear(); + clear_has_threshold_param(); +} +const ::caffe::ThresholdParameter& LayerParameter::threshold_param() const { + // @@protoc_insertion_point(field_get:caffe.LayerParameter.threshold_param) + return threshold_param_ != NULL ? *threshold_param_ + : *::caffe::ThresholdParameter::internal_default_instance(); +} +::caffe::ThresholdParameter* LayerParameter::mutable_threshold_param() { + set_has_threshold_param(); + if (threshold_param_ == NULL) { + threshold_param_ = new ::caffe::ThresholdParameter; + } + // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.threshold_param) + return threshold_param_; +} +::caffe::ThresholdParameter* LayerParameter::release_threshold_param() { + // @@protoc_insertion_point(field_release:caffe.LayerParameter.threshold_param) + clear_has_threshold_param(); + ::caffe::ThresholdParameter* temp = threshold_param_; + threshold_param_ = NULL; + return temp; +} +void LayerParameter::set_allocated_threshold_param(::caffe::ThresholdParameter* threshold_param) { + delete threshold_param_; + threshold_param_ = threshold_param; + if (threshold_param) { + set_has_threshold_param(); + } else { + clear_has_threshold_param(); + } + // @@protoc_insertion_point(field_set_allocated:caffe.LayerParameter.threshold_param) +} + +// optional .caffe.WindowDataParameter window_data_param = 129; +bool LayerParameter::has_window_data_param() const { + return (_has_bits_[1] & 0x00100000u) != 0; +} +void LayerParameter::set_has_window_data_param() { + _has_bits_[1] |= 0x00100000u; +} +void LayerParameter::clear_has_window_data_param() { + _has_bits_[1] &= ~0x00100000u; +} +void LayerParameter::clear_window_data_param() { + if (window_data_param_ != NULL) window_data_param_->::caffe::WindowDataParameter::Clear(); + clear_has_window_data_param(); +} +const ::caffe::WindowDataParameter& LayerParameter::window_data_param() const { + // @@protoc_insertion_point(field_get:caffe.LayerParameter.window_data_param) + return window_data_param_ != NULL ? *window_data_param_ + : *::caffe::WindowDataParameter::internal_default_instance(); +} +::caffe::WindowDataParameter* LayerParameter::mutable_window_data_param() { + set_has_window_data_param(); + if (window_data_param_ == NULL) { + window_data_param_ = new ::caffe::WindowDataParameter; + } + // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.window_data_param) + return window_data_param_; +} +::caffe::WindowDataParameter* LayerParameter::release_window_data_param() { + // @@protoc_insertion_point(field_release:caffe.LayerParameter.window_data_param) + clear_has_window_data_param(); + ::caffe::WindowDataParameter* temp = window_data_param_; + window_data_param_ = NULL; + return temp; +} +void LayerParameter::set_allocated_window_data_param(::caffe::WindowDataParameter* window_data_param) { + delete window_data_param_; + window_data_param_ = window_data_param; + if (window_data_param) { + set_has_window_data_param(); + } else { + clear_has_window_data_param(); + } + // @@protoc_insertion_point(field_set_allocated:caffe.LayerParameter.window_data_param) } +inline const LayerParameter* LayerParameter::internal_default_instance() { + return &LayerParameter_default_instance_.get(); +} +#endif // PROTOBUF_INLINE_NOT_IN_HEADERS // =================================================================== -#ifndef _MSC_VER +#if !defined(_MSC_VER) || _MSC_VER >= 1900 const int TransformationParameter::kScaleFieldNumber; const int TransformationParameter::kMirrorFieldNumber; const int TransformationParameter::kCropSizeFieldNumber; @@ -12250,43 +18813,41 @@ const int TransformationParameter::kMeanFileFieldNumber; const int TransformationParameter::kMeanValueFieldNumber; const int TransformationParameter::kForceColorFieldNumber; const int TransformationParameter::kForceGrayFieldNumber; -#endif // !_MSC_VER +#endif // !defined(_MSC_VER) || _MSC_VER >= 1900 TransformationParameter::TransformationParameter() - : ::google::protobuf::Message() { + : ::google::protobuf::Message(), _internal_metadata_(NULL) { + if (this != internal_default_instance()) protobuf_InitDefaults_caffe_2eproto(); SharedCtor(); + // @@protoc_insertion_point(constructor:caffe.TransformationParameter) } void TransformationParameter::InitAsDefaultInstance() { } TransformationParameter::TransformationParameter(const TransformationParameter& from) - : ::google::protobuf::Message() { + : ::google::protobuf::Message(), + _internal_metadata_(NULL) { SharedCtor(); - MergeFrom(from); + UnsafeMergeFrom(from); + // @@protoc_insertion_point(copy_constructor:caffe.TransformationParameter) } void TransformationParameter::SharedCtor() { _cached_size_ = 0; + mean_file_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + ::memset(&crop_size_, 0, reinterpret_cast(&force_gray_) - + reinterpret_cast(&crop_size_) + sizeof(force_gray_)); scale_ = 1; - mirror_ = false; - crop_size_ = 0u; - mean_file_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); - force_color_ = false; - force_gray_ = false; - ::memset(_has_bits_, 0, sizeof(_has_bits_)); } TransformationParameter::~TransformationParameter() { + // @@protoc_insertion_point(destructor:caffe.TransformationParameter) SharedDtor(); } void TransformationParameter::SharedDtor() { - if (mean_file_ != &::google::protobuf::internal::kEmptyString) { - delete mean_file_; - } - if (this != default_instance_) { - } + mean_file_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } void TransformationParameter::SetCachedSize(int size) const { @@ -12300,50 +18861,75 @@ const ::google::protobuf::Descriptor* TransformationParameter::descriptor() { } const TransformationParameter& TransformationParameter::default_instance() { - if (default_instance_ == NULL) protobuf_AddDesc_caffe_2eproto(); - return *default_instance_; + protobuf_InitDefaults_caffe_2eproto(); + return *internal_default_instance(); } -TransformationParameter* TransformationParameter::default_instance_ = NULL; +::google::protobuf::internal::ExplicitlyConstructed TransformationParameter_default_instance_; -TransformationParameter* TransformationParameter::New() const { - return new TransformationParameter; +TransformationParameter* TransformationParameter::New(::google::protobuf::Arena* arena) const { + TransformationParameter* n = new TransformationParameter; + if (arena != NULL) { + arena->Own(n); + } + return n; } void TransformationParameter::Clear() { - if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) { +// @@protoc_insertion_point(message_clear_start:caffe.TransformationParameter) +#if defined(__clang__) +#define ZR_HELPER_(f) \ + _Pragma("clang diagnostic push") \ + _Pragma("clang diagnostic ignored \"-Winvalid-offsetof\"") \ + __builtin_offsetof(TransformationParameter, f) \ + _Pragma("clang diagnostic pop") +#else +#define ZR_HELPER_(f) reinterpret_cast(\ + &reinterpret_cast(16)->f) +#endif + +#define ZR_(first, last) do {\ + ::memset(&(first), 0,\ + ZR_HELPER_(last) - ZR_HELPER_(first) + sizeof(last));\ +} while (0) + + if (_has_bits_[0 / 32] & 111u) { + ZR_(crop_size_, force_gray_); scale_ = 1; - mirror_ = false; - crop_size_ = 0u; if (has_mean_file()) { - if (mean_file_ != &::google::protobuf::internal::kEmptyString) { - mean_file_->clear(); - } + mean_file_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - force_color_ = false; - force_gray_ = false; } + +#undef ZR_HELPER_ +#undef ZR_ + mean_value_.Clear(); - ::memset(_has_bits_, 0, sizeof(_has_bits_)); - mutable_unknown_fields()->Clear(); + _has_bits_.Clear(); + if (_internal_metadata_.have_unknown_fields()) { + mutable_unknown_fields()->Clear(); + } } bool TransformationParameter::MergePartialFromCodedStream( ::google::protobuf::io::CodedInputStream* input) { -#define DO_(EXPRESSION) if (!(EXPRESSION)) return false +#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure ::google::protobuf::uint32 tag; - while ((tag = input->ReadTag()) != 0) { + // @@protoc_insertion_point(parse_start:caffe.TransformationParameter) + for (;;) { + ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127); + tag = p.first; + if (!p.second) goto handle_unusual; switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { // optional float scale = 1 [default = 1]; case 1: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_FIXED32) { + if (tag == 13) { + set_has_scale(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< float, ::google::protobuf::internal::WireFormatLite::TYPE_FLOAT>( input, &scale_))); - set_has_scale(); } else { - goto handle_uninterpreted; + goto handle_unusual; } if (input->ExpectTag(16)) goto parse_mirror; break; @@ -12351,15 +18937,14 @@ bool TransformationParameter::MergePartialFromCodedStream( // optional bool mirror = 2 [default = false]; case 2: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) { + if (tag == 16) { parse_mirror: + set_has_mirror(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>( input, &mirror_))); - set_has_mirror(); } else { - goto handle_uninterpreted; + goto handle_unusual; } if (input->ExpectTag(24)) goto parse_crop_size; break; @@ -12367,15 +18952,14 @@ bool TransformationParameter::MergePartialFromCodedStream( // optional uint32 crop_size = 3 [default = 0]; case 3: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) { + if (tag == 24) { parse_crop_size: + set_has_crop_size(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>( input, &crop_size_))); - set_has_crop_size(); } else { - goto handle_uninterpreted; + goto handle_unusual; } if (input->ExpectTag(34)) goto parse_mean_file; break; @@ -12383,16 +18967,16 @@ bool TransformationParameter::MergePartialFromCodedStream( // optional string mean_file = 4; case 4: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) { + if (tag == 34) { parse_mean_file: DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->mutable_mean_file())); - ::google::protobuf::internal::WireFormat::VerifyUTF8String( + ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( this->mean_file().data(), this->mean_file().length(), - ::google::protobuf::internal::WireFormat::PARSE); + ::google::protobuf::internal::WireFormat::PARSE, + "caffe.TransformationParameter.mean_file"); } else { - goto handle_uninterpreted; + goto handle_unusual; } if (input->ExpectTag(45)) goto parse_mean_value; break; @@ -12400,20 +18984,17 @@ bool TransformationParameter::MergePartialFromCodedStream( // repeated float mean_value = 5; case 5: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_FIXED32) { + if (tag == 45) { parse_mean_value: DO_((::google::protobuf::internal::WireFormatLite::ReadRepeatedPrimitive< float, ::google::protobuf::internal::WireFormatLite::TYPE_FLOAT>( 1, 45, input, this->mutable_mean_value()))); - } else if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) - == ::google::protobuf::internal::WireFormatLite:: - WIRETYPE_LENGTH_DELIMITED) { + } else if (tag == 42) { DO_((::google::protobuf::internal::WireFormatLite::ReadPackedPrimitiveNoInline< float, ::google::protobuf::internal::WireFormatLite::TYPE_FLOAT>( input, this->mutable_mean_value()))); } else { - goto handle_uninterpreted; + goto handle_unusual; } if (input->ExpectTag(45)) goto parse_mean_value; if (input->ExpectTag(48)) goto parse_force_color; @@ -12422,15 +19003,14 @@ bool TransformationParameter::MergePartialFromCodedStream( // optional bool force_color = 6 [default = false]; case 6: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) { + if (tag == 48) { parse_force_color: + set_has_force_color(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>( input, &force_color_))); - set_has_force_color(); } else { - goto handle_uninterpreted; + goto handle_unusual; } if (input->ExpectTag(56)) goto parse_force_gray; break; @@ -12438,25 +19018,25 @@ bool TransformationParameter::MergePartialFromCodedStream( // optional bool force_gray = 7 [default = false]; case 7: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) { + if (tag == 56) { parse_force_gray: + set_has_force_gray(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>( input, &force_gray_))); - set_has_force_gray(); } else { - goto handle_uninterpreted; + goto handle_unusual; } - if (input->ExpectAtEnd()) return true; + if (input->ExpectAtEnd()) goto success; break; } default: { - handle_uninterpreted: - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == + handle_unusual: + if (tag == 0 || + ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) { - return true; + goto success; } DO_(::google::protobuf::internal::WireFormat::SkipField( input, tag, mutable_unknown_fields())); @@ -12464,12 +19044,18 @@ bool TransformationParameter::MergePartialFromCodedStream( } } } +success: + // @@protoc_insertion_point(parse_success:caffe.TransformationParameter) return true; +failure: + // @@protoc_insertion_point(parse_failure:caffe.TransformationParameter) + return false; #undef DO_ } void TransformationParameter::SerializeWithCachedSizes( ::google::protobuf::io::CodedOutputStream* output) const { + // @@protoc_insertion_point(serialize_start:caffe.TransformationParameter) // optional float scale = 1 [default = 1]; if (has_scale()) { ::google::protobuf::internal::WireFormatLite::WriteFloat(1, this->scale(), output); @@ -12487,10 +19073,11 @@ void TransformationParameter::SerializeWithCachedSizes( // optional string mean_file = 4; if (has_mean_file()) { - ::google::protobuf::internal::WireFormat::VerifyUTF8String( + ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( this->mean_file().data(), this->mean_file().length(), - ::google::protobuf::internal::WireFormat::SERIALIZE); - ::google::protobuf::internal::WireFormatLite::WriteString( + ::google::protobuf::internal::WireFormat::SERIALIZE, + "caffe.TransformationParameter.mean_file"); + ::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased( 4, this->mean_file(), output); } @@ -12510,14 +19097,17 @@ void TransformationParameter::SerializeWithCachedSizes( ::google::protobuf::internal::WireFormatLite::WriteBool(7, this->force_gray(), output); } - if (!unknown_fields().empty()) { + if (_internal_metadata_.have_unknown_fields()) { ::google::protobuf::internal::WireFormat::SerializeUnknownFields( unknown_fields(), output); } + // @@protoc_insertion_point(serialize_end:caffe.TransformationParameter) } -::google::protobuf::uint8* TransformationParameter::SerializeWithCachedSizesToArray( - ::google::protobuf::uint8* target) const { +::google::protobuf::uint8* TransformationParameter::InternalSerializeWithCachedSizesToArray( + bool deterministic, ::google::protobuf::uint8* target) const { + (void)deterministic; // Unused + // @@protoc_insertion_point(serialize_to_array_start:caffe.TransformationParameter) // optional float scale = 1 [default = 1]; if (has_scale()) { target = ::google::protobuf::internal::WireFormatLite::WriteFloatToArray(1, this->scale(), target); @@ -12535,9 +19125,10 @@ void TransformationParameter::SerializeWithCachedSizes( // optional string mean_file = 4; if (has_mean_file()) { - ::google::protobuf::internal::WireFormat::VerifyUTF8String( + ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( this->mean_file().data(), this->mean_file().length(), - ::google::protobuf::internal::WireFormat::SERIALIZE); + ::google::protobuf::internal::WireFormat::SERIALIZE, + "caffe.TransformationParameter.mean_file"); target = ::google::protobuf::internal::WireFormatLite::WriteStringToArray( 4, this->mean_file(), target); @@ -12559,17 +19150,19 @@ void TransformationParameter::SerializeWithCachedSizes( target = ::google::protobuf::internal::WireFormatLite::WriteBoolToArray(7, this->force_gray(), target); } - if (!unknown_fields().empty()) { + if (_internal_metadata_.have_unknown_fields()) { target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray( unknown_fields(), target); } + // @@protoc_insertion_point(serialize_to_array_end:caffe.TransformationParameter) return target; } -int TransformationParameter::ByteSize() const { - int total_size = 0; +size_t TransformationParameter::ByteSizeLong() const { +// @@protoc_insertion_point(message_byte_size_start:caffe.TransformationParameter) + size_t total_size = 0; - if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) { + if (_has_bits_[0 / 32] & 111u) { // optional float scale = 1 [default = 1]; if (has_scale()) { total_size += 1 + 4; @@ -12607,37 +19200,53 @@ int TransformationParameter::ByteSize() const { } // repeated float mean_value = 5; { - int data_size = 0; - data_size = 4 * this->mean_value_size(); - total_size += 1 * this->mean_value_size() + data_size; + size_t data_size = 0; + unsigned int count = this->mean_value_size(); + data_size = 4UL * count; + total_size += 1 * + ::google::protobuf::internal::FromIntSize(this->mean_value_size()); + total_size += data_size; } - if (!unknown_fields().empty()) { + if (_internal_metadata_.have_unknown_fields()) { total_size += ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( unknown_fields()); } + int cached_size = ::google::protobuf::internal::ToCachedSize(total_size); GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); - _cached_size_ = total_size; + _cached_size_ = cached_size; GOOGLE_SAFE_CONCURRENT_WRITES_END(); return total_size; } void TransformationParameter::MergeFrom(const ::google::protobuf::Message& from) { - GOOGLE_CHECK_NE(&from, this); +// @@protoc_insertion_point(generalized_merge_from_start:caffe.TransformationParameter) + if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__); const TransformationParameter* source = - ::google::protobuf::internal::dynamic_cast_if_available( - &from); + ::google::protobuf::internal::DynamicCastToGenerated( + &from); if (source == NULL) { + // @@protoc_insertion_point(generalized_merge_from_cast_fail:caffe.TransformationParameter) ::google::protobuf::internal::ReflectionOps::Merge(from, this); } else { - MergeFrom(*source); + // @@protoc_insertion_point(generalized_merge_from_cast_success:caffe.TransformationParameter) + UnsafeMergeFrom(*source); } } void TransformationParameter::MergeFrom(const TransformationParameter& from) { - GOOGLE_CHECK_NE(&from, this); - mean_value_.MergeFrom(from.mean_value_); +// @@protoc_insertion_point(class_specific_merge_from_start:caffe.TransformationParameter) + if (GOOGLE_PREDICT_TRUE(&from != this)) { + UnsafeMergeFrom(from); + } else { + MergeFromFail(__LINE__); + } +} + +void TransformationParameter::UnsafeMergeFrom(const TransformationParameter& from) { + GOOGLE_DCHECK(&from != this); + mean_value_.UnsafeMergeFrom(from.mean_value_); if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) { if (from.has_scale()) { set_scale(from.scale()); @@ -12649,7 +19258,8 @@ void TransformationParameter::MergeFrom(const TransformationParameter& from) { set_crop_size(from.crop_size()); } if (from.has_mean_file()) { - set_mean_file(from.mean_file()); + set_has_mean_file(); + mean_file_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.mean_file_); } if (from.has_force_color()) { set_force_color(from.force_color()); @@ -12658,85 +19268,305 @@ void TransformationParameter::MergeFrom(const TransformationParameter& from) { set_force_gray(from.force_gray()); } } - mutable_unknown_fields()->MergeFrom(from.unknown_fields()); + if (from._internal_metadata_.have_unknown_fields()) { + ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata( + from.unknown_fields(), &_internal_metadata_); + } } void TransformationParameter::CopyFrom(const ::google::protobuf::Message& from) { +// @@protoc_insertion_point(generalized_copy_from_start:caffe.TransformationParameter) if (&from == this) return; Clear(); MergeFrom(from); } -void TransformationParameter::CopyFrom(const TransformationParameter& from) { - if (&from == this) return; - Clear(); - MergeFrom(from); +void TransformationParameter::CopyFrom(const TransformationParameter& from) { +// @@protoc_insertion_point(class_specific_copy_from_start:caffe.TransformationParameter) + if (&from == this) return; + Clear(); + UnsafeMergeFrom(from); +} + +bool TransformationParameter::IsInitialized() const { + + return true; +} + +void TransformationParameter::Swap(TransformationParameter* other) { + if (other == this) return; + InternalSwap(other); +} +void TransformationParameter::InternalSwap(TransformationParameter* other) { + std::swap(scale_, other->scale_); + std::swap(mirror_, other->mirror_); + std::swap(crop_size_, other->crop_size_); + mean_file_.Swap(&other->mean_file_); + mean_value_.UnsafeArenaSwap(&other->mean_value_); + std::swap(force_color_, other->force_color_); + std::swap(force_gray_, other->force_gray_); + std::swap(_has_bits_[0], other->_has_bits_[0]); + _internal_metadata_.Swap(&other->_internal_metadata_); + std::swap(_cached_size_, other->_cached_size_); +} + +::google::protobuf::Metadata TransformationParameter::GetMetadata() const { + protobuf_AssignDescriptorsOnce(); + ::google::protobuf::Metadata metadata; + metadata.descriptor = TransformationParameter_descriptor_; + metadata.reflection = TransformationParameter_reflection_; + return metadata; +} + +#if PROTOBUF_INLINE_NOT_IN_HEADERS +// TransformationParameter + +// optional float scale = 1 [default = 1]; +bool TransformationParameter::has_scale() const { + return (_has_bits_[0] & 0x00000001u) != 0; +} +void TransformationParameter::set_has_scale() { + _has_bits_[0] |= 0x00000001u; +} +void TransformationParameter::clear_has_scale() { + _has_bits_[0] &= ~0x00000001u; +} +void TransformationParameter::clear_scale() { + scale_ = 1; + clear_has_scale(); +} +float TransformationParameter::scale() const { + // @@protoc_insertion_point(field_get:caffe.TransformationParameter.scale) + return scale_; +} +void TransformationParameter::set_scale(float value) { + set_has_scale(); + scale_ = value; + // @@protoc_insertion_point(field_set:caffe.TransformationParameter.scale) +} + +// optional bool mirror = 2 [default = false]; +bool TransformationParameter::has_mirror() const { + return (_has_bits_[0] & 0x00000002u) != 0; +} +void TransformationParameter::set_has_mirror() { + _has_bits_[0] |= 0x00000002u; +} +void TransformationParameter::clear_has_mirror() { + _has_bits_[0] &= ~0x00000002u; +} +void TransformationParameter::clear_mirror() { + mirror_ = false; + clear_has_mirror(); +} +bool TransformationParameter::mirror() const { + // @@protoc_insertion_point(field_get:caffe.TransformationParameter.mirror) + return mirror_; +} +void TransformationParameter::set_mirror(bool value) { + set_has_mirror(); + mirror_ = value; + // @@protoc_insertion_point(field_set:caffe.TransformationParameter.mirror) +} + +// optional uint32 crop_size = 3 [default = 0]; +bool TransformationParameter::has_crop_size() const { + return (_has_bits_[0] & 0x00000004u) != 0; +} +void TransformationParameter::set_has_crop_size() { + _has_bits_[0] |= 0x00000004u; +} +void TransformationParameter::clear_has_crop_size() { + _has_bits_[0] &= ~0x00000004u; +} +void TransformationParameter::clear_crop_size() { + crop_size_ = 0u; + clear_has_crop_size(); +} +::google::protobuf::uint32 TransformationParameter::crop_size() const { + // @@protoc_insertion_point(field_get:caffe.TransformationParameter.crop_size) + return crop_size_; +} +void TransformationParameter::set_crop_size(::google::protobuf::uint32 value) { + set_has_crop_size(); + crop_size_ = value; + // @@protoc_insertion_point(field_set:caffe.TransformationParameter.crop_size) } -bool TransformationParameter::IsInitialized() const { +// optional string mean_file = 4; +bool TransformationParameter::has_mean_file() const { + return (_has_bits_[0] & 0x00000008u) != 0; +} +void TransformationParameter::set_has_mean_file() { + _has_bits_[0] |= 0x00000008u; +} +void TransformationParameter::clear_has_mean_file() { + _has_bits_[0] &= ~0x00000008u; +} +void TransformationParameter::clear_mean_file() { + mean_file_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + clear_has_mean_file(); +} +const ::std::string& TransformationParameter::mean_file() const { + // @@protoc_insertion_point(field_get:caffe.TransformationParameter.mean_file) + return mean_file_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); +} +void TransformationParameter::set_mean_file(const ::std::string& value) { + set_has_mean_file(); + mean_file_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); + // @@protoc_insertion_point(field_set:caffe.TransformationParameter.mean_file) +} +void TransformationParameter::set_mean_file(const char* value) { + set_has_mean_file(); + mean_file_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); + // @@protoc_insertion_point(field_set_char:caffe.TransformationParameter.mean_file) +} +void TransformationParameter::set_mean_file(const char* value, size_t size) { + set_has_mean_file(); + mean_file_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), + ::std::string(reinterpret_cast(value), size)); + // @@protoc_insertion_point(field_set_pointer:caffe.TransformationParameter.mean_file) +} +::std::string* TransformationParameter::mutable_mean_file() { + set_has_mean_file(); + // @@protoc_insertion_point(field_mutable:caffe.TransformationParameter.mean_file) + return mean_file_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); +} +::std::string* TransformationParameter::release_mean_file() { + // @@protoc_insertion_point(field_release:caffe.TransformationParameter.mean_file) + clear_has_mean_file(); + return mean_file_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); +} +void TransformationParameter::set_allocated_mean_file(::std::string* mean_file) { + if (mean_file != NULL) { + set_has_mean_file(); + } else { + clear_has_mean_file(); + } + mean_file_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), mean_file); + // @@protoc_insertion_point(field_set_allocated:caffe.TransformationParameter.mean_file) +} - return true; +// repeated float mean_value = 5; +int TransformationParameter::mean_value_size() const { + return mean_value_.size(); +} +void TransformationParameter::clear_mean_value() { + mean_value_.Clear(); +} +float TransformationParameter::mean_value(int index) const { + // @@protoc_insertion_point(field_get:caffe.TransformationParameter.mean_value) + return mean_value_.Get(index); +} +void TransformationParameter::set_mean_value(int index, float value) { + mean_value_.Set(index, value); + // @@protoc_insertion_point(field_set:caffe.TransformationParameter.mean_value) +} +void TransformationParameter::add_mean_value(float value) { + mean_value_.Add(value); + // @@protoc_insertion_point(field_add:caffe.TransformationParameter.mean_value) +} +const ::google::protobuf::RepeatedField< float >& +TransformationParameter::mean_value() const { + // @@protoc_insertion_point(field_list:caffe.TransformationParameter.mean_value) + return mean_value_; +} +::google::protobuf::RepeatedField< float >* +TransformationParameter::mutable_mean_value() { + // @@protoc_insertion_point(field_mutable_list:caffe.TransformationParameter.mean_value) + return &mean_value_; } -void TransformationParameter::Swap(TransformationParameter* other) { - if (other != this) { - std::swap(scale_, other->scale_); - std::swap(mirror_, other->mirror_); - std::swap(crop_size_, other->crop_size_); - std::swap(mean_file_, other->mean_file_); - mean_value_.Swap(&other->mean_value_); - std::swap(force_color_, other->force_color_); - std::swap(force_gray_, other->force_gray_); - std::swap(_has_bits_[0], other->_has_bits_[0]); - _unknown_fields_.Swap(&other->_unknown_fields_); - std::swap(_cached_size_, other->_cached_size_); - } +// optional bool force_color = 6 [default = false]; +bool TransformationParameter::has_force_color() const { + return (_has_bits_[0] & 0x00000020u) != 0; +} +void TransformationParameter::set_has_force_color() { + _has_bits_[0] |= 0x00000020u; +} +void TransformationParameter::clear_has_force_color() { + _has_bits_[0] &= ~0x00000020u; +} +void TransformationParameter::clear_force_color() { + force_color_ = false; + clear_has_force_color(); +} +bool TransformationParameter::force_color() const { + // @@protoc_insertion_point(field_get:caffe.TransformationParameter.force_color) + return force_color_; +} +void TransformationParameter::set_force_color(bool value) { + set_has_force_color(); + force_color_ = value; + // @@protoc_insertion_point(field_set:caffe.TransformationParameter.force_color) } -::google::protobuf::Metadata TransformationParameter::GetMetadata() const { - protobuf_AssignDescriptorsOnce(); - ::google::protobuf::Metadata metadata; - metadata.descriptor = TransformationParameter_descriptor_; - metadata.reflection = TransformationParameter_reflection_; - return metadata; +// optional bool force_gray = 7 [default = false]; +bool TransformationParameter::has_force_gray() const { + return (_has_bits_[0] & 0x00000040u) != 0; +} +void TransformationParameter::set_has_force_gray() { + _has_bits_[0] |= 0x00000040u; +} +void TransformationParameter::clear_has_force_gray() { + _has_bits_[0] &= ~0x00000040u; +} +void TransformationParameter::clear_force_gray() { + force_gray_ = false; + clear_has_force_gray(); +} +bool TransformationParameter::force_gray() const { + // @@protoc_insertion_point(field_get:caffe.TransformationParameter.force_gray) + return force_gray_; +} +void TransformationParameter::set_force_gray(bool value) { + set_has_force_gray(); + force_gray_ = value; + // @@protoc_insertion_point(field_set:caffe.TransformationParameter.force_gray) } +inline const TransformationParameter* TransformationParameter::internal_default_instance() { + return &TransformationParameter_default_instance_.get(); +} +#endif // PROTOBUF_INLINE_NOT_IN_HEADERS // =================================================================== -#ifndef _MSC_VER +#if !defined(_MSC_VER) || _MSC_VER >= 1900 const int LossParameter::kIgnoreLabelFieldNumber; const int LossParameter::kNormalizeFieldNumber; -#endif // !_MSC_VER +#endif // !defined(_MSC_VER) || _MSC_VER >= 1900 LossParameter::LossParameter() - : ::google::protobuf::Message() { + : ::google::protobuf::Message(), _internal_metadata_(NULL) { + if (this != internal_default_instance()) protobuf_InitDefaults_caffe_2eproto(); SharedCtor(); + // @@protoc_insertion_point(constructor:caffe.LossParameter) } void LossParameter::InitAsDefaultInstance() { } LossParameter::LossParameter(const LossParameter& from) - : ::google::protobuf::Message() { + : ::google::protobuf::Message(), + _internal_metadata_(NULL) { SharedCtor(); - MergeFrom(from); + UnsafeMergeFrom(from); + // @@protoc_insertion_point(copy_constructor:caffe.LossParameter) } void LossParameter::SharedCtor() { _cached_size_ = 0; ignore_label_ = 0; normalize_ = true; - ::memset(_has_bits_, 0, sizeof(_has_bits_)); } LossParameter::~LossParameter() { + // @@protoc_insertion_point(destructor:caffe.LossParameter) SharedDtor(); } void LossParameter::SharedDtor() { - if (this != default_instance_) { - } } void LossParameter::SetCachedSize(int size) const { @@ -12750,41 +19580,51 @@ const ::google::protobuf::Descriptor* LossParameter::descriptor() { } const LossParameter& LossParameter::default_instance() { - if (default_instance_ == NULL) protobuf_AddDesc_caffe_2eproto(); - return *default_instance_; + protobuf_InitDefaults_caffe_2eproto(); + return *internal_default_instance(); } -LossParameter* LossParameter::default_instance_ = NULL; +::google::protobuf::internal::ExplicitlyConstructed LossParameter_default_instance_; -LossParameter* LossParameter::New() const { - return new LossParameter; +LossParameter* LossParameter::New(::google::protobuf::Arena* arena) const { + LossParameter* n = new LossParameter; + if (arena != NULL) { + arena->Own(n); + } + return n; } void LossParameter::Clear() { - if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) { +// @@protoc_insertion_point(message_clear_start:caffe.LossParameter) + if (_has_bits_[0 / 32] & 3u) { ignore_label_ = 0; normalize_ = true; } - ::memset(_has_bits_, 0, sizeof(_has_bits_)); - mutable_unknown_fields()->Clear(); + _has_bits_.Clear(); + if (_internal_metadata_.have_unknown_fields()) { + mutable_unknown_fields()->Clear(); + } } bool LossParameter::MergePartialFromCodedStream( ::google::protobuf::io::CodedInputStream* input) { -#define DO_(EXPRESSION) if (!(EXPRESSION)) return false +#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure ::google::protobuf::uint32 tag; - while ((tag = input->ReadTag()) != 0) { + // @@protoc_insertion_point(parse_start:caffe.LossParameter) + for (;;) { + ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127); + tag = p.first; + if (!p.second) goto handle_unusual; switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { // optional int32 ignore_label = 1; case 1: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) { + if (tag == 8) { + set_has_ignore_label(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>( input, &ignore_label_))); - set_has_ignore_label(); } else { - goto handle_uninterpreted; + goto handle_unusual; } if (input->ExpectTag(16)) goto parse_normalize; break; @@ -12792,25 +19632,25 @@ bool LossParameter::MergePartialFromCodedStream( // optional bool normalize = 2 [default = true]; case 2: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) { + if (tag == 16) { parse_normalize: + set_has_normalize(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>( input, &normalize_))); - set_has_normalize(); } else { - goto handle_uninterpreted; + goto handle_unusual; } - if (input->ExpectAtEnd()) return true; + if (input->ExpectAtEnd()) goto success; break; } default: { - handle_uninterpreted: - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == + handle_unusual: + if (tag == 0 || + ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) { - return true; + goto success; } DO_(::google::protobuf::internal::WireFormat::SkipField( input, tag, mutable_unknown_fields())); @@ -12818,12 +19658,18 @@ bool LossParameter::MergePartialFromCodedStream( } } } +success: + // @@protoc_insertion_point(parse_success:caffe.LossParameter) return true; +failure: + // @@protoc_insertion_point(parse_failure:caffe.LossParameter) + return false; #undef DO_ } void LossParameter::SerializeWithCachedSizes( ::google::protobuf::io::CodedOutputStream* output) const { + // @@protoc_insertion_point(serialize_start:caffe.LossParameter) // optional int32 ignore_label = 1; if (has_ignore_label()) { ::google::protobuf::internal::WireFormatLite::WriteInt32(1, this->ignore_label(), output); @@ -12834,14 +19680,17 @@ void LossParameter::SerializeWithCachedSizes( ::google::protobuf::internal::WireFormatLite::WriteBool(2, this->normalize(), output); } - if (!unknown_fields().empty()) { + if (_internal_metadata_.have_unknown_fields()) { ::google::protobuf::internal::WireFormat::SerializeUnknownFields( unknown_fields(), output); } + // @@protoc_insertion_point(serialize_end:caffe.LossParameter) } -::google::protobuf::uint8* LossParameter::SerializeWithCachedSizesToArray( - ::google::protobuf::uint8* target) const { +::google::protobuf::uint8* LossParameter::InternalSerializeWithCachedSizesToArray( + bool deterministic, ::google::protobuf::uint8* target) const { + (void)deterministic; // Unused + // @@protoc_insertion_point(serialize_to_array_start:caffe.LossParameter) // optional int32 ignore_label = 1; if (has_ignore_label()) { target = ::google::protobuf::internal::WireFormatLite::WriteInt32ToArray(1, this->ignore_label(), target); @@ -12852,17 +19701,19 @@ void LossParameter::SerializeWithCachedSizes( target = ::google::protobuf::internal::WireFormatLite::WriteBoolToArray(2, this->normalize(), target); } - if (!unknown_fields().empty()) { + if (_internal_metadata_.have_unknown_fields()) { target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray( unknown_fields(), target); } + // @@protoc_insertion_point(serialize_to_array_end:caffe.LossParameter) return target; } -int LossParameter::ByteSize() const { - int total_size = 0; +size_t LossParameter::ByteSizeLong() const { +// @@protoc_insertion_point(message_byte_size_start:caffe.LossParameter) + size_t total_size = 0; - if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) { + if (_has_bits_[0 / 32] & 3u) { // optional int32 ignore_label = 1; if (has_ignore_label()) { total_size += 1 + @@ -12876,31 +19727,44 @@ int LossParameter::ByteSize() const { } } - if (!unknown_fields().empty()) { + if (_internal_metadata_.have_unknown_fields()) { total_size += ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( unknown_fields()); } + int cached_size = ::google::protobuf::internal::ToCachedSize(total_size); GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); - _cached_size_ = total_size; + _cached_size_ = cached_size; GOOGLE_SAFE_CONCURRENT_WRITES_END(); return total_size; } void LossParameter::MergeFrom(const ::google::protobuf::Message& from) { - GOOGLE_CHECK_NE(&from, this); +// @@protoc_insertion_point(generalized_merge_from_start:caffe.LossParameter) + if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__); const LossParameter* source = - ::google::protobuf::internal::dynamic_cast_if_available( - &from); + ::google::protobuf::internal::DynamicCastToGenerated( + &from); if (source == NULL) { + // @@protoc_insertion_point(generalized_merge_from_cast_fail:caffe.LossParameter) ::google::protobuf::internal::ReflectionOps::Merge(from, this); } else { - MergeFrom(*source); + // @@protoc_insertion_point(generalized_merge_from_cast_success:caffe.LossParameter) + UnsafeMergeFrom(*source); } } void LossParameter::MergeFrom(const LossParameter& from) { - GOOGLE_CHECK_NE(&from, this); +// @@protoc_insertion_point(class_specific_merge_from_start:caffe.LossParameter) + if (GOOGLE_PREDICT_TRUE(&from != this)) { + UnsafeMergeFrom(from); + } else { + MergeFromFail(__LINE__); + } +} + +void LossParameter::UnsafeMergeFrom(const LossParameter& from) { + GOOGLE_DCHECK(&from != this); if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) { if (from.has_ignore_label()) { set_ignore_label(from.ignore_label()); @@ -12909,19 +19773,24 @@ void LossParameter::MergeFrom(const LossParameter& from) { set_normalize(from.normalize()); } } - mutable_unknown_fields()->MergeFrom(from.unknown_fields()); + if (from._internal_metadata_.have_unknown_fields()) { + ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata( + from.unknown_fields(), &_internal_metadata_); + } } void LossParameter::CopyFrom(const ::google::protobuf::Message& from) { +// @@protoc_insertion_point(generalized_copy_from_start:caffe.LossParameter) if (&from == this) return; Clear(); MergeFrom(from); } void LossParameter::CopyFrom(const LossParameter& from) { +// @@protoc_insertion_point(class_specific_copy_from_start:caffe.LossParameter) if (&from == this) return; Clear(); - MergeFrom(from); + UnsafeMergeFrom(from); } bool LossParameter::IsInitialized() const { @@ -12930,13 +19799,15 @@ bool LossParameter::IsInitialized() const { } void LossParameter::Swap(LossParameter* other) { - if (other != this) { - std::swap(ignore_label_, other->ignore_label_); - std::swap(normalize_, other->normalize_); - std::swap(_has_bits_[0], other->_has_bits_[0]); - _unknown_fields_.Swap(&other->_unknown_fields_); - std::swap(_cached_size_, other->_cached_size_); - } + if (other == this) return; + InternalSwap(other); +} +void LossParameter::InternalSwap(LossParameter* other) { + std::swap(ignore_label_, other->ignore_label_); + std::swap(normalize_, other->normalize_); + std::swap(_has_bits_[0], other->_has_bits_[0]); + _internal_metadata_.Swap(&other->_internal_metadata_); + std::swap(_cached_size_, other->_cached_size_); } ::google::protobuf::Metadata LossParameter::GetMetadata() const { @@ -12947,44 +19818,101 @@ void LossParameter::Swap(LossParameter* other) { return metadata; } +#if PROTOBUF_INLINE_NOT_IN_HEADERS +// LossParameter + +// optional int32 ignore_label = 1; +bool LossParameter::has_ignore_label() const { + return (_has_bits_[0] & 0x00000001u) != 0; +} +void LossParameter::set_has_ignore_label() { + _has_bits_[0] |= 0x00000001u; +} +void LossParameter::clear_has_ignore_label() { + _has_bits_[0] &= ~0x00000001u; +} +void LossParameter::clear_ignore_label() { + ignore_label_ = 0; + clear_has_ignore_label(); +} +::google::protobuf::int32 LossParameter::ignore_label() const { + // @@protoc_insertion_point(field_get:caffe.LossParameter.ignore_label) + return ignore_label_; +} +void LossParameter::set_ignore_label(::google::protobuf::int32 value) { + set_has_ignore_label(); + ignore_label_ = value; + // @@protoc_insertion_point(field_set:caffe.LossParameter.ignore_label) +} + +// optional bool normalize = 2 [default = true]; +bool LossParameter::has_normalize() const { + return (_has_bits_[0] & 0x00000002u) != 0; +} +void LossParameter::set_has_normalize() { + _has_bits_[0] |= 0x00000002u; +} +void LossParameter::clear_has_normalize() { + _has_bits_[0] &= ~0x00000002u; +} +void LossParameter::clear_normalize() { + normalize_ = true; + clear_has_normalize(); +} +bool LossParameter::normalize() const { + // @@protoc_insertion_point(field_get:caffe.LossParameter.normalize) + return normalize_; +} +void LossParameter::set_normalize(bool value) { + set_has_normalize(); + normalize_ = value; + // @@protoc_insertion_point(field_set:caffe.LossParameter.normalize) +} + +inline const LossParameter* LossParameter::internal_default_instance() { + return &LossParameter_default_instance_.get(); +} +#endif // PROTOBUF_INLINE_NOT_IN_HEADERS // =================================================================== -#ifndef _MSC_VER +#if !defined(_MSC_VER) || _MSC_VER >= 1900 const int AccuracyParameter::kTopKFieldNumber; const int AccuracyParameter::kAxisFieldNumber; const int AccuracyParameter::kIgnoreLabelFieldNumber; -#endif // !_MSC_VER +#endif // !defined(_MSC_VER) || _MSC_VER >= 1900 AccuracyParameter::AccuracyParameter() - : ::google::protobuf::Message() { + : ::google::protobuf::Message(), _internal_metadata_(NULL) { + if (this != internal_default_instance()) protobuf_InitDefaults_caffe_2eproto(); SharedCtor(); + // @@protoc_insertion_point(constructor:caffe.AccuracyParameter) } void AccuracyParameter::InitAsDefaultInstance() { } AccuracyParameter::AccuracyParameter(const AccuracyParameter& from) - : ::google::protobuf::Message() { + : ::google::protobuf::Message(), + _internal_metadata_(NULL) { SharedCtor(); - MergeFrom(from); + UnsafeMergeFrom(from); + // @@protoc_insertion_point(copy_constructor:caffe.AccuracyParameter) } void AccuracyParameter::SharedCtor() { _cached_size_ = 0; + ignore_label_ = 0; top_k_ = 1u; axis_ = 1; - ignore_label_ = 0; - ::memset(_has_bits_, 0, sizeof(_has_bits_)); } AccuracyParameter::~AccuracyParameter() { + // @@protoc_insertion_point(destructor:caffe.AccuracyParameter) SharedDtor(); } void AccuracyParameter::SharedDtor() { - if (this != default_instance_) { - } } void AccuracyParameter::SetCachedSize(int size) const { @@ -12998,42 +19926,52 @@ const ::google::protobuf::Descriptor* AccuracyParameter::descriptor() { } const AccuracyParameter& AccuracyParameter::default_instance() { - if (default_instance_ == NULL) protobuf_AddDesc_caffe_2eproto(); - return *default_instance_; + protobuf_InitDefaults_caffe_2eproto(); + return *internal_default_instance(); } -AccuracyParameter* AccuracyParameter::default_instance_ = NULL; +::google::protobuf::internal::ExplicitlyConstructed AccuracyParameter_default_instance_; -AccuracyParameter* AccuracyParameter::New() const { - return new AccuracyParameter; +AccuracyParameter* AccuracyParameter::New(::google::protobuf::Arena* arena) const { + AccuracyParameter* n = new AccuracyParameter; + if (arena != NULL) { + arena->Own(n); + } + return n; } void AccuracyParameter::Clear() { - if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) { +// @@protoc_insertion_point(message_clear_start:caffe.AccuracyParameter) + if (_has_bits_[0 / 32] & 7u) { top_k_ = 1u; axis_ = 1; ignore_label_ = 0; } - ::memset(_has_bits_, 0, sizeof(_has_bits_)); - mutable_unknown_fields()->Clear(); + _has_bits_.Clear(); + if (_internal_metadata_.have_unknown_fields()) { + mutable_unknown_fields()->Clear(); + } } bool AccuracyParameter::MergePartialFromCodedStream( ::google::protobuf::io::CodedInputStream* input) { -#define DO_(EXPRESSION) if (!(EXPRESSION)) return false +#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure ::google::protobuf::uint32 tag; - while ((tag = input->ReadTag()) != 0) { + // @@protoc_insertion_point(parse_start:caffe.AccuracyParameter) + for (;;) { + ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127); + tag = p.first; + if (!p.second) goto handle_unusual; switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { // optional uint32 top_k = 1 [default = 1]; case 1: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) { + if (tag == 8) { + set_has_top_k(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>( input, &top_k_))); - set_has_top_k(); } else { - goto handle_uninterpreted; + goto handle_unusual; } if (input->ExpectTag(16)) goto parse_axis; break; @@ -13041,15 +19979,14 @@ bool AccuracyParameter::MergePartialFromCodedStream( // optional int32 axis = 2 [default = 1]; case 2: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) { + if (tag == 16) { parse_axis: + set_has_axis(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>( input, &axis_))); - set_has_axis(); } else { - goto handle_uninterpreted; + goto handle_unusual; } if (input->ExpectTag(24)) goto parse_ignore_label; break; @@ -13057,25 +19994,25 @@ bool AccuracyParameter::MergePartialFromCodedStream( // optional int32 ignore_label = 3; case 3: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) { + if (tag == 24) { parse_ignore_label: + set_has_ignore_label(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>( input, &ignore_label_))); - set_has_ignore_label(); } else { - goto handle_uninterpreted; + goto handle_unusual; } - if (input->ExpectAtEnd()) return true; + if (input->ExpectAtEnd()) goto success; break; } default: { - handle_uninterpreted: - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == + handle_unusual: + if (tag == 0 || + ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) { - return true; + goto success; } DO_(::google::protobuf::internal::WireFormat::SkipField( input, tag, mutable_unknown_fields())); @@ -13083,12 +20020,18 @@ bool AccuracyParameter::MergePartialFromCodedStream( } } } +success: + // @@protoc_insertion_point(parse_success:caffe.AccuracyParameter) return true; +failure: + // @@protoc_insertion_point(parse_failure:caffe.AccuracyParameter) + return false; #undef DO_ } void AccuracyParameter::SerializeWithCachedSizes( ::google::protobuf::io::CodedOutputStream* output) const { + // @@protoc_insertion_point(serialize_start:caffe.AccuracyParameter) // optional uint32 top_k = 1 [default = 1]; if (has_top_k()) { ::google::protobuf::internal::WireFormatLite::WriteUInt32(1, this->top_k(), output); @@ -13104,14 +20047,17 @@ void AccuracyParameter::SerializeWithCachedSizes( ::google::protobuf::internal::WireFormatLite::WriteInt32(3, this->ignore_label(), output); } - if (!unknown_fields().empty()) { + if (_internal_metadata_.have_unknown_fields()) { ::google::protobuf::internal::WireFormat::SerializeUnknownFields( unknown_fields(), output); } + // @@protoc_insertion_point(serialize_end:caffe.AccuracyParameter) } -::google::protobuf::uint8* AccuracyParameter::SerializeWithCachedSizesToArray( - ::google::protobuf::uint8* target) const { +::google::protobuf::uint8* AccuracyParameter::InternalSerializeWithCachedSizesToArray( + bool deterministic, ::google::protobuf::uint8* target) const { + (void)deterministic; // Unused + // @@protoc_insertion_point(serialize_to_array_start:caffe.AccuracyParameter) // optional uint32 top_k = 1 [default = 1]; if (has_top_k()) { target = ::google::protobuf::internal::WireFormatLite::WriteUInt32ToArray(1, this->top_k(), target); @@ -13127,17 +20073,19 @@ void AccuracyParameter::SerializeWithCachedSizes( target = ::google::protobuf::internal::WireFormatLite::WriteInt32ToArray(3, this->ignore_label(), target); } - if (!unknown_fields().empty()) { + if (_internal_metadata_.have_unknown_fields()) { target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray( unknown_fields(), target); } + // @@protoc_insertion_point(serialize_to_array_end:caffe.AccuracyParameter) return target; } -int AccuracyParameter::ByteSize() const { - int total_size = 0; +size_t AccuracyParameter::ByteSizeLong() const { +// @@protoc_insertion_point(message_byte_size_start:caffe.AccuracyParameter) + size_t total_size = 0; - if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) { + if (_has_bits_[0 / 32] & 7u) { // optional uint32 top_k = 1 [default = 1]; if (has_top_k()) { total_size += 1 + @@ -13160,31 +20108,44 @@ int AccuracyParameter::ByteSize() const { } } - if (!unknown_fields().empty()) { + if (_internal_metadata_.have_unknown_fields()) { total_size += ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( unknown_fields()); } + int cached_size = ::google::protobuf::internal::ToCachedSize(total_size); GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); - _cached_size_ = total_size; + _cached_size_ = cached_size; GOOGLE_SAFE_CONCURRENT_WRITES_END(); return total_size; } void AccuracyParameter::MergeFrom(const ::google::protobuf::Message& from) { - GOOGLE_CHECK_NE(&from, this); +// @@protoc_insertion_point(generalized_merge_from_start:caffe.AccuracyParameter) + if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__); const AccuracyParameter* source = - ::google::protobuf::internal::dynamic_cast_if_available( - &from); + ::google::protobuf::internal::DynamicCastToGenerated( + &from); if (source == NULL) { + // @@protoc_insertion_point(generalized_merge_from_cast_fail:caffe.AccuracyParameter) ::google::protobuf::internal::ReflectionOps::Merge(from, this); } else { - MergeFrom(*source); + // @@protoc_insertion_point(generalized_merge_from_cast_success:caffe.AccuracyParameter) + UnsafeMergeFrom(*source); } } void AccuracyParameter::MergeFrom(const AccuracyParameter& from) { - GOOGLE_CHECK_NE(&from, this); +// @@protoc_insertion_point(class_specific_merge_from_start:caffe.AccuracyParameter) + if (GOOGLE_PREDICT_TRUE(&from != this)) { + UnsafeMergeFrom(from); + } else { + MergeFromFail(__LINE__); + } +} + +void AccuracyParameter::UnsafeMergeFrom(const AccuracyParameter& from) { + GOOGLE_DCHECK(&from != this); if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) { if (from.has_top_k()) { set_top_k(from.top_k()); @@ -13196,19 +20157,24 @@ void AccuracyParameter::MergeFrom(const AccuracyParameter& from) { set_ignore_label(from.ignore_label()); } } - mutable_unknown_fields()->MergeFrom(from.unknown_fields()); + if (from._internal_metadata_.have_unknown_fields()) { + ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata( + from.unknown_fields(), &_internal_metadata_); + } } void AccuracyParameter::CopyFrom(const ::google::protobuf::Message& from) { +// @@protoc_insertion_point(generalized_copy_from_start:caffe.AccuracyParameter) if (&from == this) return; Clear(); MergeFrom(from); } void AccuracyParameter::CopyFrom(const AccuracyParameter& from) { +// @@protoc_insertion_point(class_specific_copy_from_start:caffe.AccuracyParameter) if (&from == this) return; Clear(); - MergeFrom(from); + UnsafeMergeFrom(from); } bool AccuracyParameter::IsInitialized() const { @@ -13217,14 +20183,16 @@ bool AccuracyParameter::IsInitialized() const { } void AccuracyParameter::Swap(AccuracyParameter* other) { - if (other != this) { - std::swap(top_k_, other->top_k_); - std::swap(axis_, other->axis_); - std::swap(ignore_label_, other->ignore_label_); - std::swap(_has_bits_[0], other->_has_bits_[0]); - _unknown_fields_.Swap(&other->_unknown_fields_); - std::swap(_cached_size_, other->_cached_size_); - } + if (other == this) return; + InternalSwap(other); +} +void AccuracyParameter::InternalSwap(AccuracyParameter* other) { + std::swap(top_k_, other->top_k_); + std::swap(axis_, other->axis_); + std::swap(ignore_label_, other->ignore_label_); + std::swap(_has_bits_[0], other->_has_bits_[0]); + _internal_metadata_.Swap(&other->_internal_metadata_); + std::swap(_cached_size_, other->_cached_size_); } ::google::protobuf::Metadata AccuracyParameter::GetMetadata() const { @@ -13235,42 +20203,123 @@ void AccuracyParameter::Swap(AccuracyParameter* other) { return metadata; } +#if PROTOBUF_INLINE_NOT_IN_HEADERS +// AccuracyParameter + +// optional uint32 top_k = 1 [default = 1]; +bool AccuracyParameter::has_top_k() const { + return (_has_bits_[0] & 0x00000001u) != 0; +} +void AccuracyParameter::set_has_top_k() { + _has_bits_[0] |= 0x00000001u; +} +void AccuracyParameter::clear_has_top_k() { + _has_bits_[0] &= ~0x00000001u; +} +void AccuracyParameter::clear_top_k() { + top_k_ = 1u; + clear_has_top_k(); +} +::google::protobuf::uint32 AccuracyParameter::top_k() const { + // @@protoc_insertion_point(field_get:caffe.AccuracyParameter.top_k) + return top_k_; +} +void AccuracyParameter::set_top_k(::google::protobuf::uint32 value) { + set_has_top_k(); + top_k_ = value; + // @@protoc_insertion_point(field_set:caffe.AccuracyParameter.top_k) +} + +// optional int32 axis = 2 [default = 1]; +bool AccuracyParameter::has_axis() const { + return (_has_bits_[0] & 0x00000002u) != 0; +} +void AccuracyParameter::set_has_axis() { + _has_bits_[0] |= 0x00000002u; +} +void AccuracyParameter::clear_has_axis() { + _has_bits_[0] &= ~0x00000002u; +} +void AccuracyParameter::clear_axis() { + axis_ = 1; + clear_has_axis(); +} +::google::protobuf::int32 AccuracyParameter::axis() const { + // @@protoc_insertion_point(field_get:caffe.AccuracyParameter.axis) + return axis_; +} +void AccuracyParameter::set_axis(::google::protobuf::int32 value) { + set_has_axis(); + axis_ = value; + // @@protoc_insertion_point(field_set:caffe.AccuracyParameter.axis) +} + +// optional int32 ignore_label = 3; +bool AccuracyParameter::has_ignore_label() const { + return (_has_bits_[0] & 0x00000004u) != 0; +} +void AccuracyParameter::set_has_ignore_label() { + _has_bits_[0] |= 0x00000004u; +} +void AccuracyParameter::clear_has_ignore_label() { + _has_bits_[0] &= ~0x00000004u; +} +void AccuracyParameter::clear_ignore_label() { + ignore_label_ = 0; + clear_has_ignore_label(); +} +::google::protobuf::int32 AccuracyParameter::ignore_label() const { + // @@protoc_insertion_point(field_get:caffe.AccuracyParameter.ignore_label) + return ignore_label_; +} +void AccuracyParameter::set_ignore_label(::google::protobuf::int32 value) { + set_has_ignore_label(); + ignore_label_ = value; + // @@protoc_insertion_point(field_set:caffe.AccuracyParameter.ignore_label) +} + +inline const AccuracyParameter* AccuracyParameter::internal_default_instance() { + return &AccuracyParameter_default_instance_.get(); +} +#endif // PROTOBUF_INLINE_NOT_IN_HEADERS // =================================================================== -#ifndef _MSC_VER +#if !defined(_MSC_VER) || _MSC_VER >= 1900 const int ArgMaxParameter::kOutMaxValFieldNumber; const int ArgMaxParameter::kTopKFieldNumber; -#endif // !_MSC_VER +#endif // !defined(_MSC_VER) || _MSC_VER >= 1900 ArgMaxParameter::ArgMaxParameter() - : ::google::protobuf::Message() { + : ::google::protobuf::Message(), _internal_metadata_(NULL) { + if (this != internal_default_instance()) protobuf_InitDefaults_caffe_2eproto(); SharedCtor(); + // @@protoc_insertion_point(constructor:caffe.ArgMaxParameter) } void ArgMaxParameter::InitAsDefaultInstance() { } ArgMaxParameter::ArgMaxParameter(const ArgMaxParameter& from) - : ::google::protobuf::Message() { + : ::google::protobuf::Message(), + _internal_metadata_(NULL) { SharedCtor(); - MergeFrom(from); + UnsafeMergeFrom(from); + // @@protoc_insertion_point(copy_constructor:caffe.ArgMaxParameter) } void ArgMaxParameter::SharedCtor() { _cached_size_ = 0; out_max_val_ = false; top_k_ = 1u; - ::memset(_has_bits_, 0, sizeof(_has_bits_)); } ArgMaxParameter::~ArgMaxParameter() { + // @@protoc_insertion_point(destructor:caffe.ArgMaxParameter) SharedDtor(); } void ArgMaxParameter::SharedDtor() { - if (this != default_instance_) { - } } void ArgMaxParameter::SetCachedSize(int size) const { @@ -13284,41 +20333,51 @@ const ::google::protobuf::Descriptor* ArgMaxParameter::descriptor() { } const ArgMaxParameter& ArgMaxParameter::default_instance() { - if (default_instance_ == NULL) protobuf_AddDesc_caffe_2eproto(); - return *default_instance_; + protobuf_InitDefaults_caffe_2eproto(); + return *internal_default_instance(); } -ArgMaxParameter* ArgMaxParameter::default_instance_ = NULL; +::google::protobuf::internal::ExplicitlyConstructed ArgMaxParameter_default_instance_; -ArgMaxParameter* ArgMaxParameter::New() const { - return new ArgMaxParameter; +ArgMaxParameter* ArgMaxParameter::New(::google::protobuf::Arena* arena) const { + ArgMaxParameter* n = new ArgMaxParameter; + if (arena != NULL) { + arena->Own(n); + } + return n; } void ArgMaxParameter::Clear() { - if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) { +// @@protoc_insertion_point(message_clear_start:caffe.ArgMaxParameter) + if (_has_bits_[0 / 32] & 3u) { out_max_val_ = false; top_k_ = 1u; } - ::memset(_has_bits_, 0, sizeof(_has_bits_)); - mutable_unknown_fields()->Clear(); + _has_bits_.Clear(); + if (_internal_metadata_.have_unknown_fields()) { + mutable_unknown_fields()->Clear(); + } } bool ArgMaxParameter::MergePartialFromCodedStream( ::google::protobuf::io::CodedInputStream* input) { -#define DO_(EXPRESSION) if (!(EXPRESSION)) return false +#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure ::google::protobuf::uint32 tag; - while ((tag = input->ReadTag()) != 0) { + // @@protoc_insertion_point(parse_start:caffe.ArgMaxParameter) + for (;;) { + ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127); + tag = p.first; + if (!p.second) goto handle_unusual; switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { // optional bool out_max_val = 1 [default = false]; case 1: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) { + if (tag == 8) { + set_has_out_max_val(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>( input, &out_max_val_))); - set_has_out_max_val(); } else { - goto handle_uninterpreted; + goto handle_unusual; } if (input->ExpectTag(16)) goto parse_top_k; break; @@ -13326,25 +20385,25 @@ bool ArgMaxParameter::MergePartialFromCodedStream( // optional uint32 top_k = 2 [default = 1]; case 2: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) { + if (tag == 16) { parse_top_k: + set_has_top_k(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>( input, &top_k_))); - set_has_top_k(); } else { - goto handle_uninterpreted; + goto handle_unusual; } - if (input->ExpectAtEnd()) return true; + if (input->ExpectAtEnd()) goto success; break; } default: { - handle_uninterpreted: - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == + handle_unusual: + if (tag == 0 || + ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) { - return true; + goto success; } DO_(::google::protobuf::internal::WireFormat::SkipField( input, tag, mutable_unknown_fields())); @@ -13352,12 +20411,18 @@ bool ArgMaxParameter::MergePartialFromCodedStream( } } } +success: + // @@protoc_insertion_point(parse_success:caffe.ArgMaxParameter) return true; +failure: + // @@protoc_insertion_point(parse_failure:caffe.ArgMaxParameter) + return false; #undef DO_ } void ArgMaxParameter::SerializeWithCachedSizes( ::google::protobuf::io::CodedOutputStream* output) const { + // @@protoc_insertion_point(serialize_start:caffe.ArgMaxParameter) // optional bool out_max_val = 1 [default = false]; if (has_out_max_val()) { ::google::protobuf::internal::WireFormatLite::WriteBool(1, this->out_max_val(), output); @@ -13368,14 +20433,17 @@ void ArgMaxParameter::SerializeWithCachedSizes( ::google::protobuf::internal::WireFormatLite::WriteUInt32(2, this->top_k(), output); } - if (!unknown_fields().empty()) { + if (_internal_metadata_.have_unknown_fields()) { ::google::protobuf::internal::WireFormat::SerializeUnknownFields( unknown_fields(), output); } + // @@protoc_insertion_point(serialize_end:caffe.ArgMaxParameter) } -::google::protobuf::uint8* ArgMaxParameter::SerializeWithCachedSizesToArray( - ::google::protobuf::uint8* target) const { +::google::protobuf::uint8* ArgMaxParameter::InternalSerializeWithCachedSizesToArray( + bool deterministic, ::google::protobuf::uint8* target) const { + (void)deterministic; // Unused + // @@protoc_insertion_point(serialize_to_array_start:caffe.ArgMaxParameter) // optional bool out_max_val = 1 [default = false]; if (has_out_max_val()) { target = ::google::protobuf::internal::WireFormatLite::WriteBoolToArray(1, this->out_max_val(), target); @@ -13386,17 +20454,19 @@ void ArgMaxParameter::SerializeWithCachedSizes( target = ::google::protobuf::internal::WireFormatLite::WriteUInt32ToArray(2, this->top_k(), target); } - if (!unknown_fields().empty()) { + if (_internal_metadata_.have_unknown_fields()) { target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray( unknown_fields(), target); } + // @@protoc_insertion_point(serialize_to_array_end:caffe.ArgMaxParameter) return target; } -int ArgMaxParameter::ByteSize() const { - int total_size = 0; +size_t ArgMaxParameter::ByteSizeLong() const { +// @@protoc_insertion_point(message_byte_size_start:caffe.ArgMaxParameter) + size_t total_size = 0; - if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) { + if (_has_bits_[0 / 32] & 3u) { // optional bool out_max_val = 1 [default = false]; if (has_out_max_val()) { total_size += 1 + 1; @@ -13410,31 +20480,44 @@ int ArgMaxParameter::ByteSize() const { } } - if (!unknown_fields().empty()) { + if (_internal_metadata_.have_unknown_fields()) { total_size += ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( unknown_fields()); } + int cached_size = ::google::protobuf::internal::ToCachedSize(total_size); GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); - _cached_size_ = total_size; + _cached_size_ = cached_size; GOOGLE_SAFE_CONCURRENT_WRITES_END(); return total_size; } void ArgMaxParameter::MergeFrom(const ::google::protobuf::Message& from) { - GOOGLE_CHECK_NE(&from, this); +// @@protoc_insertion_point(generalized_merge_from_start:caffe.ArgMaxParameter) + if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__); const ArgMaxParameter* source = - ::google::protobuf::internal::dynamic_cast_if_available( - &from); + ::google::protobuf::internal::DynamicCastToGenerated( + &from); if (source == NULL) { + // @@protoc_insertion_point(generalized_merge_from_cast_fail:caffe.ArgMaxParameter) ::google::protobuf::internal::ReflectionOps::Merge(from, this); } else { - MergeFrom(*source); + // @@protoc_insertion_point(generalized_merge_from_cast_success:caffe.ArgMaxParameter) + UnsafeMergeFrom(*source); } } void ArgMaxParameter::MergeFrom(const ArgMaxParameter& from) { - GOOGLE_CHECK_NE(&from, this); +// @@protoc_insertion_point(class_specific_merge_from_start:caffe.ArgMaxParameter) + if (GOOGLE_PREDICT_TRUE(&from != this)) { + UnsafeMergeFrom(from); + } else { + MergeFromFail(__LINE__); + } +} + +void ArgMaxParameter::UnsafeMergeFrom(const ArgMaxParameter& from) { + GOOGLE_DCHECK(&from != this); if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) { if (from.has_out_max_val()) { set_out_max_val(from.out_max_val()); @@ -13443,19 +20526,24 @@ void ArgMaxParameter::MergeFrom(const ArgMaxParameter& from) { set_top_k(from.top_k()); } } - mutable_unknown_fields()->MergeFrom(from.unknown_fields()); + if (from._internal_metadata_.have_unknown_fields()) { + ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata( + from.unknown_fields(), &_internal_metadata_); + } } void ArgMaxParameter::CopyFrom(const ::google::protobuf::Message& from) { +// @@protoc_insertion_point(generalized_copy_from_start:caffe.ArgMaxParameter) if (&from == this) return; Clear(); MergeFrom(from); } void ArgMaxParameter::CopyFrom(const ArgMaxParameter& from) { +// @@protoc_insertion_point(class_specific_copy_from_start:caffe.ArgMaxParameter) if (&from == this) return; Clear(); - MergeFrom(from); + UnsafeMergeFrom(from); } bool ArgMaxParameter::IsInitialized() const { @@ -13464,13 +20552,15 @@ bool ArgMaxParameter::IsInitialized() const { } void ArgMaxParameter::Swap(ArgMaxParameter* other) { - if (other != this) { - std::swap(out_max_val_, other->out_max_val_); - std::swap(top_k_, other->top_k_); - std::swap(_has_bits_[0], other->_has_bits_[0]); - _unknown_fields_.Swap(&other->_unknown_fields_); - std::swap(_cached_size_, other->_cached_size_); - } + if (other == this) return; + InternalSwap(other); +} +void ArgMaxParameter::InternalSwap(ArgMaxParameter* other) { + std::swap(out_max_val_, other->out_max_val_); + std::swap(top_k_, other->top_k_); + std::swap(_has_bits_[0], other->_has_bits_[0]); + _internal_metadata_.Swap(&other->_internal_metadata_); + std::swap(_cached_size_, other->_cached_size_); } ::google::protobuf::Metadata ArgMaxParameter::GetMetadata() const { @@ -13481,42 +20571,99 @@ void ArgMaxParameter::Swap(ArgMaxParameter* other) { return metadata; } +#if PROTOBUF_INLINE_NOT_IN_HEADERS +// ArgMaxParameter + +// optional bool out_max_val = 1 [default = false]; +bool ArgMaxParameter::has_out_max_val() const { + return (_has_bits_[0] & 0x00000001u) != 0; +} +void ArgMaxParameter::set_has_out_max_val() { + _has_bits_[0] |= 0x00000001u; +} +void ArgMaxParameter::clear_has_out_max_val() { + _has_bits_[0] &= ~0x00000001u; +} +void ArgMaxParameter::clear_out_max_val() { + out_max_val_ = false; + clear_has_out_max_val(); +} +bool ArgMaxParameter::out_max_val() const { + // @@protoc_insertion_point(field_get:caffe.ArgMaxParameter.out_max_val) + return out_max_val_; +} +void ArgMaxParameter::set_out_max_val(bool value) { + set_has_out_max_val(); + out_max_val_ = value; + // @@protoc_insertion_point(field_set:caffe.ArgMaxParameter.out_max_val) +} + +// optional uint32 top_k = 2 [default = 1]; +bool ArgMaxParameter::has_top_k() const { + return (_has_bits_[0] & 0x00000002u) != 0; +} +void ArgMaxParameter::set_has_top_k() { + _has_bits_[0] |= 0x00000002u; +} +void ArgMaxParameter::clear_has_top_k() { + _has_bits_[0] &= ~0x00000002u; +} +void ArgMaxParameter::clear_top_k() { + top_k_ = 1u; + clear_has_top_k(); +} +::google::protobuf::uint32 ArgMaxParameter::top_k() const { + // @@protoc_insertion_point(field_get:caffe.ArgMaxParameter.top_k) + return top_k_; +} +void ArgMaxParameter::set_top_k(::google::protobuf::uint32 value) { + set_has_top_k(); + top_k_ = value; + // @@protoc_insertion_point(field_set:caffe.ArgMaxParameter.top_k) +} + +inline const ArgMaxParameter* ArgMaxParameter::internal_default_instance() { + return &ArgMaxParameter_default_instance_.get(); +} +#endif // PROTOBUF_INLINE_NOT_IN_HEADERS // =================================================================== -#ifndef _MSC_VER +#if !defined(_MSC_VER) || _MSC_VER >= 1900 const int ConcatParameter::kAxisFieldNumber; const int ConcatParameter::kConcatDimFieldNumber; -#endif // !_MSC_VER +#endif // !defined(_MSC_VER) || _MSC_VER >= 1900 ConcatParameter::ConcatParameter() - : ::google::protobuf::Message() { + : ::google::protobuf::Message(), _internal_metadata_(NULL) { + if (this != internal_default_instance()) protobuf_InitDefaults_caffe_2eproto(); SharedCtor(); + // @@protoc_insertion_point(constructor:caffe.ConcatParameter) } void ConcatParameter::InitAsDefaultInstance() { } ConcatParameter::ConcatParameter(const ConcatParameter& from) - : ::google::protobuf::Message() { + : ::google::protobuf::Message(), + _internal_metadata_(NULL) { SharedCtor(); - MergeFrom(from); + UnsafeMergeFrom(from); + // @@protoc_insertion_point(copy_constructor:caffe.ConcatParameter) } void ConcatParameter::SharedCtor() { _cached_size_ = 0; axis_ = 1; concat_dim_ = 1u; - ::memset(_has_bits_, 0, sizeof(_has_bits_)); } ConcatParameter::~ConcatParameter() { + // @@protoc_insertion_point(destructor:caffe.ConcatParameter) SharedDtor(); } void ConcatParameter::SharedDtor() { - if (this != default_instance_) { - } } void ConcatParameter::SetCachedSize(int size) const { @@ -13530,41 +20677,51 @@ const ::google::protobuf::Descriptor* ConcatParameter::descriptor() { } const ConcatParameter& ConcatParameter::default_instance() { - if (default_instance_ == NULL) protobuf_AddDesc_caffe_2eproto(); - return *default_instance_; + protobuf_InitDefaults_caffe_2eproto(); + return *internal_default_instance(); } -ConcatParameter* ConcatParameter::default_instance_ = NULL; +::google::protobuf::internal::ExplicitlyConstructed ConcatParameter_default_instance_; -ConcatParameter* ConcatParameter::New() const { - return new ConcatParameter; +ConcatParameter* ConcatParameter::New(::google::protobuf::Arena* arena) const { + ConcatParameter* n = new ConcatParameter; + if (arena != NULL) { + arena->Own(n); + } + return n; } void ConcatParameter::Clear() { - if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) { +// @@protoc_insertion_point(message_clear_start:caffe.ConcatParameter) + if (_has_bits_[0 / 32] & 3u) { axis_ = 1; concat_dim_ = 1u; } - ::memset(_has_bits_, 0, sizeof(_has_bits_)); - mutable_unknown_fields()->Clear(); + _has_bits_.Clear(); + if (_internal_metadata_.have_unknown_fields()) { + mutable_unknown_fields()->Clear(); + } } bool ConcatParameter::MergePartialFromCodedStream( ::google::protobuf::io::CodedInputStream* input) { -#define DO_(EXPRESSION) if (!(EXPRESSION)) return false +#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure ::google::protobuf::uint32 tag; - while ((tag = input->ReadTag()) != 0) { + // @@protoc_insertion_point(parse_start:caffe.ConcatParameter) + for (;;) { + ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127); + tag = p.first; + if (!p.second) goto handle_unusual; switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { // optional uint32 concat_dim = 1 [default = 1]; case 1: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) { + if (tag == 8) { + set_has_concat_dim(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>( input, &concat_dim_))); - set_has_concat_dim(); } else { - goto handle_uninterpreted; + goto handle_unusual; } if (input->ExpectTag(16)) goto parse_axis; break; @@ -13572,25 +20729,25 @@ bool ConcatParameter::MergePartialFromCodedStream( // optional int32 axis = 2 [default = 1]; case 2: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) { + if (tag == 16) { parse_axis: + set_has_axis(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>( input, &axis_))); - set_has_axis(); } else { - goto handle_uninterpreted; + goto handle_unusual; } - if (input->ExpectAtEnd()) return true; + if (input->ExpectAtEnd()) goto success; break; } default: { - handle_uninterpreted: - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == + handle_unusual: + if (tag == 0 || + ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) { - return true; + goto success; } DO_(::google::protobuf::internal::WireFormat::SkipField( input, tag, mutable_unknown_fields())); @@ -13598,12 +20755,18 @@ bool ConcatParameter::MergePartialFromCodedStream( } } } +success: + // @@protoc_insertion_point(parse_success:caffe.ConcatParameter) return true; +failure: + // @@protoc_insertion_point(parse_failure:caffe.ConcatParameter) + return false; #undef DO_ } void ConcatParameter::SerializeWithCachedSizes( ::google::protobuf::io::CodedOutputStream* output) const { + // @@protoc_insertion_point(serialize_start:caffe.ConcatParameter) // optional uint32 concat_dim = 1 [default = 1]; if (has_concat_dim()) { ::google::protobuf::internal::WireFormatLite::WriteUInt32(1, this->concat_dim(), output); @@ -13614,14 +20777,17 @@ void ConcatParameter::SerializeWithCachedSizes( ::google::protobuf::internal::WireFormatLite::WriteInt32(2, this->axis(), output); } - if (!unknown_fields().empty()) { + if (_internal_metadata_.have_unknown_fields()) { ::google::protobuf::internal::WireFormat::SerializeUnknownFields( unknown_fields(), output); } + // @@protoc_insertion_point(serialize_end:caffe.ConcatParameter) } -::google::protobuf::uint8* ConcatParameter::SerializeWithCachedSizesToArray( - ::google::protobuf::uint8* target) const { +::google::protobuf::uint8* ConcatParameter::InternalSerializeWithCachedSizesToArray( + bool deterministic, ::google::protobuf::uint8* target) const { + (void)deterministic; // Unused + // @@protoc_insertion_point(serialize_to_array_start:caffe.ConcatParameter) // optional uint32 concat_dim = 1 [default = 1]; if (has_concat_dim()) { target = ::google::protobuf::internal::WireFormatLite::WriteUInt32ToArray(1, this->concat_dim(), target); @@ -13632,17 +20798,19 @@ void ConcatParameter::SerializeWithCachedSizes( target = ::google::protobuf::internal::WireFormatLite::WriteInt32ToArray(2, this->axis(), target); } - if (!unknown_fields().empty()) { + if (_internal_metadata_.have_unknown_fields()) { target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray( unknown_fields(), target); } + // @@protoc_insertion_point(serialize_to_array_end:caffe.ConcatParameter) return target; } -int ConcatParameter::ByteSize() const { - int total_size = 0; +size_t ConcatParameter::ByteSizeLong() const { +// @@protoc_insertion_point(message_byte_size_start:caffe.ConcatParameter) + size_t total_size = 0; - if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) { + if (_has_bits_[0 / 32] & 3u) { // optional int32 axis = 2 [default = 1]; if (has_axis()) { total_size += 1 + @@ -13658,31 +20826,44 @@ int ConcatParameter::ByteSize() const { } } - if (!unknown_fields().empty()) { + if (_internal_metadata_.have_unknown_fields()) { total_size += ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( unknown_fields()); } + int cached_size = ::google::protobuf::internal::ToCachedSize(total_size); GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); - _cached_size_ = total_size; + _cached_size_ = cached_size; GOOGLE_SAFE_CONCURRENT_WRITES_END(); return total_size; } void ConcatParameter::MergeFrom(const ::google::protobuf::Message& from) { - GOOGLE_CHECK_NE(&from, this); +// @@protoc_insertion_point(generalized_merge_from_start:caffe.ConcatParameter) + if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__); const ConcatParameter* source = - ::google::protobuf::internal::dynamic_cast_if_available( - &from); + ::google::protobuf::internal::DynamicCastToGenerated( + &from); if (source == NULL) { + // @@protoc_insertion_point(generalized_merge_from_cast_fail:caffe.ConcatParameter) ::google::protobuf::internal::ReflectionOps::Merge(from, this); } else { - MergeFrom(*source); + // @@protoc_insertion_point(generalized_merge_from_cast_success:caffe.ConcatParameter) + UnsafeMergeFrom(*source); } } void ConcatParameter::MergeFrom(const ConcatParameter& from) { - GOOGLE_CHECK_NE(&from, this); +// @@protoc_insertion_point(class_specific_merge_from_start:caffe.ConcatParameter) + if (GOOGLE_PREDICT_TRUE(&from != this)) { + UnsafeMergeFrom(from); + } else { + MergeFromFail(__LINE__); + } +} + +void ConcatParameter::UnsafeMergeFrom(const ConcatParameter& from) { + GOOGLE_DCHECK(&from != this); if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) { if (from.has_axis()) { set_axis(from.axis()); @@ -13691,19 +20872,24 @@ void ConcatParameter::MergeFrom(const ConcatParameter& from) { set_concat_dim(from.concat_dim()); } } - mutable_unknown_fields()->MergeFrom(from.unknown_fields()); + if (from._internal_metadata_.have_unknown_fields()) { + ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata( + from.unknown_fields(), &_internal_metadata_); + } } void ConcatParameter::CopyFrom(const ::google::protobuf::Message& from) { +// @@protoc_insertion_point(generalized_copy_from_start:caffe.ConcatParameter) if (&from == this) return; Clear(); MergeFrom(from); } void ConcatParameter::CopyFrom(const ConcatParameter& from) { +// @@protoc_insertion_point(class_specific_copy_from_start:caffe.ConcatParameter) if (&from == this) return; Clear(); - MergeFrom(from); + UnsafeMergeFrom(from); } bool ConcatParameter::IsInitialized() const { @@ -13712,13 +20898,15 @@ bool ConcatParameter::IsInitialized() const { } void ConcatParameter::Swap(ConcatParameter* other) { - if (other != this) { - std::swap(axis_, other->axis_); - std::swap(concat_dim_, other->concat_dim_); - std::swap(_has_bits_[0], other->_has_bits_[0]); - _unknown_fields_.Swap(&other->_unknown_fields_); - std::swap(_cached_size_, other->_cached_size_); - } + if (other == this) return; + InternalSwap(other); +} +void ConcatParameter::InternalSwap(ConcatParameter* other) { + std::swap(axis_, other->axis_); + std::swap(concat_dim_, other->concat_dim_); + std::swap(_has_bits_[0], other->_has_bits_[0]); + _internal_metadata_.Swap(&other->_internal_metadata_); + std::swap(_cached_size_, other->_cached_size_); } ::google::protobuf::Metadata ConcatParameter::GetMetadata() const { @@ -13729,42 +20917,99 @@ void ConcatParameter::Swap(ConcatParameter* other) { return metadata; } +#if PROTOBUF_INLINE_NOT_IN_HEADERS +// ConcatParameter + +// optional int32 axis = 2 [default = 1]; +bool ConcatParameter::has_axis() const { + return (_has_bits_[0] & 0x00000001u) != 0; +} +void ConcatParameter::set_has_axis() { + _has_bits_[0] |= 0x00000001u; +} +void ConcatParameter::clear_has_axis() { + _has_bits_[0] &= ~0x00000001u; +} +void ConcatParameter::clear_axis() { + axis_ = 1; + clear_has_axis(); +} +::google::protobuf::int32 ConcatParameter::axis() const { + // @@protoc_insertion_point(field_get:caffe.ConcatParameter.axis) + return axis_; +} +void ConcatParameter::set_axis(::google::protobuf::int32 value) { + set_has_axis(); + axis_ = value; + // @@protoc_insertion_point(field_set:caffe.ConcatParameter.axis) +} + +// optional uint32 concat_dim = 1 [default = 1]; +bool ConcatParameter::has_concat_dim() const { + return (_has_bits_[0] & 0x00000002u) != 0; +} +void ConcatParameter::set_has_concat_dim() { + _has_bits_[0] |= 0x00000002u; +} +void ConcatParameter::clear_has_concat_dim() { + _has_bits_[0] &= ~0x00000002u; +} +void ConcatParameter::clear_concat_dim() { + concat_dim_ = 1u; + clear_has_concat_dim(); +} +::google::protobuf::uint32 ConcatParameter::concat_dim() const { + // @@protoc_insertion_point(field_get:caffe.ConcatParameter.concat_dim) + return concat_dim_; +} +void ConcatParameter::set_concat_dim(::google::protobuf::uint32 value) { + set_has_concat_dim(); + concat_dim_ = value; + // @@protoc_insertion_point(field_set:caffe.ConcatParameter.concat_dim) +} + +inline const ConcatParameter* ConcatParameter::internal_default_instance() { + return &ConcatParameter_default_instance_.get(); +} +#endif // PROTOBUF_INLINE_NOT_IN_HEADERS // =================================================================== -#ifndef _MSC_VER +#if !defined(_MSC_VER) || _MSC_VER >= 1900 const int ContrastiveLossParameter::kMarginFieldNumber; const int ContrastiveLossParameter::kLegacyVersionFieldNumber; -#endif // !_MSC_VER +#endif // !defined(_MSC_VER) || _MSC_VER >= 1900 ContrastiveLossParameter::ContrastiveLossParameter() - : ::google::protobuf::Message() { + : ::google::protobuf::Message(), _internal_metadata_(NULL) { + if (this != internal_default_instance()) protobuf_InitDefaults_caffe_2eproto(); SharedCtor(); + // @@protoc_insertion_point(constructor:caffe.ContrastiveLossParameter) } void ContrastiveLossParameter::InitAsDefaultInstance() { } ContrastiveLossParameter::ContrastiveLossParameter(const ContrastiveLossParameter& from) - : ::google::protobuf::Message() { + : ::google::protobuf::Message(), + _internal_metadata_(NULL) { SharedCtor(); - MergeFrom(from); + UnsafeMergeFrom(from); + // @@protoc_insertion_point(copy_constructor:caffe.ContrastiveLossParameter) } void ContrastiveLossParameter::SharedCtor() { _cached_size_ = 0; - margin_ = 1; legacy_version_ = false; - ::memset(_has_bits_, 0, sizeof(_has_bits_)); + margin_ = 1; } ContrastiveLossParameter::~ContrastiveLossParameter() { + // @@protoc_insertion_point(destructor:caffe.ContrastiveLossParameter) SharedDtor(); } void ContrastiveLossParameter::SharedDtor() { - if (this != default_instance_) { - } } void ContrastiveLossParameter::SetCachedSize(int size) const { @@ -13778,41 +21023,51 @@ const ::google::protobuf::Descriptor* ContrastiveLossParameter::descriptor() { } const ContrastiveLossParameter& ContrastiveLossParameter::default_instance() { - if (default_instance_ == NULL) protobuf_AddDesc_caffe_2eproto(); - return *default_instance_; + protobuf_InitDefaults_caffe_2eproto(); + return *internal_default_instance(); } -ContrastiveLossParameter* ContrastiveLossParameter::default_instance_ = NULL; +::google::protobuf::internal::ExplicitlyConstructed ContrastiveLossParameter_default_instance_; -ContrastiveLossParameter* ContrastiveLossParameter::New() const { - return new ContrastiveLossParameter; +ContrastiveLossParameter* ContrastiveLossParameter::New(::google::protobuf::Arena* arena) const { + ContrastiveLossParameter* n = new ContrastiveLossParameter; + if (arena != NULL) { + arena->Own(n); + } + return n; } void ContrastiveLossParameter::Clear() { - if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) { +// @@protoc_insertion_point(message_clear_start:caffe.ContrastiveLossParameter) + if (_has_bits_[0 / 32] & 3u) { margin_ = 1; legacy_version_ = false; } - ::memset(_has_bits_, 0, sizeof(_has_bits_)); - mutable_unknown_fields()->Clear(); + _has_bits_.Clear(); + if (_internal_metadata_.have_unknown_fields()) { + mutable_unknown_fields()->Clear(); + } } bool ContrastiveLossParameter::MergePartialFromCodedStream( ::google::protobuf::io::CodedInputStream* input) { -#define DO_(EXPRESSION) if (!(EXPRESSION)) return false +#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure ::google::protobuf::uint32 tag; - while ((tag = input->ReadTag()) != 0) { + // @@protoc_insertion_point(parse_start:caffe.ContrastiveLossParameter) + for (;;) { + ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127); + tag = p.first; + if (!p.second) goto handle_unusual; switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { // optional float margin = 1 [default = 1]; case 1: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_FIXED32) { + if (tag == 13) { + set_has_margin(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< float, ::google::protobuf::internal::WireFormatLite::TYPE_FLOAT>( input, &margin_))); - set_has_margin(); } else { - goto handle_uninterpreted; + goto handle_unusual; } if (input->ExpectTag(16)) goto parse_legacy_version; break; @@ -13820,25 +21075,25 @@ bool ContrastiveLossParameter::MergePartialFromCodedStream( // optional bool legacy_version = 2 [default = false]; case 2: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) { + if (tag == 16) { parse_legacy_version: + set_has_legacy_version(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>( input, &legacy_version_))); - set_has_legacy_version(); } else { - goto handle_uninterpreted; + goto handle_unusual; } - if (input->ExpectAtEnd()) return true; + if (input->ExpectAtEnd()) goto success; break; } default: { - handle_uninterpreted: - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == + handle_unusual: + if (tag == 0 || + ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) { - return true; + goto success; } DO_(::google::protobuf::internal::WireFormat::SkipField( input, tag, mutable_unknown_fields())); @@ -13846,12 +21101,18 @@ bool ContrastiveLossParameter::MergePartialFromCodedStream( } } } +success: + // @@protoc_insertion_point(parse_success:caffe.ContrastiveLossParameter) return true; +failure: + // @@protoc_insertion_point(parse_failure:caffe.ContrastiveLossParameter) + return false; #undef DO_ } void ContrastiveLossParameter::SerializeWithCachedSizes( ::google::protobuf::io::CodedOutputStream* output) const { + // @@protoc_insertion_point(serialize_start:caffe.ContrastiveLossParameter) // optional float margin = 1 [default = 1]; if (has_margin()) { ::google::protobuf::internal::WireFormatLite::WriteFloat(1, this->margin(), output); @@ -13862,14 +21123,17 @@ void ContrastiveLossParameter::SerializeWithCachedSizes( ::google::protobuf::internal::WireFormatLite::WriteBool(2, this->legacy_version(), output); } - if (!unknown_fields().empty()) { + if (_internal_metadata_.have_unknown_fields()) { ::google::protobuf::internal::WireFormat::SerializeUnknownFields( unknown_fields(), output); } + // @@protoc_insertion_point(serialize_end:caffe.ContrastiveLossParameter) } -::google::protobuf::uint8* ContrastiveLossParameter::SerializeWithCachedSizesToArray( - ::google::protobuf::uint8* target) const { +::google::protobuf::uint8* ContrastiveLossParameter::InternalSerializeWithCachedSizesToArray( + bool deterministic, ::google::protobuf::uint8* target) const { + (void)deterministic; // Unused + // @@protoc_insertion_point(serialize_to_array_start:caffe.ContrastiveLossParameter) // optional float margin = 1 [default = 1]; if (has_margin()) { target = ::google::protobuf::internal::WireFormatLite::WriteFloatToArray(1, this->margin(), target); @@ -13880,17 +21144,19 @@ void ContrastiveLossParameter::SerializeWithCachedSizes( target = ::google::protobuf::internal::WireFormatLite::WriteBoolToArray(2, this->legacy_version(), target); } - if (!unknown_fields().empty()) { + if (_internal_metadata_.have_unknown_fields()) { target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray( unknown_fields(), target); } + // @@protoc_insertion_point(serialize_to_array_end:caffe.ContrastiveLossParameter) return target; } -int ContrastiveLossParameter::ByteSize() const { - int total_size = 0; +size_t ContrastiveLossParameter::ByteSizeLong() const { +// @@protoc_insertion_point(message_byte_size_start:caffe.ContrastiveLossParameter) + size_t total_size = 0; - if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) { + if (_has_bits_[0 / 32] & 3u) { // optional float margin = 1 [default = 1]; if (has_margin()) { total_size += 1 + 4; @@ -13902,31 +21168,44 @@ int ContrastiveLossParameter::ByteSize() const { } } - if (!unknown_fields().empty()) { + if (_internal_metadata_.have_unknown_fields()) { total_size += ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( unknown_fields()); } + int cached_size = ::google::protobuf::internal::ToCachedSize(total_size); GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); - _cached_size_ = total_size; + _cached_size_ = cached_size; GOOGLE_SAFE_CONCURRENT_WRITES_END(); return total_size; } void ContrastiveLossParameter::MergeFrom(const ::google::protobuf::Message& from) { - GOOGLE_CHECK_NE(&from, this); +// @@protoc_insertion_point(generalized_merge_from_start:caffe.ContrastiveLossParameter) + if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__); const ContrastiveLossParameter* source = - ::google::protobuf::internal::dynamic_cast_if_available( - &from); + ::google::protobuf::internal::DynamicCastToGenerated( + &from); if (source == NULL) { + // @@protoc_insertion_point(generalized_merge_from_cast_fail:caffe.ContrastiveLossParameter) ::google::protobuf::internal::ReflectionOps::Merge(from, this); } else { - MergeFrom(*source); + // @@protoc_insertion_point(generalized_merge_from_cast_success:caffe.ContrastiveLossParameter) + UnsafeMergeFrom(*source); } } void ContrastiveLossParameter::MergeFrom(const ContrastiveLossParameter& from) { - GOOGLE_CHECK_NE(&from, this); +// @@protoc_insertion_point(class_specific_merge_from_start:caffe.ContrastiveLossParameter) + if (GOOGLE_PREDICT_TRUE(&from != this)) { + UnsafeMergeFrom(from); + } else { + MergeFromFail(__LINE__); + } +} + +void ContrastiveLossParameter::UnsafeMergeFrom(const ContrastiveLossParameter& from) { + GOOGLE_DCHECK(&from != this); if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) { if (from.has_margin()) { set_margin(from.margin()); @@ -13935,19 +21214,24 @@ void ContrastiveLossParameter::MergeFrom(const ContrastiveLossParameter& from) { set_legacy_version(from.legacy_version()); } } - mutable_unknown_fields()->MergeFrom(from.unknown_fields()); + if (from._internal_metadata_.have_unknown_fields()) { + ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata( + from.unknown_fields(), &_internal_metadata_); + } } void ContrastiveLossParameter::CopyFrom(const ::google::protobuf::Message& from) { +// @@protoc_insertion_point(generalized_copy_from_start:caffe.ContrastiveLossParameter) if (&from == this) return; Clear(); MergeFrom(from); } void ContrastiveLossParameter::CopyFrom(const ContrastiveLossParameter& from) { +// @@protoc_insertion_point(class_specific_copy_from_start:caffe.ContrastiveLossParameter) if (&from == this) return; Clear(); - MergeFrom(from); + UnsafeMergeFrom(from); } bool ContrastiveLossParameter::IsInitialized() const { @@ -13956,13 +21240,15 @@ bool ContrastiveLossParameter::IsInitialized() const { } void ContrastiveLossParameter::Swap(ContrastiveLossParameter* other) { - if (other != this) { - std::swap(margin_, other->margin_); - std::swap(legacy_version_, other->legacy_version_); - std::swap(_has_bits_[0], other->_has_bits_[0]); - _unknown_fields_.Swap(&other->_unknown_fields_); - std::swap(_cached_size_, other->_cached_size_); - } + if (other == this) return; + InternalSwap(other); +} +void ContrastiveLossParameter::InternalSwap(ContrastiveLossParameter* other) { + std::swap(margin_, other->margin_); + std::swap(legacy_version_, other->legacy_version_); + std::swap(_has_bits_[0], other->_has_bits_[0]); + _internal_metadata_.Swap(&other->_internal_metadata_); + std::swap(_cached_size_, other->_cached_size_); } ::google::protobuf::Metadata ContrastiveLossParameter::GetMetadata() const { @@ -13973,6 +21259,61 @@ void ContrastiveLossParameter::Swap(ContrastiveLossParameter* other) { return metadata; } +#if PROTOBUF_INLINE_NOT_IN_HEADERS +// ContrastiveLossParameter + +// optional float margin = 1 [default = 1]; +bool ContrastiveLossParameter::has_margin() const { + return (_has_bits_[0] & 0x00000001u) != 0; +} +void ContrastiveLossParameter::set_has_margin() { + _has_bits_[0] |= 0x00000001u; +} +void ContrastiveLossParameter::clear_has_margin() { + _has_bits_[0] &= ~0x00000001u; +} +void ContrastiveLossParameter::clear_margin() { + margin_ = 1; + clear_has_margin(); +} +float ContrastiveLossParameter::margin() const { + // @@protoc_insertion_point(field_get:caffe.ContrastiveLossParameter.margin) + return margin_; +} +void ContrastiveLossParameter::set_margin(float value) { + set_has_margin(); + margin_ = value; + // @@protoc_insertion_point(field_set:caffe.ContrastiveLossParameter.margin) +} + +// optional bool legacy_version = 2 [default = false]; +bool ContrastiveLossParameter::has_legacy_version() const { + return (_has_bits_[0] & 0x00000002u) != 0; +} +void ContrastiveLossParameter::set_has_legacy_version() { + _has_bits_[0] |= 0x00000002u; +} +void ContrastiveLossParameter::clear_has_legacy_version() { + _has_bits_[0] &= ~0x00000002u; +} +void ContrastiveLossParameter::clear_legacy_version() { + legacy_version_ = false; + clear_has_legacy_version(); +} +bool ContrastiveLossParameter::legacy_version() const { + // @@protoc_insertion_point(field_get:caffe.ContrastiveLossParameter.legacy_version) + return legacy_version_; +} +void ContrastiveLossParameter::set_legacy_version(bool value) { + set_has_legacy_version(); + legacy_version_ = value; + // @@protoc_insertion_point(field_set:caffe.ContrastiveLossParameter.legacy_version) +} + +inline const ContrastiveLossParameter* ContrastiveLossParameter::internal_default_instance() { + return &ContrastiveLossParameter_default_instance_.get(); +} +#endif // PROTOBUF_INLINE_NOT_IN_HEADERS // =================================================================== @@ -13981,7 +21322,7 @@ const ::google::protobuf::EnumDescriptor* ConvolutionParameter_Engine_descriptor return ConvolutionParameter_Engine_descriptor_; } bool ConvolutionParameter_Engine_IsValid(int value) { - switch(value) { + switch (value) { case 0: case 1: case 2: @@ -13991,15 +21332,15 @@ bool ConvolutionParameter_Engine_IsValid(int value) { } } -#ifndef _MSC_VER +#if !defined(_MSC_VER) || _MSC_VER >= 1900 const ConvolutionParameter_Engine ConvolutionParameter::DEFAULT; const ConvolutionParameter_Engine ConvolutionParameter::CAFFE; const ConvolutionParameter_Engine ConvolutionParameter::CUDNN; const ConvolutionParameter_Engine ConvolutionParameter::Engine_MIN; const ConvolutionParameter_Engine ConvolutionParameter::Engine_MAX; const int ConvolutionParameter::Engine_ARRAYSIZE; -#endif // _MSC_VER -#ifndef _MSC_VER +#endif // !defined(_MSC_VER) || _MSC_VER >= 1900 +#if !defined(_MSC_VER) || _MSC_VER >= 1900 const int ConvolutionParameter::kNumOutputFieldNumber; const int ConvolutionParameter::kBiasTermFieldNumber; const int ConvolutionParameter::kPadFieldNumber; @@ -14018,53 +21359,48 @@ const int ConvolutionParameter::kEngineFieldNumber; const int ConvolutionParameter::kDilationHFieldNumber; const int ConvolutionParameter::kDilationWFieldNumber; const int ConvolutionParameter::kDilationFieldNumber; -#endif // !_MSC_VER +#endif // !defined(_MSC_VER) || _MSC_VER >= 1900 ConvolutionParameter::ConvolutionParameter() - : ::google::protobuf::Message() { + : ::google::protobuf::Message(), _internal_metadata_(NULL) { + if (this != internal_default_instance()) protobuf_InitDefaults_caffe_2eproto(); SharedCtor(); + // @@protoc_insertion_point(constructor:caffe.ConvolutionParameter) } void ConvolutionParameter::InitAsDefaultInstance() { - weight_filler_ = const_cast< ::caffe::FillerParameter*>(&::caffe::FillerParameter::default_instance()); - bias_filler_ = const_cast< ::caffe::FillerParameter*>(&::caffe::FillerParameter::default_instance()); + weight_filler_ = const_cast< ::caffe::FillerParameter*>( + ::caffe::FillerParameter::internal_default_instance()); + bias_filler_ = const_cast< ::caffe::FillerParameter*>( + ::caffe::FillerParameter::internal_default_instance()); } ConvolutionParameter::ConvolutionParameter(const ConvolutionParameter& from) - : ::google::protobuf::Message() { - SharedCtor(); - MergeFrom(from); -} - -void ConvolutionParameter::SharedCtor() { - _cached_size_ = 0; - num_output_ = 0u; - bias_term_ = true; - pad_ = 0u; - pad_h_ = 0u; - pad_w_ = 0u; - kernel_size_ = 0u; - kernel_h_ = 0u; - kernel_w_ = 0u; - group_ = 1u; - stride_ = 1u; - stride_h_ = 0u; - stride_w_ = 0u; + : ::google::protobuf::Message(), + _internal_metadata_(NULL) { + SharedCtor(); + UnsafeMergeFrom(from); + // @@protoc_insertion_point(copy_constructor:caffe.ConvolutionParameter) +} + +void ConvolutionParameter::SharedCtor() { + _cached_size_ = 0; weight_filler_ = NULL; bias_filler_ = NULL; - engine_ = 0; - dilation_h_ = 0u; - dilation_w_ = 0u; - dilation_ = 0u; - ::memset(_has_bits_, 0, sizeof(_has_bits_)); + ::memset(&num_output_, 0, reinterpret_cast(&dilation_) - + reinterpret_cast(&num_output_) + sizeof(dilation_)); + stride_ = 1u; + bias_term_ = true; + group_ = 1u; } ConvolutionParameter::~ConvolutionParameter() { + // @@protoc_insertion_point(destructor:caffe.ConvolutionParameter) SharedDtor(); } void ConvolutionParameter::SharedDtor() { - if (this != default_instance_) { + if (this != &ConvolutionParameter_default_instance_.get()) { delete weight_filler_; delete bias_filler_; } @@ -14081,65 +21417,83 @@ const ::google::protobuf::Descriptor* ConvolutionParameter::descriptor() { } const ConvolutionParameter& ConvolutionParameter::default_instance() { - if (default_instance_ == NULL) protobuf_AddDesc_caffe_2eproto(); - return *default_instance_; + protobuf_InitDefaults_caffe_2eproto(); + return *internal_default_instance(); } -ConvolutionParameter* ConvolutionParameter::default_instance_ = NULL; +::google::protobuf::internal::ExplicitlyConstructed ConvolutionParameter_default_instance_; -ConvolutionParameter* ConvolutionParameter::New() const { - return new ConvolutionParameter; +ConvolutionParameter* ConvolutionParameter::New(::google::protobuf::Arena* arena) const { + ConvolutionParameter* n = new ConvolutionParameter; + if (arena != NULL) { + arena->Own(n); + } + return n; } void ConvolutionParameter::Clear() { - if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) { - num_output_ = 0u; +// @@protoc_insertion_point(message_clear_start:caffe.ConvolutionParameter) +#if defined(__clang__) +#define ZR_HELPER_(f) \ + _Pragma("clang diagnostic push") \ + _Pragma("clang diagnostic ignored \"-Winvalid-offsetof\"") \ + __builtin_offsetof(ConvolutionParameter, f) \ + _Pragma("clang diagnostic pop") +#else +#define ZR_HELPER_(f) reinterpret_cast(\ + &reinterpret_cast(16)->f) +#endif + +#define ZR_(first, last) do {\ + ::memset(&(first), 0,\ + ZR_HELPER_(last) - ZR_HELPER_(first) + sizeof(last));\ +} while (0) + + if (_has_bits_[0 / 32] & 255u) { + ZR_(num_output_, kernel_w_); bias_term_ = true; - pad_ = 0u; - pad_h_ = 0u; - pad_w_ = 0u; - kernel_size_ = 0u; - kernel_h_ = 0u; - kernel_w_ = 0u; - } - if (_has_bits_[8 / 32] & (0xffu << (8 % 32))) { + } + if (_has_bits_[8 / 32] & 65280u) { + ZR_(stride_h_, dilation_h_); group_ = 1u; stride_ = 1u; - stride_h_ = 0u; - stride_w_ = 0u; if (has_weight_filler()) { if (weight_filler_ != NULL) weight_filler_->::caffe::FillerParameter::Clear(); } if (has_bias_filler()) { if (bias_filler_ != NULL) bias_filler_->::caffe::FillerParameter::Clear(); } - engine_ = 0; - dilation_h_ = 0u; } - if (_has_bits_[16 / 32] & (0xffu << (16 % 32))) { - dilation_w_ = 0u; - dilation_ = 0u; + ZR_(dilation_w_, dilation_); + +#undef ZR_HELPER_ +#undef ZR_ + + _has_bits_.Clear(); + if (_internal_metadata_.have_unknown_fields()) { + mutable_unknown_fields()->Clear(); } - ::memset(_has_bits_, 0, sizeof(_has_bits_)); - mutable_unknown_fields()->Clear(); } bool ConvolutionParameter::MergePartialFromCodedStream( ::google::protobuf::io::CodedInputStream* input) { -#define DO_(EXPRESSION) if (!(EXPRESSION)) return false +#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure ::google::protobuf::uint32 tag; - while ((tag = input->ReadTag()) != 0) { + // @@protoc_insertion_point(parse_start:caffe.ConvolutionParameter) + for (;;) { + ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(16383); + tag = p.first; + if (!p.second) goto handle_unusual; switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { // optional uint32 num_output = 1; case 1: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) { + if (tag == 8) { + set_has_num_output(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>( input, &num_output_))); - set_has_num_output(); } else { - goto handle_uninterpreted; + goto handle_unusual; } if (input->ExpectTag(16)) goto parse_bias_term; break; @@ -14147,15 +21501,14 @@ bool ConvolutionParameter::MergePartialFromCodedStream( // optional bool bias_term = 2 [default = true]; case 2: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) { + if (tag == 16) { parse_bias_term: + set_has_bias_term(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>( input, &bias_term_))); - set_has_bias_term(); } else { - goto handle_uninterpreted; + goto handle_unusual; } if (input->ExpectTag(24)) goto parse_pad; break; @@ -14163,15 +21516,14 @@ bool ConvolutionParameter::MergePartialFromCodedStream( // optional uint32 pad = 3 [default = 0]; case 3: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) { + if (tag == 24) { parse_pad: + set_has_pad(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>( input, &pad_))); - set_has_pad(); } else { - goto handle_uninterpreted; + goto handle_unusual; } if (input->ExpectTag(32)) goto parse_kernel_size; break; @@ -14179,15 +21531,14 @@ bool ConvolutionParameter::MergePartialFromCodedStream( // optional uint32 kernel_size = 4; case 4: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) { + if (tag == 32) { parse_kernel_size: + set_has_kernel_size(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>( input, &kernel_size_))); - set_has_kernel_size(); } else { - goto handle_uninterpreted; + goto handle_unusual; } if (input->ExpectTag(40)) goto parse_group; break; @@ -14195,15 +21546,14 @@ bool ConvolutionParameter::MergePartialFromCodedStream( // optional uint32 group = 5 [default = 1]; case 5: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) { + if (tag == 40) { parse_group: + set_has_group(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>( input, &group_))); - set_has_group(); } else { - goto handle_uninterpreted; + goto handle_unusual; } if (input->ExpectTag(48)) goto parse_stride; break; @@ -14211,15 +21561,14 @@ bool ConvolutionParameter::MergePartialFromCodedStream( // optional uint32 stride = 6 [default = 1]; case 6: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) { + if (tag == 48) { parse_stride: + set_has_stride(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>( input, &stride_))); - set_has_stride(); } else { - goto handle_uninterpreted; + goto handle_unusual; } if (input->ExpectTag(58)) goto parse_weight_filler; break; @@ -14227,13 +21576,12 @@ bool ConvolutionParameter::MergePartialFromCodedStream( // optional .caffe.FillerParameter weight_filler = 7; case 7: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) { + if (tag == 58) { parse_weight_filler: DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual( input, mutable_weight_filler())); } else { - goto handle_uninterpreted; + goto handle_unusual; } if (input->ExpectTag(66)) goto parse_bias_filler; break; @@ -14241,13 +21589,12 @@ bool ConvolutionParameter::MergePartialFromCodedStream( // optional .caffe.FillerParameter bias_filler = 8; case 8: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) { + if (tag == 66) { parse_bias_filler: DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual( input, mutable_bias_filler())); } else { - goto handle_uninterpreted; + goto handle_unusual; } if (input->ExpectTag(72)) goto parse_pad_h; break; @@ -14255,15 +21602,14 @@ bool ConvolutionParameter::MergePartialFromCodedStream( // optional uint32 pad_h = 9 [default = 0]; case 9: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) { + if (tag == 72) { parse_pad_h: + set_has_pad_h(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>( input, &pad_h_))); - set_has_pad_h(); } else { - goto handle_uninterpreted; + goto handle_unusual; } if (input->ExpectTag(80)) goto parse_pad_w; break; @@ -14271,15 +21617,14 @@ bool ConvolutionParameter::MergePartialFromCodedStream( // optional uint32 pad_w = 10 [default = 0]; case 10: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) { + if (tag == 80) { parse_pad_w: + set_has_pad_w(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>( input, &pad_w_))); - set_has_pad_w(); } else { - goto handle_uninterpreted; + goto handle_unusual; } if (input->ExpectTag(88)) goto parse_kernel_h; break; @@ -14287,15 +21632,14 @@ bool ConvolutionParameter::MergePartialFromCodedStream( // optional uint32 kernel_h = 11; case 11: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) { + if (tag == 88) { parse_kernel_h: + set_has_kernel_h(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>( input, &kernel_h_))); - set_has_kernel_h(); } else { - goto handle_uninterpreted; + goto handle_unusual; } if (input->ExpectTag(96)) goto parse_kernel_w; break; @@ -14303,15 +21647,14 @@ bool ConvolutionParameter::MergePartialFromCodedStream( // optional uint32 kernel_w = 12; case 12: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) { + if (tag == 96) { parse_kernel_w: + set_has_kernel_w(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>( input, &kernel_w_))); - set_has_kernel_w(); } else { - goto handle_uninterpreted; + goto handle_unusual; } if (input->ExpectTag(104)) goto parse_stride_h; break; @@ -14319,15 +21662,14 @@ bool ConvolutionParameter::MergePartialFromCodedStream( // optional uint32 stride_h = 13; case 13: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) { + if (tag == 104) { parse_stride_h: + set_has_stride_h(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>( input, &stride_h_))); - set_has_stride_h(); } else { - goto handle_uninterpreted; + goto handle_unusual; } if (input->ExpectTag(112)) goto parse_stride_w; break; @@ -14335,15 +21677,14 @@ bool ConvolutionParameter::MergePartialFromCodedStream( // optional uint32 stride_w = 14; case 14: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) { + if (tag == 112) { parse_stride_w: + set_has_stride_w(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>( input, &stride_w_))); - set_has_stride_w(); } else { - goto handle_uninterpreted; + goto handle_unusual; } if (input->ExpectTag(120)) goto parse_engine; break; @@ -14351,8 +21692,7 @@ bool ConvolutionParameter::MergePartialFromCodedStream( // optional .caffe.ConvolutionParameter.Engine engine = 15 [default = DEFAULT]; case 15: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) { + if (tag == 120) { parse_engine: int value; DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< @@ -14364,7 +21704,7 @@ bool ConvolutionParameter::MergePartialFromCodedStream( mutable_unknown_fields()->AddVarint(15, value); } } else { - goto handle_uninterpreted; + goto handle_unusual; } if (input->ExpectTag(144)) goto parse_dilation_h; break; @@ -14372,15 +21712,14 @@ bool ConvolutionParameter::MergePartialFromCodedStream( // optional uint32 dilation_h = 18; case 18: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) { + if (tag == 144) { parse_dilation_h: + set_has_dilation_h(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>( input, &dilation_h_))); - set_has_dilation_h(); } else { - goto handle_uninterpreted; + goto handle_unusual; } if (input->ExpectTag(152)) goto parse_dilation_w; break; @@ -14388,15 +21727,14 @@ bool ConvolutionParameter::MergePartialFromCodedStream( // optional uint32 dilation_w = 19; case 19: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) { + if (tag == 152) { parse_dilation_w: + set_has_dilation_w(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>( input, &dilation_w_))); - set_has_dilation_w(); } else { - goto handle_uninterpreted; + goto handle_unusual; } if (input->ExpectTag(160)) goto parse_dilation; break; @@ -14404,25 +21742,25 @@ bool ConvolutionParameter::MergePartialFromCodedStream( // optional uint32 dilation = 20; case 20: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) { + if (tag == 160) { parse_dilation: + set_has_dilation(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>( input, &dilation_))); - set_has_dilation(); } else { - goto handle_uninterpreted; + goto handle_unusual; } - if (input->ExpectAtEnd()) return true; + if (input->ExpectAtEnd()) goto success; break; } default: { - handle_uninterpreted: - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == + handle_unusual: + if (tag == 0 || + ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) { - return true; + goto success; } DO_(::google::protobuf::internal::WireFormat::SkipField( input, tag, mutable_unknown_fields())); @@ -14430,12 +21768,18 @@ bool ConvolutionParameter::MergePartialFromCodedStream( } } } +success: + // @@protoc_insertion_point(parse_success:caffe.ConvolutionParameter) return true; +failure: + // @@protoc_insertion_point(parse_failure:caffe.ConvolutionParameter) + return false; #undef DO_ } void ConvolutionParameter::SerializeWithCachedSizes( ::google::protobuf::io::CodedOutputStream* output) const { + // @@protoc_insertion_point(serialize_start:caffe.ConvolutionParameter) // optional uint32 num_output = 1; if (has_num_output()) { ::google::protobuf::internal::WireFormatLite::WriteUInt32(1, this->num_output(), output); @@ -14469,13 +21813,13 @@ void ConvolutionParameter::SerializeWithCachedSizes( // optional .caffe.FillerParameter weight_filler = 7; if (has_weight_filler()) { ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( - 7, this->weight_filler(), output); + 7, *this->weight_filler_, output); } // optional .caffe.FillerParameter bias_filler = 8; if (has_bias_filler()) { ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( - 8, this->bias_filler(), output); + 8, *this->bias_filler_, output); } // optional uint32 pad_h = 9 [default = 0]; @@ -14529,14 +21873,17 @@ void ConvolutionParameter::SerializeWithCachedSizes( ::google::protobuf::internal::WireFormatLite::WriteUInt32(20, this->dilation(), output); } - if (!unknown_fields().empty()) { + if (_internal_metadata_.have_unknown_fields()) { ::google::protobuf::internal::WireFormat::SerializeUnknownFields( unknown_fields(), output); } + // @@protoc_insertion_point(serialize_end:caffe.ConvolutionParameter) } -::google::protobuf::uint8* ConvolutionParameter::SerializeWithCachedSizesToArray( - ::google::protobuf::uint8* target) const { +::google::protobuf::uint8* ConvolutionParameter::InternalSerializeWithCachedSizesToArray( + bool deterministic, ::google::protobuf::uint8* target) const { + (void)deterministic; // Unused + // @@protoc_insertion_point(serialize_to_array_start:caffe.ConvolutionParameter) // optional uint32 num_output = 1; if (has_num_output()) { target = ::google::protobuf::internal::WireFormatLite::WriteUInt32ToArray(1, this->num_output(), target); @@ -14570,15 +21917,15 @@ void ConvolutionParameter::SerializeWithCachedSizes( // optional .caffe.FillerParameter weight_filler = 7; if (has_weight_filler()) { target = ::google::protobuf::internal::WireFormatLite:: - WriteMessageNoVirtualToArray( - 7, this->weight_filler(), target); + InternalWriteMessageNoVirtualToArray( + 7, *this->weight_filler_, false, target); } // optional .caffe.FillerParameter bias_filler = 8; if (has_bias_filler()) { target = ::google::protobuf::internal::WireFormatLite:: - WriteMessageNoVirtualToArray( - 8, this->bias_filler(), target); + InternalWriteMessageNoVirtualToArray( + 8, *this->bias_filler_, false, target); } // optional uint32 pad_h = 9 [default = 0]; @@ -14632,17 +21979,19 @@ void ConvolutionParameter::SerializeWithCachedSizes( target = ::google::protobuf::internal::WireFormatLite::WriteUInt32ToArray(20, this->dilation(), target); } - if (!unknown_fields().empty()) { + if (_internal_metadata_.have_unknown_fields()) { target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray( unknown_fields(), target); } + // @@protoc_insertion_point(serialize_to_array_end:caffe.ConvolutionParameter) return target; } -int ConvolutionParameter::ByteSize() const { - int total_size = 0; +size_t ConvolutionParameter::ByteSizeLong() const { +// @@protoc_insertion_point(message_byte_size_start:caffe.ConvolutionParameter) + size_t total_size = 0; - if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) { + if (_has_bits_[0 / 32] & 255u) { // optional uint32 num_output = 1; if (has_num_output()) { total_size += 1 + @@ -14698,7 +22047,7 @@ int ConvolutionParameter::ByteSize() const { } } - if (_has_bits_[8 / 32] & (0xffu << (8 % 32))) { + if (_has_bits_[8 / 32] & 65280u) { // optional uint32 group = 5 [default = 1]; if (has_group()) { total_size += 1 + @@ -14731,14 +22080,14 @@ int ConvolutionParameter::ByteSize() const { if (has_weight_filler()) { total_size += 1 + ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( - this->weight_filler()); + *this->weight_filler_); } // optional .caffe.FillerParameter bias_filler = 8; if (has_bias_filler()) { total_size += 1 + ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( - this->bias_filler()); + *this->bias_filler_); } // optional .caffe.ConvolutionParameter.Engine engine = 15 [default = DEFAULT]; @@ -14755,7 +22104,7 @@ int ConvolutionParameter::ByteSize() const { } } - if (_has_bits_[16 / 32] & (0xffu << (16 % 32))) { + if (_has_bits_[16 / 32] & 196608u) { // optional uint32 dilation_w = 19; if (has_dilation_w()) { total_size += 2 + @@ -14771,145 +22120,647 @@ int ConvolutionParameter::ByteSize() const { } } - if (!unknown_fields().empty()) { + if (_internal_metadata_.have_unknown_fields()) { total_size += ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( unknown_fields()); } + int cached_size = ::google::protobuf::internal::ToCachedSize(total_size); GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); - _cached_size_ = total_size; + _cached_size_ = cached_size; GOOGLE_SAFE_CONCURRENT_WRITES_END(); return total_size; } - -void ConvolutionParameter::MergeFrom(const ::google::protobuf::Message& from) { - GOOGLE_CHECK_NE(&from, this); - const ConvolutionParameter* source = - ::google::protobuf::internal::dynamic_cast_if_available( - &from); - if (source == NULL) { - ::google::protobuf::internal::ReflectionOps::Merge(from, this); + +void ConvolutionParameter::MergeFrom(const ::google::protobuf::Message& from) { +// @@protoc_insertion_point(generalized_merge_from_start:caffe.ConvolutionParameter) + if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__); + const ConvolutionParameter* source = + ::google::protobuf::internal::DynamicCastToGenerated( + &from); + if (source == NULL) { + // @@protoc_insertion_point(generalized_merge_from_cast_fail:caffe.ConvolutionParameter) + ::google::protobuf::internal::ReflectionOps::Merge(from, this); + } else { + // @@protoc_insertion_point(generalized_merge_from_cast_success:caffe.ConvolutionParameter) + UnsafeMergeFrom(*source); + } +} + +void ConvolutionParameter::MergeFrom(const ConvolutionParameter& from) { +// @@protoc_insertion_point(class_specific_merge_from_start:caffe.ConvolutionParameter) + if (GOOGLE_PREDICT_TRUE(&from != this)) { + UnsafeMergeFrom(from); + } else { + MergeFromFail(__LINE__); + } +} + +void ConvolutionParameter::UnsafeMergeFrom(const ConvolutionParameter& from) { + GOOGLE_DCHECK(&from != this); + if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) { + if (from.has_num_output()) { + set_num_output(from.num_output()); + } + if (from.has_bias_term()) { + set_bias_term(from.bias_term()); + } + if (from.has_pad()) { + set_pad(from.pad()); + } + if (from.has_pad_h()) { + set_pad_h(from.pad_h()); + } + if (from.has_pad_w()) { + set_pad_w(from.pad_w()); + } + if (from.has_kernel_size()) { + set_kernel_size(from.kernel_size()); + } + if (from.has_kernel_h()) { + set_kernel_h(from.kernel_h()); + } + if (from.has_kernel_w()) { + set_kernel_w(from.kernel_w()); + } + } + if (from._has_bits_[8 / 32] & (0xffu << (8 % 32))) { + if (from.has_group()) { + set_group(from.group()); + } + if (from.has_stride()) { + set_stride(from.stride()); + } + if (from.has_stride_h()) { + set_stride_h(from.stride_h()); + } + if (from.has_stride_w()) { + set_stride_w(from.stride_w()); + } + if (from.has_weight_filler()) { + mutable_weight_filler()->::caffe::FillerParameter::MergeFrom(from.weight_filler()); + } + if (from.has_bias_filler()) { + mutable_bias_filler()->::caffe::FillerParameter::MergeFrom(from.bias_filler()); + } + if (from.has_engine()) { + set_engine(from.engine()); + } + if (from.has_dilation_h()) { + set_dilation_h(from.dilation_h()); + } + } + if (from._has_bits_[16 / 32] & (0xffu << (16 % 32))) { + if (from.has_dilation_w()) { + set_dilation_w(from.dilation_w()); + } + if (from.has_dilation()) { + set_dilation(from.dilation()); + } + } + if (from._internal_metadata_.have_unknown_fields()) { + ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata( + from.unknown_fields(), &_internal_metadata_); + } +} + +void ConvolutionParameter::CopyFrom(const ::google::protobuf::Message& from) { +// @@protoc_insertion_point(generalized_copy_from_start:caffe.ConvolutionParameter) + if (&from == this) return; + Clear(); + MergeFrom(from); +} + +void ConvolutionParameter::CopyFrom(const ConvolutionParameter& from) { +// @@protoc_insertion_point(class_specific_copy_from_start:caffe.ConvolutionParameter) + if (&from == this) return; + Clear(); + UnsafeMergeFrom(from); +} + +bool ConvolutionParameter::IsInitialized() const { + + return true; +} + +void ConvolutionParameter::Swap(ConvolutionParameter* other) { + if (other == this) return; + InternalSwap(other); +} +void ConvolutionParameter::InternalSwap(ConvolutionParameter* other) { + std::swap(num_output_, other->num_output_); + std::swap(bias_term_, other->bias_term_); + std::swap(pad_, other->pad_); + std::swap(pad_h_, other->pad_h_); + std::swap(pad_w_, other->pad_w_); + std::swap(kernel_size_, other->kernel_size_); + std::swap(kernel_h_, other->kernel_h_); + std::swap(kernel_w_, other->kernel_w_); + std::swap(group_, other->group_); + std::swap(stride_, other->stride_); + std::swap(stride_h_, other->stride_h_); + std::swap(stride_w_, other->stride_w_); + std::swap(weight_filler_, other->weight_filler_); + std::swap(bias_filler_, other->bias_filler_); + std::swap(engine_, other->engine_); + std::swap(dilation_h_, other->dilation_h_); + std::swap(dilation_w_, other->dilation_w_); + std::swap(dilation_, other->dilation_); + std::swap(_has_bits_[0], other->_has_bits_[0]); + _internal_metadata_.Swap(&other->_internal_metadata_); + std::swap(_cached_size_, other->_cached_size_); +} + +::google::protobuf::Metadata ConvolutionParameter::GetMetadata() const { + protobuf_AssignDescriptorsOnce(); + ::google::protobuf::Metadata metadata; + metadata.descriptor = ConvolutionParameter_descriptor_; + metadata.reflection = ConvolutionParameter_reflection_; + return metadata; +} + +#if PROTOBUF_INLINE_NOT_IN_HEADERS +// ConvolutionParameter + +// optional uint32 num_output = 1; +bool ConvolutionParameter::has_num_output() const { + return (_has_bits_[0] & 0x00000001u) != 0; +} +void ConvolutionParameter::set_has_num_output() { + _has_bits_[0] |= 0x00000001u; +} +void ConvolutionParameter::clear_has_num_output() { + _has_bits_[0] &= ~0x00000001u; +} +void ConvolutionParameter::clear_num_output() { + num_output_ = 0u; + clear_has_num_output(); +} +::google::protobuf::uint32 ConvolutionParameter::num_output() const { + // @@protoc_insertion_point(field_get:caffe.ConvolutionParameter.num_output) + return num_output_; +} +void ConvolutionParameter::set_num_output(::google::protobuf::uint32 value) { + set_has_num_output(); + num_output_ = value; + // @@protoc_insertion_point(field_set:caffe.ConvolutionParameter.num_output) +} + +// optional bool bias_term = 2 [default = true]; +bool ConvolutionParameter::has_bias_term() const { + return (_has_bits_[0] & 0x00000002u) != 0; +} +void ConvolutionParameter::set_has_bias_term() { + _has_bits_[0] |= 0x00000002u; +} +void ConvolutionParameter::clear_has_bias_term() { + _has_bits_[0] &= ~0x00000002u; +} +void ConvolutionParameter::clear_bias_term() { + bias_term_ = true; + clear_has_bias_term(); +} +bool ConvolutionParameter::bias_term() const { + // @@protoc_insertion_point(field_get:caffe.ConvolutionParameter.bias_term) + return bias_term_; +} +void ConvolutionParameter::set_bias_term(bool value) { + set_has_bias_term(); + bias_term_ = value; + // @@protoc_insertion_point(field_set:caffe.ConvolutionParameter.bias_term) +} + +// optional uint32 pad = 3 [default = 0]; +bool ConvolutionParameter::has_pad() const { + return (_has_bits_[0] & 0x00000004u) != 0; +} +void ConvolutionParameter::set_has_pad() { + _has_bits_[0] |= 0x00000004u; +} +void ConvolutionParameter::clear_has_pad() { + _has_bits_[0] &= ~0x00000004u; +} +void ConvolutionParameter::clear_pad() { + pad_ = 0u; + clear_has_pad(); +} +::google::protobuf::uint32 ConvolutionParameter::pad() const { + // @@protoc_insertion_point(field_get:caffe.ConvolutionParameter.pad) + return pad_; +} +void ConvolutionParameter::set_pad(::google::protobuf::uint32 value) { + set_has_pad(); + pad_ = value; + // @@protoc_insertion_point(field_set:caffe.ConvolutionParameter.pad) +} + +// optional uint32 pad_h = 9 [default = 0]; +bool ConvolutionParameter::has_pad_h() const { + return (_has_bits_[0] & 0x00000008u) != 0; +} +void ConvolutionParameter::set_has_pad_h() { + _has_bits_[0] |= 0x00000008u; +} +void ConvolutionParameter::clear_has_pad_h() { + _has_bits_[0] &= ~0x00000008u; +} +void ConvolutionParameter::clear_pad_h() { + pad_h_ = 0u; + clear_has_pad_h(); +} +::google::protobuf::uint32 ConvolutionParameter::pad_h() const { + // @@protoc_insertion_point(field_get:caffe.ConvolutionParameter.pad_h) + return pad_h_; +} +void ConvolutionParameter::set_pad_h(::google::protobuf::uint32 value) { + set_has_pad_h(); + pad_h_ = value; + // @@protoc_insertion_point(field_set:caffe.ConvolutionParameter.pad_h) +} + +// optional uint32 pad_w = 10 [default = 0]; +bool ConvolutionParameter::has_pad_w() const { + return (_has_bits_[0] & 0x00000010u) != 0; +} +void ConvolutionParameter::set_has_pad_w() { + _has_bits_[0] |= 0x00000010u; +} +void ConvolutionParameter::clear_has_pad_w() { + _has_bits_[0] &= ~0x00000010u; +} +void ConvolutionParameter::clear_pad_w() { + pad_w_ = 0u; + clear_has_pad_w(); +} +::google::protobuf::uint32 ConvolutionParameter::pad_w() const { + // @@protoc_insertion_point(field_get:caffe.ConvolutionParameter.pad_w) + return pad_w_; +} +void ConvolutionParameter::set_pad_w(::google::protobuf::uint32 value) { + set_has_pad_w(); + pad_w_ = value; + // @@protoc_insertion_point(field_set:caffe.ConvolutionParameter.pad_w) +} + +// optional uint32 kernel_size = 4; +bool ConvolutionParameter::has_kernel_size() const { + return (_has_bits_[0] & 0x00000020u) != 0; +} +void ConvolutionParameter::set_has_kernel_size() { + _has_bits_[0] |= 0x00000020u; +} +void ConvolutionParameter::clear_has_kernel_size() { + _has_bits_[0] &= ~0x00000020u; +} +void ConvolutionParameter::clear_kernel_size() { + kernel_size_ = 0u; + clear_has_kernel_size(); +} +::google::protobuf::uint32 ConvolutionParameter::kernel_size() const { + // @@protoc_insertion_point(field_get:caffe.ConvolutionParameter.kernel_size) + return kernel_size_; +} +void ConvolutionParameter::set_kernel_size(::google::protobuf::uint32 value) { + set_has_kernel_size(); + kernel_size_ = value; + // @@protoc_insertion_point(field_set:caffe.ConvolutionParameter.kernel_size) +} + +// optional uint32 kernel_h = 11; +bool ConvolutionParameter::has_kernel_h() const { + return (_has_bits_[0] & 0x00000040u) != 0; +} +void ConvolutionParameter::set_has_kernel_h() { + _has_bits_[0] |= 0x00000040u; +} +void ConvolutionParameter::clear_has_kernel_h() { + _has_bits_[0] &= ~0x00000040u; +} +void ConvolutionParameter::clear_kernel_h() { + kernel_h_ = 0u; + clear_has_kernel_h(); +} +::google::protobuf::uint32 ConvolutionParameter::kernel_h() const { + // @@protoc_insertion_point(field_get:caffe.ConvolutionParameter.kernel_h) + return kernel_h_; +} +void ConvolutionParameter::set_kernel_h(::google::protobuf::uint32 value) { + set_has_kernel_h(); + kernel_h_ = value; + // @@protoc_insertion_point(field_set:caffe.ConvolutionParameter.kernel_h) +} + +// optional uint32 kernel_w = 12; +bool ConvolutionParameter::has_kernel_w() const { + return (_has_bits_[0] & 0x00000080u) != 0; +} +void ConvolutionParameter::set_has_kernel_w() { + _has_bits_[0] |= 0x00000080u; +} +void ConvolutionParameter::clear_has_kernel_w() { + _has_bits_[0] &= ~0x00000080u; +} +void ConvolutionParameter::clear_kernel_w() { + kernel_w_ = 0u; + clear_has_kernel_w(); +} +::google::protobuf::uint32 ConvolutionParameter::kernel_w() const { + // @@protoc_insertion_point(field_get:caffe.ConvolutionParameter.kernel_w) + return kernel_w_; +} +void ConvolutionParameter::set_kernel_w(::google::protobuf::uint32 value) { + set_has_kernel_w(); + kernel_w_ = value; + // @@protoc_insertion_point(field_set:caffe.ConvolutionParameter.kernel_w) +} + +// optional uint32 group = 5 [default = 1]; +bool ConvolutionParameter::has_group() const { + return (_has_bits_[0] & 0x00000100u) != 0; +} +void ConvolutionParameter::set_has_group() { + _has_bits_[0] |= 0x00000100u; +} +void ConvolutionParameter::clear_has_group() { + _has_bits_[0] &= ~0x00000100u; +} +void ConvolutionParameter::clear_group() { + group_ = 1u; + clear_has_group(); +} +::google::protobuf::uint32 ConvolutionParameter::group() const { + // @@protoc_insertion_point(field_get:caffe.ConvolutionParameter.group) + return group_; +} +void ConvolutionParameter::set_group(::google::protobuf::uint32 value) { + set_has_group(); + group_ = value; + // @@protoc_insertion_point(field_set:caffe.ConvolutionParameter.group) +} + +// optional uint32 stride = 6 [default = 1]; +bool ConvolutionParameter::has_stride() const { + return (_has_bits_[0] & 0x00000200u) != 0; +} +void ConvolutionParameter::set_has_stride() { + _has_bits_[0] |= 0x00000200u; +} +void ConvolutionParameter::clear_has_stride() { + _has_bits_[0] &= ~0x00000200u; +} +void ConvolutionParameter::clear_stride() { + stride_ = 1u; + clear_has_stride(); +} +::google::protobuf::uint32 ConvolutionParameter::stride() const { + // @@protoc_insertion_point(field_get:caffe.ConvolutionParameter.stride) + return stride_; +} +void ConvolutionParameter::set_stride(::google::protobuf::uint32 value) { + set_has_stride(); + stride_ = value; + // @@protoc_insertion_point(field_set:caffe.ConvolutionParameter.stride) +} + +// optional uint32 stride_h = 13; +bool ConvolutionParameter::has_stride_h() const { + return (_has_bits_[0] & 0x00000400u) != 0; +} +void ConvolutionParameter::set_has_stride_h() { + _has_bits_[0] |= 0x00000400u; +} +void ConvolutionParameter::clear_has_stride_h() { + _has_bits_[0] &= ~0x00000400u; +} +void ConvolutionParameter::clear_stride_h() { + stride_h_ = 0u; + clear_has_stride_h(); +} +::google::protobuf::uint32 ConvolutionParameter::stride_h() const { + // @@protoc_insertion_point(field_get:caffe.ConvolutionParameter.stride_h) + return stride_h_; +} +void ConvolutionParameter::set_stride_h(::google::protobuf::uint32 value) { + set_has_stride_h(); + stride_h_ = value; + // @@protoc_insertion_point(field_set:caffe.ConvolutionParameter.stride_h) +} + +// optional uint32 stride_w = 14; +bool ConvolutionParameter::has_stride_w() const { + return (_has_bits_[0] & 0x00000800u) != 0; +} +void ConvolutionParameter::set_has_stride_w() { + _has_bits_[0] |= 0x00000800u; +} +void ConvolutionParameter::clear_has_stride_w() { + _has_bits_[0] &= ~0x00000800u; +} +void ConvolutionParameter::clear_stride_w() { + stride_w_ = 0u; + clear_has_stride_w(); +} +::google::protobuf::uint32 ConvolutionParameter::stride_w() const { + // @@protoc_insertion_point(field_get:caffe.ConvolutionParameter.stride_w) + return stride_w_; +} +void ConvolutionParameter::set_stride_w(::google::protobuf::uint32 value) { + set_has_stride_w(); + stride_w_ = value; + // @@protoc_insertion_point(field_set:caffe.ConvolutionParameter.stride_w) +} + +// optional .caffe.FillerParameter weight_filler = 7; +bool ConvolutionParameter::has_weight_filler() const { + return (_has_bits_[0] & 0x00001000u) != 0; +} +void ConvolutionParameter::set_has_weight_filler() { + _has_bits_[0] |= 0x00001000u; +} +void ConvolutionParameter::clear_has_weight_filler() { + _has_bits_[0] &= ~0x00001000u; +} +void ConvolutionParameter::clear_weight_filler() { + if (weight_filler_ != NULL) weight_filler_->::caffe::FillerParameter::Clear(); + clear_has_weight_filler(); +} +const ::caffe::FillerParameter& ConvolutionParameter::weight_filler() const { + // @@protoc_insertion_point(field_get:caffe.ConvolutionParameter.weight_filler) + return weight_filler_ != NULL ? *weight_filler_ + : *::caffe::FillerParameter::internal_default_instance(); +} +::caffe::FillerParameter* ConvolutionParameter::mutable_weight_filler() { + set_has_weight_filler(); + if (weight_filler_ == NULL) { + weight_filler_ = new ::caffe::FillerParameter; + } + // @@protoc_insertion_point(field_mutable:caffe.ConvolutionParameter.weight_filler) + return weight_filler_; +} +::caffe::FillerParameter* ConvolutionParameter::release_weight_filler() { + // @@protoc_insertion_point(field_release:caffe.ConvolutionParameter.weight_filler) + clear_has_weight_filler(); + ::caffe::FillerParameter* temp = weight_filler_; + weight_filler_ = NULL; + return temp; +} +void ConvolutionParameter::set_allocated_weight_filler(::caffe::FillerParameter* weight_filler) { + delete weight_filler_; + weight_filler_ = weight_filler; + if (weight_filler) { + set_has_weight_filler(); } else { - MergeFrom(*source); + clear_has_weight_filler(); } + // @@protoc_insertion_point(field_set_allocated:caffe.ConvolutionParameter.weight_filler) } -void ConvolutionParameter::MergeFrom(const ConvolutionParameter& from) { - GOOGLE_CHECK_NE(&from, this); - if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) { - if (from.has_num_output()) { - set_num_output(from.num_output()); - } - if (from.has_bias_term()) { - set_bias_term(from.bias_term()); - } - if (from.has_pad()) { - set_pad(from.pad()); - } - if (from.has_pad_h()) { - set_pad_h(from.pad_h()); - } - if (from.has_pad_w()) { - set_pad_w(from.pad_w()); - } - if (from.has_kernel_size()) { - set_kernel_size(from.kernel_size()); - } - if (from.has_kernel_h()) { - set_kernel_h(from.kernel_h()); - } - if (from.has_kernel_w()) { - set_kernel_w(from.kernel_w()); - } - } - if (from._has_bits_[8 / 32] & (0xffu << (8 % 32))) { - if (from.has_group()) { - set_group(from.group()); - } - if (from.has_stride()) { - set_stride(from.stride()); - } - if (from.has_stride_h()) { - set_stride_h(from.stride_h()); - } - if (from.has_stride_w()) { - set_stride_w(from.stride_w()); - } - if (from.has_weight_filler()) { - mutable_weight_filler()->::caffe::FillerParameter::MergeFrom(from.weight_filler()); - } - if (from.has_bias_filler()) { - mutable_bias_filler()->::caffe::FillerParameter::MergeFrom(from.bias_filler()); - } - if (from.has_engine()) { - set_engine(from.engine()); - } - if (from.has_dilation_h()) { - set_dilation_h(from.dilation_h()); - } +// optional .caffe.FillerParameter bias_filler = 8; +bool ConvolutionParameter::has_bias_filler() const { + return (_has_bits_[0] & 0x00002000u) != 0; +} +void ConvolutionParameter::set_has_bias_filler() { + _has_bits_[0] |= 0x00002000u; +} +void ConvolutionParameter::clear_has_bias_filler() { + _has_bits_[0] &= ~0x00002000u; +} +void ConvolutionParameter::clear_bias_filler() { + if (bias_filler_ != NULL) bias_filler_->::caffe::FillerParameter::Clear(); + clear_has_bias_filler(); +} +const ::caffe::FillerParameter& ConvolutionParameter::bias_filler() const { + // @@protoc_insertion_point(field_get:caffe.ConvolutionParameter.bias_filler) + return bias_filler_ != NULL ? *bias_filler_ + : *::caffe::FillerParameter::internal_default_instance(); +} +::caffe::FillerParameter* ConvolutionParameter::mutable_bias_filler() { + set_has_bias_filler(); + if (bias_filler_ == NULL) { + bias_filler_ = new ::caffe::FillerParameter; } - if (from._has_bits_[16 / 32] & (0xffu << (16 % 32))) { - if (from.has_dilation_w()) { - set_dilation_w(from.dilation_w()); - } - if (from.has_dilation()) { - set_dilation(from.dilation()); - } + // @@protoc_insertion_point(field_mutable:caffe.ConvolutionParameter.bias_filler) + return bias_filler_; +} +::caffe::FillerParameter* ConvolutionParameter::release_bias_filler() { + // @@protoc_insertion_point(field_release:caffe.ConvolutionParameter.bias_filler) + clear_has_bias_filler(); + ::caffe::FillerParameter* temp = bias_filler_; + bias_filler_ = NULL; + return temp; +} +void ConvolutionParameter::set_allocated_bias_filler(::caffe::FillerParameter* bias_filler) { + delete bias_filler_; + bias_filler_ = bias_filler; + if (bias_filler) { + set_has_bias_filler(); + } else { + clear_has_bias_filler(); } - mutable_unknown_fields()->MergeFrom(from.unknown_fields()); + // @@protoc_insertion_point(field_set_allocated:caffe.ConvolutionParameter.bias_filler) } -void ConvolutionParameter::CopyFrom(const ::google::protobuf::Message& from) { - if (&from == this) return; - Clear(); - MergeFrom(from); +// optional .caffe.ConvolutionParameter.Engine engine = 15 [default = DEFAULT]; +bool ConvolutionParameter::has_engine() const { + return (_has_bits_[0] & 0x00004000u) != 0; } - -void ConvolutionParameter::CopyFrom(const ConvolutionParameter& from) { - if (&from == this) return; - Clear(); - MergeFrom(from); +void ConvolutionParameter::set_has_engine() { + _has_bits_[0] |= 0x00004000u; +} +void ConvolutionParameter::clear_has_engine() { + _has_bits_[0] &= ~0x00004000u; +} +void ConvolutionParameter::clear_engine() { + engine_ = 0; + clear_has_engine(); +} +::caffe::ConvolutionParameter_Engine ConvolutionParameter::engine() const { + // @@protoc_insertion_point(field_get:caffe.ConvolutionParameter.engine) + return static_cast< ::caffe::ConvolutionParameter_Engine >(engine_); +} +void ConvolutionParameter::set_engine(::caffe::ConvolutionParameter_Engine value) { + assert(::caffe::ConvolutionParameter_Engine_IsValid(value)); + set_has_engine(); + engine_ = value; + // @@protoc_insertion_point(field_set:caffe.ConvolutionParameter.engine) } -bool ConvolutionParameter::IsInitialized() const { - - return true; +// optional uint32 dilation_h = 18; +bool ConvolutionParameter::has_dilation_h() const { + return (_has_bits_[0] & 0x00008000u) != 0; +} +void ConvolutionParameter::set_has_dilation_h() { + _has_bits_[0] |= 0x00008000u; +} +void ConvolutionParameter::clear_has_dilation_h() { + _has_bits_[0] &= ~0x00008000u; +} +void ConvolutionParameter::clear_dilation_h() { + dilation_h_ = 0u; + clear_has_dilation_h(); +} +::google::protobuf::uint32 ConvolutionParameter::dilation_h() const { + // @@protoc_insertion_point(field_get:caffe.ConvolutionParameter.dilation_h) + return dilation_h_; +} +void ConvolutionParameter::set_dilation_h(::google::protobuf::uint32 value) { + set_has_dilation_h(); + dilation_h_ = value; + // @@protoc_insertion_point(field_set:caffe.ConvolutionParameter.dilation_h) } -void ConvolutionParameter::Swap(ConvolutionParameter* other) { - if (other != this) { - std::swap(num_output_, other->num_output_); - std::swap(bias_term_, other->bias_term_); - std::swap(pad_, other->pad_); - std::swap(pad_h_, other->pad_h_); - std::swap(pad_w_, other->pad_w_); - std::swap(kernel_size_, other->kernel_size_); - std::swap(kernel_h_, other->kernel_h_); - std::swap(kernel_w_, other->kernel_w_); - std::swap(group_, other->group_); - std::swap(stride_, other->stride_); - std::swap(stride_h_, other->stride_h_); - std::swap(stride_w_, other->stride_w_); - std::swap(weight_filler_, other->weight_filler_); - std::swap(bias_filler_, other->bias_filler_); - std::swap(engine_, other->engine_); - std::swap(dilation_h_, other->dilation_h_); - std::swap(dilation_w_, other->dilation_w_); - std::swap(dilation_, other->dilation_); - std::swap(_has_bits_[0], other->_has_bits_[0]); - _unknown_fields_.Swap(&other->_unknown_fields_); - std::swap(_cached_size_, other->_cached_size_); - } +// optional uint32 dilation_w = 19; +bool ConvolutionParameter::has_dilation_w() const { + return (_has_bits_[0] & 0x00010000u) != 0; +} +void ConvolutionParameter::set_has_dilation_w() { + _has_bits_[0] |= 0x00010000u; +} +void ConvolutionParameter::clear_has_dilation_w() { + _has_bits_[0] &= ~0x00010000u; +} +void ConvolutionParameter::clear_dilation_w() { + dilation_w_ = 0u; + clear_has_dilation_w(); +} +::google::protobuf::uint32 ConvolutionParameter::dilation_w() const { + // @@protoc_insertion_point(field_get:caffe.ConvolutionParameter.dilation_w) + return dilation_w_; +} +void ConvolutionParameter::set_dilation_w(::google::protobuf::uint32 value) { + set_has_dilation_w(); + dilation_w_ = value; + // @@protoc_insertion_point(field_set:caffe.ConvolutionParameter.dilation_w) } -::google::protobuf::Metadata ConvolutionParameter::GetMetadata() const { - protobuf_AssignDescriptorsOnce(); - ::google::protobuf::Metadata metadata; - metadata.descriptor = ConvolutionParameter_descriptor_; - metadata.reflection = ConvolutionParameter_reflection_; - return metadata; +// optional uint32 dilation = 20; +bool ConvolutionParameter::has_dilation() const { + return (_has_bits_[0] & 0x00020000u) != 0; +} +void ConvolutionParameter::set_has_dilation() { + _has_bits_[0] |= 0x00020000u; +} +void ConvolutionParameter::clear_has_dilation() { + _has_bits_[0] &= ~0x00020000u; +} +void ConvolutionParameter::clear_dilation() { + dilation_ = 0u; + clear_has_dilation(); +} +::google::protobuf::uint32 ConvolutionParameter::dilation() const { + // @@protoc_insertion_point(field_get:caffe.ConvolutionParameter.dilation) + return dilation_; +} +void ConvolutionParameter::set_dilation(::google::protobuf::uint32 value) { + set_has_dilation(); + dilation_ = value; + // @@protoc_insertion_point(field_set:caffe.ConvolutionParameter.dilation) } +inline const ConvolutionParameter* ConvolutionParameter::internal_default_instance() { + return &ConvolutionParameter_default_instance_.get(); +} +#endif // PROTOBUF_INLINE_NOT_IN_HEADERS // =================================================================== @@ -14918,7 +22769,7 @@ const ::google::protobuf::EnumDescriptor* DataParameter_DB_descriptor() { return DataParameter_DB_descriptor_; } bool DataParameter_DB_IsValid(int value) { - switch(value) { + switch (value) { case 0: case 1: return true; @@ -14927,14 +22778,14 @@ bool DataParameter_DB_IsValid(int value) { } } -#ifndef _MSC_VER +#if !defined(_MSC_VER) || _MSC_VER >= 1900 const DataParameter_DB DataParameter::LEVELDB; const DataParameter_DB DataParameter::LMDB; const DataParameter_DB DataParameter::DB_MIN; const DataParameter_DB DataParameter::DB_MAX; const int DataParameter::DB_ARRAYSIZE; -#endif // _MSC_VER -#ifndef _MSC_VER +#endif // !defined(_MSC_VER) || _MSC_VER >= 1900 +#if !defined(_MSC_VER) || _MSC_VER >= 1900 const int DataParameter::kSourceFieldNumber; const int DataParameter::kBatchSizeFieldNumber; const int DataParameter::kRandSkipFieldNumber; @@ -14944,49 +22795,43 @@ const int DataParameter::kMeanFileFieldNumber; const int DataParameter::kCropSizeFieldNumber; const int DataParameter::kMirrorFieldNumber; const int DataParameter::kForceEncodedColorFieldNumber; -#endif // !_MSC_VER +#endif // !defined(_MSC_VER) || _MSC_VER >= 1900 DataParameter::DataParameter() - : ::google::protobuf::Message() { + : ::google::protobuf::Message(), _internal_metadata_(NULL) { + if (this != internal_default_instance()) protobuf_InitDefaults_caffe_2eproto(); SharedCtor(); + // @@protoc_insertion_point(constructor:caffe.DataParameter) } void DataParameter::InitAsDefaultInstance() { } DataParameter::DataParameter(const DataParameter& from) - : ::google::protobuf::Message() { + : ::google::protobuf::Message(), + _internal_metadata_(NULL) { SharedCtor(); - MergeFrom(from); + UnsafeMergeFrom(from); + // @@protoc_insertion_point(copy_constructor:caffe.DataParameter) } void DataParameter::SharedCtor() { _cached_size_ = 0; - source_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); - batch_size_ = 0u; - rand_skip_ = 0u; - backend_ = 0; + source_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + mean_file_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + ::memset(&batch_size_, 0, reinterpret_cast(&force_encoded_color_) - + reinterpret_cast(&batch_size_) + sizeof(force_encoded_color_)); scale_ = 1; - mean_file_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); - crop_size_ = 0u; - mirror_ = false; - force_encoded_color_ = false; - ::memset(_has_bits_, 0, sizeof(_has_bits_)); } DataParameter::~DataParameter() { + // @@protoc_insertion_point(destructor:caffe.DataParameter) SharedDtor(); } void DataParameter::SharedDtor() { - if (source_ != &::google::protobuf::internal::kEmptyString) { - delete source_; - } - if (mean_file_ != &::google::protobuf::internal::kEmptyString) { - delete mean_file_; - } - if (this != default_instance_) { - } + source_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + mean_file_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } void DataParameter::SetCachedSize(int size) const { @@ -15000,59 +22845,80 @@ const ::google::protobuf::Descriptor* DataParameter::descriptor() { } const DataParameter& DataParameter::default_instance() { - if (default_instance_ == NULL) protobuf_AddDesc_caffe_2eproto(); - return *default_instance_; + protobuf_InitDefaults_caffe_2eproto(); + return *internal_default_instance(); } -DataParameter* DataParameter::default_instance_ = NULL; +::google::protobuf::internal::ExplicitlyConstructed DataParameter_default_instance_; -DataParameter* DataParameter::New() const { - return new DataParameter; +DataParameter* DataParameter::New(::google::protobuf::Arena* arena) const { + DataParameter* n = new DataParameter; + if (arena != NULL) { + arena->Own(n); + } + return n; } void DataParameter::Clear() { - if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) { +// @@protoc_insertion_point(message_clear_start:caffe.DataParameter) +#if defined(__clang__) +#define ZR_HELPER_(f) \ + _Pragma("clang diagnostic push") \ + _Pragma("clang diagnostic ignored \"-Winvalid-offsetof\"") \ + __builtin_offsetof(DataParameter, f) \ + _Pragma("clang diagnostic pop") +#else +#define ZR_HELPER_(f) reinterpret_cast(\ + &reinterpret_cast(16)->f) +#endif + +#define ZR_(first, last) do {\ + ::memset(&(first), 0,\ + ZR_HELPER_(last) - ZR_HELPER_(first) + sizeof(last));\ +} while (0) + + if (_has_bits_[0 / 32] & 255u) { + ZR_(batch_size_, mirror_); if (has_source()) { - if (source_ != &::google::protobuf::internal::kEmptyString) { - source_->clear(); - } + source_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - batch_size_ = 0u; - rand_skip_ = 0u; - backend_ = 0; scale_ = 1; if (has_mean_file()) { - if (mean_file_ != &::google::protobuf::internal::kEmptyString) { - mean_file_->clear(); - } + mean_file_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - crop_size_ = 0u; - mirror_ = false; } - if (_has_bits_[8 / 32] & (0xffu << (8 % 32))) { - force_encoded_color_ = false; + force_encoded_color_ = false; + +#undef ZR_HELPER_ +#undef ZR_ + + _has_bits_.Clear(); + if (_internal_metadata_.have_unknown_fields()) { + mutable_unknown_fields()->Clear(); } - ::memset(_has_bits_, 0, sizeof(_has_bits_)); - mutable_unknown_fields()->Clear(); } bool DataParameter::MergePartialFromCodedStream( ::google::protobuf::io::CodedInputStream* input) { -#define DO_(EXPRESSION) if (!(EXPRESSION)) return false +#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure ::google::protobuf::uint32 tag; - while ((tag = input->ReadTag()) != 0) { + // @@protoc_insertion_point(parse_start:caffe.DataParameter) + for (;;) { + ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127); + tag = p.first; + if (!p.second) goto handle_unusual; switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { // optional string source = 1; case 1: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) { + if (tag == 10) { DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->mutable_source())); - ::google::protobuf::internal::WireFormat::VerifyUTF8String( + ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( this->source().data(), this->source().length(), - ::google::protobuf::internal::WireFormat::PARSE); + ::google::protobuf::internal::WireFormat::PARSE, + "caffe.DataParameter.source"); } else { - goto handle_uninterpreted; + goto handle_unusual; } if (input->ExpectTag(21)) goto parse_scale; break; @@ -15060,15 +22926,14 @@ bool DataParameter::MergePartialFromCodedStream( // optional float scale = 2 [default = 1]; case 2: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_FIXED32) { + if (tag == 21) { parse_scale: + set_has_scale(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< float, ::google::protobuf::internal::WireFormatLite::TYPE_FLOAT>( input, &scale_))); - set_has_scale(); } else { - goto handle_uninterpreted; + goto handle_unusual; } if (input->ExpectTag(26)) goto parse_mean_file; break; @@ -15076,16 +22941,16 @@ bool DataParameter::MergePartialFromCodedStream( // optional string mean_file = 3; case 3: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) { + if (tag == 26) { parse_mean_file: DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->mutable_mean_file())); - ::google::protobuf::internal::WireFormat::VerifyUTF8String( + ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( this->mean_file().data(), this->mean_file().length(), - ::google::protobuf::internal::WireFormat::PARSE); + ::google::protobuf::internal::WireFormat::PARSE, + "caffe.DataParameter.mean_file"); } else { - goto handle_uninterpreted; + goto handle_unusual; } if (input->ExpectTag(32)) goto parse_batch_size; break; @@ -15093,15 +22958,14 @@ bool DataParameter::MergePartialFromCodedStream( // optional uint32 batch_size = 4; case 4: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) { + if (tag == 32) { parse_batch_size: + set_has_batch_size(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>( input, &batch_size_))); - set_has_batch_size(); } else { - goto handle_uninterpreted; + goto handle_unusual; } if (input->ExpectTag(40)) goto parse_crop_size; break; @@ -15109,15 +22973,14 @@ bool DataParameter::MergePartialFromCodedStream( // optional uint32 crop_size = 5 [default = 0]; case 5: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) { + if (tag == 40) { parse_crop_size: + set_has_crop_size(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>( input, &crop_size_))); - set_has_crop_size(); } else { - goto handle_uninterpreted; + goto handle_unusual; } if (input->ExpectTag(48)) goto parse_mirror; break; @@ -15125,15 +22988,14 @@ bool DataParameter::MergePartialFromCodedStream( // optional bool mirror = 6 [default = false]; case 6: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) { + if (tag == 48) { parse_mirror: + set_has_mirror(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>( input, &mirror_))); - set_has_mirror(); } else { - goto handle_uninterpreted; + goto handle_unusual; } if (input->ExpectTag(56)) goto parse_rand_skip; break; @@ -15141,15 +23003,14 @@ bool DataParameter::MergePartialFromCodedStream( // optional uint32 rand_skip = 7 [default = 0]; case 7: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) { + if (tag == 56) { parse_rand_skip: + set_has_rand_skip(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>( input, &rand_skip_))); - set_has_rand_skip(); } else { - goto handle_uninterpreted; + goto handle_unusual; } if (input->ExpectTag(64)) goto parse_backend; break; @@ -15157,8 +23018,7 @@ bool DataParameter::MergePartialFromCodedStream( // optional .caffe.DataParameter.DB backend = 8 [default = LEVELDB]; case 8: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) { + if (tag == 64) { parse_backend: int value; DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< @@ -15170,7 +23030,7 @@ bool DataParameter::MergePartialFromCodedStream( mutable_unknown_fields()->AddVarint(8, value); } } else { - goto handle_uninterpreted; + goto handle_unusual; } if (input->ExpectTag(72)) goto parse_force_encoded_color; break; @@ -15178,25 +23038,25 @@ bool DataParameter::MergePartialFromCodedStream( // optional bool force_encoded_color = 9 [default = false]; case 9: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) { + if (tag == 72) { parse_force_encoded_color: + set_has_force_encoded_color(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>( input, &force_encoded_color_))); - set_has_force_encoded_color(); } else { - goto handle_uninterpreted; + goto handle_unusual; } - if (input->ExpectAtEnd()) return true; + if (input->ExpectAtEnd()) goto success; break; } default: { - handle_uninterpreted: - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == + handle_unusual: + if (tag == 0 || + ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) { - return true; + goto success; } DO_(::google::protobuf::internal::WireFormat::SkipField( input, tag, mutable_unknown_fields())); @@ -15204,18 +23064,25 @@ bool DataParameter::MergePartialFromCodedStream( } } } +success: + // @@protoc_insertion_point(parse_success:caffe.DataParameter) return true; +failure: + // @@protoc_insertion_point(parse_failure:caffe.DataParameter) + return false; #undef DO_ } void DataParameter::SerializeWithCachedSizes( ::google::protobuf::io::CodedOutputStream* output) const { + // @@protoc_insertion_point(serialize_start:caffe.DataParameter) // optional string source = 1; if (has_source()) { - ::google::protobuf::internal::WireFormat::VerifyUTF8String( + ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( this->source().data(), this->source().length(), - ::google::protobuf::internal::WireFormat::SERIALIZE); - ::google::protobuf::internal::WireFormatLite::WriteString( + ::google::protobuf::internal::WireFormat::SERIALIZE, + "caffe.DataParameter.source"); + ::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased( 1, this->source(), output); } @@ -15226,10 +23093,11 @@ void DataParameter::SerializeWithCachedSizes( // optional string mean_file = 3; if (has_mean_file()) { - ::google::protobuf::internal::WireFormat::VerifyUTF8String( + ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( this->mean_file().data(), this->mean_file().length(), - ::google::protobuf::internal::WireFormat::SERIALIZE); - ::google::protobuf::internal::WireFormatLite::WriteString( + ::google::protobuf::internal::WireFormat::SERIALIZE, + "caffe.DataParameter.mean_file"); + ::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased( 3, this->mean_file(), output); } @@ -15264,19 +23132,23 @@ void DataParameter::SerializeWithCachedSizes( ::google::protobuf::internal::WireFormatLite::WriteBool(9, this->force_encoded_color(), output); } - if (!unknown_fields().empty()) { + if (_internal_metadata_.have_unknown_fields()) { ::google::protobuf::internal::WireFormat::SerializeUnknownFields( unknown_fields(), output); } + // @@protoc_insertion_point(serialize_end:caffe.DataParameter) } -::google::protobuf::uint8* DataParameter::SerializeWithCachedSizesToArray( - ::google::protobuf::uint8* target) const { +::google::protobuf::uint8* DataParameter::InternalSerializeWithCachedSizesToArray( + bool deterministic, ::google::protobuf::uint8* target) const { + (void)deterministic; // Unused + // @@protoc_insertion_point(serialize_to_array_start:caffe.DataParameter) // optional string source = 1; if (has_source()) { - ::google::protobuf::internal::WireFormat::VerifyUTF8String( + ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( this->source().data(), this->source().length(), - ::google::protobuf::internal::WireFormat::SERIALIZE); + ::google::protobuf::internal::WireFormat::SERIALIZE, + "caffe.DataParameter.source"); target = ::google::protobuf::internal::WireFormatLite::WriteStringToArray( 1, this->source(), target); @@ -15289,9 +23161,10 @@ void DataParameter::SerializeWithCachedSizes( // optional string mean_file = 3; if (has_mean_file()) { - ::google::protobuf::internal::WireFormat::VerifyUTF8String( + ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( this->mean_file().data(), this->mean_file().length(), - ::google::protobuf::internal::WireFormat::SERIALIZE); + ::google::protobuf::internal::WireFormat::SERIALIZE, + "caffe.DataParameter.mean_file"); target = ::google::protobuf::internal::WireFormatLite::WriteStringToArray( 3, this->mean_file(), target); @@ -15328,17 +23201,19 @@ void DataParameter::SerializeWithCachedSizes( target = ::google::protobuf::internal::WireFormatLite::WriteBoolToArray(9, this->force_encoded_color(), target); } - if (!unknown_fields().empty()) { + if (_internal_metadata_.have_unknown_fields()) { target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray( unknown_fields(), target); } + // @@protoc_insertion_point(serialize_to_array_end:caffe.DataParameter) return target; } -int DataParameter::ByteSize() const { - int total_size = 0; +size_t DataParameter::ByteSizeLong() const { +// @@protoc_insertion_point(message_byte_size_start:caffe.DataParameter) + size_t total_size = 0; - if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) { + if (_has_bits_[0 / 32] & 255u) { // optional string source = 1; if (has_source()) { total_size += 1 + @@ -15391,41 +23266,53 @@ int DataParameter::ByteSize() const { } } - if (_has_bits_[8 / 32] & (0xffu << (8 % 32))) { - // optional bool force_encoded_color = 9 [default = false]; - if (has_force_encoded_color()) { - total_size += 1 + 1; - } - + // optional bool force_encoded_color = 9 [default = false]; + if (has_force_encoded_color()) { + total_size += 1 + 1; } - if (!unknown_fields().empty()) { + + if (_internal_metadata_.have_unknown_fields()) { total_size += ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( unknown_fields()); } + int cached_size = ::google::protobuf::internal::ToCachedSize(total_size); GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); - _cached_size_ = total_size; + _cached_size_ = cached_size; GOOGLE_SAFE_CONCURRENT_WRITES_END(); return total_size; } void DataParameter::MergeFrom(const ::google::protobuf::Message& from) { - GOOGLE_CHECK_NE(&from, this); +// @@protoc_insertion_point(generalized_merge_from_start:caffe.DataParameter) + if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__); const DataParameter* source = - ::google::protobuf::internal::dynamic_cast_if_available( - &from); + ::google::protobuf::internal::DynamicCastToGenerated( + &from); if (source == NULL) { + // @@protoc_insertion_point(generalized_merge_from_cast_fail:caffe.DataParameter) ::google::protobuf::internal::ReflectionOps::Merge(from, this); } else { - MergeFrom(*source); + // @@protoc_insertion_point(generalized_merge_from_cast_success:caffe.DataParameter) + UnsafeMergeFrom(*source); } } void DataParameter::MergeFrom(const DataParameter& from) { - GOOGLE_CHECK_NE(&from, this); +// @@protoc_insertion_point(class_specific_merge_from_start:caffe.DataParameter) + if (GOOGLE_PREDICT_TRUE(&from != this)) { + UnsafeMergeFrom(from); + } else { + MergeFromFail(__LINE__); + } +} + +void DataParameter::UnsafeMergeFrom(const DataParameter& from) { + GOOGLE_DCHECK(&from != this); if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) { if (from.has_source()) { - set_source(from.source()); + set_has_source(); + source_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.source_); } if (from.has_batch_size()) { set_batch_size(from.batch_size()); @@ -15440,7 +23327,8 @@ void DataParameter::MergeFrom(const DataParameter& from) { set_scale(from.scale()); } if (from.has_mean_file()) { - set_mean_file(from.mean_file()); + set_has_mean_file(); + mean_file_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.mean_file_); } if (from.has_crop_size()) { set_crop_size(from.crop_size()); @@ -15454,85 +23342,378 @@ void DataParameter::MergeFrom(const DataParameter& from) { set_force_encoded_color(from.force_encoded_color()); } } - mutable_unknown_fields()->MergeFrom(from.unknown_fields()); + if (from._internal_metadata_.have_unknown_fields()) { + ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata( + from.unknown_fields(), &_internal_metadata_); + } } void DataParameter::CopyFrom(const ::google::protobuf::Message& from) { +// @@protoc_insertion_point(generalized_copy_from_start:caffe.DataParameter) if (&from == this) return; Clear(); MergeFrom(from); } void DataParameter::CopyFrom(const DataParameter& from) { +// @@protoc_insertion_point(class_specific_copy_from_start:caffe.DataParameter) if (&from == this) return; Clear(); - MergeFrom(from); + UnsafeMergeFrom(from); } bool DataParameter::IsInitialized() const { return true; } - -void DataParameter::Swap(DataParameter* other) { - if (other != this) { - std::swap(source_, other->source_); - std::swap(batch_size_, other->batch_size_); - std::swap(rand_skip_, other->rand_skip_); - std::swap(backend_, other->backend_); - std::swap(scale_, other->scale_); - std::swap(mean_file_, other->mean_file_); - std::swap(crop_size_, other->crop_size_); - std::swap(mirror_, other->mirror_); - std::swap(force_encoded_color_, other->force_encoded_color_); - std::swap(_has_bits_[0], other->_has_bits_[0]); - _unknown_fields_.Swap(&other->_unknown_fields_); - std::swap(_cached_size_, other->_cached_size_); - } + +void DataParameter::Swap(DataParameter* other) { + if (other == this) return; + InternalSwap(other); +} +void DataParameter::InternalSwap(DataParameter* other) { + source_.Swap(&other->source_); + std::swap(batch_size_, other->batch_size_); + std::swap(rand_skip_, other->rand_skip_); + std::swap(backend_, other->backend_); + std::swap(scale_, other->scale_); + mean_file_.Swap(&other->mean_file_); + std::swap(crop_size_, other->crop_size_); + std::swap(mirror_, other->mirror_); + std::swap(force_encoded_color_, other->force_encoded_color_); + std::swap(_has_bits_[0], other->_has_bits_[0]); + _internal_metadata_.Swap(&other->_internal_metadata_); + std::swap(_cached_size_, other->_cached_size_); +} + +::google::protobuf::Metadata DataParameter::GetMetadata() const { + protobuf_AssignDescriptorsOnce(); + ::google::protobuf::Metadata metadata; + metadata.descriptor = DataParameter_descriptor_; + metadata.reflection = DataParameter_reflection_; + return metadata; +} + +#if PROTOBUF_INLINE_NOT_IN_HEADERS +// DataParameter + +// optional string source = 1; +bool DataParameter::has_source() const { + return (_has_bits_[0] & 0x00000001u) != 0; +} +void DataParameter::set_has_source() { + _has_bits_[0] |= 0x00000001u; +} +void DataParameter::clear_has_source() { + _has_bits_[0] &= ~0x00000001u; +} +void DataParameter::clear_source() { + source_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + clear_has_source(); +} +const ::std::string& DataParameter::source() const { + // @@protoc_insertion_point(field_get:caffe.DataParameter.source) + return source_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); +} +void DataParameter::set_source(const ::std::string& value) { + set_has_source(); + source_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); + // @@protoc_insertion_point(field_set:caffe.DataParameter.source) +} +void DataParameter::set_source(const char* value) { + set_has_source(); + source_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); + // @@protoc_insertion_point(field_set_char:caffe.DataParameter.source) +} +void DataParameter::set_source(const char* value, size_t size) { + set_has_source(); + source_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), + ::std::string(reinterpret_cast(value), size)); + // @@protoc_insertion_point(field_set_pointer:caffe.DataParameter.source) +} +::std::string* DataParameter::mutable_source() { + set_has_source(); + // @@protoc_insertion_point(field_mutable:caffe.DataParameter.source) + return source_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); +} +::std::string* DataParameter::release_source() { + // @@protoc_insertion_point(field_release:caffe.DataParameter.source) + clear_has_source(); + return source_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); +} +void DataParameter::set_allocated_source(::std::string* source) { + if (source != NULL) { + set_has_source(); + } else { + clear_has_source(); + } + source_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), source); + // @@protoc_insertion_point(field_set_allocated:caffe.DataParameter.source) +} + +// optional uint32 batch_size = 4; +bool DataParameter::has_batch_size() const { + return (_has_bits_[0] & 0x00000002u) != 0; +} +void DataParameter::set_has_batch_size() { + _has_bits_[0] |= 0x00000002u; +} +void DataParameter::clear_has_batch_size() { + _has_bits_[0] &= ~0x00000002u; +} +void DataParameter::clear_batch_size() { + batch_size_ = 0u; + clear_has_batch_size(); +} +::google::protobuf::uint32 DataParameter::batch_size() const { + // @@protoc_insertion_point(field_get:caffe.DataParameter.batch_size) + return batch_size_; +} +void DataParameter::set_batch_size(::google::protobuf::uint32 value) { + set_has_batch_size(); + batch_size_ = value; + // @@protoc_insertion_point(field_set:caffe.DataParameter.batch_size) +} + +// optional uint32 rand_skip = 7 [default = 0]; +bool DataParameter::has_rand_skip() const { + return (_has_bits_[0] & 0x00000004u) != 0; +} +void DataParameter::set_has_rand_skip() { + _has_bits_[0] |= 0x00000004u; +} +void DataParameter::clear_has_rand_skip() { + _has_bits_[0] &= ~0x00000004u; +} +void DataParameter::clear_rand_skip() { + rand_skip_ = 0u; + clear_has_rand_skip(); +} +::google::protobuf::uint32 DataParameter::rand_skip() const { + // @@protoc_insertion_point(field_get:caffe.DataParameter.rand_skip) + return rand_skip_; +} +void DataParameter::set_rand_skip(::google::protobuf::uint32 value) { + set_has_rand_skip(); + rand_skip_ = value; + // @@protoc_insertion_point(field_set:caffe.DataParameter.rand_skip) +} + +// optional .caffe.DataParameter.DB backend = 8 [default = LEVELDB]; +bool DataParameter::has_backend() const { + return (_has_bits_[0] & 0x00000008u) != 0; +} +void DataParameter::set_has_backend() { + _has_bits_[0] |= 0x00000008u; +} +void DataParameter::clear_has_backend() { + _has_bits_[0] &= ~0x00000008u; +} +void DataParameter::clear_backend() { + backend_ = 0; + clear_has_backend(); +} +::caffe::DataParameter_DB DataParameter::backend() const { + // @@protoc_insertion_point(field_get:caffe.DataParameter.backend) + return static_cast< ::caffe::DataParameter_DB >(backend_); +} +void DataParameter::set_backend(::caffe::DataParameter_DB value) { + assert(::caffe::DataParameter_DB_IsValid(value)); + set_has_backend(); + backend_ = value; + // @@protoc_insertion_point(field_set:caffe.DataParameter.backend) +} + +// optional float scale = 2 [default = 1]; +bool DataParameter::has_scale() const { + return (_has_bits_[0] & 0x00000010u) != 0; +} +void DataParameter::set_has_scale() { + _has_bits_[0] |= 0x00000010u; +} +void DataParameter::clear_has_scale() { + _has_bits_[0] &= ~0x00000010u; +} +void DataParameter::clear_scale() { + scale_ = 1; + clear_has_scale(); +} +float DataParameter::scale() const { + // @@protoc_insertion_point(field_get:caffe.DataParameter.scale) + return scale_; +} +void DataParameter::set_scale(float value) { + set_has_scale(); + scale_ = value; + // @@protoc_insertion_point(field_set:caffe.DataParameter.scale) +} + +// optional string mean_file = 3; +bool DataParameter::has_mean_file() const { + return (_has_bits_[0] & 0x00000020u) != 0; +} +void DataParameter::set_has_mean_file() { + _has_bits_[0] |= 0x00000020u; +} +void DataParameter::clear_has_mean_file() { + _has_bits_[0] &= ~0x00000020u; +} +void DataParameter::clear_mean_file() { + mean_file_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + clear_has_mean_file(); +} +const ::std::string& DataParameter::mean_file() const { + // @@protoc_insertion_point(field_get:caffe.DataParameter.mean_file) + return mean_file_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); +} +void DataParameter::set_mean_file(const ::std::string& value) { + set_has_mean_file(); + mean_file_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); + // @@protoc_insertion_point(field_set:caffe.DataParameter.mean_file) +} +void DataParameter::set_mean_file(const char* value) { + set_has_mean_file(); + mean_file_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); + // @@protoc_insertion_point(field_set_char:caffe.DataParameter.mean_file) +} +void DataParameter::set_mean_file(const char* value, size_t size) { + set_has_mean_file(); + mean_file_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), + ::std::string(reinterpret_cast(value), size)); + // @@protoc_insertion_point(field_set_pointer:caffe.DataParameter.mean_file) +} +::std::string* DataParameter::mutable_mean_file() { + set_has_mean_file(); + // @@protoc_insertion_point(field_mutable:caffe.DataParameter.mean_file) + return mean_file_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); +} +::std::string* DataParameter::release_mean_file() { + // @@protoc_insertion_point(field_release:caffe.DataParameter.mean_file) + clear_has_mean_file(); + return mean_file_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); +} +void DataParameter::set_allocated_mean_file(::std::string* mean_file) { + if (mean_file != NULL) { + set_has_mean_file(); + } else { + clear_has_mean_file(); + } + mean_file_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), mean_file); + // @@protoc_insertion_point(field_set_allocated:caffe.DataParameter.mean_file) +} + +// optional uint32 crop_size = 5 [default = 0]; +bool DataParameter::has_crop_size() const { + return (_has_bits_[0] & 0x00000040u) != 0; +} +void DataParameter::set_has_crop_size() { + _has_bits_[0] |= 0x00000040u; +} +void DataParameter::clear_has_crop_size() { + _has_bits_[0] &= ~0x00000040u; +} +void DataParameter::clear_crop_size() { + crop_size_ = 0u; + clear_has_crop_size(); +} +::google::protobuf::uint32 DataParameter::crop_size() const { + // @@protoc_insertion_point(field_get:caffe.DataParameter.crop_size) + return crop_size_; +} +void DataParameter::set_crop_size(::google::protobuf::uint32 value) { + set_has_crop_size(); + crop_size_ = value; + // @@protoc_insertion_point(field_set:caffe.DataParameter.crop_size) +} + +// optional bool mirror = 6 [default = false]; +bool DataParameter::has_mirror() const { + return (_has_bits_[0] & 0x00000080u) != 0; +} +void DataParameter::set_has_mirror() { + _has_bits_[0] |= 0x00000080u; +} +void DataParameter::clear_has_mirror() { + _has_bits_[0] &= ~0x00000080u; +} +void DataParameter::clear_mirror() { + mirror_ = false; + clear_has_mirror(); +} +bool DataParameter::mirror() const { + // @@protoc_insertion_point(field_get:caffe.DataParameter.mirror) + return mirror_; +} +void DataParameter::set_mirror(bool value) { + set_has_mirror(); + mirror_ = value; + // @@protoc_insertion_point(field_set:caffe.DataParameter.mirror) +} + +// optional bool force_encoded_color = 9 [default = false]; +bool DataParameter::has_force_encoded_color() const { + return (_has_bits_[0] & 0x00000100u) != 0; +} +void DataParameter::set_has_force_encoded_color() { + _has_bits_[0] |= 0x00000100u; +} +void DataParameter::clear_has_force_encoded_color() { + _has_bits_[0] &= ~0x00000100u; +} +void DataParameter::clear_force_encoded_color() { + force_encoded_color_ = false; + clear_has_force_encoded_color(); +} +bool DataParameter::force_encoded_color() const { + // @@protoc_insertion_point(field_get:caffe.DataParameter.force_encoded_color) + return force_encoded_color_; } - -::google::protobuf::Metadata DataParameter::GetMetadata() const { - protobuf_AssignDescriptorsOnce(); - ::google::protobuf::Metadata metadata; - metadata.descriptor = DataParameter_descriptor_; - metadata.reflection = DataParameter_reflection_; - return metadata; +void DataParameter::set_force_encoded_color(bool value) { + set_has_force_encoded_color(); + force_encoded_color_ = value; + // @@protoc_insertion_point(field_set:caffe.DataParameter.force_encoded_color) } +inline const DataParameter* DataParameter::internal_default_instance() { + return &DataParameter_default_instance_.get(); +} +#endif // PROTOBUF_INLINE_NOT_IN_HEADERS // =================================================================== -#ifndef _MSC_VER +#if !defined(_MSC_VER) || _MSC_VER >= 1900 const int DropoutParameter::kDropoutRatioFieldNumber; -#endif // !_MSC_VER +#endif // !defined(_MSC_VER) || _MSC_VER >= 1900 DropoutParameter::DropoutParameter() - : ::google::protobuf::Message() { + : ::google::protobuf::Message(), _internal_metadata_(NULL) { + if (this != internal_default_instance()) protobuf_InitDefaults_caffe_2eproto(); SharedCtor(); + // @@protoc_insertion_point(constructor:caffe.DropoutParameter) } void DropoutParameter::InitAsDefaultInstance() { } DropoutParameter::DropoutParameter(const DropoutParameter& from) - : ::google::protobuf::Message() { + : ::google::protobuf::Message(), + _internal_metadata_(NULL) { SharedCtor(); - MergeFrom(from); + UnsafeMergeFrom(from); + // @@protoc_insertion_point(copy_constructor:caffe.DropoutParameter) } void DropoutParameter::SharedCtor() { _cached_size_ = 0; dropout_ratio_ = 0.5f; - ::memset(_has_bits_, 0, sizeof(_has_bits_)); } DropoutParameter::~DropoutParameter() { + // @@protoc_insertion_point(destructor:caffe.DropoutParameter) SharedDtor(); } void DropoutParameter::SharedDtor() { - if (this != default_instance_) { - } } void DropoutParameter::SetCachedSize(int size) const { @@ -15546,50 +23727,59 @@ const ::google::protobuf::Descriptor* DropoutParameter::descriptor() { } const DropoutParameter& DropoutParameter::default_instance() { - if (default_instance_ == NULL) protobuf_AddDesc_caffe_2eproto(); - return *default_instance_; + protobuf_InitDefaults_caffe_2eproto(); + return *internal_default_instance(); } -DropoutParameter* DropoutParameter::default_instance_ = NULL; +::google::protobuf::internal::ExplicitlyConstructed DropoutParameter_default_instance_; -DropoutParameter* DropoutParameter::New() const { - return new DropoutParameter; +DropoutParameter* DropoutParameter::New(::google::protobuf::Arena* arena) const { + DropoutParameter* n = new DropoutParameter; + if (arena != NULL) { + arena->Own(n); + } + return n; } void DropoutParameter::Clear() { - if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) { - dropout_ratio_ = 0.5f; +// @@protoc_insertion_point(message_clear_start:caffe.DropoutParameter) + dropout_ratio_ = 0.5f; + _has_bits_.Clear(); + if (_internal_metadata_.have_unknown_fields()) { + mutable_unknown_fields()->Clear(); } - ::memset(_has_bits_, 0, sizeof(_has_bits_)); - mutable_unknown_fields()->Clear(); } bool DropoutParameter::MergePartialFromCodedStream( ::google::protobuf::io::CodedInputStream* input) { -#define DO_(EXPRESSION) if (!(EXPRESSION)) return false +#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure ::google::protobuf::uint32 tag; - while ((tag = input->ReadTag()) != 0) { + // @@protoc_insertion_point(parse_start:caffe.DropoutParameter) + for (;;) { + ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127); + tag = p.first; + if (!p.second) goto handle_unusual; switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { // optional float dropout_ratio = 1 [default = 0.5]; case 1: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_FIXED32) { + if (tag == 13) { + set_has_dropout_ratio(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< float, ::google::protobuf::internal::WireFormatLite::TYPE_FLOAT>( input, &dropout_ratio_))); - set_has_dropout_ratio(); } else { - goto handle_uninterpreted; + goto handle_unusual; } - if (input->ExpectAtEnd()) return true; + if (input->ExpectAtEnd()) goto success; break; } default: { - handle_uninterpreted: - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == + handle_unusual: + if (tag == 0 || + ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) { - return true; + goto success; } DO_(::google::protobuf::internal::WireFormat::SkipField( input, tag, mutable_unknown_fields())); @@ -15597,90 +23787,117 @@ bool DropoutParameter::MergePartialFromCodedStream( } } } +success: + // @@protoc_insertion_point(parse_success:caffe.DropoutParameter) return true; +failure: + // @@protoc_insertion_point(parse_failure:caffe.DropoutParameter) + return false; #undef DO_ } void DropoutParameter::SerializeWithCachedSizes( ::google::protobuf::io::CodedOutputStream* output) const { + // @@protoc_insertion_point(serialize_start:caffe.DropoutParameter) // optional float dropout_ratio = 1 [default = 0.5]; if (has_dropout_ratio()) { ::google::protobuf::internal::WireFormatLite::WriteFloat(1, this->dropout_ratio(), output); } - if (!unknown_fields().empty()) { + if (_internal_metadata_.have_unknown_fields()) { ::google::protobuf::internal::WireFormat::SerializeUnknownFields( unknown_fields(), output); } + // @@protoc_insertion_point(serialize_end:caffe.DropoutParameter) } -::google::protobuf::uint8* DropoutParameter::SerializeWithCachedSizesToArray( - ::google::protobuf::uint8* target) const { +::google::protobuf::uint8* DropoutParameter::InternalSerializeWithCachedSizesToArray( + bool deterministic, ::google::protobuf::uint8* target) const { + (void)deterministic; // Unused + // @@protoc_insertion_point(serialize_to_array_start:caffe.DropoutParameter) // optional float dropout_ratio = 1 [default = 0.5]; if (has_dropout_ratio()) { target = ::google::protobuf::internal::WireFormatLite::WriteFloatToArray(1, this->dropout_ratio(), target); } - if (!unknown_fields().empty()) { + if (_internal_metadata_.have_unknown_fields()) { target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray( unknown_fields(), target); } + // @@protoc_insertion_point(serialize_to_array_end:caffe.DropoutParameter) return target; } -int DropoutParameter::ByteSize() const { - int total_size = 0; - - if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) { - // optional float dropout_ratio = 1 [default = 0.5]; - if (has_dropout_ratio()) { - total_size += 1 + 4; - } +size_t DropoutParameter::ByteSizeLong() const { +// @@protoc_insertion_point(message_byte_size_start:caffe.DropoutParameter) + size_t total_size = 0; + // optional float dropout_ratio = 1 [default = 0.5]; + if (has_dropout_ratio()) { + total_size += 1 + 4; } - if (!unknown_fields().empty()) { + + if (_internal_metadata_.have_unknown_fields()) { total_size += ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( unknown_fields()); } + int cached_size = ::google::protobuf::internal::ToCachedSize(total_size); GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); - _cached_size_ = total_size; + _cached_size_ = cached_size; GOOGLE_SAFE_CONCURRENT_WRITES_END(); return total_size; } void DropoutParameter::MergeFrom(const ::google::protobuf::Message& from) { - GOOGLE_CHECK_NE(&from, this); +// @@protoc_insertion_point(generalized_merge_from_start:caffe.DropoutParameter) + if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__); const DropoutParameter* source = - ::google::protobuf::internal::dynamic_cast_if_available( - &from); + ::google::protobuf::internal::DynamicCastToGenerated( + &from); if (source == NULL) { + // @@protoc_insertion_point(generalized_merge_from_cast_fail:caffe.DropoutParameter) ::google::protobuf::internal::ReflectionOps::Merge(from, this); } else { - MergeFrom(*source); + // @@protoc_insertion_point(generalized_merge_from_cast_success:caffe.DropoutParameter) + UnsafeMergeFrom(*source); } } void DropoutParameter::MergeFrom(const DropoutParameter& from) { - GOOGLE_CHECK_NE(&from, this); +// @@protoc_insertion_point(class_specific_merge_from_start:caffe.DropoutParameter) + if (GOOGLE_PREDICT_TRUE(&from != this)) { + UnsafeMergeFrom(from); + } else { + MergeFromFail(__LINE__); + } +} + +void DropoutParameter::UnsafeMergeFrom(const DropoutParameter& from) { + GOOGLE_DCHECK(&from != this); if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) { if (from.has_dropout_ratio()) { set_dropout_ratio(from.dropout_ratio()); } } - mutable_unknown_fields()->MergeFrom(from.unknown_fields()); + if (from._internal_metadata_.have_unknown_fields()) { + ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata( + from.unknown_fields(), &_internal_metadata_); + } } void DropoutParameter::CopyFrom(const ::google::protobuf::Message& from) { +// @@protoc_insertion_point(generalized_copy_from_start:caffe.DropoutParameter) if (&from == this) return; Clear(); MergeFrom(from); } void DropoutParameter::CopyFrom(const DropoutParameter& from) { +// @@protoc_insertion_point(class_specific_copy_from_start:caffe.DropoutParameter) if (&from == this) return; Clear(); - MergeFrom(from); + UnsafeMergeFrom(from); } bool DropoutParameter::IsInitialized() const { @@ -15689,12 +23906,14 @@ bool DropoutParameter::IsInitialized() const { } void DropoutParameter::Swap(DropoutParameter* other) { - if (other != this) { - std::swap(dropout_ratio_, other->dropout_ratio_); - std::swap(_has_bits_[0], other->_has_bits_[0]); - _unknown_fields_.Swap(&other->_unknown_fields_); - std::swap(_cached_size_, other->_cached_size_); - } + if (other == this) return; + InternalSwap(other); +} +void DropoutParameter::InternalSwap(DropoutParameter* other) { + std::swap(dropout_ratio_, other->dropout_ratio_); + std::swap(_has_bits_[0], other->_has_bits_[0]); + _internal_metadata_.Swap(&other->_internal_metadata_); + std::swap(_cached_size_, other->_cached_size_); } ::google::protobuf::Metadata DropoutParameter::GetMetadata() const { @@ -15705,44 +23924,77 @@ void DropoutParameter::Swap(DropoutParameter* other) { return metadata; } +#if PROTOBUF_INLINE_NOT_IN_HEADERS +// DropoutParameter + +// optional float dropout_ratio = 1 [default = 0.5]; +bool DropoutParameter::has_dropout_ratio() const { + return (_has_bits_[0] & 0x00000001u) != 0; +} +void DropoutParameter::set_has_dropout_ratio() { + _has_bits_[0] |= 0x00000001u; +} +void DropoutParameter::clear_has_dropout_ratio() { + _has_bits_[0] &= ~0x00000001u; +} +void DropoutParameter::clear_dropout_ratio() { + dropout_ratio_ = 0.5f; + clear_has_dropout_ratio(); +} +float DropoutParameter::dropout_ratio() const { + // @@protoc_insertion_point(field_get:caffe.DropoutParameter.dropout_ratio) + return dropout_ratio_; +} +void DropoutParameter::set_dropout_ratio(float value) { + set_has_dropout_ratio(); + dropout_ratio_ = value; + // @@protoc_insertion_point(field_set:caffe.DropoutParameter.dropout_ratio) +} + +inline const DropoutParameter* DropoutParameter::internal_default_instance() { + return &DropoutParameter_default_instance_.get(); +} +#endif // PROTOBUF_INLINE_NOT_IN_HEADERS // =================================================================== -#ifndef _MSC_VER +#if !defined(_MSC_VER) || _MSC_VER >= 1900 const int DummyDataParameter::kDataFillerFieldNumber; const int DummyDataParameter::kShapeFieldNumber; const int DummyDataParameter::kNumFieldNumber; const int DummyDataParameter::kChannelsFieldNumber; const int DummyDataParameter::kHeightFieldNumber; const int DummyDataParameter::kWidthFieldNumber; -#endif // !_MSC_VER +#endif // !defined(_MSC_VER) || _MSC_VER >= 1900 DummyDataParameter::DummyDataParameter() - : ::google::protobuf::Message() { + : ::google::protobuf::Message(), _internal_metadata_(NULL) { + if (this != internal_default_instance()) protobuf_InitDefaults_caffe_2eproto(); SharedCtor(); + // @@protoc_insertion_point(constructor:caffe.DummyDataParameter) } void DummyDataParameter::InitAsDefaultInstance() { } DummyDataParameter::DummyDataParameter(const DummyDataParameter& from) - : ::google::protobuf::Message() { + : ::google::protobuf::Message(), + _internal_metadata_(NULL) { SharedCtor(); - MergeFrom(from); + UnsafeMergeFrom(from); + // @@protoc_insertion_point(copy_constructor:caffe.DummyDataParameter) } void DummyDataParameter::SharedCtor() { _cached_size_ = 0; - ::memset(_has_bits_, 0, sizeof(_has_bits_)); } DummyDataParameter::~DummyDataParameter() { + // @@protoc_insertion_point(destructor:caffe.DummyDataParameter) SharedDtor(); } void DummyDataParameter::SharedDtor() { - if (this != default_instance_) { - } } void DummyDataParameter::SetCachedSize(int size) const { @@ -15756,64 +24008,73 @@ const ::google::protobuf::Descriptor* DummyDataParameter::descriptor() { } const DummyDataParameter& DummyDataParameter::default_instance() { - if (default_instance_ == NULL) protobuf_AddDesc_caffe_2eproto(); - return *default_instance_; + protobuf_InitDefaults_caffe_2eproto(); + return *internal_default_instance(); } -DummyDataParameter* DummyDataParameter::default_instance_ = NULL; +::google::protobuf::internal::ExplicitlyConstructed DummyDataParameter_default_instance_; -DummyDataParameter* DummyDataParameter::New() const { - return new DummyDataParameter; +DummyDataParameter* DummyDataParameter::New(::google::protobuf::Arena* arena) const { + DummyDataParameter* n = new DummyDataParameter; + if (arena != NULL) { + arena->Own(n); + } + return n; } void DummyDataParameter::Clear() { +// @@protoc_insertion_point(message_clear_start:caffe.DummyDataParameter) data_filler_.Clear(); shape_.Clear(); num_.Clear(); channels_.Clear(); height_.Clear(); width_.Clear(); - ::memset(_has_bits_, 0, sizeof(_has_bits_)); - mutable_unknown_fields()->Clear(); + _has_bits_.Clear(); + if (_internal_metadata_.have_unknown_fields()) { + mutable_unknown_fields()->Clear(); + } } bool DummyDataParameter::MergePartialFromCodedStream( ::google::protobuf::io::CodedInputStream* input) { -#define DO_(EXPRESSION) if (!(EXPRESSION)) return false +#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure ::google::protobuf::uint32 tag; - while ((tag = input->ReadTag()) != 0) { + // @@protoc_insertion_point(parse_start:caffe.DummyDataParameter) + for (;;) { + ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127); + tag = p.first; + if (!p.second) goto handle_unusual; switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { // repeated .caffe.FillerParameter data_filler = 1; case 1: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) { - parse_data_filler: - DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual( + if (tag == 10) { + DO_(input->IncrementRecursionDepth()); + parse_loop_data_filler: + DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtualNoRecursionDepth( input, add_data_filler())); } else { - goto handle_uninterpreted; + goto handle_unusual; } - if (input->ExpectTag(10)) goto parse_data_filler; + if (input->ExpectTag(10)) goto parse_loop_data_filler; + input->UnsafeDecrementRecursionDepth(); if (input->ExpectTag(16)) goto parse_num; break; } // repeated uint32 num = 2; case 2: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) { + if (tag == 16) { parse_num: DO_((::google::protobuf::internal::WireFormatLite::ReadRepeatedPrimitive< ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>( 1, 16, input, this->mutable_num()))); - } else if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) - == ::google::protobuf::internal::WireFormatLite:: - WIRETYPE_LENGTH_DELIMITED) { + } else if (tag == 18) { DO_((::google::protobuf::internal::WireFormatLite::ReadPackedPrimitiveNoInline< ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>( input, this->mutable_num()))); } else { - goto handle_uninterpreted; + goto handle_unusual; } if (input->ExpectTag(16)) goto parse_num; if (input->ExpectTag(24)) goto parse_channels; @@ -15822,20 +24083,17 @@ bool DummyDataParameter::MergePartialFromCodedStream( // repeated uint32 channels = 3; case 3: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) { + if (tag == 24) { parse_channels: DO_((::google::protobuf::internal::WireFormatLite::ReadRepeatedPrimitive< ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>( 1, 24, input, this->mutable_channels()))); - } else if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) - == ::google::protobuf::internal::WireFormatLite:: - WIRETYPE_LENGTH_DELIMITED) { + } else if (tag == 26) { DO_((::google::protobuf::internal::WireFormatLite::ReadPackedPrimitiveNoInline< ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>( input, this->mutable_channels()))); } else { - goto handle_uninterpreted; + goto handle_unusual; } if (input->ExpectTag(24)) goto parse_channels; if (input->ExpectTag(32)) goto parse_height; @@ -15844,20 +24102,17 @@ bool DummyDataParameter::MergePartialFromCodedStream( // repeated uint32 height = 4; case 4: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) { + if (tag == 32) { parse_height: DO_((::google::protobuf::internal::WireFormatLite::ReadRepeatedPrimitive< ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>( 1, 32, input, this->mutable_height()))); - } else if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) - == ::google::protobuf::internal::WireFormatLite:: - WIRETYPE_LENGTH_DELIMITED) { + } else if (tag == 34) { DO_((::google::protobuf::internal::WireFormatLite::ReadPackedPrimitiveNoInline< ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>( input, this->mutable_height()))); } else { - goto handle_uninterpreted; + goto handle_unusual; } if (input->ExpectTag(32)) goto parse_height; if (input->ExpectTag(40)) goto parse_width; @@ -15866,20 +24121,17 @@ bool DummyDataParameter::MergePartialFromCodedStream( // repeated uint32 width = 5; case 5: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) { + if (tag == 40) { parse_width: DO_((::google::protobuf::internal::WireFormatLite::ReadRepeatedPrimitive< ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>( 1, 40, input, this->mutable_width()))); - } else if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) - == ::google::protobuf::internal::WireFormatLite:: - WIRETYPE_LENGTH_DELIMITED) { + } else if (tag == 42) { DO_((::google::protobuf::internal::WireFormatLite::ReadPackedPrimitiveNoInline< ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>( input, this->mutable_width()))); } else { - goto handle_uninterpreted; + goto handle_unusual; } if (input->ExpectTag(40)) goto parse_width; if (input->ExpectTag(50)) goto parse_shape; @@ -15888,24 +24140,27 @@ bool DummyDataParameter::MergePartialFromCodedStream( // repeated .caffe.BlobShape shape = 6; case 6: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) { + if (tag == 50) { parse_shape: - DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual( + DO_(input->IncrementRecursionDepth()); + parse_loop_shape: + DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtualNoRecursionDepth( input, add_shape())); } else { - goto handle_uninterpreted; + goto handle_unusual; } - if (input->ExpectTag(50)) goto parse_shape; - if (input->ExpectAtEnd()) return true; + if (input->ExpectTag(50)) goto parse_loop_shape; + input->UnsafeDecrementRecursionDepth(); + if (input->ExpectAtEnd()) goto success; break; } default: { - handle_uninterpreted: - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == + handle_unusual: + if (tag == 0 || + ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) { - return true; + goto success; } DO_(::google::protobuf::internal::WireFormat::SkipField( input, tag, mutable_unknown_fields())); @@ -15913,14 +24168,20 @@ bool DummyDataParameter::MergePartialFromCodedStream( } } } +success: + // @@protoc_insertion_point(parse_success:caffe.DummyDataParameter) return true; +failure: + // @@protoc_insertion_point(parse_failure:caffe.DummyDataParameter) + return false; #undef DO_ } void DummyDataParameter::SerializeWithCachedSizes( ::google::protobuf::io::CodedOutputStream* output) const { + // @@protoc_insertion_point(serialize_start:caffe.DummyDataParameter) // repeated .caffe.FillerParameter data_filler = 1; - for (int i = 0; i < this->data_filler_size(); i++) { + for (unsigned int i = 0, n = this->data_filler_size(); i < n; i++) { ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( 1, this->data_filler(i), output); } @@ -15950,24 +24211,27 @@ void DummyDataParameter::SerializeWithCachedSizes( } // repeated .caffe.BlobShape shape = 6; - for (int i = 0; i < this->shape_size(); i++) { + for (unsigned int i = 0, n = this->shape_size(); i < n; i++) { ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( 6, this->shape(i), output); } - if (!unknown_fields().empty()) { + if (_internal_metadata_.have_unknown_fields()) { ::google::protobuf::internal::WireFormat::SerializeUnknownFields( unknown_fields(), output); } + // @@protoc_insertion_point(serialize_end:caffe.DummyDataParameter) } -::google::protobuf::uint8* DummyDataParameter::SerializeWithCachedSizesToArray( - ::google::protobuf::uint8* target) const { +::google::protobuf::uint8* DummyDataParameter::InternalSerializeWithCachedSizesToArray( + bool deterministic, ::google::protobuf::uint8* target) const { + (void)deterministic; // Unused + // @@protoc_insertion_point(serialize_to_array_start:caffe.DummyDataParameter) // repeated .caffe.FillerParameter data_filler = 1; - for (int i = 0; i < this->data_filler_size(); i++) { + for (unsigned int i = 0, n = this->data_filler_size(); i < n; i++) { target = ::google::protobuf::internal::WireFormatLite:: - WriteMessageNoVirtualToArray( - 1, this->data_filler(i), target); + InternalWriteMessageNoVirtualToArray( + 1, this->data_filler(i), false, target); } // repeated uint32 num = 2; @@ -15995,122 +24259,160 @@ void DummyDataParameter::SerializeWithCachedSizes( } // repeated .caffe.BlobShape shape = 6; - for (int i = 0; i < this->shape_size(); i++) { + for (unsigned int i = 0, n = this->shape_size(); i < n; i++) { target = ::google::protobuf::internal::WireFormatLite:: - WriteMessageNoVirtualToArray( - 6, this->shape(i), target); + InternalWriteMessageNoVirtualToArray( + 6, this->shape(i), false, target); } - if (!unknown_fields().empty()) { + if (_internal_metadata_.have_unknown_fields()) { target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray( unknown_fields(), target); } + // @@protoc_insertion_point(serialize_to_array_end:caffe.DummyDataParameter) return target; } -int DummyDataParameter::ByteSize() const { - int total_size = 0; +size_t DummyDataParameter::ByteSizeLong() const { +// @@protoc_insertion_point(message_byte_size_start:caffe.DummyDataParameter) + size_t total_size = 0; // repeated .caffe.FillerParameter data_filler = 1; - total_size += 1 * this->data_filler_size(); - for (int i = 0; i < this->data_filler_size(); i++) { - total_size += - ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( - this->data_filler(i)); + { + unsigned int count = this->data_filler_size(); + total_size += 1UL * count; + for (unsigned int i = 0; i < count; i++) { + total_size += + ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( + this->data_filler(i)); + } } // repeated .caffe.BlobShape shape = 6; - total_size += 1 * this->shape_size(); - for (int i = 0; i < this->shape_size(); i++) { - total_size += - ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( - this->shape(i)); + { + unsigned int count = this->shape_size(); + total_size += 1UL * count; + for (unsigned int i = 0; i < count; i++) { + total_size += + ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( + this->shape(i)); + } } // repeated uint32 num = 2; { - int data_size = 0; - for (int i = 0; i < this->num_size(); i++) { + size_t data_size = 0; + unsigned int count = this->num_size(); + for (unsigned int i = 0; i < count; i++) { data_size += ::google::protobuf::internal::WireFormatLite:: UInt32Size(this->num(i)); } - total_size += 1 * this->num_size() + data_size; + total_size += 1 * + ::google::protobuf::internal::FromIntSize(this->num_size()); + total_size += data_size; } // repeated uint32 channels = 3; { - int data_size = 0; - for (int i = 0; i < this->channels_size(); i++) { + size_t data_size = 0; + unsigned int count = this->channels_size(); + for (unsigned int i = 0; i < count; i++) { data_size += ::google::protobuf::internal::WireFormatLite:: UInt32Size(this->channels(i)); } - total_size += 1 * this->channels_size() + data_size; + total_size += 1 * + ::google::protobuf::internal::FromIntSize(this->channels_size()); + total_size += data_size; } // repeated uint32 height = 4; { - int data_size = 0; - for (int i = 0; i < this->height_size(); i++) { + size_t data_size = 0; + unsigned int count = this->height_size(); + for (unsigned int i = 0; i < count; i++) { data_size += ::google::protobuf::internal::WireFormatLite:: UInt32Size(this->height(i)); } - total_size += 1 * this->height_size() + data_size; + total_size += 1 * + ::google::protobuf::internal::FromIntSize(this->height_size()); + total_size += data_size; } // repeated uint32 width = 5; { - int data_size = 0; - for (int i = 0; i < this->width_size(); i++) { + size_t data_size = 0; + unsigned int count = this->width_size(); + for (unsigned int i = 0; i < count; i++) { data_size += ::google::protobuf::internal::WireFormatLite:: UInt32Size(this->width(i)); } - total_size += 1 * this->width_size() + data_size; + total_size += 1 * + ::google::protobuf::internal::FromIntSize(this->width_size()); + total_size += data_size; } - if (!unknown_fields().empty()) { + if (_internal_metadata_.have_unknown_fields()) { total_size += ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( unknown_fields()); } + int cached_size = ::google::protobuf::internal::ToCachedSize(total_size); GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); - _cached_size_ = total_size; + _cached_size_ = cached_size; GOOGLE_SAFE_CONCURRENT_WRITES_END(); return total_size; } void DummyDataParameter::MergeFrom(const ::google::protobuf::Message& from) { - GOOGLE_CHECK_NE(&from, this); +// @@protoc_insertion_point(generalized_merge_from_start:caffe.DummyDataParameter) + if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__); const DummyDataParameter* source = - ::google::protobuf::internal::dynamic_cast_if_available( - &from); + ::google::protobuf::internal::DynamicCastToGenerated( + &from); if (source == NULL) { + // @@protoc_insertion_point(generalized_merge_from_cast_fail:caffe.DummyDataParameter) ::google::protobuf::internal::ReflectionOps::Merge(from, this); } else { - MergeFrom(*source); + // @@protoc_insertion_point(generalized_merge_from_cast_success:caffe.DummyDataParameter) + UnsafeMergeFrom(*source); } } void DummyDataParameter::MergeFrom(const DummyDataParameter& from) { - GOOGLE_CHECK_NE(&from, this); +// @@protoc_insertion_point(class_specific_merge_from_start:caffe.DummyDataParameter) + if (GOOGLE_PREDICT_TRUE(&from != this)) { + UnsafeMergeFrom(from); + } else { + MergeFromFail(__LINE__); + } +} + +void DummyDataParameter::UnsafeMergeFrom(const DummyDataParameter& from) { + GOOGLE_DCHECK(&from != this); data_filler_.MergeFrom(from.data_filler_); shape_.MergeFrom(from.shape_); - num_.MergeFrom(from.num_); - channels_.MergeFrom(from.channels_); - height_.MergeFrom(from.height_); - width_.MergeFrom(from.width_); - mutable_unknown_fields()->MergeFrom(from.unknown_fields()); + num_.UnsafeMergeFrom(from.num_); + channels_.UnsafeMergeFrom(from.channels_); + height_.UnsafeMergeFrom(from.height_); + width_.UnsafeMergeFrom(from.width_); + if (from._internal_metadata_.have_unknown_fields()) { + ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata( + from.unknown_fields(), &_internal_metadata_); + } } void DummyDataParameter::CopyFrom(const ::google::protobuf::Message& from) { +// @@protoc_insertion_point(generalized_copy_from_start:caffe.DummyDataParameter) if (&from == this) return; Clear(); MergeFrom(from); } void DummyDataParameter::CopyFrom(const DummyDataParameter& from) { +// @@protoc_insertion_point(class_specific_copy_from_start:caffe.DummyDataParameter) if (&from == this) return; Clear(); - MergeFrom(from); + UnsafeMergeFrom(from); } bool DummyDataParameter::IsInitialized() const { @@ -16119,17 +24421,19 @@ bool DummyDataParameter::IsInitialized() const { } void DummyDataParameter::Swap(DummyDataParameter* other) { - if (other != this) { - data_filler_.Swap(&other->data_filler_); - shape_.Swap(&other->shape_); - num_.Swap(&other->num_); - channels_.Swap(&other->channels_); - height_.Swap(&other->height_); - width_.Swap(&other->width_); - std::swap(_has_bits_[0], other->_has_bits_[0]); - _unknown_fields_.Swap(&other->_unknown_fields_); - std::swap(_cached_size_, other->_cached_size_); - } + if (other == this) return; + InternalSwap(other); +} +void DummyDataParameter::InternalSwap(DummyDataParameter* other) { + data_filler_.UnsafeArenaSwap(&other->data_filler_); + shape_.UnsafeArenaSwap(&other->shape_); + num_.UnsafeArenaSwap(&other->num_); + channels_.UnsafeArenaSwap(&other->channels_); + height_.UnsafeArenaSwap(&other->height_); + width_.UnsafeArenaSwap(&other->width_); + std::swap(_has_bits_[0], other->_has_bits_[0]); + _internal_metadata_.Swap(&other->_internal_metadata_); + std::swap(_cached_size_, other->_cached_size_); } ::google::protobuf::Metadata DummyDataParameter::GetMetadata() const { @@ -16140,6 +24444,193 @@ void DummyDataParameter::Swap(DummyDataParameter* other) { return metadata; } +#if PROTOBUF_INLINE_NOT_IN_HEADERS +// DummyDataParameter + +// repeated .caffe.FillerParameter data_filler = 1; +int DummyDataParameter::data_filler_size() const { + return data_filler_.size(); +} +void DummyDataParameter::clear_data_filler() { + data_filler_.Clear(); +} +const ::caffe::FillerParameter& DummyDataParameter::data_filler(int index) const { + // @@protoc_insertion_point(field_get:caffe.DummyDataParameter.data_filler) + return data_filler_.Get(index); +} +::caffe::FillerParameter* DummyDataParameter::mutable_data_filler(int index) { + // @@protoc_insertion_point(field_mutable:caffe.DummyDataParameter.data_filler) + return data_filler_.Mutable(index); +} +::caffe::FillerParameter* DummyDataParameter::add_data_filler() { + // @@protoc_insertion_point(field_add:caffe.DummyDataParameter.data_filler) + return data_filler_.Add(); +} +::google::protobuf::RepeatedPtrField< ::caffe::FillerParameter >* +DummyDataParameter::mutable_data_filler() { + // @@protoc_insertion_point(field_mutable_list:caffe.DummyDataParameter.data_filler) + return &data_filler_; +} +const ::google::protobuf::RepeatedPtrField< ::caffe::FillerParameter >& +DummyDataParameter::data_filler() const { + // @@protoc_insertion_point(field_list:caffe.DummyDataParameter.data_filler) + return data_filler_; +} + +// repeated .caffe.BlobShape shape = 6; +int DummyDataParameter::shape_size() const { + return shape_.size(); +} +void DummyDataParameter::clear_shape() { + shape_.Clear(); +} +const ::caffe::BlobShape& DummyDataParameter::shape(int index) const { + // @@protoc_insertion_point(field_get:caffe.DummyDataParameter.shape) + return shape_.Get(index); +} +::caffe::BlobShape* DummyDataParameter::mutable_shape(int index) { + // @@protoc_insertion_point(field_mutable:caffe.DummyDataParameter.shape) + return shape_.Mutable(index); +} +::caffe::BlobShape* DummyDataParameter::add_shape() { + // @@protoc_insertion_point(field_add:caffe.DummyDataParameter.shape) + return shape_.Add(); +} +::google::protobuf::RepeatedPtrField< ::caffe::BlobShape >* +DummyDataParameter::mutable_shape() { + // @@protoc_insertion_point(field_mutable_list:caffe.DummyDataParameter.shape) + return &shape_; +} +const ::google::protobuf::RepeatedPtrField< ::caffe::BlobShape >& +DummyDataParameter::shape() const { + // @@protoc_insertion_point(field_list:caffe.DummyDataParameter.shape) + return shape_; +} + +// repeated uint32 num = 2; +int DummyDataParameter::num_size() const { + return num_.size(); +} +void DummyDataParameter::clear_num() { + num_.Clear(); +} +::google::protobuf::uint32 DummyDataParameter::num(int index) const { + // @@protoc_insertion_point(field_get:caffe.DummyDataParameter.num) + return num_.Get(index); +} +void DummyDataParameter::set_num(int index, ::google::protobuf::uint32 value) { + num_.Set(index, value); + // @@protoc_insertion_point(field_set:caffe.DummyDataParameter.num) +} +void DummyDataParameter::add_num(::google::protobuf::uint32 value) { + num_.Add(value); + // @@protoc_insertion_point(field_add:caffe.DummyDataParameter.num) +} +const ::google::protobuf::RepeatedField< ::google::protobuf::uint32 >& +DummyDataParameter::num() const { + // @@protoc_insertion_point(field_list:caffe.DummyDataParameter.num) + return num_; +} +::google::protobuf::RepeatedField< ::google::protobuf::uint32 >* +DummyDataParameter::mutable_num() { + // @@protoc_insertion_point(field_mutable_list:caffe.DummyDataParameter.num) + return &num_; +} + +// repeated uint32 channels = 3; +int DummyDataParameter::channels_size() const { + return channels_.size(); +} +void DummyDataParameter::clear_channels() { + channels_.Clear(); +} +::google::protobuf::uint32 DummyDataParameter::channels(int index) const { + // @@protoc_insertion_point(field_get:caffe.DummyDataParameter.channels) + return channels_.Get(index); +} +void DummyDataParameter::set_channels(int index, ::google::protobuf::uint32 value) { + channels_.Set(index, value); + // @@protoc_insertion_point(field_set:caffe.DummyDataParameter.channels) +} +void DummyDataParameter::add_channels(::google::protobuf::uint32 value) { + channels_.Add(value); + // @@protoc_insertion_point(field_add:caffe.DummyDataParameter.channels) +} +const ::google::protobuf::RepeatedField< ::google::protobuf::uint32 >& +DummyDataParameter::channels() const { + // @@protoc_insertion_point(field_list:caffe.DummyDataParameter.channels) + return channels_; +} +::google::protobuf::RepeatedField< ::google::protobuf::uint32 >* +DummyDataParameter::mutable_channels() { + // @@protoc_insertion_point(field_mutable_list:caffe.DummyDataParameter.channels) + return &channels_; +} + +// repeated uint32 height = 4; +int DummyDataParameter::height_size() const { + return height_.size(); +} +void DummyDataParameter::clear_height() { + height_.Clear(); +} +::google::protobuf::uint32 DummyDataParameter::height(int index) const { + // @@protoc_insertion_point(field_get:caffe.DummyDataParameter.height) + return height_.Get(index); +} +void DummyDataParameter::set_height(int index, ::google::protobuf::uint32 value) { + height_.Set(index, value); + // @@protoc_insertion_point(field_set:caffe.DummyDataParameter.height) +} +void DummyDataParameter::add_height(::google::protobuf::uint32 value) { + height_.Add(value); + // @@protoc_insertion_point(field_add:caffe.DummyDataParameter.height) +} +const ::google::protobuf::RepeatedField< ::google::protobuf::uint32 >& +DummyDataParameter::height() const { + // @@protoc_insertion_point(field_list:caffe.DummyDataParameter.height) + return height_; +} +::google::protobuf::RepeatedField< ::google::protobuf::uint32 >* +DummyDataParameter::mutable_height() { + // @@protoc_insertion_point(field_mutable_list:caffe.DummyDataParameter.height) + return &height_; +} + +// repeated uint32 width = 5; +int DummyDataParameter::width_size() const { + return width_.size(); +} +void DummyDataParameter::clear_width() { + width_.Clear(); +} +::google::protobuf::uint32 DummyDataParameter::width(int index) const { + // @@protoc_insertion_point(field_get:caffe.DummyDataParameter.width) + return width_.Get(index); +} +void DummyDataParameter::set_width(int index, ::google::protobuf::uint32 value) { + width_.Set(index, value); + // @@protoc_insertion_point(field_set:caffe.DummyDataParameter.width) +} +void DummyDataParameter::add_width(::google::protobuf::uint32 value) { + width_.Add(value); + // @@protoc_insertion_point(field_add:caffe.DummyDataParameter.width) +} +const ::google::protobuf::RepeatedField< ::google::protobuf::uint32 >& +DummyDataParameter::width() const { + // @@protoc_insertion_point(field_list:caffe.DummyDataParameter.width) + return width_; +} +::google::protobuf::RepeatedField< ::google::protobuf::uint32 >* +DummyDataParameter::mutable_width() { + // @@protoc_insertion_point(field_mutable_list:caffe.DummyDataParameter.width) + return &width_; +} + +inline const DummyDataParameter* DummyDataParameter::internal_default_instance() { + return &DummyDataParameter_default_instance_.get(); +} +#endif // PROTOBUF_INLINE_NOT_IN_HEADERS // =================================================================== @@ -16148,7 +24639,7 @@ const ::google::protobuf::EnumDescriptor* EltwiseParameter_EltwiseOp_descriptor( return EltwiseParameter_EltwiseOp_descriptor_; } bool EltwiseParameter_EltwiseOp_IsValid(int value) { - switch(value) { + switch (value) { case 0: case 1: case 2: @@ -16158,48 +24649,50 @@ bool EltwiseParameter_EltwiseOp_IsValid(int value) { } } -#ifndef _MSC_VER +#if !defined(_MSC_VER) || _MSC_VER >= 1900 const EltwiseParameter_EltwiseOp EltwiseParameter::PROD; const EltwiseParameter_EltwiseOp EltwiseParameter::SUM; const EltwiseParameter_EltwiseOp EltwiseParameter::MAX; const EltwiseParameter_EltwiseOp EltwiseParameter::EltwiseOp_MIN; const EltwiseParameter_EltwiseOp EltwiseParameter::EltwiseOp_MAX; const int EltwiseParameter::EltwiseOp_ARRAYSIZE; -#endif // _MSC_VER -#ifndef _MSC_VER +#endif // !defined(_MSC_VER) || _MSC_VER >= 1900 +#if !defined(_MSC_VER) || _MSC_VER >= 1900 const int EltwiseParameter::kOperationFieldNumber; const int EltwiseParameter::kCoeffFieldNumber; const int EltwiseParameter::kStableProdGradFieldNumber; -#endif // !_MSC_VER +#endif // !defined(_MSC_VER) || _MSC_VER >= 1900 EltwiseParameter::EltwiseParameter() - : ::google::protobuf::Message() { + : ::google::protobuf::Message(), _internal_metadata_(NULL) { + if (this != internal_default_instance()) protobuf_InitDefaults_caffe_2eproto(); SharedCtor(); + // @@protoc_insertion_point(constructor:caffe.EltwiseParameter) } void EltwiseParameter::InitAsDefaultInstance() { } EltwiseParameter::EltwiseParameter(const EltwiseParameter& from) - : ::google::protobuf::Message() { + : ::google::protobuf::Message(), + _internal_metadata_(NULL) { SharedCtor(); - MergeFrom(from); + UnsafeMergeFrom(from); + // @@protoc_insertion_point(copy_constructor:caffe.EltwiseParameter) } void EltwiseParameter::SharedCtor() { _cached_size_ = 0; operation_ = 1; stable_prod_grad_ = true; - ::memset(_has_bits_, 0, sizeof(_has_bits_)); } EltwiseParameter::~EltwiseParameter() { + // @@protoc_insertion_point(destructor:caffe.EltwiseParameter) SharedDtor(); } void EltwiseParameter::SharedDtor() { - if (this != default_instance_) { - } } void EltwiseParameter::SetCachedSize(int size) const { @@ -16213,36 +24706,46 @@ const ::google::protobuf::Descriptor* EltwiseParameter::descriptor() { } const EltwiseParameter& EltwiseParameter::default_instance() { - if (default_instance_ == NULL) protobuf_AddDesc_caffe_2eproto(); - return *default_instance_; + protobuf_InitDefaults_caffe_2eproto(); + return *internal_default_instance(); } -EltwiseParameter* EltwiseParameter::default_instance_ = NULL; +::google::protobuf::internal::ExplicitlyConstructed EltwiseParameter_default_instance_; -EltwiseParameter* EltwiseParameter::New() const { - return new EltwiseParameter; +EltwiseParameter* EltwiseParameter::New(::google::protobuf::Arena* arena) const { + EltwiseParameter* n = new EltwiseParameter; + if (arena != NULL) { + arena->Own(n); + } + return n; } void EltwiseParameter::Clear() { - if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) { +// @@protoc_insertion_point(message_clear_start:caffe.EltwiseParameter) + if (_has_bits_[0 / 32] & 5u) { operation_ = 1; stable_prod_grad_ = true; } coeff_.Clear(); - ::memset(_has_bits_, 0, sizeof(_has_bits_)); - mutable_unknown_fields()->Clear(); + _has_bits_.Clear(); + if (_internal_metadata_.have_unknown_fields()) { + mutable_unknown_fields()->Clear(); + } } bool EltwiseParameter::MergePartialFromCodedStream( ::google::protobuf::io::CodedInputStream* input) { -#define DO_(EXPRESSION) if (!(EXPRESSION)) return false +#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure ::google::protobuf::uint32 tag; - while ((tag = input->ReadTag()) != 0) { + // @@protoc_insertion_point(parse_start:caffe.EltwiseParameter) + for (;;) { + ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127); + tag = p.first; + if (!p.second) goto handle_unusual; switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { // optional .caffe.EltwiseParameter.EltwiseOp operation = 1 [default = SUM]; case 1: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) { + if (tag == 8) { int value; DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< int, ::google::protobuf::internal::WireFormatLite::TYPE_ENUM>( @@ -16253,7 +24756,7 @@ bool EltwiseParameter::MergePartialFromCodedStream( mutable_unknown_fields()->AddVarint(1, value); } } else { - goto handle_uninterpreted; + goto handle_unusual; } if (input->ExpectTag(21)) goto parse_coeff; break; @@ -16261,20 +24764,17 @@ bool EltwiseParameter::MergePartialFromCodedStream( // repeated float coeff = 2; case 2: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_FIXED32) { + if (tag == 21) { parse_coeff: DO_((::google::protobuf::internal::WireFormatLite::ReadRepeatedPrimitive< float, ::google::protobuf::internal::WireFormatLite::TYPE_FLOAT>( 1, 21, input, this->mutable_coeff()))); - } else if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) - == ::google::protobuf::internal::WireFormatLite:: - WIRETYPE_LENGTH_DELIMITED) { + } else if (tag == 18) { DO_((::google::protobuf::internal::WireFormatLite::ReadPackedPrimitiveNoInline< float, ::google::protobuf::internal::WireFormatLite::TYPE_FLOAT>( input, this->mutable_coeff()))); } else { - goto handle_uninterpreted; + goto handle_unusual; } if (input->ExpectTag(21)) goto parse_coeff; if (input->ExpectTag(24)) goto parse_stable_prod_grad; @@ -16283,25 +24783,25 @@ bool EltwiseParameter::MergePartialFromCodedStream( // optional bool stable_prod_grad = 3 [default = true]; case 3: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) { + if (tag == 24) { parse_stable_prod_grad: + set_has_stable_prod_grad(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>( input, &stable_prod_grad_))); - set_has_stable_prod_grad(); } else { - goto handle_uninterpreted; + goto handle_unusual; } - if (input->ExpectAtEnd()) return true; + if (input->ExpectAtEnd()) goto success; break; } default: { - handle_uninterpreted: - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == + handle_unusual: + if (tag == 0 || + ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) { - return true; + goto success; } DO_(::google::protobuf::internal::WireFormat::SkipField( input, tag, mutable_unknown_fields())); @@ -16309,12 +24809,18 @@ bool EltwiseParameter::MergePartialFromCodedStream( } } } +success: + // @@protoc_insertion_point(parse_success:caffe.EltwiseParameter) return true; +failure: + // @@protoc_insertion_point(parse_failure:caffe.EltwiseParameter) + return false; #undef DO_ } void EltwiseParameter::SerializeWithCachedSizes( ::google::protobuf::io::CodedOutputStream* output) const { + // @@protoc_insertion_point(serialize_start:caffe.EltwiseParameter) // optional .caffe.EltwiseParameter.EltwiseOp operation = 1 [default = SUM]; if (has_operation()) { ::google::protobuf::internal::WireFormatLite::WriteEnum( @@ -16332,14 +24838,17 @@ void EltwiseParameter::SerializeWithCachedSizes( ::google::protobuf::internal::WireFormatLite::WriteBool(3, this->stable_prod_grad(), output); } - if (!unknown_fields().empty()) { + if (_internal_metadata_.have_unknown_fields()) { ::google::protobuf::internal::WireFormat::SerializeUnknownFields( unknown_fields(), output); } + // @@protoc_insertion_point(serialize_end:caffe.EltwiseParameter) } -::google::protobuf::uint8* EltwiseParameter::SerializeWithCachedSizesToArray( - ::google::protobuf::uint8* target) const { +::google::protobuf::uint8* EltwiseParameter::InternalSerializeWithCachedSizesToArray( + bool deterministic, ::google::protobuf::uint8* target) const { + (void)deterministic; // Unused + // @@protoc_insertion_point(serialize_to_array_start:caffe.EltwiseParameter) // optional .caffe.EltwiseParameter.EltwiseOp operation = 1 [default = SUM]; if (has_operation()) { target = ::google::protobuf::internal::WireFormatLite::WriteEnumToArray( @@ -16357,17 +24866,19 @@ void EltwiseParameter::SerializeWithCachedSizes( target = ::google::protobuf::internal::WireFormatLite::WriteBoolToArray(3, this->stable_prod_grad(), target); } - if (!unknown_fields().empty()) { + if (_internal_metadata_.have_unknown_fields()) { target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray( unknown_fields(), target); } + // @@protoc_insertion_point(serialize_to_array_end:caffe.EltwiseParameter) return target; } -int EltwiseParameter::ByteSize() const { - int total_size = 0; +size_t EltwiseParameter::ByteSizeLong() const { +// @@protoc_insertion_point(message_byte_size_start:caffe.EltwiseParameter) + size_t total_size = 0; - if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) { + if (_has_bits_[0 / 32] & 5u) { // optional .caffe.EltwiseParameter.EltwiseOp operation = 1 [default = SUM]; if (has_operation()) { total_size += 1 + @@ -16382,37 +24893,53 @@ int EltwiseParameter::ByteSize() const { } // repeated float coeff = 2; { - int data_size = 0; - data_size = 4 * this->coeff_size(); - total_size += 1 * this->coeff_size() + data_size; + size_t data_size = 0; + unsigned int count = this->coeff_size(); + data_size = 4UL * count; + total_size += 1 * + ::google::protobuf::internal::FromIntSize(this->coeff_size()); + total_size += data_size; } - if (!unknown_fields().empty()) { + if (_internal_metadata_.have_unknown_fields()) { total_size += ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( unknown_fields()); } + int cached_size = ::google::protobuf::internal::ToCachedSize(total_size); GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); - _cached_size_ = total_size; + _cached_size_ = cached_size; GOOGLE_SAFE_CONCURRENT_WRITES_END(); return total_size; } void EltwiseParameter::MergeFrom(const ::google::protobuf::Message& from) { - GOOGLE_CHECK_NE(&from, this); +// @@protoc_insertion_point(generalized_merge_from_start:caffe.EltwiseParameter) + if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__); const EltwiseParameter* source = - ::google::protobuf::internal::dynamic_cast_if_available( - &from); + ::google::protobuf::internal::DynamicCastToGenerated( + &from); if (source == NULL) { + // @@protoc_insertion_point(generalized_merge_from_cast_fail:caffe.EltwiseParameter) ::google::protobuf::internal::ReflectionOps::Merge(from, this); } else { - MergeFrom(*source); + // @@protoc_insertion_point(generalized_merge_from_cast_success:caffe.EltwiseParameter) + UnsafeMergeFrom(*source); } } void EltwiseParameter::MergeFrom(const EltwiseParameter& from) { - GOOGLE_CHECK_NE(&from, this); - coeff_.MergeFrom(from.coeff_); +// @@protoc_insertion_point(class_specific_merge_from_start:caffe.EltwiseParameter) + if (GOOGLE_PREDICT_TRUE(&from != this)) { + UnsafeMergeFrom(from); + } else { + MergeFromFail(__LINE__); + } +} + +void EltwiseParameter::UnsafeMergeFrom(const EltwiseParameter& from) { + GOOGLE_DCHECK(&from != this); + coeff_.UnsafeMergeFrom(from.coeff_); if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) { if (from.has_operation()) { set_operation(from.operation()); @@ -16421,19 +24948,24 @@ void EltwiseParameter::MergeFrom(const EltwiseParameter& from) { set_stable_prod_grad(from.stable_prod_grad()); } } - mutable_unknown_fields()->MergeFrom(from.unknown_fields()); + if (from._internal_metadata_.have_unknown_fields()) { + ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata( + from.unknown_fields(), &_internal_metadata_); + } } void EltwiseParameter::CopyFrom(const ::google::protobuf::Message& from) { +// @@protoc_insertion_point(generalized_copy_from_start:caffe.EltwiseParameter) if (&from == this) return; Clear(); MergeFrom(from); } void EltwiseParameter::CopyFrom(const EltwiseParameter& from) { +// @@protoc_insertion_point(class_specific_copy_from_start:caffe.EltwiseParameter) if (&from == this) return; Clear(); - MergeFrom(from); + UnsafeMergeFrom(from); } bool EltwiseParameter::IsInitialized() const { @@ -16442,14 +24974,16 @@ bool EltwiseParameter::IsInitialized() const { } void EltwiseParameter::Swap(EltwiseParameter* other) { - if (other != this) { - std::swap(operation_, other->operation_); - coeff_.Swap(&other->coeff_); - std::swap(stable_prod_grad_, other->stable_prod_grad_); - std::swap(_has_bits_[0], other->_has_bits_[0]); - _unknown_fields_.Swap(&other->_unknown_fields_); - std::swap(_cached_size_, other->_cached_size_); - } + if (other == this) return; + InternalSwap(other); +} +void EltwiseParameter::InternalSwap(EltwiseParameter* other) { + std::swap(operation_, other->operation_); + coeff_.UnsafeArenaSwap(&other->coeff_); + std::swap(stable_prod_grad_, other->stable_prod_grad_); + std::swap(_has_bits_[0], other->_has_bits_[0]); + _internal_metadata_.Swap(&other->_internal_metadata_); + std::swap(_cached_size_, other->_cached_size_); } ::google::protobuf::Metadata EltwiseParameter::GetMetadata() const { @@ -16460,44 +24994,132 @@ void EltwiseParameter::Swap(EltwiseParameter* other) { return metadata; } +#if PROTOBUF_INLINE_NOT_IN_HEADERS +// EltwiseParameter + +// optional .caffe.EltwiseParameter.EltwiseOp operation = 1 [default = SUM]; +bool EltwiseParameter::has_operation() const { + return (_has_bits_[0] & 0x00000001u) != 0; +} +void EltwiseParameter::set_has_operation() { + _has_bits_[0] |= 0x00000001u; +} +void EltwiseParameter::clear_has_operation() { + _has_bits_[0] &= ~0x00000001u; +} +void EltwiseParameter::clear_operation() { + operation_ = 1; + clear_has_operation(); +} +::caffe::EltwiseParameter_EltwiseOp EltwiseParameter::operation() const { + // @@protoc_insertion_point(field_get:caffe.EltwiseParameter.operation) + return static_cast< ::caffe::EltwiseParameter_EltwiseOp >(operation_); +} +void EltwiseParameter::set_operation(::caffe::EltwiseParameter_EltwiseOp value) { + assert(::caffe::EltwiseParameter_EltwiseOp_IsValid(value)); + set_has_operation(); + operation_ = value; + // @@protoc_insertion_point(field_set:caffe.EltwiseParameter.operation) +} + +// repeated float coeff = 2; +int EltwiseParameter::coeff_size() const { + return coeff_.size(); +} +void EltwiseParameter::clear_coeff() { + coeff_.Clear(); +} +float EltwiseParameter::coeff(int index) const { + // @@protoc_insertion_point(field_get:caffe.EltwiseParameter.coeff) + return coeff_.Get(index); +} +void EltwiseParameter::set_coeff(int index, float value) { + coeff_.Set(index, value); + // @@protoc_insertion_point(field_set:caffe.EltwiseParameter.coeff) +} +void EltwiseParameter::add_coeff(float value) { + coeff_.Add(value); + // @@protoc_insertion_point(field_add:caffe.EltwiseParameter.coeff) +} +const ::google::protobuf::RepeatedField< float >& +EltwiseParameter::coeff() const { + // @@protoc_insertion_point(field_list:caffe.EltwiseParameter.coeff) + return coeff_; +} +::google::protobuf::RepeatedField< float >* +EltwiseParameter::mutable_coeff() { + // @@protoc_insertion_point(field_mutable_list:caffe.EltwiseParameter.coeff) + return &coeff_; +} + +// optional bool stable_prod_grad = 3 [default = true]; +bool EltwiseParameter::has_stable_prod_grad() const { + return (_has_bits_[0] & 0x00000004u) != 0; +} +void EltwiseParameter::set_has_stable_prod_grad() { + _has_bits_[0] |= 0x00000004u; +} +void EltwiseParameter::clear_has_stable_prod_grad() { + _has_bits_[0] &= ~0x00000004u; +} +void EltwiseParameter::clear_stable_prod_grad() { + stable_prod_grad_ = true; + clear_has_stable_prod_grad(); +} +bool EltwiseParameter::stable_prod_grad() const { + // @@protoc_insertion_point(field_get:caffe.EltwiseParameter.stable_prod_grad) + return stable_prod_grad_; +} +void EltwiseParameter::set_stable_prod_grad(bool value) { + set_has_stable_prod_grad(); + stable_prod_grad_ = value; + // @@protoc_insertion_point(field_set:caffe.EltwiseParameter.stable_prod_grad) +} + +inline const EltwiseParameter* EltwiseParameter::internal_default_instance() { + return &EltwiseParameter_default_instance_.get(); +} +#endif // PROTOBUF_INLINE_NOT_IN_HEADERS // =================================================================== -#ifndef _MSC_VER +#if !defined(_MSC_VER) || _MSC_VER >= 1900 const int ExpParameter::kBaseFieldNumber; const int ExpParameter::kScaleFieldNumber; const int ExpParameter::kShiftFieldNumber; -#endif // !_MSC_VER +#endif // !defined(_MSC_VER) || _MSC_VER >= 1900 ExpParameter::ExpParameter() - : ::google::protobuf::Message() { + : ::google::protobuf::Message(), _internal_metadata_(NULL) { + if (this != internal_default_instance()) protobuf_InitDefaults_caffe_2eproto(); SharedCtor(); + // @@protoc_insertion_point(constructor:caffe.ExpParameter) } void ExpParameter::InitAsDefaultInstance() { } ExpParameter::ExpParameter(const ExpParameter& from) - : ::google::protobuf::Message() { + : ::google::protobuf::Message(), + _internal_metadata_(NULL) { SharedCtor(); - MergeFrom(from); + UnsafeMergeFrom(from); + // @@protoc_insertion_point(copy_constructor:caffe.ExpParameter) } void ExpParameter::SharedCtor() { _cached_size_ = 0; + shift_ = 0; base_ = -1; scale_ = 1; - shift_ = 0; - ::memset(_has_bits_, 0, sizeof(_has_bits_)); } ExpParameter::~ExpParameter() { + // @@protoc_insertion_point(destructor:caffe.ExpParameter) SharedDtor(); } void ExpParameter::SharedDtor() { - if (this != default_instance_) { - } } void ExpParameter::SetCachedSize(int size) const { @@ -16511,42 +25133,52 @@ const ::google::protobuf::Descriptor* ExpParameter::descriptor() { } const ExpParameter& ExpParameter::default_instance() { - if (default_instance_ == NULL) protobuf_AddDesc_caffe_2eproto(); - return *default_instance_; + protobuf_InitDefaults_caffe_2eproto(); + return *internal_default_instance(); } -ExpParameter* ExpParameter::default_instance_ = NULL; +::google::protobuf::internal::ExplicitlyConstructed ExpParameter_default_instance_; -ExpParameter* ExpParameter::New() const { - return new ExpParameter; +ExpParameter* ExpParameter::New(::google::protobuf::Arena* arena) const { + ExpParameter* n = new ExpParameter; + if (arena != NULL) { + arena->Own(n); + } + return n; } void ExpParameter::Clear() { - if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) { +// @@protoc_insertion_point(message_clear_start:caffe.ExpParameter) + if (_has_bits_[0 / 32] & 7u) { base_ = -1; scale_ = 1; shift_ = 0; } - ::memset(_has_bits_, 0, sizeof(_has_bits_)); - mutable_unknown_fields()->Clear(); + _has_bits_.Clear(); + if (_internal_metadata_.have_unknown_fields()) { + mutable_unknown_fields()->Clear(); + } } bool ExpParameter::MergePartialFromCodedStream( ::google::protobuf::io::CodedInputStream* input) { -#define DO_(EXPRESSION) if (!(EXPRESSION)) return false +#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure ::google::protobuf::uint32 tag; - while ((tag = input->ReadTag()) != 0) { + // @@protoc_insertion_point(parse_start:caffe.ExpParameter) + for (;;) { + ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127); + tag = p.first; + if (!p.second) goto handle_unusual; switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { // optional float base = 1 [default = -1]; case 1: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_FIXED32) { + if (tag == 13) { + set_has_base(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< float, ::google::protobuf::internal::WireFormatLite::TYPE_FLOAT>( input, &base_))); - set_has_base(); } else { - goto handle_uninterpreted; + goto handle_unusual; } if (input->ExpectTag(21)) goto parse_scale; break; @@ -16554,15 +25186,14 @@ bool ExpParameter::MergePartialFromCodedStream( // optional float scale = 2 [default = 1]; case 2: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_FIXED32) { + if (tag == 21) { parse_scale: + set_has_scale(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< float, ::google::protobuf::internal::WireFormatLite::TYPE_FLOAT>( input, &scale_))); - set_has_scale(); } else { - goto handle_uninterpreted; + goto handle_unusual; } if (input->ExpectTag(29)) goto parse_shift; break; @@ -16570,25 +25201,25 @@ bool ExpParameter::MergePartialFromCodedStream( // optional float shift = 3 [default = 0]; case 3: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_FIXED32) { + if (tag == 29) { parse_shift: + set_has_shift(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< float, ::google::protobuf::internal::WireFormatLite::TYPE_FLOAT>( input, &shift_))); - set_has_shift(); } else { - goto handle_uninterpreted; + goto handle_unusual; } - if (input->ExpectAtEnd()) return true; + if (input->ExpectAtEnd()) goto success; break; } default: { - handle_uninterpreted: - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == + handle_unusual: + if (tag == 0 || + ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) { - return true; + goto success; } DO_(::google::protobuf::internal::WireFormat::SkipField( input, tag, mutable_unknown_fields())); @@ -16596,12 +25227,18 @@ bool ExpParameter::MergePartialFromCodedStream( } } } +success: + // @@protoc_insertion_point(parse_success:caffe.ExpParameter) return true; +failure: + // @@protoc_insertion_point(parse_failure:caffe.ExpParameter) + return false; #undef DO_ } void ExpParameter::SerializeWithCachedSizes( ::google::protobuf::io::CodedOutputStream* output) const { + // @@protoc_insertion_point(serialize_start:caffe.ExpParameter) // optional float base = 1 [default = -1]; if (has_base()) { ::google::protobuf::internal::WireFormatLite::WriteFloat(1, this->base(), output); @@ -16617,14 +25254,17 @@ void ExpParameter::SerializeWithCachedSizes( ::google::protobuf::internal::WireFormatLite::WriteFloat(3, this->shift(), output); } - if (!unknown_fields().empty()) { + if (_internal_metadata_.have_unknown_fields()) { ::google::protobuf::internal::WireFormat::SerializeUnknownFields( unknown_fields(), output); } + // @@protoc_insertion_point(serialize_end:caffe.ExpParameter) } -::google::protobuf::uint8* ExpParameter::SerializeWithCachedSizesToArray( - ::google::protobuf::uint8* target) const { +::google::protobuf::uint8* ExpParameter::InternalSerializeWithCachedSizesToArray( + bool deterministic, ::google::protobuf::uint8* target) const { + (void)deterministic; // Unused + // @@protoc_insertion_point(serialize_to_array_start:caffe.ExpParameter) // optional float base = 1 [default = -1]; if (has_base()) { target = ::google::protobuf::internal::WireFormatLite::WriteFloatToArray(1, this->base(), target); @@ -16640,17 +25280,19 @@ void ExpParameter::SerializeWithCachedSizes( target = ::google::protobuf::internal::WireFormatLite::WriteFloatToArray(3, this->shift(), target); } - if (!unknown_fields().empty()) { + if (_internal_metadata_.have_unknown_fields()) { target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray( unknown_fields(), target); } + // @@protoc_insertion_point(serialize_to_array_end:caffe.ExpParameter) return target; } -int ExpParameter::ByteSize() const { - int total_size = 0; +size_t ExpParameter::ByteSizeLong() const { +// @@protoc_insertion_point(message_byte_size_start:caffe.ExpParameter) + size_t total_size = 0; - if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) { + if (_has_bits_[0 / 32] & 7u) { // optional float base = 1 [default = -1]; if (has_base()) { total_size += 1 + 4; @@ -16667,31 +25309,44 @@ int ExpParameter::ByteSize() const { } } - if (!unknown_fields().empty()) { + if (_internal_metadata_.have_unknown_fields()) { total_size += ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( unknown_fields()); } + int cached_size = ::google::protobuf::internal::ToCachedSize(total_size); GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); - _cached_size_ = total_size; + _cached_size_ = cached_size; GOOGLE_SAFE_CONCURRENT_WRITES_END(); return total_size; } void ExpParameter::MergeFrom(const ::google::protobuf::Message& from) { - GOOGLE_CHECK_NE(&from, this); +// @@protoc_insertion_point(generalized_merge_from_start:caffe.ExpParameter) + if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__); const ExpParameter* source = - ::google::protobuf::internal::dynamic_cast_if_available( - &from); + ::google::protobuf::internal::DynamicCastToGenerated( + &from); if (source == NULL) { + // @@protoc_insertion_point(generalized_merge_from_cast_fail:caffe.ExpParameter) ::google::protobuf::internal::ReflectionOps::Merge(from, this); } else { - MergeFrom(*source); + // @@protoc_insertion_point(generalized_merge_from_cast_success:caffe.ExpParameter) + UnsafeMergeFrom(*source); } } void ExpParameter::MergeFrom(const ExpParameter& from) { - GOOGLE_CHECK_NE(&from, this); +// @@protoc_insertion_point(class_specific_merge_from_start:caffe.ExpParameter) + if (GOOGLE_PREDICT_TRUE(&from != this)) { + UnsafeMergeFrom(from); + } else { + MergeFromFail(__LINE__); + } +} + +void ExpParameter::UnsafeMergeFrom(const ExpParameter& from) { + GOOGLE_DCHECK(&from != this); if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) { if (from.has_base()) { set_base(from.base()); @@ -16703,19 +25358,24 @@ void ExpParameter::MergeFrom(const ExpParameter& from) { set_shift(from.shift()); } } - mutable_unknown_fields()->MergeFrom(from.unknown_fields()); + if (from._internal_metadata_.have_unknown_fields()) { + ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata( + from.unknown_fields(), &_internal_metadata_); + } } void ExpParameter::CopyFrom(const ::google::protobuf::Message& from) { +// @@protoc_insertion_point(generalized_copy_from_start:caffe.ExpParameter) if (&from == this) return; Clear(); MergeFrom(from); } void ExpParameter::CopyFrom(const ExpParameter& from) { +// @@protoc_insertion_point(class_specific_copy_from_start:caffe.ExpParameter) if (&from == this) return; Clear(); - MergeFrom(from); + UnsafeMergeFrom(from); } bool ExpParameter::IsInitialized() const { @@ -16724,14 +25384,16 @@ bool ExpParameter::IsInitialized() const { } void ExpParameter::Swap(ExpParameter* other) { - if (other != this) { - std::swap(base_, other->base_); - std::swap(scale_, other->scale_); - std::swap(shift_, other->shift_); - std::swap(_has_bits_[0], other->_has_bits_[0]); - _unknown_fields_.Swap(&other->_unknown_fields_); - std::swap(_cached_size_, other->_cached_size_); - } + if (other == this) return; + InternalSwap(other); +} +void ExpParameter::InternalSwap(ExpParameter* other) { + std::swap(base_, other->base_); + std::swap(scale_, other->scale_); + std::swap(shift_, other->shift_); + std::swap(_has_bits_[0], other->_has_bits_[0]); + _internal_metadata_.Swap(&other->_internal_metadata_); + std::swap(_cached_size_, other->_cached_size_); } ::google::protobuf::Metadata ExpParameter::GetMetadata() const { @@ -16742,42 +25404,123 @@ void ExpParameter::Swap(ExpParameter* other) { return metadata; } +#if PROTOBUF_INLINE_NOT_IN_HEADERS +// ExpParameter + +// optional float base = 1 [default = -1]; +bool ExpParameter::has_base() const { + return (_has_bits_[0] & 0x00000001u) != 0; +} +void ExpParameter::set_has_base() { + _has_bits_[0] |= 0x00000001u; +} +void ExpParameter::clear_has_base() { + _has_bits_[0] &= ~0x00000001u; +} +void ExpParameter::clear_base() { + base_ = -1; + clear_has_base(); +} +float ExpParameter::base() const { + // @@protoc_insertion_point(field_get:caffe.ExpParameter.base) + return base_; +} +void ExpParameter::set_base(float value) { + set_has_base(); + base_ = value; + // @@protoc_insertion_point(field_set:caffe.ExpParameter.base) +} + +// optional float scale = 2 [default = 1]; +bool ExpParameter::has_scale() const { + return (_has_bits_[0] & 0x00000002u) != 0; +} +void ExpParameter::set_has_scale() { + _has_bits_[0] |= 0x00000002u; +} +void ExpParameter::clear_has_scale() { + _has_bits_[0] &= ~0x00000002u; +} +void ExpParameter::clear_scale() { + scale_ = 1; + clear_has_scale(); +} +float ExpParameter::scale() const { + // @@protoc_insertion_point(field_get:caffe.ExpParameter.scale) + return scale_; +} +void ExpParameter::set_scale(float value) { + set_has_scale(); + scale_ = value; + // @@protoc_insertion_point(field_set:caffe.ExpParameter.scale) +} + +// optional float shift = 3 [default = 0]; +bool ExpParameter::has_shift() const { + return (_has_bits_[0] & 0x00000004u) != 0; +} +void ExpParameter::set_has_shift() { + _has_bits_[0] |= 0x00000004u; +} +void ExpParameter::clear_has_shift() { + _has_bits_[0] &= ~0x00000004u; +} +void ExpParameter::clear_shift() { + shift_ = 0; + clear_has_shift(); +} +float ExpParameter::shift() const { + // @@protoc_insertion_point(field_get:caffe.ExpParameter.shift) + return shift_; +} +void ExpParameter::set_shift(float value) { + set_has_shift(); + shift_ = value; + // @@protoc_insertion_point(field_set:caffe.ExpParameter.shift) +} + +inline const ExpParameter* ExpParameter::internal_default_instance() { + return &ExpParameter_default_instance_.get(); +} +#endif // PROTOBUF_INLINE_NOT_IN_HEADERS // =================================================================== -#ifndef _MSC_VER +#if !defined(_MSC_VER) || _MSC_VER >= 1900 const int FlattenParameter::kAxisFieldNumber; const int FlattenParameter::kEndAxisFieldNumber; -#endif // !_MSC_VER +#endif // !defined(_MSC_VER) || _MSC_VER >= 1900 FlattenParameter::FlattenParameter() - : ::google::protobuf::Message() { + : ::google::protobuf::Message(), _internal_metadata_(NULL) { + if (this != internal_default_instance()) protobuf_InitDefaults_caffe_2eproto(); SharedCtor(); + // @@protoc_insertion_point(constructor:caffe.FlattenParameter) } void FlattenParameter::InitAsDefaultInstance() { } FlattenParameter::FlattenParameter(const FlattenParameter& from) - : ::google::protobuf::Message() { + : ::google::protobuf::Message(), + _internal_metadata_(NULL) { SharedCtor(); - MergeFrom(from); + UnsafeMergeFrom(from); + // @@protoc_insertion_point(copy_constructor:caffe.FlattenParameter) } void FlattenParameter::SharedCtor() { _cached_size_ = 0; axis_ = 1; end_axis_ = -1; - ::memset(_has_bits_, 0, sizeof(_has_bits_)); } FlattenParameter::~FlattenParameter() { + // @@protoc_insertion_point(destructor:caffe.FlattenParameter) SharedDtor(); } void FlattenParameter::SharedDtor() { - if (this != default_instance_) { - } } void FlattenParameter::SetCachedSize(int size) const { @@ -16791,41 +25534,51 @@ const ::google::protobuf::Descriptor* FlattenParameter::descriptor() { } const FlattenParameter& FlattenParameter::default_instance() { - if (default_instance_ == NULL) protobuf_AddDesc_caffe_2eproto(); - return *default_instance_; + protobuf_InitDefaults_caffe_2eproto(); + return *internal_default_instance(); } -FlattenParameter* FlattenParameter::default_instance_ = NULL; +::google::protobuf::internal::ExplicitlyConstructed FlattenParameter_default_instance_; -FlattenParameter* FlattenParameter::New() const { - return new FlattenParameter; +FlattenParameter* FlattenParameter::New(::google::protobuf::Arena* arena) const { + FlattenParameter* n = new FlattenParameter; + if (arena != NULL) { + arena->Own(n); + } + return n; } void FlattenParameter::Clear() { - if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) { +// @@protoc_insertion_point(message_clear_start:caffe.FlattenParameter) + if (_has_bits_[0 / 32] & 3u) { axis_ = 1; end_axis_ = -1; } - ::memset(_has_bits_, 0, sizeof(_has_bits_)); - mutable_unknown_fields()->Clear(); + _has_bits_.Clear(); + if (_internal_metadata_.have_unknown_fields()) { + mutable_unknown_fields()->Clear(); + } } bool FlattenParameter::MergePartialFromCodedStream( ::google::protobuf::io::CodedInputStream* input) { -#define DO_(EXPRESSION) if (!(EXPRESSION)) return false +#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure ::google::protobuf::uint32 tag; - while ((tag = input->ReadTag()) != 0) { + // @@protoc_insertion_point(parse_start:caffe.FlattenParameter) + for (;;) { + ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127); + tag = p.first; + if (!p.second) goto handle_unusual; switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { // optional int32 axis = 1 [default = 1]; case 1: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) { + if (tag == 8) { + set_has_axis(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>( input, &axis_))); - set_has_axis(); } else { - goto handle_uninterpreted; + goto handle_unusual; } if (input->ExpectTag(16)) goto parse_end_axis; break; @@ -16833,25 +25586,25 @@ bool FlattenParameter::MergePartialFromCodedStream( // optional int32 end_axis = 2 [default = -1]; case 2: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) { + if (tag == 16) { parse_end_axis: + set_has_end_axis(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>( input, &end_axis_))); - set_has_end_axis(); } else { - goto handle_uninterpreted; + goto handle_unusual; } - if (input->ExpectAtEnd()) return true; + if (input->ExpectAtEnd()) goto success; break; } default: { - handle_uninterpreted: - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == + handle_unusual: + if (tag == 0 || + ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) { - return true; + goto success; } DO_(::google::protobuf::internal::WireFormat::SkipField( input, tag, mutable_unknown_fields())); @@ -16859,12 +25612,18 @@ bool FlattenParameter::MergePartialFromCodedStream( } } } +success: + // @@protoc_insertion_point(parse_success:caffe.FlattenParameter) return true; +failure: + // @@protoc_insertion_point(parse_failure:caffe.FlattenParameter) + return false; #undef DO_ } void FlattenParameter::SerializeWithCachedSizes( ::google::protobuf::io::CodedOutputStream* output) const { + // @@protoc_insertion_point(serialize_start:caffe.FlattenParameter) // optional int32 axis = 1 [default = 1]; if (has_axis()) { ::google::protobuf::internal::WireFormatLite::WriteInt32(1, this->axis(), output); @@ -16875,14 +25634,17 @@ void FlattenParameter::SerializeWithCachedSizes( ::google::protobuf::internal::WireFormatLite::WriteInt32(2, this->end_axis(), output); } - if (!unknown_fields().empty()) { + if (_internal_metadata_.have_unknown_fields()) { ::google::protobuf::internal::WireFormat::SerializeUnknownFields( unknown_fields(), output); } + // @@protoc_insertion_point(serialize_end:caffe.FlattenParameter) } -::google::protobuf::uint8* FlattenParameter::SerializeWithCachedSizesToArray( - ::google::protobuf::uint8* target) const { +::google::protobuf::uint8* FlattenParameter::InternalSerializeWithCachedSizesToArray( + bool deterministic, ::google::protobuf::uint8* target) const { + (void)deterministic; // Unused + // @@protoc_insertion_point(serialize_to_array_start:caffe.FlattenParameter) // optional int32 axis = 1 [default = 1]; if (has_axis()) { target = ::google::protobuf::internal::WireFormatLite::WriteInt32ToArray(1, this->axis(), target); @@ -16893,17 +25655,19 @@ void FlattenParameter::SerializeWithCachedSizes( target = ::google::protobuf::internal::WireFormatLite::WriteInt32ToArray(2, this->end_axis(), target); } - if (!unknown_fields().empty()) { + if (_internal_metadata_.have_unknown_fields()) { target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray( unknown_fields(), target); } + // @@protoc_insertion_point(serialize_to_array_end:caffe.FlattenParameter) return target; } -int FlattenParameter::ByteSize() const { - int total_size = 0; +size_t FlattenParameter::ByteSizeLong() const { +// @@protoc_insertion_point(message_byte_size_start:caffe.FlattenParameter) + size_t total_size = 0; - if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) { + if (_has_bits_[0 / 32] & 3u) { // optional int32 axis = 1 [default = 1]; if (has_axis()) { total_size += 1 + @@ -16919,31 +25683,44 @@ int FlattenParameter::ByteSize() const { } } - if (!unknown_fields().empty()) { + if (_internal_metadata_.have_unknown_fields()) { total_size += ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( unknown_fields()); } + int cached_size = ::google::protobuf::internal::ToCachedSize(total_size); GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); - _cached_size_ = total_size; + _cached_size_ = cached_size; GOOGLE_SAFE_CONCURRENT_WRITES_END(); return total_size; } void FlattenParameter::MergeFrom(const ::google::protobuf::Message& from) { - GOOGLE_CHECK_NE(&from, this); +// @@protoc_insertion_point(generalized_merge_from_start:caffe.FlattenParameter) + if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__); const FlattenParameter* source = - ::google::protobuf::internal::dynamic_cast_if_available( - &from); + ::google::protobuf::internal::DynamicCastToGenerated( + &from); if (source == NULL) { + // @@protoc_insertion_point(generalized_merge_from_cast_fail:caffe.FlattenParameter) ::google::protobuf::internal::ReflectionOps::Merge(from, this); } else { - MergeFrom(*source); + // @@protoc_insertion_point(generalized_merge_from_cast_success:caffe.FlattenParameter) + UnsafeMergeFrom(*source); } } void FlattenParameter::MergeFrom(const FlattenParameter& from) { - GOOGLE_CHECK_NE(&from, this); +// @@protoc_insertion_point(class_specific_merge_from_start:caffe.FlattenParameter) + if (GOOGLE_PREDICT_TRUE(&from != this)) { + UnsafeMergeFrom(from); + } else { + MergeFromFail(__LINE__); + } +} + +void FlattenParameter::UnsafeMergeFrom(const FlattenParameter& from) { + GOOGLE_DCHECK(&from != this); if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) { if (from.has_axis()) { set_axis(from.axis()); @@ -16952,85 +25729,147 @@ void FlattenParameter::MergeFrom(const FlattenParameter& from) { set_end_axis(from.end_axis()); } } - mutable_unknown_fields()->MergeFrom(from.unknown_fields()); + if (from._internal_metadata_.have_unknown_fields()) { + ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata( + from.unknown_fields(), &_internal_metadata_); + } } void FlattenParameter::CopyFrom(const ::google::protobuf::Message& from) { +// @@protoc_insertion_point(generalized_copy_from_start:caffe.FlattenParameter) if (&from == this) return; Clear(); MergeFrom(from); } void FlattenParameter::CopyFrom(const FlattenParameter& from) { +// @@protoc_insertion_point(class_specific_copy_from_start:caffe.FlattenParameter) if (&from == this) return; Clear(); - MergeFrom(from); + UnsafeMergeFrom(from); } bool FlattenParameter::IsInitialized() const { return true; } - -void FlattenParameter::Swap(FlattenParameter* other) { - if (other != this) { - std::swap(axis_, other->axis_); - std::swap(end_axis_, other->end_axis_); - std::swap(_has_bits_[0], other->_has_bits_[0]); - _unknown_fields_.Swap(&other->_unknown_fields_); - std::swap(_cached_size_, other->_cached_size_); - } + +void FlattenParameter::Swap(FlattenParameter* other) { + if (other == this) return; + InternalSwap(other); +} +void FlattenParameter::InternalSwap(FlattenParameter* other) { + std::swap(axis_, other->axis_); + std::swap(end_axis_, other->end_axis_); + std::swap(_has_bits_[0], other->_has_bits_[0]); + _internal_metadata_.Swap(&other->_internal_metadata_); + std::swap(_cached_size_, other->_cached_size_); +} + +::google::protobuf::Metadata FlattenParameter::GetMetadata() const { + protobuf_AssignDescriptorsOnce(); + ::google::protobuf::Metadata metadata; + metadata.descriptor = FlattenParameter_descriptor_; + metadata.reflection = FlattenParameter_reflection_; + return metadata; +} + +#if PROTOBUF_INLINE_NOT_IN_HEADERS +// FlattenParameter + +// optional int32 axis = 1 [default = 1]; +bool FlattenParameter::has_axis() const { + return (_has_bits_[0] & 0x00000001u) != 0; +} +void FlattenParameter::set_has_axis() { + _has_bits_[0] |= 0x00000001u; +} +void FlattenParameter::clear_has_axis() { + _has_bits_[0] &= ~0x00000001u; +} +void FlattenParameter::clear_axis() { + axis_ = 1; + clear_has_axis(); +} +::google::protobuf::int32 FlattenParameter::axis() const { + // @@protoc_insertion_point(field_get:caffe.FlattenParameter.axis) + return axis_; +} +void FlattenParameter::set_axis(::google::protobuf::int32 value) { + set_has_axis(); + axis_ = value; + // @@protoc_insertion_point(field_set:caffe.FlattenParameter.axis) +} + +// optional int32 end_axis = 2 [default = -1]; +bool FlattenParameter::has_end_axis() const { + return (_has_bits_[0] & 0x00000002u) != 0; +} +void FlattenParameter::set_has_end_axis() { + _has_bits_[0] |= 0x00000002u; +} +void FlattenParameter::clear_has_end_axis() { + _has_bits_[0] &= ~0x00000002u; +} +void FlattenParameter::clear_end_axis() { + end_axis_ = -1; + clear_has_end_axis(); +} +::google::protobuf::int32 FlattenParameter::end_axis() const { + // @@protoc_insertion_point(field_get:caffe.FlattenParameter.end_axis) + return end_axis_; } - -::google::protobuf::Metadata FlattenParameter::GetMetadata() const { - protobuf_AssignDescriptorsOnce(); - ::google::protobuf::Metadata metadata; - metadata.descriptor = FlattenParameter_descriptor_; - metadata.reflection = FlattenParameter_reflection_; - return metadata; +void FlattenParameter::set_end_axis(::google::protobuf::int32 value) { + set_has_end_axis(); + end_axis_ = value; + // @@protoc_insertion_point(field_set:caffe.FlattenParameter.end_axis) } +inline const FlattenParameter* FlattenParameter::internal_default_instance() { + return &FlattenParameter_default_instance_.get(); +} +#endif // PROTOBUF_INLINE_NOT_IN_HEADERS // =================================================================== -#ifndef _MSC_VER +#if !defined(_MSC_VER) || _MSC_VER >= 1900 const int HDF5DataParameter::kSourceFieldNumber; const int HDF5DataParameter::kBatchSizeFieldNumber; const int HDF5DataParameter::kShuffleFieldNumber; -#endif // !_MSC_VER +#endif // !defined(_MSC_VER) || _MSC_VER >= 1900 HDF5DataParameter::HDF5DataParameter() - : ::google::protobuf::Message() { + : ::google::protobuf::Message(), _internal_metadata_(NULL) { + if (this != internal_default_instance()) protobuf_InitDefaults_caffe_2eproto(); SharedCtor(); + // @@protoc_insertion_point(constructor:caffe.HDF5DataParameter) } void HDF5DataParameter::InitAsDefaultInstance() { } HDF5DataParameter::HDF5DataParameter(const HDF5DataParameter& from) - : ::google::protobuf::Message() { + : ::google::protobuf::Message(), + _internal_metadata_(NULL) { SharedCtor(); - MergeFrom(from); + UnsafeMergeFrom(from); + // @@protoc_insertion_point(copy_constructor:caffe.HDF5DataParameter) } void HDF5DataParameter::SharedCtor() { _cached_size_ = 0; - source_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); - batch_size_ = 0u; - shuffle_ = false; - ::memset(_has_bits_, 0, sizeof(_has_bits_)); + source_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + ::memset(&batch_size_, 0, reinterpret_cast(&shuffle_) - + reinterpret_cast(&batch_size_) + sizeof(shuffle_)); } HDF5DataParameter::~HDF5DataParameter() { + // @@protoc_insertion_point(destructor:caffe.HDF5DataParameter) SharedDtor(); } void HDF5DataParameter::SharedDtor() { - if (source_ != &::google::protobuf::internal::kEmptyString) { - delete source_; - } - if (this != default_instance_) { - } + source_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } void HDF5DataParameter::SetCachedSize(int size) const { @@ -17044,47 +25883,75 @@ const ::google::protobuf::Descriptor* HDF5DataParameter::descriptor() { } const HDF5DataParameter& HDF5DataParameter::default_instance() { - if (default_instance_ == NULL) protobuf_AddDesc_caffe_2eproto(); - return *default_instance_; + protobuf_InitDefaults_caffe_2eproto(); + return *internal_default_instance(); } -HDF5DataParameter* HDF5DataParameter::default_instance_ = NULL; +::google::protobuf::internal::ExplicitlyConstructed HDF5DataParameter_default_instance_; -HDF5DataParameter* HDF5DataParameter::New() const { - return new HDF5DataParameter; +HDF5DataParameter* HDF5DataParameter::New(::google::protobuf::Arena* arena) const { + HDF5DataParameter* n = new HDF5DataParameter; + if (arena != NULL) { + arena->Own(n); + } + return n; } void HDF5DataParameter::Clear() { - if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) { +// @@protoc_insertion_point(message_clear_start:caffe.HDF5DataParameter) +#if defined(__clang__) +#define ZR_HELPER_(f) \ + _Pragma("clang diagnostic push") \ + _Pragma("clang diagnostic ignored \"-Winvalid-offsetof\"") \ + __builtin_offsetof(HDF5DataParameter, f) \ + _Pragma("clang diagnostic pop") +#else +#define ZR_HELPER_(f) reinterpret_cast(\ + &reinterpret_cast(16)->f) +#endif + +#define ZR_(first, last) do {\ + ::memset(&(first), 0,\ + ZR_HELPER_(last) - ZR_HELPER_(first) + sizeof(last));\ +} while (0) + + if (_has_bits_[0 / 32] & 7u) { + ZR_(batch_size_, shuffle_); if (has_source()) { - if (source_ != &::google::protobuf::internal::kEmptyString) { - source_->clear(); - } + source_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - batch_size_ = 0u; - shuffle_ = false; } - ::memset(_has_bits_, 0, sizeof(_has_bits_)); - mutable_unknown_fields()->Clear(); + +#undef ZR_HELPER_ +#undef ZR_ + + _has_bits_.Clear(); + if (_internal_metadata_.have_unknown_fields()) { + mutable_unknown_fields()->Clear(); + } } bool HDF5DataParameter::MergePartialFromCodedStream( ::google::protobuf::io::CodedInputStream* input) { -#define DO_(EXPRESSION) if (!(EXPRESSION)) return false +#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure ::google::protobuf::uint32 tag; - while ((tag = input->ReadTag()) != 0) { + // @@protoc_insertion_point(parse_start:caffe.HDF5DataParameter) + for (;;) { + ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127); + tag = p.first; + if (!p.second) goto handle_unusual; switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { // optional string source = 1; case 1: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) { + if (tag == 10) { DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->mutable_source())); - ::google::protobuf::internal::WireFormat::VerifyUTF8String( + ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( this->source().data(), this->source().length(), - ::google::protobuf::internal::WireFormat::PARSE); + ::google::protobuf::internal::WireFormat::PARSE, + "caffe.HDF5DataParameter.source"); } else { - goto handle_uninterpreted; + goto handle_unusual; } if (input->ExpectTag(16)) goto parse_batch_size; break; @@ -17092,15 +25959,14 @@ bool HDF5DataParameter::MergePartialFromCodedStream( // optional uint32 batch_size = 2; case 2: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) { + if (tag == 16) { parse_batch_size: + set_has_batch_size(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>( input, &batch_size_))); - set_has_batch_size(); } else { - goto handle_uninterpreted; + goto handle_unusual; } if (input->ExpectTag(24)) goto parse_shuffle; break; @@ -17108,25 +25974,25 @@ bool HDF5DataParameter::MergePartialFromCodedStream( // optional bool shuffle = 3 [default = false]; case 3: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) { + if (tag == 24) { parse_shuffle: + set_has_shuffle(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>( input, &shuffle_))); - set_has_shuffle(); } else { - goto handle_uninterpreted; + goto handle_unusual; } - if (input->ExpectAtEnd()) return true; + if (input->ExpectAtEnd()) goto success; break; } default: { - handle_uninterpreted: - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == + handle_unusual: + if (tag == 0 || + ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) { - return true; + goto success; } DO_(::google::protobuf::internal::WireFormat::SkipField( input, tag, mutable_unknown_fields())); @@ -17134,18 +26000,25 @@ bool HDF5DataParameter::MergePartialFromCodedStream( } } } +success: + // @@protoc_insertion_point(parse_success:caffe.HDF5DataParameter) return true; +failure: + // @@protoc_insertion_point(parse_failure:caffe.HDF5DataParameter) + return false; #undef DO_ } void HDF5DataParameter::SerializeWithCachedSizes( ::google::protobuf::io::CodedOutputStream* output) const { + // @@protoc_insertion_point(serialize_start:caffe.HDF5DataParameter) // optional string source = 1; if (has_source()) { - ::google::protobuf::internal::WireFormat::VerifyUTF8String( + ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( this->source().data(), this->source().length(), - ::google::protobuf::internal::WireFormat::SERIALIZE); - ::google::protobuf::internal::WireFormatLite::WriteString( + ::google::protobuf::internal::WireFormat::SERIALIZE, + "caffe.HDF5DataParameter.source"); + ::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased( 1, this->source(), output); } @@ -17159,19 +26032,23 @@ void HDF5DataParameter::SerializeWithCachedSizes( ::google::protobuf::internal::WireFormatLite::WriteBool(3, this->shuffle(), output); } - if (!unknown_fields().empty()) { + if (_internal_metadata_.have_unknown_fields()) { ::google::protobuf::internal::WireFormat::SerializeUnknownFields( unknown_fields(), output); } + // @@protoc_insertion_point(serialize_end:caffe.HDF5DataParameter) } -::google::protobuf::uint8* HDF5DataParameter::SerializeWithCachedSizesToArray( - ::google::protobuf::uint8* target) const { +::google::protobuf::uint8* HDF5DataParameter::InternalSerializeWithCachedSizesToArray( + bool deterministic, ::google::protobuf::uint8* target) const { + (void)deterministic; // Unused + // @@protoc_insertion_point(serialize_to_array_start:caffe.HDF5DataParameter) // optional string source = 1; if (has_source()) { - ::google::protobuf::internal::WireFormat::VerifyUTF8String( + ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( this->source().data(), this->source().length(), - ::google::protobuf::internal::WireFormat::SERIALIZE); + ::google::protobuf::internal::WireFormat::SERIALIZE, + "caffe.HDF5DataParameter.source"); target = ::google::protobuf::internal::WireFormatLite::WriteStringToArray( 1, this->source(), target); @@ -17187,17 +26064,19 @@ void HDF5DataParameter::SerializeWithCachedSizes( target = ::google::protobuf::internal::WireFormatLite::WriteBoolToArray(3, this->shuffle(), target); } - if (!unknown_fields().empty()) { + if (_internal_metadata_.have_unknown_fields()) { target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray( unknown_fields(), target); } + // @@protoc_insertion_point(serialize_to_array_end:caffe.HDF5DataParameter) return target; } -int HDF5DataParameter::ByteSize() const { - int total_size = 0; +size_t HDF5DataParameter::ByteSizeLong() const { +// @@protoc_insertion_point(message_byte_size_start:caffe.HDF5DataParameter) + size_t total_size = 0; - if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) { + if (_has_bits_[0 / 32] & 7u) { // optional string source = 1; if (has_source()) { total_size += 1 + @@ -17218,34 +26097,48 @@ int HDF5DataParameter::ByteSize() const { } } - if (!unknown_fields().empty()) { + if (_internal_metadata_.have_unknown_fields()) { total_size += ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( unknown_fields()); } + int cached_size = ::google::protobuf::internal::ToCachedSize(total_size); GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); - _cached_size_ = total_size; + _cached_size_ = cached_size; GOOGLE_SAFE_CONCURRENT_WRITES_END(); return total_size; } void HDF5DataParameter::MergeFrom(const ::google::protobuf::Message& from) { - GOOGLE_CHECK_NE(&from, this); +// @@protoc_insertion_point(generalized_merge_from_start:caffe.HDF5DataParameter) + if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__); const HDF5DataParameter* source = - ::google::protobuf::internal::dynamic_cast_if_available( - &from); + ::google::protobuf::internal::DynamicCastToGenerated( + &from); if (source == NULL) { + // @@protoc_insertion_point(generalized_merge_from_cast_fail:caffe.HDF5DataParameter) ::google::protobuf::internal::ReflectionOps::Merge(from, this); } else { - MergeFrom(*source); + // @@protoc_insertion_point(generalized_merge_from_cast_success:caffe.HDF5DataParameter) + UnsafeMergeFrom(*source); } } void HDF5DataParameter::MergeFrom(const HDF5DataParameter& from) { - GOOGLE_CHECK_NE(&from, this); +// @@protoc_insertion_point(class_specific_merge_from_start:caffe.HDF5DataParameter) + if (GOOGLE_PREDICT_TRUE(&from != this)) { + UnsafeMergeFrom(from); + } else { + MergeFromFail(__LINE__); + } +} + +void HDF5DataParameter::UnsafeMergeFrom(const HDF5DataParameter& from) { + GOOGLE_DCHECK(&from != this); if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) { if (from.has_source()) { - set_source(from.source()); + set_has_source(); + source_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.source_); } if (from.has_batch_size()) { set_batch_size(from.batch_size()); @@ -17254,19 +26147,24 @@ void HDF5DataParameter::MergeFrom(const HDF5DataParameter& from) { set_shuffle(from.shuffle()); } } - mutable_unknown_fields()->MergeFrom(from.unknown_fields()); + if (from._internal_metadata_.have_unknown_fields()) { + ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata( + from.unknown_fields(), &_internal_metadata_); + } } void HDF5DataParameter::CopyFrom(const ::google::protobuf::Message& from) { +// @@protoc_insertion_point(generalized_copy_from_start:caffe.HDF5DataParameter) if (&from == this) return; Clear(); MergeFrom(from); } void HDF5DataParameter::CopyFrom(const HDF5DataParameter& from) { +// @@protoc_insertion_point(class_specific_copy_from_start:caffe.HDF5DataParameter) if (&from == this) return; Clear(); - MergeFrom(from); + UnsafeMergeFrom(from); } bool HDF5DataParameter::IsInitialized() const { @@ -17275,14 +26173,16 @@ bool HDF5DataParameter::IsInitialized() const { } void HDF5DataParameter::Swap(HDF5DataParameter* other) { - if (other != this) { - std::swap(source_, other->source_); - std::swap(batch_size_, other->batch_size_); - std::swap(shuffle_, other->shuffle_); - std::swap(_has_bits_[0], other->_has_bits_[0]); - _unknown_fields_.Swap(&other->_unknown_fields_); - std::swap(_cached_size_, other->_cached_size_); - } + if (other == this) return; + InternalSwap(other); +} +void HDF5DataParameter::InternalSwap(HDF5DataParameter* other) { + source_.Swap(&other->source_); + std::swap(batch_size_, other->batch_size_); + std::swap(shuffle_, other->shuffle_); + std::swap(_has_bits_[0], other->_has_bits_[0]); + _internal_metadata_.Swap(&other->_internal_metadata_); + std::swap(_cached_size_, other->_cached_size_); } ::google::protobuf::Metadata HDF5DataParameter::GetMetadata() const { @@ -17293,43 +26193,152 @@ void HDF5DataParameter::Swap(HDF5DataParameter* other) { return metadata; } +#if PROTOBUF_INLINE_NOT_IN_HEADERS +// HDF5DataParameter + +// optional string source = 1; +bool HDF5DataParameter::has_source() const { + return (_has_bits_[0] & 0x00000001u) != 0; +} +void HDF5DataParameter::set_has_source() { + _has_bits_[0] |= 0x00000001u; +} +void HDF5DataParameter::clear_has_source() { + _has_bits_[0] &= ~0x00000001u; +} +void HDF5DataParameter::clear_source() { + source_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + clear_has_source(); +} +const ::std::string& HDF5DataParameter::source() const { + // @@protoc_insertion_point(field_get:caffe.HDF5DataParameter.source) + return source_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); +} +void HDF5DataParameter::set_source(const ::std::string& value) { + set_has_source(); + source_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); + // @@protoc_insertion_point(field_set:caffe.HDF5DataParameter.source) +} +void HDF5DataParameter::set_source(const char* value) { + set_has_source(); + source_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); + // @@protoc_insertion_point(field_set_char:caffe.HDF5DataParameter.source) +} +void HDF5DataParameter::set_source(const char* value, size_t size) { + set_has_source(); + source_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), + ::std::string(reinterpret_cast(value), size)); + // @@protoc_insertion_point(field_set_pointer:caffe.HDF5DataParameter.source) +} +::std::string* HDF5DataParameter::mutable_source() { + set_has_source(); + // @@protoc_insertion_point(field_mutable:caffe.HDF5DataParameter.source) + return source_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); +} +::std::string* HDF5DataParameter::release_source() { + // @@protoc_insertion_point(field_release:caffe.HDF5DataParameter.source) + clear_has_source(); + return source_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); +} +void HDF5DataParameter::set_allocated_source(::std::string* source) { + if (source != NULL) { + set_has_source(); + } else { + clear_has_source(); + } + source_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), source); + // @@protoc_insertion_point(field_set_allocated:caffe.HDF5DataParameter.source) +} + +// optional uint32 batch_size = 2; +bool HDF5DataParameter::has_batch_size() const { + return (_has_bits_[0] & 0x00000002u) != 0; +} +void HDF5DataParameter::set_has_batch_size() { + _has_bits_[0] |= 0x00000002u; +} +void HDF5DataParameter::clear_has_batch_size() { + _has_bits_[0] &= ~0x00000002u; +} +void HDF5DataParameter::clear_batch_size() { + batch_size_ = 0u; + clear_has_batch_size(); +} +::google::protobuf::uint32 HDF5DataParameter::batch_size() const { + // @@protoc_insertion_point(field_get:caffe.HDF5DataParameter.batch_size) + return batch_size_; +} +void HDF5DataParameter::set_batch_size(::google::protobuf::uint32 value) { + set_has_batch_size(); + batch_size_ = value; + // @@protoc_insertion_point(field_set:caffe.HDF5DataParameter.batch_size) +} + +// optional bool shuffle = 3 [default = false]; +bool HDF5DataParameter::has_shuffle() const { + return (_has_bits_[0] & 0x00000004u) != 0; +} +void HDF5DataParameter::set_has_shuffle() { + _has_bits_[0] |= 0x00000004u; +} +void HDF5DataParameter::clear_has_shuffle() { + _has_bits_[0] &= ~0x00000004u; +} +void HDF5DataParameter::clear_shuffle() { + shuffle_ = false; + clear_has_shuffle(); +} +bool HDF5DataParameter::shuffle() const { + // @@protoc_insertion_point(field_get:caffe.HDF5DataParameter.shuffle) + return shuffle_; +} +void HDF5DataParameter::set_shuffle(bool value) { + set_has_shuffle(); + shuffle_ = value; + // @@protoc_insertion_point(field_set:caffe.HDF5DataParameter.shuffle) +} + +inline const HDF5DataParameter* HDF5DataParameter::internal_default_instance() { + return &HDF5DataParameter_default_instance_.get(); +} +#endif // PROTOBUF_INLINE_NOT_IN_HEADERS // =================================================================== -#ifndef _MSC_VER +#if !defined(_MSC_VER) || _MSC_VER >= 1900 const int HDF5OutputParameter::kFileNameFieldNumber; -#endif // !_MSC_VER +#endif // !defined(_MSC_VER) || _MSC_VER >= 1900 HDF5OutputParameter::HDF5OutputParameter() - : ::google::protobuf::Message() { + : ::google::protobuf::Message(), _internal_metadata_(NULL) { + if (this != internal_default_instance()) protobuf_InitDefaults_caffe_2eproto(); SharedCtor(); + // @@protoc_insertion_point(constructor:caffe.HDF5OutputParameter) } void HDF5OutputParameter::InitAsDefaultInstance() { } HDF5OutputParameter::HDF5OutputParameter(const HDF5OutputParameter& from) - : ::google::protobuf::Message() { + : ::google::protobuf::Message(), + _internal_metadata_(NULL) { SharedCtor(); - MergeFrom(from); + UnsafeMergeFrom(from); + // @@protoc_insertion_point(copy_constructor:caffe.HDF5OutputParameter) } void HDF5OutputParameter::SharedCtor() { _cached_size_ = 0; - file_name_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); - ::memset(_has_bits_, 0, sizeof(_has_bits_)); + file_name_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } HDF5OutputParameter::~HDF5OutputParameter() { + // @@protoc_insertion_point(destructor:caffe.HDF5OutputParameter) SharedDtor(); } void HDF5OutputParameter::SharedDtor() { - if (file_name_ != &::google::protobuf::internal::kEmptyString) { - delete file_name_; - } - if (this != default_instance_) { - } + file_name_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } void HDF5OutputParameter::SetCachedSize(int size) const { @@ -17343,55 +26352,63 @@ const ::google::protobuf::Descriptor* HDF5OutputParameter::descriptor() { } const HDF5OutputParameter& HDF5OutputParameter::default_instance() { - if (default_instance_ == NULL) protobuf_AddDesc_caffe_2eproto(); - return *default_instance_; + protobuf_InitDefaults_caffe_2eproto(); + return *internal_default_instance(); } -HDF5OutputParameter* HDF5OutputParameter::default_instance_ = NULL; +::google::protobuf::internal::ExplicitlyConstructed HDF5OutputParameter_default_instance_; -HDF5OutputParameter* HDF5OutputParameter::New() const { - return new HDF5OutputParameter; +HDF5OutputParameter* HDF5OutputParameter::New(::google::protobuf::Arena* arena) const { + HDF5OutputParameter* n = new HDF5OutputParameter; + if (arena != NULL) { + arena->Own(n); + } + return n; } void HDF5OutputParameter::Clear() { - if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) { - if (has_file_name()) { - if (file_name_ != &::google::protobuf::internal::kEmptyString) { - file_name_->clear(); - } - } +// @@protoc_insertion_point(message_clear_start:caffe.HDF5OutputParameter) + if (has_file_name()) { + file_name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + } + _has_bits_.Clear(); + if (_internal_metadata_.have_unknown_fields()) { + mutable_unknown_fields()->Clear(); } - ::memset(_has_bits_, 0, sizeof(_has_bits_)); - mutable_unknown_fields()->Clear(); } bool HDF5OutputParameter::MergePartialFromCodedStream( ::google::protobuf::io::CodedInputStream* input) { -#define DO_(EXPRESSION) if (!(EXPRESSION)) return false +#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure ::google::protobuf::uint32 tag; - while ((tag = input->ReadTag()) != 0) { + // @@protoc_insertion_point(parse_start:caffe.HDF5OutputParameter) + for (;;) { + ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127); + tag = p.first; + if (!p.second) goto handle_unusual; switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { // optional string file_name = 1; case 1: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) { + if (tag == 10) { DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->mutable_file_name())); - ::google::protobuf::internal::WireFormat::VerifyUTF8String( + ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( this->file_name().data(), this->file_name().length(), - ::google::protobuf::internal::WireFormat::PARSE); + ::google::protobuf::internal::WireFormat::PARSE, + "caffe.HDF5OutputParameter.file_name"); } else { - goto handle_uninterpreted; + goto handle_unusual; } - if (input->ExpectAtEnd()) return true; + if (input->ExpectAtEnd()) goto success; break; } default: { - handle_uninterpreted: - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == + handle_unusual: + if (tag == 0 || + ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) { - return true; + goto success; } DO_(::google::protobuf::internal::WireFormat::SkipField( input, tag, mutable_unknown_fields())); @@ -17399,101 +26416,131 @@ bool HDF5OutputParameter::MergePartialFromCodedStream( } } } +success: + // @@protoc_insertion_point(parse_success:caffe.HDF5OutputParameter) return true; +failure: + // @@protoc_insertion_point(parse_failure:caffe.HDF5OutputParameter) + return false; #undef DO_ } void HDF5OutputParameter::SerializeWithCachedSizes( ::google::protobuf::io::CodedOutputStream* output) const { + // @@protoc_insertion_point(serialize_start:caffe.HDF5OutputParameter) // optional string file_name = 1; if (has_file_name()) { - ::google::protobuf::internal::WireFormat::VerifyUTF8String( + ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( this->file_name().data(), this->file_name().length(), - ::google::protobuf::internal::WireFormat::SERIALIZE); - ::google::protobuf::internal::WireFormatLite::WriteString( + ::google::protobuf::internal::WireFormat::SERIALIZE, + "caffe.HDF5OutputParameter.file_name"); + ::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased( 1, this->file_name(), output); } - if (!unknown_fields().empty()) { + if (_internal_metadata_.have_unknown_fields()) { ::google::protobuf::internal::WireFormat::SerializeUnknownFields( unknown_fields(), output); } + // @@protoc_insertion_point(serialize_end:caffe.HDF5OutputParameter) } -::google::protobuf::uint8* HDF5OutputParameter::SerializeWithCachedSizesToArray( - ::google::protobuf::uint8* target) const { +::google::protobuf::uint8* HDF5OutputParameter::InternalSerializeWithCachedSizesToArray( + bool deterministic, ::google::protobuf::uint8* target) const { + (void)deterministic; // Unused + // @@protoc_insertion_point(serialize_to_array_start:caffe.HDF5OutputParameter) // optional string file_name = 1; if (has_file_name()) { - ::google::protobuf::internal::WireFormat::VerifyUTF8String( + ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( this->file_name().data(), this->file_name().length(), - ::google::protobuf::internal::WireFormat::SERIALIZE); + ::google::protobuf::internal::WireFormat::SERIALIZE, + "caffe.HDF5OutputParameter.file_name"); target = ::google::protobuf::internal::WireFormatLite::WriteStringToArray( 1, this->file_name(), target); } - if (!unknown_fields().empty()) { + if (_internal_metadata_.have_unknown_fields()) { target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray( unknown_fields(), target); } + // @@protoc_insertion_point(serialize_to_array_end:caffe.HDF5OutputParameter) return target; } -int HDF5OutputParameter::ByteSize() const { - int total_size = 0; - - if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) { - // optional string file_name = 1; - if (has_file_name()) { - total_size += 1 + - ::google::protobuf::internal::WireFormatLite::StringSize( - this->file_name()); - } +size_t HDF5OutputParameter::ByteSizeLong() const { +// @@protoc_insertion_point(message_byte_size_start:caffe.HDF5OutputParameter) + size_t total_size = 0; + // optional string file_name = 1; + if (has_file_name()) { + total_size += 1 + + ::google::protobuf::internal::WireFormatLite::StringSize( + this->file_name()); } - if (!unknown_fields().empty()) { + + if (_internal_metadata_.have_unknown_fields()) { total_size += ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( unknown_fields()); } + int cached_size = ::google::protobuf::internal::ToCachedSize(total_size); GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); - _cached_size_ = total_size; + _cached_size_ = cached_size; GOOGLE_SAFE_CONCURRENT_WRITES_END(); return total_size; } void HDF5OutputParameter::MergeFrom(const ::google::protobuf::Message& from) { - GOOGLE_CHECK_NE(&from, this); +// @@protoc_insertion_point(generalized_merge_from_start:caffe.HDF5OutputParameter) + if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__); const HDF5OutputParameter* source = - ::google::protobuf::internal::dynamic_cast_if_available( - &from); + ::google::protobuf::internal::DynamicCastToGenerated( + &from); if (source == NULL) { + // @@protoc_insertion_point(generalized_merge_from_cast_fail:caffe.HDF5OutputParameter) ::google::protobuf::internal::ReflectionOps::Merge(from, this); } else { - MergeFrom(*source); + // @@protoc_insertion_point(generalized_merge_from_cast_success:caffe.HDF5OutputParameter) + UnsafeMergeFrom(*source); } } void HDF5OutputParameter::MergeFrom(const HDF5OutputParameter& from) { - GOOGLE_CHECK_NE(&from, this); +// @@protoc_insertion_point(class_specific_merge_from_start:caffe.HDF5OutputParameter) + if (GOOGLE_PREDICT_TRUE(&from != this)) { + UnsafeMergeFrom(from); + } else { + MergeFromFail(__LINE__); + } +} + +void HDF5OutputParameter::UnsafeMergeFrom(const HDF5OutputParameter& from) { + GOOGLE_DCHECK(&from != this); if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) { if (from.has_file_name()) { - set_file_name(from.file_name()); + set_has_file_name(); + file_name_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.file_name_); } } - mutable_unknown_fields()->MergeFrom(from.unknown_fields()); + if (from._internal_metadata_.have_unknown_fields()) { + ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata( + from.unknown_fields(), &_internal_metadata_); + } } void HDF5OutputParameter::CopyFrom(const ::google::protobuf::Message& from) { +// @@protoc_insertion_point(generalized_copy_from_start:caffe.HDF5OutputParameter) if (&from == this) return; Clear(); MergeFrom(from); } void HDF5OutputParameter::CopyFrom(const HDF5OutputParameter& from) { +// @@protoc_insertion_point(class_specific_copy_from_start:caffe.HDF5OutputParameter) if (&from == this) return; Clear(); - MergeFrom(from); + UnsafeMergeFrom(from); } bool HDF5OutputParameter::IsInitialized() const { @@ -17502,12 +26549,14 @@ bool HDF5OutputParameter::IsInitialized() const { } void HDF5OutputParameter::Swap(HDF5OutputParameter* other) { - if (other != this) { - std::swap(file_name_, other->file_name_); - std::swap(_has_bits_[0], other->_has_bits_[0]); - _unknown_fields_.Swap(&other->_unknown_fields_); - std::swap(_cached_size_, other->_cached_size_); - } + if (other == this) return; + InternalSwap(other); +} +void HDF5OutputParameter::InternalSwap(HDF5OutputParameter* other) { + file_name_.Swap(&other->file_name_); + std::swap(_has_bits_[0], other->_has_bits_[0]); + _internal_metadata_.Swap(&other->_internal_metadata_); + std::swap(_cached_size_, other->_cached_size_); } ::google::protobuf::Metadata HDF5OutputParameter::GetMetadata() const { @@ -17518,6 +26567,67 @@ void HDF5OutputParameter::Swap(HDF5OutputParameter* other) { return metadata; } +#if PROTOBUF_INLINE_NOT_IN_HEADERS +// HDF5OutputParameter + +// optional string file_name = 1; +bool HDF5OutputParameter::has_file_name() const { + return (_has_bits_[0] & 0x00000001u) != 0; +} +void HDF5OutputParameter::set_has_file_name() { + _has_bits_[0] |= 0x00000001u; +} +void HDF5OutputParameter::clear_has_file_name() { + _has_bits_[0] &= ~0x00000001u; +} +void HDF5OutputParameter::clear_file_name() { + file_name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + clear_has_file_name(); +} +const ::std::string& HDF5OutputParameter::file_name() const { + // @@protoc_insertion_point(field_get:caffe.HDF5OutputParameter.file_name) + return file_name_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); +} +void HDF5OutputParameter::set_file_name(const ::std::string& value) { + set_has_file_name(); + file_name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); + // @@protoc_insertion_point(field_set:caffe.HDF5OutputParameter.file_name) +} +void HDF5OutputParameter::set_file_name(const char* value) { + set_has_file_name(); + file_name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); + // @@protoc_insertion_point(field_set_char:caffe.HDF5OutputParameter.file_name) +} +void HDF5OutputParameter::set_file_name(const char* value, size_t size) { + set_has_file_name(); + file_name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), + ::std::string(reinterpret_cast(value), size)); + // @@protoc_insertion_point(field_set_pointer:caffe.HDF5OutputParameter.file_name) +} +::std::string* HDF5OutputParameter::mutable_file_name() { + set_has_file_name(); + // @@protoc_insertion_point(field_mutable:caffe.HDF5OutputParameter.file_name) + return file_name_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); +} +::std::string* HDF5OutputParameter::release_file_name() { + // @@protoc_insertion_point(field_release:caffe.HDF5OutputParameter.file_name) + clear_has_file_name(); + return file_name_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); +} +void HDF5OutputParameter::set_allocated_file_name(::std::string* file_name) { + if (file_name != NULL) { + set_has_file_name(); + } else { + clear_has_file_name(); + } + file_name_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), file_name); + // @@protoc_insertion_point(field_set_allocated:caffe.HDF5OutputParameter.file_name) +} + +inline const HDF5OutputParameter* HDF5OutputParameter::internal_default_instance() { + return &HDF5OutputParameter_default_instance_.get(); +} +#endif // PROTOBUF_INLINE_NOT_IN_HEADERS // =================================================================== @@ -17526,7 +26636,7 @@ const ::google::protobuf::EnumDescriptor* HingeLossParameter_Norm_descriptor() { return HingeLossParameter_Norm_descriptor_; } bool HingeLossParameter_Norm_IsValid(int value) { - switch(value) { + switch (value) { case 1: case 2: return true; @@ -17535,44 +26645,46 @@ bool HingeLossParameter_Norm_IsValid(int value) { } } -#ifndef _MSC_VER +#if !defined(_MSC_VER) || _MSC_VER >= 1900 const HingeLossParameter_Norm HingeLossParameter::L1; const HingeLossParameter_Norm HingeLossParameter::L2; const HingeLossParameter_Norm HingeLossParameter::Norm_MIN; const HingeLossParameter_Norm HingeLossParameter::Norm_MAX; const int HingeLossParameter::Norm_ARRAYSIZE; -#endif // _MSC_VER -#ifndef _MSC_VER +#endif // !defined(_MSC_VER) || _MSC_VER >= 1900 +#if !defined(_MSC_VER) || _MSC_VER >= 1900 const int HingeLossParameter::kNormFieldNumber; -#endif // !_MSC_VER +#endif // !defined(_MSC_VER) || _MSC_VER >= 1900 HingeLossParameter::HingeLossParameter() - : ::google::protobuf::Message() { + : ::google::protobuf::Message(), _internal_metadata_(NULL) { + if (this != internal_default_instance()) protobuf_InitDefaults_caffe_2eproto(); SharedCtor(); + // @@protoc_insertion_point(constructor:caffe.HingeLossParameter) } void HingeLossParameter::InitAsDefaultInstance() { } HingeLossParameter::HingeLossParameter(const HingeLossParameter& from) - : ::google::protobuf::Message() { + : ::google::protobuf::Message(), + _internal_metadata_(NULL) { SharedCtor(); - MergeFrom(from); + UnsafeMergeFrom(from); + // @@protoc_insertion_point(copy_constructor:caffe.HingeLossParameter) } void HingeLossParameter::SharedCtor() { _cached_size_ = 0; norm_ = 1; - ::memset(_has_bits_, 0, sizeof(_has_bits_)); } HingeLossParameter::~HingeLossParameter() { + // @@protoc_insertion_point(destructor:caffe.HingeLossParameter) SharedDtor(); } void HingeLossParameter::SharedDtor() { - if (this != default_instance_) { - } } void HingeLossParameter::SetCachedSize(int size) const { @@ -17586,34 +26698,42 @@ const ::google::protobuf::Descriptor* HingeLossParameter::descriptor() { } const HingeLossParameter& HingeLossParameter::default_instance() { - if (default_instance_ == NULL) protobuf_AddDesc_caffe_2eproto(); - return *default_instance_; + protobuf_InitDefaults_caffe_2eproto(); + return *internal_default_instance(); } -HingeLossParameter* HingeLossParameter::default_instance_ = NULL; +::google::protobuf::internal::ExplicitlyConstructed HingeLossParameter_default_instance_; -HingeLossParameter* HingeLossParameter::New() const { - return new HingeLossParameter; +HingeLossParameter* HingeLossParameter::New(::google::protobuf::Arena* arena) const { + HingeLossParameter* n = new HingeLossParameter; + if (arena != NULL) { + arena->Own(n); + } + return n; } void HingeLossParameter::Clear() { - if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) { - norm_ = 1; +// @@protoc_insertion_point(message_clear_start:caffe.HingeLossParameter) + norm_ = 1; + _has_bits_.Clear(); + if (_internal_metadata_.have_unknown_fields()) { + mutable_unknown_fields()->Clear(); } - ::memset(_has_bits_, 0, sizeof(_has_bits_)); - mutable_unknown_fields()->Clear(); } bool HingeLossParameter::MergePartialFromCodedStream( ::google::protobuf::io::CodedInputStream* input) { -#define DO_(EXPRESSION) if (!(EXPRESSION)) return false +#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure ::google::protobuf::uint32 tag; - while ((tag = input->ReadTag()) != 0) { + // @@protoc_insertion_point(parse_start:caffe.HingeLossParameter) + for (;;) { + ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127); + tag = p.first; + if (!p.second) goto handle_unusual; switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { // optional .caffe.HingeLossParameter.Norm norm = 1 [default = L1]; case 1: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) { + if (tag == 8) { int value; DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< int, ::google::protobuf::internal::WireFormatLite::TYPE_ENUM>( @@ -17624,17 +26744,18 @@ bool HingeLossParameter::MergePartialFromCodedStream( mutable_unknown_fields()->AddVarint(1, value); } } else { - goto handle_uninterpreted; + goto handle_unusual; } - if (input->ExpectAtEnd()) return true; + if (input->ExpectAtEnd()) goto success; break; } default: { - handle_uninterpreted: - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == + handle_unusual: + if (tag == 0 || + ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) { - return true; + goto success; } DO_(::google::protobuf::internal::WireFormat::SkipField( input, tag, mutable_unknown_fields())); @@ -17642,93 +26763,120 @@ bool HingeLossParameter::MergePartialFromCodedStream( } } } +success: + // @@protoc_insertion_point(parse_success:caffe.HingeLossParameter) return true; +failure: + // @@protoc_insertion_point(parse_failure:caffe.HingeLossParameter) + return false; #undef DO_ } void HingeLossParameter::SerializeWithCachedSizes( ::google::protobuf::io::CodedOutputStream* output) const { + // @@protoc_insertion_point(serialize_start:caffe.HingeLossParameter) // optional .caffe.HingeLossParameter.Norm norm = 1 [default = L1]; if (has_norm()) { ::google::protobuf::internal::WireFormatLite::WriteEnum( 1, this->norm(), output); } - if (!unknown_fields().empty()) { + if (_internal_metadata_.have_unknown_fields()) { ::google::protobuf::internal::WireFormat::SerializeUnknownFields( unknown_fields(), output); } + // @@protoc_insertion_point(serialize_end:caffe.HingeLossParameter) } -::google::protobuf::uint8* HingeLossParameter::SerializeWithCachedSizesToArray( - ::google::protobuf::uint8* target) const { +::google::protobuf::uint8* HingeLossParameter::InternalSerializeWithCachedSizesToArray( + bool deterministic, ::google::protobuf::uint8* target) const { + (void)deterministic; // Unused + // @@protoc_insertion_point(serialize_to_array_start:caffe.HingeLossParameter) // optional .caffe.HingeLossParameter.Norm norm = 1 [default = L1]; if (has_norm()) { target = ::google::protobuf::internal::WireFormatLite::WriteEnumToArray( 1, this->norm(), target); } - if (!unknown_fields().empty()) { + if (_internal_metadata_.have_unknown_fields()) { target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray( unknown_fields(), target); } + // @@protoc_insertion_point(serialize_to_array_end:caffe.HingeLossParameter) return target; } -int HingeLossParameter::ByteSize() const { - int total_size = 0; - - if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) { - // optional .caffe.HingeLossParameter.Norm norm = 1 [default = L1]; - if (has_norm()) { - total_size += 1 + - ::google::protobuf::internal::WireFormatLite::EnumSize(this->norm()); - } +size_t HingeLossParameter::ByteSizeLong() const { +// @@protoc_insertion_point(message_byte_size_start:caffe.HingeLossParameter) + size_t total_size = 0; + // optional .caffe.HingeLossParameter.Norm norm = 1 [default = L1]; + if (has_norm()) { + total_size += 1 + + ::google::protobuf::internal::WireFormatLite::EnumSize(this->norm()); } - if (!unknown_fields().empty()) { + + if (_internal_metadata_.have_unknown_fields()) { total_size += ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( unknown_fields()); } + int cached_size = ::google::protobuf::internal::ToCachedSize(total_size); GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); - _cached_size_ = total_size; + _cached_size_ = cached_size; GOOGLE_SAFE_CONCURRENT_WRITES_END(); return total_size; } void HingeLossParameter::MergeFrom(const ::google::protobuf::Message& from) { - GOOGLE_CHECK_NE(&from, this); +// @@protoc_insertion_point(generalized_merge_from_start:caffe.HingeLossParameter) + if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__); const HingeLossParameter* source = - ::google::protobuf::internal::dynamic_cast_if_available( - &from); + ::google::protobuf::internal::DynamicCastToGenerated( + &from); if (source == NULL) { + // @@protoc_insertion_point(generalized_merge_from_cast_fail:caffe.HingeLossParameter) ::google::protobuf::internal::ReflectionOps::Merge(from, this); } else { - MergeFrom(*source); + // @@protoc_insertion_point(generalized_merge_from_cast_success:caffe.HingeLossParameter) + UnsafeMergeFrom(*source); } } void HingeLossParameter::MergeFrom(const HingeLossParameter& from) { - GOOGLE_CHECK_NE(&from, this); +// @@protoc_insertion_point(class_specific_merge_from_start:caffe.HingeLossParameter) + if (GOOGLE_PREDICT_TRUE(&from != this)) { + UnsafeMergeFrom(from); + } else { + MergeFromFail(__LINE__); + } +} + +void HingeLossParameter::UnsafeMergeFrom(const HingeLossParameter& from) { + GOOGLE_DCHECK(&from != this); if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) { if (from.has_norm()) { set_norm(from.norm()); } } - mutable_unknown_fields()->MergeFrom(from.unknown_fields()); + if (from._internal_metadata_.have_unknown_fields()) { + ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata( + from.unknown_fields(), &_internal_metadata_); + } } void HingeLossParameter::CopyFrom(const ::google::protobuf::Message& from) { +// @@protoc_insertion_point(generalized_copy_from_start:caffe.HingeLossParameter) if (&from == this) return; Clear(); MergeFrom(from); } void HingeLossParameter::CopyFrom(const HingeLossParameter& from) { +// @@protoc_insertion_point(class_specific_copy_from_start:caffe.HingeLossParameter) if (&from == this) return; Clear(); - MergeFrom(from); + UnsafeMergeFrom(from); } bool HingeLossParameter::IsInitialized() const { @@ -17737,12 +26885,14 @@ bool HingeLossParameter::IsInitialized() const { } void HingeLossParameter::Swap(HingeLossParameter* other) { - if (other != this) { - std::swap(norm_, other->norm_); - std::swap(_has_bits_[0], other->_has_bits_[0]); - _unknown_fields_.Swap(&other->_unknown_fields_); - std::swap(_cached_size_, other->_cached_size_); - } + if (other == this) return; + InternalSwap(other); +} +void HingeLossParameter::InternalSwap(HingeLossParameter* other) { + std::swap(norm_, other->norm_); + std::swap(_has_bits_[0], other->_has_bits_[0]); + _internal_metadata_.Swap(&other->_internal_metadata_); + std::swap(_cached_size_, other->_cached_size_); } ::google::protobuf::Metadata HingeLossParameter::GetMetadata() const { @@ -17753,10 +26903,42 @@ void HingeLossParameter::Swap(HingeLossParameter* other) { return metadata; } +#if PROTOBUF_INLINE_NOT_IN_HEADERS +// HingeLossParameter + +// optional .caffe.HingeLossParameter.Norm norm = 1 [default = L1]; +bool HingeLossParameter::has_norm() const { + return (_has_bits_[0] & 0x00000001u) != 0; +} +void HingeLossParameter::set_has_norm() { + _has_bits_[0] |= 0x00000001u; +} +void HingeLossParameter::clear_has_norm() { + _has_bits_[0] &= ~0x00000001u; +} +void HingeLossParameter::clear_norm() { + norm_ = 1; + clear_has_norm(); +} +::caffe::HingeLossParameter_Norm HingeLossParameter::norm() const { + // @@protoc_insertion_point(field_get:caffe.HingeLossParameter.norm) + return static_cast< ::caffe::HingeLossParameter_Norm >(norm_); +} +void HingeLossParameter::set_norm(::caffe::HingeLossParameter_Norm value) { + assert(::caffe::HingeLossParameter_Norm_IsValid(value)); + set_has_norm(); + norm_ = value; + // @@protoc_insertion_point(field_set:caffe.HingeLossParameter.norm) +} + +inline const HingeLossParameter* HingeLossParameter::internal_default_instance() { + return &HingeLossParameter_default_instance_.get(); +} +#endif // PROTOBUF_INLINE_NOT_IN_HEADERS // =================================================================== -#ifndef _MSC_VER +#if !defined(_MSC_VER) || _MSC_VER >= 1900 const int ImageDataParameter::kSourceFieldNumber; const int ImageDataParameter::kBatchSizeFieldNumber; const int ImageDataParameter::kRandSkipFieldNumber; @@ -17769,55 +26951,46 @@ const int ImageDataParameter::kMeanFileFieldNumber; const int ImageDataParameter::kCropSizeFieldNumber; const int ImageDataParameter::kMirrorFieldNumber; const int ImageDataParameter::kRootFolderFieldNumber; -#endif // !_MSC_VER +#endif // !defined(_MSC_VER) || _MSC_VER >= 1900 ImageDataParameter::ImageDataParameter() - : ::google::protobuf::Message() { + : ::google::protobuf::Message(), _internal_metadata_(NULL) { + if (this != internal_default_instance()) protobuf_InitDefaults_caffe_2eproto(); SharedCtor(); + // @@protoc_insertion_point(constructor:caffe.ImageDataParameter) } void ImageDataParameter::InitAsDefaultInstance() { } ImageDataParameter::ImageDataParameter(const ImageDataParameter& from) - : ::google::protobuf::Message() { + : ::google::protobuf::Message(), + _internal_metadata_(NULL) { SharedCtor(); - MergeFrom(from); + UnsafeMergeFrom(from); + // @@protoc_insertion_point(copy_constructor:caffe.ImageDataParameter) } void ImageDataParameter::SharedCtor() { _cached_size_ = 0; - source_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); - batch_size_ = 0u; - rand_skip_ = 0u; - shuffle_ = false; - new_height_ = 0u; - new_width_ = 0u; + source_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + mean_file_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + root_folder_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + ::memset(&batch_size_, 0, reinterpret_cast(&crop_size_) - + reinterpret_cast(&batch_size_) + sizeof(crop_size_)); is_color_ = true; scale_ = 1; - mean_file_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); - crop_size_ = 0u; - mirror_ = false; - root_folder_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); - ::memset(_has_bits_, 0, sizeof(_has_bits_)); } ImageDataParameter::~ImageDataParameter() { + // @@protoc_insertion_point(destructor:caffe.ImageDataParameter) SharedDtor(); } void ImageDataParameter::SharedDtor() { - if (source_ != &::google::protobuf::internal::kEmptyString) { - delete source_; - } - if (mean_file_ != &::google::protobuf::internal::kEmptyString) { - delete mean_file_; - } - if (root_folder_ != &::google::protobuf::internal::kEmptyString) { - delete root_folder_; - } - if (this != default_instance_) { - } + source_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + mean_file_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + root_folder_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } void ImageDataParameter::SetCachedSize(int size) const { @@ -17831,66 +27004,86 @@ const ::google::protobuf::Descriptor* ImageDataParameter::descriptor() { } const ImageDataParameter& ImageDataParameter::default_instance() { - if (default_instance_ == NULL) protobuf_AddDesc_caffe_2eproto(); - return *default_instance_; + protobuf_InitDefaults_caffe_2eproto(); + return *internal_default_instance(); } -ImageDataParameter* ImageDataParameter::default_instance_ = NULL; +::google::protobuf::internal::ExplicitlyConstructed ImageDataParameter_default_instance_; -ImageDataParameter* ImageDataParameter::New() const { - return new ImageDataParameter; +ImageDataParameter* ImageDataParameter::New(::google::protobuf::Arena* arena) const { + ImageDataParameter* n = new ImageDataParameter; + if (arena != NULL) { + arena->Own(n); + } + return n; } void ImageDataParameter::Clear() { - if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) { +// @@protoc_insertion_point(message_clear_start:caffe.ImageDataParameter) +#if defined(__clang__) +#define ZR_HELPER_(f) \ + _Pragma("clang diagnostic push") \ + _Pragma("clang diagnostic ignored \"-Winvalid-offsetof\"") \ + __builtin_offsetof(ImageDataParameter, f) \ + _Pragma("clang diagnostic pop") +#else +#define ZR_HELPER_(f) reinterpret_cast(\ + &reinterpret_cast(16)->f) +#endif + +#define ZR_(first, last) do {\ + ::memset(&(first), 0,\ + ZR_HELPER_(last) - ZR_HELPER_(first) + sizeof(last));\ +} while (0) + + if (_has_bits_[0 / 32] & 255u) { + ZR_(batch_size_, shuffle_); if (has_source()) { - if (source_ != &::google::protobuf::internal::kEmptyString) { - source_->clear(); - } + source_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - batch_size_ = 0u; - rand_skip_ = 0u; - shuffle_ = false; - new_height_ = 0u; - new_width_ = 0u; is_color_ = true; scale_ = 1; } - if (_has_bits_[8 / 32] & (0xffu << (8 % 32))) { + if (_has_bits_[8 / 32] & 3840u) { + ZR_(mirror_, crop_size_); if (has_mean_file()) { - if (mean_file_ != &::google::protobuf::internal::kEmptyString) { - mean_file_->clear(); - } + mean_file_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - crop_size_ = 0u; - mirror_ = false; if (has_root_folder()) { - if (root_folder_ != &::google::protobuf::internal::kEmptyString) { - root_folder_->clear(); - } + root_folder_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } } - ::memset(_has_bits_, 0, sizeof(_has_bits_)); - mutable_unknown_fields()->Clear(); + +#undef ZR_HELPER_ +#undef ZR_ + + _has_bits_.Clear(); + if (_internal_metadata_.have_unknown_fields()) { + mutable_unknown_fields()->Clear(); + } } bool ImageDataParameter::MergePartialFromCodedStream( ::google::protobuf::io::CodedInputStream* input) { -#define DO_(EXPRESSION) if (!(EXPRESSION)) return false +#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure ::google::protobuf::uint32 tag; - while ((tag = input->ReadTag()) != 0) { + // @@protoc_insertion_point(parse_start:caffe.ImageDataParameter) + for (;;) { + ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127); + tag = p.first; + if (!p.second) goto handle_unusual; switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { // optional string source = 1; case 1: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) { + if (tag == 10) { DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->mutable_source())); - ::google::protobuf::internal::WireFormat::VerifyUTF8String( + ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( this->source().data(), this->source().length(), - ::google::protobuf::internal::WireFormat::PARSE); + ::google::protobuf::internal::WireFormat::PARSE, + "caffe.ImageDataParameter.source"); } else { - goto handle_uninterpreted; + goto handle_unusual; } if (input->ExpectTag(21)) goto parse_scale; break; @@ -17898,15 +27091,14 @@ bool ImageDataParameter::MergePartialFromCodedStream( // optional float scale = 2 [default = 1]; case 2: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_FIXED32) { + if (tag == 21) { parse_scale: + set_has_scale(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< float, ::google::protobuf::internal::WireFormatLite::TYPE_FLOAT>( input, &scale_))); - set_has_scale(); } else { - goto handle_uninterpreted; + goto handle_unusual; } if (input->ExpectTag(26)) goto parse_mean_file; break; @@ -17914,16 +27106,16 @@ bool ImageDataParameter::MergePartialFromCodedStream( // optional string mean_file = 3; case 3: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) { + if (tag == 26) { parse_mean_file: DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->mutable_mean_file())); - ::google::protobuf::internal::WireFormat::VerifyUTF8String( + ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( this->mean_file().data(), this->mean_file().length(), - ::google::protobuf::internal::WireFormat::PARSE); + ::google::protobuf::internal::WireFormat::PARSE, + "caffe.ImageDataParameter.mean_file"); } else { - goto handle_uninterpreted; + goto handle_unusual; } if (input->ExpectTag(32)) goto parse_batch_size; break; @@ -17931,15 +27123,14 @@ bool ImageDataParameter::MergePartialFromCodedStream( // optional uint32 batch_size = 4; case 4: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) { + if (tag == 32) { parse_batch_size: + set_has_batch_size(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>( input, &batch_size_))); - set_has_batch_size(); } else { - goto handle_uninterpreted; + goto handle_unusual; } if (input->ExpectTag(40)) goto parse_crop_size; break; @@ -17947,15 +27138,14 @@ bool ImageDataParameter::MergePartialFromCodedStream( // optional uint32 crop_size = 5 [default = 0]; case 5: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) { + if (tag == 40) { parse_crop_size: + set_has_crop_size(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>( input, &crop_size_))); - set_has_crop_size(); } else { - goto handle_uninterpreted; + goto handle_unusual; } if (input->ExpectTag(48)) goto parse_mirror; break; @@ -17963,15 +27153,14 @@ bool ImageDataParameter::MergePartialFromCodedStream( // optional bool mirror = 6 [default = false]; case 6: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) { + if (tag == 48) { parse_mirror: + set_has_mirror(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>( input, &mirror_))); - set_has_mirror(); } else { - goto handle_uninterpreted; + goto handle_unusual; } if (input->ExpectTag(56)) goto parse_rand_skip; break; @@ -17979,15 +27168,14 @@ bool ImageDataParameter::MergePartialFromCodedStream( // optional uint32 rand_skip = 7 [default = 0]; case 7: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) { + if (tag == 56) { parse_rand_skip: + set_has_rand_skip(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>( input, &rand_skip_))); - set_has_rand_skip(); } else { - goto handle_uninterpreted; + goto handle_unusual; } if (input->ExpectTag(64)) goto parse_shuffle; break; @@ -17995,15 +27183,14 @@ bool ImageDataParameter::MergePartialFromCodedStream( // optional bool shuffle = 8 [default = false]; case 8: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) { + if (tag == 64) { parse_shuffle: + set_has_shuffle(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>( input, &shuffle_))); - set_has_shuffle(); } else { - goto handle_uninterpreted; + goto handle_unusual; } if (input->ExpectTag(72)) goto parse_new_height; break; @@ -18011,15 +27198,14 @@ bool ImageDataParameter::MergePartialFromCodedStream( // optional uint32 new_height = 9 [default = 0]; case 9: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) { + if (tag == 72) { parse_new_height: + set_has_new_height(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>( input, &new_height_))); - set_has_new_height(); } else { - goto handle_uninterpreted; + goto handle_unusual; } if (input->ExpectTag(80)) goto parse_new_width; break; @@ -18027,15 +27213,14 @@ bool ImageDataParameter::MergePartialFromCodedStream( // optional uint32 new_width = 10 [default = 0]; case 10: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) { + if (tag == 80) { parse_new_width: + set_has_new_width(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>( input, &new_width_))); - set_has_new_width(); } else { - goto handle_uninterpreted; + goto handle_unusual; } if (input->ExpectTag(88)) goto parse_is_color; break; @@ -18043,15 +27228,14 @@ bool ImageDataParameter::MergePartialFromCodedStream( // optional bool is_color = 11 [default = true]; case 11: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) { + if (tag == 88) { parse_is_color: + set_has_is_color(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>( input, &is_color_))); - set_has_is_color(); } else { - goto handle_uninterpreted; + goto handle_unusual; } if (input->ExpectTag(98)) goto parse_root_folder; break; @@ -18059,26 +27243,27 @@ bool ImageDataParameter::MergePartialFromCodedStream( // optional string root_folder = 12 [default = ""]; case 12: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) { + if (tag == 98) { parse_root_folder: DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->mutable_root_folder())); - ::google::protobuf::internal::WireFormat::VerifyUTF8String( + ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( this->root_folder().data(), this->root_folder().length(), - ::google::protobuf::internal::WireFormat::PARSE); + ::google::protobuf::internal::WireFormat::PARSE, + "caffe.ImageDataParameter.root_folder"); } else { - goto handle_uninterpreted; + goto handle_unusual; } - if (input->ExpectAtEnd()) return true; + if (input->ExpectAtEnd()) goto success; break; } default: { - handle_uninterpreted: - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == + handle_unusual: + if (tag == 0 || + ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) { - return true; + goto success; } DO_(::google::protobuf::internal::WireFormat::SkipField( input, tag, mutable_unknown_fields())); @@ -18086,18 +27271,25 @@ bool ImageDataParameter::MergePartialFromCodedStream( } } } +success: + // @@protoc_insertion_point(parse_success:caffe.ImageDataParameter) return true; +failure: + // @@protoc_insertion_point(parse_failure:caffe.ImageDataParameter) + return false; #undef DO_ } void ImageDataParameter::SerializeWithCachedSizes( ::google::protobuf::io::CodedOutputStream* output) const { + // @@protoc_insertion_point(serialize_start:caffe.ImageDataParameter) // optional string source = 1; if (has_source()) { - ::google::protobuf::internal::WireFormat::VerifyUTF8String( + ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( this->source().data(), this->source().length(), - ::google::protobuf::internal::WireFormat::SERIALIZE); - ::google::protobuf::internal::WireFormatLite::WriteString( + ::google::protobuf::internal::WireFormat::SERIALIZE, + "caffe.ImageDataParameter.source"); + ::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased( 1, this->source(), output); } @@ -18108,10 +27300,11 @@ void ImageDataParameter::SerializeWithCachedSizes( // optional string mean_file = 3; if (has_mean_file()) { - ::google::protobuf::internal::WireFormat::VerifyUTF8String( + ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( this->mean_file().data(), this->mean_file().length(), - ::google::protobuf::internal::WireFormat::SERIALIZE); - ::google::protobuf::internal::WireFormatLite::WriteString( + ::google::protobuf::internal::WireFormat::SERIALIZE, + "caffe.ImageDataParameter.mean_file"); + ::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased( 3, this->mean_file(), output); } @@ -18157,26 +27350,31 @@ void ImageDataParameter::SerializeWithCachedSizes( // optional string root_folder = 12 [default = ""]; if (has_root_folder()) { - ::google::protobuf::internal::WireFormat::VerifyUTF8String( + ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( this->root_folder().data(), this->root_folder().length(), - ::google::protobuf::internal::WireFormat::SERIALIZE); - ::google::protobuf::internal::WireFormatLite::WriteString( + ::google::protobuf::internal::WireFormat::SERIALIZE, + "caffe.ImageDataParameter.root_folder"); + ::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased( 12, this->root_folder(), output); } - if (!unknown_fields().empty()) { + if (_internal_metadata_.have_unknown_fields()) { ::google::protobuf::internal::WireFormat::SerializeUnknownFields( unknown_fields(), output); } + // @@protoc_insertion_point(serialize_end:caffe.ImageDataParameter) } -::google::protobuf::uint8* ImageDataParameter::SerializeWithCachedSizesToArray( - ::google::protobuf::uint8* target) const { +::google::protobuf::uint8* ImageDataParameter::InternalSerializeWithCachedSizesToArray( + bool deterministic, ::google::protobuf::uint8* target) const { + (void)deterministic; // Unused + // @@protoc_insertion_point(serialize_to_array_start:caffe.ImageDataParameter) // optional string source = 1; if (has_source()) { - ::google::protobuf::internal::WireFormat::VerifyUTF8String( + ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( this->source().data(), this->source().length(), - ::google::protobuf::internal::WireFormat::SERIALIZE); + ::google::protobuf::internal::WireFormat::SERIALIZE, + "caffe.ImageDataParameter.source"); target = ::google::protobuf::internal::WireFormatLite::WriteStringToArray( 1, this->source(), target); @@ -18189,9 +27387,10 @@ void ImageDataParameter::SerializeWithCachedSizes( // optional string mean_file = 3; if (has_mean_file()) { - ::google::protobuf::internal::WireFormat::VerifyUTF8String( + ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( this->mean_file().data(), this->mean_file().length(), - ::google::protobuf::internal::WireFormat::SERIALIZE); + ::google::protobuf::internal::WireFormat::SERIALIZE, + "caffe.ImageDataParameter.mean_file"); target = ::google::protobuf::internal::WireFormatLite::WriteStringToArray( 3, this->mean_file(), target); @@ -18239,25 +27438,28 @@ void ImageDataParameter::SerializeWithCachedSizes( // optional string root_folder = 12 [default = ""]; if (has_root_folder()) { - ::google::protobuf::internal::WireFormat::VerifyUTF8String( + ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( this->root_folder().data(), this->root_folder().length(), - ::google::protobuf::internal::WireFormat::SERIALIZE); + ::google::protobuf::internal::WireFormat::SERIALIZE, + "caffe.ImageDataParameter.root_folder"); target = ::google::protobuf::internal::WireFormatLite::WriteStringToArray( 12, this->root_folder(), target); } - if (!unknown_fields().empty()) { + if (_internal_metadata_.have_unknown_fields()) { target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray( unknown_fields(), target); } + // @@protoc_insertion_point(serialize_to_array_end:caffe.ImageDataParameter) return target; } -int ImageDataParameter::ByteSize() const { - int total_size = 0; +size_t ImageDataParameter::ByteSizeLong() const { +// @@protoc_insertion_point(message_byte_size_start:caffe.ImageDataParameter) + size_t total_size = 0; - if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) { + if (_has_bits_[0 / 32] & 255u) { // optional string source = 1; if (has_source()) { total_size += 1 + @@ -18309,7 +27511,7 @@ int ImageDataParameter::ByteSize() const { } } - if (_has_bits_[8 / 32] & (0xffu << (8 % 32))) { + if (_has_bits_[8 / 32] & 3840u) { // optional string mean_file = 3; if (has_mean_file()) { total_size += 1 + @@ -18337,34 +27539,48 @@ int ImageDataParameter::ByteSize() const { } } - if (!unknown_fields().empty()) { + if (_internal_metadata_.have_unknown_fields()) { total_size += ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( unknown_fields()); } + int cached_size = ::google::protobuf::internal::ToCachedSize(total_size); GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); - _cached_size_ = total_size; + _cached_size_ = cached_size; GOOGLE_SAFE_CONCURRENT_WRITES_END(); return total_size; } void ImageDataParameter::MergeFrom(const ::google::protobuf::Message& from) { - GOOGLE_CHECK_NE(&from, this); +// @@protoc_insertion_point(generalized_merge_from_start:caffe.ImageDataParameter) + if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__); const ImageDataParameter* source = - ::google::protobuf::internal::dynamic_cast_if_available( - &from); + ::google::protobuf::internal::DynamicCastToGenerated( + &from); if (source == NULL) { + // @@protoc_insertion_point(generalized_merge_from_cast_fail:caffe.ImageDataParameter) ::google::protobuf::internal::ReflectionOps::Merge(from, this); } else { - MergeFrom(*source); + // @@protoc_insertion_point(generalized_merge_from_cast_success:caffe.ImageDataParameter) + UnsafeMergeFrom(*source); } } void ImageDataParameter::MergeFrom(const ImageDataParameter& from) { - GOOGLE_CHECK_NE(&from, this); +// @@protoc_insertion_point(class_specific_merge_from_start:caffe.ImageDataParameter) + if (GOOGLE_PREDICT_TRUE(&from != this)) { + UnsafeMergeFrom(from); + } else { + MergeFromFail(__LINE__); + } +} + +void ImageDataParameter::UnsafeMergeFrom(const ImageDataParameter& from) { + GOOGLE_DCHECK(&from != this); if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) { if (from.has_source()) { - set_source(from.source()); + set_has_source(); + source_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.source_); } if (from.has_batch_size()) { set_batch_size(from.batch_size()); @@ -18390,7 +27606,8 @@ void ImageDataParameter::MergeFrom(const ImageDataParameter& from) { } if (from._has_bits_[8 / 32] & (0xffu << (8 % 32))) { if (from.has_mean_file()) { - set_mean_file(from.mean_file()); + set_has_mean_file(); + mean_file_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.mean_file_); } if (from.has_crop_size()) { set_crop_size(from.crop_size()); @@ -18399,94 +27616,487 @@ void ImageDataParameter::MergeFrom(const ImageDataParameter& from) { set_mirror(from.mirror()); } if (from.has_root_folder()) { - set_root_folder(from.root_folder()); + set_has_root_folder(); + root_folder_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.root_folder_); } } - mutable_unknown_fields()->MergeFrom(from.unknown_fields()); + if (from._internal_metadata_.have_unknown_fields()) { + ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata( + from.unknown_fields(), &_internal_metadata_); + } +} + +void ImageDataParameter::CopyFrom(const ::google::protobuf::Message& from) { +// @@protoc_insertion_point(generalized_copy_from_start:caffe.ImageDataParameter) + if (&from == this) return; + Clear(); + MergeFrom(from); +} + +void ImageDataParameter::CopyFrom(const ImageDataParameter& from) { +// @@protoc_insertion_point(class_specific_copy_from_start:caffe.ImageDataParameter) + if (&from == this) return; + Clear(); + UnsafeMergeFrom(from); +} + +bool ImageDataParameter::IsInitialized() const { + + return true; +} + +void ImageDataParameter::Swap(ImageDataParameter* other) { + if (other == this) return; + InternalSwap(other); +} +void ImageDataParameter::InternalSwap(ImageDataParameter* other) { + source_.Swap(&other->source_); + std::swap(batch_size_, other->batch_size_); + std::swap(rand_skip_, other->rand_skip_); + std::swap(shuffle_, other->shuffle_); + std::swap(new_height_, other->new_height_); + std::swap(new_width_, other->new_width_); + std::swap(is_color_, other->is_color_); + std::swap(scale_, other->scale_); + mean_file_.Swap(&other->mean_file_); + std::swap(crop_size_, other->crop_size_); + std::swap(mirror_, other->mirror_); + root_folder_.Swap(&other->root_folder_); + std::swap(_has_bits_[0], other->_has_bits_[0]); + _internal_metadata_.Swap(&other->_internal_metadata_); + std::swap(_cached_size_, other->_cached_size_); +} + +::google::protobuf::Metadata ImageDataParameter::GetMetadata() const { + protobuf_AssignDescriptorsOnce(); + ::google::protobuf::Metadata metadata; + metadata.descriptor = ImageDataParameter_descriptor_; + metadata.reflection = ImageDataParameter_reflection_; + return metadata; +} + +#if PROTOBUF_INLINE_NOT_IN_HEADERS +// ImageDataParameter + +// optional string source = 1; +bool ImageDataParameter::has_source() const { + return (_has_bits_[0] & 0x00000001u) != 0; +} +void ImageDataParameter::set_has_source() { + _has_bits_[0] |= 0x00000001u; +} +void ImageDataParameter::clear_has_source() { + _has_bits_[0] &= ~0x00000001u; +} +void ImageDataParameter::clear_source() { + source_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + clear_has_source(); +} +const ::std::string& ImageDataParameter::source() const { + // @@protoc_insertion_point(field_get:caffe.ImageDataParameter.source) + return source_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); +} +void ImageDataParameter::set_source(const ::std::string& value) { + set_has_source(); + source_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); + // @@protoc_insertion_point(field_set:caffe.ImageDataParameter.source) +} +void ImageDataParameter::set_source(const char* value) { + set_has_source(); + source_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); + // @@protoc_insertion_point(field_set_char:caffe.ImageDataParameter.source) +} +void ImageDataParameter::set_source(const char* value, size_t size) { + set_has_source(); + source_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), + ::std::string(reinterpret_cast(value), size)); + // @@protoc_insertion_point(field_set_pointer:caffe.ImageDataParameter.source) +} +::std::string* ImageDataParameter::mutable_source() { + set_has_source(); + // @@protoc_insertion_point(field_mutable:caffe.ImageDataParameter.source) + return source_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); +} +::std::string* ImageDataParameter::release_source() { + // @@protoc_insertion_point(field_release:caffe.ImageDataParameter.source) + clear_has_source(); + return source_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); +} +void ImageDataParameter::set_allocated_source(::std::string* source) { + if (source != NULL) { + set_has_source(); + } else { + clear_has_source(); + } + source_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), source); + // @@protoc_insertion_point(field_set_allocated:caffe.ImageDataParameter.source) +} + +// optional uint32 batch_size = 4; +bool ImageDataParameter::has_batch_size() const { + return (_has_bits_[0] & 0x00000002u) != 0; +} +void ImageDataParameter::set_has_batch_size() { + _has_bits_[0] |= 0x00000002u; +} +void ImageDataParameter::clear_has_batch_size() { + _has_bits_[0] &= ~0x00000002u; +} +void ImageDataParameter::clear_batch_size() { + batch_size_ = 0u; + clear_has_batch_size(); +} +::google::protobuf::uint32 ImageDataParameter::batch_size() const { + // @@protoc_insertion_point(field_get:caffe.ImageDataParameter.batch_size) + return batch_size_; +} +void ImageDataParameter::set_batch_size(::google::protobuf::uint32 value) { + set_has_batch_size(); + batch_size_ = value; + // @@protoc_insertion_point(field_set:caffe.ImageDataParameter.batch_size) +} + +// optional uint32 rand_skip = 7 [default = 0]; +bool ImageDataParameter::has_rand_skip() const { + return (_has_bits_[0] & 0x00000004u) != 0; +} +void ImageDataParameter::set_has_rand_skip() { + _has_bits_[0] |= 0x00000004u; +} +void ImageDataParameter::clear_has_rand_skip() { + _has_bits_[0] &= ~0x00000004u; +} +void ImageDataParameter::clear_rand_skip() { + rand_skip_ = 0u; + clear_has_rand_skip(); +} +::google::protobuf::uint32 ImageDataParameter::rand_skip() const { + // @@protoc_insertion_point(field_get:caffe.ImageDataParameter.rand_skip) + return rand_skip_; +} +void ImageDataParameter::set_rand_skip(::google::protobuf::uint32 value) { + set_has_rand_skip(); + rand_skip_ = value; + // @@protoc_insertion_point(field_set:caffe.ImageDataParameter.rand_skip) +} + +// optional bool shuffle = 8 [default = false]; +bool ImageDataParameter::has_shuffle() const { + return (_has_bits_[0] & 0x00000008u) != 0; +} +void ImageDataParameter::set_has_shuffle() { + _has_bits_[0] |= 0x00000008u; +} +void ImageDataParameter::clear_has_shuffle() { + _has_bits_[0] &= ~0x00000008u; +} +void ImageDataParameter::clear_shuffle() { + shuffle_ = false; + clear_has_shuffle(); +} +bool ImageDataParameter::shuffle() const { + // @@protoc_insertion_point(field_get:caffe.ImageDataParameter.shuffle) + return shuffle_; +} +void ImageDataParameter::set_shuffle(bool value) { + set_has_shuffle(); + shuffle_ = value; + // @@protoc_insertion_point(field_set:caffe.ImageDataParameter.shuffle) +} + +// optional uint32 new_height = 9 [default = 0]; +bool ImageDataParameter::has_new_height() const { + return (_has_bits_[0] & 0x00000010u) != 0; +} +void ImageDataParameter::set_has_new_height() { + _has_bits_[0] |= 0x00000010u; +} +void ImageDataParameter::clear_has_new_height() { + _has_bits_[0] &= ~0x00000010u; +} +void ImageDataParameter::clear_new_height() { + new_height_ = 0u; + clear_has_new_height(); +} +::google::protobuf::uint32 ImageDataParameter::new_height() const { + // @@protoc_insertion_point(field_get:caffe.ImageDataParameter.new_height) + return new_height_; +} +void ImageDataParameter::set_new_height(::google::protobuf::uint32 value) { + set_has_new_height(); + new_height_ = value; + // @@protoc_insertion_point(field_set:caffe.ImageDataParameter.new_height) +} + +// optional uint32 new_width = 10 [default = 0]; +bool ImageDataParameter::has_new_width() const { + return (_has_bits_[0] & 0x00000020u) != 0; +} +void ImageDataParameter::set_has_new_width() { + _has_bits_[0] |= 0x00000020u; +} +void ImageDataParameter::clear_has_new_width() { + _has_bits_[0] &= ~0x00000020u; +} +void ImageDataParameter::clear_new_width() { + new_width_ = 0u; + clear_has_new_width(); +} +::google::protobuf::uint32 ImageDataParameter::new_width() const { + // @@protoc_insertion_point(field_get:caffe.ImageDataParameter.new_width) + return new_width_; +} +void ImageDataParameter::set_new_width(::google::protobuf::uint32 value) { + set_has_new_width(); + new_width_ = value; + // @@protoc_insertion_point(field_set:caffe.ImageDataParameter.new_width) } -void ImageDataParameter::CopyFrom(const ::google::protobuf::Message& from) { - if (&from == this) return; - Clear(); - MergeFrom(from); +// optional bool is_color = 11 [default = true]; +bool ImageDataParameter::has_is_color() const { + return (_has_bits_[0] & 0x00000040u) != 0; +} +void ImageDataParameter::set_has_is_color() { + _has_bits_[0] |= 0x00000040u; +} +void ImageDataParameter::clear_has_is_color() { + _has_bits_[0] &= ~0x00000040u; +} +void ImageDataParameter::clear_is_color() { + is_color_ = true; + clear_has_is_color(); +} +bool ImageDataParameter::is_color() const { + // @@protoc_insertion_point(field_get:caffe.ImageDataParameter.is_color) + return is_color_; +} +void ImageDataParameter::set_is_color(bool value) { + set_has_is_color(); + is_color_ = value; + // @@protoc_insertion_point(field_set:caffe.ImageDataParameter.is_color) } -void ImageDataParameter::CopyFrom(const ImageDataParameter& from) { - if (&from == this) return; - Clear(); - MergeFrom(from); +// optional float scale = 2 [default = 1]; +bool ImageDataParameter::has_scale() const { + return (_has_bits_[0] & 0x00000080u) != 0; +} +void ImageDataParameter::set_has_scale() { + _has_bits_[0] |= 0x00000080u; +} +void ImageDataParameter::clear_has_scale() { + _has_bits_[0] &= ~0x00000080u; +} +void ImageDataParameter::clear_scale() { + scale_ = 1; + clear_has_scale(); +} +float ImageDataParameter::scale() const { + // @@protoc_insertion_point(field_get:caffe.ImageDataParameter.scale) + return scale_; +} +void ImageDataParameter::set_scale(float value) { + set_has_scale(); + scale_ = value; + // @@protoc_insertion_point(field_set:caffe.ImageDataParameter.scale) } -bool ImageDataParameter::IsInitialized() const { +// optional string mean_file = 3; +bool ImageDataParameter::has_mean_file() const { + return (_has_bits_[0] & 0x00000100u) != 0; +} +void ImageDataParameter::set_has_mean_file() { + _has_bits_[0] |= 0x00000100u; +} +void ImageDataParameter::clear_has_mean_file() { + _has_bits_[0] &= ~0x00000100u; +} +void ImageDataParameter::clear_mean_file() { + mean_file_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + clear_has_mean_file(); +} +const ::std::string& ImageDataParameter::mean_file() const { + // @@protoc_insertion_point(field_get:caffe.ImageDataParameter.mean_file) + return mean_file_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); +} +void ImageDataParameter::set_mean_file(const ::std::string& value) { + set_has_mean_file(); + mean_file_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); + // @@protoc_insertion_point(field_set:caffe.ImageDataParameter.mean_file) +} +void ImageDataParameter::set_mean_file(const char* value) { + set_has_mean_file(); + mean_file_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); + // @@protoc_insertion_point(field_set_char:caffe.ImageDataParameter.mean_file) +} +void ImageDataParameter::set_mean_file(const char* value, size_t size) { + set_has_mean_file(); + mean_file_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), + ::std::string(reinterpret_cast(value), size)); + // @@protoc_insertion_point(field_set_pointer:caffe.ImageDataParameter.mean_file) +} +::std::string* ImageDataParameter::mutable_mean_file() { + set_has_mean_file(); + // @@protoc_insertion_point(field_mutable:caffe.ImageDataParameter.mean_file) + return mean_file_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); +} +::std::string* ImageDataParameter::release_mean_file() { + // @@protoc_insertion_point(field_release:caffe.ImageDataParameter.mean_file) + clear_has_mean_file(); + return mean_file_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); +} +void ImageDataParameter::set_allocated_mean_file(::std::string* mean_file) { + if (mean_file != NULL) { + set_has_mean_file(); + } else { + clear_has_mean_file(); + } + mean_file_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), mean_file); + // @@protoc_insertion_point(field_set_allocated:caffe.ImageDataParameter.mean_file) +} - return true; +// optional uint32 crop_size = 5 [default = 0]; +bool ImageDataParameter::has_crop_size() const { + return (_has_bits_[0] & 0x00000200u) != 0; +} +void ImageDataParameter::set_has_crop_size() { + _has_bits_[0] |= 0x00000200u; +} +void ImageDataParameter::clear_has_crop_size() { + _has_bits_[0] &= ~0x00000200u; +} +void ImageDataParameter::clear_crop_size() { + crop_size_ = 0u; + clear_has_crop_size(); +} +::google::protobuf::uint32 ImageDataParameter::crop_size() const { + // @@protoc_insertion_point(field_get:caffe.ImageDataParameter.crop_size) + return crop_size_; +} +void ImageDataParameter::set_crop_size(::google::protobuf::uint32 value) { + set_has_crop_size(); + crop_size_ = value; + // @@protoc_insertion_point(field_set:caffe.ImageDataParameter.crop_size) } -void ImageDataParameter::Swap(ImageDataParameter* other) { - if (other != this) { - std::swap(source_, other->source_); - std::swap(batch_size_, other->batch_size_); - std::swap(rand_skip_, other->rand_skip_); - std::swap(shuffle_, other->shuffle_); - std::swap(new_height_, other->new_height_); - std::swap(new_width_, other->new_width_); - std::swap(is_color_, other->is_color_); - std::swap(scale_, other->scale_); - std::swap(mean_file_, other->mean_file_); - std::swap(crop_size_, other->crop_size_); - std::swap(mirror_, other->mirror_); - std::swap(root_folder_, other->root_folder_); - std::swap(_has_bits_[0], other->_has_bits_[0]); - _unknown_fields_.Swap(&other->_unknown_fields_); - std::swap(_cached_size_, other->_cached_size_); - } +// optional bool mirror = 6 [default = false]; +bool ImageDataParameter::has_mirror() const { + return (_has_bits_[0] & 0x00000400u) != 0; +} +void ImageDataParameter::set_has_mirror() { + _has_bits_[0] |= 0x00000400u; +} +void ImageDataParameter::clear_has_mirror() { + _has_bits_[0] &= ~0x00000400u; +} +void ImageDataParameter::clear_mirror() { + mirror_ = false; + clear_has_mirror(); +} +bool ImageDataParameter::mirror() const { + // @@protoc_insertion_point(field_get:caffe.ImageDataParameter.mirror) + return mirror_; +} +void ImageDataParameter::set_mirror(bool value) { + set_has_mirror(); + mirror_ = value; + // @@protoc_insertion_point(field_set:caffe.ImageDataParameter.mirror) } -::google::protobuf::Metadata ImageDataParameter::GetMetadata() const { - protobuf_AssignDescriptorsOnce(); - ::google::protobuf::Metadata metadata; - metadata.descriptor = ImageDataParameter_descriptor_; - metadata.reflection = ImageDataParameter_reflection_; - return metadata; +// optional string root_folder = 12 [default = ""]; +bool ImageDataParameter::has_root_folder() const { + return (_has_bits_[0] & 0x00000800u) != 0; +} +void ImageDataParameter::set_has_root_folder() { + _has_bits_[0] |= 0x00000800u; +} +void ImageDataParameter::clear_has_root_folder() { + _has_bits_[0] &= ~0x00000800u; +} +void ImageDataParameter::clear_root_folder() { + root_folder_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + clear_has_root_folder(); +} +const ::std::string& ImageDataParameter::root_folder() const { + // @@protoc_insertion_point(field_get:caffe.ImageDataParameter.root_folder) + return root_folder_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); +} +void ImageDataParameter::set_root_folder(const ::std::string& value) { + set_has_root_folder(); + root_folder_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); + // @@protoc_insertion_point(field_set:caffe.ImageDataParameter.root_folder) +} +void ImageDataParameter::set_root_folder(const char* value) { + set_has_root_folder(); + root_folder_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); + // @@protoc_insertion_point(field_set_char:caffe.ImageDataParameter.root_folder) +} +void ImageDataParameter::set_root_folder(const char* value, size_t size) { + set_has_root_folder(); + root_folder_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), + ::std::string(reinterpret_cast(value), size)); + // @@protoc_insertion_point(field_set_pointer:caffe.ImageDataParameter.root_folder) +} +::std::string* ImageDataParameter::mutable_root_folder() { + set_has_root_folder(); + // @@protoc_insertion_point(field_mutable:caffe.ImageDataParameter.root_folder) + return root_folder_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); +} +::std::string* ImageDataParameter::release_root_folder() { + // @@protoc_insertion_point(field_release:caffe.ImageDataParameter.root_folder) + clear_has_root_folder(); + return root_folder_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); +} +void ImageDataParameter::set_allocated_root_folder(::std::string* root_folder) { + if (root_folder != NULL) { + set_has_root_folder(); + } else { + clear_has_root_folder(); + } + root_folder_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), root_folder); + // @@protoc_insertion_point(field_set_allocated:caffe.ImageDataParameter.root_folder) } +inline const ImageDataParameter* ImageDataParameter::internal_default_instance() { + return &ImageDataParameter_default_instance_.get(); +} +#endif // PROTOBUF_INLINE_NOT_IN_HEADERS // =================================================================== -#ifndef _MSC_VER +#if !defined(_MSC_VER) || _MSC_VER >= 1900 const int InfogainLossParameter::kSourceFieldNumber; -#endif // !_MSC_VER +#endif // !defined(_MSC_VER) || _MSC_VER >= 1900 InfogainLossParameter::InfogainLossParameter() - : ::google::protobuf::Message() { + : ::google::protobuf::Message(), _internal_metadata_(NULL) { + if (this != internal_default_instance()) protobuf_InitDefaults_caffe_2eproto(); SharedCtor(); + // @@protoc_insertion_point(constructor:caffe.InfogainLossParameter) } void InfogainLossParameter::InitAsDefaultInstance() { } InfogainLossParameter::InfogainLossParameter(const InfogainLossParameter& from) - : ::google::protobuf::Message() { + : ::google::protobuf::Message(), + _internal_metadata_(NULL) { SharedCtor(); - MergeFrom(from); + UnsafeMergeFrom(from); + // @@protoc_insertion_point(copy_constructor:caffe.InfogainLossParameter) } void InfogainLossParameter::SharedCtor() { _cached_size_ = 0; - source_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); - ::memset(_has_bits_, 0, sizeof(_has_bits_)); + source_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } InfogainLossParameter::~InfogainLossParameter() { + // @@protoc_insertion_point(destructor:caffe.InfogainLossParameter) SharedDtor(); } void InfogainLossParameter::SharedDtor() { - if (source_ != &::google::protobuf::internal::kEmptyString) { - delete source_; - } - if (this != default_instance_) { - } + source_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } void InfogainLossParameter::SetCachedSize(int size) const { @@ -18500,55 +28110,63 @@ const ::google::protobuf::Descriptor* InfogainLossParameter::descriptor() { } const InfogainLossParameter& InfogainLossParameter::default_instance() { - if (default_instance_ == NULL) protobuf_AddDesc_caffe_2eproto(); - return *default_instance_; + protobuf_InitDefaults_caffe_2eproto(); + return *internal_default_instance(); } -InfogainLossParameter* InfogainLossParameter::default_instance_ = NULL; +::google::protobuf::internal::ExplicitlyConstructed InfogainLossParameter_default_instance_; -InfogainLossParameter* InfogainLossParameter::New() const { - return new InfogainLossParameter; +InfogainLossParameter* InfogainLossParameter::New(::google::protobuf::Arena* arena) const { + InfogainLossParameter* n = new InfogainLossParameter; + if (arena != NULL) { + arena->Own(n); + } + return n; } void InfogainLossParameter::Clear() { - if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) { - if (has_source()) { - if (source_ != &::google::protobuf::internal::kEmptyString) { - source_->clear(); - } - } +// @@protoc_insertion_point(message_clear_start:caffe.InfogainLossParameter) + if (has_source()) { + source_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + } + _has_bits_.Clear(); + if (_internal_metadata_.have_unknown_fields()) { + mutable_unknown_fields()->Clear(); } - ::memset(_has_bits_, 0, sizeof(_has_bits_)); - mutable_unknown_fields()->Clear(); } bool InfogainLossParameter::MergePartialFromCodedStream( ::google::protobuf::io::CodedInputStream* input) { -#define DO_(EXPRESSION) if (!(EXPRESSION)) return false +#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure ::google::protobuf::uint32 tag; - while ((tag = input->ReadTag()) != 0) { + // @@protoc_insertion_point(parse_start:caffe.InfogainLossParameter) + for (;;) { + ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127); + tag = p.first; + if (!p.second) goto handle_unusual; switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { // optional string source = 1; case 1: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) { + if (tag == 10) { DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->mutable_source())); - ::google::protobuf::internal::WireFormat::VerifyUTF8String( + ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( this->source().data(), this->source().length(), - ::google::protobuf::internal::WireFormat::PARSE); + ::google::protobuf::internal::WireFormat::PARSE, + "caffe.InfogainLossParameter.source"); } else { - goto handle_uninterpreted; + goto handle_unusual; } - if (input->ExpectAtEnd()) return true; + if (input->ExpectAtEnd()) goto success; break; } default: { - handle_uninterpreted: - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == + handle_unusual: + if (tag == 0 || + ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) { - return true; + goto success; } DO_(::google::protobuf::internal::WireFormat::SkipField( input, tag, mutable_unknown_fields())); @@ -18556,101 +28174,131 @@ bool InfogainLossParameter::MergePartialFromCodedStream( } } } +success: + // @@protoc_insertion_point(parse_success:caffe.InfogainLossParameter) return true; +failure: + // @@protoc_insertion_point(parse_failure:caffe.InfogainLossParameter) + return false; #undef DO_ } void InfogainLossParameter::SerializeWithCachedSizes( ::google::protobuf::io::CodedOutputStream* output) const { + // @@protoc_insertion_point(serialize_start:caffe.InfogainLossParameter) // optional string source = 1; if (has_source()) { - ::google::protobuf::internal::WireFormat::VerifyUTF8String( + ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( this->source().data(), this->source().length(), - ::google::protobuf::internal::WireFormat::SERIALIZE); - ::google::protobuf::internal::WireFormatLite::WriteString( + ::google::protobuf::internal::WireFormat::SERIALIZE, + "caffe.InfogainLossParameter.source"); + ::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased( 1, this->source(), output); } - if (!unknown_fields().empty()) { + if (_internal_metadata_.have_unknown_fields()) { ::google::protobuf::internal::WireFormat::SerializeUnknownFields( unknown_fields(), output); } + // @@protoc_insertion_point(serialize_end:caffe.InfogainLossParameter) } -::google::protobuf::uint8* InfogainLossParameter::SerializeWithCachedSizesToArray( - ::google::protobuf::uint8* target) const { +::google::protobuf::uint8* InfogainLossParameter::InternalSerializeWithCachedSizesToArray( + bool deterministic, ::google::protobuf::uint8* target) const { + (void)deterministic; // Unused + // @@protoc_insertion_point(serialize_to_array_start:caffe.InfogainLossParameter) // optional string source = 1; if (has_source()) { - ::google::protobuf::internal::WireFormat::VerifyUTF8String( + ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( this->source().data(), this->source().length(), - ::google::protobuf::internal::WireFormat::SERIALIZE); + ::google::protobuf::internal::WireFormat::SERIALIZE, + "caffe.InfogainLossParameter.source"); target = ::google::protobuf::internal::WireFormatLite::WriteStringToArray( 1, this->source(), target); } - if (!unknown_fields().empty()) { + if (_internal_metadata_.have_unknown_fields()) { target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray( unknown_fields(), target); } + // @@protoc_insertion_point(serialize_to_array_end:caffe.InfogainLossParameter) return target; } -int InfogainLossParameter::ByteSize() const { - int total_size = 0; - - if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) { - // optional string source = 1; - if (has_source()) { - total_size += 1 + - ::google::protobuf::internal::WireFormatLite::StringSize( - this->source()); - } +size_t InfogainLossParameter::ByteSizeLong() const { +// @@protoc_insertion_point(message_byte_size_start:caffe.InfogainLossParameter) + size_t total_size = 0; + // optional string source = 1; + if (has_source()) { + total_size += 1 + + ::google::protobuf::internal::WireFormatLite::StringSize( + this->source()); } - if (!unknown_fields().empty()) { + + if (_internal_metadata_.have_unknown_fields()) { total_size += ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( unknown_fields()); } + int cached_size = ::google::protobuf::internal::ToCachedSize(total_size); GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); - _cached_size_ = total_size; + _cached_size_ = cached_size; GOOGLE_SAFE_CONCURRENT_WRITES_END(); return total_size; } void InfogainLossParameter::MergeFrom(const ::google::protobuf::Message& from) { - GOOGLE_CHECK_NE(&from, this); +// @@protoc_insertion_point(generalized_merge_from_start:caffe.InfogainLossParameter) + if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__); const InfogainLossParameter* source = - ::google::protobuf::internal::dynamic_cast_if_available( - &from); + ::google::protobuf::internal::DynamicCastToGenerated( + &from); if (source == NULL) { + // @@protoc_insertion_point(generalized_merge_from_cast_fail:caffe.InfogainLossParameter) ::google::protobuf::internal::ReflectionOps::Merge(from, this); } else { - MergeFrom(*source); + // @@protoc_insertion_point(generalized_merge_from_cast_success:caffe.InfogainLossParameter) + UnsafeMergeFrom(*source); } } void InfogainLossParameter::MergeFrom(const InfogainLossParameter& from) { - GOOGLE_CHECK_NE(&from, this); +// @@protoc_insertion_point(class_specific_merge_from_start:caffe.InfogainLossParameter) + if (GOOGLE_PREDICT_TRUE(&from != this)) { + UnsafeMergeFrom(from); + } else { + MergeFromFail(__LINE__); + } +} + +void InfogainLossParameter::UnsafeMergeFrom(const InfogainLossParameter& from) { + GOOGLE_DCHECK(&from != this); if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) { if (from.has_source()) { - set_source(from.source()); + set_has_source(); + source_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.source_); } } - mutable_unknown_fields()->MergeFrom(from.unknown_fields()); + if (from._internal_metadata_.have_unknown_fields()) { + ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata( + from.unknown_fields(), &_internal_metadata_); + } } void InfogainLossParameter::CopyFrom(const ::google::protobuf::Message& from) { +// @@protoc_insertion_point(generalized_copy_from_start:caffe.InfogainLossParameter) if (&from == this) return; Clear(); MergeFrom(from); } void InfogainLossParameter::CopyFrom(const InfogainLossParameter& from) { +// @@protoc_insertion_point(class_specific_copy_from_start:caffe.InfogainLossParameter) if (&from == this) return; Clear(); - MergeFrom(from); + UnsafeMergeFrom(from); } bool InfogainLossParameter::IsInitialized() const { @@ -18659,12 +28307,14 @@ bool InfogainLossParameter::IsInitialized() const { } void InfogainLossParameter::Swap(InfogainLossParameter* other) { - if (other != this) { - std::swap(source_, other->source_); - std::swap(_has_bits_[0], other->_has_bits_[0]); - _unknown_fields_.Swap(&other->_unknown_fields_); - std::swap(_cached_size_, other->_cached_size_); - } + if (other == this) return; + InternalSwap(other); +} +void InfogainLossParameter::InternalSwap(InfogainLossParameter* other) { + source_.Swap(&other->source_); + std::swap(_has_bits_[0], other->_has_bits_[0]); + _internal_metadata_.Swap(&other->_internal_metadata_); + std::swap(_cached_size_, other->_cached_size_); } ::google::protobuf::Metadata InfogainLossParameter::GetMetadata() const { @@ -18675,49 +28325,116 @@ void InfogainLossParameter::Swap(InfogainLossParameter* other) { return metadata; } +#if PROTOBUF_INLINE_NOT_IN_HEADERS +// InfogainLossParameter + +// optional string source = 1; +bool InfogainLossParameter::has_source() const { + return (_has_bits_[0] & 0x00000001u) != 0; +} +void InfogainLossParameter::set_has_source() { + _has_bits_[0] |= 0x00000001u; +} +void InfogainLossParameter::clear_has_source() { + _has_bits_[0] &= ~0x00000001u; +} +void InfogainLossParameter::clear_source() { + source_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + clear_has_source(); +} +const ::std::string& InfogainLossParameter::source() const { + // @@protoc_insertion_point(field_get:caffe.InfogainLossParameter.source) + return source_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); +} +void InfogainLossParameter::set_source(const ::std::string& value) { + set_has_source(); + source_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); + // @@protoc_insertion_point(field_set:caffe.InfogainLossParameter.source) +} +void InfogainLossParameter::set_source(const char* value) { + set_has_source(); + source_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); + // @@protoc_insertion_point(field_set_char:caffe.InfogainLossParameter.source) +} +void InfogainLossParameter::set_source(const char* value, size_t size) { + set_has_source(); + source_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), + ::std::string(reinterpret_cast(value), size)); + // @@protoc_insertion_point(field_set_pointer:caffe.InfogainLossParameter.source) +} +::std::string* InfogainLossParameter::mutable_source() { + set_has_source(); + // @@protoc_insertion_point(field_mutable:caffe.InfogainLossParameter.source) + return source_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); +} +::std::string* InfogainLossParameter::release_source() { + // @@protoc_insertion_point(field_release:caffe.InfogainLossParameter.source) + clear_has_source(); + return source_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); +} +void InfogainLossParameter::set_allocated_source(::std::string* source) { + if (source != NULL) { + set_has_source(); + } else { + clear_has_source(); + } + source_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), source); + // @@protoc_insertion_point(field_set_allocated:caffe.InfogainLossParameter.source) +} + +inline const InfogainLossParameter* InfogainLossParameter::internal_default_instance() { + return &InfogainLossParameter_default_instance_.get(); +} +#endif // PROTOBUF_INLINE_NOT_IN_HEADERS // =================================================================== -#ifndef _MSC_VER +#if !defined(_MSC_VER) || _MSC_VER >= 1900 const int InnerProductParameter::kNumOutputFieldNumber; const int InnerProductParameter::kBiasTermFieldNumber; const int InnerProductParameter::kWeightFillerFieldNumber; const int InnerProductParameter::kBiasFillerFieldNumber; const int InnerProductParameter::kAxisFieldNumber; -#endif // !_MSC_VER +#endif // !defined(_MSC_VER) || _MSC_VER >= 1900 InnerProductParameter::InnerProductParameter() - : ::google::protobuf::Message() { + : ::google::protobuf::Message(), _internal_metadata_(NULL) { + if (this != internal_default_instance()) protobuf_InitDefaults_caffe_2eproto(); SharedCtor(); + // @@protoc_insertion_point(constructor:caffe.InnerProductParameter) } void InnerProductParameter::InitAsDefaultInstance() { - weight_filler_ = const_cast< ::caffe::FillerParameter*>(&::caffe::FillerParameter::default_instance()); - bias_filler_ = const_cast< ::caffe::FillerParameter*>(&::caffe::FillerParameter::default_instance()); + weight_filler_ = const_cast< ::caffe::FillerParameter*>( + ::caffe::FillerParameter::internal_default_instance()); + bias_filler_ = const_cast< ::caffe::FillerParameter*>( + ::caffe::FillerParameter::internal_default_instance()); } InnerProductParameter::InnerProductParameter(const InnerProductParameter& from) - : ::google::protobuf::Message() { + : ::google::protobuf::Message(), + _internal_metadata_(NULL) { SharedCtor(); - MergeFrom(from); + UnsafeMergeFrom(from); + // @@protoc_insertion_point(copy_constructor:caffe.InnerProductParameter) } void InnerProductParameter::SharedCtor() { _cached_size_ = 0; - num_output_ = 0u; - bias_term_ = true; weight_filler_ = NULL; bias_filler_ = NULL; + num_output_ = 0u; + bias_term_ = true; axis_ = 1; - ::memset(_has_bits_, 0, sizeof(_has_bits_)); } InnerProductParameter::~InnerProductParameter() { + // @@protoc_insertion_point(destructor:caffe.InnerProductParameter) SharedDtor(); } void InnerProductParameter::SharedDtor() { - if (this != default_instance_) { + if (this != &InnerProductParameter_default_instance_.get()) { delete weight_filler_; delete bias_filler_; } @@ -18734,18 +28451,23 @@ const ::google::protobuf::Descriptor* InnerProductParameter::descriptor() { } const InnerProductParameter& InnerProductParameter::default_instance() { - if (default_instance_ == NULL) protobuf_AddDesc_caffe_2eproto(); - return *default_instance_; + protobuf_InitDefaults_caffe_2eproto(); + return *internal_default_instance(); } -InnerProductParameter* InnerProductParameter::default_instance_ = NULL; +::google::protobuf::internal::ExplicitlyConstructed InnerProductParameter_default_instance_; -InnerProductParameter* InnerProductParameter::New() const { - return new InnerProductParameter; +InnerProductParameter* InnerProductParameter::New(::google::protobuf::Arena* arena) const { + InnerProductParameter* n = new InnerProductParameter; + if (arena != NULL) { + arena->Own(n); + } + return n; } void InnerProductParameter::Clear() { - if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) { +// @@protoc_insertion_point(message_clear_start:caffe.InnerProductParameter) + if (_has_bits_[0 / 32] & 31u) { num_output_ = 0u; bias_term_ = true; if (has_weight_filler()) { @@ -18756,26 +28478,31 @@ void InnerProductParameter::Clear() { } axis_ = 1; } - ::memset(_has_bits_, 0, sizeof(_has_bits_)); - mutable_unknown_fields()->Clear(); + _has_bits_.Clear(); + if (_internal_metadata_.have_unknown_fields()) { + mutable_unknown_fields()->Clear(); + } } bool InnerProductParameter::MergePartialFromCodedStream( ::google::protobuf::io::CodedInputStream* input) { -#define DO_(EXPRESSION) if (!(EXPRESSION)) return false +#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure ::google::protobuf::uint32 tag; - while ((tag = input->ReadTag()) != 0) { + // @@protoc_insertion_point(parse_start:caffe.InnerProductParameter) + for (;;) { + ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127); + tag = p.first; + if (!p.second) goto handle_unusual; switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { // optional uint32 num_output = 1; case 1: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) { + if (tag == 8) { + set_has_num_output(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>( input, &num_output_))); - set_has_num_output(); } else { - goto handle_uninterpreted; + goto handle_unusual; } if (input->ExpectTag(16)) goto parse_bias_term; break; @@ -18783,15 +28510,14 @@ bool InnerProductParameter::MergePartialFromCodedStream( // optional bool bias_term = 2 [default = true]; case 2: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) { + if (tag == 16) { parse_bias_term: + set_has_bias_term(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>( input, &bias_term_))); - set_has_bias_term(); } else { - goto handle_uninterpreted; + goto handle_unusual; } if (input->ExpectTag(26)) goto parse_weight_filler; break; @@ -18799,13 +28525,12 @@ bool InnerProductParameter::MergePartialFromCodedStream( // optional .caffe.FillerParameter weight_filler = 3; case 3: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) { + if (tag == 26) { parse_weight_filler: DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual( input, mutable_weight_filler())); } else { - goto handle_uninterpreted; + goto handle_unusual; } if (input->ExpectTag(34)) goto parse_bias_filler; break; @@ -18813,13 +28538,12 @@ bool InnerProductParameter::MergePartialFromCodedStream( // optional .caffe.FillerParameter bias_filler = 4; case 4: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) { + if (tag == 34) { parse_bias_filler: DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual( input, mutable_bias_filler())); } else { - goto handle_uninterpreted; + goto handle_unusual; } if (input->ExpectTag(40)) goto parse_axis; break; @@ -18827,25 +28551,25 @@ bool InnerProductParameter::MergePartialFromCodedStream( // optional int32 axis = 5 [default = 1]; case 5: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) { + if (tag == 40) { parse_axis: + set_has_axis(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>( input, &axis_))); - set_has_axis(); } else { - goto handle_uninterpreted; + goto handle_unusual; } - if (input->ExpectAtEnd()) return true; + if (input->ExpectAtEnd()) goto success; break; } default: { - handle_uninterpreted: - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == + handle_unusual: + if (tag == 0 || + ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) { - return true; + goto success; } DO_(::google::protobuf::internal::WireFormat::SkipField( input, tag, mutable_unknown_fields())); @@ -18853,12 +28577,18 @@ bool InnerProductParameter::MergePartialFromCodedStream( } } } +success: + // @@protoc_insertion_point(parse_success:caffe.InnerProductParameter) return true; +failure: + // @@protoc_insertion_point(parse_failure:caffe.InnerProductParameter) + return false; #undef DO_ } void InnerProductParameter::SerializeWithCachedSizes( ::google::protobuf::io::CodedOutputStream* output) const { + // @@protoc_insertion_point(serialize_start:caffe.InnerProductParameter) // optional uint32 num_output = 1; if (has_num_output()) { ::google::protobuf::internal::WireFormatLite::WriteUInt32(1, this->num_output(), output); @@ -18872,13 +28602,13 @@ void InnerProductParameter::SerializeWithCachedSizes( // optional .caffe.FillerParameter weight_filler = 3; if (has_weight_filler()) { ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( - 3, this->weight_filler(), output); + 3, *this->weight_filler_, output); } // optional .caffe.FillerParameter bias_filler = 4; if (has_bias_filler()) { ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( - 4, this->bias_filler(), output); + 4, *this->bias_filler_, output); } // optional int32 axis = 5 [default = 1]; @@ -18886,14 +28616,17 @@ void InnerProductParameter::SerializeWithCachedSizes( ::google::protobuf::internal::WireFormatLite::WriteInt32(5, this->axis(), output); } - if (!unknown_fields().empty()) { + if (_internal_metadata_.have_unknown_fields()) { ::google::protobuf::internal::WireFormat::SerializeUnknownFields( unknown_fields(), output); } + // @@protoc_insertion_point(serialize_end:caffe.InnerProductParameter) } -::google::protobuf::uint8* InnerProductParameter::SerializeWithCachedSizesToArray( - ::google::protobuf::uint8* target) const { +::google::protobuf::uint8* InnerProductParameter::InternalSerializeWithCachedSizesToArray( + bool deterministic, ::google::protobuf::uint8* target) const { + (void)deterministic; // Unused + // @@protoc_insertion_point(serialize_to_array_start:caffe.InnerProductParameter) // optional uint32 num_output = 1; if (has_num_output()) { target = ::google::protobuf::internal::WireFormatLite::WriteUInt32ToArray(1, this->num_output(), target); @@ -18907,15 +28640,15 @@ void InnerProductParameter::SerializeWithCachedSizes( // optional .caffe.FillerParameter weight_filler = 3; if (has_weight_filler()) { target = ::google::protobuf::internal::WireFormatLite:: - WriteMessageNoVirtualToArray( - 3, this->weight_filler(), target); + InternalWriteMessageNoVirtualToArray( + 3, *this->weight_filler_, false, target); } // optional .caffe.FillerParameter bias_filler = 4; if (has_bias_filler()) { target = ::google::protobuf::internal::WireFormatLite:: - WriteMessageNoVirtualToArray( - 4, this->bias_filler(), target); + InternalWriteMessageNoVirtualToArray( + 4, *this->bias_filler_, false, target); } // optional int32 axis = 5 [default = 1]; @@ -18923,17 +28656,19 @@ void InnerProductParameter::SerializeWithCachedSizes( target = ::google::protobuf::internal::WireFormatLite::WriteInt32ToArray(5, this->axis(), target); } - if (!unknown_fields().empty()) { + if (_internal_metadata_.have_unknown_fields()) { target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray( unknown_fields(), target); } + // @@protoc_insertion_point(serialize_to_array_end:caffe.InnerProductParameter) return target; } -int InnerProductParameter::ByteSize() const { - int total_size = 0; +size_t InnerProductParameter::ByteSizeLong() const { +// @@protoc_insertion_point(message_byte_size_start:caffe.InnerProductParameter) + size_t total_size = 0; - if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) { + if (_has_bits_[0 / 32] & 31u) { // optional uint32 num_output = 1; if (has_num_output()) { total_size += 1 + @@ -18950,14 +28685,14 @@ int InnerProductParameter::ByteSize() const { if (has_weight_filler()) { total_size += 1 + ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( - this->weight_filler()); + *this->weight_filler_); } // optional .caffe.FillerParameter bias_filler = 4; if (has_bias_filler()) { total_size += 1 + ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( - this->bias_filler()); + *this->bias_filler_); } // optional int32 axis = 5 [default = 1]; @@ -18968,31 +28703,44 @@ int InnerProductParameter::ByteSize() const { } } - if (!unknown_fields().empty()) { + if (_internal_metadata_.have_unknown_fields()) { total_size += ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( unknown_fields()); } + int cached_size = ::google::protobuf::internal::ToCachedSize(total_size); GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); - _cached_size_ = total_size; + _cached_size_ = cached_size; GOOGLE_SAFE_CONCURRENT_WRITES_END(); return total_size; } void InnerProductParameter::MergeFrom(const ::google::protobuf::Message& from) { - GOOGLE_CHECK_NE(&from, this); +// @@protoc_insertion_point(generalized_merge_from_start:caffe.InnerProductParameter) + if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__); const InnerProductParameter* source = - ::google::protobuf::internal::dynamic_cast_if_available( - &from); + ::google::protobuf::internal::DynamicCastToGenerated( + &from); if (source == NULL) { + // @@protoc_insertion_point(generalized_merge_from_cast_fail:caffe.InnerProductParameter) ::google::protobuf::internal::ReflectionOps::Merge(from, this); } else { - MergeFrom(*source); + // @@protoc_insertion_point(generalized_merge_from_cast_success:caffe.InnerProductParameter) + UnsafeMergeFrom(*source); } } void InnerProductParameter::MergeFrom(const InnerProductParameter& from) { - GOOGLE_CHECK_NE(&from, this); +// @@protoc_insertion_point(class_specific_merge_from_start:caffe.InnerProductParameter) + if (GOOGLE_PREDICT_TRUE(&from != this)) { + UnsafeMergeFrom(from); + } else { + MergeFromFail(__LINE__); + } +} + +void InnerProductParameter::UnsafeMergeFrom(const InnerProductParameter& from) { + GOOGLE_DCHECK(&from != this); if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) { if (from.has_num_output()) { set_num_output(from.num_output()); @@ -19010,19 +28758,24 @@ void InnerProductParameter::MergeFrom(const InnerProductParameter& from) { set_axis(from.axis()); } } - mutable_unknown_fields()->MergeFrom(from.unknown_fields()); + if (from._internal_metadata_.have_unknown_fields()) { + ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata( + from.unknown_fields(), &_internal_metadata_); + } } void InnerProductParameter::CopyFrom(const ::google::protobuf::Message& from) { +// @@protoc_insertion_point(generalized_copy_from_start:caffe.InnerProductParameter) if (&from == this) return; Clear(); MergeFrom(from); } void InnerProductParameter::CopyFrom(const InnerProductParameter& from) { +// @@protoc_insertion_point(class_specific_copy_from_start:caffe.InnerProductParameter) if (&from == this) return; Clear(); - MergeFrom(from); + UnsafeMergeFrom(from); } bool InnerProductParameter::IsInitialized() const { @@ -19031,16 +28784,18 @@ bool InnerProductParameter::IsInitialized() const { } void InnerProductParameter::Swap(InnerProductParameter* other) { - if (other != this) { - std::swap(num_output_, other->num_output_); - std::swap(bias_term_, other->bias_term_); - std::swap(weight_filler_, other->weight_filler_); - std::swap(bias_filler_, other->bias_filler_); - std::swap(axis_, other->axis_); - std::swap(_has_bits_[0], other->_has_bits_[0]); - _unknown_fields_.Swap(&other->_unknown_fields_); - std::swap(_cached_size_, other->_cached_size_); - } + if (other == this) return; + InternalSwap(other); +} +void InnerProductParameter::InternalSwap(InnerProductParameter* other) { + std::swap(num_output_, other->num_output_); + std::swap(bias_term_, other->bias_term_); + std::swap(weight_filler_, other->weight_filler_); + std::swap(bias_filler_, other->bias_filler_); + std::swap(axis_, other->axis_); + std::swap(_has_bits_[0], other->_has_bits_[0]); + _internal_metadata_.Swap(&other->_internal_metadata_); + std::swap(_cached_size_, other->_cached_size_); } ::google::protobuf::Metadata InnerProductParameter::GetMetadata() const { @@ -19051,44 +28806,215 @@ void InnerProductParameter::Swap(InnerProductParameter* other) { return metadata; } +#if PROTOBUF_INLINE_NOT_IN_HEADERS +// InnerProductParameter + +// optional uint32 num_output = 1; +bool InnerProductParameter::has_num_output() const { + return (_has_bits_[0] & 0x00000001u) != 0; +} +void InnerProductParameter::set_has_num_output() { + _has_bits_[0] |= 0x00000001u; +} +void InnerProductParameter::clear_has_num_output() { + _has_bits_[0] &= ~0x00000001u; +} +void InnerProductParameter::clear_num_output() { + num_output_ = 0u; + clear_has_num_output(); +} +::google::protobuf::uint32 InnerProductParameter::num_output() const { + // @@protoc_insertion_point(field_get:caffe.InnerProductParameter.num_output) + return num_output_; +} +void InnerProductParameter::set_num_output(::google::protobuf::uint32 value) { + set_has_num_output(); + num_output_ = value; + // @@protoc_insertion_point(field_set:caffe.InnerProductParameter.num_output) +} + +// optional bool bias_term = 2 [default = true]; +bool InnerProductParameter::has_bias_term() const { + return (_has_bits_[0] & 0x00000002u) != 0; +} +void InnerProductParameter::set_has_bias_term() { + _has_bits_[0] |= 0x00000002u; +} +void InnerProductParameter::clear_has_bias_term() { + _has_bits_[0] &= ~0x00000002u; +} +void InnerProductParameter::clear_bias_term() { + bias_term_ = true; + clear_has_bias_term(); +} +bool InnerProductParameter::bias_term() const { + // @@protoc_insertion_point(field_get:caffe.InnerProductParameter.bias_term) + return bias_term_; +} +void InnerProductParameter::set_bias_term(bool value) { + set_has_bias_term(); + bias_term_ = value; + // @@protoc_insertion_point(field_set:caffe.InnerProductParameter.bias_term) +} + +// optional .caffe.FillerParameter weight_filler = 3; +bool InnerProductParameter::has_weight_filler() const { + return (_has_bits_[0] & 0x00000004u) != 0; +} +void InnerProductParameter::set_has_weight_filler() { + _has_bits_[0] |= 0x00000004u; +} +void InnerProductParameter::clear_has_weight_filler() { + _has_bits_[0] &= ~0x00000004u; +} +void InnerProductParameter::clear_weight_filler() { + if (weight_filler_ != NULL) weight_filler_->::caffe::FillerParameter::Clear(); + clear_has_weight_filler(); +} +const ::caffe::FillerParameter& InnerProductParameter::weight_filler() const { + // @@protoc_insertion_point(field_get:caffe.InnerProductParameter.weight_filler) + return weight_filler_ != NULL ? *weight_filler_ + : *::caffe::FillerParameter::internal_default_instance(); +} +::caffe::FillerParameter* InnerProductParameter::mutable_weight_filler() { + set_has_weight_filler(); + if (weight_filler_ == NULL) { + weight_filler_ = new ::caffe::FillerParameter; + } + // @@protoc_insertion_point(field_mutable:caffe.InnerProductParameter.weight_filler) + return weight_filler_; +} +::caffe::FillerParameter* InnerProductParameter::release_weight_filler() { + // @@protoc_insertion_point(field_release:caffe.InnerProductParameter.weight_filler) + clear_has_weight_filler(); + ::caffe::FillerParameter* temp = weight_filler_; + weight_filler_ = NULL; + return temp; +} +void InnerProductParameter::set_allocated_weight_filler(::caffe::FillerParameter* weight_filler) { + delete weight_filler_; + weight_filler_ = weight_filler; + if (weight_filler) { + set_has_weight_filler(); + } else { + clear_has_weight_filler(); + } + // @@protoc_insertion_point(field_set_allocated:caffe.InnerProductParameter.weight_filler) +} + +// optional .caffe.FillerParameter bias_filler = 4; +bool InnerProductParameter::has_bias_filler() const { + return (_has_bits_[0] & 0x00000008u) != 0; +} +void InnerProductParameter::set_has_bias_filler() { + _has_bits_[0] |= 0x00000008u; +} +void InnerProductParameter::clear_has_bias_filler() { + _has_bits_[0] &= ~0x00000008u; +} +void InnerProductParameter::clear_bias_filler() { + if (bias_filler_ != NULL) bias_filler_->::caffe::FillerParameter::Clear(); + clear_has_bias_filler(); +} +const ::caffe::FillerParameter& InnerProductParameter::bias_filler() const { + // @@protoc_insertion_point(field_get:caffe.InnerProductParameter.bias_filler) + return bias_filler_ != NULL ? *bias_filler_ + : *::caffe::FillerParameter::internal_default_instance(); +} +::caffe::FillerParameter* InnerProductParameter::mutable_bias_filler() { + set_has_bias_filler(); + if (bias_filler_ == NULL) { + bias_filler_ = new ::caffe::FillerParameter; + } + // @@protoc_insertion_point(field_mutable:caffe.InnerProductParameter.bias_filler) + return bias_filler_; +} +::caffe::FillerParameter* InnerProductParameter::release_bias_filler() { + // @@protoc_insertion_point(field_release:caffe.InnerProductParameter.bias_filler) + clear_has_bias_filler(); + ::caffe::FillerParameter* temp = bias_filler_; + bias_filler_ = NULL; + return temp; +} +void InnerProductParameter::set_allocated_bias_filler(::caffe::FillerParameter* bias_filler) { + delete bias_filler_; + bias_filler_ = bias_filler; + if (bias_filler) { + set_has_bias_filler(); + } else { + clear_has_bias_filler(); + } + // @@protoc_insertion_point(field_set_allocated:caffe.InnerProductParameter.bias_filler) +} + +// optional int32 axis = 5 [default = 1]; +bool InnerProductParameter::has_axis() const { + return (_has_bits_[0] & 0x00000010u) != 0; +} +void InnerProductParameter::set_has_axis() { + _has_bits_[0] |= 0x00000010u; +} +void InnerProductParameter::clear_has_axis() { + _has_bits_[0] &= ~0x00000010u; +} +void InnerProductParameter::clear_axis() { + axis_ = 1; + clear_has_axis(); +} +::google::protobuf::int32 InnerProductParameter::axis() const { + // @@protoc_insertion_point(field_get:caffe.InnerProductParameter.axis) + return axis_; +} +void InnerProductParameter::set_axis(::google::protobuf::int32 value) { + set_has_axis(); + axis_ = value; + // @@protoc_insertion_point(field_set:caffe.InnerProductParameter.axis) +} + +inline const InnerProductParameter* InnerProductParameter::internal_default_instance() { + return &InnerProductParameter_default_instance_.get(); +} +#endif // PROTOBUF_INLINE_NOT_IN_HEADERS // =================================================================== -#ifndef _MSC_VER +#if !defined(_MSC_VER) || _MSC_VER >= 1900 const int LogParameter::kBaseFieldNumber; const int LogParameter::kScaleFieldNumber; const int LogParameter::kShiftFieldNumber; -#endif // !_MSC_VER +#endif // !defined(_MSC_VER) || _MSC_VER >= 1900 LogParameter::LogParameter() - : ::google::protobuf::Message() { + : ::google::protobuf::Message(), _internal_metadata_(NULL) { + if (this != internal_default_instance()) protobuf_InitDefaults_caffe_2eproto(); SharedCtor(); + // @@protoc_insertion_point(constructor:caffe.LogParameter) } void LogParameter::InitAsDefaultInstance() { } LogParameter::LogParameter(const LogParameter& from) - : ::google::protobuf::Message() { + : ::google::protobuf::Message(), + _internal_metadata_(NULL) { SharedCtor(); - MergeFrom(from); + UnsafeMergeFrom(from); + // @@protoc_insertion_point(copy_constructor:caffe.LogParameter) } void LogParameter::SharedCtor() { _cached_size_ = 0; + shift_ = 0; base_ = -1; scale_ = 1; - shift_ = 0; - ::memset(_has_bits_, 0, sizeof(_has_bits_)); } LogParameter::~LogParameter() { + // @@protoc_insertion_point(destructor:caffe.LogParameter) SharedDtor(); } void LogParameter::SharedDtor() { - if (this != default_instance_) { - } } void LogParameter::SetCachedSize(int size) const { @@ -19102,42 +29028,52 @@ const ::google::protobuf::Descriptor* LogParameter::descriptor() { } const LogParameter& LogParameter::default_instance() { - if (default_instance_ == NULL) protobuf_AddDesc_caffe_2eproto(); - return *default_instance_; + protobuf_InitDefaults_caffe_2eproto(); + return *internal_default_instance(); } -LogParameter* LogParameter::default_instance_ = NULL; +::google::protobuf::internal::ExplicitlyConstructed LogParameter_default_instance_; -LogParameter* LogParameter::New() const { - return new LogParameter; +LogParameter* LogParameter::New(::google::protobuf::Arena* arena) const { + LogParameter* n = new LogParameter; + if (arena != NULL) { + arena->Own(n); + } + return n; } void LogParameter::Clear() { - if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) { +// @@protoc_insertion_point(message_clear_start:caffe.LogParameter) + if (_has_bits_[0 / 32] & 7u) { base_ = -1; scale_ = 1; shift_ = 0; } - ::memset(_has_bits_, 0, sizeof(_has_bits_)); - mutable_unknown_fields()->Clear(); + _has_bits_.Clear(); + if (_internal_metadata_.have_unknown_fields()) { + mutable_unknown_fields()->Clear(); + } } bool LogParameter::MergePartialFromCodedStream( ::google::protobuf::io::CodedInputStream* input) { -#define DO_(EXPRESSION) if (!(EXPRESSION)) return false +#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure ::google::protobuf::uint32 tag; - while ((tag = input->ReadTag()) != 0) { + // @@protoc_insertion_point(parse_start:caffe.LogParameter) + for (;;) { + ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127); + tag = p.first; + if (!p.second) goto handle_unusual; switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { // optional float base = 1 [default = -1]; case 1: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_FIXED32) { + if (tag == 13) { + set_has_base(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< float, ::google::protobuf::internal::WireFormatLite::TYPE_FLOAT>( input, &base_))); - set_has_base(); } else { - goto handle_uninterpreted; + goto handle_unusual; } if (input->ExpectTag(21)) goto parse_scale; break; @@ -19145,15 +29081,14 @@ bool LogParameter::MergePartialFromCodedStream( // optional float scale = 2 [default = 1]; case 2: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_FIXED32) { + if (tag == 21) { parse_scale: + set_has_scale(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< float, ::google::protobuf::internal::WireFormatLite::TYPE_FLOAT>( input, &scale_))); - set_has_scale(); } else { - goto handle_uninterpreted; + goto handle_unusual; } if (input->ExpectTag(29)) goto parse_shift; break; @@ -19161,25 +29096,25 @@ bool LogParameter::MergePartialFromCodedStream( // optional float shift = 3 [default = 0]; case 3: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_FIXED32) { + if (tag == 29) { parse_shift: + set_has_shift(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< float, ::google::protobuf::internal::WireFormatLite::TYPE_FLOAT>( input, &shift_))); - set_has_shift(); } else { - goto handle_uninterpreted; + goto handle_unusual; } - if (input->ExpectAtEnd()) return true; + if (input->ExpectAtEnd()) goto success; break; } default: { - handle_uninterpreted: - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == + handle_unusual: + if (tag == 0 || + ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) { - return true; + goto success; } DO_(::google::protobuf::internal::WireFormat::SkipField( input, tag, mutable_unknown_fields())); @@ -19187,12 +29122,18 @@ bool LogParameter::MergePartialFromCodedStream( } } } +success: + // @@protoc_insertion_point(parse_success:caffe.LogParameter) return true; +failure: + // @@protoc_insertion_point(parse_failure:caffe.LogParameter) + return false; #undef DO_ } void LogParameter::SerializeWithCachedSizes( ::google::protobuf::io::CodedOutputStream* output) const { + // @@protoc_insertion_point(serialize_start:caffe.LogParameter) // optional float base = 1 [default = -1]; if (has_base()) { ::google::protobuf::internal::WireFormatLite::WriteFloat(1, this->base(), output); @@ -19208,14 +29149,17 @@ void LogParameter::SerializeWithCachedSizes( ::google::protobuf::internal::WireFormatLite::WriteFloat(3, this->shift(), output); } - if (!unknown_fields().empty()) { + if (_internal_metadata_.have_unknown_fields()) { ::google::protobuf::internal::WireFormat::SerializeUnknownFields( unknown_fields(), output); } + // @@protoc_insertion_point(serialize_end:caffe.LogParameter) } -::google::protobuf::uint8* LogParameter::SerializeWithCachedSizesToArray( - ::google::protobuf::uint8* target) const { +::google::protobuf::uint8* LogParameter::InternalSerializeWithCachedSizesToArray( + bool deterministic, ::google::protobuf::uint8* target) const { + (void)deterministic; // Unused + // @@protoc_insertion_point(serialize_to_array_start:caffe.LogParameter) // optional float base = 1 [default = -1]; if (has_base()) { target = ::google::protobuf::internal::WireFormatLite::WriteFloatToArray(1, this->base(), target); @@ -19231,17 +29175,19 @@ void LogParameter::SerializeWithCachedSizes( target = ::google::protobuf::internal::WireFormatLite::WriteFloatToArray(3, this->shift(), target); } - if (!unknown_fields().empty()) { + if (_internal_metadata_.have_unknown_fields()) { target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray( unknown_fields(), target); } + // @@protoc_insertion_point(serialize_to_array_end:caffe.LogParameter) return target; } -int LogParameter::ByteSize() const { - int total_size = 0; +size_t LogParameter::ByteSizeLong() const { +// @@protoc_insertion_point(message_byte_size_start:caffe.LogParameter) + size_t total_size = 0; - if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) { + if (_has_bits_[0 / 32] & 7u) { // optional float base = 1 [default = -1]; if (has_base()) { total_size += 1 + 4; @@ -19258,31 +29204,44 @@ int LogParameter::ByteSize() const { } } - if (!unknown_fields().empty()) { + if (_internal_metadata_.have_unknown_fields()) { total_size += ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( unknown_fields()); } + int cached_size = ::google::protobuf::internal::ToCachedSize(total_size); GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); - _cached_size_ = total_size; + _cached_size_ = cached_size; GOOGLE_SAFE_CONCURRENT_WRITES_END(); return total_size; } void LogParameter::MergeFrom(const ::google::protobuf::Message& from) { - GOOGLE_CHECK_NE(&from, this); +// @@protoc_insertion_point(generalized_merge_from_start:caffe.LogParameter) + if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__); const LogParameter* source = - ::google::protobuf::internal::dynamic_cast_if_available( - &from); + ::google::protobuf::internal::DynamicCastToGenerated( + &from); if (source == NULL) { + // @@protoc_insertion_point(generalized_merge_from_cast_fail:caffe.LogParameter) ::google::protobuf::internal::ReflectionOps::Merge(from, this); } else { - MergeFrom(*source); + // @@protoc_insertion_point(generalized_merge_from_cast_success:caffe.LogParameter) + UnsafeMergeFrom(*source); } } void LogParameter::MergeFrom(const LogParameter& from) { - GOOGLE_CHECK_NE(&from, this); +// @@protoc_insertion_point(class_specific_merge_from_start:caffe.LogParameter) + if (GOOGLE_PREDICT_TRUE(&from != this)) { + UnsafeMergeFrom(from); + } else { + MergeFromFail(__LINE__); + } +} + +void LogParameter::UnsafeMergeFrom(const LogParameter& from) { + GOOGLE_DCHECK(&from != this); if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) { if (from.has_base()) { set_base(from.base()); @@ -19294,19 +29253,24 @@ void LogParameter::MergeFrom(const LogParameter& from) { set_shift(from.shift()); } } - mutable_unknown_fields()->MergeFrom(from.unknown_fields()); + if (from._internal_metadata_.have_unknown_fields()) { + ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata( + from.unknown_fields(), &_internal_metadata_); + } } void LogParameter::CopyFrom(const ::google::protobuf::Message& from) { +// @@protoc_insertion_point(generalized_copy_from_start:caffe.LogParameter) if (&from == this) return; Clear(); MergeFrom(from); } void LogParameter::CopyFrom(const LogParameter& from) { +// @@protoc_insertion_point(class_specific_copy_from_start:caffe.LogParameter) if (&from == this) return; Clear(); - MergeFrom(from); + UnsafeMergeFrom(from); } bool LogParameter::IsInitialized() const { @@ -19315,14 +29279,16 @@ bool LogParameter::IsInitialized() const { } void LogParameter::Swap(LogParameter* other) { - if (other != this) { - std::swap(base_, other->base_); - std::swap(scale_, other->scale_); - std::swap(shift_, other->shift_); - std::swap(_has_bits_[0], other->_has_bits_[0]); - _unknown_fields_.Swap(&other->_unknown_fields_); - std::swap(_cached_size_, other->_cached_size_); - } + if (other == this) return; + InternalSwap(other); +} +void LogParameter::InternalSwap(LogParameter* other) { + std::swap(base_, other->base_); + std::swap(scale_, other->scale_); + std::swap(shift_, other->shift_); + std::swap(_has_bits_[0], other->_has_bits_[0]); + _internal_metadata_.Swap(&other->_internal_metadata_); + std::swap(_cached_size_, other->_cached_size_); } ::google::protobuf::Metadata LogParameter::GetMetadata() const { @@ -19333,6 +29299,85 @@ void LogParameter::Swap(LogParameter* other) { return metadata; } +#if PROTOBUF_INLINE_NOT_IN_HEADERS +// LogParameter + +// optional float base = 1 [default = -1]; +bool LogParameter::has_base() const { + return (_has_bits_[0] & 0x00000001u) != 0; +} +void LogParameter::set_has_base() { + _has_bits_[0] |= 0x00000001u; +} +void LogParameter::clear_has_base() { + _has_bits_[0] &= ~0x00000001u; +} +void LogParameter::clear_base() { + base_ = -1; + clear_has_base(); +} +float LogParameter::base() const { + // @@protoc_insertion_point(field_get:caffe.LogParameter.base) + return base_; +} +void LogParameter::set_base(float value) { + set_has_base(); + base_ = value; + // @@protoc_insertion_point(field_set:caffe.LogParameter.base) +} + +// optional float scale = 2 [default = 1]; +bool LogParameter::has_scale() const { + return (_has_bits_[0] & 0x00000002u) != 0; +} +void LogParameter::set_has_scale() { + _has_bits_[0] |= 0x00000002u; +} +void LogParameter::clear_has_scale() { + _has_bits_[0] &= ~0x00000002u; +} +void LogParameter::clear_scale() { + scale_ = 1; + clear_has_scale(); +} +float LogParameter::scale() const { + // @@protoc_insertion_point(field_get:caffe.LogParameter.scale) + return scale_; +} +void LogParameter::set_scale(float value) { + set_has_scale(); + scale_ = value; + // @@protoc_insertion_point(field_set:caffe.LogParameter.scale) +} + +// optional float shift = 3 [default = 0]; +bool LogParameter::has_shift() const { + return (_has_bits_[0] & 0x00000004u) != 0; +} +void LogParameter::set_has_shift() { + _has_bits_[0] |= 0x00000004u; +} +void LogParameter::clear_has_shift() { + _has_bits_[0] &= ~0x00000004u; +} +void LogParameter::clear_shift() { + shift_ = 0; + clear_has_shift(); +} +float LogParameter::shift() const { + // @@protoc_insertion_point(field_get:caffe.LogParameter.shift) + return shift_; +} +void LogParameter::set_shift(float value) { + set_has_shift(); + shift_ = value; + // @@protoc_insertion_point(field_set:caffe.LogParameter.shift) +} + +inline const LogParameter* LogParameter::internal_default_instance() { + return &LogParameter_default_instance_.get(); +} +#endif // PROTOBUF_INLINE_NOT_IN_HEADERS // =================================================================== @@ -19341,7 +29386,7 @@ const ::google::protobuf::EnumDescriptor* LRNParameter_NormRegion_descriptor() { return LRNParameter_NormRegion_descriptor_; } bool LRNParameter_NormRegion_IsValid(int value) { - switch(value) { + switch (value) { case 0: case 1: return true; @@ -19350,52 +29395,54 @@ bool LRNParameter_NormRegion_IsValid(int value) { } } -#ifndef _MSC_VER +#if !defined(_MSC_VER) || _MSC_VER >= 1900 const LRNParameter_NormRegion LRNParameter::ACROSS_CHANNELS; const LRNParameter_NormRegion LRNParameter::WITHIN_CHANNEL; const LRNParameter_NormRegion LRNParameter::NormRegion_MIN; const LRNParameter_NormRegion LRNParameter::NormRegion_MAX; const int LRNParameter::NormRegion_ARRAYSIZE; -#endif // _MSC_VER -#ifndef _MSC_VER +#endif // !defined(_MSC_VER) || _MSC_VER >= 1900 +#if !defined(_MSC_VER) || _MSC_VER >= 1900 const int LRNParameter::kLocalSizeFieldNumber; const int LRNParameter::kAlphaFieldNumber; const int LRNParameter::kBetaFieldNumber; const int LRNParameter::kNormRegionFieldNumber; const int LRNParameter::kKFieldNumber; -#endif // !_MSC_VER +#endif // !defined(_MSC_VER) || _MSC_VER >= 1900 LRNParameter::LRNParameter() - : ::google::protobuf::Message() { + : ::google::protobuf::Message(), _internal_metadata_(NULL) { + if (this != internal_default_instance()) protobuf_InitDefaults_caffe_2eproto(); SharedCtor(); + // @@protoc_insertion_point(constructor:caffe.LRNParameter) } void LRNParameter::InitAsDefaultInstance() { } LRNParameter::LRNParameter(const LRNParameter& from) - : ::google::protobuf::Message() { + : ::google::protobuf::Message(), + _internal_metadata_(NULL) { SharedCtor(); - MergeFrom(from); + UnsafeMergeFrom(from); + // @@protoc_insertion_point(copy_constructor:caffe.LRNParameter) } void LRNParameter::SharedCtor() { _cached_size_ = 0; + norm_region_ = 0; local_size_ = 5u; alpha_ = 1; beta_ = 0.75f; - norm_region_ = 0; k_ = 1; - ::memset(_has_bits_, 0, sizeof(_has_bits_)); } LRNParameter::~LRNParameter() { + // @@protoc_insertion_point(destructor:caffe.LRNParameter) SharedDtor(); } void LRNParameter::SharedDtor() { - if (this != default_instance_) { - } } void LRNParameter::SetCachedSize(int size) const { @@ -19409,44 +29456,54 @@ const ::google::protobuf::Descriptor* LRNParameter::descriptor() { } const LRNParameter& LRNParameter::default_instance() { - if (default_instance_ == NULL) protobuf_AddDesc_caffe_2eproto(); - return *default_instance_; + protobuf_InitDefaults_caffe_2eproto(); + return *internal_default_instance(); } -LRNParameter* LRNParameter::default_instance_ = NULL; +::google::protobuf::internal::ExplicitlyConstructed LRNParameter_default_instance_; -LRNParameter* LRNParameter::New() const { - return new LRNParameter; +LRNParameter* LRNParameter::New(::google::protobuf::Arena* arena) const { + LRNParameter* n = new LRNParameter; + if (arena != NULL) { + arena->Own(n); + } + return n; } void LRNParameter::Clear() { - if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) { +// @@protoc_insertion_point(message_clear_start:caffe.LRNParameter) + if (_has_bits_[0 / 32] & 31u) { local_size_ = 5u; alpha_ = 1; beta_ = 0.75f; norm_region_ = 0; k_ = 1; } - ::memset(_has_bits_, 0, sizeof(_has_bits_)); - mutable_unknown_fields()->Clear(); + _has_bits_.Clear(); + if (_internal_metadata_.have_unknown_fields()) { + mutable_unknown_fields()->Clear(); + } } bool LRNParameter::MergePartialFromCodedStream( ::google::protobuf::io::CodedInputStream* input) { -#define DO_(EXPRESSION) if (!(EXPRESSION)) return false +#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure ::google::protobuf::uint32 tag; - while ((tag = input->ReadTag()) != 0) { + // @@protoc_insertion_point(parse_start:caffe.LRNParameter) + for (;;) { + ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127); + tag = p.first; + if (!p.second) goto handle_unusual; switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { // optional uint32 local_size = 1 [default = 5]; case 1: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) { + if (tag == 8) { + set_has_local_size(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>( input, &local_size_))); - set_has_local_size(); } else { - goto handle_uninterpreted; + goto handle_unusual; } if (input->ExpectTag(21)) goto parse_alpha; break; @@ -19454,15 +29511,14 @@ bool LRNParameter::MergePartialFromCodedStream( // optional float alpha = 2 [default = 1]; case 2: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_FIXED32) { + if (tag == 21) { parse_alpha: + set_has_alpha(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< float, ::google::protobuf::internal::WireFormatLite::TYPE_FLOAT>( input, &alpha_))); - set_has_alpha(); } else { - goto handle_uninterpreted; + goto handle_unusual; } if (input->ExpectTag(29)) goto parse_beta; break; @@ -19470,15 +29526,14 @@ bool LRNParameter::MergePartialFromCodedStream( // optional float beta = 3 [default = 0.75]; case 3: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_FIXED32) { + if (tag == 29) { parse_beta: + set_has_beta(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< float, ::google::protobuf::internal::WireFormatLite::TYPE_FLOAT>( input, &beta_))); - set_has_beta(); } else { - goto handle_uninterpreted; + goto handle_unusual; } if (input->ExpectTag(32)) goto parse_norm_region; break; @@ -19486,8 +29541,7 @@ bool LRNParameter::MergePartialFromCodedStream( // optional .caffe.LRNParameter.NormRegion norm_region = 4 [default = ACROSS_CHANNELS]; case 4: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) { + if (tag == 32) { parse_norm_region: int value; DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< @@ -19499,7 +29553,7 @@ bool LRNParameter::MergePartialFromCodedStream( mutable_unknown_fields()->AddVarint(4, value); } } else { - goto handle_uninterpreted; + goto handle_unusual; } if (input->ExpectTag(45)) goto parse_k; break; @@ -19507,25 +29561,25 @@ bool LRNParameter::MergePartialFromCodedStream( // optional float k = 5 [default = 1]; case 5: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_FIXED32) { + if (tag == 45) { parse_k: + set_has_k(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< float, ::google::protobuf::internal::WireFormatLite::TYPE_FLOAT>( input, &k_))); - set_has_k(); } else { - goto handle_uninterpreted; + goto handle_unusual; } - if (input->ExpectAtEnd()) return true; + if (input->ExpectAtEnd()) goto success; break; } default: { - handle_uninterpreted: - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == + handle_unusual: + if (tag == 0 || + ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) { - return true; + goto success; } DO_(::google::protobuf::internal::WireFormat::SkipField( input, tag, mutable_unknown_fields())); @@ -19533,12 +29587,18 @@ bool LRNParameter::MergePartialFromCodedStream( } } } +success: + // @@protoc_insertion_point(parse_success:caffe.LRNParameter) return true; +failure: + // @@protoc_insertion_point(parse_failure:caffe.LRNParameter) + return false; #undef DO_ } void LRNParameter::SerializeWithCachedSizes( ::google::protobuf::io::CodedOutputStream* output) const { + // @@protoc_insertion_point(serialize_start:caffe.LRNParameter) // optional uint32 local_size = 1 [default = 5]; if (has_local_size()) { ::google::protobuf::internal::WireFormatLite::WriteUInt32(1, this->local_size(), output); @@ -19565,14 +29625,17 @@ void LRNParameter::SerializeWithCachedSizes( ::google::protobuf::internal::WireFormatLite::WriteFloat(5, this->k(), output); } - if (!unknown_fields().empty()) { + if (_internal_metadata_.have_unknown_fields()) { ::google::protobuf::internal::WireFormat::SerializeUnknownFields( unknown_fields(), output); } + // @@protoc_insertion_point(serialize_end:caffe.LRNParameter) } -::google::protobuf::uint8* LRNParameter::SerializeWithCachedSizesToArray( - ::google::protobuf::uint8* target) const { +::google::protobuf::uint8* LRNParameter::InternalSerializeWithCachedSizesToArray( + bool deterministic, ::google::protobuf::uint8* target) const { + (void)deterministic; // Unused + // @@protoc_insertion_point(serialize_to_array_start:caffe.LRNParameter) // optional uint32 local_size = 1 [default = 5]; if (has_local_size()) { target = ::google::protobuf::internal::WireFormatLite::WriteUInt32ToArray(1, this->local_size(), target); @@ -19599,17 +29662,19 @@ void LRNParameter::SerializeWithCachedSizes( target = ::google::protobuf::internal::WireFormatLite::WriteFloatToArray(5, this->k(), target); } - if (!unknown_fields().empty()) { + if (_internal_metadata_.have_unknown_fields()) { target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray( unknown_fields(), target); } + // @@protoc_insertion_point(serialize_to_array_end:caffe.LRNParameter) return target; } -int LRNParameter::ByteSize() const { - int total_size = 0; +size_t LRNParameter::ByteSizeLong() const { +// @@protoc_insertion_point(message_byte_size_start:caffe.LRNParameter) + size_t total_size = 0; - if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) { + if (_has_bits_[0 / 32] & 31u) { // optional uint32 local_size = 1 [default = 5]; if (has_local_size()) { total_size += 1 + @@ -19639,31 +29704,44 @@ int LRNParameter::ByteSize() const { } } - if (!unknown_fields().empty()) { + if (_internal_metadata_.have_unknown_fields()) { total_size += ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( unknown_fields()); } + int cached_size = ::google::protobuf::internal::ToCachedSize(total_size); GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); - _cached_size_ = total_size; + _cached_size_ = cached_size; GOOGLE_SAFE_CONCURRENT_WRITES_END(); return total_size; } void LRNParameter::MergeFrom(const ::google::protobuf::Message& from) { - GOOGLE_CHECK_NE(&from, this); +// @@protoc_insertion_point(generalized_merge_from_start:caffe.LRNParameter) + if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__); const LRNParameter* source = - ::google::protobuf::internal::dynamic_cast_if_available( - &from); + ::google::protobuf::internal::DynamicCastToGenerated( + &from); if (source == NULL) { + // @@protoc_insertion_point(generalized_merge_from_cast_fail:caffe.LRNParameter) ::google::protobuf::internal::ReflectionOps::Merge(from, this); } else { - MergeFrom(*source); + // @@protoc_insertion_point(generalized_merge_from_cast_success:caffe.LRNParameter) + UnsafeMergeFrom(*source); + } +} + +void LRNParameter::MergeFrom(const LRNParameter& from) { +// @@protoc_insertion_point(class_specific_merge_from_start:caffe.LRNParameter) + if (GOOGLE_PREDICT_TRUE(&from != this)) { + UnsafeMergeFrom(from); + } else { + MergeFromFail(__LINE__); } } -void LRNParameter::MergeFrom(const LRNParameter& from) { - GOOGLE_CHECK_NE(&from, this); +void LRNParameter::UnsafeMergeFrom(const LRNParameter& from) { + GOOGLE_DCHECK(&from != this); if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) { if (from.has_local_size()) { set_local_size(from.local_size()); @@ -19681,19 +29759,24 @@ void LRNParameter::MergeFrom(const LRNParameter& from) { set_k(from.k()); } } - mutable_unknown_fields()->MergeFrom(from.unknown_fields()); + if (from._internal_metadata_.have_unknown_fields()) { + ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata( + from.unknown_fields(), &_internal_metadata_); + } } void LRNParameter::CopyFrom(const ::google::protobuf::Message& from) { +// @@protoc_insertion_point(generalized_copy_from_start:caffe.LRNParameter) if (&from == this) return; Clear(); MergeFrom(from); } void LRNParameter::CopyFrom(const LRNParameter& from) { +// @@protoc_insertion_point(class_specific_copy_from_start:caffe.LRNParameter) if (&from == this) return; Clear(); - MergeFrom(from); + UnsafeMergeFrom(from); } bool LRNParameter::IsInitialized() const { @@ -19702,16 +29785,18 @@ bool LRNParameter::IsInitialized() const { } void LRNParameter::Swap(LRNParameter* other) { - if (other != this) { - std::swap(local_size_, other->local_size_); - std::swap(alpha_, other->alpha_); - std::swap(beta_, other->beta_); - std::swap(norm_region_, other->norm_region_); - std::swap(k_, other->k_); - std::swap(_has_bits_[0], other->_has_bits_[0]); - _unknown_fields_.Swap(&other->_unknown_fields_); - std::swap(_cached_size_, other->_cached_size_); - } + if (other == this) return; + InternalSwap(other); +} +void LRNParameter::InternalSwap(LRNParameter* other) { + std::swap(local_size_, other->local_size_); + std::swap(alpha_, other->alpha_); + std::swap(beta_, other->beta_); + std::swap(norm_region_, other->norm_region_); + std::swap(k_, other->k_); + std::swap(_has_bits_[0], other->_has_bits_[0]); + _internal_metadata_.Swap(&other->_internal_metadata_); + std::swap(_cached_size_, other->_cached_size_); } ::google::protobuf::Metadata LRNParameter::GetMetadata() const { @@ -19722,46 +29807,174 @@ void LRNParameter::Swap(LRNParameter* other) { return metadata; } +#if PROTOBUF_INLINE_NOT_IN_HEADERS +// LRNParameter + +// optional uint32 local_size = 1 [default = 5]; +bool LRNParameter::has_local_size() const { + return (_has_bits_[0] & 0x00000001u) != 0; +} +void LRNParameter::set_has_local_size() { + _has_bits_[0] |= 0x00000001u; +} +void LRNParameter::clear_has_local_size() { + _has_bits_[0] &= ~0x00000001u; +} +void LRNParameter::clear_local_size() { + local_size_ = 5u; + clear_has_local_size(); +} +::google::protobuf::uint32 LRNParameter::local_size() const { + // @@protoc_insertion_point(field_get:caffe.LRNParameter.local_size) + return local_size_; +} +void LRNParameter::set_local_size(::google::protobuf::uint32 value) { + set_has_local_size(); + local_size_ = value; + // @@protoc_insertion_point(field_set:caffe.LRNParameter.local_size) +} + +// optional float alpha = 2 [default = 1]; +bool LRNParameter::has_alpha() const { + return (_has_bits_[0] & 0x00000002u) != 0; +} +void LRNParameter::set_has_alpha() { + _has_bits_[0] |= 0x00000002u; +} +void LRNParameter::clear_has_alpha() { + _has_bits_[0] &= ~0x00000002u; +} +void LRNParameter::clear_alpha() { + alpha_ = 1; + clear_has_alpha(); +} +float LRNParameter::alpha() const { + // @@protoc_insertion_point(field_get:caffe.LRNParameter.alpha) + return alpha_; +} +void LRNParameter::set_alpha(float value) { + set_has_alpha(); + alpha_ = value; + // @@protoc_insertion_point(field_set:caffe.LRNParameter.alpha) +} + +// optional float beta = 3 [default = 0.75]; +bool LRNParameter::has_beta() const { + return (_has_bits_[0] & 0x00000004u) != 0; +} +void LRNParameter::set_has_beta() { + _has_bits_[0] |= 0x00000004u; +} +void LRNParameter::clear_has_beta() { + _has_bits_[0] &= ~0x00000004u; +} +void LRNParameter::clear_beta() { + beta_ = 0.75f; + clear_has_beta(); +} +float LRNParameter::beta() const { + // @@protoc_insertion_point(field_get:caffe.LRNParameter.beta) + return beta_; +} +void LRNParameter::set_beta(float value) { + set_has_beta(); + beta_ = value; + // @@protoc_insertion_point(field_set:caffe.LRNParameter.beta) +} + +// optional .caffe.LRNParameter.NormRegion norm_region = 4 [default = ACROSS_CHANNELS]; +bool LRNParameter::has_norm_region() const { + return (_has_bits_[0] & 0x00000008u) != 0; +} +void LRNParameter::set_has_norm_region() { + _has_bits_[0] |= 0x00000008u; +} +void LRNParameter::clear_has_norm_region() { + _has_bits_[0] &= ~0x00000008u; +} +void LRNParameter::clear_norm_region() { + norm_region_ = 0; + clear_has_norm_region(); +} +::caffe::LRNParameter_NormRegion LRNParameter::norm_region() const { + // @@protoc_insertion_point(field_get:caffe.LRNParameter.norm_region) + return static_cast< ::caffe::LRNParameter_NormRegion >(norm_region_); +} +void LRNParameter::set_norm_region(::caffe::LRNParameter_NormRegion value) { + assert(::caffe::LRNParameter_NormRegion_IsValid(value)); + set_has_norm_region(); + norm_region_ = value; + // @@protoc_insertion_point(field_set:caffe.LRNParameter.norm_region) +} + +// optional float k = 5 [default = 1]; +bool LRNParameter::has_k() const { + return (_has_bits_[0] & 0x00000010u) != 0; +} +void LRNParameter::set_has_k() { + _has_bits_[0] |= 0x00000010u; +} +void LRNParameter::clear_has_k() { + _has_bits_[0] &= ~0x00000010u; +} +void LRNParameter::clear_k() { + k_ = 1; + clear_has_k(); +} +float LRNParameter::k() const { + // @@protoc_insertion_point(field_get:caffe.LRNParameter.k) + return k_; +} +void LRNParameter::set_k(float value) { + set_has_k(); + k_ = value; + // @@protoc_insertion_point(field_set:caffe.LRNParameter.k) +} + +inline const LRNParameter* LRNParameter::internal_default_instance() { + return &LRNParameter_default_instance_.get(); +} +#endif // PROTOBUF_INLINE_NOT_IN_HEADERS // =================================================================== -#ifndef _MSC_VER +#if !defined(_MSC_VER) || _MSC_VER >= 1900 const int MemoryDataParameter::kBatchSizeFieldNumber; const int MemoryDataParameter::kChannelsFieldNumber; const int MemoryDataParameter::kHeightFieldNumber; const int MemoryDataParameter::kWidthFieldNumber; -#endif // !_MSC_VER +#endif // !defined(_MSC_VER) || _MSC_VER >= 1900 MemoryDataParameter::MemoryDataParameter() - : ::google::protobuf::Message() { + : ::google::protobuf::Message(), _internal_metadata_(NULL) { + if (this != internal_default_instance()) protobuf_InitDefaults_caffe_2eproto(); SharedCtor(); + // @@protoc_insertion_point(constructor:caffe.MemoryDataParameter) } void MemoryDataParameter::InitAsDefaultInstance() { } MemoryDataParameter::MemoryDataParameter(const MemoryDataParameter& from) - : ::google::protobuf::Message() { + : ::google::protobuf::Message(), + _internal_metadata_(NULL) { SharedCtor(); - MergeFrom(from); + UnsafeMergeFrom(from); + // @@protoc_insertion_point(copy_constructor:caffe.MemoryDataParameter) } void MemoryDataParameter::SharedCtor() { _cached_size_ = 0; - batch_size_ = 0u; - channels_ = 0u; - height_ = 0u; - width_ = 0u; - ::memset(_has_bits_, 0, sizeof(_has_bits_)); + ::memset(&batch_size_, 0, reinterpret_cast(&width_) - + reinterpret_cast(&batch_size_) + sizeof(width_)); } MemoryDataParameter::~MemoryDataParameter() { + // @@protoc_insertion_point(destructor:caffe.MemoryDataParameter) SharedDtor(); } void MemoryDataParameter::SharedDtor() { - if (this != default_instance_) { - } } void MemoryDataParameter::SetCachedSize(int size) const { @@ -19775,43 +29988,68 @@ const ::google::protobuf::Descriptor* MemoryDataParameter::descriptor() { } const MemoryDataParameter& MemoryDataParameter::default_instance() { - if (default_instance_ == NULL) protobuf_AddDesc_caffe_2eproto(); - return *default_instance_; + protobuf_InitDefaults_caffe_2eproto(); + return *internal_default_instance(); } -MemoryDataParameter* MemoryDataParameter::default_instance_ = NULL; +::google::protobuf::internal::ExplicitlyConstructed MemoryDataParameter_default_instance_; -MemoryDataParameter* MemoryDataParameter::New() const { - return new MemoryDataParameter; +MemoryDataParameter* MemoryDataParameter::New(::google::protobuf::Arena* arena) const { + MemoryDataParameter* n = new MemoryDataParameter; + if (arena != NULL) { + arena->Own(n); + } + return n; } void MemoryDataParameter::Clear() { - if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) { - batch_size_ = 0u; - channels_ = 0u; - height_ = 0u; - width_ = 0u; +// @@protoc_insertion_point(message_clear_start:caffe.MemoryDataParameter) +#if defined(__clang__) +#define ZR_HELPER_(f) \ + _Pragma("clang diagnostic push") \ + _Pragma("clang diagnostic ignored \"-Winvalid-offsetof\"") \ + __builtin_offsetof(MemoryDataParameter, f) \ + _Pragma("clang diagnostic pop") +#else +#define ZR_HELPER_(f) reinterpret_cast(\ + &reinterpret_cast(16)->f) +#endif + +#define ZR_(first, last) do {\ + ::memset(&(first), 0,\ + ZR_HELPER_(last) - ZR_HELPER_(first) + sizeof(last));\ +} while (0) + + ZR_(batch_size_, width_); + +#undef ZR_HELPER_ +#undef ZR_ + + _has_bits_.Clear(); + if (_internal_metadata_.have_unknown_fields()) { + mutable_unknown_fields()->Clear(); } - ::memset(_has_bits_, 0, sizeof(_has_bits_)); - mutable_unknown_fields()->Clear(); } bool MemoryDataParameter::MergePartialFromCodedStream( ::google::protobuf::io::CodedInputStream* input) { -#define DO_(EXPRESSION) if (!(EXPRESSION)) return false +#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure ::google::protobuf::uint32 tag; - while ((tag = input->ReadTag()) != 0) { + // @@protoc_insertion_point(parse_start:caffe.MemoryDataParameter) + for (;;) { + ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127); + tag = p.first; + if (!p.second) goto handle_unusual; switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { // optional uint32 batch_size = 1; case 1: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) { + if (tag == 8) { + set_has_batch_size(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>( input, &batch_size_))); - set_has_batch_size(); } else { - goto handle_uninterpreted; + goto handle_unusual; } if (input->ExpectTag(16)) goto parse_channels; break; @@ -19819,15 +30057,14 @@ bool MemoryDataParameter::MergePartialFromCodedStream( // optional uint32 channels = 2; case 2: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) { + if (tag == 16) { parse_channels: + set_has_channels(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>( input, &channels_))); - set_has_channels(); } else { - goto handle_uninterpreted; + goto handle_unusual; } if (input->ExpectTag(24)) goto parse_height; break; @@ -19835,15 +30072,14 @@ bool MemoryDataParameter::MergePartialFromCodedStream( // optional uint32 height = 3; case 3: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) { + if (tag == 24) { parse_height: + set_has_height(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>( input, &height_))); - set_has_height(); } else { - goto handle_uninterpreted; + goto handle_unusual; } if (input->ExpectTag(32)) goto parse_width; break; @@ -19851,25 +30087,25 @@ bool MemoryDataParameter::MergePartialFromCodedStream( // optional uint32 width = 4; case 4: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) { + if (tag == 32) { parse_width: + set_has_width(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>( input, &width_))); - set_has_width(); } else { - goto handle_uninterpreted; + goto handle_unusual; } - if (input->ExpectAtEnd()) return true; + if (input->ExpectAtEnd()) goto success; break; } default: { - handle_uninterpreted: - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == + handle_unusual: + if (tag == 0 || + ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) { - return true; + goto success; } DO_(::google::protobuf::internal::WireFormat::SkipField( input, tag, mutable_unknown_fields())); @@ -19877,12 +30113,18 @@ bool MemoryDataParameter::MergePartialFromCodedStream( } } } +success: + // @@protoc_insertion_point(parse_success:caffe.MemoryDataParameter) return true; +failure: + // @@protoc_insertion_point(parse_failure:caffe.MemoryDataParameter) + return false; #undef DO_ } void MemoryDataParameter::SerializeWithCachedSizes( ::google::protobuf::io::CodedOutputStream* output) const { + // @@protoc_insertion_point(serialize_start:caffe.MemoryDataParameter) // optional uint32 batch_size = 1; if (has_batch_size()) { ::google::protobuf::internal::WireFormatLite::WriteUInt32(1, this->batch_size(), output); @@ -19903,14 +30145,17 @@ void MemoryDataParameter::SerializeWithCachedSizes( ::google::protobuf::internal::WireFormatLite::WriteUInt32(4, this->width(), output); } - if (!unknown_fields().empty()) { + if (_internal_metadata_.have_unknown_fields()) { ::google::protobuf::internal::WireFormat::SerializeUnknownFields( unknown_fields(), output); } + // @@protoc_insertion_point(serialize_end:caffe.MemoryDataParameter) } -::google::protobuf::uint8* MemoryDataParameter::SerializeWithCachedSizesToArray( - ::google::protobuf::uint8* target) const { +::google::protobuf::uint8* MemoryDataParameter::InternalSerializeWithCachedSizesToArray( + bool deterministic, ::google::protobuf::uint8* target) const { + (void)deterministic; // Unused + // @@protoc_insertion_point(serialize_to_array_start:caffe.MemoryDataParameter) // optional uint32 batch_size = 1; if (has_batch_size()) { target = ::google::protobuf::internal::WireFormatLite::WriteUInt32ToArray(1, this->batch_size(), target); @@ -19931,17 +30176,19 @@ void MemoryDataParameter::SerializeWithCachedSizes( target = ::google::protobuf::internal::WireFormatLite::WriteUInt32ToArray(4, this->width(), target); } - if (!unknown_fields().empty()) { + if (_internal_metadata_.have_unknown_fields()) { target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray( unknown_fields(), target); } + // @@protoc_insertion_point(serialize_to_array_end:caffe.MemoryDataParameter) return target; } -int MemoryDataParameter::ByteSize() const { - int total_size = 0; +size_t MemoryDataParameter::ByteSizeLong() const { +// @@protoc_insertion_point(message_byte_size_start:caffe.MemoryDataParameter) + size_t total_size = 0; - if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) { + if (_has_bits_[0 / 32] & 15u) { // optional uint32 batch_size = 1; if (has_batch_size()) { total_size += 1 + @@ -19971,31 +30218,44 @@ int MemoryDataParameter::ByteSize() const { } } - if (!unknown_fields().empty()) { + if (_internal_metadata_.have_unknown_fields()) { total_size += ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( unknown_fields()); } + int cached_size = ::google::protobuf::internal::ToCachedSize(total_size); GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); - _cached_size_ = total_size; + _cached_size_ = cached_size; GOOGLE_SAFE_CONCURRENT_WRITES_END(); return total_size; } void MemoryDataParameter::MergeFrom(const ::google::protobuf::Message& from) { - GOOGLE_CHECK_NE(&from, this); +// @@protoc_insertion_point(generalized_merge_from_start:caffe.MemoryDataParameter) + if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__); const MemoryDataParameter* source = - ::google::protobuf::internal::dynamic_cast_if_available( - &from); + ::google::protobuf::internal::DynamicCastToGenerated( + &from); if (source == NULL) { + // @@protoc_insertion_point(generalized_merge_from_cast_fail:caffe.MemoryDataParameter) ::google::protobuf::internal::ReflectionOps::Merge(from, this); } else { - MergeFrom(*source); + // @@protoc_insertion_point(generalized_merge_from_cast_success:caffe.MemoryDataParameter) + UnsafeMergeFrom(*source); } } void MemoryDataParameter::MergeFrom(const MemoryDataParameter& from) { - GOOGLE_CHECK_NE(&from, this); +// @@protoc_insertion_point(class_specific_merge_from_start:caffe.MemoryDataParameter) + if (GOOGLE_PREDICT_TRUE(&from != this)) { + UnsafeMergeFrom(from); + } else { + MergeFromFail(__LINE__); + } +} + +void MemoryDataParameter::UnsafeMergeFrom(const MemoryDataParameter& from) { + GOOGLE_DCHECK(&from != this); if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) { if (from.has_batch_size()) { set_batch_size(from.batch_size()); @@ -20010,19 +30270,24 @@ void MemoryDataParameter::MergeFrom(const MemoryDataParameter& from) { set_width(from.width()); } } - mutable_unknown_fields()->MergeFrom(from.unknown_fields()); + if (from._internal_metadata_.have_unknown_fields()) { + ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata( + from.unknown_fields(), &_internal_metadata_); + } } void MemoryDataParameter::CopyFrom(const ::google::protobuf::Message& from) { +// @@protoc_insertion_point(generalized_copy_from_start:caffe.MemoryDataParameter) if (&from == this) return; Clear(); MergeFrom(from); } void MemoryDataParameter::CopyFrom(const MemoryDataParameter& from) { +// @@protoc_insertion_point(class_specific_copy_from_start:caffe.MemoryDataParameter) if (&from == this) return; Clear(); - MergeFrom(from); + UnsafeMergeFrom(from); } bool MemoryDataParameter::IsInitialized() const { @@ -20031,15 +30296,17 @@ bool MemoryDataParameter::IsInitialized() const { } void MemoryDataParameter::Swap(MemoryDataParameter* other) { - if (other != this) { - std::swap(batch_size_, other->batch_size_); - std::swap(channels_, other->channels_); - std::swap(height_, other->height_); - std::swap(width_, other->width_); - std::swap(_has_bits_[0], other->_has_bits_[0]); - _unknown_fields_.Swap(&other->_unknown_fields_); - std::swap(_cached_size_, other->_cached_size_); - } + if (other == this) return; + InternalSwap(other); +} +void MemoryDataParameter::InternalSwap(MemoryDataParameter* other) { + std::swap(batch_size_, other->batch_size_); + std::swap(channels_, other->channels_); + std::swap(height_, other->height_); + std::swap(width_, other->width_); + std::swap(_has_bits_[0], other->_has_bits_[0]); + _internal_metadata_.Swap(&other->_internal_metadata_); + std::swap(_cached_size_, other->_cached_size_); } ::google::protobuf::Metadata MemoryDataParameter::GetMetadata() const { @@ -20050,44 +30317,149 @@ void MemoryDataParameter::Swap(MemoryDataParameter* other) { return metadata; } +#if PROTOBUF_INLINE_NOT_IN_HEADERS +// MemoryDataParameter + +// optional uint32 batch_size = 1; +bool MemoryDataParameter::has_batch_size() const { + return (_has_bits_[0] & 0x00000001u) != 0; +} +void MemoryDataParameter::set_has_batch_size() { + _has_bits_[0] |= 0x00000001u; +} +void MemoryDataParameter::clear_has_batch_size() { + _has_bits_[0] &= ~0x00000001u; +} +void MemoryDataParameter::clear_batch_size() { + batch_size_ = 0u; + clear_has_batch_size(); +} +::google::protobuf::uint32 MemoryDataParameter::batch_size() const { + // @@protoc_insertion_point(field_get:caffe.MemoryDataParameter.batch_size) + return batch_size_; +} +void MemoryDataParameter::set_batch_size(::google::protobuf::uint32 value) { + set_has_batch_size(); + batch_size_ = value; + // @@protoc_insertion_point(field_set:caffe.MemoryDataParameter.batch_size) +} + +// optional uint32 channels = 2; +bool MemoryDataParameter::has_channels() const { + return (_has_bits_[0] & 0x00000002u) != 0; +} +void MemoryDataParameter::set_has_channels() { + _has_bits_[0] |= 0x00000002u; +} +void MemoryDataParameter::clear_has_channels() { + _has_bits_[0] &= ~0x00000002u; +} +void MemoryDataParameter::clear_channels() { + channels_ = 0u; + clear_has_channels(); +} +::google::protobuf::uint32 MemoryDataParameter::channels() const { + // @@protoc_insertion_point(field_get:caffe.MemoryDataParameter.channels) + return channels_; +} +void MemoryDataParameter::set_channels(::google::protobuf::uint32 value) { + set_has_channels(); + channels_ = value; + // @@protoc_insertion_point(field_set:caffe.MemoryDataParameter.channels) +} + +// optional uint32 height = 3; +bool MemoryDataParameter::has_height() const { + return (_has_bits_[0] & 0x00000004u) != 0; +} +void MemoryDataParameter::set_has_height() { + _has_bits_[0] |= 0x00000004u; +} +void MemoryDataParameter::clear_has_height() { + _has_bits_[0] &= ~0x00000004u; +} +void MemoryDataParameter::clear_height() { + height_ = 0u; + clear_has_height(); +} +::google::protobuf::uint32 MemoryDataParameter::height() const { + // @@protoc_insertion_point(field_get:caffe.MemoryDataParameter.height) + return height_; +} +void MemoryDataParameter::set_height(::google::protobuf::uint32 value) { + set_has_height(); + height_ = value; + // @@protoc_insertion_point(field_set:caffe.MemoryDataParameter.height) +} + +// optional uint32 width = 4; +bool MemoryDataParameter::has_width() const { + return (_has_bits_[0] & 0x00000008u) != 0; +} +void MemoryDataParameter::set_has_width() { + _has_bits_[0] |= 0x00000008u; +} +void MemoryDataParameter::clear_has_width() { + _has_bits_[0] &= ~0x00000008u; +} +void MemoryDataParameter::clear_width() { + width_ = 0u; + clear_has_width(); +} +::google::protobuf::uint32 MemoryDataParameter::width() const { + // @@protoc_insertion_point(field_get:caffe.MemoryDataParameter.width) + return width_; +} +void MemoryDataParameter::set_width(::google::protobuf::uint32 value) { + set_has_width(); + width_ = value; + // @@protoc_insertion_point(field_set:caffe.MemoryDataParameter.width) +} + +inline const MemoryDataParameter* MemoryDataParameter::internal_default_instance() { + return &MemoryDataParameter_default_instance_.get(); +} +#endif // PROTOBUF_INLINE_NOT_IN_HEADERS // =================================================================== -#ifndef _MSC_VER +#if !defined(_MSC_VER) || _MSC_VER >= 1900 const int MVNParameter::kNormalizeVarianceFieldNumber; const int MVNParameter::kAcrossChannelsFieldNumber; const int MVNParameter::kEpsFieldNumber; -#endif // !_MSC_VER +#endif // !defined(_MSC_VER) || _MSC_VER >= 1900 MVNParameter::MVNParameter() - : ::google::protobuf::Message() { + : ::google::protobuf::Message(), _internal_metadata_(NULL) { + if (this != internal_default_instance()) protobuf_InitDefaults_caffe_2eproto(); SharedCtor(); + // @@protoc_insertion_point(constructor:caffe.MVNParameter) } void MVNParameter::InitAsDefaultInstance() { } MVNParameter::MVNParameter(const MVNParameter& from) - : ::google::protobuf::Message() { + : ::google::protobuf::Message(), + _internal_metadata_(NULL) { SharedCtor(); - MergeFrom(from); + UnsafeMergeFrom(from); + // @@protoc_insertion_point(copy_constructor:caffe.MVNParameter) } void MVNParameter::SharedCtor() { _cached_size_ = 0; - normalize_variance_ = true; across_channels_ = false; + normalize_variance_ = true; eps_ = 1e-09f; - ::memset(_has_bits_, 0, sizeof(_has_bits_)); } MVNParameter::~MVNParameter() { + // @@protoc_insertion_point(destructor:caffe.MVNParameter) SharedDtor(); } void MVNParameter::SharedDtor() { - if (this != default_instance_) { - } } void MVNParameter::SetCachedSize(int size) const { @@ -20101,42 +30473,52 @@ const ::google::protobuf::Descriptor* MVNParameter::descriptor() { } const MVNParameter& MVNParameter::default_instance() { - if (default_instance_ == NULL) protobuf_AddDesc_caffe_2eproto(); - return *default_instance_; + protobuf_InitDefaults_caffe_2eproto(); + return *internal_default_instance(); } -MVNParameter* MVNParameter::default_instance_ = NULL; +::google::protobuf::internal::ExplicitlyConstructed MVNParameter_default_instance_; -MVNParameter* MVNParameter::New() const { - return new MVNParameter; +MVNParameter* MVNParameter::New(::google::protobuf::Arena* arena) const { + MVNParameter* n = new MVNParameter; + if (arena != NULL) { + arena->Own(n); + } + return n; } void MVNParameter::Clear() { - if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) { +// @@protoc_insertion_point(message_clear_start:caffe.MVNParameter) + if (_has_bits_[0 / 32] & 7u) { normalize_variance_ = true; across_channels_ = false; eps_ = 1e-09f; } - ::memset(_has_bits_, 0, sizeof(_has_bits_)); - mutable_unknown_fields()->Clear(); + _has_bits_.Clear(); + if (_internal_metadata_.have_unknown_fields()) { + mutable_unknown_fields()->Clear(); + } } bool MVNParameter::MergePartialFromCodedStream( ::google::protobuf::io::CodedInputStream* input) { -#define DO_(EXPRESSION) if (!(EXPRESSION)) return false +#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure ::google::protobuf::uint32 tag; - while ((tag = input->ReadTag()) != 0) { + // @@protoc_insertion_point(parse_start:caffe.MVNParameter) + for (;;) { + ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127); + tag = p.first; + if (!p.second) goto handle_unusual; switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { // optional bool normalize_variance = 1 [default = true]; case 1: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) { + if (tag == 8) { + set_has_normalize_variance(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>( input, &normalize_variance_))); - set_has_normalize_variance(); } else { - goto handle_uninterpreted; + goto handle_unusual; } if (input->ExpectTag(16)) goto parse_across_channels; break; @@ -20144,15 +30526,14 @@ bool MVNParameter::MergePartialFromCodedStream( // optional bool across_channels = 2 [default = false]; case 2: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) { + if (tag == 16) { parse_across_channels: + set_has_across_channels(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>( input, &across_channels_))); - set_has_across_channels(); } else { - goto handle_uninterpreted; + goto handle_unusual; } if (input->ExpectTag(29)) goto parse_eps; break; @@ -20160,25 +30541,25 @@ bool MVNParameter::MergePartialFromCodedStream( // optional float eps = 3 [default = 1e-09]; case 3: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_FIXED32) { + if (tag == 29) { parse_eps: + set_has_eps(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< float, ::google::protobuf::internal::WireFormatLite::TYPE_FLOAT>( input, &eps_))); - set_has_eps(); } else { - goto handle_uninterpreted; + goto handle_unusual; } - if (input->ExpectAtEnd()) return true; + if (input->ExpectAtEnd()) goto success; break; } default: { - handle_uninterpreted: - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == + handle_unusual: + if (tag == 0 || + ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) { - return true; + goto success; } DO_(::google::protobuf::internal::WireFormat::SkipField( input, tag, mutable_unknown_fields())); @@ -20186,12 +30567,18 @@ bool MVNParameter::MergePartialFromCodedStream( } } } +success: + // @@protoc_insertion_point(parse_success:caffe.MVNParameter) return true; +failure: + // @@protoc_insertion_point(parse_failure:caffe.MVNParameter) + return false; #undef DO_ } void MVNParameter::SerializeWithCachedSizes( ::google::protobuf::io::CodedOutputStream* output) const { + // @@protoc_insertion_point(serialize_start:caffe.MVNParameter) // optional bool normalize_variance = 1 [default = true]; if (has_normalize_variance()) { ::google::protobuf::internal::WireFormatLite::WriteBool(1, this->normalize_variance(), output); @@ -20207,14 +30594,17 @@ void MVNParameter::SerializeWithCachedSizes( ::google::protobuf::internal::WireFormatLite::WriteFloat(3, this->eps(), output); } - if (!unknown_fields().empty()) { + if (_internal_metadata_.have_unknown_fields()) { ::google::protobuf::internal::WireFormat::SerializeUnknownFields( unknown_fields(), output); } + // @@protoc_insertion_point(serialize_end:caffe.MVNParameter) } -::google::protobuf::uint8* MVNParameter::SerializeWithCachedSizesToArray( - ::google::protobuf::uint8* target) const { +::google::protobuf::uint8* MVNParameter::InternalSerializeWithCachedSizesToArray( + bool deterministic, ::google::protobuf::uint8* target) const { + (void)deterministic; // Unused + // @@protoc_insertion_point(serialize_to_array_start:caffe.MVNParameter) // optional bool normalize_variance = 1 [default = true]; if (has_normalize_variance()) { target = ::google::protobuf::internal::WireFormatLite::WriteBoolToArray(1, this->normalize_variance(), target); @@ -20230,17 +30620,19 @@ void MVNParameter::SerializeWithCachedSizes( target = ::google::protobuf::internal::WireFormatLite::WriteFloatToArray(3, this->eps(), target); } - if (!unknown_fields().empty()) { + if (_internal_metadata_.have_unknown_fields()) { target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray( unknown_fields(), target); } + // @@protoc_insertion_point(serialize_to_array_end:caffe.MVNParameter) return target; } -int MVNParameter::ByteSize() const { - int total_size = 0; +size_t MVNParameter::ByteSizeLong() const { +// @@protoc_insertion_point(message_byte_size_start:caffe.MVNParameter) + size_t total_size = 0; - if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) { + if (_has_bits_[0 / 32] & 7u) { // optional bool normalize_variance = 1 [default = true]; if (has_normalize_variance()) { total_size += 1 + 1; @@ -20257,31 +30649,44 @@ int MVNParameter::ByteSize() const { } } - if (!unknown_fields().empty()) { + if (_internal_metadata_.have_unknown_fields()) { total_size += ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( unknown_fields()); } + int cached_size = ::google::protobuf::internal::ToCachedSize(total_size); GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); - _cached_size_ = total_size; + _cached_size_ = cached_size; GOOGLE_SAFE_CONCURRENT_WRITES_END(); return total_size; } void MVNParameter::MergeFrom(const ::google::protobuf::Message& from) { - GOOGLE_CHECK_NE(&from, this); +// @@protoc_insertion_point(generalized_merge_from_start:caffe.MVNParameter) + if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__); const MVNParameter* source = - ::google::protobuf::internal::dynamic_cast_if_available( - &from); + ::google::protobuf::internal::DynamicCastToGenerated( + &from); if (source == NULL) { + // @@protoc_insertion_point(generalized_merge_from_cast_fail:caffe.MVNParameter) ::google::protobuf::internal::ReflectionOps::Merge(from, this); } else { - MergeFrom(*source); + // @@protoc_insertion_point(generalized_merge_from_cast_success:caffe.MVNParameter) + UnsafeMergeFrom(*source); } } void MVNParameter::MergeFrom(const MVNParameter& from) { - GOOGLE_CHECK_NE(&from, this); +// @@protoc_insertion_point(class_specific_merge_from_start:caffe.MVNParameter) + if (GOOGLE_PREDICT_TRUE(&from != this)) { + UnsafeMergeFrom(from); + } else { + MergeFromFail(__LINE__); + } +} + +void MVNParameter::UnsafeMergeFrom(const MVNParameter& from) { + GOOGLE_DCHECK(&from != this); if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) { if (from.has_normalize_variance()) { set_normalize_variance(from.normalize_variance()); @@ -20293,19 +30698,24 @@ void MVNParameter::MergeFrom(const MVNParameter& from) { set_eps(from.eps()); } } - mutable_unknown_fields()->MergeFrom(from.unknown_fields()); + if (from._internal_metadata_.have_unknown_fields()) { + ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata( + from.unknown_fields(), &_internal_metadata_); + } } void MVNParameter::CopyFrom(const ::google::protobuf::Message& from) { +// @@protoc_insertion_point(generalized_copy_from_start:caffe.MVNParameter) if (&from == this) return; Clear(); MergeFrom(from); } void MVNParameter::CopyFrom(const MVNParameter& from) { +// @@protoc_insertion_point(class_specific_copy_from_start:caffe.MVNParameter) if (&from == this) return; Clear(); - MergeFrom(from); + UnsafeMergeFrom(from); } bool MVNParameter::IsInitialized() const { @@ -20314,14 +30724,16 @@ bool MVNParameter::IsInitialized() const { } void MVNParameter::Swap(MVNParameter* other) { - if (other != this) { - std::swap(normalize_variance_, other->normalize_variance_); - std::swap(across_channels_, other->across_channels_); - std::swap(eps_, other->eps_); - std::swap(_has_bits_[0], other->_has_bits_[0]); - _unknown_fields_.Swap(&other->_unknown_fields_); - std::swap(_cached_size_, other->_cached_size_); - } + if (other == this) return; + InternalSwap(other); +} +void MVNParameter::InternalSwap(MVNParameter* other) { + std::swap(normalize_variance_, other->normalize_variance_); + std::swap(across_channels_, other->across_channels_); + std::swap(eps_, other->eps_); + std::swap(_has_bits_[0], other->_has_bits_[0]); + _internal_metadata_.Swap(&other->_internal_metadata_); + std::swap(_cached_size_, other->_cached_size_); } ::google::protobuf::Metadata MVNParameter::GetMetadata() const { @@ -20332,6 +30744,85 @@ void MVNParameter::Swap(MVNParameter* other) { return metadata; } +#if PROTOBUF_INLINE_NOT_IN_HEADERS +// MVNParameter + +// optional bool normalize_variance = 1 [default = true]; +bool MVNParameter::has_normalize_variance() const { + return (_has_bits_[0] & 0x00000001u) != 0; +} +void MVNParameter::set_has_normalize_variance() { + _has_bits_[0] |= 0x00000001u; +} +void MVNParameter::clear_has_normalize_variance() { + _has_bits_[0] &= ~0x00000001u; +} +void MVNParameter::clear_normalize_variance() { + normalize_variance_ = true; + clear_has_normalize_variance(); +} +bool MVNParameter::normalize_variance() const { + // @@protoc_insertion_point(field_get:caffe.MVNParameter.normalize_variance) + return normalize_variance_; +} +void MVNParameter::set_normalize_variance(bool value) { + set_has_normalize_variance(); + normalize_variance_ = value; + // @@protoc_insertion_point(field_set:caffe.MVNParameter.normalize_variance) +} + +// optional bool across_channels = 2 [default = false]; +bool MVNParameter::has_across_channels() const { + return (_has_bits_[0] & 0x00000002u) != 0; +} +void MVNParameter::set_has_across_channels() { + _has_bits_[0] |= 0x00000002u; +} +void MVNParameter::clear_has_across_channels() { + _has_bits_[0] &= ~0x00000002u; +} +void MVNParameter::clear_across_channels() { + across_channels_ = false; + clear_has_across_channels(); +} +bool MVNParameter::across_channels() const { + // @@protoc_insertion_point(field_get:caffe.MVNParameter.across_channels) + return across_channels_; +} +void MVNParameter::set_across_channels(bool value) { + set_has_across_channels(); + across_channels_ = value; + // @@protoc_insertion_point(field_set:caffe.MVNParameter.across_channels) +} + +// optional float eps = 3 [default = 1e-09]; +bool MVNParameter::has_eps() const { + return (_has_bits_[0] & 0x00000004u) != 0; +} +void MVNParameter::set_has_eps() { + _has_bits_[0] |= 0x00000004u; +} +void MVNParameter::clear_has_eps() { + _has_bits_[0] &= ~0x00000004u; +} +void MVNParameter::clear_eps() { + eps_ = 1e-09f; + clear_has_eps(); +} +float MVNParameter::eps() const { + // @@protoc_insertion_point(field_get:caffe.MVNParameter.eps) + return eps_; +} +void MVNParameter::set_eps(float value) { + set_has_eps(); + eps_ = value; + // @@protoc_insertion_point(field_set:caffe.MVNParameter.eps) +} + +inline const MVNParameter* MVNParameter::internal_default_instance() { + return &MVNParameter_default_instance_.get(); +} +#endif // PROTOBUF_INLINE_NOT_IN_HEADERS // =================================================================== @@ -20340,7 +30831,7 @@ const ::google::protobuf::EnumDescriptor* PoolingParameter_PoolMethod_descriptor return PoolingParameter_PoolMethod_descriptor_; } bool PoolingParameter_PoolMethod_IsValid(int value) { - switch(value) { + switch (value) { case 0: case 1: case 2: @@ -20350,20 +30841,20 @@ bool PoolingParameter_PoolMethod_IsValid(int value) { } } -#ifndef _MSC_VER +#if !defined(_MSC_VER) || _MSC_VER >= 1900 const PoolingParameter_PoolMethod PoolingParameter::MAX; const PoolingParameter_PoolMethod PoolingParameter::AVE; const PoolingParameter_PoolMethod PoolingParameter::STOCHASTIC; const PoolingParameter_PoolMethod PoolingParameter::PoolMethod_MIN; const PoolingParameter_PoolMethod PoolingParameter::PoolMethod_MAX; const int PoolingParameter::PoolMethod_ARRAYSIZE; -#endif // _MSC_VER +#endif // !defined(_MSC_VER) || _MSC_VER >= 1900 const ::google::protobuf::EnumDescriptor* PoolingParameter_Engine_descriptor() { protobuf_AssignDescriptorsOnce(); return PoolingParameter_Engine_descriptor_; } bool PoolingParameter_Engine_IsValid(int value) { - switch(value) { + switch (value) { case 0: case 1: case 2: @@ -20373,15 +30864,15 @@ bool PoolingParameter_Engine_IsValid(int value) { } } -#ifndef _MSC_VER +#if !defined(_MSC_VER) || _MSC_VER >= 1900 const PoolingParameter_Engine PoolingParameter::DEFAULT; const PoolingParameter_Engine PoolingParameter::CAFFE; const PoolingParameter_Engine PoolingParameter::CUDNN; const PoolingParameter_Engine PoolingParameter::Engine_MIN; const PoolingParameter_Engine PoolingParameter::Engine_MAX; const int PoolingParameter::Engine_ARRAYSIZE; -#endif // _MSC_VER -#ifndef _MSC_VER +#endif // !defined(_MSC_VER) || _MSC_VER >= 1900 +#if !defined(_MSC_VER) || _MSC_VER >= 1900 const int PoolingParameter::kPoolFieldNumber; const int PoolingParameter::kPadFieldNumber; const int PoolingParameter::kPadHFieldNumber; @@ -20394,46 +30885,39 @@ const int PoolingParameter::kStrideHFieldNumber; const int PoolingParameter::kStrideWFieldNumber; const int PoolingParameter::kEngineFieldNumber; const int PoolingParameter::kGlobalPoolingFieldNumber; -#endif // !_MSC_VER +#endif // !defined(_MSC_VER) || _MSC_VER >= 1900 PoolingParameter::PoolingParameter() - : ::google::protobuf::Message() { + : ::google::protobuf::Message(), _internal_metadata_(NULL) { + if (this != internal_default_instance()) protobuf_InitDefaults_caffe_2eproto(); SharedCtor(); + // @@protoc_insertion_point(constructor:caffe.PoolingParameter) } void PoolingParameter::InitAsDefaultInstance() { } PoolingParameter::PoolingParameter(const PoolingParameter& from) - : ::google::protobuf::Message() { + : ::google::protobuf::Message(), + _internal_metadata_(NULL) { SharedCtor(); - MergeFrom(from); + UnsafeMergeFrom(from); + // @@protoc_insertion_point(copy_constructor:caffe.PoolingParameter) } void PoolingParameter::SharedCtor() { _cached_size_ = 0; - pool_ = 0; - pad_ = 0u; - pad_h_ = 0u; - pad_w_ = 0u; - kernel_size_ = 0u; - kernel_h_ = 0u; - kernel_w_ = 0u; + ::memset(&pool_, 0, reinterpret_cast(&global_pooling_) - + reinterpret_cast(&pool_) + sizeof(global_pooling_)); stride_ = 1u; - stride_h_ = 0u; - stride_w_ = 0u; - engine_ = 0; - global_pooling_ = false; - ::memset(_has_bits_, 0, sizeof(_has_bits_)); } PoolingParameter::~PoolingParameter() { + // @@protoc_insertion_point(destructor:caffe.PoolingParameter) SharedDtor(); } void PoolingParameter::SharedDtor() { - if (this != default_instance_) { - } } void PoolingParameter::SetCachedSize(int size) const { @@ -20447,47 +30931,66 @@ const ::google::protobuf::Descriptor* PoolingParameter::descriptor() { } const PoolingParameter& PoolingParameter::default_instance() { - if (default_instance_ == NULL) protobuf_AddDesc_caffe_2eproto(); - return *default_instance_; + protobuf_InitDefaults_caffe_2eproto(); + return *internal_default_instance(); } -PoolingParameter* PoolingParameter::default_instance_ = NULL; +::google::protobuf::internal::ExplicitlyConstructed PoolingParameter_default_instance_; -PoolingParameter* PoolingParameter::New() const { - return new PoolingParameter; +PoolingParameter* PoolingParameter::New(::google::protobuf::Arena* arena) const { + PoolingParameter* n = new PoolingParameter; + if (arena != NULL) { + arena->Own(n); + } + return n; } void PoolingParameter::Clear() { - if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) { - pool_ = 0; - pad_ = 0u; - pad_h_ = 0u; - pad_w_ = 0u; - kernel_size_ = 0u; - kernel_h_ = 0u; - kernel_w_ = 0u; +// @@protoc_insertion_point(message_clear_start:caffe.PoolingParameter) +#if defined(__clang__) +#define ZR_HELPER_(f) \ + _Pragma("clang diagnostic push") \ + _Pragma("clang diagnostic ignored \"-Winvalid-offsetof\"") \ + __builtin_offsetof(PoolingParameter, f) \ + _Pragma("clang diagnostic pop") +#else +#define ZR_HELPER_(f) reinterpret_cast(\ + &reinterpret_cast(16)->f) +#endif + +#define ZR_(first, last) do {\ + ::memset(&(first), 0,\ + ZR_HELPER_(last) - ZR_HELPER_(first) + sizeof(last));\ +} while (0) + + if (_has_bits_[0 / 32] & 255u) { + ZR_(pool_, kernel_w_); stride_ = 1u; } - if (_has_bits_[8 / 32] & (0xffu << (8 % 32))) { - stride_h_ = 0u; - stride_w_ = 0u; - engine_ = 0; - global_pooling_ = false; + ZR_(stride_h_, global_pooling_); + +#undef ZR_HELPER_ +#undef ZR_ + + _has_bits_.Clear(); + if (_internal_metadata_.have_unknown_fields()) { + mutable_unknown_fields()->Clear(); } - ::memset(_has_bits_, 0, sizeof(_has_bits_)); - mutable_unknown_fields()->Clear(); } bool PoolingParameter::MergePartialFromCodedStream( ::google::protobuf::io::CodedInputStream* input) { -#define DO_(EXPRESSION) if (!(EXPRESSION)) return false +#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure ::google::protobuf::uint32 tag; - while ((tag = input->ReadTag()) != 0) { + // @@protoc_insertion_point(parse_start:caffe.PoolingParameter) + for (;;) { + ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127); + tag = p.first; + if (!p.second) goto handle_unusual; switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { // optional .caffe.PoolingParameter.PoolMethod pool = 1 [default = MAX]; case 1: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) { + if (tag == 8) { int value; DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< int, ::google::protobuf::internal::WireFormatLite::TYPE_ENUM>( @@ -20498,7 +31001,7 @@ bool PoolingParameter::MergePartialFromCodedStream( mutable_unknown_fields()->AddVarint(1, value); } } else { - goto handle_uninterpreted; + goto handle_unusual; } if (input->ExpectTag(16)) goto parse_kernel_size; break; @@ -20506,15 +31009,14 @@ bool PoolingParameter::MergePartialFromCodedStream( // optional uint32 kernel_size = 2; case 2: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) { + if (tag == 16) { parse_kernel_size: + set_has_kernel_size(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>( input, &kernel_size_))); - set_has_kernel_size(); } else { - goto handle_uninterpreted; + goto handle_unusual; } if (input->ExpectTag(24)) goto parse_stride; break; @@ -20522,15 +31024,14 @@ bool PoolingParameter::MergePartialFromCodedStream( // optional uint32 stride = 3 [default = 1]; case 3: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) { + if (tag == 24) { parse_stride: + set_has_stride(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>( input, &stride_))); - set_has_stride(); } else { - goto handle_uninterpreted; + goto handle_unusual; } if (input->ExpectTag(32)) goto parse_pad; break; @@ -20538,15 +31039,14 @@ bool PoolingParameter::MergePartialFromCodedStream( // optional uint32 pad = 4 [default = 0]; case 4: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) { + if (tag == 32) { parse_pad: + set_has_pad(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>( input, &pad_))); - set_has_pad(); } else { - goto handle_uninterpreted; + goto handle_unusual; } if (input->ExpectTag(40)) goto parse_kernel_h; break; @@ -20554,15 +31054,14 @@ bool PoolingParameter::MergePartialFromCodedStream( // optional uint32 kernel_h = 5; case 5: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) { + if (tag == 40) { parse_kernel_h: + set_has_kernel_h(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>( input, &kernel_h_))); - set_has_kernel_h(); } else { - goto handle_uninterpreted; + goto handle_unusual; } if (input->ExpectTag(48)) goto parse_kernel_w; break; @@ -20570,15 +31069,14 @@ bool PoolingParameter::MergePartialFromCodedStream( // optional uint32 kernel_w = 6; case 6: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) { + if (tag == 48) { parse_kernel_w: + set_has_kernel_w(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>( input, &kernel_w_))); - set_has_kernel_w(); } else { - goto handle_uninterpreted; + goto handle_unusual; } if (input->ExpectTag(56)) goto parse_stride_h; break; @@ -20586,15 +31084,14 @@ bool PoolingParameter::MergePartialFromCodedStream( // optional uint32 stride_h = 7; case 7: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) { + if (tag == 56) { parse_stride_h: + set_has_stride_h(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>( input, &stride_h_))); - set_has_stride_h(); } else { - goto handle_uninterpreted; + goto handle_unusual; } if (input->ExpectTag(64)) goto parse_stride_w; break; @@ -20602,15 +31099,14 @@ bool PoolingParameter::MergePartialFromCodedStream( // optional uint32 stride_w = 8; case 8: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) { + if (tag == 64) { parse_stride_w: + set_has_stride_w(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>( input, &stride_w_))); - set_has_stride_w(); } else { - goto handle_uninterpreted; + goto handle_unusual; } if (input->ExpectTag(72)) goto parse_pad_h; break; @@ -20618,15 +31114,14 @@ bool PoolingParameter::MergePartialFromCodedStream( // optional uint32 pad_h = 9 [default = 0]; case 9: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) { + if (tag == 72) { parse_pad_h: + set_has_pad_h(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>( input, &pad_h_))); - set_has_pad_h(); } else { - goto handle_uninterpreted; + goto handle_unusual; } if (input->ExpectTag(80)) goto parse_pad_w; break; @@ -20634,15 +31129,14 @@ bool PoolingParameter::MergePartialFromCodedStream( // optional uint32 pad_w = 10 [default = 0]; case 10: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) { + if (tag == 80) { parse_pad_w: + set_has_pad_w(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>( input, &pad_w_))); - set_has_pad_w(); } else { - goto handle_uninterpreted; + goto handle_unusual; } if (input->ExpectTag(88)) goto parse_engine; break; @@ -20650,8 +31144,7 @@ bool PoolingParameter::MergePartialFromCodedStream( // optional .caffe.PoolingParameter.Engine engine = 11 [default = DEFAULT]; case 11: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) { + if (tag == 88) { parse_engine: int value; DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< @@ -20663,7 +31156,7 @@ bool PoolingParameter::MergePartialFromCodedStream( mutable_unknown_fields()->AddVarint(11, value); } } else { - goto handle_uninterpreted; + goto handle_unusual; } if (input->ExpectTag(96)) goto parse_global_pooling; break; @@ -20671,25 +31164,25 @@ bool PoolingParameter::MergePartialFromCodedStream( // optional bool global_pooling = 12 [default = false]; case 12: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) { + if (tag == 96) { parse_global_pooling: + set_has_global_pooling(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>( input, &global_pooling_))); - set_has_global_pooling(); } else { - goto handle_uninterpreted; + goto handle_unusual; } - if (input->ExpectAtEnd()) return true; + if (input->ExpectAtEnd()) goto success; break; } default: { - handle_uninterpreted: - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == + handle_unusual: + if (tag == 0 || + ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) { - return true; + goto success; } DO_(::google::protobuf::internal::WireFormat::SkipField( input, tag, mutable_unknown_fields())); @@ -20697,12 +31190,18 @@ bool PoolingParameter::MergePartialFromCodedStream( } } } +success: + // @@protoc_insertion_point(parse_success:caffe.PoolingParameter) return true; +failure: + // @@protoc_insertion_point(parse_failure:caffe.PoolingParameter) + return false; #undef DO_ } void PoolingParameter::SerializeWithCachedSizes( ::google::protobuf::io::CodedOutputStream* output) const { + // @@protoc_insertion_point(serialize_start:caffe.PoolingParameter) // optional .caffe.PoolingParameter.PoolMethod pool = 1 [default = MAX]; if (has_pool()) { ::google::protobuf::internal::WireFormatLite::WriteEnum( @@ -20765,14 +31264,17 @@ void PoolingParameter::SerializeWithCachedSizes( ::google::protobuf::internal::WireFormatLite::WriteBool(12, this->global_pooling(), output); } - if (!unknown_fields().empty()) { + if (_internal_metadata_.have_unknown_fields()) { ::google::protobuf::internal::WireFormat::SerializeUnknownFields( unknown_fields(), output); } + // @@protoc_insertion_point(serialize_end:caffe.PoolingParameter) } -::google::protobuf::uint8* PoolingParameter::SerializeWithCachedSizesToArray( - ::google::protobuf::uint8* target) const { +::google::protobuf::uint8* PoolingParameter::InternalSerializeWithCachedSizesToArray( + bool deterministic, ::google::protobuf::uint8* target) const { + (void)deterministic; // Unused + // @@protoc_insertion_point(serialize_to_array_start:caffe.PoolingParameter) // optional .caffe.PoolingParameter.PoolMethod pool = 1 [default = MAX]; if (has_pool()) { target = ::google::protobuf::internal::WireFormatLite::WriteEnumToArray( @@ -20835,17 +31337,19 @@ void PoolingParameter::SerializeWithCachedSizes( target = ::google::protobuf::internal::WireFormatLite::WriteBoolToArray(12, this->global_pooling(), target); } - if (!unknown_fields().empty()) { + if (_internal_metadata_.have_unknown_fields()) { target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray( unknown_fields(), target); } + // @@protoc_insertion_point(serialize_to_array_end:caffe.PoolingParameter) return target; } -int PoolingParameter::ByteSize() const { - int total_size = 0; +size_t PoolingParameter::ByteSizeLong() const { +// @@protoc_insertion_point(message_byte_size_start:caffe.PoolingParameter) + size_t total_size = 0; - if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) { + if (_has_bits_[0 / 32] & 255u) { // optional .caffe.PoolingParameter.PoolMethod pool = 1 [default = MAX]; if (has_pool()) { total_size += 1 + @@ -20902,7 +31406,7 @@ int PoolingParameter::ByteSize() const { } } - if (_has_bits_[8 / 32] & (0xffu << (8 % 32))) { + if (_has_bits_[8 / 32] & 3840u) { // optional uint32 stride_h = 7; if (has_stride_h()) { total_size += 1 + @@ -20929,31 +31433,44 @@ int PoolingParameter::ByteSize() const { } } - if (!unknown_fields().empty()) { + if (_internal_metadata_.have_unknown_fields()) { total_size += ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( unknown_fields()); } + int cached_size = ::google::protobuf::internal::ToCachedSize(total_size); GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); - _cached_size_ = total_size; + _cached_size_ = cached_size; GOOGLE_SAFE_CONCURRENT_WRITES_END(); return total_size; } void PoolingParameter::MergeFrom(const ::google::protobuf::Message& from) { - GOOGLE_CHECK_NE(&from, this); +// @@protoc_insertion_point(generalized_merge_from_start:caffe.PoolingParameter) + if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__); const PoolingParameter* source = - ::google::protobuf::internal::dynamic_cast_if_available( - &from); + ::google::protobuf::internal::DynamicCastToGenerated( + &from); if (source == NULL) { + // @@protoc_insertion_point(generalized_merge_from_cast_fail:caffe.PoolingParameter) ::google::protobuf::internal::ReflectionOps::Merge(from, this); } else { - MergeFrom(*source); + // @@protoc_insertion_point(generalized_merge_from_cast_success:caffe.PoolingParameter) + UnsafeMergeFrom(*source); } } void PoolingParameter::MergeFrom(const PoolingParameter& from) { - GOOGLE_CHECK_NE(&from, this); +// @@protoc_insertion_point(class_specific_merge_from_start:caffe.PoolingParameter) + if (GOOGLE_PREDICT_TRUE(&from != this)) { + UnsafeMergeFrom(from); + } else { + MergeFromFail(__LINE__); + } +} + +void PoolingParameter::UnsafeMergeFrom(const PoolingParameter& from) { + GOOGLE_DCHECK(&from != this); if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) { if (from.has_pool()) { set_pool(from.pool()); @@ -20994,92 +31511,398 @@ void PoolingParameter::MergeFrom(const PoolingParameter& from) { set_global_pooling(from.global_pooling()); } } - mutable_unknown_fields()->MergeFrom(from.unknown_fields()); + if (from._internal_metadata_.have_unknown_fields()) { + ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata( + from.unknown_fields(), &_internal_metadata_); + } +} + +void PoolingParameter::CopyFrom(const ::google::protobuf::Message& from) { +// @@protoc_insertion_point(generalized_copy_from_start:caffe.PoolingParameter) + if (&from == this) return; + Clear(); + MergeFrom(from); +} + +void PoolingParameter::CopyFrom(const PoolingParameter& from) { +// @@protoc_insertion_point(class_specific_copy_from_start:caffe.PoolingParameter) + if (&from == this) return; + Clear(); + UnsafeMergeFrom(from); +} + +bool PoolingParameter::IsInitialized() const { + + return true; +} + +void PoolingParameter::Swap(PoolingParameter* other) { + if (other == this) return; + InternalSwap(other); +} +void PoolingParameter::InternalSwap(PoolingParameter* other) { + std::swap(pool_, other->pool_); + std::swap(pad_, other->pad_); + std::swap(pad_h_, other->pad_h_); + std::swap(pad_w_, other->pad_w_); + std::swap(kernel_size_, other->kernel_size_); + std::swap(kernel_h_, other->kernel_h_); + std::swap(kernel_w_, other->kernel_w_); + std::swap(stride_, other->stride_); + std::swap(stride_h_, other->stride_h_); + std::swap(stride_w_, other->stride_w_); + std::swap(engine_, other->engine_); + std::swap(global_pooling_, other->global_pooling_); + std::swap(_has_bits_[0], other->_has_bits_[0]); + _internal_metadata_.Swap(&other->_internal_metadata_); + std::swap(_cached_size_, other->_cached_size_); +} + +::google::protobuf::Metadata PoolingParameter::GetMetadata() const { + protobuf_AssignDescriptorsOnce(); + ::google::protobuf::Metadata metadata; + metadata.descriptor = PoolingParameter_descriptor_; + metadata.reflection = PoolingParameter_reflection_; + return metadata; +} + +#if PROTOBUF_INLINE_NOT_IN_HEADERS +// PoolingParameter + +// optional .caffe.PoolingParameter.PoolMethod pool = 1 [default = MAX]; +bool PoolingParameter::has_pool() const { + return (_has_bits_[0] & 0x00000001u) != 0; +} +void PoolingParameter::set_has_pool() { + _has_bits_[0] |= 0x00000001u; +} +void PoolingParameter::clear_has_pool() { + _has_bits_[0] &= ~0x00000001u; +} +void PoolingParameter::clear_pool() { + pool_ = 0; + clear_has_pool(); +} +::caffe::PoolingParameter_PoolMethod PoolingParameter::pool() const { + // @@protoc_insertion_point(field_get:caffe.PoolingParameter.pool) + return static_cast< ::caffe::PoolingParameter_PoolMethod >(pool_); +} +void PoolingParameter::set_pool(::caffe::PoolingParameter_PoolMethod value) { + assert(::caffe::PoolingParameter_PoolMethod_IsValid(value)); + set_has_pool(); + pool_ = value; + // @@protoc_insertion_point(field_set:caffe.PoolingParameter.pool) +} + +// optional uint32 pad = 4 [default = 0]; +bool PoolingParameter::has_pad() const { + return (_has_bits_[0] & 0x00000002u) != 0; +} +void PoolingParameter::set_has_pad() { + _has_bits_[0] |= 0x00000002u; +} +void PoolingParameter::clear_has_pad() { + _has_bits_[0] &= ~0x00000002u; +} +void PoolingParameter::clear_pad() { + pad_ = 0u; + clear_has_pad(); +} +::google::protobuf::uint32 PoolingParameter::pad() const { + // @@protoc_insertion_point(field_get:caffe.PoolingParameter.pad) + return pad_; +} +void PoolingParameter::set_pad(::google::protobuf::uint32 value) { + set_has_pad(); + pad_ = value; + // @@protoc_insertion_point(field_set:caffe.PoolingParameter.pad) +} + +// optional uint32 pad_h = 9 [default = 0]; +bool PoolingParameter::has_pad_h() const { + return (_has_bits_[0] & 0x00000004u) != 0; +} +void PoolingParameter::set_has_pad_h() { + _has_bits_[0] |= 0x00000004u; +} +void PoolingParameter::clear_has_pad_h() { + _has_bits_[0] &= ~0x00000004u; +} +void PoolingParameter::clear_pad_h() { + pad_h_ = 0u; + clear_has_pad_h(); +} +::google::protobuf::uint32 PoolingParameter::pad_h() const { + // @@protoc_insertion_point(field_get:caffe.PoolingParameter.pad_h) + return pad_h_; +} +void PoolingParameter::set_pad_h(::google::protobuf::uint32 value) { + set_has_pad_h(); + pad_h_ = value; + // @@protoc_insertion_point(field_set:caffe.PoolingParameter.pad_h) +} + +// optional uint32 pad_w = 10 [default = 0]; +bool PoolingParameter::has_pad_w() const { + return (_has_bits_[0] & 0x00000008u) != 0; +} +void PoolingParameter::set_has_pad_w() { + _has_bits_[0] |= 0x00000008u; +} +void PoolingParameter::clear_has_pad_w() { + _has_bits_[0] &= ~0x00000008u; +} +void PoolingParameter::clear_pad_w() { + pad_w_ = 0u; + clear_has_pad_w(); +} +::google::protobuf::uint32 PoolingParameter::pad_w() const { + // @@protoc_insertion_point(field_get:caffe.PoolingParameter.pad_w) + return pad_w_; +} +void PoolingParameter::set_pad_w(::google::protobuf::uint32 value) { + set_has_pad_w(); + pad_w_ = value; + // @@protoc_insertion_point(field_set:caffe.PoolingParameter.pad_w) } -void PoolingParameter::CopyFrom(const ::google::protobuf::Message& from) { - if (&from == this) return; - Clear(); - MergeFrom(from); +// optional uint32 kernel_size = 2; +bool PoolingParameter::has_kernel_size() const { + return (_has_bits_[0] & 0x00000010u) != 0; +} +void PoolingParameter::set_has_kernel_size() { + _has_bits_[0] |= 0x00000010u; +} +void PoolingParameter::clear_has_kernel_size() { + _has_bits_[0] &= ~0x00000010u; +} +void PoolingParameter::clear_kernel_size() { + kernel_size_ = 0u; + clear_has_kernel_size(); +} +::google::protobuf::uint32 PoolingParameter::kernel_size() const { + // @@protoc_insertion_point(field_get:caffe.PoolingParameter.kernel_size) + return kernel_size_; +} +void PoolingParameter::set_kernel_size(::google::protobuf::uint32 value) { + set_has_kernel_size(); + kernel_size_ = value; + // @@protoc_insertion_point(field_set:caffe.PoolingParameter.kernel_size) } -void PoolingParameter::CopyFrom(const PoolingParameter& from) { - if (&from == this) return; - Clear(); - MergeFrom(from); +// optional uint32 kernel_h = 5; +bool PoolingParameter::has_kernel_h() const { + return (_has_bits_[0] & 0x00000020u) != 0; +} +void PoolingParameter::set_has_kernel_h() { + _has_bits_[0] |= 0x00000020u; +} +void PoolingParameter::clear_has_kernel_h() { + _has_bits_[0] &= ~0x00000020u; +} +void PoolingParameter::clear_kernel_h() { + kernel_h_ = 0u; + clear_has_kernel_h(); +} +::google::protobuf::uint32 PoolingParameter::kernel_h() const { + // @@protoc_insertion_point(field_get:caffe.PoolingParameter.kernel_h) + return kernel_h_; +} +void PoolingParameter::set_kernel_h(::google::protobuf::uint32 value) { + set_has_kernel_h(); + kernel_h_ = value; + // @@protoc_insertion_point(field_set:caffe.PoolingParameter.kernel_h) } -bool PoolingParameter::IsInitialized() const { +// optional uint32 kernel_w = 6; +bool PoolingParameter::has_kernel_w() const { + return (_has_bits_[0] & 0x00000040u) != 0; +} +void PoolingParameter::set_has_kernel_w() { + _has_bits_[0] |= 0x00000040u; +} +void PoolingParameter::clear_has_kernel_w() { + _has_bits_[0] &= ~0x00000040u; +} +void PoolingParameter::clear_kernel_w() { + kernel_w_ = 0u; + clear_has_kernel_w(); +} +::google::protobuf::uint32 PoolingParameter::kernel_w() const { + // @@protoc_insertion_point(field_get:caffe.PoolingParameter.kernel_w) + return kernel_w_; +} +void PoolingParameter::set_kernel_w(::google::protobuf::uint32 value) { + set_has_kernel_w(); + kernel_w_ = value; + // @@protoc_insertion_point(field_set:caffe.PoolingParameter.kernel_w) +} - return true; +// optional uint32 stride = 3 [default = 1]; +bool PoolingParameter::has_stride() const { + return (_has_bits_[0] & 0x00000080u) != 0; +} +void PoolingParameter::set_has_stride() { + _has_bits_[0] |= 0x00000080u; +} +void PoolingParameter::clear_has_stride() { + _has_bits_[0] &= ~0x00000080u; +} +void PoolingParameter::clear_stride() { + stride_ = 1u; + clear_has_stride(); +} +::google::protobuf::uint32 PoolingParameter::stride() const { + // @@protoc_insertion_point(field_get:caffe.PoolingParameter.stride) + return stride_; +} +void PoolingParameter::set_stride(::google::protobuf::uint32 value) { + set_has_stride(); + stride_ = value; + // @@protoc_insertion_point(field_set:caffe.PoolingParameter.stride) } -void PoolingParameter::Swap(PoolingParameter* other) { - if (other != this) { - std::swap(pool_, other->pool_); - std::swap(pad_, other->pad_); - std::swap(pad_h_, other->pad_h_); - std::swap(pad_w_, other->pad_w_); - std::swap(kernel_size_, other->kernel_size_); - std::swap(kernel_h_, other->kernel_h_); - std::swap(kernel_w_, other->kernel_w_); - std::swap(stride_, other->stride_); - std::swap(stride_h_, other->stride_h_); - std::swap(stride_w_, other->stride_w_); - std::swap(engine_, other->engine_); - std::swap(global_pooling_, other->global_pooling_); - std::swap(_has_bits_[0], other->_has_bits_[0]); - _unknown_fields_.Swap(&other->_unknown_fields_); - std::swap(_cached_size_, other->_cached_size_); - } +// optional uint32 stride_h = 7; +bool PoolingParameter::has_stride_h() const { + return (_has_bits_[0] & 0x00000100u) != 0; +} +void PoolingParameter::set_has_stride_h() { + _has_bits_[0] |= 0x00000100u; +} +void PoolingParameter::clear_has_stride_h() { + _has_bits_[0] &= ~0x00000100u; +} +void PoolingParameter::clear_stride_h() { + stride_h_ = 0u; + clear_has_stride_h(); +} +::google::protobuf::uint32 PoolingParameter::stride_h() const { + // @@protoc_insertion_point(field_get:caffe.PoolingParameter.stride_h) + return stride_h_; +} +void PoolingParameter::set_stride_h(::google::protobuf::uint32 value) { + set_has_stride_h(); + stride_h_ = value; + // @@protoc_insertion_point(field_set:caffe.PoolingParameter.stride_h) } -::google::protobuf::Metadata PoolingParameter::GetMetadata() const { - protobuf_AssignDescriptorsOnce(); - ::google::protobuf::Metadata metadata; - metadata.descriptor = PoolingParameter_descriptor_; - metadata.reflection = PoolingParameter_reflection_; - return metadata; +// optional uint32 stride_w = 8; +bool PoolingParameter::has_stride_w() const { + return (_has_bits_[0] & 0x00000200u) != 0; +} +void PoolingParameter::set_has_stride_w() { + _has_bits_[0] |= 0x00000200u; +} +void PoolingParameter::clear_has_stride_w() { + _has_bits_[0] &= ~0x00000200u; +} +void PoolingParameter::clear_stride_w() { + stride_w_ = 0u; + clear_has_stride_w(); +} +::google::protobuf::uint32 PoolingParameter::stride_w() const { + // @@protoc_insertion_point(field_get:caffe.PoolingParameter.stride_w) + return stride_w_; +} +void PoolingParameter::set_stride_w(::google::protobuf::uint32 value) { + set_has_stride_w(); + stride_w_ = value; + // @@protoc_insertion_point(field_set:caffe.PoolingParameter.stride_w) +} + +// optional .caffe.PoolingParameter.Engine engine = 11 [default = DEFAULT]; +bool PoolingParameter::has_engine() const { + return (_has_bits_[0] & 0x00000400u) != 0; +} +void PoolingParameter::set_has_engine() { + _has_bits_[0] |= 0x00000400u; +} +void PoolingParameter::clear_has_engine() { + _has_bits_[0] &= ~0x00000400u; +} +void PoolingParameter::clear_engine() { + engine_ = 0; + clear_has_engine(); +} +::caffe::PoolingParameter_Engine PoolingParameter::engine() const { + // @@protoc_insertion_point(field_get:caffe.PoolingParameter.engine) + return static_cast< ::caffe::PoolingParameter_Engine >(engine_); +} +void PoolingParameter::set_engine(::caffe::PoolingParameter_Engine value) { + assert(::caffe::PoolingParameter_Engine_IsValid(value)); + set_has_engine(); + engine_ = value; + // @@protoc_insertion_point(field_set:caffe.PoolingParameter.engine) +} + +// optional bool global_pooling = 12 [default = false]; +bool PoolingParameter::has_global_pooling() const { + return (_has_bits_[0] & 0x00000800u) != 0; +} +void PoolingParameter::set_has_global_pooling() { + _has_bits_[0] |= 0x00000800u; +} +void PoolingParameter::clear_has_global_pooling() { + _has_bits_[0] &= ~0x00000800u; +} +void PoolingParameter::clear_global_pooling() { + global_pooling_ = false; + clear_has_global_pooling(); +} +bool PoolingParameter::global_pooling() const { + // @@protoc_insertion_point(field_get:caffe.PoolingParameter.global_pooling) + return global_pooling_; +} +void PoolingParameter::set_global_pooling(bool value) { + set_has_global_pooling(); + global_pooling_ = value; + // @@protoc_insertion_point(field_set:caffe.PoolingParameter.global_pooling) } +inline const PoolingParameter* PoolingParameter::internal_default_instance() { + return &PoolingParameter_default_instance_.get(); +} +#endif // PROTOBUF_INLINE_NOT_IN_HEADERS // =================================================================== -#ifndef _MSC_VER +#if !defined(_MSC_VER) || _MSC_VER >= 1900 const int PowerParameter::kPowerFieldNumber; const int PowerParameter::kScaleFieldNumber; const int PowerParameter::kShiftFieldNumber; -#endif // !_MSC_VER +#endif // !defined(_MSC_VER) || _MSC_VER >= 1900 PowerParameter::PowerParameter() - : ::google::protobuf::Message() { + : ::google::protobuf::Message(), _internal_metadata_(NULL) { + if (this != internal_default_instance()) protobuf_InitDefaults_caffe_2eproto(); SharedCtor(); + // @@protoc_insertion_point(constructor:caffe.PowerParameter) } void PowerParameter::InitAsDefaultInstance() { } PowerParameter::PowerParameter(const PowerParameter& from) - : ::google::protobuf::Message() { + : ::google::protobuf::Message(), + _internal_metadata_(NULL) { SharedCtor(); - MergeFrom(from); + UnsafeMergeFrom(from); + // @@protoc_insertion_point(copy_constructor:caffe.PowerParameter) } void PowerParameter::SharedCtor() { _cached_size_ = 0; + shift_ = 0; power_ = 1; scale_ = 1; - shift_ = 0; - ::memset(_has_bits_, 0, sizeof(_has_bits_)); } PowerParameter::~PowerParameter() { + // @@protoc_insertion_point(destructor:caffe.PowerParameter) SharedDtor(); } void PowerParameter::SharedDtor() { - if (this != default_instance_) { - } } void PowerParameter::SetCachedSize(int size) const { @@ -21093,42 +31916,52 @@ const ::google::protobuf::Descriptor* PowerParameter::descriptor() { } const PowerParameter& PowerParameter::default_instance() { - if (default_instance_ == NULL) protobuf_AddDesc_caffe_2eproto(); - return *default_instance_; + protobuf_InitDefaults_caffe_2eproto(); + return *internal_default_instance(); } -PowerParameter* PowerParameter::default_instance_ = NULL; +::google::protobuf::internal::ExplicitlyConstructed PowerParameter_default_instance_; -PowerParameter* PowerParameter::New() const { - return new PowerParameter; +PowerParameter* PowerParameter::New(::google::protobuf::Arena* arena) const { + PowerParameter* n = new PowerParameter; + if (arena != NULL) { + arena->Own(n); + } + return n; } void PowerParameter::Clear() { - if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) { +// @@protoc_insertion_point(message_clear_start:caffe.PowerParameter) + if (_has_bits_[0 / 32] & 7u) { power_ = 1; scale_ = 1; shift_ = 0; } - ::memset(_has_bits_, 0, sizeof(_has_bits_)); - mutable_unknown_fields()->Clear(); + _has_bits_.Clear(); + if (_internal_metadata_.have_unknown_fields()) { + mutable_unknown_fields()->Clear(); + } } bool PowerParameter::MergePartialFromCodedStream( ::google::protobuf::io::CodedInputStream* input) { -#define DO_(EXPRESSION) if (!(EXPRESSION)) return false +#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure ::google::protobuf::uint32 tag; - while ((tag = input->ReadTag()) != 0) { + // @@protoc_insertion_point(parse_start:caffe.PowerParameter) + for (;;) { + ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127); + tag = p.first; + if (!p.second) goto handle_unusual; switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { // optional float power = 1 [default = 1]; case 1: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_FIXED32) { + if (tag == 13) { + set_has_power(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< float, ::google::protobuf::internal::WireFormatLite::TYPE_FLOAT>( input, &power_))); - set_has_power(); } else { - goto handle_uninterpreted; + goto handle_unusual; } if (input->ExpectTag(21)) goto parse_scale; break; @@ -21136,15 +31969,14 @@ bool PowerParameter::MergePartialFromCodedStream( // optional float scale = 2 [default = 1]; case 2: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_FIXED32) { + if (tag == 21) { parse_scale: + set_has_scale(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< float, ::google::protobuf::internal::WireFormatLite::TYPE_FLOAT>( input, &scale_))); - set_has_scale(); } else { - goto handle_uninterpreted; + goto handle_unusual; } if (input->ExpectTag(29)) goto parse_shift; break; @@ -21152,25 +31984,25 @@ bool PowerParameter::MergePartialFromCodedStream( // optional float shift = 3 [default = 0]; case 3: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_FIXED32) { + if (tag == 29) { parse_shift: + set_has_shift(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< float, ::google::protobuf::internal::WireFormatLite::TYPE_FLOAT>( input, &shift_))); - set_has_shift(); } else { - goto handle_uninterpreted; + goto handle_unusual; } - if (input->ExpectAtEnd()) return true; + if (input->ExpectAtEnd()) goto success; break; } default: { - handle_uninterpreted: - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == + handle_unusual: + if (tag == 0 || + ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) { - return true; + goto success; } DO_(::google::protobuf::internal::WireFormat::SkipField( input, tag, mutable_unknown_fields())); @@ -21178,12 +32010,18 @@ bool PowerParameter::MergePartialFromCodedStream( } } } +success: + // @@protoc_insertion_point(parse_success:caffe.PowerParameter) return true; +failure: + // @@protoc_insertion_point(parse_failure:caffe.PowerParameter) + return false; #undef DO_ } void PowerParameter::SerializeWithCachedSizes( ::google::protobuf::io::CodedOutputStream* output) const { + // @@protoc_insertion_point(serialize_start:caffe.PowerParameter) // optional float power = 1 [default = 1]; if (has_power()) { ::google::protobuf::internal::WireFormatLite::WriteFloat(1, this->power(), output); @@ -21199,14 +32037,17 @@ void PowerParameter::SerializeWithCachedSizes( ::google::protobuf::internal::WireFormatLite::WriteFloat(3, this->shift(), output); } - if (!unknown_fields().empty()) { + if (_internal_metadata_.have_unknown_fields()) { ::google::protobuf::internal::WireFormat::SerializeUnknownFields( unknown_fields(), output); } + // @@protoc_insertion_point(serialize_end:caffe.PowerParameter) } -::google::protobuf::uint8* PowerParameter::SerializeWithCachedSizesToArray( - ::google::protobuf::uint8* target) const { +::google::protobuf::uint8* PowerParameter::InternalSerializeWithCachedSizesToArray( + bool deterministic, ::google::protobuf::uint8* target) const { + (void)deterministic; // Unused + // @@protoc_insertion_point(serialize_to_array_start:caffe.PowerParameter) // optional float power = 1 [default = 1]; if (has_power()) { target = ::google::protobuf::internal::WireFormatLite::WriteFloatToArray(1, this->power(), target); @@ -21222,17 +32063,19 @@ void PowerParameter::SerializeWithCachedSizes( target = ::google::protobuf::internal::WireFormatLite::WriteFloatToArray(3, this->shift(), target); } - if (!unknown_fields().empty()) { + if (_internal_metadata_.have_unknown_fields()) { target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray( unknown_fields(), target); } + // @@protoc_insertion_point(serialize_to_array_end:caffe.PowerParameter) return target; } -int PowerParameter::ByteSize() const { - int total_size = 0; +size_t PowerParameter::ByteSizeLong() const { +// @@protoc_insertion_point(message_byte_size_start:caffe.PowerParameter) + size_t total_size = 0; - if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) { + if (_has_bits_[0 / 32] & 7u) { // optional float power = 1 [default = 1]; if (has_power()) { total_size += 1 + 4; @@ -21249,31 +32092,44 @@ int PowerParameter::ByteSize() const { } } - if (!unknown_fields().empty()) { + if (_internal_metadata_.have_unknown_fields()) { total_size += ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( unknown_fields()); } + int cached_size = ::google::protobuf::internal::ToCachedSize(total_size); GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); - _cached_size_ = total_size; + _cached_size_ = cached_size; GOOGLE_SAFE_CONCURRENT_WRITES_END(); return total_size; } void PowerParameter::MergeFrom(const ::google::protobuf::Message& from) { - GOOGLE_CHECK_NE(&from, this); +// @@protoc_insertion_point(generalized_merge_from_start:caffe.PowerParameter) + if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__); const PowerParameter* source = - ::google::protobuf::internal::dynamic_cast_if_available( - &from); + ::google::protobuf::internal::DynamicCastToGenerated( + &from); if (source == NULL) { + // @@protoc_insertion_point(generalized_merge_from_cast_fail:caffe.PowerParameter) ::google::protobuf::internal::ReflectionOps::Merge(from, this); } else { - MergeFrom(*source); + // @@protoc_insertion_point(generalized_merge_from_cast_success:caffe.PowerParameter) + UnsafeMergeFrom(*source); } } void PowerParameter::MergeFrom(const PowerParameter& from) { - GOOGLE_CHECK_NE(&from, this); +// @@protoc_insertion_point(class_specific_merge_from_start:caffe.PowerParameter) + if (GOOGLE_PREDICT_TRUE(&from != this)) { + UnsafeMergeFrom(from); + } else { + MergeFromFail(__LINE__); + } +} + +void PowerParameter::UnsafeMergeFrom(const PowerParameter& from) { + GOOGLE_DCHECK(&from != this); if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) { if (from.has_power()) { set_power(from.power()); @@ -21285,19 +32141,24 @@ void PowerParameter::MergeFrom(const PowerParameter& from) { set_shift(from.shift()); } } - mutable_unknown_fields()->MergeFrom(from.unknown_fields()); + if (from._internal_metadata_.have_unknown_fields()) { + ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata( + from.unknown_fields(), &_internal_metadata_); + } } void PowerParameter::CopyFrom(const ::google::protobuf::Message& from) { +// @@protoc_insertion_point(generalized_copy_from_start:caffe.PowerParameter) if (&from == this) return; Clear(); MergeFrom(from); } void PowerParameter::CopyFrom(const PowerParameter& from) { +// @@protoc_insertion_point(class_specific_copy_from_start:caffe.PowerParameter) if (&from == this) return; Clear(); - MergeFrom(from); + UnsafeMergeFrom(from); } bool PowerParameter::IsInitialized() const { @@ -21306,14 +32167,16 @@ bool PowerParameter::IsInitialized() const { } void PowerParameter::Swap(PowerParameter* other) { - if (other != this) { - std::swap(power_, other->power_); - std::swap(scale_, other->scale_); - std::swap(shift_, other->shift_); - std::swap(_has_bits_[0], other->_has_bits_[0]); - _unknown_fields_.Swap(&other->_unknown_fields_); - std::swap(_cached_size_, other->_cached_size_); - } + if (other == this) return; + InternalSwap(other); +} +void PowerParameter::InternalSwap(PowerParameter* other) { + std::swap(power_, other->power_); + std::swap(scale_, other->scale_); + std::swap(shift_, other->shift_); + std::swap(_has_bits_[0], other->_has_bits_[0]); + _internal_metadata_.Swap(&other->_internal_metadata_); + std::swap(_cached_size_, other->_cached_size_); } ::google::protobuf::Metadata PowerParameter::GetMetadata() const { @@ -21324,48 +32187,125 @@ void PowerParameter::Swap(PowerParameter* other) { return metadata; } +#if PROTOBUF_INLINE_NOT_IN_HEADERS +// PowerParameter + +// optional float power = 1 [default = 1]; +bool PowerParameter::has_power() const { + return (_has_bits_[0] & 0x00000001u) != 0; +} +void PowerParameter::set_has_power() { + _has_bits_[0] |= 0x00000001u; +} +void PowerParameter::clear_has_power() { + _has_bits_[0] &= ~0x00000001u; +} +void PowerParameter::clear_power() { + power_ = 1; + clear_has_power(); +} +float PowerParameter::power() const { + // @@protoc_insertion_point(field_get:caffe.PowerParameter.power) + return power_; +} +void PowerParameter::set_power(float value) { + set_has_power(); + power_ = value; + // @@protoc_insertion_point(field_set:caffe.PowerParameter.power) +} + +// optional float scale = 2 [default = 1]; +bool PowerParameter::has_scale() const { + return (_has_bits_[0] & 0x00000002u) != 0; +} +void PowerParameter::set_has_scale() { + _has_bits_[0] |= 0x00000002u; +} +void PowerParameter::clear_has_scale() { + _has_bits_[0] &= ~0x00000002u; +} +void PowerParameter::clear_scale() { + scale_ = 1; + clear_has_scale(); +} +float PowerParameter::scale() const { + // @@protoc_insertion_point(field_get:caffe.PowerParameter.scale) + return scale_; +} +void PowerParameter::set_scale(float value) { + set_has_scale(); + scale_ = value; + // @@protoc_insertion_point(field_set:caffe.PowerParameter.scale) +} + +// optional float shift = 3 [default = 0]; +bool PowerParameter::has_shift() const { + return (_has_bits_[0] & 0x00000004u) != 0; +} +void PowerParameter::set_has_shift() { + _has_bits_[0] |= 0x00000004u; +} +void PowerParameter::clear_has_shift() { + _has_bits_[0] &= ~0x00000004u; +} +void PowerParameter::clear_shift() { + shift_ = 0; + clear_has_shift(); +} +float PowerParameter::shift() const { + // @@protoc_insertion_point(field_get:caffe.PowerParameter.shift) + return shift_; +} +void PowerParameter::set_shift(float value) { + set_has_shift(); + shift_ = value; + // @@protoc_insertion_point(field_set:caffe.PowerParameter.shift) +} + +inline const PowerParameter* PowerParameter::internal_default_instance() { + return &PowerParameter_default_instance_.get(); +} +#endif // PROTOBUF_INLINE_NOT_IN_HEADERS // =================================================================== -#ifndef _MSC_VER +#if !defined(_MSC_VER) || _MSC_VER >= 1900 const int PythonParameter::kModuleFieldNumber; const int PythonParameter::kLayerFieldNumber; -#endif // !_MSC_VER +#endif // !defined(_MSC_VER) || _MSC_VER >= 1900 PythonParameter::PythonParameter() - : ::google::protobuf::Message() { + : ::google::protobuf::Message(), _internal_metadata_(NULL) { + if (this != internal_default_instance()) protobuf_InitDefaults_caffe_2eproto(); SharedCtor(); + // @@protoc_insertion_point(constructor:caffe.PythonParameter) } void PythonParameter::InitAsDefaultInstance() { } PythonParameter::PythonParameter(const PythonParameter& from) - : ::google::protobuf::Message() { + : ::google::protobuf::Message(), + _internal_metadata_(NULL) { SharedCtor(); - MergeFrom(from); + UnsafeMergeFrom(from); + // @@protoc_insertion_point(copy_constructor:caffe.PythonParameter) } void PythonParameter::SharedCtor() { _cached_size_ = 0; - module_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); - layer_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); - ::memset(_has_bits_, 0, sizeof(_has_bits_)); + module_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + layer_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } PythonParameter::~PythonParameter() { + // @@protoc_insertion_point(destructor:caffe.PythonParameter) SharedDtor(); } void PythonParameter::SharedDtor() { - if (module_ != &::google::protobuf::internal::kEmptyString) { - delete module_; - } - if (layer_ != &::google::protobuf::internal::kEmptyString) { - delete layer_; - } - if (this != default_instance_) { - } + module_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + layer_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } void PythonParameter::SetCachedSize(int size) const { @@ -21379,50 +32319,57 @@ const ::google::protobuf::Descriptor* PythonParameter::descriptor() { } const PythonParameter& PythonParameter::default_instance() { - if (default_instance_ == NULL) protobuf_AddDesc_caffe_2eproto(); - return *default_instance_; + protobuf_InitDefaults_caffe_2eproto(); + return *internal_default_instance(); } -PythonParameter* PythonParameter::default_instance_ = NULL; +::google::protobuf::internal::ExplicitlyConstructed PythonParameter_default_instance_; -PythonParameter* PythonParameter::New() const { - return new PythonParameter; +PythonParameter* PythonParameter::New(::google::protobuf::Arena* arena) const { + PythonParameter* n = new PythonParameter; + if (arena != NULL) { + arena->Own(n); + } + return n; } void PythonParameter::Clear() { - if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) { +// @@protoc_insertion_point(message_clear_start:caffe.PythonParameter) + if (_has_bits_[0 / 32] & 3u) { if (has_module()) { - if (module_ != &::google::protobuf::internal::kEmptyString) { - module_->clear(); - } + module_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } if (has_layer()) { - if (layer_ != &::google::protobuf::internal::kEmptyString) { - layer_->clear(); - } + layer_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } } - ::memset(_has_bits_, 0, sizeof(_has_bits_)); - mutable_unknown_fields()->Clear(); + _has_bits_.Clear(); + if (_internal_metadata_.have_unknown_fields()) { + mutable_unknown_fields()->Clear(); + } } bool PythonParameter::MergePartialFromCodedStream( ::google::protobuf::io::CodedInputStream* input) { -#define DO_(EXPRESSION) if (!(EXPRESSION)) return false +#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure ::google::protobuf::uint32 tag; - while ((tag = input->ReadTag()) != 0) { + // @@protoc_insertion_point(parse_start:caffe.PythonParameter) + for (;;) { + ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127); + tag = p.first; + if (!p.second) goto handle_unusual; switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { // optional string module = 1; case 1: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) { + if (tag == 10) { DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->mutable_module())); - ::google::protobuf::internal::WireFormat::VerifyUTF8String( + ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( this->module().data(), this->module().length(), - ::google::protobuf::internal::WireFormat::PARSE); + ::google::protobuf::internal::WireFormat::PARSE, + "caffe.PythonParameter.module"); } else { - goto handle_uninterpreted; + goto handle_unusual; } if (input->ExpectTag(18)) goto parse_layer; break; @@ -21430,26 +32377,27 @@ bool PythonParameter::MergePartialFromCodedStream( // optional string layer = 2; case 2: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) { + if (tag == 18) { parse_layer: DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->mutable_layer())); - ::google::protobuf::internal::WireFormat::VerifyUTF8String( + ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( this->layer().data(), this->layer().length(), - ::google::protobuf::internal::WireFormat::PARSE); + ::google::protobuf::internal::WireFormat::PARSE, + "caffe.PythonParameter.layer"); } else { - goto handle_uninterpreted; + goto handle_unusual; } - if (input->ExpectAtEnd()) return true; + if (input->ExpectAtEnd()) goto success; break; } default: { - handle_uninterpreted: - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == + handle_unusual: + if (tag == 0 || + ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) { - return true; + goto success; } DO_(::google::protobuf::internal::WireFormat::SkipField( input, tag, mutable_unknown_fields())); @@ -21457,43 +32405,55 @@ bool PythonParameter::MergePartialFromCodedStream( } } } +success: + // @@protoc_insertion_point(parse_success:caffe.PythonParameter) return true; +failure: + // @@protoc_insertion_point(parse_failure:caffe.PythonParameter) + return false; #undef DO_ } void PythonParameter::SerializeWithCachedSizes( ::google::protobuf::io::CodedOutputStream* output) const { + // @@protoc_insertion_point(serialize_start:caffe.PythonParameter) // optional string module = 1; if (has_module()) { - ::google::protobuf::internal::WireFormat::VerifyUTF8String( + ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( this->module().data(), this->module().length(), - ::google::protobuf::internal::WireFormat::SERIALIZE); - ::google::protobuf::internal::WireFormatLite::WriteString( + ::google::protobuf::internal::WireFormat::SERIALIZE, + "caffe.PythonParameter.module"); + ::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased( 1, this->module(), output); } // optional string layer = 2; if (has_layer()) { - ::google::protobuf::internal::WireFormat::VerifyUTF8String( + ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( this->layer().data(), this->layer().length(), - ::google::protobuf::internal::WireFormat::SERIALIZE); - ::google::protobuf::internal::WireFormatLite::WriteString( + ::google::protobuf::internal::WireFormat::SERIALIZE, + "caffe.PythonParameter.layer"); + ::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased( 2, this->layer(), output); } - if (!unknown_fields().empty()) { + if (_internal_metadata_.have_unknown_fields()) { ::google::protobuf::internal::WireFormat::SerializeUnknownFields( unknown_fields(), output); } + // @@protoc_insertion_point(serialize_end:caffe.PythonParameter) } -::google::protobuf::uint8* PythonParameter::SerializeWithCachedSizesToArray( - ::google::protobuf::uint8* target) const { +::google::protobuf::uint8* PythonParameter::InternalSerializeWithCachedSizesToArray( + bool deterministic, ::google::protobuf::uint8* target) const { + (void)deterministic; // Unused + // @@protoc_insertion_point(serialize_to_array_start:caffe.PythonParameter) // optional string module = 1; if (has_module()) { - ::google::protobuf::internal::WireFormat::VerifyUTF8String( + ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( this->module().data(), this->module().length(), - ::google::protobuf::internal::WireFormat::SERIALIZE); + ::google::protobuf::internal::WireFormat::SERIALIZE, + "caffe.PythonParameter.module"); target = ::google::protobuf::internal::WireFormatLite::WriteStringToArray( 1, this->module(), target); @@ -21501,25 +32461,28 @@ void PythonParameter::SerializeWithCachedSizes( // optional string layer = 2; if (has_layer()) { - ::google::protobuf::internal::WireFormat::VerifyUTF8String( + ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( this->layer().data(), this->layer().length(), - ::google::protobuf::internal::WireFormat::SERIALIZE); + ::google::protobuf::internal::WireFormat::SERIALIZE, + "caffe.PythonParameter.layer"); target = ::google::protobuf::internal::WireFormatLite::WriteStringToArray( 2, this->layer(), target); } - if (!unknown_fields().empty()) { + if (_internal_metadata_.have_unknown_fields()) { target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray( unknown_fields(), target); } + // @@protoc_insertion_point(serialize_to_array_end:caffe.PythonParameter) return target; } -int PythonParameter::ByteSize() const { - int total_size = 0; +size_t PythonParameter::ByteSizeLong() const { +// @@protoc_insertion_point(message_byte_size_start:caffe.PythonParameter) + size_t total_size = 0; - if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) { + if (_has_bits_[0 / 32] & 3u) { // optional string module = 1; if (has_module()) { total_size += 1 + @@ -21535,52 +32498,72 @@ int PythonParameter::ByteSize() const { } } - if (!unknown_fields().empty()) { + if (_internal_metadata_.have_unknown_fields()) { total_size += ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( unknown_fields()); } + int cached_size = ::google::protobuf::internal::ToCachedSize(total_size); GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); - _cached_size_ = total_size; + _cached_size_ = cached_size; GOOGLE_SAFE_CONCURRENT_WRITES_END(); return total_size; } void PythonParameter::MergeFrom(const ::google::protobuf::Message& from) { - GOOGLE_CHECK_NE(&from, this); +// @@protoc_insertion_point(generalized_merge_from_start:caffe.PythonParameter) + if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__); const PythonParameter* source = - ::google::protobuf::internal::dynamic_cast_if_available( - &from); + ::google::protobuf::internal::DynamicCastToGenerated( + &from); if (source == NULL) { + // @@protoc_insertion_point(generalized_merge_from_cast_fail:caffe.PythonParameter) ::google::protobuf::internal::ReflectionOps::Merge(from, this); } else { - MergeFrom(*source); + // @@protoc_insertion_point(generalized_merge_from_cast_success:caffe.PythonParameter) + UnsafeMergeFrom(*source); } } void PythonParameter::MergeFrom(const PythonParameter& from) { - GOOGLE_CHECK_NE(&from, this); +// @@protoc_insertion_point(class_specific_merge_from_start:caffe.PythonParameter) + if (GOOGLE_PREDICT_TRUE(&from != this)) { + UnsafeMergeFrom(from); + } else { + MergeFromFail(__LINE__); + } +} + +void PythonParameter::UnsafeMergeFrom(const PythonParameter& from) { + GOOGLE_DCHECK(&from != this); if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) { if (from.has_module()) { - set_module(from.module()); + set_has_module(); + module_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.module_); } if (from.has_layer()) { - set_layer(from.layer()); + set_has_layer(); + layer_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.layer_); } } - mutable_unknown_fields()->MergeFrom(from.unknown_fields()); + if (from._internal_metadata_.have_unknown_fields()) { + ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata( + from.unknown_fields(), &_internal_metadata_); + } } void PythonParameter::CopyFrom(const ::google::protobuf::Message& from) { +// @@protoc_insertion_point(generalized_copy_from_start:caffe.PythonParameter) if (&from == this) return; Clear(); MergeFrom(from); } void PythonParameter::CopyFrom(const PythonParameter& from) { +// @@protoc_insertion_point(class_specific_copy_from_start:caffe.PythonParameter) if (&from == this) return; Clear(); - MergeFrom(from); + UnsafeMergeFrom(from); } bool PythonParameter::IsInitialized() const { @@ -21589,13 +32572,15 @@ bool PythonParameter::IsInitialized() const { } void PythonParameter::Swap(PythonParameter* other) { - if (other != this) { - std::swap(module_, other->module_); - std::swap(layer_, other->layer_); - std::swap(_has_bits_[0], other->_has_bits_[0]); - _unknown_fields_.Swap(&other->_unknown_fields_); - std::swap(_cached_size_, other->_cached_size_); - } + if (other == this) return; + InternalSwap(other); +} +void PythonParameter::InternalSwap(PythonParameter* other) { + module_.Swap(&other->module_); + layer_.Swap(&other->layer_); + std::swap(_has_bits_[0], other->_has_bits_[0]); + _internal_metadata_.Swap(&other->_internal_metadata_); + std::swap(_cached_size_, other->_cached_size_); } ::google::protobuf::Metadata PythonParameter::GetMetadata() const { @@ -21606,6 +32591,121 @@ void PythonParameter::Swap(PythonParameter* other) { return metadata; } +#if PROTOBUF_INLINE_NOT_IN_HEADERS +// PythonParameter + +// optional string module = 1; +bool PythonParameter::has_module() const { + return (_has_bits_[0] & 0x00000001u) != 0; +} +void PythonParameter::set_has_module() { + _has_bits_[0] |= 0x00000001u; +} +void PythonParameter::clear_has_module() { + _has_bits_[0] &= ~0x00000001u; +} +void PythonParameter::clear_module() { + module_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + clear_has_module(); +} +const ::std::string& PythonParameter::module() const { + // @@protoc_insertion_point(field_get:caffe.PythonParameter.module) + return module_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); +} +void PythonParameter::set_module(const ::std::string& value) { + set_has_module(); + module_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); + // @@protoc_insertion_point(field_set:caffe.PythonParameter.module) +} +void PythonParameter::set_module(const char* value) { + set_has_module(); + module_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); + // @@protoc_insertion_point(field_set_char:caffe.PythonParameter.module) +} +void PythonParameter::set_module(const char* value, size_t size) { + set_has_module(); + module_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), + ::std::string(reinterpret_cast(value), size)); + // @@protoc_insertion_point(field_set_pointer:caffe.PythonParameter.module) +} +::std::string* PythonParameter::mutable_module() { + set_has_module(); + // @@protoc_insertion_point(field_mutable:caffe.PythonParameter.module) + return module_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); +} +::std::string* PythonParameter::release_module() { + // @@protoc_insertion_point(field_release:caffe.PythonParameter.module) + clear_has_module(); + return module_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); +} +void PythonParameter::set_allocated_module(::std::string* module) { + if (module != NULL) { + set_has_module(); + } else { + clear_has_module(); + } + module_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), module); + // @@protoc_insertion_point(field_set_allocated:caffe.PythonParameter.module) +} + +// optional string layer = 2; +bool PythonParameter::has_layer() const { + return (_has_bits_[0] & 0x00000002u) != 0; +} +void PythonParameter::set_has_layer() { + _has_bits_[0] |= 0x00000002u; +} +void PythonParameter::clear_has_layer() { + _has_bits_[0] &= ~0x00000002u; +} +void PythonParameter::clear_layer() { + layer_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + clear_has_layer(); +} +const ::std::string& PythonParameter::layer() const { + // @@protoc_insertion_point(field_get:caffe.PythonParameter.layer) + return layer_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); +} +void PythonParameter::set_layer(const ::std::string& value) { + set_has_layer(); + layer_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); + // @@protoc_insertion_point(field_set:caffe.PythonParameter.layer) +} +void PythonParameter::set_layer(const char* value) { + set_has_layer(); + layer_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); + // @@protoc_insertion_point(field_set_char:caffe.PythonParameter.layer) +} +void PythonParameter::set_layer(const char* value, size_t size) { + set_has_layer(); + layer_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), + ::std::string(reinterpret_cast(value), size)); + // @@protoc_insertion_point(field_set_pointer:caffe.PythonParameter.layer) +} +::std::string* PythonParameter::mutable_layer() { + set_has_layer(); + // @@protoc_insertion_point(field_mutable:caffe.PythonParameter.layer) + return layer_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); +} +::std::string* PythonParameter::release_layer() { + // @@protoc_insertion_point(field_release:caffe.PythonParameter.layer) + clear_has_layer(); + return layer_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); +} +void PythonParameter::set_allocated_layer(::std::string* layer) { + if (layer != NULL) { + set_has_layer(); + } else { + clear_has_layer(); + } + layer_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), layer); + // @@protoc_insertion_point(field_set_allocated:caffe.PythonParameter.layer) +} + +inline const PythonParameter* PythonParameter::internal_default_instance() { + return &PythonParameter_default_instance_.get(); +} +#endif // PROTOBUF_INLINE_NOT_IN_HEADERS // =================================================================== @@ -21614,7 +32714,7 @@ const ::google::protobuf::EnumDescriptor* ReductionParameter_ReductionOp_descrip return ReductionParameter_ReductionOp_descriptor_; } bool ReductionParameter_ReductionOp_IsValid(int value) { - switch(value) { + switch (value) { case 1: case 2: case 3: @@ -21625,7 +32725,7 @@ bool ReductionParameter_ReductionOp_IsValid(int value) { } } -#ifndef _MSC_VER +#if !defined(_MSC_VER) || _MSC_VER >= 1900 const ReductionParameter_ReductionOp ReductionParameter::SUM; const ReductionParameter_ReductionOp ReductionParameter::ASUM; const ReductionParameter_ReductionOp ReductionParameter::SUMSQ; @@ -21633,42 +32733,44 @@ const ReductionParameter_ReductionOp ReductionParameter::MEAN; const ReductionParameter_ReductionOp ReductionParameter::ReductionOp_MIN; const ReductionParameter_ReductionOp ReductionParameter::ReductionOp_MAX; const int ReductionParameter::ReductionOp_ARRAYSIZE; -#endif // _MSC_VER -#ifndef _MSC_VER +#endif // !defined(_MSC_VER) || _MSC_VER >= 1900 +#if !defined(_MSC_VER) || _MSC_VER >= 1900 const int ReductionParameter::kOperationFieldNumber; const int ReductionParameter::kAxisFieldNumber; const int ReductionParameter::kCoeffFieldNumber; -#endif // !_MSC_VER +#endif // !defined(_MSC_VER) || _MSC_VER >= 1900 ReductionParameter::ReductionParameter() - : ::google::protobuf::Message() { + : ::google::protobuf::Message(), _internal_metadata_(NULL) { + if (this != internal_default_instance()) protobuf_InitDefaults_caffe_2eproto(); SharedCtor(); + // @@protoc_insertion_point(constructor:caffe.ReductionParameter) } void ReductionParameter::InitAsDefaultInstance() { } ReductionParameter::ReductionParameter(const ReductionParameter& from) - : ::google::protobuf::Message() { + : ::google::protobuf::Message(), + _internal_metadata_(NULL) { SharedCtor(); - MergeFrom(from); + UnsafeMergeFrom(from); + // @@protoc_insertion_point(copy_constructor:caffe.ReductionParameter) } void ReductionParameter::SharedCtor() { _cached_size_ = 0; - operation_ = 1; axis_ = 0; + operation_ = 1; coeff_ = 1; - ::memset(_has_bits_, 0, sizeof(_has_bits_)); } ReductionParameter::~ReductionParameter() { + // @@protoc_insertion_point(destructor:caffe.ReductionParameter) SharedDtor(); } void ReductionParameter::SharedDtor() { - if (this != default_instance_) { - } } void ReductionParameter::SetCachedSize(int size) const { @@ -21682,36 +32784,46 @@ const ::google::protobuf::Descriptor* ReductionParameter::descriptor() { } const ReductionParameter& ReductionParameter::default_instance() { - if (default_instance_ == NULL) protobuf_AddDesc_caffe_2eproto(); - return *default_instance_; + protobuf_InitDefaults_caffe_2eproto(); + return *internal_default_instance(); } -ReductionParameter* ReductionParameter::default_instance_ = NULL; +::google::protobuf::internal::ExplicitlyConstructed ReductionParameter_default_instance_; -ReductionParameter* ReductionParameter::New() const { - return new ReductionParameter; +ReductionParameter* ReductionParameter::New(::google::protobuf::Arena* arena) const { + ReductionParameter* n = new ReductionParameter; + if (arena != NULL) { + arena->Own(n); + } + return n; } void ReductionParameter::Clear() { - if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) { +// @@protoc_insertion_point(message_clear_start:caffe.ReductionParameter) + if (_has_bits_[0 / 32] & 7u) { operation_ = 1; axis_ = 0; coeff_ = 1; } - ::memset(_has_bits_, 0, sizeof(_has_bits_)); - mutable_unknown_fields()->Clear(); + _has_bits_.Clear(); + if (_internal_metadata_.have_unknown_fields()) { + mutable_unknown_fields()->Clear(); + } } bool ReductionParameter::MergePartialFromCodedStream( ::google::protobuf::io::CodedInputStream* input) { -#define DO_(EXPRESSION) if (!(EXPRESSION)) return false +#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure ::google::protobuf::uint32 tag; - while ((tag = input->ReadTag()) != 0) { + // @@protoc_insertion_point(parse_start:caffe.ReductionParameter) + for (;;) { + ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127); + tag = p.first; + if (!p.second) goto handle_unusual; switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { // optional .caffe.ReductionParameter.ReductionOp operation = 1 [default = SUM]; case 1: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) { + if (tag == 8) { int value; DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< int, ::google::protobuf::internal::WireFormatLite::TYPE_ENUM>( @@ -21722,7 +32834,7 @@ bool ReductionParameter::MergePartialFromCodedStream( mutable_unknown_fields()->AddVarint(1, value); } } else { - goto handle_uninterpreted; + goto handle_unusual; } if (input->ExpectTag(16)) goto parse_axis; break; @@ -21730,15 +32842,14 @@ bool ReductionParameter::MergePartialFromCodedStream( // optional int32 axis = 2 [default = 0]; case 2: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) { + if (tag == 16) { parse_axis: + set_has_axis(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>( input, &axis_))); - set_has_axis(); } else { - goto handle_uninterpreted; + goto handle_unusual; } if (input->ExpectTag(29)) goto parse_coeff; break; @@ -21746,25 +32857,25 @@ bool ReductionParameter::MergePartialFromCodedStream( // optional float coeff = 3 [default = 1]; case 3: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_FIXED32) { + if (tag == 29) { parse_coeff: + set_has_coeff(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< float, ::google::protobuf::internal::WireFormatLite::TYPE_FLOAT>( input, &coeff_))); - set_has_coeff(); } else { - goto handle_uninterpreted; + goto handle_unusual; } - if (input->ExpectAtEnd()) return true; + if (input->ExpectAtEnd()) goto success; break; } default: { - handle_uninterpreted: - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == + handle_unusual: + if (tag == 0 || + ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) { - return true; + goto success; } DO_(::google::protobuf::internal::WireFormat::SkipField( input, tag, mutable_unknown_fields())); @@ -21772,12 +32883,18 @@ bool ReductionParameter::MergePartialFromCodedStream( } } } +success: + // @@protoc_insertion_point(parse_success:caffe.ReductionParameter) return true; +failure: + // @@protoc_insertion_point(parse_failure:caffe.ReductionParameter) + return false; #undef DO_ } void ReductionParameter::SerializeWithCachedSizes( ::google::protobuf::io::CodedOutputStream* output) const { + // @@protoc_insertion_point(serialize_start:caffe.ReductionParameter) // optional .caffe.ReductionParameter.ReductionOp operation = 1 [default = SUM]; if (has_operation()) { ::google::protobuf::internal::WireFormatLite::WriteEnum( @@ -21794,14 +32911,17 @@ void ReductionParameter::SerializeWithCachedSizes( ::google::protobuf::internal::WireFormatLite::WriteFloat(3, this->coeff(), output); } - if (!unknown_fields().empty()) { + if (_internal_metadata_.have_unknown_fields()) { ::google::protobuf::internal::WireFormat::SerializeUnknownFields( unknown_fields(), output); } + // @@protoc_insertion_point(serialize_end:caffe.ReductionParameter) } -::google::protobuf::uint8* ReductionParameter::SerializeWithCachedSizesToArray( - ::google::protobuf::uint8* target) const { +::google::protobuf::uint8* ReductionParameter::InternalSerializeWithCachedSizesToArray( + bool deterministic, ::google::protobuf::uint8* target) const { + (void)deterministic; // Unused + // @@protoc_insertion_point(serialize_to_array_start:caffe.ReductionParameter) // optional .caffe.ReductionParameter.ReductionOp operation = 1 [default = SUM]; if (has_operation()) { target = ::google::protobuf::internal::WireFormatLite::WriteEnumToArray( @@ -21818,17 +32938,19 @@ void ReductionParameter::SerializeWithCachedSizes( target = ::google::protobuf::internal::WireFormatLite::WriteFloatToArray(3, this->coeff(), target); } - if (!unknown_fields().empty()) { + if (_internal_metadata_.have_unknown_fields()) { target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray( unknown_fields(), target); } + // @@protoc_insertion_point(serialize_to_array_end:caffe.ReductionParameter) return target; } -int ReductionParameter::ByteSize() const { - int total_size = 0; +size_t ReductionParameter::ByteSizeLong() const { +// @@protoc_insertion_point(message_byte_size_start:caffe.ReductionParameter) + size_t total_size = 0; - if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) { + if (_has_bits_[0 / 32] & 7u) { // optional .caffe.ReductionParameter.ReductionOp operation = 1 [default = SUM]; if (has_operation()) { total_size += 1 + @@ -21848,31 +32970,44 @@ int ReductionParameter::ByteSize() const { } } - if (!unknown_fields().empty()) { + if (_internal_metadata_.have_unknown_fields()) { total_size += ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( unknown_fields()); } + int cached_size = ::google::protobuf::internal::ToCachedSize(total_size); GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); - _cached_size_ = total_size; + _cached_size_ = cached_size; GOOGLE_SAFE_CONCURRENT_WRITES_END(); return total_size; } void ReductionParameter::MergeFrom(const ::google::protobuf::Message& from) { - GOOGLE_CHECK_NE(&from, this); +// @@protoc_insertion_point(generalized_merge_from_start:caffe.ReductionParameter) + if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__); const ReductionParameter* source = - ::google::protobuf::internal::dynamic_cast_if_available( - &from); + ::google::protobuf::internal::DynamicCastToGenerated( + &from); if (source == NULL) { + // @@protoc_insertion_point(generalized_merge_from_cast_fail:caffe.ReductionParameter) ::google::protobuf::internal::ReflectionOps::Merge(from, this); } else { - MergeFrom(*source); + // @@protoc_insertion_point(generalized_merge_from_cast_success:caffe.ReductionParameter) + UnsafeMergeFrom(*source); } } void ReductionParameter::MergeFrom(const ReductionParameter& from) { - GOOGLE_CHECK_NE(&from, this); +// @@protoc_insertion_point(class_specific_merge_from_start:caffe.ReductionParameter) + if (GOOGLE_PREDICT_TRUE(&from != this)) { + UnsafeMergeFrom(from); + } else { + MergeFromFail(__LINE__); + } +} + +void ReductionParameter::UnsafeMergeFrom(const ReductionParameter& from) { + GOOGLE_DCHECK(&from != this); if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) { if (from.has_operation()) { set_operation(from.operation()); @@ -21884,19 +33019,24 @@ void ReductionParameter::MergeFrom(const ReductionParameter& from) { set_coeff(from.coeff()); } } - mutable_unknown_fields()->MergeFrom(from.unknown_fields()); + if (from._internal_metadata_.have_unknown_fields()) { + ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata( + from.unknown_fields(), &_internal_metadata_); + } } void ReductionParameter::CopyFrom(const ::google::protobuf::Message& from) { +// @@protoc_insertion_point(generalized_copy_from_start:caffe.ReductionParameter) if (&from == this) return; Clear(); MergeFrom(from); } void ReductionParameter::CopyFrom(const ReductionParameter& from) { +// @@protoc_insertion_point(class_specific_copy_from_start:caffe.ReductionParameter) if (&from == this) return; Clear(); - MergeFrom(from); + UnsafeMergeFrom(from); } bool ReductionParameter::IsInitialized() const { @@ -21905,14 +33045,16 @@ bool ReductionParameter::IsInitialized() const { } void ReductionParameter::Swap(ReductionParameter* other) { - if (other != this) { - std::swap(operation_, other->operation_); - std::swap(axis_, other->axis_); - std::swap(coeff_, other->coeff_); - std::swap(_has_bits_[0], other->_has_bits_[0]); - _unknown_fields_.Swap(&other->_unknown_fields_); - std::swap(_cached_size_, other->_cached_size_); - } + if (other == this) return; + InternalSwap(other); +} +void ReductionParameter::InternalSwap(ReductionParameter* other) { + std::swap(operation_, other->operation_); + std::swap(axis_, other->axis_); + std::swap(coeff_, other->coeff_); + std::swap(_has_bits_[0], other->_has_bits_[0]); + _internal_metadata_.Swap(&other->_internal_metadata_); + std::swap(_cached_size_, other->_cached_size_); } ::google::protobuf::Metadata ReductionParameter::GetMetadata() const { @@ -21923,6 +33065,86 @@ void ReductionParameter::Swap(ReductionParameter* other) { return metadata; } +#if PROTOBUF_INLINE_NOT_IN_HEADERS +// ReductionParameter + +// optional .caffe.ReductionParameter.ReductionOp operation = 1 [default = SUM]; +bool ReductionParameter::has_operation() const { + return (_has_bits_[0] & 0x00000001u) != 0; +} +void ReductionParameter::set_has_operation() { + _has_bits_[0] |= 0x00000001u; +} +void ReductionParameter::clear_has_operation() { + _has_bits_[0] &= ~0x00000001u; +} +void ReductionParameter::clear_operation() { + operation_ = 1; + clear_has_operation(); +} +::caffe::ReductionParameter_ReductionOp ReductionParameter::operation() const { + // @@protoc_insertion_point(field_get:caffe.ReductionParameter.operation) + return static_cast< ::caffe::ReductionParameter_ReductionOp >(operation_); +} +void ReductionParameter::set_operation(::caffe::ReductionParameter_ReductionOp value) { + assert(::caffe::ReductionParameter_ReductionOp_IsValid(value)); + set_has_operation(); + operation_ = value; + // @@protoc_insertion_point(field_set:caffe.ReductionParameter.operation) +} + +// optional int32 axis = 2 [default = 0]; +bool ReductionParameter::has_axis() const { + return (_has_bits_[0] & 0x00000002u) != 0; +} +void ReductionParameter::set_has_axis() { + _has_bits_[0] |= 0x00000002u; +} +void ReductionParameter::clear_has_axis() { + _has_bits_[0] &= ~0x00000002u; +} +void ReductionParameter::clear_axis() { + axis_ = 0; + clear_has_axis(); +} +::google::protobuf::int32 ReductionParameter::axis() const { + // @@protoc_insertion_point(field_get:caffe.ReductionParameter.axis) + return axis_; +} +void ReductionParameter::set_axis(::google::protobuf::int32 value) { + set_has_axis(); + axis_ = value; + // @@protoc_insertion_point(field_set:caffe.ReductionParameter.axis) +} + +// optional float coeff = 3 [default = 1]; +bool ReductionParameter::has_coeff() const { + return (_has_bits_[0] & 0x00000004u) != 0; +} +void ReductionParameter::set_has_coeff() { + _has_bits_[0] |= 0x00000004u; +} +void ReductionParameter::clear_has_coeff() { + _has_bits_[0] &= ~0x00000004u; +} +void ReductionParameter::clear_coeff() { + coeff_ = 1; + clear_has_coeff(); +} +float ReductionParameter::coeff() const { + // @@protoc_insertion_point(field_get:caffe.ReductionParameter.coeff) + return coeff_; +} +void ReductionParameter::set_coeff(float value) { + set_has_coeff(); + coeff_ = value; + // @@protoc_insertion_point(field_set:caffe.ReductionParameter.coeff) +} + +inline const ReductionParameter* ReductionParameter::internal_default_instance() { + return &ReductionParameter_default_instance_.get(); +} +#endif // PROTOBUF_INLINE_NOT_IN_HEADERS // =================================================================== @@ -21931,7 +33153,7 @@ const ::google::protobuf::EnumDescriptor* ReLUParameter_Engine_descriptor() { return ReLUParameter_Engine_descriptor_; } bool ReLUParameter_Engine_IsValid(int value) { - switch(value) { + switch (value) { case 0: case 1: case 2: @@ -21941,47 +33163,49 @@ bool ReLUParameter_Engine_IsValid(int value) { } } -#ifndef _MSC_VER +#if !defined(_MSC_VER) || _MSC_VER >= 1900 const ReLUParameter_Engine ReLUParameter::DEFAULT; const ReLUParameter_Engine ReLUParameter::CAFFE; const ReLUParameter_Engine ReLUParameter::CUDNN; const ReLUParameter_Engine ReLUParameter::Engine_MIN; const ReLUParameter_Engine ReLUParameter::Engine_MAX; const int ReLUParameter::Engine_ARRAYSIZE; -#endif // _MSC_VER -#ifndef _MSC_VER +#endif // !defined(_MSC_VER) || _MSC_VER >= 1900 +#if !defined(_MSC_VER) || _MSC_VER >= 1900 const int ReLUParameter::kNegativeSlopeFieldNumber; const int ReLUParameter::kEngineFieldNumber; -#endif // !_MSC_VER +#endif // !defined(_MSC_VER) || _MSC_VER >= 1900 ReLUParameter::ReLUParameter() - : ::google::protobuf::Message() { + : ::google::protobuf::Message(), _internal_metadata_(NULL) { + if (this != internal_default_instance()) protobuf_InitDefaults_caffe_2eproto(); SharedCtor(); + // @@protoc_insertion_point(constructor:caffe.ReLUParameter) } void ReLUParameter::InitAsDefaultInstance() { } ReLUParameter::ReLUParameter(const ReLUParameter& from) - : ::google::protobuf::Message() { + : ::google::protobuf::Message(), + _internal_metadata_(NULL) { SharedCtor(); - MergeFrom(from); + UnsafeMergeFrom(from); + // @@protoc_insertion_point(copy_constructor:caffe.ReLUParameter) } void ReLUParameter::SharedCtor() { _cached_size_ = 0; - negative_slope_ = 0; - engine_ = 0; - ::memset(_has_bits_, 0, sizeof(_has_bits_)); + ::memset(&negative_slope_, 0, reinterpret_cast(&engine_) - + reinterpret_cast(&negative_slope_) + sizeof(engine_)); } ReLUParameter::~ReLUParameter() { + // @@protoc_insertion_point(destructor:caffe.ReLUParameter) SharedDtor(); } void ReLUParameter::SharedDtor() { - if (this != default_instance_) { - } } void ReLUParameter::SetCachedSize(int size) const { @@ -21995,41 +33219,68 @@ const ::google::protobuf::Descriptor* ReLUParameter::descriptor() { } const ReLUParameter& ReLUParameter::default_instance() { - if (default_instance_ == NULL) protobuf_AddDesc_caffe_2eproto(); - return *default_instance_; + protobuf_InitDefaults_caffe_2eproto(); + return *internal_default_instance(); } -ReLUParameter* ReLUParameter::default_instance_ = NULL; +::google::protobuf::internal::ExplicitlyConstructed ReLUParameter_default_instance_; -ReLUParameter* ReLUParameter::New() const { - return new ReLUParameter; +ReLUParameter* ReLUParameter::New(::google::protobuf::Arena* arena) const { + ReLUParameter* n = new ReLUParameter; + if (arena != NULL) { + arena->Own(n); + } + return n; } void ReLUParameter::Clear() { - if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) { - negative_slope_ = 0; - engine_ = 0; +// @@protoc_insertion_point(message_clear_start:caffe.ReLUParameter) +#if defined(__clang__) +#define ZR_HELPER_(f) \ + _Pragma("clang diagnostic push") \ + _Pragma("clang diagnostic ignored \"-Winvalid-offsetof\"") \ + __builtin_offsetof(ReLUParameter, f) \ + _Pragma("clang diagnostic pop") +#else +#define ZR_HELPER_(f) reinterpret_cast(\ + &reinterpret_cast(16)->f) +#endif + +#define ZR_(first, last) do {\ + ::memset(&(first), 0,\ + ZR_HELPER_(last) - ZR_HELPER_(first) + sizeof(last));\ +} while (0) + + ZR_(negative_slope_, engine_); + +#undef ZR_HELPER_ +#undef ZR_ + + _has_bits_.Clear(); + if (_internal_metadata_.have_unknown_fields()) { + mutable_unknown_fields()->Clear(); } - ::memset(_has_bits_, 0, sizeof(_has_bits_)); - mutable_unknown_fields()->Clear(); } bool ReLUParameter::MergePartialFromCodedStream( ::google::protobuf::io::CodedInputStream* input) { -#define DO_(EXPRESSION) if (!(EXPRESSION)) return false +#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure ::google::protobuf::uint32 tag; - while ((tag = input->ReadTag()) != 0) { + // @@protoc_insertion_point(parse_start:caffe.ReLUParameter) + for (;;) { + ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127); + tag = p.first; + if (!p.second) goto handle_unusual; switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { // optional float negative_slope = 1 [default = 0]; case 1: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_FIXED32) { + if (tag == 13) { + set_has_negative_slope(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< float, ::google::protobuf::internal::WireFormatLite::TYPE_FLOAT>( input, &negative_slope_))); - set_has_negative_slope(); } else { - goto handle_uninterpreted; + goto handle_unusual; } if (input->ExpectTag(16)) goto parse_engine; break; @@ -22037,8 +33288,7 @@ bool ReLUParameter::MergePartialFromCodedStream( // optional .caffe.ReLUParameter.Engine engine = 2 [default = DEFAULT]; case 2: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) { + if (tag == 16) { parse_engine: int value; DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< @@ -22050,17 +33300,18 @@ bool ReLUParameter::MergePartialFromCodedStream( mutable_unknown_fields()->AddVarint(2, value); } } else { - goto handle_uninterpreted; + goto handle_unusual; } - if (input->ExpectAtEnd()) return true; + if (input->ExpectAtEnd()) goto success; break; } default: { - handle_uninterpreted: - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == + handle_unusual: + if (tag == 0 || + ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) { - return true; + goto success; } DO_(::google::protobuf::internal::WireFormat::SkipField( input, tag, mutable_unknown_fields())); @@ -22068,12 +33319,18 @@ bool ReLUParameter::MergePartialFromCodedStream( } } } +success: + // @@protoc_insertion_point(parse_success:caffe.ReLUParameter) return true; +failure: + // @@protoc_insertion_point(parse_failure:caffe.ReLUParameter) + return false; #undef DO_ } void ReLUParameter::SerializeWithCachedSizes( ::google::protobuf::io::CodedOutputStream* output) const { + // @@protoc_insertion_point(serialize_start:caffe.ReLUParameter) // optional float negative_slope = 1 [default = 0]; if (has_negative_slope()) { ::google::protobuf::internal::WireFormatLite::WriteFloat(1, this->negative_slope(), output); @@ -22085,14 +33342,17 @@ void ReLUParameter::SerializeWithCachedSizes( 2, this->engine(), output); } - if (!unknown_fields().empty()) { + if (_internal_metadata_.have_unknown_fields()) { ::google::protobuf::internal::WireFormat::SerializeUnknownFields( unknown_fields(), output); } + // @@protoc_insertion_point(serialize_end:caffe.ReLUParameter) } -::google::protobuf::uint8* ReLUParameter::SerializeWithCachedSizesToArray( - ::google::protobuf::uint8* target) const { +::google::protobuf::uint8* ReLUParameter::InternalSerializeWithCachedSizesToArray( + bool deterministic, ::google::protobuf::uint8* target) const { + (void)deterministic; // Unused + // @@protoc_insertion_point(serialize_to_array_start:caffe.ReLUParameter) // optional float negative_slope = 1 [default = 0]; if (has_negative_slope()) { target = ::google::protobuf::internal::WireFormatLite::WriteFloatToArray(1, this->negative_slope(), target); @@ -22104,17 +33364,19 @@ void ReLUParameter::SerializeWithCachedSizes( 2, this->engine(), target); } - if (!unknown_fields().empty()) { + if (_internal_metadata_.have_unknown_fields()) { target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray( unknown_fields(), target); } + // @@protoc_insertion_point(serialize_to_array_end:caffe.ReLUParameter) return target; } -int ReLUParameter::ByteSize() const { - int total_size = 0; +size_t ReLUParameter::ByteSizeLong() const { +// @@protoc_insertion_point(message_byte_size_start:caffe.ReLUParameter) + size_t total_size = 0; - if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) { + if (_has_bits_[0 / 32] & 3u) { // optional float negative_slope = 1 [default = 0]; if (has_negative_slope()) { total_size += 1 + 4; @@ -22127,31 +33389,44 @@ int ReLUParameter::ByteSize() const { } } - if (!unknown_fields().empty()) { + if (_internal_metadata_.have_unknown_fields()) { total_size += ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( unknown_fields()); } + int cached_size = ::google::protobuf::internal::ToCachedSize(total_size); GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); - _cached_size_ = total_size; + _cached_size_ = cached_size; GOOGLE_SAFE_CONCURRENT_WRITES_END(); return total_size; } void ReLUParameter::MergeFrom(const ::google::protobuf::Message& from) { - GOOGLE_CHECK_NE(&from, this); +// @@protoc_insertion_point(generalized_merge_from_start:caffe.ReLUParameter) + if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__); const ReLUParameter* source = - ::google::protobuf::internal::dynamic_cast_if_available( - &from); + ::google::protobuf::internal::DynamicCastToGenerated( + &from); if (source == NULL) { + // @@protoc_insertion_point(generalized_merge_from_cast_fail:caffe.ReLUParameter) ::google::protobuf::internal::ReflectionOps::Merge(from, this); } else { - MergeFrom(*source); + // @@protoc_insertion_point(generalized_merge_from_cast_success:caffe.ReLUParameter) + UnsafeMergeFrom(*source); } } void ReLUParameter::MergeFrom(const ReLUParameter& from) { - GOOGLE_CHECK_NE(&from, this); +// @@protoc_insertion_point(class_specific_merge_from_start:caffe.ReLUParameter) + if (GOOGLE_PREDICT_TRUE(&from != this)) { + UnsafeMergeFrom(from); + } else { + MergeFromFail(__LINE__); + } +} + +void ReLUParameter::UnsafeMergeFrom(const ReLUParameter& from) { + GOOGLE_DCHECK(&from != this); if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) { if (from.has_negative_slope()) { set_negative_slope(from.negative_slope()); @@ -22160,19 +33435,24 @@ void ReLUParameter::MergeFrom(const ReLUParameter& from) { set_engine(from.engine()); } } - mutable_unknown_fields()->MergeFrom(from.unknown_fields()); + if (from._internal_metadata_.have_unknown_fields()) { + ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata( + from.unknown_fields(), &_internal_metadata_); + } } void ReLUParameter::CopyFrom(const ::google::protobuf::Message& from) { +// @@protoc_insertion_point(generalized_copy_from_start:caffe.ReLUParameter) if (&from == this) return; Clear(); MergeFrom(from); } void ReLUParameter::CopyFrom(const ReLUParameter& from) { +// @@protoc_insertion_point(class_specific_copy_from_start:caffe.ReLUParameter) if (&from == this) return; Clear(); - MergeFrom(from); + UnsafeMergeFrom(from); } bool ReLUParameter::IsInitialized() const { @@ -22181,13 +33461,15 @@ bool ReLUParameter::IsInitialized() const { } void ReLUParameter::Swap(ReLUParameter* other) { - if (other != this) { - std::swap(negative_slope_, other->negative_slope_); - std::swap(engine_, other->engine_); - std::swap(_has_bits_[0], other->_has_bits_[0]); - _unknown_fields_.Swap(&other->_unknown_fields_); - std::swap(_cached_size_, other->_cached_size_); - } + if (other == this) return; + InternalSwap(other); +} +void ReLUParameter::InternalSwap(ReLUParameter* other) { + std::swap(negative_slope_, other->negative_slope_); + std::swap(engine_, other->engine_); + std::swap(_has_bits_[0], other->_has_bits_[0]); + _internal_metadata_.Swap(&other->_internal_metadata_); + std::swap(_cached_size_, other->_cached_size_); } ::google::protobuf::Metadata ReLUParameter::GetMetadata() const { @@ -22198,28 +33480,89 @@ void ReLUParameter::Swap(ReLUParameter* other) { return metadata; } +#if PROTOBUF_INLINE_NOT_IN_HEADERS +// ReLUParameter + +// optional float negative_slope = 1 [default = 0]; +bool ReLUParameter::has_negative_slope() const { + return (_has_bits_[0] & 0x00000001u) != 0; +} +void ReLUParameter::set_has_negative_slope() { + _has_bits_[0] |= 0x00000001u; +} +void ReLUParameter::clear_has_negative_slope() { + _has_bits_[0] &= ~0x00000001u; +} +void ReLUParameter::clear_negative_slope() { + negative_slope_ = 0; + clear_has_negative_slope(); +} +float ReLUParameter::negative_slope() const { + // @@protoc_insertion_point(field_get:caffe.ReLUParameter.negative_slope) + return negative_slope_; +} +void ReLUParameter::set_negative_slope(float value) { + set_has_negative_slope(); + negative_slope_ = value; + // @@protoc_insertion_point(field_set:caffe.ReLUParameter.negative_slope) +} + +// optional .caffe.ReLUParameter.Engine engine = 2 [default = DEFAULT]; +bool ReLUParameter::has_engine() const { + return (_has_bits_[0] & 0x00000002u) != 0; +} +void ReLUParameter::set_has_engine() { + _has_bits_[0] |= 0x00000002u; +} +void ReLUParameter::clear_has_engine() { + _has_bits_[0] &= ~0x00000002u; +} +void ReLUParameter::clear_engine() { + engine_ = 0; + clear_has_engine(); +} +::caffe::ReLUParameter_Engine ReLUParameter::engine() const { + // @@protoc_insertion_point(field_get:caffe.ReLUParameter.engine) + return static_cast< ::caffe::ReLUParameter_Engine >(engine_); +} +void ReLUParameter::set_engine(::caffe::ReLUParameter_Engine value) { + assert(::caffe::ReLUParameter_Engine_IsValid(value)); + set_has_engine(); + engine_ = value; + // @@protoc_insertion_point(field_set:caffe.ReLUParameter.engine) +} + +inline const ReLUParameter* ReLUParameter::internal_default_instance() { + return &ReLUParameter_default_instance_.get(); +} +#endif // PROTOBUF_INLINE_NOT_IN_HEADERS // =================================================================== -#ifndef _MSC_VER +#if !defined(_MSC_VER) || _MSC_VER >= 1900 const int ReshapeParameter::kShapeFieldNumber; const int ReshapeParameter::kAxisFieldNumber; const int ReshapeParameter::kNumAxesFieldNumber; -#endif // !_MSC_VER +#endif // !defined(_MSC_VER) || _MSC_VER >= 1900 ReshapeParameter::ReshapeParameter() - : ::google::protobuf::Message() { + : ::google::protobuf::Message(), _internal_metadata_(NULL) { + if (this != internal_default_instance()) protobuf_InitDefaults_caffe_2eproto(); SharedCtor(); + // @@protoc_insertion_point(constructor:caffe.ReshapeParameter) } void ReshapeParameter::InitAsDefaultInstance() { - shape_ = const_cast< ::caffe::BlobShape*>(&::caffe::BlobShape::default_instance()); + shape_ = const_cast< ::caffe::BlobShape*>( + ::caffe::BlobShape::internal_default_instance()); } ReshapeParameter::ReshapeParameter(const ReshapeParameter& from) - : ::google::protobuf::Message() { + : ::google::protobuf::Message(), + _internal_metadata_(NULL) { SharedCtor(); - MergeFrom(from); + UnsafeMergeFrom(from); + // @@protoc_insertion_point(copy_constructor:caffe.ReshapeParameter) } void ReshapeParameter::SharedCtor() { @@ -22227,15 +33570,15 @@ void ReshapeParameter::SharedCtor() { shape_ = NULL; axis_ = 0; num_axes_ = -1; - ::memset(_has_bits_, 0, sizeof(_has_bits_)); } ReshapeParameter::~ReshapeParameter() { + // @@protoc_insertion_point(destructor:caffe.ReshapeParameter) SharedDtor(); } void ReshapeParameter::SharedDtor() { - if (this != default_instance_) { + if (this != &ReshapeParameter_default_instance_.get()) { delete shape_; } } @@ -22251,42 +33594,52 @@ const ::google::protobuf::Descriptor* ReshapeParameter::descriptor() { } const ReshapeParameter& ReshapeParameter::default_instance() { - if (default_instance_ == NULL) protobuf_AddDesc_caffe_2eproto(); - return *default_instance_; + protobuf_InitDefaults_caffe_2eproto(); + return *internal_default_instance(); } -ReshapeParameter* ReshapeParameter::default_instance_ = NULL; +::google::protobuf::internal::ExplicitlyConstructed ReshapeParameter_default_instance_; -ReshapeParameter* ReshapeParameter::New() const { - return new ReshapeParameter; +ReshapeParameter* ReshapeParameter::New(::google::protobuf::Arena* arena) const { + ReshapeParameter* n = new ReshapeParameter; + if (arena != NULL) { + arena->Own(n); + } + return n; } void ReshapeParameter::Clear() { - if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) { +// @@protoc_insertion_point(message_clear_start:caffe.ReshapeParameter) + if (_has_bits_[0 / 32] & 7u) { if (has_shape()) { if (shape_ != NULL) shape_->::caffe::BlobShape::Clear(); } axis_ = 0; num_axes_ = -1; } - ::memset(_has_bits_, 0, sizeof(_has_bits_)); - mutable_unknown_fields()->Clear(); + _has_bits_.Clear(); + if (_internal_metadata_.have_unknown_fields()) { + mutable_unknown_fields()->Clear(); + } } bool ReshapeParameter::MergePartialFromCodedStream( ::google::protobuf::io::CodedInputStream* input) { -#define DO_(EXPRESSION) if (!(EXPRESSION)) return false +#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure ::google::protobuf::uint32 tag; - while ((tag = input->ReadTag()) != 0) { + // @@protoc_insertion_point(parse_start:caffe.ReshapeParameter) + for (;;) { + ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127); + tag = p.first; + if (!p.second) goto handle_unusual; switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { // optional .caffe.BlobShape shape = 1; case 1: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) { + if (tag == 10) { DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual( input, mutable_shape())); } else { - goto handle_uninterpreted; + goto handle_unusual; } if (input->ExpectTag(16)) goto parse_axis; break; @@ -22294,15 +33647,14 @@ bool ReshapeParameter::MergePartialFromCodedStream( // optional int32 axis = 2 [default = 0]; case 2: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) { + if (tag == 16) { parse_axis: + set_has_axis(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>( input, &axis_))); - set_has_axis(); } else { - goto handle_uninterpreted; + goto handle_unusual; } if (input->ExpectTag(24)) goto parse_num_axes; break; @@ -22310,25 +33662,25 @@ bool ReshapeParameter::MergePartialFromCodedStream( // optional int32 num_axes = 3 [default = -1]; case 3: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) { + if (tag == 24) { parse_num_axes: + set_has_num_axes(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>( input, &num_axes_))); - set_has_num_axes(); } else { - goto handle_uninterpreted; + goto handle_unusual; } - if (input->ExpectAtEnd()) return true; + if (input->ExpectAtEnd()) goto success; break; } default: { - handle_uninterpreted: - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == + handle_unusual: + if (tag == 0 || + ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) { - return true; + goto success; } DO_(::google::protobuf::internal::WireFormat::SkipField( input, tag, mutable_unknown_fields())); @@ -22336,16 +33688,22 @@ bool ReshapeParameter::MergePartialFromCodedStream( } } } +success: + // @@protoc_insertion_point(parse_success:caffe.ReshapeParameter) return true; +failure: + // @@protoc_insertion_point(parse_failure:caffe.ReshapeParameter) + return false; #undef DO_ } void ReshapeParameter::SerializeWithCachedSizes( ::google::protobuf::io::CodedOutputStream* output) const { + // @@protoc_insertion_point(serialize_start:caffe.ReshapeParameter) // optional .caffe.BlobShape shape = 1; if (has_shape()) { ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( - 1, this->shape(), output); + 1, *this->shape_, output); } // optional int32 axis = 2 [default = 0]; @@ -22358,19 +33716,22 @@ void ReshapeParameter::SerializeWithCachedSizes( ::google::protobuf::internal::WireFormatLite::WriteInt32(3, this->num_axes(), output); } - if (!unknown_fields().empty()) { + if (_internal_metadata_.have_unknown_fields()) { ::google::protobuf::internal::WireFormat::SerializeUnknownFields( unknown_fields(), output); } + // @@protoc_insertion_point(serialize_end:caffe.ReshapeParameter) } -::google::protobuf::uint8* ReshapeParameter::SerializeWithCachedSizesToArray( - ::google::protobuf::uint8* target) const { +::google::protobuf::uint8* ReshapeParameter::InternalSerializeWithCachedSizesToArray( + bool deterministic, ::google::protobuf::uint8* target) const { + (void)deterministic; // Unused + // @@protoc_insertion_point(serialize_to_array_start:caffe.ReshapeParameter) // optional .caffe.BlobShape shape = 1; if (has_shape()) { target = ::google::protobuf::internal::WireFormatLite:: - WriteMessageNoVirtualToArray( - 1, this->shape(), target); + InternalWriteMessageNoVirtualToArray( + 1, *this->shape_, false, target); } // optional int32 axis = 2 [default = 0]; @@ -22383,22 +33744,24 @@ void ReshapeParameter::SerializeWithCachedSizes( target = ::google::protobuf::internal::WireFormatLite::WriteInt32ToArray(3, this->num_axes(), target); } - if (!unknown_fields().empty()) { + if (_internal_metadata_.have_unknown_fields()) { target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray( unknown_fields(), target); } + // @@protoc_insertion_point(serialize_to_array_end:caffe.ReshapeParameter) return target; } -int ReshapeParameter::ByteSize() const { - int total_size = 0; +size_t ReshapeParameter::ByteSizeLong() const { +// @@protoc_insertion_point(message_byte_size_start:caffe.ReshapeParameter) + size_t total_size = 0; - if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) { + if (_has_bits_[0 / 32] & 7u) { // optional .caffe.BlobShape shape = 1; if (has_shape()) { total_size += 1 + ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( - this->shape()); + *this->shape_); } // optional int32 axis = 2 [default = 0]; @@ -22416,31 +33779,44 @@ int ReshapeParameter::ByteSize() const { } } - if (!unknown_fields().empty()) { + if (_internal_metadata_.have_unknown_fields()) { total_size += ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( unknown_fields()); } + int cached_size = ::google::protobuf::internal::ToCachedSize(total_size); GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); - _cached_size_ = total_size; + _cached_size_ = cached_size; GOOGLE_SAFE_CONCURRENT_WRITES_END(); return total_size; } void ReshapeParameter::MergeFrom(const ::google::protobuf::Message& from) { - GOOGLE_CHECK_NE(&from, this); +// @@protoc_insertion_point(generalized_merge_from_start:caffe.ReshapeParameter) + if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__); const ReshapeParameter* source = - ::google::protobuf::internal::dynamic_cast_if_available( - &from); + ::google::protobuf::internal::DynamicCastToGenerated( + &from); if (source == NULL) { + // @@protoc_insertion_point(generalized_merge_from_cast_fail:caffe.ReshapeParameter) ::google::protobuf::internal::ReflectionOps::Merge(from, this); } else { - MergeFrom(*source); + // @@protoc_insertion_point(generalized_merge_from_cast_success:caffe.ReshapeParameter) + UnsafeMergeFrom(*source); } } void ReshapeParameter::MergeFrom(const ReshapeParameter& from) { - GOOGLE_CHECK_NE(&from, this); +// @@protoc_insertion_point(class_specific_merge_from_start:caffe.ReshapeParameter) + if (GOOGLE_PREDICT_TRUE(&from != this)) { + UnsafeMergeFrom(from); + } else { + MergeFromFail(__LINE__); + } +} + +void ReshapeParameter::UnsafeMergeFrom(const ReshapeParameter& from) { + GOOGLE_DCHECK(&from != this); if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) { if (from.has_shape()) { mutable_shape()->::caffe::BlobShape::MergeFrom(from.shape()); @@ -22452,19 +33828,24 @@ void ReshapeParameter::MergeFrom(const ReshapeParameter& from) { set_num_axes(from.num_axes()); } } - mutable_unknown_fields()->MergeFrom(from.unknown_fields()); + if (from._internal_metadata_.have_unknown_fields()) { + ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata( + from.unknown_fields(), &_internal_metadata_); + } } void ReshapeParameter::CopyFrom(const ::google::protobuf::Message& from) { +// @@protoc_insertion_point(generalized_copy_from_start:caffe.ReshapeParameter) if (&from == this) return; Clear(); MergeFrom(from); } void ReshapeParameter::CopyFrom(const ReshapeParameter& from) { +// @@protoc_insertion_point(class_specific_copy_from_start:caffe.ReshapeParameter) if (&from == this) return; Clear(); - MergeFrom(from); + UnsafeMergeFrom(from); } bool ReshapeParameter::IsInitialized() const { @@ -22473,14 +33854,16 @@ bool ReshapeParameter::IsInitialized() const { } void ReshapeParameter::Swap(ReshapeParameter* other) { - if (other != this) { - std::swap(shape_, other->shape_); - std::swap(axis_, other->axis_); - std::swap(num_axes_, other->num_axes_); - std::swap(_has_bits_[0], other->_has_bits_[0]); - _unknown_fields_.Swap(&other->_unknown_fields_); - std::swap(_cached_size_, other->_cached_size_); - } + if (other == this) return; + InternalSwap(other); +} +void ReshapeParameter::InternalSwap(ReshapeParameter* other) { + std::swap(shape_, other->shape_); + std::swap(axis_, other->axis_); + std::swap(num_axes_, other->num_axes_); + std::swap(_has_bits_[0], other->_has_bits_[0]); + _internal_metadata_.Swap(&other->_internal_metadata_); + std::swap(_cached_size_, other->_cached_size_); } ::google::protobuf::Metadata ReshapeParameter::GetMetadata() const { @@ -22491,6 +33874,106 @@ void ReshapeParameter::Swap(ReshapeParameter* other) { return metadata; } +#if PROTOBUF_INLINE_NOT_IN_HEADERS +// ReshapeParameter + +// optional .caffe.BlobShape shape = 1; +bool ReshapeParameter::has_shape() const { + return (_has_bits_[0] & 0x00000001u) != 0; +} +void ReshapeParameter::set_has_shape() { + _has_bits_[0] |= 0x00000001u; +} +void ReshapeParameter::clear_has_shape() { + _has_bits_[0] &= ~0x00000001u; +} +void ReshapeParameter::clear_shape() { + if (shape_ != NULL) shape_->::caffe::BlobShape::Clear(); + clear_has_shape(); +} +const ::caffe::BlobShape& ReshapeParameter::shape() const { + // @@protoc_insertion_point(field_get:caffe.ReshapeParameter.shape) + return shape_ != NULL ? *shape_ + : *::caffe::BlobShape::internal_default_instance(); +} +::caffe::BlobShape* ReshapeParameter::mutable_shape() { + set_has_shape(); + if (shape_ == NULL) { + shape_ = new ::caffe::BlobShape; + } + // @@protoc_insertion_point(field_mutable:caffe.ReshapeParameter.shape) + return shape_; +} +::caffe::BlobShape* ReshapeParameter::release_shape() { + // @@protoc_insertion_point(field_release:caffe.ReshapeParameter.shape) + clear_has_shape(); + ::caffe::BlobShape* temp = shape_; + shape_ = NULL; + return temp; +} +void ReshapeParameter::set_allocated_shape(::caffe::BlobShape* shape) { + delete shape_; + shape_ = shape; + if (shape) { + set_has_shape(); + } else { + clear_has_shape(); + } + // @@protoc_insertion_point(field_set_allocated:caffe.ReshapeParameter.shape) +} + +// optional int32 axis = 2 [default = 0]; +bool ReshapeParameter::has_axis() const { + return (_has_bits_[0] & 0x00000002u) != 0; +} +void ReshapeParameter::set_has_axis() { + _has_bits_[0] |= 0x00000002u; +} +void ReshapeParameter::clear_has_axis() { + _has_bits_[0] &= ~0x00000002u; +} +void ReshapeParameter::clear_axis() { + axis_ = 0; + clear_has_axis(); +} +::google::protobuf::int32 ReshapeParameter::axis() const { + // @@protoc_insertion_point(field_get:caffe.ReshapeParameter.axis) + return axis_; +} +void ReshapeParameter::set_axis(::google::protobuf::int32 value) { + set_has_axis(); + axis_ = value; + // @@protoc_insertion_point(field_set:caffe.ReshapeParameter.axis) +} + +// optional int32 num_axes = 3 [default = -1]; +bool ReshapeParameter::has_num_axes() const { + return (_has_bits_[0] & 0x00000004u) != 0; +} +void ReshapeParameter::set_has_num_axes() { + _has_bits_[0] |= 0x00000004u; +} +void ReshapeParameter::clear_has_num_axes() { + _has_bits_[0] &= ~0x00000004u; +} +void ReshapeParameter::clear_num_axes() { + num_axes_ = -1; + clear_has_num_axes(); +} +::google::protobuf::int32 ReshapeParameter::num_axes() const { + // @@protoc_insertion_point(field_get:caffe.ReshapeParameter.num_axes) + return num_axes_; +} +void ReshapeParameter::set_num_axes(::google::protobuf::int32 value) { + set_has_num_axes(); + num_axes_ = value; + // @@protoc_insertion_point(field_set:caffe.ReshapeParameter.num_axes) +} + +inline const ReshapeParameter* ReshapeParameter::internal_default_instance() { + return &ReshapeParameter_default_instance_.get(); +} +#endif // PROTOBUF_INLINE_NOT_IN_HEADERS // =================================================================== @@ -22499,7 +33982,7 @@ const ::google::protobuf::EnumDescriptor* SigmoidParameter_Engine_descriptor() { return SigmoidParameter_Engine_descriptor_; } bool SigmoidParameter_Engine_IsValid(int value) { - switch(value) { + switch (value) { case 0: case 1: case 2: @@ -22509,45 +33992,47 @@ bool SigmoidParameter_Engine_IsValid(int value) { } } -#ifndef _MSC_VER +#if !defined(_MSC_VER) || _MSC_VER >= 1900 const SigmoidParameter_Engine SigmoidParameter::DEFAULT; const SigmoidParameter_Engine SigmoidParameter::CAFFE; const SigmoidParameter_Engine SigmoidParameter::CUDNN; const SigmoidParameter_Engine SigmoidParameter::Engine_MIN; const SigmoidParameter_Engine SigmoidParameter::Engine_MAX; const int SigmoidParameter::Engine_ARRAYSIZE; -#endif // _MSC_VER -#ifndef _MSC_VER +#endif // !defined(_MSC_VER) || _MSC_VER >= 1900 +#if !defined(_MSC_VER) || _MSC_VER >= 1900 const int SigmoidParameter::kEngineFieldNumber; -#endif // !_MSC_VER +#endif // !defined(_MSC_VER) || _MSC_VER >= 1900 SigmoidParameter::SigmoidParameter() - : ::google::protobuf::Message() { + : ::google::protobuf::Message(), _internal_metadata_(NULL) { + if (this != internal_default_instance()) protobuf_InitDefaults_caffe_2eproto(); SharedCtor(); + // @@protoc_insertion_point(constructor:caffe.SigmoidParameter) } void SigmoidParameter::InitAsDefaultInstance() { } SigmoidParameter::SigmoidParameter(const SigmoidParameter& from) - : ::google::protobuf::Message() { + : ::google::protobuf::Message(), + _internal_metadata_(NULL) { SharedCtor(); - MergeFrom(from); + UnsafeMergeFrom(from); + // @@protoc_insertion_point(copy_constructor:caffe.SigmoidParameter) } void SigmoidParameter::SharedCtor() { _cached_size_ = 0; engine_ = 0; - ::memset(_has_bits_, 0, sizeof(_has_bits_)); } SigmoidParameter::~SigmoidParameter() { + // @@protoc_insertion_point(destructor:caffe.SigmoidParameter) SharedDtor(); } void SigmoidParameter::SharedDtor() { - if (this != default_instance_) { - } } void SigmoidParameter::SetCachedSize(int size) const { @@ -22561,34 +34046,42 @@ const ::google::protobuf::Descriptor* SigmoidParameter::descriptor() { } const SigmoidParameter& SigmoidParameter::default_instance() { - if (default_instance_ == NULL) protobuf_AddDesc_caffe_2eproto(); - return *default_instance_; + protobuf_InitDefaults_caffe_2eproto(); + return *internal_default_instance(); } -SigmoidParameter* SigmoidParameter::default_instance_ = NULL; +::google::protobuf::internal::ExplicitlyConstructed SigmoidParameter_default_instance_; -SigmoidParameter* SigmoidParameter::New() const { - return new SigmoidParameter; +SigmoidParameter* SigmoidParameter::New(::google::protobuf::Arena* arena) const { + SigmoidParameter* n = new SigmoidParameter; + if (arena != NULL) { + arena->Own(n); + } + return n; } void SigmoidParameter::Clear() { - if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) { - engine_ = 0; +// @@protoc_insertion_point(message_clear_start:caffe.SigmoidParameter) + engine_ = 0; + _has_bits_.Clear(); + if (_internal_metadata_.have_unknown_fields()) { + mutable_unknown_fields()->Clear(); } - ::memset(_has_bits_, 0, sizeof(_has_bits_)); - mutable_unknown_fields()->Clear(); } bool SigmoidParameter::MergePartialFromCodedStream( ::google::protobuf::io::CodedInputStream* input) { -#define DO_(EXPRESSION) if (!(EXPRESSION)) return false +#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure ::google::protobuf::uint32 tag; - while ((tag = input->ReadTag()) != 0) { + // @@protoc_insertion_point(parse_start:caffe.SigmoidParameter) + for (;;) { + ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127); + tag = p.first; + if (!p.second) goto handle_unusual; switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { // optional .caffe.SigmoidParameter.Engine engine = 1 [default = DEFAULT]; case 1: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) { + if (tag == 8) { int value; DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< int, ::google::protobuf::internal::WireFormatLite::TYPE_ENUM>( @@ -22599,17 +34092,18 @@ bool SigmoidParameter::MergePartialFromCodedStream( mutable_unknown_fields()->AddVarint(1, value); } } else { - goto handle_uninterpreted; + goto handle_unusual; } - if (input->ExpectAtEnd()) return true; + if (input->ExpectAtEnd()) goto success; break; } default: { - handle_uninterpreted: - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == + handle_unusual: + if (tag == 0 || + ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) { - return true; + goto success; } DO_(::google::protobuf::internal::WireFormat::SkipField( input, tag, mutable_unknown_fields())); @@ -22617,93 +34111,120 @@ bool SigmoidParameter::MergePartialFromCodedStream( } } } +success: + // @@protoc_insertion_point(parse_success:caffe.SigmoidParameter) return true; +failure: + // @@protoc_insertion_point(parse_failure:caffe.SigmoidParameter) + return false; #undef DO_ } void SigmoidParameter::SerializeWithCachedSizes( ::google::protobuf::io::CodedOutputStream* output) const { + // @@protoc_insertion_point(serialize_start:caffe.SigmoidParameter) // optional .caffe.SigmoidParameter.Engine engine = 1 [default = DEFAULT]; if (has_engine()) { ::google::protobuf::internal::WireFormatLite::WriteEnum( 1, this->engine(), output); } - if (!unknown_fields().empty()) { + if (_internal_metadata_.have_unknown_fields()) { ::google::protobuf::internal::WireFormat::SerializeUnknownFields( unknown_fields(), output); } + // @@protoc_insertion_point(serialize_end:caffe.SigmoidParameter) } -::google::protobuf::uint8* SigmoidParameter::SerializeWithCachedSizesToArray( - ::google::protobuf::uint8* target) const { +::google::protobuf::uint8* SigmoidParameter::InternalSerializeWithCachedSizesToArray( + bool deterministic, ::google::protobuf::uint8* target) const { + (void)deterministic; // Unused + // @@protoc_insertion_point(serialize_to_array_start:caffe.SigmoidParameter) // optional .caffe.SigmoidParameter.Engine engine = 1 [default = DEFAULT]; if (has_engine()) { target = ::google::protobuf::internal::WireFormatLite::WriteEnumToArray( 1, this->engine(), target); } - if (!unknown_fields().empty()) { + if (_internal_metadata_.have_unknown_fields()) { target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray( unknown_fields(), target); } + // @@protoc_insertion_point(serialize_to_array_end:caffe.SigmoidParameter) return target; } -int SigmoidParameter::ByteSize() const { - int total_size = 0; - - if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) { - // optional .caffe.SigmoidParameter.Engine engine = 1 [default = DEFAULT]; - if (has_engine()) { - total_size += 1 + - ::google::protobuf::internal::WireFormatLite::EnumSize(this->engine()); - } +size_t SigmoidParameter::ByteSizeLong() const { +// @@protoc_insertion_point(message_byte_size_start:caffe.SigmoidParameter) + size_t total_size = 0; + // optional .caffe.SigmoidParameter.Engine engine = 1 [default = DEFAULT]; + if (has_engine()) { + total_size += 1 + + ::google::protobuf::internal::WireFormatLite::EnumSize(this->engine()); } - if (!unknown_fields().empty()) { + + if (_internal_metadata_.have_unknown_fields()) { total_size += ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( unknown_fields()); } + int cached_size = ::google::protobuf::internal::ToCachedSize(total_size); GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); - _cached_size_ = total_size; + _cached_size_ = cached_size; GOOGLE_SAFE_CONCURRENT_WRITES_END(); return total_size; } void SigmoidParameter::MergeFrom(const ::google::protobuf::Message& from) { - GOOGLE_CHECK_NE(&from, this); +// @@protoc_insertion_point(generalized_merge_from_start:caffe.SigmoidParameter) + if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__); const SigmoidParameter* source = - ::google::protobuf::internal::dynamic_cast_if_available( - &from); + ::google::protobuf::internal::DynamicCastToGenerated( + &from); if (source == NULL) { + // @@protoc_insertion_point(generalized_merge_from_cast_fail:caffe.SigmoidParameter) ::google::protobuf::internal::ReflectionOps::Merge(from, this); } else { - MergeFrom(*source); + // @@protoc_insertion_point(generalized_merge_from_cast_success:caffe.SigmoidParameter) + UnsafeMergeFrom(*source); } } void SigmoidParameter::MergeFrom(const SigmoidParameter& from) { - GOOGLE_CHECK_NE(&from, this); +// @@protoc_insertion_point(class_specific_merge_from_start:caffe.SigmoidParameter) + if (GOOGLE_PREDICT_TRUE(&from != this)) { + UnsafeMergeFrom(from); + } else { + MergeFromFail(__LINE__); + } +} + +void SigmoidParameter::UnsafeMergeFrom(const SigmoidParameter& from) { + GOOGLE_DCHECK(&from != this); if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) { if (from.has_engine()) { set_engine(from.engine()); } } - mutable_unknown_fields()->MergeFrom(from.unknown_fields()); + if (from._internal_metadata_.have_unknown_fields()) { + ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata( + from.unknown_fields(), &_internal_metadata_); + } } void SigmoidParameter::CopyFrom(const ::google::protobuf::Message& from) { +// @@protoc_insertion_point(generalized_copy_from_start:caffe.SigmoidParameter) if (&from == this) return; Clear(); MergeFrom(from); } void SigmoidParameter::CopyFrom(const SigmoidParameter& from) { +// @@protoc_insertion_point(class_specific_copy_from_start:caffe.SigmoidParameter) if (&from == this) return; Clear(); - MergeFrom(from); + UnsafeMergeFrom(from); } bool SigmoidParameter::IsInitialized() const { @@ -22712,12 +34233,14 @@ bool SigmoidParameter::IsInitialized() const { } void SigmoidParameter::Swap(SigmoidParameter* other) { - if (other != this) { - std::swap(engine_, other->engine_); - std::swap(_has_bits_[0], other->_has_bits_[0]); - _unknown_fields_.Swap(&other->_unknown_fields_); - std::swap(_cached_size_, other->_cached_size_); - } + if (other == this) return; + InternalSwap(other); +} +void SigmoidParameter::InternalSwap(SigmoidParameter* other) { + std::swap(engine_, other->engine_); + std::swap(_has_bits_[0], other->_has_bits_[0]); + _internal_metadata_.Swap(&other->_internal_metadata_); + std::swap(_cached_size_, other->_cached_size_); } ::google::protobuf::Metadata SigmoidParameter::GetMetadata() const { @@ -22728,43 +34251,77 @@ void SigmoidParameter::Swap(SigmoidParameter* other) { return metadata; } +#if PROTOBUF_INLINE_NOT_IN_HEADERS +// SigmoidParameter + +// optional .caffe.SigmoidParameter.Engine engine = 1 [default = DEFAULT]; +bool SigmoidParameter::has_engine() const { + return (_has_bits_[0] & 0x00000001u) != 0; +} +void SigmoidParameter::set_has_engine() { + _has_bits_[0] |= 0x00000001u; +} +void SigmoidParameter::clear_has_engine() { + _has_bits_[0] &= ~0x00000001u; +} +void SigmoidParameter::clear_engine() { + engine_ = 0; + clear_has_engine(); +} +::caffe::SigmoidParameter_Engine SigmoidParameter::engine() const { + // @@protoc_insertion_point(field_get:caffe.SigmoidParameter.engine) + return static_cast< ::caffe::SigmoidParameter_Engine >(engine_); +} +void SigmoidParameter::set_engine(::caffe::SigmoidParameter_Engine value) { + assert(::caffe::SigmoidParameter_Engine_IsValid(value)); + set_has_engine(); + engine_ = value; + // @@protoc_insertion_point(field_set:caffe.SigmoidParameter.engine) +} + +inline const SigmoidParameter* SigmoidParameter::internal_default_instance() { + return &SigmoidParameter_default_instance_.get(); +} +#endif // PROTOBUF_INLINE_NOT_IN_HEADERS // =================================================================== -#ifndef _MSC_VER +#if !defined(_MSC_VER) || _MSC_VER >= 1900 const int SliceParameter::kAxisFieldNumber; const int SliceParameter::kSlicePointFieldNumber; const int SliceParameter::kSliceDimFieldNumber; -#endif // !_MSC_VER +#endif // !defined(_MSC_VER) || _MSC_VER >= 1900 SliceParameter::SliceParameter() - : ::google::protobuf::Message() { + : ::google::protobuf::Message(), _internal_metadata_(NULL) { + if (this != internal_default_instance()) protobuf_InitDefaults_caffe_2eproto(); SharedCtor(); + // @@protoc_insertion_point(constructor:caffe.SliceParameter) } void SliceParameter::InitAsDefaultInstance() { } SliceParameter::SliceParameter(const SliceParameter& from) - : ::google::protobuf::Message() { + : ::google::protobuf::Message(), + _internal_metadata_(NULL) { SharedCtor(); - MergeFrom(from); + UnsafeMergeFrom(from); + // @@protoc_insertion_point(copy_constructor:caffe.SliceParameter) } void SliceParameter::SharedCtor() { _cached_size_ = 0; axis_ = 1; slice_dim_ = 1u; - ::memset(_has_bits_, 0, sizeof(_has_bits_)); } SliceParameter::~SliceParameter() { + // @@protoc_insertion_point(destructor:caffe.SliceParameter) SharedDtor(); } void SliceParameter::SharedDtor() { - if (this != default_instance_) { - } } void SliceParameter::SetCachedSize(int size) const { @@ -22778,42 +34335,52 @@ const ::google::protobuf::Descriptor* SliceParameter::descriptor() { } const SliceParameter& SliceParameter::default_instance() { - if (default_instance_ == NULL) protobuf_AddDesc_caffe_2eproto(); - return *default_instance_; + protobuf_InitDefaults_caffe_2eproto(); + return *internal_default_instance(); } -SliceParameter* SliceParameter::default_instance_ = NULL; +::google::protobuf::internal::ExplicitlyConstructed SliceParameter_default_instance_; -SliceParameter* SliceParameter::New() const { - return new SliceParameter; +SliceParameter* SliceParameter::New(::google::protobuf::Arena* arena) const { + SliceParameter* n = new SliceParameter; + if (arena != NULL) { + arena->Own(n); + } + return n; } void SliceParameter::Clear() { - if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) { +// @@protoc_insertion_point(message_clear_start:caffe.SliceParameter) + if (_has_bits_[0 / 32] & 5u) { axis_ = 1; slice_dim_ = 1u; } slice_point_.Clear(); - ::memset(_has_bits_, 0, sizeof(_has_bits_)); - mutable_unknown_fields()->Clear(); + _has_bits_.Clear(); + if (_internal_metadata_.have_unknown_fields()) { + mutable_unknown_fields()->Clear(); + } } bool SliceParameter::MergePartialFromCodedStream( ::google::protobuf::io::CodedInputStream* input) { -#define DO_(EXPRESSION) if (!(EXPRESSION)) return false +#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure ::google::protobuf::uint32 tag; - while ((tag = input->ReadTag()) != 0) { + // @@protoc_insertion_point(parse_start:caffe.SliceParameter) + for (;;) { + ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127); + tag = p.first; + if (!p.second) goto handle_unusual; switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { // optional uint32 slice_dim = 1 [default = 1]; case 1: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) { + if (tag == 8) { + set_has_slice_dim(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>( input, &slice_dim_))); - set_has_slice_dim(); } else { - goto handle_uninterpreted; + goto handle_unusual; } if (input->ExpectTag(16)) goto parse_slice_point; break; @@ -22821,20 +34388,17 @@ bool SliceParameter::MergePartialFromCodedStream( // repeated uint32 slice_point = 2; case 2: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) { + if (tag == 16) { parse_slice_point: DO_((::google::protobuf::internal::WireFormatLite::ReadRepeatedPrimitive< ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>( 1, 16, input, this->mutable_slice_point()))); - } else if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) - == ::google::protobuf::internal::WireFormatLite:: - WIRETYPE_LENGTH_DELIMITED) { + } else if (tag == 18) { DO_((::google::protobuf::internal::WireFormatLite::ReadPackedPrimitiveNoInline< ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>( input, this->mutable_slice_point()))); } else { - goto handle_uninterpreted; + goto handle_unusual; } if (input->ExpectTag(16)) goto parse_slice_point; if (input->ExpectTag(24)) goto parse_axis; @@ -22843,25 +34407,25 @@ bool SliceParameter::MergePartialFromCodedStream( // optional int32 axis = 3 [default = 1]; case 3: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) { + if (tag == 24) { parse_axis: + set_has_axis(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>( input, &axis_))); - set_has_axis(); } else { - goto handle_uninterpreted; + goto handle_unusual; } - if (input->ExpectAtEnd()) return true; + if (input->ExpectAtEnd()) goto success; break; } default: { - handle_uninterpreted: - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == + handle_unusual: + if (tag == 0 || + ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) { - return true; + goto success; } DO_(::google::protobuf::internal::WireFormat::SkipField( input, tag, mutable_unknown_fields())); @@ -22869,12 +34433,18 @@ bool SliceParameter::MergePartialFromCodedStream( } } } +success: + // @@protoc_insertion_point(parse_success:caffe.SliceParameter) return true; +failure: + // @@protoc_insertion_point(parse_failure:caffe.SliceParameter) + return false; #undef DO_ } void SliceParameter::SerializeWithCachedSizes( ::google::protobuf::io::CodedOutputStream* output) const { + // @@protoc_insertion_point(serialize_start:caffe.SliceParameter) // optional uint32 slice_dim = 1 [default = 1]; if (has_slice_dim()) { ::google::protobuf::internal::WireFormatLite::WriteUInt32(1, this->slice_dim(), output); @@ -22891,14 +34461,17 @@ void SliceParameter::SerializeWithCachedSizes( ::google::protobuf::internal::WireFormatLite::WriteInt32(3, this->axis(), output); } - if (!unknown_fields().empty()) { + if (_internal_metadata_.have_unknown_fields()) { ::google::protobuf::internal::WireFormat::SerializeUnknownFields( unknown_fields(), output); } + // @@protoc_insertion_point(serialize_end:caffe.SliceParameter) } -::google::protobuf::uint8* SliceParameter::SerializeWithCachedSizesToArray( - ::google::protobuf::uint8* target) const { +::google::protobuf::uint8* SliceParameter::InternalSerializeWithCachedSizesToArray( + bool deterministic, ::google::protobuf::uint8* target) const { + (void)deterministic; // Unused + // @@protoc_insertion_point(serialize_to_array_start:caffe.SliceParameter) // optional uint32 slice_dim = 1 [default = 1]; if (has_slice_dim()) { target = ::google::protobuf::internal::WireFormatLite::WriteUInt32ToArray(1, this->slice_dim(), target); @@ -22915,17 +34488,19 @@ void SliceParameter::SerializeWithCachedSizes( target = ::google::protobuf::internal::WireFormatLite::WriteInt32ToArray(3, this->axis(), target); } - if (!unknown_fields().empty()) { + if (_internal_metadata_.have_unknown_fields()) { target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray( unknown_fields(), target); } + // @@protoc_insertion_point(serialize_to_array_end:caffe.SliceParameter) return target; } -int SliceParameter::ByteSize() const { - int total_size = 0; +size_t SliceParameter::ByteSizeLong() const { +// @@protoc_insertion_point(message_byte_size_start:caffe.SliceParameter) + size_t total_size = 0; - if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) { + if (_has_bits_[0 / 32] & 5u) { // optional int32 axis = 3 [default = 1]; if (has_axis()) { total_size += 1 + @@ -22943,40 +34518,56 @@ int SliceParameter::ByteSize() const { } // repeated uint32 slice_point = 2; { - int data_size = 0; - for (int i = 0; i < this->slice_point_size(); i++) { + size_t data_size = 0; + unsigned int count = this->slice_point_size(); + for (unsigned int i = 0; i < count; i++) { data_size += ::google::protobuf::internal::WireFormatLite:: UInt32Size(this->slice_point(i)); } - total_size += 1 * this->slice_point_size() + data_size; + total_size += 1 * + ::google::protobuf::internal::FromIntSize(this->slice_point_size()); + total_size += data_size; } - if (!unknown_fields().empty()) { + if (_internal_metadata_.have_unknown_fields()) { total_size += ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( unknown_fields()); } + int cached_size = ::google::protobuf::internal::ToCachedSize(total_size); GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); - _cached_size_ = total_size; + _cached_size_ = cached_size; GOOGLE_SAFE_CONCURRENT_WRITES_END(); return total_size; } void SliceParameter::MergeFrom(const ::google::protobuf::Message& from) { - GOOGLE_CHECK_NE(&from, this); +// @@protoc_insertion_point(generalized_merge_from_start:caffe.SliceParameter) + if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__); const SliceParameter* source = - ::google::protobuf::internal::dynamic_cast_if_available( - &from); + ::google::protobuf::internal::DynamicCastToGenerated( + &from); if (source == NULL) { + // @@protoc_insertion_point(generalized_merge_from_cast_fail:caffe.SliceParameter) ::google::protobuf::internal::ReflectionOps::Merge(from, this); } else { - MergeFrom(*source); + // @@protoc_insertion_point(generalized_merge_from_cast_success:caffe.SliceParameter) + UnsafeMergeFrom(*source); } } void SliceParameter::MergeFrom(const SliceParameter& from) { - GOOGLE_CHECK_NE(&from, this); - slice_point_.MergeFrom(from.slice_point_); +// @@protoc_insertion_point(class_specific_merge_from_start:caffe.SliceParameter) + if (GOOGLE_PREDICT_TRUE(&from != this)) { + UnsafeMergeFrom(from); + } else { + MergeFromFail(__LINE__); + } +} + +void SliceParameter::UnsafeMergeFrom(const SliceParameter& from) { + GOOGLE_DCHECK(&from != this); + slice_point_.UnsafeMergeFrom(from.slice_point_); if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) { if (from.has_axis()) { set_axis(from.axis()); @@ -22985,19 +34576,24 @@ void SliceParameter::MergeFrom(const SliceParameter& from) { set_slice_dim(from.slice_dim()); } } - mutable_unknown_fields()->MergeFrom(from.unknown_fields()); + if (from._internal_metadata_.have_unknown_fields()) { + ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata( + from.unknown_fields(), &_internal_metadata_); + } } void SliceParameter::CopyFrom(const ::google::protobuf::Message& from) { +// @@protoc_insertion_point(generalized_copy_from_start:caffe.SliceParameter) if (&from == this) return; Clear(); MergeFrom(from); } void SliceParameter::CopyFrom(const SliceParameter& from) { +// @@protoc_insertion_point(class_specific_copy_from_start:caffe.SliceParameter) if (&from == this) return; Clear(); - MergeFrom(from); + UnsafeMergeFrom(from); } bool SliceParameter::IsInitialized() const { @@ -23006,14 +34602,16 @@ bool SliceParameter::IsInitialized() const { } void SliceParameter::Swap(SliceParameter* other) { - if (other != this) { - std::swap(axis_, other->axis_); - slice_point_.Swap(&other->slice_point_); - std::swap(slice_dim_, other->slice_dim_); - std::swap(_has_bits_[0], other->_has_bits_[0]); - _unknown_fields_.Swap(&other->_unknown_fields_); - std::swap(_cached_size_, other->_cached_size_); - } + if (other == this) return; + InternalSwap(other); +} +void SliceParameter::InternalSwap(SliceParameter* other) { + std::swap(axis_, other->axis_); + slice_point_.UnsafeArenaSwap(&other->slice_point_); + std::swap(slice_dim_, other->slice_dim_); + std::swap(_has_bits_[0], other->_has_bits_[0]); + _internal_metadata_.Swap(&other->_internal_metadata_); + std::swap(_cached_size_, other->_cached_size_); } ::google::protobuf::Metadata SliceParameter::GetMetadata() const { @@ -23024,6 +34622,91 @@ void SliceParameter::Swap(SliceParameter* other) { return metadata; } +#if PROTOBUF_INLINE_NOT_IN_HEADERS +// SliceParameter + +// optional int32 axis = 3 [default = 1]; +bool SliceParameter::has_axis() const { + return (_has_bits_[0] & 0x00000001u) != 0; +} +void SliceParameter::set_has_axis() { + _has_bits_[0] |= 0x00000001u; +} +void SliceParameter::clear_has_axis() { + _has_bits_[0] &= ~0x00000001u; +} +void SliceParameter::clear_axis() { + axis_ = 1; + clear_has_axis(); +} +::google::protobuf::int32 SliceParameter::axis() const { + // @@protoc_insertion_point(field_get:caffe.SliceParameter.axis) + return axis_; +} +void SliceParameter::set_axis(::google::protobuf::int32 value) { + set_has_axis(); + axis_ = value; + // @@protoc_insertion_point(field_set:caffe.SliceParameter.axis) +} + +// repeated uint32 slice_point = 2; +int SliceParameter::slice_point_size() const { + return slice_point_.size(); +} +void SliceParameter::clear_slice_point() { + slice_point_.Clear(); +} +::google::protobuf::uint32 SliceParameter::slice_point(int index) const { + // @@protoc_insertion_point(field_get:caffe.SliceParameter.slice_point) + return slice_point_.Get(index); +} +void SliceParameter::set_slice_point(int index, ::google::protobuf::uint32 value) { + slice_point_.Set(index, value); + // @@protoc_insertion_point(field_set:caffe.SliceParameter.slice_point) +} +void SliceParameter::add_slice_point(::google::protobuf::uint32 value) { + slice_point_.Add(value); + // @@protoc_insertion_point(field_add:caffe.SliceParameter.slice_point) +} +const ::google::protobuf::RepeatedField< ::google::protobuf::uint32 >& +SliceParameter::slice_point() const { + // @@protoc_insertion_point(field_list:caffe.SliceParameter.slice_point) + return slice_point_; +} +::google::protobuf::RepeatedField< ::google::protobuf::uint32 >* +SliceParameter::mutable_slice_point() { + // @@protoc_insertion_point(field_mutable_list:caffe.SliceParameter.slice_point) + return &slice_point_; +} + +// optional uint32 slice_dim = 1 [default = 1]; +bool SliceParameter::has_slice_dim() const { + return (_has_bits_[0] & 0x00000004u) != 0; +} +void SliceParameter::set_has_slice_dim() { + _has_bits_[0] |= 0x00000004u; +} +void SliceParameter::clear_has_slice_dim() { + _has_bits_[0] &= ~0x00000004u; +} +void SliceParameter::clear_slice_dim() { + slice_dim_ = 1u; + clear_has_slice_dim(); +} +::google::protobuf::uint32 SliceParameter::slice_dim() const { + // @@protoc_insertion_point(field_get:caffe.SliceParameter.slice_dim) + return slice_dim_; +} +void SliceParameter::set_slice_dim(::google::protobuf::uint32 value) { + set_has_slice_dim(); + slice_dim_ = value; + // @@protoc_insertion_point(field_set:caffe.SliceParameter.slice_dim) +} + +inline const SliceParameter* SliceParameter::internal_default_instance() { + return &SliceParameter_default_instance_.get(); +} +#endif // PROTOBUF_INLINE_NOT_IN_HEADERS // =================================================================== @@ -23032,7 +34715,7 @@ const ::google::protobuf::EnumDescriptor* SoftmaxParameter_Engine_descriptor() { return SoftmaxParameter_Engine_descriptor_; } bool SoftmaxParameter_Engine_IsValid(int value) { - switch(value) { + switch (value) { case 0: case 1: case 2: @@ -23042,47 +34725,49 @@ bool SoftmaxParameter_Engine_IsValid(int value) { } } -#ifndef _MSC_VER +#if !defined(_MSC_VER) || _MSC_VER >= 1900 const SoftmaxParameter_Engine SoftmaxParameter::DEFAULT; const SoftmaxParameter_Engine SoftmaxParameter::CAFFE; const SoftmaxParameter_Engine SoftmaxParameter::CUDNN; const SoftmaxParameter_Engine SoftmaxParameter::Engine_MIN; const SoftmaxParameter_Engine SoftmaxParameter::Engine_MAX; const int SoftmaxParameter::Engine_ARRAYSIZE; -#endif // _MSC_VER -#ifndef _MSC_VER +#endif // !defined(_MSC_VER) || _MSC_VER >= 1900 +#if !defined(_MSC_VER) || _MSC_VER >= 1900 const int SoftmaxParameter::kEngineFieldNumber; const int SoftmaxParameter::kAxisFieldNumber; -#endif // !_MSC_VER +#endif // !defined(_MSC_VER) || _MSC_VER >= 1900 SoftmaxParameter::SoftmaxParameter() - : ::google::protobuf::Message() { + : ::google::protobuf::Message(), _internal_metadata_(NULL) { + if (this != internal_default_instance()) protobuf_InitDefaults_caffe_2eproto(); SharedCtor(); + // @@protoc_insertion_point(constructor:caffe.SoftmaxParameter) } void SoftmaxParameter::InitAsDefaultInstance() { } SoftmaxParameter::SoftmaxParameter(const SoftmaxParameter& from) - : ::google::protobuf::Message() { + : ::google::protobuf::Message(), + _internal_metadata_(NULL) { SharedCtor(); - MergeFrom(from); + UnsafeMergeFrom(from); + // @@protoc_insertion_point(copy_constructor:caffe.SoftmaxParameter) } void SoftmaxParameter::SharedCtor() { _cached_size_ = 0; engine_ = 0; axis_ = 1; - ::memset(_has_bits_, 0, sizeof(_has_bits_)); } SoftmaxParameter::~SoftmaxParameter() { + // @@protoc_insertion_point(destructor:caffe.SoftmaxParameter) SharedDtor(); } void SoftmaxParameter::SharedDtor() { - if (this != default_instance_) { - } } void SoftmaxParameter::SetCachedSize(int size) const { @@ -23096,35 +34781,45 @@ const ::google::protobuf::Descriptor* SoftmaxParameter::descriptor() { } const SoftmaxParameter& SoftmaxParameter::default_instance() { - if (default_instance_ == NULL) protobuf_AddDesc_caffe_2eproto(); - return *default_instance_; + protobuf_InitDefaults_caffe_2eproto(); + return *internal_default_instance(); } -SoftmaxParameter* SoftmaxParameter::default_instance_ = NULL; +::google::protobuf::internal::ExplicitlyConstructed SoftmaxParameter_default_instance_; -SoftmaxParameter* SoftmaxParameter::New() const { - return new SoftmaxParameter; +SoftmaxParameter* SoftmaxParameter::New(::google::protobuf::Arena* arena) const { + SoftmaxParameter* n = new SoftmaxParameter; + if (arena != NULL) { + arena->Own(n); + } + return n; } void SoftmaxParameter::Clear() { - if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) { +// @@protoc_insertion_point(message_clear_start:caffe.SoftmaxParameter) + if (_has_bits_[0 / 32] & 3u) { engine_ = 0; axis_ = 1; } - ::memset(_has_bits_, 0, sizeof(_has_bits_)); - mutable_unknown_fields()->Clear(); + _has_bits_.Clear(); + if (_internal_metadata_.have_unknown_fields()) { + mutable_unknown_fields()->Clear(); + } } bool SoftmaxParameter::MergePartialFromCodedStream( ::google::protobuf::io::CodedInputStream* input) { -#define DO_(EXPRESSION) if (!(EXPRESSION)) return false +#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure ::google::protobuf::uint32 tag; - while ((tag = input->ReadTag()) != 0) { + // @@protoc_insertion_point(parse_start:caffe.SoftmaxParameter) + for (;;) { + ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127); + tag = p.first; + if (!p.second) goto handle_unusual; switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { // optional .caffe.SoftmaxParameter.Engine engine = 1 [default = DEFAULT]; case 1: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) { + if (tag == 8) { int value; DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< int, ::google::protobuf::internal::WireFormatLite::TYPE_ENUM>( @@ -23135,7 +34830,7 @@ bool SoftmaxParameter::MergePartialFromCodedStream( mutable_unknown_fields()->AddVarint(1, value); } } else { - goto handle_uninterpreted; + goto handle_unusual; } if (input->ExpectTag(16)) goto parse_axis; break; @@ -23143,25 +34838,25 @@ bool SoftmaxParameter::MergePartialFromCodedStream( // optional int32 axis = 2 [default = 1]; case 2: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) { + if (tag == 16) { parse_axis: + set_has_axis(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>( input, &axis_))); - set_has_axis(); } else { - goto handle_uninterpreted; + goto handle_unusual; } - if (input->ExpectAtEnd()) return true; + if (input->ExpectAtEnd()) goto success; break; } default: { - handle_uninterpreted: - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == + handle_unusual: + if (tag == 0 || + ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) { - return true; + goto success; } DO_(::google::protobuf::internal::WireFormat::SkipField( input, tag, mutable_unknown_fields())); @@ -23169,12 +34864,18 @@ bool SoftmaxParameter::MergePartialFromCodedStream( } } } +success: + // @@protoc_insertion_point(parse_success:caffe.SoftmaxParameter) return true; +failure: + // @@protoc_insertion_point(parse_failure:caffe.SoftmaxParameter) + return false; #undef DO_ } void SoftmaxParameter::SerializeWithCachedSizes( ::google::protobuf::io::CodedOutputStream* output) const { + // @@protoc_insertion_point(serialize_start:caffe.SoftmaxParameter) // optional .caffe.SoftmaxParameter.Engine engine = 1 [default = DEFAULT]; if (has_engine()) { ::google::protobuf::internal::WireFormatLite::WriteEnum( @@ -23186,14 +34887,17 @@ void SoftmaxParameter::SerializeWithCachedSizes( ::google::protobuf::internal::WireFormatLite::WriteInt32(2, this->axis(), output); } - if (!unknown_fields().empty()) { + if (_internal_metadata_.have_unknown_fields()) { ::google::protobuf::internal::WireFormat::SerializeUnknownFields( unknown_fields(), output); } + // @@protoc_insertion_point(serialize_end:caffe.SoftmaxParameter) } -::google::protobuf::uint8* SoftmaxParameter::SerializeWithCachedSizesToArray( - ::google::protobuf::uint8* target) const { +::google::protobuf::uint8* SoftmaxParameter::InternalSerializeWithCachedSizesToArray( + bool deterministic, ::google::protobuf::uint8* target) const { + (void)deterministic; // Unused + // @@protoc_insertion_point(serialize_to_array_start:caffe.SoftmaxParameter) // optional .caffe.SoftmaxParameter.Engine engine = 1 [default = DEFAULT]; if (has_engine()) { target = ::google::protobuf::internal::WireFormatLite::WriteEnumToArray( @@ -23205,17 +34909,19 @@ void SoftmaxParameter::SerializeWithCachedSizes( target = ::google::protobuf::internal::WireFormatLite::WriteInt32ToArray(2, this->axis(), target); } - if (!unknown_fields().empty()) { + if (_internal_metadata_.have_unknown_fields()) { target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray( unknown_fields(), target); } + // @@protoc_insertion_point(serialize_to_array_end:caffe.SoftmaxParameter) return target; } -int SoftmaxParameter::ByteSize() const { - int total_size = 0; +size_t SoftmaxParameter::ByteSizeLong() const { +// @@protoc_insertion_point(message_byte_size_start:caffe.SoftmaxParameter) + size_t total_size = 0; - if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) { + if (_has_bits_[0 / 32] & 3u) { // optional .caffe.SoftmaxParameter.Engine engine = 1 [default = DEFAULT]; if (has_engine()) { total_size += 1 + @@ -23230,31 +34936,44 @@ int SoftmaxParameter::ByteSize() const { } } - if (!unknown_fields().empty()) { + if (_internal_metadata_.have_unknown_fields()) { total_size += ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( unknown_fields()); } + int cached_size = ::google::protobuf::internal::ToCachedSize(total_size); GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); - _cached_size_ = total_size; + _cached_size_ = cached_size; GOOGLE_SAFE_CONCURRENT_WRITES_END(); return total_size; } void SoftmaxParameter::MergeFrom(const ::google::protobuf::Message& from) { - GOOGLE_CHECK_NE(&from, this); +// @@protoc_insertion_point(generalized_merge_from_start:caffe.SoftmaxParameter) + if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__); const SoftmaxParameter* source = - ::google::protobuf::internal::dynamic_cast_if_available( - &from); + ::google::protobuf::internal::DynamicCastToGenerated( + &from); if (source == NULL) { + // @@protoc_insertion_point(generalized_merge_from_cast_fail:caffe.SoftmaxParameter) ::google::protobuf::internal::ReflectionOps::Merge(from, this); } else { - MergeFrom(*source); + // @@protoc_insertion_point(generalized_merge_from_cast_success:caffe.SoftmaxParameter) + UnsafeMergeFrom(*source); } } void SoftmaxParameter::MergeFrom(const SoftmaxParameter& from) { - GOOGLE_CHECK_NE(&from, this); +// @@protoc_insertion_point(class_specific_merge_from_start:caffe.SoftmaxParameter) + if (GOOGLE_PREDICT_TRUE(&from != this)) { + UnsafeMergeFrom(from); + } else { + MergeFromFail(__LINE__); + } +} + +void SoftmaxParameter::UnsafeMergeFrom(const SoftmaxParameter& from) { + GOOGLE_DCHECK(&from != this); if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) { if (from.has_engine()) { set_engine(from.engine()); @@ -23263,19 +34982,24 @@ void SoftmaxParameter::MergeFrom(const SoftmaxParameter& from) { set_axis(from.axis()); } } - mutable_unknown_fields()->MergeFrom(from.unknown_fields()); + if (from._internal_metadata_.have_unknown_fields()) { + ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata( + from.unknown_fields(), &_internal_metadata_); + } } void SoftmaxParameter::CopyFrom(const ::google::protobuf::Message& from) { +// @@protoc_insertion_point(generalized_copy_from_start:caffe.SoftmaxParameter) if (&from == this) return; Clear(); MergeFrom(from); } void SoftmaxParameter::CopyFrom(const SoftmaxParameter& from) { +// @@protoc_insertion_point(class_specific_copy_from_start:caffe.SoftmaxParameter) if (&from == this) return; Clear(); - MergeFrom(from); + UnsafeMergeFrom(from); } bool SoftmaxParameter::IsInitialized() const { @@ -23284,13 +35008,15 @@ bool SoftmaxParameter::IsInitialized() const { } void SoftmaxParameter::Swap(SoftmaxParameter* other) { - if (other != this) { - std::swap(engine_, other->engine_); - std::swap(axis_, other->axis_); - std::swap(_has_bits_[0], other->_has_bits_[0]); - _unknown_fields_.Swap(&other->_unknown_fields_); - std::swap(_cached_size_, other->_cached_size_); - } + if (other == this) return; + InternalSwap(other); +} +void SoftmaxParameter::InternalSwap(SoftmaxParameter* other) { + std::swap(engine_, other->engine_); + std::swap(axis_, other->axis_); + std::swap(_has_bits_[0], other->_has_bits_[0]); + _internal_metadata_.Swap(&other->_internal_metadata_); + std::swap(_cached_size_, other->_cached_size_); } ::google::protobuf::Metadata SoftmaxParameter::GetMetadata() const { @@ -23301,6 +35027,62 @@ void SoftmaxParameter::Swap(SoftmaxParameter* other) { return metadata; } +#if PROTOBUF_INLINE_NOT_IN_HEADERS +// SoftmaxParameter + +// optional .caffe.SoftmaxParameter.Engine engine = 1 [default = DEFAULT]; +bool SoftmaxParameter::has_engine() const { + return (_has_bits_[0] & 0x00000001u) != 0; +} +void SoftmaxParameter::set_has_engine() { + _has_bits_[0] |= 0x00000001u; +} +void SoftmaxParameter::clear_has_engine() { + _has_bits_[0] &= ~0x00000001u; +} +void SoftmaxParameter::clear_engine() { + engine_ = 0; + clear_has_engine(); +} +::caffe::SoftmaxParameter_Engine SoftmaxParameter::engine() const { + // @@protoc_insertion_point(field_get:caffe.SoftmaxParameter.engine) + return static_cast< ::caffe::SoftmaxParameter_Engine >(engine_); +} +void SoftmaxParameter::set_engine(::caffe::SoftmaxParameter_Engine value) { + assert(::caffe::SoftmaxParameter_Engine_IsValid(value)); + set_has_engine(); + engine_ = value; + // @@protoc_insertion_point(field_set:caffe.SoftmaxParameter.engine) +} + +// optional int32 axis = 2 [default = 1]; +bool SoftmaxParameter::has_axis() const { + return (_has_bits_[0] & 0x00000002u) != 0; +} +void SoftmaxParameter::set_has_axis() { + _has_bits_[0] |= 0x00000002u; +} +void SoftmaxParameter::clear_has_axis() { + _has_bits_[0] &= ~0x00000002u; +} +void SoftmaxParameter::clear_axis() { + axis_ = 1; + clear_has_axis(); +} +::google::protobuf::int32 SoftmaxParameter::axis() const { + // @@protoc_insertion_point(field_get:caffe.SoftmaxParameter.axis) + return axis_; +} +void SoftmaxParameter::set_axis(::google::protobuf::int32 value) { + set_has_axis(); + axis_ = value; + // @@protoc_insertion_point(field_set:caffe.SoftmaxParameter.axis) +} + +inline const SoftmaxParameter* SoftmaxParameter::internal_default_instance() { + return &SoftmaxParameter_default_instance_.get(); +} +#endif // PROTOBUF_INLINE_NOT_IN_HEADERS // =================================================================== @@ -23309,7 +35091,7 @@ const ::google::protobuf::EnumDescriptor* TanHParameter_Engine_descriptor() { return TanHParameter_Engine_descriptor_; } bool TanHParameter_Engine_IsValid(int value) { - switch(value) { + switch (value) { case 0: case 1: case 2: @@ -23319,45 +35101,47 @@ bool TanHParameter_Engine_IsValid(int value) { } } -#ifndef _MSC_VER +#if !defined(_MSC_VER) || _MSC_VER >= 1900 const TanHParameter_Engine TanHParameter::DEFAULT; const TanHParameter_Engine TanHParameter::CAFFE; const TanHParameter_Engine TanHParameter::CUDNN; const TanHParameter_Engine TanHParameter::Engine_MIN; const TanHParameter_Engine TanHParameter::Engine_MAX; const int TanHParameter::Engine_ARRAYSIZE; -#endif // _MSC_VER -#ifndef _MSC_VER +#endif // !defined(_MSC_VER) || _MSC_VER >= 1900 +#if !defined(_MSC_VER) || _MSC_VER >= 1900 const int TanHParameter::kEngineFieldNumber; -#endif // !_MSC_VER +#endif // !defined(_MSC_VER) || _MSC_VER >= 1900 TanHParameter::TanHParameter() - : ::google::protobuf::Message() { + : ::google::protobuf::Message(), _internal_metadata_(NULL) { + if (this != internal_default_instance()) protobuf_InitDefaults_caffe_2eproto(); SharedCtor(); + // @@protoc_insertion_point(constructor:caffe.TanHParameter) } void TanHParameter::InitAsDefaultInstance() { } TanHParameter::TanHParameter(const TanHParameter& from) - : ::google::protobuf::Message() { + : ::google::protobuf::Message(), + _internal_metadata_(NULL) { SharedCtor(); - MergeFrom(from); + UnsafeMergeFrom(from); + // @@protoc_insertion_point(copy_constructor:caffe.TanHParameter) } void TanHParameter::SharedCtor() { _cached_size_ = 0; engine_ = 0; - ::memset(_has_bits_, 0, sizeof(_has_bits_)); } TanHParameter::~TanHParameter() { + // @@protoc_insertion_point(destructor:caffe.TanHParameter) SharedDtor(); } void TanHParameter::SharedDtor() { - if (this != default_instance_) { - } } void TanHParameter::SetCachedSize(int size) const { @@ -23371,34 +35155,42 @@ const ::google::protobuf::Descriptor* TanHParameter::descriptor() { } const TanHParameter& TanHParameter::default_instance() { - if (default_instance_ == NULL) protobuf_AddDesc_caffe_2eproto(); - return *default_instance_; + protobuf_InitDefaults_caffe_2eproto(); + return *internal_default_instance(); } -TanHParameter* TanHParameter::default_instance_ = NULL; +::google::protobuf::internal::ExplicitlyConstructed TanHParameter_default_instance_; -TanHParameter* TanHParameter::New() const { - return new TanHParameter; +TanHParameter* TanHParameter::New(::google::protobuf::Arena* arena) const { + TanHParameter* n = new TanHParameter; + if (arena != NULL) { + arena->Own(n); + } + return n; } void TanHParameter::Clear() { - if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) { - engine_ = 0; +// @@protoc_insertion_point(message_clear_start:caffe.TanHParameter) + engine_ = 0; + _has_bits_.Clear(); + if (_internal_metadata_.have_unknown_fields()) { + mutable_unknown_fields()->Clear(); } - ::memset(_has_bits_, 0, sizeof(_has_bits_)); - mutable_unknown_fields()->Clear(); } bool TanHParameter::MergePartialFromCodedStream( ::google::protobuf::io::CodedInputStream* input) { -#define DO_(EXPRESSION) if (!(EXPRESSION)) return false +#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure ::google::protobuf::uint32 tag; - while ((tag = input->ReadTag()) != 0) { + // @@protoc_insertion_point(parse_start:caffe.TanHParameter) + for (;;) { + ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127); + tag = p.first; + if (!p.second) goto handle_unusual; switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { // optional .caffe.TanHParameter.Engine engine = 1 [default = DEFAULT]; case 1: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) { + if (tag == 8) { int value; DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< int, ::google::protobuf::internal::WireFormatLite::TYPE_ENUM>( @@ -23409,17 +35201,18 @@ bool TanHParameter::MergePartialFromCodedStream( mutable_unknown_fields()->AddVarint(1, value); } } else { - goto handle_uninterpreted; + goto handle_unusual; } - if (input->ExpectAtEnd()) return true; + if (input->ExpectAtEnd()) goto success; break; } default: { - handle_uninterpreted: - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == + handle_unusual: + if (tag == 0 || + ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) { - return true; + goto success; } DO_(::google::protobuf::internal::WireFormat::SkipField( input, tag, mutable_unknown_fields())); @@ -23427,93 +35220,120 @@ bool TanHParameter::MergePartialFromCodedStream( } } } +success: + // @@protoc_insertion_point(parse_success:caffe.TanHParameter) return true; +failure: + // @@protoc_insertion_point(parse_failure:caffe.TanHParameter) + return false; #undef DO_ } void TanHParameter::SerializeWithCachedSizes( ::google::protobuf::io::CodedOutputStream* output) const { + // @@protoc_insertion_point(serialize_start:caffe.TanHParameter) // optional .caffe.TanHParameter.Engine engine = 1 [default = DEFAULT]; if (has_engine()) { ::google::protobuf::internal::WireFormatLite::WriteEnum( 1, this->engine(), output); } - if (!unknown_fields().empty()) { + if (_internal_metadata_.have_unknown_fields()) { ::google::protobuf::internal::WireFormat::SerializeUnknownFields( unknown_fields(), output); } + // @@protoc_insertion_point(serialize_end:caffe.TanHParameter) } -::google::protobuf::uint8* TanHParameter::SerializeWithCachedSizesToArray( - ::google::protobuf::uint8* target) const { +::google::protobuf::uint8* TanHParameter::InternalSerializeWithCachedSizesToArray( + bool deterministic, ::google::protobuf::uint8* target) const { + (void)deterministic; // Unused + // @@protoc_insertion_point(serialize_to_array_start:caffe.TanHParameter) // optional .caffe.TanHParameter.Engine engine = 1 [default = DEFAULT]; if (has_engine()) { target = ::google::protobuf::internal::WireFormatLite::WriteEnumToArray( 1, this->engine(), target); } - if (!unknown_fields().empty()) { + if (_internal_metadata_.have_unknown_fields()) { target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray( unknown_fields(), target); } + // @@protoc_insertion_point(serialize_to_array_end:caffe.TanHParameter) return target; } -int TanHParameter::ByteSize() const { - int total_size = 0; - - if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) { - // optional .caffe.TanHParameter.Engine engine = 1 [default = DEFAULT]; - if (has_engine()) { - total_size += 1 + - ::google::protobuf::internal::WireFormatLite::EnumSize(this->engine()); - } +size_t TanHParameter::ByteSizeLong() const { +// @@protoc_insertion_point(message_byte_size_start:caffe.TanHParameter) + size_t total_size = 0; + // optional .caffe.TanHParameter.Engine engine = 1 [default = DEFAULT]; + if (has_engine()) { + total_size += 1 + + ::google::protobuf::internal::WireFormatLite::EnumSize(this->engine()); } - if (!unknown_fields().empty()) { + + if (_internal_metadata_.have_unknown_fields()) { total_size += ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( unknown_fields()); } + int cached_size = ::google::protobuf::internal::ToCachedSize(total_size); GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); - _cached_size_ = total_size; + _cached_size_ = cached_size; GOOGLE_SAFE_CONCURRENT_WRITES_END(); return total_size; } void TanHParameter::MergeFrom(const ::google::protobuf::Message& from) { - GOOGLE_CHECK_NE(&from, this); +// @@protoc_insertion_point(generalized_merge_from_start:caffe.TanHParameter) + if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__); const TanHParameter* source = - ::google::protobuf::internal::dynamic_cast_if_available( - &from); + ::google::protobuf::internal::DynamicCastToGenerated( + &from); if (source == NULL) { + // @@protoc_insertion_point(generalized_merge_from_cast_fail:caffe.TanHParameter) ::google::protobuf::internal::ReflectionOps::Merge(from, this); } else { - MergeFrom(*source); + // @@protoc_insertion_point(generalized_merge_from_cast_success:caffe.TanHParameter) + UnsafeMergeFrom(*source); } } void TanHParameter::MergeFrom(const TanHParameter& from) { - GOOGLE_CHECK_NE(&from, this); +// @@protoc_insertion_point(class_specific_merge_from_start:caffe.TanHParameter) + if (GOOGLE_PREDICT_TRUE(&from != this)) { + UnsafeMergeFrom(from); + } else { + MergeFromFail(__LINE__); + } +} + +void TanHParameter::UnsafeMergeFrom(const TanHParameter& from) { + GOOGLE_DCHECK(&from != this); if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) { if (from.has_engine()) { set_engine(from.engine()); } } - mutable_unknown_fields()->MergeFrom(from.unknown_fields()); + if (from._internal_metadata_.have_unknown_fields()) { + ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata( + from.unknown_fields(), &_internal_metadata_); + } } void TanHParameter::CopyFrom(const ::google::protobuf::Message& from) { +// @@protoc_insertion_point(generalized_copy_from_start:caffe.TanHParameter) if (&from == this) return; Clear(); MergeFrom(from); } void TanHParameter::CopyFrom(const TanHParameter& from) { +// @@protoc_insertion_point(class_specific_copy_from_start:caffe.TanHParameter) if (&from == this) return; Clear(); - MergeFrom(from); + UnsafeMergeFrom(from); } bool TanHParameter::IsInitialized() const { @@ -23522,12 +35342,14 @@ bool TanHParameter::IsInitialized() const { } void TanHParameter::Swap(TanHParameter* other) { - if (other != this) { - std::swap(engine_, other->engine_); - std::swap(_has_bits_[0], other->_has_bits_[0]); - _unknown_fields_.Swap(&other->_unknown_fields_); - std::swap(_cached_size_, other->_cached_size_); - } + if (other == this) return; + InternalSwap(other); +} +void TanHParameter::InternalSwap(TanHParameter* other) { + std::swap(engine_, other->engine_); + std::swap(_has_bits_[0], other->_has_bits_[0]); + _internal_metadata_.Swap(&other->_internal_metadata_); + std::swap(_cached_size_, other->_cached_size_); } ::google::protobuf::Metadata TanHParameter::GetMetadata() const { @@ -23538,40 +35360,74 @@ void TanHParameter::Swap(TanHParameter* other) { return metadata; } +#if PROTOBUF_INLINE_NOT_IN_HEADERS +// TanHParameter + +// optional .caffe.TanHParameter.Engine engine = 1 [default = DEFAULT]; +bool TanHParameter::has_engine() const { + return (_has_bits_[0] & 0x00000001u) != 0; +} +void TanHParameter::set_has_engine() { + _has_bits_[0] |= 0x00000001u; +} +void TanHParameter::clear_has_engine() { + _has_bits_[0] &= ~0x00000001u; +} +void TanHParameter::clear_engine() { + engine_ = 0; + clear_has_engine(); +} +::caffe::TanHParameter_Engine TanHParameter::engine() const { + // @@protoc_insertion_point(field_get:caffe.TanHParameter.engine) + return static_cast< ::caffe::TanHParameter_Engine >(engine_); +} +void TanHParameter::set_engine(::caffe::TanHParameter_Engine value) { + assert(::caffe::TanHParameter_Engine_IsValid(value)); + set_has_engine(); + engine_ = value; + // @@protoc_insertion_point(field_set:caffe.TanHParameter.engine) +} + +inline const TanHParameter* TanHParameter::internal_default_instance() { + return &TanHParameter_default_instance_.get(); +} +#endif // PROTOBUF_INLINE_NOT_IN_HEADERS // =================================================================== -#ifndef _MSC_VER +#if !defined(_MSC_VER) || _MSC_VER >= 1900 const int ThresholdParameter::kThresholdFieldNumber; -#endif // !_MSC_VER +#endif // !defined(_MSC_VER) || _MSC_VER >= 1900 ThresholdParameter::ThresholdParameter() - : ::google::protobuf::Message() { + : ::google::protobuf::Message(), _internal_metadata_(NULL) { + if (this != internal_default_instance()) protobuf_InitDefaults_caffe_2eproto(); SharedCtor(); + // @@protoc_insertion_point(constructor:caffe.ThresholdParameter) } void ThresholdParameter::InitAsDefaultInstance() { } ThresholdParameter::ThresholdParameter(const ThresholdParameter& from) - : ::google::protobuf::Message() { + : ::google::protobuf::Message(), + _internal_metadata_(NULL) { SharedCtor(); - MergeFrom(from); + UnsafeMergeFrom(from); + // @@protoc_insertion_point(copy_constructor:caffe.ThresholdParameter) } void ThresholdParameter::SharedCtor() { _cached_size_ = 0; threshold_ = 0; - ::memset(_has_bits_, 0, sizeof(_has_bits_)); } ThresholdParameter::~ThresholdParameter() { + // @@protoc_insertion_point(destructor:caffe.ThresholdParameter) SharedDtor(); } void ThresholdParameter::SharedDtor() { - if (this != default_instance_) { - } } void ThresholdParameter::SetCachedSize(int size) const { @@ -23585,50 +35441,59 @@ const ::google::protobuf::Descriptor* ThresholdParameter::descriptor() { } const ThresholdParameter& ThresholdParameter::default_instance() { - if (default_instance_ == NULL) protobuf_AddDesc_caffe_2eproto(); - return *default_instance_; + protobuf_InitDefaults_caffe_2eproto(); + return *internal_default_instance(); } -ThresholdParameter* ThresholdParameter::default_instance_ = NULL; +::google::protobuf::internal::ExplicitlyConstructed ThresholdParameter_default_instance_; -ThresholdParameter* ThresholdParameter::New() const { - return new ThresholdParameter; +ThresholdParameter* ThresholdParameter::New(::google::protobuf::Arena* arena) const { + ThresholdParameter* n = new ThresholdParameter; + if (arena != NULL) { + arena->Own(n); + } + return n; } void ThresholdParameter::Clear() { - if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) { - threshold_ = 0; +// @@protoc_insertion_point(message_clear_start:caffe.ThresholdParameter) + threshold_ = 0; + _has_bits_.Clear(); + if (_internal_metadata_.have_unknown_fields()) { + mutable_unknown_fields()->Clear(); } - ::memset(_has_bits_, 0, sizeof(_has_bits_)); - mutable_unknown_fields()->Clear(); } bool ThresholdParameter::MergePartialFromCodedStream( ::google::protobuf::io::CodedInputStream* input) { -#define DO_(EXPRESSION) if (!(EXPRESSION)) return false +#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure ::google::protobuf::uint32 tag; - while ((tag = input->ReadTag()) != 0) { + // @@protoc_insertion_point(parse_start:caffe.ThresholdParameter) + for (;;) { + ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127); + tag = p.first; + if (!p.second) goto handle_unusual; switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { // optional float threshold = 1 [default = 0]; case 1: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_FIXED32) { + if (tag == 13) { + set_has_threshold(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< float, ::google::protobuf::internal::WireFormatLite::TYPE_FLOAT>( input, &threshold_))); - set_has_threshold(); } else { - goto handle_uninterpreted; + goto handle_unusual; } - if (input->ExpectAtEnd()) return true; + if (input->ExpectAtEnd()) goto success; break; } default: { - handle_uninterpreted: - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == + handle_unusual: + if (tag == 0 || + ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) { - return true; + goto success; } DO_(::google::protobuf::internal::WireFormat::SkipField( input, tag, mutable_unknown_fields())); @@ -23636,90 +35501,117 @@ bool ThresholdParameter::MergePartialFromCodedStream( } } } +success: + // @@protoc_insertion_point(parse_success:caffe.ThresholdParameter) return true; +failure: + // @@protoc_insertion_point(parse_failure:caffe.ThresholdParameter) + return false; #undef DO_ } void ThresholdParameter::SerializeWithCachedSizes( ::google::protobuf::io::CodedOutputStream* output) const { + // @@protoc_insertion_point(serialize_start:caffe.ThresholdParameter) // optional float threshold = 1 [default = 0]; if (has_threshold()) { ::google::protobuf::internal::WireFormatLite::WriteFloat(1, this->threshold(), output); } - if (!unknown_fields().empty()) { + if (_internal_metadata_.have_unknown_fields()) { ::google::protobuf::internal::WireFormat::SerializeUnknownFields( unknown_fields(), output); } + // @@protoc_insertion_point(serialize_end:caffe.ThresholdParameter) } -::google::protobuf::uint8* ThresholdParameter::SerializeWithCachedSizesToArray( - ::google::protobuf::uint8* target) const { +::google::protobuf::uint8* ThresholdParameter::InternalSerializeWithCachedSizesToArray( + bool deterministic, ::google::protobuf::uint8* target) const { + (void)deterministic; // Unused + // @@protoc_insertion_point(serialize_to_array_start:caffe.ThresholdParameter) // optional float threshold = 1 [default = 0]; if (has_threshold()) { target = ::google::protobuf::internal::WireFormatLite::WriteFloatToArray(1, this->threshold(), target); } - if (!unknown_fields().empty()) { + if (_internal_metadata_.have_unknown_fields()) { target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray( unknown_fields(), target); } + // @@protoc_insertion_point(serialize_to_array_end:caffe.ThresholdParameter) return target; } -int ThresholdParameter::ByteSize() const { - int total_size = 0; - - if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) { - // optional float threshold = 1 [default = 0]; - if (has_threshold()) { - total_size += 1 + 4; - } +size_t ThresholdParameter::ByteSizeLong() const { +// @@protoc_insertion_point(message_byte_size_start:caffe.ThresholdParameter) + size_t total_size = 0; + // optional float threshold = 1 [default = 0]; + if (has_threshold()) { + total_size += 1 + 4; } - if (!unknown_fields().empty()) { + + if (_internal_metadata_.have_unknown_fields()) { total_size += ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( unknown_fields()); } + int cached_size = ::google::protobuf::internal::ToCachedSize(total_size); GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); - _cached_size_ = total_size; + _cached_size_ = cached_size; GOOGLE_SAFE_CONCURRENT_WRITES_END(); return total_size; } void ThresholdParameter::MergeFrom(const ::google::protobuf::Message& from) { - GOOGLE_CHECK_NE(&from, this); +// @@protoc_insertion_point(generalized_merge_from_start:caffe.ThresholdParameter) + if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__); const ThresholdParameter* source = - ::google::protobuf::internal::dynamic_cast_if_available( - &from); + ::google::protobuf::internal::DynamicCastToGenerated( + &from); if (source == NULL) { + // @@protoc_insertion_point(generalized_merge_from_cast_fail:caffe.ThresholdParameter) ::google::protobuf::internal::ReflectionOps::Merge(from, this); } else { - MergeFrom(*source); + // @@protoc_insertion_point(generalized_merge_from_cast_success:caffe.ThresholdParameter) + UnsafeMergeFrom(*source); } } void ThresholdParameter::MergeFrom(const ThresholdParameter& from) { - GOOGLE_CHECK_NE(&from, this); +// @@protoc_insertion_point(class_specific_merge_from_start:caffe.ThresholdParameter) + if (GOOGLE_PREDICT_TRUE(&from != this)) { + UnsafeMergeFrom(from); + } else { + MergeFromFail(__LINE__); + } +} + +void ThresholdParameter::UnsafeMergeFrom(const ThresholdParameter& from) { + GOOGLE_DCHECK(&from != this); if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) { if (from.has_threshold()) { set_threshold(from.threshold()); } } - mutable_unknown_fields()->MergeFrom(from.unknown_fields()); + if (from._internal_metadata_.have_unknown_fields()) { + ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata( + from.unknown_fields(), &_internal_metadata_); + } } void ThresholdParameter::CopyFrom(const ::google::protobuf::Message& from) { +// @@protoc_insertion_point(generalized_copy_from_start:caffe.ThresholdParameter) if (&from == this) return; Clear(); MergeFrom(from); } void ThresholdParameter::CopyFrom(const ThresholdParameter& from) { +// @@protoc_insertion_point(class_specific_copy_from_start:caffe.ThresholdParameter) if (&from == this) return; Clear(); - MergeFrom(from); + UnsafeMergeFrom(from); } bool ThresholdParameter::IsInitialized() const { @@ -23728,12 +35620,14 @@ bool ThresholdParameter::IsInitialized() const { } void ThresholdParameter::Swap(ThresholdParameter* other) { - if (other != this) { - std::swap(threshold_, other->threshold_); - std::swap(_has_bits_[0], other->_has_bits_[0]); - _unknown_fields_.Swap(&other->_unknown_fields_); - std::swap(_cached_size_, other->_cached_size_); - } + if (other == this) return; + InternalSwap(other); +} +void ThresholdParameter::InternalSwap(ThresholdParameter* other) { + std::swap(threshold_, other->threshold_); + std::swap(_has_bits_[0], other->_has_bits_[0]); + _internal_metadata_.Swap(&other->_internal_metadata_); + std::swap(_cached_size_, other->_cached_size_); } ::google::protobuf::Metadata ThresholdParameter::GetMetadata() const { @@ -23744,11 +35638,42 @@ void ThresholdParameter::Swap(ThresholdParameter* other) { return metadata; } +#if PROTOBUF_INLINE_NOT_IN_HEADERS +// ThresholdParameter + +// optional float threshold = 1 [default = 0]; +bool ThresholdParameter::has_threshold() const { + return (_has_bits_[0] & 0x00000001u) != 0; +} +void ThresholdParameter::set_has_threshold() { + _has_bits_[0] |= 0x00000001u; +} +void ThresholdParameter::clear_has_threshold() { + _has_bits_[0] &= ~0x00000001u; +} +void ThresholdParameter::clear_threshold() { + threshold_ = 0; + clear_has_threshold(); +} +float ThresholdParameter::threshold() const { + // @@protoc_insertion_point(field_get:caffe.ThresholdParameter.threshold) + return threshold_; +} +void ThresholdParameter::set_threshold(float value) { + set_has_threshold(); + threshold_ = value; + // @@protoc_insertion_point(field_set:caffe.ThresholdParameter.threshold) +} + +inline const ThresholdParameter* ThresholdParameter::internal_default_instance() { + return &ThresholdParameter_default_instance_.get(); +} +#endif // PROTOBUF_INLINE_NOT_IN_HEADERS // =================================================================== ::std::string* WindowDataParameter::_default_crop_mode_ = NULL; -#ifndef _MSC_VER +#if !defined(_MSC_VER) || _MSC_VER >= 1900 const int WindowDataParameter::kSourceFieldNumber; const int WindowDataParameter::kScaleFieldNumber; const int WindowDataParameter::kMeanFileFieldNumber; @@ -23762,59 +35687,50 @@ const int WindowDataParameter::kContextPadFieldNumber; const int WindowDataParameter::kCropModeFieldNumber; const int WindowDataParameter::kCacheImagesFieldNumber; const int WindowDataParameter::kRootFolderFieldNumber; -#endif // !_MSC_VER +#endif // !defined(_MSC_VER) || _MSC_VER >= 1900 WindowDataParameter::WindowDataParameter() - : ::google::protobuf::Message() { + : ::google::protobuf::Message(), _internal_metadata_(NULL) { + if (this != internal_default_instance()) protobuf_InitDefaults_caffe_2eproto(); SharedCtor(); + // @@protoc_insertion_point(constructor:caffe.WindowDataParameter) } void WindowDataParameter::InitAsDefaultInstance() { } WindowDataParameter::WindowDataParameter(const WindowDataParameter& from) - : ::google::protobuf::Message() { + : ::google::protobuf::Message(), + _internal_metadata_(NULL) { SharedCtor(); - MergeFrom(from); + UnsafeMergeFrom(from); + // @@protoc_insertion_point(copy_constructor:caffe.WindowDataParameter) } void WindowDataParameter::SharedCtor() { _cached_size_ = 0; - source_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); + source_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + mean_file_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + crop_mode_.UnsafeSetDefault(_default_crop_mode_); + root_folder_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + ::memset(&batch_size_, 0, reinterpret_cast(&context_pad_) - + reinterpret_cast(&batch_size_) + sizeof(context_pad_)); scale_ = 1; - mean_file_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); - batch_size_ = 0u; - crop_size_ = 0u; - mirror_ = false; fg_threshold_ = 0.5f; bg_threshold_ = 0.5f; fg_fraction_ = 0.25f; - context_pad_ = 0u; - crop_mode_ = const_cast< ::std::string*>(_default_crop_mode_); - cache_images_ = false; - root_folder_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); - ::memset(_has_bits_, 0, sizeof(_has_bits_)); } WindowDataParameter::~WindowDataParameter() { + // @@protoc_insertion_point(destructor:caffe.WindowDataParameter) SharedDtor(); } void WindowDataParameter::SharedDtor() { - if (source_ != &::google::protobuf::internal::kEmptyString) { - delete source_; - } - if (mean_file_ != &::google::protobuf::internal::kEmptyString) { - delete mean_file_; - } - if (crop_mode_ != _default_crop_mode_) { - delete crop_mode_; - } - if (root_folder_ != &::google::protobuf::internal::kEmptyString) { - delete root_folder_; - } - if (this != default_instance_) { - } + source_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + mean_file_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + crop_mode_.DestroyNoArena(_default_crop_mode_); + root_folder_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } void WindowDataParameter::SetCachedSize(int size) const { @@ -23828,71 +35744,91 @@ const ::google::protobuf::Descriptor* WindowDataParameter::descriptor() { } const WindowDataParameter& WindowDataParameter::default_instance() { - if (default_instance_ == NULL) protobuf_AddDesc_caffe_2eproto(); - return *default_instance_; + protobuf_InitDefaults_caffe_2eproto(); + return *internal_default_instance(); } -WindowDataParameter* WindowDataParameter::default_instance_ = NULL; +::google::protobuf::internal::ExplicitlyConstructed WindowDataParameter_default_instance_; -WindowDataParameter* WindowDataParameter::New() const { - return new WindowDataParameter; +WindowDataParameter* WindowDataParameter::New(::google::protobuf::Arena* arena) const { + WindowDataParameter* n = new WindowDataParameter; + if (arena != NULL) { + arena->Own(n); + } + return n; } void WindowDataParameter::Clear() { - if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) { +// @@protoc_insertion_point(message_clear_start:caffe.WindowDataParameter) +#if defined(__clang__) +#define ZR_HELPER_(f) \ + _Pragma("clang diagnostic push") \ + _Pragma("clang diagnostic ignored \"-Winvalid-offsetof\"") \ + __builtin_offsetof(WindowDataParameter, f) \ + _Pragma("clang diagnostic pop") +#else +#define ZR_HELPER_(f) reinterpret_cast(\ + &reinterpret_cast(16)->f) +#endif + +#define ZR_(first, last) do {\ + ::memset(&(first), 0,\ + ZR_HELPER_(last) - ZR_HELPER_(first) + sizeof(last));\ +} while (0) + + if (_has_bits_[0 / 32] & 255u) { + ZR_(batch_size_, mirror_); if (has_source()) { - if (source_ != &::google::protobuf::internal::kEmptyString) { - source_->clear(); - } + source_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } scale_ = 1; if (has_mean_file()) { - if (mean_file_ != &::google::protobuf::internal::kEmptyString) { - mean_file_->clear(); - } + mean_file_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - batch_size_ = 0u; - crop_size_ = 0u; - mirror_ = false; fg_threshold_ = 0.5f; bg_threshold_ = 0.5f; } - if (_has_bits_[8 / 32] & (0xffu << (8 % 32))) { + if (_has_bits_[8 / 32] & 7936u) { + ZR_(cache_images_, context_pad_); fg_fraction_ = 0.25f; - context_pad_ = 0u; if (has_crop_mode()) { - if (crop_mode_ != _default_crop_mode_) { - crop_mode_->assign(*_default_crop_mode_); - } + crop_mode_.ClearToDefaultNoArena(_default_crop_mode_); } - cache_images_ = false; if (has_root_folder()) { - if (root_folder_ != &::google::protobuf::internal::kEmptyString) { - root_folder_->clear(); - } + root_folder_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } } - ::memset(_has_bits_, 0, sizeof(_has_bits_)); - mutable_unknown_fields()->Clear(); + +#undef ZR_HELPER_ +#undef ZR_ + + _has_bits_.Clear(); + if (_internal_metadata_.have_unknown_fields()) { + mutable_unknown_fields()->Clear(); + } } bool WindowDataParameter::MergePartialFromCodedStream( ::google::protobuf::io::CodedInputStream* input) { -#define DO_(EXPRESSION) if (!(EXPRESSION)) return false +#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure ::google::protobuf::uint32 tag; - while ((tag = input->ReadTag()) != 0) { + // @@protoc_insertion_point(parse_start:caffe.WindowDataParameter) + for (;;) { + ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127); + tag = p.first; + if (!p.second) goto handle_unusual; switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { // optional string source = 1; case 1: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) { + if (tag == 10) { DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->mutable_source())); - ::google::protobuf::internal::WireFormat::VerifyUTF8String( + ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( this->source().data(), this->source().length(), - ::google::protobuf::internal::WireFormat::PARSE); + ::google::protobuf::internal::WireFormat::PARSE, + "caffe.WindowDataParameter.source"); } else { - goto handle_uninterpreted; + goto handle_unusual; } if (input->ExpectTag(21)) goto parse_scale; break; @@ -23900,15 +35836,14 @@ bool WindowDataParameter::MergePartialFromCodedStream( // optional float scale = 2 [default = 1]; case 2: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_FIXED32) { + if (tag == 21) { parse_scale: + set_has_scale(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< float, ::google::protobuf::internal::WireFormatLite::TYPE_FLOAT>( input, &scale_))); - set_has_scale(); } else { - goto handle_uninterpreted; + goto handle_unusual; } if (input->ExpectTag(26)) goto parse_mean_file; break; @@ -23916,16 +35851,16 @@ bool WindowDataParameter::MergePartialFromCodedStream( // optional string mean_file = 3; case 3: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) { + if (tag == 26) { parse_mean_file: DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->mutable_mean_file())); - ::google::protobuf::internal::WireFormat::VerifyUTF8String( + ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( this->mean_file().data(), this->mean_file().length(), - ::google::protobuf::internal::WireFormat::PARSE); + ::google::protobuf::internal::WireFormat::PARSE, + "caffe.WindowDataParameter.mean_file"); } else { - goto handle_uninterpreted; + goto handle_unusual; } if (input->ExpectTag(32)) goto parse_batch_size; break; @@ -23933,15 +35868,14 @@ bool WindowDataParameter::MergePartialFromCodedStream( // optional uint32 batch_size = 4; case 4: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) { + if (tag == 32) { parse_batch_size: + set_has_batch_size(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>( input, &batch_size_))); - set_has_batch_size(); } else { - goto handle_uninterpreted; + goto handle_unusual; } if (input->ExpectTag(40)) goto parse_crop_size; break; @@ -23949,15 +35883,14 @@ bool WindowDataParameter::MergePartialFromCodedStream( // optional uint32 crop_size = 5 [default = 0]; case 5: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) { + if (tag == 40) { parse_crop_size: + set_has_crop_size(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>( input, &crop_size_))); - set_has_crop_size(); } else { - goto handle_uninterpreted; + goto handle_unusual; } if (input->ExpectTag(48)) goto parse_mirror; break; @@ -23965,15 +35898,14 @@ bool WindowDataParameter::MergePartialFromCodedStream( // optional bool mirror = 6 [default = false]; case 6: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) { + if (tag == 48) { parse_mirror: + set_has_mirror(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>( input, &mirror_))); - set_has_mirror(); } else { - goto handle_uninterpreted; + goto handle_unusual; } if (input->ExpectTag(61)) goto parse_fg_threshold; break; @@ -23981,15 +35913,14 @@ bool WindowDataParameter::MergePartialFromCodedStream( // optional float fg_threshold = 7 [default = 0.5]; case 7: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_FIXED32) { + if (tag == 61) { parse_fg_threshold: + set_has_fg_threshold(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< float, ::google::protobuf::internal::WireFormatLite::TYPE_FLOAT>( input, &fg_threshold_))); - set_has_fg_threshold(); } else { - goto handle_uninterpreted; + goto handle_unusual; } if (input->ExpectTag(69)) goto parse_bg_threshold; break; @@ -23997,15 +35928,14 @@ bool WindowDataParameter::MergePartialFromCodedStream( // optional float bg_threshold = 8 [default = 0.5]; case 8: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_FIXED32) { + if (tag == 69) { parse_bg_threshold: + set_has_bg_threshold(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< float, ::google::protobuf::internal::WireFormatLite::TYPE_FLOAT>( input, &bg_threshold_))); - set_has_bg_threshold(); } else { - goto handle_uninterpreted; + goto handle_unusual; } if (input->ExpectTag(77)) goto parse_fg_fraction; break; @@ -24013,15 +35943,14 @@ bool WindowDataParameter::MergePartialFromCodedStream( // optional float fg_fraction = 9 [default = 0.25]; case 9: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_FIXED32) { + if (tag == 77) { parse_fg_fraction: + set_has_fg_fraction(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< float, ::google::protobuf::internal::WireFormatLite::TYPE_FLOAT>( input, &fg_fraction_))); - set_has_fg_fraction(); } else { - goto handle_uninterpreted; + goto handle_unusual; } if (input->ExpectTag(80)) goto parse_context_pad; break; @@ -24029,15 +35958,14 @@ bool WindowDataParameter::MergePartialFromCodedStream( // optional uint32 context_pad = 10 [default = 0]; case 10: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) { + if (tag == 80) { parse_context_pad: + set_has_context_pad(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>( input, &context_pad_))); - set_has_context_pad(); } else { - goto handle_uninterpreted; + goto handle_unusual; } if (input->ExpectTag(90)) goto parse_crop_mode; break; @@ -24045,16 +35973,16 @@ bool WindowDataParameter::MergePartialFromCodedStream( // optional string crop_mode = 11 [default = "warp"]; case 11: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) { + if (tag == 90) { parse_crop_mode: DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->mutable_crop_mode())); - ::google::protobuf::internal::WireFormat::VerifyUTF8String( + ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( this->crop_mode().data(), this->crop_mode().length(), - ::google::protobuf::internal::WireFormat::PARSE); + ::google::protobuf::internal::WireFormat::PARSE, + "caffe.WindowDataParameter.crop_mode"); } else { - goto handle_uninterpreted; + goto handle_unusual; } if (input->ExpectTag(96)) goto parse_cache_images; break; @@ -24062,15 +35990,14 @@ bool WindowDataParameter::MergePartialFromCodedStream( // optional bool cache_images = 12 [default = false]; case 12: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) { + if (tag == 96) { parse_cache_images: + set_has_cache_images(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>( input, &cache_images_))); - set_has_cache_images(); } else { - goto handle_uninterpreted; + goto handle_unusual; } if (input->ExpectTag(106)) goto parse_root_folder; break; @@ -24078,26 +36005,27 @@ bool WindowDataParameter::MergePartialFromCodedStream( // optional string root_folder = 13 [default = ""]; case 13: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) { + if (tag == 106) { parse_root_folder: DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->mutable_root_folder())); - ::google::protobuf::internal::WireFormat::VerifyUTF8String( + ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( this->root_folder().data(), this->root_folder().length(), - ::google::protobuf::internal::WireFormat::PARSE); + ::google::protobuf::internal::WireFormat::PARSE, + "caffe.WindowDataParameter.root_folder"); } else { - goto handle_uninterpreted; + goto handle_unusual; } - if (input->ExpectAtEnd()) return true; + if (input->ExpectAtEnd()) goto success; break; } default: { - handle_uninterpreted: - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == + handle_unusual: + if (tag == 0 || + ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) { - return true; + goto success; } DO_(::google::protobuf::internal::WireFormat::SkipField( input, tag, mutable_unknown_fields())); @@ -24105,18 +36033,25 @@ bool WindowDataParameter::MergePartialFromCodedStream( } } } +success: + // @@protoc_insertion_point(parse_success:caffe.WindowDataParameter) return true; +failure: + // @@protoc_insertion_point(parse_failure:caffe.WindowDataParameter) + return false; #undef DO_ } void WindowDataParameter::SerializeWithCachedSizes( ::google::protobuf::io::CodedOutputStream* output) const { + // @@protoc_insertion_point(serialize_start:caffe.WindowDataParameter) // optional string source = 1; if (has_source()) { - ::google::protobuf::internal::WireFormat::VerifyUTF8String( + ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( this->source().data(), this->source().length(), - ::google::protobuf::internal::WireFormat::SERIALIZE); - ::google::protobuf::internal::WireFormatLite::WriteString( + ::google::protobuf::internal::WireFormat::SERIALIZE, + "caffe.WindowDataParameter.source"); + ::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased( 1, this->source(), output); } @@ -24127,10 +36062,11 @@ void WindowDataParameter::SerializeWithCachedSizes( // optional string mean_file = 3; if (has_mean_file()) { - ::google::protobuf::internal::WireFormat::VerifyUTF8String( + ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( this->mean_file().data(), this->mean_file().length(), - ::google::protobuf::internal::WireFormat::SERIALIZE); - ::google::protobuf::internal::WireFormatLite::WriteString( + ::google::protobuf::internal::WireFormat::SERIALIZE, + "caffe.WindowDataParameter.mean_file"); + ::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased( 3, this->mean_file(), output); } @@ -24171,10 +36107,11 @@ void WindowDataParameter::SerializeWithCachedSizes( // optional string crop_mode = 11 [default = "warp"]; if (has_crop_mode()) { - ::google::protobuf::internal::WireFormat::VerifyUTF8String( + ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( this->crop_mode().data(), this->crop_mode().length(), - ::google::protobuf::internal::WireFormat::SERIALIZE); - ::google::protobuf::internal::WireFormatLite::WriteString( + ::google::protobuf::internal::WireFormat::SERIALIZE, + "caffe.WindowDataParameter.crop_mode"); + ::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased( 11, this->crop_mode(), output); } @@ -24185,26 +36122,31 @@ void WindowDataParameter::SerializeWithCachedSizes( // optional string root_folder = 13 [default = ""]; if (has_root_folder()) { - ::google::protobuf::internal::WireFormat::VerifyUTF8String( + ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( this->root_folder().data(), this->root_folder().length(), - ::google::protobuf::internal::WireFormat::SERIALIZE); - ::google::protobuf::internal::WireFormatLite::WriteString( + ::google::protobuf::internal::WireFormat::SERIALIZE, + "caffe.WindowDataParameter.root_folder"); + ::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased( 13, this->root_folder(), output); } - if (!unknown_fields().empty()) { + if (_internal_metadata_.have_unknown_fields()) { ::google::protobuf::internal::WireFormat::SerializeUnknownFields( unknown_fields(), output); } + // @@protoc_insertion_point(serialize_end:caffe.WindowDataParameter) } -::google::protobuf::uint8* WindowDataParameter::SerializeWithCachedSizesToArray( - ::google::protobuf::uint8* target) const { +::google::protobuf::uint8* WindowDataParameter::InternalSerializeWithCachedSizesToArray( + bool deterministic, ::google::protobuf::uint8* target) const { + (void)deterministic; // Unused + // @@protoc_insertion_point(serialize_to_array_start:caffe.WindowDataParameter) // optional string source = 1; if (has_source()) { - ::google::protobuf::internal::WireFormat::VerifyUTF8String( + ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( this->source().data(), this->source().length(), - ::google::protobuf::internal::WireFormat::SERIALIZE); + ::google::protobuf::internal::WireFormat::SERIALIZE, + "caffe.WindowDataParameter.source"); target = ::google::protobuf::internal::WireFormatLite::WriteStringToArray( 1, this->source(), target); @@ -24217,9 +36159,10 @@ void WindowDataParameter::SerializeWithCachedSizes( // optional string mean_file = 3; if (has_mean_file()) { - ::google::protobuf::internal::WireFormat::VerifyUTF8String( + ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( this->mean_file().data(), this->mean_file().length(), - ::google::protobuf::internal::WireFormat::SERIALIZE); + ::google::protobuf::internal::WireFormat::SERIALIZE, + "caffe.WindowDataParameter.mean_file"); target = ::google::protobuf::internal::WireFormatLite::WriteStringToArray( 3, this->mean_file(), target); @@ -24262,9 +36205,10 @@ void WindowDataParameter::SerializeWithCachedSizes( // optional string crop_mode = 11 [default = "warp"]; if (has_crop_mode()) { - ::google::protobuf::internal::WireFormat::VerifyUTF8String( + ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( this->crop_mode().data(), this->crop_mode().length(), - ::google::protobuf::internal::WireFormat::SERIALIZE); + ::google::protobuf::internal::WireFormat::SERIALIZE, + "caffe.WindowDataParameter.crop_mode"); target = ::google::protobuf::internal::WireFormatLite::WriteStringToArray( 11, this->crop_mode(), target); @@ -24277,25 +36221,28 @@ void WindowDataParameter::SerializeWithCachedSizes( // optional string root_folder = 13 [default = ""]; if (has_root_folder()) { - ::google::protobuf::internal::WireFormat::VerifyUTF8String( + ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( this->root_folder().data(), this->root_folder().length(), - ::google::protobuf::internal::WireFormat::SERIALIZE); + ::google::protobuf::internal::WireFormat::SERIALIZE, + "caffe.WindowDataParameter.root_folder"); target = ::google::protobuf::internal::WireFormatLite::WriteStringToArray( 13, this->root_folder(), target); } - if (!unknown_fields().empty()) { + if (_internal_metadata_.have_unknown_fields()) { target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray( unknown_fields(), target); } + // @@protoc_insertion_point(serialize_to_array_end:caffe.WindowDataParameter) return target; } -int WindowDataParameter::ByteSize() const { - int total_size = 0; +size_t WindowDataParameter::ByteSizeLong() const { +// @@protoc_insertion_point(message_byte_size_start:caffe.WindowDataParameter) + size_t total_size = 0; - if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) { + if (_has_bits_[0 / 32] & 255u) { // optional string source = 1; if (has_source()) { total_size += 1 + @@ -24345,7 +36292,7 @@ int WindowDataParameter::ByteSize() const { } } - if (_has_bits_[8 / 32] & (0xffu << (8 % 32))) { + if (_has_bits_[8 / 32] & 7936u) { // optional float fg_fraction = 9 [default = 0.25]; if (has_fg_fraction()) { total_size += 1 + 4; @@ -24378,40 +36325,55 @@ int WindowDataParameter::ByteSize() const { } } - if (!unknown_fields().empty()) { + if (_internal_metadata_.have_unknown_fields()) { total_size += ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( unknown_fields()); } + int cached_size = ::google::protobuf::internal::ToCachedSize(total_size); GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); - _cached_size_ = total_size; + _cached_size_ = cached_size; GOOGLE_SAFE_CONCURRENT_WRITES_END(); return total_size; } void WindowDataParameter::MergeFrom(const ::google::protobuf::Message& from) { - GOOGLE_CHECK_NE(&from, this); +// @@protoc_insertion_point(generalized_merge_from_start:caffe.WindowDataParameter) + if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__); const WindowDataParameter* source = - ::google::protobuf::internal::dynamic_cast_if_available( - &from); + ::google::protobuf::internal::DynamicCastToGenerated( + &from); if (source == NULL) { + // @@protoc_insertion_point(generalized_merge_from_cast_fail:caffe.WindowDataParameter) ::google::protobuf::internal::ReflectionOps::Merge(from, this); } else { - MergeFrom(*source); + // @@protoc_insertion_point(generalized_merge_from_cast_success:caffe.WindowDataParameter) + UnsafeMergeFrom(*source); } } void WindowDataParameter::MergeFrom(const WindowDataParameter& from) { - GOOGLE_CHECK_NE(&from, this); +// @@protoc_insertion_point(class_specific_merge_from_start:caffe.WindowDataParameter) + if (GOOGLE_PREDICT_TRUE(&from != this)) { + UnsafeMergeFrom(from); + } else { + MergeFromFail(__LINE__); + } +} + +void WindowDataParameter::UnsafeMergeFrom(const WindowDataParameter& from) { + GOOGLE_DCHECK(&from != this); if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) { if (from.has_source()) { - set_source(from.source()); + set_has_source(); + source_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.source_); } if (from.has_scale()) { set_scale(from.scale()); } if (from.has_mean_file()) { - set_mean_file(from.mean_file()); + set_has_mean_file(); + mean_file_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.mean_file_); } if (from.has_batch_size()) { set_batch_size(from.batch_size()); @@ -24437,28 +36399,35 @@ void WindowDataParameter::MergeFrom(const WindowDataParameter& from) { set_context_pad(from.context_pad()); } if (from.has_crop_mode()) { - set_crop_mode(from.crop_mode()); + set_has_crop_mode(); + crop_mode_.AssignWithDefault(_default_crop_mode_, from.crop_mode_); } if (from.has_cache_images()) { set_cache_images(from.cache_images()); } if (from.has_root_folder()) { - set_root_folder(from.root_folder()); + set_has_root_folder(); + root_folder_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.root_folder_); } } - mutable_unknown_fields()->MergeFrom(from.unknown_fields()); + if (from._internal_metadata_.have_unknown_fields()) { + ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata( + from.unknown_fields(), &_internal_metadata_); + } } void WindowDataParameter::CopyFrom(const ::google::protobuf::Message& from) { +// @@protoc_insertion_point(generalized_copy_from_start:caffe.WindowDataParameter) if (&from == this) return; Clear(); MergeFrom(from); } void WindowDataParameter::CopyFrom(const WindowDataParameter& from) { +// @@protoc_insertion_point(class_specific_copy_from_start:caffe.WindowDataParameter) if (&from == this) return; Clear(); - MergeFrom(from); + UnsafeMergeFrom(from); } bool WindowDataParameter::IsInitialized() const { @@ -24467,24 +36436,26 @@ bool WindowDataParameter::IsInitialized() const { } void WindowDataParameter::Swap(WindowDataParameter* other) { - if (other != this) { - std::swap(source_, other->source_); - std::swap(scale_, other->scale_); - std::swap(mean_file_, other->mean_file_); - std::swap(batch_size_, other->batch_size_); - std::swap(crop_size_, other->crop_size_); - std::swap(mirror_, other->mirror_); - std::swap(fg_threshold_, other->fg_threshold_); - std::swap(bg_threshold_, other->bg_threshold_); - std::swap(fg_fraction_, other->fg_fraction_); - std::swap(context_pad_, other->context_pad_); - std::swap(crop_mode_, other->crop_mode_); - std::swap(cache_images_, other->cache_images_); - std::swap(root_folder_, other->root_folder_); - std::swap(_has_bits_[0], other->_has_bits_[0]); - _unknown_fields_.Swap(&other->_unknown_fields_); - std::swap(_cached_size_, other->_cached_size_); - } + if (other == this) return; + InternalSwap(other); +} +void WindowDataParameter::InternalSwap(WindowDataParameter* other) { + source_.Swap(&other->source_); + std::swap(scale_, other->scale_); + mean_file_.Swap(&other->mean_file_); + std::swap(batch_size_, other->batch_size_); + std::swap(crop_size_, other->crop_size_); + std::swap(mirror_, other->mirror_); + std::swap(fg_threshold_, other->fg_threshold_); + std::swap(bg_threshold_, other->bg_threshold_); + std::swap(fg_fraction_, other->fg_fraction_); + std::swap(context_pad_, other->context_pad_); + crop_mode_.Swap(&other->crop_mode_); + std::swap(cache_images_, other->cache_images_); + root_folder_.Swap(&other->root_folder_); + std::swap(_has_bits_[0], other->_has_bits_[0]); + _internal_metadata_.Swap(&other->_internal_metadata_); + std::swap(_cached_size_, other->_cached_size_); } ::google::protobuf::Metadata WindowDataParameter::GetMetadata() const { @@ -24495,6 +36466,445 @@ void WindowDataParameter::Swap(WindowDataParameter* other) { return metadata; } +#if PROTOBUF_INLINE_NOT_IN_HEADERS +// WindowDataParameter + +// optional string source = 1; +bool WindowDataParameter::has_source() const { + return (_has_bits_[0] & 0x00000001u) != 0; +} +void WindowDataParameter::set_has_source() { + _has_bits_[0] |= 0x00000001u; +} +void WindowDataParameter::clear_has_source() { + _has_bits_[0] &= ~0x00000001u; +} +void WindowDataParameter::clear_source() { + source_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + clear_has_source(); +} +const ::std::string& WindowDataParameter::source() const { + // @@protoc_insertion_point(field_get:caffe.WindowDataParameter.source) + return source_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); +} +void WindowDataParameter::set_source(const ::std::string& value) { + set_has_source(); + source_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); + // @@protoc_insertion_point(field_set:caffe.WindowDataParameter.source) +} +void WindowDataParameter::set_source(const char* value) { + set_has_source(); + source_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); + // @@protoc_insertion_point(field_set_char:caffe.WindowDataParameter.source) +} +void WindowDataParameter::set_source(const char* value, size_t size) { + set_has_source(); + source_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), + ::std::string(reinterpret_cast(value), size)); + // @@protoc_insertion_point(field_set_pointer:caffe.WindowDataParameter.source) +} +::std::string* WindowDataParameter::mutable_source() { + set_has_source(); + // @@protoc_insertion_point(field_mutable:caffe.WindowDataParameter.source) + return source_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); +} +::std::string* WindowDataParameter::release_source() { + // @@protoc_insertion_point(field_release:caffe.WindowDataParameter.source) + clear_has_source(); + return source_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); +} +void WindowDataParameter::set_allocated_source(::std::string* source) { + if (source != NULL) { + set_has_source(); + } else { + clear_has_source(); + } + source_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), source); + // @@protoc_insertion_point(field_set_allocated:caffe.WindowDataParameter.source) +} + +// optional float scale = 2 [default = 1]; +bool WindowDataParameter::has_scale() const { + return (_has_bits_[0] & 0x00000002u) != 0; +} +void WindowDataParameter::set_has_scale() { + _has_bits_[0] |= 0x00000002u; +} +void WindowDataParameter::clear_has_scale() { + _has_bits_[0] &= ~0x00000002u; +} +void WindowDataParameter::clear_scale() { + scale_ = 1; + clear_has_scale(); +} +float WindowDataParameter::scale() const { + // @@protoc_insertion_point(field_get:caffe.WindowDataParameter.scale) + return scale_; +} +void WindowDataParameter::set_scale(float value) { + set_has_scale(); + scale_ = value; + // @@protoc_insertion_point(field_set:caffe.WindowDataParameter.scale) +} + +// optional string mean_file = 3; +bool WindowDataParameter::has_mean_file() const { + return (_has_bits_[0] & 0x00000004u) != 0; +} +void WindowDataParameter::set_has_mean_file() { + _has_bits_[0] |= 0x00000004u; +} +void WindowDataParameter::clear_has_mean_file() { + _has_bits_[0] &= ~0x00000004u; +} +void WindowDataParameter::clear_mean_file() { + mean_file_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + clear_has_mean_file(); +} +const ::std::string& WindowDataParameter::mean_file() const { + // @@protoc_insertion_point(field_get:caffe.WindowDataParameter.mean_file) + return mean_file_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); +} +void WindowDataParameter::set_mean_file(const ::std::string& value) { + set_has_mean_file(); + mean_file_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); + // @@protoc_insertion_point(field_set:caffe.WindowDataParameter.mean_file) +} +void WindowDataParameter::set_mean_file(const char* value) { + set_has_mean_file(); + mean_file_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); + // @@protoc_insertion_point(field_set_char:caffe.WindowDataParameter.mean_file) +} +void WindowDataParameter::set_mean_file(const char* value, size_t size) { + set_has_mean_file(); + mean_file_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), + ::std::string(reinterpret_cast(value), size)); + // @@protoc_insertion_point(field_set_pointer:caffe.WindowDataParameter.mean_file) +} +::std::string* WindowDataParameter::mutable_mean_file() { + set_has_mean_file(); + // @@protoc_insertion_point(field_mutable:caffe.WindowDataParameter.mean_file) + return mean_file_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); +} +::std::string* WindowDataParameter::release_mean_file() { + // @@protoc_insertion_point(field_release:caffe.WindowDataParameter.mean_file) + clear_has_mean_file(); + return mean_file_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); +} +void WindowDataParameter::set_allocated_mean_file(::std::string* mean_file) { + if (mean_file != NULL) { + set_has_mean_file(); + } else { + clear_has_mean_file(); + } + mean_file_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), mean_file); + // @@protoc_insertion_point(field_set_allocated:caffe.WindowDataParameter.mean_file) +} + +// optional uint32 batch_size = 4; +bool WindowDataParameter::has_batch_size() const { + return (_has_bits_[0] & 0x00000008u) != 0; +} +void WindowDataParameter::set_has_batch_size() { + _has_bits_[0] |= 0x00000008u; +} +void WindowDataParameter::clear_has_batch_size() { + _has_bits_[0] &= ~0x00000008u; +} +void WindowDataParameter::clear_batch_size() { + batch_size_ = 0u; + clear_has_batch_size(); +} +::google::protobuf::uint32 WindowDataParameter::batch_size() const { + // @@protoc_insertion_point(field_get:caffe.WindowDataParameter.batch_size) + return batch_size_; +} +void WindowDataParameter::set_batch_size(::google::protobuf::uint32 value) { + set_has_batch_size(); + batch_size_ = value; + // @@protoc_insertion_point(field_set:caffe.WindowDataParameter.batch_size) +} + +// optional uint32 crop_size = 5 [default = 0]; +bool WindowDataParameter::has_crop_size() const { + return (_has_bits_[0] & 0x00000010u) != 0; +} +void WindowDataParameter::set_has_crop_size() { + _has_bits_[0] |= 0x00000010u; +} +void WindowDataParameter::clear_has_crop_size() { + _has_bits_[0] &= ~0x00000010u; +} +void WindowDataParameter::clear_crop_size() { + crop_size_ = 0u; + clear_has_crop_size(); +} +::google::protobuf::uint32 WindowDataParameter::crop_size() const { + // @@protoc_insertion_point(field_get:caffe.WindowDataParameter.crop_size) + return crop_size_; +} +void WindowDataParameter::set_crop_size(::google::protobuf::uint32 value) { + set_has_crop_size(); + crop_size_ = value; + // @@protoc_insertion_point(field_set:caffe.WindowDataParameter.crop_size) +} + +// optional bool mirror = 6 [default = false]; +bool WindowDataParameter::has_mirror() const { + return (_has_bits_[0] & 0x00000020u) != 0; +} +void WindowDataParameter::set_has_mirror() { + _has_bits_[0] |= 0x00000020u; +} +void WindowDataParameter::clear_has_mirror() { + _has_bits_[0] &= ~0x00000020u; +} +void WindowDataParameter::clear_mirror() { + mirror_ = false; + clear_has_mirror(); +} +bool WindowDataParameter::mirror() const { + // @@protoc_insertion_point(field_get:caffe.WindowDataParameter.mirror) + return mirror_; +} +void WindowDataParameter::set_mirror(bool value) { + set_has_mirror(); + mirror_ = value; + // @@protoc_insertion_point(field_set:caffe.WindowDataParameter.mirror) +} + +// optional float fg_threshold = 7 [default = 0.5]; +bool WindowDataParameter::has_fg_threshold() const { + return (_has_bits_[0] & 0x00000040u) != 0; +} +void WindowDataParameter::set_has_fg_threshold() { + _has_bits_[0] |= 0x00000040u; +} +void WindowDataParameter::clear_has_fg_threshold() { + _has_bits_[0] &= ~0x00000040u; +} +void WindowDataParameter::clear_fg_threshold() { + fg_threshold_ = 0.5f; + clear_has_fg_threshold(); +} +float WindowDataParameter::fg_threshold() const { + // @@protoc_insertion_point(field_get:caffe.WindowDataParameter.fg_threshold) + return fg_threshold_; +} +void WindowDataParameter::set_fg_threshold(float value) { + set_has_fg_threshold(); + fg_threshold_ = value; + // @@protoc_insertion_point(field_set:caffe.WindowDataParameter.fg_threshold) +} + +// optional float bg_threshold = 8 [default = 0.5]; +bool WindowDataParameter::has_bg_threshold() const { + return (_has_bits_[0] & 0x00000080u) != 0; +} +void WindowDataParameter::set_has_bg_threshold() { + _has_bits_[0] |= 0x00000080u; +} +void WindowDataParameter::clear_has_bg_threshold() { + _has_bits_[0] &= ~0x00000080u; +} +void WindowDataParameter::clear_bg_threshold() { + bg_threshold_ = 0.5f; + clear_has_bg_threshold(); +} +float WindowDataParameter::bg_threshold() const { + // @@protoc_insertion_point(field_get:caffe.WindowDataParameter.bg_threshold) + return bg_threshold_; +} +void WindowDataParameter::set_bg_threshold(float value) { + set_has_bg_threshold(); + bg_threshold_ = value; + // @@protoc_insertion_point(field_set:caffe.WindowDataParameter.bg_threshold) +} + +// optional float fg_fraction = 9 [default = 0.25]; +bool WindowDataParameter::has_fg_fraction() const { + return (_has_bits_[0] & 0x00000100u) != 0; +} +void WindowDataParameter::set_has_fg_fraction() { + _has_bits_[0] |= 0x00000100u; +} +void WindowDataParameter::clear_has_fg_fraction() { + _has_bits_[0] &= ~0x00000100u; +} +void WindowDataParameter::clear_fg_fraction() { + fg_fraction_ = 0.25f; + clear_has_fg_fraction(); +} +float WindowDataParameter::fg_fraction() const { + // @@protoc_insertion_point(field_get:caffe.WindowDataParameter.fg_fraction) + return fg_fraction_; +} +void WindowDataParameter::set_fg_fraction(float value) { + set_has_fg_fraction(); + fg_fraction_ = value; + // @@protoc_insertion_point(field_set:caffe.WindowDataParameter.fg_fraction) +} + +// optional uint32 context_pad = 10 [default = 0]; +bool WindowDataParameter::has_context_pad() const { + return (_has_bits_[0] & 0x00000200u) != 0; +} +void WindowDataParameter::set_has_context_pad() { + _has_bits_[0] |= 0x00000200u; +} +void WindowDataParameter::clear_has_context_pad() { + _has_bits_[0] &= ~0x00000200u; +} +void WindowDataParameter::clear_context_pad() { + context_pad_ = 0u; + clear_has_context_pad(); +} +::google::protobuf::uint32 WindowDataParameter::context_pad() const { + // @@protoc_insertion_point(field_get:caffe.WindowDataParameter.context_pad) + return context_pad_; +} +void WindowDataParameter::set_context_pad(::google::protobuf::uint32 value) { + set_has_context_pad(); + context_pad_ = value; + // @@protoc_insertion_point(field_set:caffe.WindowDataParameter.context_pad) +} + +// optional string crop_mode = 11 [default = "warp"]; +bool WindowDataParameter::has_crop_mode() const { + return (_has_bits_[0] & 0x00000400u) != 0; +} +void WindowDataParameter::set_has_crop_mode() { + _has_bits_[0] |= 0x00000400u; +} +void WindowDataParameter::clear_has_crop_mode() { + _has_bits_[0] &= ~0x00000400u; +} +void WindowDataParameter::clear_crop_mode() { + crop_mode_.ClearToDefaultNoArena(_default_crop_mode_); + clear_has_crop_mode(); +} +const ::std::string& WindowDataParameter::crop_mode() const { + // @@protoc_insertion_point(field_get:caffe.WindowDataParameter.crop_mode) + return crop_mode_.GetNoArena(_default_crop_mode_); +} +void WindowDataParameter::set_crop_mode(const ::std::string& value) { + set_has_crop_mode(); + crop_mode_.SetNoArena(_default_crop_mode_, value); + // @@protoc_insertion_point(field_set:caffe.WindowDataParameter.crop_mode) +} +void WindowDataParameter::set_crop_mode(const char* value) { + set_has_crop_mode(); + crop_mode_.SetNoArena(_default_crop_mode_, ::std::string(value)); + // @@protoc_insertion_point(field_set_char:caffe.WindowDataParameter.crop_mode) +} +void WindowDataParameter::set_crop_mode(const char* value, size_t size) { + set_has_crop_mode(); + crop_mode_.SetNoArena(_default_crop_mode_, + ::std::string(reinterpret_cast(value), size)); + // @@protoc_insertion_point(field_set_pointer:caffe.WindowDataParameter.crop_mode) +} +::std::string* WindowDataParameter::mutable_crop_mode() { + set_has_crop_mode(); + // @@protoc_insertion_point(field_mutable:caffe.WindowDataParameter.crop_mode) + return crop_mode_.MutableNoArena(_default_crop_mode_); +} +::std::string* WindowDataParameter::release_crop_mode() { + // @@protoc_insertion_point(field_release:caffe.WindowDataParameter.crop_mode) + clear_has_crop_mode(); + return crop_mode_.ReleaseNoArena(_default_crop_mode_); +} +void WindowDataParameter::set_allocated_crop_mode(::std::string* crop_mode) { + if (crop_mode != NULL) { + set_has_crop_mode(); + } else { + clear_has_crop_mode(); + } + crop_mode_.SetAllocatedNoArena(_default_crop_mode_, crop_mode); + // @@protoc_insertion_point(field_set_allocated:caffe.WindowDataParameter.crop_mode) +} + +// optional bool cache_images = 12 [default = false]; +bool WindowDataParameter::has_cache_images() const { + return (_has_bits_[0] & 0x00000800u) != 0; +} +void WindowDataParameter::set_has_cache_images() { + _has_bits_[0] |= 0x00000800u; +} +void WindowDataParameter::clear_has_cache_images() { + _has_bits_[0] &= ~0x00000800u; +} +void WindowDataParameter::clear_cache_images() { + cache_images_ = false; + clear_has_cache_images(); +} +bool WindowDataParameter::cache_images() const { + // @@protoc_insertion_point(field_get:caffe.WindowDataParameter.cache_images) + return cache_images_; +} +void WindowDataParameter::set_cache_images(bool value) { + set_has_cache_images(); + cache_images_ = value; + // @@protoc_insertion_point(field_set:caffe.WindowDataParameter.cache_images) +} + +// optional string root_folder = 13 [default = ""]; +bool WindowDataParameter::has_root_folder() const { + return (_has_bits_[0] & 0x00001000u) != 0; +} +void WindowDataParameter::set_has_root_folder() { + _has_bits_[0] |= 0x00001000u; +} +void WindowDataParameter::clear_has_root_folder() { + _has_bits_[0] &= ~0x00001000u; +} +void WindowDataParameter::clear_root_folder() { + root_folder_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + clear_has_root_folder(); +} +const ::std::string& WindowDataParameter::root_folder() const { + // @@protoc_insertion_point(field_get:caffe.WindowDataParameter.root_folder) + return root_folder_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); +} +void WindowDataParameter::set_root_folder(const ::std::string& value) { + set_has_root_folder(); + root_folder_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); + // @@protoc_insertion_point(field_set:caffe.WindowDataParameter.root_folder) +} +void WindowDataParameter::set_root_folder(const char* value) { + set_has_root_folder(); + root_folder_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); + // @@protoc_insertion_point(field_set_char:caffe.WindowDataParameter.root_folder) +} +void WindowDataParameter::set_root_folder(const char* value, size_t size) { + set_has_root_folder(); + root_folder_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), + ::std::string(reinterpret_cast(value), size)); + // @@protoc_insertion_point(field_set_pointer:caffe.WindowDataParameter.root_folder) +} +::std::string* WindowDataParameter::mutable_root_folder() { + set_has_root_folder(); + // @@protoc_insertion_point(field_mutable:caffe.WindowDataParameter.root_folder) + return root_folder_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); +} +::std::string* WindowDataParameter::release_root_folder() { + // @@protoc_insertion_point(field_release:caffe.WindowDataParameter.root_folder) + clear_has_root_folder(); + return root_folder_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); +} +void WindowDataParameter::set_allocated_root_folder(::std::string* root_folder) { + if (root_folder != NULL) { + set_has_root_folder(); + } else { + clear_has_root_folder(); + } + root_folder_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), root_folder); + // @@protoc_insertion_point(field_set_allocated:caffe.WindowDataParameter.root_folder) +} + +inline const WindowDataParameter* WindowDataParameter::internal_default_instance() { + return &WindowDataParameter_default_instance_.get(); +} +#endif // PROTOBUF_INLINE_NOT_IN_HEADERS // =================================================================== @@ -24503,7 +36913,7 @@ const ::google::protobuf::EnumDescriptor* SPPParameter_PoolMethod_descriptor() { return SPPParameter_PoolMethod_descriptor_; } bool SPPParameter_PoolMethod_IsValid(int value) { - switch(value) { + switch (value) { case 0: case 1: case 2: @@ -24513,20 +36923,20 @@ bool SPPParameter_PoolMethod_IsValid(int value) { } } -#ifndef _MSC_VER +#if !defined(_MSC_VER) || _MSC_VER >= 1900 const SPPParameter_PoolMethod SPPParameter::MAX; const SPPParameter_PoolMethod SPPParameter::AVE; const SPPParameter_PoolMethod SPPParameter::STOCHASTIC; const SPPParameter_PoolMethod SPPParameter::PoolMethod_MIN; const SPPParameter_PoolMethod SPPParameter::PoolMethod_MAX; const int SPPParameter::PoolMethod_ARRAYSIZE; -#endif // _MSC_VER +#endif // !defined(_MSC_VER) || _MSC_VER >= 1900 const ::google::protobuf::EnumDescriptor* SPPParameter_Engine_descriptor() { protobuf_AssignDescriptorsOnce(); return SPPParameter_Engine_descriptor_; } bool SPPParameter_Engine_IsValid(int value) { - switch(value) { + switch (value) { case 0: case 1: case 2: @@ -24536,49 +36946,50 @@ bool SPPParameter_Engine_IsValid(int value) { } } -#ifndef _MSC_VER +#if !defined(_MSC_VER) || _MSC_VER >= 1900 const SPPParameter_Engine SPPParameter::DEFAULT; const SPPParameter_Engine SPPParameter::CAFFE; const SPPParameter_Engine SPPParameter::CUDNN; const SPPParameter_Engine SPPParameter::Engine_MIN; const SPPParameter_Engine SPPParameter::Engine_MAX; const int SPPParameter::Engine_ARRAYSIZE; -#endif // _MSC_VER -#ifndef _MSC_VER +#endif // !defined(_MSC_VER) || _MSC_VER >= 1900 +#if !defined(_MSC_VER) || _MSC_VER >= 1900 const int SPPParameter::kPyramidHeightFieldNumber; const int SPPParameter::kPoolFieldNumber; const int SPPParameter::kEngineFieldNumber; -#endif // !_MSC_VER +#endif // !defined(_MSC_VER) || _MSC_VER >= 1900 SPPParameter::SPPParameter() - : ::google::protobuf::Message() { + : ::google::protobuf::Message(), _internal_metadata_(NULL) { + if (this != internal_default_instance()) protobuf_InitDefaults_caffe_2eproto(); SharedCtor(); + // @@protoc_insertion_point(constructor:caffe.SPPParameter) } void SPPParameter::InitAsDefaultInstance() { } SPPParameter::SPPParameter(const SPPParameter& from) - : ::google::protobuf::Message() { + : ::google::protobuf::Message(), + _internal_metadata_(NULL) { SharedCtor(); - MergeFrom(from); + UnsafeMergeFrom(from); + // @@protoc_insertion_point(copy_constructor:caffe.SPPParameter) } void SPPParameter::SharedCtor() { _cached_size_ = 0; - pyramid_height_ = 0u; - pool_ = 0; - engine_ = 0; - ::memset(_has_bits_, 0, sizeof(_has_bits_)); + ::memset(&pyramid_height_, 0, reinterpret_cast(&engine_) - + reinterpret_cast(&pyramid_height_) + sizeof(engine_)); } SPPParameter::~SPPParameter() { + // @@protoc_insertion_point(destructor:caffe.SPPParameter) SharedDtor(); } void SPPParameter::SharedDtor() { - if (this != default_instance_) { - } } void SPPParameter::SetCachedSize(int size) const { @@ -24592,42 +37003,68 @@ const ::google::protobuf::Descriptor* SPPParameter::descriptor() { } const SPPParameter& SPPParameter::default_instance() { - if (default_instance_ == NULL) protobuf_AddDesc_caffe_2eproto(); - return *default_instance_; + protobuf_InitDefaults_caffe_2eproto(); + return *internal_default_instance(); } -SPPParameter* SPPParameter::default_instance_ = NULL; +::google::protobuf::internal::ExplicitlyConstructed SPPParameter_default_instance_; -SPPParameter* SPPParameter::New() const { - return new SPPParameter; +SPPParameter* SPPParameter::New(::google::protobuf::Arena* arena) const { + SPPParameter* n = new SPPParameter; + if (arena != NULL) { + arena->Own(n); + } + return n; } void SPPParameter::Clear() { - if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) { - pyramid_height_ = 0u; - pool_ = 0; - engine_ = 0; +// @@protoc_insertion_point(message_clear_start:caffe.SPPParameter) +#if defined(__clang__) +#define ZR_HELPER_(f) \ + _Pragma("clang diagnostic push") \ + _Pragma("clang diagnostic ignored \"-Winvalid-offsetof\"") \ + __builtin_offsetof(SPPParameter, f) \ + _Pragma("clang diagnostic pop") +#else +#define ZR_HELPER_(f) reinterpret_cast(\ + &reinterpret_cast(16)->f) +#endif + +#define ZR_(first, last) do {\ + ::memset(&(first), 0,\ + ZR_HELPER_(last) - ZR_HELPER_(first) + sizeof(last));\ +} while (0) + + ZR_(pyramid_height_, engine_); + +#undef ZR_HELPER_ +#undef ZR_ + + _has_bits_.Clear(); + if (_internal_metadata_.have_unknown_fields()) { + mutable_unknown_fields()->Clear(); } - ::memset(_has_bits_, 0, sizeof(_has_bits_)); - mutable_unknown_fields()->Clear(); } bool SPPParameter::MergePartialFromCodedStream( ::google::protobuf::io::CodedInputStream* input) { -#define DO_(EXPRESSION) if (!(EXPRESSION)) return false +#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure ::google::protobuf::uint32 tag; - while ((tag = input->ReadTag()) != 0) { + // @@protoc_insertion_point(parse_start:caffe.SPPParameter) + for (;;) { + ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127); + tag = p.first; + if (!p.second) goto handle_unusual; switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { // optional uint32 pyramid_height = 1; case 1: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) { + if (tag == 8) { + set_has_pyramid_height(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>( input, &pyramid_height_))); - set_has_pyramid_height(); } else { - goto handle_uninterpreted; + goto handle_unusual; } if (input->ExpectTag(16)) goto parse_pool; break; @@ -24635,8 +37072,7 @@ bool SPPParameter::MergePartialFromCodedStream( // optional .caffe.SPPParameter.PoolMethod pool = 2 [default = MAX]; case 2: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) { + if (tag == 16) { parse_pool: int value; DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< @@ -24648,7 +37084,7 @@ bool SPPParameter::MergePartialFromCodedStream( mutable_unknown_fields()->AddVarint(2, value); } } else { - goto handle_uninterpreted; + goto handle_unusual; } if (input->ExpectTag(48)) goto parse_engine; break; @@ -24656,8 +37092,7 @@ bool SPPParameter::MergePartialFromCodedStream( // optional .caffe.SPPParameter.Engine engine = 6 [default = DEFAULT]; case 6: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) { + if (tag == 48) { parse_engine: int value; DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< @@ -24669,17 +37104,18 @@ bool SPPParameter::MergePartialFromCodedStream( mutable_unknown_fields()->AddVarint(6, value); } } else { - goto handle_uninterpreted; + goto handle_unusual; } - if (input->ExpectAtEnd()) return true; + if (input->ExpectAtEnd()) goto success; break; } default: { - handle_uninterpreted: - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == + handle_unusual: + if (tag == 0 || + ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) { - return true; + goto success; } DO_(::google::protobuf::internal::WireFormat::SkipField( input, tag, mutable_unknown_fields())); @@ -24687,12 +37123,18 @@ bool SPPParameter::MergePartialFromCodedStream( } } } +success: + // @@protoc_insertion_point(parse_success:caffe.SPPParameter) return true; +failure: + // @@protoc_insertion_point(parse_failure:caffe.SPPParameter) + return false; #undef DO_ } void SPPParameter::SerializeWithCachedSizes( ::google::protobuf::io::CodedOutputStream* output) const { + // @@protoc_insertion_point(serialize_start:caffe.SPPParameter) // optional uint32 pyramid_height = 1; if (has_pyramid_height()) { ::google::protobuf::internal::WireFormatLite::WriteUInt32(1, this->pyramid_height(), output); @@ -24710,14 +37152,17 @@ void SPPParameter::SerializeWithCachedSizes( 6, this->engine(), output); } - if (!unknown_fields().empty()) { + if (_internal_metadata_.have_unknown_fields()) { ::google::protobuf::internal::WireFormat::SerializeUnknownFields( unknown_fields(), output); } + // @@protoc_insertion_point(serialize_end:caffe.SPPParameter) } -::google::protobuf::uint8* SPPParameter::SerializeWithCachedSizesToArray( - ::google::protobuf::uint8* target) const { +::google::protobuf::uint8* SPPParameter::InternalSerializeWithCachedSizesToArray( + bool deterministic, ::google::protobuf::uint8* target) const { + (void)deterministic; // Unused + // @@protoc_insertion_point(serialize_to_array_start:caffe.SPPParameter) // optional uint32 pyramid_height = 1; if (has_pyramid_height()) { target = ::google::protobuf::internal::WireFormatLite::WriteUInt32ToArray(1, this->pyramid_height(), target); @@ -24735,17 +37180,19 @@ void SPPParameter::SerializeWithCachedSizes( 6, this->engine(), target); } - if (!unknown_fields().empty()) { + if (_internal_metadata_.have_unknown_fields()) { target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray( unknown_fields(), target); } + // @@protoc_insertion_point(serialize_to_array_end:caffe.SPPParameter) return target; } -int SPPParameter::ByteSize() const { - int total_size = 0; +size_t SPPParameter::ByteSizeLong() const { +// @@protoc_insertion_point(message_byte_size_start:caffe.SPPParameter) + size_t total_size = 0; - if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) { + if (_has_bits_[0 / 32] & 7u) { // optional uint32 pyramid_height = 1; if (has_pyramid_height()) { total_size += 1 + @@ -24766,31 +37213,44 @@ int SPPParameter::ByteSize() const { } } - if (!unknown_fields().empty()) { + if (_internal_metadata_.have_unknown_fields()) { total_size += ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( unknown_fields()); } + int cached_size = ::google::protobuf::internal::ToCachedSize(total_size); GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); - _cached_size_ = total_size; + _cached_size_ = cached_size; GOOGLE_SAFE_CONCURRENT_WRITES_END(); return total_size; } void SPPParameter::MergeFrom(const ::google::protobuf::Message& from) { - GOOGLE_CHECK_NE(&from, this); +// @@protoc_insertion_point(generalized_merge_from_start:caffe.SPPParameter) + if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__); const SPPParameter* source = - ::google::protobuf::internal::dynamic_cast_if_available( - &from); + ::google::protobuf::internal::DynamicCastToGenerated( + &from); if (source == NULL) { + // @@protoc_insertion_point(generalized_merge_from_cast_fail:caffe.SPPParameter) ::google::protobuf::internal::ReflectionOps::Merge(from, this); } else { - MergeFrom(*source); + // @@protoc_insertion_point(generalized_merge_from_cast_success:caffe.SPPParameter) + UnsafeMergeFrom(*source); } } void SPPParameter::MergeFrom(const SPPParameter& from) { - GOOGLE_CHECK_NE(&from, this); +// @@protoc_insertion_point(class_specific_merge_from_start:caffe.SPPParameter) + if (GOOGLE_PREDICT_TRUE(&from != this)) { + UnsafeMergeFrom(from); + } else { + MergeFromFail(__LINE__); + } +} + +void SPPParameter::UnsafeMergeFrom(const SPPParameter& from) { + GOOGLE_DCHECK(&from != this); if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) { if (from.has_pyramid_height()) { set_pyramid_height(from.pyramid_height()); @@ -24802,19 +37262,24 @@ void SPPParameter::MergeFrom(const SPPParameter& from) { set_engine(from.engine()); } } - mutable_unknown_fields()->MergeFrom(from.unknown_fields()); + if (from._internal_metadata_.have_unknown_fields()) { + ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata( + from.unknown_fields(), &_internal_metadata_); + } } void SPPParameter::CopyFrom(const ::google::protobuf::Message& from) { +// @@protoc_insertion_point(generalized_copy_from_start:caffe.SPPParameter) if (&from == this) return; Clear(); MergeFrom(from); } void SPPParameter::CopyFrom(const SPPParameter& from) { +// @@protoc_insertion_point(class_specific_copy_from_start:caffe.SPPParameter) if (&from == this) return; Clear(); - MergeFrom(from); + UnsafeMergeFrom(from); } bool SPPParameter::IsInitialized() const { @@ -24823,14 +37288,16 @@ bool SPPParameter::IsInitialized() const { } void SPPParameter::Swap(SPPParameter* other) { - if (other != this) { - std::swap(pyramid_height_, other->pyramid_height_); - std::swap(pool_, other->pool_); - std::swap(engine_, other->engine_); - std::swap(_has_bits_[0], other->_has_bits_[0]); - _unknown_fields_.Swap(&other->_unknown_fields_); - std::swap(_cached_size_, other->_cached_size_); - } + if (other == this) return; + InternalSwap(other); +} +void SPPParameter::InternalSwap(SPPParameter* other) { + std::swap(pyramid_height_, other->pyramid_height_); + std::swap(pool_, other->pool_); + std::swap(engine_, other->engine_); + std::swap(_has_bits_[0], other->_has_bits_[0]); + _internal_metadata_.Swap(&other->_internal_metadata_); + std::swap(_cached_size_, other->_cached_size_); } ::google::protobuf::Metadata SPPParameter::GetMetadata() const { @@ -24841,6 +37308,87 @@ void SPPParameter::Swap(SPPParameter* other) { return metadata; } +#if PROTOBUF_INLINE_NOT_IN_HEADERS +// SPPParameter + +// optional uint32 pyramid_height = 1; +bool SPPParameter::has_pyramid_height() const { + return (_has_bits_[0] & 0x00000001u) != 0; +} +void SPPParameter::set_has_pyramid_height() { + _has_bits_[0] |= 0x00000001u; +} +void SPPParameter::clear_has_pyramid_height() { + _has_bits_[0] &= ~0x00000001u; +} +void SPPParameter::clear_pyramid_height() { + pyramid_height_ = 0u; + clear_has_pyramid_height(); +} +::google::protobuf::uint32 SPPParameter::pyramid_height() const { + // @@protoc_insertion_point(field_get:caffe.SPPParameter.pyramid_height) + return pyramid_height_; +} +void SPPParameter::set_pyramid_height(::google::protobuf::uint32 value) { + set_has_pyramid_height(); + pyramid_height_ = value; + // @@protoc_insertion_point(field_set:caffe.SPPParameter.pyramid_height) +} + +// optional .caffe.SPPParameter.PoolMethod pool = 2 [default = MAX]; +bool SPPParameter::has_pool() const { + return (_has_bits_[0] & 0x00000002u) != 0; +} +void SPPParameter::set_has_pool() { + _has_bits_[0] |= 0x00000002u; +} +void SPPParameter::clear_has_pool() { + _has_bits_[0] &= ~0x00000002u; +} +void SPPParameter::clear_pool() { + pool_ = 0; + clear_has_pool(); +} +::caffe::SPPParameter_PoolMethod SPPParameter::pool() const { + // @@protoc_insertion_point(field_get:caffe.SPPParameter.pool) + return static_cast< ::caffe::SPPParameter_PoolMethod >(pool_); +} +void SPPParameter::set_pool(::caffe::SPPParameter_PoolMethod value) { + assert(::caffe::SPPParameter_PoolMethod_IsValid(value)); + set_has_pool(); + pool_ = value; + // @@protoc_insertion_point(field_set:caffe.SPPParameter.pool) +} + +// optional .caffe.SPPParameter.Engine engine = 6 [default = DEFAULT]; +bool SPPParameter::has_engine() const { + return (_has_bits_[0] & 0x00000004u) != 0; +} +void SPPParameter::set_has_engine() { + _has_bits_[0] |= 0x00000004u; +} +void SPPParameter::clear_has_engine() { + _has_bits_[0] &= ~0x00000004u; +} +void SPPParameter::clear_engine() { + engine_ = 0; + clear_has_engine(); +} +::caffe::SPPParameter_Engine SPPParameter::engine() const { + // @@protoc_insertion_point(field_get:caffe.SPPParameter.engine) + return static_cast< ::caffe::SPPParameter_Engine >(engine_); +} +void SPPParameter::set_engine(::caffe::SPPParameter_Engine value) { + assert(::caffe::SPPParameter_Engine_IsValid(value)); + set_has_engine(); + engine_ = value; + // @@protoc_insertion_point(field_set:caffe.SPPParameter.engine) +} + +inline const SPPParameter* SPPParameter::internal_default_instance() { + return &SPPParameter_default_instance_.get(); +} +#endif // PROTOBUF_INLINE_NOT_IN_HEADERS // =================================================================== @@ -24849,7 +37397,7 @@ const ::google::protobuf::EnumDescriptor* V1LayerParameter_LayerType_descriptor( return V1LayerParameter_LayerType_descriptor_; } bool V1LayerParameter_LayerType_IsValid(int value) { - switch(value) { + switch (value) { case 0: case 1: case 2: @@ -24896,7 +37444,7 @@ bool V1LayerParameter_LayerType_IsValid(int value) { } } -#ifndef _MSC_VER +#if !defined(_MSC_VER) || _MSC_VER >= 1900 const V1LayerParameter_LayerType V1LayerParameter::NONE; const V1LayerParameter_LayerType V1LayerParameter::ABSVAL; const V1LayerParameter_LayerType V1LayerParameter::ACCURACY; @@ -24940,13 +37488,13 @@ const V1LayerParameter_LayerType V1LayerParameter::THRESHOLD; const V1LayerParameter_LayerType V1LayerParameter::LayerType_MIN; const V1LayerParameter_LayerType V1LayerParameter::LayerType_MAX; const int V1LayerParameter::LayerType_ARRAYSIZE; -#endif // _MSC_VER +#endif // !defined(_MSC_VER) || _MSC_VER >= 1900 const ::google::protobuf::EnumDescriptor* V1LayerParameter_DimCheckMode_descriptor() { protobuf_AssignDescriptorsOnce(); return V1LayerParameter_DimCheckMode_descriptor_; } bool V1LayerParameter_DimCheckMode_IsValid(int value) { - switch(value) { + switch (value) { case 0: case 1: return true; @@ -24955,14 +37503,14 @@ bool V1LayerParameter_DimCheckMode_IsValid(int value) { } } -#ifndef _MSC_VER +#if !defined(_MSC_VER) || _MSC_VER >= 1900 const V1LayerParameter_DimCheckMode V1LayerParameter::STRICT; const V1LayerParameter_DimCheckMode V1LayerParameter::PERMISSIVE; const V1LayerParameter_DimCheckMode V1LayerParameter::DimCheckMode_MIN; const V1LayerParameter_DimCheckMode V1LayerParameter::DimCheckMode_MAX; const int V1LayerParameter::DimCheckMode_ARRAYSIZE; -#endif // _MSC_VER -#ifndef _MSC_VER +#endif // !defined(_MSC_VER) || _MSC_VER >= 1900 +#if !defined(_MSC_VER) || _MSC_VER >= 1900 const int V1LayerParameter::kBottomFieldNumber; const int V1LayerParameter::kTopFieldNumber; const int V1LayerParameter::kNameFieldNumber; @@ -25006,57 +37554,90 @@ const int V1LayerParameter::kWindowDataParamFieldNumber; const int V1LayerParameter::kTransformParamFieldNumber; const int V1LayerParameter::kLossParamFieldNumber; const int V1LayerParameter::kLayerFieldNumber; -#endif // !_MSC_VER +#endif // !defined(_MSC_VER) || _MSC_VER >= 1900 V1LayerParameter::V1LayerParameter() - : ::google::protobuf::Message() { + : ::google::protobuf::Message(), _internal_metadata_(NULL) { + if (this != internal_default_instance()) protobuf_InitDefaults_caffe_2eproto(); SharedCtor(); + // @@protoc_insertion_point(constructor:caffe.V1LayerParameter) } void V1LayerParameter::InitAsDefaultInstance() { - accuracy_param_ = const_cast< ::caffe::AccuracyParameter*>(&::caffe::AccuracyParameter::default_instance()); - argmax_param_ = const_cast< ::caffe::ArgMaxParameter*>(&::caffe::ArgMaxParameter::default_instance()); - concat_param_ = const_cast< ::caffe::ConcatParameter*>(&::caffe::ConcatParameter::default_instance()); - contrastive_loss_param_ = const_cast< ::caffe::ContrastiveLossParameter*>(&::caffe::ContrastiveLossParameter::default_instance()); - convolution_param_ = const_cast< ::caffe::ConvolutionParameter*>(&::caffe::ConvolutionParameter::default_instance()); - data_param_ = const_cast< ::caffe::DataParameter*>(&::caffe::DataParameter::default_instance()); - dropout_param_ = const_cast< ::caffe::DropoutParameter*>(&::caffe::DropoutParameter::default_instance()); - dummy_data_param_ = const_cast< ::caffe::DummyDataParameter*>(&::caffe::DummyDataParameter::default_instance()); - eltwise_param_ = const_cast< ::caffe::EltwiseParameter*>(&::caffe::EltwiseParameter::default_instance()); - exp_param_ = const_cast< ::caffe::ExpParameter*>(&::caffe::ExpParameter::default_instance()); - hdf5_data_param_ = const_cast< ::caffe::HDF5DataParameter*>(&::caffe::HDF5DataParameter::default_instance()); - hdf5_output_param_ = const_cast< ::caffe::HDF5OutputParameter*>(&::caffe::HDF5OutputParameter::default_instance()); - hinge_loss_param_ = const_cast< ::caffe::HingeLossParameter*>(&::caffe::HingeLossParameter::default_instance()); - image_data_param_ = const_cast< ::caffe::ImageDataParameter*>(&::caffe::ImageDataParameter::default_instance()); - infogain_loss_param_ = const_cast< ::caffe::InfogainLossParameter*>(&::caffe::InfogainLossParameter::default_instance()); - inner_product_param_ = const_cast< ::caffe::InnerProductParameter*>(&::caffe::InnerProductParameter::default_instance()); - lrn_param_ = const_cast< ::caffe::LRNParameter*>(&::caffe::LRNParameter::default_instance()); - memory_data_param_ = const_cast< ::caffe::MemoryDataParameter*>(&::caffe::MemoryDataParameter::default_instance()); - mvn_param_ = const_cast< ::caffe::MVNParameter*>(&::caffe::MVNParameter::default_instance()); - pooling_param_ = const_cast< ::caffe::PoolingParameter*>(&::caffe::PoolingParameter::default_instance()); - power_param_ = const_cast< ::caffe::PowerParameter*>(&::caffe::PowerParameter::default_instance()); - relu_param_ = const_cast< ::caffe::ReLUParameter*>(&::caffe::ReLUParameter::default_instance()); - sigmoid_param_ = const_cast< ::caffe::SigmoidParameter*>(&::caffe::SigmoidParameter::default_instance()); - softmax_param_ = const_cast< ::caffe::SoftmaxParameter*>(&::caffe::SoftmaxParameter::default_instance()); - slice_param_ = const_cast< ::caffe::SliceParameter*>(&::caffe::SliceParameter::default_instance()); - tanh_param_ = const_cast< ::caffe::TanHParameter*>(&::caffe::TanHParameter::default_instance()); - threshold_param_ = const_cast< ::caffe::ThresholdParameter*>(&::caffe::ThresholdParameter::default_instance()); - window_data_param_ = const_cast< ::caffe::WindowDataParameter*>(&::caffe::WindowDataParameter::default_instance()); - transform_param_ = const_cast< ::caffe::TransformationParameter*>(&::caffe::TransformationParameter::default_instance()); - loss_param_ = const_cast< ::caffe::LossParameter*>(&::caffe::LossParameter::default_instance()); - layer_ = const_cast< ::caffe::V0LayerParameter*>(&::caffe::V0LayerParameter::default_instance()); + accuracy_param_ = const_cast< ::caffe::AccuracyParameter*>( + ::caffe::AccuracyParameter::internal_default_instance()); + argmax_param_ = const_cast< ::caffe::ArgMaxParameter*>( + ::caffe::ArgMaxParameter::internal_default_instance()); + concat_param_ = const_cast< ::caffe::ConcatParameter*>( + ::caffe::ConcatParameter::internal_default_instance()); + contrastive_loss_param_ = const_cast< ::caffe::ContrastiveLossParameter*>( + ::caffe::ContrastiveLossParameter::internal_default_instance()); + convolution_param_ = const_cast< ::caffe::ConvolutionParameter*>( + ::caffe::ConvolutionParameter::internal_default_instance()); + data_param_ = const_cast< ::caffe::DataParameter*>( + ::caffe::DataParameter::internal_default_instance()); + dropout_param_ = const_cast< ::caffe::DropoutParameter*>( + ::caffe::DropoutParameter::internal_default_instance()); + dummy_data_param_ = const_cast< ::caffe::DummyDataParameter*>( + ::caffe::DummyDataParameter::internal_default_instance()); + eltwise_param_ = const_cast< ::caffe::EltwiseParameter*>( + ::caffe::EltwiseParameter::internal_default_instance()); + exp_param_ = const_cast< ::caffe::ExpParameter*>( + ::caffe::ExpParameter::internal_default_instance()); + hdf5_data_param_ = const_cast< ::caffe::HDF5DataParameter*>( + ::caffe::HDF5DataParameter::internal_default_instance()); + hdf5_output_param_ = const_cast< ::caffe::HDF5OutputParameter*>( + ::caffe::HDF5OutputParameter::internal_default_instance()); + hinge_loss_param_ = const_cast< ::caffe::HingeLossParameter*>( + ::caffe::HingeLossParameter::internal_default_instance()); + image_data_param_ = const_cast< ::caffe::ImageDataParameter*>( + ::caffe::ImageDataParameter::internal_default_instance()); + infogain_loss_param_ = const_cast< ::caffe::InfogainLossParameter*>( + ::caffe::InfogainLossParameter::internal_default_instance()); + inner_product_param_ = const_cast< ::caffe::InnerProductParameter*>( + ::caffe::InnerProductParameter::internal_default_instance()); + lrn_param_ = const_cast< ::caffe::LRNParameter*>( + ::caffe::LRNParameter::internal_default_instance()); + memory_data_param_ = const_cast< ::caffe::MemoryDataParameter*>( + ::caffe::MemoryDataParameter::internal_default_instance()); + mvn_param_ = const_cast< ::caffe::MVNParameter*>( + ::caffe::MVNParameter::internal_default_instance()); + pooling_param_ = const_cast< ::caffe::PoolingParameter*>( + ::caffe::PoolingParameter::internal_default_instance()); + power_param_ = const_cast< ::caffe::PowerParameter*>( + ::caffe::PowerParameter::internal_default_instance()); + relu_param_ = const_cast< ::caffe::ReLUParameter*>( + ::caffe::ReLUParameter::internal_default_instance()); + sigmoid_param_ = const_cast< ::caffe::SigmoidParameter*>( + ::caffe::SigmoidParameter::internal_default_instance()); + softmax_param_ = const_cast< ::caffe::SoftmaxParameter*>( + ::caffe::SoftmaxParameter::internal_default_instance()); + slice_param_ = const_cast< ::caffe::SliceParameter*>( + ::caffe::SliceParameter::internal_default_instance()); + tanh_param_ = const_cast< ::caffe::TanHParameter*>( + ::caffe::TanHParameter::internal_default_instance()); + threshold_param_ = const_cast< ::caffe::ThresholdParameter*>( + ::caffe::ThresholdParameter::internal_default_instance()); + window_data_param_ = const_cast< ::caffe::WindowDataParameter*>( + ::caffe::WindowDataParameter::internal_default_instance()); + transform_param_ = const_cast< ::caffe::TransformationParameter*>( + ::caffe::TransformationParameter::internal_default_instance()); + loss_param_ = const_cast< ::caffe::LossParameter*>( + ::caffe::LossParameter::internal_default_instance()); + layer_ = const_cast< ::caffe::V0LayerParameter*>( + ::caffe::V0LayerParameter::internal_default_instance()); } V1LayerParameter::V1LayerParameter(const V1LayerParameter& from) - : ::google::protobuf::Message() { + : ::google::protobuf::Message(), + _internal_metadata_(NULL) { SharedCtor(); - MergeFrom(from); + UnsafeMergeFrom(from); + // @@protoc_insertion_point(copy_constructor:caffe.V1LayerParameter) } void V1LayerParameter::SharedCtor() { - _cached_size_ = 0; - name_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); - type_ = 0; + name_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); accuracy_param_ = NULL; argmax_param_ = NULL; concat_param_ = NULL; @@ -25088,18 +37669,18 @@ void V1LayerParameter::SharedCtor() { transform_param_ = NULL; loss_param_ = NULL; layer_ = NULL; - ::memset(_has_bits_, 0, sizeof(_has_bits_)); + type_ = 0; + _cached_size_ = 0; } V1LayerParameter::~V1LayerParameter() { + // @@protoc_insertion_point(destructor:caffe.V1LayerParameter) SharedDtor(); } void V1LayerParameter::SharedDtor() { - if (name_ != &::google::protobuf::internal::kEmptyString) { - delete name_; - } - if (this != default_instance_) { + name_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + if (this != &V1LayerParameter_default_instance_.get()) { delete accuracy_param_; delete argmax_param_; delete concat_param_; @@ -25145,26 +37726,29 @@ const ::google::protobuf::Descriptor* V1LayerParameter::descriptor() { } const V1LayerParameter& V1LayerParameter::default_instance() { - if (default_instance_ == NULL) protobuf_AddDesc_caffe_2eproto(); - return *default_instance_; + protobuf_InitDefaults_caffe_2eproto(); + return *internal_default_instance(); } -V1LayerParameter* V1LayerParameter::default_instance_ = NULL; +::google::protobuf::internal::ExplicitlyConstructed V1LayerParameter_default_instance_; -V1LayerParameter* V1LayerParameter::New() const { - return new V1LayerParameter; +V1LayerParameter* V1LayerParameter::New(::google::protobuf::Arena* arena) const { + V1LayerParameter* n = new V1LayerParameter; + if (arena != NULL) { + arena->Own(n); + } + return n; } void V1LayerParameter::Clear() { - if (_has_bits_[2 / 32] & (0xffu << (2 % 32))) { +// @@protoc_insertion_point(message_clear_start:caffe.V1LayerParameter) + if (_has_bits_[0 / 32] & 36u) { if (has_name()) { - if (name_ != &::google::protobuf::internal::kEmptyString) { - name_->clear(); - } + name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } type_ = 0; } - if (_has_bits_[12 / 32] & (0xffu << (12 % 32))) { + if (_has_bits_[8 / 32] & 61440u) { if (has_accuracy_param()) { if (accuracy_param_ != NULL) accuracy_param_->::caffe::AccuracyParameter::Clear(); } @@ -25178,7 +37762,7 @@ void V1LayerParameter::Clear() { if (contrastive_loss_param_ != NULL) contrastive_loss_param_->::caffe::ContrastiveLossParameter::Clear(); } } - if (_has_bits_[16 / 32] & (0xffu << (16 % 32))) { + if (_has_bits_[16 / 32] & 16711680u) { if (has_convolution_param()) { if (convolution_param_ != NULL) convolution_param_->::caffe::ConvolutionParameter::Clear(); } @@ -25204,7 +37788,7 @@ void V1LayerParameter::Clear() { if (hdf5_output_param_ != NULL) hdf5_output_param_->::caffe::HDF5OutputParameter::Clear(); } } - if (_has_bits_[24 / 32] & (0xffu << (24 % 32))) { + if (_has_bits_[24 / 32] & 4278190080u) { if (has_hinge_loss_param()) { if (hinge_loss_param_ != NULL) hinge_loss_param_->::caffe::HingeLossParameter::Clear(); } @@ -25230,7 +37814,7 @@ void V1LayerParameter::Clear() { if (pooling_param_ != NULL) pooling_param_->::caffe::PoolingParameter::Clear(); } } - if (_has_bits_[32 / 32] & (0xffu << (32 % 32))) { + if (_has_bits_[32 / 32] & 255u) { if (has_power_param()) { if (power_param_ != NULL) power_param_->::caffe::PowerParameter::Clear(); } @@ -25256,7 +37840,7 @@ void V1LayerParameter::Clear() { if (window_data_param_ != NULL) window_data_param_->::caffe::WindowDataParameter::Clear(); } } - if (_has_bits_[40 / 32] & (0xffu << (40 % 32))) { + if (_has_bits_[40 / 32] & 1792u) { if (has_transform_param()) { if (transform_param_ != NULL) transform_param_->::caffe::TransformationParameter::Clear(); } @@ -25277,24 +37861,29 @@ void V1LayerParameter::Clear() { blobs_lr_.Clear(); weight_decay_.Clear(); loss_weight_.Clear(); - ::memset(_has_bits_, 0, sizeof(_has_bits_)); - mutable_unknown_fields()->Clear(); + _has_bits_.Clear(); + if (_internal_metadata_.have_unknown_fields()) { + mutable_unknown_fields()->Clear(); + } } bool V1LayerParameter::MergePartialFromCodedStream( ::google::protobuf::io::CodedInputStream* input) { -#define DO_(EXPRESSION) if (!(EXPRESSION)) return false +#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure ::google::protobuf::uint32 tag; - while ((tag = input->ReadTag()) != 0) { + // @@protoc_insertion_point(parse_start:caffe.V1LayerParameter) + for (;;) { + ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(16383); + tag = p.first; + if (!p.second) goto handle_unusual; switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { // optional .caffe.V0LayerParameter layer = 1; case 1: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) { + if (tag == 10) { DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual( input, mutable_layer())); } else { - goto handle_uninterpreted; + goto handle_unusual; } if (input->ExpectTag(18)) goto parse_bottom; break; @@ -25302,17 +37891,17 @@ bool V1LayerParameter::MergePartialFromCodedStream( // repeated string bottom = 2; case 2: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) { + if (tag == 18) { parse_bottom: DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->add_bottom())); - ::google::protobuf::internal::WireFormat::VerifyUTF8String( + ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( this->bottom(this->bottom_size() - 1).data(), this->bottom(this->bottom_size() - 1).length(), - ::google::protobuf::internal::WireFormat::PARSE); + ::google::protobuf::internal::WireFormat::PARSE, + "caffe.V1LayerParameter.bottom"); } else { - goto handle_uninterpreted; + goto handle_unusual; } if (input->ExpectTag(18)) goto parse_bottom; if (input->ExpectTag(26)) goto parse_top; @@ -25321,17 +37910,17 @@ bool V1LayerParameter::MergePartialFromCodedStream( // repeated string top = 3; case 3: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) { + if (tag == 26) { parse_top: DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->add_top())); - ::google::protobuf::internal::WireFormat::VerifyUTF8String( + ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( this->top(this->top_size() - 1).data(), this->top(this->top_size() - 1).length(), - ::google::protobuf::internal::WireFormat::PARSE); + ::google::protobuf::internal::WireFormat::PARSE, + "caffe.V1LayerParameter.top"); } else { - goto handle_uninterpreted; + goto handle_unusual; } if (input->ExpectTag(26)) goto parse_top; if (input->ExpectTag(34)) goto parse_name; @@ -25340,16 +37929,16 @@ bool V1LayerParameter::MergePartialFromCodedStream( // optional string name = 4; case 4: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) { + if (tag == 34) { parse_name: DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->mutable_name())); - ::google::protobuf::internal::WireFormat::VerifyUTF8String( + ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( this->name().data(), this->name().length(), - ::google::protobuf::internal::WireFormat::PARSE); + ::google::protobuf::internal::WireFormat::PARSE, + "caffe.V1LayerParameter.name"); } else { - goto handle_uninterpreted; + goto handle_unusual; } if (input->ExpectTag(40)) goto parse_type; break; @@ -25357,8 +37946,7 @@ bool V1LayerParameter::MergePartialFromCodedStream( // optional .caffe.V1LayerParameter.LayerType type = 5; case 5: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) { + if (tag == 40) { parse_type: int value; DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< @@ -25370,7 +37958,7 @@ bool V1LayerParameter::MergePartialFromCodedStream( mutable_unknown_fields()->AddVarint(5, value); } } else { - goto handle_uninterpreted; + goto handle_unusual; } if (input->ExpectTag(50)) goto parse_blobs; break; @@ -25378,35 +37966,34 @@ bool V1LayerParameter::MergePartialFromCodedStream( // repeated .caffe.BlobProto blobs = 6; case 6: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) { + if (tag == 50) { parse_blobs: - DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual( + DO_(input->IncrementRecursionDepth()); + parse_loop_blobs: + DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtualNoRecursionDepth( input, add_blobs())); } else { - goto handle_uninterpreted; + goto handle_unusual; } - if (input->ExpectTag(50)) goto parse_blobs; + if (input->ExpectTag(50)) goto parse_loop_blobs; + input->UnsafeDecrementRecursionDepth(); if (input->ExpectTag(61)) goto parse_blobs_lr; break; } // repeated float blobs_lr = 7; case 7: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_FIXED32) { + if (tag == 61) { parse_blobs_lr: DO_((::google::protobuf::internal::WireFormatLite::ReadRepeatedPrimitive< float, ::google::protobuf::internal::WireFormatLite::TYPE_FLOAT>( 1, 61, input, this->mutable_blobs_lr()))); - } else if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) - == ::google::protobuf::internal::WireFormatLite:: - WIRETYPE_LENGTH_DELIMITED) { + } else if (tag == 58) { DO_((::google::protobuf::internal::WireFormatLite::ReadPackedPrimitiveNoInline< float, ::google::protobuf::internal::WireFormatLite::TYPE_FLOAT>( input, this->mutable_blobs_lr()))); } else { - goto handle_uninterpreted; + goto handle_unusual; } if (input->ExpectTag(61)) goto parse_blobs_lr; if (input->ExpectTag(69)) goto parse_weight_decay; @@ -25415,20 +38002,17 @@ bool V1LayerParameter::MergePartialFromCodedStream( // repeated float weight_decay = 8; case 8: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_FIXED32) { + if (tag == 69) { parse_weight_decay: DO_((::google::protobuf::internal::WireFormatLite::ReadRepeatedPrimitive< float, ::google::protobuf::internal::WireFormatLite::TYPE_FLOAT>( 1, 69, input, this->mutable_weight_decay()))); - } else if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) - == ::google::protobuf::internal::WireFormatLite:: - WIRETYPE_LENGTH_DELIMITED) { + } else if (tag == 66) { DO_((::google::protobuf::internal::WireFormatLite::ReadPackedPrimitiveNoInline< float, ::google::protobuf::internal::WireFormatLite::TYPE_FLOAT>( input, this->mutable_weight_decay()))); } else { - goto handle_uninterpreted; + goto handle_unusual; } if (input->ExpectTag(69)) goto parse_weight_decay; if (input->ExpectTag(74)) goto parse_concat_param; @@ -25437,13 +38021,12 @@ bool V1LayerParameter::MergePartialFromCodedStream( // optional .caffe.ConcatParameter concat_param = 9; case 9: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) { + if (tag == 74) { parse_concat_param: DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual( input, mutable_concat_param())); } else { - goto handle_uninterpreted; + goto handle_unusual; } if (input->ExpectTag(82)) goto parse_convolution_param; break; @@ -25451,13 +38034,12 @@ bool V1LayerParameter::MergePartialFromCodedStream( // optional .caffe.ConvolutionParameter convolution_param = 10; case 10: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) { + if (tag == 82) { parse_convolution_param: DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual( input, mutable_convolution_param())); } else { - goto handle_uninterpreted; + goto handle_unusual; } if (input->ExpectTag(90)) goto parse_data_param; break; @@ -25465,13 +38047,12 @@ bool V1LayerParameter::MergePartialFromCodedStream( // optional .caffe.DataParameter data_param = 11; case 11: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) { + if (tag == 90) { parse_data_param: DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual( input, mutable_data_param())); } else { - goto handle_uninterpreted; + goto handle_unusual; } if (input->ExpectTag(98)) goto parse_dropout_param; break; @@ -25479,13 +38060,12 @@ bool V1LayerParameter::MergePartialFromCodedStream( // optional .caffe.DropoutParameter dropout_param = 12; case 12: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) { + if (tag == 98) { parse_dropout_param: DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual( input, mutable_dropout_param())); } else { - goto handle_uninterpreted; + goto handle_unusual; } if (input->ExpectTag(106)) goto parse_hdf5_data_param; break; @@ -25493,13 +38073,12 @@ bool V1LayerParameter::MergePartialFromCodedStream( // optional .caffe.HDF5DataParameter hdf5_data_param = 13; case 13: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) { + if (tag == 106) { parse_hdf5_data_param: DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual( input, mutable_hdf5_data_param())); } else { - goto handle_uninterpreted; + goto handle_unusual; } if (input->ExpectTag(114)) goto parse_hdf5_output_param; break; @@ -25507,13 +38086,12 @@ bool V1LayerParameter::MergePartialFromCodedStream( // optional .caffe.HDF5OutputParameter hdf5_output_param = 14; case 14: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) { + if (tag == 114) { parse_hdf5_output_param: DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual( input, mutable_hdf5_output_param())); } else { - goto handle_uninterpreted; + goto handle_unusual; } if (input->ExpectTag(122)) goto parse_image_data_param; break; @@ -25521,13 +38099,12 @@ bool V1LayerParameter::MergePartialFromCodedStream( // optional .caffe.ImageDataParameter image_data_param = 15; case 15: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) { + if (tag == 122) { parse_image_data_param: DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual( input, mutable_image_data_param())); } else { - goto handle_uninterpreted; + goto handle_unusual; } if (input->ExpectTag(130)) goto parse_infogain_loss_param; break; @@ -25535,13 +38112,12 @@ bool V1LayerParameter::MergePartialFromCodedStream( // optional .caffe.InfogainLossParameter infogain_loss_param = 16; case 16: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) { + if (tag == 130) { parse_infogain_loss_param: DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual( input, mutable_infogain_loss_param())); } else { - goto handle_uninterpreted; + goto handle_unusual; } if (input->ExpectTag(138)) goto parse_inner_product_param; break; @@ -25549,13 +38125,12 @@ bool V1LayerParameter::MergePartialFromCodedStream( // optional .caffe.InnerProductParameter inner_product_param = 17; case 17: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) { + if (tag == 138) { parse_inner_product_param: DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual( input, mutable_inner_product_param())); } else { - goto handle_uninterpreted; + goto handle_unusual; } if (input->ExpectTag(146)) goto parse_lrn_param; break; @@ -25563,13 +38138,12 @@ bool V1LayerParameter::MergePartialFromCodedStream( // optional .caffe.LRNParameter lrn_param = 18; case 18: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) { + if (tag == 146) { parse_lrn_param: DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual( input, mutable_lrn_param())); } else { - goto handle_uninterpreted; + goto handle_unusual; } if (input->ExpectTag(154)) goto parse_pooling_param; break; @@ -25577,13 +38151,12 @@ bool V1LayerParameter::MergePartialFromCodedStream( // optional .caffe.PoolingParameter pooling_param = 19; case 19: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) { + if (tag == 154) { parse_pooling_param: DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual( input, mutable_pooling_param())); } else { - goto handle_uninterpreted; + goto handle_unusual; } if (input->ExpectTag(162)) goto parse_window_data_param; break; @@ -25591,13 +38164,12 @@ bool V1LayerParameter::MergePartialFromCodedStream( // optional .caffe.WindowDataParameter window_data_param = 20; case 20: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) { + if (tag == 162) { parse_window_data_param: DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual( input, mutable_window_data_param())); } else { - goto handle_uninterpreted; + goto handle_unusual; } if (input->ExpectTag(170)) goto parse_power_param; break; @@ -25605,13 +38177,12 @@ bool V1LayerParameter::MergePartialFromCodedStream( // optional .caffe.PowerParameter power_param = 21; case 21: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) { + if (tag == 170) { parse_power_param: DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual( input, mutable_power_param())); } else { - goto handle_uninterpreted; + goto handle_unusual; } if (input->ExpectTag(178)) goto parse_memory_data_param; break; @@ -25619,13 +38190,12 @@ bool V1LayerParameter::MergePartialFromCodedStream( // optional .caffe.MemoryDataParameter memory_data_param = 22; case 22: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) { + if (tag == 178) { parse_memory_data_param: DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual( input, mutable_memory_data_param())); } else { - goto handle_uninterpreted; + goto handle_unusual; } if (input->ExpectTag(186)) goto parse_argmax_param; break; @@ -25633,13 +38203,12 @@ bool V1LayerParameter::MergePartialFromCodedStream( // optional .caffe.ArgMaxParameter argmax_param = 23; case 23: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) { + if (tag == 186) { parse_argmax_param: DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual( input, mutable_argmax_param())); } else { - goto handle_uninterpreted; + goto handle_unusual; } if (input->ExpectTag(194)) goto parse_eltwise_param; break; @@ -25647,13 +38216,12 @@ bool V1LayerParameter::MergePartialFromCodedStream( // optional .caffe.EltwiseParameter eltwise_param = 24; case 24: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) { + if (tag == 194) { parse_eltwise_param: DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual( input, mutable_eltwise_param())); } else { - goto handle_uninterpreted; + goto handle_unusual; } if (input->ExpectTag(202)) goto parse_threshold_param; break; @@ -25661,13 +38229,12 @@ bool V1LayerParameter::MergePartialFromCodedStream( // optional .caffe.ThresholdParameter threshold_param = 25; case 25: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) { + if (tag == 202) { parse_threshold_param: DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual( input, mutable_threshold_param())); } else { - goto handle_uninterpreted; + goto handle_unusual; } if (input->ExpectTag(210)) goto parse_dummy_data_param; break; @@ -25675,13 +38242,12 @@ bool V1LayerParameter::MergePartialFromCodedStream( // optional .caffe.DummyDataParameter dummy_data_param = 26; case 26: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) { + if (tag == 210) { parse_dummy_data_param: DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual( input, mutable_dummy_data_param())); } else { - goto handle_uninterpreted; + goto handle_unusual; } if (input->ExpectTag(218)) goto parse_accuracy_param; break; @@ -25689,13 +38255,12 @@ bool V1LayerParameter::MergePartialFromCodedStream( // optional .caffe.AccuracyParameter accuracy_param = 27; case 27: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) { + if (tag == 218) { parse_accuracy_param: DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual( input, mutable_accuracy_param())); } else { - goto handle_uninterpreted; + goto handle_unusual; } if (input->ExpectTag(234)) goto parse_hinge_loss_param; break; @@ -25703,13 +38268,12 @@ bool V1LayerParameter::MergePartialFromCodedStream( // optional .caffe.HingeLossParameter hinge_loss_param = 29; case 29: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) { + if (tag == 234) { parse_hinge_loss_param: DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual( input, mutable_hinge_loss_param())); } else { - goto handle_uninterpreted; + goto handle_unusual; } if (input->ExpectTag(242)) goto parse_relu_param; break; @@ -25717,13 +38281,12 @@ bool V1LayerParameter::MergePartialFromCodedStream( // optional .caffe.ReLUParameter relu_param = 30; case 30: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) { + if (tag == 242) { parse_relu_param: DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual( input, mutable_relu_param())); } else { - goto handle_uninterpreted; + goto handle_unusual; } if (input->ExpectTag(250)) goto parse_slice_param; break; @@ -25731,13 +38294,12 @@ bool V1LayerParameter::MergePartialFromCodedStream( // optional .caffe.SliceParameter slice_param = 31; case 31: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) { + if (tag == 250) { parse_slice_param: DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual( input, mutable_slice_param())); } else { - goto handle_uninterpreted; + goto handle_unusual; } if (input->ExpectTag(258)) goto parse_include; break; @@ -25745,43 +38307,45 @@ bool V1LayerParameter::MergePartialFromCodedStream( // repeated .caffe.NetStateRule include = 32; case 32: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) { + if (tag == 258) { parse_include: - DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual( + DO_(input->IncrementRecursionDepth()); + parse_loop_include: + DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtualNoRecursionDepth( input, add_include())); } else { - goto handle_uninterpreted; + goto handle_unusual; } - if (input->ExpectTag(258)) goto parse_include; - if (input->ExpectTag(266)) goto parse_exclude; + if (input->ExpectTag(258)) goto parse_loop_include; + if (input->ExpectTag(266)) goto parse_loop_exclude; + input->UnsafeDecrementRecursionDepth(); break; } // repeated .caffe.NetStateRule exclude = 33; case 33: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) { - parse_exclude: - DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual( + if (tag == 266) { + DO_(input->IncrementRecursionDepth()); + parse_loop_exclude: + DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtualNoRecursionDepth( input, add_exclude())); } else { - goto handle_uninterpreted; + goto handle_unusual; } - if (input->ExpectTag(266)) goto parse_exclude; + if (input->ExpectTag(266)) goto parse_loop_exclude; + input->UnsafeDecrementRecursionDepth(); if (input->ExpectTag(274)) goto parse_mvn_param; break; } // optional .caffe.MVNParameter mvn_param = 34; case 34: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) { + if (tag == 274) { parse_mvn_param: DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual( input, mutable_mvn_param())); } else { - goto handle_uninterpreted; + goto handle_unusual; } if (input->ExpectTag(285)) goto parse_loss_weight; break; @@ -25789,1327 +38353,3236 @@ bool V1LayerParameter::MergePartialFromCodedStream( // repeated float loss_weight = 35; case 35: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_FIXED32) { + if (tag == 285) { parse_loss_weight: DO_((::google::protobuf::internal::WireFormatLite::ReadRepeatedPrimitive< float, ::google::protobuf::internal::WireFormatLite::TYPE_FLOAT>( 2, 285, input, this->mutable_loss_weight()))); - } else if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) - == ::google::protobuf::internal::WireFormatLite:: - WIRETYPE_LENGTH_DELIMITED) { + } else if (tag == 282) { DO_((::google::protobuf::internal::WireFormatLite::ReadPackedPrimitiveNoInline< float, ::google::protobuf::internal::WireFormatLite::TYPE_FLOAT>( input, this->mutable_loss_weight()))); } else { - goto handle_uninterpreted; + goto handle_unusual; + } + if (input->ExpectTag(285)) goto parse_loss_weight; + if (input->ExpectTag(290)) goto parse_transform_param; + break; + } + + // optional .caffe.TransformationParameter transform_param = 36; + case 36: { + if (tag == 290) { + parse_transform_param: + DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual( + input, mutable_transform_param())); + } else { + goto handle_unusual; + } + if (input->ExpectTag(298)) goto parse_tanh_param; + break; + } + + // optional .caffe.TanHParameter tanh_param = 37; + case 37: { + if (tag == 298) { + parse_tanh_param: + DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual( + input, mutable_tanh_param())); + } else { + goto handle_unusual; + } + if (input->ExpectTag(306)) goto parse_sigmoid_param; + break; + } + + // optional .caffe.SigmoidParameter sigmoid_param = 38; + case 38: { + if (tag == 306) { + parse_sigmoid_param: + DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual( + input, mutable_sigmoid_param())); + } else { + goto handle_unusual; + } + if (input->ExpectTag(314)) goto parse_softmax_param; + break; + } + + // optional .caffe.SoftmaxParameter softmax_param = 39; + case 39: { + if (tag == 314) { + parse_softmax_param: + DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual( + input, mutable_softmax_param())); + } else { + goto handle_unusual; + } + if (input->ExpectTag(322)) goto parse_contrastive_loss_param; + break; + } + + // optional .caffe.ContrastiveLossParameter contrastive_loss_param = 40; + case 40: { + if (tag == 322) { + parse_contrastive_loss_param: + DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual( + input, mutable_contrastive_loss_param())); + } else { + goto handle_unusual; + } + if (input->ExpectTag(330)) goto parse_exp_param; + break; + } + + // optional .caffe.ExpParameter exp_param = 41; + case 41: { + if (tag == 330) { + parse_exp_param: + DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual( + input, mutable_exp_param())); + } else { + goto handle_unusual; } - if (input->ExpectTag(285)) goto parse_loss_weight; - if (input->ExpectTag(290)) goto parse_transform_param; + if (input->ExpectTag(338)) goto parse_loss_param; break; } - // optional .caffe.TransformationParameter transform_param = 36; - case 36: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) { - parse_transform_param: + // optional .caffe.LossParameter loss_param = 42; + case 42: { + if (tag == 338) { + parse_loss_param: DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual( - input, mutable_transform_param())); + input, mutable_loss_param())); } else { - goto handle_uninterpreted; + goto handle_unusual; } - if (input->ExpectTag(298)) goto parse_tanh_param; + if (input->ExpectTag(8010)) goto parse_param; break; } - // optional .caffe.TanHParameter tanh_param = 37; - case 37: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) { - parse_tanh_param: - DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual( - input, mutable_tanh_param())); + // repeated string param = 1001; + case 1001: { + if (tag == 8010) { + parse_param: + DO_(::google::protobuf::internal::WireFormatLite::ReadString( + input, this->add_param())); + ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( + this->param(this->param_size() - 1).data(), + this->param(this->param_size() - 1).length(), + ::google::protobuf::internal::WireFormat::PARSE, + "caffe.V1LayerParameter.param"); } else { - goto handle_uninterpreted; + goto handle_unusual; } - if (input->ExpectTag(306)) goto parse_sigmoid_param; + if (input->ExpectTag(8010)) goto parse_param; + if (input->ExpectTag(8016)) goto parse_blob_share_mode; break; } - // optional .caffe.SigmoidParameter sigmoid_param = 38; - case 38: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) { - parse_sigmoid_param: - DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual( - input, mutable_sigmoid_param())); + // repeated .caffe.V1LayerParameter.DimCheckMode blob_share_mode = 1002; + case 1002: { + if (tag == 8016) { + parse_blob_share_mode: + int value; + DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< + int, ::google::protobuf::internal::WireFormatLite::TYPE_ENUM>( + input, &value))); + if (::caffe::V1LayerParameter_DimCheckMode_IsValid(value)) { + add_blob_share_mode(static_cast< ::caffe::V1LayerParameter_DimCheckMode >(value)); + } else { + mutable_unknown_fields()->AddVarint(1002, value); + } + } else if (tag == 8018) { + DO_((::google::protobuf::internal::WireFormat::ReadPackedEnumPreserveUnknowns( + input, + 1002, + ::caffe::V1LayerParameter_DimCheckMode_IsValid, + mutable_unknown_fields(), + this->mutable_blob_share_mode()))); } else { - goto handle_uninterpreted; + goto handle_unusual; } - if (input->ExpectTag(314)) goto parse_softmax_param; + if (input->ExpectTag(8016)) goto parse_blob_share_mode; + if (input->ExpectAtEnd()) goto success; + break; + } + + default: { + handle_unusual: + if (tag == 0 || + ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == + ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) { + goto success; + } + DO_(::google::protobuf::internal::WireFormat::SkipField( + input, tag, mutable_unknown_fields())); break; } + } + } +success: + // @@protoc_insertion_point(parse_success:caffe.V1LayerParameter) + return true; +failure: + // @@protoc_insertion_point(parse_failure:caffe.V1LayerParameter) + return false; +#undef DO_ +} + +void V1LayerParameter::SerializeWithCachedSizes( + ::google::protobuf::io::CodedOutputStream* output) const { + // @@protoc_insertion_point(serialize_start:caffe.V1LayerParameter) + // optional .caffe.V0LayerParameter layer = 1; + if (has_layer()) { + ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( + 1, *this->layer_, output); + } + + // repeated string bottom = 2; + for (int i = 0; i < this->bottom_size(); i++) { + ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( + this->bottom(i).data(), this->bottom(i).length(), + ::google::protobuf::internal::WireFormat::SERIALIZE, + "caffe.V1LayerParameter.bottom"); + ::google::protobuf::internal::WireFormatLite::WriteString( + 2, this->bottom(i), output); + } + + // repeated string top = 3; + for (int i = 0; i < this->top_size(); i++) { + ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( + this->top(i).data(), this->top(i).length(), + ::google::protobuf::internal::WireFormat::SERIALIZE, + "caffe.V1LayerParameter.top"); + ::google::protobuf::internal::WireFormatLite::WriteString( + 3, this->top(i), output); + } + + // optional string name = 4; + if (has_name()) { + ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( + this->name().data(), this->name().length(), + ::google::protobuf::internal::WireFormat::SERIALIZE, + "caffe.V1LayerParameter.name"); + ::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased( + 4, this->name(), output); + } + + // optional .caffe.V1LayerParameter.LayerType type = 5; + if (has_type()) { + ::google::protobuf::internal::WireFormatLite::WriteEnum( + 5, this->type(), output); + } + + // repeated .caffe.BlobProto blobs = 6; + for (unsigned int i = 0, n = this->blobs_size(); i < n; i++) { + ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( + 6, this->blobs(i), output); + } + + // repeated float blobs_lr = 7; + for (int i = 0; i < this->blobs_lr_size(); i++) { + ::google::protobuf::internal::WireFormatLite::WriteFloat( + 7, this->blobs_lr(i), output); + } + + // repeated float weight_decay = 8; + for (int i = 0; i < this->weight_decay_size(); i++) { + ::google::protobuf::internal::WireFormatLite::WriteFloat( + 8, this->weight_decay(i), output); + } + + // optional .caffe.ConcatParameter concat_param = 9; + if (has_concat_param()) { + ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( + 9, *this->concat_param_, output); + } + + // optional .caffe.ConvolutionParameter convolution_param = 10; + if (has_convolution_param()) { + ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( + 10, *this->convolution_param_, output); + } + + // optional .caffe.DataParameter data_param = 11; + if (has_data_param()) { + ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( + 11, *this->data_param_, output); + } + + // optional .caffe.DropoutParameter dropout_param = 12; + if (has_dropout_param()) { + ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( + 12, *this->dropout_param_, output); + } + + // optional .caffe.HDF5DataParameter hdf5_data_param = 13; + if (has_hdf5_data_param()) { + ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( + 13, *this->hdf5_data_param_, output); + } + + // optional .caffe.HDF5OutputParameter hdf5_output_param = 14; + if (has_hdf5_output_param()) { + ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( + 14, *this->hdf5_output_param_, output); + } + + // optional .caffe.ImageDataParameter image_data_param = 15; + if (has_image_data_param()) { + ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( + 15, *this->image_data_param_, output); + } + + // optional .caffe.InfogainLossParameter infogain_loss_param = 16; + if (has_infogain_loss_param()) { + ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( + 16, *this->infogain_loss_param_, output); + } + + // optional .caffe.InnerProductParameter inner_product_param = 17; + if (has_inner_product_param()) { + ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( + 17, *this->inner_product_param_, output); + } + + // optional .caffe.LRNParameter lrn_param = 18; + if (has_lrn_param()) { + ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( + 18, *this->lrn_param_, output); + } + + // optional .caffe.PoolingParameter pooling_param = 19; + if (has_pooling_param()) { + ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( + 19, *this->pooling_param_, output); + } + + // optional .caffe.WindowDataParameter window_data_param = 20; + if (has_window_data_param()) { + ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( + 20, *this->window_data_param_, output); + } + + // optional .caffe.PowerParameter power_param = 21; + if (has_power_param()) { + ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( + 21, *this->power_param_, output); + } + + // optional .caffe.MemoryDataParameter memory_data_param = 22; + if (has_memory_data_param()) { + ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( + 22, *this->memory_data_param_, output); + } + + // optional .caffe.ArgMaxParameter argmax_param = 23; + if (has_argmax_param()) { + ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( + 23, *this->argmax_param_, output); + } + + // optional .caffe.EltwiseParameter eltwise_param = 24; + if (has_eltwise_param()) { + ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( + 24, *this->eltwise_param_, output); + } + + // optional .caffe.ThresholdParameter threshold_param = 25; + if (has_threshold_param()) { + ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( + 25, *this->threshold_param_, output); + } + + // optional .caffe.DummyDataParameter dummy_data_param = 26; + if (has_dummy_data_param()) { + ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( + 26, *this->dummy_data_param_, output); + } + + // optional .caffe.AccuracyParameter accuracy_param = 27; + if (has_accuracy_param()) { + ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( + 27, *this->accuracy_param_, output); + } + + // optional .caffe.HingeLossParameter hinge_loss_param = 29; + if (has_hinge_loss_param()) { + ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( + 29, *this->hinge_loss_param_, output); + } + + // optional .caffe.ReLUParameter relu_param = 30; + if (has_relu_param()) { + ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( + 30, *this->relu_param_, output); + } + + // optional .caffe.SliceParameter slice_param = 31; + if (has_slice_param()) { + ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( + 31, *this->slice_param_, output); + } + + // repeated .caffe.NetStateRule include = 32; + for (unsigned int i = 0, n = this->include_size(); i < n; i++) { + ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( + 32, this->include(i), output); + } + + // repeated .caffe.NetStateRule exclude = 33; + for (unsigned int i = 0, n = this->exclude_size(); i < n; i++) { + ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( + 33, this->exclude(i), output); + } + + // optional .caffe.MVNParameter mvn_param = 34; + if (has_mvn_param()) { + ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( + 34, *this->mvn_param_, output); + } + + // repeated float loss_weight = 35; + for (int i = 0; i < this->loss_weight_size(); i++) { + ::google::protobuf::internal::WireFormatLite::WriteFloat( + 35, this->loss_weight(i), output); + } + + // optional .caffe.TransformationParameter transform_param = 36; + if (has_transform_param()) { + ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( + 36, *this->transform_param_, output); + } + + // optional .caffe.TanHParameter tanh_param = 37; + if (has_tanh_param()) { + ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( + 37, *this->tanh_param_, output); + } - // optional .caffe.SoftmaxParameter softmax_param = 39; - case 39: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) { - parse_softmax_param: - DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual( - input, mutable_softmax_param())); - } else { - goto handle_uninterpreted; - } - if (input->ExpectTag(322)) goto parse_contrastive_loss_param; - break; - } + // optional .caffe.SigmoidParameter sigmoid_param = 38; + if (has_sigmoid_param()) { + ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( + 38, *this->sigmoid_param_, output); + } - // optional .caffe.ContrastiveLossParameter contrastive_loss_param = 40; - case 40: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) { - parse_contrastive_loss_param: - DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual( - input, mutable_contrastive_loss_param())); - } else { - goto handle_uninterpreted; - } - if (input->ExpectTag(330)) goto parse_exp_param; - break; - } + // optional .caffe.SoftmaxParameter softmax_param = 39; + if (has_softmax_param()) { + ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( + 39, *this->softmax_param_, output); + } - // optional .caffe.ExpParameter exp_param = 41; - case 41: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) { - parse_exp_param: - DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual( - input, mutable_exp_param())); - } else { - goto handle_uninterpreted; - } - if (input->ExpectTag(338)) goto parse_loss_param; - break; - } + // optional .caffe.ContrastiveLossParameter contrastive_loss_param = 40; + if (has_contrastive_loss_param()) { + ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( + 40, *this->contrastive_loss_param_, output); + } - // optional .caffe.LossParameter loss_param = 42; - case 42: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) { - parse_loss_param: - DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual( - input, mutable_loss_param())); - } else { - goto handle_uninterpreted; - } - if (input->ExpectTag(8010)) goto parse_param; - break; - } + // optional .caffe.ExpParameter exp_param = 41; + if (has_exp_param()) { + ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( + 41, *this->exp_param_, output); + } - // repeated string param = 1001; - case 1001: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) { - parse_param: - DO_(::google::protobuf::internal::WireFormatLite::ReadString( - input, this->add_param())); - ::google::protobuf::internal::WireFormat::VerifyUTF8String( - this->param(this->param_size() - 1).data(), - this->param(this->param_size() - 1).length(), - ::google::protobuf::internal::WireFormat::PARSE); - } else { - goto handle_uninterpreted; - } - if (input->ExpectTag(8010)) goto parse_param; - if (input->ExpectTag(8016)) goto parse_blob_share_mode; - break; - } + // optional .caffe.LossParameter loss_param = 42; + if (has_loss_param()) { + ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( + 42, *this->loss_param_, output); + } - // repeated .caffe.V1LayerParameter.DimCheckMode blob_share_mode = 1002; - case 1002: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) { - parse_blob_share_mode: - int value; - DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< - int, ::google::protobuf::internal::WireFormatLite::TYPE_ENUM>( - input, &value))); - if (::caffe::V1LayerParameter_DimCheckMode_IsValid(value)) { - add_blob_share_mode(static_cast< ::caffe::V1LayerParameter_DimCheckMode >(value)); - } else { - mutable_unknown_fields()->AddVarint(1002, value); - } - } else if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) - == ::google::protobuf::internal::WireFormatLite:: - WIRETYPE_LENGTH_DELIMITED) { - DO_((::google::protobuf::internal::WireFormatLite::ReadPackedEnumNoInline( - input, - &::caffe::V1LayerParameter_DimCheckMode_IsValid, - this->mutable_blob_share_mode()))); - } else { - goto handle_uninterpreted; - } - if (input->ExpectTag(8016)) goto parse_blob_share_mode; - if (input->ExpectAtEnd()) return true; - break; - } + // repeated string param = 1001; + for (int i = 0; i < this->param_size(); i++) { + ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( + this->param(i).data(), this->param(i).length(), + ::google::protobuf::internal::WireFormat::SERIALIZE, + "caffe.V1LayerParameter.param"); + ::google::protobuf::internal::WireFormatLite::WriteString( + 1001, this->param(i), output); + } - default: { - handle_uninterpreted: - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) { - return true; - } - DO_(::google::protobuf::internal::WireFormat::SkipField( - input, tag, mutable_unknown_fields())); - break; - } - } + // repeated .caffe.V1LayerParameter.DimCheckMode blob_share_mode = 1002; + for (int i = 0; i < this->blob_share_mode_size(); i++) { + ::google::protobuf::internal::WireFormatLite::WriteEnum( + 1002, this->blob_share_mode(i), output); } - return true; -#undef DO_ + + if (_internal_metadata_.have_unknown_fields()) { + ::google::protobuf::internal::WireFormat::SerializeUnknownFields( + unknown_fields(), output); + } + // @@protoc_insertion_point(serialize_end:caffe.V1LayerParameter) } -void V1LayerParameter::SerializeWithCachedSizes( - ::google::protobuf::io::CodedOutputStream* output) const { +::google::protobuf::uint8* V1LayerParameter::InternalSerializeWithCachedSizesToArray( + bool deterministic, ::google::protobuf::uint8* target) const { + (void)deterministic; // Unused + // @@protoc_insertion_point(serialize_to_array_start:caffe.V1LayerParameter) // optional .caffe.V0LayerParameter layer = 1; if (has_layer()) { - ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( - 1, this->layer(), output); + target = ::google::protobuf::internal::WireFormatLite:: + InternalWriteMessageNoVirtualToArray( + 1, *this->layer_, false, target); } // repeated string bottom = 2; for (int i = 0; i < this->bottom_size(); i++) { - ::google::protobuf::internal::WireFormat::VerifyUTF8String( - this->bottom(i).data(), this->bottom(i).length(), - ::google::protobuf::internal::WireFormat::SERIALIZE); - ::google::protobuf::internal::WireFormatLite::WriteString( - 2, this->bottom(i), output); + ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( + this->bottom(i).data(), this->bottom(i).length(), + ::google::protobuf::internal::WireFormat::SERIALIZE, + "caffe.V1LayerParameter.bottom"); + target = ::google::protobuf::internal::WireFormatLite:: + WriteStringToArray(2, this->bottom(i), target); } // repeated string top = 3; for (int i = 0; i < this->top_size(); i++) { - ::google::protobuf::internal::WireFormat::VerifyUTF8String( - this->top(i).data(), this->top(i).length(), - ::google::protobuf::internal::WireFormat::SERIALIZE); - ::google::protobuf::internal::WireFormatLite::WriteString( - 3, this->top(i), output); + ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( + this->top(i).data(), this->top(i).length(), + ::google::protobuf::internal::WireFormat::SERIALIZE, + "caffe.V1LayerParameter.top"); + target = ::google::protobuf::internal::WireFormatLite:: + WriteStringToArray(3, this->top(i), target); } // optional string name = 4; if (has_name()) { - ::google::protobuf::internal::WireFormat::VerifyUTF8String( + ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( this->name().data(), this->name().length(), - ::google::protobuf::internal::WireFormat::SERIALIZE); - ::google::protobuf::internal::WireFormatLite::WriteString( - 4, this->name(), output); + ::google::protobuf::internal::WireFormat::SERIALIZE, + "caffe.V1LayerParameter.name"); + target = + ::google::protobuf::internal::WireFormatLite::WriteStringToArray( + 4, this->name(), target); } // optional .caffe.V1LayerParameter.LayerType type = 5; if (has_type()) { - ::google::protobuf::internal::WireFormatLite::WriteEnum( - 5, this->type(), output); + target = ::google::protobuf::internal::WireFormatLite::WriteEnumToArray( + 5, this->type(), target); } // repeated .caffe.BlobProto blobs = 6; - for (int i = 0; i < this->blobs_size(); i++) { - ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( - 6, this->blobs(i), output); + for (unsigned int i = 0, n = this->blobs_size(); i < n; i++) { + target = ::google::protobuf::internal::WireFormatLite:: + InternalWriteMessageNoVirtualToArray( + 6, this->blobs(i), false, target); + } + + // repeated float blobs_lr = 7; + for (int i = 0; i < this->blobs_lr_size(); i++) { + target = ::google::protobuf::internal::WireFormatLite:: + WriteFloatToArray(7, this->blobs_lr(i), target); + } + + // repeated float weight_decay = 8; + for (int i = 0; i < this->weight_decay_size(); i++) { + target = ::google::protobuf::internal::WireFormatLite:: + WriteFloatToArray(8, this->weight_decay(i), target); + } + + // optional .caffe.ConcatParameter concat_param = 9; + if (has_concat_param()) { + target = ::google::protobuf::internal::WireFormatLite:: + InternalWriteMessageNoVirtualToArray( + 9, *this->concat_param_, false, target); + } + + // optional .caffe.ConvolutionParameter convolution_param = 10; + if (has_convolution_param()) { + target = ::google::protobuf::internal::WireFormatLite:: + InternalWriteMessageNoVirtualToArray( + 10, *this->convolution_param_, false, target); + } + + // optional .caffe.DataParameter data_param = 11; + if (has_data_param()) { + target = ::google::protobuf::internal::WireFormatLite:: + InternalWriteMessageNoVirtualToArray( + 11, *this->data_param_, false, target); + } + + // optional .caffe.DropoutParameter dropout_param = 12; + if (has_dropout_param()) { + target = ::google::protobuf::internal::WireFormatLite:: + InternalWriteMessageNoVirtualToArray( + 12, *this->dropout_param_, false, target); + } + + // optional .caffe.HDF5DataParameter hdf5_data_param = 13; + if (has_hdf5_data_param()) { + target = ::google::protobuf::internal::WireFormatLite:: + InternalWriteMessageNoVirtualToArray( + 13, *this->hdf5_data_param_, false, target); + } + + // optional .caffe.HDF5OutputParameter hdf5_output_param = 14; + if (has_hdf5_output_param()) { + target = ::google::protobuf::internal::WireFormatLite:: + InternalWriteMessageNoVirtualToArray( + 14, *this->hdf5_output_param_, false, target); + } + + // optional .caffe.ImageDataParameter image_data_param = 15; + if (has_image_data_param()) { + target = ::google::protobuf::internal::WireFormatLite:: + InternalWriteMessageNoVirtualToArray( + 15, *this->image_data_param_, false, target); + } + + // optional .caffe.InfogainLossParameter infogain_loss_param = 16; + if (has_infogain_loss_param()) { + target = ::google::protobuf::internal::WireFormatLite:: + InternalWriteMessageNoVirtualToArray( + 16, *this->infogain_loss_param_, false, target); + } + + // optional .caffe.InnerProductParameter inner_product_param = 17; + if (has_inner_product_param()) { + target = ::google::protobuf::internal::WireFormatLite:: + InternalWriteMessageNoVirtualToArray( + 17, *this->inner_product_param_, false, target); + } + + // optional .caffe.LRNParameter lrn_param = 18; + if (has_lrn_param()) { + target = ::google::protobuf::internal::WireFormatLite:: + InternalWriteMessageNoVirtualToArray( + 18, *this->lrn_param_, false, target); + } + + // optional .caffe.PoolingParameter pooling_param = 19; + if (has_pooling_param()) { + target = ::google::protobuf::internal::WireFormatLite:: + InternalWriteMessageNoVirtualToArray( + 19, *this->pooling_param_, false, target); + } + + // optional .caffe.WindowDataParameter window_data_param = 20; + if (has_window_data_param()) { + target = ::google::protobuf::internal::WireFormatLite:: + InternalWriteMessageNoVirtualToArray( + 20, *this->window_data_param_, false, target); + } + + // optional .caffe.PowerParameter power_param = 21; + if (has_power_param()) { + target = ::google::protobuf::internal::WireFormatLite:: + InternalWriteMessageNoVirtualToArray( + 21, *this->power_param_, false, target); + } + + // optional .caffe.MemoryDataParameter memory_data_param = 22; + if (has_memory_data_param()) { + target = ::google::protobuf::internal::WireFormatLite:: + InternalWriteMessageNoVirtualToArray( + 22, *this->memory_data_param_, false, target); + } + + // optional .caffe.ArgMaxParameter argmax_param = 23; + if (has_argmax_param()) { + target = ::google::protobuf::internal::WireFormatLite:: + InternalWriteMessageNoVirtualToArray( + 23, *this->argmax_param_, false, target); + } + + // optional .caffe.EltwiseParameter eltwise_param = 24; + if (has_eltwise_param()) { + target = ::google::protobuf::internal::WireFormatLite:: + InternalWriteMessageNoVirtualToArray( + 24, *this->eltwise_param_, false, target); + } + + // optional .caffe.ThresholdParameter threshold_param = 25; + if (has_threshold_param()) { + target = ::google::protobuf::internal::WireFormatLite:: + InternalWriteMessageNoVirtualToArray( + 25, *this->threshold_param_, false, target); + } + + // optional .caffe.DummyDataParameter dummy_data_param = 26; + if (has_dummy_data_param()) { + target = ::google::protobuf::internal::WireFormatLite:: + InternalWriteMessageNoVirtualToArray( + 26, *this->dummy_data_param_, false, target); + } + + // optional .caffe.AccuracyParameter accuracy_param = 27; + if (has_accuracy_param()) { + target = ::google::protobuf::internal::WireFormatLite:: + InternalWriteMessageNoVirtualToArray( + 27, *this->accuracy_param_, false, target); + } + + // optional .caffe.HingeLossParameter hinge_loss_param = 29; + if (has_hinge_loss_param()) { + target = ::google::protobuf::internal::WireFormatLite:: + InternalWriteMessageNoVirtualToArray( + 29, *this->hinge_loss_param_, false, target); } - // repeated float blobs_lr = 7; - for (int i = 0; i < this->blobs_lr_size(); i++) { - ::google::protobuf::internal::WireFormatLite::WriteFloat( - 7, this->blobs_lr(i), output); + // optional .caffe.ReLUParameter relu_param = 30; + if (has_relu_param()) { + target = ::google::protobuf::internal::WireFormatLite:: + InternalWriteMessageNoVirtualToArray( + 30, *this->relu_param_, false, target); } - // repeated float weight_decay = 8; - for (int i = 0; i < this->weight_decay_size(); i++) { - ::google::protobuf::internal::WireFormatLite::WriteFloat( - 8, this->weight_decay(i), output); + // optional .caffe.SliceParameter slice_param = 31; + if (has_slice_param()) { + target = ::google::protobuf::internal::WireFormatLite:: + InternalWriteMessageNoVirtualToArray( + 31, *this->slice_param_, false, target); } - // optional .caffe.ConcatParameter concat_param = 9; - if (has_concat_param()) { - ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( - 9, this->concat_param(), output); + // repeated .caffe.NetStateRule include = 32; + for (unsigned int i = 0, n = this->include_size(); i < n; i++) { + target = ::google::protobuf::internal::WireFormatLite:: + InternalWriteMessageNoVirtualToArray( + 32, this->include(i), false, target); } - // optional .caffe.ConvolutionParameter convolution_param = 10; - if (has_convolution_param()) { - ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( - 10, this->convolution_param(), output); + // repeated .caffe.NetStateRule exclude = 33; + for (unsigned int i = 0, n = this->exclude_size(); i < n; i++) { + target = ::google::protobuf::internal::WireFormatLite:: + InternalWriteMessageNoVirtualToArray( + 33, this->exclude(i), false, target); } - // optional .caffe.DataParameter data_param = 11; - if (has_data_param()) { - ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( - 11, this->data_param(), output); + // optional .caffe.MVNParameter mvn_param = 34; + if (has_mvn_param()) { + target = ::google::protobuf::internal::WireFormatLite:: + InternalWriteMessageNoVirtualToArray( + 34, *this->mvn_param_, false, target); } - // optional .caffe.DropoutParameter dropout_param = 12; - if (has_dropout_param()) { - ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( - 12, this->dropout_param(), output); + // repeated float loss_weight = 35; + for (int i = 0; i < this->loss_weight_size(); i++) { + target = ::google::protobuf::internal::WireFormatLite:: + WriteFloatToArray(35, this->loss_weight(i), target); } - // optional .caffe.HDF5DataParameter hdf5_data_param = 13; - if (has_hdf5_data_param()) { - ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( - 13, this->hdf5_data_param(), output); + // optional .caffe.TransformationParameter transform_param = 36; + if (has_transform_param()) { + target = ::google::protobuf::internal::WireFormatLite:: + InternalWriteMessageNoVirtualToArray( + 36, *this->transform_param_, false, target); } - // optional .caffe.HDF5OutputParameter hdf5_output_param = 14; - if (has_hdf5_output_param()) { - ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( - 14, this->hdf5_output_param(), output); + // optional .caffe.TanHParameter tanh_param = 37; + if (has_tanh_param()) { + target = ::google::protobuf::internal::WireFormatLite:: + InternalWriteMessageNoVirtualToArray( + 37, *this->tanh_param_, false, target); } - // optional .caffe.ImageDataParameter image_data_param = 15; - if (has_image_data_param()) { - ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( - 15, this->image_data_param(), output); + // optional .caffe.SigmoidParameter sigmoid_param = 38; + if (has_sigmoid_param()) { + target = ::google::protobuf::internal::WireFormatLite:: + InternalWriteMessageNoVirtualToArray( + 38, *this->sigmoid_param_, false, target); } - // optional .caffe.InfogainLossParameter infogain_loss_param = 16; - if (has_infogain_loss_param()) { - ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( - 16, this->infogain_loss_param(), output); + // optional .caffe.SoftmaxParameter softmax_param = 39; + if (has_softmax_param()) { + target = ::google::protobuf::internal::WireFormatLite:: + InternalWriteMessageNoVirtualToArray( + 39, *this->softmax_param_, false, target); } - // optional .caffe.InnerProductParameter inner_product_param = 17; - if (has_inner_product_param()) { - ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( - 17, this->inner_product_param(), output); + // optional .caffe.ContrastiveLossParameter contrastive_loss_param = 40; + if (has_contrastive_loss_param()) { + target = ::google::protobuf::internal::WireFormatLite:: + InternalWriteMessageNoVirtualToArray( + 40, *this->contrastive_loss_param_, false, target); } - // optional .caffe.LRNParameter lrn_param = 18; - if (has_lrn_param()) { - ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( - 18, this->lrn_param(), output); + // optional .caffe.ExpParameter exp_param = 41; + if (has_exp_param()) { + target = ::google::protobuf::internal::WireFormatLite:: + InternalWriteMessageNoVirtualToArray( + 41, *this->exp_param_, false, target); } - // optional .caffe.PoolingParameter pooling_param = 19; - if (has_pooling_param()) { - ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( - 19, this->pooling_param(), output); + // optional .caffe.LossParameter loss_param = 42; + if (has_loss_param()) { + target = ::google::protobuf::internal::WireFormatLite:: + InternalWriteMessageNoVirtualToArray( + 42, *this->loss_param_, false, target); } - // optional .caffe.WindowDataParameter window_data_param = 20; - if (has_window_data_param()) { - ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( - 20, this->window_data_param(), output); + // repeated string param = 1001; + for (int i = 0; i < this->param_size(); i++) { + ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( + this->param(i).data(), this->param(i).length(), + ::google::protobuf::internal::WireFormat::SERIALIZE, + "caffe.V1LayerParameter.param"); + target = ::google::protobuf::internal::WireFormatLite:: + WriteStringToArray(1001, this->param(i), target); } - // optional .caffe.PowerParameter power_param = 21; - if (has_power_param()) { - ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( - 21, this->power_param(), output); + // repeated .caffe.V1LayerParameter.DimCheckMode blob_share_mode = 1002; + for (int i = 0; i < this->blob_share_mode_size(); i++) { + target = ::google::protobuf::internal::WireFormatLite::WriteEnumToArray( + 1002, this->blob_share_mode(i), target); } - // optional .caffe.MemoryDataParameter memory_data_param = 22; - if (has_memory_data_param()) { - ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( - 22, this->memory_data_param(), output); + if (_internal_metadata_.have_unknown_fields()) { + target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray( + unknown_fields(), target); } + // @@protoc_insertion_point(serialize_to_array_end:caffe.V1LayerParameter) + return target; +} - // optional .caffe.ArgMaxParameter argmax_param = 23; - if (has_argmax_param()) { - ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( - 23, this->argmax_param(), output); - } +size_t V1LayerParameter::ByteSizeLong() const { +// @@protoc_insertion_point(message_byte_size_start:caffe.V1LayerParameter) + size_t total_size = 0; + + if (_has_bits_[2 / 32] & 36u) { + // optional string name = 4; + if (has_name()) { + total_size += 1 + + ::google::protobuf::internal::WireFormatLite::StringSize( + this->name()); + } + + // optional .caffe.V1LayerParameter.LayerType type = 5; + if (has_type()) { + total_size += 1 + + ::google::protobuf::internal::WireFormatLite::EnumSize(this->type()); + } - // optional .caffe.EltwiseParameter eltwise_param = 24; - if (has_eltwise_param()) { - ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( - 24, this->eltwise_param(), output); } + if (_has_bits_[12 / 32] & 61440u) { + // optional .caffe.AccuracyParameter accuracy_param = 27; + if (has_accuracy_param()) { + total_size += 2 + + ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( + *this->accuracy_param_); + } + + // optional .caffe.ArgMaxParameter argmax_param = 23; + if (has_argmax_param()) { + total_size += 2 + + ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( + *this->argmax_param_); + } + + // optional .caffe.ConcatParameter concat_param = 9; + if (has_concat_param()) { + total_size += 1 + + ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( + *this->concat_param_); + } + + // optional .caffe.ContrastiveLossParameter contrastive_loss_param = 40; + if (has_contrastive_loss_param()) { + total_size += 2 + + ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( + *this->contrastive_loss_param_); + } - // optional .caffe.ThresholdParameter threshold_param = 25; - if (has_threshold_param()) { - ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( - 25, this->threshold_param(), output); } + if (_has_bits_[16 / 32] & 16711680u) { + // optional .caffe.ConvolutionParameter convolution_param = 10; + if (has_convolution_param()) { + total_size += 1 + + ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( + *this->convolution_param_); + } + + // optional .caffe.DataParameter data_param = 11; + if (has_data_param()) { + total_size += 1 + + ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( + *this->data_param_); + } + + // optional .caffe.DropoutParameter dropout_param = 12; + if (has_dropout_param()) { + total_size += 1 + + ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( + *this->dropout_param_); + } + + // optional .caffe.DummyDataParameter dummy_data_param = 26; + if (has_dummy_data_param()) { + total_size += 2 + + ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( + *this->dummy_data_param_); + } + + // optional .caffe.EltwiseParameter eltwise_param = 24; + if (has_eltwise_param()) { + total_size += 2 + + ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( + *this->eltwise_param_); + } + + // optional .caffe.ExpParameter exp_param = 41; + if (has_exp_param()) { + total_size += 2 + + ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( + *this->exp_param_); + } + + // optional .caffe.HDF5DataParameter hdf5_data_param = 13; + if (has_hdf5_data_param()) { + total_size += 1 + + ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( + *this->hdf5_data_param_); + } + + // optional .caffe.HDF5OutputParameter hdf5_output_param = 14; + if (has_hdf5_output_param()) { + total_size += 1 + + ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( + *this->hdf5_output_param_); + } - // optional .caffe.DummyDataParameter dummy_data_param = 26; - if (has_dummy_data_param()) { - ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( - 26, this->dummy_data_param(), output); } + if (_has_bits_[24 / 32] & 4278190080u) { + // optional .caffe.HingeLossParameter hinge_loss_param = 29; + if (has_hinge_loss_param()) { + total_size += 2 + + ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( + *this->hinge_loss_param_); + } + + // optional .caffe.ImageDataParameter image_data_param = 15; + if (has_image_data_param()) { + total_size += 1 + + ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( + *this->image_data_param_); + } + + // optional .caffe.InfogainLossParameter infogain_loss_param = 16; + if (has_infogain_loss_param()) { + total_size += 2 + + ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( + *this->infogain_loss_param_); + } + + // optional .caffe.InnerProductParameter inner_product_param = 17; + if (has_inner_product_param()) { + total_size += 2 + + ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( + *this->inner_product_param_); + } + + // optional .caffe.LRNParameter lrn_param = 18; + if (has_lrn_param()) { + total_size += 2 + + ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( + *this->lrn_param_); + } + + // optional .caffe.MemoryDataParameter memory_data_param = 22; + if (has_memory_data_param()) { + total_size += 2 + + ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( + *this->memory_data_param_); + } + + // optional .caffe.MVNParameter mvn_param = 34; + if (has_mvn_param()) { + total_size += 2 + + ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( + *this->mvn_param_); + } + + // optional .caffe.PoolingParameter pooling_param = 19; + if (has_pooling_param()) { + total_size += 2 + + ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( + *this->pooling_param_); + } - // optional .caffe.AccuracyParameter accuracy_param = 27; - if (has_accuracy_param()) { - ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( - 27, this->accuracy_param(), output); } + if (_has_bits_[32 / 32] & 255u) { + // optional .caffe.PowerParameter power_param = 21; + if (has_power_param()) { + total_size += 2 + + ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( + *this->power_param_); + } + + // optional .caffe.ReLUParameter relu_param = 30; + if (has_relu_param()) { + total_size += 2 + + ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( + *this->relu_param_); + } - // optional .caffe.HingeLossParameter hinge_loss_param = 29; - if (has_hinge_loss_param()) { - ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( - 29, this->hinge_loss_param(), output); - } + // optional .caffe.SigmoidParameter sigmoid_param = 38; + if (has_sigmoid_param()) { + total_size += 2 + + ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( + *this->sigmoid_param_); + } - // optional .caffe.ReLUParameter relu_param = 30; - if (has_relu_param()) { - ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( - 30, this->relu_param(), output); - } + // optional .caffe.SoftmaxParameter softmax_param = 39; + if (has_softmax_param()) { + total_size += 2 + + ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( + *this->softmax_param_); + } - // optional .caffe.SliceParameter slice_param = 31; - if (has_slice_param()) { - ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( - 31, this->slice_param(), output); - } + // optional .caffe.SliceParameter slice_param = 31; + if (has_slice_param()) { + total_size += 2 + + ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( + *this->slice_param_); + } - // repeated .caffe.NetStateRule include = 32; - for (int i = 0; i < this->include_size(); i++) { - ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( - 32, this->include(i), output); - } + // optional .caffe.TanHParameter tanh_param = 37; + if (has_tanh_param()) { + total_size += 2 + + ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( + *this->tanh_param_); + } - // repeated .caffe.NetStateRule exclude = 33; - for (int i = 0; i < this->exclude_size(); i++) { - ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( - 33, this->exclude(i), output); - } + // optional .caffe.ThresholdParameter threshold_param = 25; + if (has_threshold_param()) { + total_size += 2 + + ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( + *this->threshold_param_); + } - // optional .caffe.MVNParameter mvn_param = 34; - if (has_mvn_param()) { - ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( - 34, this->mvn_param(), output); - } + // optional .caffe.WindowDataParameter window_data_param = 20; + if (has_window_data_param()) { + total_size += 2 + + ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( + *this->window_data_param_); + } - // repeated float loss_weight = 35; - for (int i = 0; i < this->loss_weight_size(); i++) { - ::google::protobuf::internal::WireFormatLite::WriteFloat( - 35, this->loss_weight(i), output); } + if (_has_bits_[40 / 32] & 1792u) { + // optional .caffe.TransformationParameter transform_param = 36; + if (has_transform_param()) { + total_size += 2 + + ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( + *this->transform_param_); + } - // optional .caffe.TransformationParameter transform_param = 36; - if (has_transform_param()) { - ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( - 36, this->transform_param(), output); - } + // optional .caffe.LossParameter loss_param = 42; + if (has_loss_param()) { + total_size += 2 + + ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( + *this->loss_param_); + } - // optional .caffe.TanHParameter tanh_param = 37; - if (has_tanh_param()) { - ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( - 37, this->tanh_param(), output); - } + // optional .caffe.V0LayerParameter layer = 1; + if (has_layer()) { + total_size += 1 + + ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( + *this->layer_); + } - // optional .caffe.SigmoidParameter sigmoid_param = 38; - if (has_sigmoid_param()) { - ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( - 38, this->sigmoid_param(), output); + } + // repeated string bottom = 2; + total_size += 1 * + ::google::protobuf::internal::FromIntSize(this->bottom_size()); + for (int i = 0; i < this->bottom_size(); i++) { + total_size += ::google::protobuf::internal::WireFormatLite::StringSize( + this->bottom(i)); } - // optional .caffe.SoftmaxParameter softmax_param = 39; - if (has_softmax_param()) { - ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( - 39, this->softmax_param(), output); + // repeated string top = 3; + total_size += 1 * + ::google::protobuf::internal::FromIntSize(this->top_size()); + for (int i = 0; i < this->top_size(); i++) { + total_size += ::google::protobuf::internal::WireFormatLite::StringSize( + this->top(i)); } - // optional .caffe.ContrastiveLossParameter contrastive_loss_param = 40; - if (has_contrastive_loss_param()) { - ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( - 40, this->contrastive_loss_param(), output); + // repeated .caffe.NetStateRule include = 32; + { + unsigned int count = this->include_size(); + total_size += 2UL * count; + for (unsigned int i = 0; i < count; i++) { + total_size += + ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( + this->include(i)); + } } - // optional .caffe.ExpParameter exp_param = 41; - if (has_exp_param()) { - ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( - 41, this->exp_param(), output); + // repeated .caffe.NetStateRule exclude = 33; + { + unsigned int count = this->exclude_size(); + total_size += 2UL * count; + for (unsigned int i = 0; i < count; i++) { + total_size += + ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( + this->exclude(i)); + } } - // optional .caffe.LossParameter loss_param = 42; - if (has_loss_param()) { - ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( - 42, this->loss_param(), output); + // repeated .caffe.BlobProto blobs = 6; + { + unsigned int count = this->blobs_size(); + total_size += 1UL * count; + for (unsigned int i = 0; i < count; i++) { + total_size += + ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( + this->blobs(i)); + } } // repeated string param = 1001; + total_size += 2 * + ::google::protobuf::internal::FromIntSize(this->param_size()); for (int i = 0; i < this->param_size(); i++) { - ::google::protobuf::internal::WireFormat::VerifyUTF8String( - this->param(i).data(), this->param(i).length(), - ::google::protobuf::internal::WireFormat::SERIALIZE); - ::google::protobuf::internal::WireFormatLite::WriteString( - 1001, this->param(i), output); + total_size += ::google::protobuf::internal::WireFormatLite::StringSize( + this->param(i)); } // repeated .caffe.V1LayerParameter.DimCheckMode blob_share_mode = 1002; - for (int i = 0; i < this->blob_share_mode_size(); i++) { - ::google::protobuf::internal::WireFormatLite::WriteEnum( - 1002, this->blob_share_mode(i), output); - } - - if (!unknown_fields().empty()) { - ::google::protobuf::internal::WireFormat::SerializeUnknownFields( - unknown_fields(), output); - } -} - -::google::protobuf::uint8* V1LayerParameter::SerializeWithCachedSizesToArray( - ::google::protobuf::uint8* target) const { - // optional .caffe.V0LayerParameter layer = 1; - if (has_layer()) { - target = ::google::protobuf::internal::WireFormatLite:: - WriteMessageNoVirtualToArray( - 1, this->layer(), target); + { + size_t data_size = 0; + unsigned int count = this->blob_share_mode_size();for (unsigned int i = 0; i < count; i++) { + data_size += ::google::protobuf::internal::WireFormatLite::EnumSize( + this->blob_share_mode(i)); + } + total_size += (2UL * count) + data_size; } - // repeated string bottom = 2; - for (int i = 0; i < this->bottom_size(); i++) { - ::google::protobuf::internal::WireFormat::VerifyUTF8String( - this->bottom(i).data(), this->bottom(i).length(), - ::google::protobuf::internal::WireFormat::SERIALIZE); - target = ::google::protobuf::internal::WireFormatLite:: - WriteStringToArray(2, this->bottom(i), target); + // repeated float blobs_lr = 7; + { + size_t data_size = 0; + unsigned int count = this->blobs_lr_size(); + data_size = 4UL * count; + total_size += 1 * + ::google::protobuf::internal::FromIntSize(this->blobs_lr_size()); + total_size += data_size; } - // repeated string top = 3; - for (int i = 0; i < this->top_size(); i++) { - ::google::protobuf::internal::WireFormat::VerifyUTF8String( - this->top(i).data(), this->top(i).length(), - ::google::protobuf::internal::WireFormat::SERIALIZE); - target = ::google::protobuf::internal::WireFormatLite:: - WriteStringToArray(3, this->top(i), target); + // repeated float weight_decay = 8; + { + size_t data_size = 0; + unsigned int count = this->weight_decay_size(); + data_size = 4UL * count; + total_size += 1 * + ::google::protobuf::internal::FromIntSize(this->weight_decay_size()); + total_size += data_size; } - // optional string name = 4; - if (has_name()) { - ::google::protobuf::internal::WireFormat::VerifyUTF8String( - this->name().data(), this->name().length(), - ::google::protobuf::internal::WireFormat::SERIALIZE); - target = - ::google::protobuf::internal::WireFormatLite::WriteStringToArray( - 4, this->name(), target); + // repeated float loss_weight = 35; + { + size_t data_size = 0; + unsigned int count = this->loss_weight_size(); + data_size = 4UL * count; + total_size += 2 * + ::google::protobuf::internal::FromIntSize(this->loss_weight_size()); + total_size += data_size; } - // optional .caffe.V1LayerParameter.LayerType type = 5; - if (has_type()) { - target = ::google::protobuf::internal::WireFormatLite::WriteEnumToArray( - 5, this->type(), target); + if (_internal_metadata_.have_unknown_fields()) { + total_size += + ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( + unknown_fields()); } + int cached_size = ::google::protobuf::internal::ToCachedSize(total_size); + GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); + _cached_size_ = cached_size; + GOOGLE_SAFE_CONCURRENT_WRITES_END(); + return total_size; +} - // repeated .caffe.BlobProto blobs = 6; - for (int i = 0; i < this->blobs_size(); i++) { - target = ::google::protobuf::internal::WireFormatLite:: - WriteMessageNoVirtualToArray( - 6, this->blobs(i), target); +void V1LayerParameter::MergeFrom(const ::google::protobuf::Message& from) { +// @@protoc_insertion_point(generalized_merge_from_start:caffe.V1LayerParameter) + if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__); + const V1LayerParameter* source = + ::google::protobuf::internal::DynamicCastToGenerated( + &from); + if (source == NULL) { + // @@protoc_insertion_point(generalized_merge_from_cast_fail:caffe.V1LayerParameter) + ::google::protobuf::internal::ReflectionOps::Merge(from, this); + } else { + // @@protoc_insertion_point(generalized_merge_from_cast_success:caffe.V1LayerParameter) + UnsafeMergeFrom(*source); } +} - // repeated float blobs_lr = 7; - for (int i = 0; i < this->blobs_lr_size(); i++) { - target = ::google::protobuf::internal::WireFormatLite:: - WriteFloatToArray(7, this->blobs_lr(i), target); +void V1LayerParameter::MergeFrom(const V1LayerParameter& from) { +// @@protoc_insertion_point(class_specific_merge_from_start:caffe.V1LayerParameter) + if (GOOGLE_PREDICT_TRUE(&from != this)) { + UnsafeMergeFrom(from); + } else { + MergeFromFail(__LINE__); } +} - // repeated float weight_decay = 8; - for (int i = 0; i < this->weight_decay_size(); i++) { - target = ::google::protobuf::internal::WireFormatLite:: - WriteFloatToArray(8, this->weight_decay(i), target); +void V1LayerParameter::UnsafeMergeFrom(const V1LayerParameter& from) { + GOOGLE_DCHECK(&from != this); + bottom_.UnsafeMergeFrom(from.bottom_); + top_.UnsafeMergeFrom(from.top_); + include_.MergeFrom(from.include_); + exclude_.MergeFrom(from.exclude_); + blobs_.MergeFrom(from.blobs_); + param_.UnsafeMergeFrom(from.param_); + blob_share_mode_.UnsafeMergeFrom(from.blob_share_mode_); + blobs_lr_.UnsafeMergeFrom(from.blobs_lr_); + weight_decay_.UnsafeMergeFrom(from.weight_decay_); + loss_weight_.UnsafeMergeFrom(from.loss_weight_); + if (from._has_bits_[2 / 32] & (0xffu << (2 % 32))) { + if (from.has_name()) { + set_has_name(); + name_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.name_); + } + if (from.has_type()) { + set_type(from.type()); + } } - - // optional .caffe.ConcatParameter concat_param = 9; - if (has_concat_param()) { - target = ::google::protobuf::internal::WireFormatLite:: - WriteMessageNoVirtualToArray( - 9, this->concat_param(), target); + if (from._has_bits_[12 / 32] & (0xffu << (12 % 32))) { + if (from.has_accuracy_param()) { + mutable_accuracy_param()->::caffe::AccuracyParameter::MergeFrom(from.accuracy_param()); + } + if (from.has_argmax_param()) { + mutable_argmax_param()->::caffe::ArgMaxParameter::MergeFrom(from.argmax_param()); + } + if (from.has_concat_param()) { + mutable_concat_param()->::caffe::ConcatParameter::MergeFrom(from.concat_param()); + } + if (from.has_contrastive_loss_param()) { + mutable_contrastive_loss_param()->::caffe::ContrastiveLossParameter::MergeFrom(from.contrastive_loss_param()); + } } - - // optional .caffe.ConvolutionParameter convolution_param = 10; - if (has_convolution_param()) { - target = ::google::protobuf::internal::WireFormatLite:: - WriteMessageNoVirtualToArray( - 10, this->convolution_param(), target); + if (from._has_bits_[16 / 32] & (0xffu << (16 % 32))) { + if (from.has_convolution_param()) { + mutable_convolution_param()->::caffe::ConvolutionParameter::MergeFrom(from.convolution_param()); + } + if (from.has_data_param()) { + mutable_data_param()->::caffe::DataParameter::MergeFrom(from.data_param()); + } + if (from.has_dropout_param()) { + mutable_dropout_param()->::caffe::DropoutParameter::MergeFrom(from.dropout_param()); + } + if (from.has_dummy_data_param()) { + mutable_dummy_data_param()->::caffe::DummyDataParameter::MergeFrom(from.dummy_data_param()); + } + if (from.has_eltwise_param()) { + mutable_eltwise_param()->::caffe::EltwiseParameter::MergeFrom(from.eltwise_param()); + } + if (from.has_exp_param()) { + mutable_exp_param()->::caffe::ExpParameter::MergeFrom(from.exp_param()); + } + if (from.has_hdf5_data_param()) { + mutable_hdf5_data_param()->::caffe::HDF5DataParameter::MergeFrom(from.hdf5_data_param()); + } + if (from.has_hdf5_output_param()) { + mutable_hdf5_output_param()->::caffe::HDF5OutputParameter::MergeFrom(from.hdf5_output_param()); + } } - - // optional .caffe.DataParameter data_param = 11; - if (has_data_param()) { - target = ::google::protobuf::internal::WireFormatLite:: - WriteMessageNoVirtualToArray( - 11, this->data_param(), target); + if (from._has_bits_[24 / 32] & (0xffu << (24 % 32))) { + if (from.has_hinge_loss_param()) { + mutable_hinge_loss_param()->::caffe::HingeLossParameter::MergeFrom(from.hinge_loss_param()); + } + if (from.has_image_data_param()) { + mutable_image_data_param()->::caffe::ImageDataParameter::MergeFrom(from.image_data_param()); + } + if (from.has_infogain_loss_param()) { + mutable_infogain_loss_param()->::caffe::InfogainLossParameter::MergeFrom(from.infogain_loss_param()); + } + if (from.has_inner_product_param()) { + mutable_inner_product_param()->::caffe::InnerProductParameter::MergeFrom(from.inner_product_param()); + } + if (from.has_lrn_param()) { + mutable_lrn_param()->::caffe::LRNParameter::MergeFrom(from.lrn_param()); + } + if (from.has_memory_data_param()) { + mutable_memory_data_param()->::caffe::MemoryDataParameter::MergeFrom(from.memory_data_param()); + } + if (from.has_mvn_param()) { + mutable_mvn_param()->::caffe::MVNParameter::MergeFrom(from.mvn_param()); + } + if (from.has_pooling_param()) { + mutable_pooling_param()->::caffe::PoolingParameter::MergeFrom(from.pooling_param()); + } } - - // optional .caffe.DropoutParameter dropout_param = 12; - if (has_dropout_param()) { - target = ::google::protobuf::internal::WireFormatLite:: - WriteMessageNoVirtualToArray( - 12, this->dropout_param(), target); + if (from._has_bits_[32 / 32] & (0xffu << (32 % 32))) { + if (from.has_power_param()) { + mutable_power_param()->::caffe::PowerParameter::MergeFrom(from.power_param()); + } + if (from.has_relu_param()) { + mutable_relu_param()->::caffe::ReLUParameter::MergeFrom(from.relu_param()); + } + if (from.has_sigmoid_param()) { + mutable_sigmoid_param()->::caffe::SigmoidParameter::MergeFrom(from.sigmoid_param()); + } + if (from.has_softmax_param()) { + mutable_softmax_param()->::caffe::SoftmaxParameter::MergeFrom(from.softmax_param()); + } + if (from.has_slice_param()) { + mutable_slice_param()->::caffe::SliceParameter::MergeFrom(from.slice_param()); + } + if (from.has_tanh_param()) { + mutable_tanh_param()->::caffe::TanHParameter::MergeFrom(from.tanh_param()); + } + if (from.has_threshold_param()) { + mutable_threshold_param()->::caffe::ThresholdParameter::MergeFrom(from.threshold_param()); + } + if (from.has_window_data_param()) { + mutable_window_data_param()->::caffe::WindowDataParameter::MergeFrom(from.window_data_param()); + } } - - // optional .caffe.HDF5DataParameter hdf5_data_param = 13; - if (has_hdf5_data_param()) { - target = ::google::protobuf::internal::WireFormatLite:: - WriteMessageNoVirtualToArray( - 13, this->hdf5_data_param(), target); + if (from._has_bits_[40 / 32] & (0xffu << (40 % 32))) { + if (from.has_transform_param()) { + mutable_transform_param()->::caffe::TransformationParameter::MergeFrom(from.transform_param()); + } + if (from.has_loss_param()) { + mutable_loss_param()->::caffe::LossParameter::MergeFrom(from.loss_param()); + } + if (from.has_layer()) { + mutable_layer()->::caffe::V0LayerParameter::MergeFrom(from.layer()); + } } - - // optional .caffe.HDF5OutputParameter hdf5_output_param = 14; - if (has_hdf5_output_param()) { - target = ::google::protobuf::internal::WireFormatLite:: - WriteMessageNoVirtualToArray( - 14, this->hdf5_output_param(), target); + if (from._internal_metadata_.have_unknown_fields()) { + ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata( + from.unknown_fields(), &_internal_metadata_); } +} - // optional .caffe.ImageDataParameter image_data_param = 15; - if (has_image_data_param()) { - target = ::google::protobuf::internal::WireFormatLite:: - WriteMessageNoVirtualToArray( - 15, this->image_data_param(), target); - } +void V1LayerParameter::CopyFrom(const ::google::protobuf::Message& from) { +// @@protoc_insertion_point(generalized_copy_from_start:caffe.V1LayerParameter) + if (&from == this) return; + Clear(); + MergeFrom(from); +} - // optional .caffe.InfogainLossParameter infogain_loss_param = 16; - if (has_infogain_loss_param()) { - target = ::google::protobuf::internal::WireFormatLite:: - WriteMessageNoVirtualToArray( - 16, this->infogain_loss_param(), target); - } +void V1LayerParameter::CopyFrom(const V1LayerParameter& from) { +// @@protoc_insertion_point(class_specific_copy_from_start:caffe.V1LayerParameter) + if (&from == this) return; + Clear(); + UnsafeMergeFrom(from); +} - // optional .caffe.InnerProductParameter inner_product_param = 17; - if (has_inner_product_param()) { - target = ::google::protobuf::internal::WireFormatLite:: - WriteMessageNoVirtualToArray( - 17, this->inner_product_param(), target); - } +bool V1LayerParameter::IsInitialized() const { - // optional .caffe.LRNParameter lrn_param = 18; - if (has_lrn_param()) { - target = ::google::protobuf::internal::WireFormatLite:: - WriteMessageNoVirtualToArray( - 18, this->lrn_param(), target); - } + return true; +} - // optional .caffe.PoolingParameter pooling_param = 19; - if (has_pooling_param()) { - target = ::google::protobuf::internal::WireFormatLite:: - WriteMessageNoVirtualToArray( - 19, this->pooling_param(), target); - } +void V1LayerParameter::Swap(V1LayerParameter* other) { + if (other == this) return; + InternalSwap(other); +} +void V1LayerParameter::InternalSwap(V1LayerParameter* other) { + bottom_.UnsafeArenaSwap(&other->bottom_); + top_.UnsafeArenaSwap(&other->top_); + name_.Swap(&other->name_); + include_.UnsafeArenaSwap(&other->include_); + exclude_.UnsafeArenaSwap(&other->exclude_); + std::swap(type_, other->type_); + blobs_.UnsafeArenaSwap(&other->blobs_); + param_.UnsafeArenaSwap(&other->param_); + blob_share_mode_.UnsafeArenaSwap(&other->blob_share_mode_); + blobs_lr_.UnsafeArenaSwap(&other->blobs_lr_); + weight_decay_.UnsafeArenaSwap(&other->weight_decay_); + loss_weight_.UnsafeArenaSwap(&other->loss_weight_); + std::swap(accuracy_param_, other->accuracy_param_); + std::swap(argmax_param_, other->argmax_param_); + std::swap(concat_param_, other->concat_param_); + std::swap(contrastive_loss_param_, other->contrastive_loss_param_); + std::swap(convolution_param_, other->convolution_param_); + std::swap(data_param_, other->data_param_); + std::swap(dropout_param_, other->dropout_param_); + std::swap(dummy_data_param_, other->dummy_data_param_); + std::swap(eltwise_param_, other->eltwise_param_); + std::swap(exp_param_, other->exp_param_); + std::swap(hdf5_data_param_, other->hdf5_data_param_); + std::swap(hdf5_output_param_, other->hdf5_output_param_); + std::swap(hinge_loss_param_, other->hinge_loss_param_); + std::swap(image_data_param_, other->image_data_param_); + std::swap(infogain_loss_param_, other->infogain_loss_param_); + std::swap(inner_product_param_, other->inner_product_param_); + std::swap(lrn_param_, other->lrn_param_); + std::swap(memory_data_param_, other->memory_data_param_); + std::swap(mvn_param_, other->mvn_param_); + std::swap(pooling_param_, other->pooling_param_); + std::swap(power_param_, other->power_param_); + std::swap(relu_param_, other->relu_param_); + std::swap(sigmoid_param_, other->sigmoid_param_); + std::swap(softmax_param_, other->softmax_param_); + std::swap(slice_param_, other->slice_param_); + std::swap(tanh_param_, other->tanh_param_); + std::swap(threshold_param_, other->threshold_param_); + std::swap(window_data_param_, other->window_data_param_); + std::swap(transform_param_, other->transform_param_); + std::swap(loss_param_, other->loss_param_); + std::swap(layer_, other->layer_); + std::swap(_has_bits_[0], other->_has_bits_[0]); + std::swap(_has_bits_[1], other->_has_bits_[1]); + _internal_metadata_.Swap(&other->_internal_metadata_); + std::swap(_cached_size_, other->_cached_size_); +} - // optional .caffe.WindowDataParameter window_data_param = 20; - if (has_window_data_param()) { - target = ::google::protobuf::internal::WireFormatLite:: - WriteMessageNoVirtualToArray( - 20, this->window_data_param(), target); - } +::google::protobuf::Metadata V1LayerParameter::GetMetadata() const { + protobuf_AssignDescriptorsOnce(); + ::google::protobuf::Metadata metadata; + metadata.descriptor = V1LayerParameter_descriptor_; + metadata.reflection = V1LayerParameter_reflection_; + return metadata; +} - // optional .caffe.PowerParameter power_param = 21; - if (has_power_param()) { - target = ::google::protobuf::internal::WireFormatLite:: - WriteMessageNoVirtualToArray( - 21, this->power_param(), target); - } +#if PROTOBUF_INLINE_NOT_IN_HEADERS +// V1LayerParameter - // optional .caffe.MemoryDataParameter memory_data_param = 22; - if (has_memory_data_param()) { - target = ::google::protobuf::internal::WireFormatLite:: - WriteMessageNoVirtualToArray( - 22, this->memory_data_param(), target); - } +// repeated string bottom = 2; +int V1LayerParameter::bottom_size() const { + return bottom_.size(); +} +void V1LayerParameter::clear_bottom() { + bottom_.Clear(); +} +const ::std::string& V1LayerParameter::bottom(int index) const { + // @@protoc_insertion_point(field_get:caffe.V1LayerParameter.bottom) + return bottom_.Get(index); +} +::std::string* V1LayerParameter::mutable_bottom(int index) { + // @@protoc_insertion_point(field_mutable:caffe.V1LayerParameter.bottom) + return bottom_.Mutable(index); +} +void V1LayerParameter::set_bottom(int index, const ::std::string& value) { + // @@protoc_insertion_point(field_set:caffe.V1LayerParameter.bottom) + bottom_.Mutable(index)->assign(value); +} +void V1LayerParameter::set_bottom(int index, const char* value) { + bottom_.Mutable(index)->assign(value); + // @@protoc_insertion_point(field_set_char:caffe.V1LayerParameter.bottom) +} +void V1LayerParameter::set_bottom(int index, const char* value, size_t size) { + bottom_.Mutable(index)->assign( + reinterpret_cast(value), size); + // @@protoc_insertion_point(field_set_pointer:caffe.V1LayerParameter.bottom) +} +::std::string* V1LayerParameter::add_bottom() { + // @@protoc_insertion_point(field_add_mutable:caffe.V1LayerParameter.bottom) + return bottom_.Add(); +} +void V1LayerParameter::add_bottom(const ::std::string& value) { + bottom_.Add()->assign(value); + // @@protoc_insertion_point(field_add:caffe.V1LayerParameter.bottom) +} +void V1LayerParameter::add_bottom(const char* value) { + bottom_.Add()->assign(value); + // @@protoc_insertion_point(field_add_char:caffe.V1LayerParameter.bottom) +} +void V1LayerParameter::add_bottom(const char* value, size_t size) { + bottom_.Add()->assign(reinterpret_cast(value), size); + // @@protoc_insertion_point(field_add_pointer:caffe.V1LayerParameter.bottom) +} +const ::google::protobuf::RepeatedPtrField< ::std::string>& +V1LayerParameter::bottom() const { + // @@protoc_insertion_point(field_list:caffe.V1LayerParameter.bottom) + return bottom_; +} +::google::protobuf::RepeatedPtrField< ::std::string>* +V1LayerParameter::mutable_bottom() { + // @@protoc_insertion_point(field_mutable_list:caffe.V1LayerParameter.bottom) + return &bottom_; +} - // optional .caffe.ArgMaxParameter argmax_param = 23; - if (has_argmax_param()) { - target = ::google::protobuf::internal::WireFormatLite:: - WriteMessageNoVirtualToArray( - 23, this->argmax_param(), target); +// repeated string top = 3; +int V1LayerParameter::top_size() const { + return top_.size(); +} +void V1LayerParameter::clear_top() { + top_.Clear(); +} +const ::std::string& V1LayerParameter::top(int index) const { + // @@protoc_insertion_point(field_get:caffe.V1LayerParameter.top) + return top_.Get(index); +} +::std::string* V1LayerParameter::mutable_top(int index) { + // @@protoc_insertion_point(field_mutable:caffe.V1LayerParameter.top) + return top_.Mutable(index); +} +void V1LayerParameter::set_top(int index, const ::std::string& value) { + // @@protoc_insertion_point(field_set:caffe.V1LayerParameter.top) + top_.Mutable(index)->assign(value); +} +void V1LayerParameter::set_top(int index, const char* value) { + top_.Mutable(index)->assign(value); + // @@protoc_insertion_point(field_set_char:caffe.V1LayerParameter.top) +} +void V1LayerParameter::set_top(int index, const char* value, size_t size) { + top_.Mutable(index)->assign( + reinterpret_cast(value), size); + // @@protoc_insertion_point(field_set_pointer:caffe.V1LayerParameter.top) +} +::std::string* V1LayerParameter::add_top() { + // @@protoc_insertion_point(field_add_mutable:caffe.V1LayerParameter.top) + return top_.Add(); +} +void V1LayerParameter::add_top(const ::std::string& value) { + top_.Add()->assign(value); + // @@protoc_insertion_point(field_add:caffe.V1LayerParameter.top) +} +void V1LayerParameter::add_top(const char* value) { + top_.Add()->assign(value); + // @@protoc_insertion_point(field_add_char:caffe.V1LayerParameter.top) +} +void V1LayerParameter::add_top(const char* value, size_t size) { + top_.Add()->assign(reinterpret_cast(value), size); + // @@protoc_insertion_point(field_add_pointer:caffe.V1LayerParameter.top) +} +const ::google::protobuf::RepeatedPtrField< ::std::string>& +V1LayerParameter::top() const { + // @@protoc_insertion_point(field_list:caffe.V1LayerParameter.top) + return top_; +} +::google::protobuf::RepeatedPtrField< ::std::string>* +V1LayerParameter::mutable_top() { + // @@protoc_insertion_point(field_mutable_list:caffe.V1LayerParameter.top) + return &top_; +} + +// optional string name = 4; +bool V1LayerParameter::has_name() const { + return (_has_bits_[0] & 0x00000004u) != 0; +} +void V1LayerParameter::set_has_name() { + _has_bits_[0] |= 0x00000004u; +} +void V1LayerParameter::clear_has_name() { + _has_bits_[0] &= ~0x00000004u; +} +void V1LayerParameter::clear_name() { + name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + clear_has_name(); +} +const ::std::string& V1LayerParameter::name() const { + // @@protoc_insertion_point(field_get:caffe.V1LayerParameter.name) + return name_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); +} +void V1LayerParameter::set_name(const ::std::string& value) { + set_has_name(); + name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); + // @@protoc_insertion_point(field_set:caffe.V1LayerParameter.name) +} +void V1LayerParameter::set_name(const char* value) { + set_has_name(); + name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); + // @@protoc_insertion_point(field_set_char:caffe.V1LayerParameter.name) +} +void V1LayerParameter::set_name(const char* value, size_t size) { + set_has_name(); + name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), + ::std::string(reinterpret_cast(value), size)); + // @@protoc_insertion_point(field_set_pointer:caffe.V1LayerParameter.name) +} +::std::string* V1LayerParameter::mutable_name() { + set_has_name(); + // @@protoc_insertion_point(field_mutable:caffe.V1LayerParameter.name) + return name_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); +} +::std::string* V1LayerParameter::release_name() { + // @@protoc_insertion_point(field_release:caffe.V1LayerParameter.name) + clear_has_name(); + return name_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); +} +void V1LayerParameter::set_allocated_name(::std::string* name) { + if (name != NULL) { + set_has_name(); + } else { + clear_has_name(); } + name_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), name); + // @@protoc_insertion_point(field_set_allocated:caffe.V1LayerParameter.name) +} - // optional .caffe.EltwiseParameter eltwise_param = 24; - if (has_eltwise_param()) { - target = ::google::protobuf::internal::WireFormatLite:: - WriteMessageNoVirtualToArray( - 24, this->eltwise_param(), target); - } +// repeated .caffe.NetStateRule include = 32; +int V1LayerParameter::include_size() const { + return include_.size(); +} +void V1LayerParameter::clear_include() { + include_.Clear(); +} +const ::caffe::NetStateRule& V1LayerParameter::include(int index) const { + // @@protoc_insertion_point(field_get:caffe.V1LayerParameter.include) + return include_.Get(index); +} +::caffe::NetStateRule* V1LayerParameter::mutable_include(int index) { + // @@protoc_insertion_point(field_mutable:caffe.V1LayerParameter.include) + return include_.Mutable(index); +} +::caffe::NetStateRule* V1LayerParameter::add_include() { + // @@protoc_insertion_point(field_add:caffe.V1LayerParameter.include) + return include_.Add(); +} +::google::protobuf::RepeatedPtrField< ::caffe::NetStateRule >* +V1LayerParameter::mutable_include() { + // @@protoc_insertion_point(field_mutable_list:caffe.V1LayerParameter.include) + return &include_; +} +const ::google::protobuf::RepeatedPtrField< ::caffe::NetStateRule >& +V1LayerParameter::include() const { + // @@protoc_insertion_point(field_list:caffe.V1LayerParameter.include) + return include_; +} - // optional .caffe.ThresholdParameter threshold_param = 25; - if (has_threshold_param()) { - target = ::google::protobuf::internal::WireFormatLite:: - WriteMessageNoVirtualToArray( - 25, this->threshold_param(), target); - } +// repeated .caffe.NetStateRule exclude = 33; +int V1LayerParameter::exclude_size() const { + return exclude_.size(); +} +void V1LayerParameter::clear_exclude() { + exclude_.Clear(); +} +const ::caffe::NetStateRule& V1LayerParameter::exclude(int index) const { + // @@protoc_insertion_point(field_get:caffe.V1LayerParameter.exclude) + return exclude_.Get(index); +} +::caffe::NetStateRule* V1LayerParameter::mutable_exclude(int index) { + // @@protoc_insertion_point(field_mutable:caffe.V1LayerParameter.exclude) + return exclude_.Mutable(index); +} +::caffe::NetStateRule* V1LayerParameter::add_exclude() { + // @@protoc_insertion_point(field_add:caffe.V1LayerParameter.exclude) + return exclude_.Add(); +} +::google::protobuf::RepeatedPtrField< ::caffe::NetStateRule >* +V1LayerParameter::mutable_exclude() { + // @@protoc_insertion_point(field_mutable_list:caffe.V1LayerParameter.exclude) + return &exclude_; +} +const ::google::protobuf::RepeatedPtrField< ::caffe::NetStateRule >& +V1LayerParameter::exclude() const { + // @@protoc_insertion_point(field_list:caffe.V1LayerParameter.exclude) + return exclude_; +} - // optional .caffe.DummyDataParameter dummy_data_param = 26; - if (has_dummy_data_param()) { - target = ::google::protobuf::internal::WireFormatLite:: - WriteMessageNoVirtualToArray( - 26, this->dummy_data_param(), target); - } +// optional .caffe.V1LayerParameter.LayerType type = 5; +bool V1LayerParameter::has_type() const { + return (_has_bits_[0] & 0x00000020u) != 0; +} +void V1LayerParameter::set_has_type() { + _has_bits_[0] |= 0x00000020u; +} +void V1LayerParameter::clear_has_type() { + _has_bits_[0] &= ~0x00000020u; +} +void V1LayerParameter::clear_type() { + type_ = 0; + clear_has_type(); +} +::caffe::V1LayerParameter_LayerType V1LayerParameter::type() const { + // @@protoc_insertion_point(field_get:caffe.V1LayerParameter.type) + return static_cast< ::caffe::V1LayerParameter_LayerType >(type_); +} +void V1LayerParameter::set_type(::caffe::V1LayerParameter_LayerType value) { + assert(::caffe::V1LayerParameter_LayerType_IsValid(value)); + set_has_type(); + type_ = value; + // @@protoc_insertion_point(field_set:caffe.V1LayerParameter.type) +} - // optional .caffe.AccuracyParameter accuracy_param = 27; - if (has_accuracy_param()) { - target = ::google::protobuf::internal::WireFormatLite:: - WriteMessageNoVirtualToArray( - 27, this->accuracy_param(), target); - } +// repeated .caffe.BlobProto blobs = 6; +int V1LayerParameter::blobs_size() const { + return blobs_.size(); +} +void V1LayerParameter::clear_blobs() { + blobs_.Clear(); +} +const ::caffe::BlobProto& V1LayerParameter::blobs(int index) const { + // @@protoc_insertion_point(field_get:caffe.V1LayerParameter.blobs) + return blobs_.Get(index); +} +::caffe::BlobProto* V1LayerParameter::mutable_blobs(int index) { + // @@protoc_insertion_point(field_mutable:caffe.V1LayerParameter.blobs) + return blobs_.Mutable(index); +} +::caffe::BlobProto* V1LayerParameter::add_blobs() { + // @@protoc_insertion_point(field_add:caffe.V1LayerParameter.blobs) + return blobs_.Add(); +} +::google::protobuf::RepeatedPtrField< ::caffe::BlobProto >* +V1LayerParameter::mutable_blobs() { + // @@protoc_insertion_point(field_mutable_list:caffe.V1LayerParameter.blobs) + return &blobs_; +} +const ::google::protobuf::RepeatedPtrField< ::caffe::BlobProto >& +V1LayerParameter::blobs() const { + // @@protoc_insertion_point(field_list:caffe.V1LayerParameter.blobs) + return blobs_; +} - // optional .caffe.HingeLossParameter hinge_loss_param = 29; - if (has_hinge_loss_param()) { - target = ::google::protobuf::internal::WireFormatLite:: - WriteMessageNoVirtualToArray( - 29, this->hinge_loss_param(), target); - } +// repeated string param = 1001; +int V1LayerParameter::param_size() const { + return param_.size(); +} +void V1LayerParameter::clear_param() { + param_.Clear(); +} +const ::std::string& V1LayerParameter::param(int index) const { + // @@protoc_insertion_point(field_get:caffe.V1LayerParameter.param) + return param_.Get(index); +} +::std::string* V1LayerParameter::mutable_param(int index) { + // @@protoc_insertion_point(field_mutable:caffe.V1LayerParameter.param) + return param_.Mutable(index); +} +void V1LayerParameter::set_param(int index, const ::std::string& value) { + // @@protoc_insertion_point(field_set:caffe.V1LayerParameter.param) + param_.Mutable(index)->assign(value); +} +void V1LayerParameter::set_param(int index, const char* value) { + param_.Mutable(index)->assign(value); + // @@protoc_insertion_point(field_set_char:caffe.V1LayerParameter.param) +} +void V1LayerParameter::set_param(int index, const char* value, size_t size) { + param_.Mutable(index)->assign( + reinterpret_cast(value), size); + // @@protoc_insertion_point(field_set_pointer:caffe.V1LayerParameter.param) +} +::std::string* V1LayerParameter::add_param() { + // @@protoc_insertion_point(field_add_mutable:caffe.V1LayerParameter.param) + return param_.Add(); +} +void V1LayerParameter::add_param(const ::std::string& value) { + param_.Add()->assign(value); + // @@protoc_insertion_point(field_add:caffe.V1LayerParameter.param) +} +void V1LayerParameter::add_param(const char* value) { + param_.Add()->assign(value); + // @@protoc_insertion_point(field_add_char:caffe.V1LayerParameter.param) +} +void V1LayerParameter::add_param(const char* value, size_t size) { + param_.Add()->assign(reinterpret_cast(value), size); + // @@protoc_insertion_point(field_add_pointer:caffe.V1LayerParameter.param) +} +const ::google::protobuf::RepeatedPtrField< ::std::string>& +V1LayerParameter::param() const { + // @@protoc_insertion_point(field_list:caffe.V1LayerParameter.param) + return param_; +} +::google::protobuf::RepeatedPtrField< ::std::string>* +V1LayerParameter::mutable_param() { + // @@protoc_insertion_point(field_mutable_list:caffe.V1LayerParameter.param) + return ¶m_; +} - // optional .caffe.ReLUParameter relu_param = 30; - if (has_relu_param()) { - target = ::google::protobuf::internal::WireFormatLite:: - WriteMessageNoVirtualToArray( - 30, this->relu_param(), target); - } +// repeated .caffe.V1LayerParameter.DimCheckMode blob_share_mode = 1002; +int V1LayerParameter::blob_share_mode_size() const { + return blob_share_mode_.size(); +} +void V1LayerParameter::clear_blob_share_mode() { + blob_share_mode_.Clear(); +} +::caffe::V1LayerParameter_DimCheckMode V1LayerParameter::blob_share_mode(int index) const { + // @@protoc_insertion_point(field_get:caffe.V1LayerParameter.blob_share_mode) + return static_cast< ::caffe::V1LayerParameter_DimCheckMode >(blob_share_mode_.Get(index)); +} +void V1LayerParameter::set_blob_share_mode(int index, ::caffe::V1LayerParameter_DimCheckMode value) { + assert(::caffe::V1LayerParameter_DimCheckMode_IsValid(value)); + blob_share_mode_.Set(index, value); + // @@protoc_insertion_point(field_set:caffe.V1LayerParameter.blob_share_mode) +} +void V1LayerParameter::add_blob_share_mode(::caffe::V1LayerParameter_DimCheckMode value) { + assert(::caffe::V1LayerParameter_DimCheckMode_IsValid(value)); + blob_share_mode_.Add(value); + // @@protoc_insertion_point(field_add:caffe.V1LayerParameter.blob_share_mode) +} +const ::google::protobuf::RepeatedField& +V1LayerParameter::blob_share_mode() const { + // @@protoc_insertion_point(field_list:caffe.V1LayerParameter.blob_share_mode) + return blob_share_mode_; +} +::google::protobuf::RepeatedField* +V1LayerParameter::mutable_blob_share_mode() { + // @@protoc_insertion_point(field_mutable_list:caffe.V1LayerParameter.blob_share_mode) + return &blob_share_mode_; +} - // optional .caffe.SliceParameter slice_param = 31; - if (has_slice_param()) { - target = ::google::protobuf::internal::WireFormatLite:: - WriteMessageNoVirtualToArray( - 31, this->slice_param(), target); - } +// repeated float blobs_lr = 7; +int V1LayerParameter::blobs_lr_size() const { + return blobs_lr_.size(); +} +void V1LayerParameter::clear_blobs_lr() { + blobs_lr_.Clear(); +} +float V1LayerParameter::blobs_lr(int index) const { + // @@protoc_insertion_point(field_get:caffe.V1LayerParameter.blobs_lr) + return blobs_lr_.Get(index); +} +void V1LayerParameter::set_blobs_lr(int index, float value) { + blobs_lr_.Set(index, value); + // @@protoc_insertion_point(field_set:caffe.V1LayerParameter.blobs_lr) +} +void V1LayerParameter::add_blobs_lr(float value) { + blobs_lr_.Add(value); + // @@protoc_insertion_point(field_add:caffe.V1LayerParameter.blobs_lr) +} +const ::google::protobuf::RepeatedField< float >& +V1LayerParameter::blobs_lr() const { + // @@protoc_insertion_point(field_list:caffe.V1LayerParameter.blobs_lr) + return blobs_lr_; +} +::google::protobuf::RepeatedField< float >* +V1LayerParameter::mutable_blobs_lr() { + // @@protoc_insertion_point(field_mutable_list:caffe.V1LayerParameter.blobs_lr) + return &blobs_lr_; +} - // repeated .caffe.NetStateRule include = 32; - for (int i = 0; i < this->include_size(); i++) { - target = ::google::protobuf::internal::WireFormatLite:: - WriteMessageNoVirtualToArray( - 32, this->include(i), target); - } +// repeated float weight_decay = 8; +int V1LayerParameter::weight_decay_size() const { + return weight_decay_.size(); +} +void V1LayerParameter::clear_weight_decay() { + weight_decay_.Clear(); +} +float V1LayerParameter::weight_decay(int index) const { + // @@protoc_insertion_point(field_get:caffe.V1LayerParameter.weight_decay) + return weight_decay_.Get(index); +} +void V1LayerParameter::set_weight_decay(int index, float value) { + weight_decay_.Set(index, value); + // @@protoc_insertion_point(field_set:caffe.V1LayerParameter.weight_decay) +} +void V1LayerParameter::add_weight_decay(float value) { + weight_decay_.Add(value); + // @@protoc_insertion_point(field_add:caffe.V1LayerParameter.weight_decay) +} +const ::google::protobuf::RepeatedField< float >& +V1LayerParameter::weight_decay() const { + // @@protoc_insertion_point(field_list:caffe.V1LayerParameter.weight_decay) + return weight_decay_; +} +::google::protobuf::RepeatedField< float >* +V1LayerParameter::mutable_weight_decay() { + // @@protoc_insertion_point(field_mutable_list:caffe.V1LayerParameter.weight_decay) + return &weight_decay_; +} - // repeated .caffe.NetStateRule exclude = 33; - for (int i = 0; i < this->exclude_size(); i++) { - target = ::google::protobuf::internal::WireFormatLite:: - WriteMessageNoVirtualToArray( - 33, this->exclude(i), target); - } +// repeated float loss_weight = 35; +int V1LayerParameter::loss_weight_size() const { + return loss_weight_.size(); +} +void V1LayerParameter::clear_loss_weight() { + loss_weight_.Clear(); +} +float V1LayerParameter::loss_weight(int index) const { + // @@protoc_insertion_point(field_get:caffe.V1LayerParameter.loss_weight) + return loss_weight_.Get(index); +} +void V1LayerParameter::set_loss_weight(int index, float value) { + loss_weight_.Set(index, value); + // @@protoc_insertion_point(field_set:caffe.V1LayerParameter.loss_weight) +} +void V1LayerParameter::add_loss_weight(float value) { + loss_weight_.Add(value); + // @@protoc_insertion_point(field_add:caffe.V1LayerParameter.loss_weight) +} +const ::google::protobuf::RepeatedField< float >& +V1LayerParameter::loss_weight() const { + // @@protoc_insertion_point(field_list:caffe.V1LayerParameter.loss_weight) + return loss_weight_; +} +::google::protobuf::RepeatedField< float >* +V1LayerParameter::mutable_loss_weight() { + // @@protoc_insertion_point(field_mutable_list:caffe.V1LayerParameter.loss_weight) + return &loss_weight_; +} - // optional .caffe.MVNParameter mvn_param = 34; - if (has_mvn_param()) { - target = ::google::protobuf::internal::WireFormatLite:: - WriteMessageNoVirtualToArray( - 34, this->mvn_param(), target); +// optional .caffe.AccuracyParameter accuracy_param = 27; +bool V1LayerParameter::has_accuracy_param() const { + return (_has_bits_[0] & 0x00001000u) != 0; +} +void V1LayerParameter::set_has_accuracy_param() { + _has_bits_[0] |= 0x00001000u; +} +void V1LayerParameter::clear_has_accuracy_param() { + _has_bits_[0] &= ~0x00001000u; +} +void V1LayerParameter::clear_accuracy_param() { + if (accuracy_param_ != NULL) accuracy_param_->::caffe::AccuracyParameter::Clear(); + clear_has_accuracy_param(); +} +const ::caffe::AccuracyParameter& V1LayerParameter::accuracy_param() const { + // @@protoc_insertion_point(field_get:caffe.V1LayerParameter.accuracy_param) + return accuracy_param_ != NULL ? *accuracy_param_ + : *::caffe::AccuracyParameter::internal_default_instance(); +} +::caffe::AccuracyParameter* V1LayerParameter::mutable_accuracy_param() { + set_has_accuracy_param(); + if (accuracy_param_ == NULL) { + accuracy_param_ = new ::caffe::AccuracyParameter; } - - // repeated float loss_weight = 35; - for (int i = 0; i < this->loss_weight_size(); i++) { - target = ::google::protobuf::internal::WireFormatLite:: - WriteFloatToArray(35, this->loss_weight(i), target); + // @@protoc_insertion_point(field_mutable:caffe.V1LayerParameter.accuracy_param) + return accuracy_param_; +} +::caffe::AccuracyParameter* V1LayerParameter::release_accuracy_param() { + // @@protoc_insertion_point(field_release:caffe.V1LayerParameter.accuracy_param) + clear_has_accuracy_param(); + ::caffe::AccuracyParameter* temp = accuracy_param_; + accuracy_param_ = NULL; + return temp; +} +void V1LayerParameter::set_allocated_accuracy_param(::caffe::AccuracyParameter* accuracy_param) { + delete accuracy_param_; + accuracy_param_ = accuracy_param; + if (accuracy_param) { + set_has_accuracy_param(); + } else { + clear_has_accuracy_param(); } + // @@protoc_insertion_point(field_set_allocated:caffe.V1LayerParameter.accuracy_param) +} - // optional .caffe.TransformationParameter transform_param = 36; - if (has_transform_param()) { - target = ::google::protobuf::internal::WireFormatLite:: - WriteMessageNoVirtualToArray( - 36, this->transform_param(), target); +// optional .caffe.ArgMaxParameter argmax_param = 23; +bool V1LayerParameter::has_argmax_param() const { + return (_has_bits_[0] & 0x00002000u) != 0; +} +void V1LayerParameter::set_has_argmax_param() { + _has_bits_[0] |= 0x00002000u; +} +void V1LayerParameter::clear_has_argmax_param() { + _has_bits_[0] &= ~0x00002000u; +} +void V1LayerParameter::clear_argmax_param() { + if (argmax_param_ != NULL) argmax_param_->::caffe::ArgMaxParameter::Clear(); + clear_has_argmax_param(); +} +const ::caffe::ArgMaxParameter& V1LayerParameter::argmax_param() const { + // @@protoc_insertion_point(field_get:caffe.V1LayerParameter.argmax_param) + return argmax_param_ != NULL ? *argmax_param_ + : *::caffe::ArgMaxParameter::internal_default_instance(); +} +::caffe::ArgMaxParameter* V1LayerParameter::mutable_argmax_param() { + set_has_argmax_param(); + if (argmax_param_ == NULL) { + argmax_param_ = new ::caffe::ArgMaxParameter; } - - // optional .caffe.TanHParameter tanh_param = 37; - if (has_tanh_param()) { - target = ::google::protobuf::internal::WireFormatLite:: - WriteMessageNoVirtualToArray( - 37, this->tanh_param(), target); + // @@protoc_insertion_point(field_mutable:caffe.V1LayerParameter.argmax_param) + return argmax_param_; +} +::caffe::ArgMaxParameter* V1LayerParameter::release_argmax_param() { + // @@protoc_insertion_point(field_release:caffe.V1LayerParameter.argmax_param) + clear_has_argmax_param(); + ::caffe::ArgMaxParameter* temp = argmax_param_; + argmax_param_ = NULL; + return temp; +} +void V1LayerParameter::set_allocated_argmax_param(::caffe::ArgMaxParameter* argmax_param) { + delete argmax_param_; + argmax_param_ = argmax_param; + if (argmax_param) { + set_has_argmax_param(); + } else { + clear_has_argmax_param(); } + // @@protoc_insertion_point(field_set_allocated:caffe.V1LayerParameter.argmax_param) +} - // optional .caffe.SigmoidParameter sigmoid_param = 38; - if (has_sigmoid_param()) { - target = ::google::protobuf::internal::WireFormatLite:: - WriteMessageNoVirtualToArray( - 38, this->sigmoid_param(), target); +// optional .caffe.ConcatParameter concat_param = 9; +bool V1LayerParameter::has_concat_param() const { + return (_has_bits_[0] & 0x00004000u) != 0; +} +void V1LayerParameter::set_has_concat_param() { + _has_bits_[0] |= 0x00004000u; +} +void V1LayerParameter::clear_has_concat_param() { + _has_bits_[0] &= ~0x00004000u; +} +void V1LayerParameter::clear_concat_param() { + if (concat_param_ != NULL) concat_param_->::caffe::ConcatParameter::Clear(); + clear_has_concat_param(); +} +const ::caffe::ConcatParameter& V1LayerParameter::concat_param() const { + // @@protoc_insertion_point(field_get:caffe.V1LayerParameter.concat_param) + return concat_param_ != NULL ? *concat_param_ + : *::caffe::ConcatParameter::internal_default_instance(); +} +::caffe::ConcatParameter* V1LayerParameter::mutable_concat_param() { + set_has_concat_param(); + if (concat_param_ == NULL) { + concat_param_ = new ::caffe::ConcatParameter; } - - // optional .caffe.SoftmaxParameter softmax_param = 39; - if (has_softmax_param()) { - target = ::google::protobuf::internal::WireFormatLite:: - WriteMessageNoVirtualToArray( - 39, this->softmax_param(), target); + // @@protoc_insertion_point(field_mutable:caffe.V1LayerParameter.concat_param) + return concat_param_; +} +::caffe::ConcatParameter* V1LayerParameter::release_concat_param() { + // @@protoc_insertion_point(field_release:caffe.V1LayerParameter.concat_param) + clear_has_concat_param(); + ::caffe::ConcatParameter* temp = concat_param_; + concat_param_ = NULL; + return temp; +} +void V1LayerParameter::set_allocated_concat_param(::caffe::ConcatParameter* concat_param) { + delete concat_param_; + concat_param_ = concat_param; + if (concat_param) { + set_has_concat_param(); + } else { + clear_has_concat_param(); } + // @@protoc_insertion_point(field_set_allocated:caffe.V1LayerParameter.concat_param) +} - // optional .caffe.ContrastiveLossParameter contrastive_loss_param = 40; - if (has_contrastive_loss_param()) { - target = ::google::protobuf::internal::WireFormatLite:: - WriteMessageNoVirtualToArray( - 40, this->contrastive_loss_param(), target); +// optional .caffe.ContrastiveLossParameter contrastive_loss_param = 40; +bool V1LayerParameter::has_contrastive_loss_param() const { + return (_has_bits_[0] & 0x00008000u) != 0; +} +void V1LayerParameter::set_has_contrastive_loss_param() { + _has_bits_[0] |= 0x00008000u; +} +void V1LayerParameter::clear_has_contrastive_loss_param() { + _has_bits_[0] &= ~0x00008000u; +} +void V1LayerParameter::clear_contrastive_loss_param() { + if (contrastive_loss_param_ != NULL) contrastive_loss_param_->::caffe::ContrastiveLossParameter::Clear(); + clear_has_contrastive_loss_param(); +} +const ::caffe::ContrastiveLossParameter& V1LayerParameter::contrastive_loss_param() const { + // @@protoc_insertion_point(field_get:caffe.V1LayerParameter.contrastive_loss_param) + return contrastive_loss_param_ != NULL ? *contrastive_loss_param_ + : *::caffe::ContrastiveLossParameter::internal_default_instance(); +} +::caffe::ContrastiveLossParameter* V1LayerParameter::mutable_contrastive_loss_param() { + set_has_contrastive_loss_param(); + if (contrastive_loss_param_ == NULL) { + contrastive_loss_param_ = new ::caffe::ContrastiveLossParameter; } - - // optional .caffe.ExpParameter exp_param = 41; - if (has_exp_param()) { - target = ::google::protobuf::internal::WireFormatLite:: - WriteMessageNoVirtualToArray( - 41, this->exp_param(), target); + // @@protoc_insertion_point(field_mutable:caffe.V1LayerParameter.contrastive_loss_param) + return contrastive_loss_param_; +} +::caffe::ContrastiveLossParameter* V1LayerParameter::release_contrastive_loss_param() { + // @@protoc_insertion_point(field_release:caffe.V1LayerParameter.contrastive_loss_param) + clear_has_contrastive_loss_param(); + ::caffe::ContrastiveLossParameter* temp = contrastive_loss_param_; + contrastive_loss_param_ = NULL; + return temp; +} +void V1LayerParameter::set_allocated_contrastive_loss_param(::caffe::ContrastiveLossParameter* contrastive_loss_param) { + delete contrastive_loss_param_; + contrastive_loss_param_ = contrastive_loss_param; + if (contrastive_loss_param) { + set_has_contrastive_loss_param(); + } else { + clear_has_contrastive_loss_param(); } + // @@protoc_insertion_point(field_set_allocated:caffe.V1LayerParameter.contrastive_loss_param) +} - // optional .caffe.LossParameter loss_param = 42; - if (has_loss_param()) { - target = ::google::protobuf::internal::WireFormatLite:: - WriteMessageNoVirtualToArray( - 42, this->loss_param(), target); +// optional .caffe.ConvolutionParameter convolution_param = 10; +bool V1LayerParameter::has_convolution_param() const { + return (_has_bits_[0] & 0x00010000u) != 0; +} +void V1LayerParameter::set_has_convolution_param() { + _has_bits_[0] |= 0x00010000u; +} +void V1LayerParameter::clear_has_convolution_param() { + _has_bits_[0] &= ~0x00010000u; +} +void V1LayerParameter::clear_convolution_param() { + if (convolution_param_ != NULL) convolution_param_->::caffe::ConvolutionParameter::Clear(); + clear_has_convolution_param(); +} +const ::caffe::ConvolutionParameter& V1LayerParameter::convolution_param() const { + // @@protoc_insertion_point(field_get:caffe.V1LayerParameter.convolution_param) + return convolution_param_ != NULL ? *convolution_param_ + : *::caffe::ConvolutionParameter::internal_default_instance(); +} +::caffe::ConvolutionParameter* V1LayerParameter::mutable_convolution_param() { + set_has_convolution_param(); + if (convolution_param_ == NULL) { + convolution_param_ = new ::caffe::ConvolutionParameter; } - - // repeated string param = 1001; - for (int i = 0; i < this->param_size(); i++) { - ::google::protobuf::internal::WireFormat::VerifyUTF8String( - this->param(i).data(), this->param(i).length(), - ::google::protobuf::internal::WireFormat::SERIALIZE); - target = ::google::protobuf::internal::WireFormatLite:: - WriteStringToArray(1001, this->param(i), target); + // @@protoc_insertion_point(field_mutable:caffe.V1LayerParameter.convolution_param) + return convolution_param_; +} +::caffe::ConvolutionParameter* V1LayerParameter::release_convolution_param() { + // @@protoc_insertion_point(field_release:caffe.V1LayerParameter.convolution_param) + clear_has_convolution_param(); + ::caffe::ConvolutionParameter* temp = convolution_param_; + convolution_param_ = NULL; + return temp; +} +void V1LayerParameter::set_allocated_convolution_param(::caffe::ConvolutionParameter* convolution_param) { + delete convolution_param_; + convolution_param_ = convolution_param; + if (convolution_param) { + set_has_convolution_param(); + } else { + clear_has_convolution_param(); } + // @@protoc_insertion_point(field_set_allocated:caffe.V1LayerParameter.convolution_param) +} - // repeated .caffe.V1LayerParameter.DimCheckMode blob_share_mode = 1002; - for (int i = 0; i < this->blob_share_mode_size(); i++) { - target = ::google::protobuf::internal::WireFormatLite::WriteEnumToArray( - 1002, this->blob_share_mode(i), target); +// optional .caffe.DataParameter data_param = 11; +bool V1LayerParameter::has_data_param() const { + return (_has_bits_[0] & 0x00020000u) != 0; +} +void V1LayerParameter::set_has_data_param() { + _has_bits_[0] |= 0x00020000u; +} +void V1LayerParameter::clear_has_data_param() { + _has_bits_[0] &= ~0x00020000u; +} +void V1LayerParameter::clear_data_param() { + if (data_param_ != NULL) data_param_->::caffe::DataParameter::Clear(); + clear_has_data_param(); +} +const ::caffe::DataParameter& V1LayerParameter::data_param() const { + // @@protoc_insertion_point(field_get:caffe.V1LayerParameter.data_param) + return data_param_ != NULL ? *data_param_ + : *::caffe::DataParameter::internal_default_instance(); +} +::caffe::DataParameter* V1LayerParameter::mutable_data_param() { + set_has_data_param(); + if (data_param_ == NULL) { + data_param_ = new ::caffe::DataParameter; } - - if (!unknown_fields().empty()) { - target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray( - unknown_fields(), target); + // @@protoc_insertion_point(field_mutable:caffe.V1LayerParameter.data_param) + return data_param_; +} +::caffe::DataParameter* V1LayerParameter::release_data_param() { + // @@protoc_insertion_point(field_release:caffe.V1LayerParameter.data_param) + clear_has_data_param(); + ::caffe::DataParameter* temp = data_param_; + data_param_ = NULL; + return temp; +} +void V1LayerParameter::set_allocated_data_param(::caffe::DataParameter* data_param) { + delete data_param_; + data_param_ = data_param; + if (data_param) { + set_has_data_param(); + } else { + clear_has_data_param(); } - return target; + // @@protoc_insertion_point(field_set_allocated:caffe.V1LayerParameter.data_param) } -int V1LayerParameter::ByteSize() const { - int total_size = 0; - - if (_has_bits_[2 / 32] & (0xffu << (2 % 32))) { - // optional string name = 4; - if (has_name()) { - total_size += 1 + - ::google::protobuf::internal::WireFormatLite::StringSize( - this->name()); - } - - // optional .caffe.V1LayerParameter.LayerType type = 5; - if (has_type()) { - total_size += 1 + - ::google::protobuf::internal::WireFormatLite::EnumSize(this->type()); - } - +// optional .caffe.DropoutParameter dropout_param = 12; +bool V1LayerParameter::has_dropout_param() const { + return (_has_bits_[0] & 0x00040000u) != 0; +} +void V1LayerParameter::set_has_dropout_param() { + _has_bits_[0] |= 0x00040000u; +} +void V1LayerParameter::clear_has_dropout_param() { + _has_bits_[0] &= ~0x00040000u; +} +void V1LayerParameter::clear_dropout_param() { + if (dropout_param_ != NULL) dropout_param_->::caffe::DropoutParameter::Clear(); + clear_has_dropout_param(); +} +const ::caffe::DropoutParameter& V1LayerParameter::dropout_param() const { + // @@protoc_insertion_point(field_get:caffe.V1LayerParameter.dropout_param) + return dropout_param_ != NULL ? *dropout_param_ + : *::caffe::DropoutParameter::internal_default_instance(); +} +::caffe::DropoutParameter* V1LayerParameter::mutable_dropout_param() { + set_has_dropout_param(); + if (dropout_param_ == NULL) { + dropout_param_ = new ::caffe::DropoutParameter; } - if (_has_bits_[12 / 32] & (0xffu << (12 % 32))) { - // optional .caffe.AccuracyParameter accuracy_param = 27; - if (has_accuracy_param()) { - total_size += 2 + - ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( - this->accuracy_param()); - } - - // optional .caffe.ArgMaxParameter argmax_param = 23; - if (has_argmax_param()) { - total_size += 2 + - ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( - this->argmax_param()); - } - - // optional .caffe.ConcatParameter concat_param = 9; - if (has_concat_param()) { - total_size += 1 + - ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( - this->concat_param()); - } - - // optional .caffe.ContrastiveLossParameter contrastive_loss_param = 40; - if (has_contrastive_loss_param()) { - total_size += 2 + - ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( - this->contrastive_loss_param()); - } - + // @@protoc_insertion_point(field_mutable:caffe.V1LayerParameter.dropout_param) + return dropout_param_; +} +::caffe::DropoutParameter* V1LayerParameter::release_dropout_param() { + // @@protoc_insertion_point(field_release:caffe.V1LayerParameter.dropout_param) + clear_has_dropout_param(); + ::caffe::DropoutParameter* temp = dropout_param_; + dropout_param_ = NULL; + return temp; +} +void V1LayerParameter::set_allocated_dropout_param(::caffe::DropoutParameter* dropout_param) { + delete dropout_param_; + dropout_param_ = dropout_param; + if (dropout_param) { + set_has_dropout_param(); + } else { + clear_has_dropout_param(); } - if (_has_bits_[16 / 32] & (0xffu << (16 % 32))) { - // optional .caffe.ConvolutionParameter convolution_param = 10; - if (has_convolution_param()) { - total_size += 1 + - ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( - this->convolution_param()); - } - - // optional .caffe.DataParameter data_param = 11; - if (has_data_param()) { - total_size += 1 + - ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( - this->data_param()); - } - - // optional .caffe.DropoutParameter dropout_param = 12; - if (has_dropout_param()) { - total_size += 1 + - ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( - this->dropout_param()); - } - - // optional .caffe.DummyDataParameter dummy_data_param = 26; - if (has_dummy_data_param()) { - total_size += 2 + - ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( - this->dummy_data_param()); - } - - // optional .caffe.EltwiseParameter eltwise_param = 24; - if (has_eltwise_param()) { - total_size += 2 + - ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( - this->eltwise_param()); - } - - // optional .caffe.ExpParameter exp_param = 41; - if (has_exp_param()) { - total_size += 2 + - ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( - this->exp_param()); - } - - // optional .caffe.HDF5DataParameter hdf5_data_param = 13; - if (has_hdf5_data_param()) { - total_size += 1 + - ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( - this->hdf5_data_param()); - } - - // optional .caffe.HDF5OutputParameter hdf5_output_param = 14; - if (has_hdf5_output_param()) { - total_size += 1 + - ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( - this->hdf5_output_param()); - } + // @@protoc_insertion_point(field_set_allocated:caffe.V1LayerParameter.dropout_param) +} +// optional .caffe.DummyDataParameter dummy_data_param = 26; +bool V1LayerParameter::has_dummy_data_param() const { + return (_has_bits_[0] & 0x00080000u) != 0; +} +void V1LayerParameter::set_has_dummy_data_param() { + _has_bits_[0] |= 0x00080000u; +} +void V1LayerParameter::clear_has_dummy_data_param() { + _has_bits_[0] &= ~0x00080000u; +} +void V1LayerParameter::clear_dummy_data_param() { + if (dummy_data_param_ != NULL) dummy_data_param_->::caffe::DummyDataParameter::Clear(); + clear_has_dummy_data_param(); +} +const ::caffe::DummyDataParameter& V1LayerParameter::dummy_data_param() const { + // @@protoc_insertion_point(field_get:caffe.V1LayerParameter.dummy_data_param) + return dummy_data_param_ != NULL ? *dummy_data_param_ + : *::caffe::DummyDataParameter::internal_default_instance(); +} +::caffe::DummyDataParameter* V1LayerParameter::mutable_dummy_data_param() { + set_has_dummy_data_param(); + if (dummy_data_param_ == NULL) { + dummy_data_param_ = new ::caffe::DummyDataParameter; } - if (_has_bits_[24 / 32] & (0xffu << (24 % 32))) { - // optional .caffe.HingeLossParameter hinge_loss_param = 29; - if (has_hinge_loss_param()) { - total_size += 2 + - ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( - this->hinge_loss_param()); - } - - // optional .caffe.ImageDataParameter image_data_param = 15; - if (has_image_data_param()) { - total_size += 1 + - ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( - this->image_data_param()); - } - - // optional .caffe.InfogainLossParameter infogain_loss_param = 16; - if (has_infogain_loss_param()) { - total_size += 2 + - ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( - this->infogain_loss_param()); - } - - // optional .caffe.InnerProductParameter inner_product_param = 17; - if (has_inner_product_param()) { - total_size += 2 + - ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( - this->inner_product_param()); - } - - // optional .caffe.LRNParameter lrn_param = 18; - if (has_lrn_param()) { - total_size += 2 + - ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( - this->lrn_param()); - } - - // optional .caffe.MemoryDataParameter memory_data_param = 22; - if (has_memory_data_param()) { - total_size += 2 + - ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( - this->memory_data_param()); - } - - // optional .caffe.MVNParameter mvn_param = 34; - if (has_mvn_param()) { - total_size += 2 + - ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( - this->mvn_param()); - } - - // optional .caffe.PoolingParameter pooling_param = 19; - if (has_pooling_param()) { - total_size += 2 + - ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( - this->pooling_param()); - } + // @@protoc_insertion_point(field_mutable:caffe.V1LayerParameter.dummy_data_param) + return dummy_data_param_; +} +::caffe::DummyDataParameter* V1LayerParameter::release_dummy_data_param() { + // @@protoc_insertion_point(field_release:caffe.V1LayerParameter.dummy_data_param) + clear_has_dummy_data_param(); + ::caffe::DummyDataParameter* temp = dummy_data_param_; + dummy_data_param_ = NULL; + return temp; +} +void V1LayerParameter::set_allocated_dummy_data_param(::caffe::DummyDataParameter* dummy_data_param) { + delete dummy_data_param_; + dummy_data_param_ = dummy_data_param; + if (dummy_data_param) { + set_has_dummy_data_param(); + } else { + clear_has_dummy_data_param(); + } + // @@protoc_insertion_point(field_set_allocated:caffe.V1LayerParameter.dummy_data_param) +} +// optional .caffe.EltwiseParameter eltwise_param = 24; +bool V1LayerParameter::has_eltwise_param() const { + return (_has_bits_[0] & 0x00100000u) != 0; +} +void V1LayerParameter::set_has_eltwise_param() { + _has_bits_[0] |= 0x00100000u; +} +void V1LayerParameter::clear_has_eltwise_param() { + _has_bits_[0] &= ~0x00100000u; +} +void V1LayerParameter::clear_eltwise_param() { + if (eltwise_param_ != NULL) eltwise_param_->::caffe::EltwiseParameter::Clear(); + clear_has_eltwise_param(); +} +const ::caffe::EltwiseParameter& V1LayerParameter::eltwise_param() const { + // @@protoc_insertion_point(field_get:caffe.V1LayerParameter.eltwise_param) + return eltwise_param_ != NULL ? *eltwise_param_ + : *::caffe::EltwiseParameter::internal_default_instance(); +} +::caffe::EltwiseParameter* V1LayerParameter::mutable_eltwise_param() { + set_has_eltwise_param(); + if (eltwise_param_ == NULL) { + eltwise_param_ = new ::caffe::EltwiseParameter; } - if (_has_bits_[32 / 32] & (0xffu << (32 % 32))) { - // optional .caffe.PowerParameter power_param = 21; - if (has_power_param()) { - total_size += 2 + - ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( - this->power_param()); - } + // @@protoc_insertion_point(field_mutable:caffe.V1LayerParameter.eltwise_param) + return eltwise_param_; +} +::caffe::EltwiseParameter* V1LayerParameter::release_eltwise_param() { + // @@protoc_insertion_point(field_release:caffe.V1LayerParameter.eltwise_param) + clear_has_eltwise_param(); + ::caffe::EltwiseParameter* temp = eltwise_param_; + eltwise_param_ = NULL; + return temp; +} +void V1LayerParameter::set_allocated_eltwise_param(::caffe::EltwiseParameter* eltwise_param) { + delete eltwise_param_; + eltwise_param_ = eltwise_param; + if (eltwise_param) { + set_has_eltwise_param(); + } else { + clear_has_eltwise_param(); + } + // @@protoc_insertion_point(field_set_allocated:caffe.V1LayerParameter.eltwise_param) +} - // optional .caffe.ReLUParameter relu_param = 30; - if (has_relu_param()) { - total_size += 2 + - ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( - this->relu_param()); - } +// optional .caffe.ExpParameter exp_param = 41; +bool V1LayerParameter::has_exp_param() const { + return (_has_bits_[0] & 0x00200000u) != 0; +} +void V1LayerParameter::set_has_exp_param() { + _has_bits_[0] |= 0x00200000u; +} +void V1LayerParameter::clear_has_exp_param() { + _has_bits_[0] &= ~0x00200000u; +} +void V1LayerParameter::clear_exp_param() { + if (exp_param_ != NULL) exp_param_->::caffe::ExpParameter::Clear(); + clear_has_exp_param(); +} +const ::caffe::ExpParameter& V1LayerParameter::exp_param() const { + // @@protoc_insertion_point(field_get:caffe.V1LayerParameter.exp_param) + return exp_param_ != NULL ? *exp_param_ + : *::caffe::ExpParameter::internal_default_instance(); +} +::caffe::ExpParameter* V1LayerParameter::mutable_exp_param() { + set_has_exp_param(); + if (exp_param_ == NULL) { + exp_param_ = new ::caffe::ExpParameter; + } + // @@protoc_insertion_point(field_mutable:caffe.V1LayerParameter.exp_param) + return exp_param_; +} +::caffe::ExpParameter* V1LayerParameter::release_exp_param() { + // @@protoc_insertion_point(field_release:caffe.V1LayerParameter.exp_param) + clear_has_exp_param(); + ::caffe::ExpParameter* temp = exp_param_; + exp_param_ = NULL; + return temp; +} +void V1LayerParameter::set_allocated_exp_param(::caffe::ExpParameter* exp_param) { + delete exp_param_; + exp_param_ = exp_param; + if (exp_param) { + set_has_exp_param(); + } else { + clear_has_exp_param(); + } + // @@protoc_insertion_point(field_set_allocated:caffe.V1LayerParameter.exp_param) +} - // optional .caffe.SigmoidParameter sigmoid_param = 38; - if (has_sigmoid_param()) { - total_size += 2 + - ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( - this->sigmoid_param()); - } +// optional .caffe.HDF5DataParameter hdf5_data_param = 13; +bool V1LayerParameter::has_hdf5_data_param() const { + return (_has_bits_[0] & 0x00400000u) != 0; +} +void V1LayerParameter::set_has_hdf5_data_param() { + _has_bits_[0] |= 0x00400000u; +} +void V1LayerParameter::clear_has_hdf5_data_param() { + _has_bits_[0] &= ~0x00400000u; +} +void V1LayerParameter::clear_hdf5_data_param() { + if (hdf5_data_param_ != NULL) hdf5_data_param_->::caffe::HDF5DataParameter::Clear(); + clear_has_hdf5_data_param(); +} +const ::caffe::HDF5DataParameter& V1LayerParameter::hdf5_data_param() const { + // @@protoc_insertion_point(field_get:caffe.V1LayerParameter.hdf5_data_param) + return hdf5_data_param_ != NULL ? *hdf5_data_param_ + : *::caffe::HDF5DataParameter::internal_default_instance(); +} +::caffe::HDF5DataParameter* V1LayerParameter::mutable_hdf5_data_param() { + set_has_hdf5_data_param(); + if (hdf5_data_param_ == NULL) { + hdf5_data_param_ = new ::caffe::HDF5DataParameter; + } + // @@protoc_insertion_point(field_mutable:caffe.V1LayerParameter.hdf5_data_param) + return hdf5_data_param_; +} +::caffe::HDF5DataParameter* V1LayerParameter::release_hdf5_data_param() { + // @@protoc_insertion_point(field_release:caffe.V1LayerParameter.hdf5_data_param) + clear_has_hdf5_data_param(); + ::caffe::HDF5DataParameter* temp = hdf5_data_param_; + hdf5_data_param_ = NULL; + return temp; +} +void V1LayerParameter::set_allocated_hdf5_data_param(::caffe::HDF5DataParameter* hdf5_data_param) { + delete hdf5_data_param_; + hdf5_data_param_ = hdf5_data_param; + if (hdf5_data_param) { + set_has_hdf5_data_param(); + } else { + clear_has_hdf5_data_param(); + } + // @@protoc_insertion_point(field_set_allocated:caffe.V1LayerParameter.hdf5_data_param) +} - // optional .caffe.SoftmaxParameter softmax_param = 39; - if (has_softmax_param()) { - total_size += 2 + - ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( - this->softmax_param()); - } +// optional .caffe.HDF5OutputParameter hdf5_output_param = 14; +bool V1LayerParameter::has_hdf5_output_param() const { + return (_has_bits_[0] & 0x00800000u) != 0; +} +void V1LayerParameter::set_has_hdf5_output_param() { + _has_bits_[0] |= 0x00800000u; +} +void V1LayerParameter::clear_has_hdf5_output_param() { + _has_bits_[0] &= ~0x00800000u; +} +void V1LayerParameter::clear_hdf5_output_param() { + if (hdf5_output_param_ != NULL) hdf5_output_param_->::caffe::HDF5OutputParameter::Clear(); + clear_has_hdf5_output_param(); +} +const ::caffe::HDF5OutputParameter& V1LayerParameter::hdf5_output_param() const { + // @@protoc_insertion_point(field_get:caffe.V1LayerParameter.hdf5_output_param) + return hdf5_output_param_ != NULL ? *hdf5_output_param_ + : *::caffe::HDF5OutputParameter::internal_default_instance(); +} +::caffe::HDF5OutputParameter* V1LayerParameter::mutable_hdf5_output_param() { + set_has_hdf5_output_param(); + if (hdf5_output_param_ == NULL) { + hdf5_output_param_ = new ::caffe::HDF5OutputParameter; + } + // @@protoc_insertion_point(field_mutable:caffe.V1LayerParameter.hdf5_output_param) + return hdf5_output_param_; +} +::caffe::HDF5OutputParameter* V1LayerParameter::release_hdf5_output_param() { + // @@protoc_insertion_point(field_release:caffe.V1LayerParameter.hdf5_output_param) + clear_has_hdf5_output_param(); + ::caffe::HDF5OutputParameter* temp = hdf5_output_param_; + hdf5_output_param_ = NULL; + return temp; +} +void V1LayerParameter::set_allocated_hdf5_output_param(::caffe::HDF5OutputParameter* hdf5_output_param) { + delete hdf5_output_param_; + hdf5_output_param_ = hdf5_output_param; + if (hdf5_output_param) { + set_has_hdf5_output_param(); + } else { + clear_has_hdf5_output_param(); + } + // @@protoc_insertion_point(field_set_allocated:caffe.V1LayerParameter.hdf5_output_param) +} - // optional .caffe.SliceParameter slice_param = 31; - if (has_slice_param()) { - total_size += 2 + - ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( - this->slice_param()); - } +// optional .caffe.HingeLossParameter hinge_loss_param = 29; +bool V1LayerParameter::has_hinge_loss_param() const { + return (_has_bits_[0] & 0x01000000u) != 0; +} +void V1LayerParameter::set_has_hinge_loss_param() { + _has_bits_[0] |= 0x01000000u; +} +void V1LayerParameter::clear_has_hinge_loss_param() { + _has_bits_[0] &= ~0x01000000u; +} +void V1LayerParameter::clear_hinge_loss_param() { + if (hinge_loss_param_ != NULL) hinge_loss_param_->::caffe::HingeLossParameter::Clear(); + clear_has_hinge_loss_param(); +} +const ::caffe::HingeLossParameter& V1LayerParameter::hinge_loss_param() const { + // @@protoc_insertion_point(field_get:caffe.V1LayerParameter.hinge_loss_param) + return hinge_loss_param_ != NULL ? *hinge_loss_param_ + : *::caffe::HingeLossParameter::internal_default_instance(); +} +::caffe::HingeLossParameter* V1LayerParameter::mutable_hinge_loss_param() { + set_has_hinge_loss_param(); + if (hinge_loss_param_ == NULL) { + hinge_loss_param_ = new ::caffe::HingeLossParameter; + } + // @@protoc_insertion_point(field_mutable:caffe.V1LayerParameter.hinge_loss_param) + return hinge_loss_param_; +} +::caffe::HingeLossParameter* V1LayerParameter::release_hinge_loss_param() { + // @@protoc_insertion_point(field_release:caffe.V1LayerParameter.hinge_loss_param) + clear_has_hinge_loss_param(); + ::caffe::HingeLossParameter* temp = hinge_loss_param_; + hinge_loss_param_ = NULL; + return temp; +} +void V1LayerParameter::set_allocated_hinge_loss_param(::caffe::HingeLossParameter* hinge_loss_param) { + delete hinge_loss_param_; + hinge_loss_param_ = hinge_loss_param; + if (hinge_loss_param) { + set_has_hinge_loss_param(); + } else { + clear_has_hinge_loss_param(); + } + // @@protoc_insertion_point(field_set_allocated:caffe.V1LayerParameter.hinge_loss_param) +} - // optional .caffe.TanHParameter tanh_param = 37; - if (has_tanh_param()) { - total_size += 2 + - ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( - this->tanh_param()); - } +// optional .caffe.ImageDataParameter image_data_param = 15; +bool V1LayerParameter::has_image_data_param() const { + return (_has_bits_[0] & 0x02000000u) != 0; +} +void V1LayerParameter::set_has_image_data_param() { + _has_bits_[0] |= 0x02000000u; +} +void V1LayerParameter::clear_has_image_data_param() { + _has_bits_[0] &= ~0x02000000u; +} +void V1LayerParameter::clear_image_data_param() { + if (image_data_param_ != NULL) image_data_param_->::caffe::ImageDataParameter::Clear(); + clear_has_image_data_param(); +} +const ::caffe::ImageDataParameter& V1LayerParameter::image_data_param() const { + // @@protoc_insertion_point(field_get:caffe.V1LayerParameter.image_data_param) + return image_data_param_ != NULL ? *image_data_param_ + : *::caffe::ImageDataParameter::internal_default_instance(); +} +::caffe::ImageDataParameter* V1LayerParameter::mutable_image_data_param() { + set_has_image_data_param(); + if (image_data_param_ == NULL) { + image_data_param_ = new ::caffe::ImageDataParameter; + } + // @@protoc_insertion_point(field_mutable:caffe.V1LayerParameter.image_data_param) + return image_data_param_; +} +::caffe::ImageDataParameter* V1LayerParameter::release_image_data_param() { + // @@protoc_insertion_point(field_release:caffe.V1LayerParameter.image_data_param) + clear_has_image_data_param(); + ::caffe::ImageDataParameter* temp = image_data_param_; + image_data_param_ = NULL; + return temp; +} +void V1LayerParameter::set_allocated_image_data_param(::caffe::ImageDataParameter* image_data_param) { + delete image_data_param_; + image_data_param_ = image_data_param; + if (image_data_param) { + set_has_image_data_param(); + } else { + clear_has_image_data_param(); + } + // @@protoc_insertion_point(field_set_allocated:caffe.V1LayerParameter.image_data_param) +} - // optional .caffe.ThresholdParameter threshold_param = 25; - if (has_threshold_param()) { - total_size += 2 + - ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( - this->threshold_param()); - } +// optional .caffe.InfogainLossParameter infogain_loss_param = 16; +bool V1LayerParameter::has_infogain_loss_param() const { + return (_has_bits_[0] & 0x04000000u) != 0; +} +void V1LayerParameter::set_has_infogain_loss_param() { + _has_bits_[0] |= 0x04000000u; +} +void V1LayerParameter::clear_has_infogain_loss_param() { + _has_bits_[0] &= ~0x04000000u; +} +void V1LayerParameter::clear_infogain_loss_param() { + if (infogain_loss_param_ != NULL) infogain_loss_param_->::caffe::InfogainLossParameter::Clear(); + clear_has_infogain_loss_param(); +} +const ::caffe::InfogainLossParameter& V1LayerParameter::infogain_loss_param() const { + // @@protoc_insertion_point(field_get:caffe.V1LayerParameter.infogain_loss_param) + return infogain_loss_param_ != NULL ? *infogain_loss_param_ + : *::caffe::InfogainLossParameter::internal_default_instance(); +} +::caffe::InfogainLossParameter* V1LayerParameter::mutable_infogain_loss_param() { + set_has_infogain_loss_param(); + if (infogain_loss_param_ == NULL) { + infogain_loss_param_ = new ::caffe::InfogainLossParameter; + } + // @@protoc_insertion_point(field_mutable:caffe.V1LayerParameter.infogain_loss_param) + return infogain_loss_param_; +} +::caffe::InfogainLossParameter* V1LayerParameter::release_infogain_loss_param() { + // @@protoc_insertion_point(field_release:caffe.V1LayerParameter.infogain_loss_param) + clear_has_infogain_loss_param(); + ::caffe::InfogainLossParameter* temp = infogain_loss_param_; + infogain_loss_param_ = NULL; + return temp; +} +void V1LayerParameter::set_allocated_infogain_loss_param(::caffe::InfogainLossParameter* infogain_loss_param) { + delete infogain_loss_param_; + infogain_loss_param_ = infogain_loss_param; + if (infogain_loss_param) { + set_has_infogain_loss_param(); + } else { + clear_has_infogain_loss_param(); + } + // @@protoc_insertion_point(field_set_allocated:caffe.V1LayerParameter.infogain_loss_param) +} - // optional .caffe.WindowDataParameter window_data_param = 20; - if (has_window_data_param()) { - total_size += 2 + - ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( - this->window_data_param()); - } +// optional .caffe.InnerProductParameter inner_product_param = 17; +bool V1LayerParameter::has_inner_product_param() const { + return (_has_bits_[0] & 0x08000000u) != 0; +} +void V1LayerParameter::set_has_inner_product_param() { + _has_bits_[0] |= 0x08000000u; +} +void V1LayerParameter::clear_has_inner_product_param() { + _has_bits_[0] &= ~0x08000000u; +} +void V1LayerParameter::clear_inner_product_param() { + if (inner_product_param_ != NULL) inner_product_param_->::caffe::InnerProductParameter::Clear(); + clear_has_inner_product_param(); +} +const ::caffe::InnerProductParameter& V1LayerParameter::inner_product_param() const { + // @@protoc_insertion_point(field_get:caffe.V1LayerParameter.inner_product_param) + return inner_product_param_ != NULL ? *inner_product_param_ + : *::caffe::InnerProductParameter::internal_default_instance(); +} +::caffe::InnerProductParameter* V1LayerParameter::mutable_inner_product_param() { + set_has_inner_product_param(); + if (inner_product_param_ == NULL) { + inner_product_param_ = new ::caffe::InnerProductParameter; + } + // @@protoc_insertion_point(field_mutable:caffe.V1LayerParameter.inner_product_param) + return inner_product_param_; +} +::caffe::InnerProductParameter* V1LayerParameter::release_inner_product_param() { + // @@protoc_insertion_point(field_release:caffe.V1LayerParameter.inner_product_param) + clear_has_inner_product_param(); + ::caffe::InnerProductParameter* temp = inner_product_param_; + inner_product_param_ = NULL; + return temp; +} +void V1LayerParameter::set_allocated_inner_product_param(::caffe::InnerProductParameter* inner_product_param) { + delete inner_product_param_; + inner_product_param_ = inner_product_param; + if (inner_product_param) { + set_has_inner_product_param(); + } else { + clear_has_inner_product_param(); + } + // @@protoc_insertion_point(field_set_allocated:caffe.V1LayerParameter.inner_product_param) +} +// optional .caffe.LRNParameter lrn_param = 18; +bool V1LayerParameter::has_lrn_param() const { + return (_has_bits_[0] & 0x10000000u) != 0; +} +void V1LayerParameter::set_has_lrn_param() { + _has_bits_[0] |= 0x10000000u; +} +void V1LayerParameter::clear_has_lrn_param() { + _has_bits_[0] &= ~0x10000000u; +} +void V1LayerParameter::clear_lrn_param() { + if (lrn_param_ != NULL) lrn_param_->::caffe::LRNParameter::Clear(); + clear_has_lrn_param(); +} +const ::caffe::LRNParameter& V1LayerParameter::lrn_param() const { + // @@protoc_insertion_point(field_get:caffe.V1LayerParameter.lrn_param) + return lrn_param_ != NULL ? *lrn_param_ + : *::caffe::LRNParameter::internal_default_instance(); +} +::caffe::LRNParameter* V1LayerParameter::mutable_lrn_param() { + set_has_lrn_param(); + if (lrn_param_ == NULL) { + lrn_param_ = new ::caffe::LRNParameter; } - if (_has_bits_[40 / 32] & (0xffu << (40 % 32))) { - // optional .caffe.TransformationParameter transform_param = 36; - if (has_transform_param()) { - total_size += 2 + - ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( - this->transform_param()); - } + // @@protoc_insertion_point(field_mutable:caffe.V1LayerParameter.lrn_param) + return lrn_param_; +} +::caffe::LRNParameter* V1LayerParameter::release_lrn_param() { + // @@protoc_insertion_point(field_release:caffe.V1LayerParameter.lrn_param) + clear_has_lrn_param(); + ::caffe::LRNParameter* temp = lrn_param_; + lrn_param_ = NULL; + return temp; +} +void V1LayerParameter::set_allocated_lrn_param(::caffe::LRNParameter* lrn_param) { + delete lrn_param_; + lrn_param_ = lrn_param; + if (lrn_param) { + set_has_lrn_param(); + } else { + clear_has_lrn_param(); + } + // @@protoc_insertion_point(field_set_allocated:caffe.V1LayerParameter.lrn_param) +} - // optional .caffe.LossParameter loss_param = 42; - if (has_loss_param()) { - total_size += 2 + - ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( - this->loss_param()); - } +// optional .caffe.MemoryDataParameter memory_data_param = 22; +bool V1LayerParameter::has_memory_data_param() const { + return (_has_bits_[0] & 0x20000000u) != 0; +} +void V1LayerParameter::set_has_memory_data_param() { + _has_bits_[0] |= 0x20000000u; +} +void V1LayerParameter::clear_has_memory_data_param() { + _has_bits_[0] &= ~0x20000000u; +} +void V1LayerParameter::clear_memory_data_param() { + if (memory_data_param_ != NULL) memory_data_param_->::caffe::MemoryDataParameter::Clear(); + clear_has_memory_data_param(); +} +const ::caffe::MemoryDataParameter& V1LayerParameter::memory_data_param() const { + // @@protoc_insertion_point(field_get:caffe.V1LayerParameter.memory_data_param) + return memory_data_param_ != NULL ? *memory_data_param_ + : *::caffe::MemoryDataParameter::internal_default_instance(); +} +::caffe::MemoryDataParameter* V1LayerParameter::mutable_memory_data_param() { + set_has_memory_data_param(); + if (memory_data_param_ == NULL) { + memory_data_param_ = new ::caffe::MemoryDataParameter; + } + // @@protoc_insertion_point(field_mutable:caffe.V1LayerParameter.memory_data_param) + return memory_data_param_; +} +::caffe::MemoryDataParameter* V1LayerParameter::release_memory_data_param() { + // @@protoc_insertion_point(field_release:caffe.V1LayerParameter.memory_data_param) + clear_has_memory_data_param(); + ::caffe::MemoryDataParameter* temp = memory_data_param_; + memory_data_param_ = NULL; + return temp; +} +void V1LayerParameter::set_allocated_memory_data_param(::caffe::MemoryDataParameter* memory_data_param) { + delete memory_data_param_; + memory_data_param_ = memory_data_param; + if (memory_data_param) { + set_has_memory_data_param(); + } else { + clear_has_memory_data_param(); + } + // @@protoc_insertion_point(field_set_allocated:caffe.V1LayerParameter.memory_data_param) +} - // optional .caffe.V0LayerParameter layer = 1; - if (has_layer()) { - total_size += 1 + - ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( - this->layer()); - } +// optional .caffe.MVNParameter mvn_param = 34; +bool V1LayerParameter::has_mvn_param() const { + return (_has_bits_[0] & 0x40000000u) != 0; +} +void V1LayerParameter::set_has_mvn_param() { + _has_bits_[0] |= 0x40000000u; +} +void V1LayerParameter::clear_has_mvn_param() { + _has_bits_[0] &= ~0x40000000u; +} +void V1LayerParameter::clear_mvn_param() { + if (mvn_param_ != NULL) mvn_param_->::caffe::MVNParameter::Clear(); + clear_has_mvn_param(); +} +const ::caffe::MVNParameter& V1LayerParameter::mvn_param() const { + // @@protoc_insertion_point(field_get:caffe.V1LayerParameter.mvn_param) + return mvn_param_ != NULL ? *mvn_param_ + : *::caffe::MVNParameter::internal_default_instance(); +} +::caffe::MVNParameter* V1LayerParameter::mutable_mvn_param() { + set_has_mvn_param(); + if (mvn_param_ == NULL) { + mvn_param_ = new ::caffe::MVNParameter; + } + // @@protoc_insertion_point(field_mutable:caffe.V1LayerParameter.mvn_param) + return mvn_param_; +} +::caffe::MVNParameter* V1LayerParameter::release_mvn_param() { + // @@protoc_insertion_point(field_release:caffe.V1LayerParameter.mvn_param) + clear_has_mvn_param(); + ::caffe::MVNParameter* temp = mvn_param_; + mvn_param_ = NULL; + return temp; +} +void V1LayerParameter::set_allocated_mvn_param(::caffe::MVNParameter* mvn_param) { + delete mvn_param_; + mvn_param_ = mvn_param; + if (mvn_param) { + set_has_mvn_param(); + } else { + clear_has_mvn_param(); + } + // @@protoc_insertion_point(field_set_allocated:caffe.V1LayerParameter.mvn_param) +} + +// optional .caffe.PoolingParameter pooling_param = 19; +bool V1LayerParameter::has_pooling_param() const { + return (_has_bits_[0] & 0x80000000u) != 0; +} +void V1LayerParameter::set_has_pooling_param() { + _has_bits_[0] |= 0x80000000u; +} +void V1LayerParameter::clear_has_pooling_param() { + _has_bits_[0] &= ~0x80000000u; +} +void V1LayerParameter::clear_pooling_param() { + if (pooling_param_ != NULL) pooling_param_->::caffe::PoolingParameter::Clear(); + clear_has_pooling_param(); +} +const ::caffe::PoolingParameter& V1LayerParameter::pooling_param() const { + // @@protoc_insertion_point(field_get:caffe.V1LayerParameter.pooling_param) + return pooling_param_ != NULL ? *pooling_param_ + : *::caffe::PoolingParameter::internal_default_instance(); +} +::caffe::PoolingParameter* V1LayerParameter::mutable_pooling_param() { + set_has_pooling_param(); + if (pooling_param_ == NULL) { + pooling_param_ = new ::caffe::PoolingParameter; + } + // @@protoc_insertion_point(field_mutable:caffe.V1LayerParameter.pooling_param) + return pooling_param_; +} +::caffe::PoolingParameter* V1LayerParameter::release_pooling_param() { + // @@protoc_insertion_point(field_release:caffe.V1LayerParameter.pooling_param) + clear_has_pooling_param(); + ::caffe::PoolingParameter* temp = pooling_param_; + pooling_param_ = NULL; + return temp; +} +void V1LayerParameter::set_allocated_pooling_param(::caffe::PoolingParameter* pooling_param) { + delete pooling_param_; + pooling_param_ = pooling_param; + if (pooling_param) { + set_has_pooling_param(); + } else { + clear_has_pooling_param(); + } + // @@protoc_insertion_point(field_set_allocated:caffe.V1LayerParameter.pooling_param) +} +// optional .caffe.PowerParameter power_param = 21; +bool V1LayerParameter::has_power_param() const { + return (_has_bits_[1] & 0x00000001u) != 0; +} +void V1LayerParameter::set_has_power_param() { + _has_bits_[1] |= 0x00000001u; +} +void V1LayerParameter::clear_has_power_param() { + _has_bits_[1] &= ~0x00000001u; +} +void V1LayerParameter::clear_power_param() { + if (power_param_ != NULL) power_param_->::caffe::PowerParameter::Clear(); + clear_has_power_param(); +} +const ::caffe::PowerParameter& V1LayerParameter::power_param() const { + // @@protoc_insertion_point(field_get:caffe.V1LayerParameter.power_param) + return power_param_ != NULL ? *power_param_ + : *::caffe::PowerParameter::internal_default_instance(); +} +::caffe::PowerParameter* V1LayerParameter::mutable_power_param() { + set_has_power_param(); + if (power_param_ == NULL) { + power_param_ = new ::caffe::PowerParameter; } - // repeated string bottom = 2; - total_size += 1 * this->bottom_size(); - for (int i = 0; i < this->bottom_size(); i++) { - total_size += ::google::protobuf::internal::WireFormatLite::StringSize( - this->bottom(i)); + // @@protoc_insertion_point(field_mutable:caffe.V1LayerParameter.power_param) + return power_param_; +} +::caffe::PowerParameter* V1LayerParameter::release_power_param() { + // @@protoc_insertion_point(field_release:caffe.V1LayerParameter.power_param) + clear_has_power_param(); + ::caffe::PowerParameter* temp = power_param_; + power_param_ = NULL; + return temp; +} +void V1LayerParameter::set_allocated_power_param(::caffe::PowerParameter* power_param) { + delete power_param_; + power_param_ = power_param; + if (power_param) { + set_has_power_param(); + } else { + clear_has_power_param(); } + // @@protoc_insertion_point(field_set_allocated:caffe.V1LayerParameter.power_param) +} - // repeated string top = 3; - total_size += 1 * this->top_size(); - for (int i = 0; i < this->top_size(); i++) { - total_size += ::google::protobuf::internal::WireFormatLite::StringSize( - this->top(i)); +// optional .caffe.ReLUParameter relu_param = 30; +bool V1LayerParameter::has_relu_param() const { + return (_has_bits_[1] & 0x00000002u) != 0; +} +void V1LayerParameter::set_has_relu_param() { + _has_bits_[1] |= 0x00000002u; +} +void V1LayerParameter::clear_has_relu_param() { + _has_bits_[1] &= ~0x00000002u; +} +void V1LayerParameter::clear_relu_param() { + if (relu_param_ != NULL) relu_param_->::caffe::ReLUParameter::Clear(); + clear_has_relu_param(); +} +const ::caffe::ReLUParameter& V1LayerParameter::relu_param() const { + // @@protoc_insertion_point(field_get:caffe.V1LayerParameter.relu_param) + return relu_param_ != NULL ? *relu_param_ + : *::caffe::ReLUParameter::internal_default_instance(); +} +::caffe::ReLUParameter* V1LayerParameter::mutable_relu_param() { + set_has_relu_param(); + if (relu_param_ == NULL) { + relu_param_ = new ::caffe::ReLUParameter; + } + // @@protoc_insertion_point(field_mutable:caffe.V1LayerParameter.relu_param) + return relu_param_; +} +::caffe::ReLUParameter* V1LayerParameter::release_relu_param() { + // @@protoc_insertion_point(field_release:caffe.V1LayerParameter.relu_param) + clear_has_relu_param(); + ::caffe::ReLUParameter* temp = relu_param_; + relu_param_ = NULL; + return temp; +} +void V1LayerParameter::set_allocated_relu_param(::caffe::ReLUParameter* relu_param) { + delete relu_param_; + relu_param_ = relu_param; + if (relu_param) { + set_has_relu_param(); + } else { + clear_has_relu_param(); } + // @@protoc_insertion_point(field_set_allocated:caffe.V1LayerParameter.relu_param) +} - // repeated .caffe.NetStateRule include = 32; - total_size += 2 * this->include_size(); - for (int i = 0; i < this->include_size(); i++) { - total_size += - ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( - this->include(i)); +// optional .caffe.SigmoidParameter sigmoid_param = 38; +bool V1LayerParameter::has_sigmoid_param() const { + return (_has_bits_[1] & 0x00000004u) != 0; +} +void V1LayerParameter::set_has_sigmoid_param() { + _has_bits_[1] |= 0x00000004u; +} +void V1LayerParameter::clear_has_sigmoid_param() { + _has_bits_[1] &= ~0x00000004u; +} +void V1LayerParameter::clear_sigmoid_param() { + if (sigmoid_param_ != NULL) sigmoid_param_->::caffe::SigmoidParameter::Clear(); + clear_has_sigmoid_param(); +} +const ::caffe::SigmoidParameter& V1LayerParameter::sigmoid_param() const { + // @@protoc_insertion_point(field_get:caffe.V1LayerParameter.sigmoid_param) + return sigmoid_param_ != NULL ? *sigmoid_param_ + : *::caffe::SigmoidParameter::internal_default_instance(); +} +::caffe::SigmoidParameter* V1LayerParameter::mutable_sigmoid_param() { + set_has_sigmoid_param(); + if (sigmoid_param_ == NULL) { + sigmoid_param_ = new ::caffe::SigmoidParameter; + } + // @@protoc_insertion_point(field_mutable:caffe.V1LayerParameter.sigmoid_param) + return sigmoid_param_; +} +::caffe::SigmoidParameter* V1LayerParameter::release_sigmoid_param() { + // @@protoc_insertion_point(field_release:caffe.V1LayerParameter.sigmoid_param) + clear_has_sigmoid_param(); + ::caffe::SigmoidParameter* temp = sigmoid_param_; + sigmoid_param_ = NULL; + return temp; +} +void V1LayerParameter::set_allocated_sigmoid_param(::caffe::SigmoidParameter* sigmoid_param) { + delete sigmoid_param_; + sigmoid_param_ = sigmoid_param; + if (sigmoid_param) { + set_has_sigmoid_param(); + } else { + clear_has_sigmoid_param(); } + // @@protoc_insertion_point(field_set_allocated:caffe.V1LayerParameter.sigmoid_param) +} - // repeated .caffe.NetStateRule exclude = 33; - total_size += 2 * this->exclude_size(); - for (int i = 0; i < this->exclude_size(); i++) { - total_size += - ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( - this->exclude(i)); +// optional .caffe.SoftmaxParameter softmax_param = 39; +bool V1LayerParameter::has_softmax_param() const { + return (_has_bits_[1] & 0x00000008u) != 0; +} +void V1LayerParameter::set_has_softmax_param() { + _has_bits_[1] |= 0x00000008u; +} +void V1LayerParameter::clear_has_softmax_param() { + _has_bits_[1] &= ~0x00000008u; +} +void V1LayerParameter::clear_softmax_param() { + if (softmax_param_ != NULL) softmax_param_->::caffe::SoftmaxParameter::Clear(); + clear_has_softmax_param(); +} +const ::caffe::SoftmaxParameter& V1LayerParameter::softmax_param() const { + // @@protoc_insertion_point(field_get:caffe.V1LayerParameter.softmax_param) + return softmax_param_ != NULL ? *softmax_param_ + : *::caffe::SoftmaxParameter::internal_default_instance(); +} +::caffe::SoftmaxParameter* V1LayerParameter::mutable_softmax_param() { + set_has_softmax_param(); + if (softmax_param_ == NULL) { + softmax_param_ = new ::caffe::SoftmaxParameter; + } + // @@protoc_insertion_point(field_mutable:caffe.V1LayerParameter.softmax_param) + return softmax_param_; +} +::caffe::SoftmaxParameter* V1LayerParameter::release_softmax_param() { + // @@protoc_insertion_point(field_release:caffe.V1LayerParameter.softmax_param) + clear_has_softmax_param(); + ::caffe::SoftmaxParameter* temp = softmax_param_; + softmax_param_ = NULL; + return temp; +} +void V1LayerParameter::set_allocated_softmax_param(::caffe::SoftmaxParameter* softmax_param) { + delete softmax_param_; + softmax_param_ = softmax_param; + if (softmax_param) { + set_has_softmax_param(); + } else { + clear_has_softmax_param(); } + // @@protoc_insertion_point(field_set_allocated:caffe.V1LayerParameter.softmax_param) +} - // repeated .caffe.BlobProto blobs = 6; - total_size += 1 * this->blobs_size(); - for (int i = 0; i < this->blobs_size(); i++) { - total_size += - ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( - this->blobs(i)); +// optional .caffe.SliceParameter slice_param = 31; +bool V1LayerParameter::has_slice_param() const { + return (_has_bits_[1] & 0x00000010u) != 0; +} +void V1LayerParameter::set_has_slice_param() { + _has_bits_[1] |= 0x00000010u; +} +void V1LayerParameter::clear_has_slice_param() { + _has_bits_[1] &= ~0x00000010u; +} +void V1LayerParameter::clear_slice_param() { + if (slice_param_ != NULL) slice_param_->::caffe::SliceParameter::Clear(); + clear_has_slice_param(); +} +const ::caffe::SliceParameter& V1LayerParameter::slice_param() const { + // @@protoc_insertion_point(field_get:caffe.V1LayerParameter.slice_param) + return slice_param_ != NULL ? *slice_param_ + : *::caffe::SliceParameter::internal_default_instance(); +} +::caffe::SliceParameter* V1LayerParameter::mutable_slice_param() { + set_has_slice_param(); + if (slice_param_ == NULL) { + slice_param_ = new ::caffe::SliceParameter; } - - // repeated string param = 1001; - total_size += 2 * this->param_size(); - for (int i = 0; i < this->param_size(); i++) { - total_size += ::google::protobuf::internal::WireFormatLite::StringSize( - this->param(i)); + // @@protoc_insertion_point(field_mutable:caffe.V1LayerParameter.slice_param) + return slice_param_; +} +::caffe::SliceParameter* V1LayerParameter::release_slice_param() { + // @@protoc_insertion_point(field_release:caffe.V1LayerParameter.slice_param) + clear_has_slice_param(); + ::caffe::SliceParameter* temp = slice_param_; + slice_param_ = NULL; + return temp; +} +void V1LayerParameter::set_allocated_slice_param(::caffe::SliceParameter* slice_param) { + delete slice_param_; + slice_param_ = slice_param; + if (slice_param) { + set_has_slice_param(); + } else { + clear_has_slice_param(); } + // @@protoc_insertion_point(field_set_allocated:caffe.V1LayerParameter.slice_param) +} - // repeated .caffe.V1LayerParameter.DimCheckMode blob_share_mode = 1002; - { - int data_size = 0; - for (int i = 0; i < this->blob_share_mode_size(); i++) { - data_size += ::google::protobuf::internal::WireFormatLite::EnumSize( - this->blob_share_mode(i)); - } - total_size += 2 * this->blob_share_mode_size() + data_size; +// optional .caffe.TanHParameter tanh_param = 37; +bool V1LayerParameter::has_tanh_param() const { + return (_has_bits_[1] & 0x00000020u) != 0; +} +void V1LayerParameter::set_has_tanh_param() { + _has_bits_[1] |= 0x00000020u; +} +void V1LayerParameter::clear_has_tanh_param() { + _has_bits_[1] &= ~0x00000020u; +} +void V1LayerParameter::clear_tanh_param() { + if (tanh_param_ != NULL) tanh_param_->::caffe::TanHParameter::Clear(); + clear_has_tanh_param(); +} +const ::caffe::TanHParameter& V1LayerParameter::tanh_param() const { + // @@protoc_insertion_point(field_get:caffe.V1LayerParameter.tanh_param) + return tanh_param_ != NULL ? *tanh_param_ + : *::caffe::TanHParameter::internal_default_instance(); +} +::caffe::TanHParameter* V1LayerParameter::mutable_tanh_param() { + set_has_tanh_param(); + if (tanh_param_ == NULL) { + tanh_param_ = new ::caffe::TanHParameter; } - - // repeated float blobs_lr = 7; - { - int data_size = 0; - data_size = 4 * this->blobs_lr_size(); - total_size += 1 * this->blobs_lr_size() + data_size; + // @@protoc_insertion_point(field_mutable:caffe.V1LayerParameter.tanh_param) + return tanh_param_; +} +::caffe::TanHParameter* V1LayerParameter::release_tanh_param() { + // @@protoc_insertion_point(field_release:caffe.V1LayerParameter.tanh_param) + clear_has_tanh_param(); + ::caffe::TanHParameter* temp = tanh_param_; + tanh_param_ = NULL; + return temp; +} +void V1LayerParameter::set_allocated_tanh_param(::caffe::TanHParameter* tanh_param) { + delete tanh_param_; + tanh_param_ = tanh_param; + if (tanh_param) { + set_has_tanh_param(); + } else { + clear_has_tanh_param(); } + // @@protoc_insertion_point(field_set_allocated:caffe.V1LayerParameter.tanh_param) +} - // repeated float weight_decay = 8; - { - int data_size = 0; - data_size = 4 * this->weight_decay_size(); - total_size += 1 * this->weight_decay_size() + data_size; +// optional .caffe.ThresholdParameter threshold_param = 25; +bool V1LayerParameter::has_threshold_param() const { + return (_has_bits_[1] & 0x00000040u) != 0; +} +void V1LayerParameter::set_has_threshold_param() { + _has_bits_[1] |= 0x00000040u; +} +void V1LayerParameter::clear_has_threshold_param() { + _has_bits_[1] &= ~0x00000040u; +} +void V1LayerParameter::clear_threshold_param() { + if (threshold_param_ != NULL) threshold_param_->::caffe::ThresholdParameter::Clear(); + clear_has_threshold_param(); +} +const ::caffe::ThresholdParameter& V1LayerParameter::threshold_param() const { + // @@protoc_insertion_point(field_get:caffe.V1LayerParameter.threshold_param) + return threshold_param_ != NULL ? *threshold_param_ + : *::caffe::ThresholdParameter::internal_default_instance(); +} +::caffe::ThresholdParameter* V1LayerParameter::mutable_threshold_param() { + set_has_threshold_param(); + if (threshold_param_ == NULL) { + threshold_param_ = new ::caffe::ThresholdParameter; } - - // repeated float loss_weight = 35; - { - int data_size = 0; - data_size = 4 * this->loss_weight_size(); - total_size += 2 * this->loss_weight_size() + data_size; + // @@protoc_insertion_point(field_mutable:caffe.V1LayerParameter.threshold_param) + return threshold_param_; +} +::caffe::ThresholdParameter* V1LayerParameter::release_threshold_param() { + // @@protoc_insertion_point(field_release:caffe.V1LayerParameter.threshold_param) + clear_has_threshold_param(); + ::caffe::ThresholdParameter* temp = threshold_param_; + threshold_param_ = NULL; + return temp; +} +void V1LayerParameter::set_allocated_threshold_param(::caffe::ThresholdParameter* threshold_param) { + delete threshold_param_; + threshold_param_ = threshold_param; + if (threshold_param) { + set_has_threshold_param(); + } else { + clear_has_threshold_param(); } + // @@protoc_insertion_point(field_set_allocated:caffe.V1LayerParameter.threshold_param) +} - if (!unknown_fields().empty()) { - total_size += - ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( - unknown_fields()); +// optional .caffe.WindowDataParameter window_data_param = 20; +bool V1LayerParameter::has_window_data_param() const { + return (_has_bits_[1] & 0x00000080u) != 0; +} +void V1LayerParameter::set_has_window_data_param() { + _has_bits_[1] |= 0x00000080u; +} +void V1LayerParameter::clear_has_window_data_param() { + _has_bits_[1] &= ~0x00000080u; +} +void V1LayerParameter::clear_window_data_param() { + if (window_data_param_ != NULL) window_data_param_->::caffe::WindowDataParameter::Clear(); + clear_has_window_data_param(); +} +const ::caffe::WindowDataParameter& V1LayerParameter::window_data_param() const { + // @@protoc_insertion_point(field_get:caffe.V1LayerParameter.window_data_param) + return window_data_param_ != NULL ? *window_data_param_ + : *::caffe::WindowDataParameter::internal_default_instance(); +} +::caffe::WindowDataParameter* V1LayerParameter::mutable_window_data_param() { + set_has_window_data_param(); + if (window_data_param_ == NULL) { + window_data_param_ = new ::caffe::WindowDataParameter; } - GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); - _cached_size_ = total_size; - GOOGLE_SAFE_CONCURRENT_WRITES_END(); - return total_size; + // @@protoc_insertion_point(field_mutable:caffe.V1LayerParameter.window_data_param) + return window_data_param_; } - -void V1LayerParameter::MergeFrom(const ::google::protobuf::Message& from) { - GOOGLE_CHECK_NE(&from, this); - const V1LayerParameter* source = - ::google::protobuf::internal::dynamic_cast_if_available( - &from); - if (source == NULL) { - ::google::protobuf::internal::ReflectionOps::Merge(from, this); +::caffe::WindowDataParameter* V1LayerParameter::release_window_data_param() { + // @@protoc_insertion_point(field_release:caffe.V1LayerParameter.window_data_param) + clear_has_window_data_param(); + ::caffe::WindowDataParameter* temp = window_data_param_; + window_data_param_ = NULL; + return temp; +} +void V1LayerParameter::set_allocated_window_data_param(::caffe::WindowDataParameter* window_data_param) { + delete window_data_param_; + window_data_param_ = window_data_param; + if (window_data_param) { + set_has_window_data_param(); } else { - MergeFrom(*source); + clear_has_window_data_param(); } + // @@protoc_insertion_point(field_set_allocated:caffe.V1LayerParameter.window_data_param) } -void V1LayerParameter::MergeFrom(const V1LayerParameter& from) { - GOOGLE_CHECK_NE(&from, this); - bottom_.MergeFrom(from.bottom_); - top_.MergeFrom(from.top_); - include_.MergeFrom(from.include_); - exclude_.MergeFrom(from.exclude_); - blobs_.MergeFrom(from.blobs_); - param_.MergeFrom(from.param_); - blob_share_mode_.MergeFrom(from.blob_share_mode_); - blobs_lr_.MergeFrom(from.blobs_lr_); - weight_decay_.MergeFrom(from.weight_decay_); - loss_weight_.MergeFrom(from.loss_weight_); - if (from._has_bits_[2 / 32] & (0xffu << (2 % 32))) { - if (from.has_name()) { - set_name(from.name()); - } - if (from.has_type()) { - set_type(from.type()); - } - } - if (from._has_bits_[12 / 32] & (0xffu << (12 % 32))) { - if (from.has_accuracy_param()) { - mutable_accuracy_param()->::caffe::AccuracyParameter::MergeFrom(from.accuracy_param()); - } - if (from.has_argmax_param()) { - mutable_argmax_param()->::caffe::ArgMaxParameter::MergeFrom(from.argmax_param()); - } - if (from.has_concat_param()) { - mutable_concat_param()->::caffe::ConcatParameter::MergeFrom(from.concat_param()); - } - if (from.has_contrastive_loss_param()) { - mutable_contrastive_loss_param()->::caffe::ContrastiveLossParameter::MergeFrom(from.contrastive_loss_param()); - } - } - if (from._has_bits_[16 / 32] & (0xffu << (16 % 32))) { - if (from.has_convolution_param()) { - mutable_convolution_param()->::caffe::ConvolutionParameter::MergeFrom(from.convolution_param()); - } - if (from.has_data_param()) { - mutable_data_param()->::caffe::DataParameter::MergeFrom(from.data_param()); - } - if (from.has_dropout_param()) { - mutable_dropout_param()->::caffe::DropoutParameter::MergeFrom(from.dropout_param()); - } - if (from.has_dummy_data_param()) { - mutable_dummy_data_param()->::caffe::DummyDataParameter::MergeFrom(from.dummy_data_param()); - } - if (from.has_eltwise_param()) { - mutable_eltwise_param()->::caffe::EltwiseParameter::MergeFrom(from.eltwise_param()); - } - if (from.has_exp_param()) { - mutable_exp_param()->::caffe::ExpParameter::MergeFrom(from.exp_param()); - } - if (from.has_hdf5_data_param()) { - mutable_hdf5_data_param()->::caffe::HDF5DataParameter::MergeFrom(from.hdf5_data_param()); - } - if (from.has_hdf5_output_param()) { - mutable_hdf5_output_param()->::caffe::HDF5OutputParameter::MergeFrom(from.hdf5_output_param()); - } +// optional .caffe.TransformationParameter transform_param = 36; +bool V1LayerParameter::has_transform_param() const { + return (_has_bits_[1] & 0x00000100u) != 0; +} +void V1LayerParameter::set_has_transform_param() { + _has_bits_[1] |= 0x00000100u; +} +void V1LayerParameter::clear_has_transform_param() { + _has_bits_[1] &= ~0x00000100u; +} +void V1LayerParameter::clear_transform_param() { + if (transform_param_ != NULL) transform_param_->::caffe::TransformationParameter::Clear(); + clear_has_transform_param(); +} +const ::caffe::TransformationParameter& V1LayerParameter::transform_param() const { + // @@protoc_insertion_point(field_get:caffe.V1LayerParameter.transform_param) + return transform_param_ != NULL ? *transform_param_ + : *::caffe::TransformationParameter::internal_default_instance(); +} +::caffe::TransformationParameter* V1LayerParameter::mutable_transform_param() { + set_has_transform_param(); + if (transform_param_ == NULL) { + transform_param_ = new ::caffe::TransformationParameter; } - if (from._has_bits_[24 / 32] & (0xffu << (24 % 32))) { - if (from.has_hinge_loss_param()) { - mutable_hinge_loss_param()->::caffe::HingeLossParameter::MergeFrom(from.hinge_loss_param()); - } - if (from.has_image_data_param()) { - mutable_image_data_param()->::caffe::ImageDataParameter::MergeFrom(from.image_data_param()); - } - if (from.has_infogain_loss_param()) { - mutable_infogain_loss_param()->::caffe::InfogainLossParameter::MergeFrom(from.infogain_loss_param()); - } - if (from.has_inner_product_param()) { - mutable_inner_product_param()->::caffe::InnerProductParameter::MergeFrom(from.inner_product_param()); - } - if (from.has_lrn_param()) { - mutable_lrn_param()->::caffe::LRNParameter::MergeFrom(from.lrn_param()); - } - if (from.has_memory_data_param()) { - mutable_memory_data_param()->::caffe::MemoryDataParameter::MergeFrom(from.memory_data_param()); - } - if (from.has_mvn_param()) { - mutable_mvn_param()->::caffe::MVNParameter::MergeFrom(from.mvn_param()); - } - if (from.has_pooling_param()) { - mutable_pooling_param()->::caffe::PoolingParameter::MergeFrom(from.pooling_param()); - } + // @@protoc_insertion_point(field_mutable:caffe.V1LayerParameter.transform_param) + return transform_param_; +} +::caffe::TransformationParameter* V1LayerParameter::release_transform_param() { + // @@protoc_insertion_point(field_release:caffe.V1LayerParameter.transform_param) + clear_has_transform_param(); + ::caffe::TransformationParameter* temp = transform_param_; + transform_param_ = NULL; + return temp; +} +void V1LayerParameter::set_allocated_transform_param(::caffe::TransformationParameter* transform_param) { + delete transform_param_; + transform_param_ = transform_param; + if (transform_param) { + set_has_transform_param(); + } else { + clear_has_transform_param(); } - if (from._has_bits_[32 / 32] & (0xffu << (32 % 32))) { - if (from.has_power_param()) { - mutable_power_param()->::caffe::PowerParameter::MergeFrom(from.power_param()); - } - if (from.has_relu_param()) { - mutable_relu_param()->::caffe::ReLUParameter::MergeFrom(from.relu_param()); - } - if (from.has_sigmoid_param()) { - mutable_sigmoid_param()->::caffe::SigmoidParameter::MergeFrom(from.sigmoid_param()); - } - if (from.has_softmax_param()) { - mutable_softmax_param()->::caffe::SoftmaxParameter::MergeFrom(from.softmax_param()); - } - if (from.has_slice_param()) { - mutable_slice_param()->::caffe::SliceParameter::MergeFrom(from.slice_param()); - } - if (from.has_tanh_param()) { - mutable_tanh_param()->::caffe::TanHParameter::MergeFrom(from.tanh_param()); - } - if (from.has_threshold_param()) { - mutable_threshold_param()->::caffe::ThresholdParameter::MergeFrom(from.threshold_param()); - } - if (from.has_window_data_param()) { - mutable_window_data_param()->::caffe::WindowDataParameter::MergeFrom(from.window_data_param()); - } + // @@protoc_insertion_point(field_set_allocated:caffe.V1LayerParameter.transform_param) +} + +// optional .caffe.LossParameter loss_param = 42; +bool V1LayerParameter::has_loss_param() const { + return (_has_bits_[1] & 0x00000200u) != 0; +} +void V1LayerParameter::set_has_loss_param() { + _has_bits_[1] |= 0x00000200u; +} +void V1LayerParameter::clear_has_loss_param() { + _has_bits_[1] &= ~0x00000200u; +} +void V1LayerParameter::clear_loss_param() { + if (loss_param_ != NULL) loss_param_->::caffe::LossParameter::Clear(); + clear_has_loss_param(); +} +const ::caffe::LossParameter& V1LayerParameter::loss_param() const { + // @@protoc_insertion_point(field_get:caffe.V1LayerParameter.loss_param) + return loss_param_ != NULL ? *loss_param_ + : *::caffe::LossParameter::internal_default_instance(); +} +::caffe::LossParameter* V1LayerParameter::mutable_loss_param() { + set_has_loss_param(); + if (loss_param_ == NULL) { + loss_param_ = new ::caffe::LossParameter; } - if (from._has_bits_[40 / 32] & (0xffu << (40 % 32))) { - if (from.has_transform_param()) { - mutable_transform_param()->::caffe::TransformationParameter::MergeFrom(from.transform_param()); - } - if (from.has_loss_param()) { - mutable_loss_param()->::caffe::LossParameter::MergeFrom(from.loss_param()); - } - if (from.has_layer()) { - mutable_layer()->::caffe::V0LayerParameter::MergeFrom(from.layer()); - } + // @@protoc_insertion_point(field_mutable:caffe.V1LayerParameter.loss_param) + return loss_param_; +} +::caffe::LossParameter* V1LayerParameter::release_loss_param() { + // @@protoc_insertion_point(field_release:caffe.V1LayerParameter.loss_param) + clear_has_loss_param(); + ::caffe::LossParameter* temp = loss_param_; + loss_param_ = NULL; + return temp; +} +void V1LayerParameter::set_allocated_loss_param(::caffe::LossParameter* loss_param) { + delete loss_param_; + loss_param_ = loss_param; + if (loss_param) { + set_has_loss_param(); + } else { + clear_has_loss_param(); } - mutable_unknown_fields()->MergeFrom(from.unknown_fields()); + // @@protoc_insertion_point(field_set_allocated:caffe.V1LayerParameter.loss_param) } -void V1LayerParameter::CopyFrom(const ::google::protobuf::Message& from) { - if (&from == this) return; - Clear(); - MergeFrom(from); +// optional .caffe.V0LayerParameter layer = 1; +bool V1LayerParameter::has_layer() const { + return (_has_bits_[1] & 0x00000400u) != 0; } - -void V1LayerParameter::CopyFrom(const V1LayerParameter& from) { - if (&from == this) return; - Clear(); - MergeFrom(from); +void V1LayerParameter::set_has_layer() { + _has_bits_[1] |= 0x00000400u; } - -bool V1LayerParameter::IsInitialized() const { - - return true; +void V1LayerParameter::clear_has_layer() { + _has_bits_[1] &= ~0x00000400u; } - -void V1LayerParameter::Swap(V1LayerParameter* other) { - if (other != this) { - bottom_.Swap(&other->bottom_); - top_.Swap(&other->top_); - std::swap(name_, other->name_); - include_.Swap(&other->include_); - exclude_.Swap(&other->exclude_); - std::swap(type_, other->type_); - blobs_.Swap(&other->blobs_); - param_.Swap(&other->param_); - blob_share_mode_.Swap(&other->blob_share_mode_); - blobs_lr_.Swap(&other->blobs_lr_); - weight_decay_.Swap(&other->weight_decay_); - loss_weight_.Swap(&other->loss_weight_); - std::swap(accuracy_param_, other->accuracy_param_); - std::swap(argmax_param_, other->argmax_param_); - std::swap(concat_param_, other->concat_param_); - std::swap(contrastive_loss_param_, other->contrastive_loss_param_); - std::swap(convolution_param_, other->convolution_param_); - std::swap(data_param_, other->data_param_); - std::swap(dropout_param_, other->dropout_param_); - std::swap(dummy_data_param_, other->dummy_data_param_); - std::swap(eltwise_param_, other->eltwise_param_); - std::swap(exp_param_, other->exp_param_); - std::swap(hdf5_data_param_, other->hdf5_data_param_); - std::swap(hdf5_output_param_, other->hdf5_output_param_); - std::swap(hinge_loss_param_, other->hinge_loss_param_); - std::swap(image_data_param_, other->image_data_param_); - std::swap(infogain_loss_param_, other->infogain_loss_param_); - std::swap(inner_product_param_, other->inner_product_param_); - std::swap(lrn_param_, other->lrn_param_); - std::swap(memory_data_param_, other->memory_data_param_); - std::swap(mvn_param_, other->mvn_param_); - std::swap(pooling_param_, other->pooling_param_); - std::swap(power_param_, other->power_param_); - std::swap(relu_param_, other->relu_param_); - std::swap(sigmoid_param_, other->sigmoid_param_); - std::swap(softmax_param_, other->softmax_param_); - std::swap(slice_param_, other->slice_param_); - std::swap(tanh_param_, other->tanh_param_); - std::swap(threshold_param_, other->threshold_param_); - std::swap(window_data_param_, other->window_data_param_); - std::swap(transform_param_, other->transform_param_); - std::swap(loss_param_, other->loss_param_); - std::swap(layer_, other->layer_); - std::swap(_has_bits_[0], other->_has_bits_[0]); - std::swap(_has_bits_[1], other->_has_bits_[1]); - _unknown_fields_.Swap(&other->_unknown_fields_); - std::swap(_cached_size_, other->_cached_size_); +void V1LayerParameter::clear_layer() { + if (layer_ != NULL) layer_->::caffe::V0LayerParameter::Clear(); + clear_has_layer(); +} +const ::caffe::V0LayerParameter& V1LayerParameter::layer() const { + // @@protoc_insertion_point(field_get:caffe.V1LayerParameter.layer) + return layer_ != NULL ? *layer_ + : *::caffe::V0LayerParameter::internal_default_instance(); +} +::caffe::V0LayerParameter* V1LayerParameter::mutable_layer() { + set_has_layer(); + if (layer_ == NULL) { + layer_ = new ::caffe::V0LayerParameter; } + // @@protoc_insertion_point(field_mutable:caffe.V1LayerParameter.layer) + return layer_; } - -::google::protobuf::Metadata V1LayerParameter::GetMetadata() const { - protobuf_AssignDescriptorsOnce(); - ::google::protobuf::Metadata metadata; - metadata.descriptor = V1LayerParameter_descriptor_; - metadata.reflection = V1LayerParameter_reflection_; - return metadata; +::caffe::V0LayerParameter* V1LayerParameter::release_layer() { + // @@protoc_insertion_point(field_release:caffe.V1LayerParameter.layer) + clear_has_layer(); + ::caffe::V0LayerParameter* temp = layer_; + layer_ = NULL; + return temp; +} +void V1LayerParameter::set_allocated_layer(::caffe::V0LayerParameter* layer) { + delete layer_; + layer_ = layer; + if (layer) { + set_has_layer(); + } else { + clear_has_layer(); + } + // @@protoc_insertion_point(field_set_allocated:caffe.V1LayerParameter.layer) } +inline const V1LayerParameter* V1LayerParameter::internal_default_instance() { + return &V1LayerParameter_default_instance_.get(); +} +#endif // PROTOBUF_INLINE_NOT_IN_HEADERS // =================================================================== @@ -27118,7 +41591,7 @@ const ::google::protobuf::EnumDescriptor* V0LayerParameter_PoolMethod_descriptor return V0LayerParameter_PoolMethod_descriptor_; } bool V0LayerParameter_PoolMethod_IsValid(int value) { - switch(value) { + switch (value) { case 0: case 1: case 2: @@ -27128,16 +41601,16 @@ bool V0LayerParameter_PoolMethod_IsValid(int value) { } } -#ifndef _MSC_VER +#if !defined(_MSC_VER) || _MSC_VER >= 1900 const V0LayerParameter_PoolMethod V0LayerParameter::MAX; const V0LayerParameter_PoolMethod V0LayerParameter::AVE; const V0LayerParameter_PoolMethod V0LayerParameter::STOCHASTIC; const V0LayerParameter_PoolMethod V0LayerParameter::PoolMethod_MIN; const V0LayerParameter_PoolMethod V0LayerParameter::PoolMethod_MAX; const int V0LayerParameter::PoolMethod_ARRAYSIZE; -#endif // _MSC_VER +#endif // !defined(_MSC_VER) || _MSC_VER >= 1900 ::std::string* V0LayerParameter::_default_det_crop_mode_ = NULL; -#ifndef _MSC_VER +#if !defined(_MSC_VER) || _MSC_VER >= 1900 const int V0LayerParameter::kNameFieldNumber; const int V0LayerParameter::kTypeFieldNumber; const int V0LayerParameter::kNumOutputFieldNumber; @@ -27176,86 +41649,71 @@ const int V0LayerParameter::kNewWidthFieldNumber; const int V0LayerParameter::kShuffleImagesFieldNumber; const int V0LayerParameter::kConcatDimFieldNumber; const int V0LayerParameter::kHdf5OutputParamFieldNumber; -#endif // !_MSC_VER +#endif // !defined(_MSC_VER) || _MSC_VER >= 1900 V0LayerParameter::V0LayerParameter() - : ::google::protobuf::Message() { + : ::google::protobuf::Message(), _internal_metadata_(NULL) { + if (this != internal_default_instance()) protobuf_InitDefaults_caffe_2eproto(); SharedCtor(); + // @@protoc_insertion_point(constructor:caffe.V0LayerParameter) } void V0LayerParameter::InitAsDefaultInstance() { - weight_filler_ = const_cast< ::caffe::FillerParameter*>(&::caffe::FillerParameter::default_instance()); - bias_filler_ = const_cast< ::caffe::FillerParameter*>(&::caffe::FillerParameter::default_instance()); - hdf5_output_param_ = const_cast< ::caffe::HDF5OutputParameter*>(&::caffe::HDF5OutputParameter::default_instance()); + weight_filler_ = const_cast< ::caffe::FillerParameter*>( + ::caffe::FillerParameter::internal_default_instance()); + bias_filler_ = const_cast< ::caffe::FillerParameter*>( + ::caffe::FillerParameter::internal_default_instance()); + hdf5_output_param_ = const_cast< ::caffe::HDF5OutputParameter*>( + ::caffe::HDF5OutputParameter::internal_default_instance()); } V0LayerParameter::V0LayerParameter(const V0LayerParameter& from) - : ::google::protobuf::Message() { + : ::google::protobuf::Message(), + _internal_metadata_(NULL) { SharedCtor(); - MergeFrom(from); + UnsafeMergeFrom(from); + // @@protoc_insertion_point(copy_constructor:caffe.V0LayerParameter) } void V0LayerParameter::SharedCtor() { - _cached_size_ = 0; - name_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); - type_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); - num_output_ = 0u; - biasterm_ = true; + name_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + type_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + source_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + meanfile_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + det_crop_mode_.UnsafeSetDefault(_default_det_crop_mode_); weight_filler_ = NULL; bias_filler_ = NULL; - pad_ = 0u; - kernelsize_ = 0u; + hdf5_output_param_ = NULL; + ::memset(&num_output_, 0, reinterpret_cast(&new_width_) - + reinterpret_cast(&num_output_) + sizeof(new_width_)); + concat_dim_ = 1u; + biasterm_ = true; group_ = 1u; stride_ = 1u; - pool_ = 0; dropout_ratio_ = 0.5f; local_size_ = 5u; alpha_ = 1; beta_ = 0.75f; - k_ = 1; - source_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); - scale_ = 1; - meanfile_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); - batchsize_ = 0u; - cropsize_ = 0u; - mirror_ = false; - rand_skip_ = 0u; - det_fg_threshold_ = 0.5f; - det_bg_threshold_ = 0.5f; - det_fg_fraction_ = 0.25f; - det_context_pad_ = 0u; - det_crop_mode_ = const_cast< ::std::string*>(_default_det_crop_mode_); - new_num_ = 0; - new_channels_ = 0; - new_height_ = 0; - new_width_ = 0; - shuffle_images_ = false; - concat_dim_ = 1u; - hdf5_output_param_ = NULL; - ::memset(_has_bits_, 0, sizeof(_has_bits_)); + k_ = 1; + scale_ = 1; + det_fg_threshold_ = 0.5f; + det_bg_threshold_ = 0.5f; + det_fg_fraction_ = 0.25f; + _cached_size_ = 0; } V0LayerParameter::~V0LayerParameter() { + // @@protoc_insertion_point(destructor:caffe.V0LayerParameter) SharedDtor(); } void V0LayerParameter::SharedDtor() { - if (name_ != &::google::protobuf::internal::kEmptyString) { - delete name_; - } - if (type_ != &::google::protobuf::internal::kEmptyString) { - delete type_; - } - if (source_ != &::google::protobuf::internal::kEmptyString) { - delete source_; - } - if (meanfile_ != &::google::protobuf::internal::kEmptyString) { - delete meanfile_; - } - if (det_crop_mode_ != _default_det_crop_mode_) { - delete det_crop_mode_; - } - if (this != default_instance_) { + name_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + type_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + source_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + meanfile_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + det_crop_mode_.DestroyNoArena(_default_det_crop_mode_); + if (this != &V0LayerParameter_default_instance_.get()) { delete weight_filler_; delete bias_filler_; delete hdf5_output_param_; @@ -27273,29 +41731,46 @@ const ::google::protobuf::Descriptor* V0LayerParameter::descriptor() { } const V0LayerParameter& V0LayerParameter::default_instance() { - if (default_instance_ == NULL) protobuf_AddDesc_caffe_2eproto(); - return *default_instance_; + protobuf_InitDefaults_caffe_2eproto(); + return *internal_default_instance(); } -V0LayerParameter* V0LayerParameter::default_instance_ = NULL; +::google::protobuf::internal::ExplicitlyConstructed V0LayerParameter_default_instance_; -V0LayerParameter* V0LayerParameter::New() const { - return new V0LayerParameter; +V0LayerParameter* V0LayerParameter::New(::google::protobuf::Arena* arena) const { + V0LayerParameter* n = new V0LayerParameter; + if (arena != NULL) { + arena->Own(n); + } + return n; } void V0LayerParameter::Clear() { - if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) { +// @@protoc_insertion_point(message_clear_start:caffe.V0LayerParameter) +#if defined(__clang__) +#define ZR_HELPER_(f) \ + _Pragma("clang diagnostic push") \ + _Pragma("clang diagnostic ignored \"-Winvalid-offsetof\"") \ + __builtin_offsetof(V0LayerParameter, f) \ + _Pragma("clang diagnostic pop") +#else +#define ZR_HELPER_(f) reinterpret_cast(\ + &reinterpret_cast(16)->f) +#endif + +#define ZR_(first, last) do {\ + ::memset(&(first), 0,\ + ZR_HELPER_(last) - ZR_HELPER_(first) + sizeof(last));\ +} while (0) + + if (_has_bits_[0 / 32] & 255u) { + ZR_(num_output_, kernelsize_); if (has_name()) { - if (name_ != &::google::protobuf::internal::kEmptyString) { - name_->clear(); - } + name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } if (has_type()) { - if (type_ != &::google::protobuf::internal::kEmptyString) { - type_->clear(); - } + type_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - num_output_ = 0u; biasterm_ = true; if (has_weight_filler()) { if (weight_filler_ != NULL) weight_filler_->::caffe::FillerParameter::Clear(); @@ -27303,10 +41778,8 @@ void V0LayerParameter::Clear() { if (has_bias_filler()) { if (bias_filler_ != NULL) bias_filler_->::caffe::FillerParameter::Clear(); } - pad_ = 0u; - kernelsize_ = 0u; } - if (_has_bits_[8 / 32] & (0xffu << (8 % 32))) { + if (_has_bits_[8 / 32] & 65280u) { group_ = 1u; stride_ = 1u; pool_ = 0; @@ -27316,69 +41789,69 @@ void V0LayerParameter::Clear() { beta_ = 0.75f; k_ = 1; } - if (_has_bits_[16 / 32] & (0xffu << (16 % 32))) { + if (_has_bits_[16 / 32] & 4128768u) { + ZR_(batchsize_, cropsize_); if (has_source()) { - if (source_ != &::google::protobuf::internal::kEmptyString) { - source_->clear(); - } + source_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } scale_ = 1; if (has_meanfile()) { - if (meanfile_ != &::google::protobuf::internal::kEmptyString) { - meanfile_->clear(); - } + meanfile_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } - batchsize_ = 0u; - cropsize_ = 0u; mirror_ = false; } - if (_has_bits_[25 / 32] & (0xffu << (25 % 32))) { + if (_has_bits_[24 / 32] & 4261412864u) { + ZR_(det_context_pad_, new_num_); rand_skip_ = 0u; det_fg_threshold_ = 0.5f; det_bg_threshold_ = 0.5f; det_fg_fraction_ = 0.25f; - det_context_pad_ = 0u; if (has_det_crop_mode()) { - if (det_crop_mode_ != _default_det_crop_mode_) { - det_crop_mode_->assign(*_default_det_crop_mode_); - } + det_crop_mode_.ClearToDefaultNoArena(_default_det_crop_mode_); } - new_num_ = 0; } - if (_has_bits_[32 / 32] & (0xffu << (32 % 32))) { - new_channels_ = 0; - new_height_ = 0; - new_width_ = 0; + if (_has_bits_[32 / 32] & 63u) { + ZR_(new_channels_, new_width_); shuffle_images_ = false; concat_dim_ = 1u; if (has_hdf5_output_param()) { if (hdf5_output_param_ != NULL) hdf5_output_param_->::caffe::HDF5OutputParameter::Clear(); } } + +#undef ZR_HELPER_ +#undef ZR_ + blobs_.Clear(); blobs_lr_.Clear(); weight_decay_.Clear(); - ::memset(_has_bits_, 0, sizeof(_has_bits_)); - mutable_unknown_fields()->Clear(); + _has_bits_.Clear(); + if (_internal_metadata_.have_unknown_fields()) { + mutable_unknown_fields()->Clear(); + } } bool V0LayerParameter::MergePartialFromCodedStream( ::google::protobuf::io::CodedInputStream* input) { -#define DO_(EXPRESSION) if (!(EXPRESSION)) return false +#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure ::google::protobuf::uint32 tag; - while ((tag = input->ReadTag()) != 0) { + // @@protoc_insertion_point(parse_start:caffe.V0LayerParameter) + for (;;) { + ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(16383); + tag = p.first; + if (!p.second) goto handle_unusual; switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { // optional string name = 1; case 1: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) { + if (tag == 10) { DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->mutable_name())); - ::google::protobuf::internal::WireFormat::VerifyUTF8String( + ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( this->name().data(), this->name().length(), - ::google::protobuf::internal::WireFormat::PARSE); + ::google::protobuf::internal::WireFormat::PARSE, + "caffe.V0LayerParameter.name"); } else { - goto handle_uninterpreted; + goto handle_unusual; } if (input->ExpectTag(18)) goto parse_type; break; @@ -27386,16 +41859,16 @@ bool V0LayerParameter::MergePartialFromCodedStream( // optional string type = 2; case 2: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) { + if (tag == 18) { parse_type: DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->mutable_type())); - ::google::protobuf::internal::WireFormat::VerifyUTF8String( + ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( this->type().data(), this->type().length(), - ::google::protobuf::internal::WireFormat::PARSE); + ::google::protobuf::internal::WireFormat::PARSE, + "caffe.V0LayerParameter.type"); } else { - goto handle_uninterpreted; + goto handle_unusual; } if (input->ExpectTag(24)) goto parse_num_output; break; @@ -27403,15 +41876,14 @@ bool V0LayerParameter::MergePartialFromCodedStream( // optional uint32 num_output = 3; case 3: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) { + if (tag == 24) { parse_num_output: + set_has_num_output(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>( input, &num_output_))); - set_has_num_output(); } else { - goto handle_uninterpreted; + goto handle_unusual; } if (input->ExpectTag(32)) goto parse_biasterm; break; @@ -27419,15 +41891,14 @@ bool V0LayerParameter::MergePartialFromCodedStream( // optional bool biasterm = 4 [default = true]; case 4: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) { + if (tag == 32) { parse_biasterm: + set_has_biasterm(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>( input, &biasterm_))); - set_has_biasterm(); } else { - goto handle_uninterpreted; + goto handle_unusual; } if (input->ExpectTag(42)) goto parse_weight_filler; break; @@ -27435,13 +41906,12 @@ bool V0LayerParameter::MergePartialFromCodedStream( // optional .caffe.FillerParameter weight_filler = 5; case 5: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) { + if (tag == 42) { parse_weight_filler: DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual( input, mutable_weight_filler())); } else { - goto handle_uninterpreted; + goto handle_unusual; } if (input->ExpectTag(50)) goto parse_bias_filler; break; @@ -27449,13 +41919,12 @@ bool V0LayerParameter::MergePartialFromCodedStream( // optional .caffe.FillerParameter bias_filler = 6; case 6: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) { + if (tag == 50) { parse_bias_filler: DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual( input, mutable_bias_filler())); } else { - goto handle_uninterpreted; + goto handle_unusual; } if (input->ExpectTag(56)) goto parse_pad; break; @@ -27463,15 +41932,14 @@ bool V0LayerParameter::MergePartialFromCodedStream( // optional uint32 pad = 7 [default = 0]; case 7: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) { + if (tag == 56) { parse_pad: + set_has_pad(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>( input, &pad_))); - set_has_pad(); } else { - goto handle_uninterpreted; + goto handle_unusual; } if (input->ExpectTag(64)) goto parse_kernelsize; break; @@ -27479,15 +41947,14 @@ bool V0LayerParameter::MergePartialFromCodedStream( // optional uint32 kernelsize = 8; case 8: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) { + if (tag == 64) { parse_kernelsize: + set_has_kernelsize(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>( input, &kernelsize_))); - set_has_kernelsize(); } else { - goto handle_uninterpreted; + goto handle_unusual; } if (input->ExpectTag(72)) goto parse_group; break; @@ -27495,15 +41962,14 @@ bool V0LayerParameter::MergePartialFromCodedStream( // optional uint32 group = 9 [default = 1]; case 9: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) { + if (tag == 72) { parse_group: + set_has_group(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>( input, &group_))); - set_has_group(); } else { - goto handle_uninterpreted; + goto handle_unusual; } if (input->ExpectTag(80)) goto parse_stride; break; @@ -27511,15 +41977,14 @@ bool V0LayerParameter::MergePartialFromCodedStream( // optional uint32 stride = 10 [default = 1]; case 10: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) { + if (tag == 80) { parse_stride: + set_has_stride(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>( input, &stride_))); - set_has_stride(); } else { - goto handle_uninterpreted; + goto handle_unusual; } if (input->ExpectTag(88)) goto parse_pool; break; @@ -27527,8 +41992,7 @@ bool V0LayerParameter::MergePartialFromCodedStream( // optional .caffe.V0LayerParameter.PoolMethod pool = 11 [default = MAX]; case 11: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) { + if (tag == 88) { parse_pool: int value; DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< @@ -27540,7 +42004,7 @@ bool V0LayerParameter::MergePartialFromCodedStream( mutable_unknown_fields()->AddVarint(11, value); } } else { - goto handle_uninterpreted; + goto handle_unusual; } if (input->ExpectTag(101)) goto parse_dropout_ratio; break; @@ -27548,15 +42012,14 @@ bool V0LayerParameter::MergePartialFromCodedStream( // optional float dropout_ratio = 12 [default = 0.5]; case 12: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_FIXED32) { + if (tag == 101) { parse_dropout_ratio: + set_has_dropout_ratio(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< float, ::google::protobuf::internal::WireFormatLite::TYPE_FLOAT>( input, &dropout_ratio_))); - set_has_dropout_ratio(); } else { - goto handle_uninterpreted; + goto handle_unusual; } if (input->ExpectTag(104)) goto parse_local_size; break; @@ -27564,15 +42027,14 @@ bool V0LayerParameter::MergePartialFromCodedStream( // optional uint32 local_size = 13 [default = 5]; case 13: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) { + if (tag == 104) { parse_local_size: + set_has_local_size(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>( input, &local_size_))); - set_has_local_size(); } else { - goto handle_uninterpreted; + goto handle_unusual; } if (input->ExpectTag(117)) goto parse_alpha; break; @@ -27580,15 +42042,14 @@ bool V0LayerParameter::MergePartialFromCodedStream( // optional float alpha = 14 [default = 1]; case 14: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_FIXED32) { + if (tag == 117) { parse_alpha: + set_has_alpha(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< float, ::google::protobuf::internal::WireFormatLite::TYPE_FLOAT>( input, &alpha_))); - set_has_alpha(); } else { - goto handle_uninterpreted; + goto handle_unusual; } if (input->ExpectTag(125)) goto parse_beta; break; @@ -27596,15 +42057,14 @@ bool V0LayerParameter::MergePartialFromCodedStream( // optional float beta = 15 [default = 0.75]; case 15: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_FIXED32) { + if (tag == 125) { parse_beta: + set_has_beta(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< float, ::google::protobuf::internal::WireFormatLite::TYPE_FLOAT>( input, &beta_))); - set_has_beta(); } else { - goto handle_uninterpreted; + goto handle_unusual; } if (input->ExpectTag(130)) goto parse_source; break; @@ -27612,16 +42072,16 @@ bool V0LayerParameter::MergePartialFromCodedStream( // optional string source = 16; case 16: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) { + if (tag == 130) { parse_source: DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->mutable_source())); - ::google::protobuf::internal::WireFormat::VerifyUTF8String( + ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( this->source().data(), this->source().length(), - ::google::protobuf::internal::WireFormat::PARSE); + ::google::protobuf::internal::WireFormat::PARSE, + "caffe.V0LayerParameter.source"); } else { - goto handle_uninterpreted; + goto handle_unusual; } if (input->ExpectTag(141)) goto parse_scale; break; @@ -27629,15 +42089,14 @@ bool V0LayerParameter::MergePartialFromCodedStream( // optional float scale = 17 [default = 1]; case 17: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_FIXED32) { + if (tag == 141) { parse_scale: + set_has_scale(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< float, ::google::protobuf::internal::WireFormatLite::TYPE_FLOAT>( input, &scale_))); - set_has_scale(); } else { - goto handle_uninterpreted; + goto handle_unusual; } if (input->ExpectTag(146)) goto parse_meanfile; break; @@ -27645,16 +42104,16 @@ bool V0LayerParameter::MergePartialFromCodedStream( // optional string meanfile = 18; case 18: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) { + if (tag == 146) { parse_meanfile: DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->mutable_meanfile())); - ::google::protobuf::internal::WireFormat::VerifyUTF8String( + ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( this->meanfile().data(), this->meanfile().length(), - ::google::protobuf::internal::WireFormat::PARSE); + ::google::protobuf::internal::WireFormat::PARSE, + "caffe.V0LayerParameter.meanfile"); } else { - goto handle_uninterpreted; + goto handle_unusual; } if (input->ExpectTag(152)) goto parse_batchsize; break; @@ -27662,15 +42121,14 @@ bool V0LayerParameter::MergePartialFromCodedStream( // optional uint32 batchsize = 19; case 19: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) { + if (tag == 152) { parse_batchsize: + set_has_batchsize(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>( input, &batchsize_))); - set_has_batchsize(); } else { - goto handle_uninterpreted; + goto handle_unusual; } if (input->ExpectTag(160)) goto parse_cropsize; break; @@ -27678,15 +42136,14 @@ bool V0LayerParameter::MergePartialFromCodedStream( // optional uint32 cropsize = 20 [default = 0]; case 20: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) { + if (tag == 160) { parse_cropsize: + set_has_cropsize(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>( input, &cropsize_))); - set_has_cropsize(); } else { - goto handle_uninterpreted; + goto handle_unusual; } if (input->ExpectTag(168)) goto parse_mirror; break; @@ -27694,15 +42151,14 @@ bool V0LayerParameter::MergePartialFromCodedStream( // optional bool mirror = 21 [default = false]; case 21: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) { + if (tag == 168) { parse_mirror: + set_has_mirror(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>( input, &mirror_))); - set_has_mirror(); } else { - goto handle_uninterpreted; + goto handle_unusual; } if (input->ExpectTag(181)) goto parse_k; break; @@ -27710,15 +42166,14 @@ bool V0LayerParameter::MergePartialFromCodedStream( // optional float k = 22 [default = 1]; case 22: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_FIXED32) { + if (tag == 181) { parse_k: + set_has_k(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< float, ::google::protobuf::internal::WireFormatLite::TYPE_FLOAT>( input, &k_))); - set_has_k(); } else { - goto handle_uninterpreted; + goto handle_unusual; } if (input->ExpectTag(402)) goto parse_blobs; break; @@ -27726,35 +42181,34 @@ bool V0LayerParameter::MergePartialFromCodedStream( // repeated .caffe.BlobProto blobs = 50; case 50: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) { + if (tag == 402) { parse_blobs: - DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual( + DO_(input->IncrementRecursionDepth()); + parse_loop_blobs: + DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtualNoRecursionDepth( input, add_blobs())); } else { - goto handle_uninterpreted; + goto handle_unusual; } - if (input->ExpectTag(402)) goto parse_blobs; + if (input->ExpectTag(402)) goto parse_loop_blobs; + input->UnsafeDecrementRecursionDepth(); if (input->ExpectTag(413)) goto parse_blobs_lr; break; } // repeated float blobs_lr = 51; case 51: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_FIXED32) { + if (tag == 413) { parse_blobs_lr: DO_((::google::protobuf::internal::WireFormatLite::ReadRepeatedPrimitive< float, ::google::protobuf::internal::WireFormatLite::TYPE_FLOAT>( 2, 413, input, this->mutable_blobs_lr()))); - } else if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) - == ::google::protobuf::internal::WireFormatLite:: - WIRETYPE_LENGTH_DELIMITED) { + } else if (tag == 410) { DO_((::google::protobuf::internal::WireFormatLite::ReadPackedPrimitiveNoInline< float, ::google::protobuf::internal::WireFormatLite::TYPE_FLOAT>( input, this->mutable_blobs_lr()))); } else { - goto handle_uninterpreted; + goto handle_unusual; } if (input->ExpectTag(413)) goto parse_blobs_lr; if (input->ExpectTag(421)) goto parse_weight_decay; @@ -27763,20 +42217,17 @@ bool V0LayerParameter::MergePartialFromCodedStream( // repeated float weight_decay = 52; case 52: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_FIXED32) { + if (tag == 421) { parse_weight_decay: DO_((::google::protobuf::internal::WireFormatLite::ReadRepeatedPrimitive< float, ::google::protobuf::internal::WireFormatLite::TYPE_FLOAT>( 2, 421, input, this->mutable_weight_decay()))); - } else if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) - == ::google::protobuf::internal::WireFormatLite:: - WIRETYPE_LENGTH_DELIMITED) { + } else if (tag == 418) { DO_((::google::protobuf::internal::WireFormatLite::ReadPackedPrimitiveNoInline< float, ::google::protobuf::internal::WireFormatLite::TYPE_FLOAT>( input, this->mutable_weight_decay()))); } else { - goto handle_uninterpreted; + goto handle_unusual; } if (input->ExpectTag(421)) goto parse_weight_decay; if (input->ExpectTag(424)) goto parse_rand_skip; @@ -27785,15 +42236,14 @@ bool V0LayerParameter::MergePartialFromCodedStream( // optional uint32 rand_skip = 53 [default = 0]; case 53: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) { + if (tag == 424) { parse_rand_skip: + set_has_rand_skip(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>( input, &rand_skip_))); - set_has_rand_skip(); } else { - goto handle_uninterpreted; + goto handle_unusual; } if (input->ExpectTag(437)) goto parse_det_fg_threshold; break; @@ -27801,15 +42251,14 @@ bool V0LayerParameter::MergePartialFromCodedStream( // optional float det_fg_threshold = 54 [default = 0.5]; case 54: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_FIXED32) { + if (tag == 437) { parse_det_fg_threshold: + set_has_det_fg_threshold(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< float, ::google::protobuf::internal::WireFormatLite::TYPE_FLOAT>( input, &det_fg_threshold_))); - set_has_det_fg_threshold(); } else { - goto handle_uninterpreted; + goto handle_unusual; } if (input->ExpectTag(445)) goto parse_det_bg_threshold; break; @@ -27817,15 +42266,14 @@ bool V0LayerParameter::MergePartialFromCodedStream( // optional float det_bg_threshold = 55 [default = 0.5]; case 55: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_FIXED32) { + if (tag == 445) { parse_det_bg_threshold: + set_has_det_bg_threshold(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< float, ::google::protobuf::internal::WireFormatLite::TYPE_FLOAT>( input, &det_bg_threshold_))); - set_has_det_bg_threshold(); } else { - goto handle_uninterpreted; + goto handle_unusual; } if (input->ExpectTag(453)) goto parse_det_fg_fraction; break; @@ -27833,15 +42281,14 @@ bool V0LayerParameter::MergePartialFromCodedStream( // optional float det_fg_fraction = 56 [default = 0.25]; case 56: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_FIXED32) { + if (tag == 453) { parse_det_fg_fraction: + set_has_det_fg_fraction(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< float, ::google::protobuf::internal::WireFormatLite::TYPE_FLOAT>( input, &det_fg_fraction_))); - set_has_det_fg_fraction(); } else { - goto handle_uninterpreted; + goto handle_unusual; } if (input->ExpectTag(464)) goto parse_det_context_pad; break; @@ -27849,15 +42296,14 @@ bool V0LayerParameter::MergePartialFromCodedStream( // optional uint32 det_context_pad = 58 [default = 0]; case 58: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) { + if (tag == 464) { parse_det_context_pad: + set_has_det_context_pad(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>( input, &det_context_pad_))); - set_has_det_context_pad(); } else { - goto handle_uninterpreted; + goto handle_unusual; } if (input->ExpectTag(474)) goto parse_det_crop_mode; break; @@ -27865,16 +42311,16 @@ bool V0LayerParameter::MergePartialFromCodedStream( // optional string det_crop_mode = 59 [default = "warp"]; case 59: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) { + if (tag == 474) { parse_det_crop_mode: DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->mutable_det_crop_mode())); - ::google::protobuf::internal::WireFormat::VerifyUTF8String( + ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( this->det_crop_mode().data(), this->det_crop_mode().length(), - ::google::protobuf::internal::WireFormat::PARSE); + ::google::protobuf::internal::WireFormat::PARSE, + "caffe.V0LayerParameter.det_crop_mode"); } else { - goto handle_uninterpreted; + goto handle_unusual; } if (input->ExpectTag(480)) goto parse_new_num; break; @@ -27882,15 +42328,14 @@ bool V0LayerParameter::MergePartialFromCodedStream( // optional int32 new_num = 60 [default = 0]; case 60: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) { + if (tag == 480) { parse_new_num: + set_has_new_num(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>( input, &new_num_))); - set_has_new_num(); } else { - goto handle_uninterpreted; + goto handle_unusual; } if (input->ExpectTag(488)) goto parse_new_channels; break; @@ -27898,15 +42343,14 @@ bool V0LayerParameter::MergePartialFromCodedStream( // optional int32 new_channels = 61 [default = 0]; case 61: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) { + if (tag == 488) { parse_new_channels: + set_has_new_channels(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>( input, &new_channels_))); - set_has_new_channels(); } else { - goto handle_uninterpreted; + goto handle_unusual; } if (input->ExpectTag(496)) goto parse_new_height; break; @@ -27914,15 +42358,14 @@ bool V0LayerParameter::MergePartialFromCodedStream( // optional int32 new_height = 62 [default = 0]; case 62: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) { + if (tag == 496) { parse_new_height: + set_has_new_height(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>( input, &new_height_))); - set_has_new_height(); } else { - goto handle_uninterpreted; + goto handle_unusual; } if (input->ExpectTag(504)) goto parse_new_width; break; @@ -27930,15 +42373,14 @@ bool V0LayerParameter::MergePartialFromCodedStream( // optional int32 new_width = 63 [default = 0]; case 63: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) { + if (tag == 504) { parse_new_width: + set_has_new_width(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>( input, &new_width_))); - set_has_new_width(); } else { - goto handle_uninterpreted; + goto handle_unusual; } if (input->ExpectTag(512)) goto parse_shuffle_images; break; @@ -27946,15 +42388,14 @@ bool V0LayerParameter::MergePartialFromCodedStream( // optional bool shuffle_images = 64 [default = false]; case 64: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) { + if (tag == 512) { parse_shuffle_images: + set_has_shuffle_images(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>( input, &shuffle_images_))); - set_has_shuffle_images(); } else { - goto handle_uninterpreted; + goto handle_unusual; } if (input->ExpectTag(520)) goto parse_concat_dim; break; @@ -27962,15 +42403,14 @@ bool V0LayerParameter::MergePartialFromCodedStream( // optional uint32 concat_dim = 65 [default = 1]; case 65: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) { + if (tag == 520) { parse_concat_dim: + set_has_concat_dim(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>( input, &concat_dim_))); - set_has_concat_dim(); } else { - goto handle_uninterpreted; + goto handle_unusual; } if (input->ExpectTag(8010)) goto parse_hdf5_output_param; break; @@ -27978,23 +42418,23 @@ bool V0LayerParameter::MergePartialFromCodedStream( // optional .caffe.HDF5OutputParameter hdf5_output_param = 1001; case 1001: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) { + if (tag == 8010) { parse_hdf5_output_param: DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual( input, mutable_hdf5_output_param())); } else { - goto handle_uninterpreted; + goto handle_unusual; } - if (input->ExpectAtEnd()) return true; + if (input->ExpectAtEnd()) goto success; break; } default: { - handle_uninterpreted: - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == + handle_unusual: + if (tag == 0 || + ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) { - return true; + goto success; } DO_(::google::protobuf::internal::WireFormat::SkipField( input, tag, mutable_unknown_fields())); @@ -28002,27 +42442,35 @@ bool V0LayerParameter::MergePartialFromCodedStream( } } } +success: + // @@protoc_insertion_point(parse_success:caffe.V0LayerParameter) return true; +failure: + // @@protoc_insertion_point(parse_failure:caffe.V0LayerParameter) + return false; #undef DO_ } void V0LayerParameter::SerializeWithCachedSizes( ::google::protobuf::io::CodedOutputStream* output) const { + // @@protoc_insertion_point(serialize_start:caffe.V0LayerParameter) // optional string name = 1; if (has_name()) { - ::google::protobuf::internal::WireFormat::VerifyUTF8String( + ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( this->name().data(), this->name().length(), - ::google::protobuf::internal::WireFormat::SERIALIZE); - ::google::protobuf::internal::WireFormatLite::WriteString( + ::google::protobuf::internal::WireFormat::SERIALIZE, + "caffe.V0LayerParameter.name"); + ::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased( 1, this->name(), output); } // optional string type = 2; if (has_type()) { - ::google::protobuf::internal::WireFormat::VerifyUTF8String( + ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( this->type().data(), this->type().length(), - ::google::protobuf::internal::WireFormat::SERIALIZE); - ::google::protobuf::internal::WireFormatLite::WriteString( + ::google::protobuf::internal::WireFormat::SERIALIZE, + "caffe.V0LayerParameter.type"); + ::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased( 2, this->type(), output); } @@ -28039,13 +42487,13 @@ void V0LayerParameter::SerializeWithCachedSizes( // optional .caffe.FillerParameter weight_filler = 5; if (has_weight_filler()) { ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( - 5, this->weight_filler(), output); + 5, *this->weight_filler_, output); } // optional .caffe.FillerParameter bias_filler = 6; if (has_bias_filler()) { ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( - 6, this->bias_filler(), output); + 6, *this->bias_filler_, output); } // optional uint32 pad = 7 [default = 0]; @@ -28096,10 +42544,11 @@ void V0LayerParameter::SerializeWithCachedSizes( // optional string source = 16; if (has_source()) { - ::google::protobuf::internal::WireFormat::VerifyUTF8String( + ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( this->source().data(), this->source().length(), - ::google::protobuf::internal::WireFormat::SERIALIZE); - ::google::protobuf::internal::WireFormatLite::WriteString( + ::google::protobuf::internal::WireFormat::SERIALIZE, + "caffe.V0LayerParameter.source"); + ::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased( 16, this->source(), output); } @@ -28110,10 +42559,11 @@ void V0LayerParameter::SerializeWithCachedSizes( // optional string meanfile = 18; if (has_meanfile()) { - ::google::protobuf::internal::WireFormat::VerifyUTF8String( + ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( this->meanfile().data(), this->meanfile().length(), - ::google::protobuf::internal::WireFormat::SERIALIZE); - ::google::protobuf::internal::WireFormatLite::WriteString( + ::google::protobuf::internal::WireFormat::SERIALIZE, + "caffe.V0LayerParameter.meanfile"); + ::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased( 18, this->meanfile(), output); } @@ -28138,7 +42588,7 @@ void V0LayerParameter::SerializeWithCachedSizes( } // repeated .caffe.BlobProto blobs = 50; - for (int i = 0; i < this->blobs_size(); i++) { + for (unsigned int i = 0, n = this->blobs_size(); i < n; i++) { ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( 50, this->blobs(i), output); } @@ -28182,10 +42632,11 @@ void V0LayerParameter::SerializeWithCachedSizes( // optional string det_crop_mode = 59 [default = "warp"]; if (has_det_crop_mode()) { - ::google::protobuf::internal::WireFormat::VerifyUTF8String( + ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( this->det_crop_mode().data(), this->det_crop_mode().length(), - ::google::protobuf::internal::WireFormat::SERIALIZE); - ::google::protobuf::internal::WireFormatLite::WriteString( + ::google::protobuf::internal::WireFormat::SERIALIZE, + "caffe.V0LayerParameter.det_crop_mode"); + ::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased( 59, this->det_crop_mode(), output); } @@ -28222,22 +42673,26 @@ void V0LayerParameter::SerializeWithCachedSizes( // optional .caffe.HDF5OutputParameter hdf5_output_param = 1001; if (has_hdf5_output_param()) { ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( - 1001, this->hdf5_output_param(), output); + 1001, *this->hdf5_output_param_, output); } - if (!unknown_fields().empty()) { + if (_internal_metadata_.have_unknown_fields()) { ::google::protobuf::internal::WireFormat::SerializeUnknownFields( unknown_fields(), output); } + // @@protoc_insertion_point(serialize_end:caffe.V0LayerParameter) } -::google::protobuf::uint8* V0LayerParameter::SerializeWithCachedSizesToArray( - ::google::protobuf::uint8* target) const { +::google::protobuf::uint8* V0LayerParameter::InternalSerializeWithCachedSizesToArray( + bool deterministic, ::google::protobuf::uint8* target) const { + (void)deterministic; // Unused + // @@protoc_insertion_point(serialize_to_array_start:caffe.V0LayerParameter) // optional string name = 1; if (has_name()) { - ::google::protobuf::internal::WireFormat::VerifyUTF8String( + ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( this->name().data(), this->name().length(), - ::google::protobuf::internal::WireFormat::SERIALIZE); + ::google::protobuf::internal::WireFormat::SERIALIZE, + "caffe.V0LayerParameter.name"); target = ::google::protobuf::internal::WireFormatLite::WriteStringToArray( 1, this->name(), target); @@ -28245,9 +42700,10 @@ void V0LayerParameter::SerializeWithCachedSizes( // optional string type = 2; if (has_type()) { - ::google::protobuf::internal::WireFormat::VerifyUTF8String( + ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( this->type().data(), this->type().length(), - ::google::protobuf::internal::WireFormat::SERIALIZE); + ::google::protobuf::internal::WireFormat::SERIALIZE, + "caffe.V0LayerParameter.type"); target = ::google::protobuf::internal::WireFormatLite::WriteStringToArray( 2, this->type(), target); @@ -28258,725 +42714,1920 @@ void V0LayerParameter::SerializeWithCachedSizes( target = ::google::protobuf::internal::WireFormatLite::WriteUInt32ToArray(3, this->num_output(), target); } - // optional bool biasterm = 4 [default = true]; - if (has_biasterm()) { - target = ::google::protobuf::internal::WireFormatLite::WriteBoolToArray(4, this->biasterm(), target); + // optional bool biasterm = 4 [default = true]; + if (has_biasterm()) { + target = ::google::protobuf::internal::WireFormatLite::WriteBoolToArray(4, this->biasterm(), target); + } + + // optional .caffe.FillerParameter weight_filler = 5; + if (has_weight_filler()) { + target = ::google::protobuf::internal::WireFormatLite:: + InternalWriteMessageNoVirtualToArray( + 5, *this->weight_filler_, false, target); + } + + // optional .caffe.FillerParameter bias_filler = 6; + if (has_bias_filler()) { + target = ::google::protobuf::internal::WireFormatLite:: + InternalWriteMessageNoVirtualToArray( + 6, *this->bias_filler_, false, target); + } + + // optional uint32 pad = 7 [default = 0]; + if (has_pad()) { + target = ::google::protobuf::internal::WireFormatLite::WriteUInt32ToArray(7, this->pad(), target); + } + + // optional uint32 kernelsize = 8; + if (has_kernelsize()) { + target = ::google::protobuf::internal::WireFormatLite::WriteUInt32ToArray(8, this->kernelsize(), target); + } + + // optional uint32 group = 9 [default = 1]; + if (has_group()) { + target = ::google::protobuf::internal::WireFormatLite::WriteUInt32ToArray(9, this->group(), target); + } + + // optional uint32 stride = 10 [default = 1]; + if (has_stride()) { + target = ::google::protobuf::internal::WireFormatLite::WriteUInt32ToArray(10, this->stride(), target); + } + + // optional .caffe.V0LayerParameter.PoolMethod pool = 11 [default = MAX]; + if (has_pool()) { + target = ::google::protobuf::internal::WireFormatLite::WriteEnumToArray( + 11, this->pool(), target); + } + + // optional float dropout_ratio = 12 [default = 0.5]; + if (has_dropout_ratio()) { + target = ::google::protobuf::internal::WireFormatLite::WriteFloatToArray(12, this->dropout_ratio(), target); + } + + // optional uint32 local_size = 13 [default = 5]; + if (has_local_size()) { + target = ::google::protobuf::internal::WireFormatLite::WriteUInt32ToArray(13, this->local_size(), target); + } + + // optional float alpha = 14 [default = 1]; + if (has_alpha()) { + target = ::google::protobuf::internal::WireFormatLite::WriteFloatToArray(14, this->alpha(), target); + } + + // optional float beta = 15 [default = 0.75]; + if (has_beta()) { + target = ::google::protobuf::internal::WireFormatLite::WriteFloatToArray(15, this->beta(), target); + } + + // optional string source = 16; + if (has_source()) { + ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( + this->source().data(), this->source().length(), + ::google::protobuf::internal::WireFormat::SERIALIZE, + "caffe.V0LayerParameter.source"); + target = + ::google::protobuf::internal::WireFormatLite::WriteStringToArray( + 16, this->source(), target); + } + + // optional float scale = 17 [default = 1]; + if (has_scale()) { + target = ::google::protobuf::internal::WireFormatLite::WriteFloatToArray(17, this->scale(), target); + } + + // optional string meanfile = 18; + if (has_meanfile()) { + ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( + this->meanfile().data(), this->meanfile().length(), + ::google::protobuf::internal::WireFormat::SERIALIZE, + "caffe.V0LayerParameter.meanfile"); + target = + ::google::protobuf::internal::WireFormatLite::WriteStringToArray( + 18, this->meanfile(), target); + } + + // optional uint32 batchsize = 19; + if (has_batchsize()) { + target = ::google::protobuf::internal::WireFormatLite::WriteUInt32ToArray(19, this->batchsize(), target); + } + + // optional uint32 cropsize = 20 [default = 0]; + if (has_cropsize()) { + target = ::google::protobuf::internal::WireFormatLite::WriteUInt32ToArray(20, this->cropsize(), target); + } + + // optional bool mirror = 21 [default = false]; + if (has_mirror()) { + target = ::google::protobuf::internal::WireFormatLite::WriteBoolToArray(21, this->mirror(), target); + } + + // optional float k = 22 [default = 1]; + if (has_k()) { + target = ::google::protobuf::internal::WireFormatLite::WriteFloatToArray(22, this->k(), target); + } + + // repeated .caffe.BlobProto blobs = 50; + for (unsigned int i = 0, n = this->blobs_size(); i < n; i++) { + target = ::google::protobuf::internal::WireFormatLite:: + InternalWriteMessageNoVirtualToArray( + 50, this->blobs(i), false, target); + } + + // repeated float blobs_lr = 51; + for (int i = 0; i < this->blobs_lr_size(); i++) { + target = ::google::protobuf::internal::WireFormatLite:: + WriteFloatToArray(51, this->blobs_lr(i), target); + } + + // repeated float weight_decay = 52; + for (int i = 0; i < this->weight_decay_size(); i++) { + target = ::google::protobuf::internal::WireFormatLite:: + WriteFloatToArray(52, this->weight_decay(i), target); + } + + // optional uint32 rand_skip = 53 [default = 0]; + if (has_rand_skip()) { + target = ::google::protobuf::internal::WireFormatLite::WriteUInt32ToArray(53, this->rand_skip(), target); + } + + // optional float det_fg_threshold = 54 [default = 0.5]; + if (has_det_fg_threshold()) { + target = ::google::protobuf::internal::WireFormatLite::WriteFloatToArray(54, this->det_fg_threshold(), target); + } + + // optional float det_bg_threshold = 55 [default = 0.5]; + if (has_det_bg_threshold()) { + target = ::google::protobuf::internal::WireFormatLite::WriteFloatToArray(55, this->det_bg_threshold(), target); + } + + // optional float det_fg_fraction = 56 [default = 0.25]; + if (has_det_fg_fraction()) { + target = ::google::protobuf::internal::WireFormatLite::WriteFloatToArray(56, this->det_fg_fraction(), target); + } + + // optional uint32 det_context_pad = 58 [default = 0]; + if (has_det_context_pad()) { + target = ::google::protobuf::internal::WireFormatLite::WriteUInt32ToArray(58, this->det_context_pad(), target); + } + + // optional string det_crop_mode = 59 [default = "warp"]; + if (has_det_crop_mode()) { + ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( + this->det_crop_mode().data(), this->det_crop_mode().length(), + ::google::protobuf::internal::WireFormat::SERIALIZE, + "caffe.V0LayerParameter.det_crop_mode"); + target = + ::google::protobuf::internal::WireFormatLite::WriteStringToArray( + 59, this->det_crop_mode(), target); + } + + // optional int32 new_num = 60 [default = 0]; + if (has_new_num()) { + target = ::google::protobuf::internal::WireFormatLite::WriteInt32ToArray(60, this->new_num(), target); + } + + // optional int32 new_channels = 61 [default = 0]; + if (has_new_channels()) { + target = ::google::protobuf::internal::WireFormatLite::WriteInt32ToArray(61, this->new_channels(), target); + } + + // optional int32 new_height = 62 [default = 0]; + if (has_new_height()) { + target = ::google::protobuf::internal::WireFormatLite::WriteInt32ToArray(62, this->new_height(), target); + } + + // optional int32 new_width = 63 [default = 0]; + if (has_new_width()) { + target = ::google::protobuf::internal::WireFormatLite::WriteInt32ToArray(63, this->new_width(), target); + } + + // optional bool shuffle_images = 64 [default = false]; + if (has_shuffle_images()) { + target = ::google::protobuf::internal::WireFormatLite::WriteBoolToArray(64, this->shuffle_images(), target); + } + + // optional uint32 concat_dim = 65 [default = 1]; + if (has_concat_dim()) { + target = ::google::protobuf::internal::WireFormatLite::WriteUInt32ToArray(65, this->concat_dim(), target); } - // optional .caffe.FillerParameter weight_filler = 5; - if (has_weight_filler()) { + // optional .caffe.HDF5OutputParameter hdf5_output_param = 1001; + if (has_hdf5_output_param()) { target = ::google::protobuf::internal::WireFormatLite:: - WriteMessageNoVirtualToArray( - 5, this->weight_filler(), target); + InternalWriteMessageNoVirtualToArray( + 1001, *this->hdf5_output_param_, false, target); } - // optional .caffe.FillerParameter bias_filler = 6; - if (has_bias_filler()) { - target = ::google::protobuf::internal::WireFormatLite:: - WriteMessageNoVirtualToArray( - 6, this->bias_filler(), target); + if (_internal_metadata_.have_unknown_fields()) { + target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray( + unknown_fields(), target); } + // @@protoc_insertion_point(serialize_to_array_end:caffe.V0LayerParameter) + return target; +} - // optional uint32 pad = 7 [default = 0]; - if (has_pad()) { - target = ::google::protobuf::internal::WireFormatLite::WriteUInt32ToArray(7, this->pad(), target); - } +size_t V0LayerParameter::ByteSizeLong() const { +// @@protoc_insertion_point(message_byte_size_start:caffe.V0LayerParameter) + size_t total_size = 0; - // optional uint32 kernelsize = 8; - if (has_kernelsize()) { - target = ::google::protobuf::internal::WireFormatLite::WriteUInt32ToArray(8, this->kernelsize(), target); - } + if (_has_bits_[0 / 32] & 255u) { + // optional string name = 1; + if (has_name()) { + total_size += 1 + + ::google::protobuf::internal::WireFormatLite::StringSize( + this->name()); + } - // optional uint32 group = 9 [default = 1]; - if (has_group()) { - target = ::google::protobuf::internal::WireFormatLite::WriteUInt32ToArray(9, this->group(), target); - } + // optional string type = 2; + if (has_type()) { + total_size += 1 + + ::google::protobuf::internal::WireFormatLite::StringSize( + this->type()); + } - // optional uint32 stride = 10 [default = 1]; - if (has_stride()) { - target = ::google::protobuf::internal::WireFormatLite::WriteUInt32ToArray(10, this->stride(), target); - } + // optional uint32 num_output = 3; + if (has_num_output()) { + total_size += 1 + + ::google::protobuf::internal::WireFormatLite::UInt32Size( + this->num_output()); + } - // optional .caffe.V0LayerParameter.PoolMethod pool = 11 [default = MAX]; - if (has_pool()) { - target = ::google::protobuf::internal::WireFormatLite::WriteEnumToArray( - 11, this->pool(), target); - } + // optional bool biasterm = 4 [default = true]; + if (has_biasterm()) { + total_size += 1 + 1; + } - // optional float dropout_ratio = 12 [default = 0.5]; - if (has_dropout_ratio()) { - target = ::google::protobuf::internal::WireFormatLite::WriteFloatToArray(12, this->dropout_ratio(), target); - } + // optional .caffe.FillerParameter weight_filler = 5; + if (has_weight_filler()) { + total_size += 1 + + ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( + *this->weight_filler_); + } - // optional uint32 local_size = 13 [default = 5]; - if (has_local_size()) { - target = ::google::protobuf::internal::WireFormatLite::WriteUInt32ToArray(13, this->local_size(), target); - } + // optional .caffe.FillerParameter bias_filler = 6; + if (has_bias_filler()) { + total_size += 1 + + ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( + *this->bias_filler_); + } - // optional float alpha = 14 [default = 1]; - if (has_alpha()) { - target = ::google::protobuf::internal::WireFormatLite::WriteFloatToArray(14, this->alpha(), target); - } + // optional uint32 pad = 7 [default = 0]; + if (has_pad()) { + total_size += 1 + + ::google::protobuf::internal::WireFormatLite::UInt32Size( + this->pad()); + } - // optional float beta = 15 [default = 0.75]; - if (has_beta()) { - target = ::google::protobuf::internal::WireFormatLite::WriteFloatToArray(15, this->beta(), target); - } + // optional uint32 kernelsize = 8; + if (has_kernelsize()) { + total_size += 1 + + ::google::protobuf::internal::WireFormatLite::UInt32Size( + this->kernelsize()); + } - // optional string source = 16; - if (has_source()) { - ::google::protobuf::internal::WireFormat::VerifyUTF8String( - this->source().data(), this->source().length(), - ::google::protobuf::internal::WireFormat::SERIALIZE); - target = - ::google::protobuf::internal::WireFormatLite::WriteStringToArray( - 16, this->source(), target); } + if (_has_bits_[8 / 32] & 65280u) { + // optional uint32 group = 9 [default = 1]; + if (has_group()) { + total_size += 1 + + ::google::protobuf::internal::WireFormatLite::UInt32Size( + this->group()); + } - // optional float scale = 17 [default = 1]; - if (has_scale()) { - target = ::google::protobuf::internal::WireFormatLite::WriteFloatToArray(17, this->scale(), target); - } + // optional uint32 stride = 10 [default = 1]; + if (has_stride()) { + total_size += 1 + + ::google::protobuf::internal::WireFormatLite::UInt32Size( + this->stride()); + } - // optional string meanfile = 18; - if (has_meanfile()) { - ::google::protobuf::internal::WireFormat::VerifyUTF8String( - this->meanfile().data(), this->meanfile().length(), - ::google::protobuf::internal::WireFormat::SERIALIZE); - target = - ::google::protobuf::internal::WireFormatLite::WriteStringToArray( - 18, this->meanfile(), target); - } + // optional .caffe.V0LayerParameter.PoolMethod pool = 11 [default = MAX]; + if (has_pool()) { + total_size += 1 + + ::google::protobuf::internal::WireFormatLite::EnumSize(this->pool()); + } - // optional uint32 batchsize = 19; - if (has_batchsize()) { - target = ::google::protobuf::internal::WireFormatLite::WriteUInt32ToArray(19, this->batchsize(), target); - } + // optional float dropout_ratio = 12 [default = 0.5]; + if (has_dropout_ratio()) { + total_size += 1 + 4; + } - // optional uint32 cropsize = 20 [default = 0]; - if (has_cropsize()) { - target = ::google::protobuf::internal::WireFormatLite::WriteUInt32ToArray(20, this->cropsize(), target); - } + // optional uint32 local_size = 13 [default = 5]; + if (has_local_size()) { + total_size += 1 + + ::google::protobuf::internal::WireFormatLite::UInt32Size( + this->local_size()); + } - // optional bool mirror = 21 [default = false]; - if (has_mirror()) { - target = ::google::protobuf::internal::WireFormatLite::WriteBoolToArray(21, this->mirror(), target); - } + // optional float alpha = 14 [default = 1]; + if (has_alpha()) { + total_size += 1 + 4; + } - // optional float k = 22 [default = 1]; - if (has_k()) { - target = ::google::protobuf::internal::WireFormatLite::WriteFloatToArray(22, this->k(), target); - } + // optional float beta = 15 [default = 0.75]; + if (has_beta()) { + total_size += 1 + 4; + } + + // optional float k = 22 [default = 1]; + if (has_k()) { + total_size += 2 + 4; + } - // repeated .caffe.BlobProto blobs = 50; - for (int i = 0; i < this->blobs_size(); i++) { - target = ::google::protobuf::internal::WireFormatLite:: - WriteMessageNoVirtualToArray( - 50, this->blobs(i), target); } + if (_has_bits_[16 / 32] & 4128768u) { + // optional string source = 16; + if (has_source()) { + total_size += 2 + + ::google::protobuf::internal::WireFormatLite::StringSize( + this->source()); + } + + // optional float scale = 17 [default = 1]; + if (has_scale()) { + total_size += 2 + 4; + } + + // optional string meanfile = 18; + if (has_meanfile()) { + total_size += 2 + + ::google::protobuf::internal::WireFormatLite::StringSize( + this->meanfile()); + } + + // optional uint32 batchsize = 19; + if (has_batchsize()) { + total_size += 2 + + ::google::protobuf::internal::WireFormatLite::UInt32Size( + this->batchsize()); + } + + // optional uint32 cropsize = 20 [default = 0]; + if (has_cropsize()) { + total_size += 2 + + ::google::protobuf::internal::WireFormatLite::UInt32Size( + this->cropsize()); + } + + // optional bool mirror = 21 [default = false]; + if (has_mirror()) { + total_size += 2 + 1; + } - // repeated float blobs_lr = 51; - for (int i = 0; i < this->blobs_lr_size(); i++) { - target = ::google::protobuf::internal::WireFormatLite:: - WriteFloatToArray(51, this->blobs_lr(i), target); } + if (_has_bits_[25 / 32] & 4261412864u) { + // optional uint32 rand_skip = 53 [default = 0]; + if (has_rand_skip()) { + total_size += 2 + + ::google::protobuf::internal::WireFormatLite::UInt32Size( + this->rand_skip()); + } + + // optional float det_fg_threshold = 54 [default = 0.5]; + if (has_det_fg_threshold()) { + total_size += 2 + 4; + } + + // optional float det_bg_threshold = 55 [default = 0.5]; + if (has_det_bg_threshold()) { + total_size += 2 + 4; + } + + // optional float det_fg_fraction = 56 [default = 0.25]; + if (has_det_fg_fraction()) { + total_size += 2 + 4; + } + + // optional uint32 det_context_pad = 58 [default = 0]; + if (has_det_context_pad()) { + total_size += 2 + + ::google::protobuf::internal::WireFormatLite::UInt32Size( + this->det_context_pad()); + } + + // optional string det_crop_mode = 59 [default = "warp"]; + if (has_det_crop_mode()) { + total_size += 2 + + ::google::protobuf::internal::WireFormatLite::StringSize( + this->det_crop_mode()); + } + + // optional int32 new_num = 60 [default = 0]; + if (has_new_num()) { + total_size += 2 + + ::google::protobuf::internal::WireFormatLite::Int32Size( + this->new_num()); + } - // repeated float weight_decay = 52; - for (int i = 0; i < this->weight_decay_size(); i++) { - target = ::google::protobuf::internal::WireFormatLite:: - WriteFloatToArray(52, this->weight_decay(i), target); } + if (_has_bits_[32 / 32] & 63u) { + // optional int32 new_channels = 61 [default = 0]; + if (has_new_channels()) { + total_size += 2 + + ::google::protobuf::internal::WireFormatLite::Int32Size( + this->new_channels()); + } - // optional uint32 rand_skip = 53 [default = 0]; - if (has_rand_skip()) { - target = ::google::protobuf::internal::WireFormatLite::WriteUInt32ToArray(53, this->rand_skip(), target); - } + // optional int32 new_height = 62 [default = 0]; + if (has_new_height()) { + total_size += 2 + + ::google::protobuf::internal::WireFormatLite::Int32Size( + this->new_height()); + } - // optional float det_fg_threshold = 54 [default = 0.5]; - if (has_det_fg_threshold()) { - target = ::google::protobuf::internal::WireFormatLite::WriteFloatToArray(54, this->det_fg_threshold(), target); - } + // optional int32 new_width = 63 [default = 0]; + if (has_new_width()) { + total_size += 2 + + ::google::protobuf::internal::WireFormatLite::Int32Size( + this->new_width()); + } - // optional float det_bg_threshold = 55 [default = 0.5]; - if (has_det_bg_threshold()) { - target = ::google::protobuf::internal::WireFormatLite::WriteFloatToArray(55, this->det_bg_threshold(), target); - } + // optional bool shuffle_images = 64 [default = false]; + if (has_shuffle_images()) { + total_size += 2 + 1; + } - // optional float det_fg_fraction = 56 [default = 0.25]; - if (has_det_fg_fraction()) { - target = ::google::protobuf::internal::WireFormatLite::WriteFloatToArray(56, this->det_fg_fraction(), target); - } + // optional uint32 concat_dim = 65 [default = 1]; + if (has_concat_dim()) { + total_size += 2 + + ::google::protobuf::internal::WireFormatLite::UInt32Size( + this->concat_dim()); + } - // optional uint32 det_context_pad = 58 [default = 0]; - if (has_det_context_pad()) { - target = ::google::protobuf::internal::WireFormatLite::WriteUInt32ToArray(58, this->det_context_pad(), target); - } + // optional .caffe.HDF5OutputParameter hdf5_output_param = 1001; + if (has_hdf5_output_param()) { + total_size += 2 + + ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( + *this->hdf5_output_param_); + } - // optional string det_crop_mode = 59 [default = "warp"]; - if (has_det_crop_mode()) { - ::google::protobuf::internal::WireFormat::VerifyUTF8String( - this->det_crop_mode().data(), this->det_crop_mode().length(), - ::google::protobuf::internal::WireFormat::SERIALIZE); - target = - ::google::protobuf::internal::WireFormatLite::WriteStringToArray( - 59, this->det_crop_mode(), target); } - - // optional int32 new_num = 60 [default = 0]; - if (has_new_num()) { - target = ::google::protobuf::internal::WireFormatLite::WriteInt32ToArray(60, this->new_num(), target); + // repeated .caffe.BlobProto blobs = 50; + { + unsigned int count = this->blobs_size(); + total_size += 2UL * count; + for (unsigned int i = 0; i < count; i++) { + total_size += + ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( + this->blobs(i)); + } } - // optional int32 new_channels = 61 [default = 0]; - if (has_new_channels()) { - target = ::google::protobuf::internal::WireFormatLite::WriteInt32ToArray(61, this->new_channels(), target); + // repeated float blobs_lr = 51; + { + size_t data_size = 0; + unsigned int count = this->blobs_lr_size(); + data_size = 4UL * count; + total_size += 2 * + ::google::protobuf::internal::FromIntSize(this->blobs_lr_size()); + total_size += data_size; } - // optional int32 new_height = 62 [default = 0]; - if (has_new_height()) { - target = ::google::protobuf::internal::WireFormatLite::WriteInt32ToArray(62, this->new_height(), target); + // repeated float weight_decay = 52; + { + size_t data_size = 0; + unsigned int count = this->weight_decay_size(); + data_size = 4UL * count; + total_size += 2 * + ::google::protobuf::internal::FromIntSize(this->weight_decay_size()); + total_size += data_size; } - // optional int32 new_width = 63 [default = 0]; - if (has_new_width()) { - target = ::google::protobuf::internal::WireFormatLite::WriteInt32ToArray(63, this->new_width(), target); + if (_internal_metadata_.have_unknown_fields()) { + total_size += + ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( + unknown_fields()); } + int cached_size = ::google::protobuf::internal::ToCachedSize(total_size); + GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); + _cached_size_ = cached_size; + GOOGLE_SAFE_CONCURRENT_WRITES_END(); + return total_size; +} - // optional bool shuffle_images = 64 [default = false]; - if (has_shuffle_images()) { - target = ::google::protobuf::internal::WireFormatLite::WriteBoolToArray(64, this->shuffle_images(), target); +void V0LayerParameter::MergeFrom(const ::google::protobuf::Message& from) { +// @@protoc_insertion_point(generalized_merge_from_start:caffe.V0LayerParameter) + if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__); + const V0LayerParameter* source = + ::google::protobuf::internal::DynamicCastToGenerated( + &from); + if (source == NULL) { + // @@protoc_insertion_point(generalized_merge_from_cast_fail:caffe.V0LayerParameter) + ::google::protobuf::internal::ReflectionOps::Merge(from, this); + } else { + // @@protoc_insertion_point(generalized_merge_from_cast_success:caffe.V0LayerParameter) + UnsafeMergeFrom(*source); } +} - // optional uint32 concat_dim = 65 [default = 1]; - if (has_concat_dim()) { - target = ::google::protobuf::internal::WireFormatLite::WriteUInt32ToArray(65, this->concat_dim(), target); +void V0LayerParameter::MergeFrom(const V0LayerParameter& from) { +// @@protoc_insertion_point(class_specific_merge_from_start:caffe.V0LayerParameter) + if (GOOGLE_PREDICT_TRUE(&from != this)) { + UnsafeMergeFrom(from); + } else { + MergeFromFail(__LINE__); } +} - // optional .caffe.HDF5OutputParameter hdf5_output_param = 1001; - if (has_hdf5_output_param()) { - target = ::google::protobuf::internal::WireFormatLite:: - WriteMessageNoVirtualToArray( - 1001, this->hdf5_output_param(), target); +void V0LayerParameter::UnsafeMergeFrom(const V0LayerParameter& from) { + GOOGLE_DCHECK(&from != this); + blobs_.MergeFrom(from.blobs_); + blobs_lr_.UnsafeMergeFrom(from.blobs_lr_); + weight_decay_.UnsafeMergeFrom(from.weight_decay_); + if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) { + if (from.has_name()) { + set_has_name(); + name_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.name_); + } + if (from.has_type()) { + set_has_type(); + type_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.type_); + } + if (from.has_num_output()) { + set_num_output(from.num_output()); + } + if (from.has_biasterm()) { + set_biasterm(from.biasterm()); + } + if (from.has_weight_filler()) { + mutable_weight_filler()->::caffe::FillerParameter::MergeFrom(from.weight_filler()); + } + if (from.has_bias_filler()) { + mutable_bias_filler()->::caffe::FillerParameter::MergeFrom(from.bias_filler()); + } + if (from.has_pad()) { + set_pad(from.pad()); + } + if (from.has_kernelsize()) { + set_kernelsize(from.kernelsize()); + } } - - if (!unknown_fields().empty()) { - target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray( - unknown_fields(), target); + if (from._has_bits_[8 / 32] & (0xffu << (8 % 32))) { + if (from.has_group()) { + set_group(from.group()); + } + if (from.has_stride()) { + set_stride(from.stride()); + } + if (from.has_pool()) { + set_pool(from.pool()); + } + if (from.has_dropout_ratio()) { + set_dropout_ratio(from.dropout_ratio()); + } + if (from.has_local_size()) { + set_local_size(from.local_size()); + } + if (from.has_alpha()) { + set_alpha(from.alpha()); + } + if (from.has_beta()) { + set_beta(from.beta()); + } + if (from.has_k()) { + set_k(from.k()); + } } - return target; -} - -int V0LayerParameter::ByteSize() const { - int total_size = 0; - - if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) { - // optional string name = 1; - if (has_name()) { - total_size += 1 + - ::google::protobuf::internal::WireFormatLite::StringSize( - this->name()); + if (from._has_bits_[16 / 32] & (0xffu << (16 % 32))) { + if (from.has_source()) { + set_has_source(); + source_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.source_); } - - // optional string type = 2; - if (has_type()) { - total_size += 1 + - ::google::protobuf::internal::WireFormatLite::StringSize( - this->type()); + if (from.has_scale()) { + set_scale(from.scale()); } - - // optional uint32 num_output = 3; - if (has_num_output()) { - total_size += 1 + - ::google::protobuf::internal::WireFormatLite::UInt32Size( - this->num_output()); + if (from.has_meanfile()) { + set_has_meanfile(); + meanfile_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.meanfile_); } - - // optional bool biasterm = 4 [default = true]; - if (has_biasterm()) { - total_size += 1 + 1; + if (from.has_batchsize()) { + set_batchsize(from.batchsize()); } - - // optional .caffe.FillerParameter weight_filler = 5; - if (has_weight_filler()) { - total_size += 1 + - ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( - this->weight_filler()); + if (from.has_cropsize()) { + set_cropsize(from.cropsize()); } - - // optional .caffe.FillerParameter bias_filler = 6; - if (has_bias_filler()) { - total_size += 1 + - ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( - this->bias_filler()); + if (from.has_mirror()) { + set_mirror(from.mirror()); } - - // optional uint32 pad = 7 [default = 0]; - if (has_pad()) { - total_size += 1 + - ::google::protobuf::internal::WireFormatLite::UInt32Size( - this->pad()); + } + if (from._has_bits_[25 / 32] & (0xffu << (25 % 32))) { + if (from.has_rand_skip()) { + set_rand_skip(from.rand_skip()); } - - // optional uint32 kernelsize = 8; - if (has_kernelsize()) { - total_size += 1 + - ::google::protobuf::internal::WireFormatLite::UInt32Size( - this->kernelsize()); + if (from.has_det_fg_threshold()) { + set_det_fg_threshold(from.det_fg_threshold()); + } + if (from.has_det_bg_threshold()) { + set_det_bg_threshold(from.det_bg_threshold()); + } + if (from.has_det_fg_fraction()) { + set_det_fg_fraction(from.det_fg_fraction()); + } + if (from.has_det_context_pad()) { + set_det_context_pad(from.det_context_pad()); + } + if (from.has_det_crop_mode()) { + set_has_det_crop_mode(); + det_crop_mode_.AssignWithDefault(_default_det_crop_mode_, from.det_crop_mode_); + } + if (from.has_new_num()) { + set_new_num(from.new_num()); } - } - if (_has_bits_[8 / 32] & (0xffu << (8 % 32))) { - // optional uint32 group = 9 [default = 1]; - if (has_group()) { - total_size += 1 + - ::google::protobuf::internal::WireFormatLite::UInt32Size( - this->group()); + if (from._has_bits_[32 / 32] & (0xffu << (32 % 32))) { + if (from.has_new_channels()) { + set_new_channels(from.new_channels()); } - - // optional uint32 stride = 10 [default = 1]; - if (has_stride()) { - total_size += 1 + - ::google::protobuf::internal::WireFormatLite::UInt32Size( - this->stride()); + if (from.has_new_height()) { + set_new_height(from.new_height()); } - - // optional .caffe.V0LayerParameter.PoolMethod pool = 11 [default = MAX]; - if (has_pool()) { - total_size += 1 + - ::google::protobuf::internal::WireFormatLite::EnumSize(this->pool()); + if (from.has_new_width()) { + set_new_width(from.new_width()); } - - // optional float dropout_ratio = 12 [default = 0.5]; - if (has_dropout_ratio()) { - total_size += 1 + 4; + if (from.has_shuffle_images()) { + set_shuffle_images(from.shuffle_images()); } - - // optional uint32 local_size = 13 [default = 5]; - if (has_local_size()) { - total_size += 1 + - ::google::protobuf::internal::WireFormatLite::UInt32Size( - this->local_size()); + if (from.has_concat_dim()) { + set_concat_dim(from.concat_dim()); } - - // optional float alpha = 14 [default = 1]; - if (has_alpha()) { - total_size += 1 + 4; + if (from.has_hdf5_output_param()) { + mutable_hdf5_output_param()->::caffe::HDF5OutputParameter::MergeFrom(from.hdf5_output_param()); } + } + if (from._internal_metadata_.have_unknown_fields()) { + ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata( + from.unknown_fields(), &_internal_metadata_); + } +} - // optional float beta = 15 [default = 0.75]; - if (has_beta()) { - total_size += 1 + 4; - } +void V0LayerParameter::CopyFrom(const ::google::protobuf::Message& from) { +// @@protoc_insertion_point(generalized_copy_from_start:caffe.V0LayerParameter) + if (&from == this) return; + Clear(); + MergeFrom(from); +} - // optional float k = 22 [default = 1]; - if (has_k()) { - total_size += 2 + 4; - } +void V0LayerParameter::CopyFrom(const V0LayerParameter& from) { +// @@protoc_insertion_point(class_specific_copy_from_start:caffe.V0LayerParameter) + if (&from == this) return; + Clear(); + UnsafeMergeFrom(from); +} - } - if (_has_bits_[16 / 32] & (0xffu << (16 % 32))) { - // optional string source = 16; - if (has_source()) { - total_size += 2 + - ::google::protobuf::internal::WireFormatLite::StringSize( - this->source()); - } +bool V0LayerParameter::IsInitialized() const { - // optional float scale = 17 [default = 1]; - if (has_scale()) { - total_size += 2 + 4; - } + return true; +} - // optional string meanfile = 18; - if (has_meanfile()) { - total_size += 2 + - ::google::protobuf::internal::WireFormatLite::StringSize( - this->meanfile()); - } +void V0LayerParameter::Swap(V0LayerParameter* other) { + if (other == this) return; + InternalSwap(other); +} +void V0LayerParameter::InternalSwap(V0LayerParameter* other) { + name_.Swap(&other->name_); + type_.Swap(&other->type_); + std::swap(num_output_, other->num_output_); + std::swap(biasterm_, other->biasterm_); + std::swap(weight_filler_, other->weight_filler_); + std::swap(bias_filler_, other->bias_filler_); + std::swap(pad_, other->pad_); + std::swap(kernelsize_, other->kernelsize_); + std::swap(group_, other->group_); + std::swap(stride_, other->stride_); + std::swap(pool_, other->pool_); + std::swap(dropout_ratio_, other->dropout_ratio_); + std::swap(local_size_, other->local_size_); + std::swap(alpha_, other->alpha_); + std::swap(beta_, other->beta_); + std::swap(k_, other->k_); + source_.Swap(&other->source_); + std::swap(scale_, other->scale_); + meanfile_.Swap(&other->meanfile_); + std::swap(batchsize_, other->batchsize_); + std::swap(cropsize_, other->cropsize_); + std::swap(mirror_, other->mirror_); + blobs_.UnsafeArenaSwap(&other->blobs_); + blobs_lr_.UnsafeArenaSwap(&other->blobs_lr_); + weight_decay_.UnsafeArenaSwap(&other->weight_decay_); + std::swap(rand_skip_, other->rand_skip_); + std::swap(det_fg_threshold_, other->det_fg_threshold_); + std::swap(det_bg_threshold_, other->det_bg_threshold_); + std::swap(det_fg_fraction_, other->det_fg_fraction_); + std::swap(det_context_pad_, other->det_context_pad_); + det_crop_mode_.Swap(&other->det_crop_mode_); + std::swap(new_num_, other->new_num_); + std::swap(new_channels_, other->new_channels_); + std::swap(new_height_, other->new_height_); + std::swap(new_width_, other->new_width_); + std::swap(shuffle_images_, other->shuffle_images_); + std::swap(concat_dim_, other->concat_dim_); + std::swap(hdf5_output_param_, other->hdf5_output_param_); + std::swap(_has_bits_[0], other->_has_bits_[0]); + std::swap(_has_bits_[1], other->_has_bits_[1]); + _internal_metadata_.Swap(&other->_internal_metadata_); + std::swap(_cached_size_, other->_cached_size_); +} - // optional uint32 batchsize = 19; - if (has_batchsize()) { - total_size += 2 + - ::google::protobuf::internal::WireFormatLite::UInt32Size( - this->batchsize()); - } +::google::protobuf::Metadata V0LayerParameter::GetMetadata() const { + protobuf_AssignDescriptorsOnce(); + ::google::protobuf::Metadata metadata; + metadata.descriptor = V0LayerParameter_descriptor_; + metadata.reflection = V0LayerParameter_reflection_; + return metadata; +} - // optional uint32 cropsize = 20 [default = 0]; - if (has_cropsize()) { - total_size += 2 + - ::google::protobuf::internal::WireFormatLite::UInt32Size( - this->cropsize()); - } +#if PROTOBUF_INLINE_NOT_IN_HEADERS +// V0LayerParameter - // optional bool mirror = 21 [default = false]; - if (has_mirror()) { - total_size += 2 + 1; - } +// optional string name = 1; +bool V0LayerParameter::has_name() const { + return (_has_bits_[0] & 0x00000001u) != 0; +} +void V0LayerParameter::set_has_name() { + _has_bits_[0] |= 0x00000001u; +} +void V0LayerParameter::clear_has_name() { + _has_bits_[0] &= ~0x00000001u; +} +void V0LayerParameter::clear_name() { + name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + clear_has_name(); +} +const ::std::string& V0LayerParameter::name() const { + // @@protoc_insertion_point(field_get:caffe.V0LayerParameter.name) + return name_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); +} +void V0LayerParameter::set_name(const ::std::string& value) { + set_has_name(); + name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); + // @@protoc_insertion_point(field_set:caffe.V0LayerParameter.name) +} +void V0LayerParameter::set_name(const char* value) { + set_has_name(); + name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); + // @@protoc_insertion_point(field_set_char:caffe.V0LayerParameter.name) +} +void V0LayerParameter::set_name(const char* value, size_t size) { + set_has_name(); + name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), + ::std::string(reinterpret_cast(value), size)); + // @@protoc_insertion_point(field_set_pointer:caffe.V0LayerParameter.name) +} +::std::string* V0LayerParameter::mutable_name() { + set_has_name(); + // @@protoc_insertion_point(field_mutable:caffe.V0LayerParameter.name) + return name_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); +} +::std::string* V0LayerParameter::release_name() { + // @@protoc_insertion_point(field_release:caffe.V0LayerParameter.name) + clear_has_name(); + return name_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); +} +void V0LayerParameter::set_allocated_name(::std::string* name) { + if (name != NULL) { + set_has_name(); + } else { + clear_has_name(); + } + name_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), name); + // @@protoc_insertion_point(field_set_allocated:caffe.V0LayerParameter.name) +} +// optional string type = 2; +bool V0LayerParameter::has_type() const { + return (_has_bits_[0] & 0x00000002u) != 0; +} +void V0LayerParameter::set_has_type() { + _has_bits_[0] |= 0x00000002u; +} +void V0LayerParameter::clear_has_type() { + _has_bits_[0] &= ~0x00000002u; +} +void V0LayerParameter::clear_type() { + type_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + clear_has_type(); +} +const ::std::string& V0LayerParameter::type() const { + // @@protoc_insertion_point(field_get:caffe.V0LayerParameter.type) + return type_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); +} +void V0LayerParameter::set_type(const ::std::string& value) { + set_has_type(); + type_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); + // @@protoc_insertion_point(field_set:caffe.V0LayerParameter.type) +} +void V0LayerParameter::set_type(const char* value) { + set_has_type(); + type_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); + // @@protoc_insertion_point(field_set_char:caffe.V0LayerParameter.type) +} +void V0LayerParameter::set_type(const char* value, size_t size) { + set_has_type(); + type_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), + ::std::string(reinterpret_cast(value), size)); + // @@protoc_insertion_point(field_set_pointer:caffe.V0LayerParameter.type) +} +::std::string* V0LayerParameter::mutable_type() { + set_has_type(); + // @@protoc_insertion_point(field_mutable:caffe.V0LayerParameter.type) + return type_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); +} +::std::string* V0LayerParameter::release_type() { + // @@protoc_insertion_point(field_release:caffe.V0LayerParameter.type) + clear_has_type(); + return type_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); +} +void V0LayerParameter::set_allocated_type(::std::string* type) { + if (type != NULL) { + set_has_type(); + } else { + clear_has_type(); } - if (_has_bits_[25 / 32] & (0xffu << (25 % 32))) { - // optional uint32 rand_skip = 53 [default = 0]; - if (has_rand_skip()) { - total_size += 2 + - ::google::protobuf::internal::WireFormatLite::UInt32Size( - this->rand_skip()); - } + type_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), type); + // @@protoc_insertion_point(field_set_allocated:caffe.V0LayerParameter.type) +} - // optional float det_fg_threshold = 54 [default = 0.5]; - if (has_det_fg_threshold()) { - total_size += 2 + 4; - } +// optional uint32 num_output = 3; +bool V0LayerParameter::has_num_output() const { + return (_has_bits_[0] & 0x00000004u) != 0; +} +void V0LayerParameter::set_has_num_output() { + _has_bits_[0] |= 0x00000004u; +} +void V0LayerParameter::clear_has_num_output() { + _has_bits_[0] &= ~0x00000004u; +} +void V0LayerParameter::clear_num_output() { + num_output_ = 0u; + clear_has_num_output(); +} +::google::protobuf::uint32 V0LayerParameter::num_output() const { + // @@protoc_insertion_point(field_get:caffe.V0LayerParameter.num_output) + return num_output_; +} +void V0LayerParameter::set_num_output(::google::protobuf::uint32 value) { + set_has_num_output(); + num_output_ = value; + // @@protoc_insertion_point(field_set:caffe.V0LayerParameter.num_output) +} - // optional float det_bg_threshold = 55 [default = 0.5]; - if (has_det_bg_threshold()) { - total_size += 2 + 4; - } +// optional bool biasterm = 4 [default = true]; +bool V0LayerParameter::has_biasterm() const { + return (_has_bits_[0] & 0x00000008u) != 0; +} +void V0LayerParameter::set_has_biasterm() { + _has_bits_[0] |= 0x00000008u; +} +void V0LayerParameter::clear_has_biasterm() { + _has_bits_[0] &= ~0x00000008u; +} +void V0LayerParameter::clear_biasterm() { + biasterm_ = true; + clear_has_biasterm(); +} +bool V0LayerParameter::biasterm() const { + // @@protoc_insertion_point(field_get:caffe.V0LayerParameter.biasterm) + return biasterm_; +} +void V0LayerParameter::set_biasterm(bool value) { + set_has_biasterm(); + biasterm_ = value; + // @@protoc_insertion_point(field_set:caffe.V0LayerParameter.biasterm) +} - // optional float det_fg_fraction = 56 [default = 0.25]; - if (has_det_fg_fraction()) { - total_size += 2 + 4; - } +// optional .caffe.FillerParameter weight_filler = 5; +bool V0LayerParameter::has_weight_filler() const { + return (_has_bits_[0] & 0x00000010u) != 0; +} +void V0LayerParameter::set_has_weight_filler() { + _has_bits_[0] |= 0x00000010u; +} +void V0LayerParameter::clear_has_weight_filler() { + _has_bits_[0] &= ~0x00000010u; +} +void V0LayerParameter::clear_weight_filler() { + if (weight_filler_ != NULL) weight_filler_->::caffe::FillerParameter::Clear(); + clear_has_weight_filler(); +} +const ::caffe::FillerParameter& V0LayerParameter::weight_filler() const { + // @@protoc_insertion_point(field_get:caffe.V0LayerParameter.weight_filler) + return weight_filler_ != NULL ? *weight_filler_ + : *::caffe::FillerParameter::internal_default_instance(); +} +::caffe::FillerParameter* V0LayerParameter::mutable_weight_filler() { + set_has_weight_filler(); + if (weight_filler_ == NULL) { + weight_filler_ = new ::caffe::FillerParameter; + } + // @@protoc_insertion_point(field_mutable:caffe.V0LayerParameter.weight_filler) + return weight_filler_; +} +::caffe::FillerParameter* V0LayerParameter::release_weight_filler() { + // @@protoc_insertion_point(field_release:caffe.V0LayerParameter.weight_filler) + clear_has_weight_filler(); + ::caffe::FillerParameter* temp = weight_filler_; + weight_filler_ = NULL; + return temp; +} +void V0LayerParameter::set_allocated_weight_filler(::caffe::FillerParameter* weight_filler) { + delete weight_filler_; + weight_filler_ = weight_filler; + if (weight_filler) { + set_has_weight_filler(); + } else { + clear_has_weight_filler(); + } + // @@protoc_insertion_point(field_set_allocated:caffe.V0LayerParameter.weight_filler) +} - // optional uint32 det_context_pad = 58 [default = 0]; - if (has_det_context_pad()) { - total_size += 2 + - ::google::protobuf::internal::WireFormatLite::UInt32Size( - this->det_context_pad()); - } +// optional .caffe.FillerParameter bias_filler = 6; +bool V0LayerParameter::has_bias_filler() const { + return (_has_bits_[0] & 0x00000020u) != 0; +} +void V0LayerParameter::set_has_bias_filler() { + _has_bits_[0] |= 0x00000020u; +} +void V0LayerParameter::clear_has_bias_filler() { + _has_bits_[0] &= ~0x00000020u; +} +void V0LayerParameter::clear_bias_filler() { + if (bias_filler_ != NULL) bias_filler_->::caffe::FillerParameter::Clear(); + clear_has_bias_filler(); +} +const ::caffe::FillerParameter& V0LayerParameter::bias_filler() const { + // @@protoc_insertion_point(field_get:caffe.V0LayerParameter.bias_filler) + return bias_filler_ != NULL ? *bias_filler_ + : *::caffe::FillerParameter::internal_default_instance(); +} +::caffe::FillerParameter* V0LayerParameter::mutable_bias_filler() { + set_has_bias_filler(); + if (bias_filler_ == NULL) { + bias_filler_ = new ::caffe::FillerParameter; + } + // @@protoc_insertion_point(field_mutable:caffe.V0LayerParameter.bias_filler) + return bias_filler_; +} +::caffe::FillerParameter* V0LayerParameter::release_bias_filler() { + // @@protoc_insertion_point(field_release:caffe.V0LayerParameter.bias_filler) + clear_has_bias_filler(); + ::caffe::FillerParameter* temp = bias_filler_; + bias_filler_ = NULL; + return temp; +} +void V0LayerParameter::set_allocated_bias_filler(::caffe::FillerParameter* bias_filler) { + delete bias_filler_; + bias_filler_ = bias_filler; + if (bias_filler) { + set_has_bias_filler(); + } else { + clear_has_bias_filler(); + } + // @@protoc_insertion_point(field_set_allocated:caffe.V0LayerParameter.bias_filler) +} - // optional string det_crop_mode = 59 [default = "warp"]; - if (has_det_crop_mode()) { - total_size += 2 + - ::google::protobuf::internal::WireFormatLite::StringSize( - this->det_crop_mode()); - } +// optional uint32 pad = 7 [default = 0]; +bool V0LayerParameter::has_pad() const { + return (_has_bits_[0] & 0x00000040u) != 0; +} +void V0LayerParameter::set_has_pad() { + _has_bits_[0] |= 0x00000040u; +} +void V0LayerParameter::clear_has_pad() { + _has_bits_[0] &= ~0x00000040u; +} +void V0LayerParameter::clear_pad() { + pad_ = 0u; + clear_has_pad(); +} +::google::protobuf::uint32 V0LayerParameter::pad() const { + // @@protoc_insertion_point(field_get:caffe.V0LayerParameter.pad) + return pad_; +} +void V0LayerParameter::set_pad(::google::protobuf::uint32 value) { + set_has_pad(); + pad_ = value; + // @@protoc_insertion_point(field_set:caffe.V0LayerParameter.pad) +} - // optional int32 new_num = 60 [default = 0]; - if (has_new_num()) { - total_size += 2 + - ::google::protobuf::internal::WireFormatLite::Int32Size( - this->new_num()); - } +// optional uint32 kernelsize = 8; +bool V0LayerParameter::has_kernelsize() const { + return (_has_bits_[0] & 0x00000080u) != 0; +} +void V0LayerParameter::set_has_kernelsize() { + _has_bits_[0] |= 0x00000080u; +} +void V0LayerParameter::clear_has_kernelsize() { + _has_bits_[0] &= ~0x00000080u; +} +void V0LayerParameter::clear_kernelsize() { + kernelsize_ = 0u; + clear_has_kernelsize(); +} +::google::protobuf::uint32 V0LayerParameter::kernelsize() const { + // @@protoc_insertion_point(field_get:caffe.V0LayerParameter.kernelsize) + return kernelsize_; +} +void V0LayerParameter::set_kernelsize(::google::protobuf::uint32 value) { + set_has_kernelsize(); + kernelsize_ = value; + // @@protoc_insertion_point(field_set:caffe.V0LayerParameter.kernelsize) +} - } - if (_has_bits_[32 / 32] & (0xffu << (32 % 32))) { - // optional int32 new_channels = 61 [default = 0]; - if (has_new_channels()) { - total_size += 2 + - ::google::protobuf::internal::WireFormatLite::Int32Size( - this->new_channels()); - } +// optional uint32 group = 9 [default = 1]; +bool V0LayerParameter::has_group() const { + return (_has_bits_[0] & 0x00000100u) != 0; +} +void V0LayerParameter::set_has_group() { + _has_bits_[0] |= 0x00000100u; +} +void V0LayerParameter::clear_has_group() { + _has_bits_[0] &= ~0x00000100u; +} +void V0LayerParameter::clear_group() { + group_ = 1u; + clear_has_group(); +} +::google::protobuf::uint32 V0LayerParameter::group() const { + // @@protoc_insertion_point(field_get:caffe.V0LayerParameter.group) + return group_; +} +void V0LayerParameter::set_group(::google::protobuf::uint32 value) { + set_has_group(); + group_ = value; + // @@protoc_insertion_point(field_set:caffe.V0LayerParameter.group) +} - // optional int32 new_height = 62 [default = 0]; - if (has_new_height()) { - total_size += 2 + - ::google::protobuf::internal::WireFormatLite::Int32Size( - this->new_height()); - } +// optional uint32 stride = 10 [default = 1]; +bool V0LayerParameter::has_stride() const { + return (_has_bits_[0] & 0x00000200u) != 0; +} +void V0LayerParameter::set_has_stride() { + _has_bits_[0] |= 0x00000200u; +} +void V0LayerParameter::clear_has_stride() { + _has_bits_[0] &= ~0x00000200u; +} +void V0LayerParameter::clear_stride() { + stride_ = 1u; + clear_has_stride(); +} +::google::protobuf::uint32 V0LayerParameter::stride() const { + // @@protoc_insertion_point(field_get:caffe.V0LayerParameter.stride) + return stride_; +} +void V0LayerParameter::set_stride(::google::protobuf::uint32 value) { + set_has_stride(); + stride_ = value; + // @@protoc_insertion_point(field_set:caffe.V0LayerParameter.stride) +} - // optional int32 new_width = 63 [default = 0]; - if (has_new_width()) { - total_size += 2 + - ::google::protobuf::internal::WireFormatLite::Int32Size( - this->new_width()); - } +// optional .caffe.V0LayerParameter.PoolMethod pool = 11 [default = MAX]; +bool V0LayerParameter::has_pool() const { + return (_has_bits_[0] & 0x00000400u) != 0; +} +void V0LayerParameter::set_has_pool() { + _has_bits_[0] |= 0x00000400u; +} +void V0LayerParameter::clear_has_pool() { + _has_bits_[0] &= ~0x00000400u; +} +void V0LayerParameter::clear_pool() { + pool_ = 0; + clear_has_pool(); +} +::caffe::V0LayerParameter_PoolMethod V0LayerParameter::pool() const { + // @@protoc_insertion_point(field_get:caffe.V0LayerParameter.pool) + return static_cast< ::caffe::V0LayerParameter_PoolMethod >(pool_); +} +void V0LayerParameter::set_pool(::caffe::V0LayerParameter_PoolMethod value) { + assert(::caffe::V0LayerParameter_PoolMethod_IsValid(value)); + set_has_pool(); + pool_ = value; + // @@protoc_insertion_point(field_set:caffe.V0LayerParameter.pool) +} - // optional bool shuffle_images = 64 [default = false]; - if (has_shuffle_images()) { - total_size += 2 + 1; - } +// optional float dropout_ratio = 12 [default = 0.5]; +bool V0LayerParameter::has_dropout_ratio() const { + return (_has_bits_[0] & 0x00000800u) != 0; +} +void V0LayerParameter::set_has_dropout_ratio() { + _has_bits_[0] |= 0x00000800u; +} +void V0LayerParameter::clear_has_dropout_ratio() { + _has_bits_[0] &= ~0x00000800u; +} +void V0LayerParameter::clear_dropout_ratio() { + dropout_ratio_ = 0.5f; + clear_has_dropout_ratio(); +} +float V0LayerParameter::dropout_ratio() const { + // @@protoc_insertion_point(field_get:caffe.V0LayerParameter.dropout_ratio) + return dropout_ratio_; +} +void V0LayerParameter::set_dropout_ratio(float value) { + set_has_dropout_ratio(); + dropout_ratio_ = value; + // @@protoc_insertion_point(field_set:caffe.V0LayerParameter.dropout_ratio) +} - // optional uint32 concat_dim = 65 [default = 1]; - if (has_concat_dim()) { - total_size += 2 + - ::google::protobuf::internal::WireFormatLite::UInt32Size( - this->concat_dim()); - } +// optional uint32 local_size = 13 [default = 5]; +bool V0LayerParameter::has_local_size() const { + return (_has_bits_[0] & 0x00001000u) != 0; +} +void V0LayerParameter::set_has_local_size() { + _has_bits_[0] |= 0x00001000u; +} +void V0LayerParameter::clear_has_local_size() { + _has_bits_[0] &= ~0x00001000u; +} +void V0LayerParameter::clear_local_size() { + local_size_ = 5u; + clear_has_local_size(); +} +::google::protobuf::uint32 V0LayerParameter::local_size() const { + // @@protoc_insertion_point(field_get:caffe.V0LayerParameter.local_size) + return local_size_; +} +void V0LayerParameter::set_local_size(::google::protobuf::uint32 value) { + set_has_local_size(); + local_size_ = value; + // @@protoc_insertion_point(field_set:caffe.V0LayerParameter.local_size) +} - // optional .caffe.HDF5OutputParameter hdf5_output_param = 1001; - if (has_hdf5_output_param()) { - total_size += 2 + - ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( - this->hdf5_output_param()); - } +// optional float alpha = 14 [default = 1]; +bool V0LayerParameter::has_alpha() const { + return (_has_bits_[0] & 0x00002000u) != 0; +} +void V0LayerParameter::set_has_alpha() { + _has_bits_[0] |= 0x00002000u; +} +void V0LayerParameter::clear_has_alpha() { + _has_bits_[0] &= ~0x00002000u; +} +void V0LayerParameter::clear_alpha() { + alpha_ = 1; + clear_has_alpha(); +} +float V0LayerParameter::alpha() const { + // @@protoc_insertion_point(field_get:caffe.V0LayerParameter.alpha) + return alpha_; +} +void V0LayerParameter::set_alpha(float value) { + set_has_alpha(); + alpha_ = value; + // @@protoc_insertion_point(field_set:caffe.V0LayerParameter.alpha) +} - } - // repeated .caffe.BlobProto blobs = 50; - total_size += 2 * this->blobs_size(); - for (int i = 0; i < this->blobs_size(); i++) { - total_size += - ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( - this->blobs(i)); - } +// optional float beta = 15 [default = 0.75]; +bool V0LayerParameter::has_beta() const { + return (_has_bits_[0] & 0x00004000u) != 0; +} +void V0LayerParameter::set_has_beta() { + _has_bits_[0] |= 0x00004000u; +} +void V0LayerParameter::clear_has_beta() { + _has_bits_[0] &= ~0x00004000u; +} +void V0LayerParameter::clear_beta() { + beta_ = 0.75f; + clear_has_beta(); +} +float V0LayerParameter::beta() const { + // @@protoc_insertion_point(field_get:caffe.V0LayerParameter.beta) + return beta_; +} +void V0LayerParameter::set_beta(float value) { + set_has_beta(); + beta_ = value; + // @@protoc_insertion_point(field_set:caffe.V0LayerParameter.beta) +} - // repeated float blobs_lr = 51; - { - int data_size = 0; - data_size = 4 * this->blobs_lr_size(); - total_size += 2 * this->blobs_lr_size() + data_size; - } +// optional float k = 22 [default = 1]; +bool V0LayerParameter::has_k() const { + return (_has_bits_[0] & 0x00008000u) != 0; +} +void V0LayerParameter::set_has_k() { + _has_bits_[0] |= 0x00008000u; +} +void V0LayerParameter::clear_has_k() { + _has_bits_[0] &= ~0x00008000u; +} +void V0LayerParameter::clear_k() { + k_ = 1; + clear_has_k(); +} +float V0LayerParameter::k() const { + // @@protoc_insertion_point(field_get:caffe.V0LayerParameter.k) + return k_; +} +void V0LayerParameter::set_k(float value) { + set_has_k(); + k_ = value; + // @@protoc_insertion_point(field_set:caffe.V0LayerParameter.k) +} - // repeated float weight_decay = 52; - { - int data_size = 0; - data_size = 4 * this->weight_decay_size(); - total_size += 2 * this->weight_decay_size() + data_size; +// optional string source = 16; +bool V0LayerParameter::has_source() const { + return (_has_bits_[0] & 0x00010000u) != 0; +} +void V0LayerParameter::set_has_source() { + _has_bits_[0] |= 0x00010000u; +} +void V0LayerParameter::clear_has_source() { + _has_bits_[0] &= ~0x00010000u; +} +void V0LayerParameter::clear_source() { + source_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + clear_has_source(); +} +const ::std::string& V0LayerParameter::source() const { + // @@protoc_insertion_point(field_get:caffe.V0LayerParameter.source) + return source_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); +} +void V0LayerParameter::set_source(const ::std::string& value) { + set_has_source(); + source_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); + // @@protoc_insertion_point(field_set:caffe.V0LayerParameter.source) +} +void V0LayerParameter::set_source(const char* value) { + set_has_source(); + source_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); + // @@protoc_insertion_point(field_set_char:caffe.V0LayerParameter.source) +} +void V0LayerParameter::set_source(const char* value, size_t size) { + set_has_source(); + source_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), + ::std::string(reinterpret_cast(value), size)); + // @@protoc_insertion_point(field_set_pointer:caffe.V0LayerParameter.source) +} +::std::string* V0LayerParameter::mutable_source() { + set_has_source(); + // @@protoc_insertion_point(field_mutable:caffe.V0LayerParameter.source) + return source_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); +} +::std::string* V0LayerParameter::release_source() { + // @@protoc_insertion_point(field_release:caffe.V0LayerParameter.source) + clear_has_source(); + return source_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); +} +void V0LayerParameter::set_allocated_source(::std::string* source) { + if (source != NULL) { + set_has_source(); + } else { + clear_has_source(); } + source_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), source); + // @@protoc_insertion_point(field_set_allocated:caffe.V0LayerParameter.source) +} - if (!unknown_fields().empty()) { - total_size += - ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( - unknown_fields()); - } - GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); - _cached_size_ = total_size; - GOOGLE_SAFE_CONCURRENT_WRITES_END(); - return total_size; +// optional float scale = 17 [default = 1]; +bool V0LayerParameter::has_scale() const { + return (_has_bits_[0] & 0x00020000u) != 0; +} +void V0LayerParameter::set_has_scale() { + _has_bits_[0] |= 0x00020000u; +} +void V0LayerParameter::clear_has_scale() { + _has_bits_[0] &= ~0x00020000u; +} +void V0LayerParameter::clear_scale() { + scale_ = 1; + clear_has_scale(); +} +float V0LayerParameter::scale() const { + // @@protoc_insertion_point(field_get:caffe.V0LayerParameter.scale) + return scale_; +} +void V0LayerParameter::set_scale(float value) { + set_has_scale(); + scale_ = value; + // @@protoc_insertion_point(field_set:caffe.V0LayerParameter.scale) } -void V0LayerParameter::MergeFrom(const ::google::protobuf::Message& from) { - GOOGLE_CHECK_NE(&from, this); - const V0LayerParameter* source = - ::google::protobuf::internal::dynamic_cast_if_available( - &from); - if (source == NULL) { - ::google::protobuf::internal::ReflectionOps::Merge(from, this); +// optional string meanfile = 18; +bool V0LayerParameter::has_meanfile() const { + return (_has_bits_[0] & 0x00040000u) != 0; +} +void V0LayerParameter::set_has_meanfile() { + _has_bits_[0] |= 0x00040000u; +} +void V0LayerParameter::clear_has_meanfile() { + _has_bits_[0] &= ~0x00040000u; +} +void V0LayerParameter::clear_meanfile() { + meanfile_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + clear_has_meanfile(); +} +const ::std::string& V0LayerParameter::meanfile() const { + // @@protoc_insertion_point(field_get:caffe.V0LayerParameter.meanfile) + return meanfile_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); +} +void V0LayerParameter::set_meanfile(const ::std::string& value) { + set_has_meanfile(); + meanfile_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); + // @@protoc_insertion_point(field_set:caffe.V0LayerParameter.meanfile) +} +void V0LayerParameter::set_meanfile(const char* value) { + set_has_meanfile(); + meanfile_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); + // @@protoc_insertion_point(field_set_char:caffe.V0LayerParameter.meanfile) +} +void V0LayerParameter::set_meanfile(const char* value, size_t size) { + set_has_meanfile(); + meanfile_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), + ::std::string(reinterpret_cast(value), size)); + // @@protoc_insertion_point(field_set_pointer:caffe.V0LayerParameter.meanfile) +} +::std::string* V0LayerParameter::mutable_meanfile() { + set_has_meanfile(); + // @@protoc_insertion_point(field_mutable:caffe.V0LayerParameter.meanfile) + return meanfile_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); +} +::std::string* V0LayerParameter::release_meanfile() { + // @@protoc_insertion_point(field_release:caffe.V0LayerParameter.meanfile) + clear_has_meanfile(); + return meanfile_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); +} +void V0LayerParameter::set_allocated_meanfile(::std::string* meanfile) { + if (meanfile != NULL) { + set_has_meanfile(); } else { - MergeFrom(*source); + clear_has_meanfile(); } + meanfile_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), meanfile); + // @@protoc_insertion_point(field_set_allocated:caffe.V0LayerParameter.meanfile) } -void V0LayerParameter::MergeFrom(const V0LayerParameter& from) { - GOOGLE_CHECK_NE(&from, this); - blobs_.MergeFrom(from.blobs_); - blobs_lr_.MergeFrom(from.blobs_lr_); - weight_decay_.MergeFrom(from.weight_decay_); - if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) { - if (from.has_name()) { - set_name(from.name()); - } - if (from.has_type()) { - set_type(from.type()); - } - if (from.has_num_output()) { - set_num_output(from.num_output()); - } - if (from.has_biasterm()) { - set_biasterm(from.biasterm()); - } - if (from.has_weight_filler()) { - mutable_weight_filler()->::caffe::FillerParameter::MergeFrom(from.weight_filler()); - } - if (from.has_bias_filler()) { - mutable_bias_filler()->::caffe::FillerParameter::MergeFrom(from.bias_filler()); - } - if (from.has_pad()) { - set_pad(from.pad()); - } - if (from.has_kernelsize()) { - set_kernelsize(from.kernelsize()); - } - } - if (from._has_bits_[8 / 32] & (0xffu << (8 % 32))) { - if (from.has_group()) { - set_group(from.group()); - } - if (from.has_stride()) { - set_stride(from.stride()); - } - if (from.has_pool()) { - set_pool(from.pool()); - } - if (from.has_dropout_ratio()) { - set_dropout_ratio(from.dropout_ratio()); - } - if (from.has_local_size()) { - set_local_size(from.local_size()); - } - if (from.has_alpha()) { - set_alpha(from.alpha()); - } - if (from.has_beta()) { - set_beta(from.beta()); - } - if (from.has_k()) { - set_k(from.k()); - } - } - if (from._has_bits_[16 / 32] & (0xffu << (16 % 32))) { - if (from.has_source()) { - set_source(from.source()); - } - if (from.has_scale()) { - set_scale(from.scale()); - } - if (from.has_meanfile()) { - set_meanfile(from.meanfile()); - } - if (from.has_batchsize()) { - set_batchsize(from.batchsize()); - } - if (from.has_cropsize()) { - set_cropsize(from.cropsize()); - } - if (from.has_mirror()) { - set_mirror(from.mirror()); - } - } - if (from._has_bits_[25 / 32] & (0xffu << (25 % 32))) { - if (from.has_rand_skip()) { - set_rand_skip(from.rand_skip()); - } - if (from.has_det_fg_threshold()) { - set_det_fg_threshold(from.det_fg_threshold()); - } - if (from.has_det_bg_threshold()) { - set_det_bg_threshold(from.det_bg_threshold()); - } - if (from.has_det_fg_fraction()) { - set_det_fg_fraction(from.det_fg_fraction()); - } - if (from.has_det_context_pad()) { - set_det_context_pad(from.det_context_pad()); - } - if (from.has_det_crop_mode()) { - set_det_crop_mode(from.det_crop_mode()); - } - if (from.has_new_num()) { - set_new_num(from.new_num()); - } - } - if (from._has_bits_[32 / 32] & (0xffu << (32 % 32))) { - if (from.has_new_channels()) { - set_new_channels(from.new_channels()); - } - if (from.has_new_height()) { - set_new_height(from.new_height()); - } - if (from.has_new_width()) { - set_new_width(from.new_width()); - } - if (from.has_shuffle_images()) { - set_shuffle_images(from.shuffle_images()); - } - if (from.has_concat_dim()) { - set_concat_dim(from.concat_dim()); - } - if (from.has_hdf5_output_param()) { - mutable_hdf5_output_param()->::caffe::HDF5OutputParameter::MergeFrom(from.hdf5_output_param()); - } - } - mutable_unknown_fields()->MergeFrom(from.unknown_fields()); +// optional uint32 batchsize = 19; +bool V0LayerParameter::has_batchsize() const { + return (_has_bits_[0] & 0x00080000u) != 0; +} +void V0LayerParameter::set_has_batchsize() { + _has_bits_[0] |= 0x00080000u; +} +void V0LayerParameter::clear_has_batchsize() { + _has_bits_[0] &= ~0x00080000u; +} +void V0LayerParameter::clear_batchsize() { + batchsize_ = 0u; + clear_has_batchsize(); +} +::google::protobuf::uint32 V0LayerParameter::batchsize() const { + // @@protoc_insertion_point(field_get:caffe.V0LayerParameter.batchsize) + return batchsize_; +} +void V0LayerParameter::set_batchsize(::google::protobuf::uint32 value) { + set_has_batchsize(); + batchsize_ = value; + // @@protoc_insertion_point(field_set:caffe.V0LayerParameter.batchsize) +} + +// optional uint32 cropsize = 20 [default = 0]; +bool V0LayerParameter::has_cropsize() const { + return (_has_bits_[0] & 0x00100000u) != 0; +} +void V0LayerParameter::set_has_cropsize() { + _has_bits_[0] |= 0x00100000u; +} +void V0LayerParameter::clear_has_cropsize() { + _has_bits_[0] &= ~0x00100000u; +} +void V0LayerParameter::clear_cropsize() { + cropsize_ = 0u; + clear_has_cropsize(); +} +::google::protobuf::uint32 V0LayerParameter::cropsize() const { + // @@protoc_insertion_point(field_get:caffe.V0LayerParameter.cropsize) + return cropsize_; +} +void V0LayerParameter::set_cropsize(::google::protobuf::uint32 value) { + set_has_cropsize(); + cropsize_ = value; + // @@protoc_insertion_point(field_set:caffe.V0LayerParameter.cropsize) +} + +// optional bool mirror = 21 [default = false]; +bool V0LayerParameter::has_mirror() const { + return (_has_bits_[0] & 0x00200000u) != 0; +} +void V0LayerParameter::set_has_mirror() { + _has_bits_[0] |= 0x00200000u; +} +void V0LayerParameter::clear_has_mirror() { + _has_bits_[0] &= ~0x00200000u; +} +void V0LayerParameter::clear_mirror() { + mirror_ = false; + clear_has_mirror(); +} +bool V0LayerParameter::mirror() const { + // @@protoc_insertion_point(field_get:caffe.V0LayerParameter.mirror) + return mirror_; +} +void V0LayerParameter::set_mirror(bool value) { + set_has_mirror(); + mirror_ = value; + // @@protoc_insertion_point(field_set:caffe.V0LayerParameter.mirror) +} + +// repeated .caffe.BlobProto blobs = 50; +int V0LayerParameter::blobs_size() const { + return blobs_.size(); +} +void V0LayerParameter::clear_blobs() { + blobs_.Clear(); +} +const ::caffe::BlobProto& V0LayerParameter::blobs(int index) const { + // @@protoc_insertion_point(field_get:caffe.V0LayerParameter.blobs) + return blobs_.Get(index); +} +::caffe::BlobProto* V0LayerParameter::mutable_blobs(int index) { + // @@protoc_insertion_point(field_mutable:caffe.V0LayerParameter.blobs) + return blobs_.Mutable(index); +} +::caffe::BlobProto* V0LayerParameter::add_blobs() { + // @@protoc_insertion_point(field_add:caffe.V0LayerParameter.blobs) + return blobs_.Add(); +} +::google::protobuf::RepeatedPtrField< ::caffe::BlobProto >* +V0LayerParameter::mutable_blobs() { + // @@protoc_insertion_point(field_mutable_list:caffe.V0LayerParameter.blobs) + return &blobs_; +} +const ::google::protobuf::RepeatedPtrField< ::caffe::BlobProto >& +V0LayerParameter::blobs() const { + // @@protoc_insertion_point(field_list:caffe.V0LayerParameter.blobs) + return blobs_; +} + +// repeated float blobs_lr = 51; +int V0LayerParameter::blobs_lr_size() const { + return blobs_lr_.size(); +} +void V0LayerParameter::clear_blobs_lr() { + blobs_lr_.Clear(); +} +float V0LayerParameter::blobs_lr(int index) const { + // @@protoc_insertion_point(field_get:caffe.V0LayerParameter.blobs_lr) + return blobs_lr_.Get(index); +} +void V0LayerParameter::set_blobs_lr(int index, float value) { + blobs_lr_.Set(index, value); + // @@protoc_insertion_point(field_set:caffe.V0LayerParameter.blobs_lr) +} +void V0LayerParameter::add_blobs_lr(float value) { + blobs_lr_.Add(value); + // @@protoc_insertion_point(field_add:caffe.V0LayerParameter.blobs_lr) +} +const ::google::protobuf::RepeatedField< float >& +V0LayerParameter::blobs_lr() const { + // @@protoc_insertion_point(field_list:caffe.V0LayerParameter.blobs_lr) + return blobs_lr_; +} +::google::protobuf::RepeatedField< float >* +V0LayerParameter::mutable_blobs_lr() { + // @@protoc_insertion_point(field_mutable_list:caffe.V0LayerParameter.blobs_lr) + return &blobs_lr_; +} + +// repeated float weight_decay = 52; +int V0LayerParameter::weight_decay_size() const { + return weight_decay_.size(); +} +void V0LayerParameter::clear_weight_decay() { + weight_decay_.Clear(); +} +float V0LayerParameter::weight_decay(int index) const { + // @@protoc_insertion_point(field_get:caffe.V0LayerParameter.weight_decay) + return weight_decay_.Get(index); +} +void V0LayerParameter::set_weight_decay(int index, float value) { + weight_decay_.Set(index, value); + // @@protoc_insertion_point(field_set:caffe.V0LayerParameter.weight_decay) +} +void V0LayerParameter::add_weight_decay(float value) { + weight_decay_.Add(value); + // @@protoc_insertion_point(field_add:caffe.V0LayerParameter.weight_decay) +} +const ::google::protobuf::RepeatedField< float >& +V0LayerParameter::weight_decay() const { + // @@protoc_insertion_point(field_list:caffe.V0LayerParameter.weight_decay) + return weight_decay_; +} +::google::protobuf::RepeatedField< float >* +V0LayerParameter::mutable_weight_decay() { + // @@protoc_insertion_point(field_mutable_list:caffe.V0LayerParameter.weight_decay) + return &weight_decay_; +} + +// optional uint32 rand_skip = 53 [default = 0]; +bool V0LayerParameter::has_rand_skip() const { + return (_has_bits_[0] & 0x02000000u) != 0; +} +void V0LayerParameter::set_has_rand_skip() { + _has_bits_[0] |= 0x02000000u; +} +void V0LayerParameter::clear_has_rand_skip() { + _has_bits_[0] &= ~0x02000000u; +} +void V0LayerParameter::clear_rand_skip() { + rand_skip_ = 0u; + clear_has_rand_skip(); +} +::google::protobuf::uint32 V0LayerParameter::rand_skip() const { + // @@protoc_insertion_point(field_get:caffe.V0LayerParameter.rand_skip) + return rand_skip_; +} +void V0LayerParameter::set_rand_skip(::google::protobuf::uint32 value) { + set_has_rand_skip(); + rand_skip_ = value; + // @@protoc_insertion_point(field_set:caffe.V0LayerParameter.rand_skip) } -void V0LayerParameter::CopyFrom(const ::google::protobuf::Message& from) { - if (&from == this) return; - Clear(); - MergeFrom(from); +// optional float det_fg_threshold = 54 [default = 0.5]; +bool V0LayerParameter::has_det_fg_threshold() const { + return (_has_bits_[0] & 0x04000000u) != 0; +} +void V0LayerParameter::set_has_det_fg_threshold() { + _has_bits_[0] |= 0x04000000u; +} +void V0LayerParameter::clear_has_det_fg_threshold() { + _has_bits_[0] &= ~0x04000000u; +} +void V0LayerParameter::clear_det_fg_threshold() { + det_fg_threshold_ = 0.5f; + clear_has_det_fg_threshold(); +} +float V0LayerParameter::det_fg_threshold() const { + // @@protoc_insertion_point(field_get:caffe.V0LayerParameter.det_fg_threshold) + return det_fg_threshold_; +} +void V0LayerParameter::set_det_fg_threshold(float value) { + set_has_det_fg_threshold(); + det_fg_threshold_ = value; + // @@protoc_insertion_point(field_set:caffe.V0LayerParameter.det_fg_threshold) } -void V0LayerParameter::CopyFrom(const V0LayerParameter& from) { - if (&from == this) return; - Clear(); - MergeFrom(from); +// optional float det_bg_threshold = 55 [default = 0.5]; +bool V0LayerParameter::has_det_bg_threshold() const { + return (_has_bits_[0] & 0x08000000u) != 0; +} +void V0LayerParameter::set_has_det_bg_threshold() { + _has_bits_[0] |= 0x08000000u; +} +void V0LayerParameter::clear_has_det_bg_threshold() { + _has_bits_[0] &= ~0x08000000u; +} +void V0LayerParameter::clear_det_bg_threshold() { + det_bg_threshold_ = 0.5f; + clear_has_det_bg_threshold(); +} +float V0LayerParameter::det_bg_threshold() const { + // @@protoc_insertion_point(field_get:caffe.V0LayerParameter.det_bg_threshold) + return det_bg_threshold_; +} +void V0LayerParameter::set_det_bg_threshold(float value) { + set_has_det_bg_threshold(); + det_bg_threshold_ = value; + // @@protoc_insertion_point(field_set:caffe.V0LayerParameter.det_bg_threshold) } -bool V0LayerParameter::IsInitialized() const { +// optional float det_fg_fraction = 56 [default = 0.25]; +bool V0LayerParameter::has_det_fg_fraction() const { + return (_has_bits_[0] & 0x10000000u) != 0; +} +void V0LayerParameter::set_has_det_fg_fraction() { + _has_bits_[0] |= 0x10000000u; +} +void V0LayerParameter::clear_has_det_fg_fraction() { + _has_bits_[0] &= ~0x10000000u; +} +void V0LayerParameter::clear_det_fg_fraction() { + det_fg_fraction_ = 0.25f; + clear_has_det_fg_fraction(); +} +float V0LayerParameter::det_fg_fraction() const { + // @@protoc_insertion_point(field_get:caffe.V0LayerParameter.det_fg_fraction) + return det_fg_fraction_; +} +void V0LayerParameter::set_det_fg_fraction(float value) { + set_has_det_fg_fraction(); + det_fg_fraction_ = value; + // @@protoc_insertion_point(field_set:caffe.V0LayerParameter.det_fg_fraction) +} - return true; +// optional uint32 det_context_pad = 58 [default = 0]; +bool V0LayerParameter::has_det_context_pad() const { + return (_has_bits_[0] & 0x20000000u) != 0; +} +void V0LayerParameter::set_has_det_context_pad() { + _has_bits_[0] |= 0x20000000u; +} +void V0LayerParameter::clear_has_det_context_pad() { + _has_bits_[0] &= ~0x20000000u; +} +void V0LayerParameter::clear_det_context_pad() { + det_context_pad_ = 0u; + clear_has_det_context_pad(); +} +::google::protobuf::uint32 V0LayerParameter::det_context_pad() const { + // @@protoc_insertion_point(field_get:caffe.V0LayerParameter.det_context_pad) + return det_context_pad_; +} +void V0LayerParameter::set_det_context_pad(::google::protobuf::uint32 value) { + set_has_det_context_pad(); + det_context_pad_ = value; + // @@protoc_insertion_point(field_set:caffe.V0LayerParameter.det_context_pad) } -void V0LayerParameter::Swap(V0LayerParameter* other) { - if (other != this) { - std::swap(name_, other->name_); - std::swap(type_, other->type_); - std::swap(num_output_, other->num_output_); - std::swap(biasterm_, other->biasterm_); - std::swap(weight_filler_, other->weight_filler_); - std::swap(bias_filler_, other->bias_filler_); - std::swap(pad_, other->pad_); - std::swap(kernelsize_, other->kernelsize_); - std::swap(group_, other->group_); - std::swap(stride_, other->stride_); - std::swap(pool_, other->pool_); - std::swap(dropout_ratio_, other->dropout_ratio_); - std::swap(local_size_, other->local_size_); - std::swap(alpha_, other->alpha_); - std::swap(beta_, other->beta_); - std::swap(k_, other->k_); - std::swap(source_, other->source_); - std::swap(scale_, other->scale_); - std::swap(meanfile_, other->meanfile_); - std::swap(batchsize_, other->batchsize_); - std::swap(cropsize_, other->cropsize_); - std::swap(mirror_, other->mirror_); - blobs_.Swap(&other->blobs_); - blobs_lr_.Swap(&other->blobs_lr_); - weight_decay_.Swap(&other->weight_decay_); - std::swap(rand_skip_, other->rand_skip_); - std::swap(det_fg_threshold_, other->det_fg_threshold_); - std::swap(det_bg_threshold_, other->det_bg_threshold_); - std::swap(det_fg_fraction_, other->det_fg_fraction_); - std::swap(det_context_pad_, other->det_context_pad_); - std::swap(det_crop_mode_, other->det_crop_mode_); - std::swap(new_num_, other->new_num_); - std::swap(new_channels_, other->new_channels_); - std::swap(new_height_, other->new_height_); - std::swap(new_width_, other->new_width_); - std::swap(shuffle_images_, other->shuffle_images_); - std::swap(concat_dim_, other->concat_dim_); - std::swap(hdf5_output_param_, other->hdf5_output_param_); - std::swap(_has_bits_[0], other->_has_bits_[0]); - std::swap(_has_bits_[1], other->_has_bits_[1]); - _unknown_fields_.Swap(&other->_unknown_fields_); - std::swap(_cached_size_, other->_cached_size_); +// optional string det_crop_mode = 59 [default = "warp"]; +bool V0LayerParameter::has_det_crop_mode() const { + return (_has_bits_[0] & 0x40000000u) != 0; +} +void V0LayerParameter::set_has_det_crop_mode() { + _has_bits_[0] |= 0x40000000u; +} +void V0LayerParameter::clear_has_det_crop_mode() { + _has_bits_[0] &= ~0x40000000u; +} +void V0LayerParameter::clear_det_crop_mode() { + det_crop_mode_.ClearToDefaultNoArena(_default_det_crop_mode_); + clear_has_det_crop_mode(); +} +const ::std::string& V0LayerParameter::det_crop_mode() const { + // @@protoc_insertion_point(field_get:caffe.V0LayerParameter.det_crop_mode) + return det_crop_mode_.GetNoArena(_default_det_crop_mode_); +} +void V0LayerParameter::set_det_crop_mode(const ::std::string& value) { + set_has_det_crop_mode(); + det_crop_mode_.SetNoArena(_default_det_crop_mode_, value); + // @@protoc_insertion_point(field_set:caffe.V0LayerParameter.det_crop_mode) +} +void V0LayerParameter::set_det_crop_mode(const char* value) { + set_has_det_crop_mode(); + det_crop_mode_.SetNoArena(_default_det_crop_mode_, ::std::string(value)); + // @@protoc_insertion_point(field_set_char:caffe.V0LayerParameter.det_crop_mode) +} +void V0LayerParameter::set_det_crop_mode(const char* value, size_t size) { + set_has_det_crop_mode(); + det_crop_mode_.SetNoArena(_default_det_crop_mode_, + ::std::string(reinterpret_cast(value), size)); + // @@protoc_insertion_point(field_set_pointer:caffe.V0LayerParameter.det_crop_mode) +} +::std::string* V0LayerParameter::mutable_det_crop_mode() { + set_has_det_crop_mode(); + // @@protoc_insertion_point(field_mutable:caffe.V0LayerParameter.det_crop_mode) + return det_crop_mode_.MutableNoArena(_default_det_crop_mode_); +} +::std::string* V0LayerParameter::release_det_crop_mode() { + // @@protoc_insertion_point(field_release:caffe.V0LayerParameter.det_crop_mode) + clear_has_det_crop_mode(); + return det_crop_mode_.ReleaseNoArena(_default_det_crop_mode_); +} +void V0LayerParameter::set_allocated_det_crop_mode(::std::string* det_crop_mode) { + if (det_crop_mode != NULL) { + set_has_det_crop_mode(); + } else { + clear_has_det_crop_mode(); } + det_crop_mode_.SetAllocatedNoArena(_default_det_crop_mode_, det_crop_mode); + // @@protoc_insertion_point(field_set_allocated:caffe.V0LayerParameter.det_crop_mode) } -::google::protobuf::Metadata V0LayerParameter::GetMetadata() const { - protobuf_AssignDescriptorsOnce(); - ::google::protobuf::Metadata metadata; - metadata.descriptor = V0LayerParameter_descriptor_; - metadata.reflection = V0LayerParameter_reflection_; - return metadata; +// optional int32 new_num = 60 [default = 0]; +bool V0LayerParameter::has_new_num() const { + return (_has_bits_[0] & 0x80000000u) != 0; +} +void V0LayerParameter::set_has_new_num() { + _has_bits_[0] |= 0x80000000u; +} +void V0LayerParameter::clear_has_new_num() { + _has_bits_[0] &= ~0x80000000u; +} +void V0LayerParameter::clear_new_num() { + new_num_ = 0; + clear_has_new_num(); +} +::google::protobuf::int32 V0LayerParameter::new_num() const { + // @@protoc_insertion_point(field_get:caffe.V0LayerParameter.new_num) + return new_num_; +} +void V0LayerParameter::set_new_num(::google::protobuf::int32 value) { + set_has_new_num(); + new_num_ = value; + // @@protoc_insertion_point(field_set:caffe.V0LayerParameter.new_num) +} + +// optional int32 new_channels = 61 [default = 0]; +bool V0LayerParameter::has_new_channels() const { + return (_has_bits_[1] & 0x00000001u) != 0; +} +void V0LayerParameter::set_has_new_channels() { + _has_bits_[1] |= 0x00000001u; +} +void V0LayerParameter::clear_has_new_channels() { + _has_bits_[1] &= ~0x00000001u; +} +void V0LayerParameter::clear_new_channels() { + new_channels_ = 0; + clear_has_new_channels(); +} +::google::protobuf::int32 V0LayerParameter::new_channels() const { + // @@protoc_insertion_point(field_get:caffe.V0LayerParameter.new_channels) + return new_channels_; +} +void V0LayerParameter::set_new_channels(::google::protobuf::int32 value) { + set_has_new_channels(); + new_channels_ = value; + // @@protoc_insertion_point(field_set:caffe.V0LayerParameter.new_channels) +} + +// optional int32 new_height = 62 [default = 0]; +bool V0LayerParameter::has_new_height() const { + return (_has_bits_[1] & 0x00000002u) != 0; +} +void V0LayerParameter::set_has_new_height() { + _has_bits_[1] |= 0x00000002u; +} +void V0LayerParameter::clear_has_new_height() { + _has_bits_[1] &= ~0x00000002u; +} +void V0LayerParameter::clear_new_height() { + new_height_ = 0; + clear_has_new_height(); +} +::google::protobuf::int32 V0LayerParameter::new_height() const { + // @@protoc_insertion_point(field_get:caffe.V0LayerParameter.new_height) + return new_height_; +} +void V0LayerParameter::set_new_height(::google::protobuf::int32 value) { + set_has_new_height(); + new_height_ = value; + // @@protoc_insertion_point(field_set:caffe.V0LayerParameter.new_height) +} + +// optional int32 new_width = 63 [default = 0]; +bool V0LayerParameter::has_new_width() const { + return (_has_bits_[1] & 0x00000004u) != 0; +} +void V0LayerParameter::set_has_new_width() { + _has_bits_[1] |= 0x00000004u; +} +void V0LayerParameter::clear_has_new_width() { + _has_bits_[1] &= ~0x00000004u; +} +void V0LayerParameter::clear_new_width() { + new_width_ = 0; + clear_has_new_width(); +} +::google::protobuf::int32 V0LayerParameter::new_width() const { + // @@protoc_insertion_point(field_get:caffe.V0LayerParameter.new_width) + return new_width_; +} +void V0LayerParameter::set_new_width(::google::protobuf::int32 value) { + set_has_new_width(); + new_width_ = value; + // @@protoc_insertion_point(field_set:caffe.V0LayerParameter.new_width) +} + +// optional bool shuffle_images = 64 [default = false]; +bool V0LayerParameter::has_shuffle_images() const { + return (_has_bits_[1] & 0x00000008u) != 0; +} +void V0LayerParameter::set_has_shuffle_images() { + _has_bits_[1] |= 0x00000008u; +} +void V0LayerParameter::clear_has_shuffle_images() { + _has_bits_[1] &= ~0x00000008u; +} +void V0LayerParameter::clear_shuffle_images() { + shuffle_images_ = false; + clear_has_shuffle_images(); +} +bool V0LayerParameter::shuffle_images() const { + // @@protoc_insertion_point(field_get:caffe.V0LayerParameter.shuffle_images) + return shuffle_images_; +} +void V0LayerParameter::set_shuffle_images(bool value) { + set_has_shuffle_images(); + shuffle_images_ = value; + // @@protoc_insertion_point(field_set:caffe.V0LayerParameter.shuffle_images) +} + +// optional uint32 concat_dim = 65 [default = 1]; +bool V0LayerParameter::has_concat_dim() const { + return (_has_bits_[1] & 0x00000010u) != 0; +} +void V0LayerParameter::set_has_concat_dim() { + _has_bits_[1] |= 0x00000010u; +} +void V0LayerParameter::clear_has_concat_dim() { + _has_bits_[1] &= ~0x00000010u; +} +void V0LayerParameter::clear_concat_dim() { + concat_dim_ = 1u; + clear_has_concat_dim(); +} +::google::protobuf::uint32 V0LayerParameter::concat_dim() const { + // @@protoc_insertion_point(field_get:caffe.V0LayerParameter.concat_dim) + return concat_dim_; +} +void V0LayerParameter::set_concat_dim(::google::protobuf::uint32 value) { + set_has_concat_dim(); + concat_dim_ = value; + // @@protoc_insertion_point(field_set:caffe.V0LayerParameter.concat_dim) +} + +// optional .caffe.HDF5OutputParameter hdf5_output_param = 1001; +bool V0LayerParameter::has_hdf5_output_param() const { + return (_has_bits_[1] & 0x00000020u) != 0; +} +void V0LayerParameter::set_has_hdf5_output_param() { + _has_bits_[1] |= 0x00000020u; +} +void V0LayerParameter::clear_has_hdf5_output_param() { + _has_bits_[1] &= ~0x00000020u; +} +void V0LayerParameter::clear_hdf5_output_param() { + if (hdf5_output_param_ != NULL) hdf5_output_param_->::caffe::HDF5OutputParameter::Clear(); + clear_has_hdf5_output_param(); +} +const ::caffe::HDF5OutputParameter& V0LayerParameter::hdf5_output_param() const { + // @@protoc_insertion_point(field_get:caffe.V0LayerParameter.hdf5_output_param) + return hdf5_output_param_ != NULL ? *hdf5_output_param_ + : *::caffe::HDF5OutputParameter::internal_default_instance(); +} +::caffe::HDF5OutputParameter* V0LayerParameter::mutable_hdf5_output_param() { + set_has_hdf5_output_param(); + if (hdf5_output_param_ == NULL) { + hdf5_output_param_ = new ::caffe::HDF5OutputParameter; + } + // @@protoc_insertion_point(field_mutable:caffe.V0LayerParameter.hdf5_output_param) + return hdf5_output_param_; +} +::caffe::HDF5OutputParameter* V0LayerParameter::release_hdf5_output_param() { + // @@protoc_insertion_point(field_release:caffe.V0LayerParameter.hdf5_output_param) + clear_has_hdf5_output_param(); + ::caffe::HDF5OutputParameter* temp = hdf5_output_param_; + hdf5_output_param_ = NULL; + return temp; +} +void V0LayerParameter::set_allocated_hdf5_output_param(::caffe::HDF5OutputParameter* hdf5_output_param) { + delete hdf5_output_param_; + hdf5_output_param_ = hdf5_output_param; + if (hdf5_output_param) { + set_has_hdf5_output_param(); + } else { + clear_has_hdf5_output_param(); + } + // @@protoc_insertion_point(field_set_allocated:caffe.V0LayerParameter.hdf5_output_param) } +inline const V0LayerParameter* V0LayerParameter::internal_default_instance() { + return &V0LayerParameter_default_instance_.get(); +} +#endif // PROTOBUF_INLINE_NOT_IN_HEADERS // =================================================================== -#ifndef _MSC_VER +#if !defined(_MSC_VER) || _MSC_VER >= 1900 const int PReLUParameter::kFillerFieldNumber; const int PReLUParameter::kChannelSharedFieldNumber; -#endif // !_MSC_VER +#endif // !defined(_MSC_VER) || _MSC_VER >= 1900 PReLUParameter::PReLUParameter() - : ::google::protobuf::Message() { + : ::google::protobuf::Message(), _internal_metadata_(NULL) { + if (this != internal_default_instance()) protobuf_InitDefaults_caffe_2eproto(); SharedCtor(); + // @@protoc_insertion_point(constructor:caffe.PReLUParameter) } void PReLUParameter::InitAsDefaultInstance() { - filler_ = const_cast< ::caffe::FillerParameter*>(&::caffe::FillerParameter::default_instance()); + filler_ = const_cast< ::caffe::FillerParameter*>( + ::caffe::FillerParameter::internal_default_instance()); } PReLUParameter::PReLUParameter(const PReLUParameter& from) - : ::google::protobuf::Message() { + : ::google::protobuf::Message(), + _internal_metadata_(NULL) { SharedCtor(); - MergeFrom(from); + UnsafeMergeFrom(from); + // @@protoc_insertion_point(copy_constructor:caffe.PReLUParameter) } void PReLUParameter::SharedCtor() { _cached_size_ = 0; filler_ = NULL; channel_shared_ = false; - ::memset(_has_bits_, 0, sizeof(_has_bits_)); } PReLUParameter::~PReLUParameter() { + // @@protoc_insertion_point(destructor:caffe.PReLUParameter) SharedDtor(); } void PReLUParameter::SharedDtor() { - if (this != default_instance_) { + if (this != &PReLUParameter_default_instance_.get()) { delete filler_; } } @@ -28992,41 +44643,51 @@ const ::google::protobuf::Descriptor* PReLUParameter::descriptor() { } const PReLUParameter& PReLUParameter::default_instance() { - if (default_instance_ == NULL) protobuf_AddDesc_caffe_2eproto(); - return *default_instance_; + protobuf_InitDefaults_caffe_2eproto(); + return *internal_default_instance(); } -PReLUParameter* PReLUParameter::default_instance_ = NULL; +::google::protobuf::internal::ExplicitlyConstructed PReLUParameter_default_instance_; -PReLUParameter* PReLUParameter::New() const { - return new PReLUParameter; +PReLUParameter* PReLUParameter::New(::google::protobuf::Arena* arena) const { + PReLUParameter* n = new PReLUParameter; + if (arena != NULL) { + arena->Own(n); + } + return n; } void PReLUParameter::Clear() { - if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) { +// @@protoc_insertion_point(message_clear_start:caffe.PReLUParameter) + if (_has_bits_[0 / 32] & 3u) { if (has_filler()) { if (filler_ != NULL) filler_->::caffe::FillerParameter::Clear(); } channel_shared_ = false; } - ::memset(_has_bits_, 0, sizeof(_has_bits_)); - mutable_unknown_fields()->Clear(); + _has_bits_.Clear(); + if (_internal_metadata_.have_unknown_fields()) { + mutable_unknown_fields()->Clear(); + } } bool PReLUParameter::MergePartialFromCodedStream( ::google::protobuf::io::CodedInputStream* input) { -#define DO_(EXPRESSION) if (!(EXPRESSION)) return false +#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure ::google::protobuf::uint32 tag; - while ((tag = input->ReadTag()) != 0) { + // @@protoc_insertion_point(parse_start:caffe.PReLUParameter) + for (;;) { + ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127); + tag = p.first; + if (!p.second) goto handle_unusual; switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { // optional .caffe.FillerParameter filler = 1; case 1: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) { + if (tag == 10) { DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual( input, mutable_filler())); } else { - goto handle_uninterpreted; + goto handle_unusual; } if (input->ExpectTag(16)) goto parse_channel_shared; break; @@ -29034,25 +44695,25 @@ bool PReLUParameter::MergePartialFromCodedStream( // optional bool channel_shared = 2 [default = false]; case 2: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) { + if (tag == 16) { parse_channel_shared: + set_has_channel_shared(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>( input, &channel_shared_))); - set_has_channel_shared(); } else { - goto handle_uninterpreted; + goto handle_unusual; } - if (input->ExpectAtEnd()) return true; + if (input->ExpectAtEnd()) goto success; break; } default: { - handle_uninterpreted: - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == + handle_unusual: + if (tag == 0 || + ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) { - return true; + goto success; } DO_(::google::protobuf::internal::WireFormat::SkipField( input, tag, mutable_unknown_fields())); @@ -29060,16 +44721,22 @@ bool PReLUParameter::MergePartialFromCodedStream( } } } +success: + // @@protoc_insertion_point(parse_success:caffe.PReLUParameter) return true; +failure: + // @@protoc_insertion_point(parse_failure:caffe.PReLUParameter) + return false; #undef DO_ } void PReLUParameter::SerializeWithCachedSizes( ::google::protobuf::io::CodedOutputStream* output) const { + // @@protoc_insertion_point(serialize_start:caffe.PReLUParameter) // optional .caffe.FillerParameter filler = 1; if (has_filler()) { ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( - 1, this->filler(), output); + 1, *this->filler_, output); } // optional bool channel_shared = 2 [default = false]; @@ -29077,19 +44744,22 @@ void PReLUParameter::SerializeWithCachedSizes( ::google::protobuf::internal::WireFormatLite::WriteBool(2, this->channel_shared(), output); } - if (!unknown_fields().empty()) { + if (_internal_metadata_.have_unknown_fields()) { ::google::protobuf::internal::WireFormat::SerializeUnknownFields( unknown_fields(), output); } + // @@protoc_insertion_point(serialize_end:caffe.PReLUParameter) } -::google::protobuf::uint8* PReLUParameter::SerializeWithCachedSizesToArray( - ::google::protobuf::uint8* target) const { +::google::protobuf::uint8* PReLUParameter::InternalSerializeWithCachedSizesToArray( + bool deterministic, ::google::protobuf::uint8* target) const { + (void)deterministic; // Unused + // @@protoc_insertion_point(serialize_to_array_start:caffe.PReLUParameter) // optional .caffe.FillerParameter filler = 1; if (has_filler()) { target = ::google::protobuf::internal::WireFormatLite:: - WriteMessageNoVirtualToArray( - 1, this->filler(), target); + InternalWriteMessageNoVirtualToArray( + 1, *this->filler_, false, target); } // optional bool channel_shared = 2 [default = false]; @@ -29097,22 +44767,24 @@ void PReLUParameter::SerializeWithCachedSizes( target = ::google::protobuf::internal::WireFormatLite::WriteBoolToArray(2, this->channel_shared(), target); } - if (!unknown_fields().empty()) { + if (_internal_metadata_.have_unknown_fields()) { target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray( unknown_fields(), target); } + // @@protoc_insertion_point(serialize_to_array_end:caffe.PReLUParameter) return target; } -int PReLUParameter::ByteSize() const { - int total_size = 0; +size_t PReLUParameter::ByteSizeLong() const { +// @@protoc_insertion_point(message_byte_size_start:caffe.PReLUParameter) + size_t total_size = 0; - if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) { + if (_has_bits_[0 / 32] & 3u) { // optional .caffe.FillerParameter filler = 1; if (has_filler()) { total_size += 1 + ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( - this->filler()); + *this->filler_); } // optional bool channel_shared = 2 [default = false]; @@ -29121,31 +44793,44 @@ int PReLUParameter::ByteSize() const { } } - if (!unknown_fields().empty()) { + if (_internal_metadata_.have_unknown_fields()) { total_size += ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( unknown_fields()); } + int cached_size = ::google::protobuf::internal::ToCachedSize(total_size); GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); - _cached_size_ = total_size; + _cached_size_ = cached_size; GOOGLE_SAFE_CONCURRENT_WRITES_END(); return total_size; } void PReLUParameter::MergeFrom(const ::google::protobuf::Message& from) { - GOOGLE_CHECK_NE(&from, this); +// @@protoc_insertion_point(generalized_merge_from_start:caffe.PReLUParameter) + if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__); const PReLUParameter* source = - ::google::protobuf::internal::dynamic_cast_if_available( - &from); + ::google::protobuf::internal::DynamicCastToGenerated( + &from); if (source == NULL) { + // @@protoc_insertion_point(generalized_merge_from_cast_fail:caffe.PReLUParameter) ::google::protobuf::internal::ReflectionOps::Merge(from, this); } else { - MergeFrom(*source); + // @@protoc_insertion_point(generalized_merge_from_cast_success:caffe.PReLUParameter) + UnsafeMergeFrom(*source); } } void PReLUParameter::MergeFrom(const PReLUParameter& from) { - GOOGLE_CHECK_NE(&from, this); +// @@protoc_insertion_point(class_specific_merge_from_start:caffe.PReLUParameter) + if (GOOGLE_PREDICT_TRUE(&from != this)) { + UnsafeMergeFrom(from); + } else { + MergeFromFail(__LINE__); + } +} + +void PReLUParameter::UnsafeMergeFrom(const PReLUParameter& from) { + GOOGLE_DCHECK(&from != this); if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) { if (from.has_filler()) { mutable_filler()->::caffe::FillerParameter::MergeFrom(from.filler()); @@ -29154,19 +44839,24 @@ void PReLUParameter::MergeFrom(const PReLUParameter& from) { set_channel_shared(from.channel_shared()); } } - mutable_unknown_fields()->MergeFrom(from.unknown_fields()); + if (from._internal_metadata_.have_unknown_fields()) { + ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata( + from.unknown_fields(), &_internal_metadata_); + } } void PReLUParameter::CopyFrom(const ::google::protobuf::Message& from) { +// @@protoc_insertion_point(generalized_copy_from_start:caffe.PReLUParameter) if (&from == this) return; Clear(); MergeFrom(from); } void PReLUParameter::CopyFrom(const PReLUParameter& from) { +// @@protoc_insertion_point(class_specific_copy_from_start:caffe.PReLUParameter) if (&from == this) return; Clear(); - MergeFrom(from); + UnsafeMergeFrom(from); } bool PReLUParameter::IsInitialized() const { @@ -29175,13 +44865,15 @@ bool PReLUParameter::IsInitialized() const { } void PReLUParameter::Swap(PReLUParameter* other) { - if (other != this) { - std::swap(filler_, other->filler_); - std::swap(channel_shared_, other->channel_shared_); - std::swap(_has_bits_[0], other->_has_bits_[0]); - _unknown_fields_.Swap(&other->_unknown_fields_); - std::swap(_cached_size_, other->_cached_size_); - } + if (other == this) return; + InternalSwap(other); +} +void PReLUParameter::InternalSwap(PReLUParameter* other) { + std::swap(filler_, other->filler_); + std::swap(channel_shared_, other->channel_shared_); + std::swap(_has_bits_[0], other->_has_bits_[0]); + _internal_metadata_.Swap(&other->_internal_metadata_); + std::swap(_cached_size_, other->_cached_size_); } ::google::protobuf::Metadata PReLUParameter::GetMetadata() const { @@ -29192,10 +44884,86 @@ void PReLUParameter::Swap(PReLUParameter* other) { return metadata; } +#if PROTOBUF_INLINE_NOT_IN_HEADERS +// PReLUParameter + +// optional .caffe.FillerParameter filler = 1; +bool PReLUParameter::has_filler() const { + return (_has_bits_[0] & 0x00000001u) != 0; +} +void PReLUParameter::set_has_filler() { + _has_bits_[0] |= 0x00000001u; +} +void PReLUParameter::clear_has_filler() { + _has_bits_[0] &= ~0x00000001u; +} +void PReLUParameter::clear_filler() { + if (filler_ != NULL) filler_->::caffe::FillerParameter::Clear(); + clear_has_filler(); +} +const ::caffe::FillerParameter& PReLUParameter::filler() const { + // @@protoc_insertion_point(field_get:caffe.PReLUParameter.filler) + return filler_ != NULL ? *filler_ + : *::caffe::FillerParameter::internal_default_instance(); +} +::caffe::FillerParameter* PReLUParameter::mutable_filler() { + set_has_filler(); + if (filler_ == NULL) { + filler_ = new ::caffe::FillerParameter; + } + // @@protoc_insertion_point(field_mutable:caffe.PReLUParameter.filler) + return filler_; +} +::caffe::FillerParameter* PReLUParameter::release_filler() { + // @@protoc_insertion_point(field_release:caffe.PReLUParameter.filler) + clear_has_filler(); + ::caffe::FillerParameter* temp = filler_; + filler_ = NULL; + return temp; +} +void PReLUParameter::set_allocated_filler(::caffe::FillerParameter* filler) { + delete filler_; + filler_ = filler; + if (filler) { + set_has_filler(); + } else { + clear_has_filler(); + } + // @@protoc_insertion_point(field_set_allocated:caffe.PReLUParameter.filler) +} + +// optional bool channel_shared = 2 [default = false]; +bool PReLUParameter::has_channel_shared() const { + return (_has_bits_[0] & 0x00000002u) != 0; +} +void PReLUParameter::set_has_channel_shared() { + _has_bits_[0] |= 0x00000002u; +} +void PReLUParameter::clear_has_channel_shared() { + _has_bits_[0] &= ~0x00000002u; +} +void PReLUParameter::clear_channel_shared() { + channel_shared_ = false; + clear_has_channel_shared(); +} +bool PReLUParameter::channel_shared() const { + // @@protoc_insertion_point(field_get:caffe.PReLUParameter.channel_shared) + return channel_shared_; +} +void PReLUParameter::set_channel_shared(bool value) { + set_has_channel_shared(); + channel_shared_ = value; + // @@protoc_insertion_point(field_set:caffe.PReLUParameter.channel_shared) +} + +inline const PReLUParameter* PReLUParameter::internal_default_instance() { + return &PReLUParameter_default_instance_.get(); +} +#endif // PROTOBUF_INLINE_NOT_IN_HEADERS // =================================================================== -#ifndef _MSC_VER +#if !defined(_MSC_VER) || _MSC_VER >= 1900 const int NormalizedBBox::kXminFieldNumber; const int NormalizedBBox::kYminFieldNumber; const int NormalizedBBox::kXmaxFieldNumber; @@ -29204,42 +44972,38 @@ const int NormalizedBBox::kLabelFieldNumber; const int NormalizedBBox::kDifficultFieldNumber; const int NormalizedBBox::kScoreFieldNumber; const int NormalizedBBox::kSizeFieldNumber; -#endif // !_MSC_VER +#endif // !defined(_MSC_VER) || _MSC_VER >= 1900 NormalizedBBox::NormalizedBBox() - : ::google::protobuf::Message() { + : ::google::protobuf::Message(), _internal_metadata_(NULL) { + if (this != internal_default_instance()) protobuf_InitDefaults_caffe_2eproto(); SharedCtor(); + // @@protoc_insertion_point(constructor:caffe.NormalizedBBox) } void NormalizedBBox::InitAsDefaultInstance() { } NormalizedBBox::NormalizedBBox(const NormalizedBBox& from) - : ::google::protobuf::Message() { + : ::google::protobuf::Message(), + _internal_metadata_(NULL) { SharedCtor(); - MergeFrom(from); + UnsafeMergeFrom(from); + // @@protoc_insertion_point(copy_constructor:caffe.NormalizedBBox) } void NormalizedBBox::SharedCtor() { _cached_size_ = 0; - xmin_ = 0; - ymin_ = 0; - xmax_ = 0; - ymax_ = 0; - label_ = 0; - difficult_ = false; - score_ = 0; - size_ = 0; - ::memset(_has_bits_, 0, sizeof(_has_bits_)); + ::memset(&xmin_, 0, reinterpret_cast(&size_) - + reinterpret_cast(&xmin_) + sizeof(size_)); } NormalizedBBox::~NormalizedBBox() { + // @@protoc_insertion_point(destructor:caffe.NormalizedBBox) SharedDtor(); } void NormalizedBBox::SharedDtor() { - if (this != default_instance_) { - } } void NormalizedBBox::SetCachedSize(int size) const { @@ -29253,47 +45017,68 @@ const ::google::protobuf::Descriptor* NormalizedBBox::descriptor() { } const NormalizedBBox& NormalizedBBox::default_instance() { - if (default_instance_ == NULL) protobuf_AddDesc_caffe_2eproto(); - return *default_instance_; + protobuf_InitDefaults_caffe_2eproto(); + return *internal_default_instance(); } -NormalizedBBox* NormalizedBBox::default_instance_ = NULL; +::google::protobuf::internal::ExplicitlyConstructed NormalizedBBox_default_instance_; -NormalizedBBox* NormalizedBBox::New() const { - return new NormalizedBBox; +NormalizedBBox* NormalizedBBox::New(::google::protobuf::Arena* arena) const { + NormalizedBBox* n = new NormalizedBBox; + if (arena != NULL) { + arena->Own(n); + } + return n; } void NormalizedBBox::Clear() { - if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) { - xmin_ = 0; - ymin_ = 0; - xmax_ = 0; - ymax_ = 0; - label_ = 0; - difficult_ = false; - score_ = 0; - size_ = 0; +// @@protoc_insertion_point(message_clear_start:caffe.NormalizedBBox) +#if defined(__clang__) +#define ZR_HELPER_(f) \ + _Pragma("clang diagnostic push") \ + _Pragma("clang diagnostic ignored \"-Winvalid-offsetof\"") \ + __builtin_offsetof(NormalizedBBox, f) \ + _Pragma("clang diagnostic pop") +#else +#define ZR_HELPER_(f) reinterpret_cast(\ + &reinterpret_cast(16)->f) +#endif + +#define ZR_(first, last) do {\ + ::memset(&(first), 0,\ + ZR_HELPER_(last) - ZR_HELPER_(first) + sizeof(last));\ +} while (0) + + ZR_(xmin_, size_); + +#undef ZR_HELPER_ +#undef ZR_ + + _has_bits_.Clear(); + if (_internal_metadata_.have_unknown_fields()) { + mutable_unknown_fields()->Clear(); } - ::memset(_has_bits_, 0, sizeof(_has_bits_)); - mutable_unknown_fields()->Clear(); } bool NormalizedBBox::MergePartialFromCodedStream( ::google::protobuf::io::CodedInputStream* input) { -#define DO_(EXPRESSION) if (!(EXPRESSION)) return false +#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure ::google::protobuf::uint32 tag; - while ((tag = input->ReadTag()) != 0) { + // @@protoc_insertion_point(parse_start:caffe.NormalizedBBox) + for (;;) { + ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127); + tag = p.first; + if (!p.second) goto handle_unusual; switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { // optional float xmin = 1; case 1: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_FIXED32) { + if (tag == 13) { + set_has_xmin(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< float, ::google::protobuf::internal::WireFormatLite::TYPE_FLOAT>( input, &xmin_))); - set_has_xmin(); } else { - goto handle_uninterpreted; + goto handle_unusual; } if (input->ExpectTag(21)) goto parse_ymin; break; @@ -29301,15 +45086,14 @@ bool NormalizedBBox::MergePartialFromCodedStream( // optional float ymin = 2; case 2: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_FIXED32) { + if (tag == 21) { parse_ymin: + set_has_ymin(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< float, ::google::protobuf::internal::WireFormatLite::TYPE_FLOAT>( input, &ymin_))); - set_has_ymin(); } else { - goto handle_uninterpreted; + goto handle_unusual; } if (input->ExpectTag(29)) goto parse_xmax; break; @@ -29317,15 +45101,14 @@ bool NormalizedBBox::MergePartialFromCodedStream( // optional float xmax = 3; case 3: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_FIXED32) { + if (tag == 29) { parse_xmax: + set_has_xmax(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< float, ::google::protobuf::internal::WireFormatLite::TYPE_FLOAT>( input, &xmax_))); - set_has_xmax(); } else { - goto handle_uninterpreted; + goto handle_unusual; } if (input->ExpectTag(37)) goto parse_ymax; break; @@ -29333,15 +45116,14 @@ bool NormalizedBBox::MergePartialFromCodedStream( // optional float ymax = 4; case 4: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_FIXED32) { + if (tag == 37) { parse_ymax: + set_has_ymax(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< float, ::google::protobuf::internal::WireFormatLite::TYPE_FLOAT>( input, &ymax_))); - set_has_ymax(); } else { - goto handle_uninterpreted; + goto handle_unusual; } if (input->ExpectTag(40)) goto parse_label; break; @@ -29349,15 +45131,14 @@ bool NormalizedBBox::MergePartialFromCodedStream( // optional int32 label = 5; case 5: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) { + if (tag == 40) { parse_label: + set_has_label(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>( input, &label_))); - set_has_label(); } else { - goto handle_uninterpreted; + goto handle_unusual; } if (input->ExpectTag(48)) goto parse_difficult; break; @@ -29365,15 +45146,14 @@ bool NormalizedBBox::MergePartialFromCodedStream( // optional bool difficult = 6; case 6: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) { + if (tag == 48) { parse_difficult: + set_has_difficult(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>( input, &difficult_))); - set_has_difficult(); } else { - goto handle_uninterpreted; + goto handle_unusual; } if (input->ExpectTag(61)) goto parse_score; break; @@ -29381,15 +45161,14 @@ bool NormalizedBBox::MergePartialFromCodedStream( // optional float score = 7; case 7: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_FIXED32) { + if (tag == 61) { parse_score: + set_has_score(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< float, ::google::protobuf::internal::WireFormatLite::TYPE_FLOAT>( input, &score_))); - set_has_score(); } else { - goto handle_uninterpreted; + goto handle_unusual; } if (input->ExpectTag(69)) goto parse_size; break; @@ -29397,25 +45176,25 @@ bool NormalizedBBox::MergePartialFromCodedStream( // optional float size = 8; case 8: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_FIXED32) { + if (tag == 69) { parse_size: + set_has_size(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< float, ::google::protobuf::internal::WireFormatLite::TYPE_FLOAT>( input, &size_))); - set_has_size(); } else { - goto handle_uninterpreted; + goto handle_unusual; } - if (input->ExpectAtEnd()) return true; + if (input->ExpectAtEnd()) goto success; break; } default: { - handle_uninterpreted: - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == + handle_unusual: + if (tag == 0 || + ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) { - return true; + goto success; } DO_(::google::protobuf::internal::WireFormat::SkipField( input, tag, mutable_unknown_fields())); @@ -29423,12 +45202,18 @@ bool NormalizedBBox::MergePartialFromCodedStream( } } } +success: + // @@protoc_insertion_point(parse_success:caffe.NormalizedBBox) return true; +failure: + // @@protoc_insertion_point(parse_failure:caffe.NormalizedBBox) + return false; #undef DO_ } void NormalizedBBox::SerializeWithCachedSizes( ::google::protobuf::io::CodedOutputStream* output) const { + // @@protoc_insertion_point(serialize_start:caffe.NormalizedBBox) // optional float xmin = 1; if (has_xmin()) { ::google::protobuf::internal::WireFormatLite::WriteFloat(1, this->xmin(), output); @@ -29469,14 +45254,17 @@ void NormalizedBBox::SerializeWithCachedSizes( ::google::protobuf::internal::WireFormatLite::WriteFloat(8, this->size(), output); } - if (!unknown_fields().empty()) { + if (_internal_metadata_.have_unknown_fields()) { ::google::protobuf::internal::WireFormat::SerializeUnknownFields( unknown_fields(), output); } + // @@protoc_insertion_point(serialize_end:caffe.NormalizedBBox) } -::google::protobuf::uint8* NormalizedBBox::SerializeWithCachedSizesToArray( - ::google::protobuf::uint8* target) const { +::google::protobuf::uint8* NormalizedBBox::InternalSerializeWithCachedSizesToArray( + bool deterministic, ::google::protobuf::uint8* target) const { + (void)deterministic; // Unused + // @@protoc_insertion_point(serialize_to_array_start:caffe.NormalizedBBox) // optional float xmin = 1; if (has_xmin()) { target = ::google::protobuf::internal::WireFormatLite::WriteFloatToArray(1, this->xmin(), target); @@ -29517,17 +45305,19 @@ void NormalizedBBox::SerializeWithCachedSizes( target = ::google::protobuf::internal::WireFormatLite::WriteFloatToArray(8, this->size(), target); } - if (!unknown_fields().empty()) { + if (_internal_metadata_.have_unknown_fields()) { target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray( unknown_fields(), target); } + // @@protoc_insertion_point(serialize_to_array_end:caffe.NormalizedBBox) return target; } -int NormalizedBBox::ByteSize() const { - int total_size = 0; +size_t NormalizedBBox::ByteSizeLong() const { +// @@protoc_insertion_point(message_byte_size_start:caffe.NormalizedBBox) + size_t total_size = 0; - if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) { + if (_has_bits_[0 / 32] & 255u) { // optional float xmin = 1; if (has_xmin()) { total_size += 1 + 4; @@ -29571,31 +45361,44 @@ int NormalizedBBox::ByteSize() const { } } - if (!unknown_fields().empty()) { + if (_internal_metadata_.have_unknown_fields()) { total_size += ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( unknown_fields()); } + int cached_size = ::google::protobuf::internal::ToCachedSize(total_size); GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); - _cached_size_ = total_size; + _cached_size_ = cached_size; GOOGLE_SAFE_CONCURRENT_WRITES_END(); return total_size; } void NormalizedBBox::MergeFrom(const ::google::protobuf::Message& from) { - GOOGLE_CHECK_NE(&from, this); +// @@protoc_insertion_point(generalized_merge_from_start:caffe.NormalizedBBox) + if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__); const NormalizedBBox* source = - ::google::protobuf::internal::dynamic_cast_if_available( - &from); + ::google::protobuf::internal::DynamicCastToGenerated( + &from); if (source == NULL) { + // @@protoc_insertion_point(generalized_merge_from_cast_fail:caffe.NormalizedBBox) ::google::protobuf::internal::ReflectionOps::Merge(from, this); } else { - MergeFrom(*source); + // @@protoc_insertion_point(generalized_merge_from_cast_success:caffe.NormalizedBBox) + UnsafeMergeFrom(*source); } } void NormalizedBBox::MergeFrom(const NormalizedBBox& from) { - GOOGLE_CHECK_NE(&from, this); +// @@protoc_insertion_point(class_specific_merge_from_start:caffe.NormalizedBBox) + if (GOOGLE_PREDICT_TRUE(&from != this)) { + UnsafeMergeFrom(from); + } else { + MergeFromFail(__LINE__); + } +} + +void NormalizedBBox::UnsafeMergeFrom(const NormalizedBBox& from) { + GOOGLE_DCHECK(&from != this); if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) { if (from.has_xmin()) { set_xmin(from.xmin()); @@ -29622,19 +45425,24 @@ void NormalizedBBox::MergeFrom(const NormalizedBBox& from) { set_size(from.size()); } } - mutable_unknown_fields()->MergeFrom(from.unknown_fields()); + if (from._internal_metadata_.have_unknown_fields()) { + ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata( + from.unknown_fields(), &_internal_metadata_); + } } void NormalizedBBox::CopyFrom(const ::google::protobuf::Message& from) { +// @@protoc_insertion_point(generalized_copy_from_start:caffe.NormalizedBBox) if (&from == this) return; Clear(); MergeFrom(from); } void NormalizedBBox::CopyFrom(const NormalizedBBox& from) { +// @@protoc_insertion_point(class_specific_copy_from_start:caffe.NormalizedBBox) if (&from == this) return; Clear(); - MergeFrom(from); + UnsafeMergeFrom(from); } bool NormalizedBBox::IsInitialized() const { @@ -29643,19 +45451,21 @@ bool NormalizedBBox::IsInitialized() const { } void NormalizedBBox::Swap(NormalizedBBox* other) { - if (other != this) { - std::swap(xmin_, other->xmin_); - std::swap(ymin_, other->ymin_); - std::swap(xmax_, other->xmax_); - std::swap(ymax_, other->ymax_); - std::swap(label_, other->label_); - std::swap(difficult_, other->difficult_); - std::swap(score_, other->score_); - std::swap(size_, other->size_); - std::swap(_has_bits_[0], other->_has_bits_[0]); - _unknown_fields_.Swap(&other->_unknown_fields_); - std::swap(_cached_size_, other->_cached_size_); - } + if (other == this) return; + InternalSwap(other); +} +void NormalizedBBox::InternalSwap(NormalizedBBox* other) { + std::swap(xmin_, other->xmin_); + std::swap(ymin_, other->ymin_); + std::swap(xmax_, other->xmax_); + std::swap(ymax_, other->ymax_); + std::swap(label_, other->label_); + std::swap(difficult_, other->difficult_); + std::swap(score_, other->score_); + std::swap(size_, other->size_); + std::swap(_has_bits_[0], other->_has_bits_[0]); + _internal_metadata_.Swap(&other->_internal_metadata_); + std::swap(_cached_size_, other->_cached_size_); } ::google::protobuf::Metadata NormalizedBBox::GetMetadata() const { @@ -29666,6 +45476,205 @@ void NormalizedBBox::Swap(NormalizedBBox* other) { return metadata; } +#if PROTOBUF_INLINE_NOT_IN_HEADERS +// NormalizedBBox + +// optional float xmin = 1; +bool NormalizedBBox::has_xmin() const { + return (_has_bits_[0] & 0x00000001u) != 0; +} +void NormalizedBBox::set_has_xmin() { + _has_bits_[0] |= 0x00000001u; +} +void NormalizedBBox::clear_has_xmin() { + _has_bits_[0] &= ~0x00000001u; +} +void NormalizedBBox::clear_xmin() { + xmin_ = 0; + clear_has_xmin(); +} +float NormalizedBBox::xmin() const { + // @@protoc_insertion_point(field_get:caffe.NormalizedBBox.xmin) + return xmin_; +} +void NormalizedBBox::set_xmin(float value) { + set_has_xmin(); + xmin_ = value; + // @@protoc_insertion_point(field_set:caffe.NormalizedBBox.xmin) +} + +// optional float ymin = 2; +bool NormalizedBBox::has_ymin() const { + return (_has_bits_[0] & 0x00000002u) != 0; +} +void NormalizedBBox::set_has_ymin() { + _has_bits_[0] |= 0x00000002u; +} +void NormalizedBBox::clear_has_ymin() { + _has_bits_[0] &= ~0x00000002u; +} +void NormalizedBBox::clear_ymin() { + ymin_ = 0; + clear_has_ymin(); +} +float NormalizedBBox::ymin() const { + // @@protoc_insertion_point(field_get:caffe.NormalizedBBox.ymin) + return ymin_; +} +void NormalizedBBox::set_ymin(float value) { + set_has_ymin(); + ymin_ = value; + // @@protoc_insertion_point(field_set:caffe.NormalizedBBox.ymin) +} + +// optional float xmax = 3; +bool NormalizedBBox::has_xmax() const { + return (_has_bits_[0] & 0x00000004u) != 0; +} +void NormalizedBBox::set_has_xmax() { + _has_bits_[0] |= 0x00000004u; +} +void NormalizedBBox::clear_has_xmax() { + _has_bits_[0] &= ~0x00000004u; +} +void NormalizedBBox::clear_xmax() { + xmax_ = 0; + clear_has_xmax(); +} +float NormalizedBBox::xmax() const { + // @@protoc_insertion_point(field_get:caffe.NormalizedBBox.xmax) + return xmax_; +} +void NormalizedBBox::set_xmax(float value) { + set_has_xmax(); + xmax_ = value; + // @@protoc_insertion_point(field_set:caffe.NormalizedBBox.xmax) +} + +// optional float ymax = 4; +bool NormalizedBBox::has_ymax() const { + return (_has_bits_[0] & 0x00000008u) != 0; +} +void NormalizedBBox::set_has_ymax() { + _has_bits_[0] |= 0x00000008u; +} +void NormalizedBBox::clear_has_ymax() { + _has_bits_[0] &= ~0x00000008u; +} +void NormalizedBBox::clear_ymax() { + ymax_ = 0; + clear_has_ymax(); +} +float NormalizedBBox::ymax() const { + // @@protoc_insertion_point(field_get:caffe.NormalizedBBox.ymax) + return ymax_; +} +void NormalizedBBox::set_ymax(float value) { + set_has_ymax(); + ymax_ = value; + // @@protoc_insertion_point(field_set:caffe.NormalizedBBox.ymax) +} + +// optional int32 label = 5; +bool NormalizedBBox::has_label() const { + return (_has_bits_[0] & 0x00000010u) != 0; +} +void NormalizedBBox::set_has_label() { + _has_bits_[0] |= 0x00000010u; +} +void NormalizedBBox::clear_has_label() { + _has_bits_[0] &= ~0x00000010u; +} +void NormalizedBBox::clear_label() { + label_ = 0; + clear_has_label(); +} +::google::protobuf::int32 NormalizedBBox::label() const { + // @@protoc_insertion_point(field_get:caffe.NormalizedBBox.label) + return label_; +} +void NormalizedBBox::set_label(::google::protobuf::int32 value) { + set_has_label(); + label_ = value; + // @@protoc_insertion_point(field_set:caffe.NormalizedBBox.label) +} + +// optional bool difficult = 6; +bool NormalizedBBox::has_difficult() const { + return (_has_bits_[0] & 0x00000020u) != 0; +} +void NormalizedBBox::set_has_difficult() { + _has_bits_[0] |= 0x00000020u; +} +void NormalizedBBox::clear_has_difficult() { + _has_bits_[0] &= ~0x00000020u; +} +void NormalizedBBox::clear_difficult() { + difficult_ = false; + clear_has_difficult(); +} +bool NormalizedBBox::difficult() const { + // @@protoc_insertion_point(field_get:caffe.NormalizedBBox.difficult) + return difficult_; +} +void NormalizedBBox::set_difficult(bool value) { + set_has_difficult(); + difficult_ = value; + // @@protoc_insertion_point(field_set:caffe.NormalizedBBox.difficult) +} + +// optional float score = 7; +bool NormalizedBBox::has_score() const { + return (_has_bits_[0] & 0x00000040u) != 0; +} +void NormalizedBBox::set_has_score() { + _has_bits_[0] |= 0x00000040u; +} +void NormalizedBBox::clear_has_score() { + _has_bits_[0] &= ~0x00000040u; +} +void NormalizedBBox::clear_score() { + score_ = 0; + clear_has_score(); +} +float NormalizedBBox::score() const { + // @@protoc_insertion_point(field_get:caffe.NormalizedBBox.score) + return score_; +} +void NormalizedBBox::set_score(float value) { + set_has_score(); + score_ = value; + // @@protoc_insertion_point(field_set:caffe.NormalizedBBox.score) +} + +// optional float size = 8; +bool NormalizedBBox::has_size() const { + return (_has_bits_[0] & 0x00000080u) != 0; +} +void NormalizedBBox::set_has_size() { + _has_bits_[0] |= 0x00000080u; +} +void NormalizedBBox::clear_has_size() { + _has_bits_[0] &= ~0x00000080u; +} +void NormalizedBBox::clear_size() { + size_ = 0; + clear_has_size(); +} +float NormalizedBBox::size() const { + // @@protoc_insertion_point(field_get:caffe.NormalizedBBox.size) + return size_; +} +void NormalizedBBox::set_size(float value) { + set_has_size(); + size_ = value; + // @@protoc_insertion_point(field_set:caffe.NormalizedBBox.size) +} + +inline const NormalizedBBox* NormalizedBBox::internal_default_instance() { + return &NormalizedBBox_default_instance_.get(); +} +#endif // PROTOBUF_INLINE_NOT_IN_HEADERS // @@protoc_insertion_point(namespace_scope) diff --git a/modules/dnn/misc/caffe/caffe.pb.h b/modules/dnn/misc/caffe/caffe.pb.h index 2f4835fe0..84ee77029 100644 --- a/modules/dnn/misc/caffe/caffe.pb.h +++ b/modules/dnn/misc/caffe/caffe.pb.h @@ -8,18 +8,21 @@ #include -#if GOOGLE_PROTOBUF_VERSION < 2005000 +#if GOOGLE_PROTOBUF_VERSION < 3001000 #error This file was generated by a newer version of protoc which is #error incompatible with your Protocol Buffer headers. Please update #error your headers. #endif -#if 2005000 < GOOGLE_PROTOBUF_MIN_PROTOC_VERSION +#if 3001000 < GOOGLE_PROTOBUF_MIN_PROTOC_VERSION #error This file was generated by an older version of protoc which is #error incompatible with your Protocol Buffer headers. Please #error regenerate this file with a newer version of protoc. #endif +#include +#include #include +#include #include #include #include @@ -30,39 +33,28 @@ namespace caffe { // Internal implementation detail -- do not call these. -void protobuf_AddDesc_caffe_2eproto(); +void protobuf_AddDesc_caffe_2eproto(); +void protobuf_InitDefaults_caffe_2eproto(); void protobuf_AssignDesc_caffe_2eproto(); void protobuf_ShutdownFile_caffe_2eproto(); -class BlobShape; -class BlobProto; -class BlobProtoVector; -class CropParameter; -class PermuteParameter; -class NormalizeBBoxParameter; -class PriorBoxParameter; -class DetectionOutputParameter; -class Datum; -class FillerParameter; -class NetParameter; -class SolverParameter; -class SolverState; -class NetState; -class NetStateRule; -class ParamSpec; -class LayerParameter; -class TransformationParameter; -class LossParameter; class AccuracyParameter; class ArgMaxParameter; +class BlobProto; +class BlobProtoVector; +class BlobShape; class ConcatParameter; class ContrastiveLossParameter; class ConvolutionParameter; +class CropParameter; class DataParameter; +class Datum; +class DetectionOutputParameter; class DropoutParameter; class DummyDataParameter; class EltwiseParameter; class ExpParameter; +class FillerParameter; class FlattenParameter; class HDF5DataParameter; class HDF5OutputParameter; @@ -70,27 +62,39 @@ class HingeLossParameter; class ImageDataParameter; class InfogainLossParameter; class InnerProductParameter; -class LogParameter; class LRNParameter; -class MemoryDataParameter; +class LayerParameter; +class LogParameter; +class LossParameter; class MVNParameter; +class MemoryDataParameter; +class NetParameter; +class NetState; +class NetStateRule; +class NormalizeBBoxParameter; +class NormalizedBBox; +class PReLUParameter; +class ParamSpec; +class PermuteParameter; class PoolingParameter; class PowerParameter; +class PriorBoxParameter; class PythonParameter; -class ReductionParameter; class ReLUParameter; +class ReductionParameter; class ReshapeParameter; +class SPPParameter; class SigmoidParameter; class SliceParameter; class SoftmaxParameter; +class SolverParameter; +class SolverState; class TanHParameter; class ThresholdParameter; -class WindowDataParameter; -class SPPParameter; -class V1LayerParameter; +class TransformationParameter; class V0LayerParameter; -class PReLUParameter; -class NormalizedBBox; +class V1LayerParameter; +class WindowDataParameter; enum PriorBoxParameter_CodeType { PriorBoxParameter_CodeType_CORNER = 1, @@ -584,7 +588,7 @@ inline bool Phase_Parse( } // =================================================================== -class BlobShape : public ::google::protobuf::Message { +class BlobShape : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:caffe.BlobShape) */ { public: BlobShape(); virtual ~BlobShape(); @@ -597,21 +601,25 @@ class BlobShape : public ::google::protobuf::Message { } inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const { - return _unknown_fields_; + return _internal_metadata_.unknown_fields(); } inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() { - return &_unknown_fields_; + return _internal_metadata_.mutable_unknown_fields(); } static const ::google::protobuf::Descriptor* descriptor(); static const BlobShape& default_instance(); + static const BlobShape* internal_default_instance(); + void Swap(BlobShape* other); // implements Message ---------------------------------------------- - BlobShape* New() const; + inline BlobShape* New() const { return New(NULL); } + + BlobShape* New(::google::protobuf::Arena* arena) const; void CopyFrom(const ::google::protobuf::Message& from); void MergeFrom(const ::google::protobuf::Message& from); void CopyFrom(const BlobShape& from); @@ -619,17 +627,30 @@ class BlobShape : public ::google::protobuf::Message { void Clear(); bool IsInitialized() const; - int ByteSize() const; + size_t ByteSizeLong() const; bool MergePartialFromCodedStream( ::google::protobuf::io::CodedInputStream* input); void SerializeWithCachedSizes( ::google::protobuf::io::CodedOutputStream* output) const; - ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const; + ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray( + bool deterministic, ::google::protobuf::uint8* output) const; + ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const { + return InternalSerializeWithCachedSizesToArray(false, output); + } int GetCachedSize() const { return _cached_size_; } private: void SharedCtor(); void SharedDtor(); void SetCachedSize(int size) const; + void InternalSwap(BlobShape* other); + void UnsafeMergeFrom(const BlobShape& from); + private: + inline ::google::protobuf::Arena* GetArenaNoVirtual() const { + return _internal_metadata_.arena(); + } + inline void* MaybeArenaPtr() const { + return _internal_metadata_.raw_arena_ptr(); + } public: ::google::protobuf::Metadata GetMetadata() const; @@ -639,38 +660,37 @@ class BlobShape : public ::google::protobuf::Message { // accessors ------------------------------------------------------- // repeated int64 dim = 1 [packed = true]; - inline int dim_size() const; - inline void clear_dim(); + int dim_size() const; + void clear_dim(); static const int kDimFieldNumber = 1; - inline ::google::protobuf::int64 dim(int index) const; - inline void set_dim(int index, ::google::protobuf::int64 value); - inline void add_dim(::google::protobuf::int64 value); - inline const ::google::protobuf::RepeatedField< ::google::protobuf::int64 >& + ::google::protobuf::int64 dim(int index) const; + void set_dim(int index, ::google::protobuf::int64 value); + void add_dim(::google::protobuf::int64 value); + const ::google::protobuf::RepeatedField< ::google::protobuf::int64 >& dim() const; - inline ::google::protobuf::RepeatedField< ::google::protobuf::int64 >* + ::google::protobuf::RepeatedField< ::google::protobuf::int64 >* mutable_dim(); // @@protoc_insertion_point(class_scope:caffe.BlobShape) private: - ::google::protobuf::UnknownFieldSet _unknown_fields_; - + ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_; + ::google::protobuf::internal::HasBits<1> _has_bits_; + mutable int _cached_size_; ::google::protobuf::RepeatedField< ::google::protobuf::int64 > dim_; mutable int _dim_cached_byte_size_; - - mutable int _cached_size_; - ::google::protobuf::uint32 _has_bits_[(1 + 31) / 32]; - - friend void protobuf_AddDesc_caffe_2eproto(); + friend void protobuf_InitDefaults_caffe_2eproto_impl(); + friend void protobuf_AddDesc_caffe_2eproto_impl(); friend void protobuf_AssignDesc_caffe_2eproto(); friend void protobuf_ShutdownFile_caffe_2eproto(); void InitAsDefaultInstance(); - static BlobShape* default_instance_; }; +extern ::google::protobuf::internal::ExplicitlyConstructed BlobShape_default_instance_; + // ------------------------------------------------------------------- -class BlobProto : public ::google::protobuf::Message { +class BlobProto : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:caffe.BlobProto) */ { public: BlobProto(); virtual ~BlobProto(); @@ -683,21 +703,25 @@ class BlobProto : public ::google::protobuf::Message { } inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const { - return _unknown_fields_; + return _internal_metadata_.unknown_fields(); } inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() { - return &_unknown_fields_; + return _internal_metadata_.mutable_unknown_fields(); } static const ::google::protobuf::Descriptor* descriptor(); static const BlobProto& default_instance(); + static const BlobProto* internal_default_instance(); + void Swap(BlobProto* other); // implements Message ---------------------------------------------- - BlobProto* New() const; + inline BlobProto* New() const { return New(NULL); } + + BlobProto* New(::google::protobuf::Arena* arena) const; void CopyFrom(const ::google::protobuf::Message& from); void MergeFrom(const ::google::protobuf::Message& from); void CopyFrom(const BlobProto& from); @@ -705,17 +729,30 @@ class BlobProto : public ::google::protobuf::Message { void Clear(); bool IsInitialized() const; - int ByteSize() const; + size_t ByteSizeLong() const; bool MergePartialFromCodedStream( ::google::protobuf::io::CodedInputStream* input); void SerializeWithCachedSizes( ::google::protobuf::io::CodedOutputStream* output) const; - ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const; + ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray( + bool deterministic, ::google::protobuf::uint8* output) const; + ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const { + return InternalSerializeWithCachedSizesToArray(false, output); + } int GetCachedSize() const { return _cached_size_; } private: void SharedCtor(); void SharedDtor(); void SetCachedSize(int size) const; + void InternalSwap(BlobProto* other); + void UnsafeMergeFrom(const BlobProto& from); + private: + inline ::google::protobuf::Arena* GetArenaNoVirtual() const { + return _internal_metadata_.arena(); + } + inline void* MaybeArenaPtr() const { + return _internal_metadata_.raw_arena_ptr(); + } public: ::google::protobuf::Metadata GetMetadata() const; @@ -725,65 +762,65 @@ class BlobProto : public ::google::protobuf::Message { // accessors ------------------------------------------------------- // optional .caffe.BlobShape shape = 7; - inline bool has_shape() const; - inline void clear_shape(); + bool has_shape() const; + void clear_shape(); static const int kShapeFieldNumber = 7; - inline const ::caffe::BlobShape& shape() const; - inline ::caffe::BlobShape* mutable_shape(); - inline ::caffe::BlobShape* release_shape(); - inline void set_allocated_shape(::caffe::BlobShape* shape); + const ::caffe::BlobShape& shape() const; + ::caffe::BlobShape* mutable_shape(); + ::caffe::BlobShape* release_shape(); + void set_allocated_shape(::caffe::BlobShape* shape); // repeated float data = 5 [packed = true]; - inline int data_size() const; - inline void clear_data(); + int data_size() const; + void clear_data(); static const int kDataFieldNumber = 5; - inline float data(int index) const; - inline void set_data(int index, float value); - inline void add_data(float value); - inline const ::google::protobuf::RepeatedField< float >& + float data(int index) const; + void set_data(int index, float value); + void add_data(float value); + const ::google::protobuf::RepeatedField< float >& data() const; - inline ::google::protobuf::RepeatedField< float >* + ::google::protobuf::RepeatedField< float >* mutable_data(); // repeated float diff = 6 [packed = true]; - inline int diff_size() const; - inline void clear_diff(); + int diff_size() const; + void clear_diff(); static const int kDiffFieldNumber = 6; - inline float diff(int index) const; - inline void set_diff(int index, float value); - inline void add_diff(float value); - inline const ::google::protobuf::RepeatedField< float >& + float diff(int index) const; + void set_diff(int index, float value); + void add_diff(float value); + const ::google::protobuf::RepeatedField< float >& diff() const; - inline ::google::protobuf::RepeatedField< float >* + ::google::protobuf::RepeatedField< float >* mutable_diff(); // optional int32 num = 1 [default = 0]; - inline bool has_num() const; - inline void clear_num(); + bool has_num() const; + void clear_num(); static const int kNumFieldNumber = 1; - inline ::google::protobuf::int32 num() const; - inline void set_num(::google::protobuf::int32 value); + ::google::protobuf::int32 num() const; + void set_num(::google::protobuf::int32 value); // optional int32 channels = 2 [default = 0]; - inline bool has_channels() const; - inline void clear_channels(); + bool has_channels() const; + void clear_channels(); static const int kChannelsFieldNumber = 2; - inline ::google::protobuf::int32 channels() const; - inline void set_channels(::google::protobuf::int32 value); + ::google::protobuf::int32 channels() const; + void set_channels(::google::protobuf::int32 value); // optional int32 height = 3 [default = 0]; - inline bool has_height() const; - inline void clear_height(); + bool has_height() const; + void clear_height(); static const int kHeightFieldNumber = 3; - inline ::google::protobuf::int32 height() const; - inline void set_height(::google::protobuf::int32 value); + ::google::protobuf::int32 height() const; + void set_height(::google::protobuf::int32 value); // optional int32 width = 4 [default = 0]; - inline bool has_width() const; - inline void clear_width(); + bool has_width() const; + void clear_width(); static const int kWidthFieldNumber = 4; - inline ::google::protobuf::int32 width() const; - inline void set_width(::google::protobuf::int32 value); + ::google::protobuf::int32 width() const; + void set_width(::google::protobuf::int32 value); // @@protoc_insertion_point(class_scope:caffe.BlobProto) private: @@ -798,31 +835,30 @@ class BlobProto : public ::google::protobuf::Message { inline void set_has_width(); inline void clear_has_width(); - ::google::protobuf::UnknownFieldSet _unknown_fields_; - - ::caffe::BlobShape* shape_; + ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_; + ::google::protobuf::internal::HasBits<1> _has_bits_; + mutable int _cached_size_; ::google::protobuf::RepeatedField< float > data_; mutable int _data_cached_byte_size_; ::google::protobuf::RepeatedField< float > diff_; mutable int _diff_cached_byte_size_; + ::caffe::BlobShape* shape_; ::google::protobuf::int32 num_; ::google::protobuf::int32 channels_; ::google::protobuf::int32 height_; ::google::protobuf::int32 width_; - - mutable int _cached_size_; - ::google::protobuf::uint32 _has_bits_[(7 + 31) / 32]; - - friend void protobuf_AddDesc_caffe_2eproto(); + friend void protobuf_InitDefaults_caffe_2eproto_impl(); + friend void protobuf_AddDesc_caffe_2eproto_impl(); friend void protobuf_AssignDesc_caffe_2eproto(); friend void protobuf_ShutdownFile_caffe_2eproto(); void InitAsDefaultInstance(); - static BlobProto* default_instance_; }; +extern ::google::protobuf::internal::ExplicitlyConstructed BlobProto_default_instance_; + // ------------------------------------------------------------------- -class BlobProtoVector : public ::google::protobuf::Message { +class BlobProtoVector : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:caffe.BlobProtoVector) */ { public: BlobProtoVector(); virtual ~BlobProtoVector(); @@ -835,21 +871,25 @@ class BlobProtoVector : public ::google::protobuf::Message { } inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const { - return _unknown_fields_; + return _internal_metadata_.unknown_fields(); } inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() { - return &_unknown_fields_; + return _internal_metadata_.mutable_unknown_fields(); } static const ::google::protobuf::Descriptor* descriptor(); static const BlobProtoVector& default_instance(); + static const BlobProtoVector* internal_default_instance(); + void Swap(BlobProtoVector* other); // implements Message ---------------------------------------------- - BlobProtoVector* New() const; + inline BlobProtoVector* New() const { return New(NULL); } + + BlobProtoVector* New(::google::protobuf::Arena* arena) const; void CopyFrom(const ::google::protobuf::Message& from); void MergeFrom(const ::google::protobuf::Message& from); void CopyFrom(const BlobProtoVector& from); @@ -857,17 +897,30 @@ class BlobProtoVector : public ::google::protobuf::Message { void Clear(); bool IsInitialized() const; - int ByteSize() const; + size_t ByteSizeLong() const; bool MergePartialFromCodedStream( ::google::protobuf::io::CodedInputStream* input); void SerializeWithCachedSizes( ::google::protobuf::io::CodedOutputStream* output) const; - ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const; + ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray( + bool deterministic, ::google::protobuf::uint8* output) const; + ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const { + return InternalSerializeWithCachedSizesToArray(false, output); + } int GetCachedSize() const { return _cached_size_; } private: void SharedCtor(); void SharedDtor(); void SetCachedSize(int size) const; + void InternalSwap(BlobProtoVector* other); + void UnsafeMergeFrom(const BlobProtoVector& from); + private: + inline ::google::protobuf::Arena* GetArenaNoVirtual() const { + return _internal_metadata_.arena(); + } + inline void* MaybeArenaPtr() const { + return _internal_metadata_.raw_arena_ptr(); + } public: ::google::protobuf::Metadata GetMetadata() const; @@ -877,37 +930,36 @@ class BlobProtoVector : public ::google::protobuf::Message { // accessors ------------------------------------------------------- // repeated .caffe.BlobProto blobs = 1; - inline int blobs_size() const; - inline void clear_blobs(); + int blobs_size() const; + void clear_blobs(); static const int kBlobsFieldNumber = 1; - inline const ::caffe::BlobProto& blobs(int index) const; - inline ::caffe::BlobProto* mutable_blobs(int index); - inline ::caffe::BlobProto* add_blobs(); - inline const ::google::protobuf::RepeatedPtrField< ::caffe::BlobProto >& - blobs() const; - inline ::google::protobuf::RepeatedPtrField< ::caffe::BlobProto >* + const ::caffe::BlobProto& blobs(int index) const; + ::caffe::BlobProto* mutable_blobs(int index); + ::caffe::BlobProto* add_blobs(); + ::google::protobuf::RepeatedPtrField< ::caffe::BlobProto >* mutable_blobs(); + const ::google::protobuf::RepeatedPtrField< ::caffe::BlobProto >& + blobs() const; // @@protoc_insertion_point(class_scope:caffe.BlobProtoVector) private: - ::google::protobuf::UnknownFieldSet _unknown_fields_; - - ::google::protobuf::RepeatedPtrField< ::caffe::BlobProto > blobs_; - + ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_; + ::google::protobuf::internal::HasBits<1> _has_bits_; mutable int _cached_size_; - ::google::protobuf::uint32 _has_bits_[(1 + 31) / 32]; - - friend void protobuf_AddDesc_caffe_2eproto(); + ::google::protobuf::RepeatedPtrField< ::caffe::BlobProto > blobs_; + friend void protobuf_InitDefaults_caffe_2eproto_impl(); + friend void protobuf_AddDesc_caffe_2eproto_impl(); friend void protobuf_AssignDesc_caffe_2eproto(); friend void protobuf_ShutdownFile_caffe_2eproto(); void InitAsDefaultInstance(); - static BlobProtoVector* default_instance_; }; +extern ::google::protobuf::internal::ExplicitlyConstructed BlobProtoVector_default_instance_; + // ------------------------------------------------------------------- -class CropParameter : public ::google::protobuf::Message { +class CropParameter : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:caffe.CropParameter) */ { public: CropParameter(); virtual ~CropParameter(); @@ -920,21 +972,25 @@ class CropParameter : public ::google::protobuf::Message { } inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const { - return _unknown_fields_; + return _internal_metadata_.unknown_fields(); } inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() { - return &_unknown_fields_; + return _internal_metadata_.mutable_unknown_fields(); } static const ::google::protobuf::Descriptor* descriptor(); static const CropParameter& default_instance(); + static const CropParameter* internal_default_instance(); + void Swap(CropParameter* other); // implements Message ---------------------------------------------- - CropParameter* New() const; + inline CropParameter* New() const { return New(NULL); } + + CropParameter* New(::google::protobuf::Arena* arena) const; void CopyFrom(const ::google::protobuf::Message& from); void MergeFrom(const ::google::protobuf::Message& from); void CopyFrom(const CropParameter& from); @@ -942,17 +998,30 @@ class CropParameter : public ::google::protobuf::Message { void Clear(); bool IsInitialized() const; - int ByteSize() const; + size_t ByteSizeLong() const; bool MergePartialFromCodedStream( ::google::protobuf::io::CodedInputStream* input); void SerializeWithCachedSizes( ::google::protobuf::io::CodedOutputStream* output) const; - ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const; + ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray( + bool deterministic, ::google::protobuf::uint8* output) const; + ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const { + return InternalSerializeWithCachedSizesToArray(false, output); + } int GetCachedSize() const { return _cached_size_; } private: void SharedCtor(); void SharedDtor(); void SetCachedSize(int size) const; + void InternalSwap(CropParameter* other); + void UnsafeMergeFrom(const CropParameter& from); + private: + inline ::google::protobuf::Arena* GetArenaNoVirtual() const { + return _internal_metadata_.arena(); + } + inline void* MaybeArenaPtr() const { + return _internal_metadata_.raw_arena_ptr(); + } public: ::google::protobuf::Metadata GetMetadata() const; @@ -962,22 +1031,22 @@ class CropParameter : public ::google::protobuf::Message { // accessors ------------------------------------------------------- // optional int32 axis = 1 [default = 2]; - inline bool has_axis() const; - inline void clear_axis(); + bool has_axis() const; + void clear_axis(); static const int kAxisFieldNumber = 1; - inline ::google::protobuf::int32 axis() const; - inline void set_axis(::google::protobuf::int32 value); + ::google::protobuf::int32 axis() const; + void set_axis(::google::protobuf::int32 value); // repeated uint32 offset = 2; - inline int offset_size() const; - inline void clear_offset(); + int offset_size() const; + void clear_offset(); static const int kOffsetFieldNumber = 2; - inline ::google::protobuf::uint32 offset(int index) const; - inline void set_offset(int index, ::google::protobuf::uint32 value); - inline void add_offset(::google::protobuf::uint32 value); - inline const ::google::protobuf::RepeatedField< ::google::protobuf::uint32 >& + ::google::protobuf::uint32 offset(int index) const; + void set_offset(int index, ::google::protobuf::uint32 value); + void add_offset(::google::protobuf::uint32 value); + const ::google::protobuf::RepeatedField< ::google::protobuf::uint32 >& offset() const; - inline ::google::protobuf::RepeatedField< ::google::protobuf::uint32 >* + ::google::protobuf::RepeatedField< ::google::protobuf::uint32 >* mutable_offset(); // @@protoc_insertion_point(class_scope:caffe.CropParameter) @@ -985,24 +1054,23 @@ class CropParameter : public ::google::protobuf::Message { inline void set_has_axis(); inline void clear_has_axis(); - ::google::protobuf::UnknownFieldSet _unknown_fields_; - + ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_; + ::google::protobuf::internal::HasBits<1> _has_bits_; + mutable int _cached_size_; ::google::protobuf::RepeatedField< ::google::protobuf::uint32 > offset_; ::google::protobuf::int32 axis_; - - mutable int _cached_size_; - ::google::protobuf::uint32 _has_bits_[(2 + 31) / 32]; - - friend void protobuf_AddDesc_caffe_2eproto(); + friend void protobuf_InitDefaults_caffe_2eproto_impl(); + friend void protobuf_AddDesc_caffe_2eproto_impl(); friend void protobuf_AssignDesc_caffe_2eproto(); friend void protobuf_ShutdownFile_caffe_2eproto(); void InitAsDefaultInstance(); - static CropParameter* default_instance_; }; +extern ::google::protobuf::internal::ExplicitlyConstructed CropParameter_default_instance_; + // ------------------------------------------------------------------- -class PermuteParameter : public ::google::protobuf::Message { +class PermuteParameter : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:caffe.PermuteParameter) */ { public: PermuteParameter(); virtual ~PermuteParameter(); @@ -1015,21 +1083,25 @@ class PermuteParameter : public ::google::protobuf::Message { } inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const { - return _unknown_fields_; + return _internal_metadata_.unknown_fields(); } inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() { - return &_unknown_fields_; + return _internal_metadata_.mutable_unknown_fields(); } static const ::google::protobuf::Descriptor* descriptor(); static const PermuteParameter& default_instance(); + static const PermuteParameter* internal_default_instance(); + void Swap(PermuteParameter* other); // implements Message ---------------------------------------------- - PermuteParameter* New() const; + inline PermuteParameter* New() const { return New(NULL); } + + PermuteParameter* New(::google::protobuf::Arena* arena) const; void CopyFrom(const ::google::protobuf::Message& from); void MergeFrom(const ::google::protobuf::Message& from); void CopyFrom(const PermuteParameter& from); @@ -1037,17 +1109,30 @@ class PermuteParameter : public ::google::protobuf::Message { void Clear(); bool IsInitialized() const; - int ByteSize() const; + size_t ByteSizeLong() const; bool MergePartialFromCodedStream( ::google::protobuf::io::CodedInputStream* input); void SerializeWithCachedSizes( ::google::protobuf::io::CodedOutputStream* output) const; - ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const; + ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray( + bool deterministic, ::google::protobuf::uint8* output) const; + ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const { + return InternalSerializeWithCachedSizesToArray(false, output); + } int GetCachedSize() const { return _cached_size_; } private: void SharedCtor(); void SharedDtor(); void SetCachedSize(int size) const; + void InternalSwap(PermuteParameter* other); + void UnsafeMergeFrom(const PermuteParameter& from); + private: + inline ::google::protobuf::Arena* GetArenaNoVirtual() const { + return _internal_metadata_.arena(); + } + inline void* MaybeArenaPtr() const { + return _internal_metadata_.raw_arena_ptr(); + } public: ::google::protobuf::Metadata GetMetadata() const; @@ -1057,37 +1142,36 @@ class PermuteParameter : public ::google::protobuf::Message { // accessors ------------------------------------------------------- // repeated uint32 order = 1; - inline int order_size() const; - inline void clear_order(); + int order_size() const; + void clear_order(); static const int kOrderFieldNumber = 1; - inline ::google::protobuf::uint32 order(int index) const; - inline void set_order(int index, ::google::protobuf::uint32 value); - inline void add_order(::google::protobuf::uint32 value); - inline const ::google::protobuf::RepeatedField< ::google::protobuf::uint32 >& + ::google::protobuf::uint32 order(int index) const; + void set_order(int index, ::google::protobuf::uint32 value); + void add_order(::google::protobuf::uint32 value); + const ::google::protobuf::RepeatedField< ::google::protobuf::uint32 >& order() const; - inline ::google::protobuf::RepeatedField< ::google::protobuf::uint32 >* + ::google::protobuf::RepeatedField< ::google::protobuf::uint32 >* mutable_order(); // @@protoc_insertion_point(class_scope:caffe.PermuteParameter) private: - ::google::protobuf::UnknownFieldSet _unknown_fields_; - - ::google::protobuf::RepeatedField< ::google::protobuf::uint32 > order_; - + ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_; + ::google::protobuf::internal::HasBits<1> _has_bits_; mutable int _cached_size_; - ::google::protobuf::uint32 _has_bits_[(1 + 31) / 32]; - - friend void protobuf_AddDesc_caffe_2eproto(); + ::google::protobuf::RepeatedField< ::google::protobuf::uint32 > order_; + friend void protobuf_InitDefaults_caffe_2eproto_impl(); + friend void protobuf_AddDesc_caffe_2eproto_impl(); friend void protobuf_AssignDesc_caffe_2eproto(); friend void protobuf_ShutdownFile_caffe_2eproto(); void InitAsDefaultInstance(); - static PermuteParameter* default_instance_; }; +extern ::google::protobuf::internal::ExplicitlyConstructed PermuteParameter_default_instance_; + // ------------------------------------------------------------------- -class NormalizeBBoxParameter : public ::google::protobuf::Message { +class NormalizeBBoxParameter : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:caffe.NormalizeBBoxParameter) */ { public: NormalizeBBoxParameter(); virtual ~NormalizeBBoxParameter(); @@ -1100,21 +1184,25 @@ class NormalizeBBoxParameter : public ::google::protobuf::Message { } inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const { - return _unknown_fields_; + return _internal_metadata_.unknown_fields(); } inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() { - return &_unknown_fields_; + return _internal_metadata_.mutable_unknown_fields(); } static const ::google::protobuf::Descriptor* descriptor(); static const NormalizeBBoxParameter& default_instance(); + static const NormalizeBBoxParameter* internal_default_instance(); + void Swap(NormalizeBBoxParameter* other); // implements Message ---------------------------------------------- - NormalizeBBoxParameter* New() const; + inline NormalizeBBoxParameter* New() const { return New(NULL); } + + NormalizeBBoxParameter* New(::google::protobuf::Arena* arena) const; void CopyFrom(const ::google::protobuf::Message& from); void MergeFrom(const ::google::protobuf::Message& from); void CopyFrom(const NormalizeBBoxParameter& from); @@ -1122,17 +1210,30 @@ class NormalizeBBoxParameter : public ::google::protobuf::Message { void Clear(); bool IsInitialized() const; - int ByteSize() const; + size_t ByteSizeLong() const; bool MergePartialFromCodedStream( ::google::protobuf::io::CodedInputStream* input); void SerializeWithCachedSizes( ::google::protobuf::io::CodedOutputStream* output) const; - ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const; + ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray( + bool deterministic, ::google::protobuf::uint8* output) const; + ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const { + return InternalSerializeWithCachedSizesToArray(false, output); + } int GetCachedSize() const { return _cached_size_; } private: void SharedCtor(); void SharedDtor(); void SetCachedSize(int size) const; + void InternalSwap(NormalizeBBoxParameter* other); + void UnsafeMergeFrom(const NormalizeBBoxParameter& from); + private: + inline ::google::protobuf::Arena* GetArenaNoVirtual() const { + return _internal_metadata_.arena(); + } + inline void* MaybeArenaPtr() const { + return _internal_metadata_.raw_arena_ptr(); + } public: ::google::protobuf::Metadata GetMetadata() const; @@ -1142,34 +1243,34 @@ class NormalizeBBoxParameter : public ::google::protobuf::Message { // accessors ------------------------------------------------------- // optional bool across_spatial = 1 [default = true]; - inline bool has_across_spatial() const; - inline void clear_across_spatial(); + bool has_across_spatial() const; + void clear_across_spatial(); static const int kAcrossSpatialFieldNumber = 1; - inline bool across_spatial() const; - inline void set_across_spatial(bool value); + bool across_spatial() const; + void set_across_spatial(bool value); // optional .caffe.FillerParameter scale_filler = 2; - inline bool has_scale_filler() const; - inline void clear_scale_filler(); + bool has_scale_filler() const; + void clear_scale_filler(); static const int kScaleFillerFieldNumber = 2; - inline const ::caffe::FillerParameter& scale_filler() const; - inline ::caffe::FillerParameter* mutable_scale_filler(); - inline ::caffe::FillerParameter* release_scale_filler(); - inline void set_allocated_scale_filler(::caffe::FillerParameter* scale_filler); + const ::caffe::FillerParameter& scale_filler() const; + ::caffe::FillerParameter* mutable_scale_filler(); + ::caffe::FillerParameter* release_scale_filler(); + void set_allocated_scale_filler(::caffe::FillerParameter* scale_filler); // optional bool channel_shared = 3 [default = true]; - inline bool has_channel_shared() const; - inline void clear_channel_shared(); + bool has_channel_shared() const; + void clear_channel_shared(); static const int kChannelSharedFieldNumber = 3; - inline bool channel_shared() const; - inline void set_channel_shared(bool value); + bool channel_shared() const; + void set_channel_shared(bool value); // optional float eps = 4 [default = 1e-10]; - inline bool has_eps() const; - inline void clear_eps(); + bool has_eps() const; + void clear_eps(); static const int kEpsFieldNumber = 4; - inline float eps() const; - inline void set_eps(float value); + float eps() const; + void set_eps(float value); // @@protoc_insertion_point(class_scope:caffe.NormalizeBBoxParameter) private: @@ -1182,26 +1283,25 @@ class NormalizeBBoxParameter : public ::google::protobuf::Message { inline void set_has_eps(); inline void clear_has_eps(); - ::google::protobuf::UnknownFieldSet _unknown_fields_; - + ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_; + ::google::protobuf::internal::HasBits<1> _has_bits_; + mutable int _cached_size_; ::caffe::FillerParameter* scale_filler_; bool across_spatial_; bool channel_shared_; float eps_; - - mutable int _cached_size_; - ::google::protobuf::uint32 _has_bits_[(4 + 31) / 32]; - - friend void protobuf_AddDesc_caffe_2eproto(); + friend void protobuf_InitDefaults_caffe_2eproto_impl(); + friend void protobuf_AddDesc_caffe_2eproto_impl(); friend void protobuf_AssignDesc_caffe_2eproto(); friend void protobuf_ShutdownFile_caffe_2eproto(); void InitAsDefaultInstance(); - static NormalizeBBoxParameter* default_instance_; }; +extern ::google::protobuf::internal::ExplicitlyConstructed NormalizeBBoxParameter_default_instance_; + // ------------------------------------------------------------------- -class PriorBoxParameter : public ::google::protobuf::Message { +class PriorBoxParameter : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:caffe.PriorBoxParameter) */ { public: PriorBoxParameter(); virtual ~PriorBoxParameter(); @@ -1214,21 +1314,25 @@ class PriorBoxParameter : public ::google::protobuf::Message { } inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const { - return _unknown_fields_; + return _internal_metadata_.unknown_fields(); } inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() { - return &_unknown_fields_; + return _internal_metadata_.mutable_unknown_fields(); } static const ::google::protobuf::Descriptor* descriptor(); static const PriorBoxParameter& default_instance(); + static const PriorBoxParameter* internal_default_instance(); + void Swap(PriorBoxParameter* other); // implements Message ---------------------------------------------- - PriorBoxParameter* New() const; + inline PriorBoxParameter* New() const { return New(NULL); } + + PriorBoxParameter* New(::google::protobuf::Arena* arena) const; void CopyFrom(const ::google::protobuf::Message& from); void MergeFrom(const ::google::protobuf::Message& from); void CopyFrom(const PriorBoxParameter& from); @@ -1236,17 +1340,30 @@ class PriorBoxParameter : public ::google::protobuf::Message { void Clear(); bool IsInitialized() const; - int ByteSize() const; + size_t ByteSizeLong() const; bool MergePartialFromCodedStream( ::google::protobuf::io::CodedInputStream* input); void SerializeWithCachedSizes( ::google::protobuf::io::CodedOutputStream* output) const; - ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const; + ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray( + bool deterministic, ::google::protobuf::uint8* output) const; + ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const { + return InternalSerializeWithCachedSizesToArray(false, output); + } int GetCachedSize() const { return _cached_size_; } private: void SharedCtor(); void SharedDtor(); void SetCachedSize(int size) const; + void InternalSwap(PriorBoxParameter* other); + void UnsafeMergeFrom(const PriorBoxParameter& from); + private: + inline ::google::protobuf::Arena* GetArenaNoVirtual() const { + return _internal_metadata_.arena(); + } + inline void* MaybeArenaPtr() const { + return _internal_metadata_.raw_arena_ptr(); + } public: ::google::protobuf::Metadata GetMetadata() const; @@ -1254,8 +1371,10 @@ class PriorBoxParameter : public ::google::protobuf::Message { // nested types ---------------------------------------------------- typedef PriorBoxParameter_CodeType CodeType; - static const CodeType CORNER = PriorBoxParameter_CodeType_CORNER; - static const CodeType CENTER_SIZE = PriorBoxParameter_CodeType_CENTER_SIZE; + static const CodeType CORNER = + PriorBoxParameter_CodeType_CORNER; + static const CodeType CENTER_SIZE = + PriorBoxParameter_CodeType_CENTER_SIZE; static inline bool CodeType_IsValid(int value) { return PriorBoxParameter_CodeType_IsValid(value); } @@ -1280,55 +1399,55 @@ class PriorBoxParameter : public ::google::protobuf::Message { // accessors ------------------------------------------------------- // optional float min_size = 1; - inline bool has_min_size() const; - inline void clear_min_size(); + bool has_min_size() const; + void clear_min_size(); static const int kMinSizeFieldNumber = 1; - inline float min_size() const; - inline void set_min_size(float value); + float min_size() const; + void set_min_size(float value); // optional float max_size = 2; - inline bool has_max_size() const; - inline void clear_max_size(); + bool has_max_size() const; + void clear_max_size(); static const int kMaxSizeFieldNumber = 2; - inline float max_size() const; - inline void set_max_size(float value); + float max_size() const; + void set_max_size(float value); // repeated float aspect_ratio = 3; - inline int aspect_ratio_size() const; - inline void clear_aspect_ratio(); + int aspect_ratio_size() const; + void clear_aspect_ratio(); static const int kAspectRatioFieldNumber = 3; - inline float aspect_ratio(int index) const; - inline void set_aspect_ratio(int index, float value); - inline void add_aspect_ratio(float value); - inline const ::google::protobuf::RepeatedField< float >& + float aspect_ratio(int index) const; + void set_aspect_ratio(int index, float value); + void add_aspect_ratio(float value); + const ::google::protobuf::RepeatedField< float >& aspect_ratio() const; - inline ::google::protobuf::RepeatedField< float >* + ::google::protobuf::RepeatedField< float >* mutable_aspect_ratio(); // optional bool flip = 4 [default = true]; - inline bool has_flip() const; - inline void clear_flip(); + bool has_flip() const; + void clear_flip(); static const int kFlipFieldNumber = 4; - inline bool flip() const; - inline void set_flip(bool value); + bool flip() const; + void set_flip(bool value); // optional bool clip = 5 [default = true]; - inline bool has_clip() const; - inline void clear_clip(); + bool has_clip() const; + void clear_clip(); static const int kClipFieldNumber = 5; - inline bool clip() const; - inline void set_clip(bool value); + bool clip() const; + void set_clip(bool value); // repeated float variance = 6; - inline int variance_size() const; - inline void clear_variance(); + int variance_size() const; + void clear_variance(); static const int kVarianceFieldNumber = 6; - inline float variance(int index) const; - inline void set_variance(int index, float value); - inline void add_variance(float value); - inline const ::google::protobuf::RepeatedField< float >& + float variance(int index) const; + void set_variance(int index, float value); + void add_variance(float value); + const ::google::protobuf::RepeatedField< float >& variance() const; - inline ::google::protobuf::RepeatedField< float >* + ::google::protobuf::RepeatedField< float >* mutable_variance(); // @@protoc_insertion_point(class_scope:caffe.PriorBoxParameter) @@ -1342,28 +1461,27 @@ class PriorBoxParameter : public ::google::protobuf::Message { inline void set_has_clip(); inline void clear_has_clip(); - ::google::protobuf::UnknownFieldSet _unknown_fields_; - - float min_size_; - float max_size_; + ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_; + ::google::protobuf::internal::HasBits<1> _has_bits_; + mutable int _cached_size_; ::google::protobuf::RepeatedField< float > aspect_ratio_; ::google::protobuf::RepeatedField< float > variance_; + float min_size_; + float max_size_; bool flip_; bool clip_; - - mutable int _cached_size_; - ::google::protobuf::uint32 _has_bits_[(6 + 31) / 32]; - - friend void protobuf_AddDesc_caffe_2eproto(); + friend void protobuf_InitDefaults_caffe_2eproto_impl(); + friend void protobuf_AddDesc_caffe_2eproto_impl(); friend void protobuf_AssignDesc_caffe_2eproto(); friend void protobuf_ShutdownFile_caffe_2eproto(); void InitAsDefaultInstance(); - static PriorBoxParameter* default_instance_; }; +extern ::google::protobuf::internal::ExplicitlyConstructed PriorBoxParameter_default_instance_; + // ------------------------------------------------------------------- -class DetectionOutputParameter : public ::google::protobuf::Message { +class DetectionOutputParameter : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:caffe.DetectionOutputParameter) */ { public: DetectionOutputParameter(); virtual ~DetectionOutputParameter(); @@ -1376,21 +1494,25 @@ class DetectionOutputParameter : public ::google::protobuf::Message { } inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const { - return _unknown_fields_; + return _internal_metadata_.unknown_fields(); } inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() { - return &_unknown_fields_; + return _internal_metadata_.mutable_unknown_fields(); } static const ::google::protobuf::Descriptor* descriptor(); static const DetectionOutputParameter& default_instance(); + static const DetectionOutputParameter* internal_default_instance(); + void Swap(DetectionOutputParameter* other); // implements Message ---------------------------------------------- - DetectionOutputParameter* New() const; + inline DetectionOutputParameter* New() const { return New(NULL); } + + DetectionOutputParameter* New(::google::protobuf::Arena* arena) const; void CopyFrom(const ::google::protobuf::Message& from); void MergeFrom(const ::google::protobuf::Message& from); void CopyFrom(const DetectionOutputParameter& from); @@ -1398,17 +1520,30 @@ class DetectionOutputParameter : public ::google::protobuf::Message { void Clear(); bool IsInitialized() const; - int ByteSize() const; + size_t ByteSizeLong() const; bool MergePartialFromCodedStream( ::google::protobuf::io::CodedInputStream* input); void SerializeWithCachedSizes( ::google::protobuf::io::CodedOutputStream* output) const; - ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const; + ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray( + bool deterministic, ::google::protobuf::uint8* output) const; + ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const { + return InternalSerializeWithCachedSizesToArray(false, output); + } int GetCachedSize() const { return _cached_size_; } private: void SharedCtor(); void SharedDtor(); void SetCachedSize(int size) const; + void InternalSwap(DetectionOutputParameter* other); + void UnsafeMergeFrom(const DetectionOutputParameter& from); + private: + inline ::google::protobuf::Arena* GetArenaNoVirtual() const { + return _internal_metadata_.arena(); + } + inline void* MaybeArenaPtr() const { + return _internal_metadata_.raw_arena_ptr(); + } public: ::google::protobuf::Metadata GetMetadata() const; @@ -1418,67 +1553,67 @@ class DetectionOutputParameter : public ::google::protobuf::Message { // accessors ------------------------------------------------------- // optional uint32 num_classes = 1; - inline bool has_num_classes() const; - inline void clear_num_classes(); + bool has_num_classes() const; + void clear_num_classes(); static const int kNumClassesFieldNumber = 1; - inline ::google::protobuf::uint32 num_classes() const; - inline void set_num_classes(::google::protobuf::uint32 value); + ::google::protobuf::uint32 num_classes() const; + void set_num_classes(::google::protobuf::uint32 value); // optional bool share_location = 2 [default = true]; - inline bool has_share_location() const; - inline void clear_share_location(); + bool has_share_location() const; + void clear_share_location(); static const int kShareLocationFieldNumber = 2; - inline bool share_location() const; - inline void set_share_location(bool value); + bool share_location() const; + void set_share_location(bool value); // optional int32 background_label_id = 3 [default = 0]; - inline bool has_background_label_id() const; - inline void clear_background_label_id(); + bool has_background_label_id() const; + void clear_background_label_id(); static const int kBackgroundLabelIdFieldNumber = 3; - inline ::google::protobuf::int32 background_label_id() const; - inline void set_background_label_id(::google::protobuf::int32 value); + ::google::protobuf::int32 background_label_id() const; + void set_background_label_id(::google::protobuf::int32 value); // optional .caffe.PriorBoxParameter.CodeType code_type = 6 [default = CORNER]; - inline bool has_code_type() const; - inline void clear_code_type(); + bool has_code_type() const; + void clear_code_type(); static const int kCodeTypeFieldNumber = 6; - inline ::caffe::PriorBoxParameter_CodeType code_type() const; - inline void set_code_type(::caffe::PriorBoxParameter_CodeType value); + ::caffe::PriorBoxParameter_CodeType code_type() const; + void set_code_type(::caffe::PriorBoxParameter_CodeType value); // optional bool variance_encoded_in_target = 8 [default = false]; - inline bool has_variance_encoded_in_target() const; - inline void clear_variance_encoded_in_target(); + bool has_variance_encoded_in_target() const; + void clear_variance_encoded_in_target(); static const int kVarianceEncodedInTargetFieldNumber = 8; - inline bool variance_encoded_in_target() const; - inline void set_variance_encoded_in_target(bool value); + bool variance_encoded_in_target() const; + void set_variance_encoded_in_target(bool value); // optional int32 keep_top_k = 7 [default = -1]; - inline bool has_keep_top_k() const; - inline void clear_keep_top_k(); + bool has_keep_top_k() const; + void clear_keep_top_k(); static const int kKeepTopKFieldNumber = 7; - inline ::google::protobuf::int32 keep_top_k() const; - inline void set_keep_top_k(::google::protobuf::int32 value); + ::google::protobuf::int32 keep_top_k() const; + void set_keep_top_k(::google::protobuf::int32 value); // optional float confidence_threshold = 9; - inline bool has_confidence_threshold() const; - inline void clear_confidence_threshold(); + bool has_confidence_threshold() const; + void clear_confidence_threshold(); static const int kConfidenceThresholdFieldNumber = 9; - inline float confidence_threshold() const; - inline void set_confidence_threshold(float value); + float confidence_threshold() const; + void set_confidence_threshold(float value); // optional float nms_threshold = 10 [default = 0.3]; - inline bool has_nms_threshold() const; - inline void clear_nms_threshold(); + bool has_nms_threshold() const; + void clear_nms_threshold(); static const int kNmsThresholdFieldNumber = 10; - inline float nms_threshold() const; - inline void set_nms_threshold(float value); + float nms_threshold() const; + void set_nms_threshold(float value); // optional int32 top_k = 11; - inline bool has_top_k() const; - inline void clear_top_k(); + bool has_top_k() const; + void clear_top_k(); static const int kTopKFieldNumber = 11; - inline ::google::protobuf::int32 top_k() const; - inline void set_top_k(::google::protobuf::int32 value); + ::google::protobuf::int32 top_k() const; + void set_top_k(::google::protobuf::int32 value); // @@protoc_insertion_point(class_scope:caffe.DetectionOutputParameter) private: @@ -1501,31 +1636,30 @@ class DetectionOutputParameter : public ::google::protobuf::Message { inline void set_has_top_k(); inline void clear_has_top_k(); - ::google::protobuf::UnknownFieldSet _unknown_fields_; - + ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_; + ::google::protobuf::internal::HasBits<1> _has_bits_; + mutable int _cached_size_; ::google::protobuf::uint32 num_classes_; ::google::protobuf::int32 background_label_id_; - bool share_location_; bool variance_encoded_in_target_; + float confidence_threshold_; + ::google::protobuf::int32 top_k_; + bool share_location_; int code_type_; ::google::protobuf::int32 keep_top_k_; - float confidence_threshold_; float nms_threshold_; - ::google::protobuf::int32 top_k_; - - mutable int _cached_size_; - ::google::protobuf::uint32 _has_bits_[(9 + 31) / 32]; - - friend void protobuf_AddDesc_caffe_2eproto(); + friend void protobuf_InitDefaults_caffe_2eproto_impl(); + friend void protobuf_AddDesc_caffe_2eproto_impl(); friend void protobuf_AssignDesc_caffe_2eproto(); friend void protobuf_ShutdownFile_caffe_2eproto(); void InitAsDefaultInstance(); - static DetectionOutputParameter* default_instance_; }; +extern ::google::protobuf::internal::ExplicitlyConstructed DetectionOutputParameter_default_instance_; + // ------------------------------------------------------------------- -class Datum : public ::google::protobuf::Message { +class Datum : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:caffe.Datum) */ { public: Datum(); virtual ~Datum(); @@ -1538,21 +1672,25 @@ class Datum : public ::google::protobuf::Message { } inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const { - return _unknown_fields_; + return _internal_metadata_.unknown_fields(); } inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() { - return &_unknown_fields_; + return _internal_metadata_.mutable_unknown_fields(); } static const ::google::protobuf::Descriptor* descriptor(); static const Datum& default_instance(); + static const Datum* internal_default_instance(); + void Swap(Datum* other); // implements Message ---------------------------------------------- - Datum* New() const; + inline Datum* New() const { return New(NULL); } + + Datum* New(::google::protobuf::Arena* arena) const; void CopyFrom(const ::google::protobuf::Message& from); void MergeFrom(const ::google::protobuf::Message& from); void CopyFrom(const Datum& from); @@ -1560,17 +1698,30 @@ class Datum : public ::google::protobuf::Message { void Clear(); bool IsInitialized() const; - int ByteSize() const; + size_t ByteSizeLong() const; bool MergePartialFromCodedStream( ::google::protobuf::io::CodedInputStream* input); void SerializeWithCachedSizes( ::google::protobuf::io::CodedOutputStream* output) const; - ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const; + ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray( + bool deterministic, ::google::protobuf::uint8* output) const; + ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const { + return InternalSerializeWithCachedSizesToArray(false, output); + } int GetCachedSize() const { return _cached_size_; } private: void SharedCtor(); void SharedDtor(); void SetCachedSize(int size) const; + void InternalSwap(Datum* other); + void UnsafeMergeFrom(const Datum& from); + private: + inline ::google::protobuf::Arena* GetArenaNoVirtual() const { + return _internal_metadata_.arena(); + } + inline void* MaybeArenaPtr() const { + return _internal_metadata_.raw_arena_ptr(); + } public: ::google::protobuf::Metadata GetMetadata() const; @@ -1580,63 +1731,63 @@ class Datum : public ::google::protobuf::Message { // accessors ------------------------------------------------------- // optional int32 channels = 1; - inline bool has_channels() const; - inline void clear_channels(); + bool has_channels() const; + void clear_channels(); static const int kChannelsFieldNumber = 1; - inline ::google::protobuf::int32 channels() const; - inline void set_channels(::google::protobuf::int32 value); + ::google::protobuf::int32 channels() const; + void set_channels(::google::protobuf::int32 value); // optional int32 height = 2; - inline bool has_height() const; - inline void clear_height(); + bool has_height() const; + void clear_height(); static const int kHeightFieldNumber = 2; - inline ::google::protobuf::int32 height() const; - inline void set_height(::google::protobuf::int32 value); + ::google::protobuf::int32 height() const; + void set_height(::google::protobuf::int32 value); // optional int32 width = 3; - inline bool has_width() const; - inline void clear_width(); + bool has_width() const; + void clear_width(); static const int kWidthFieldNumber = 3; - inline ::google::protobuf::int32 width() const; - inline void set_width(::google::protobuf::int32 value); + ::google::protobuf::int32 width() const; + void set_width(::google::protobuf::int32 value); // optional bytes data = 4; - inline bool has_data() const; - inline void clear_data(); + bool has_data() const; + void clear_data(); static const int kDataFieldNumber = 4; - inline const ::std::string& data() const; - inline void set_data(const ::std::string& value); - inline void set_data(const char* value); - inline void set_data(const void* value, size_t size); - inline ::std::string* mutable_data(); - inline ::std::string* release_data(); - inline void set_allocated_data(::std::string* data); + const ::std::string& data() const; + void set_data(const ::std::string& value); + void set_data(const char* value); + void set_data(const void* value, size_t size); + ::std::string* mutable_data(); + ::std::string* release_data(); + void set_allocated_data(::std::string* data); // optional int32 label = 5; - inline bool has_label() const; - inline void clear_label(); + bool has_label() const; + void clear_label(); static const int kLabelFieldNumber = 5; - inline ::google::protobuf::int32 label() const; - inline void set_label(::google::protobuf::int32 value); + ::google::protobuf::int32 label() const; + void set_label(::google::protobuf::int32 value); // repeated float float_data = 6; - inline int float_data_size() const; - inline void clear_float_data(); + int float_data_size() const; + void clear_float_data(); static const int kFloatDataFieldNumber = 6; - inline float float_data(int index) const; - inline void set_float_data(int index, float value); - inline void add_float_data(float value); - inline const ::google::protobuf::RepeatedField< float >& + float float_data(int index) const; + void set_float_data(int index, float value); + void add_float_data(float value); + const ::google::protobuf::RepeatedField< float >& float_data() const; - inline ::google::protobuf::RepeatedField< float >* + ::google::protobuf::RepeatedField< float >* mutable_float_data(); // optional bool encoded = 7 [default = false]; - inline bool has_encoded() const; - inline void clear_encoded(); + bool has_encoded() const; + void clear_encoded(); static const int kEncodedFieldNumber = 7; - inline bool encoded() const; - inline void set_encoded(bool value); + bool encoded() const; + void set_encoded(bool value); // @@protoc_insertion_point(class_scope:caffe.Datum) private: @@ -1653,29 +1804,28 @@ class Datum : public ::google::protobuf::Message { inline void set_has_encoded(); inline void clear_has_encoded(); - ::google::protobuf::UnknownFieldSet _unknown_fields_; - + ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_; + ::google::protobuf::internal::HasBits<1> _has_bits_; + mutable int _cached_size_; + ::google::protobuf::RepeatedField< float > float_data_; + ::google::protobuf::internal::ArenaStringPtr data_; ::google::protobuf::int32 channels_; ::google::protobuf::int32 height_; - ::std::string* data_; ::google::protobuf::int32 width_; ::google::protobuf::int32 label_; - ::google::protobuf::RepeatedField< float > float_data_; bool encoded_; - - mutable int _cached_size_; - ::google::protobuf::uint32 _has_bits_[(7 + 31) / 32]; - - friend void protobuf_AddDesc_caffe_2eproto(); + friend void protobuf_InitDefaults_caffe_2eproto_impl(); + friend void protobuf_AddDesc_caffe_2eproto_impl(); friend void protobuf_AssignDesc_caffe_2eproto(); friend void protobuf_ShutdownFile_caffe_2eproto(); void InitAsDefaultInstance(); - static Datum* default_instance_; }; +extern ::google::protobuf::internal::ExplicitlyConstructed Datum_default_instance_; + // ------------------------------------------------------------------- -class FillerParameter : public ::google::protobuf::Message { +class FillerParameter : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:caffe.FillerParameter) */ { public: FillerParameter(); virtual ~FillerParameter(); @@ -1688,21 +1838,25 @@ class FillerParameter : public ::google::protobuf::Message { } inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const { - return _unknown_fields_; + return _internal_metadata_.unknown_fields(); } inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() { - return &_unknown_fields_; + return _internal_metadata_.mutable_unknown_fields(); } static const ::google::protobuf::Descriptor* descriptor(); static const FillerParameter& default_instance(); + static const FillerParameter* internal_default_instance(); + void Swap(FillerParameter* other); // implements Message ---------------------------------------------- - FillerParameter* New() const; + inline FillerParameter* New() const { return New(NULL); } + + FillerParameter* New(::google::protobuf::Arena* arena) const; void CopyFrom(const ::google::protobuf::Message& from); void MergeFrom(const ::google::protobuf::Message& from); void CopyFrom(const FillerParameter& from); @@ -1710,17 +1864,30 @@ class FillerParameter : public ::google::protobuf::Message { void Clear(); bool IsInitialized() const; - int ByteSize() const; + size_t ByteSizeLong() const; bool MergePartialFromCodedStream( ::google::protobuf::io::CodedInputStream* input); void SerializeWithCachedSizes( ::google::protobuf::io::CodedOutputStream* output) const; - ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const; + ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray( + bool deterministic, ::google::protobuf::uint8* output) const; + ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const { + return InternalSerializeWithCachedSizesToArray(false, output); + } int GetCachedSize() const { return _cached_size_; } private: void SharedCtor(); void SharedDtor(); void SetCachedSize(int size) const; + void InternalSwap(FillerParameter* other); + void UnsafeMergeFrom(const FillerParameter& from); + private: + inline ::google::protobuf::Arena* GetArenaNoVirtual() const { + return _internal_metadata_.arena(); + } + inline void* MaybeArenaPtr() const { + return _internal_metadata_.raw_arena_ptr(); + } public: ::google::protobuf::Metadata GetMetadata() const; @@ -1728,9 +1895,12 @@ class FillerParameter : public ::google::protobuf::Message { // nested types ---------------------------------------------------- typedef FillerParameter_VarianceNorm VarianceNorm; - static const VarianceNorm FAN_IN = FillerParameter_VarianceNorm_FAN_IN; - static const VarianceNorm FAN_OUT = FillerParameter_VarianceNorm_FAN_OUT; - static const VarianceNorm AVERAGE = FillerParameter_VarianceNorm_AVERAGE; + static const VarianceNorm FAN_IN = + FillerParameter_VarianceNorm_FAN_IN; + static const VarianceNorm FAN_OUT = + FillerParameter_VarianceNorm_FAN_OUT; + static const VarianceNorm AVERAGE = + FillerParameter_VarianceNorm_AVERAGE; static inline bool VarianceNorm_IsValid(int value) { return FillerParameter_VarianceNorm_IsValid(value); } @@ -1755,65 +1925,65 @@ class FillerParameter : public ::google::protobuf::Message { // accessors ------------------------------------------------------- // optional string type = 1 [default = "constant"]; - inline bool has_type() const; - inline void clear_type(); + bool has_type() const; + void clear_type(); static const int kTypeFieldNumber = 1; - inline const ::std::string& type() const; - inline void set_type(const ::std::string& value); - inline void set_type(const char* value); - inline void set_type(const char* value, size_t size); - inline ::std::string* mutable_type(); - inline ::std::string* release_type(); - inline void set_allocated_type(::std::string* type); + const ::std::string& type() const; + void set_type(const ::std::string& value); + void set_type(const char* value); + void set_type(const char* value, size_t size); + ::std::string* mutable_type(); + ::std::string* release_type(); + void set_allocated_type(::std::string* type); // optional float value = 2 [default = 0]; - inline bool has_value() const; - inline void clear_value(); + bool has_value() const; + void clear_value(); static const int kValueFieldNumber = 2; - inline float value() const; - inline void set_value(float value); + float value() const; + void set_value(float value); // optional float min = 3 [default = 0]; - inline bool has_min() const; - inline void clear_min(); + bool has_min() const; + void clear_min(); static const int kMinFieldNumber = 3; - inline float min() const; - inline void set_min(float value); + float min() const; + void set_min(float value); // optional float max = 4 [default = 1]; - inline bool has_max() const; - inline void clear_max(); + bool has_max() const; + void clear_max(); static const int kMaxFieldNumber = 4; - inline float max() const; - inline void set_max(float value); + float max() const; + void set_max(float value); // optional float mean = 5 [default = 0]; - inline bool has_mean() const; - inline void clear_mean(); + bool has_mean() const; + void clear_mean(); static const int kMeanFieldNumber = 5; - inline float mean() const; - inline void set_mean(float value); + float mean() const; + void set_mean(float value); // optional float std = 6 [default = 1]; - inline bool has_std() const; - inline void clear_std(); + bool has_std() const; + void clear_std(); static const int kStdFieldNumber = 6; - inline float std() const; - inline void set_std(float value); + float std() const; + void set_std(float value); // optional int32 sparse = 7 [default = -1]; - inline bool has_sparse() const; - inline void clear_sparse(); + bool has_sparse() const; + void clear_sparse(); static const int kSparseFieldNumber = 7; - inline ::google::protobuf::int32 sparse() const; - inline void set_sparse(::google::protobuf::int32 value); + ::google::protobuf::int32 sparse() const; + void set_sparse(::google::protobuf::int32 value); // optional .caffe.FillerParameter.VarianceNorm variance_norm = 8 [default = FAN_IN]; - inline bool has_variance_norm() const; - inline void clear_variance_norm(); + bool has_variance_norm() const; + void clear_variance_norm(); static const int kVarianceNormFieldNumber = 8; - inline ::caffe::FillerParameter_VarianceNorm variance_norm() const; - inline void set_variance_norm(::caffe::FillerParameter_VarianceNorm value); + ::caffe::FillerParameter_VarianceNorm variance_norm() const; + void set_variance_norm(::caffe::FillerParameter_VarianceNorm value); // @@protoc_insertion_point(class_scope:caffe.FillerParameter) private: @@ -1834,31 +2004,30 @@ class FillerParameter : public ::google::protobuf::Message { inline void set_has_variance_norm(); inline void clear_has_variance_norm(); - ::google::protobuf::UnknownFieldSet _unknown_fields_; - - ::std::string* type_; + ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_; + ::google::protobuf::internal::HasBits<1> _has_bits_; + mutable int _cached_size_; static ::std::string* _default_type_; + ::google::protobuf::internal::ArenaStringPtr type_; float value_; float min_; - float max_; float mean_; - float std_; - ::google::protobuf::int32 sparse_; int variance_norm_; - - mutable int _cached_size_; - ::google::protobuf::uint32 _has_bits_[(8 + 31) / 32]; - - friend void protobuf_AddDesc_caffe_2eproto(); + ::google::protobuf::int32 sparse_; + float max_; + float std_; + friend void protobuf_InitDefaults_caffe_2eproto_impl(); + friend void protobuf_AddDesc_caffe_2eproto_impl(); friend void protobuf_AssignDesc_caffe_2eproto(); friend void protobuf_ShutdownFile_caffe_2eproto(); void InitAsDefaultInstance(); - static FillerParameter* default_instance_; }; +extern ::google::protobuf::internal::ExplicitlyConstructed FillerParameter_default_instance_; + // ------------------------------------------------------------------- -class NetParameter : public ::google::protobuf::Message { +class NetParameter : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:caffe.NetParameter) */ { public: NetParameter(); virtual ~NetParameter(); @@ -1871,21 +2040,25 @@ class NetParameter : public ::google::protobuf::Message { } inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const { - return _unknown_fields_; + return _internal_metadata_.unknown_fields(); } inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() { - return &_unknown_fields_; + return _internal_metadata_.mutable_unknown_fields(); } static const ::google::protobuf::Descriptor* descriptor(); static const NetParameter& default_instance(); + static const NetParameter* internal_default_instance(); + void Swap(NetParameter* other); // implements Message ---------------------------------------------- - NetParameter* New() const; + inline NetParameter* New() const { return New(NULL); } + + NetParameter* New(::google::protobuf::Arena* arena) const; void CopyFrom(const ::google::protobuf::Message& from); void MergeFrom(const ::google::protobuf::Message& from); void CopyFrom(const NetParameter& from); @@ -1893,17 +2066,30 @@ class NetParameter : public ::google::protobuf::Message { void Clear(); bool IsInitialized() const; - int ByteSize() const; + size_t ByteSizeLong() const; bool MergePartialFromCodedStream( ::google::protobuf::io::CodedInputStream* input); void SerializeWithCachedSizes( ::google::protobuf::io::CodedOutputStream* output) const; - ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const; + ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray( + bool deterministic, ::google::protobuf::uint8* output) const; + ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const { + return InternalSerializeWithCachedSizesToArray(false, output); + } int GetCachedSize() const { return _cached_size_; } private: void SharedCtor(); void SharedDtor(); void SetCachedSize(int size) const; + void InternalSwap(NetParameter* other); + void UnsafeMergeFrom(const NetParameter& from); + private: + inline ::google::protobuf::Arena* GetArenaNoVirtual() const { + return _internal_metadata_.arena(); + } + inline void* MaybeArenaPtr() const { + return _internal_metadata_.raw_arena_ptr(); + } public: ::google::protobuf::Metadata GetMetadata() const; @@ -1913,103 +2099,103 @@ class NetParameter : public ::google::protobuf::Message { // accessors ------------------------------------------------------- // optional string name = 1; - inline bool has_name() const; - inline void clear_name(); + bool has_name() const; + void clear_name(); static const int kNameFieldNumber = 1; - inline const ::std::string& name() const; - inline void set_name(const ::std::string& value); - inline void set_name(const char* value); - inline void set_name(const char* value, size_t size); - inline ::std::string* mutable_name(); - inline ::std::string* release_name(); - inline void set_allocated_name(::std::string* name); + const ::std::string& name() const; + void set_name(const ::std::string& value); + void set_name(const char* value); + void set_name(const char* value, size_t size); + ::std::string* mutable_name(); + ::std::string* release_name(); + void set_allocated_name(::std::string* name); // repeated string input = 3; - inline int input_size() const; - inline void clear_input(); + int input_size() const; + void clear_input(); static const int kInputFieldNumber = 3; - inline const ::std::string& input(int index) const; - inline ::std::string* mutable_input(int index); - inline void set_input(int index, const ::std::string& value); - inline void set_input(int index, const char* value); - inline void set_input(int index, const char* value, size_t size); - inline ::std::string* add_input(); - inline void add_input(const ::std::string& value); - inline void add_input(const char* value); - inline void add_input(const char* value, size_t size); - inline const ::google::protobuf::RepeatedPtrField< ::std::string>& input() const; - inline ::google::protobuf::RepeatedPtrField< ::std::string>* mutable_input(); + const ::std::string& input(int index) const; + ::std::string* mutable_input(int index); + void set_input(int index, const ::std::string& value); + void set_input(int index, const char* value); + void set_input(int index, const char* value, size_t size); + ::std::string* add_input(); + void add_input(const ::std::string& value); + void add_input(const char* value); + void add_input(const char* value, size_t size); + const ::google::protobuf::RepeatedPtrField< ::std::string>& input() const; + ::google::protobuf::RepeatedPtrField< ::std::string>* mutable_input(); // repeated .caffe.BlobShape input_shape = 8; - inline int input_shape_size() const; - inline void clear_input_shape(); + int input_shape_size() const; + void clear_input_shape(); static const int kInputShapeFieldNumber = 8; - inline const ::caffe::BlobShape& input_shape(int index) const; - inline ::caffe::BlobShape* mutable_input_shape(int index); - inline ::caffe::BlobShape* add_input_shape(); - inline const ::google::protobuf::RepeatedPtrField< ::caffe::BlobShape >& - input_shape() const; - inline ::google::protobuf::RepeatedPtrField< ::caffe::BlobShape >* + const ::caffe::BlobShape& input_shape(int index) const; + ::caffe::BlobShape* mutable_input_shape(int index); + ::caffe::BlobShape* add_input_shape(); + ::google::protobuf::RepeatedPtrField< ::caffe::BlobShape >* mutable_input_shape(); + const ::google::protobuf::RepeatedPtrField< ::caffe::BlobShape >& + input_shape() const; // repeated int32 input_dim = 4; - inline int input_dim_size() const; - inline void clear_input_dim(); + int input_dim_size() const; + void clear_input_dim(); static const int kInputDimFieldNumber = 4; - inline ::google::protobuf::int32 input_dim(int index) const; - inline void set_input_dim(int index, ::google::protobuf::int32 value); - inline void add_input_dim(::google::protobuf::int32 value); - inline const ::google::protobuf::RepeatedField< ::google::protobuf::int32 >& + ::google::protobuf::int32 input_dim(int index) const; + void set_input_dim(int index, ::google::protobuf::int32 value); + void add_input_dim(::google::protobuf::int32 value); + const ::google::protobuf::RepeatedField< ::google::protobuf::int32 >& input_dim() const; - inline ::google::protobuf::RepeatedField< ::google::protobuf::int32 >* + ::google::protobuf::RepeatedField< ::google::protobuf::int32 >* mutable_input_dim(); // optional bool force_backward = 5 [default = false]; - inline bool has_force_backward() const; - inline void clear_force_backward(); + bool has_force_backward() const; + void clear_force_backward(); static const int kForceBackwardFieldNumber = 5; - inline bool force_backward() const; - inline void set_force_backward(bool value); + bool force_backward() const; + void set_force_backward(bool value); // optional .caffe.NetState state = 6; - inline bool has_state() const; - inline void clear_state(); + bool has_state() const; + void clear_state(); static const int kStateFieldNumber = 6; - inline const ::caffe::NetState& state() const; - inline ::caffe::NetState* mutable_state(); - inline ::caffe::NetState* release_state(); - inline void set_allocated_state(::caffe::NetState* state); + const ::caffe::NetState& state() const; + ::caffe::NetState* mutable_state(); + ::caffe::NetState* release_state(); + void set_allocated_state(::caffe::NetState* state); // optional bool debug_info = 7 [default = false]; - inline bool has_debug_info() const; - inline void clear_debug_info(); + bool has_debug_info() const; + void clear_debug_info(); static const int kDebugInfoFieldNumber = 7; - inline bool debug_info() const; - inline void set_debug_info(bool value); + bool debug_info() const; + void set_debug_info(bool value); // repeated .caffe.LayerParameter layer = 100; - inline int layer_size() const; - inline void clear_layer(); + int layer_size() const; + void clear_layer(); static const int kLayerFieldNumber = 100; - inline const ::caffe::LayerParameter& layer(int index) const; - inline ::caffe::LayerParameter* mutable_layer(int index); - inline ::caffe::LayerParameter* add_layer(); - inline const ::google::protobuf::RepeatedPtrField< ::caffe::LayerParameter >& - layer() const; - inline ::google::protobuf::RepeatedPtrField< ::caffe::LayerParameter >* + const ::caffe::LayerParameter& layer(int index) const; + ::caffe::LayerParameter* mutable_layer(int index); + ::caffe::LayerParameter* add_layer(); + ::google::protobuf::RepeatedPtrField< ::caffe::LayerParameter >* mutable_layer(); + const ::google::protobuf::RepeatedPtrField< ::caffe::LayerParameter >& + layer() const; // repeated .caffe.V1LayerParameter layers = 2; - inline int layers_size() const; - inline void clear_layers(); + int layers_size() const; + void clear_layers(); static const int kLayersFieldNumber = 2; - inline const ::caffe::V1LayerParameter& layers(int index) const; - inline ::caffe::V1LayerParameter* mutable_layers(int index); - inline ::caffe::V1LayerParameter* add_layers(); - inline const ::google::protobuf::RepeatedPtrField< ::caffe::V1LayerParameter >& - layers() const; - inline ::google::protobuf::RepeatedPtrField< ::caffe::V1LayerParameter >* + const ::caffe::V1LayerParameter& layers(int index) const; + ::caffe::V1LayerParameter* mutable_layers(int index); + ::caffe::V1LayerParameter* add_layers(); + ::google::protobuf::RepeatedPtrField< ::caffe::V1LayerParameter >* mutable_layers(); + const ::google::protobuf::RepeatedPtrField< ::caffe::V1LayerParameter >& + layers() const; // @@protoc_insertion_point(class_scope:caffe.NetParameter) private: @@ -2022,31 +2208,30 @@ class NetParameter : public ::google::protobuf::Message { inline void set_has_debug_info(); inline void clear_has_debug_info(); - ::google::protobuf::UnknownFieldSet _unknown_fields_; - - ::std::string* name_; + ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_; + ::google::protobuf::internal::HasBits<1> _has_bits_; + mutable int _cached_size_; ::google::protobuf::RepeatedPtrField< ::std::string> input_; ::google::protobuf::RepeatedPtrField< ::caffe::BlobShape > input_shape_; ::google::protobuf::RepeatedField< ::google::protobuf::int32 > input_dim_; - ::caffe::NetState* state_; ::google::protobuf::RepeatedPtrField< ::caffe::LayerParameter > layer_; ::google::protobuf::RepeatedPtrField< ::caffe::V1LayerParameter > layers_; + ::google::protobuf::internal::ArenaStringPtr name_; + ::caffe::NetState* state_; bool force_backward_; bool debug_info_; - - mutable int _cached_size_; - ::google::protobuf::uint32 _has_bits_[(9 + 31) / 32]; - - friend void protobuf_AddDesc_caffe_2eproto(); + friend void protobuf_InitDefaults_caffe_2eproto_impl(); + friend void protobuf_AddDesc_caffe_2eproto_impl(); friend void protobuf_AssignDesc_caffe_2eproto(); friend void protobuf_ShutdownFile_caffe_2eproto(); void InitAsDefaultInstance(); - static NetParameter* default_instance_; }; +extern ::google::protobuf::internal::ExplicitlyConstructed NetParameter_default_instance_; + // ------------------------------------------------------------------- -class SolverParameter : public ::google::protobuf::Message { +class SolverParameter : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:caffe.SolverParameter) */ { public: SolverParameter(); virtual ~SolverParameter(); @@ -2059,21 +2244,25 @@ class SolverParameter : public ::google::protobuf::Message { } inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const { - return _unknown_fields_; + return _internal_metadata_.unknown_fields(); } inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() { - return &_unknown_fields_; + return _internal_metadata_.mutable_unknown_fields(); } static const ::google::protobuf::Descriptor* descriptor(); static const SolverParameter& default_instance(); + static const SolverParameter* internal_default_instance(); + void Swap(SolverParameter* other); // implements Message ---------------------------------------------- - SolverParameter* New() const; + inline SolverParameter* New() const { return New(NULL); } + + SolverParameter* New(::google::protobuf::Arena* arena) const; void CopyFrom(const ::google::protobuf::Message& from); void MergeFrom(const ::google::protobuf::Message& from); void CopyFrom(const SolverParameter& from); @@ -2081,17 +2270,30 @@ class SolverParameter : public ::google::protobuf::Message { void Clear(); bool IsInitialized() const; - int ByteSize() const; + size_t ByteSizeLong() const; bool MergePartialFromCodedStream( ::google::protobuf::io::CodedInputStream* input); void SerializeWithCachedSizes( ::google::protobuf::io::CodedOutputStream* output) const; - ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const; + ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray( + bool deterministic, ::google::protobuf::uint8* output) const; + ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const { + return InternalSerializeWithCachedSizesToArray(false, output); + } int GetCachedSize() const { return _cached_size_; } private: void SharedCtor(); void SharedDtor(); void SetCachedSize(int size) const; + void InternalSwap(SolverParameter* other); + void UnsafeMergeFrom(const SolverParameter& from); + private: + inline ::google::protobuf::Arena* GetArenaNoVirtual() const { + return _internal_metadata_.arena(); + } + inline void* MaybeArenaPtr() const { + return _internal_metadata_.raw_arena_ptr(); + } public: ::google::protobuf::Metadata GetMetadata() const; @@ -2099,8 +2301,10 @@ class SolverParameter : public ::google::protobuf::Message { // nested types ---------------------------------------------------- typedef SolverParameter_SolverMode SolverMode; - static const SolverMode CPU = SolverParameter_SolverMode_CPU; - static const SolverMode GPU = SolverParameter_SolverMode_GPU; + static const SolverMode CPU = + SolverParameter_SolverMode_CPU; + static const SolverMode GPU = + SolverParameter_SolverMode_GPU; static inline bool SolverMode_IsValid(int value) { return SolverParameter_SolverMode_IsValid(value); } @@ -2123,9 +2327,12 @@ class SolverParameter : public ::google::protobuf::Message { } typedef SolverParameter_SolverType SolverType; - static const SolverType SGD = SolverParameter_SolverType_SGD; - static const SolverType NESTEROV = SolverParameter_SolverType_NESTEROV; - static const SolverType ADAGRAD = SolverParameter_SolverType_ADAGRAD; + static const SolverType SGD = + SolverParameter_SolverType_SGD; + static const SolverType NESTEROV = + SolverParameter_SolverType_NESTEROV; + static const SolverType ADAGRAD = + SolverParameter_SolverType_ADAGRAD; static inline bool SolverType_IsValid(int value) { return SolverParameter_SolverType_IsValid(value); } @@ -2150,316 +2357,316 @@ class SolverParameter : public ::google::protobuf::Message { // accessors ------------------------------------------------------- // optional string net = 24; - inline bool has_net() const; - inline void clear_net(); + bool has_net() const; + void clear_net(); static const int kNetFieldNumber = 24; - inline const ::std::string& net() const; - inline void set_net(const ::std::string& value); - inline void set_net(const char* value); - inline void set_net(const char* value, size_t size); - inline ::std::string* mutable_net(); - inline ::std::string* release_net(); - inline void set_allocated_net(::std::string* net); + const ::std::string& net() const; + void set_net(const ::std::string& value); + void set_net(const char* value); + void set_net(const char* value, size_t size); + ::std::string* mutable_net(); + ::std::string* release_net(); + void set_allocated_net(::std::string* net); // optional .caffe.NetParameter net_param = 25; - inline bool has_net_param() const; - inline void clear_net_param(); + bool has_net_param() const; + void clear_net_param(); static const int kNetParamFieldNumber = 25; - inline const ::caffe::NetParameter& net_param() const; - inline ::caffe::NetParameter* mutable_net_param(); - inline ::caffe::NetParameter* release_net_param(); - inline void set_allocated_net_param(::caffe::NetParameter* net_param); + const ::caffe::NetParameter& net_param() const; + ::caffe::NetParameter* mutable_net_param(); + ::caffe::NetParameter* release_net_param(); + void set_allocated_net_param(::caffe::NetParameter* net_param); // optional string train_net = 1; - inline bool has_train_net() const; - inline void clear_train_net(); + bool has_train_net() const; + void clear_train_net(); static const int kTrainNetFieldNumber = 1; - inline const ::std::string& train_net() const; - inline void set_train_net(const ::std::string& value); - inline void set_train_net(const char* value); - inline void set_train_net(const char* value, size_t size); - inline ::std::string* mutable_train_net(); - inline ::std::string* release_train_net(); - inline void set_allocated_train_net(::std::string* train_net); + const ::std::string& train_net() const; + void set_train_net(const ::std::string& value); + void set_train_net(const char* value); + void set_train_net(const char* value, size_t size); + ::std::string* mutable_train_net(); + ::std::string* release_train_net(); + void set_allocated_train_net(::std::string* train_net); // repeated string test_net = 2; - inline int test_net_size() const; - inline void clear_test_net(); + int test_net_size() const; + void clear_test_net(); static const int kTestNetFieldNumber = 2; - inline const ::std::string& test_net(int index) const; - inline ::std::string* mutable_test_net(int index); - inline void set_test_net(int index, const ::std::string& value); - inline void set_test_net(int index, const char* value); - inline void set_test_net(int index, const char* value, size_t size); - inline ::std::string* add_test_net(); - inline void add_test_net(const ::std::string& value); - inline void add_test_net(const char* value); - inline void add_test_net(const char* value, size_t size); - inline const ::google::protobuf::RepeatedPtrField< ::std::string>& test_net() const; - inline ::google::protobuf::RepeatedPtrField< ::std::string>* mutable_test_net(); + const ::std::string& test_net(int index) const; + ::std::string* mutable_test_net(int index); + void set_test_net(int index, const ::std::string& value); + void set_test_net(int index, const char* value); + void set_test_net(int index, const char* value, size_t size); + ::std::string* add_test_net(); + void add_test_net(const ::std::string& value); + void add_test_net(const char* value); + void add_test_net(const char* value, size_t size); + const ::google::protobuf::RepeatedPtrField< ::std::string>& test_net() const; + ::google::protobuf::RepeatedPtrField< ::std::string>* mutable_test_net(); // optional .caffe.NetParameter train_net_param = 21; - inline bool has_train_net_param() const; - inline void clear_train_net_param(); + bool has_train_net_param() const; + void clear_train_net_param(); static const int kTrainNetParamFieldNumber = 21; - inline const ::caffe::NetParameter& train_net_param() const; - inline ::caffe::NetParameter* mutable_train_net_param(); - inline ::caffe::NetParameter* release_train_net_param(); - inline void set_allocated_train_net_param(::caffe::NetParameter* train_net_param); + const ::caffe::NetParameter& train_net_param() const; + ::caffe::NetParameter* mutable_train_net_param(); + ::caffe::NetParameter* release_train_net_param(); + void set_allocated_train_net_param(::caffe::NetParameter* train_net_param); // repeated .caffe.NetParameter test_net_param = 22; - inline int test_net_param_size() const; - inline void clear_test_net_param(); + int test_net_param_size() const; + void clear_test_net_param(); static const int kTestNetParamFieldNumber = 22; - inline const ::caffe::NetParameter& test_net_param(int index) const; - inline ::caffe::NetParameter* mutable_test_net_param(int index); - inline ::caffe::NetParameter* add_test_net_param(); - inline const ::google::protobuf::RepeatedPtrField< ::caffe::NetParameter >& - test_net_param() const; - inline ::google::protobuf::RepeatedPtrField< ::caffe::NetParameter >* + const ::caffe::NetParameter& test_net_param(int index) const; + ::caffe::NetParameter* mutable_test_net_param(int index); + ::caffe::NetParameter* add_test_net_param(); + ::google::protobuf::RepeatedPtrField< ::caffe::NetParameter >* mutable_test_net_param(); + const ::google::protobuf::RepeatedPtrField< ::caffe::NetParameter >& + test_net_param() const; // optional .caffe.NetState train_state = 26; - inline bool has_train_state() const; - inline void clear_train_state(); + bool has_train_state() const; + void clear_train_state(); static const int kTrainStateFieldNumber = 26; - inline const ::caffe::NetState& train_state() const; - inline ::caffe::NetState* mutable_train_state(); - inline ::caffe::NetState* release_train_state(); - inline void set_allocated_train_state(::caffe::NetState* train_state); + const ::caffe::NetState& train_state() const; + ::caffe::NetState* mutable_train_state(); + ::caffe::NetState* release_train_state(); + void set_allocated_train_state(::caffe::NetState* train_state); // repeated .caffe.NetState test_state = 27; - inline int test_state_size() const; - inline void clear_test_state(); + int test_state_size() const; + void clear_test_state(); static const int kTestStateFieldNumber = 27; - inline const ::caffe::NetState& test_state(int index) const; - inline ::caffe::NetState* mutable_test_state(int index); - inline ::caffe::NetState* add_test_state(); - inline const ::google::protobuf::RepeatedPtrField< ::caffe::NetState >& - test_state() const; - inline ::google::protobuf::RepeatedPtrField< ::caffe::NetState >* + const ::caffe::NetState& test_state(int index) const; + ::caffe::NetState* mutable_test_state(int index); + ::caffe::NetState* add_test_state(); + ::google::protobuf::RepeatedPtrField< ::caffe::NetState >* mutable_test_state(); + const ::google::protobuf::RepeatedPtrField< ::caffe::NetState >& + test_state() const; // repeated int32 test_iter = 3; - inline int test_iter_size() const; - inline void clear_test_iter(); + int test_iter_size() const; + void clear_test_iter(); static const int kTestIterFieldNumber = 3; - inline ::google::protobuf::int32 test_iter(int index) const; - inline void set_test_iter(int index, ::google::protobuf::int32 value); - inline void add_test_iter(::google::protobuf::int32 value); - inline const ::google::protobuf::RepeatedField< ::google::protobuf::int32 >& + ::google::protobuf::int32 test_iter(int index) const; + void set_test_iter(int index, ::google::protobuf::int32 value); + void add_test_iter(::google::protobuf::int32 value); + const ::google::protobuf::RepeatedField< ::google::protobuf::int32 >& test_iter() const; - inline ::google::protobuf::RepeatedField< ::google::protobuf::int32 >* + ::google::protobuf::RepeatedField< ::google::protobuf::int32 >* mutable_test_iter(); // optional int32 test_interval = 4 [default = 0]; - inline bool has_test_interval() const; - inline void clear_test_interval(); + bool has_test_interval() const; + void clear_test_interval(); static const int kTestIntervalFieldNumber = 4; - inline ::google::protobuf::int32 test_interval() const; - inline void set_test_interval(::google::protobuf::int32 value); + ::google::protobuf::int32 test_interval() const; + void set_test_interval(::google::protobuf::int32 value); // optional bool test_compute_loss = 19 [default = false]; - inline bool has_test_compute_loss() const; - inline void clear_test_compute_loss(); + bool has_test_compute_loss() const; + void clear_test_compute_loss(); static const int kTestComputeLossFieldNumber = 19; - inline bool test_compute_loss() const; - inline void set_test_compute_loss(bool value); + bool test_compute_loss() const; + void set_test_compute_loss(bool value); // optional bool test_initialization = 32 [default = true]; - inline bool has_test_initialization() const; - inline void clear_test_initialization(); + bool has_test_initialization() const; + void clear_test_initialization(); static const int kTestInitializationFieldNumber = 32; - inline bool test_initialization() const; - inline void set_test_initialization(bool value); + bool test_initialization() const; + void set_test_initialization(bool value); // optional float base_lr = 5; - inline bool has_base_lr() const; - inline void clear_base_lr(); + bool has_base_lr() const; + void clear_base_lr(); static const int kBaseLrFieldNumber = 5; - inline float base_lr() const; - inline void set_base_lr(float value); + float base_lr() const; + void set_base_lr(float value); // optional int32 display = 6; - inline bool has_display() const; - inline void clear_display(); + bool has_display() const; + void clear_display(); static const int kDisplayFieldNumber = 6; - inline ::google::protobuf::int32 display() const; - inline void set_display(::google::protobuf::int32 value); + ::google::protobuf::int32 display() const; + void set_display(::google::protobuf::int32 value); // optional int32 average_loss = 33 [default = 1]; - inline bool has_average_loss() const; - inline void clear_average_loss(); + bool has_average_loss() const; + void clear_average_loss(); static const int kAverageLossFieldNumber = 33; - inline ::google::protobuf::int32 average_loss() const; - inline void set_average_loss(::google::protobuf::int32 value); + ::google::protobuf::int32 average_loss() const; + void set_average_loss(::google::protobuf::int32 value); // optional int32 max_iter = 7; - inline bool has_max_iter() const; - inline void clear_max_iter(); + bool has_max_iter() const; + void clear_max_iter(); static const int kMaxIterFieldNumber = 7; - inline ::google::protobuf::int32 max_iter() const; - inline void set_max_iter(::google::protobuf::int32 value); + ::google::protobuf::int32 max_iter() const; + void set_max_iter(::google::protobuf::int32 value); // optional int32 iter_size = 36 [default = 1]; - inline bool has_iter_size() const; - inline void clear_iter_size(); + bool has_iter_size() const; + void clear_iter_size(); static const int kIterSizeFieldNumber = 36; - inline ::google::protobuf::int32 iter_size() const; - inline void set_iter_size(::google::protobuf::int32 value); + ::google::protobuf::int32 iter_size() const; + void set_iter_size(::google::protobuf::int32 value); // optional string lr_policy = 8; - inline bool has_lr_policy() const; - inline void clear_lr_policy(); + bool has_lr_policy() const; + void clear_lr_policy(); static const int kLrPolicyFieldNumber = 8; - inline const ::std::string& lr_policy() const; - inline void set_lr_policy(const ::std::string& value); - inline void set_lr_policy(const char* value); - inline void set_lr_policy(const char* value, size_t size); - inline ::std::string* mutable_lr_policy(); - inline ::std::string* release_lr_policy(); - inline void set_allocated_lr_policy(::std::string* lr_policy); + const ::std::string& lr_policy() const; + void set_lr_policy(const ::std::string& value); + void set_lr_policy(const char* value); + void set_lr_policy(const char* value, size_t size); + ::std::string* mutable_lr_policy(); + ::std::string* release_lr_policy(); + void set_allocated_lr_policy(::std::string* lr_policy); // optional float gamma = 9; - inline bool has_gamma() const; - inline void clear_gamma(); + bool has_gamma() const; + void clear_gamma(); static const int kGammaFieldNumber = 9; - inline float gamma() const; - inline void set_gamma(float value); + float gamma() const; + void set_gamma(float value); // optional float power = 10; - inline bool has_power() const; - inline void clear_power(); + bool has_power() const; + void clear_power(); static const int kPowerFieldNumber = 10; - inline float power() const; - inline void set_power(float value); + float power() const; + void set_power(float value); // optional float momentum = 11; - inline bool has_momentum() const; - inline void clear_momentum(); + bool has_momentum() const; + void clear_momentum(); static const int kMomentumFieldNumber = 11; - inline float momentum() const; - inline void set_momentum(float value); + float momentum() const; + void set_momentum(float value); // optional float weight_decay = 12; - inline bool has_weight_decay() const; - inline void clear_weight_decay(); + bool has_weight_decay() const; + void clear_weight_decay(); static const int kWeightDecayFieldNumber = 12; - inline float weight_decay() const; - inline void set_weight_decay(float value); + float weight_decay() const; + void set_weight_decay(float value); // optional string regularization_type = 29 [default = "L2"]; - inline bool has_regularization_type() const; - inline void clear_regularization_type(); + bool has_regularization_type() const; + void clear_regularization_type(); static const int kRegularizationTypeFieldNumber = 29; - inline const ::std::string& regularization_type() const; - inline void set_regularization_type(const ::std::string& value); - inline void set_regularization_type(const char* value); - inline void set_regularization_type(const char* value, size_t size); - inline ::std::string* mutable_regularization_type(); - inline ::std::string* release_regularization_type(); - inline void set_allocated_regularization_type(::std::string* regularization_type); + const ::std::string& regularization_type() const; + void set_regularization_type(const ::std::string& value); + void set_regularization_type(const char* value); + void set_regularization_type(const char* value, size_t size); + ::std::string* mutable_regularization_type(); + ::std::string* release_regularization_type(); + void set_allocated_regularization_type(::std::string* regularization_type); // optional int32 stepsize = 13; - inline bool has_stepsize() const; - inline void clear_stepsize(); + bool has_stepsize() const; + void clear_stepsize(); static const int kStepsizeFieldNumber = 13; - inline ::google::protobuf::int32 stepsize() const; - inline void set_stepsize(::google::protobuf::int32 value); + ::google::protobuf::int32 stepsize() const; + void set_stepsize(::google::protobuf::int32 value); // repeated int32 stepvalue = 34; - inline int stepvalue_size() const; - inline void clear_stepvalue(); + int stepvalue_size() const; + void clear_stepvalue(); static const int kStepvalueFieldNumber = 34; - inline ::google::protobuf::int32 stepvalue(int index) const; - inline void set_stepvalue(int index, ::google::protobuf::int32 value); - inline void add_stepvalue(::google::protobuf::int32 value); - inline const ::google::protobuf::RepeatedField< ::google::protobuf::int32 >& + ::google::protobuf::int32 stepvalue(int index) const; + void set_stepvalue(int index, ::google::protobuf::int32 value); + void add_stepvalue(::google::protobuf::int32 value); + const ::google::protobuf::RepeatedField< ::google::protobuf::int32 >& stepvalue() const; - inline ::google::protobuf::RepeatedField< ::google::protobuf::int32 >* + ::google::protobuf::RepeatedField< ::google::protobuf::int32 >* mutable_stepvalue(); // optional float clip_gradients = 35 [default = -1]; - inline bool has_clip_gradients() const; - inline void clear_clip_gradients(); + bool has_clip_gradients() const; + void clear_clip_gradients(); static const int kClipGradientsFieldNumber = 35; - inline float clip_gradients() const; - inline void set_clip_gradients(float value); + float clip_gradients() const; + void set_clip_gradients(float value); // optional int32 snapshot = 14 [default = 0]; - inline bool has_snapshot() const; - inline void clear_snapshot(); + bool has_snapshot() const; + void clear_snapshot(); static const int kSnapshotFieldNumber = 14; - inline ::google::protobuf::int32 snapshot() const; - inline void set_snapshot(::google::protobuf::int32 value); + ::google::protobuf::int32 snapshot() const; + void set_snapshot(::google::protobuf::int32 value); // optional string snapshot_prefix = 15; - inline bool has_snapshot_prefix() const; - inline void clear_snapshot_prefix(); + bool has_snapshot_prefix() const; + void clear_snapshot_prefix(); static const int kSnapshotPrefixFieldNumber = 15; - inline const ::std::string& snapshot_prefix() const; - inline void set_snapshot_prefix(const ::std::string& value); - inline void set_snapshot_prefix(const char* value); - inline void set_snapshot_prefix(const char* value, size_t size); - inline ::std::string* mutable_snapshot_prefix(); - inline ::std::string* release_snapshot_prefix(); - inline void set_allocated_snapshot_prefix(::std::string* snapshot_prefix); + const ::std::string& snapshot_prefix() const; + void set_snapshot_prefix(const ::std::string& value); + void set_snapshot_prefix(const char* value); + void set_snapshot_prefix(const char* value, size_t size); + ::std::string* mutable_snapshot_prefix(); + ::std::string* release_snapshot_prefix(); + void set_allocated_snapshot_prefix(::std::string* snapshot_prefix); // optional bool snapshot_diff = 16 [default = false]; - inline bool has_snapshot_diff() const; - inline void clear_snapshot_diff(); + bool has_snapshot_diff() const; + void clear_snapshot_diff(); static const int kSnapshotDiffFieldNumber = 16; - inline bool snapshot_diff() const; - inline void set_snapshot_diff(bool value); + bool snapshot_diff() const; + void set_snapshot_diff(bool value); // optional .caffe.SolverParameter.SolverMode solver_mode = 17 [default = GPU]; - inline bool has_solver_mode() const; - inline void clear_solver_mode(); + bool has_solver_mode() const; + void clear_solver_mode(); static const int kSolverModeFieldNumber = 17; - inline ::caffe::SolverParameter_SolverMode solver_mode() const; - inline void set_solver_mode(::caffe::SolverParameter_SolverMode value); + ::caffe::SolverParameter_SolverMode solver_mode() const; + void set_solver_mode(::caffe::SolverParameter_SolverMode value); // optional int32 device_id = 18 [default = 0]; - inline bool has_device_id() const; - inline void clear_device_id(); + bool has_device_id() const; + void clear_device_id(); static const int kDeviceIdFieldNumber = 18; - inline ::google::protobuf::int32 device_id() const; - inline void set_device_id(::google::protobuf::int32 value); + ::google::protobuf::int32 device_id() const; + void set_device_id(::google::protobuf::int32 value); // optional int64 random_seed = 20 [default = -1]; - inline bool has_random_seed() const; - inline void clear_random_seed(); + bool has_random_seed() const; + void clear_random_seed(); static const int kRandomSeedFieldNumber = 20; - inline ::google::protobuf::int64 random_seed() const; - inline void set_random_seed(::google::protobuf::int64 value); + ::google::protobuf::int64 random_seed() const; + void set_random_seed(::google::protobuf::int64 value); // optional .caffe.SolverParameter.SolverType solver_type = 30 [default = SGD]; - inline bool has_solver_type() const; - inline void clear_solver_type(); + bool has_solver_type() const; + void clear_solver_type(); static const int kSolverTypeFieldNumber = 30; - inline ::caffe::SolverParameter_SolverType solver_type() const; - inline void set_solver_type(::caffe::SolverParameter_SolverType value); + ::caffe::SolverParameter_SolverType solver_type() const; + void set_solver_type(::caffe::SolverParameter_SolverType value); // optional float delta = 31 [default = 1e-08]; - inline bool has_delta() const; - inline void clear_delta(); + bool has_delta() const; + void clear_delta(); static const int kDeltaFieldNumber = 31; - inline float delta() const; - inline void set_delta(float value); + float delta() const; + void set_delta(float value); // optional bool debug_info = 23 [default = false]; - inline bool has_debug_info() const; - inline void clear_debug_info(); + bool has_debug_info() const; + void clear_debug_info(); static const int kDebugInfoFieldNumber = 23; - inline bool debug_info() const; - inline void set_debug_info(bool value); + bool debug_info() const; + void set_debug_info(bool value); // optional bool snapshot_after_train = 28 [default = true]; - inline bool has_snapshot_after_train() const; - inline void clear_snapshot_after_train(); + bool has_snapshot_after_train() const; + void clear_snapshot_after_train(); static const int kSnapshotAfterTrainFieldNumber = 28; - inline bool snapshot_after_train() const; - inline void set_snapshot_after_train(bool value); + bool snapshot_after_train() const; + void set_snapshot_after_train(bool value); // @@protoc_insertion_point(class_scope:caffe.SolverParameter) private: @@ -2526,59 +2733,58 @@ class SolverParameter : public ::google::protobuf::Message { inline void set_has_snapshot_after_train(); inline void clear_has_snapshot_after_train(); - ::google::protobuf::UnknownFieldSet _unknown_fields_; - - ::std::string* net_; - ::caffe::NetParameter* net_param_; - ::std::string* train_net_; + ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_; + ::google::protobuf::internal::HasBits<2> _has_bits_; ::google::protobuf::RepeatedPtrField< ::std::string> test_net_; - ::caffe::NetParameter* train_net_param_; ::google::protobuf::RepeatedPtrField< ::caffe::NetParameter > test_net_param_; - ::caffe::NetState* train_state_; ::google::protobuf::RepeatedPtrField< ::caffe::NetState > test_state_; ::google::protobuf::RepeatedField< ::google::protobuf::int32 > test_iter_; + ::google::protobuf::RepeatedField< ::google::protobuf::int32 > stepvalue_; + ::google::protobuf::internal::ArenaStringPtr net_; + ::google::protobuf::internal::ArenaStringPtr train_net_; + ::google::protobuf::internal::ArenaStringPtr lr_policy_; + static ::std::string* _default_regularization_type_; + ::google::protobuf::internal::ArenaStringPtr regularization_type_; + ::google::protobuf::internal::ArenaStringPtr snapshot_prefix_; + ::caffe::NetParameter* net_param_; + ::caffe::NetParameter* train_net_param_; + ::caffe::NetState* train_state_; ::google::protobuf::int32 test_interval_; float base_lr_; ::google::protobuf::int32 display_; - ::google::protobuf::int32 average_loss_; ::google::protobuf::int32 max_iter_; - ::google::protobuf::int32 iter_size_; - ::std::string* lr_policy_; float gamma_; float power_; float momentum_; + float weight_decay_; + ::google::protobuf::int32 stepsize_; bool test_compute_loss_; - bool test_initialization_; bool snapshot_diff_; bool debug_info_; - float weight_decay_; - ::google::protobuf::int32 stepsize_; - ::std::string* regularization_type_; - static ::std::string* _default_regularization_type_; - ::google::protobuf::RepeatedField< ::google::protobuf::int32 > stepvalue_; - float clip_gradients_; ::google::protobuf::int32 snapshot_; - ::std::string* snapshot_prefix_; - int solver_mode_; ::google::protobuf::int32 device_id_; - ::google::protobuf::int64 random_seed_; int solver_type_; - float delta_; + ::google::protobuf::int32 average_loss_; + ::google::protobuf::int32 iter_size_; + bool test_initialization_; bool snapshot_after_train_; - + float clip_gradients_; + ::google::protobuf::int64 random_seed_; + int solver_mode_; + float delta_; mutable int _cached_size_; - ::google::protobuf::uint32 _has_bits_[(36 + 31) / 32]; - - friend void protobuf_AddDesc_caffe_2eproto(); + friend void protobuf_InitDefaults_caffe_2eproto_impl(); + friend void protobuf_AddDesc_caffe_2eproto_impl(); friend void protobuf_AssignDesc_caffe_2eproto(); friend void protobuf_ShutdownFile_caffe_2eproto(); void InitAsDefaultInstance(); - static SolverParameter* default_instance_; }; +extern ::google::protobuf::internal::ExplicitlyConstructed SolverParameter_default_instance_; + // ------------------------------------------------------------------- -class SolverState : public ::google::protobuf::Message { +class SolverState : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:caffe.SolverState) */ { public: SolverState(); virtual ~SolverState(); @@ -2591,21 +2797,25 @@ class SolverState : public ::google::protobuf::Message { } inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const { - return _unknown_fields_; + return _internal_metadata_.unknown_fields(); } inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() { - return &_unknown_fields_; + return _internal_metadata_.mutable_unknown_fields(); } static const ::google::protobuf::Descriptor* descriptor(); static const SolverState& default_instance(); + static const SolverState* internal_default_instance(); + void Swap(SolverState* other); // implements Message ---------------------------------------------- - SolverState* New() const; + inline SolverState* New() const { return New(NULL); } + + SolverState* New(::google::protobuf::Arena* arena) const; void CopyFrom(const ::google::protobuf::Message& from); void MergeFrom(const ::google::protobuf::Message& from); void CopyFrom(const SolverState& from); @@ -2613,17 +2823,30 @@ class SolverState : public ::google::protobuf::Message { void Clear(); bool IsInitialized() const; - int ByteSize() const; + size_t ByteSizeLong() const; bool MergePartialFromCodedStream( ::google::protobuf::io::CodedInputStream* input); void SerializeWithCachedSizes( ::google::protobuf::io::CodedOutputStream* output) const; - ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const; + ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray( + bool deterministic, ::google::protobuf::uint8* output) const; + ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const { + return InternalSerializeWithCachedSizesToArray(false, output); + } int GetCachedSize() const { return _cached_size_; } private: void SharedCtor(); void SharedDtor(); void SetCachedSize(int size) const; + void InternalSwap(SolverState* other); + void UnsafeMergeFrom(const SolverState& from); + private: + inline ::google::protobuf::Arena* GetArenaNoVirtual() const { + return _internal_metadata_.arena(); + } + inline void* MaybeArenaPtr() const { + return _internal_metadata_.raw_arena_ptr(); + } public: ::google::protobuf::Metadata GetMetadata() const; @@ -2633,42 +2856,42 @@ class SolverState : public ::google::protobuf::Message { // accessors ------------------------------------------------------- // optional int32 iter = 1; - inline bool has_iter() const; - inline void clear_iter(); + bool has_iter() const; + void clear_iter(); static const int kIterFieldNumber = 1; - inline ::google::protobuf::int32 iter() const; - inline void set_iter(::google::protobuf::int32 value); + ::google::protobuf::int32 iter() const; + void set_iter(::google::protobuf::int32 value); // optional string learned_net = 2; - inline bool has_learned_net() const; - inline void clear_learned_net(); + bool has_learned_net() const; + void clear_learned_net(); static const int kLearnedNetFieldNumber = 2; - inline const ::std::string& learned_net() const; - inline void set_learned_net(const ::std::string& value); - inline void set_learned_net(const char* value); - inline void set_learned_net(const char* value, size_t size); - inline ::std::string* mutable_learned_net(); - inline ::std::string* release_learned_net(); - inline void set_allocated_learned_net(::std::string* learned_net); + const ::std::string& learned_net() const; + void set_learned_net(const ::std::string& value); + void set_learned_net(const char* value); + void set_learned_net(const char* value, size_t size); + ::std::string* mutable_learned_net(); + ::std::string* release_learned_net(); + void set_allocated_learned_net(::std::string* learned_net); // repeated .caffe.BlobProto history = 3; - inline int history_size() const; - inline void clear_history(); + int history_size() const; + void clear_history(); static const int kHistoryFieldNumber = 3; - inline const ::caffe::BlobProto& history(int index) const; - inline ::caffe::BlobProto* mutable_history(int index); - inline ::caffe::BlobProto* add_history(); - inline const ::google::protobuf::RepeatedPtrField< ::caffe::BlobProto >& - history() const; - inline ::google::protobuf::RepeatedPtrField< ::caffe::BlobProto >* + const ::caffe::BlobProto& history(int index) const; + ::caffe::BlobProto* mutable_history(int index); + ::caffe::BlobProto* add_history(); + ::google::protobuf::RepeatedPtrField< ::caffe::BlobProto >* mutable_history(); + const ::google::protobuf::RepeatedPtrField< ::caffe::BlobProto >& + history() const; // optional int32 current_step = 4 [default = 0]; - inline bool has_current_step() const; - inline void clear_current_step(); + bool has_current_step() const; + void clear_current_step(); static const int kCurrentStepFieldNumber = 4; - inline ::google::protobuf::int32 current_step() const; - inline void set_current_step(::google::protobuf::int32 value); + ::google::protobuf::int32 current_step() const; + void set_current_step(::google::protobuf::int32 value); // @@protoc_insertion_point(class_scope:caffe.SolverState) private: @@ -2679,26 +2902,25 @@ class SolverState : public ::google::protobuf::Message { inline void set_has_current_step(); inline void clear_has_current_step(); - ::google::protobuf::UnknownFieldSet _unknown_fields_; - - ::std::string* learned_net_; + ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_; + ::google::protobuf::internal::HasBits<1> _has_bits_; + mutable int _cached_size_; + ::google::protobuf::RepeatedPtrField< ::caffe::BlobProto > history_; + ::google::protobuf::internal::ArenaStringPtr learned_net_; ::google::protobuf::int32 iter_; ::google::protobuf::int32 current_step_; - ::google::protobuf::RepeatedPtrField< ::caffe::BlobProto > history_; - - mutable int _cached_size_; - ::google::protobuf::uint32 _has_bits_[(4 + 31) / 32]; - - friend void protobuf_AddDesc_caffe_2eproto(); + friend void protobuf_InitDefaults_caffe_2eproto_impl(); + friend void protobuf_AddDesc_caffe_2eproto_impl(); friend void protobuf_AssignDesc_caffe_2eproto(); friend void protobuf_ShutdownFile_caffe_2eproto(); void InitAsDefaultInstance(); - static SolverState* default_instance_; }; +extern ::google::protobuf::internal::ExplicitlyConstructed SolverState_default_instance_; + // ------------------------------------------------------------------- -class NetState : public ::google::protobuf::Message { +class NetState : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:caffe.NetState) */ { public: NetState(); virtual ~NetState(); @@ -2711,21 +2933,25 @@ class NetState : public ::google::protobuf::Message { } inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const { - return _unknown_fields_; + return _internal_metadata_.unknown_fields(); } inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() { - return &_unknown_fields_; + return _internal_metadata_.mutable_unknown_fields(); } static const ::google::protobuf::Descriptor* descriptor(); static const NetState& default_instance(); + static const NetState* internal_default_instance(); + void Swap(NetState* other); // implements Message ---------------------------------------------- - NetState* New() const; + inline NetState* New() const { return New(NULL); } + + NetState* New(::google::protobuf::Arena* arena) const; void CopyFrom(const ::google::protobuf::Message& from); void MergeFrom(const ::google::protobuf::Message& from); void CopyFrom(const NetState& from); @@ -2733,17 +2959,30 @@ class NetState : public ::google::protobuf::Message { void Clear(); bool IsInitialized() const; - int ByteSize() const; + size_t ByteSizeLong() const; bool MergePartialFromCodedStream( ::google::protobuf::io::CodedInputStream* input); void SerializeWithCachedSizes( ::google::protobuf::io::CodedOutputStream* output) const; - ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const; + ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray( + bool deterministic, ::google::protobuf::uint8* output) const; + ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const { + return InternalSerializeWithCachedSizesToArray(false, output); + } int GetCachedSize() const { return _cached_size_; } private: void SharedCtor(); void SharedDtor(); void SetCachedSize(int size) const; + void InternalSwap(NetState* other); + void UnsafeMergeFrom(const NetState& from); + private: + inline ::google::protobuf::Arena* GetArenaNoVirtual() const { + return _internal_metadata_.arena(); + } + inline void* MaybeArenaPtr() const { + return _internal_metadata_.raw_arena_ptr(); + } public: ::google::protobuf::Metadata GetMetadata() const; @@ -2753,34 +2992,34 @@ class NetState : public ::google::protobuf::Message { // accessors ------------------------------------------------------- // optional .caffe.Phase phase = 1 [default = TEST]; - inline bool has_phase() const; - inline void clear_phase(); + bool has_phase() const; + void clear_phase(); static const int kPhaseFieldNumber = 1; - inline ::caffe::Phase phase() const; - inline void set_phase(::caffe::Phase value); + ::caffe::Phase phase() const; + void set_phase(::caffe::Phase value); // optional int32 level = 2 [default = 0]; - inline bool has_level() const; - inline void clear_level(); + bool has_level() const; + void clear_level(); static const int kLevelFieldNumber = 2; - inline ::google::protobuf::int32 level() const; - inline void set_level(::google::protobuf::int32 value); + ::google::protobuf::int32 level() const; + void set_level(::google::protobuf::int32 value); // repeated string stage = 3; - inline int stage_size() const; - inline void clear_stage(); + int stage_size() const; + void clear_stage(); static const int kStageFieldNumber = 3; - inline const ::std::string& stage(int index) const; - inline ::std::string* mutable_stage(int index); - inline void set_stage(int index, const ::std::string& value); - inline void set_stage(int index, const char* value); - inline void set_stage(int index, const char* value, size_t size); - inline ::std::string* add_stage(); - inline void add_stage(const ::std::string& value); - inline void add_stage(const char* value); - inline void add_stage(const char* value, size_t size); - inline const ::google::protobuf::RepeatedPtrField< ::std::string>& stage() const; - inline ::google::protobuf::RepeatedPtrField< ::std::string>* mutable_stage(); + const ::std::string& stage(int index) const; + ::std::string* mutable_stage(int index); + void set_stage(int index, const ::std::string& value); + void set_stage(int index, const char* value); + void set_stage(int index, const char* value, size_t size); + ::std::string* add_stage(); + void add_stage(const ::std::string& value); + void add_stage(const char* value); + void add_stage(const char* value, size_t size); + const ::google::protobuf::RepeatedPtrField< ::std::string>& stage() const; + ::google::protobuf::RepeatedPtrField< ::std::string>* mutable_stage(); // @@protoc_insertion_point(class_scope:caffe.NetState) private: @@ -2789,25 +3028,24 @@ class NetState : public ::google::protobuf::Message { inline void set_has_level(); inline void clear_has_level(); - ::google::protobuf::UnknownFieldSet _unknown_fields_; - - int phase_; - ::google::protobuf::int32 level_; - ::google::protobuf::RepeatedPtrField< ::std::string> stage_; - + ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_; + ::google::protobuf::internal::HasBits<1> _has_bits_; mutable int _cached_size_; - ::google::protobuf::uint32 _has_bits_[(3 + 31) / 32]; - - friend void protobuf_AddDesc_caffe_2eproto(); + ::google::protobuf::RepeatedPtrField< ::std::string> stage_; + ::google::protobuf::int32 level_; + int phase_; + friend void protobuf_InitDefaults_caffe_2eproto_impl(); + friend void protobuf_AddDesc_caffe_2eproto_impl(); friend void protobuf_AssignDesc_caffe_2eproto(); friend void protobuf_ShutdownFile_caffe_2eproto(); void InitAsDefaultInstance(); - static NetState* default_instance_; }; +extern ::google::protobuf::internal::ExplicitlyConstructed NetState_default_instance_; + // ------------------------------------------------------------------- -class NetStateRule : public ::google::protobuf::Message { +class NetStateRule : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:caffe.NetStateRule) */ { public: NetStateRule(); virtual ~NetStateRule(); @@ -2820,21 +3058,25 @@ class NetStateRule : public ::google::protobuf::Message { } inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const { - return _unknown_fields_; + return _internal_metadata_.unknown_fields(); } inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() { - return &_unknown_fields_; + return _internal_metadata_.mutable_unknown_fields(); } static const ::google::protobuf::Descriptor* descriptor(); static const NetStateRule& default_instance(); + static const NetStateRule* internal_default_instance(); + void Swap(NetStateRule* other); // implements Message ---------------------------------------------- - NetStateRule* New() const; + inline NetStateRule* New() const { return New(NULL); } + + NetStateRule* New(::google::protobuf::Arena* arena) const; void CopyFrom(const ::google::protobuf::Message& from); void MergeFrom(const ::google::protobuf::Message& from); void CopyFrom(const NetStateRule& from); @@ -2842,17 +3084,30 @@ class NetStateRule : public ::google::protobuf::Message { void Clear(); bool IsInitialized() const; - int ByteSize() const; + size_t ByteSizeLong() const; bool MergePartialFromCodedStream( ::google::protobuf::io::CodedInputStream* input); void SerializeWithCachedSizes( ::google::protobuf::io::CodedOutputStream* output) const; - ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const; + ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray( + bool deterministic, ::google::protobuf::uint8* output) const; + ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const { + return InternalSerializeWithCachedSizesToArray(false, output); + } int GetCachedSize() const { return _cached_size_; } private: void SharedCtor(); void SharedDtor(); void SetCachedSize(int size) const; + void InternalSwap(NetStateRule* other); + void UnsafeMergeFrom(const NetStateRule& from); + private: + inline ::google::protobuf::Arena* GetArenaNoVirtual() const { + return _internal_metadata_.arena(); + } + inline void* MaybeArenaPtr() const { + return _internal_metadata_.raw_arena_ptr(); + } public: ::google::protobuf::Metadata GetMetadata() const; @@ -2862,57 +3117,57 @@ class NetStateRule : public ::google::protobuf::Message { // accessors ------------------------------------------------------- // optional .caffe.Phase phase = 1; - inline bool has_phase() const; - inline void clear_phase(); + bool has_phase() const; + void clear_phase(); static const int kPhaseFieldNumber = 1; - inline ::caffe::Phase phase() const; - inline void set_phase(::caffe::Phase value); + ::caffe::Phase phase() const; + void set_phase(::caffe::Phase value); // optional int32 min_level = 2; - inline bool has_min_level() const; - inline void clear_min_level(); + bool has_min_level() const; + void clear_min_level(); static const int kMinLevelFieldNumber = 2; - inline ::google::protobuf::int32 min_level() const; - inline void set_min_level(::google::protobuf::int32 value); + ::google::protobuf::int32 min_level() const; + void set_min_level(::google::protobuf::int32 value); // optional int32 max_level = 3; - inline bool has_max_level() const; - inline void clear_max_level(); + bool has_max_level() const; + void clear_max_level(); static const int kMaxLevelFieldNumber = 3; - inline ::google::protobuf::int32 max_level() const; - inline void set_max_level(::google::protobuf::int32 value); + ::google::protobuf::int32 max_level() const; + void set_max_level(::google::protobuf::int32 value); // repeated string stage = 4; - inline int stage_size() const; - inline void clear_stage(); + int stage_size() const; + void clear_stage(); static const int kStageFieldNumber = 4; - inline const ::std::string& stage(int index) const; - inline ::std::string* mutable_stage(int index); - inline void set_stage(int index, const ::std::string& value); - inline void set_stage(int index, const char* value); - inline void set_stage(int index, const char* value, size_t size); - inline ::std::string* add_stage(); - inline void add_stage(const ::std::string& value); - inline void add_stage(const char* value); - inline void add_stage(const char* value, size_t size); - inline const ::google::protobuf::RepeatedPtrField< ::std::string>& stage() const; - inline ::google::protobuf::RepeatedPtrField< ::std::string>* mutable_stage(); + const ::std::string& stage(int index) const; + ::std::string* mutable_stage(int index); + void set_stage(int index, const ::std::string& value); + void set_stage(int index, const char* value); + void set_stage(int index, const char* value, size_t size); + ::std::string* add_stage(); + void add_stage(const ::std::string& value); + void add_stage(const char* value); + void add_stage(const char* value, size_t size); + const ::google::protobuf::RepeatedPtrField< ::std::string>& stage() const; + ::google::protobuf::RepeatedPtrField< ::std::string>* mutable_stage(); // repeated string not_stage = 5; - inline int not_stage_size() const; - inline void clear_not_stage(); + int not_stage_size() const; + void clear_not_stage(); static const int kNotStageFieldNumber = 5; - inline const ::std::string& not_stage(int index) const; - inline ::std::string* mutable_not_stage(int index); - inline void set_not_stage(int index, const ::std::string& value); - inline void set_not_stage(int index, const char* value); - inline void set_not_stage(int index, const char* value, size_t size); - inline ::std::string* add_not_stage(); - inline void add_not_stage(const ::std::string& value); - inline void add_not_stage(const char* value); - inline void add_not_stage(const char* value, size_t size); - inline const ::google::protobuf::RepeatedPtrField< ::std::string>& not_stage() const; - inline ::google::protobuf::RepeatedPtrField< ::std::string>* mutable_not_stage(); + const ::std::string& not_stage(int index) const; + ::std::string* mutable_not_stage(int index); + void set_not_stage(int index, const ::std::string& value); + void set_not_stage(int index, const char* value); + void set_not_stage(int index, const char* value, size_t size); + ::std::string* add_not_stage(); + void add_not_stage(const ::std::string& value); + void add_not_stage(const char* value); + void add_not_stage(const char* value, size_t size); + const ::google::protobuf::RepeatedPtrField< ::std::string>& not_stage() const; + ::google::protobuf::RepeatedPtrField< ::std::string>* mutable_not_stage(); // @@protoc_insertion_point(class_scope:caffe.NetStateRule) private: @@ -2923,27 +3178,26 @@ class NetStateRule : public ::google::protobuf::Message { inline void set_has_max_level(); inline void clear_has_max_level(); - ::google::protobuf::UnknownFieldSet _unknown_fields_; - - int phase_; - ::google::protobuf::int32 min_level_; + ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_; + ::google::protobuf::internal::HasBits<1> _has_bits_; + mutable int _cached_size_; ::google::protobuf::RepeatedPtrField< ::std::string> stage_; ::google::protobuf::RepeatedPtrField< ::std::string> not_stage_; + int phase_; + ::google::protobuf::int32 min_level_; ::google::protobuf::int32 max_level_; - - mutable int _cached_size_; - ::google::protobuf::uint32 _has_bits_[(5 + 31) / 32]; - - friend void protobuf_AddDesc_caffe_2eproto(); + friend void protobuf_InitDefaults_caffe_2eproto_impl(); + friend void protobuf_AddDesc_caffe_2eproto_impl(); friend void protobuf_AssignDesc_caffe_2eproto(); friend void protobuf_ShutdownFile_caffe_2eproto(); void InitAsDefaultInstance(); - static NetStateRule* default_instance_; }; +extern ::google::protobuf::internal::ExplicitlyConstructed NetStateRule_default_instance_; + // ------------------------------------------------------------------- -class ParamSpec : public ::google::protobuf::Message { +class ParamSpec : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:caffe.ParamSpec) */ { public: ParamSpec(); virtual ~ParamSpec(); @@ -2956,21 +3210,25 @@ class ParamSpec : public ::google::protobuf::Message { } inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const { - return _unknown_fields_; + return _internal_metadata_.unknown_fields(); } inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() { - return &_unknown_fields_; + return _internal_metadata_.mutable_unknown_fields(); } static const ::google::protobuf::Descriptor* descriptor(); static const ParamSpec& default_instance(); + static const ParamSpec* internal_default_instance(); + void Swap(ParamSpec* other); // implements Message ---------------------------------------------- - ParamSpec* New() const; + inline ParamSpec* New() const { return New(NULL); } + + ParamSpec* New(::google::protobuf::Arena* arena) const; void CopyFrom(const ::google::protobuf::Message& from); void MergeFrom(const ::google::protobuf::Message& from); void CopyFrom(const ParamSpec& from); @@ -2978,17 +3236,30 @@ class ParamSpec : public ::google::protobuf::Message { void Clear(); bool IsInitialized() const; - int ByteSize() const; + size_t ByteSizeLong() const; bool MergePartialFromCodedStream( ::google::protobuf::io::CodedInputStream* input); void SerializeWithCachedSizes( ::google::protobuf::io::CodedOutputStream* output) const; - ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const; + ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray( + bool deterministic, ::google::protobuf::uint8* output) const; + ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const { + return InternalSerializeWithCachedSizesToArray(false, output); + } int GetCachedSize() const { return _cached_size_; } private: void SharedCtor(); void SharedDtor(); void SetCachedSize(int size) const; + void InternalSwap(ParamSpec* other); + void UnsafeMergeFrom(const ParamSpec& from); + private: + inline ::google::protobuf::Arena* GetArenaNoVirtual() const { + return _internal_metadata_.arena(); + } + inline void* MaybeArenaPtr() const { + return _internal_metadata_.raw_arena_ptr(); + } public: ::google::protobuf::Metadata GetMetadata() const; @@ -2996,8 +3267,10 @@ class ParamSpec : public ::google::protobuf::Message { // nested types ---------------------------------------------------- typedef ParamSpec_DimCheckMode DimCheckMode; - static const DimCheckMode STRICT = ParamSpec_DimCheckMode_STRICT; - static const DimCheckMode PERMISSIVE = ParamSpec_DimCheckMode_PERMISSIVE; + static const DimCheckMode STRICT = + ParamSpec_DimCheckMode_STRICT; + static const DimCheckMode PERMISSIVE = + ParamSpec_DimCheckMode_PERMISSIVE; static inline bool DimCheckMode_IsValid(int value) { return ParamSpec_DimCheckMode_IsValid(value); } @@ -3022,37 +3295,37 @@ class ParamSpec : public ::google::protobuf::Message { // accessors ------------------------------------------------------- // optional string name = 1; - inline bool has_name() const; - inline void clear_name(); + bool has_name() const; + void clear_name(); static const int kNameFieldNumber = 1; - inline const ::std::string& name() const; - inline void set_name(const ::std::string& value); - inline void set_name(const char* value); - inline void set_name(const char* value, size_t size); - inline ::std::string* mutable_name(); - inline ::std::string* release_name(); - inline void set_allocated_name(::std::string* name); + const ::std::string& name() const; + void set_name(const ::std::string& value); + void set_name(const char* value); + void set_name(const char* value, size_t size); + ::std::string* mutable_name(); + ::std::string* release_name(); + void set_allocated_name(::std::string* name); // optional .caffe.ParamSpec.DimCheckMode share_mode = 2; - inline bool has_share_mode() const; - inline void clear_share_mode(); + bool has_share_mode() const; + void clear_share_mode(); static const int kShareModeFieldNumber = 2; - inline ::caffe::ParamSpec_DimCheckMode share_mode() const; - inline void set_share_mode(::caffe::ParamSpec_DimCheckMode value); + ::caffe::ParamSpec_DimCheckMode share_mode() const; + void set_share_mode(::caffe::ParamSpec_DimCheckMode value); // optional float lr_mult = 3 [default = 1]; - inline bool has_lr_mult() const; - inline void clear_lr_mult(); + bool has_lr_mult() const; + void clear_lr_mult(); static const int kLrMultFieldNumber = 3; - inline float lr_mult() const; - inline void set_lr_mult(float value); + float lr_mult() const; + void set_lr_mult(float value); // optional float decay_mult = 4 [default = 1]; - inline bool has_decay_mult() const; - inline void clear_decay_mult(); + bool has_decay_mult() const; + void clear_decay_mult(); static const int kDecayMultFieldNumber = 4; - inline float decay_mult() const; - inline void set_decay_mult(float value); + float decay_mult() const; + void set_decay_mult(float value); // @@protoc_insertion_point(class_scope:caffe.ParamSpec) private: @@ -3065,26 +3338,25 @@ class ParamSpec : public ::google::protobuf::Message { inline void set_has_decay_mult(); inline void clear_has_decay_mult(); - ::google::protobuf::UnknownFieldSet _unknown_fields_; - - ::std::string* name_; + ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_; + ::google::protobuf::internal::HasBits<1> _has_bits_; + mutable int _cached_size_; + ::google::protobuf::internal::ArenaStringPtr name_; int share_mode_; float lr_mult_; float decay_mult_; - - mutable int _cached_size_; - ::google::protobuf::uint32 _has_bits_[(4 + 31) / 32]; - - friend void protobuf_AddDesc_caffe_2eproto(); + friend void protobuf_InitDefaults_caffe_2eproto_impl(); + friend void protobuf_AddDesc_caffe_2eproto_impl(); friend void protobuf_AssignDesc_caffe_2eproto(); friend void protobuf_ShutdownFile_caffe_2eproto(); void InitAsDefaultInstance(); - static ParamSpec* default_instance_; }; +extern ::google::protobuf::internal::ExplicitlyConstructed ParamSpec_default_instance_; + // ------------------------------------------------------------------- -class LayerParameter : public ::google::protobuf::Message { +class LayerParameter : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:caffe.LayerParameter) */ { public: LayerParameter(); virtual ~LayerParameter(); @@ -3097,21 +3369,25 @@ class LayerParameter : public ::google::protobuf::Message { } inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const { - return _unknown_fields_; + return _internal_metadata_.unknown_fields(); } inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() { - return &_unknown_fields_; + return _internal_metadata_.mutable_unknown_fields(); } static const ::google::protobuf::Descriptor* descriptor(); static const LayerParameter& default_instance(); + static const LayerParameter* internal_default_instance(); + void Swap(LayerParameter* other); // implements Message ---------------------------------------------- - LayerParameter* New() const; + inline LayerParameter* New() const { return New(NULL); } + + LayerParameter* New(::google::protobuf::Arena* arena) const; void CopyFrom(const ::google::protobuf::Message& from); void MergeFrom(const ::google::protobuf::Message& from); void CopyFrom(const LayerParameter& from); @@ -3119,17 +3395,30 @@ class LayerParameter : public ::google::protobuf::Message { void Clear(); bool IsInitialized() const; - int ByteSize() const; + size_t ByteSizeLong() const; bool MergePartialFromCodedStream( ::google::protobuf::io::CodedInputStream* input); void SerializeWithCachedSizes( ::google::protobuf::io::CodedOutputStream* output) const; - ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const; + ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray( + bool deterministic, ::google::protobuf::uint8* output) const; + ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const { + return InternalSerializeWithCachedSizesToArray(false, output); + } int GetCachedSize() const { return _cached_size_; } private: void SharedCtor(); void SharedDtor(); void SetCachedSize(int size) const; + void InternalSwap(LayerParameter* other); + void UnsafeMergeFrom(const LayerParameter& from); + private: + inline ::google::protobuf::Arena* GetArenaNoVirtual() const { + return _internal_metadata_.arena(); + } + inline void* MaybeArenaPtr() const { + return _internal_metadata_.raw_arena_ptr(); + } public: ::google::protobuf::Metadata GetMetadata() const; @@ -3139,517 +3428,517 @@ class LayerParameter : public ::google::protobuf::Message { // accessors ------------------------------------------------------- // optional string name = 1; - inline bool has_name() const; - inline void clear_name(); + bool has_name() const; + void clear_name(); static const int kNameFieldNumber = 1; - inline const ::std::string& name() const; - inline void set_name(const ::std::string& value); - inline void set_name(const char* value); - inline void set_name(const char* value, size_t size); - inline ::std::string* mutable_name(); - inline ::std::string* release_name(); - inline void set_allocated_name(::std::string* name); + const ::std::string& name() const; + void set_name(const ::std::string& value); + void set_name(const char* value); + void set_name(const char* value, size_t size); + ::std::string* mutable_name(); + ::std::string* release_name(); + void set_allocated_name(::std::string* name); // optional string type = 2; - inline bool has_type() const; - inline void clear_type(); + bool has_type() const; + void clear_type(); static const int kTypeFieldNumber = 2; - inline const ::std::string& type() const; - inline void set_type(const ::std::string& value); - inline void set_type(const char* value); - inline void set_type(const char* value, size_t size); - inline ::std::string* mutable_type(); - inline ::std::string* release_type(); - inline void set_allocated_type(::std::string* type); + const ::std::string& type() const; + void set_type(const ::std::string& value); + void set_type(const char* value); + void set_type(const char* value, size_t size); + ::std::string* mutable_type(); + ::std::string* release_type(); + void set_allocated_type(::std::string* type); // repeated string bottom = 3; - inline int bottom_size() const; - inline void clear_bottom(); + int bottom_size() const; + void clear_bottom(); static const int kBottomFieldNumber = 3; - inline const ::std::string& bottom(int index) const; - inline ::std::string* mutable_bottom(int index); - inline void set_bottom(int index, const ::std::string& value); - inline void set_bottom(int index, const char* value); - inline void set_bottom(int index, const char* value, size_t size); - inline ::std::string* add_bottom(); - inline void add_bottom(const ::std::string& value); - inline void add_bottom(const char* value); - inline void add_bottom(const char* value, size_t size); - inline const ::google::protobuf::RepeatedPtrField< ::std::string>& bottom() const; - inline ::google::protobuf::RepeatedPtrField< ::std::string>* mutable_bottom(); + const ::std::string& bottom(int index) const; + ::std::string* mutable_bottom(int index); + void set_bottom(int index, const ::std::string& value); + void set_bottom(int index, const char* value); + void set_bottom(int index, const char* value, size_t size); + ::std::string* add_bottom(); + void add_bottom(const ::std::string& value); + void add_bottom(const char* value); + void add_bottom(const char* value, size_t size); + const ::google::protobuf::RepeatedPtrField< ::std::string>& bottom() const; + ::google::protobuf::RepeatedPtrField< ::std::string>* mutable_bottom(); // repeated string top = 4; - inline int top_size() const; - inline void clear_top(); + int top_size() const; + void clear_top(); static const int kTopFieldNumber = 4; - inline const ::std::string& top(int index) const; - inline ::std::string* mutable_top(int index); - inline void set_top(int index, const ::std::string& value); - inline void set_top(int index, const char* value); - inline void set_top(int index, const char* value, size_t size); - inline ::std::string* add_top(); - inline void add_top(const ::std::string& value); - inline void add_top(const char* value); - inline void add_top(const char* value, size_t size); - inline const ::google::protobuf::RepeatedPtrField< ::std::string>& top() const; - inline ::google::protobuf::RepeatedPtrField< ::std::string>* mutable_top(); + const ::std::string& top(int index) const; + ::std::string* mutable_top(int index); + void set_top(int index, const ::std::string& value); + void set_top(int index, const char* value); + void set_top(int index, const char* value, size_t size); + ::std::string* add_top(); + void add_top(const ::std::string& value); + void add_top(const char* value); + void add_top(const char* value, size_t size); + const ::google::protobuf::RepeatedPtrField< ::std::string>& top() const; + ::google::protobuf::RepeatedPtrField< ::std::string>* mutable_top(); // optional .caffe.Phase phase = 10; - inline bool has_phase() const; - inline void clear_phase(); + bool has_phase() const; + void clear_phase(); static const int kPhaseFieldNumber = 10; - inline ::caffe::Phase phase() const; - inline void set_phase(::caffe::Phase value); + ::caffe::Phase phase() const; + void set_phase(::caffe::Phase value); // repeated float loss_weight = 5; - inline int loss_weight_size() const; - inline void clear_loss_weight(); + int loss_weight_size() const; + void clear_loss_weight(); static const int kLossWeightFieldNumber = 5; - inline float loss_weight(int index) const; - inline void set_loss_weight(int index, float value); - inline void add_loss_weight(float value); - inline const ::google::protobuf::RepeatedField< float >& + float loss_weight(int index) const; + void set_loss_weight(int index, float value); + void add_loss_weight(float value); + const ::google::protobuf::RepeatedField< float >& loss_weight() const; - inline ::google::protobuf::RepeatedField< float >* + ::google::protobuf::RepeatedField< float >* mutable_loss_weight(); // repeated .caffe.ParamSpec param = 6; - inline int param_size() const; - inline void clear_param(); + int param_size() const; + void clear_param(); static const int kParamFieldNumber = 6; - inline const ::caffe::ParamSpec& param(int index) const; - inline ::caffe::ParamSpec* mutable_param(int index); - inline ::caffe::ParamSpec* add_param(); - inline const ::google::protobuf::RepeatedPtrField< ::caffe::ParamSpec >& - param() const; - inline ::google::protobuf::RepeatedPtrField< ::caffe::ParamSpec >* + const ::caffe::ParamSpec& param(int index) const; + ::caffe::ParamSpec* mutable_param(int index); + ::caffe::ParamSpec* add_param(); + ::google::protobuf::RepeatedPtrField< ::caffe::ParamSpec >* mutable_param(); + const ::google::protobuf::RepeatedPtrField< ::caffe::ParamSpec >& + param() const; // repeated .caffe.BlobProto blobs = 7; - inline int blobs_size() const; - inline void clear_blobs(); + int blobs_size() const; + void clear_blobs(); static const int kBlobsFieldNumber = 7; - inline const ::caffe::BlobProto& blobs(int index) const; - inline ::caffe::BlobProto* mutable_blobs(int index); - inline ::caffe::BlobProto* add_blobs(); - inline const ::google::protobuf::RepeatedPtrField< ::caffe::BlobProto >& - blobs() const; - inline ::google::protobuf::RepeatedPtrField< ::caffe::BlobProto >* + const ::caffe::BlobProto& blobs(int index) const; + ::caffe::BlobProto* mutable_blobs(int index); + ::caffe::BlobProto* add_blobs(); + ::google::protobuf::RepeatedPtrField< ::caffe::BlobProto >* mutable_blobs(); + const ::google::protobuf::RepeatedPtrField< ::caffe::BlobProto >& + blobs() const; // repeated bool propagate_down = 11; - inline int propagate_down_size() const; - inline void clear_propagate_down(); + int propagate_down_size() const; + void clear_propagate_down(); static const int kPropagateDownFieldNumber = 11; - inline bool propagate_down(int index) const; - inline void set_propagate_down(int index, bool value); - inline void add_propagate_down(bool value); - inline const ::google::protobuf::RepeatedField< bool >& + bool propagate_down(int index) const; + void set_propagate_down(int index, bool value); + void add_propagate_down(bool value); + const ::google::protobuf::RepeatedField< bool >& propagate_down() const; - inline ::google::protobuf::RepeatedField< bool >* + ::google::protobuf::RepeatedField< bool >* mutable_propagate_down(); // repeated .caffe.NetStateRule include = 8; - inline int include_size() const; - inline void clear_include(); + int include_size() const; + void clear_include(); static const int kIncludeFieldNumber = 8; - inline const ::caffe::NetStateRule& include(int index) const; - inline ::caffe::NetStateRule* mutable_include(int index); - inline ::caffe::NetStateRule* add_include(); - inline const ::google::protobuf::RepeatedPtrField< ::caffe::NetStateRule >& - include() const; - inline ::google::protobuf::RepeatedPtrField< ::caffe::NetStateRule >* + const ::caffe::NetStateRule& include(int index) const; + ::caffe::NetStateRule* mutable_include(int index); + ::caffe::NetStateRule* add_include(); + ::google::protobuf::RepeatedPtrField< ::caffe::NetStateRule >* mutable_include(); + const ::google::protobuf::RepeatedPtrField< ::caffe::NetStateRule >& + include() const; // repeated .caffe.NetStateRule exclude = 9; - inline int exclude_size() const; - inline void clear_exclude(); + int exclude_size() const; + void clear_exclude(); static const int kExcludeFieldNumber = 9; - inline const ::caffe::NetStateRule& exclude(int index) const; - inline ::caffe::NetStateRule* mutable_exclude(int index); - inline ::caffe::NetStateRule* add_exclude(); - inline const ::google::protobuf::RepeatedPtrField< ::caffe::NetStateRule >& - exclude() const; - inline ::google::protobuf::RepeatedPtrField< ::caffe::NetStateRule >* + const ::caffe::NetStateRule& exclude(int index) const; + ::caffe::NetStateRule* mutable_exclude(int index); + ::caffe::NetStateRule* add_exclude(); + ::google::protobuf::RepeatedPtrField< ::caffe::NetStateRule >* mutable_exclude(); + const ::google::protobuf::RepeatedPtrField< ::caffe::NetStateRule >& + exclude() const; // optional .caffe.TransformationParameter transform_param = 100; - inline bool has_transform_param() const; - inline void clear_transform_param(); + bool has_transform_param() const; + void clear_transform_param(); static const int kTransformParamFieldNumber = 100; - inline const ::caffe::TransformationParameter& transform_param() const; - inline ::caffe::TransformationParameter* mutable_transform_param(); - inline ::caffe::TransformationParameter* release_transform_param(); - inline void set_allocated_transform_param(::caffe::TransformationParameter* transform_param); + const ::caffe::TransformationParameter& transform_param() const; + ::caffe::TransformationParameter* mutable_transform_param(); + ::caffe::TransformationParameter* release_transform_param(); + void set_allocated_transform_param(::caffe::TransformationParameter* transform_param); // optional .caffe.LossParameter loss_param = 101; - inline bool has_loss_param() const; - inline void clear_loss_param(); + bool has_loss_param() const; + void clear_loss_param(); static const int kLossParamFieldNumber = 101; - inline const ::caffe::LossParameter& loss_param() const; - inline ::caffe::LossParameter* mutable_loss_param(); - inline ::caffe::LossParameter* release_loss_param(); - inline void set_allocated_loss_param(::caffe::LossParameter* loss_param); + const ::caffe::LossParameter& loss_param() const; + ::caffe::LossParameter* mutable_loss_param(); + ::caffe::LossParameter* release_loss_param(); + void set_allocated_loss_param(::caffe::LossParameter* loss_param); // optional .caffe.AccuracyParameter accuracy_param = 102; - inline bool has_accuracy_param() const; - inline void clear_accuracy_param(); + bool has_accuracy_param() const; + void clear_accuracy_param(); static const int kAccuracyParamFieldNumber = 102; - inline const ::caffe::AccuracyParameter& accuracy_param() const; - inline ::caffe::AccuracyParameter* mutable_accuracy_param(); - inline ::caffe::AccuracyParameter* release_accuracy_param(); - inline void set_allocated_accuracy_param(::caffe::AccuracyParameter* accuracy_param); + const ::caffe::AccuracyParameter& accuracy_param() const; + ::caffe::AccuracyParameter* mutable_accuracy_param(); + ::caffe::AccuracyParameter* release_accuracy_param(); + void set_allocated_accuracy_param(::caffe::AccuracyParameter* accuracy_param); // optional .caffe.ArgMaxParameter argmax_param = 103; - inline bool has_argmax_param() const; - inline void clear_argmax_param(); + bool has_argmax_param() const; + void clear_argmax_param(); static const int kArgmaxParamFieldNumber = 103; - inline const ::caffe::ArgMaxParameter& argmax_param() const; - inline ::caffe::ArgMaxParameter* mutable_argmax_param(); - inline ::caffe::ArgMaxParameter* release_argmax_param(); - inline void set_allocated_argmax_param(::caffe::ArgMaxParameter* argmax_param); + const ::caffe::ArgMaxParameter& argmax_param() const; + ::caffe::ArgMaxParameter* mutable_argmax_param(); + ::caffe::ArgMaxParameter* release_argmax_param(); + void set_allocated_argmax_param(::caffe::ArgMaxParameter* argmax_param); // optional .caffe.ConcatParameter concat_param = 104; - inline bool has_concat_param() const; - inline void clear_concat_param(); + bool has_concat_param() const; + void clear_concat_param(); static const int kConcatParamFieldNumber = 104; - inline const ::caffe::ConcatParameter& concat_param() const; - inline ::caffe::ConcatParameter* mutable_concat_param(); - inline ::caffe::ConcatParameter* release_concat_param(); - inline void set_allocated_concat_param(::caffe::ConcatParameter* concat_param); + const ::caffe::ConcatParameter& concat_param() const; + ::caffe::ConcatParameter* mutable_concat_param(); + ::caffe::ConcatParameter* release_concat_param(); + void set_allocated_concat_param(::caffe::ConcatParameter* concat_param); // optional .caffe.ContrastiveLossParameter contrastive_loss_param = 105; - inline bool has_contrastive_loss_param() const; - inline void clear_contrastive_loss_param(); + bool has_contrastive_loss_param() const; + void clear_contrastive_loss_param(); static const int kContrastiveLossParamFieldNumber = 105; - inline const ::caffe::ContrastiveLossParameter& contrastive_loss_param() const; - inline ::caffe::ContrastiveLossParameter* mutable_contrastive_loss_param(); - inline ::caffe::ContrastiveLossParameter* release_contrastive_loss_param(); - inline void set_allocated_contrastive_loss_param(::caffe::ContrastiveLossParameter* contrastive_loss_param); + const ::caffe::ContrastiveLossParameter& contrastive_loss_param() const; + ::caffe::ContrastiveLossParameter* mutable_contrastive_loss_param(); + ::caffe::ContrastiveLossParameter* release_contrastive_loss_param(); + void set_allocated_contrastive_loss_param(::caffe::ContrastiveLossParameter* contrastive_loss_param); // optional .caffe.ConvolutionParameter convolution_param = 106; - inline bool has_convolution_param() const; - inline void clear_convolution_param(); + bool has_convolution_param() const; + void clear_convolution_param(); static const int kConvolutionParamFieldNumber = 106; - inline const ::caffe::ConvolutionParameter& convolution_param() const; - inline ::caffe::ConvolutionParameter* mutable_convolution_param(); - inline ::caffe::ConvolutionParameter* release_convolution_param(); - inline void set_allocated_convolution_param(::caffe::ConvolutionParameter* convolution_param); + const ::caffe::ConvolutionParameter& convolution_param() const; + ::caffe::ConvolutionParameter* mutable_convolution_param(); + ::caffe::ConvolutionParameter* release_convolution_param(); + void set_allocated_convolution_param(::caffe::ConvolutionParameter* convolution_param); // optional .caffe.CropParameter crop_param = 137; - inline bool has_crop_param() const; - inline void clear_crop_param(); + bool has_crop_param() const; + void clear_crop_param(); static const int kCropParamFieldNumber = 137; - inline const ::caffe::CropParameter& crop_param() const; - inline ::caffe::CropParameter* mutable_crop_param(); - inline ::caffe::CropParameter* release_crop_param(); - inline void set_allocated_crop_param(::caffe::CropParameter* crop_param); + const ::caffe::CropParameter& crop_param() const; + ::caffe::CropParameter* mutable_crop_param(); + ::caffe::CropParameter* release_crop_param(); + void set_allocated_crop_param(::caffe::CropParameter* crop_param); // optional .caffe.DataParameter data_param = 107; - inline bool has_data_param() const; - inline void clear_data_param(); + bool has_data_param() const; + void clear_data_param(); static const int kDataParamFieldNumber = 107; - inline const ::caffe::DataParameter& data_param() const; - inline ::caffe::DataParameter* mutable_data_param(); - inline ::caffe::DataParameter* release_data_param(); - inline void set_allocated_data_param(::caffe::DataParameter* data_param); + const ::caffe::DataParameter& data_param() const; + ::caffe::DataParameter* mutable_data_param(); + ::caffe::DataParameter* release_data_param(); + void set_allocated_data_param(::caffe::DataParameter* data_param); // optional .caffe.DetectionOutputParameter detection_output_param = 141; - inline bool has_detection_output_param() const; - inline void clear_detection_output_param(); + bool has_detection_output_param() const; + void clear_detection_output_param(); static const int kDetectionOutputParamFieldNumber = 141; - inline const ::caffe::DetectionOutputParameter& detection_output_param() const; - inline ::caffe::DetectionOutputParameter* mutable_detection_output_param(); - inline ::caffe::DetectionOutputParameter* release_detection_output_param(); - inline void set_allocated_detection_output_param(::caffe::DetectionOutputParameter* detection_output_param); + const ::caffe::DetectionOutputParameter& detection_output_param() const; + ::caffe::DetectionOutputParameter* mutable_detection_output_param(); + ::caffe::DetectionOutputParameter* release_detection_output_param(); + void set_allocated_detection_output_param(::caffe::DetectionOutputParameter* detection_output_param); // optional .caffe.DropoutParameter dropout_param = 108; - inline bool has_dropout_param() const; - inline void clear_dropout_param(); + bool has_dropout_param() const; + void clear_dropout_param(); static const int kDropoutParamFieldNumber = 108; - inline const ::caffe::DropoutParameter& dropout_param() const; - inline ::caffe::DropoutParameter* mutable_dropout_param(); - inline ::caffe::DropoutParameter* release_dropout_param(); - inline void set_allocated_dropout_param(::caffe::DropoutParameter* dropout_param); + const ::caffe::DropoutParameter& dropout_param() const; + ::caffe::DropoutParameter* mutable_dropout_param(); + ::caffe::DropoutParameter* release_dropout_param(); + void set_allocated_dropout_param(::caffe::DropoutParameter* dropout_param); // optional .caffe.DummyDataParameter dummy_data_param = 109; - inline bool has_dummy_data_param() const; - inline void clear_dummy_data_param(); + bool has_dummy_data_param() const; + void clear_dummy_data_param(); static const int kDummyDataParamFieldNumber = 109; - inline const ::caffe::DummyDataParameter& dummy_data_param() const; - inline ::caffe::DummyDataParameter* mutable_dummy_data_param(); - inline ::caffe::DummyDataParameter* release_dummy_data_param(); - inline void set_allocated_dummy_data_param(::caffe::DummyDataParameter* dummy_data_param); + const ::caffe::DummyDataParameter& dummy_data_param() const; + ::caffe::DummyDataParameter* mutable_dummy_data_param(); + ::caffe::DummyDataParameter* release_dummy_data_param(); + void set_allocated_dummy_data_param(::caffe::DummyDataParameter* dummy_data_param); // optional .caffe.EltwiseParameter eltwise_param = 110; - inline bool has_eltwise_param() const; - inline void clear_eltwise_param(); + bool has_eltwise_param() const; + void clear_eltwise_param(); static const int kEltwiseParamFieldNumber = 110; - inline const ::caffe::EltwiseParameter& eltwise_param() const; - inline ::caffe::EltwiseParameter* mutable_eltwise_param(); - inline ::caffe::EltwiseParameter* release_eltwise_param(); - inline void set_allocated_eltwise_param(::caffe::EltwiseParameter* eltwise_param); + const ::caffe::EltwiseParameter& eltwise_param() const; + ::caffe::EltwiseParameter* mutable_eltwise_param(); + ::caffe::EltwiseParameter* release_eltwise_param(); + void set_allocated_eltwise_param(::caffe::EltwiseParameter* eltwise_param); // optional .caffe.ExpParameter exp_param = 111; - inline bool has_exp_param() const; - inline void clear_exp_param(); + bool has_exp_param() const; + void clear_exp_param(); static const int kExpParamFieldNumber = 111; - inline const ::caffe::ExpParameter& exp_param() const; - inline ::caffe::ExpParameter* mutable_exp_param(); - inline ::caffe::ExpParameter* release_exp_param(); - inline void set_allocated_exp_param(::caffe::ExpParameter* exp_param); + const ::caffe::ExpParameter& exp_param() const; + ::caffe::ExpParameter* mutable_exp_param(); + ::caffe::ExpParameter* release_exp_param(); + void set_allocated_exp_param(::caffe::ExpParameter* exp_param); // optional .caffe.FlattenParameter flatten_param = 135; - inline bool has_flatten_param() const; - inline void clear_flatten_param(); + bool has_flatten_param() const; + void clear_flatten_param(); static const int kFlattenParamFieldNumber = 135; - inline const ::caffe::FlattenParameter& flatten_param() const; - inline ::caffe::FlattenParameter* mutable_flatten_param(); - inline ::caffe::FlattenParameter* release_flatten_param(); - inline void set_allocated_flatten_param(::caffe::FlattenParameter* flatten_param); + const ::caffe::FlattenParameter& flatten_param() const; + ::caffe::FlattenParameter* mutable_flatten_param(); + ::caffe::FlattenParameter* release_flatten_param(); + void set_allocated_flatten_param(::caffe::FlattenParameter* flatten_param); // optional .caffe.HDF5DataParameter hdf5_data_param = 112; - inline bool has_hdf5_data_param() const; - inline void clear_hdf5_data_param(); + bool has_hdf5_data_param() const; + void clear_hdf5_data_param(); static const int kHdf5DataParamFieldNumber = 112; - inline const ::caffe::HDF5DataParameter& hdf5_data_param() const; - inline ::caffe::HDF5DataParameter* mutable_hdf5_data_param(); - inline ::caffe::HDF5DataParameter* release_hdf5_data_param(); - inline void set_allocated_hdf5_data_param(::caffe::HDF5DataParameter* hdf5_data_param); + const ::caffe::HDF5DataParameter& hdf5_data_param() const; + ::caffe::HDF5DataParameter* mutable_hdf5_data_param(); + ::caffe::HDF5DataParameter* release_hdf5_data_param(); + void set_allocated_hdf5_data_param(::caffe::HDF5DataParameter* hdf5_data_param); // optional .caffe.HDF5OutputParameter hdf5_output_param = 113; - inline bool has_hdf5_output_param() const; - inline void clear_hdf5_output_param(); + bool has_hdf5_output_param() const; + void clear_hdf5_output_param(); static const int kHdf5OutputParamFieldNumber = 113; - inline const ::caffe::HDF5OutputParameter& hdf5_output_param() const; - inline ::caffe::HDF5OutputParameter* mutable_hdf5_output_param(); - inline ::caffe::HDF5OutputParameter* release_hdf5_output_param(); - inline void set_allocated_hdf5_output_param(::caffe::HDF5OutputParameter* hdf5_output_param); + const ::caffe::HDF5OutputParameter& hdf5_output_param() const; + ::caffe::HDF5OutputParameter* mutable_hdf5_output_param(); + ::caffe::HDF5OutputParameter* release_hdf5_output_param(); + void set_allocated_hdf5_output_param(::caffe::HDF5OutputParameter* hdf5_output_param); // optional .caffe.HingeLossParameter hinge_loss_param = 114; - inline bool has_hinge_loss_param() const; - inline void clear_hinge_loss_param(); + bool has_hinge_loss_param() const; + void clear_hinge_loss_param(); static const int kHingeLossParamFieldNumber = 114; - inline const ::caffe::HingeLossParameter& hinge_loss_param() const; - inline ::caffe::HingeLossParameter* mutable_hinge_loss_param(); - inline ::caffe::HingeLossParameter* release_hinge_loss_param(); - inline void set_allocated_hinge_loss_param(::caffe::HingeLossParameter* hinge_loss_param); + const ::caffe::HingeLossParameter& hinge_loss_param() const; + ::caffe::HingeLossParameter* mutable_hinge_loss_param(); + ::caffe::HingeLossParameter* release_hinge_loss_param(); + void set_allocated_hinge_loss_param(::caffe::HingeLossParameter* hinge_loss_param); // optional .caffe.ImageDataParameter image_data_param = 115; - inline bool has_image_data_param() const; - inline void clear_image_data_param(); + bool has_image_data_param() const; + void clear_image_data_param(); static const int kImageDataParamFieldNumber = 115; - inline const ::caffe::ImageDataParameter& image_data_param() const; - inline ::caffe::ImageDataParameter* mutable_image_data_param(); - inline ::caffe::ImageDataParameter* release_image_data_param(); - inline void set_allocated_image_data_param(::caffe::ImageDataParameter* image_data_param); + const ::caffe::ImageDataParameter& image_data_param() const; + ::caffe::ImageDataParameter* mutable_image_data_param(); + ::caffe::ImageDataParameter* release_image_data_param(); + void set_allocated_image_data_param(::caffe::ImageDataParameter* image_data_param); // optional .caffe.InfogainLossParameter infogain_loss_param = 116; - inline bool has_infogain_loss_param() const; - inline void clear_infogain_loss_param(); + bool has_infogain_loss_param() const; + void clear_infogain_loss_param(); static const int kInfogainLossParamFieldNumber = 116; - inline const ::caffe::InfogainLossParameter& infogain_loss_param() const; - inline ::caffe::InfogainLossParameter* mutable_infogain_loss_param(); - inline ::caffe::InfogainLossParameter* release_infogain_loss_param(); - inline void set_allocated_infogain_loss_param(::caffe::InfogainLossParameter* infogain_loss_param); + const ::caffe::InfogainLossParameter& infogain_loss_param() const; + ::caffe::InfogainLossParameter* mutable_infogain_loss_param(); + ::caffe::InfogainLossParameter* release_infogain_loss_param(); + void set_allocated_infogain_loss_param(::caffe::InfogainLossParameter* infogain_loss_param); // optional .caffe.InnerProductParameter inner_product_param = 117; - inline bool has_inner_product_param() const; - inline void clear_inner_product_param(); + bool has_inner_product_param() const; + void clear_inner_product_param(); static const int kInnerProductParamFieldNumber = 117; - inline const ::caffe::InnerProductParameter& inner_product_param() const; - inline ::caffe::InnerProductParameter* mutable_inner_product_param(); - inline ::caffe::InnerProductParameter* release_inner_product_param(); - inline void set_allocated_inner_product_param(::caffe::InnerProductParameter* inner_product_param); + const ::caffe::InnerProductParameter& inner_product_param() const; + ::caffe::InnerProductParameter* mutable_inner_product_param(); + ::caffe::InnerProductParameter* release_inner_product_param(); + void set_allocated_inner_product_param(::caffe::InnerProductParameter* inner_product_param); // optional .caffe.LogParameter log_param = 134; - inline bool has_log_param() const; - inline void clear_log_param(); + bool has_log_param() const; + void clear_log_param(); static const int kLogParamFieldNumber = 134; - inline const ::caffe::LogParameter& log_param() const; - inline ::caffe::LogParameter* mutable_log_param(); - inline ::caffe::LogParameter* release_log_param(); - inline void set_allocated_log_param(::caffe::LogParameter* log_param); + const ::caffe::LogParameter& log_param() const; + ::caffe::LogParameter* mutable_log_param(); + ::caffe::LogParameter* release_log_param(); + void set_allocated_log_param(::caffe::LogParameter* log_param); // optional .caffe.LRNParameter lrn_param = 118; - inline bool has_lrn_param() const; - inline void clear_lrn_param(); + bool has_lrn_param() const; + void clear_lrn_param(); static const int kLrnParamFieldNumber = 118; - inline const ::caffe::LRNParameter& lrn_param() const; - inline ::caffe::LRNParameter* mutable_lrn_param(); - inline ::caffe::LRNParameter* release_lrn_param(); - inline void set_allocated_lrn_param(::caffe::LRNParameter* lrn_param); + const ::caffe::LRNParameter& lrn_param() const; + ::caffe::LRNParameter* mutable_lrn_param(); + ::caffe::LRNParameter* release_lrn_param(); + void set_allocated_lrn_param(::caffe::LRNParameter* lrn_param); // optional .caffe.MemoryDataParameter memory_data_param = 119; - inline bool has_memory_data_param() const; - inline void clear_memory_data_param(); + bool has_memory_data_param() const; + void clear_memory_data_param(); static const int kMemoryDataParamFieldNumber = 119; - inline const ::caffe::MemoryDataParameter& memory_data_param() const; - inline ::caffe::MemoryDataParameter* mutable_memory_data_param(); - inline ::caffe::MemoryDataParameter* release_memory_data_param(); - inline void set_allocated_memory_data_param(::caffe::MemoryDataParameter* memory_data_param); + const ::caffe::MemoryDataParameter& memory_data_param() const; + ::caffe::MemoryDataParameter* mutable_memory_data_param(); + ::caffe::MemoryDataParameter* release_memory_data_param(); + void set_allocated_memory_data_param(::caffe::MemoryDataParameter* memory_data_param); // optional .caffe.MVNParameter mvn_param = 120; - inline bool has_mvn_param() const; - inline void clear_mvn_param(); + bool has_mvn_param() const; + void clear_mvn_param(); static const int kMvnParamFieldNumber = 120; - inline const ::caffe::MVNParameter& mvn_param() const; - inline ::caffe::MVNParameter* mutable_mvn_param(); - inline ::caffe::MVNParameter* release_mvn_param(); - inline void set_allocated_mvn_param(::caffe::MVNParameter* mvn_param); + const ::caffe::MVNParameter& mvn_param() const; + ::caffe::MVNParameter* mutable_mvn_param(); + ::caffe::MVNParameter* release_mvn_param(); + void set_allocated_mvn_param(::caffe::MVNParameter* mvn_param); // optional .caffe.NormalizeBBoxParameter normalize_bbox_param = 139; - inline bool has_normalize_bbox_param() const; - inline void clear_normalize_bbox_param(); + bool has_normalize_bbox_param() const; + void clear_normalize_bbox_param(); static const int kNormalizeBboxParamFieldNumber = 139; - inline const ::caffe::NormalizeBBoxParameter& normalize_bbox_param() const; - inline ::caffe::NormalizeBBoxParameter* mutable_normalize_bbox_param(); - inline ::caffe::NormalizeBBoxParameter* release_normalize_bbox_param(); - inline void set_allocated_normalize_bbox_param(::caffe::NormalizeBBoxParameter* normalize_bbox_param); + const ::caffe::NormalizeBBoxParameter& normalize_bbox_param() const; + ::caffe::NormalizeBBoxParameter* mutable_normalize_bbox_param(); + ::caffe::NormalizeBBoxParameter* release_normalize_bbox_param(); + void set_allocated_normalize_bbox_param(::caffe::NormalizeBBoxParameter* normalize_bbox_param); // optional .caffe.PermuteParameter permute_param = 138; - inline bool has_permute_param() const; - inline void clear_permute_param(); + bool has_permute_param() const; + void clear_permute_param(); static const int kPermuteParamFieldNumber = 138; - inline const ::caffe::PermuteParameter& permute_param() const; - inline ::caffe::PermuteParameter* mutable_permute_param(); - inline ::caffe::PermuteParameter* release_permute_param(); - inline void set_allocated_permute_param(::caffe::PermuteParameter* permute_param); + const ::caffe::PermuteParameter& permute_param() const; + ::caffe::PermuteParameter* mutable_permute_param(); + ::caffe::PermuteParameter* release_permute_param(); + void set_allocated_permute_param(::caffe::PermuteParameter* permute_param); // optional .caffe.PoolingParameter pooling_param = 121; - inline bool has_pooling_param() const; - inline void clear_pooling_param(); + bool has_pooling_param() const; + void clear_pooling_param(); static const int kPoolingParamFieldNumber = 121; - inline const ::caffe::PoolingParameter& pooling_param() const; - inline ::caffe::PoolingParameter* mutable_pooling_param(); - inline ::caffe::PoolingParameter* release_pooling_param(); - inline void set_allocated_pooling_param(::caffe::PoolingParameter* pooling_param); + const ::caffe::PoolingParameter& pooling_param() const; + ::caffe::PoolingParameter* mutable_pooling_param(); + ::caffe::PoolingParameter* release_pooling_param(); + void set_allocated_pooling_param(::caffe::PoolingParameter* pooling_param); // optional .caffe.PowerParameter power_param = 122; - inline bool has_power_param() const; - inline void clear_power_param(); + bool has_power_param() const; + void clear_power_param(); static const int kPowerParamFieldNumber = 122; - inline const ::caffe::PowerParameter& power_param() const; - inline ::caffe::PowerParameter* mutable_power_param(); - inline ::caffe::PowerParameter* release_power_param(); - inline void set_allocated_power_param(::caffe::PowerParameter* power_param); + const ::caffe::PowerParameter& power_param() const; + ::caffe::PowerParameter* mutable_power_param(); + ::caffe::PowerParameter* release_power_param(); + void set_allocated_power_param(::caffe::PowerParameter* power_param); // optional .caffe.PReLUParameter prelu_param = 131; - inline bool has_prelu_param() const; - inline void clear_prelu_param(); + bool has_prelu_param() const; + void clear_prelu_param(); static const int kPreluParamFieldNumber = 131; - inline const ::caffe::PReLUParameter& prelu_param() const; - inline ::caffe::PReLUParameter* mutable_prelu_param(); - inline ::caffe::PReLUParameter* release_prelu_param(); - inline void set_allocated_prelu_param(::caffe::PReLUParameter* prelu_param); + const ::caffe::PReLUParameter& prelu_param() const; + ::caffe::PReLUParameter* mutable_prelu_param(); + ::caffe::PReLUParameter* release_prelu_param(); + void set_allocated_prelu_param(::caffe::PReLUParameter* prelu_param); // optional .caffe.PriorBoxParameter prior_box_param = 140; - inline bool has_prior_box_param() const; - inline void clear_prior_box_param(); + bool has_prior_box_param() const; + void clear_prior_box_param(); static const int kPriorBoxParamFieldNumber = 140; - inline const ::caffe::PriorBoxParameter& prior_box_param() const; - inline ::caffe::PriorBoxParameter* mutable_prior_box_param(); - inline ::caffe::PriorBoxParameter* release_prior_box_param(); - inline void set_allocated_prior_box_param(::caffe::PriorBoxParameter* prior_box_param); + const ::caffe::PriorBoxParameter& prior_box_param() const; + ::caffe::PriorBoxParameter* mutable_prior_box_param(); + ::caffe::PriorBoxParameter* release_prior_box_param(); + void set_allocated_prior_box_param(::caffe::PriorBoxParameter* prior_box_param); // optional .caffe.PythonParameter python_param = 130; - inline bool has_python_param() const; - inline void clear_python_param(); + bool has_python_param() const; + void clear_python_param(); static const int kPythonParamFieldNumber = 130; - inline const ::caffe::PythonParameter& python_param() const; - inline ::caffe::PythonParameter* mutable_python_param(); - inline ::caffe::PythonParameter* release_python_param(); - inline void set_allocated_python_param(::caffe::PythonParameter* python_param); + const ::caffe::PythonParameter& python_param() const; + ::caffe::PythonParameter* mutable_python_param(); + ::caffe::PythonParameter* release_python_param(); + void set_allocated_python_param(::caffe::PythonParameter* python_param); // optional .caffe.ReductionParameter reduction_param = 136; - inline bool has_reduction_param() const; - inline void clear_reduction_param(); + bool has_reduction_param() const; + void clear_reduction_param(); static const int kReductionParamFieldNumber = 136; - inline const ::caffe::ReductionParameter& reduction_param() const; - inline ::caffe::ReductionParameter* mutable_reduction_param(); - inline ::caffe::ReductionParameter* release_reduction_param(); - inline void set_allocated_reduction_param(::caffe::ReductionParameter* reduction_param); + const ::caffe::ReductionParameter& reduction_param() const; + ::caffe::ReductionParameter* mutable_reduction_param(); + ::caffe::ReductionParameter* release_reduction_param(); + void set_allocated_reduction_param(::caffe::ReductionParameter* reduction_param); // optional .caffe.ReLUParameter relu_param = 123; - inline bool has_relu_param() const; - inline void clear_relu_param(); + bool has_relu_param() const; + void clear_relu_param(); static const int kReluParamFieldNumber = 123; - inline const ::caffe::ReLUParameter& relu_param() const; - inline ::caffe::ReLUParameter* mutable_relu_param(); - inline ::caffe::ReLUParameter* release_relu_param(); - inline void set_allocated_relu_param(::caffe::ReLUParameter* relu_param); + const ::caffe::ReLUParameter& relu_param() const; + ::caffe::ReLUParameter* mutable_relu_param(); + ::caffe::ReLUParameter* release_relu_param(); + void set_allocated_relu_param(::caffe::ReLUParameter* relu_param); // optional .caffe.ReshapeParameter reshape_param = 133; - inline bool has_reshape_param() const; - inline void clear_reshape_param(); + bool has_reshape_param() const; + void clear_reshape_param(); static const int kReshapeParamFieldNumber = 133; - inline const ::caffe::ReshapeParameter& reshape_param() const; - inline ::caffe::ReshapeParameter* mutable_reshape_param(); - inline ::caffe::ReshapeParameter* release_reshape_param(); - inline void set_allocated_reshape_param(::caffe::ReshapeParameter* reshape_param); + const ::caffe::ReshapeParameter& reshape_param() const; + ::caffe::ReshapeParameter* mutable_reshape_param(); + ::caffe::ReshapeParameter* release_reshape_param(); + void set_allocated_reshape_param(::caffe::ReshapeParameter* reshape_param); // optional .caffe.SigmoidParameter sigmoid_param = 124; - inline bool has_sigmoid_param() const; - inline void clear_sigmoid_param(); + bool has_sigmoid_param() const; + void clear_sigmoid_param(); static const int kSigmoidParamFieldNumber = 124; - inline const ::caffe::SigmoidParameter& sigmoid_param() const; - inline ::caffe::SigmoidParameter* mutable_sigmoid_param(); - inline ::caffe::SigmoidParameter* release_sigmoid_param(); - inline void set_allocated_sigmoid_param(::caffe::SigmoidParameter* sigmoid_param); + const ::caffe::SigmoidParameter& sigmoid_param() const; + ::caffe::SigmoidParameter* mutable_sigmoid_param(); + ::caffe::SigmoidParameter* release_sigmoid_param(); + void set_allocated_sigmoid_param(::caffe::SigmoidParameter* sigmoid_param); // optional .caffe.SliceParameter slice_param = 126; - inline bool has_slice_param() const; - inline void clear_slice_param(); + bool has_slice_param() const; + void clear_slice_param(); static const int kSliceParamFieldNumber = 126; - inline const ::caffe::SliceParameter& slice_param() const; - inline ::caffe::SliceParameter* mutable_slice_param(); - inline ::caffe::SliceParameter* release_slice_param(); - inline void set_allocated_slice_param(::caffe::SliceParameter* slice_param); + const ::caffe::SliceParameter& slice_param() const; + ::caffe::SliceParameter* mutable_slice_param(); + ::caffe::SliceParameter* release_slice_param(); + void set_allocated_slice_param(::caffe::SliceParameter* slice_param); // optional .caffe.SoftmaxParameter softmax_param = 125; - inline bool has_softmax_param() const; - inline void clear_softmax_param(); + bool has_softmax_param() const; + void clear_softmax_param(); static const int kSoftmaxParamFieldNumber = 125; - inline const ::caffe::SoftmaxParameter& softmax_param() const; - inline ::caffe::SoftmaxParameter* mutable_softmax_param(); - inline ::caffe::SoftmaxParameter* release_softmax_param(); - inline void set_allocated_softmax_param(::caffe::SoftmaxParameter* softmax_param); + const ::caffe::SoftmaxParameter& softmax_param() const; + ::caffe::SoftmaxParameter* mutable_softmax_param(); + ::caffe::SoftmaxParameter* release_softmax_param(); + void set_allocated_softmax_param(::caffe::SoftmaxParameter* softmax_param); // optional .caffe.SPPParameter spp_param = 132; - inline bool has_spp_param() const; - inline void clear_spp_param(); + bool has_spp_param() const; + void clear_spp_param(); static const int kSppParamFieldNumber = 132; - inline const ::caffe::SPPParameter& spp_param() const; - inline ::caffe::SPPParameter* mutable_spp_param(); - inline ::caffe::SPPParameter* release_spp_param(); - inline void set_allocated_spp_param(::caffe::SPPParameter* spp_param); + const ::caffe::SPPParameter& spp_param() const; + ::caffe::SPPParameter* mutable_spp_param(); + ::caffe::SPPParameter* release_spp_param(); + void set_allocated_spp_param(::caffe::SPPParameter* spp_param); // optional .caffe.TanHParameter tanh_param = 127; - inline bool has_tanh_param() const; - inline void clear_tanh_param(); + bool has_tanh_param() const; + void clear_tanh_param(); static const int kTanhParamFieldNumber = 127; - inline const ::caffe::TanHParameter& tanh_param() const; - inline ::caffe::TanHParameter* mutable_tanh_param(); - inline ::caffe::TanHParameter* release_tanh_param(); - inline void set_allocated_tanh_param(::caffe::TanHParameter* tanh_param); + const ::caffe::TanHParameter& tanh_param() const; + ::caffe::TanHParameter* mutable_tanh_param(); + ::caffe::TanHParameter* release_tanh_param(); + void set_allocated_tanh_param(::caffe::TanHParameter* tanh_param); // optional .caffe.ThresholdParameter threshold_param = 128; - inline bool has_threshold_param() const; - inline void clear_threshold_param(); + bool has_threshold_param() const; + void clear_threshold_param(); static const int kThresholdParamFieldNumber = 128; - inline const ::caffe::ThresholdParameter& threshold_param() const; - inline ::caffe::ThresholdParameter* mutable_threshold_param(); - inline ::caffe::ThresholdParameter* release_threshold_param(); - inline void set_allocated_threshold_param(::caffe::ThresholdParameter* threshold_param); + const ::caffe::ThresholdParameter& threshold_param() const; + ::caffe::ThresholdParameter* mutable_threshold_param(); + ::caffe::ThresholdParameter* release_threshold_param(); + void set_allocated_threshold_param(::caffe::ThresholdParameter* threshold_param); // optional .caffe.WindowDataParameter window_data_param = 129; - inline bool has_window_data_param() const; - inline void clear_window_data_param(); + bool has_window_data_param() const; + void clear_window_data_param(); static const int kWindowDataParamFieldNumber = 129; - inline const ::caffe::WindowDataParameter& window_data_param() const; - inline ::caffe::WindowDataParameter* mutable_window_data_param(); - inline ::caffe::WindowDataParameter* release_window_data_param(); - inline void set_allocated_window_data_param(::caffe::WindowDataParameter* window_data_param); + const ::caffe::WindowDataParameter& window_data_param() const; + ::caffe::WindowDataParameter* mutable_window_data_param(); + ::caffe::WindowDataParameter* release_window_data_param(); + void set_allocated_window_data_param(::caffe::WindowDataParameter* window_data_param); // @@protoc_insertion_point(class_scope:caffe.LayerParameter) private: @@ -3744,10 +4033,8 @@ class LayerParameter : public ::google::protobuf::Message { inline void set_has_window_data_param(); inline void clear_has_window_data_param(); - ::google::protobuf::UnknownFieldSet _unknown_fields_; - - ::std::string* name_; - ::std::string* type_; + ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_; + ::google::protobuf::internal::HasBits<2> _has_bits_; ::google::protobuf::RepeatedPtrField< ::std::string> bottom_; ::google::protobuf::RepeatedPtrField< ::std::string> top_; ::google::protobuf::RepeatedField< float > loss_weight_; @@ -3756,6 +4043,8 @@ class LayerParameter : public ::google::protobuf::Message { ::google::protobuf::RepeatedField< bool > propagate_down_; ::google::protobuf::RepeatedPtrField< ::caffe::NetStateRule > include_; ::google::protobuf::RepeatedPtrField< ::caffe::NetStateRule > exclude_; + ::google::protobuf::internal::ArenaStringPtr name_; + ::google::protobuf::internal::ArenaStringPtr type_; ::caffe::TransformationParameter* transform_param_; ::caffe::LossParameter* loss_param_; ::caffe::AccuracyParameter* accuracy_param_; @@ -3799,20 +4088,19 @@ class LayerParameter : public ::google::protobuf::Message { ::caffe::ThresholdParameter* threshold_param_; ::caffe::WindowDataParameter* window_data_param_; int phase_; - mutable int _cached_size_; - ::google::protobuf::uint32 _has_bits_[(53 + 31) / 32]; - - friend void protobuf_AddDesc_caffe_2eproto(); + friend void protobuf_InitDefaults_caffe_2eproto_impl(); + friend void protobuf_AddDesc_caffe_2eproto_impl(); friend void protobuf_AssignDesc_caffe_2eproto(); friend void protobuf_ShutdownFile_caffe_2eproto(); void InitAsDefaultInstance(); - static LayerParameter* default_instance_; }; +extern ::google::protobuf::internal::ExplicitlyConstructed LayerParameter_default_instance_; + // ------------------------------------------------------------------- -class TransformationParameter : public ::google::protobuf::Message { +class TransformationParameter : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:caffe.TransformationParameter) */ { public: TransformationParameter(); virtual ~TransformationParameter(); @@ -3825,21 +4113,25 @@ class TransformationParameter : public ::google::protobuf::Message { } inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const { - return _unknown_fields_; + return _internal_metadata_.unknown_fields(); } inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() { - return &_unknown_fields_; + return _internal_metadata_.mutable_unknown_fields(); } static const ::google::protobuf::Descriptor* descriptor(); static const TransformationParameter& default_instance(); + static const TransformationParameter* internal_default_instance(); + void Swap(TransformationParameter* other); // implements Message ---------------------------------------------- - TransformationParameter* New() const; + inline TransformationParameter* New() const { return New(NULL); } + + TransformationParameter* New(::google::protobuf::Arena* arena) const; void CopyFrom(const ::google::protobuf::Message& from); void MergeFrom(const ::google::protobuf::Message& from); void CopyFrom(const TransformationParameter& from); @@ -3847,17 +4139,30 @@ class TransformationParameter : public ::google::protobuf::Message { void Clear(); bool IsInitialized() const; - int ByteSize() const; + size_t ByteSizeLong() const; bool MergePartialFromCodedStream( ::google::protobuf::io::CodedInputStream* input); void SerializeWithCachedSizes( ::google::protobuf::io::CodedOutputStream* output) const; - ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const; + ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray( + bool deterministic, ::google::protobuf::uint8* output) const; + ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const { + return InternalSerializeWithCachedSizesToArray(false, output); + } int GetCachedSize() const { return _cached_size_; } private: void SharedCtor(); void SharedDtor(); void SetCachedSize(int size) const; + void InternalSwap(TransformationParameter* other); + void UnsafeMergeFrom(const TransformationParameter& from); + private: + inline ::google::protobuf::Arena* GetArenaNoVirtual() const { + return _internal_metadata_.arena(); + } + inline void* MaybeArenaPtr() const { + return _internal_metadata_.raw_arena_ptr(); + } public: ::google::protobuf::Metadata GetMetadata() const; @@ -3867,63 +4172,63 @@ class TransformationParameter : public ::google::protobuf::Message { // accessors ------------------------------------------------------- // optional float scale = 1 [default = 1]; - inline bool has_scale() const; - inline void clear_scale(); + bool has_scale() const; + void clear_scale(); static const int kScaleFieldNumber = 1; - inline float scale() const; - inline void set_scale(float value); + float scale() const; + void set_scale(float value); // optional bool mirror = 2 [default = false]; - inline bool has_mirror() const; - inline void clear_mirror(); + bool has_mirror() const; + void clear_mirror(); static const int kMirrorFieldNumber = 2; - inline bool mirror() const; - inline void set_mirror(bool value); + bool mirror() const; + void set_mirror(bool value); // optional uint32 crop_size = 3 [default = 0]; - inline bool has_crop_size() const; - inline void clear_crop_size(); + bool has_crop_size() const; + void clear_crop_size(); static const int kCropSizeFieldNumber = 3; - inline ::google::protobuf::uint32 crop_size() const; - inline void set_crop_size(::google::protobuf::uint32 value); + ::google::protobuf::uint32 crop_size() const; + void set_crop_size(::google::protobuf::uint32 value); // optional string mean_file = 4; - inline bool has_mean_file() const; - inline void clear_mean_file(); + bool has_mean_file() const; + void clear_mean_file(); static const int kMeanFileFieldNumber = 4; - inline const ::std::string& mean_file() const; - inline void set_mean_file(const ::std::string& value); - inline void set_mean_file(const char* value); - inline void set_mean_file(const char* value, size_t size); - inline ::std::string* mutable_mean_file(); - inline ::std::string* release_mean_file(); - inline void set_allocated_mean_file(::std::string* mean_file); + const ::std::string& mean_file() const; + void set_mean_file(const ::std::string& value); + void set_mean_file(const char* value); + void set_mean_file(const char* value, size_t size); + ::std::string* mutable_mean_file(); + ::std::string* release_mean_file(); + void set_allocated_mean_file(::std::string* mean_file); // repeated float mean_value = 5; - inline int mean_value_size() const; - inline void clear_mean_value(); + int mean_value_size() const; + void clear_mean_value(); static const int kMeanValueFieldNumber = 5; - inline float mean_value(int index) const; - inline void set_mean_value(int index, float value); - inline void add_mean_value(float value); - inline const ::google::protobuf::RepeatedField< float >& + float mean_value(int index) const; + void set_mean_value(int index, float value); + void add_mean_value(float value); + const ::google::protobuf::RepeatedField< float >& mean_value() const; - inline ::google::protobuf::RepeatedField< float >* + ::google::protobuf::RepeatedField< float >* mutable_mean_value(); // optional bool force_color = 6 [default = false]; - inline bool has_force_color() const; - inline void clear_force_color(); + bool has_force_color() const; + void clear_force_color(); static const int kForceColorFieldNumber = 6; - inline bool force_color() const; - inline void set_force_color(bool value); + bool force_color() const; + void set_force_color(bool value); // optional bool force_gray = 7 [default = false]; - inline bool has_force_gray() const; - inline void clear_force_gray(); + bool has_force_gray() const; + void clear_force_gray(); static const int kForceGrayFieldNumber = 7; - inline bool force_gray() const; - inline void set_force_gray(bool value); + bool force_gray() const; + void set_force_gray(bool value); // @@protoc_insertion_point(class_scope:caffe.TransformationParameter) private: @@ -3940,29 +4245,28 @@ class TransformationParameter : public ::google::protobuf::Message { inline void set_has_force_gray(); inline void clear_has_force_gray(); - ::google::protobuf::UnknownFieldSet _unknown_fields_; - - float scale_; - ::google::protobuf::uint32 crop_size_; - ::std::string* mean_file_; + ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_; + ::google::protobuf::internal::HasBits<1> _has_bits_; + mutable int _cached_size_; ::google::protobuf::RepeatedField< float > mean_value_; + ::google::protobuf::internal::ArenaStringPtr mean_file_; + ::google::protobuf::uint32 crop_size_; bool mirror_; bool force_color_; bool force_gray_; - - mutable int _cached_size_; - ::google::protobuf::uint32 _has_bits_[(7 + 31) / 32]; - - friend void protobuf_AddDesc_caffe_2eproto(); + float scale_; + friend void protobuf_InitDefaults_caffe_2eproto_impl(); + friend void protobuf_AddDesc_caffe_2eproto_impl(); friend void protobuf_AssignDesc_caffe_2eproto(); friend void protobuf_ShutdownFile_caffe_2eproto(); void InitAsDefaultInstance(); - static TransformationParameter* default_instance_; }; +extern ::google::protobuf::internal::ExplicitlyConstructed TransformationParameter_default_instance_; + // ------------------------------------------------------------------- -class LossParameter : public ::google::protobuf::Message { +class LossParameter : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:caffe.LossParameter) */ { public: LossParameter(); virtual ~LossParameter(); @@ -3975,21 +4279,25 @@ class LossParameter : public ::google::protobuf::Message { } inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const { - return _unknown_fields_; + return _internal_metadata_.unknown_fields(); } inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() { - return &_unknown_fields_; + return _internal_metadata_.mutable_unknown_fields(); } static const ::google::protobuf::Descriptor* descriptor(); static const LossParameter& default_instance(); + static const LossParameter* internal_default_instance(); + void Swap(LossParameter* other); // implements Message ---------------------------------------------- - LossParameter* New() const; + inline LossParameter* New() const { return New(NULL); } + + LossParameter* New(::google::protobuf::Arena* arena) const; void CopyFrom(const ::google::protobuf::Message& from); void MergeFrom(const ::google::protobuf::Message& from); void CopyFrom(const LossParameter& from); @@ -3997,17 +4305,30 @@ class LossParameter : public ::google::protobuf::Message { void Clear(); bool IsInitialized() const; - int ByteSize() const; + size_t ByteSizeLong() const; bool MergePartialFromCodedStream( ::google::protobuf::io::CodedInputStream* input); void SerializeWithCachedSizes( ::google::protobuf::io::CodedOutputStream* output) const; - ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const; + ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray( + bool deterministic, ::google::protobuf::uint8* output) const; + ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const { + return InternalSerializeWithCachedSizesToArray(false, output); + } int GetCachedSize() const { return _cached_size_; } private: void SharedCtor(); void SharedDtor(); void SetCachedSize(int size) const; + void InternalSwap(LossParameter* other); + void UnsafeMergeFrom(const LossParameter& from); + private: + inline ::google::protobuf::Arena* GetArenaNoVirtual() const { + return _internal_metadata_.arena(); + } + inline void* MaybeArenaPtr() const { + return _internal_metadata_.raw_arena_ptr(); + } public: ::google::protobuf::Metadata GetMetadata() const; @@ -4017,18 +4338,18 @@ class LossParameter : public ::google::protobuf::Message { // accessors ------------------------------------------------------- // optional int32 ignore_label = 1; - inline bool has_ignore_label() const; - inline void clear_ignore_label(); + bool has_ignore_label() const; + void clear_ignore_label(); static const int kIgnoreLabelFieldNumber = 1; - inline ::google::protobuf::int32 ignore_label() const; - inline void set_ignore_label(::google::protobuf::int32 value); + ::google::protobuf::int32 ignore_label() const; + void set_ignore_label(::google::protobuf::int32 value); // optional bool normalize = 2 [default = true]; - inline bool has_normalize() const; - inline void clear_normalize(); + bool has_normalize() const; + void clear_normalize(); static const int kNormalizeFieldNumber = 2; - inline bool normalize() const; - inline void set_normalize(bool value); + bool normalize() const; + void set_normalize(bool value); // @@protoc_insertion_point(class_scope:caffe.LossParameter) private: @@ -4037,24 +4358,23 @@ class LossParameter : public ::google::protobuf::Message { inline void set_has_normalize(); inline void clear_has_normalize(); - ::google::protobuf::UnknownFieldSet _unknown_fields_; - + ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_; + ::google::protobuf::internal::HasBits<1> _has_bits_; + mutable int _cached_size_; ::google::protobuf::int32 ignore_label_; bool normalize_; - - mutable int _cached_size_; - ::google::protobuf::uint32 _has_bits_[(2 + 31) / 32]; - - friend void protobuf_AddDesc_caffe_2eproto(); + friend void protobuf_InitDefaults_caffe_2eproto_impl(); + friend void protobuf_AddDesc_caffe_2eproto_impl(); friend void protobuf_AssignDesc_caffe_2eproto(); friend void protobuf_ShutdownFile_caffe_2eproto(); void InitAsDefaultInstance(); - static LossParameter* default_instance_; }; +extern ::google::protobuf::internal::ExplicitlyConstructed LossParameter_default_instance_; + // ------------------------------------------------------------------- -class AccuracyParameter : public ::google::protobuf::Message { +class AccuracyParameter : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:caffe.AccuracyParameter) */ { public: AccuracyParameter(); virtual ~AccuracyParameter(); @@ -4067,21 +4387,25 @@ class AccuracyParameter : public ::google::protobuf::Message { } inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const { - return _unknown_fields_; + return _internal_metadata_.unknown_fields(); } inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() { - return &_unknown_fields_; + return _internal_metadata_.mutable_unknown_fields(); } static const ::google::protobuf::Descriptor* descriptor(); static const AccuracyParameter& default_instance(); + static const AccuracyParameter* internal_default_instance(); + void Swap(AccuracyParameter* other); // implements Message ---------------------------------------------- - AccuracyParameter* New() const; + inline AccuracyParameter* New() const { return New(NULL); } + + AccuracyParameter* New(::google::protobuf::Arena* arena) const; void CopyFrom(const ::google::protobuf::Message& from); void MergeFrom(const ::google::protobuf::Message& from); void CopyFrom(const AccuracyParameter& from); @@ -4089,17 +4413,30 @@ class AccuracyParameter : public ::google::protobuf::Message { void Clear(); bool IsInitialized() const; - int ByteSize() const; + size_t ByteSizeLong() const; bool MergePartialFromCodedStream( ::google::protobuf::io::CodedInputStream* input); void SerializeWithCachedSizes( ::google::protobuf::io::CodedOutputStream* output) const; - ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const; + ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray( + bool deterministic, ::google::protobuf::uint8* output) const; + ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const { + return InternalSerializeWithCachedSizesToArray(false, output); + } int GetCachedSize() const { return _cached_size_; } private: void SharedCtor(); void SharedDtor(); void SetCachedSize(int size) const; + void InternalSwap(AccuracyParameter* other); + void UnsafeMergeFrom(const AccuracyParameter& from); + private: + inline ::google::protobuf::Arena* GetArenaNoVirtual() const { + return _internal_metadata_.arena(); + } + inline void* MaybeArenaPtr() const { + return _internal_metadata_.raw_arena_ptr(); + } public: ::google::protobuf::Metadata GetMetadata() const; @@ -4109,25 +4446,25 @@ class AccuracyParameter : public ::google::protobuf::Message { // accessors ------------------------------------------------------- // optional uint32 top_k = 1 [default = 1]; - inline bool has_top_k() const; - inline void clear_top_k(); + bool has_top_k() const; + void clear_top_k(); static const int kTopKFieldNumber = 1; - inline ::google::protobuf::uint32 top_k() const; - inline void set_top_k(::google::protobuf::uint32 value); + ::google::protobuf::uint32 top_k() const; + void set_top_k(::google::protobuf::uint32 value); // optional int32 axis = 2 [default = 1]; - inline bool has_axis() const; - inline void clear_axis(); + bool has_axis() const; + void clear_axis(); static const int kAxisFieldNumber = 2; - inline ::google::protobuf::int32 axis() const; - inline void set_axis(::google::protobuf::int32 value); + ::google::protobuf::int32 axis() const; + void set_axis(::google::protobuf::int32 value); // optional int32 ignore_label = 3; - inline bool has_ignore_label() const; - inline void clear_ignore_label(); + bool has_ignore_label() const; + void clear_ignore_label(); static const int kIgnoreLabelFieldNumber = 3; - inline ::google::protobuf::int32 ignore_label() const; - inline void set_ignore_label(::google::protobuf::int32 value); + ::google::protobuf::int32 ignore_label() const; + void set_ignore_label(::google::protobuf::int32 value); // @@protoc_insertion_point(class_scope:caffe.AccuracyParameter) private: @@ -4138,25 +4475,24 @@ class AccuracyParameter : public ::google::protobuf::Message { inline void set_has_ignore_label(); inline void clear_has_ignore_label(); - ::google::protobuf::UnknownFieldSet _unknown_fields_; - + ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_; + ::google::protobuf::internal::HasBits<1> _has_bits_; + mutable int _cached_size_; + ::google::protobuf::int32 ignore_label_; ::google::protobuf::uint32 top_k_; ::google::protobuf::int32 axis_; - ::google::protobuf::int32 ignore_label_; - - mutable int _cached_size_; - ::google::protobuf::uint32 _has_bits_[(3 + 31) / 32]; - - friend void protobuf_AddDesc_caffe_2eproto(); + friend void protobuf_InitDefaults_caffe_2eproto_impl(); + friend void protobuf_AddDesc_caffe_2eproto_impl(); friend void protobuf_AssignDesc_caffe_2eproto(); friend void protobuf_ShutdownFile_caffe_2eproto(); void InitAsDefaultInstance(); - static AccuracyParameter* default_instance_; }; +extern ::google::protobuf::internal::ExplicitlyConstructed AccuracyParameter_default_instance_; + // ------------------------------------------------------------------- -class ArgMaxParameter : public ::google::protobuf::Message { +class ArgMaxParameter : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:caffe.ArgMaxParameter) */ { public: ArgMaxParameter(); virtual ~ArgMaxParameter(); @@ -4169,21 +4505,25 @@ class ArgMaxParameter : public ::google::protobuf::Message { } inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const { - return _unknown_fields_; + return _internal_metadata_.unknown_fields(); } inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() { - return &_unknown_fields_; + return _internal_metadata_.mutable_unknown_fields(); } static const ::google::protobuf::Descriptor* descriptor(); static const ArgMaxParameter& default_instance(); + static const ArgMaxParameter* internal_default_instance(); + void Swap(ArgMaxParameter* other); // implements Message ---------------------------------------------- - ArgMaxParameter* New() const; + inline ArgMaxParameter* New() const { return New(NULL); } + + ArgMaxParameter* New(::google::protobuf::Arena* arena) const; void CopyFrom(const ::google::protobuf::Message& from); void MergeFrom(const ::google::protobuf::Message& from); void CopyFrom(const ArgMaxParameter& from); @@ -4191,17 +4531,30 @@ class ArgMaxParameter : public ::google::protobuf::Message { void Clear(); bool IsInitialized() const; - int ByteSize() const; + size_t ByteSizeLong() const; bool MergePartialFromCodedStream( ::google::protobuf::io::CodedInputStream* input); void SerializeWithCachedSizes( ::google::protobuf::io::CodedOutputStream* output) const; - ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const; + ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray( + bool deterministic, ::google::protobuf::uint8* output) const; + ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const { + return InternalSerializeWithCachedSizesToArray(false, output); + } int GetCachedSize() const { return _cached_size_; } private: void SharedCtor(); void SharedDtor(); void SetCachedSize(int size) const; + void InternalSwap(ArgMaxParameter* other); + void UnsafeMergeFrom(const ArgMaxParameter& from); + private: + inline ::google::protobuf::Arena* GetArenaNoVirtual() const { + return _internal_metadata_.arena(); + } + inline void* MaybeArenaPtr() const { + return _internal_metadata_.raw_arena_ptr(); + } public: ::google::protobuf::Metadata GetMetadata() const; @@ -4211,18 +4564,18 @@ class ArgMaxParameter : public ::google::protobuf::Message { // accessors ------------------------------------------------------- // optional bool out_max_val = 1 [default = false]; - inline bool has_out_max_val() const; - inline void clear_out_max_val(); + bool has_out_max_val() const; + void clear_out_max_val(); static const int kOutMaxValFieldNumber = 1; - inline bool out_max_val() const; - inline void set_out_max_val(bool value); + bool out_max_val() const; + void set_out_max_val(bool value); // optional uint32 top_k = 2 [default = 1]; - inline bool has_top_k() const; - inline void clear_top_k(); + bool has_top_k() const; + void clear_top_k(); static const int kTopKFieldNumber = 2; - inline ::google::protobuf::uint32 top_k() const; - inline void set_top_k(::google::protobuf::uint32 value); + ::google::protobuf::uint32 top_k() const; + void set_top_k(::google::protobuf::uint32 value); // @@protoc_insertion_point(class_scope:caffe.ArgMaxParameter) private: @@ -4231,24 +4584,23 @@ class ArgMaxParameter : public ::google::protobuf::Message { inline void set_has_top_k(); inline void clear_has_top_k(); - ::google::protobuf::UnknownFieldSet _unknown_fields_; - + ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_; + ::google::protobuf::internal::HasBits<1> _has_bits_; + mutable int _cached_size_; bool out_max_val_; ::google::protobuf::uint32 top_k_; - - mutable int _cached_size_; - ::google::protobuf::uint32 _has_bits_[(2 + 31) / 32]; - - friend void protobuf_AddDesc_caffe_2eproto(); + friend void protobuf_InitDefaults_caffe_2eproto_impl(); + friend void protobuf_AddDesc_caffe_2eproto_impl(); friend void protobuf_AssignDesc_caffe_2eproto(); friend void protobuf_ShutdownFile_caffe_2eproto(); void InitAsDefaultInstance(); - static ArgMaxParameter* default_instance_; }; +extern ::google::protobuf::internal::ExplicitlyConstructed ArgMaxParameter_default_instance_; + // ------------------------------------------------------------------- -class ConcatParameter : public ::google::protobuf::Message { +class ConcatParameter : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:caffe.ConcatParameter) */ { public: ConcatParameter(); virtual ~ConcatParameter(); @@ -4261,21 +4613,25 @@ class ConcatParameter : public ::google::protobuf::Message { } inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const { - return _unknown_fields_; + return _internal_metadata_.unknown_fields(); } inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() { - return &_unknown_fields_; + return _internal_metadata_.mutable_unknown_fields(); } static const ::google::protobuf::Descriptor* descriptor(); static const ConcatParameter& default_instance(); + static const ConcatParameter* internal_default_instance(); + void Swap(ConcatParameter* other); // implements Message ---------------------------------------------- - ConcatParameter* New() const; + inline ConcatParameter* New() const { return New(NULL); } + + ConcatParameter* New(::google::protobuf::Arena* arena) const; void CopyFrom(const ::google::protobuf::Message& from); void MergeFrom(const ::google::protobuf::Message& from); void CopyFrom(const ConcatParameter& from); @@ -4283,17 +4639,30 @@ class ConcatParameter : public ::google::protobuf::Message { void Clear(); bool IsInitialized() const; - int ByteSize() const; + size_t ByteSizeLong() const; bool MergePartialFromCodedStream( ::google::protobuf::io::CodedInputStream* input); void SerializeWithCachedSizes( ::google::protobuf::io::CodedOutputStream* output) const; - ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const; + ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray( + bool deterministic, ::google::protobuf::uint8* output) const; + ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const { + return InternalSerializeWithCachedSizesToArray(false, output); + } int GetCachedSize() const { return _cached_size_; } private: void SharedCtor(); void SharedDtor(); void SetCachedSize(int size) const; + void InternalSwap(ConcatParameter* other); + void UnsafeMergeFrom(const ConcatParameter& from); + private: + inline ::google::protobuf::Arena* GetArenaNoVirtual() const { + return _internal_metadata_.arena(); + } + inline void* MaybeArenaPtr() const { + return _internal_metadata_.raw_arena_ptr(); + } public: ::google::protobuf::Metadata GetMetadata() const; @@ -4303,18 +4672,18 @@ class ConcatParameter : public ::google::protobuf::Message { // accessors ------------------------------------------------------- // optional int32 axis = 2 [default = 1]; - inline bool has_axis() const; - inline void clear_axis(); + bool has_axis() const; + void clear_axis(); static const int kAxisFieldNumber = 2; - inline ::google::protobuf::int32 axis() const; - inline void set_axis(::google::protobuf::int32 value); + ::google::protobuf::int32 axis() const; + void set_axis(::google::protobuf::int32 value); // optional uint32 concat_dim = 1 [default = 1]; - inline bool has_concat_dim() const; - inline void clear_concat_dim(); + bool has_concat_dim() const; + void clear_concat_dim(); static const int kConcatDimFieldNumber = 1; - inline ::google::protobuf::uint32 concat_dim() const; - inline void set_concat_dim(::google::protobuf::uint32 value); + ::google::protobuf::uint32 concat_dim() const; + void set_concat_dim(::google::protobuf::uint32 value); // @@protoc_insertion_point(class_scope:caffe.ConcatParameter) private: @@ -4323,24 +4692,23 @@ class ConcatParameter : public ::google::protobuf::Message { inline void set_has_concat_dim(); inline void clear_has_concat_dim(); - ::google::protobuf::UnknownFieldSet _unknown_fields_; - + ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_; + ::google::protobuf::internal::HasBits<1> _has_bits_; + mutable int _cached_size_; ::google::protobuf::int32 axis_; ::google::protobuf::uint32 concat_dim_; - - mutable int _cached_size_; - ::google::protobuf::uint32 _has_bits_[(2 + 31) / 32]; - - friend void protobuf_AddDesc_caffe_2eproto(); + friend void protobuf_InitDefaults_caffe_2eproto_impl(); + friend void protobuf_AddDesc_caffe_2eproto_impl(); friend void protobuf_AssignDesc_caffe_2eproto(); friend void protobuf_ShutdownFile_caffe_2eproto(); void InitAsDefaultInstance(); - static ConcatParameter* default_instance_; }; +extern ::google::protobuf::internal::ExplicitlyConstructed ConcatParameter_default_instance_; + // ------------------------------------------------------------------- -class ContrastiveLossParameter : public ::google::protobuf::Message { +class ContrastiveLossParameter : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:caffe.ContrastiveLossParameter) */ { public: ContrastiveLossParameter(); virtual ~ContrastiveLossParameter(); @@ -4353,21 +4721,25 @@ class ContrastiveLossParameter : public ::google::protobuf::Message { } inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const { - return _unknown_fields_; + return _internal_metadata_.unknown_fields(); } inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() { - return &_unknown_fields_; + return _internal_metadata_.mutable_unknown_fields(); } static const ::google::protobuf::Descriptor* descriptor(); static const ContrastiveLossParameter& default_instance(); + static const ContrastiveLossParameter* internal_default_instance(); + void Swap(ContrastiveLossParameter* other); // implements Message ---------------------------------------------- - ContrastiveLossParameter* New() const; + inline ContrastiveLossParameter* New() const { return New(NULL); } + + ContrastiveLossParameter* New(::google::protobuf::Arena* arena) const; void CopyFrom(const ::google::protobuf::Message& from); void MergeFrom(const ::google::protobuf::Message& from); void CopyFrom(const ContrastiveLossParameter& from); @@ -4375,17 +4747,30 @@ class ContrastiveLossParameter : public ::google::protobuf::Message { void Clear(); bool IsInitialized() const; - int ByteSize() const; + size_t ByteSizeLong() const; bool MergePartialFromCodedStream( ::google::protobuf::io::CodedInputStream* input); void SerializeWithCachedSizes( ::google::protobuf::io::CodedOutputStream* output) const; - ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const; + ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray( + bool deterministic, ::google::protobuf::uint8* output) const; + ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const { + return InternalSerializeWithCachedSizesToArray(false, output); + } int GetCachedSize() const { return _cached_size_; } private: void SharedCtor(); void SharedDtor(); void SetCachedSize(int size) const; + void InternalSwap(ContrastiveLossParameter* other); + void UnsafeMergeFrom(const ContrastiveLossParameter& from); + private: + inline ::google::protobuf::Arena* GetArenaNoVirtual() const { + return _internal_metadata_.arena(); + } + inline void* MaybeArenaPtr() const { + return _internal_metadata_.raw_arena_ptr(); + } public: ::google::protobuf::Metadata GetMetadata() const; @@ -4395,18 +4780,18 @@ class ContrastiveLossParameter : public ::google::protobuf::Message { // accessors ------------------------------------------------------- // optional float margin = 1 [default = 1]; - inline bool has_margin() const; - inline void clear_margin(); + bool has_margin() const; + void clear_margin(); static const int kMarginFieldNumber = 1; - inline float margin() const; - inline void set_margin(float value); + float margin() const; + void set_margin(float value); // optional bool legacy_version = 2 [default = false]; - inline bool has_legacy_version() const; - inline void clear_legacy_version(); + bool has_legacy_version() const; + void clear_legacy_version(); static const int kLegacyVersionFieldNumber = 2; - inline bool legacy_version() const; - inline void set_legacy_version(bool value); + bool legacy_version() const; + void set_legacy_version(bool value); // @@protoc_insertion_point(class_scope:caffe.ContrastiveLossParameter) private: @@ -4415,24 +4800,23 @@ class ContrastiveLossParameter : public ::google::protobuf::Message { inline void set_has_legacy_version(); inline void clear_has_legacy_version(); - ::google::protobuf::UnknownFieldSet _unknown_fields_; - - float margin_; - bool legacy_version_; - + ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_; + ::google::protobuf::internal::HasBits<1> _has_bits_; mutable int _cached_size_; - ::google::protobuf::uint32 _has_bits_[(2 + 31) / 32]; - - friend void protobuf_AddDesc_caffe_2eproto(); + bool legacy_version_; + float margin_; + friend void protobuf_InitDefaults_caffe_2eproto_impl(); + friend void protobuf_AddDesc_caffe_2eproto_impl(); friend void protobuf_AssignDesc_caffe_2eproto(); friend void protobuf_ShutdownFile_caffe_2eproto(); void InitAsDefaultInstance(); - static ContrastiveLossParameter* default_instance_; }; +extern ::google::protobuf::internal::ExplicitlyConstructed ContrastiveLossParameter_default_instance_; + // ------------------------------------------------------------------- -class ConvolutionParameter : public ::google::protobuf::Message { +class ConvolutionParameter : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:caffe.ConvolutionParameter) */ { public: ConvolutionParameter(); virtual ~ConvolutionParameter(); @@ -4445,21 +4829,25 @@ class ConvolutionParameter : public ::google::protobuf::Message { } inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const { - return _unknown_fields_; + return _internal_metadata_.unknown_fields(); } inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() { - return &_unknown_fields_; + return _internal_metadata_.mutable_unknown_fields(); } static const ::google::protobuf::Descriptor* descriptor(); static const ConvolutionParameter& default_instance(); + static const ConvolutionParameter* internal_default_instance(); + void Swap(ConvolutionParameter* other); // implements Message ---------------------------------------------- - ConvolutionParameter* New() const; + inline ConvolutionParameter* New() const { return New(NULL); } + + ConvolutionParameter* New(::google::protobuf::Arena* arena) const; void CopyFrom(const ::google::protobuf::Message& from); void MergeFrom(const ::google::protobuf::Message& from); void CopyFrom(const ConvolutionParameter& from); @@ -4467,17 +4855,30 @@ class ConvolutionParameter : public ::google::protobuf::Message { void Clear(); bool IsInitialized() const; - int ByteSize() const; + size_t ByteSizeLong() const; bool MergePartialFromCodedStream( ::google::protobuf::io::CodedInputStream* input); void SerializeWithCachedSizes( ::google::protobuf::io::CodedOutputStream* output) const; - ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const; + ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray( + bool deterministic, ::google::protobuf::uint8* output) const; + ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const { + return InternalSerializeWithCachedSizesToArray(false, output); + } int GetCachedSize() const { return _cached_size_; } private: void SharedCtor(); void SharedDtor(); void SetCachedSize(int size) const; + void InternalSwap(ConvolutionParameter* other); + void UnsafeMergeFrom(const ConvolutionParameter& from); + private: + inline ::google::protobuf::Arena* GetArenaNoVirtual() const { + return _internal_metadata_.arena(); + } + inline void* MaybeArenaPtr() const { + return _internal_metadata_.raw_arena_ptr(); + } public: ::google::protobuf::Metadata GetMetadata() const; @@ -4485,9 +4886,12 @@ class ConvolutionParameter : public ::google::protobuf::Message { // nested types ---------------------------------------------------- typedef ConvolutionParameter_Engine Engine; - static const Engine DEFAULT = ConvolutionParameter_Engine_DEFAULT; - static const Engine CAFFE = ConvolutionParameter_Engine_CAFFE; - static const Engine CUDNN = ConvolutionParameter_Engine_CUDNN; + static const Engine DEFAULT = + ConvolutionParameter_Engine_DEFAULT; + static const Engine CAFFE = + ConvolutionParameter_Engine_CAFFE; + static const Engine CUDNN = + ConvolutionParameter_Engine_CUDNN; static inline bool Engine_IsValid(int value) { return ConvolutionParameter_Engine_IsValid(value); } @@ -4512,134 +4916,134 @@ class ConvolutionParameter : public ::google::protobuf::Message { // accessors ------------------------------------------------------- // optional uint32 num_output = 1; - inline bool has_num_output() const; - inline void clear_num_output(); + bool has_num_output() const; + void clear_num_output(); static const int kNumOutputFieldNumber = 1; - inline ::google::protobuf::uint32 num_output() const; - inline void set_num_output(::google::protobuf::uint32 value); + ::google::protobuf::uint32 num_output() const; + void set_num_output(::google::protobuf::uint32 value); // optional bool bias_term = 2 [default = true]; - inline bool has_bias_term() const; - inline void clear_bias_term(); + bool has_bias_term() const; + void clear_bias_term(); static const int kBiasTermFieldNumber = 2; - inline bool bias_term() const; - inline void set_bias_term(bool value); + bool bias_term() const; + void set_bias_term(bool value); // optional uint32 pad = 3 [default = 0]; - inline bool has_pad() const; - inline void clear_pad(); + bool has_pad() const; + void clear_pad(); static const int kPadFieldNumber = 3; - inline ::google::protobuf::uint32 pad() const; - inline void set_pad(::google::protobuf::uint32 value); + ::google::protobuf::uint32 pad() const; + void set_pad(::google::protobuf::uint32 value); // optional uint32 pad_h = 9 [default = 0]; - inline bool has_pad_h() const; - inline void clear_pad_h(); + bool has_pad_h() const; + void clear_pad_h(); static const int kPadHFieldNumber = 9; - inline ::google::protobuf::uint32 pad_h() const; - inline void set_pad_h(::google::protobuf::uint32 value); + ::google::protobuf::uint32 pad_h() const; + void set_pad_h(::google::protobuf::uint32 value); // optional uint32 pad_w = 10 [default = 0]; - inline bool has_pad_w() const; - inline void clear_pad_w(); + bool has_pad_w() const; + void clear_pad_w(); static const int kPadWFieldNumber = 10; - inline ::google::protobuf::uint32 pad_w() const; - inline void set_pad_w(::google::protobuf::uint32 value); + ::google::protobuf::uint32 pad_w() const; + void set_pad_w(::google::protobuf::uint32 value); // optional uint32 kernel_size = 4; - inline bool has_kernel_size() const; - inline void clear_kernel_size(); + bool has_kernel_size() const; + void clear_kernel_size(); static const int kKernelSizeFieldNumber = 4; - inline ::google::protobuf::uint32 kernel_size() const; - inline void set_kernel_size(::google::protobuf::uint32 value); + ::google::protobuf::uint32 kernel_size() const; + void set_kernel_size(::google::protobuf::uint32 value); // optional uint32 kernel_h = 11; - inline bool has_kernel_h() const; - inline void clear_kernel_h(); + bool has_kernel_h() const; + void clear_kernel_h(); static const int kKernelHFieldNumber = 11; - inline ::google::protobuf::uint32 kernel_h() const; - inline void set_kernel_h(::google::protobuf::uint32 value); + ::google::protobuf::uint32 kernel_h() const; + void set_kernel_h(::google::protobuf::uint32 value); // optional uint32 kernel_w = 12; - inline bool has_kernel_w() const; - inline void clear_kernel_w(); + bool has_kernel_w() const; + void clear_kernel_w(); static const int kKernelWFieldNumber = 12; - inline ::google::protobuf::uint32 kernel_w() const; - inline void set_kernel_w(::google::protobuf::uint32 value); + ::google::protobuf::uint32 kernel_w() const; + void set_kernel_w(::google::protobuf::uint32 value); // optional uint32 group = 5 [default = 1]; - inline bool has_group() const; - inline void clear_group(); + bool has_group() const; + void clear_group(); static const int kGroupFieldNumber = 5; - inline ::google::protobuf::uint32 group() const; - inline void set_group(::google::protobuf::uint32 value); + ::google::protobuf::uint32 group() const; + void set_group(::google::protobuf::uint32 value); // optional uint32 stride = 6 [default = 1]; - inline bool has_stride() const; - inline void clear_stride(); + bool has_stride() const; + void clear_stride(); static const int kStrideFieldNumber = 6; - inline ::google::protobuf::uint32 stride() const; - inline void set_stride(::google::protobuf::uint32 value); + ::google::protobuf::uint32 stride() const; + void set_stride(::google::protobuf::uint32 value); // optional uint32 stride_h = 13; - inline bool has_stride_h() const; - inline void clear_stride_h(); + bool has_stride_h() const; + void clear_stride_h(); static const int kStrideHFieldNumber = 13; - inline ::google::protobuf::uint32 stride_h() const; - inline void set_stride_h(::google::protobuf::uint32 value); + ::google::protobuf::uint32 stride_h() const; + void set_stride_h(::google::protobuf::uint32 value); // optional uint32 stride_w = 14; - inline bool has_stride_w() const; - inline void clear_stride_w(); + bool has_stride_w() const; + void clear_stride_w(); static const int kStrideWFieldNumber = 14; - inline ::google::protobuf::uint32 stride_w() const; - inline void set_stride_w(::google::protobuf::uint32 value); + ::google::protobuf::uint32 stride_w() const; + void set_stride_w(::google::protobuf::uint32 value); // optional .caffe.FillerParameter weight_filler = 7; - inline bool has_weight_filler() const; - inline void clear_weight_filler(); + bool has_weight_filler() const; + void clear_weight_filler(); static const int kWeightFillerFieldNumber = 7; - inline const ::caffe::FillerParameter& weight_filler() const; - inline ::caffe::FillerParameter* mutable_weight_filler(); - inline ::caffe::FillerParameter* release_weight_filler(); - inline void set_allocated_weight_filler(::caffe::FillerParameter* weight_filler); + const ::caffe::FillerParameter& weight_filler() const; + ::caffe::FillerParameter* mutable_weight_filler(); + ::caffe::FillerParameter* release_weight_filler(); + void set_allocated_weight_filler(::caffe::FillerParameter* weight_filler); // optional .caffe.FillerParameter bias_filler = 8; - inline bool has_bias_filler() const; - inline void clear_bias_filler(); + bool has_bias_filler() const; + void clear_bias_filler(); static const int kBiasFillerFieldNumber = 8; - inline const ::caffe::FillerParameter& bias_filler() const; - inline ::caffe::FillerParameter* mutable_bias_filler(); - inline ::caffe::FillerParameter* release_bias_filler(); - inline void set_allocated_bias_filler(::caffe::FillerParameter* bias_filler); + const ::caffe::FillerParameter& bias_filler() const; + ::caffe::FillerParameter* mutable_bias_filler(); + ::caffe::FillerParameter* release_bias_filler(); + void set_allocated_bias_filler(::caffe::FillerParameter* bias_filler); // optional .caffe.ConvolutionParameter.Engine engine = 15 [default = DEFAULT]; - inline bool has_engine() const; - inline void clear_engine(); + bool has_engine() const; + void clear_engine(); static const int kEngineFieldNumber = 15; - inline ::caffe::ConvolutionParameter_Engine engine() const; - inline void set_engine(::caffe::ConvolutionParameter_Engine value); + ::caffe::ConvolutionParameter_Engine engine() const; + void set_engine(::caffe::ConvolutionParameter_Engine value); // optional uint32 dilation_h = 18; - inline bool has_dilation_h() const; - inline void clear_dilation_h(); + bool has_dilation_h() const; + void clear_dilation_h(); static const int kDilationHFieldNumber = 18; - inline ::google::protobuf::uint32 dilation_h() const; - inline void set_dilation_h(::google::protobuf::uint32 value); + ::google::protobuf::uint32 dilation_h() const; + void set_dilation_h(::google::protobuf::uint32 value); // optional uint32 dilation_w = 19; - inline bool has_dilation_w() const; - inline void clear_dilation_w(); + bool has_dilation_w() const; + void clear_dilation_w(); static const int kDilationWFieldNumber = 19; - inline ::google::protobuf::uint32 dilation_w() const; - inline void set_dilation_w(::google::protobuf::uint32 value); + ::google::protobuf::uint32 dilation_w() const; + void set_dilation_w(::google::protobuf::uint32 value); // optional uint32 dilation = 20; - inline bool has_dilation() const; - inline void clear_dilation(); + bool has_dilation() const; + void clear_dilation(); static const int kDilationFieldNumber = 20; - inline ::google::protobuf::uint32 dilation() const; - inline void set_dilation(::google::protobuf::uint32 value); + ::google::protobuf::uint32 dilation() const; + void set_dilation(::google::protobuf::uint32 value); // @@protoc_insertion_point(class_scope:caffe.ConvolutionParameter) private: @@ -4680,40 +5084,39 @@ class ConvolutionParameter : public ::google::protobuf::Message { inline void set_has_dilation(); inline void clear_has_dilation(); - ::google::protobuf::UnknownFieldSet _unknown_fields_; - + ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_; + ::google::protobuf::internal::HasBits<1> _has_bits_; + mutable int _cached_size_; + ::caffe::FillerParameter* weight_filler_; + ::caffe::FillerParameter* bias_filler_; ::google::protobuf::uint32 num_output_; - bool bias_term_; ::google::protobuf::uint32 pad_; ::google::protobuf::uint32 pad_h_; ::google::protobuf::uint32 pad_w_; ::google::protobuf::uint32 kernel_size_; ::google::protobuf::uint32 kernel_h_; ::google::protobuf::uint32 kernel_w_; - ::google::protobuf::uint32 group_; - ::google::protobuf::uint32 stride_; ::google::protobuf::uint32 stride_h_; ::google::protobuf::uint32 stride_w_; - ::caffe::FillerParameter* weight_filler_; - ::caffe::FillerParameter* bias_filler_; int engine_; ::google::protobuf::uint32 dilation_h_; ::google::protobuf::uint32 dilation_w_; ::google::protobuf::uint32 dilation_; - - mutable int _cached_size_; - ::google::protobuf::uint32 _has_bits_[(18 + 31) / 32]; - - friend void protobuf_AddDesc_caffe_2eproto(); + ::google::protobuf::uint32 stride_; + bool bias_term_; + ::google::protobuf::uint32 group_; + friend void protobuf_InitDefaults_caffe_2eproto_impl(); + friend void protobuf_AddDesc_caffe_2eproto_impl(); friend void protobuf_AssignDesc_caffe_2eproto(); friend void protobuf_ShutdownFile_caffe_2eproto(); void InitAsDefaultInstance(); - static ConvolutionParameter* default_instance_; }; +extern ::google::protobuf::internal::ExplicitlyConstructed ConvolutionParameter_default_instance_; + // ------------------------------------------------------------------- -class DataParameter : public ::google::protobuf::Message { +class DataParameter : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:caffe.DataParameter) */ { public: DataParameter(); virtual ~DataParameter(); @@ -4726,21 +5129,25 @@ class DataParameter : public ::google::protobuf::Message { } inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const { - return _unknown_fields_; + return _internal_metadata_.unknown_fields(); } inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() { - return &_unknown_fields_; + return _internal_metadata_.mutable_unknown_fields(); } static const ::google::protobuf::Descriptor* descriptor(); static const DataParameter& default_instance(); + static const DataParameter* internal_default_instance(); + void Swap(DataParameter* other); // implements Message ---------------------------------------------- - DataParameter* New() const; + inline DataParameter* New() const { return New(NULL); } + + DataParameter* New(::google::protobuf::Arena* arena) const; void CopyFrom(const ::google::protobuf::Message& from); void MergeFrom(const ::google::protobuf::Message& from); void CopyFrom(const DataParameter& from); @@ -4748,17 +5155,30 @@ class DataParameter : public ::google::protobuf::Message { void Clear(); bool IsInitialized() const; - int ByteSize() const; + size_t ByteSizeLong() const; bool MergePartialFromCodedStream( ::google::protobuf::io::CodedInputStream* input); void SerializeWithCachedSizes( ::google::protobuf::io::CodedOutputStream* output) const; - ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const; + ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray( + bool deterministic, ::google::protobuf::uint8* output) const; + ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const { + return InternalSerializeWithCachedSizesToArray(false, output); + } int GetCachedSize() const { return _cached_size_; } private: void SharedCtor(); void SharedDtor(); void SetCachedSize(int size) const; + void InternalSwap(DataParameter* other); + void UnsafeMergeFrom(const DataParameter& from); + private: + inline ::google::protobuf::Arena* GetArenaNoVirtual() const { + return _internal_metadata_.arena(); + } + inline void* MaybeArenaPtr() const { + return _internal_metadata_.raw_arena_ptr(); + } public: ::google::protobuf::Metadata GetMetadata() const; @@ -4766,8 +5186,10 @@ class DataParameter : public ::google::protobuf::Message { // nested types ---------------------------------------------------- typedef DataParameter_DB DB; - static const DB LEVELDB = DataParameter_DB_LEVELDB; - static const DB LMDB = DataParameter_DB_LMDB; + static const DB LEVELDB = + DataParameter_DB_LEVELDB; + static const DB LMDB = + DataParameter_DB_LMDB; static inline bool DB_IsValid(int value) { return DataParameter_DB_IsValid(value); } @@ -4792,77 +5214,77 @@ class DataParameter : public ::google::protobuf::Message { // accessors ------------------------------------------------------- // optional string source = 1; - inline bool has_source() const; - inline void clear_source(); + bool has_source() const; + void clear_source(); static const int kSourceFieldNumber = 1; - inline const ::std::string& source() const; - inline void set_source(const ::std::string& value); - inline void set_source(const char* value); - inline void set_source(const char* value, size_t size); - inline ::std::string* mutable_source(); - inline ::std::string* release_source(); - inline void set_allocated_source(::std::string* source); + const ::std::string& source() const; + void set_source(const ::std::string& value); + void set_source(const char* value); + void set_source(const char* value, size_t size); + ::std::string* mutable_source(); + ::std::string* release_source(); + void set_allocated_source(::std::string* source); // optional uint32 batch_size = 4; - inline bool has_batch_size() const; - inline void clear_batch_size(); + bool has_batch_size() const; + void clear_batch_size(); static const int kBatchSizeFieldNumber = 4; - inline ::google::protobuf::uint32 batch_size() const; - inline void set_batch_size(::google::protobuf::uint32 value); + ::google::protobuf::uint32 batch_size() const; + void set_batch_size(::google::protobuf::uint32 value); // optional uint32 rand_skip = 7 [default = 0]; - inline bool has_rand_skip() const; - inline void clear_rand_skip(); + bool has_rand_skip() const; + void clear_rand_skip(); static const int kRandSkipFieldNumber = 7; - inline ::google::protobuf::uint32 rand_skip() const; - inline void set_rand_skip(::google::protobuf::uint32 value); + ::google::protobuf::uint32 rand_skip() const; + void set_rand_skip(::google::protobuf::uint32 value); // optional .caffe.DataParameter.DB backend = 8 [default = LEVELDB]; - inline bool has_backend() const; - inline void clear_backend(); + bool has_backend() const; + void clear_backend(); static const int kBackendFieldNumber = 8; - inline ::caffe::DataParameter_DB backend() const; - inline void set_backend(::caffe::DataParameter_DB value); + ::caffe::DataParameter_DB backend() const; + void set_backend(::caffe::DataParameter_DB value); // optional float scale = 2 [default = 1]; - inline bool has_scale() const; - inline void clear_scale(); + bool has_scale() const; + void clear_scale(); static const int kScaleFieldNumber = 2; - inline float scale() const; - inline void set_scale(float value); + float scale() const; + void set_scale(float value); // optional string mean_file = 3; - inline bool has_mean_file() const; - inline void clear_mean_file(); + bool has_mean_file() const; + void clear_mean_file(); static const int kMeanFileFieldNumber = 3; - inline const ::std::string& mean_file() const; - inline void set_mean_file(const ::std::string& value); - inline void set_mean_file(const char* value); - inline void set_mean_file(const char* value, size_t size); - inline ::std::string* mutable_mean_file(); - inline ::std::string* release_mean_file(); - inline void set_allocated_mean_file(::std::string* mean_file); + const ::std::string& mean_file() const; + void set_mean_file(const ::std::string& value); + void set_mean_file(const char* value); + void set_mean_file(const char* value, size_t size); + ::std::string* mutable_mean_file(); + ::std::string* release_mean_file(); + void set_allocated_mean_file(::std::string* mean_file); // optional uint32 crop_size = 5 [default = 0]; - inline bool has_crop_size() const; - inline void clear_crop_size(); + bool has_crop_size() const; + void clear_crop_size(); static const int kCropSizeFieldNumber = 5; - inline ::google::protobuf::uint32 crop_size() const; - inline void set_crop_size(::google::protobuf::uint32 value); + ::google::protobuf::uint32 crop_size() const; + void set_crop_size(::google::protobuf::uint32 value); // optional bool mirror = 6 [default = false]; - inline bool has_mirror() const; - inline void clear_mirror(); + bool has_mirror() const; + void clear_mirror(); static const int kMirrorFieldNumber = 6; - inline bool mirror() const; - inline void set_mirror(bool value); + bool mirror() const; + void set_mirror(bool value); // optional bool force_encoded_color = 9 [default = false]; - inline bool has_force_encoded_color() const; - inline void clear_force_encoded_color(); + bool has_force_encoded_color() const; + void clear_force_encoded_color(); static const int kForceEncodedColorFieldNumber = 9; - inline bool force_encoded_color() const; - inline void set_force_encoded_color(bool value); + bool force_encoded_color() const; + void set_force_encoded_color(bool value); // @@protoc_insertion_point(class_scope:caffe.DataParameter) private: @@ -4885,31 +5307,30 @@ class DataParameter : public ::google::protobuf::Message { inline void set_has_force_encoded_color(); inline void clear_has_force_encoded_color(); - ::google::protobuf::UnknownFieldSet _unknown_fields_; - - ::std::string* source_; + ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_; + ::google::protobuf::internal::HasBits<1> _has_bits_; + mutable int _cached_size_; + ::google::protobuf::internal::ArenaStringPtr source_; + ::google::protobuf::internal::ArenaStringPtr mean_file_; ::google::protobuf::uint32 batch_size_; ::google::protobuf::uint32 rand_skip_; int backend_; - float scale_; - ::std::string* mean_file_; ::google::protobuf::uint32 crop_size_; bool mirror_; bool force_encoded_color_; - - mutable int _cached_size_; - ::google::protobuf::uint32 _has_bits_[(9 + 31) / 32]; - - friend void protobuf_AddDesc_caffe_2eproto(); + float scale_; + friend void protobuf_InitDefaults_caffe_2eproto_impl(); + friend void protobuf_AddDesc_caffe_2eproto_impl(); friend void protobuf_AssignDesc_caffe_2eproto(); friend void protobuf_ShutdownFile_caffe_2eproto(); void InitAsDefaultInstance(); - static DataParameter* default_instance_; }; +extern ::google::protobuf::internal::ExplicitlyConstructed DataParameter_default_instance_; + // ------------------------------------------------------------------- -class DropoutParameter : public ::google::protobuf::Message { +class DropoutParameter : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:caffe.DropoutParameter) */ { public: DropoutParameter(); virtual ~DropoutParameter(); @@ -4922,21 +5343,25 @@ class DropoutParameter : public ::google::protobuf::Message { } inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const { - return _unknown_fields_; + return _internal_metadata_.unknown_fields(); } inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() { - return &_unknown_fields_; + return _internal_metadata_.mutable_unknown_fields(); } static const ::google::protobuf::Descriptor* descriptor(); static const DropoutParameter& default_instance(); + static const DropoutParameter* internal_default_instance(); + void Swap(DropoutParameter* other); // implements Message ---------------------------------------------- - DropoutParameter* New() const; + inline DropoutParameter* New() const { return New(NULL); } + + DropoutParameter* New(::google::protobuf::Arena* arena) const; void CopyFrom(const ::google::protobuf::Message& from); void MergeFrom(const ::google::protobuf::Message& from); void CopyFrom(const DropoutParameter& from); @@ -4944,17 +5369,30 @@ class DropoutParameter : public ::google::protobuf::Message { void Clear(); bool IsInitialized() const; - int ByteSize() const; + size_t ByteSizeLong() const; bool MergePartialFromCodedStream( ::google::protobuf::io::CodedInputStream* input); void SerializeWithCachedSizes( ::google::protobuf::io::CodedOutputStream* output) const; - ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const; + ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray( + bool deterministic, ::google::protobuf::uint8* output) const; + ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const { + return InternalSerializeWithCachedSizesToArray(false, output); + } int GetCachedSize() const { return _cached_size_; } private: void SharedCtor(); void SharedDtor(); void SetCachedSize(int size) const; + void InternalSwap(DropoutParameter* other); + void UnsafeMergeFrom(const DropoutParameter& from); + private: + inline ::google::protobuf::Arena* GetArenaNoVirtual() const { + return _internal_metadata_.arena(); + } + inline void* MaybeArenaPtr() const { + return _internal_metadata_.raw_arena_ptr(); + } public: ::google::protobuf::Metadata GetMetadata() const; @@ -4964,34 +5402,33 @@ class DropoutParameter : public ::google::protobuf::Message { // accessors ------------------------------------------------------- // optional float dropout_ratio = 1 [default = 0.5]; - inline bool has_dropout_ratio() const; - inline void clear_dropout_ratio(); + bool has_dropout_ratio() const; + void clear_dropout_ratio(); static const int kDropoutRatioFieldNumber = 1; - inline float dropout_ratio() const; - inline void set_dropout_ratio(float value); + float dropout_ratio() const; + void set_dropout_ratio(float value); // @@protoc_insertion_point(class_scope:caffe.DropoutParameter) private: inline void set_has_dropout_ratio(); inline void clear_has_dropout_ratio(); - ::google::protobuf::UnknownFieldSet _unknown_fields_; - - float dropout_ratio_; - + ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_; + ::google::protobuf::internal::HasBits<1> _has_bits_; mutable int _cached_size_; - ::google::protobuf::uint32 _has_bits_[(1 + 31) / 32]; - - friend void protobuf_AddDesc_caffe_2eproto(); + float dropout_ratio_; + friend void protobuf_InitDefaults_caffe_2eproto_impl(); + friend void protobuf_AddDesc_caffe_2eproto_impl(); friend void protobuf_AssignDesc_caffe_2eproto(); friend void protobuf_ShutdownFile_caffe_2eproto(); void InitAsDefaultInstance(); - static DropoutParameter* default_instance_; }; +extern ::google::protobuf::internal::ExplicitlyConstructed DropoutParameter_default_instance_; + // ------------------------------------------------------------------- -class DummyDataParameter : public ::google::protobuf::Message { +class DummyDataParameter : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:caffe.DummyDataParameter) */ { public: DummyDataParameter(); virtual ~DummyDataParameter(); @@ -5004,21 +5441,25 @@ class DummyDataParameter : public ::google::protobuf::Message { } inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const { - return _unknown_fields_; + return _internal_metadata_.unknown_fields(); } inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() { - return &_unknown_fields_; + return _internal_metadata_.mutable_unknown_fields(); } static const ::google::protobuf::Descriptor* descriptor(); static const DummyDataParameter& default_instance(); + static const DummyDataParameter* internal_default_instance(); + void Swap(DummyDataParameter* other); // implements Message ---------------------------------------------- - DummyDataParameter* New() const; + inline DummyDataParameter* New() const { return New(NULL); } + + DummyDataParameter* New(::google::protobuf::Arena* arena) const; void CopyFrom(const ::google::protobuf::Message& from); void MergeFrom(const ::google::protobuf::Message& from); void CopyFrom(const DummyDataParameter& from); @@ -5026,17 +5467,30 @@ class DummyDataParameter : public ::google::protobuf::Message { void Clear(); bool IsInitialized() const; - int ByteSize() const; + size_t ByteSizeLong() const; bool MergePartialFromCodedStream( ::google::protobuf::io::CodedInputStream* input); void SerializeWithCachedSizes( ::google::protobuf::io::CodedOutputStream* output) const; - ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const; + ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray( + bool deterministic, ::google::protobuf::uint8* output) const; + ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const { + return InternalSerializeWithCachedSizesToArray(false, output); + } int GetCachedSize() const { return _cached_size_; } private: void SharedCtor(); void SharedDtor(); void SetCachedSize(int size) const; + void InternalSwap(DummyDataParameter* other); + void UnsafeMergeFrom(const DummyDataParameter& from); + private: + inline ::google::protobuf::Arena* GetArenaNoVirtual() const { + return _internal_metadata_.arena(); + } + inline void* MaybeArenaPtr() const { + return _internal_metadata_.raw_arena_ptr(); + } public: ::google::protobuf::Metadata GetMetadata() const; @@ -5046,102 +5500,101 @@ class DummyDataParameter : public ::google::protobuf::Message { // accessors ------------------------------------------------------- // repeated .caffe.FillerParameter data_filler = 1; - inline int data_filler_size() const; - inline void clear_data_filler(); + int data_filler_size() const; + void clear_data_filler(); static const int kDataFillerFieldNumber = 1; - inline const ::caffe::FillerParameter& data_filler(int index) const; - inline ::caffe::FillerParameter* mutable_data_filler(int index); - inline ::caffe::FillerParameter* add_data_filler(); - inline const ::google::protobuf::RepeatedPtrField< ::caffe::FillerParameter >& - data_filler() const; - inline ::google::protobuf::RepeatedPtrField< ::caffe::FillerParameter >* + const ::caffe::FillerParameter& data_filler(int index) const; + ::caffe::FillerParameter* mutable_data_filler(int index); + ::caffe::FillerParameter* add_data_filler(); + ::google::protobuf::RepeatedPtrField< ::caffe::FillerParameter >* mutable_data_filler(); + const ::google::protobuf::RepeatedPtrField< ::caffe::FillerParameter >& + data_filler() const; // repeated .caffe.BlobShape shape = 6; - inline int shape_size() const; - inline void clear_shape(); + int shape_size() const; + void clear_shape(); static const int kShapeFieldNumber = 6; - inline const ::caffe::BlobShape& shape(int index) const; - inline ::caffe::BlobShape* mutable_shape(int index); - inline ::caffe::BlobShape* add_shape(); - inline const ::google::protobuf::RepeatedPtrField< ::caffe::BlobShape >& - shape() const; - inline ::google::protobuf::RepeatedPtrField< ::caffe::BlobShape >* + const ::caffe::BlobShape& shape(int index) const; + ::caffe::BlobShape* mutable_shape(int index); + ::caffe::BlobShape* add_shape(); + ::google::protobuf::RepeatedPtrField< ::caffe::BlobShape >* mutable_shape(); + const ::google::protobuf::RepeatedPtrField< ::caffe::BlobShape >& + shape() const; // repeated uint32 num = 2; - inline int num_size() const; - inline void clear_num(); + int num_size() const; + void clear_num(); static const int kNumFieldNumber = 2; - inline ::google::protobuf::uint32 num(int index) const; - inline void set_num(int index, ::google::protobuf::uint32 value); - inline void add_num(::google::protobuf::uint32 value); - inline const ::google::protobuf::RepeatedField< ::google::protobuf::uint32 >& + ::google::protobuf::uint32 num(int index) const; + void set_num(int index, ::google::protobuf::uint32 value); + void add_num(::google::protobuf::uint32 value); + const ::google::protobuf::RepeatedField< ::google::protobuf::uint32 >& num() const; - inline ::google::protobuf::RepeatedField< ::google::protobuf::uint32 >* + ::google::protobuf::RepeatedField< ::google::protobuf::uint32 >* mutable_num(); // repeated uint32 channels = 3; - inline int channels_size() const; - inline void clear_channels(); + int channels_size() const; + void clear_channels(); static const int kChannelsFieldNumber = 3; - inline ::google::protobuf::uint32 channels(int index) const; - inline void set_channels(int index, ::google::protobuf::uint32 value); - inline void add_channels(::google::protobuf::uint32 value); - inline const ::google::protobuf::RepeatedField< ::google::protobuf::uint32 >& + ::google::protobuf::uint32 channels(int index) const; + void set_channels(int index, ::google::protobuf::uint32 value); + void add_channels(::google::protobuf::uint32 value); + const ::google::protobuf::RepeatedField< ::google::protobuf::uint32 >& channels() const; - inline ::google::protobuf::RepeatedField< ::google::protobuf::uint32 >* + ::google::protobuf::RepeatedField< ::google::protobuf::uint32 >* mutable_channels(); // repeated uint32 height = 4; - inline int height_size() const; - inline void clear_height(); + int height_size() const; + void clear_height(); static const int kHeightFieldNumber = 4; - inline ::google::protobuf::uint32 height(int index) const; - inline void set_height(int index, ::google::protobuf::uint32 value); - inline void add_height(::google::protobuf::uint32 value); - inline const ::google::protobuf::RepeatedField< ::google::protobuf::uint32 >& + ::google::protobuf::uint32 height(int index) const; + void set_height(int index, ::google::protobuf::uint32 value); + void add_height(::google::protobuf::uint32 value); + const ::google::protobuf::RepeatedField< ::google::protobuf::uint32 >& height() const; - inline ::google::protobuf::RepeatedField< ::google::protobuf::uint32 >* + ::google::protobuf::RepeatedField< ::google::protobuf::uint32 >* mutable_height(); // repeated uint32 width = 5; - inline int width_size() const; - inline void clear_width(); + int width_size() const; + void clear_width(); static const int kWidthFieldNumber = 5; - inline ::google::protobuf::uint32 width(int index) const; - inline void set_width(int index, ::google::protobuf::uint32 value); - inline void add_width(::google::protobuf::uint32 value); - inline const ::google::protobuf::RepeatedField< ::google::protobuf::uint32 >& + ::google::protobuf::uint32 width(int index) const; + void set_width(int index, ::google::protobuf::uint32 value); + void add_width(::google::protobuf::uint32 value); + const ::google::protobuf::RepeatedField< ::google::protobuf::uint32 >& width() const; - inline ::google::protobuf::RepeatedField< ::google::protobuf::uint32 >* + ::google::protobuf::RepeatedField< ::google::protobuf::uint32 >* mutable_width(); // @@protoc_insertion_point(class_scope:caffe.DummyDataParameter) private: - ::google::protobuf::UnknownFieldSet _unknown_fields_; - + ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_; + ::google::protobuf::internal::HasBits<1> _has_bits_; + mutable int _cached_size_; ::google::protobuf::RepeatedPtrField< ::caffe::FillerParameter > data_filler_; ::google::protobuf::RepeatedPtrField< ::caffe::BlobShape > shape_; ::google::protobuf::RepeatedField< ::google::protobuf::uint32 > num_; ::google::protobuf::RepeatedField< ::google::protobuf::uint32 > channels_; ::google::protobuf::RepeatedField< ::google::protobuf::uint32 > height_; ::google::protobuf::RepeatedField< ::google::protobuf::uint32 > width_; - - mutable int _cached_size_; - ::google::protobuf::uint32 _has_bits_[(6 + 31) / 32]; - - friend void protobuf_AddDesc_caffe_2eproto(); + friend void protobuf_InitDefaults_caffe_2eproto_impl(); + friend void protobuf_AddDesc_caffe_2eproto_impl(); friend void protobuf_AssignDesc_caffe_2eproto(); friend void protobuf_ShutdownFile_caffe_2eproto(); void InitAsDefaultInstance(); - static DummyDataParameter* default_instance_; }; +extern ::google::protobuf::internal::ExplicitlyConstructed DummyDataParameter_default_instance_; + // ------------------------------------------------------------------- -class EltwiseParameter : public ::google::protobuf::Message { +class EltwiseParameter : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:caffe.EltwiseParameter) */ { public: EltwiseParameter(); virtual ~EltwiseParameter(); @@ -5154,21 +5607,25 @@ class EltwiseParameter : public ::google::protobuf::Message { } inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const { - return _unknown_fields_; + return _internal_metadata_.unknown_fields(); } inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() { - return &_unknown_fields_; + return _internal_metadata_.mutable_unknown_fields(); } static const ::google::protobuf::Descriptor* descriptor(); static const EltwiseParameter& default_instance(); + static const EltwiseParameter* internal_default_instance(); + void Swap(EltwiseParameter* other); // implements Message ---------------------------------------------- - EltwiseParameter* New() const; + inline EltwiseParameter* New() const { return New(NULL); } + + EltwiseParameter* New(::google::protobuf::Arena* arena) const; void CopyFrom(const ::google::protobuf::Message& from); void MergeFrom(const ::google::protobuf::Message& from); void CopyFrom(const EltwiseParameter& from); @@ -5176,17 +5633,30 @@ class EltwiseParameter : public ::google::protobuf::Message { void Clear(); bool IsInitialized() const; - int ByteSize() const; + size_t ByteSizeLong() const; bool MergePartialFromCodedStream( ::google::protobuf::io::CodedInputStream* input); void SerializeWithCachedSizes( ::google::protobuf::io::CodedOutputStream* output) const; - ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const; + ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray( + bool deterministic, ::google::protobuf::uint8* output) const; + ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const { + return InternalSerializeWithCachedSizesToArray(false, output); + } int GetCachedSize() const { return _cached_size_; } private: void SharedCtor(); void SharedDtor(); void SetCachedSize(int size) const; + void InternalSwap(EltwiseParameter* other); + void UnsafeMergeFrom(const EltwiseParameter& from); + private: + inline ::google::protobuf::Arena* GetArenaNoVirtual() const { + return _internal_metadata_.arena(); + } + inline void* MaybeArenaPtr() const { + return _internal_metadata_.raw_arena_ptr(); + } public: ::google::protobuf::Metadata GetMetadata() const; @@ -5194,9 +5664,12 @@ class EltwiseParameter : public ::google::protobuf::Message { // nested types ---------------------------------------------------- typedef EltwiseParameter_EltwiseOp EltwiseOp; - static const EltwiseOp PROD = EltwiseParameter_EltwiseOp_PROD; - static const EltwiseOp SUM = EltwiseParameter_EltwiseOp_SUM; - static const EltwiseOp MAX = EltwiseParameter_EltwiseOp_MAX; + static const EltwiseOp PROD = + EltwiseParameter_EltwiseOp_PROD; + static const EltwiseOp SUM = + EltwiseParameter_EltwiseOp_SUM; + static const EltwiseOp MAX = + EltwiseParameter_EltwiseOp_MAX; static inline bool EltwiseOp_IsValid(int value) { return EltwiseParameter_EltwiseOp_IsValid(value); } @@ -5221,30 +5694,30 @@ class EltwiseParameter : public ::google::protobuf::Message { // accessors ------------------------------------------------------- // optional .caffe.EltwiseParameter.EltwiseOp operation = 1 [default = SUM]; - inline bool has_operation() const; - inline void clear_operation(); + bool has_operation() const; + void clear_operation(); static const int kOperationFieldNumber = 1; - inline ::caffe::EltwiseParameter_EltwiseOp operation() const; - inline void set_operation(::caffe::EltwiseParameter_EltwiseOp value); + ::caffe::EltwiseParameter_EltwiseOp operation() const; + void set_operation(::caffe::EltwiseParameter_EltwiseOp value); // repeated float coeff = 2; - inline int coeff_size() const; - inline void clear_coeff(); + int coeff_size() const; + void clear_coeff(); static const int kCoeffFieldNumber = 2; - inline float coeff(int index) const; - inline void set_coeff(int index, float value); - inline void add_coeff(float value); - inline const ::google::protobuf::RepeatedField< float >& + float coeff(int index) const; + void set_coeff(int index, float value); + void add_coeff(float value); + const ::google::protobuf::RepeatedField< float >& coeff() const; - inline ::google::protobuf::RepeatedField< float >* + ::google::protobuf::RepeatedField< float >* mutable_coeff(); // optional bool stable_prod_grad = 3 [default = true]; - inline bool has_stable_prod_grad() const; - inline void clear_stable_prod_grad(); + bool has_stable_prod_grad() const; + void clear_stable_prod_grad(); static const int kStableProdGradFieldNumber = 3; - inline bool stable_prod_grad() const; - inline void set_stable_prod_grad(bool value); + bool stable_prod_grad() const; + void set_stable_prod_grad(bool value); // @@protoc_insertion_point(class_scope:caffe.EltwiseParameter) private: @@ -5253,25 +5726,24 @@ class EltwiseParameter : public ::google::protobuf::Message { inline void set_has_stable_prod_grad(); inline void clear_has_stable_prod_grad(); - ::google::protobuf::UnknownFieldSet _unknown_fields_; - + ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_; + ::google::protobuf::internal::HasBits<1> _has_bits_; + mutable int _cached_size_; ::google::protobuf::RepeatedField< float > coeff_; int operation_; bool stable_prod_grad_; - - mutable int _cached_size_; - ::google::protobuf::uint32 _has_bits_[(3 + 31) / 32]; - - friend void protobuf_AddDesc_caffe_2eproto(); + friend void protobuf_InitDefaults_caffe_2eproto_impl(); + friend void protobuf_AddDesc_caffe_2eproto_impl(); friend void protobuf_AssignDesc_caffe_2eproto(); friend void protobuf_ShutdownFile_caffe_2eproto(); void InitAsDefaultInstance(); - static EltwiseParameter* default_instance_; }; +extern ::google::protobuf::internal::ExplicitlyConstructed EltwiseParameter_default_instance_; + // ------------------------------------------------------------------- -class ExpParameter : public ::google::protobuf::Message { +class ExpParameter : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:caffe.ExpParameter) */ { public: ExpParameter(); virtual ~ExpParameter(); @@ -5284,21 +5756,25 @@ class ExpParameter : public ::google::protobuf::Message { } inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const { - return _unknown_fields_; + return _internal_metadata_.unknown_fields(); } inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() { - return &_unknown_fields_; + return _internal_metadata_.mutable_unknown_fields(); } static const ::google::protobuf::Descriptor* descriptor(); static const ExpParameter& default_instance(); + static const ExpParameter* internal_default_instance(); + void Swap(ExpParameter* other); // implements Message ---------------------------------------------- - ExpParameter* New() const; + inline ExpParameter* New() const { return New(NULL); } + + ExpParameter* New(::google::protobuf::Arena* arena) const; void CopyFrom(const ::google::protobuf::Message& from); void MergeFrom(const ::google::protobuf::Message& from); void CopyFrom(const ExpParameter& from); @@ -5306,17 +5782,30 @@ class ExpParameter : public ::google::protobuf::Message { void Clear(); bool IsInitialized() const; - int ByteSize() const; + size_t ByteSizeLong() const; bool MergePartialFromCodedStream( ::google::protobuf::io::CodedInputStream* input); void SerializeWithCachedSizes( ::google::protobuf::io::CodedOutputStream* output) const; - ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const; + ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray( + bool deterministic, ::google::protobuf::uint8* output) const; + ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const { + return InternalSerializeWithCachedSizesToArray(false, output); + } int GetCachedSize() const { return _cached_size_; } private: void SharedCtor(); void SharedDtor(); void SetCachedSize(int size) const; + void InternalSwap(ExpParameter* other); + void UnsafeMergeFrom(const ExpParameter& from); + private: + inline ::google::protobuf::Arena* GetArenaNoVirtual() const { + return _internal_metadata_.arena(); + } + inline void* MaybeArenaPtr() const { + return _internal_metadata_.raw_arena_ptr(); + } public: ::google::protobuf::Metadata GetMetadata() const; @@ -5326,25 +5815,25 @@ class ExpParameter : public ::google::protobuf::Message { // accessors ------------------------------------------------------- // optional float base = 1 [default = -1]; - inline bool has_base() const; - inline void clear_base(); + bool has_base() const; + void clear_base(); static const int kBaseFieldNumber = 1; - inline float base() const; - inline void set_base(float value); + float base() const; + void set_base(float value); // optional float scale = 2 [default = 1]; - inline bool has_scale() const; - inline void clear_scale(); + bool has_scale() const; + void clear_scale(); static const int kScaleFieldNumber = 2; - inline float scale() const; - inline void set_scale(float value); + float scale() const; + void set_scale(float value); // optional float shift = 3 [default = 0]; - inline bool has_shift() const; - inline void clear_shift(); + bool has_shift() const; + void clear_shift(); static const int kShiftFieldNumber = 3; - inline float shift() const; - inline void set_shift(float value); + float shift() const; + void set_shift(float value); // @@protoc_insertion_point(class_scope:caffe.ExpParameter) private: @@ -5355,25 +5844,24 @@ class ExpParameter : public ::google::protobuf::Message { inline void set_has_shift(); inline void clear_has_shift(); - ::google::protobuf::UnknownFieldSet _unknown_fields_; - + ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_; + ::google::protobuf::internal::HasBits<1> _has_bits_; + mutable int _cached_size_; + float shift_; float base_; float scale_; - float shift_; - - mutable int _cached_size_; - ::google::protobuf::uint32 _has_bits_[(3 + 31) / 32]; - - friend void protobuf_AddDesc_caffe_2eproto(); + friend void protobuf_InitDefaults_caffe_2eproto_impl(); + friend void protobuf_AddDesc_caffe_2eproto_impl(); friend void protobuf_AssignDesc_caffe_2eproto(); friend void protobuf_ShutdownFile_caffe_2eproto(); void InitAsDefaultInstance(); - static ExpParameter* default_instance_; }; +extern ::google::protobuf::internal::ExplicitlyConstructed ExpParameter_default_instance_; + // ------------------------------------------------------------------- -class FlattenParameter : public ::google::protobuf::Message { +class FlattenParameter : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:caffe.FlattenParameter) */ { public: FlattenParameter(); virtual ~FlattenParameter(); @@ -5386,21 +5874,25 @@ class FlattenParameter : public ::google::protobuf::Message { } inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const { - return _unknown_fields_; + return _internal_metadata_.unknown_fields(); } inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() { - return &_unknown_fields_; + return _internal_metadata_.mutable_unknown_fields(); } static const ::google::protobuf::Descriptor* descriptor(); static const FlattenParameter& default_instance(); + static const FlattenParameter* internal_default_instance(); + void Swap(FlattenParameter* other); // implements Message ---------------------------------------------- - FlattenParameter* New() const; + inline FlattenParameter* New() const { return New(NULL); } + + FlattenParameter* New(::google::protobuf::Arena* arena) const; void CopyFrom(const ::google::protobuf::Message& from); void MergeFrom(const ::google::protobuf::Message& from); void CopyFrom(const FlattenParameter& from); @@ -5408,17 +5900,30 @@ class FlattenParameter : public ::google::protobuf::Message { void Clear(); bool IsInitialized() const; - int ByteSize() const; + size_t ByteSizeLong() const; bool MergePartialFromCodedStream( ::google::protobuf::io::CodedInputStream* input); void SerializeWithCachedSizes( ::google::protobuf::io::CodedOutputStream* output) const; - ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const; + ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray( + bool deterministic, ::google::protobuf::uint8* output) const; + ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const { + return InternalSerializeWithCachedSizesToArray(false, output); + } int GetCachedSize() const { return _cached_size_; } private: void SharedCtor(); void SharedDtor(); void SetCachedSize(int size) const; + void InternalSwap(FlattenParameter* other); + void UnsafeMergeFrom(const FlattenParameter& from); + private: + inline ::google::protobuf::Arena* GetArenaNoVirtual() const { + return _internal_metadata_.arena(); + } + inline void* MaybeArenaPtr() const { + return _internal_metadata_.raw_arena_ptr(); + } public: ::google::protobuf::Metadata GetMetadata() const; @@ -5428,18 +5933,18 @@ class FlattenParameter : public ::google::protobuf::Message { // accessors ------------------------------------------------------- // optional int32 axis = 1 [default = 1]; - inline bool has_axis() const; - inline void clear_axis(); + bool has_axis() const; + void clear_axis(); static const int kAxisFieldNumber = 1; - inline ::google::protobuf::int32 axis() const; - inline void set_axis(::google::protobuf::int32 value); + ::google::protobuf::int32 axis() const; + void set_axis(::google::protobuf::int32 value); // optional int32 end_axis = 2 [default = -1]; - inline bool has_end_axis() const; - inline void clear_end_axis(); + bool has_end_axis() const; + void clear_end_axis(); static const int kEndAxisFieldNumber = 2; - inline ::google::protobuf::int32 end_axis() const; - inline void set_end_axis(::google::protobuf::int32 value); + ::google::protobuf::int32 end_axis() const; + void set_end_axis(::google::protobuf::int32 value); // @@protoc_insertion_point(class_scope:caffe.FlattenParameter) private: @@ -5448,24 +5953,23 @@ class FlattenParameter : public ::google::protobuf::Message { inline void set_has_end_axis(); inline void clear_has_end_axis(); - ::google::protobuf::UnknownFieldSet _unknown_fields_; - + ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_; + ::google::protobuf::internal::HasBits<1> _has_bits_; + mutable int _cached_size_; ::google::protobuf::int32 axis_; ::google::protobuf::int32 end_axis_; - - mutable int _cached_size_; - ::google::protobuf::uint32 _has_bits_[(2 + 31) / 32]; - - friend void protobuf_AddDesc_caffe_2eproto(); + friend void protobuf_InitDefaults_caffe_2eproto_impl(); + friend void protobuf_AddDesc_caffe_2eproto_impl(); friend void protobuf_AssignDesc_caffe_2eproto(); friend void protobuf_ShutdownFile_caffe_2eproto(); void InitAsDefaultInstance(); - static FlattenParameter* default_instance_; }; +extern ::google::protobuf::internal::ExplicitlyConstructed FlattenParameter_default_instance_; + // ------------------------------------------------------------------- -class HDF5DataParameter : public ::google::protobuf::Message { +class HDF5DataParameter : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:caffe.HDF5DataParameter) */ { public: HDF5DataParameter(); virtual ~HDF5DataParameter(); @@ -5478,21 +5982,25 @@ class HDF5DataParameter : public ::google::protobuf::Message { } inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const { - return _unknown_fields_; + return _internal_metadata_.unknown_fields(); } inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() { - return &_unknown_fields_; + return _internal_metadata_.mutable_unknown_fields(); } static const ::google::protobuf::Descriptor* descriptor(); static const HDF5DataParameter& default_instance(); + static const HDF5DataParameter* internal_default_instance(); + void Swap(HDF5DataParameter* other); // implements Message ---------------------------------------------- - HDF5DataParameter* New() const; + inline HDF5DataParameter* New() const { return New(NULL); } + + HDF5DataParameter* New(::google::protobuf::Arena* arena) const; void CopyFrom(const ::google::protobuf::Message& from); void MergeFrom(const ::google::protobuf::Message& from); void CopyFrom(const HDF5DataParameter& from); @@ -5500,17 +6008,30 @@ class HDF5DataParameter : public ::google::protobuf::Message { void Clear(); bool IsInitialized() const; - int ByteSize() const; + size_t ByteSizeLong() const; bool MergePartialFromCodedStream( ::google::protobuf::io::CodedInputStream* input); void SerializeWithCachedSizes( ::google::protobuf::io::CodedOutputStream* output) const; - ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const; + ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray( + bool deterministic, ::google::protobuf::uint8* output) const; + ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const { + return InternalSerializeWithCachedSizesToArray(false, output); + } int GetCachedSize() const { return _cached_size_; } private: void SharedCtor(); void SharedDtor(); void SetCachedSize(int size) const; + void InternalSwap(HDF5DataParameter* other); + void UnsafeMergeFrom(const HDF5DataParameter& from); + private: + inline ::google::protobuf::Arena* GetArenaNoVirtual() const { + return _internal_metadata_.arena(); + } + inline void* MaybeArenaPtr() const { + return _internal_metadata_.raw_arena_ptr(); + } public: ::google::protobuf::Metadata GetMetadata() const; @@ -5520,30 +6041,30 @@ class HDF5DataParameter : public ::google::protobuf::Message { // accessors ------------------------------------------------------- // optional string source = 1; - inline bool has_source() const; - inline void clear_source(); + bool has_source() const; + void clear_source(); static const int kSourceFieldNumber = 1; - inline const ::std::string& source() const; - inline void set_source(const ::std::string& value); - inline void set_source(const char* value); - inline void set_source(const char* value, size_t size); - inline ::std::string* mutable_source(); - inline ::std::string* release_source(); - inline void set_allocated_source(::std::string* source); + const ::std::string& source() const; + void set_source(const ::std::string& value); + void set_source(const char* value); + void set_source(const char* value, size_t size); + ::std::string* mutable_source(); + ::std::string* release_source(); + void set_allocated_source(::std::string* source); // optional uint32 batch_size = 2; - inline bool has_batch_size() const; - inline void clear_batch_size(); + bool has_batch_size() const; + void clear_batch_size(); static const int kBatchSizeFieldNumber = 2; - inline ::google::protobuf::uint32 batch_size() const; - inline void set_batch_size(::google::protobuf::uint32 value); + ::google::protobuf::uint32 batch_size() const; + void set_batch_size(::google::protobuf::uint32 value); // optional bool shuffle = 3 [default = false]; - inline bool has_shuffle() const; - inline void clear_shuffle(); + bool has_shuffle() const; + void clear_shuffle(); static const int kShuffleFieldNumber = 3; - inline bool shuffle() const; - inline void set_shuffle(bool value); + bool shuffle() const; + void set_shuffle(bool value); // @@protoc_insertion_point(class_scope:caffe.HDF5DataParameter) private: @@ -5554,25 +6075,24 @@ class HDF5DataParameter : public ::google::protobuf::Message { inline void set_has_shuffle(); inline void clear_has_shuffle(); - ::google::protobuf::UnknownFieldSet _unknown_fields_; - - ::std::string* source_; + ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_; + ::google::protobuf::internal::HasBits<1> _has_bits_; + mutable int _cached_size_; + ::google::protobuf::internal::ArenaStringPtr source_; ::google::protobuf::uint32 batch_size_; bool shuffle_; - - mutable int _cached_size_; - ::google::protobuf::uint32 _has_bits_[(3 + 31) / 32]; - - friend void protobuf_AddDesc_caffe_2eproto(); + friend void protobuf_InitDefaults_caffe_2eproto_impl(); + friend void protobuf_AddDesc_caffe_2eproto_impl(); friend void protobuf_AssignDesc_caffe_2eproto(); friend void protobuf_ShutdownFile_caffe_2eproto(); void InitAsDefaultInstance(); - static HDF5DataParameter* default_instance_; }; +extern ::google::protobuf::internal::ExplicitlyConstructed HDF5DataParameter_default_instance_; + // ------------------------------------------------------------------- -class HDF5OutputParameter : public ::google::protobuf::Message { +class HDF5OutputParameter : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:caffe.HDF5OutputParameter) */ { public: HDF5OutputParameter(); virtual ~HDF5OutputParameter(); @@ -5585,21 +6105,25 @@ class HDF5OutputParameter : public ::google::protobuf::Message { } inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const { - return _unknown_fields_; + return _internal_metadata_.unknown_fields(); } inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() { - return &_unknown_fields_; + return _internal_metadata_.mutable_unknown_fields(); } static const ::google::protobuf::Descriptor* descriptor(); static const HDF5OutputParameter& default_instance(); + static const HDF5OutputParameter* internal_default_instance(); + void Swap(HDF5OutputParameter* other); // implements Message ---------------------------------------------- - HDF5OutputParameter* New() const; + inline HDF5OutputParameter* New() const { return New(NULL); } + + HDF5OutputParameter* New(::google::protobuf::Arena* arena) const; void CopyFrom(const ::google::protobuf::Message& from); void MergeFrom(const ::google::protobuf::Message& from); void CopyFrom(const HDF5OutputParameter& from); @@ -5607,17 +6131,30 @@ class HDF5OutputParameter : public ::google::protobuf::Message { void Clear(); bool IsInitialized() const; - int ByteSize() const; + size_t ByteSizeLong() const; bool MergePartialFromCodedStream( ::google::protobuf::io::CodedInputStream* input); void SerializeWithCachedSizes( ::google::protobuf::io::CodedOutputStream* output) const; - ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const; + ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray( + bool deterministic, ::google::protobuf::uint8* output) const; + ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const { + return InternalSerializeWithCachedSizesToArray(false, output); + } int GetCachedSize() const { return _cached_size_; } private: void SharedCtor(); void SharedDtor(); void SetCachedSize(int size) const; + void InternalSwap(HDF5OutputParameter* other); + void UnsafeMergeFrom(const HDF5OutputParameter& from); + private: + inline ::google::protobuf::Arena* GetArenaNoVirtual() const { + return _internal_metadata_.arena(); + } + inline void* MaybeArenaPtr() const { + return _internal_metadata_.raw_arena_ptr(); + } public: ::google::protobuf::Metadata GetMetadata() const; @@ -5627,39 +6164,38 @@ class HDF5OutputParameter : public ::google::protobuf::Message { // accessors ------------------------------------------------------- // optional string file_name = 1; - inline bool has_file_name() const; - inline void clear_file_name(); + bool has_file_name() const; + void clear_file_name(); static const int kFileNameFieldNumber = 1; - inline const ::std::string& file_name() const; - inline void set_file_name(const ::std::string& value); - inline void set_file_name(const char* value); - inline void set_file_name(const char* value, size_t size); - inline ::std::string* mutable_file_name(); - inline ::std::string* release_file_name(); - inline void set_allocated_file_name(::std::string* file_name); + const ::std::string& file_name() const; + void set_file_name(const ::std::string& value); + void set_file_name(const char* value); + void set_file_name(const char* value, size_t size); + ::std::string* mutable_file_name(); + ::std::string* release_file_name(); + void set_allocated_file_name(::std::string* file_name); // @@protoc_insertion_point(class_scope:caffe.HDF5OutputParameter) private: inline void set_has_file_name(); inline void clear_has_file_name(); - ::google::protobuf::UnknownFieldSet _unknown_fields_; - - ::std::string* file_name_; - + ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_; + ::google::protobuf::internal::HasBits<1> _has_bits_; mutable int _cached_size_; - ::google::protobuf::uint32 _has_bits_[(1 + 31) / 32]; - - friend void protobuf_AddDesc_caffe_2eproto(); + ::google::protobuf::internal::ArenaStringPtr file_name_; + friend void protobuf_InitDefaults_caffe_2eproto_impl(); + friend void protobuf_AddDesc_caffe_2eproto_impl(); friend void protobuf_AssignDesc_caffe_2eproto(); friend void protobuf_ShutdownFile_caffe_2eproto(); void InitAsDefaultInstance(); - static HDF5OutputParameter* default_instance_; }; +extern ::google::protobuf::internal::ExplicitlyConstructed HDF5OutputParameter_default_instance_; + // ------------------------------------------------------------------- -class HingeLossParameter : public ::google::protobuf::Message { +class HingeLossParameter : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:caffe.HingeLossParameter) */ { public: HingeLossParameter(); virtual ~HingeLossParameter(); @@ -5672,21 +6208,25 @@ class HingeLossParameter : public ::google::protobuf::Message { } inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const { - return _unknown_fields_; + return _internal_metadata_.unknown_fields(); } inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() { - return &_unknown_fields_; + return _internal_metadata_.mutable_unknown_fields(); } static const ::google::protobuf::Descriptor* descriptor(); static const HingeLossParameter& default_instance(); + static const HingeLossParameter* internal_default_instance(); + void Swap(HingeLossParameter* other); // implements Message ---------------------------------------------- - HingeLossParameter* New() const; + inline HingeLossParameter* New() const { return New(NULL); } + + HingeLossParameter* New(::google::protobuf::Arena* arena) const; void CopyFrom(const ::google::protobuf::Message& from); void MergeFrom(const ::google::protobuf::Message& from); void CopyFrom(const HingeLossParameter& from); @@ -5694,17 +6234,30 @@ class HingeLossParameter : public ::google::protobuf::Message { void Clear(); bool IsInitialized() const; - int ByteSize() const; + size_t ByteSizeLong() const; bool MergePartialFromCodedStream( ::google::protobuf::io::CodedInputStream* input); void SerializeWithCachedSizes( ::google::protobuf::io::CodedOutputStream* output) const; - ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const; + ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray( + bool deterministic, ::google::protobuf::uint8* output) const; + ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const { + return InternalSerializeWithCachedSizesToArray(false, output); + } int GetCachedSize() const { return _cached_size_; } private: void SharedCtor(); void SharedDtor(); void SetCachedSize(int size) const; + void InternalSwap(HingeLossParameter* other); + void UnsafeMergeFrom(const HingeLossParameter& from); + private: + inline ::google::protobuf::Arena* GetArenaNoVirtual() const { + return _internal_metadata_.arena(); + } + inline void* MaybeArenaPtr() const { + return _internal_metadata_.raw_arena_ptr(); + } public: ::google::protobuf::Metadata GetMetadata() const; @@ -5712,8 +6265,10 @@ class HingeLossParameter : public ::google::protobuf::Message { // nested types ---------------------------------------------------- typedef HingeLossParameter_Norm Norm; - static const Norm L1 = HingeLossParameter_Norm_L1; - static const Norm L2 = HingeLossParameter_Norm_L2; + static const Norm L1 = + HingeLossParameter_Norm_L1; + static const Norm L2 = + HingeLossParameter_Norm_L2; static inline bool Norm_IsValid(int value) { return HingeLossParameter_Norm_IsValid(value); } @@ -5738,34 +6293,33 @@ class HingeLossParameter : public ::google::protobuf::Message { // accessors ------------------------------------------------------- // optional .caffe.HingeLossParameter.Norm norm = 1 [default = L1]; - inline bool has_norm() const; - inline void clear_norm(); + bool has_norm() const; + void clear_norm(); static const int kNormFieldNumber = 1; - inline ::caffe::HingeLossParameter_Norm norm() const; - inline void set_norm(::caffe::HingeLossParameter_Norm value); + ::caffe::HingeLossParameter_Norm norm() const; + void set_norm(::caffe::HingeLossParameter_Norm value); // @@protoc_insertion_point(class_scope:caffe.HingeLossParameter) private: inline void set_has_norm(); inline void clear_has_norm(); - ::google::protobuf::UnknownFieldSet _unknown_fields_; - - int norm_; - + ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_; + ::google::protobuf::internal::HasBits<1> _has_bits_; mutable int _cached_size_; - ::google::protobuf::uint32 _has_bits_[(1 + 31) / 32]; - - friend void protobuf_AddDesc_caffe_2eproto(); + int norm_; + friend void protobuf_InitDefaults_caffe_2eproto_impl(); + friend void protobuf_AddDesc_caffe_2eproto_impl(); friend void protobuf_AssignDesc_caffe_2eproto(); friend void protobuf_ShutdownFile_caffe_2eproto(); void InitAsDefaultInstance(); - static HingeLossParameter* default_instance_; }; +extern ::google::protobuf::internal::ExplicitlyConstructed HingeLossParameter_default_instance_; + // ------------------------------------------------------------------- -class ImageDataParameter : public ::google::protobuf::Message { +class ImageDataParameter : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:caffe.ImageDataParameter) */ { public: ImageDataParameter(); virtual ~ImageDataParameter(); @@ -5778,21 +6332,25 @@ class ImageDataParameter : public ::google::protobuf::Message { } inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const { - return _unknown_fields_; + return _internal_metadata_.unknown_fields(); } inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() { - return &_unknown_fields_; + return _internal_metadata_.mutable_unknown_fields(); } static const ::google::protobuf::Descriptor* descriptor(); static const ImageDataParameter& default_instance(); + static const ImageDataParameter* internal_default_instance(); + void Swap(ImageDataParameter* other); // implements Message ---------------------------------------------- - ImageDataParameter* New() const; + inline ImageDataParameter* New() const { return New(NULL); } + + ImageDataParameter* New(::google::protobuf::Arena* arena) const; void CopyFrom(const ::google::protobuf::Message& from); void MergeFrom(const ::google::protobuf::Message& from); void CopyFrom(const ImageDataParameter& from); @@ -5800,17 +6358,30 @@ class ImageDataParameter : public ::google::protobuf::Message { void Clear(); bool IsInitialized() const; - int ByteSize() const; + size_t ByteSizeLong() const; bool MergePartialFromCodedStream( ::google::protobuf::io::CodedInputStream* input); void SerializeWithCachedSizes( ::google::protobuf::io::CodedOutputStream* output) const; - ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const; + ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray( + bool deterministic, ::google::protobuf::uint8* output) const; + ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const { + return InternalSerializeWithCachedSizesToArray(false, output); + } int GetCachedSize() const { return _cached_size_; } private: void SharedCtor(); void SharedDtor(); void SetCachedSize(int size) const; + void InternalSwap(ImageDataParameter* other); + void UnsafeMergeFrom(const ImageDataParameter& from); + private: + inline ::google::protobuf::Arena* GetArenaNoVirtual() const { + return _internal_metadata_.arena(); + } + inline void* MaybeArenaPtr() const { + return _internal_metadata_.raw_arena_ptr(); + } public: ::google::protobuf::Metadata GetMetadata() const; @@ -5820,103 +6391,103 @@ class ImageDataParameter : public ::google::protobuf::Message { // accessors ------------------------------------------------------- // optional string source = 1; - inline bool has_source() const; - inline void clear_source(); + bool has_source() const; + void clear_source(); static const int kSourceFieldNumber = 1; - inline const ::std::string& source() const; - inline void set_source(const ::std::string& value); - inline void set_source(const char* value); - inline void set_source(const char* value, size_t size); - inline ::std::string* mutable_source(); - inline ::std::string* release_source(); - inline void set_allocated_source(::std::string* source); + const ::std::string& source() const; + void set_source(const ::std::string& value); + void set_source(const char* value); + void set_source(const char* value, size_t size); + ::std::string* mutable_source(); + ::std::string* release_source(); + void set_allocated_source(::std::string* source); // optional uint32 batch_size = 4; - inline bool has_batch_size() const; - inline void clear_batch_size(); + bool has_batch_size() const; + void clear_batch_size(); static const int kBatchSizeFieldNumber = 4; - inline ::google::protobuf::uint32 batch_size() const; - inline void set_batch_size(::google::protobuf::uint32 value); + ::google::protobuf::uint32 batch_size() const; + void set_batch_size(::google::protobuf::uint32 value); // optional uint32 rand_skip = 7 [default = 0]; - inline bool has_rand_skip() const; - inline void clear_rand_skip(); + bool has_rand_skip() const; + void clear_rand_skip(); static const int kRandSkipFieldNumber = 7; - inline ::google::protobuf::uint32 rand_skip() const; - inline void set_rand_skip(::google::protobuf::uint32 value); + ::google::protobuf::uint32 rand_skip() const; + void set_rand_skip(::google::protobuf::uint32 value); // optional bool shuffle = 8 [default = false]; - inline bool has_shuffle() const; - inline void clear_shuffle(); + bool has_shuffle() const; + void clear_shuffle(); static const int kShuffleFieldNumber = 8; - inline bool shuffle() const; - inline void set_shuffle(bool value); + bool shuffle() const; + void set_shuffle(bool value); // optional uint32 new_height = 9 [default = 0]; - inline bool has_new_height() const; - inline void clear_new_height(); + bool has_new_height() const; + void clear_new_height(); static const int kNewHeightFieldNumber = 9; - inline ::google::protobuf::uint32 new_height() const; - inline void set_new_height(::google::protobuf::uint32 value); + ::google::protobuf::uint32 new_height() const; + void set_new_height(::google::protobuf::uint32 value); // optional uint32 new_width = 10 [default = 0]; - inline bool has_new_width() const; - inline void clear_new_width(); + bool has_new_width() const; + void clear_new_width(); static const int kNewWidthFieldNumber = 10; - inline ::google::protobuf::uint32 new_width() const; - inline void set_new_width(::google::protobuf::uint32 value); + ::google::protobuf::uint32 new_width() const; + void set_new_width(::google::protobuf::uint32 value); // optional bool is_color = 11 [default = true]; - inline bool has_is_color() const; - inline void clear_is_color(); + bool has_is_color() const; + void clear_is_color(); static const int kIsColorFieldNumber = 11; - inline bool is_color() const; - inline void set_is_color(bool value); + bool is_color() const; + void set_is_color(bool value); // optional float scale = 2 [default = 1]; - inline bool has_scale() const; - inline void clear_scale(); + bool has_scale() const; + void clear_scale(); static const int kScaleFieldNumber = 2; - inline float scale() const; - inline void set_scale(float value); + float scale() const; + void set_scale(float value); // optional string mean_file = 3; - inline bool has_mean_file() const; - inline void clear_mean_file(); + bool has_mean_file() const; + void clear_mean_file(); static const int kMeanFileFieldNumber = 3; - inline const ::std::string& mean_file() const; - inline void set_mean_file(const ::std::string& value); - inline void set_mean_file(const char* value); - inline void set_mean_file(const char* value, size_t size); - inline ::std::string* mutable_mean_file(); - inline ::std::string* release_mean_file(); - inline void set_allocated_mean_file(::std::string* mean_file); + const ::std::string& mean_file() const; + void set_mean_file(const ::std::string& value); + void set_mean_file(const char* value); + void set_mean_file(const char* value, size_t size); + ::std::string* mutable_mean_file(); + ::std::string* release_mean_file(); + void set_allocated_mean_file(::std::string* mean_file); // optional uint32 crop_size = 5 [default = 0]; - inline bool has_crop_size() const; - inline void clear_crop_size(); + bool has_crop_size() const; + void clear_crop_size(); static const int kCropSizeFieldNumber = 5; - inline ::google::protobuf::uint32 crop_size() const; - inline void set_crop_size(::google::protobuf::uint32 value); + ::google::protobuf::uint32 crop_size() const; + void set_crop_size(::google::protobuf::uint32 value); // optional bool mirror = 6 [default = false]; - inline bool has_mirror() const; - inline void clear_mirror(); + bool has_mirror() const; + void clear_mirror(); static const int kMirrorFieldNumber = 6; - inline bool mirror() const; - inline void set_mirror(bool value); + bool mirror() const; + void set_mirror(bool value); // optional string root_folder = 12 [default = ""]; - inline bool has_root_folder() const; - inline void clear_root_folder(); + bool has_root_folder() const; + void clear_root_folder(); static const int kRootFolderFieldNumber = 12; - inline const ::std::string& root_folder() const; - inline void set_root_folder(const ::std::string& value); - inline void set_root_folder(const char* value); - inline void set_root_folder(const char* value, size_t size); - inline ::std::string* mutable_root_folder(); - inline ::std::string* release_root_folder(); - inline void set_allocated_root_folder(::std::string* root_folder); + const ::std::string& root_folder() const; + void set_root_folder(const ::std::string& value); + void set_root_folder(const char* value); + void set_root_folder(const char* value, size_t size); + ::std::string* mutable_root_folder(); + ::std::string* release_root_folder(); + void set_allocated_root_folder(::std::string* root_folder); // @@protoc_insertion_point(class_scope:caffe.ImageDataParameter) private: @@ -5945,34 +6516,33 @@ class ImageDataParameter : public ::google::protobuf::Message { inline void set_has_root_folder(); inline void clear_has_root_folder(); - ::google::protobuf::UnknownFieldSet _unknown_fields_; - - ::std::string* source_; + ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_; + ::google::protobuf::internal::HasBits<1> _has_bits_; + mutable int _cached_size_; + ::google::protobuf::internal::ArenaStringPtr source_; + ::google::protobuf::internal::ArenaStringPtr mean_file_; + ::google::protobuf::internal::ArenaStringPtr root_folder_; ::google::protobuf::uint32 batch_size_; ::google::protobuf::uint32 rand_skip_; ::google::protobuf::uint32 new_height_; ::google::protobuf::uint32 new_width_; bool shuffle_; - bool is_color_; bool mirror_; - float scale_; - ::std::string* mean_file_; - ::std::string* root_folder_; ::google::protobuf::uint32 crop_size_; - - mutable int _cached_size_; - ::google::protobuf::uint32 _has_bits_[(12 + 31) / 32]; - - friend void protobuf_AddDesc_caffe_2eproto(); + bool is_color_; + float scale_; + friend void protobuf_InitDefaults_caffe_2eproto_impl(); + friend void protobuf_AddDesc_caffe_2eproto_impl(); friend void protobuf_AssignDesc_caffe_2eproto(); friend void protobuf_ShutdownFile_caffe_2eproto(); void InitAsDefaultInstance(); - static ImageDataParameter* default_instance_; }; +extern ::google::protobuf::internal::ExplicitlyConstructed ImageDataParameter_default_instance_; + // ------------------------------------------------------------------- -class InfogainLossParameter : public ::google::protobuf::Message { +class InfogainLossParameter : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:caffe.InfogainLossParameter) */ { public: InfogainLossParameter(); virtual ~InfogainLossParameter(); @@ -5985,21 +6555,25 @@ class InfogainLossParameter : public ::google::protobuf::Message { } inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const { - return _unknown_fields_; + return _internal_metadata_.unknown_fields(); } inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() { - return &_unknown_fields_; + return _internal_metadata_.mutable_unknown_fields(); } static const ::google::protobuf::Descriptor* descriptor(); static const InfogainLossParameter& default_instance(); + static const InfogainLossParameter* internal_default_instance(); + void Swap(InfogainLossParameter* other); // implements Message ---------------------------------------------- - InfogainLossParameter* New() const; + inline InfogainLossParameter* New() const { return New(NULL); } + + InfogainLossParameter* New(::google::protobuf::Arena* arena) const; void CopyFrom(const ::google::protobuf::Message& from); void MergeFrom(const ::google::protobuf::Message& from); void CopyFrom(const InfogainLossParameter& from); @@ -6007,17 +6581,30 @@ class InfogainLossParameter : public ::google::protobuf::Message { void Clear(); bool IsInitialized() const; - int ByteSize() const; + size_t ByteSizeLong() const; bool MergePartialFromCodedStream( ::google::protobuf::io::CodedInputStream* input); void SerializeWithCachedSizes( ::google::protobuf::io::CodedOutputStream* output) const; - ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const; + ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray( + bool deterministic, ::google::protobuf::uint8* output) const; + ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const { + return InternalSerializeWithCachedSizesToArray(false, output); + } int GetCachedSize() const { return _cached_size_; } private: void SharedCtor(); void SharedDtor(); void SetCachedSize(int size) const; + void InternalSwap(InfogainLossParameter* other); + void UnsafeMergeFrom(const InfogainLossParameter& from); + private: + inline ::google::protobuf::Arena* GetArenaNoVirtual() const { + return _internal_metadata_.arena(); + } + inline void* MaybeArenaPtr() const { + return _internal_metadata_.raw_arena_ptr(); + } public: ::google::protobuf::Metadata GetMetadata() const; @@ -6027,39 +6614,38 @@ class InfogainLossParameter : public ::google::protobuf::Message { // accessors ------------------------------------------------------- // optional string source = 1; - inline bool has_source() const; - inline void clear_source(); + bool has_source() const; + void clear_source(); static const int kSourceFieldNumber = 1; - inline const ::std::string& source() const; - inline void set_source(const ::std::string& value); - inline void set_source(const char* value); - inline void set_source(const char* value, size_t size); - inline ::std::string* mutable_source(); - inline ::std::string* release_source(); - inline void set_allocated_source(::std::string* source); + const ::std::string& source() const; + void set_source(const ::std::string& value); + void set_source(const char* value); + void set_source(const char* value, size_t size); + ::std::string* mutable_source(); + ::std::string* release_source(); + void set_allocated_source(::std::string* source); // @@protoc_insertion_point(class_scope:caffe.InfogainLossParameter) private: inline void set_has_source(); inline void clear_has_source(); - ::google::protobuf::UnknownFieldSet _unknown_fields_; - - ::std::string* source_; - + ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_; + ::google::protobuf::internal::HasBits<1> _has_bits_; mutable int _cached_size_; - ::google::protobuf::uint32 _has_bits_[(1 + 31) / 32]; - - friend void protobuf_AddDesc_caffe_2eproto(); + ::google::protobuf::internal::ArenaStringPtr source_; + friend void protobuf_InitDefaults_caffe_2eproto_impl(); + friend void protobuf_AddDesc_caffe_2eproto_impl(); friend void protobuf_AssignDesc_caffe_2eproto(); friend void protobuf_ShutdownFile_caffe_2eproto(); void InitAsDefaultInstance(); - static InfogainLossParameter* default_instance_; }; +extern ::google::protobuf::internal::ExplicitlyConstructed InfogainLossParameter_default_instance_; + // ------------------------------------------------------------------- -class InnerProductParameter : public ::google::protobuf::Message { +class InnerProductParameter : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:caffe.InnerProductParameter) */ { public: InnerProductParameter(); virtual ~InnerProductParameter(); @@ -6072,21 +6658,25 @@ class InnerProductParameter : public ::google::protobuf::Message { } inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const { - return _unknown_fields_; + return _internal_metadata_.unknown_fields(); } inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() { - return &_unknown_fields_; + return _internal_metadata_.mutable_unknown_fields(); } static const ::google::protobuf::Descriptor* descriptor(); static const InnerProductParameter& default_instance(); + static const InnerProductParameter* internal_default_instance(); + void Swap(InnerProductParameter* other); // implements Message ---------------------------------------------- - InnerProductParameter* New() const; + inline InnerProductParameter* New() const { return New(NULL); } + + InnerProductParameter* New(::google::protobuf::Arena* arena) const; void CopyFrom(const ::google::protobuf::Message& from); void MergeFrom(const ::google::protobuf::Message& from); void CopyFrom(const InnerProductParameter& from); @@ -6094,17 +6684,30 @@ class InnerProductParameter : public ::google::protobuf::Message { void Clear(); bool IsInitialized() const; - int ByteSize() const; + size_t ByteSizeLong() const; bool MergePartialFromCodedStream( ::google::protobuf::io::CodedInputStream* input); void SerializeWithCachedSizes( ::google::protobuf::io::CodedOutputStream* output) const; - ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const; + ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray( + bool deterministic, ::google::protobuf::uint8* output) const; + ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const { + return InternalSerializeWithCachedSizesToArray(false, output); + } int GetCachedSize() const { return _cached_size_; } private: void SharedCtor(); void SharedDtor(); void SetCachedSize(int size) const; + void InternalSwap(InnerProductParameter* other); + void UnsafeMergeFrom(const InnerProductParameter& from); + private: + inline ::google::protobuf::Arena* GetArenaNoVirtual() const { + return _internal_metadata_.arena(); + } + inline void* MaybeArenaPtr() const { + return _internal_metadata_.raw_arena_ptr(); + } public: ::google::protobuf::Metadata GetMetadata() const; @@ -6114,43 +6717,43 @@ class InnerProductParameter : public ::google::protobuf::Message { // accessors ------------------------------------------------------- // optional uint32 num_output = 1; - inline bool has_num_output() const; - inline void clear_num_output(); + bool has_num_output() const; + void clear_num_output(); static const int kNumOutputFieldNumber = 1; - inline ::google::protobuf::uint32 num_output() const; - inline void set_num_output(::google::protobuf::uint32 value); + ::google::protobuf::uint32 num_output() const; + void set_num_output(::google::protobuf::uint32 value); // optional bool bias_term = 2 [default = true]; - inline bool has_bias_term() const; - inline void clear_bias_term(); + bool has_bias_term() const; + void clear_bias_term(); static const int kBiasTermFieldNumber = 2; - inline bool bias_term() const; - inline void set_bias_term(bool value); + bool bias_term() const; + void set_bias_term(bool value); // optional .caffe.FillerParameter weight_filler = 3; - inline bool has_weight_filler() const; - inline void clear_weight_filler(); + bool has_weight_filler() const; + void clear_weight_filler(); static const int kWeightFillerFieldNumber = 3; - inline const ::caffe::FillerParameter& weight_filler() const; - inline ::caffe::FillerParameter* mutable_weight_filler(); - inline ::caffe::FillerParameter* release_weight_filler(); - inline void set_allocated_weight_filler(::caffe::FillerParameter* weight_filler); + const ::caffe::FillerParameter& weight_filler() const; + ::caffe::FillerParameter* mutable_weight_filler(); + ::caffe::FillerParameter* release_weight_filler(); + void set_allocated_weight_filler(::caffe::FillerParameter* weight_filler); // optional .caffe.FillerParameter bias_filler = 4; - inline bool has_bias_filler() const; - inline void clear_bias_filler(); + bool has_bias_filler() const; + void clear_bias_filler(); static const int kBiasFillerFieldNumber = 4; - inline const ::caffe::FillerParameter& bias_filler() const; - inline ::caffe::FillerParameter* mutable_bias_filler(); - inline ::caffe::FillerParameter* release_bias_filler(); - inline void set_allocated_bias_filler(::caffe::FillerParameter* bias_filler); + const ::caffe::FillerParameter& bias_filler() const; + ::caffe::FillerParameter* mutable_bias_filler(); + ::caffe::FillerParameter* release_bias_filler(); + void set_allocated_bias_filler(::caffe::FillerParameter* bias_filler); // optional int32 axis = 5 [default = 1]; - inline bool has_axis() const; - inline void clear_axis(); + bool has_axis() const; + void clear_axis(); static const int kAxisFieldNumber = 5; - inline ::google::protobuf::int32 axis() const; - inline void set_axis(::google::protobuf::int32 value); + ::google::protobuf::int32 axis() const; + void set_axis(::google::protobuf::int32 value); // @@protoc_insertion_point(class_scope:caffe.InnerProductParameter) private: @@ -6165,27 +6768,26 @@ class InnerProductParameter : public ::google::protobuf::Message { inline void set_has_axis(); inline void clear_has_axis(); - ::google::protobuf::UnknownFieldSet _unknown_fields_; - - ::google::protobuf::uint32 num_output_; - bool bias_term_; + ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_; + ::google::protobuf::internal::HasBits<1> _has_bits_; + mutable int _cached_size_; ::caffe::FillerParameter* weight_filler_; ::caffe::FillerParameter* bias_filler_; + ::google::protobuf::uint32 num_output_; + bool bias_term_; ::google::protobuf::int32 axis_; - - mutable int _cached_size_; - ::google::protobuf::uint32 _has_bits_[(5 + 31) / 32]; - - friend void protobuf_AddDesc_caffe_2eproto(); + friend void protobuf_InitDefaults_caffe_2eproto_impl(); + friend void protobuf_AddDesc_caffe_2eproto_impl(); friend void protobuf_AssignDesc_caffe_2eproto(); friend void protobuf_ShutdownFile_caffe_2eproto(); void InitAsDefaultInstance(); - static InnerProductParameter* default_instance_; }; +extern ::google::protobuf::internal::ExplicitlyConstructed InnerProductParameter_default_instance_; + // ------------------------------------------------------------------- -class LogParameter : public ::google::protobuf::Message { +class LogParameter : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:caffe.LogParameter) */ { public: LogParameter(); virtual ~LogParameter(); @@ -6198,21 +6800,25 @@ class LogParameter : public ::google::protobuf::Message { } inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const { - return _unknown_fields_; + return _internal_metadata_.unknown_fields(); } inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() { - return &_unknown_fields_; + return _internal_metadata_.mutable_unknown_fields(); } static const ::google::protobuf::Descriptor* descriptor(); static const LogParameter& default_instance(); + static const LogParameter* internal_default_instance(); + void Swap(LogParameter* other); // implements Message ---------------------------------------------- - LogParameter* New() const; + inline LogParameter* New() const { return New(NULL); } + + LogParameter* New(::google::protobuf::Arena* arena) const; void CopyFrom(const ::google::protobuf::Message& from); void MergeFrom(const ::google::protobuf::Message& from); void CopyFrom(const LogParameter& from); @@ -6220,17 +6826,30 @@ class LogParameter : public ::google::protobuf::Message { void Clear(); bool IsInitialized() const; - int ByteSize() const; + size_t ByteSizeLong() const; bool MergePartialFromCodedStream( ::google::protobuf::io::CodedInputStream* input); void SerializeWithCachedSizes( ::google::protobuf::io::CodedOutputStream* output) const; - ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const; + ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray( + bool deterministic, ::google::protobuf::uint8* output) const; + ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const { + return InternalSerializeWithCachedSizesToArray(false, output); + } int GetCachedSize() const { return _cached_size_; } private: void SharedCtor(); void SharedDtor(); void SetCachedSize(int size) const; + void InternalSwap(LogParameter* other); + void UnsafeMergeFrom(const LogParameter& from); + private: + inline ::google::protobuf::Arena* GetArenaNoVirtual() const { + return _internal_metadata_.arena(); + } + inline void* MaybeArenaPtr() const { + return _internal_metadata_.raw_arena_ptr(); + } public: ::google::protobuf::Metadata GetMetadata() const; @@ -6240,25 +6859,25 @@ class LogParameter : public ::google::protobuf::Message { // accessors ------------------------------------------------------- // optional float base = 1 [default = -1]; - inline bool has_base() const; - inline void clear_base(); + bool has_base() const; + void clear_base(); static const int kBaseFieldNumber = 1; - inline float base() const; - inline void set_base(float value); + float base() const; + void set_base(float value); // optional float scale = 2 [default = 1]; - inline bool has_scale() const; - inline void clear_scale(); + bool has_scale() const; + void clear_scale(); static const int kScaleFieldNumber = 2; - inline float scale() const; - inline void set_scale(float value); + float scale() const; + void set_scale(float value); // optional float shift = 3 [default = 0]; - inline bool has_shift() const; - inline void clear_shift(); + bool has_shift() const; + void clear_shift(); static const int kShiftFieldNumber = 3; - inline float shift() const; - inline void set_shift(float value); + float shift() const; + void set_shift(float value); // @@protoc_insertion_point(class_scope:caffe.LogParameter) private: @@ -6269,25 +6888,24 @@ class LogParameter : public ::google::protobuf::Message { inline void set_has_shift(); inline void clear_has_shift(); - ::google::protobuf::UnknownFieldSet _unknown_fields_; - + ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_; + ::google::protobuf::internal::HasBits<1> _has_bits_; + mutable int _cached_size_; + float shift_; float base_; float scale_; - float shift_; - - mutable int _cached_size_; - ::google::protobuf::uint32 _has_bits_[(3 + 31) / 32]; - - friend void protobuf_AddDesc_caffe_2eproto(); + friend void protobuf_InitDefaults_caffe_2eproto_impl(); + friend void protobuf_AddDesc_caffe_2eproto_impl(); friend void protobuf_AssignDesc_caffe_2eproto(); friend void protobuf_ShutdownFile_caffe_2eproto(); void InitAsDefaultInstance(); - static LogParameter* default_instance_; }; +extern ::google::protobuf::internal::ExplicitlyConstructed LogParameter_default_instance_; + // ------------------------------------------------------------------- -class LRNParameter : public ::google::protobuf::Message { +class LRNParameter : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:caffe.LRNParameter) */ { public: LRNParameter(); virtual ~LRNParameter(); @@ -6300,21 +6918,25 @@ class LRNParameter : public ::google::protobuf::Message { } inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const { - return _unknown_fields_; + return _internal_metadata_.unknown_fields(); } inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() { - return &_unknown_fields_; + return _internal_metadata_.mutable_unknown_fields(); } static const ::google::protobuf::Descriptor* descriptor(); static const LRNParameter& default_instance(); + static const LRNParameter* internal_default_instance(); + void Swap(LRNParameter* other); // implements Message ---------------------------------------------- - LRNParameter* New() const; + inline LRNParameter* New() const { return New(NULL); } + + LRNParameter* New(::google::protobuf::Arena* arena) const; void CopyFrom(const ::google::protobuf::Message& from); void MergeFrom(const ::google::protobuf::Message& from); void CopyFrom(const LRNParameter& from); @@ -6322,17 +6944,30 @@ class LRNParameter : public ::google::protobuf::Message { void Clear(); bool IsInitialized() const; - int ByteSize() const; + size_t ByteSizeLong() const; bool MergePartialFromCodedStream( ::google::protobuf::io::CodedInputStream* input); void SerializeWithCachedSizes( ::google::protobuf::io::CodedOutputStream* output) const; - ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const; + ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray( + bool deterministic, ::google::protobuf::uint8* output) const; + ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const { + return InternalSerializeWithCachedSizesToArray(false, output); + } int GetCachedSize() const { return _cached_size_; } private: void SharedCtor(); void SharedDtor(); void SetCachedSize(int size) const; + void InternalSwap(LRNParameter* other); + void UnsafeMergeFrom(const LRNParameter& from); + private: + inline ::google::protobuf::Arena* GetArenaNoVirtual() const { + return _internal_metadata_.arena(); + } + inline void* MaybeArenaPtr() const { + return _internal_metadata_.raw_arena_ptr(); + } public: ::google::protobuf::Metadata GetMetadata() const; @@ -6340,8 +6975,10 @@ class LRNParameter : public ::google::protobuf::Message { // nested types ---------------------------------------------------- typedef LRNParameter_NormRegion NormRegion; - static const NormRegion ACROSS_CHANNELS = LRNParameter_NormRegion_ACROSS_CHANNELS; - static const NormRegion WITHIN_CHANNEL = LRNParameter_NormRegion_WITHIN_CHANNEL; + static const NormRegion ACROSS_CHANNELS = + LRNParameter_NormRegion_ACROSS_CHANNELS; + static const NormRegion WITHIN_CHANNEL = + LRNParameter_NormRegion_WITHIN_CHANNEL; static inline bool NormRegion_IsValid(int value) { return LRNParameter_NormRegion_IsValid(value); } @@ -6366,39 +7003,39 @@ class LRNParameter : public ::google::protobuf::Message { // accessors ------------------------------------------------------- // optional uint32 local_size = 1 [default = 5]; - inline bool has_local_size() const; - inline void clear_local_size(); + bool has_local_size() const; + void clear_local_size(); static const int kLocalSizeFieldNumber = 1; - inline ::google::protobuf::uint32 local_size() const; - inline void set_local_size(::google::protobuf::uint32 value); + ::google::protobuf::uint32 local_size() const; + void set_local_size(::google::protobuf::uint32 value); // optional float alpha = 2 [default = 1]; - inline bool has_alpha() const; - inline void clear_alpha(); + bool has_alpha() const; + void clear_alpha(); static const int kAlphaFieldNumber = 2; - inline float alpha() const; - inline void set_alpha(float value); + float alpha() const; + void set_alpha(float value); // optional float beta = 3 [default = 0.75]; - inline bool has_beta() const; - inline void clear_beta(); + bool has_beta() const; + void clear_beta(); static const int kBetaFieldNumber = 3; - inline float beta() const; - inline void set_beta(float value); + float beta() const; + void set_beta(float value); // optional .caffe.LRNParameter.NormRegion norm_region = 4 [default = ACROSS_CHANNELS]; - inline bool has_norm_region() const; - inline void clear_norm_region(); + bool has_norm_region() const; + void clear_norm_region(); static const int kNormRegionFieldNumber = 4; - inline ::caffe::LRNParameter_NormRegion norm_region() const; - inline void set_norm_region(::caffe::LRNParameter_NormRegion value); + ::caffe::LRNParameter_NormRegion norm_region() const; + void set_norm_region(::caffe::LRNParameter_NormRegion value); // optional float k = 5 [default = 1]; - inline bool has_k() const; - inline void clear_k(); + bool has_k() const; + void clear_k(); static const int kKFieldNumber = 5; - inline float k() const; - inline void set_k(float value); + float k() const; + void set_k(float value); // @@protoc_insertion_point(class_scope:caffe.LRNParameter) private: @@ -6413,27 +7050,26 @@ class LRNParameter : public ::google::protobuf::Message { inline void set_has_k(); inline void clear_has_k(); - ::google::protobuf::UnknownFieldSet _unknown_fields_; - + ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_; + ::google::protobuf::internal::HasBits<1> _has_bits_; + mutable int _cached_size_; + int norm_region_; ::google::protobuf::uint32 local_size_; float alpha_; float beta_; - int norm_region_; float k_; - - mutable int _cached_size_; - ::google::protobuf::uint32 _has_bits_[(5 + 31) / 32]; - - friend void protobuf_AddDesc_caffe_2eproto(); + friend void protobuf_InitDefaults_caffe_2eproto_impl(); + friend void protobuf_AddDesc_caffe_2eproto_impl(); friend void protobuf_AssignDesc_caffe_2eproto(); friend void protobuf_ShutdownFile_caffe_2eproto(); void InitAsDefaultInstance(); - static LRNParameter* default_instance_; }; +extern ::google::protobuf::internal::ExplicitlyConstructed LRNParameter_default_instance_; + // ------------------------------------------------------------------- -class MemoryDataParameter : public ::google::protobuf::Message { +class MemoryDataParameter : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:caffe.MemoryDataParameter) */ { public: MemoryDataParameter(); virtual ~MemoryDataParameter(); @@ -6446,21 +7082,25 @@ class MemoryDataParameter : public ::google::protobuf::Message { } inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const { - return _unknown_fields_; + return _internal_metadata_.unknown_fields(); } inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() { - return &_unknown_fields_; + return _internal_metadata_.mutable_unknown_fields(); } static const ::google::protobuf::Descriptor* descriptor(); static const MemoryDataParameter& default_instance(); + static const MemoryDataParameter* internal_default_instance(); + void Swap(MemoryDataParameter* other); // implements Message ---------------------------------------------- - MemoryDataParameter* New() const; + inline MemoryDataParameter* New() const { return New(NULL); } + + MemoryDataParameter* New(::google::protobuf::Arena* arena) const; void CopyFrom(const ::google::protobuf::Message& from); void MergeFrom(const ::google::protobuf::Message& from); void CopyFrom(const MemoryDataParameter& from); @@ -6468,17 +7108,30 @@ class MemoryDataParameter : public ::google::protobuf::Message { void Clear(); bool IsInitialized() const; - int ByteSize() const; + size_t ByteSizeLong() const; bool MergePartialFromCodedStream( ::google::protobuf::io::CodedInputStream* input); void SerializeWithCachedSizes( ::google::protobuf::io::CodedOutputStream* output) const; - ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const; + ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray( + bool deterministic, ::google::protobuf::uint8* output) const; + ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const { + return InternalSerializeWithCachedSizesToArray(false, output); + } int GetCachedSize() const { return _cached_size_; } private: void SharedCtor(); void SharedDtor(); void SetCachedSize(int size) const; + void InternalSwap(MemoryDataParameter* other); + void UnsafeMergeFrom(const MemoryDataParameter& from); + private: + inline ::google::protobuf::Arena* GetArenaNoVirtual() const { + return _internal_metadata_.arena(); + } + inline void* MaybeArenaPtr() const { + return _internal_metadata_.raw_arena_ptr(); + } public: ::google::protobuf::Metadata GetMetadata() const; @@ -6488,32 +7141,32 @@ class MemoryDataParameter : public ::google::protobuf::Message { // accessors ------------------------------------------------------- // optional uint32 batch_size = 1; - inline bool has_batch_size() const; - inline void clear_batch_size(); + bool has_batch_size() const; + void clear_batch_size(); static const int kBatchSizeFieldNumber = 1; - inline ::google::protobuf::uint32 batch_size() const; - inline void set_batch_size(::google::protobuf::uint32 value); + ::google::protobuf::uint32 batch_size() const; + void set_batch_size(::google::protobuf::uint32 value); // optional uint32 channels = 2; - inline bool has_channels() const; - inline void clear_channels(); + bool has_channels() const; + void clear_channels(); static const int kChannelsFieldNumber = 2; - inline ::google::protobuf::uint32 channels() const; - inline void set_channels(::google::protobuf::uint32 value); + ::google::protobuf::uint32 channels() const; + void set_channels(::google::protobuf::uint32 value); // optional uint32 height = 3; - inline bool has_height() const; - inline void clear_height(); + bool has_height() const; + void clear_height(); static const int kHeightFieldNumber = 3; - inline ::google::protobuf::uint32 height() const; - inline void set_height(::google::protobuf::uint32 value); + ::google::protobuf::uint32 height() const; + void set_height(::google::protobuf::uint32 value); // optional uint32 width = 4; - inline bool has_width() const; - inline void clear_width(); + bool has_width() const; + void clear_width(); static const int kWidthFieldNumber = 4; - inline ::google::protobuf::uint32 width() const; - inline void set_width(::google::protobuf::uint32 value); + ::google::protobuf::uint32 width() const; + void set_width(::google::protobuf::uint32 value); // @@protoc_insertion_point(class_scope:caffe.MemoryDataParameter) private: @@ -6526,26 +7179,25 @@ class MemoryDataParameter : public ::google::protobuf::Message { inline void set_has_width(); inline void clear_has_width(); - ::google::protobuf::UnknownFieldSet _unknown_fields_; - + ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_; + ::google::protobuf::internal::HasBits<1> _has_bits_; + mutable int _cached_size_; ::google::protobuf::uint32 batch_size_; ::google::protobuf::uint32 channels_; ::google::protobuf::uint32 height_; ::google::protobuf::uint32 width_; - - mutable int _cached_size_; - ::google::protobuf::uint32 _has_bits_[(4 + 31) / 32]; - - friend void protobuf_AddDesc_caffe_2eproto(); + friend void protobuf_InitDefaults_caffe_2eproto_impl(); + friend void protobuf_AddDesc_caffe_2eproto_impl(); friend void protobuf_AssignDesc_caffe_2eproto(); friend void protobuf_ShutdownFile_caffe_2eproto(); void InitAsDefaultInstance(); - static MemoryDataParameter* default_instance_; }; +extern ::google::protobuf::internal::ExplicitlyConstructed MemoryDataParameter_default_instance_; + // ------------------------------------------------------------------- -class MVNParameter : public ::google::protobuf::Message { +class MVNParameter : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:caffe.MVNParameter) */ { public: MVNParameter(); virtual ~MVNParameter(); @@ -6558,21 +7210,25 @@ class MVNParameter : public ::google::protobuf::Message { } inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const { - return _unknown_fields_; + return _internal_metadata_.unknown_fields(); } inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() { - return &_unknown_fields_; + return _internal_metadata_.mutable_unknown_fields(); } static const ::google::protobuf::Descriptor* descriptor(); static const MVNParameter& default_instance(); + static const MVNParameter* internal_default_instance(); + void Swap(MVNParameter* other); // implements Message ---------------------------------------------- - MVNParameter* New() const; + inline MVNParameter* New() const { return New(NULL); } + + MVNParameter* New(::google::protobuf::Arena* arena) const; void CopyFrom(const ::google::protobuf::Message& from); void MergeFrom(const ::google::protobuf::Message& from); void CopyFrom(const MVNParameter& from); @@ -6580,17 +7236,30 @@ class MVNParameter : public ::google::protobuf::Message { void Clear(); bool IsInitialized() const; - int ByteSize() const; + size_t ByteSizeLong() const; bool MergePartialFromCodedStream( ::google::protobuf::io::CodedInputStream* input); void SerializeWithCachedSizes( ::google::protobuf::io::CodedOutputStream* output) const; - ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const; + ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray( + bool deterministic, ::google::protobuf::uint8* output) const; + ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const { + return InternalSerializeWithCachedSizesToArray(false, output); + } int GetCachedSize() const { return _cached_size_; } private: void SharedCtor(); void SharedDtor(); void SetCachedSize(int size) const; + void InternalSwap(MVNParameter* other); + void UnsafeMergeFrom(const MVNParameter& from); + private: + inline ::google::protobuf::Arena* GetArenaNoVirtual() const { + return _internal_metadata_.arena(); + } + inline void* MaybeArenaPtr() const { + return _internal_metadata_.raw_arena_ptr(); + } public: ::google::protobuf::Metadata GetMetadata() const; @@ -6600,25 +7269,25 @@ class MVNParameter : public ::google::protobuf::Message { // accessors ------------------------------------------------------- // optional bool normalize_variance = 1 [default = true]; - inline bool has_normalize_variance() const; - inline void clear_normalize_variance(); + bool has_normalize_variance() const; + void clear_normalize_variance(); static const int kNormalizeVarianceFieldNumber = 1; - inline bool normalize_variance() const; - inline void set_normalize_variance(bool value); + bool normalize_variance() const; + void set_normalize_variance(bool value); // optional bool across_channels = 2 [default = false]; - inline bool has_across_channels() const; - inline void clear_across_channels(); + bool has_across_channels() const; + void clear_across_channels(); static const int kAcrossChannelsFieldNumber = 2; - inline bool across_channels() const; - inline void set_across_channels(bool value); + bool across_channels() const; + void set_across_channels(bool value); // optional float eps = 3 [default = 1e-09]; - inline bool has_eps() const; - inline void clear_eps(); + bool has_eps() const; + void clear_eps(); static const int kEpsFieldNumber = 3; - inline float eps() const; - inline void set_eps(float value); + float eps() const; + void set_eps(float value); // @@protoc_insertion_point(class_scope:caffe.MVNParameter) private: @@ -6629,25 +7298,24 @@ class MVNParameter : public ::google::protobuf::Message { inline void set_has_eps(); inline void clear_has_eps(); - ::google::protobuf::UnknownFieldSet _unknown_fields_; - - bool normalize_variance_; + ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_; + ::google::protobuf::internal::HasBits<1> _has_bits_; + mutable int _cached_size_; bool across_channels_; + bool normalize_variance_; float eps_; - - mutable int _cached_size_; - ::google::protobuf::uint32 _has_bits_[(3 + 31) / 32]; - - friend void protobuf_AddDesc_caffe_2eproto(); + friend void protobuf_InitDefaults_caffe_2eproto_impl(); + friend void protobuf_AddDesc_caffe_2eproto_impl(); friend void protobuf_AssignDesc_caffe_2eproto(); friend void protobuf_ShutdownFile_caffe_2eproto(); void InitAsDefaultInstance(); - static MVNParameter* default_instance_; }; +extern ::google::protobuf::internal::ExplicitlyConstructed MVNParameter_default_instance_; + // ------------------------------------------------------------------- -class PoolingParameter : public ::google::protobuf::Message { +class PoolingParameter : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:caffe.PoolingParameter) */ { public: PoolingParameter(); virtual ~PoolingParameter(); @@ -6660,21 +7328,25 @@ class PoolingParameter : public ::google::protobuf::Message { } inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const { - return _unknown_fields_; + return _internal_metadata_.unknown_fields(); } inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() { - return &_unknown_fields_; + return _internal_metadata_.mutable_unknown_fields(); } static const ::google::protobuf::Descriptor* descriptor(); static const PoolingParameter& default_instance(); + static const PoolingParameter* internal_default_instance(); + void Swap(PoolingParameter* other); // implements Message ---------------------------------------------- - PoolingParameter* New() const; + inline PoolingParameter* New() const { return New(NULL); } + + PoolingParameter* New(::google::protobuf::Arena* arena) const; void CopyFrom(const ::google::protobuf::Message& from); void MergeFrom(const ::google::protobuf::Message& from); void CopyFrom(const PoolingParameter& from); @@ -6682,17 +7354,30 @@ class PoolingParameter : public ::google::protobuf::Message { void Clear(); bool IsInitialized() const; - int ByteSize() const; + size_t ByteSizeLong() const; bool MergePartialFromCodedStream( ::google::protobuf::io::CodedInputStream* input); void SerializeWithCachedSizes( ::google::protobuf::io::CodedOutputStream* output) const; - ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const; + ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray( + bool deterministic, ::google::protobuf::uint8* output) const; + ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const { + return InternalSerializeWithCachedSizesToArray(false, output); + } int GetCachedSize() const { return _cached_size_; } private: void SharedCtor(); void SharedDtor(); void SetCachedSize(int size) const; + void InternalSwap(PoolingParameter* other); + void UnsafeMergeFrom(const PoolingParameter& from); + private: + inline ::google::protobuf::Arena* GetArenaNoVirtual() const { + return _internal_metadata_.arena(); + } + inline void* MaybeArenaPtr() const { + return _internal_metadata_.raw_arena_ptr(); + } public: ::google::protobuf::Metadata GetMetadata() const; @@ -6700,9 +7385,12 @@ class PoolingParameter : public ::google::protobuf::Message { // nested types ---------------------------------------------------- typedef PoolingParameter_PoolMethod PoolMethod; - static const PoolMethod MAX = PoolingParameter_PoolMethod_MAX; - static const PoolMethod AVE = PoolingParameter_PoolMethod_AVE; - static const PoolMethod STOCHASTIC = PoolingParameter_PoolMethod_STOCHASTIC; + static const PoolMethod MAX = + PoolingParameter_PoolMethod_MAX; + static const PoolMethod AVE = + PoolingParameter_PoolMethod_AVE; + static const PoolMethod STOCHASTIC = + PoolingParameter_PoolMethod_STOCHASTIC; static inline bool PoolMethod_IsValid(int value) { return PoolingParameter_PoolMethod_IsValid(value); } @@ -6725,9 +7413,12 @@ class PoolingParameter : public ::google::protobuf::Message { } typedef PoolingParameter_Engine Engine; - static const Engine DEFAULT = PoolingParameter_Engine_DEFAULT; - static const Engine CAFFE = PoolingParameter_Engine_CAFFE; - static const Engine CUDNN = PoolingParameter_Engine_CUDNN; + static const Engine DEFAULT = + PoolingParameter_Engine_DEFAULT; + static const Engine CAFFE = + PoolingParameter_Engine_CAFFE; + static const Engine CUDNN = + PoolingParameter_Engine_CUDNN; static inline bool Engine_IsValid(int value) { return PoolingParameter_Engine_IsValid(value); } @@ -6752,88 +7443,88 @@ class PoolingParameter : public ::google::protobuf::Message { // accessors ------------------------------------------------------- // optional .caffe.PoolingParameter.PoolMethod pool = 1 [default = MAX]; - inline bool has_pool() const; - inline void clear_pool(); + bool has_pool() const; + void clear_pool(); static const int kPoolFieldNumber = 1; - inline ::caffe::PoolingParameter_PoolMethod pool() const; - inline void set_pool(::caffe::PoolingParameter_PoolMethod value); + ::caffe::PoolingParameter_PoolMethod pool() const; + void set_pool(::caffe::PoolingParameter_PoolMethod value); // optional uint32 pad = 4 [default = 0]; - inline bool has_pad() const; - inline void clear_pad(); + bool has_pad() const; + void clear_pad(); static const int kPadFieldNumber = 4; - inline ::google::protobuf::uint32 pad() const; - inline void set_pad(::google::protobuf::uint32 value); + ::google::protobuf::uint32 pad() const; + void set_pad(::google::protobuf::uint32 value); // optional uint32 pad_h = 9 [default = 0]; - inline bool has_pad_h() const; - inline void clear_pad_h(); + bool has_pad_h() const; + void clear_pad_h(); static const int kPadHFieldNumber = 9; - inline ::google::protobuf::uint32 pad_h() const; - inline void set_pad_h(::google::protobuf::uint32 value); + ::google::protobuf::uint32 pad_h() const; + void set_pad_h(::google::protobuf::uint32 value); // optional uint32 pad_w = 10 [default = 0]; - inline bool has_pad_w() const; - inline void clear_pad_w(); + bool has_pad_w() const; + void clear_pad_w(); static const int kPadWFieldNumber = 10; - inline ::google::protobuf::uint32 pad_w() const; - inline void set_pad_w(::google::protobuf::uint32 value); + ::google::protobuf::uint32 pad_w() const; + void set_pad_w(::google::protobuf::uint32 value); // optional uint32 kernel_size = 2; - inline bool has_kernel_size() const; - inline void clear_kernel_size(); + bool has_kernel_size() const; + void clear_kernel_size(); static const int kKernelSizeFieldNumber = 2; - inline ::google::protobuf::uint32 kernel_size() const; - inline void set_kernel_size(::google::protobuf::uint32 value); + ::google::protobuf::uint32 kernel_size() const; + void set_kernel_size(::google::protobuf::uint32 value); // optional uint32 kernel_h = 5; - inline bool has_kernel_h() const; - inline void clear_kernel_h(); + bool has_kernel_h() const; + void clear_kernel_h(); static const int kKernelHFieldNumber = 5; - inline ::google::protobuf::uint32 kernel_h() const; - inline void set_kernel_h(::google::protobuf::uint32 value); + ::google::protobuf::uint32 kernel_h() const; + void set_kernel_h(::google::protobuf::uint32 value); // optional uint32 kernel_w = 6; - inline bool has_kernel_w() const; - inline void clear_kernel_w(); + bool has_kernel_w() const; + void clear_kernel_w(); static const int kKernelWFieldNumber = 6; - inline ::google::protobuf::uint32 kernel_w() const; - inline void set_kernel_w(::google::protobuf::uint32 value); + ::google::protobuf::uint32 kernel_w() const; + void set_kernel_w(::google::protobuf::uint32 value); // optional uint32 stride = 3 [default = 1]; - inline bool has_stride() const; - inline void clear_stride(); + bool has_stride() const; + void clear_stride(); static const int kStrideFieldNumber = 3; - inline ::google::protobuf::uint32 stride() const; - inline void set_stride(::google::protobuf::uint32 value); + ::google::protobuf::uint32 stride() const; + void set_stride(::google::protobuf::uint32 value); // optional uint32 stride_h = 7; - inline bool has_stride_h() const; - inline void clear_stride_h(); + bool has_stride_h() const; + void clear_stride_h(); static const int kStrideHFieldNumber = 7; - inline ::google::protobuf::uint32 stride_h() const; - inline void set_stride_h(::google::protobuf::uint32 value); + ::google::protobuf::uint32 stride_h() const; + void set_stride_h(::google::protobuf::uint32 value); // optional uint32 stride_w = 8; - inline bool has_stride_w() const; - inline void clear_stride_w(); + bool has_stride_w() const; + void clear_stride_w(); static const int kStrideWFieldNumber = 8; - inline ::google::protobuf::uint32 stride_w() const; - inline void set_stride_w(::google::protobuf::uint32 value); + ::google::protobuf::uint32 stride_w() const; + void set_stride_w(::google::protobuf::uint32 value); // optional .caffe.PoolingParameter.Engine engine = 11 [default = DEFAULT]; - inline bool has_engine() const; - inline void clear_engine(); + bool has_engine() const; + void clear_engine(); static const int kEngineFieldNumber = 11; - inline ::caffe::PoolingParameter_Engine engine() const; - inline void set_engine(::caffe::PoolingParameter_Engine value); + ::caffe::PoolingParameter_Engine engine() const; + void set_engine(::caffe::PoolingParameter_Engine value); // optional bool global_pooling = 12 [default = false]; - inline bool has_global_pooling() const; - inline void clear_global_pooling(); + bool has_global_pooling() const; + void clear_global_pooling(); static const int kGlobalPoolingFieldNumber = 12; - inline bool global_pooling() const; - inline void set_global_pooling(bool value); + bool global_pooling() const; + void set_global_pooling(bool value); // @@protoc_insertion_point(class_scope:caffe.PoolingParameter) private: @@ -6862,8 +7553,9 @@ class PoolingParameter : public ::google::protobuf::Message { inline void set_has_global_pooling(); inline void clear_has_global_pooling(); - ::google::protobuf::UnknownFieldSet _unknown_fields_; - + ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_; + ::google::protobuf::internal::HasBits<1> _has_bits_; + mutable int _cached_size_; int pool_; ::google::protobuf::uint32 pad_; ::google::protobuf::uint32 pad_h_; @@ -6871,25 +7563,23 @@ class PoolingParameter : public ::google::protobuf::Message { ::google::protobuf::uint32 kernel_size_; ::google::protobuf::uint32 kernel_h_; ::google::protobuf::uint32 kernel_w_; - ::google::protobuf::uint32 stride_; ::google::protobuf::uint32 stride_h_; ::google::protobuf::uint32 stride_w_; int engine_; bool global_pooling_; - - mutable int _cached_size_; - ::google::protobuf::uint32 _has_bits_[(12 + 31) / 32]; - - friend void protobuf_AddDesc_caffe_2eproto(); + ::google::protobuf::uint32 stride_; + friend void protobuf_InitDefaults_caffe_2eproto_impl(); + friend void protobuf_AddDesc_caffe_2eproto_impl(); friend void protobuf_AssignDesc_caffe_2eproto(); friend void protobuf_ShutdownFile_caffe_2eproto(); void InitAsDefaultInstance(); - static PoolingParameter* default_instance_; }; +extern ::google::protobuf::internal::ExplicitlyConstructed PoolingParameter_default_instance_; + // ------------------------------------------------------------------- -class PowerParameter : public ::google::protobuf::Message { +class PowerParameter : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:caffe.PowerParameter) */ { public: PowerParameter(); virtual ~PowerParameter(); @@ -6902,21 +7592,25 @@ class PowerParameter : public ::google::protobuf::Message { } inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const { - return _unknown_fields_; + return _internal_metadata_.unknown_fields(); } inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() { - return &_unknown_fields_; + return _internal_metadata_.mutable_unknown_fields(); } static const ::google::protobuf::Descriptor* descriptor(); static const PowerParameter& default_instance(); + static const PowerParameter* internal_default_instance(); + void Swap(PowerParameter* other); // implements Message ---------------------------------------------- - PowerParameter* New() const; + inline PowerParameter* New() const { return New(NULL); } + + PowerParameter* New(::google::protobuf::Arena* arena) const; void CopyFrom(const ::google::protobuf::Message& from); void MergeFrom(const ::google::protobuf::Message& from); void CopyFrom(const PowerParameter& from); @@ -6924,17 +7618,30 @@ class PowerParameter : public ::google::protobuf::Message { void Clear(); bool IsInitialized() const; - int ByteSize() const; + size_t ByteSizeLong() const; bool MergePartialFromCodedStream( ::google::protobuf::io::CodedInputStream* input); void SerializeWithCachedSizes( ::google::protobuf::io::CodedOutputStream* output) const; - ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const; + ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray( + bool deterministic, ::google::protobuf::uint8* output) const; + ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const { + return InternalSerializeWithCachedSizesToArray(false, output); + } int GetCachedSize() const { return _cached_size_; } private: void SharedCtor(); void SharedDtor(); void SetCachedSize(int size) const; + void InternalSwap(PowerParameter* other); + void UnsafeMergeFrom(const PowerParameter& from); + private: + inline ::google::protobuf::Arena* GetArenaNoVirtual() const { + return _internal_metadata_.arena(); + } + inline void* MaybeArenaPtr() const { + return _internal_metadata_.raw_arena_ptr(); + } public: ::google::protobuf::Metadata GetMetadata() const; @@ -6944,25 +7651,25 @@ class PowerParameter : public ::google::protobuf::Message { // accessors ------------------------------------------------------- // optional float power = 1 [default = 1]; - inline bool has_power() const; - inline void clear_power(); + bool has_power() const; + void clear_power(); static const int kPowerFieldNumber = 1; - inline float power() const; - inline void set_power(float value); + float power() const; + void set_power(float value); // optional float scale = 2 [default = 1]; - inline bool has_scale() const; - inline void clear_scale(); + bool has_scale() const; + void clear_scale(); static const int kScaleFieldNumber = 2; - inline float scale() const; - inline void set_scale(float value); + float scale() const; + void set_scale(float value); // optional float shift = 3 [default = 0]; - inline bool has_shift() const; - inline void clear_shift(); + bool has_shift() const; + void clear_shift(); static const int kShiftFieldNumber = 3; - inline float shift() const; - inline void set_shift(float value); + float shift() const; + void set_shift(float value); // @@protoc_insertion_point(class_scope:caffe.PowerParameter) private: @@ -6973,25 +7680,24 @@ class PowerParameter : public ::google::protobuf::Message { inline void set_has_shift(); inline void clear_has_shift(); - ::google::protobuf::UnknownFieldSet _unknown_fields_; - + ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_; + ::google::protobuf::internal::HasBits<1> _has_bits_; + mutable int _cached_size_; + float shift_; float power_; float scale_; - float shift_; - - mutable int _cached_size_; - ::google::protobuf::uint32 _has_bits_[(3 + 31) / 32]; - - friend void protobuf_AddDesc_caffe_2eproto(); + friend void protobuf_InitDefaults_caffe_2eproto_impl(); + friend void protobuf_AddDesc_caffe_2eproto_impl(); friend void protobuf_AssignDesc_caffe_2eproto(); friend void protobuf_ShutdownFile_caffe_2eproto(); void InitAsDefaultInstance(); - static PowerParameter* default_instance_; }; +extern ::google::protobuf::internal::ExplicitlyConstructed PowerParameter_default_instance_; + // ------------------------------------------------------------------- -class PythonParameter : public ::google::protobuf::Message { +class PythonParameter : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:caffe.PythonParameter) */ { public: PythonParameter(); virtual ~PythonParameter(); @@ -7004,21 +7710,25 @@ class PythonParameter : public ::google::protobuf::Message { } inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const { - return _unknown_fields_; + return _internal_metadata_.unknown_fields(); } inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() { - return &_unknown_fields_; + return _internal_metadata_.mutable_unknown_fields(); } static const ::google::protobuf::Descriptor* descriptor(); static const PythonParameter& default_instance(); + static const PythonParameter* internal_default_instance(); + void Swap(PythonParameter* other); // implements Message ---------------------------------------------- - PythonParameter* New() const; + inline PythonParameter* New() const { return New(NULL); } + + PythonParameter* New(::google::protobuf::Arena* arena) const; void CopyFrom(const ::google::protobuf::Message& from); void MergeFrom(const ::google::protobuf::Message& from); void CopyFrom(const PythonParameter& from); @@ -7026,17 +7736,30 @@ class PythonParameter : public ::google::protobuf::Message { void Clear(); bool IsInitialized() const; - int ByteSize() const; + size_t ByteSizeLong() const; bool MergePartialFromCodedStream( ::google::protobuf::io::CodedInputStream* input); void SerializeWithCachedSizes( ::google::protobuf::io::CodedOutputStream* output) const; - ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const; + ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray( + bool deterministic, ::google::protobuf::uint8* output) const; + ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const { + return InternalSerializeWithCachedSizesToArray(false, output); + } int GetCachedSize() const { return _cached_size_; } private: void SharedCtor(); void SharedDtor(); void SetCachedSize(int size) const; + void InternalSwap(PythonParameter* other); + void UnsafeMergeFrom(const PythonParameter& from); + private: + inline ::google::protobuf::Arena* GetArenaNoVirtual() const { + return _internal_metadata_.arena(); + } + inline void* MaybeArenaPtr() const { + return _internal_metadata_.raw_arena_ptr(); + } public: ::google::protobuf::Metadata GetMetadata() const; @@ -7046,28 +7769,28 @@ class PythonParameter : public ::google::protobuf::Message { // accessors ------------------------------------------------------- // optional string module = 1; - inline bool has_module() const; - inline void clear_module(); + bool has_module() const; + void clear_module(); static const int kModuleFieldNumber = 1; - inline const ::std::string& module() const; - inline void set_module(const ::std::string& value); - inline void set_module(const char* value); - inline void set_module(const char* value, size_t size); - inline ::std::string* mutable_module(); - inline ::std::string* release_module(); - inline void set_allocated_module(::std::string* module); + const ::std::string& module() const; + void set_module(const ::std::string& value); + void set_module(const char* value); + void set_module(const char* value, size_t size); + ::std::string* mutable_module(); + ::std::string* release_module(); + void set_allocated_module(::std::string* module); // optional string layer = 2; - inline bool has_layer() const; - inline void clear_layer(); + bool has_layer() const; + void clear_layer(); static const int kLayerFieldNumber = 2; - inline const ::std::string& layer() const; - inline void set_layer(const ::std::string& value); - inline void set_layer(const char* value); - inline void set_layer(const char* value, size_t size); - inline ::std::string* mutable_layer(); - inline ::std::string* release_layer(); - inline void set_allocated_layer(::std::string* layer); + const ::std::string& layer() const; + void set_layer(const ::std::string& value); + void set_layer(const char* value); + void set_layer(const char* value, size_t size); + ::std::string* mutable_layer(); + ::std::string* release_layer(); + void set_allocated_layer(::std::string* layer); // @@protoc_insertion_point(class_scope:caffe.PythonParameter) private: @@ -7076,24 +7799,23 @@ class PythonParameter : public ::google::protobuf::Message { inline void set_has_layer(); inline void clear_has_layer(); - ::google::protobuf::UnknownFieldSet _unknown_fields_; - - ::std::string* module_; - ::std::string* layer_; - + ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_; + ::google::protobuf::internal::HasBits<1> _has_bits_; mutable int _cached_size_; - ::google::protobuf::uint32 _has_bits_[(2 + 31) / 32]; - - friend void protobuf_AddDesc_caffe_2eproto(); + ::google::protobuf::internal::ArenaStringPtr module_; + ::google::protobuf::internal::ArenaStringPtr layer_; + friend void protobuf_InitDefaults_caffe_2eproto_impl(); + friend void protobuf_AddDesc_caffe_2eproto_impl(); friend void protobuf_AssignDesc_caffe_2eproto(); friend void protobuf_ShutdownFile_caffe_2eproto(); void InitAsDefaultInstance(); - static PythonParameter* default_instance_; }; +extern ::google::protobuf::internal::ExplicitlyConstructed PythonParameter_default_instance_; + // ------------------------------------------------------------------- -class ReductionParameter : public ::google::protobuf::Message { +class ReductionParameter : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:caffe.ReductionParameter) */ { public: ReductionParameter(); virtual ~ReductionParameter(); @@ -7106,21 +7828,25 @@ class ReductionParameter : public ::google::protobuf::Message { } inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const { - return _unknown_fields_; + return _internal_metadata_.unknown_fields(); } inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() { - return &_unknown_fields_; + return _internal_metadata_.mutable_unknown_fields(); } static const ::google::protobuf::Descriptor* descriptor(); static const ReductionParameter& default_instance(); + static const ReductionParameter* internal_default_instance(); + void Swap(ReductionParameter* other); // implements Message ---------------------------------------------- - ReductionParameter* New() const; + inline ReductionParameter* New() const { return New(NULL); } + + ReductionParameter* New(::google::protobuf::Arena* arena) const; void CopyFrom(const ::google::protobuf::Message& from); void MergeFrom(const ::google::protobuf::Message& from); void CopyFrom(const ReductionParameter& from); @@ -7128,17 +7854,30 @@ class ReductionParameter : public ::google::protobuf::Message { void Clear(); bool IsInitialized() const; - int ByteSize() const; + size_t ByteSizeLong() const; bool MergePartialFromCodedStream( ::google::protobuf::io::CodedInputStream* input); void SerializeWithCachedSizes( ::google::protobuf::io::CodedOutputStream* output) const; - ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const; + ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray( + bool deterministic, ::google::protobuf::uint8* output) const; + ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const { + return InternalSerializeWithCachedSizesToArray(false, output); + } int GetCachedSize() const { return _cached_size_; } private: void SharedCtor(); void SharedDtor(); void SetCachedSize(int size) const; + void InternalSwap(ReductionParameter* other); + void UnsafeMergeFrom(const ReductionParameter& from); + private: + inline ::google::protobuf::Arena* GetArenaNoVirtual() const { + return _internal_metadata_.arena(); + } + inline void* MaybeArenaPtr() const { + return _internal_metadata_.raw_arena_ptr(); + } public: ::google::protobuf::Metadata GetMetadata() const; @@ -7146,10 +7885,14 @@ class ReductionParameter : public ::google::protobuf::Message { // nested types ---------------------------------------------------- typedef ReductionParameter_ReductionOp ReductionOp; - static const ReductionOp SUM = ReductionParameter_ReductionOp_SUM; - static const ReductionOp ASUM = ReductionParameter_ReductionOp_ASUM; - static const ReductionOp SUMSQ = ReductionParameter_ReductionOp_SUMSQ; - static const ReductionOp MEAN = ReductionParameter_ReductionOp_MEAN; + static const ReductionOp SUM = + ReductionParameter_ReductionOp_SUM; + static const ReductionOp ASUM = + ReductionParameter_ReductionOp_ASUM; + static const ReductionOp SUMSQ = + ReductionParameter_ReductionOp_SUMSQ; + static const ReductionOp MEAN = + ReductionParameter_ReductionOp_MEAN; static inline bool ReductionOp_IsValid(int value) { return ReductionParameter_ReductionOp_IsValid(value); } @@ -7174,25 +7917,25 @@ class ReductionParameter : public ::google::protobuf::Message { // accessors ------------------------------------------------------- // optional .caffe.ReductionParameter.ReductionOp operation = 1 [default = SUM]; - inline bool has_operation() const; - inline void clear_operation(); + bool has_operation() const; + void clear_operation(); static const int kOperationFieldNumber = 1; - inline ::caffe::ReductionParameter_ReductionOp operation() const; - inline void set_operation(::caffe::ReductionParameter_ReductionOp value); + ::caffe::ReductionParameter_ReductionOp operation() const; + void set_operation(::caffe::ReductionParameter_ReductionOp value); // optional int32 axis = 2 [default = 0]; - inline bool has_axis() const; - inline void clear_axis(); + bool has_axis() const; + void clear_axis(); static const int kAxisFieldNumber = 2; - inline ::google::protobuf::int32 axis() const; - inline void set_axis(::google::protobuf::int32 value); + ::google::protobuf::int32 axis() const; + void set_axis(::google::protobuf::int32 value); // optional float coeff = 3 [default = 1]; - inline bool has_coeff() const; - inline void clear_coeff(); + bool has_coeff() const; + void clear_coeff(); static const int kCoeffFieldNumber = 3; - inline float coeff() const; - inline void set_coeff(float value); + float coeff() const; + void set_coeff(float value); // @@protoc_insertion_point(class_scope:caffe.ReductionParameter) private: @@ -7203,25 +7946,24 @@ class ReductionParameter : public ::google::protobuf::Message { inline void set_has_coeff(); inline void clear_has_coeff(); - ::google::protobuf::UnknownFieldSet _unknown_fields_; - - int operation_; + ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_; + ::google::protobuf::internal::HasBits<1> _has_bits_; + mutable int _cached_size_; ::google::protobuf::int32 axis_; + int operation_; float coeff_; - - mutable int _cached_size_; - ::google::protobuf::uint32 _has_bits_[(3 + 31) / 32]; - - friend void protobuf_AddDesc_caffe_2eproto(); + friend void protobuf_InitDefaults_caffe_2eproto_impl(); + friend void protobuf_AddDesc_caffe_2eproto_impl(); friend void protobuf_AssignDesc_caffe_2eproto(); friend void protobuf_ShutdownFile_caffe_2eproto(); void InitAsDefaultInstance(); - static ReductionParameter* default_instance_; }; +extern ::google::protobuf::internal::ExplicitlyConstructed ReductionParameter_default_instance_; + // ------------------------------------------------------------------- -class ReLUParameter : public ::google::protobuf::Message { +class ReLUParameter : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:caffe.ReLUParameter) */ { public: ReLUParameter(); virtual ~ReLUParameter(); @@ -7234,21 +7976,25 @@ class ReLUParameter : public ::google::protobuf::Message { } inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const { - return _unknown_fields_; + return _internal_metadata_.unknown_fields(); } inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() { - return &_unknown_fields_; + return _internal_metadata_.mutable_unknown_fields(); } static const ::google::protobuf::Descriptor* descriptor(); static const ReLUParameter& default_instance(); + static const ReLUParameter* internal_default_instance(); + void Swap(ReLUParameter* other); // implements Message ---------------------------------------------- - ReLUParameter* New() const; + inline ReLUParameter* New() const { return New(NULL); } + + ReLUParameter* New(::google::protobuf::Arena* arena) const; void CopyFrom(const ::google::protobuf::Message& from); void MergeFrom(const ::google::protobuf::Message& from); void CopyFrom(const ReLUParameter& from); @@ -7256,17 +8002,30 @@ class ReLUParameter : public ::google::protobuf::Message { void Clear(); bool IsInitialized() const; - int ByteSize() const; + size_t ByteSizeLong() const; bool MergePartialFromCodedStream( ::google::protobuf::io::CodedInputStream* input); void SerializeWithCachedSizes( ::google::protobuf::io::CodedOutputStream* output) const; - ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const; + ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray( + bool deterministic, ::google::protobuf::uint8* output) const; + ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const { + return InternalSerializeWithCachedSizesToArray(false, output); + } int GetCachedSize() const { return _cached_size_; } private: void SharedCtor(); void SharedDtor(); void SetCachedSize(int size) const; + void InternalSwap(ReLUParameter* other); + void UnsafeMergeFrom(const ReLUParameter& from); + private: + inline ::google::protobuf::Arena* GetArenaNoVirtual() const { + return _internal_metadata_.arena(); + } + inline void* MaybeArenaPtr() const { + return _internal_metadata_.raw_arena_ptr(); + } public: ::google::protobuf::Metadata GetMetadata() const; @@ -7274,9 +8033,12 @@ class ReLUParameter : public ::google::protobuf::Message { // nested types ---------------------------------------------------- typedef ReLUParameter_Engine Engine; - static const Engine DEFAULT = ReLUParameter_Engine_DEFAULT; - static const Engine CAFFE = ReLUParameter_Engine_CAFFE; - static const Engine CUDNN = ReLUParameter_Engine_CUDNN; + static const Engine DEFAULT = + ReLUParameter_Engine_DEFAULT; + static const Engine CAFFE = + ReLUParameter_Engine_CAFFE; + static const Engine CUDNN = + ReLUParameter_Engine_CUDNN; static inline bool Engine_IsValid(int value) { return ReLUParameter_Engine_IsValid(value); } @@ -7301,18 +8063,18 @@ class ReLUParameter : public ::google::protobuf::Message { // accessors ------------------------------------------------------- // optional float negative_slope = 1 [default = 0]; - inline bool has_negative_slope() const; - inline void clear_negative_slope(); + bool has_negative_slope() const; + void clear_negative_slope(); static const int kNegativeSlopeFieldNumber = 1; - inline float negative_slope() const; - inline void set_negative_slope(float value); + float negative_slope() const; + void set_negative_slope(float value); // optional .caffe.ReLUParameter.Engine engine = 2 [default = DEFAULT]; - inline bool has_engine() const; - inline void clear_engine(); + bool has_engine() const; + void clear_engine(); static const int kEngineFieldNumber = 2; - inline ::caffe::ReLUParameter_Engine engine() const; - inline void set_engine(::caffe::ReLUParameter_Engine value); + ::caffe::ReLUParameter_Engine engine() const; + void set_engine(::caffe::ReLUParameter_Engine value); // @@protoc_insertion_point(class_scope:caffe.ReLUParameter) private: @@ -7321,24 +8083,23 @@ class ReLUParameter : public ::google::protobuf::Message { inline void set_has_engine(); inline void clear_has_engine(); - ::google::protobuf::UnknownFieldSet _unknown_fields_; - + ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_; + ::google::protobuf::internal::HasBits<1> _has_bits_; + mutable int _cached_size_; float negative_slope_; int engine_; - - mutable int _cached_size_; - ::google::protobuf::uint32 _has_bits_[(2 + 31) / 32]; - - friend void protobuf_AddDesc_caffe_2eproto(); + friend void protobuf_InitDefaults_caffe_2eproto_impl(); + friend void protobuf_AddDesc_caffe_2eproto_impl(); friend void protobuf_AssignDesc_caffe_2eproto(); friend void protobuf_ShutdownFile_caffe_2eproto(); void InitAsDefaultInstance(); - static ReLUParameter* default_instance_; }; +extern ::google::protobuf::internal::ExplicitlyConstructed ReLUParameter_default_instance_; + // ------------------------------------------------------------------- -class ReshapeParameter : public ::google::protobuf::Message { +class ReshapeParameter : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:caffe.ReshapeParameter) */ { public: ReshapeParameter(); virtual ~ReshapeParameter(); @@ -7351,21 +8112,25 @@ class ReshapeParameter : public ::google::protobuf::Message { } inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const { - return _unknown_fields_; + return _internal_metadata_.unknown_fields(); } inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() { - return &_unknown_fields_; + return _internal_metadata_.mutable_unknown_fields(); } static const ::google::protobuf::Descriptor* descriptor(); static const ReshapeParameter& default_instance(); + static const ReshapeParameter* internal_default_instance(); + void Swap(ReshapeParameter* other); // implements Message ---------------------------------------------- - ReshapeParameter* New() const; + inline ReshapeParameter* New() const { return New(NULL); } + + ReshapeParameter* New(::google::protobuf::Arena* arena) const; void CopyFrom(const ::google::protobuf::Message& from); void MergeFrom(const ::google::protobuf::Message& from); void CopyFrom(const ReshapeParameter& from); @@ -7373,17 +8138,30 @@ class ReshapeParameter : public ::google::protobuf::Message { void Clear(); bool IsInitialized() const; - int ByteSize() const; + size_t ByteSizeLong() const; bool MergePartialFromCodedStream( ::google::protobuf::io::CodedInputStream* input); void SerializeWithCachedSizes( ::google::protobuf::io::CodedOutputStream* output) const; - ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const; + ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray( + bool deterministic, ::google::protobuf::uint8* output) const; + ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const { + return InternalSerializeWithCachedSizesToArray(false, output); + } int GetCachedSize() const { return _cached_size_; } private: void SharedCtor(); void SharedDtor(); void SetCachedSize(int size) const; + void InternalSwap(ReshapeParameter* other); + void UnsafeMergeFrom(const ReshapeParameter& from); + private: + inline ::google::protobuf::Arena* GetArenaNoVirtual() const { + return _internal_metadata_.arena(); + } + inline void* MaybeArenaPtr() const { + return _internal_metadata_.raw_arena_ptr(); + } public: ::google::protobuf::Metadata GetMetadata() const; @@ -7393,27 +8171,27 @@ class ReshapeParameter : public ::google::protobuf::Message { // accessors ------------------------------------------------------- // optional .caffe.BlobShape shape = 1; - inline bool has_shape() const; - inline void clear_shape(); + bool has_shape() const; + void clear_shape(); static const int kShapeFieldNumber = 1; - inline const ::caffe::BlobShape& shape() const; - inline ::caffe::BlobShape* mutable_shape(); - inline ::caffe::BlobShape* release_shape(); - inline void set_allocated_shape(::caffe::BlobShape* shape); + const ::caffe::BlobShape& shape() const; + ::caffe::BlobShape* mutable_shape(); + ::caffe::BlobShape* release_shape(); + void set_allocated_shape(::caffe::BlobShape* shape); // optional int32 axis = 2 [default = 0]; - inline bool has_axis() const; - inline void clear_axis(); + bool has_axis() const; + void clear_axis(); static const int kAxisFieldNumber = 2; - inline ::google::protobuf::int32 axis() const; - inline void set_axis(::google::protobuf::int32 value); + ::google::protobuf::int32 axis() const; + void set_axis(::google::protobuf::int32 value); // optional int32 num_axes = 3 [default = -1]; - inline bool has_num_axes() const; - inline void clear_num_axes(); + bool has_num_axes() const; + void clear_num_axes(); static const int kNumAxesFieldNumber = 3; - inline ::google::protobuf::int32 num_axes() const; - inline void set_num_axes(::google::protobuf::int32 value); + ::google::protobuf::int32 num_axes() const; + void set_num_axes(::google::protobuf::int32 value); // @@protoc_insertion_point(class_scope:caffe.ReshapeParameter) private: @@ -7424,25 +8202,24 @@ class ReshapeParameter : public ::google::protobuf::Message { inline void set_has_num_axes(); inline void clear_has_num_axes(); - ::google::protobuf::UnknownFieldSet _unknown_fields_; - + ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_; + ::google::protobuf::internal::HasBits<1> _has_bits_; + mutable int _cached_size_; ::caffe::BlobShape* shape_; ::google::protobuf::int32 axis_; ::google::protobuf::int32 num_axes_; - - mutable int _cached_size_; - ::google::protobuf::uint32 _has_bits_[(3 + 31) / 32]; - - friend void protobuf_AddDesc_caffe_2eproto(); + friend void protobuf_InitDefaults_caffe_2eproto_impl(); + friend void protobuf_AddDesc_caffe_2eproto_impl(); friend void protobuf_AssignDesc_caffe_2eproto(); friend void protobuf_ShutdownFile_caffe_2eproto(); void InitAsDefaultInstance(); - static ReshapeParameter* default_instance_; }; +extern ::google::protobuf::internal::ExplicitlyConstructed ReshapeParameter_default_instance_; + // ------------------------------------------------------------------- -class SigmoidParameter : public ::google::protobuf::Message { +class SigmoidParameter : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:caffe.SigmoidParameter) */ { public: SigmoidParameter(); virtual ~SigmoidParameter(); @@ -7455,21 +8232,25 @@ class SigmoidParameter : public ::google::protobuf::Message { } inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const { - return _unknown_fields_; + return _internal_metadata_.unknown_fields(); } inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() { - return &_unknown_fields_; + return _internal_metadata_.mutable_unknown_fields(); } static const ::google::protobuf::Descriptor* descriptor(); static const SigmoidParameter& default_instance(); + static const SigmoidParameter* internal_default_instance(); + void Swap(SigmoidParameter* other); // implements Message ---------------------------------------------- - SigmoidParameter* New() const; + inline SigmoidParameter* New() const { return New(NULL); } + + SigmoidParameter* New(::google::protobuf::Arena* arena) const; void CopyFrom(const ::google::protobuf::Message& from); void MergeFrom(const ::google::protobuf::Message& from); void CopyFrom(const SigmoidParameter& from); @@ -7477,17 +8258,30 @@ class SigmoidParameter : public ::google::protobuf::Message { void Clear(); bool IsInitialized() const; - int ByteSize() const; + size_t ByteSizeLong() const; bool MergePartialFromCodedStream( ::google::protobuf::io::CodedInputStream* input); void SerializeWithCachedSizes( ::google::protobuf::io::CodedOutputStream* output) const; - ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const; + ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray( + bool deterministic, ::google::protobuf::uint8* output) const; + ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const { + return InternalSerializeWithCachedSizesToArray(false, output); + } int GetCachedSize() const { return _cached_size_; } private: void SharedCtor(); void SharedDtor(); void SetCachedSize(int size) const; + void InternalSwap(SigmoidParameter* other); + void UnsafeMergeFrom(const SigmoidParameter& from); + private: + inline ::google::protobuf::Arena* GetArenaNoVirtual() const { + return _internal_metadata_.arena(); + } + inline void* MaybeArenaPtr() const { + return _internal_metadata_.raw_arena_ptr(); + } public: ::google::protobuf::Metadata GetMetadata() const; @@ -7495,9 +8289,12 @@ class SigmoidParameter : public ::google::protobuf::Message { // nested types ---------------------------------------------------- typedef SigmoidParameter_Engine Engine; - static const Engine DEFAULT = SigmoidParameter_Engine_DEFAULT; - static const Engine CAFFE = SigmoidParameter_Engine_CAFFE; - static const Engine CUDNN = SigmoidParameter_Engine_CUDNN; + static const Engine DEFAULT = + SigmoidParameter_Engine_DEFAULT; + static const Engine CAFFE = + SigmoidParameter_Engine_CAFFE; + static const Engine CUDNN = + SigmoidParameter_Engine_CUDNN; static inline bool Engine_IsValid(int value) { return SigmoidParameter_Engine_IsValid(value); } @@ -7522,34 +8319,33 @@ class SigmoidParameter : public ::google::protobuf::Message { // accessors ------------------------------------------------------- // optional .caffe.SigmoidParameter.Engine engine = 1 [default = DEFAULT]; - inline bool has_engine() const; - inline void clear_engine(); + bool has_engine() const; + void clear_engine(); static const int kEngineFieldNumber = 1; - inline ::caffe::SigmoidParameter_Engine engine() const; - inline void set_engine(::caffe::SigmoidParameter_Engine value); + ::caffe::SigmoidParameter_Engine engine() const; + void set_engine(::caffe::SigmoidParameter_Engine value); // @@protoc_insertion_point(class_scope:caffe.SigmoidParameter) private: inline void set_has_engine(); inline void clear_has_engine(); - ::google::protobuf::UnknownFieldSet _unknown_fields_; - - int engine_; - + ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_; + ::google::protobuf::internal::HasBits<1> _has_bits_; mutable int _cached_size_; - ::google::protobuf::uint32 _has_bits_[(1 + 31) / 32]; - - friend void protobuf_AddDesc_caffe_2eproto(); + int engine_; + friend void protobuf_InitDefaults_caffe_2eproto_impl(); + friend void protobuf_AddDesc_caffe_2eproto_impl(); friend void protobuf_AssignDesc_caffe_2eproto(); friend void protobuf_ShutdownFile_caffe_2eproto(); void InitAsDefaultInstance(); - static SigmoidParameter* default_instance_; }; +extern ::google::protobuf::internal::ExplicitlyConstructed SigmoidParameter_default_instance_; + // ------------------------------------------------------------------- -class SliceParameter : public ::google::protobuf::Message { +class SliceParameter : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:caffe.SliceParameter) */ { public: SliceParameter(); virtual ~SliceParameter(); @@ -7562,21 +8358,25 @@ class SliceParameter : public ::google::protobuf::Message { } inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const { - return _unknown_fields_; + return _internal_metadata_.unknown_fields(); } inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() { - return &_unknown_fields_; + return _internal_metadata_.mutable_unknown_fields(); } static const ::google::protobuf::Descriptor* descriptor(); static const SliceParameter& default_instance(); + static const SliceParameter* internal_default_instance(); + void Swap(SliceParameter* other); // implements Message ---------------------------------------------- - SliceParameter* New() const; + inline SliceParameter* New() const { return New(NULL); } + + SliceParameter* New(::google::protobuf::Arena* arena) const; void CopyFrom(const ::google::protobuf::Message& from); void MergeFrom(const ::google::protobuf::Message& from); void CopyFrom(const SliceParameter& from); @@ -7584,17 +8384,30 @@ class SliceParameter : public ::google::protobuf::Message { void Clear(); bool IsInitialized() const; - int ByteSize() const; + size_t ByteSizeLong() const; bool MergePartialFromCodedStream( ::google::protobuf::io::CodedInputStream* input); void SerializeWithCachedSizes( ::google::protobuf::io::CodedOutputStream* output) const; - ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const; + ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray( + bool deterministic, ::google::protobuf::uint8* output) const; + ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const { + return InternalSerializeWithCachedSizesToArray(false, output); + } int GetCachedSize() const { return _cached_size_; } private: void SharedCtor(); void SharedDtor(); void SetCachedSize(int size) const; + void InternalSwap(SliceParameter* other); + void UnsafeMergeFrom(const SliceParameter& from); + private: + inline ::google::protobuf::Arena* GetArenaNoVirtual() const { + return _internal_metadata_.arena(); + } + inline void* MaybeArenaPtr() const { + return _internal_metadata_.raw_arena_ptr(); + } public: ::google::protobuf::Metadata GetMetadata() const; @@ -7604,30 +8417,30 @@ class SliceParameter : public ::google::protobuf::Message { // accessors ------------------------------------------------------- // optional int32 axis = 3 [default = 1]; - inline bool has_axis() const; - inline void clear_axis(); + bool has_axis() const; + void clear_axis(); static const int kAxisFieldNumber = 3; - inline ::google::protobuf::int32 axis() const; - inline void set_axis(::google::protobuf::int32 value); + ::google::protobuf::int32 axis() const; + void set_axis(::google::protobuf::int32 value); // repeated uint32 slice_point = 2; - inline int slice_point_size() const; - inline void clear_slice_point(); + int slice_point_size() const; + void clear_slice_point(); static const int kSlicePointFieldNumber = 2; - inline ::google::protobuf::uint32 slice_point(int index) const; - inline void set_slice_point(int index, ::google::protobuf::uint32 value); - inline void add_slice_point(::google::protobuf::uint32 value); - inline const ::google::protobuf::RepeatedField< ::google::protobuf::uint32 >& + ::google::protobuf::uint32 slice_point(int index) const; + void set_slice_point(int index, ::google::protobuf::uint32 value); + void add_slice_point(::google::protobuf::uint32 value); + const ::google::protobuf::RepeatedField< ::google::protobuf::uint32 >& slice_point() const; - inline ::google::protobuf::RepeatedField< ::google::protobuf::uint32 >* + ::google::protobuf::RepeatedField< ::google::protobuf::uint32 >* mutable_slice_point(); // optional uint32 slice_dim = 1 [default = 1]; - inline bool has_slice_dim() const; - inline void clear_slice_dim(); + bool has_slice_dim() const; + void clear_slice_dim(); static const int kSliceDimFieldNumber = 1; - inline ::google::protobuf::uint32 slice_dim() const; - inline void set_slice_dim(::google::protobuf::uint32 value); + ::google::protobuf::uint32 slice_dim() const; + void set_slice_dim(::google::protobuf::uint32 value); // @@protoc_insertion_point(class_scope:caffe.SliceParameter) private: @@ -7636,25 +8449,24 @@ class SliceParameter : public ::google::protobuf::Message { inline void set_has_slice_dim(); inline void clear_has_slice_dim(); - ::google::protobuf::UnknownFieldSet _unknown_fields_; - + ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_; + ::google::protobuf::internal::HasBits<1> _has_bits_; + mutable int _cached_size_; ::google::protobuf::RepeatedField< ::google::protobuf::uint32 > slice_point_; ::google::protobuf::int32 axis_; ::google::protobuf::uint32 slice_dim_; - - mutable int _cached_size_; - ::google::protobuf::uint32 _has_bits_[(3 + 31) / 32]; - - friend void protobuf_AddDesc_caffe_2eproto(); + friend void protobuf_InitDefaults_caffe_2eproto_impl(); + friend void protobuf_AddDesc_caffe_2eproto_impl(); friend void protobuf_AssignDesc_caffe_2eproto(); friend void protobuf_ShutdownFile_caffe_2eproto(); void InitAsDefaultInstance(); - static SliceParameter* default_instance_; }; +extern ::google::protobuf::internal::ExplicitlyConstructed SliceParameter_default_instance_; + // ------------------------------------------------------------------- -class SoftmaxParameter : public ::google::protobuf::Message { +class SoftmaxParameter : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:caffe.SoftmaxParameter) */ { public: SoftmaxParameter(); virtual ~SoftmaxParameter(); @@ -7667,21 +8479,25 @@ class SoftmaxParameter : public ::google::protobuf::Message { } inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const { - return _unknown_fields_; + return _internal_metadata_.unknown_fields(); } inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() { - return &_unknown_fields_; + return _internal_metadata_.mutable_unknown_fields(); } static const ::google::protobuf::Descriptor* descriptor(); static const SoftmaxParameter& default_instance(); + static const SoftmaxParameter* internal_default_instance(); + void Swap(SoftmaxParameter* other); // implements Message ---------------------------------------------- - SoftmaxParameter* New() const; + inline SoftmaxParameter* New() const { return New(NULL); } + + SoftmaxParameter* New(::google::protobuf::Arena* arena) const; void CopyFrom(const ::google::protobuf::Message& from); void MergeFrom(const ::google::protobuf::Message& from); void CopyFrom(const SoftmaxParameter& from); @@ -7689,17 +8505,30 @@ class SoftmaxParameter : public ::google::protobuf::Message { void Clear(); bool IsInitialized() const; - int ByteSize() const; + size_t ByteSizeLong() const; bool MergePartialFromCodedStream( ::google::protobuf::io::CodedInputStream* input); void SerializeWithCachedSizes( ::google::protobuf::io::CodedOutputStream* output) const; - ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const; + ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray( + bool deterministic, ::google::protobuf::uint8* output) const; + ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const { + return InternalSerializeWithCachedSizesToArray(false, output); + } int GetCachedSize() const { return _cached_size_; } private: void SharedCtor(); void SharedDtor(); void SetCachedSize(int size) const; + void InternalSwap(SoftmaxParameter* other); + void UnsafeMergeFrom(const SoftmaxParameter& from); + private: + inline ::google::protobuf::Arena* GetArenaNoVirtual() const { + return _internal_metadata_.arena(); + } + inline void* MaybeArenaPtr() const { + return _internal_metadata_.raw_arena_ptr(); + } public: ::google::protobuf::Metadata GetMetadata() const; @@ -7707,9 +8536,12 @@ class SoftmaxParameter : public ::google::protobuf::Message { // nested types ---------------------------------------------------- typedef SoftmaxParameter_Engine Engine; - static const Engine DEFAULT = SoftmaxParameter_Engine_DEFAULT; - static const Engine CAFFE = SoftmaxParameter_Engine_CAFFE; - static const Engine CUDNN = SoftmaxParameter_Engine_CUDNN; + static const Engine DEFAULT = + SoftmaxParameter_Engine_DEFAULT; + static const Engine CAFFE = + SoftmaxParameter_Engine_CAFFE; + static const Engine CUDNN = + SoftmaxParameter_Engine_CUDNN; static inline bool Engine_IsValid(int value) { return SoftmaxParameter_Engine_IsValid(value); } @@ -7734,18 +8566,18 @@ class SoftmaxParameter : public ::google::protobuf::Message { // accessors ------------------------------------------------------- // optional .caffe.SoftmaxParameter.Engine engine = 1 [default = DEFAULT]; - inline bool has_engine() const; - inline void clear_engine(); + bool has_engine() const; + void clear_engine(); static const int kEngineFieldNumber = 1; - inline ::caffe::SoftmaxParameter_Engine engine() const; - inline void set_engine(::caffe::SoftmaxParameter_Engine value); + ::caffe::SoftmaxParameter_Engine engine() const; + void set_engine(::caffe::SoftmaxParameter_Engine value); // optional int32 axis = 2 [default = 1]; - inline bool has_axis() const; - inline void clear_axis(); + bool has_axis() const; + void clear_axis(); static const int kAxisFieldNumber = 2; - inline ::google::protobuf::int32 axis() const; - inline void set_axis(::google::protobuf::int32 value); + ::google::protobuf::int32 axis() const; + void set_axis(::google::protobuf::int32 value); // @@protoc_insertion_point(class_scope:caffe.SoftmaxParameter) private: @@ -7754,24 +8586,23 @@ class SoftmaxParameter : public ::google::protobuf::Message { inline void set_has_axis(); inline void clear_has_axis(); - ::google::protobuf::UnknownFieldSet _unknown_fields_; - + ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_; + ::google::protobuf::internal::HasBits<1> _has_bits_; + mutable int _cached_size_; int engine_; ::google::protobuf::int32 axis_; - - mutable int _cached_size_; - ::google::protobuf::uint32 _has_bits_[(2 + 31) / 32]; - - friend void protobuf_AddDesc_caffe_2eproto(); + friend void protobuf_InitDefaults_caffe_2eproto_impl(); + friend void protobuf_AddDesc_caffe_2eproto_impl(); friend void protobuf_AssignDesc_caffe_2eproto(); friend void protobuf_ShutdownFile_caffe_2eproto(); void InitAsDefaultInstance(); - static SoftmaxParameter* default_instance_; }; +extern ::google::protobuf::internal::ExplicitlyConstructed SoftmaxParameter_default_instance_; + // ------------------------------------------------------------------- -class TanHParameter : public ::google::protobuf::Message { +class TanHParameter : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:caffe.TanHParameter) */ { public: TanHParameter(); virtual ~TanHParameter(); @@ -7784,21 +8615,25 @@ class TanHParameter : public ::google::protobuf::Message { } inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const { - return _unknown_fields_; + return _internal_metadata_.unknown_fields(); } inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() { - return &_unknown_fields_; + return _internal_metadata_.mutable_unknown_fields(); } static const ::google::protobuf::Descriptor* descriptor(); static const TanHParameter& default_instance(); + static const TanHParameter* internal_default_instance(); + void Swap(TanHParameter* other); // implements Message ---------------------------------------------- - TanHParameter* New() const; + inline TanHParameter* New() const { return New(NULL); } + + TanHParameter* New(::google::protobuf::Arena* arena) const; void CopyFrom(const ::google::protobuf::Message& from); void MergeFrom(const ::google::protobuf::Message& from); void CopyFrom(const TanHParameter& from); @@ -7806,17 +8641,30 @@ class TanHParameter : public ::google::protobuf::Message { void Clear(); bool IsInitialized() const; - int ByteSize() const; + size_t ByteSizeLong() const; bool MergePartialFromCodedStream( ::google::protobuf::io::CodedInputStream* input); void SerializeWithCachedSizes( ::google::protobuf::io::CodedOutputStream* output) const; - ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const; + ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray( + bool deterministic, ::google::protobuf::uint8* output) const; + ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const { + return InternalSerializeWithCachedSizesToArray(false, output); + } int GetCachedSize() const { return _cached_size_; } private: void SharedCtor(); void SharedDtor(); void SetCachedSize(int size) const; + void InternalSwap(TanHParameter* other); + void UnsafeMergeFrom(const TanHParameter& from); + private: + inline ::google::protobuf::Arena* GetArenaNoVirtual() const { + return _internal_metadata_.arena(); + } + inline void* MaybeArenaPtr() const { + return _internal_metadata_.raw_arena_ptr(); + } public: ::google::protobuf::Metadata GetMetadata() const; @@ -7824,9 +8672,12 @@ class TanHParameter : public ::google::protobuf::Message { // nested types ---------------------------------------------------- typedef TanHParameter_Engine Engine; - static const Engine DEFAULT = TanHParameter_Engine_DEFAULT; - static const Engine CAFFE = TanHParameter_Engine_CAFFE; - static const Engine CUDNN = TanHParameter_Engine_CUDNN; + static const Engine DEFAULT = + TanHParameter_Engine_DEFAULT; + static const Engine CAFFE = + TanHParameter_Engine_CAFFE; + static const Engine CUDNN = + TanHParameter_Engine_CUDNN; static inline bool Engine_IsValid(int value) { return TanHParameter_Engine_IsValid(value); } @@ -7851,34 +8702,33 @@ class TanHParameter : public ::google::protobuf::Message { // accessors ------------------------------------------------------- // optional .caffe.TanHParameter.Engine engine = 1 [default = DEFAULT]; - inline bool has_engine() const; - inline void clear_engine(); + bool has_engine() const; + void clear_engine(); static const int kEngineFieldNumber = 1; - inline ::caffe::TanHParameter_Engine engine() const; - inline void set_engine(::caffe::TanHParameter_Engine value); + ::caffe::TanHParameter_Engine engine() const; + void set_engine(::caffe::TanHParameter_Engine value); // @@protoc_insertion_point(class_scope:caffe.TanHParameter) private: inline void set_has_engine(); inline void clear_has_engine(); - ::google::protobuf::UnknownFieldSet _unknown_fields_; - - int engine_; - + ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_; + ::google::protobuf::internal::HasBits<1> _has_bits_; mutable int _cached_size_; - ::google::protobuf::uint32 _has_bits_[(1 + 31) / 32]; - - friend void protobuf_AddDesc_caffe_2eproto(); + int engine_; + friend void protobuf_InitDefaults_caffe_2eproto_impl(); + friend void protobuf_AddDesc_caffe_2eproto_impl(); friend void protobuf_AssignDesc_caffe_2eproto(); friend void protobuf_ShutdownFile_caffe_2eproto(); void InitAsDefaultInstance(); - static TanHParameter* default_instance_; }; +extern ::google::protobuf::internal::ExplicitlyConstructed TanHParameter_default_instance_; + // ------------------------------------------------------------------- -class ThresholdParameter : public ::google::protobuf::Message { +class ThresholdParameter : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:caffe.ThresholdParameter) */ { public: ThresholdParameter(); virtual ~ThresholdParameter(); @@ -7891,21 +8741,25 @@ class ThresholdParameter : public ::google::protobuf::Message { } inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const { - return _unknown_fields_; + return _internal_metadata_.unknown_fields(); } inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() { - return &_unknown_fields_; + return _internal_metadata_.mutable_unknown_fields(); } static const ::google::protobuf::Descriptor* descriptor(); static const ThresholdParameter& default_instance(); + static const ThresholdParameter* internal_default_instance(); + void Swap(ThresholdParameter* other); // implements Message ---------------------------------------------- - ThresholdParameter* New() const; + inline ThresholdParameter* New() const { return New(NULL); } + + ThresholdParameter* New(::google::protobuf::Arena* arena) const; void CopyFrom(const ::google::protobuf::Message& from); void MergeFrom(const ::google::protobuf::Message& from); void CopyFrom(const ThresholdParameter& from); @@ -7913,17 +8767,30 @@ class ThresholdParameter : public ::google::protobuf::Message { void Clear(); bool IsInitialized() const; - int ByteSize() const; + size_t ByteSizeLong() const; bool MergePartialFromCodedStream( ::google::protobuf::io::CodedInputStream* input); void SerializeWithCachedSizes( ::google::protobuf::io::CodedOutputStream* output) const; - ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const; + ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray( + bool deterministic, ::google::protobuf::uint8* output) const; + ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const { + return InternalSerializeWithCachedSizesToArray(false, output); + } int GetCachedSize() const { return _cached_size_; } private: void SharedCtor(); void SharedDtor(); void SetCachedSize(int size) const; + void InternalSwap(ThresholdParameter* other); + void UnsafeMergeFrom(const ThresholdParameter& from); + private: + inline ::google::protobuf::Arena* GetArenaNoVirtual() const { + return _internal_metadata_.arena(); + } + inline void* MaybeArenaPtr() const { + return _internal_metadata_.raw_arena_ptr(); + } public: ::google::protobuf::Metadata GetMetadata() const; @@ -7933,34 +8800,33 @@ class ThresholdParameter : public ::google::protobuf::Message { // accessors ------------------------------------------------------- // optional float threshold = 1 [default = 0]; - inline bool has_threshold() const; - inline void clear_threshold(); + bool has_threshold() const; + void clear_threshold(); static const int kThresholdFieldNumber = 1; - inline float threshold() const; - inline void set_threshold(float value); + float threshold() const; + void set_threshold(float value); // @@protoc_insertion_point(class_scope:caffe.ThresholdParameter) private: inline void set_has_threshold(); inline void clear_has_threshold(); - ::google::protobuf::UnknownFieldSet _unknown_fields_; - - float threshold_; - + ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_; + ::google::protobuf::internal::HasBits<1> _has_bits_; mutable int _cached_size_; - ::google::protobuf::uint32 _has_bits_[(1 + 31) / 32]; - - friend void protobuf_AddDesc_caffe_2eproto(); + float threshold_; + friend void protobuf_InitDefaults_caffe_2eproto_impl(); + friend void protobuf_AddDesc_caffe_2eproto_impl(); friend void protobuf_AssignDesc_caffe_2eproto(); friend void protobuf_ShutdownFile_caffe_2eproto(); void InitAsDefaultInstance(); - static ThresholdParameter* default_instance_; }; +extern ::google::protobuf::internal::ExplicitlyConstructed ThresholdParameter_default_instance_; + // ------------------------------------------------------------------- -class WindowDataParameter : public ::google::protobuf::Message { +class WindowDataParameter : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:caffe.WindowDataParameter) */ { public: WindowDataParameter(); virtual ~WindowDataParameter(); @@ -7973,21 +8839,25 @@ class WindowDataParameter : public ::google::protobuf::Message { } inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const { - return _unknown_fields_; + return _internal_metadata_.unknown_fields(); } inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() { - return &_unknown_fields_; + return _internal_metadata_.mutable_unknown_fields(); } static const ::google::protobuf::Descriptor* descriptor(); static const WindowDataParameter& default_instance(); + static const WindowDataParameter* internal_default_instance(); + void Swap(WindowDataParameter* other); // implements Message ---------------------------------------------- - WindowDataParameter* New() const; + inline WindowDataParameter* New() const { return New(NULL); } + + WindowDataParameter* New(::google::protobuf::Arena* arena) const; void CopyFrom(const ::google::protobuf::Message& from); void MergeFrom(const ::google::protobuf::Message& from); void CopyFrom(const WindowDataParameter& from); @@ -7995,17 +8865,30 @@ class WindowDataParameter : public ::google::protobuf::Message { void Clear(); bool IsInitialized() const; - int ByteSize() const; + size_t ByteSizeLong() const; bool MergePartialFromCodedStream( ::google::protobuf::io::CodedInputStream* input); void SerializeWithCachedSizes( ::google::protobuf::io::CodedOutputStream* output) const; - ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const; + ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray( + bool deterministic, ::google::protobuf::uint8* output) const; + ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const { + return InternalSerializeWithCachedSizesToArray(false, output); + } int GetCachedSize() const { return _cached_size_; } private: void SharedCtor(); void SharedDtor(); void SetCachedSize(int size) const; + void InternalSwap(WindowDataParameter* other); + void UnsafeMergeFrom(const WindowDataParameter& from); + private: + inline ::google::protobuf::Arena* GetArenaNoVirtual() const { + return _internal_metadata_.arena(); + } + inline void* MaybeArenaPtr() const { + return _internal_metadata_.raw_arena_ptr(); + } public: ::google::protobuf::Metadata GetMetadata() const; @@ -8015,115 +8898,115 @@ class WindowDataParameter : public ::google::protobuf::Message { // accessors ------------------------------------------------------- // optional string source = 1; - inline bool has_source() const; - inline void clear_source(); + bool has_source() const; + void clear_source(); static const int kSourceFieldNumber = 1; - inline const ::std::string& source() const; - inline void set_source(const ::std::string& value); - inline void set_source(const char* value); - inline void set_source(const char* value, size_t size); - inline ::std::string* mutable_source(); - inline ::std::string* release_source(); - inline void set_allocated_source(::std::string* source); + const ::std::string& source() const; + void set_source(const ::std::string& value); + void set_source(const char* value); + void set_source(const char* value, size_t size); + ::std::string* mutable_source(); + ::std::string* release_source(); + void set_allocated_source(::std::string* source); // optional float scale = 2 [default = 1]; - inline bool has_scale() const; - inline void clear_scale(); + bool has_scale() const; + void clear_scale(); static const int kScaleFieldNumber = 2; - inline float scale() const; - inline void set_scale(float value); + float scale() const; + void set_scale(float value); // optional string mean_file = 3; - inline bool has_mean_file() const; - inline void clear_mean_file(); + bool has_mean_file() const; + void clear_mean_file(); static const int kMeanFileFieldNumber = 3; - inline const ::std::string& mean_file() const; - inline void set_mean_file(const ::std::string& value); - inline void set_mean_file(const char* value); - inline void set_mean_file(const char* value, size_t size); - inline ::std::string* mutable_mean_file(); - inline ::std::string* release_mean_file(); - inline void set_allocated_mean_file(::std::string* mean_file); + const ::std::string& mean_file() const; + void set_mean_file(const ::std::string& value); + void set_mean_file(const char* value); + void set_mean_file(const char* value, size_t size); + ::std::string* mutable_mean_file(); + ::std::string* release_mean_file(); + void set_allocated_mean_file(::std::string* mean_file); // optional uint32 batch_size = 4; - inline bool has_batch_size() const; - inline void clear_batch_size(); + bool has_batch_size() const; + void clear_batch_size(); static const int kBatchSizeFieldNumber = 4; - inline ::google::protobuf::uint32 batch_size() const; - inline void set_batch_size(::google::protobuf::uint32 value); + ::google::protobuf::uint32 batch_size() const; + void set_batch_size(::google::protobuf::uint32 value); // optional uint32 crop_size = 5 [default = 0]; - inline bool has_crop_size() const; - inline void clear_crop_size(); + bool has_crop_size() const; + void clear_crop_size(); static const int kCropSizeFieldNumber = 5; - inline ::google::protobuf::uint32 crop_size() const; - inline void set_crop_size(::google::protobuf::uint32 value); + ::google::protobuf::uint32 crop_size() const; + void set_crop_size(::google::protobuf::uint32 value); // optional bool mirror = 6 [default = false]; - inline bool has_mirror() const; - inline void clear_mirror(); + bool has_mirror() const; + void clear_mirror(); static const int kMirrorFieldNumber = 6; - inline bool mirror() const; - inline void set_mirror(bool value); + bool mirror() const; + void set_mirror(bool value); // optional float fg_threshold = 7 [default = 0.5]; - inline bool has_fg_threshold() const; - inline void clear_fg_threshold(); + bool has_fg_threshold() const; + void clear_fg_threshold(); static const int kFgThresholdFieldNumber = 7; - inline float fg_threshold() const; - inline void set_fg_threshold(float value); + float fg_threshold() const; + void set_fg_threshold(float value); // optional float bg_threshold = 8 [default = 0.5]; - inline bool has_bg_threshold() const; - inline void clear_bg_threshold(); + bool has_bg_threshold() const; + void clear_bg_threshold(); static const int kBgThresholdFieldNumber = 8; - inline float bg_threshold() const; - inline void set_bg_threshold(float value); + float bg_threshold() const; + void set_bg_threshold(float value); // optional float fg_fraction = 9 [default = 0.25]; - inline bool has_fg_fraction() const; - inline void clear_fg_fraction(); + bool has_fg_fraction() const; + void clear_fg_fraction(); static const int kFgFractionFieldNumber = 9; - inline float fg_fraction() const; - inline void set_fg_fraction(float value); + float fg_fraction() const; + void set_fg_fraction(float value); // optional uint32 context_pad = 10 [default = 0]; - inline bool has_context_pad() const; - inline void clear_context_pad(); + bool has_context_pad() const; + void clear_context_pad(); static const int kContextPadFieldNumber = 10; - inline ::google::protobuf::uint32 context_pad() const; - inline void set_context_pad(::google::protobuf::uint32 value); + ::google::protobuf::uint32 context_pad() const; + void set_context_pad(::google::protobuf::uint32 value); // optional string crop_mode = 11 [default = "warp"]; - inline bool has_crop_mode() const; - inline void clear_crop_mode(); + bool has_crop_mode() const; + void clear_crop_mode(); static const int kCropModeFieldNumber = 11; - inline const ::std::string& crop_mode() const; - inline void set_crop_mode(const ::std::string& value); - inline void set_crop_mode(const char* value); - inline void set_crop_mode(const char* value, size_t size); - inline ::std::string* mutable_crop_mode(); - inline ::std::string* release_crop_mode(); - inline void set_allocated_crop_mode(::std::string* crop_mode); + const ::std::string& crop_mode() const; + void set_crop_mode(const ::std::string& value); + void set_crop_mode(const char* value); + void set_crop_mode(const char* value, size_t size); + ::std::string* mutable_crop_mode(); + ::std::string* release_crop_mode(); + void set_allocated_crop_mode(::std::string* crop_mode); // optional bool cache_images = 12 [default = false]; - inline bool has_cache_images() const; - inline void clear_cache_images(); + bool has_cache_images() const; + void clear_cache_images(); static const int kCacheImagesFieldNumber = 12; - inline bool cache_images() const; - inline void set_cache_images(bool value); + bool cache_images() const; + void set_cache_images(bool value); // optional string root_folder = 13 [default = ""]; - inline bool has_root_folder() const; - inline void clear_root_folder(); + bool has_root_folder() const; + void clear_root_folder(); static const int kRootFolderFieldNumber = 13; - inline const ::std::string& root_folder() const; - inline void set_root_folder(const ::std::string& value); - inline void set_root_folder(const char* value); - inline void set_root_folder(const char* value, size_t size); - inline ::std::string* mutable_root_folder(); - inline ::std::string* release_root_folder(); - inline void set_allocated_root_folder(::std::string* root_folder); + const ::std::string& root_folder() const; + void set_root_folder(const ::std::string& value); + void set_root_folder(const char* value); + void set_root_folder(const char* value, size_t size); + ::std::string* mutable_root_folder(); + ::std::string* release_root_folder(); + void set_allocated_root_folder(::std::string* root_folder); // @@protoc_insertion_point(class_scope:caffe.WindowDataParameter) private: @@ -8154,36 +9037,35 @@ class WindowDataParameter : public ::google::protobuf::Message { inline void set_has_root_folder(); inline void clear_has_root_folder(); - ::google::protobuf::UnknownFieldSet _unknown_fields_; - - ::std::string* source_; - ::std::string* mean_file_; - float scale_; + ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_; + ::google::protobuf::internal::HasBits<1> _has_bits_; + mutable int _cached_size_; + ::google::protobuf::internal::ArenaStringPtr source_; + ::google::protobuf::internal::ArenaStringPtr mean_file_; + static ::std::string* _default_crop_mode_; + ::google::protobuf::internal::ArenaStringPtr crop_mode_; + ::google::protobuf::internal::ArenaStringPtr root_folder_; ::google::protobuf::uint32 batch_size_; ::google::protobuf::uint32 crop_size_; - float fg_threshold_; - float bg_threshold_; - float fg_fraction_; bool mirror_; bool cache_images_; ::google::protobuf::uint32 context_pad_; - ::std::string* crop_mode_; - static ::std::string* _default_crop_mode_; - ::std::string* root_folder_; - - mutable int _cached_size_; - ::google::protobuf::uint32 _has_bits_[(13 + 31) / 32]; - - friend void protobuf_AddDesc_caffe_2eproto(); + float scale_; + float fg_threshold_; + float bg_threshold_; + float fg_fraction_; + friend void protobuf_InitDefaults_caffe_2eproto_impl(); + friend void protobuf_AddDesc_caffe_2eproto_impl(); friend void protobuf_AssignDesc_caffe_2eproto(); friend void protobuf_ShutdownFile_caffe_2eproto(); void InitAsDefaultInstance(); - static WindowDataParameter* default_instance_; }; +extern ::google::protobuf::internal::ExplicitlyConstructed WindowDataParameter_default_instance_; + // ------------------------------------------------------------------- -class SPPParameter : public ::google::protobuf::Message { +class SPPParameter : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:caffe.SPPParameter) */ { public: SPPParameter(); virtual ~SPPParameter(); @@ -8196,21 +9078,25 @@ class SPPParameter : public ::google::protobuf::Message { } inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const { - return _unknown_fields_; + return _internal_metadata_.unknown_fields(); } inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() { - return &_unknown_fields_; + return _internal_metadata_.mutable_unknown_fields(); } static const ::google::protobuf::Descriptor* descriptor(); static const SPPParameter& default_instance(); + static const SPPParameter* internal_default_instance(); + void Swap(SPPParameter* other); // implements Message ---------------------------------------------- - SPPParameter* New() const; + inline SPPParameter* New() const { return New(NULL); } + + SPPParameter* New(::google::protobuf::Arena* arena) const; void CopyFrom(const ::google::protobuf::Message& from); void MergeFrom(const ::google::protobuf::Message& from); void CopyFrom(const SPPParameter& from); @@ -8218,17 +9104,30 @@ class SPPParameter : public ::google::protobuf::Message { void Clear(); bool IsInitialized() const; - int ByteSize() const; + size_t ByteSizeLong() const; bool MergePartialFromCodedStream( ::google::protobuf::io::CodedInputStream* input); void SerializeWithCachedSizes( ::google::protobuf::io::CodedOutputStream* output) const; - ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const; + ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray( + bool deterministic, ::google::protobuf::uint8* output) const; + ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const { + return InternalSerializeWithCachedSizesToArray(false, output); + } int GetCachedSize() const { return _cached_size_; } private: void SharedCtor(); void SharedDtor(); void SetCachedSize(int size) const; + void InternalSwap(SPPParameter* other); + void UnsafeMergeFrom(const SPPParameter& from); + private: + inline ::google::protobuf::Arena* GetArenaNoVirtual() const { + return _internal_metadata_.arena(); + } + inline void* MaybeArenaPtr() const { + return _internal_metadata_.raw_arena_ptr(); + } public: ::google::protobuf::Metadata GetMetadata() const; @@ -8236,9 +9135,12 @@ class SPPParameter : public ::google::protobuf::Message { // nested types ---------------------------------------------------- typedef SPPParameter_PoolMethod PoolMethod; - static const PoolMethod MAX = SPPParameter_PoolMethod_MAX; - static const PoolMethod AVE = SPPParameter_PoolMethod_AVE; - static const PoolMethod STOCHASTIC = SPPParameter_PoolMethod_STOCHASTIC; + static const PoolMethod MAX = + SPPParameter_PoolMethod_MAX; + static const PoolMethod AVE = + SPPParameter_PoolMethod_AVE; + static const PoolMethod STOCHASTIC = + SPPParameter_PoolMethod_STOCHASTIC; static inline bool PoolMethod_IsValid(int value) { return SPPParameter_PoolMethod_IsValid(value); } @@ -8261,9 +9163,12 @@ class SPPParameter : public ::google::protobuf::Message { } typedef SPPParameter_Engine Engine; - static const Engine DEFAULT = SPPParameter_Engine_DEFAULT; - static const Engine CAFFE = SPPParameter_Engine_CAFFE; - static const Engine CUDNN = SPPParameter_Engine_CUDNN; + static const Engine DEFAULT = + SPPParameter_Engine_DEFAULT; + static const Engine CAFFE = + SPPParameter_Engine_CAFFE; + static const Engine CUDNN = + SPPParameter_Engine_CUDNN; static inline bool Engine_IsValid(int value) { return SPPParameter_Engine_IsValid(value); } @@ -8288,25 +9193,25 @@ class SPPParameter : public ::google::protobuf::Message { // accessors ------------------------------------------------------- // optional uint32 pyramid_height = 1; - inline bool has_pyramid_height() const; - inline void clear_pyramid_height(); + bool has_pyramid_height() const; + void clear_pyramid_height(); static const int kPyramidHeightFieldNumber = 1; - inline ::google::protobuf::uint32 pyramid_height() const; - inline void set_pyramid_height(::google::protobuf::uint32 value); + ::google::protobuf::uint32 pyramid_height() const; + void set_pyramid_height(::google::protobuf::uint32 value); // optional .caffe.SPPParameter.PoolMethod pool = 2 [default = MAX]; - inline bool has_pool() const; - inline void clear_pool(); + bool has_pool() const; + void clear_pool(); static const int kPoolFieldNumber = 2; - inline ::caffe::SPPParameter_PoolMethod pool() const; - inline void set_pool(::caffe::SPPParameter_PoolMethod value); + ::caffe::SPPParameter_PoolMethod pool() const; + void set_pool(::caffe::SPPParameter_PoolMethod value); // optional .caffe.SPPParameter.Engine engine = 6 [default = DEFAULT]; - inline bool has_engine() const; - inline void clear_engine(); + bool has_engine() const; + void clear_engine(); static const int kEngineFieldNumber = 6; - inline ::caffe::SPPParameter_Engine engine() const; - inline void set_engine(::caffe::SPPParameter_Engine value); + ::caffe::SPPParameter_Engine engine() const; + void set_engine(::caffe::SPPParameter_Engine value); // @@protoc_insertion_point(class_scope:caffe.SPPParameter) private: @@ -8317,25 +9222,24 @@ class SPPParameter : public ::google::protobuf::Message { inline void set_has_engine(); inline void clear_has_engine(); - ::google::protobuf::UnknownFieldSet _unknown_fields_; - + ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_; + ::google::protobuf::internal::HasBits<1> _has_bits_; + mutable int _cached_size_; ::google::protobuf::uint32 pyramid_height_; int pool_; int engine_; - - mutable int _cached_size_; - ::google::protobuf::uint32 _has_bits_[(3 + 31) / 32]; - - friend void protobuf_AddDesc_caffe_2eproto(); + friend void protobuf_InitDefaults_caffe_2eproto_impl(); + friend void protobuf_AddDesc_caffe_2eproto_impl(); friend void protobuf_AssignDesc_caffe_2eproto(); friend void protobuf_ShutdownFile_caffe_2eproto(); void InitAsDefaultInstance(); - static SPPParameter* default_instance_; }; +extern ::google::protobuf::internal::ExplicitlyConstructed SPPParameter_default_instance_; + // ------------------------------------------------------------------- -class V1LayerParameter : public ::google::protobuf::Message { +class V1LayerParameter : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:caffe.V1LayerParameter) */ { public: V1LayerParameter(); virtual ~V1LayerParameter(); @@ -8348,21 +9252,25 @@ class V1LayerParameter : public ::google::protobuf::Message { } inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const { - return _unknown_fields_; + return _internal_metadata_.unknown_fields(); } inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() { - return &_unknown_fields_; + return _internal_metadata_.mutable_unknown_fields(); } static const ::google::protobuf::Descriptor* descriptor(); static const V1LayerParameter& default_instance(); + static const V1LayerParameter* internal_default_instance(); + void Swap(V1LayerParameter* other); // implements Message ---------------------------------------------- - V1LayerParameter* New() const; + inline V1LayerParameter* New() const { return New(NULL); } + + V1LayerParameter* New(::google::protobuf::Arena* arena) const; void CopyFrom(const ::google::protobuf::Message& from); void MergeFrom(const ::google::protobuf::Message& from); void CopyFrom(const V1LayerParameter& from); @@ -8370,17 +9278,30 @@ class V1LayerParameter : public ::google::protobuf::Message { void Clear(); bool IsInitialized() const; - int ByteSize() const; + size_t ByteSizeLong() const; bool MergePartialFromCodedStream( ::google::protobuf::io::CodedInputStream* input); void SerializeWithCachedSizes( ::google::protobuf::io::CodedOutputStream* output) const; - ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const; + ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray( + bool deterministic, ::google::protobuf::uint8* output) const; + ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const { + return InternalSerializeWithCachedSizesToArray(false, output); + } int GetCachedSize() const { return _cached_size_; } private: void SharedCtor(); void SharedDtor(); void SetCachedSize(int size) const; + void InternalSwap(V1LayerParameter* other); + void UnsafeMergeFrom(const V1LayerParameter& from); + private: + inline ::google::protobuf::Arena* GetArenaNoVirtual() const { + return _internal_metadata_.arena(); + } + inline void* MaybeArenaPtr() const { + return _internal_metadata_.raw_arena_ptr(); + } public: ::google::protobuf::Metadata GetMetadata() const; @@ -8388,46 +9309,86 @@ class V1LayerParameter : public ::google::protobuf::Message { // nested types ---------------------------------------------------- typedef V1LayerParameter_LayerType LayerType; - static const LayerType NONE = V1LayerParameter_LayerType_NONE; - static const LayerType ABSVAL = V1LayerParameter_LayerType_ABSVAL; - static const LayerType ACCURACY = V1LayerParameter_LayerType_ACCURACY; - static const LayerType ARGMAX = V1LayerParameter_LayerType_ARGMAX; - static const LayerType BNLL = V1LayerParameter_LayerType_BNLL; - static const LayerType CONCAT = V1LayerParameter_LayerType_CONCAT; - static const LayerType CONTRASTIVE_LOSS = V1LayerParameter_LayerType_CONTRASTIVE_LOSS; - static const LayerType CONVOLUTION = V1LayerParameter_LayerType_CONVOLUTION; - static const LayerType DATA = V1LayerParameter_LayerType_DATA; - static const LayerType DECONVOLUTION = V1LayerParameter_LayerType_DECONVOLUTION; - static const LayerType DROPOUT = V1LayerParameter_LayerType_DROPOUT; - static const LayerType DUMMY_DATA = V1LayerParameter_LayerType_DUMMY_DATA; - static const LayerType EUCLIDEAN_LOSS = V1LayerParameter_LayerType_EUCLIDEAN_LOSS; - static const LayerType ELTWISE = V1LayerParameter_LayerType_ELTWISE; - static const LayerType EXP = V1LayerParameter_LayerType_EXP; - static const LayerType FLATTEN = V1LayerParameter_LayerType_FLATTEN; - static const LayerType HDF5_DATA = V1LayerParameter_LayerType_HDF5_DATA; - static const LayerType HDF5_OUTPUT = V1LayerParameter_LayerType_HDF5_OUTPUT; - static const LayerType HINGE_LOSS = V1LayerParameter_LayerType_HINGE_LOSS; - static const LayerType IM2COL = V1LayerParameter_LayerType_IM2COL; - static const LayerType IMAGE_DATA = V1LayerParameter_LayerType_IMAGE_DATA; - static const LayerType INFOGAIN_LOSS = V1LayerParameter_LayerType_INFOGAIN_LOSS; - static const LayerType INNER_PRODUCT = V1LayerParameter_LayerType_INNER_PRODUCT; - static const LayerType LRN = V1LayerParameter_LayerType_LRN; - static const LayerType MEMORY_DATA = V1LayerParameter_LayerType_MEMORY_DATA; - static const LayerType MULTINOMIAL_LOGISTIC_LOSS = V1LayerParameter_LayerType_MULTINOMIAL_LOGISTIC_LOSS; - static const LayerType MVN = V1LayerParameter_LayerType_MVN; - static const LayerType POOLING = V1LayerParameter_LayerType_POOLING; - static const LayerType POWER = V1LayerParameter_LayerType_POWER; - static const LayerType RELU = V1LayerParameter_LayerType_RELU; - static const LayerType SIGMOID = V1LayerParameter_LayerType_SIGMOID; - static const LayerType SIGMOID_CROSS_ENTROPY_LOSS = V1LayerParameter_LayerType_SIGMOID_CROSS_ENTROPY_LOSS; - static const LayerType SILENCE = V1LayerParameter_LayerType_SILENCE; - static const LayerType SOFTMAX = V1LayerParameter_LayerType_SOFTMAX; - static const LayerType SOFTMAX_LOSS = V1LayerParameter_LayerType_SOFTMAX_LOSS; - static const LayerType SPLIT = V1LayerParameter_LayerType_SPLIT; - static const LayerType SLICE = V1LayerParameter_LayerType_SLICE; - static const LayerType TANH = V1LayerParameter_LayerType_TANH; - static const LayerType WINDOW_DATA = V1LayerParameter_LayerType_WINDOW_DATA; - static const LayerType THRESHOLD = V1LayerParameter_LayerType_THRESHOLD; + static const LayerType NONE = + V1LayerParameter_LayerType_NONE; + static const LayerType ABSVAL = + V1LayerParameter_LayerType_ABSVAL; + static const LayerType ACCURACY = + V1LayerParameter_LayerType_ACCURACY; + static const LayerType ARGMAX = + V1LayerParameter_LayerType_ARGMAX; + static const LayerType BNLL = + V1LayerParameter_LayerType_BNLL; + static const LayerType CONCAT = + V1LayerParameter_LayerType_CONCAT; + static const LayerType CONTRASTIVE_LOSS = + V1LayerParameter_LayerType_CONTRASTIVE_LOSS; + static const LayerType CONVOLUTION = + V1LayerParameter_LayerType_CONVOLUTION; + static const LayerType DATA = + V1LayerParameter_LayerType_DATA; + static const LayerType DECONVOLUTION = + V1LayerParameter_LayerType_DECONVOLUTION; + static const LayerType DROPOUT = + V1LayerParameter_LayerType_DROPOUT; + static const LayerType DUMMY_DATA = + V1LayerParameter_LayerType_DUMMY_DATA; + static const LayerType EUCLIDEAN_LOSS = + V1LayerParameter_LayerType_EUCLIDEAN_LOSS; + static const LayerType ELTWISE = + V1LayerParameter_LayerType_ELTWISE; + static const LayerType EXP = + V1LayerParameter_LayerType_EXP; + static const LayerType FLATTEN = + V1LayerParameter_LayerType_FLATTEN; + static const LayerType HDF5_DATA = + V1LayerParameter_LayerType_HDF5_DATA; + static const LayerType HDF5_OUTPUT = + V1LayerParameter_LayerType_HDF5_OUTPUT; + static const LayerType HINGE_LOSS = + V1LayerParameter_LayerType_HINGE_LOSS; + static const LayerType IM2COL = + V1LayerParameter_LayerType_IM2COL; + static const LayerType IMAGE_DATA = + V1LayerParameter_LayerType_IMAGE_DATA; + static const LayerType INFOGAIN_LOSS = + V1LayerParameter_LayerType_INFOGAIN_LOSS; + static const LayerType INNER_PRODUCT = + V1LayerParameter_LayerType_INNER_PRODUCT; + static const LayerType LRN = + V1LayerParameter_LayerType_LRN; + static const LayerType MEMORY_DATA = + V1LayerParameter_LayerType_MEMORY_DATA; + static const LayerType MULTINOMIAL_LOGISTIC_LOSS = + V1LayerParameter_LayerType_MULTINOMIAL_LOGISTIC_LOSS; + static const LayerType MVN = + V1LayerParameter_LayerType_MVN; + static const LayerType POOLING = + V1LayerParameter_LayerType_POOLING; + static const LayerType POWER = + V1LayerParameter_LayerType_POWER; + static const LayerType RELU = + V1LayerParameter_LayerType_RELU; + static const LayerType SIGMOID = + V1LayerParameter_LayerType_SIGMOID; + static const LayerType SIGMOID_CROSS_ENTROPY_LOSS = + V1LayerParameter_LayerType_SIGMOID_CROSS_ENTROPY_LOSS; + static const LayerType SILENCE = + V1LayerParameter_LayerType_SILENCE; + static const LayerType SOFTMAX = + V1LayerParameter_LayerType_SOFTMAX; + static const LayerType SOFTMAX_LOSS = + V1LayerParameter_LayerType_SOFTMAX_LOSS; + static const LayerType SPLIT = + V1LayerParameter_LayerType_SPLIT; + static const LayerType SLICE = + V1LayerParameter_LayerType_SLICE; + static const LayerType TANH = + V1LayerParameter_LayerType_TANH; + static const LayerType WINDOW_DATA = + V1LayerParameter_LayerType_WINDOW_DATA; + static const LayerType THRESHOLD = + V1LayerParameter_LayerType_THRESHOLD; static inline bool LayerType_IsValid(int value) { return V1LayerParameter_LayerType_IsValid(value); } @@ -8450,8 +9411,10 @@ class V1LayerParameter : public ::google::protobuf::Message { } typedef V1LayerParameter_DimCheckMode DimCheckMode; - static const DimCheckMode STRICT = V1LayerParameter_DimCheckMode_STRICT; - static const DimCheckMode PERMISSIVE = V1LayerParameter_DimCheckMode_PERMISSIVE; + static const DimCheckMode STRICT = + V1LayerParameter_DimCheckMode_STRICT; + static const DimCheckMode PERMISSIVE = + V1LayerParameter_DimCheckMode_PERMISSIVE; static inline bool DimCheckMode_IsValid(int value) { return V1LayerParameter_DimCheckMode_IsValid(value); } @@ -8476,432 +9439,432 @@ class V1LayerParameter : public ::google::protobuf::Message { // accessors ------------------------------------------------------- // repeated string bottom = 2; - inline int bottom_size() const; - inline void clear_bottom(); + int bottom_size() const; + void clear_bottom(); static const int kBottomFieldNumber = 2; - inline const ::std::string& bottom(int index) const; - inline ::std::string* mutable_bottom(int index); - inline void set_bottom(int index, const ::std::string& value); - inline void set_bottom(int index, const char* value); - inline void set_bottom(int index, const char* value, size_t size); - inline ::std::string* add_bottom(); - inline void add_bottom(const ::std::string& value); - inline void add_bottom(const char* value); - inline void add_bottom(const char* value, size_t size); - inline const ::google::protobuf::RepeatedPtrField< ::std::string>& bottom() const; - inline ::google::protobuf::RepeatedPtrField< ::std::string>* mutable_bottom(); + const ::std::string& bottom(int index) const; + ::std::string* mutable_bottom(int index); + void set_bottom(int index, const ::std::string& value); + void set_bottom(int index, const char* value); + void set_bottom(int index, const char* value, size_t size); + ::std::string* add_bottom(); + void add_bottom(const ::std::string& value); + void add_bottom(const char* value); + void add_bottom(const char* value, size_t size); + const ::google::protobuf::RepeatedPtrField< ::std::string>& bottom() const; + ::google::protobuf::RepeatedPtrField< ::std::string>* mutable_bottom(); // repeated string top = 3; - inline int top_size() const; - inline void clear_top(); + int top_size() const; + void clear_top(); static const int kTopFieldNumber = 3; - inline const ::std::string& top(int index) const; - inline ::std::string* mutable_top(int index); - inline void set_top(int index, const ::std::string& value); - inline void set_top(int index, const char* value); - inline void set_top(int index, const char* value, size_t size); - inline ::std::string* add_top(); - inline void add_top(const ::std::string& value); - inline void add_top(const char* value); - inline void add_top(const char* value, size_t size); - inline const ::google::protobuf::RepeatedPtrField< ::std::string>& top() const; - inline ::google::protobuf::RepeatedPtrField< ::std::string>* mutable_top(); + const ::std::string& top(int index) const; + ::std::string* mutable_top(int index); + void set_top(int index, const ::std::string& value); + void set_top(int index, const char* value); + void set_top(int index, const char* value, size_t size); + ::std::string* add_top(); + void add_top(const ::std::string& value); + void add_top(const char* value); + void add_top(const char* value, size_t size); + const ::google::protobuf::RepeatedPtrField< ::std::string>& top() const; + ::google::protobuf::RepeatedPtrField< ::std::string>* mutable_top(); // optional string name = 4; - inline bool has_name() const; - inline void clear_name(); + bool has_name() const; + void clear_name(); static const int kNameFieldNumber = 4; - inline const ::std::string& name() const; - inline void set_name(const ::std::string& value); - inline void set_name(const char* value); - inline void set_name(const char* value, size_t size); - inline ::std::string* mutable_name(); - inline ::std::string* release_name(); - inline void set_allocated_name(::std::string* name); + const ::std::string& name() const; + void set_name(const ::std::string& value); + void set_name(const char* value); + void set_name(const char* value, size_t size); + ::std::string* mutable_name(); + ::std::string* release_name(); + void set_allocated_name(::std::string* name); // repeated .caffe.NetStateRule include = 32; - inline int include_size() const; - inline void clear_include(); + int include_size() const; + void clear_include(); static const int kIncludeFieldNumber = 32; - inline const ::caffe::NetStateRule& include(int index) const; - inline ::caffe::NetStateRule* mutable_include(int index); - inline ::caffe::NetStateRule* add_include(); - inline const ::google::protobuf::RepeatedPtrField< ::caffe::NetStateRule >& - include() const; - inline ::google::protobuf::RepeatedPtrField< ::caffe::NetStateRule >* + const ::caffe::NetStateRule& include(int index) const; + ::caffe::NetStateRule* mutable_include(int index); + ::caffe::NetStateRule* add_include(); + ::google::protobuf::RepeatedPtrField< ::caffe::NetStateRule >* mutable_include(); + const ::google::protobuf::RepeatedPtrField< ::caffe::NetStateRule >& + include() const; // repeated .caffe.NetStateRule exclude = 33; - inline int exclude_size() const; - inline void clear_exclude(); + int exclude_size() const; + void clear_exclude(); static const int kExcludeFieldNumber = 33; - inline const ::caffe::NetStateRule& exclude(int index) const; - inline ::caffe::NetStateRule* mutable_exclude(int index); - inline ::caffe::NetStateRule* add_exclude(); - inline const ::google::protobuf::RepeatedPtrField< ::caffe::NetStateRule >& - exclude() const; - inline ::google::protobuf::RepeatedPtrField< ::caffe::NetStateRule >* + const ::caffe::NetStateRule& exclude(int index) const; + ::caffe::NetStateRule* mutable_exclude(int index); + ::caffe::NetStateRule* add_exclude(); + ::google::protobuf::RepeatedPtrField< ::caffe::NetStateRule >* mutable_exclude(); + const ::google::protobuf::RepeatedPtrField< ::caffe::NetStateRule >& + exclude() const; // optional .caffe.V1LayerParameter.LayerType type = 5; - inline bool has_type() const; - inline void clear_type(); + bool has_type() const; + void clear_type(); static const int kTypeFieldNumber = 5; - inline ::caffe::V1LayerParameter_LayerType type() const; - inline void set_type(::caffe::V1LayerParameter_LayerType value); + ::caffe::V1LayerParameter_LayerType type() const; + void set_type(::caffe::V1LayerParameter_LayerType value); // repeated .caffe.BlobProto blobs = 6; - inline int blobs_size() const; - inline void clear_blobs(); + int blobs_size() const; + void clear_blobs(); static const int kBlobsFieldNumber = 6; - inline const ::caffe::BlobProto& blobs(int index) const; - inline ::caffe::BlobProto* mutable_blobs(int index); - inline ::caffe::BlobProto* add_blobs(); - inline const ::google::protobuf::RepeatedPtrField< ::caffe::BlobProto >& - blobs() const; - inline ::google::protobuf::RepeatedPtrField< ::caffe::BlobProto >* + const ::caffe::BlobProto& blobs(int index) const; + ::caffe::BlobProto* mutable_blobs(int index); + ::caffe::BlobProto* add_blobs(); + ::google::protobuf::RepeatedPtrField< ::caffe::BlobProto >* mutable_blobs(); + const ::google::protobuf::RepeatedPtrField< ::caffe::BlobProto >& + blobs() const; // repeated string param = 1001; - inline int param_size() const; - inline void clear_param(); + int param_size() const; + void clear_param(); static const int kParamFieldNumber = 1001; - inline const ::std::string& param(int index) const; - inline ::std::string* mutable_param(int index); - inline void set_param(int index, const ::std::string& value); - inline void set_param(int index, const char* value); - inline void set_param(int index, const char* value, size_t size); - inline ::std::string* add_param(); - inline void add_param(const ::std::string& value); - inline void add_param(const char* value); - inline void add_param(const char* value, size_t size); - inline const ::google::protobuf::RepeatedPtrField< ::std::string>& param() const; - inline ::google::protobuf::RepeatedPtrField< ::std::string>* mutable_param(); + const ::std::string& param(int index) const; + ::std::string* mutable_param(int index); + void set_param(int index, const ::std::string& value); + void set_param(int index, const char* value); + void set_param(int index, const char* value, size_t size); + ::std::string* add_param(); + void add_param(const ::std::string& value); + void add_param(const char* value); + void add_param(const char* value, size_t size); + const ::google::protobuf::RepeatedPtrField< ::std::string>& param() const; + ::google::protobuf::RepeatedPtrField< ::std::string>* mutable_param(); // repeated .caffe.V1LayerParameter.DimCheckMode blob_share_mode = 1002; - inline int blob_share_mode_size() const; - inline void clear_blob_share_mode(); + int blob_share_mode_size() const; + void clear_blob_share_mode(); static const int kBlobShareModeFieldNumber = 1002; - inline ::caffe::V1LayerParameter_DimCheckMode blob_share_mode(int index) const; - inline void set_blob_share_mode(int index, ::caffe::V1LayerParameter_DimCheckMode value); - inline void add_blob_share_mode(::caffe::V1LayerParameter_DimCheckMode value); - inline const ::google::protobuf::RepeatedField& blob_share_mode() const; - inline ::google::protobuf::RepeatedField* mutable_blob_share_mode(); + ::caffe::V1LayerParameter_DimCheckMode blob_share_mode(int index) const; + void set_blob_share_mode(int index, ::caffe::V1LayerParameter_DimCheckMode value); + void add_blob_share_mode(::caffe::V1LayerParameter_DimCheckMode value); + const ::google::protobuf::RepeatedField& blob_share_mode() const; + ::google::protobuf::RepeatedField* mutable_blob_share_mode(); // repeated float blobs_lr = 7; - inline int blobs_lr_size() const; - inline void clear_blobs_lr(); + int blobs_lr_size() const; + void clear_blobs_lr(); static const int kBlobsLrFieldNumber = 7; - inline float blobs_lr(int index) const; - inline void set_blobs_lr(int index, float value); - inline void add_blobs_lr(float value); - inline const ::google::protobuf::RepeatedField< float >& + float blobs_lr(int index) const; + void set_blobs_lr(int index, float value); + void add_blobs_lr(float value); + const ::google::protobuf::RepeatedField< float >& blobs_lr() const; - inline ::google::protobuf::RepeatedField< float >* + ::google::protobuf::RepeatedField< float >* mutable_blobs_lr(); // repeated float weight_decay = 8; - inline int weight_decay_size() const; - inline void clear_weight_decay(); + int weight_decay_size() const; + void clear_weight_decay(); static const int kWeightDecayFieldNumber = 8; - inline float weight_decay(int index) const; - inline void set_weight_decay(int index, float value); - inline void add_weight_decay(float value); - inline const ::google::protobuf::RepeatedField< float >& + float weight_decay(int index) const; + void set_weight_decay(int index, float value); + void add_weight_decay(float value); + const ::google::protobuf::RepeatedField< float >& weight_decay() const; - inline ::google::protobuf::RepeatedField< float >* + ::google::protobuf::RepeatedField< float >* mutable_weight_decay(); // repeated float loss_weight = 35; - inline int loss_weight_size() const; - inline void clear_loss_weight(); + int loss_weight_size() const; + void clear_loss_weight(); static const int kLossWeightFieldNumber = 35; - inline float loss_weight(int index) const; - inline void set_loss_weight(int index, float value); - inline void add_loss_weight(float value); - inline const ::google::protobuf::RepeatedField< float >& + float loss_weight(int index) const; + void set_loss_weight(int index, float value); + void add_loss_weight(float value); + const ::google::protobuf::RepeatedField< float >& loss_weight() const; - inline ::google::protobuf::RepeatedField< float >* + ::google::protobuf::RepeatedField< float >* mutable_loss_weight(); // optional .caffe.AccuracyParameter accuracy_param = 27; - inline bool has_accuracy_param() const; - inline void clear_accuracy_param(); + bool has_accuracy_param() const; + void clear_accuracy_param(); static const int kAccuracyParamFieldNumber = 27; - inline const ::caffe::AccuracyParameter& accuracy_param() const; - inline ::caffe::AccuracyParameter* mutable_accuracy_param(); - inline ::caffe::AccuracyParameter* release_accuracy_param(); - inline void set_allocated_accuracy_param(::caffe::AccuracyParameter* accuracy_param); + const ::caffe::AccuracyParameter& accuracy_param() const; + ::caffe::AccuracyParameter* mutable_accuracy_param(); + ::caffe::AccuracyParameter* release_accuracy_param(); + void set_allocated_accuracy_param(::caffe::AccuracyParameter* accuracy_param); // optional .caffe.ArgMaxParameter argmax_param = 23; - inline bool has_argmax_param() const; - inline void clear_argmax_param(); + bool has_argmax_param() const; + void clear_argmax_param(); static const int kArgmaxParamFieldNumber = 23; - inline const ::caffe::ArgMaxParameter& argmax_param() const; - inline ::caffe::ArgMaxParameter* mutable_argmax_param(); - inline ::caffe::ArgMaxParameter* release_argmax_param(); - inline void set_allocated_argmax_param(::caffe::ArgMaxParameter* argmax_param); + const ::caffe::ArgMaxParameter& argmax_param() const; + ::caffe::ArgMaxParameter* mutable_argmax_param(); + ::caffe::ArgMaxParameter* release_argmax_param(); + void set_allocated_argmax_param(::caffe::ArgMaxParameter* argmax_param); // optional .caffe.ConcatParameter concat_param = 9; - inline bool has_concat_param() const; - inline void clear_concat_param(); + bool has_concat_param() const; + void clear_concat_param(); static const int kConcatParamFieldNumber = 9; - inline const ::caffe::ConcatParameter& concat_param() const; - inline ::caffe::ConcatParameter* mutable_concat_param(); - inline ::caffe::ConcatParameter* release_concat_param(); - inline void set_allocated_concat_param(::caffe::ConcatParameter* concat_param); + const ::caffe::ConcatParameter& concat_param() const; + ::caffe::ConcatParameter* mutable_concat_param(); + ::caffe::ConcatParameter* release_concat_param(); + void set_allocated_concat_param(::caffe::ConcatParameter* concat_param); // optional .caffe.ContrastiveLossParameter contrastive_loss_param = 40; - inline bool has_contrastive_loss_param() const; - inline void clear_contrastive_loss_param(); + bool has_contrastive_loss_param() const; + void clear_contrastive_loss_param(); static const int kContrastiveLossParamFieldNumber = 40; - inline const ::caffe::ContrastiveLossParameter& contrastive_loss_param() const; - inline ::caffe::ContrastiveLossParameter* mutable_contrastive_loss_param(); - inline ::caffe::ContrastiveLossParameter* release_contrastive_loss_param(); - inline void set_allocated_contrastive_loss_param(::caffe::ContrastiveLossParameter* contrastive_loss_param); + const ::caffe::ContrastiveLossParameter& contrastive_loss_param() const; + ::caffe::ContrastiveLossParameter* mutable_contrastive_loss_param(); + ::caffe::ContrastiveLossParameter* release_contrastive_loss_param(); + void set_allocated_contrastive_loss_param(::caffe::ContrastiveLossParameter* contrastive_loss_param); // optional .caffe.ConvolutionParameter convolution_param = 10; - inline bool has_convolution_param() const; - inline void clear_convolution_param(); + bool has_convolution_param() const; + void clear_convolution_param(); static const int kConvolutionParamFieldNumber = 10; - inline const ::caffe::ConvolutionParameter& convolution_param() const; - inline ::caffe::ConvolutionParameter* mutable_convolution_param(); - inline ::caffe::ConvolutionParameter* release_convolution_param(); - inline void set_allocated_convolution_param(::caffe::ConvolutionParameter* convolution_param); + const ::caffe::ConvolutionParameter& convolution_param() const; + ::caffe::ConvolutionParameter* mutable_convolution_param(); + ::caffe::ConvolutionParameter* release_convolution_param(); + void set_allocated_convolution_param(::caffe::ConvolutionParameter* convolution_param); // optional .caffe.DataParameter data_param = 11; - inline bool has_data_param() const; - inline void clear_data_param(); + bool has_data_param() const; + void clear_data_param(); static const int kDataParamFieldNumber = 11; - inline const ::caffe::DataParameter& data_param() const; - inline ::caffe::DataParameter* mutable_data_param(); - inline ::caffe::DataParameter* release_data_param(); - inline void set_allocated_data_param(::caffe::DataParameter* data_param); + const ::caffe::DataParameter& data_param() const; + ::caffe::DataParameter* mutable_data_param(); + ::caffe::DataParameter* release_data_param(); + void set_allocated_data_param(::caffe::DataParameter* data_param); // optional .caffe.DropoutParameter dropout_param = 12; - inline bool has_dropout_param() const; - inline void clear_dropout_param(); + bool has_dropout_param() const; + void clear_dropout_param(); static const int kDropoutParamFieldNumber = 12; - inline const ::caffe::DropoutParameter& dropout_param() const; - inline ::caffe::DropoutParameter* mutable_dropout_param(); - inline ::caffe::DropoutParameter* release_dropout_param(); - inline void set_allocated_dropout_param(::caffe::DropoutParameter* dropout_param); + const ::caffe::DropoutParameter& dropout_param() const; + ::caffe::DropoutParameter* mutable_dropout_param(); + ::caffe::DropoutParameter* release_dropout_param(); + void set_allocated_dropout_param(::caffe::DropoutParameter* dropout_param); // optional .caffe.DummyDataParameter dummy_data_param = 26; - inline bool has_dummy_data_param() const; - inline void clear_dummy_data_param(); + bool has_dummy_data_param() const; + void clear_dummy_data_param(); static const int kDummyDataParamFieldNumber = 26; - inline const ::caffe::DummyDataParameter& dummy_data_param() const; - inline ::caffe::DummyDataParameter* mutable_dummy_data_param(); - inline ::caffe::DummyDataParameter* release_dummy_data_param(); - inline void set_allocated_dummy_data_param(::caffe::DummyDataParameter* dummy_data_param); + const ::caffe::DummyDataParameter& dummy_data_param() const; + ::caffe::DummyDataParameter* mutable_dummy_data_param(); + ::caffe::DummyDataParameter* release_dummy_data_param(); + void set_allocated_dummy_data_param(::caffe::DummyDataParameter* dummy_data_param); // optional .caffe.EltwiseParameter eltwise_param = 24; - inline bool has_eltwise_param() const; - inline void clear_eltwise_param(); + bool has_eltwise_param() const; + void clear_eltwise_param(); static const int kEltwiseParamFieldNumber = 24; - inline const ::caffe::EltwiseParameter& eltwise_param() const; - inline ::caffe::EltwiseParameter* mutable_eltwise_param(); - inline ::caffe::EltwiseParameter* release_eltwise_param(); - inline void set_allocated_eltwise_param(::caffe::EltwiseParameter* eltwise_param); + const ::caffe::EltwiseParameter& eltwise_param() const; + ::caffe::EltwiseParameter* mutable_eltwise_param(); + ::caffe::EltwiseParameter* release_eltwise_param(); + void set_allocated_eltwise_param(::caffe::EltwiseParameter* eltwise_param); // optional .caffe.ExpParameter exp_param = 41; - inline bool has_exp_param() const; - inline void clear_exp_param(); + bool has_exp_param() const; + void clear_exp_param(); static const int kExpParamFieldNumber = 41; - inline const ::caffe::ExpParameter& exp_param() const; - inline ::caffe::ExpParameter* mutable_exp_param(); - inline ::caffe::ExpParameter* release_exp_param(); - inline void set_allocated_exp_param(::caffe::ExpParameter* exp_param); + const ::caffe::ExpParameter& exp_param() const; + ::caffe::ExpParameter* mutable_exp_param(); + ::caffe::ExpParameter* release_exp_param(); + void set_allocated_exp_param(::caffe::ExpParameter* exp_param); // optional .caffe.HDF5DataParameter hdf5_data_param = 13; - inline bool has_hdf5_data_param() const; - inline void clear_hdf5_data_param(); + bool has_hdf5_data_param() const; + void clear_hdf5_data_param(); static const int kHdf5DataParamFieldNumber = 13; - inline const ::caffe::HDF5DataParameter& hdf5_data_param() const; - inline ::caffe::HDF5DataParameter* mutable_hdf5_data_param(); - inline ::caffe::HDF5DataParameter* release_hdf5_data_param(); - inline void set_allocated_hdf5_data_param(::caffe::HDF5DataParameter* hdf5_data_param); + const ::caffe::HDF5DataParameter& hdf5_data_param() const; + ::caffe::HDF5DataParameter* mutable_hdf5_data_param(); + ::caffe::HDF5DataParameter* release_hdf5_data_param(); + void set_allocated_hdf5_data_param(::caffe::HDF5DataParameter* hdf5_data_param); // optional .caffe.HDF5OutputParameter hdf5_output_param = 14; - inline bool has_hdf5_output_param() const; - inline void clear_hdf5_output_param(); + bool has_hdf5_output_param() const; + void clear_hdf5_output_param(); static const int kHdf5OutputParamFieldNumber = 14; - inline const ::caffe::HDF5OutputParameter& hdf5_output_param() const; - inline ::caffe::HDF5OutputParameter* mutable_hdf5_output_param(); - inline ::caffe::HDF5OutputParameter* release_hdf5_output_param(); - inline void set_allocated_hdf5_output_param(::caffe::HDF5OutputParameter* hdf5_output_param); + const ::caffe::HDF5OutputParameter& hdf5_output_param() const; + ::caffe::HDF5OutputParameter* mutable_hdf5_output_param(); + ::caffe::HDF5OutputParameter* release_hdf5_output_param(); + void set_allocated_hdf5_output_param(::caffe::HDF5OutputParameter* hdf5_output_param); // optional .caffe.HingeLossParameter hinge_loss_param = 29; - inline bool has_hinge_loss_param() const; - inline void clear_hinge_loss_param(); + bool has_hinge_loss_param() const; + void clear_hinge_loss_param(); static const int kHingeLossParamFieldNumber = 29; - inline const ::caffe::HingeLossParameter& hinge_loss_param() const; - inline ::caffe::HingeLossParameter* mutable_hinge_loss_param(); - inline ::caffe::HingeLossParameter* release_hinge_loss_param(); - inline void set_allocated_hinge_loss_param(::caffe::HingeLossParameter* hinge_loss_param); + const ::caffe::HingeLossParameter& hinge_loss_param() const; + ::caffe::HingeLossParameter* mutable_hinge_loss_param(); + ::caffe::HingeLossParameter* release_hinge_loss_param(); + void set_allocated_hinge_loss_param(::caffe::HingeLossParameter* hinge_loss_param); // optional .caffe.ImageDataParameter image_data_param = 15; - inline bool has_image_data_param() const; - inline void clear_image_data_param(); + bool has_image_data_param() const; + void clear_image_data_param(); static const int kImageDataParamFieldNumber = 15; - inline const ::caffe::ImageDataParameter& image_data_param() const; - inline ::caffe::ImageDataParameter* mutable_image_data_param(); - inline ::caffe::ImageDataParameter* release_image_data_param(); - inline void set_allocated_image_data_param(::caffe::ImageDataParameter* image_data_param); + const ::caffe::ImageDataParameter& image_data_param() const; + ::caffe::ImageDataParameter* mutable_image_data_param(); + ::caffe::ImageDataParameter* release_image_data_param(); + void set_allocated_image_data_param(::caffe::ImageDataParameter* image_data_param); // optional .caffe.InfogainLossParameter infogain_loss_param = 16; - inline bool has_infogain_loss_param() const; - inline void clear_infogain_loss_param(); + bool has_infogain_loss_param() const; + void clear_infogain_loss_param(); static const int kInfogainLossParamFieldNumber = 16; - inline const ::caffe::InfogainLossParameter& infogain_loss_param() const; - inline ::caffe::InfogainLossParameter* mutable_infogain_loss_param(); - inline ::caffe::InfogainLossParameter* release_infogain_loss_param(); - inline void set_allocated_infogain_loss_param(::caffe::InfogainLossParameter* infogain_loss_param); + const ::caffe::InfogainLossParameter& infogain_loss_param() const; + ::caffe::InfogainLossParameter* mutable_infogain_loss_param(); + ::caffe::InfogainLossParameter* release_infogain_loss_param(); + void set_allocated_infogain_loss_param(::caffe::InfogainLossParameter* infogain_loss_param); // optional .caffe.InnerProductParameter inner_product_param = 17; - inline bool has_inner_product_param() const; - inline void clear_inner_product_param(); + bool has_inner_product_param() const; + void clear_inner_product_param(); static const int kInnerProductParamFieldNumber = 17; - inline const ::caffe::InnerProductParameter& inner_product_param() const; - inline ::caffe::InnerProductParameter* mutable_inner_product_param(); - inline ::caffe::InnerProductParameter* release_inner_product_param(); - inline void set_allocated_inner_product_param(::caffe::InnerProductParameter* inner_product_param); + const ::caffe::InnerProductParameter& inner_product_param() const; + ::caffe::InnerProductParameter* mutable_inner_product_param(); + ::caffe::InnerProductParameter* release_inner_product_param(); + void set_allocated_inner_product_param(::caffe::InnerProductParameter* inner_product_param); // optional .caffe.LRNParameter lrn_param = 18; - inline bool has_lrn_param() const; - inline void clear_lrn_param(); + bool has_lrn_param() const; + void clear_lrn_param(); static const int kLrnParamFieldNumber = 18; - inline const ::caffe::LRNParameter& lrn_param() const; - inline ::caffe::LRNParameter* mutable_lrn_param(); - inline ::caffe::LRNParameter* release_lrn_param(); - inline void set_allocated_lrn_param(::caffe::LRNParameter* lrn_param); + const ::caffe::LRNParameter& lrn_param() const; + ::caffe::LRNParameter* mutable_lrn_param(); + ::caffe::LRNParameter* release_lrn_param(); + void set_allocated_lrn_param(::caffe::LRNParameter* lrn_param); // optional .caffe.MemoryDataParameter memory_data_param = 22; - inline bool has_memory_data_param() const; - inline void clear_memory_data_param(); + bool has_memory_data_param() const; + void clear_memory_data_param(); static const int kMemoryDataParamFieldNumber = 22; - inline const ::caffe::MemoryDataParameter& memory_data_param() const; - inline ::caffe::MemoryDataParameter* mutable_memory_data_param(); - inline ::caffe::MemoryDataParameter* release_memory_data_param(); - inline void set_allocated_memory_data_param(::caffe::MemoryDataParameter* memory_data_param); + const ::caffe::MemoryDataParameter& memory_data_param() const; + ::caffe::MemoryDataParameter* mutable_memory_data_param(); + ::caffe::MemoryDataParameter* release_memory_data_param(); + void set_allocated_memory_data_param(::caffe::MemoryDataParameter* memory_data_param); // optional .caffe.MVNParameter mvn_param = 34; - inline bool has_mvn_param() const; - inline void clear_mvn_param(); + bool has_mvn_param() const; + void clear_mvn_param(); static const int kMvnParamFieldNumber = 34; - inline const ::caffe::MVNParameter& mvn_param() const; - inline ::caffe::MVNParameter* mutable_mvn_param(); - inline ::caffe::MVNParameter* release_mvn_param(); - inline void set_allocated_mvn_param(::caffe::MVNParameter* mvn_param); + const ::caffe::MVNParameter& mvn_param() const; + ::caffe::MVNParameter* mutable_mvn_param(); + ::caffe::MVNParameter* release_mvn_param(); + void set_allocated_mvn_param(::caffe::MVNParameter* mvn_param); // optional .caffe.PoolingParameter pooling_param = 19; - inline bool has_pooling_param() const; - inline void clear_pooling_param(); + bool has_pooling_param() const; + void clear_pooling_param(); static const int kPoolingParamFieldNumber = 19; - inline const ::caffe::PoolingParameter& pooling_param() const; - inline ::caffe::PoolingParameter* mutable_pooling_param(); - inline ::caffe::PoolingParameter* release_pooling_param(); - inline void set_allocated_pooling_param(::caffe::PoolingParameter* pooling_param); + const ::caffe::PoolingParameter& pooling_param() const; + ::caffe::PoolingParameter* mutable_pooling_param(); + ::caffe::PoolingParameter* release_pooling_param(); + void set_allocated_pooling_param(::caffe::PoolingParameter* pooling_param); // optional .caffe.PowerParameter power_param = 21; - inline bool has_power_param() const; - inline void clear_power_param(); + bool has_power_param() const; + void clear_power_param(); static const int kPowerParamFieldNumber = 21; - inline const ::caffe::PowerParameter& power_param() const; - inline ::caffe::PowerParameter* mutable_power_param(); - inline ::caffe::PowerParameter* release_power_param(); - inline void set_allocated_power_param(::caffe::PowerParameter* power_param); + const ::caffe::PowerParameter& power_param() const; + ::caffe::PowerParameter* mutable_power_param(); + ::caffe::PowerParameter* release_power_param(); + void set_allocated_power_param(::caffe::PowerParameter* power_param); // optional .caffe.ReLUParameter relu_param = 30; - inline bool has_relu_param() const; - inline void clear_relu_param(); + bool has_relu_param() const; + void clear_relu_param(); static const int kReluParamFieldNumber = 30; - inline const ::caffe::ReLUParameter& relu_param() const; - inline ::caffe::ReLUParameter* mutable_relu_param(); - inline ::caffe::ReLUParameter* release_relu_param(); - inline void set_allocated_relu_param(::caffe::ReLUParameter* relu_param); + const ::caffe::ReLUParameter& relu_param() const; + ::caffe::ReLUParameter* mutable_relu_param(); + ::caffe::ReLUParameter* release_relu_param(); + void set_allocated_relu_param(::caffe::ReLUParameter* relu_param); // optional .caffe.SigmoidParameter sigmoid_param = 38; - inline bool has_sigmoid_param() const; - inline void clear_sigmoid_param(); + bool has_sigmoid_param() const; + void clear_sigmoid_param(); static const int kSigmoidParamFieldNumber = 38; - inline const ::caffe::SigmoidParameter& sigmoid_param() const; - inline ::caffe::SigmoidParameter* mutable_sigmoid_param(); - inline ::caffe::SigmoidParameter* release_sigmoid_param(); - inline void set_allocated_sigmoid_param(::caffe::SigmoidParameter* sigmoid_param); + const ::caffe::SigmoidParameter& sigmoid_param() const; + ::caffe::SigmoidParameter* mutable_sigmoid_param(); + ::caffe::SigmoidParameter* release_sigmoid_param(); + void set_allocated_sigmoid_param(::caffe::SigmoidParameter* sigmoid_param); // optional .caffe.SoftmaxParameter softmax_param = 39; - inline bool has_softmax_param() const; - inline void clear_softmax_param(); + bool has_softmax_param() const; + void clear_softmax_param(); static const int kSoftmaxParamFieldNumber = 39; - inline const ::caffe::SoftmaxParameter& softmax_param() const; - inline ::caffe::SoftmaxParameter* mutable_softmax_param(); - inline ::caffe::SoftmaxParameter* release_softmax_param(); - inline void set_allocated_softmax_param(::caffe::SoftmaxParameter* softmax_param); + const ::caffe::SoftmaxParameter& softmax_param() const; + ::caffe::SoftmaxParameter* mutable_softmax_param(); + ::caffe::SoftmaxParameter* release_softmax_param(); + void set_allocated_softmax_param(::caffe::SoftmaxParameter* softmax_param); // optional .caffe.SliceParameter slice_param = 31; - inline bool has_slice_param() const; - inline void clear_slice_param(); + bool has_slice_param() const; + void clear_slice_param(); static const int kSliceParamFieldNumber = 31; - inline const ::caffe::SliceParameter& slice_param() const; - inline ::caffe::SliceParameter* mutable_slice_param(); - inline ::caffe::SliceParameter* release_slice_param(); - inline void set_allocated_slice_param(::caffe::SliceParameter* slice_param); + const ::caffe::SliceParameter& slice_param() const; + ::caffe::SliceParameter* mutable_slice_param(); + ::caffe::SliceParameter* release_slice_param(); + void set_allocated_slice_param(::caffe::SliceParameter* slice_param); // optional .caffe.TanHParameter tanh_param = 37; - inline bool has_tanh_param() const; - inline void clear_tanh_param(); + bool has_tanh_param() const; + void clear_tanh_param(); static const int kTanhParamFieldNumber = 37; - inline const ::caffe::TanHParameter& tanh_param() const; - inline ::caffe::TanHParameter* mutable_tanh_param(); - inline ::caffe::TanHParameter* release_tanh_param(); - inline void set_allocated_tanh_param(::caffe::TanHParameter* tanh_param); + const ::caffe::TanHParameter& tanh_param() const; + ::caffe::TanHParameter* mutable_tanh_param(); + ::caffe::TanHParameter* release_tanh_param(); + void set_allocated_tanh_param(::caffe::TanHParameter* tanh_param); // optional .caffe.ThresholdParameter threshold_param = 25; - inline bool has_threshold_param() const; - inline void clear_threshold_param(); + bool has_threshold_param() const; + void clear_threshold_param(); static const int kThresholdParamFieldNumber = 25; - inline const ::caffe::ThresholdParameter& threshold_param() const; - inline ::caffe::ThresholdParameter* mutable_threshold_param(); - inline ::caffe::ThresholdParameter* release_threshold_param(); - inline void set_allocated_threshold_param(::caffe::ThresholdParameter* threshold_param); + const ::caffe::ThresholdParameter& threshold_param() const; + ::caffe::ThresholdParameter* mutable_threshold_param(); + ::caffe::ThresholdParameter* release_threshold_param(); + void set_allocated_threshold_param(::caffe::ThresholdParameter* threshold_param); // optional .caffe.WindowDataParameter window_data_param = 20; - inline bool has_window_data_param() const; - inline void clear_window_data_param(); + bool has_window_data_param() const; + void clear_window_data_param(); static const int kWindowDataParamFieldNumber = 20; - inline const ::caffe::WindowDataParameter& window_data_param() const; - inline ::caffe::WindowDataParameter* mutable_window_data_param(); - inline ::caffe::WindowDataParameter* release_window_data_param(); - inline void set_allocated_window_data_param(::caffe::WindowDataParameter* window_data_param); + const ::caffe::WindowDataParameter& window_data_param() const; + ::caffe::WindowDataParameter* mutable_window_data_param(); + ::caffe::WindowDataParameter* release_window_data_param(); + void set_allocated_window_data_param(::caffe::WindowDataParameter* window_data_param); // optional .caffe.TransformationParameter transform_param = 36; - inline bool has_transform_param() const; - inline void clear_transform_param(); + bool has_transform_param() const; + void clear_transform_param(); static const int kTransformParamFieldNumber = 36; - inline const ::caffe::TransformationParameter& transform_param() const; - inline ::caffe::TransformationParameter* mutable_transform_param(); - inline ::caffe::TransformationParameter* release_transform_param(); - inline void set_allocated_transform_param(::caffe::TransformationParameter* transform_param); + const ::caffe::TransformationParameter& transform_param() const; + ::caffe::TransformationParameter* mutable_transform_param(); + ::caffe::TransformationParameter* release_transform_param(); + void set_allocated_transform_param(::caffe::TransformationParameter* transform_param); // optional .caffe.LossParameter loss_param = 42; - inline bool has_loss_param() const; - inline void clear_loss_param(); + bool has_loss_param() const; + void clear_loss_param(); static const int kLossParamFieldNumber = 42; - inline const ::caffe::LossParameter& loss_param() const; - inline ::caffe::LossParameter* mutable_loss_param(); - inline ::caffe::LossParameter* release_loss_param(); - inline void set_allocated_loss_param(::caffe::LossParameter* loss_param); + const ::caffe::LossParameter& loss_param() const; + ::caffe::LossParameter* mutable_loss_param(); + ::caffe::LossParameter* release_loss_param(); + void set_allocated_loss_param(::caffe::LossParameter* loss_param); // optional .caffe.V0LayerParameter layer = 1; - inline bool has_layer() const; - inline void clear_layer(); + bool has_layer() const; + void clear_layer(); static const int kLayerFieldNumber = 1; - inline const ::caffe::V0LayerParameter& layer() const; - inline ::caffe::V0LayerParameter* mutable_layer(); - inline ::caffe::V0LayerParameter* release_layer(); - inline void set_allocated_layer(::caffe::V0LayerParameter* layer); + const ::caffe::V0LayerParameter& layer() const; + ::caffe::V0LayerParameter* mutable_layer(); + ::caffe::V0LayerParameter* release_layer(); + void set_allocated_layer(::caffe::V0LayerParameter* layer); // @@protoc_insertion_point(class_scope:caffe.V1LayerParameter) private: @@ -8972,11 +9935,10 @@ class V1LayerParameter : public ::google::protobuf::Message { inline void set_has_layer(); inline void clear_has_layer(); - ::google::protobuf::UnknownFieldSet _unknown_fields_; - + ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_; + ::google::protobuf::internal::HasBits<2> _has_bits_; ::google::protobuf::RepeatedPtrField< ::std::string> bottom_; ::google::protobuf::RepeatedPtrField< ::std::string> top_; - ::std::string* name_; ::google::protobuf::RepeatedPtrField< ::caffe::NetStateRule > include_; ::google::protobuf::RepeatedPtrField< ::caffe::NetStateRule > exclude_; ::google::protobuf::RepeatedPtrField< ::caffe::BlobProto > blobs_; @@ -8985,6 +9947,7 @@ class V1LayerParameter : public ::google::protobuf::Message { ::google::protobuf::RepeatedField< float > blobs_lr_; ::google::protobuf::RepeatedField< float > weight_decay_; ::google::protobuf::RepeatedField< float > loss_weight_; + ::google::protobuf::internal::ArenaStringPtr name_; ::caffe::AccuracyParameter* accuracy_param_; ::caffe::ArgMaxParameter* argmax_param_; ::caffe::ConcatParameter* concat_param_; @@ -9017,20 +9980,19 @@ class V1LayerParameter : public ::google::protobuf::Message { ::caffe::LossParameter* loss_param_; ::caffe::V0LayerParameter* layer_; int type_; - mutable int _cached_size_; - ::google::protobuf::uint32 _has_bits_[(43 + 31) / 32]; - - friend void protobuf_AddDesc_caffe_2eproto(); + friend void protobuf_InitDefaults_caffe_2eproto_impl(); + friend void protobuf_AddDesc_caffe_2eproto_impl(); friend void protobuf_AssignDesc_caffe_2eproto(); friend void protobuf_ShutdownFile_caffe_2eproto(); void InitAsDefaultInstance(); - static V1LayerParameter* default_instance_; }; +extern ::google::protobuf::internal::ExplicitlyConstructed V1LayerParameter_default_instance_; + // ------------------------------------------------------------------- -class V0LayerParameter : public ::google::protobuf::Message { +class V0LayerParameter : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:caffe.V0LayerParameter) */ { public: V0LayerParameter(); virtual ~V0LayerParameter(); @@ -9043,21 +10005,25 @@ class V0LayerParameter : public ::google::protobuf::Message { } inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const { - return _unknown_fields_; + return _internal_metadata_.unknown_fields(); } inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() { - return &_unknown_fields_; + return _internal_metadata_.mutable_unknown_fields(); } static const ::google::protobuf::Descriptor* descriptor(); static const V0LayerParameter& default_instance(); + static const V0LayerParameter* internal_default_instance(); + void Swap(V0LayerParameter* other); // implements Message ---------------------------------------------- - V0LayerParameter* New() const; + inline V0LayerParameter* New() const { return New(NULL); } + + V0LayerParameter* New(::google::protobuf::Arena* arena) const; void CopyFrom(const ::google::protobuf::Message& from); void MergeFrom(const ::google::protobuf::Message& from); void CopyFrom(const V0LayerParameter& from); @@ -9065,17 +10031,30 @@ class V0LayerParameter : public ::google::protobuf::Message { void Clear(); bool IsInitialized() const; - int ByteSize() const; + size_t ByteSizeLong() const; bool MergePartialFromCodedStream( ::google::protobuf::io::CodedInputStream* input); void SerializeWithCachedSizes( ::google::protobuf::io::CodedOutputStream* output) const; - ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const; + ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray( + bool deterministic, ::google::protobuf::uint8* output) const; + ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const { + return InternalSerializeWithCachedSizesToArray(false, output); + } int GetCachedSize() const { return _cached_size_; } private: void SharedCtor(); void SharedDtor(); void SetCachedSize(int size) const; + void InternalSwap(V0LayerParameter* other); + void UnsafeMergeFrom(const V0LayerParameter& from); + private: + inline ::google::protobuf::Arena* GetArenaNoVirtual() const { + return _internal_metadata_.arena(); + } + inline void* MaybeArenaPtr() const { + return _internal_metadata_.raw_arena_ptr(); + } public: ::google::protobuf::Metadata GetMetadata() const; @@ -9083,9 +10062,12 @@ class V0LayerParameter : public ::google::protobuf::Message { // nested types ---------------------------------------------------- typedef V0LayerParameter_PoolMethod PoolMethod; - static const PoolMethod MAX = V0LayerParameter_PoolMethod_MAX; - static const PoolMethod AVE = V0LayerParameter_PoolMethod_AVE; - static const PoolMethod STOCHASTIC = V0LayerParameter_PoolMethod_STOCHASTIC; + static const PoolMethod MAX = + V0LayerParameter_PoolMethod_MAX; + static const PoolMethod AVE = + V0LayerParameter_PoolMethod_AVE; + static const PoolMethod STOCHASTIC = + V0LayerParameter_PoolMethod_STOCHASTIC; static inline bool PoolMethod_IsValid(int value) { return V0LayerParameter_PoolMethod_IsValid(value); } @@ -9110,316 +10092,316 @@ class V0LayerParameter : public ::google::protobuf::Message { // accessors ------------------------------------------------------- // optional string name = 1; - inline bool has_name() const; - inline void clear_name(); + bool has_name() const; + void clear_name(); static const int kNameFieldNumber = 1; - inline const ::std::string& name() const; - inline void set_name(const ::std::string& value); - inline void set_name(const char* value); - inline void set_name(const char* value, size_t size); - inline ::std::string* mutable_name(); - inline ::std::string* release_name(); - inline void set_allocated_name(::std::string* name); + const ::std::string& name() const; + void set_name(const ::std::string& value); + void set_name(const char* value); + void set_name(const char* value, size_t size); + ::std::string* mutable_name(); + ::std::string* release_name(); + void set_allocated_name(::std::string* name); // optional string type = 2; - inline bool has_type() const; - inline void clear_type(); + bool has_type() const; + void clear_type(); static const int kTypeFieldNumber = 2; - inline const ::std::string& type() const; - inline void set_type(const ::std::string& value); - inline void set_type(const char* value); - inline void set_type(const char* value, size_t size); - inline ::std::string* mutable_type(); - inline ::std::string* release_type(); - inline void set_allocated_type(::std::string* type); + const ::std::string& type() const; + void set_type(const ::std::string& value); + void set_type(const char* value); + void set_type(const char* value, size_t size); + ::std::string* mutable_type(); + ::std::string* release_type(); + void set_allocated_type(::std::string* type); // optional uint32 num_output = 3; - inline bool has_num_output() const; - inline void clear_num_output(); + bool has_num_output() const; + void clear_num_output(); static const int kNumOutputFieldNumber = 3; - inline ::google::protobuf::uint32 num_output() const; - inline void set_num_output(::google::protobuf::uint32 value); + ::google::protobuf::uint32 num_output() const; + void set_num_output(::google::protobuf::uint32 value); // optional bool biasterm = 4 [default = true]; - inline bool has_biasterm() const; - inline void clear_biasterm(); + bool has_biasterm() const; + void clear_biasterm(); static const int kBiastermFieldNumber = 4; - inline bool biasterm() const; - inline void set_biasterm(bool value); + bool biasterm() const; + void set_biasterm(bool value); // optional .caffe.FillerParameter weight_filler = 5; - inline bool has_weight_filler() const; - inline void clear_weight_filler(); + bool has_weight_filler() const; + void clear_weight_filler(); static const int kWeightFillerFieldNumber = 5; - inline const ::caffe::FillerParameter& weight_filler() const; - inline ::caffe::FillerParameter* mutable_weight_filler(); - inline ::caffe::FillerParameter* release_weight_filler(); - inline void set_allocated_weight_filler(::caffe::FillerParameter* weight_filler); + const ::caffe::FillerParameter& weight_filler() const; + ::caffe::FillerParameter* mutable_weight_filler(); + ::caffe::FillerParameter* release_weight_filler(); + void set_allocated_weight_filler(::caffe::FillerParameter* weight_filler); // optional .caffe.FillerParameter bias_filler = 6; - inline bool has_bias_filler() const; - inline void clear_bias_filler(); + bool has_bias_filler() const; + void clear_bias_filler(); static const int kBiasFillerFieldNumber = 6; - inline const ::caffe::FillerParameter& bias_filler() const; - inline ::caffe::FillerParameter* mutable_bias_filler(); - inline ::caffe::FillerParameter* release_bias_filler(); - inline void set_allocated_bias_filler(::caffe::FillerParameter* bias_filler); + const ::caffe::FillerParameter& bias_filler() const; + ::caffe::FillerParameter* mutable_bias_filler(); + ::caffe::FillerParameter* release_bias_filler(); + void set_allocated_bias_filler(::caffe::FillerParameter* bias_filler); // optional uint32 pad = 7 [default = 0]; - inline bool has_pad() const; - inline void clear_pad(); + bool has_pad() const; + void clear_pad(); static const int kPadFieldNumber = 7; - inline ::google::protobuf::uint32 pad() const; - inline void set_pad(::google::protobuf::uint32 value); + ::google::protobuf::uint32 pad() const; + void set_pad(::google::protobuf::uint32 value); // optional uint32 kernelsize = 8; - inline bool has_kernelsize() const; - inline void clear_kernelsize(); + bool has_kernelsize() const; + void clear_kernelsize(); static const int kKernelsizeFieldNumber = 8; - inline ::google::protobuf::uint32 kernelsize() const; - inline void set_kernelsize(::google::protobuf::uint32 value); + ::google::protobuf::uint32 kernelsize() const; + void set_kernelsize(::google::protobuf::uint32 value); // optional uint32 group = 9 [default = 1]; - inline bool has_group() const; - inline void clear_group(); + bool has_group() const; + void clear_group(); static const int kGroupFieldNumber = 9; - inline ::google::protobuf::uint32 group() const; - inline void set_group(::google::protobuf::uint32 value); + ::google::protobuf::uint32 group() const; + void set_group(::google::protobuf::uint32 value); // optional uint32 stride = 10 [default = 1]; - inline bool has_stride() const; - inline void clear_stride(); + bool has_stride() const; + void clear_stride(); static const int kStrideFieldNumber = 10; - inline ::google::protobuf::uint32 stride() const; - inline void set_stride(::google::protobuf::uint32 value); + ::google::protobuf::uint32 stride() const; + void set_stride(::google::protobuf::uint32 value); // optional .caffe.V0LayerParameter.PoolMethod pool = 11 [default = MAX]; - inline bool has_pool() const; - inline void clear_pool(); + bool has_pool() const; + void clear_pool(); static const int kPoolFieldNumber = 11; - inline ::caffe::V0LayerParameter_PoolMethod pool() const; - inline void set_pool(::caffe::V0LayerParameter_PoolMethod value); + ::caffe::V0LayerParameter_PoolMethod pool() const; + void set_pool(::caffe::V0LayerParameter_PoolMethod value); // optional float dropout_ratio = 12 [default = 0.5]; - inline bool has_dropout_ratio() const; - inline void clear_dropout_ratio(); + bool has_dropout_ratio() const; + void clear_dropout_ratio(); static const int kDropoutRatioFieldNumber = 12; - inline float dropout_ratio() const; - inline void set_dropout_ratio(float value); + float dropout_ratio() const; + void set_dropout_ratio(float value); // optional uint32 local_size = 13 [default = 5]; - inline bool has_local_size() const; - inline void clear_local_size(); + bool has_local_size() const; + void clear_local_size(); static const int kLocalSizeFieldNumber = 13; - inline ::google::protobuf::uint32 local_size() const; - inline void set_local_size(::google::protobuf::uint32 value); + ::google::protobuf::uint32 local_size() const; + void set_local_size(::google::protobuf::uint32 value); // optional float alpha = 14 [default = 1]; - inline bool has_alpha() const; - inline void clear_alpha(); + bool has_alpha() const; + void clear_alpha(); static const int kAlphaFieldNumber = 14; - inline float alpha() const; - inline void set_alpha(float value); + float alpha() const; + void set_alpha(float value); // optional float beta = 15 [default = 0.75]; - inline bool has_beta() const; - inline void clear_beta(); + bool has_beta() const; + void clear_beta(); static const int kBetaFieldNumber = 15; - inline float beta() const; - inline void set_beta(float value); + float beta() const; + void set_beta(float value); // optional float k = 22 [default = 1]; - inline bool has_k() const; - inline void clear_k(); + bool has_k() const; + void clear_k(); static const int kKFieldNumber = 22; - inline float k() const; - inline void set_k(float value); + float k() const; + void set_k(float value); // optional string source = 16; - inline bool has_source() const; - inline void clear_source(); + bool has_source() const; + void clear_source(); static const int kSourceFieldNumber = 16; - inline const ::std::string& source() const; - inline void set_source(const ::std::string& value); - inline void set_source(const char* value); - inline void set_source(const char* value, size_t size); - inline ::std::string* mutable_source(); - inline ::std::string* release_source(); - inline void set_allocated_source(::std::string* source); + const ::std::string& source() const; + void set_source(const ::std::string& value); + void set_source(const char* value); + void set_source(const char* value, size_t size); + ::std::string* mutable_source(); + ::std::string* release_source(); + void set_allocated_source(::std::string* source); // optional float scale = 17 [default = 1]; - inline bool has_scale() const; - inline void clear_scale(); + bool has_scale() const; + void clear_scale(); static const int kScaleFieldNumber = 17; - inline float scale() const; - inline void set_scale(float value); + float scale() const; + void set_scale(float value); // optional string meanfile = 18; - inline bool has_meanfile() const; - inline void clear_meanfile(); + bool has_meanfile() const; + void clear_meanfile(); static const int kMeanfileFieldNumber = 18; - inline const ::std::string& meanfile() const; - inline void set_meanfile(const ::std::string& value); - inline void set_meanfile(const char* value); - inline void set_meanfile(const char* value, size_t size); - inline ::std::string* mutable_meanfile(); - inline ::std::string* release_meanfile(); - inline void set_allocated_meanfile(::std::string* meanfile); + const ::std::string& meanfile() const; + void set_meanfile(const ::std::string& value); + void set_meanfile(const char* value); + void set_meanfile(const char* value, size_t size); + ::std::string* mutable_meanfile(); + ::std::string* release_meanfile(); + void set_allocated_meanfile(::std::string* meanfile); // optional uint32 batchsize = 19; - inline bool has_batchsize() const; - inline void clear_batchsize(); + bool has_batchsize() const; + void clear_batchsize(); static const int kBatchsizeFieldNumber = 19; - inline ::google::protobuf::uint32 batchsize() const; - inline void set_batchsize(::google::protobuf::uint32 value); + ::google::protobuf::uint32 batchsize() const; + void set_batchsize(::google::protobuf::uint32 value); // optional uint32 cropsize = 20 [default = 0]; - inline bool has_cropsize() const; - inline void clear_cropsize(); + bool has_cropsize() const; + void clear_cropsize(); static const int kCropsizeFieldNumber = 20; - inline ::google::protobuf::uint32 cropsize() const; - inline void set_cropsize(::google::protobuf::uint32 value); + ::google::protobuf::uint32 cropsize() const; + void set_cropsize(::google::protobuf::uint32 value); // optional bool mirror = 21 [default = false]; - inline bool has_mirror() const; - inline void clear_mirror(); + bool has_mirror() const; + void clear_mirror(); static const int kMirrorFieldNumber = 21; - inline bool mirror() const; - inline void set_mirror(bool value); + bool mirror() const; + void set_mirror(bool value); // repeated .caffe.BlobProto blobs = 50; - inline int blobs_size() const; - inline void clear_blobs(); + int blobs_size() const; + void clear_blobs(); static const int kBlobsFieldNumber = 50; - inline const ::caffe::BlobProto& blobs(int index) const; - inline ::caffe::BlobProto* mutable_blobs(int index); - inline ::caffe::BlobProto* add_blobs(); - inline const ::google::protobuf::RepeatedPtrField< ::caffe::BlobProto >& - blobs() const; - inline ::google::protobuf::RepeatedPtrField< ::caffe::BlobProto >* + const ::caffe::BlobProto& blobs(int index) const; + ::caffe::BlobProto* mutable_blobs(int index); + ::caffe::BlobProto* add_blobs(); + ::google::protobuf::RepeatedPtrField< ::caffe::BlobProto >* mutable_blobs(); + const ::google::protobuf::RepeatedPtrField< ::caffe::BlobProto >& + blobs() const; // repeated float blobs_lr = 51; - inline int blobs_lr_size() const; - inline void clear_blobs_lr(); + int blobs_lr_size() const; + void clear_blobs_lr(); static const int kBlobsLrFieldNumber = 51; - inline float blobs_lr(int index) const; - inline void set_blobs_lr(int index, float value); - inline void add_blobs_lr(float value); - inline const ::google::protobuf::RepeatedField< float >& + float blobs_lr(int index) const; + void set_blobs_lr(int index, float value); + void add_blobs_lr(float value); + const ::google::protobuf::RepeatedField< float >& blobs_lr() const; - inline ::google::protobuf::RepeatedField< float >* + ::google::protobuf::RepeatedField< float >* mutable_blobs_lr(); // repeated float weight_decay = 52; - inline int weight_decay_size() const; - inline void clear_weight_decay(); + int weight_decay_size() const; + void clear_weight_decay(); static const int kWeightDecayFieldNumber = 52; - inline float weight_decay(int index) const; - inline void set_weight_decay(int index, float value); - inline void add_weight_decay(float value); - inline const ::google::protobuf::RepeatedField< float >& + float weight_decay(int index) const; + void set_weight_decay(int index, float value); + void add_weight_decay(float value); + const ::google::protobuf::RepeatedField< float >& weight_decay() const; - inline ::google::protobuf::RepeatedField< float >* + ::google::protobuf::RepeatedField< float >* mutable_weight_decay(); // optional uint32 rand_skip = 53 [default = 0]; - inline bool has_rand_skip() const; - inline void clear_rand_skip(); + bool has_rand_skip() const; + void clear_rand_skip(); static const int kRandSkipFieldNumber = 53; - inline ::google::protobuf::uint32 rand_skip() const; - inline void set_rand_skip(::google::protobuf::uint32 value); + ::google::protobuf::uint32 rand_skip() const; + void set_rand_skip(::google::protobuf::uint32 value); // optional float det_fg_threshold = 54 [default = 0.5]; - inline bool has_det_fg_threshold() const; - inline void clear_det_fg_threshold(); + bool has_det_fg_threshold() const; + void clear_det_fg_threshold(); static const int kDetFgThresholdFieldNumber = 54; - inline float det_fg_threshold() const; - inline void set_det_fg_threshold(float value); + float det_fg_threshold() const; + void set_det_fg_threshold(float value); // optional float det_bg_threshold = 55 [default = 0.5]; - inline bool has_det_bg_threshold() const; - inline void clear_det_bg_threshold(); + bool has_det_bg_threshold() const; + void clear_det_bg_threshold(); static const int kDetBgThresholdFieldNumber = 55; - inline float det_bg_threshold() const; - inline void set_det_bg_threshold(float value); + float det_bg_threshold() const; + void set_det_bg_threshold(float value); // optional float det_fg_fraction = 56 [default = 0.25]; - inline bool has_det_fg_fraction() const; - inline void clear_det_fg_fraction(); + bool has_det_fg_fraction() const; + void clear_det_fg_fraction(); static const int kDetFgFractionFieldNumber = 56; - inline float det_fg_fraction() const; - inline void set_det_fg_fraction(float value); + float det_fg_fraction() const; + void set_det_fg_fraction(float value); // optional uint32 det_context_pad = 58 [default = 0]; - inline bool has_det_context_pad() const; - inline void clear_det_context_pad(); + bool has_det_context_pad() const; + void clear_det_context_pad(); static const int kDetContextPadFieldNumber = 58; - inline ::google::protobuf::uint32 det_context_pad() const; - inline void set_det_context_pad(::google::protobuf::uint32 value); + ::google::protobuf::uint32 det_context_pad() const; + void set_det_context_pad(::google::protobuf::uint32 value); // optional string det_crop_mode = 59 [default = "warp"]; - inline bool has_det_crop_mode() const; - inline void clear_det_crop_mode(); + bool has_det_crop_mode() const; + void clear_det_crop_mode(); static const int kDetCropModeFieldNumber = 59; - inline const ::std::string& det_crop_mode() const; - inline void set_det_crop_mode(const ::std::string& value); - inline void set_det_crop_mode(const char* value); - inline void set_det_crop_mode(const char* value, size_t size); - inline ::std::string* mutable_det_crop_mode(); - inline ::std::string* release_det_crop_mode(); - inline void set_allocated_det_crop_mode(::std::string* det_crop_mode); + const ::std::string& det_crop_mode() const; + void set_det_crop_mode(const ::std::string& value); + void set_det_crop_mode(const char* value); + void set_det_crop_mode(const char* value, size_t size); + ::std::string* mutable_det_crop_mode(); + ::std::string* release_det_crop_mode(); + void set_allocated_det_crop_mode(::std::string* det_crop_mode); // optional int32 new_num = 60 [default = 0]; - inline bool has_new_num() const; - inline void clear_new_num(); + bool has_new_num() const; + void clear_new_num(); static const int kNewNumFieldNumber = 60; - inline ::google::protobuf::int32 new_num() const; - inline void set_new_num(::google::protobuf::int32 value); + ::google::protobuf::int32 new_num() const; + void set_new_num(::google::protobuf::int32 value); // optional int32 new_channels = 61 [default = 0]; - inline bool has_new_channels() const; - inline void clear_new_channels(); + bool has_new_channels() const; + void clear_new_channels(); static const int kNewChannelsFieldNumber = 61; - inline ::google::protobuf::int32 new_channels() const; - inline void set_new_channels(::google::protobuf::int32 value); + ::google::protobuf::int32 new_channels() const; + void set_new_channels(::google::protobuf::int32 value); // optional int32 new_height = 62 [default = 0]; - inline bool has_new_height() const; - inline void clear_new_height(); + bool has_new_height() const; + void clear_new_height(); static const int kNewHeightFieldNumber = 62; - inline ::google::protobuf::int32 new_height() const; - inline void set_new_height(::google::protobuf::int32 value); + ::google::protobuf::int32 new_height() const; + void set_new_height(::google::protobuf::int32 value); // optional int32 new_width = 63 [default = 0]; - inline bool has_new_width() const; - inline void clear_new_width(); + bool has_new_width() const; + void clear_new_width(); static const int kNewWidthFieldNumber = 63; - inline ::google::protobuf::int32 new_width() const; - inline void set_new_width(::google::protobuf::int32 value); + ::google::protobuf::int32 new_width() const; + void set_new_width(::google::protobuf::int32 value); // optional bool shuffle_images = 64 [default = false]; - inline bool has_shuffle_images() const; - inline void clear_shuffle_images(); + bool has_shuffle_images() const; + void clear_shuffle_images(); static const int kShuffleImagesFieldNumber = 64; - inline bool shuffle_images() const; - inline void set_shuffle_images(bool value); + bool shuffle_images() const; + void set_shuffle_images(bool value); // optional uint32 concat_dim = 65 [default = 1]; - inline bool has_concat_dim() const; - inline void clear_concat_dim(); + bool has_concat_dim() const; + void clear_concat_dim(); static const int kConcatDimFieldNumber = 65; - inline ::google::protobuf::uint32 concat_dim() const; - inline void set_concat_dim(::google::protobuf::uint32 value); + ::google::protobuf::uint32 concat_dim() const; + void set_concat_dim(::google::protobuf::uint32 value); // optional .caffe.HDF5OutputParameter hdf5_output_param = 1001; - inline bool has_hdf5_output_param() const; - inline void clear_hdf5_output_param(); + bool has_hdf5_output_param() const; + void clear_hdf5_output_param(); static const int kHdf5OutputParamFieldNumber = 1001; - inline const ::caffe::HDF5OutputParameter& hdf5_output_param() const; - inline ::caffe::HDF5OutputParameter* mutable_hdf5_output_param(); - inline ::caffe::HDF5OutputParameter* release_hdf5_output_param(); - inline void set_allocated_hdf5_output_param(::caffe::HDF5OutputParameter* hdf5_output_param); + const ::caffe::HDF5OutputParameter& hdf5_output_param() const; + ::caffe::HDF5OutputParameter* mutable_hdf5_output_param(); + ::caffe::HDF5OutputParameter* release_hdf5_output_param(); + void set_allocated_hdf5_output_param(::caffe::HDF5OutputParameter* hdf5_output_param); // @@protoc_insertion_point(class_scope:caffe.V0LayerParameter) private: @@ -9494,61 +10476,60 @@ class V0LayerParameter : public ::google::protobuf::Message { inline void set_has_hdf5_output_param(); inline void clear_has_hdf5_output_param(); - ::google::protobuf::UnknownFieldSet _unknown_fields_; - - ::std::string* name_; - ::std::string* type_; + ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_; + ::google::protobuf::internal::HasBits<2> _has_bits_; + ::google::protobuf::RepeatedPtrField< ::caffe::BlobProto > blobs_; + ::google::protobuf::RepeatedField< float > blobs_lr_; + ::google::protobuf::RepeatedField< float > weight_decay_; + ::google::protobuf::internal::ArenaStringPtr name_; + ::google::protobuf::internal::ArenaStringPtr type_; + ::google::protobuf::internal::ArenaStringPtr source_; + ::google::protobuf::internal::ArenaStringPtr meanfile_; + static ::std::string* _default_det_crop_mode_; + ::google::protobuf::internal::ArenaStringPtr det_crop_mode_; ::caffe::FillerParameter* weight_filler_; + ::caffe::FillerParameter* bias_filler_; + ::caffe::HDF5OutputParameter* hdf5_output_param_; ::google::protobuf::uint32 num_output_; ::google::protobuf::uint32 pad_; - ::caffe::FillerParameter* bias_filler_; ::google::protobuf::uint32 kernelsize_; + int pool_; + ::google::protobuf::uint32 batchsize_; + ::google::protobuf::uint32 cropsize_; + ::google::protobuf::uint32 rand_skip_; + bool mirror_; + bool shuffle_images_; + ::google::protobuf::uint32 det_context_pad_; + ::google::protobuf::int32 new_num_; + ::google::protobuf::int32 new_channels_; + ::google::protobuf::int32 new_height_; + ::google::protobuf::int32 new_width_; + ::google::protobuf::uint32 concat_dim_; + bool biasterm_; ::google::protobuf::uint32 group_; ::google::protobuf::uint32 stride_; - int pool_; float dropout_ratio_; ::google::protobuf::uint32 local_size_; float alpha_; float beta_; float k_; float scale_; - ::std::string* source_; - ::std::string* meanfile_; - ::google::protobuf::uint32 batchsize_; - bool biasterm_; - bool mirror_; - bool shuffle_images_; - ::google::protobuf::RepeatedPtrField< ::caffe::BlobProto > blobs_; - ::google::protobuf::uint32 cropsize_; - ::google::protobuf::uint32 rand_skip_; - ::google::protobuf::RepeatedField< float > blobs_lr_; - ::google::protobuf::RepeatedField< float > weight_decay_; float det_fg_threshold_; float det_bg_threshold_; float det_fg_fraction_; - ::google::protobuf::uint32 det_context_pad_; - ::std::string* det_crop_mode_; - static ::std::string* _default_det_crop_mode_; - ::google::protobuf::int32 new_num_; - ::google::protobuf::int32 new_channels_; - ::google::protobuf::int32 new_height_; - ::google::protobuf::int32 new_width_; - ::caffe::HDF5OutputParameter* hdf5_output_param_; - ::google::protobuf::uint32 concat_dim_; - mutable int _cached_size_; - ::google::protobuf::uint32 _has_bits_[(38 + 31) / 32]; - - friend void protobuf_AddDesc_caffe_2eproto(); + friend void protobuf_InitDefaults_caffe_2eproto_impl(); + friend void protobuf_AddDesc_caffe_2eproto_impl(); friend void protobuf_AssignDesc_caffe_2eproto(); friend void protobuf_ShutdownFile_caffe_2eproto(); void InitAsDefaultInstance(); - static V0LayerParameter* default_instance_; }; +extern ::google::protobuf::internal::ExplicitlyConstructed V0LayerParameter_default_instance_; + // ------------------------------------------------------------------- -class PReLUParameter : public ::google::protobuf::Message { +class PReLUParameter : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:caffe.PReLUParameter) */ { public: PReLUParameter(); virtual ~PReLUParameter(); @@ -9561,21 +10542,25 @@ class PReLUParameter : public ::google::protobuf::Message { } inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const { - return _unknown_fields_; + return _internal_metadata_.unknown_fields(); } inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() { - return &_unknown_fields_; + return _internal_metadata_.mutable_unknown_fields(); } static const ::google::protobuf::Descriptor* descriptor(); static const PReLUParameter& default_instance(); + static const PReLUParameter* internal_default_instance(); + void Swap(PReLUParameter* other); // implements Message ---------------------------------------------- - PReLUParameter* New() const; + inline PReLUParameter* New() const { return New(NULL); } + + PReLUParameter* New(::google::protobuf::Arena* arena) const; void CopyFrom(const ::google::protobuf::Message& from); void MergeFrom(const ::google::protobuf::Message& from); void CopyFrom(const PReLUParameter& from); @@ -9583,17 +10568,30 @@ class PReLUParameter : public ::google::protobuf::Message { void Clear(); bool IsInitialized() const; - int ByteSize() const; + size_t ByteSizeLong() const; bool MergePartialFromCodedStream( ::google::protobuf::io::CodedInputStream* input); void SerializeWithCachedSizes( ::google::protobuf::io::CodedOutputStream* output) const; - ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const; + ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray( + bool deterministic, ::google::protobuf::uint8* output) const; + ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const { + return InternalSerializeWithCachedSizesToArray(false, output); + } int GetCachedSize() const { return _cached_size_; } private: void SharedCtor(); void SharedDtor(); void SetCachedSize(int size) const; + void InternalSwap(PReLUParameter* other); + void UnsafeMergeFrom(const PReLUParameter& from); + private: + inline ::google::protobuf::Arena* GetArenaNoVirtual() const { + return _internal_metadata_.arena(); + } + inline void* MaybeArenaPtr() const { + return _internal_metadata_.raw_arena_ptr(); + } public: ::google::protobuf::Metadata GetMetadata() const; @@ -9603,20 +10601,20 @@ class PReLUParameter : public ::google::protobuf::Message { // accessors ------------------------------------------------------- // optional .caffe.FillerParameter filler = 1; - inline bool has_filler() const; - inline void clear_filler(); + bool has_filler() const; + void clear_filler(); static const int kFillerFieldNumber = 1; - inline const ::caffe::FillerParameter& filler() const; - inline ::caffe::FillerParameter* mutable_filler(); - inline ::caffe::FillerParameter* release_filler(); - inline void set_allocated_filler(::caffe::FillerParameter* filler); + const ::caffe::FillerParameter& filler() const; + ::caffe::FillerParameter* mutable_filler(); + ::caffe::FillerParameter* release_filler(); + void set_allocated_filler(::caffe::FillerParameter* filler); // optional bool channel_shared = 2 [default = false]; - inline bool has_channel_shared() const; - inline void clear_channel_shared(); + bool has_channel_shared() const; + void clear_channel_shared(); static const int kChannelSharedFieldNumber = 2; - inline bool channel_shared() const; - inline void set_channel_shared(bool value); + bool channel_shared() const; + void set_channel_shared(bool value); // @@protoc_insertion_point(class_scope:caffe.PReLUParameter) private: @@ -9625,24 +10623,23 @@ class PReLUParameter : public ::google::protobuf::Message { inline void set_has_channel_shared(); inline void clear_has_channel_shared(); - ::google::protobuf::UnknownFieldSet _unknown_fields_; - + ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_; + ::google::protobuf::internal::HasBits<1> _has_bits_; + mutable int _cached_size_; ::caffe::FillerParameter* filler_; bool channel_shared_; - - mutable int _cached_size_; - ::google::protobuf::uint32 _has_bits_[(2 + 31) / 32]; - - friend void protobuf_AddDesc_caffe_2eproto(); + friend void protobuf_InitDefaults_caffe_2eproto_impl(); + friend void protobuf_AddDesc_caffe_2eproto_impl(); friend void protobuf_AssignDesc_caffe_2eproto(); friend void protobuf_ShutdownFile_caffe_2eproto(); void InitAsDefaultInstance(); - static PReLUParameter* default_instance_; }; +extern ::google::protobuf::internal::ExplicitlyConstructed PReLUParameter_default_instance_; + // ------------------------------------------------------------------- -class NormalizedBBox : public ::google::protobuf::Message { +class NormalizedBBox : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:caffe.NormalizedBBox) */ { public: NormalizedBBox(); virtual ~NormalizedBBox(); @@ -9655,21 +10652,25 @@ class NormalizedBBox : public ::google::protobuf::Message { } inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const { - return _unknown_fields_; + return _internal_metadata_.unknown_fields(); } inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() { - return &_unknown_fields_; + return _internal_metadata_.mutable_unknown_fields(); } static const ::google::protobuf::Descriptor* descriptor(); static const NormalizedBBox& default_instance(); + static const NormalizedBBox* internal_default_instance(); + void Swap(NormalizedBBox* other); // implements Message ---------------------------------------------- - NormalizedBBox* New() const; + inline NormalizedBBox* New() const { return New(NULL); } + + NormalizedBBox* New(::google::protobuf::Arena* arena) const; void CopyFrom(const ::google::protobuf::Message& from); void MergeFrom(const ::google::protobuf::Message& from); void CopyFrom(const NormalizedBBox& from); @@ -9677,17 +10678,30 @@ class NormalizedBBox : public ::google::protobuf::Message { void Clear(); bool IsInitialized() const; - int ByteSize() const; + size_t ByteSizeLong() const; bool MergePartialFromCodedStream( ::google::protobuf::io::CodedInputStream* input); void SerializeWithCachedSizes( ::google::protobuf::io::CodedOutputStream* output) const; - ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const; + ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray( + bool deterministic, ::google::protobuf::uint8* output) const; + ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const { + return InternalSerializeWithCachedSizesToArray(false, output); + } int GetCachedSize() const { return _cached_size_; } private: void SharedCtor(); void SharedDtor(); void SetCachedSize(int size) const; + void InternalSwap(NormalizedBBox* other); + void UnsafeMergeFrom(const NormalizedBBox& from); + private: + inline ::google::protobuf::Arena* GetArenaNoVirtual() const { + return _internal_metadata_.arena(); + } + inline void* MaybeArenaPtr() const { + return _internal_metadata_.raw_arena_ptr(); + } public: ::google::protobuf::Metadata GetMetadata() const; @@ -9697,60 +10711,60 @@ class NormalizedBBox : public ::google::protobuf::Message { // accessors ------------------------------------------------------- // optional float xmin = 1; - inline bool has_xmin() const; - inline void clear_xmin(); + bool has_xmin() const; + void clear_xmin(); static const int kXminFieldNumber = 1; - inline float xmin() const; - inline void set_xmin(float value); + float xmin() const; + void set_xmin(float value); // optional float ymin = 2; - inline bool has_ymin() const; - inline void clear_ymin(); + bool has_ymin() const; + void clear_ymin(); static const int kYminFieldNumber = 2; - inline float ymin() const; - inline void set_ymin(float value); + float ymin() const; + void set_ymin(float value); // optional float xmax = 3; - inline bool has_xmax() const; - inline void clear_xmax(); + bool has_xmax() const; + void clear_xmax(); static const int kXmaxFieldNumber = 3; - inline float xmax() const; - inline void set_xmax(float value); + float xmax() const; + void set_xmax(float value); // optional float ymax = 4; - inline bool has_ymax() const; - inline void clear_ymax(); + bool has_ymax() const; + void clear_ymax(); static const int kYmaxFieldNumber = 4; - inline float ymax() const; - inline void set_ymax(float value); + float ymax() const; + void set_ymax(float value); // optional int32 label = 5; - inline bool has_label() const; - inline void clear_label(); + bool has_label() const; + void clear_label(); static const int kLabelFieldNumber = 5; - inline ::google::protobuf::int32 label() const; - inline void set_label(::google::protobuf::int32 value); + ::google::protobuf::int32 label() const; + void set_label(::google::protobuf::int32 value); // optional bool difficult = 6; - inline bool has_difficult() const; - inline void clear_difficult(); + bool has_difficult() const; + void clear_difficult(); static const int kDifficultFieldNumber = 6; - inline bool difficult() const; - inline void set_difficult(bool value); + bool difficult() const; + void set_difficult(bool value); // optional float score = 7; - inline bool has_score() const; - inline void clear_score(); + bool has_score() const; + void clear_score(); static const int kScoreFieldNumber = 7; - inline float score() const; - inline void set_score(float value); + float score() const; + void set_score(float value); // optional float size = 8; - inline bool has_size() const; - inline void clear_size(); + bool has_size() const; + void clear_size(); static const int kSizeFieldNumber = 8; - inline float size() const; - inline void set_size(float value); + float size() const; + void set_size(float value); // @@protoc_insertion_point(class_scope:caffe.NormalizedBBox) private: @@ -9771,8 +10785,9 @@ class NormalizedBBox : public ::google::protobuf::Message { inline void set_has_size(); inline void clear_has_size(); - ::google::protobuf::UnknownFieldSet _unknown_fields_; - + ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_; + ::google::protobuf::internal::HasBits<1> _has_bits_; + mutable int _cached_size_; float xmin_; float ymin_; float xmax_; @@ -9781,22 +10796,21 @@ class NormalizedBBox : public ::google::protobuf::Message { bool difficult_; float score_; float size_; - - mutable int _cached_size_; - ::google::protobuf::uint32 _has_bits_[(8 + 31) / 32]; - - friend void protobuf_AddDesc_caffe_2eproto(); + friend void protobuf_InitDefaults_caffe_2eproto_impl(); + friend void protobuf_AddDesc_caffe_2eproto_impl(); friend void protobuf_AssignDesc_caffe_2eproto(); friend void protobuf_ShutdownFile_caffe_2eproto(); void InitAsDefaultInstance(); - static NormalizedBBox* default_instance_; }; +extern ::google::protobuf::internal::ExplicitlyConstructed NormalizedBBox_default_instance_; + // =================================================================== // =================================================================== +#if !PROTOBUF_INLINE_NOT_IN_HEADERS // BlobShape // repeated int64 dim = 1 [packed = true]; @@ -9807,23 +10821,31 @@ inline void BlobShape::clear_dim() { dim_.Clear(); } inline ::google::protobuf::int64 BlobShape::dim(int index) const { + // @@protoc_insertion_point(field_get:caffe.BlobShape.dim) return dim_.Get(index); } inline void BlobShape::set_dim(int index, ::google::protobuf::int64 value) { dim_.Set(index, value); + // @@protoc_insertion_point(field_set:caffe.BlobShape.dim) } inline void BlobShape::add_dim(::google::protobuf::int64 value) { dim_.Add(value); + // @@protoc_insertion_point(field_add:caffe.BlobShape.dim) } inline const ::google::protobuf::RepeatedField< ::google::protobuf::int64 >& BlobShape::dim() const { + // @@protoc_insertion_point(field_list:caffe.BlobShape.dim) return dim_; } inline ::google::protobuf::RepeatedField< ::google::protobuf::int64 >* BlobShape::mutable_dim() { + // @@protoc_insertion_point(field_mutable_list:caffe.BlobShape.dim) return &dim_; } +inline const BlobShape* BlobShape::internal_default_instance() { + return &BlobShape_default_instance_.get(); +} // ------------------------------------------------------------------- // BlobProto @@ -9843,14 +10865,20 @@ inline void BlobProto::clear_shape() { clear_has_shape(); } inline const ::caffe::BlobShape& BlobProto::shape() const { - return shape_ != NULL ? *shape_ : *default_instance_->shape_; + // @@protoc_insertion_point(field_get:caffe.BlobProto.shape) + return shape_ != NULL ? *shape_ + : *::caffe::BlobShape::internal_default_instance(); } inline ::caffe::BlobShape* BlobProto::mutable_shape() { set_has_shape(); - if (shape_ == NULL) shape_ = new ::caffe::BlobShape; + if (shape_ == NULL) { + shape_ = new ::caffe::BlobShape; + } + // @@protoc_insertion_point(field_mutable:caffe.BlobProto.shape) return shape_; } inline ::caffe::BlobShape* BlobProto::release_shape() { + // @@protoc_insertion_point(field_release:caffe.BlobProto.shape) clear_has_shape(); ::caffe::BlobShape* temp = shape_; shape_ = NULL; @@ -9864,6 +10892,7 @@ inline void BlobProto::set_allocated_shape(::caffe::BlobShape* shape) { } else { clear_has_shape(); } + // @@protoc_insertion_point(field_set_allocated:caffe.BlobProto.shape) } // repeated float data = 5 [packed = true]; @@ -9874,20 +10903,25 @@ inline void BlobProto::clear_data() { data_.Clear(); } inline float BlobProto::data(int index) const { + // @@protoc_insertion_point(field_get:caffe.BlobProto.data) return data_.Get(index); } inline void BlobProto::set_data(int index, float value) { data_.Set(index, value); + // @@protoc_insertion_point(field_set:caffe.BlobProto.data) } inline void BlobProto::add_data(float value) { data_.Add(value); + // @@protoc_insertion_point(field_add:caffe.BlobProto.data) } inline const ::google::protobuf::RepeatedField< float >& BlobProto::data() const { + // @@protoc_insertion_point(field_list:caffe.BlobProto.data) return data_; } inline ::google::protobuf::RepeatedField< float >* BlobProto::mutable_data() { + // @@protoc_insertion_point(field_mutable_list:caffe.BlobProto.data) return &data_; } @@ -9899,20 +10933,25 @@ inline void BlobProto::clear_diff() { diff_.Clear(); } inline float BlobProto::diff(int index) const { + // @@protoc_insertion_point(field_get:caffe.BlobProto.diff) return diff_.Get(index); } inline void BlobProto::set_diff(int index, float value) { diff_.Set(index, value); + // @@protoc_insertion_point(field_set:caffe.BlobProto.diff) } inline void BlobProto::add_diff(float value) { diff_.Add(value); + // @@protoc_insertion_point(field_add:caffe.BlobProto.diff) } inline const ::google::protobuf::RepeatedField< float >& BlobProto::diff() const { + // @@protoc_insertion_point(field_list:caffe.BlobProto.diff) return diff_; } inline ::google::protobuf::RepeatedField< float >* BlobProto::mutable_diff() { + // @@protoc_insertion_point(field_mutable_list:caffe.BlobProto.diff) return &diff_; } @@ -9931,11 +10970,13 @@ inline void BlobProto::clear_num() { clear_has_num(); } inline ::google::protobuf::int32 BlobProto::num() const { + // @@protoc_insertion_point(field_get:caffe.BlobProto.num) return num_; } inline void BlobProto::set_num(::google::protobuf::int32 value) { set_has_num(); num_ = value; + // @@protoc_insertion_point(field_set:caffe.BlobProto.num) } // optional int32 channels = 2 [default = 0]; @@ -9953,11 +10994,13 @@ inline void BlobProto::clear_channels() { clear_has_channels(); } inline ::google::protobuf::int32 BlobProto::channels() const { + // @@protoc_insertion_point(field_get:caffe.BlobProto.channels) return channels_; } inline void BlobProto::set_channels(::google::protobuf::int32 value) { set_has_channels(); channels_ = value; + // @@protoc_insertion_point(field_set:caffe.BlobProto.channels) } // optional int32 height = 3 [default = 0]; @@ -9975,11 +11018,13 @@ inline void BlobProto::clear_height() { clear_has_height(); } inline ::google::protobuf::int32 BlobProto::height() const { + // @@protoc_insertion_point(field_get:caffe.BlobProto.height) return height_; } inline void BlobProto::set_height(::google::protobuf::int32 value) { set_has_height(); height_ = value; + // @@protoc_insertion_point(field_set:caffe.BlobProto.height) } // optional int32 width = 4 [default = 0]; @@ -9997,13 +11042,18 @@ inline void BlobProto::clear_width() { clear_has_width(); } inline ::google::protobuf::int32 BlobProto::width() const { + // @@protoc_insertion_point(field_get:caffe.BlobProto.width) return width_; } inline void BlobProto::set_width(::google::protobuf::int32 value) { set_has_width(); width_ = value; + // @@protoc_insertion_point(field_set:caffe.BlobProto.width) } +inline const BlobProto* BlobProto::internal_default_instance() { + return &BlobProto_default_instance_.get(); +} // ------------------------------------------------------------------- // BlobProtoVector @@ -10016,23 +11066,31 @@ inline void BlobProtoVector::clear_blobs() { blobs_.Clear(); } inline const ::caffe::BlobProto& BlobProtoVector::blobs(int index) const { + // @@protoc_insertion_point(field_get:caffe.BlobProtoVector.blobs) return blobs_.Get(index); } inline ::caffe::BlobProto* BlobProtoVector::mutable_blobs(int index) { + // @@protoc_insertion_point(field_mutable:caffe.BlobProtoVector.blobs) return blobs_.Mutable(index); } inline ::caffe::BlobProto* BlobProtoVector::add_blobs() { + // @@protoc_insertion_point(field_add:caffe.BlobProtoVector.blobs) return blobs_.Add(); } -inline const ::google::protobuf::RepeatedPtrField< ::caffe::BlobProto >& -BlobProtoVector::blobs() const { - return blobs_; -} inline ::google::protobuf::RepeatedPtrField< ::caffe::BlobProto >* BlobProtoVector::mutable_blobs() { + // @@protoc_insertion_point(field_mutable_list:caffe.BlobProtoVector.blobs) return &blobs_; } +inline const ::google::protobuf::RepeatedPtrField< ::caffe::BlobProto >& +BlobProtoVector::blobs() const { + // @@protoc_insertion_point(field_list:caffe.BlobProtoVector.blobs) + return blobs_; +} +inline const BlobProtoVector* BlobProtoVector::internal_default_instance() { + return &BlobProtoVector_default_instance_.get(); +} // ------------------------------------------------------------------- // CropParameter @@ -10052,11 +11110,13 @@ inline void CropParameter::clear_axis() { clear_has_axis(); } inline ::google::protobuf::int32 CropParameter::axis() const { + // @@protoc_insertion_point(field_get:caffe.CropParameter.axis) return axis_; } inline void CropParameter::set_axis(::google::protobuf::int32 value) { set_has_axis(); axis_ = value; + // @@protoc_insertion_point(field_set:caffe.CropParameter.axis) } // repeated uint32 offset = 2; @@ -10067,23 +11127,31 @@ inline void CropParameter::clear_offset() { offset_.Clear(); } inline ::google::protobuf::uint32 CropParameter::offset(int index) const { + // @@protoc_insertion_point(field_get:caffe.CropParameter.offset) return offset_.Get(index); } inline void CropParameter::set_offset(int index, ::google::protobuf::uint32 value) { offset_.Set(index, value); + // @@protoc_insertion_point(field_set:caffe.CropParameter.offset) } inline void CropParameter::add_offset(::google::protobuf::uint32 value) { offset_.Add(value); + // @@protoc_insertion_point(field_add:caffe.CropParameter.offset) } inline const ::google::protobuf::RepeatedField< ::google::protobuf::uint32 >& CropParameter::offset() const { + // @@protoc_insertion_point(field_list:caffe.CropParameter.offset) return offset_; } inline ::google::protobuf::RepeatedField< ::google::protobuf::uint32 >* CropParameter::mutable_offset() { + // @@protoc_insertion_point(field_mutable_list:caffe.CropParameter.offset) return &offset_; } +inline const CropParameter* CropParameter::internal_default_instance() { + return &CropParameter_default_instance_.get(); +} // ------------------------------------------------------------------- // PermuteParameter @@ -10096,23 +11164,31 @@ inline void PermuteParameter::clear_order() { order_.Clear(); } inline ::google::protobuf::uint32 PermuteParameter::order(int index) const { + // @@protoc_insertion_point(field_get:caffe.PermuteParameter.order) return order_.Get(index); } inline void PermuteParameter::set_order(int index, ::google::protobuf::uint32 value) { order_.Set(index, value); + // @@protoc_insertion_point(field_set:caffe.PermuteParameter.order) } inline void PermuteParameter::add_order(::google::protobuf::uint32 value) { order_.Add(value); + // @@protoc_insertion_point(field_add:caffe.PermuteParameter.order) } inline const ::google::protobuf::RepeatedField< ::google::protobuf::uint32 >& PermuteParameter::order() const { + // @@protoc_insertion_point(field_list:caffe.PermuteParameter.order) return order_; } inline ::google::protobuf::RepeatedField< ::google::protobuf::uint32 >* PermuteParameter::mutable_order() { + // @@protoc_insertion_point(field_mutable_list:caffe.PermuteParameter.order) return &order_; } +inline const PermuteParameter* PermuteParameter::internal_default_instance() { + return &PermuteParameter_default_instance_.get(); +} // ------------------------------------------------------------------- // NormalizeBBoxParameter @@ -10132,11 +11208,13 @@ inline void NormalizeBBoxParameter::clear_across_spatial() { clear_has_across_spatial(); } inline bool NormalizeBBoxParameter::across_spatial() const { + // @@protoc_insertion_point(field_get:caffe.NormalizeBBoxParameter.across_spatial) return across_spatial_; } inline void NormalizeBBoxParameter::set_across_spatial(bool value) { set_has_across_spatial(); across_spatial_ = value; + // @@protoc_insertion_point(field_set:caffe.NormalizeBBoxParameter.across_spatial) } // optional .caffe.FillerParameter scale_filler = 2; @@ -10154,14 +11232,20 @@ inline void NormalizeBBoxParameter::clear_scale_filler() { clear_has_scale_filler(); } inline const ::caffe::FillerParameter& NormalizeBBoxParameter::scale_filler() const { - return scale_filler_ != NULL ? *scale_filler_ : *default_instance_->scale_filler_; + // @@protoc_insertion_point(field_get:caffe.NormalizeBBoxParameter.scale_filler) + return scale_filler_ != NULL ? *scale_filler_ + : *::caffe::FillerParameter::internal_default_instance(); } inline ::caffe::FillerParameter* NormalizeBBoxParameter::mutable_scale_filler() { set_has_scale_filler(); - if (scale_filler_ == NULL) scale_filler_ = new ::caffe::FillerParameter; + if (scale_filler_ == NULL) { + scale_filler_ = new ::caffe::FillerParameter; + } + // @@protoc_insertion_point(field_mutable:caffe.NormalizeBBoxParameter.scale_filler) return scale_filler_; } inline ::caffe::FillerParameter* NormalizeBBoxParameter::release_scale_filler() { + // @@protoc_insertion_point(field_release:caffe.NormalizeBBoxParameter.scale_filler) clear_has_scale_filler(); ::caffe::FillerParameter* temp = scale_filler_; scale_filler_ = NULL; @@ -10175,6 +11259,7 @@ inline void NormalizeBBoxParameter::set_allocated_scale_filler(::caffe::FillerPa } else { clear_has_scale_filler(); } + // @@protoc_insertion_point(field_set_allocated:caffe.NormalizeBBoxParameter.scale_filler) } // optional bool channel_shared = 3 [default = true]; @@ -10192,11 +11277,13 @@ inline void NormalizeBBoxParameter::clear_channel_shared() { clear_has_channel_shared(); } inline bool NormalizeBBoxParameter::channel_shared() const { + // @@protoc_insertion_point(field_get:caffe.NormalizeBBoxParameter.channel_shared) return channel_shared_; } inline void NormalizeBBoxParameter::set_channel_shared(bool value) { set_has_channel_shared(); channel_shared_ = value; + // @@protoc_insertion_point(field_set:caffe.NormalizeBBoxParameter.channel_shared) } // optional float eps = 4 [default = 1e-10]; @@ -10214,13 +11301,18 @@ inline void NormalizeBBoxParameter::clear_eps() { clear_has_eps(); } inline float NormalizeBBoxParameter::eps() const { + // @@protoc_insertion_point(field_get:caffe.NormalizeBBoxParameter.eps) return eps_; } inline void NormalizeBBoxParameter::set_eps(float value) { set_has_eps(); eps_ = value; + // @@protoc_insertion_point(field_set:caffe.NormalizeBBoxParameter.eps) } +inline const NormalizeBBoxParameter* NormalizeBBoxParameter::internal_default_instance() { + return &NormalizeBBoxParameter_default_instance_.get(); +} // ------------------------------------------------------------------- // PriorBoxParameter @@ -10240,11 +11332,13 @@ inline void PriorBoxParameter::clear_min_size() { clear_has_min_size(); } inline float PriorBoxParameter::min_size() const { + // @@protoc_insertion_point(field_get:caffe.PriorBoxParameter.min_size) return min_size_; } inline void PriorBoxParameter::set_min_size(float value) { set_has_min_size(); min_size_ = value; + // @@protoc_insertion_point(field_set:caffe.PriorBoxParameter.min_size) } // optional float max_size = 2; @@ -10262,11 +11356,13 @@ inline void PriorBoxParameter::clear_max_size() { clear_has_max_size(); } inline float PriorBoxParameter::max_size() const { + // @@protoc_insertion_point(field_get:caffe.PriorBoxParameter.max_size) return max_size_; } inline void PriorBoxParameter::set_max_size(float value) { set_has_max_size(); max_size_ = value; + // @@protoc_insertion_point(field_set:caffe.PriorBoxParameter.max_size) } // repeated float aspect_ratio = 3; @@ -10277,20 +11373,25 @@ inline void PriorBoxParameter::clear_aspect_ratio() { aspect_ratio_.Clear(); } inline float PriorBoxParameter::aspect_ratio(int index) const { + // @@protoc_insertion_point(field_get:caffe.PriorBoxParameter.aspect_ratio) return aspect_ratio_.Get(index); } inline void PriorBoxParameter::set_aspect_ratio(int index, float value) { aspect_ratio_.Set(index, value); + // @@protoc_insertion_point(field_set:caffe.PriorBoxParameter.aspect_ratio) } inline void PriorBoxParameter::add_aspect_ratio(float value) { aspect_ratio_.Add(value); + // @@protoc_insertion_point(field_add:caffe.PriorBoxParameter.aspect_ratio) } inline const ::google::protobuf::RepeatedField< float >& PriorBoxParameter::aspect_ratio() const { + // @@protoc_insertion_point(field_list:caffe.PriorBoxParameter.aspect_ratio) return aspect_ratio_; } inline ::google::protobuf::RepeatedField< float >* PriorBoxParameter::mutable_aspect_ratio() { + // @@protoc_insertion_point(field_mutable_list:caffe.PriorBoxParameter.aspect_ratio) return &aspect_ratio_; } @@ -10309,11 +11410,13 @@ inline void PriorBoxParameter::clear_flip() { clear_has_flip(); } inline bool PriorBoxParameter::flip() const { + // @@protoc_insertion_point(field_get:caffe.PriorBoxParameter.flip) return flip_; } inline void PriorBoxParameter::set_flip(bool value) { set_has_flip(); flip_ = value; + // @@protoc_insertion_point(field_set:caffe.PriorBoxParameter.flip) } // optional bool clip = 5 [default = true]; @@ -10331,11 +11434,13 @@ inline void PriorBoxParameter::clear_clip() { clear_has_clip(); } inline bool PriorBoxParameter::clip() const { + // @@protoc_insertion_point(field_get:caffe.PriorBoxParameter.clip) return clip_; } inline void PriorBoxParameter::set_clip(bool value) { set_has_clip(); clip_ = value; + // @@protoc_insertion_point(field_set:caffe.PriorBoxParameter.clip) } // repeated float variance = 6; @@ -10346,23 +11451,31 @@ inline void PriorBoxParameter::clear_variance() { variance_.Clear(); } inline float PriorBoxParameter::variance(int index) const { + // @@protoc_insertion_point(field_get:caffe.PriorBoxParameter.variance) return variance_.Get(index); } inline void PriorBoxParameter::set_variance(int index, float value) { variance_.Set(index, value); + // @@protoc_insertion_point(field_set:caffe.PriorBoxParameter.variance) } inline void PriorBoxParameter::add_variance(float value) { variance_.Add(value); + // @@protoc_insertion_point(field_add:caffe.PriorBoxParameter.variance) } inline const ::google::protobuf::RepeatedField< float >& PriorBoxParameter::variance() const { + // @@protoc_insertion_point(field_list:caffe.PriorBoxParameter.variance) return variance_; } inline ::google::protobuf::RepeatedField< float >* PriorBoxParameter::mutable_variance() { + // @@protoc_insertion_point(field_mutable_list:caffe.PriorBoxParameter.variance) return &variance_; } +inline const PriorBoxParameter* PriorBoxParameter::internal_default_instance() { + return &PriorBoxParameter_default_instance_.get(); +} // ------------------------------------------------------------------- // DetectionOutputParameter @@ -10382,11 +11495,13 @@ inline void DetectionOutputParameter::clear_num_classes() { clear_has_num_classes(); } inline ::google::protobuf::uint32 DetectionOutputParameter::num_classes() const { + // @@protoc_insertion_point(field_get:caffe.DetectionOutputParameter.num_classes) return num_classes_; } inline void DetectionOutputParameter::set_num_classes(::google::protobuf::uint32 value) { set_has_num_classes(); num_classes_ = value; + // @@protoc_insertion_point(field_set:caffe.DetectionOutputParameter.num_classes) } // optional bool share_location = 2 [default = true]; @@ -10404,11 +11519,13 @@ inline void DetectionOutputParameter::clear_share_location() { clear_has_share_location(); } inline bool DetectionOutputParameter::share_location() const { + // @@protoc_insertion_point(field_get:caffe.DetectionOutputParameter.share_location) return share_location_; } inline void DetectionOutputParameter::set_share_location(bool value) { set_has_share_location(); share_location_ = value; + // @@protoc_insertion_point(field_set:caffe.DetectionOutputParameter.share_location) } // optional int32 background_label_id = 3 [default = 0]; @@ -10426,11 +11543,13 @@ inline void DetectionOutputParameter::clear_background_label_id() { clear_has_background_label_id(); } inline ::google::protobuf::int32 DetectionOutputParameter::background_label_id() const { + // @@protoc_insertion_point(field_get:caffe.DetectionOutputParameter.background_label_id) return background_label_id_; } inline void DetectionOutputParameter::set_background_label_id(::google::protobuf::int32 value) { set_has_background_label_id(); background_label_id_ = value; + // @@protoc_insertion_point(field_set:caffe.DetectionOutputParameter.background_label_id) } // optional .caffe.PriorBoxParameter.CodeType code_type = 6 [default = CORNER]; @@ -10448,12 +11567,14 @@ inline void DetectionOutputParameter::clear_code_type() { clear_has_code_type(); } inline ::caffe::PriorBoxParameter_CodeType DetectionOutputParameter::code_type() const { + // @@protoc_insertion_point(field_get:caffe.DetectionOutputParameter.code_type) return static_cast< ::caffe::PriorBoxParameter_CodeType >(code_type_); } inline void DetectionOutputParameter::set_code_type(::caffe::PriorBoxParameter_CodeType value) { assert(::caffe::PriorBoxParameter_CodeType_IsValid(value)); set_has_code_type(); code_type_ = value; + // @@protoc_insertion_point(field_set:caffe.DetectionOutputParameter.code_type) } // optional bool variance_encoded_in_target = 8 [default = false]; @@ -10471,11 +11592,13 @@ inline void DetectionOutputParameter::clear_variance_encoded_in_target() { clear_has_variance_encoded_in_target(); } inline bool DetectionOutputParameter::variance_encoded_in_target() const { + // @@protoc_insertion_point(field_get:caffe.DetectionOutputParameter.variance_encoded_in_target) return variance_encoded_in_target_; } inline void DetectionOutputParameter::set_variance_encoded_in_target(bool value) { set_has_variance_encoded_in_target(); variance_encoded_in_target_ = value; + // @@protoc_insertion_point(field_set:caffe.DetectionOutputParameter.variance_encoded_in_target) } // optional int32 keep_top_k = 7 [default = -1]; @@ -10493,11 +11616,13 @@ inline void DetectionOutputParameter::clear_keep_top_k() { clear_has_keep_top_k(); } inline ::google::protobuf::int32 DetectionOutputParameter::keep_top_k() const { + // @@protoc_insertion_point(field_get:caffe.DetectionOutputParameter.keep_top_k) return keep_top_k_; } inline void DetectionOutputParameter::set_keep_top_k(::google::protobuf::int32 value) { set_has_keep_top_k(); keep_top_k_ = value; + // @@protoc_insertion_point(field_set:caffe.DetectionOutputParameter.keep_top_k) } // optional float confidence_threshold = 9; @@ -10515,11 +11640,13 @@ inline void DetectionOutputParameter::clear_confidence_threshold() { clear_has_confidence_threshold(); } inline float DetectionOutputParameter::confidence_threshold() const { + // @@protoc_insertion_point(field_get:caffe.DetectionOutputParameter.confidence_threshold) return confidence_threshold_; } inline void DetectionOutputParameter::set_confidence_threshold(float value) { set_has_confidence_threshold(); confidence_threshold_ = value; + // @@protoc_insertion_point(field_set:caffe.DetectionOutputParameter.confidence_threshold) } // optional float nms_threshold = 10 [default = 0.3]; @@ -10537,11 +11664,13 @@ inline void DetectionOutputParameter::clear_nms_threshold() { clear_has_nms_threshold(); } inline float DetectionOutputParameter::nms_threshold() const { + // @@protoc_insertion_point(field_get:caffe.DetectionOutputParameter.nms_threshold) return nms_threshold_; } inline void DetectionOutputParameter::set_nms_threshold(float value) { set_has_nms_threshold(); nms_threshold_ = value; + // @@protoc_insertion_point(field_set:caffe.DetectionOutputParameter.nms_threshold) } // optional int32 top_k = 11; @@ -10559,13 +11688,18 @@ inline void DetectionOutputParameter::clear_top_k() { clear_has_top_k(); } inline ::google::protobuf::int32 DetectionOutputParameter::top_k() const { + // @@protoc_insertion_point(field_get:caffe.DetectionOutputParameter.top_k) return top_k_; } inline void DetectionOutputParameter::set_top_k(::google::protobuf::int32 value) { set_has_top_k(); top_k_ = value; + // @@protoc_insertion_point(field_set:caffe.DetectionOutputParameter.top_k) } +inline const DetectionOutputParameter* DetectionOutputParameter::internal_default_instance() { + return &DetectionOutputParameter_default_instance_.get(); +} // ------------------------------------------------------------------- // Datum @@ -10585,11 +11719,13 @@ inline void Datum::clear_channels() { clear_has_channels(); } inline ::google::protobuf::int32 Datum::channels() const { + // @@protoc_insertion_point(field_get:caffe.Datum.channels) return channels_; } inline void Datum::set_channels(::google::protobuf::int32 value) { set_has_channels(); channels_ = value; + // @@protoc_insertion_point(field_set:caffe.Datum.channels) } // optional int32 height = 2; @@ -10607,11 +11743,13 @@ inline void Datum::clear_height() { clear_has_height(); } inline ::google::protobuf::int32 Datum::height() const { + // @@protoc_insertion_point(field_get:caffe.Datum.height) return height_; } inline void Datum::set_height(::google::protobuf::int32 value) { set_has_height(); height_ = value; + // @@protoc_insertion_point(field_set:caffe.Datum.height) } // optional int32 width = 3; @@ -10629,11 +11767,13 @@ inline void Datum::clear_width() { clear_has_width(); } inline ::google::protobuf::int32 Datum::width() const { + // @@protoc_insertion_point(field_get:caffe.Datum.width) return width_; } inline void Datum::set_width(::google::protobuf::int32 value) { set_has_width(); width_ = value; + // @@protoc_insertion_point(field_set:caffe.Datum.width) } // optional bytes data = 4; @@ -10647,63 +11787,47 @@ inline void Datum::clear_has_data() { _has_bits_[0] &= ~0x00000008u; } inline void Datum::clear_data() { - if (data_ != &::google::protobuf::internal::kEmptyString) { - data_->clear(); - } + data_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); clear_has_data(); } inline const ::std::string& Datum::data() const { - return *data_; + // @@protoc_insertion_point(field_get:caffe.Datum.data) + return data_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } inline void Datum::set_data(const ::std::string& value) { set_has_data(); - if (data_ == &::google::protobuf::internal::kEmptyString) { - data_ = new ::std::string; - } - data_->assign(value); + data_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); + // @@protoc_insertion_point(field_set:caffe.Datum.data) } inline void Datum::set_data(const char* value) { set_has_data(); - if (data_ == &::google::protobuf::internal::kEmptyString) { - data_ = new ::std::string; - } - data_->assign(value); + data_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); + // @@protoc_insertion_point(field_set_char:caffe.Datum.data) } inline void Datum::set_data(const void* value, size_t size) { set_has_data(); - if (data_ == &::google::protobuf::internal::kEmptyString) { - data_ = new ::std::string; - } - data_->assign(reinterpret_cast(value), size); + data_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), + ::std::string(reinterpret_cast(value), size)); + // @@protoc_insertion_point(field_set_pointer:caffe.Datum.data) } inline ::std::string* Datum::mutable_data() { set_has_data(); - if (data_ == &::google::protobuf::internal::kEmptyString) { - data_ = new ::std::string; - } - return data_; + // @@protoc_insertion_point(field_mutable:caffe.Datum.data) + return data_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } inline ::std::string* Datum::release_data() { + // @@protoc_insertion_point(field_release:caffe.Datum.data) clear_has_data(); - if (data_ == &::google::protobuf::internal::kEmptyString) { - return NULL; - } else { - ::std::string* temp = data_; - data_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); - return temp; - } + return data_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } inline void Datum::set_allocated_data(::std::string* data) { - if (data_ != &::google::protobuf::internal::kEmptyString) { - delete data_; - } - if (data) { + if (data != NULL) { set_has_data(); - data_ = data; } else { clear_has_data(); - data_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); } + data_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), data); + // @@protoc_insertion_point(field_set_allocated:caffe.Datum.data) } // optional int32 label = 5; @@ -10721,11 +11845,13 @@ inline void Datum::clear_label() { clear_has_label(); } inline ::google::protobuf::int32 Datum::label() const { + // @@protoc_insertion_point(field_get:caffe.Datum.label) return label_; } inline void Datum::set_label(::google::protobuf::int32 value) { set_has_label(); label_ = value; + // @@protoc_insertion_point(field_set:caffe.Datum.label) } // repeated float float_data = 6; @@ -10736,20 +11862,25 @@ inline void Datum::clear_float_data() { float_data_.Clear(); } inline float Datum::float_data(int index) const { + // @@protoc_insertion_point(field_get:caffe.Datum.float_data) return float_data_.Get(index); } inline void Datum::set_float_data(int index, float value) { float_data_.Set(index, value); + // @@protoc_insertion_point(field_set:caffe.Datum.float_data) } inline void Datum::add_float_data(float value) { float_data_.Add(value); + // @@protoc_insertion_point(field_add:caffe.Datum.float_data) } inline const ::google::protobuf::RepeatedField< float >& Datum::float_data() const { + // @@protoc_insertion_point(field_list:caffe.Datum.float_data) return float_data_; } inline ::google::protobuf::RepeatedField< float >* Datum::mutable_float_data() { + // @@protoc_insertion_point(field_mutable_list:caffe.Datum.float_data) return &float_data_; } @@ -10768,13 +11899,18 @@ inline void Datum::clear_encoded() { clear_has_encoded(); } inline bool Datum::encoded() const { + // @@protoc_insertion_point(field_get:caffe.Datum.encoded) return encoded_; } inline void Datum::set_encoded(bool value) { set_has_encoded(); encoded_ = value; + // @@protoc_insertion_point(field_set:caffe.Datum.encoded) } +inline const Datum* Datum::internal_default_instance() { + return &Datum_default_instance_.get(); +} // ------------------------------------------------------------------- // FillerParameter @@ -10790,63 +11926,47 @@ inline void FillerParameter::clear_has_type() { _has_bits_[0] &= ~0x00000001u; } inline void FillerParameter::clear_type() { - if (type_ != _default_type_) { - type_->assign(*_default_type_); - } + type_.ClearToDefaultNoArena(_default_type_); clear_has_type(); } inline const ::std::string& FillerParameter::type() const { - return *type_; + // @@protoc_insertion_point(field_get:caffe.FillerParameter.type) + return type_.GetNoArena(_default_type_); } inline void FillerParameter::set_type(const ::std::string& value) { set_has_type(); - if (type_ == _default_type_) { - type_ = new ::std::string; - } - type_->assign(value); + type_.SetNoArena(_default_type_, value); + // @@protoc_insertion_point(field_set:caffe.FillerParameter.type) } inline void FillerParameter::set_type(const char* value) { set_has_type(); - if (type_ == _default_type_) { - type_ = new ::std::string; - } - type_->assign(value); + type_.SetNoArena(_default_type_, ::std::string(value)); + // @@protoc_insertion_point(field_set_char:caffe.FillerParameter.type) } inline void FillerParameter::set_type(const char* value, size_t size) { set_has_type(); - if (type_ == _default_type_) { - type_ = new ::std::string; - } - type_->assign(reinterpret_cast(value), size); + type_.SetNoArena(_default_type_, + ::std::string(reinterpret_cast(value), size)); + // @@protoc_insertion_point(field_set_pointer:caffe.FillerParameter.type) } inline ::std::string* FillerParameter::mutable_type() { set_has_type(); - if (type_ == _default_type_) { - type_ = new ::std::string(*_default_type_); - } - return type_; + // @@protoc_insertion_point(field_mutable:caffe.FillerParameter.type) + return type_.MutableNoArena(_default_type_); } inline ::std::string* FillerParameter::release_type() { + // @@protoc_insertion_point(field_release:caffe.FillerParameter.type) clear_has_type(); - if (type_ == _default_type_) { - return NULL; - } else { - ::std::string* temp = type_; - type_ = const_cast< ::std::string*>(_default_type_); - return temp; - } + return type_.ReleaseNoArena(_default_type_); } inline void FillerParameter::set_allocated_type(::std::string* type) { - if (type_ != _default_type_) { - delete type_; - } - if (type) { + if (type != NULL) { set_has_type(); - type_ = type; } else { clear_has_type(); - type_ = const_cast< ::std::string*>(_default_type_); } + type_.SetAllocatedNoArena(_default_type_, type); + // @@protoc_insertion_point(field_set_allocated:caffe.FillerParameter.type) } // optional float value = 2 [default = 0]; @@ -10864,11 +11984,13 @@ inline void FillerParameter::clear_value() { clear_has_value(); } inline float FillerParameter::value() const { + // @@protoc_insertion_point(field_get:caffe.FillerParameter.value) return value_; } inline void FillerParameter::set_value(float value) { set_has_value(); value_ = value; + // @@protoc_insertion_point(field_set:caffe.FillerParameter.value) } // optional float min = 3 [default = 0]; @@ -10886,11 +12008,13 @@ inline void FillerParameter::clear_min() { clear_has_min(); } inline float FillerParameter::min() const { + // @@protoc_insertion_point(field_get:caffe.FillerParameter.min) return min_; } inline void FillerParameter::set_min(float value) { set_has_min(); min_ = value; + // @@protoc_insertion_point(field_set:caffe.FillerParameter.min) } // optional float max = 4 [default = 1]; @@ -10908,11 +12032,13 @@ inline void FillerParameter::clear_max() { clear_has_max(); } inline float FillerParameter::max() const { + // @@protoc_insertion_point(field_get:caffe.FillerParameter.max) return max_; } inline void FillerParameter::set_max(float value) { set_has_max(); max_ = value; + // @@protoc_insertion_point(field_set:caffe.FillerParameter.max) } // optional float mean = 5 [default = 0]; @@ -10930,11 +12056,13 @@ inline void FillerParameter::clear_mean() { clear_has_mean(); } inline float FillerParameter::mean() const { + // @@protoc_insertion_point(field_get:caffe.FillerParameter.mean) return mean_; } inline void FillerParameter::set_mean(float value) { set_has_mean(); mean_ = value; + // @@protoc_insertion_point(field_set:caffe.FillerParameter.mean) } // optional float std = 6 [default = 1]; @@ -10952,11 +12080,13 @@ inline void FillerParameter::clear_std() { clear_has_std(); } inline float FillerParameter::std() const { + // @@protoc_insertion_point(field_get:caffe.FillerParameter.std) return std_; } inline void FillerParameter::set_std(float value) { set_has_std(); std_ = value; + // @@protoc_insertion_point(field_set:caffe.FillerParameter.std) } // optional int32 sparse = 7 [default = -1]; @@ -10974,11 +12104,13 @@ inline void FillerParameter::clear_sparse() { clear_has_sparse(); } inline ::google::protobuf::int32 FillerParameter::sparse() const { + // @@protoc_insertion_point(field_get:caffe.FillerParameter.sparse) return sparse_; } inline void FillerParameter::set_sparse(::google::protobuf::int32 value) { set_has_sparse(); sparse_ = value; + // @@protoc_insertion_point(field_set:caffe.FillerParameter.sparse) } // optional .caffe.FillerParameter.VarianceNorm variance_norm = 8 [default = FAN_IN]; @@ -10996,14 +12128,19 @@ inline void FillerParameter::clear_variance_norm() { clear_has_variance_norm(); } inline ::caffe::FillerParameter_VarianceNorm FillerParameter::variance_norm() const { + // @@protoc_insertion_point(field_get:caffe.FillerParameter.variance_norm) return static_cast< ::caffe::FillerParameter_VarianceNorm >(variance_norm_); } inline void FillerParameter::set_variance_norm(::caffe::FillerParameter_VarianceNorm value) { assert(::caffe::FillerParameter_VarianceNorm_IsValid(value)); set_has_variance_norm(); variance_norm_ = value; + // @@protoc_insertion_point(field_set:caffe.FillerParameter.variance_norm) } +inline const FillerParameter* FillerParameter::internal_default_instance() { + return &FillerParameter_default_instance_.get(); +} // ------------------------------------------------------------------- // NetParameter @@ -11019,63 +12156,47 @@ inline void NetParameter::clear_has_name() { _has_bits_[0] &= ~0x00000001u; } inline void NetParameter::clear_name() { - if (name_ != &::google::protobuf::internal::kEmptyString) { - name_->clear(); - } + name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); clear_has_name(); } inline const ::std::string& NetParameter::name() const { - return *name_; + // @@protoc_insertion_point(field_get:caffe.NetParameter.name) + return name_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } inline void NetParameter::set_name(const ::std::string& value) { set_has_name(); - if (name_ == &::google::protobuf::internal::kEmptyString) { - name_ = new ::std::string; - } - name_->assign(value); + name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); + // @@protoc_insertion_point(field_set:caffe.NetParameter.name) } inline void NetParameter::set_name(const char* value) { set_has_name(); - if (name_ == &::google::protobuf::internal::kEmptyString) { - name_ = new ::std::string; - } - name_->assign(value); + name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); + // @@protoc_insertion_point(field_set_char:caffe.NetParameter.name) } inline void NetParameter::set_name(const char* value, size_t size) { set_has_name(); - if (name_ == &::google::protobuf::internal::kEmptyString) { - name_ = new ::std::string; - } - name_->assign(reinterpret_cast(value), size); + name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), + ::std::string(reinterpret_cast(value), size)); + // @@protoc_insertion_point(field_set_pointer:caffe.NetParameter.name) } inline ::std::string* NetParameter::mutable_name() { set_has_name(); - if (name_ == &::google::protobuf::internal::kEmptyString) { - name_ = new ::std::string; - } - return name_; + // @@protoc_insertion_point(field_mutable:caffe.NetParameter.name) + return name_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } inline ::std::string* NetParameter::release_name() { + // @@protoc_insertion_point(field_release:caffe.NetParameter.name) clear_has_name(); - if (name_ == &::google::protobuf::internal::kEmptyString) { - return NULL; - } else { - ::std::string* temp = name_; - name_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); - return temp; - } + return name_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } inline void NetParameter::set_allocated_name(::std::string* name) { - if (name_ != &::google::protobuf::internal::kEmptyString) { - delete name_; - } - if (name) { + if (name != NULL) { set_has_name(); - name_ = name; } else { clear_has_name(); - name_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); } + name_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), name); + // @@protoc_insertion_point(field_set_allocated:caffe.NetParameter.name) } // repeated string input = 3; @@ -11086,39 +12207,50 @@ inline void NetParameter::clear_input() { input_.Clear(); } inline const ::std::string& NetParameter::input(int index) const { + // @@protoc_insertion_point(field_get:caffe.NetParameter.input) return input_.Get(index); } inline ::std::string* NetParameter::mutable_input(int index) { + // @@protoc_insertion_point(field_mutable:caffe.NetParameter.input) return input_.Mutable(index); } inline void NetParameter::set_input(int index, const ::std::string& value) { + // @@protoc_insertion_point(field_set:caffe.NetParameter.input) input_.Mutable(index)->assign(value); } inline void NetParameter::set_input(int index, const char* value) { input_.Mutable(index)->assign(value); + // @@protoc_insertion_point(field_set_char:caffe.NetParameter.input) } inline void NetParameter::set_input(int index, const char* value, size_t size) { input_.Mutable(index)->assign( reinterpret_cast(value), size); + // @@protoc_insertion_point(field_set_pointer:caffe.NetParameter.input) } inline ::std::string* NetParameter::add_input() { + // @@protoc_insertion_point(field_add_mutable:caffe.NetParameter.input) return input_.Add(); } inline void NetParameter::add_input(const ::std::string& value) { input_.Add()->assign(value); + // @@protoc_insertion_point(field_add:caffe.NetParameter.input) } inline void NetParameter::add_input(const char* value) { input_.Add()->assign(value); + // @@protoc_insertion_point(field_add_char:caffe.NetParameter.input) } inline void NetParameter::add_input(const char* value, size_t size) { input_.Add()->assign(reinterpret_cast(value), size); + // @@protoc_insertion_point(field_add_pointer:caffe.NetParameter.input) } inline const ::google::protobuf::RepeatedPtrField< ::std::string>& NetParameter::input() const { + // @@protoc_insertion_point(field_list:caffe.NetParameter.input) return input_; } inline ::google::protobuf::RepeatedPtrField< ::std::string>* NetParameter::mutable_input() { + // @@protoc_insertion_point(field_mutable_list:caffe.NetParameter.input) return &input_; } @@ -11130,22 +12262,27 @@ inline void NetParameter::clear_input_shape() { input_shape_.Clear(); } inline const ::caffe::BlobShape& NetParameter::input_shape(int index) const { + // @@protoc_insertion_point(field_get:caffe.NetParameter.input_shape) return input_shape_.Get(index); } inline ::caffe::BlobShape* NetParameter::mutable_input_shape(int index) { + // @@protoc_insertion_point(field_mutable:caffe.NetParameter.input_shape) return input_shape_.Mutable(index); } inline ::caffe::BlobShape* NetParameter::add_input_shape() { + // @@protoc_insertion_point(field_add:caffe.NetParameter.input_shape) return input_shape_.Add(); } -inline const ::google::protobuf::RepeatedPtrField< ::caffe::BlobShape >& -NetParameter::input_shape() const { - return input_shape_; -} inline ::google::protobuf::RepeatedPtrField< ::caffe::BlobShape >* NetParameter::mutable_input_shape() { + // @@protoc_insertion_point(field_mutable_list:caffe.NetParameter.input_shape) return &input_shape_; } +inline const ::google::protobuf::RepeatedPtrField< ::caffe::BlobShape >& +NetParameter::input_shape() const { + // @@protoc_insertion_point(field_list:caffe.NetParameter.input_shape) + return input_shape_; +} // repeated int32 input_dim = 4; inline int NetParameter::input_dim_size() const { @@ -11155,20 +12292,25 @@ inline void NetParameter::clear_input_dim() { input_dim_.Clear(); } inline ::google::protobuf::int32 NetParameter::input_dim(int index) const { + // @@protoc_insertion_point(field_get:caffe.NetParameter.input_dim) return input_dim_.Get(index); } inline void NetParameter::set_input_dim(int index, ::google::protobuf::int32 value) { input_dim_.Set(index, value); + // @@protoc_insertion_point(field_set:caffe.NetParameter.input_dim) } inline void NetParameter::add_input_dim(::google::protobuf::int32 value) { input_dim_.Add(value); + // @@protoc_insertion_point(field_add:caffe.NetParameter.input_dim) } inline const ::google::protobuf::RepeatedField< ::google::protobuf::int32 >& NetParameter::input_dim() const { + // @@protoc_insertion_point(field_list:caffe.NetParameter.input_dim) return input_dim_; } inline ::google::protobuf::RepeatedField< ::google::protobuf::int32 >* NetParameter::mutable_input_dim() { + // @@protoc_insertion_point(field_mutable_list:caffe.NetParameter.input_dim) return &input_dim_; } @@ -11187,11 +12329,13 @@ inline void NetParameter::clear_force_backward() { clear_has_force_backward(); } inline bool NetParameter::force_backward() const { + // @@protoc_insertion_point(field_get:caffe.NetParameter.force_backward) return force_backward_; } inline void NetParameter::set_force_backward(bool value) { set_has_force_backward(); force_backward_ = value; + // @@protoc_insertion_point(field_set:caffe.NetParameter.force_backward) } // optional .caffe.NetState state = 6; @@ -11209,14 +12353,20 @@ inline void NetParameter::clear_state() { clear_has_state(); } inline const ::caffe::NetState& NetParameter::state() const { - return state_ != NULL ? *state_ : *default_instance_->state_; + // @@protoc_insertion_point(field_get:caffe.NetParameter.state) + return state_ != NULL ? *state_ + : *::caffe::NetState::internal_default_instance(); } inline ::caffe::NetState* NetParameter::mutable_state() { set_has_state(); - if (state_ == NULL) state_ = new ::caffe::NetState; + if (state_ == NULL) { + state_ = new ::caffe::NetState; + } + // @@protoc_insertion_point(field_mutable:caffe.NetParameter.state) return state_; } inline ::caffe::NetState* NetParameter::release_state() { + // @@protoc_insertion_point(field_release:caffe.NetParameter.state) clear_has_state(); ::caffe::NetState* temp = state_; state_ = NULL; @@ -11230,6 +12380,7 @@ inline void NetParameter::set_allocated_state(::caffe::NetState* state) { } else { clear_has_state(); } + // @@protoc_insertion_point(field_set_allocated:caffe.NetParameter.state) } // optional bool debug_info = 7 [default = false]; @@ -11247,11 +12398,13 @@ inline void NetParameter::clear_debug_info() { clear_has_debug_info(); } inline bool NetParameter::debug_info() const { + // @@protoc_insertion_point(field_get:caffe.NetParameter.debug_info) return debug_info_; } inline void NetParameter::set_debug_info(bool value) { set_has_debug_info(); debug_info_ = value; + // @@protoc_insertion_point(field_set:caffe.NetParameter.debug_info) } // repeated .caffe.LayerParameter layer = 100; @@ -11262,22 +12415,27 @@ inline void NetParameter::clear_layer() { layer_.Clear(); } inline const ::caffe::LayerParameter& NetParameter::layer(int index) const { + // @@protoc_insertion_point(field_get:caffe.NetParameter.layer) return layer_.Get(index); } inline ::caffe::LayerParameter* NetParameter::mutable_layer(int index) { + // @@protoc_insertion_point(field_mutable:caffe.NetParameter.layer) return layer_.Mutable(index); } inline ::caffe::LayerParameter* NetParameter::add_layer() { + // @@protoc_insertion_point(field_add:caffe.NetParameter.layer) return layer_.Add(); } -inline const ::google::protobuf::RepeatedPtrField< ::caffe::LayerParameter >& -NetParameter::layer() const { - return layer_; -} inline ::google::protobuf::RepeatedPtrField< ::caffe::LayerParameter >* NetParameter::mutable_layer() { + // @@protoc_insertion_point(field_mutable_list:caffe.NetParameter.layer) return &layer_; } +inline const ::google::protobuf::RepeatedPtrField< ::caffe::LayerParameter >& +NetParameter::layer() const { + // @@protoc_insertion_point(field_list:caffe.NetParameter.layer) + return layer_; +} // repeated .caffe.V1LayerParameter layers = 2; inline int NetParameter::layers_size() const { @@ -11287,23 +12445,31 @@ inline void NetParameter::clear_layers() { layers_.Clear(); } inline const ::caffe::V1LayerParameter& NetParameter::layers(int index) const { + // @@protoc_insertion_point(field_get:caffe.NetParameter.layers) return layers_.Get(index); } inline ::caffe::V1LayerParameter* NetParameter::mutable_layers(int index) { + // @@protoc_insertion_point(field_mutable:caffe.NetParameter.layers) return layers_.Mutable(index); } inline ::caffe::V1LayerParameter* NetParameter::add_layers() { + // @@protoc_insertion_point(field_add:caffe.NetParameter.layers) return layers_.Add(); } -inline const ::google::protobuf::RepeatedPtrField< ::caffe::V1LayerParameter >& -NetParameter::layers() const { - return layers_; -} inline ::google::protobuf::RepeatedPtrField< ::caffe::V1LayerParameter >* NetParameter::mutable_layers() { + // @@protoc_insertion_point(field_mutable_list:caffe.NetParameter.layers) return &layers_; } +inline const ::google::protobuf::RepeatedPtrField< ::caffe::V1LayerParameter >& +NetParameter::layers() const { + // @@protoc_insertion_point(field_list:caffe.NetParameter.layers) + return layers_; +} +inline const NetParameter* NetParameter::internal_default_instance() { + return &NetParameter_default_instance_.get(); +} // ------------------------------------------------------------------- // SolverParameter @@ -11319,63 +12485,47 @@ inline void SolverParameter::clear_has_net() { _has_bits_[0] &= ~0x00000001u; } inline void SolverParameter::clear_net() { - if (net_ != &::google::protobuf::internal::kEmptyString) { - net_->clear(); - } + net_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); clear_has_net(); } inline const ::std::string& SolverParameter::net() const { - return *net_; + // @@protoc_insertion_point(field_get:caffe.SolverParameter.net) + return net_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } inline void SolverParameter::set_net(const ::std::string& value) { set_has_net(); - if (net_ == &::google::protobuf::internal::kEmptyString) { - net_ = new ::std::string; - } - net_->assign(value); + net_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); + // @@protoc_insertion_point(field_set:caffe.SolverParameter.net) } inline void SolverParameter::set_net(const char* value) { set_has_net(); - if (net_ == &::google::protobuf::internal::kEmptyString) { - net_ = new ::std::string; - } - net_->assign(value); + net_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); + // @@protoc_insertion_point(field_set_char:caffe.SolverParameter.net) } inline void SolverParameter::set_net(const char* value, size_t size) { set_has_net(); - if (net_ == &::google::protobuf::internal::kEmptyString) { - net_ = new ::std::string; - } - net_->assign(reinterpret_cast(value), size); + net_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), + ::std::string(reinterpret_cast(value), size)); + // @@protoc_insertion_point(field_set_pointer:caffe.SolverParameter.net) } inline ::std::string* SolverParameter::mutable_net() { set_has_net(); - if (net_ == &::google::protobuf::internal::kEmptyString) { - net_ = new ::std::string; - } - return net_; + // @@protoc_insertion_point(field_mutable:caffe.SolverParameter.net) + return net_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } inline ::std::string* SolverParameter::release_net() { + // @@protoc_insertion_point(field_release:caffe.SolverParameter.net) clear_has_net(); - if (net_ == &::google::protobuf::internal::kEmptyString) { - return NULL; - } else { - ::std::string* temp = net_; - net_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); - return temp; - } + return net_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } inline void SolverParameter::set_allocated_net(::std::string* net) { - if (net_ != &::google::protobuf::internal::kEmptyString) { - delete net_; - } - if (net) { + if (net != NULL) { set_has_net(); - net_ = net; } else { clear_has_net(); - net_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); } + net_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), net); + // @@protoc_insertion_point(field_set_allocated:caffe.SolverParameter.net) } // optional .caffe.NetParameter net_param = 25; @@ -11393,14 +12543,20 @@ inline void SolverParameter::clear_net_param() { clear_has_net_param(); } inline const ::caffe::NetParameter& SolverParameter::net_param() const { - return net_param_ != NULL ? *net_param_ : *default_instance_->net_param_; + // @@protoc_insertion_point(field_get:caffe.SolverParameter.net_param) + return net_param_ != NULL ? *net_param_ + : *::caffe::NetParameter::internal_default_instance(); } inline ::caffe::NetParameter* SolverParameter::mutable_net_param() { set_has_net_param(); - if (net_param_ == NULL) net_param_ = new ::caffe::NetParameter; + if (net_param_ == NULL) { + net_param_ = new ::caffe::NetParameter; + } + // @@protoc_insertion_point(field_mutable:caffe.SolverParameter.net_param) return net_param_; } inline ::caffe::NetParameter* SolverParameter::release_net_param() { + // @@protoc_insertion_point(field_release:caffe.SolverParameter.net_param) clear_has_net_param(); ::caffe::NetParameter* temp = net_param_; net_param_ = NULL; @@ -11414,6 +12570,7 @@ inline void SolverParameter::set_allocated_net_param(::caffe::NetParameter* net_ } else { clear_has_net_param(); } + // @@protoc_insertion_point(field_set_allocated:caffe.SolverParameter.net_param) } // optional string train_net = 1; @@ -11427,63 +12584,47 @@ inline void SolverParameter::clear_has_train_net() { _has_bits_[0] &= ~0x00000004u; } inline void SolverParameter::clear_train_net() { - if (train_net_ != &::google::protobuf::internal::kEmptyString) { - train_net_->clear(); - } + train_net_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); clear_has_train_net(); } inline const ::std::string& SolverParameter::train_net() const { - return *train_net_; + // @@protoc_insertion_point(field_get:caffe.SolverParameter.train_net) + return train_net_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } inline void SolverParameter::set_train_net(const ::std::string& value) { set_has_train_net(); - if (train_net_ == &::google::protobuf::internal::kEmptyString) { - train_net_ = new ::std::string; - } - train_net_->assign(value); + train_net_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); + // @@protoc_insertion_point(field_set:caffe.SolverParameter.train_net) } inline void SolverParameter::set_train_net(const char* value) { set_has_train_net(); - if (train_net_ == &::google::protobuf::internal::kEmptyString) { - train_net_ = new ::std::string; - } - train_net_->assign(value); + train_net_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); + // @@protoc_insertion_point(field_set_char:caffe.SolverParameter.train_net) } inline void SolverParameter::set_train_net(const char* value, size_t size) { set_has_train_net(); - if (train_net_ == &::google::protobuf::internal::kEmptyString) { - train_net_ = new ::std::string; - } - train_net_->assign(reinterpret_cast(value), size); + train_net_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), + ::std::string(reinterpret_cast(value), size)); + // @@protoc_insertion_point(field_set_pointer:caffe.SolverParameter.train_net) } inline ::std::string* SolverParameter::mutable_train_net() { set_has_train_net(); - if (train_net_ == &::google::protobuf::internal::kEmptyString) { - train_net_ = new ::std::string; - } - return train_net_; + // @@protoc_insertion_point(field_mutable:caffe.SolverParameter.train_net) + return train_net_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } inline ::std::string* SolverParameter::release_train_net() { + // @@protoc_insertion_point(field_release:caffe.SolverParameter.train_net) clear_has_train_net(); - if (train_net_ == &::google::protobuf::internal::kEmptyString) { - return NULL; - } else { - ::std::string* temp = train_net_; - train_net_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); - return temp; - } + return train_net_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } inline void SolverParameter::set_allocated_train_net(::std::string* train_net) { - if (train_net_ != &::google::protobuf::internal::kEmptyString) { - delete train_net_; - } - if (train_net) { + if (train_net != NULL) { set_has_train_net(); - train_net_ = train_net; } else { clear_has_train_net(); - train_net_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); } + train_net_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), train_net); + // @@protoc_insertion_point(field_set_allocated:caffe.SolverParameter.train_net) } // repeated string test_net = 2; @@ -11494,39 +12635,50 @@ inline void SolverParameter::clear_test_net() { test_net_.Clear(); } inline const ::std::string& SolverParameter::test_net(int index) const { + // @@protoc_insertion_point(field_get:caffe.SolverParameter.test_net) return test_net_.Get(index); } inline ::std::string* SolverParameter::mutable_test_net(int index) { + // @@protoc_insertion_point(field_mutable:caffe.SolverParameter.test_net) return test_net_.Mutable(index); } inline void SolverParameter::set_test_net(int index, const ::std::string& value) { + // @@protoc_insertion_point(field_set:caffe.SolverParameter.test_net) test_net_.Mutable(index)->assign(value); } inline void SolverParameter::set_test_net(int index, const char* value) { test_net_.Mutable(index)->assign(value); + // @@protoc_insertion_point(field_set_char:caffe.SolverParameter.test_net) } inline void SolverParameter::set_test_net(int index, const char* value, size_t size) { test_net_.Mutable(index)->assign( reinterpret_cast(value), size); + // @@protoc_insertion_point(field_set_pointer:caffe.SolverParameter.test_net) } inline ::std::string* SolverParameter::add_test_net() { + // @@protoc_insertion_point(field_add_mutable:caffe.SolverParameter.test_net) return test_net_.Add(); } inline void SolverParameter::add_test_net(const ::std::string& value) { test_net_.Add()->assign(value); + // @@protoc_insertion_point(field_add:caffe.SolverParameter.test_net) } inline void SolverParameter::add_test_net(const char* value) { test_net_.Add()->assign(value); + // @@protoc_insertion_point(field_add_char:caffe.SolverParameter.test_net) } inline void SolverParameter::add_test_net(const char* value, size_t size) { test_net_.Add()->assign(reinterpret_cast(value), size); + // @@protoc_insertion_point(field_add_pointer:caffe.SolverParameter.test_net) } inline const ::google::protobuf::RepeatedPtrField< ::std::string>& SolverParameter::test_net() const { + // @@protoc_insertion_point(field_list:caffe.SolverParameter.test_net) return test_net_; } inline ::google::protobuf::RepeatedPtrField< ::std::string>* SolverParameter::mutable_test_net() { + // @@protoc_insertion_point(field_mutable_list:caffe.SolverParameter.test_net) return &test_net_; } @@ -11545,14 +12697,20 @@ inline void SolverParameter::clear_train_net_param() { clear_has_train_net_param(); } inline const ::caffe::NetParameter& SolverParameter::train_net_param() const { - return train_net_param_ != NULL ? *train_net_param_ : *default_instance_->train_net_param_; + // @@protoc_insertion_point(field_get:caffe.SolverParameter.train_net_param) + return train_net_param_ != NULL ? *train_net_param_ + : *::caffe::NetParameter::internal_default_instance(); } inline ::caffe::NetParameter* SolverParameter::mutable_train_net_param() { set_has_train_net_param(); - if (train_net_param_ == NULL) train_net_param_ = new ::caffe::NetParameter; + if (train_net_param_ == NULL) { + train_net_param_ = new ::caffe::NetParameter; + } + // @@protoc_insertion_point(field_mutable:caffe.SolverParameter.train_net_param) return train_net_param_; } inline ::caffe::NetParameter* SolverParameter::release_train_net_param() { + // @@protoc_insertion_point(field_release:caffe.SolverParameter.train_net_param) clear_has_train_net_param(); ::caffe::NetParameter* temp = train_net_param_; train_net_param_ = NULL; @@ -11566,6 +12724,7 @@ inline void SolverParameter::set_allocated_train_net_param(::caffe::NetParameter } else { clear_has_train_net_param(); } + // @@protoc_insertion_point(field_set_allocated:caffe.SolverParameter.train_net_param) } // repeated .caffe.NetParameter test_net_param = 22; @@ -11576,22 +12735,27 @@ inline void SolverParameter::clear_test_net_param() { test_net_param_.Clear(); } inline const ::caffe::NetParameter& SolverParameter::test_net_param(int index) const { + // @@protoc_insertion_point(field_get:caffe.SolverParameter.test_net_param) return test_net_param_.Get(index); } inline ::caffe::NetParameter* SolverParameter::mutable_test_net_param(int index) { + // @@protoc_insertion_point(field_mutable:caffe.SolverParameter.test_net_param) return test_net_param_.Mutable(index); } inline ::caffe::NetParameter* SolverParameter::add_test_net_param() { + // @@protoc_insertion_point(field_add:caffe.SolverParameter.test_net_param) return test_net_param_.Add(); } -inline const ::google::protobuf::RepeatedPtrField< ::caffe::NetParameter >& -SolverParameter::test_net_param() const { - return test_net_param_; -} inline ::google::protobuf::RepeatedPtrField< ::caffe::NetParameter >* SolverParameter::mutable_test_net_param() { + // @@protoc_insertion_point(field_mutable_list:caffe.SolverParameter.test_net_param) return &test_net_param_; } +inline const ::google::protobuf::RepeatedPtrField< ::caffe::NetParameter >& +SolverParameter::test_net_param() const { + // @@protoc_insertion_point(field_list:caffe.SolverParameter.test_net_param) + return test_net_param_; +} // optional .caffe.NetState train_state = 26; inline bool SolverParameter::has_train_state() const { @@ -11608,14 +12772,20 @@ inline void SolverParameter::clear_train_state() { clear_has_train_state(); } inline const ::caffe::NetState& SolverParameter::train_state() const { - return train_state_ != NULL ? *train_state_ : *default_instance_->train_state_; + // @@protoc_insertion_point(field_get:caffe.SolverParameter.train_state) + return train_state_ != NULL ? *train_state_ + : *::caffe::NetState::internal_default_instance(); } inline ::caffe::NetState* SolverParameter::mutable_train_state() { set_has_train_state(); - if (train_state_ == NULL) train_state_ = new ::caffe::NetState; + if (train_state_ == NULL) { + train_state_ = new ::caffe::NetState; + } + // @@protoc_insertion_point(field_mutable:caffe.SolverParameter.train_state) return train_state_; } inline ::caffe::NetState* SolverParameter::release_train_state() { + // @@protoc_insertion_point(field_release:caffe.SolverParameter.train_state) clear_has_train_state(); ::caffe::NetState* temp = train_state_; train_state_ = NULL; @@ -11629,6 +12799,7 @@ inline void SolverParameter::set_allocated_train_state(::caffe::NetState* train_ } else { clear_has_train_state(); } + // @@protoc_insertion_point(field_set_allocated:caffe.SolverParameter.train_state) } // repeated .caffe.NetState test_state = 27; @@ -11639,22 +12810,27 @@ inline void SolverParameter::clear_test_state() { test_state_.Clear(); } inline const ::caffe::NetState& SolverParameter::test_state(int index) const { + // @@protoc_insertion_point(field_get:caffe.SolverParameter.test_state) return test_state_.Get(index); } inline ::caffe::NetState* SolverParameter::mutable_test_state(int index) { + // @@protoc_insertion_point(field_mutable:caffe.SolverParameter.test_state) return test_state_.Mutable(index); } inline ::caffe::NetState* SolverParameter::add_test_state() { + // @@protoc_insertion_point(field_add:caffe.SolverParameter.test_state) return test_state_.Add(); } -inline const ::google::protobuf::RepeatedPtrField< ::caffe::NetState >& -SolverParameter::test_state() const { - return test_state_; -} inline ::google::protobuf::RepeatedPtrField< ::caffe::NetState >* SolverParameter::mutable_test_state() { + // @@protoc_insertion_point(field_mutable_list:caffe.SolverParameter.test_state) return &test_state_; } +inline const ::google::protobuf::RepeatedPtrField< ::caffe::NetState >& +SolverParameter::test_state() const { + // @@protoc_insertion_point(field_list:caffe.SolverParameter.test_state) + return test_state_; +} // repeated int32 test_iter = 3; inline int SolverParameter::test_iter_size() const { @@ -11664,20 +12840,25 @@ inline void SolverParameter::clear_test_iter() { test_iter_.Clear(); } inline ::google::protobuf::int32 SolverParameter::test_iter(int index) const { + // @@protoc_insertion_point(field_get:caffe.SolverParameter.test_iter) return test_iter_.Get(index); } inline void SolverParameter::set_test_iter(int index, ::google::protobuf::int32 value) { test_iter_.Set(index, value); + // @@protoc_insertion_point(field_set:caffe.SolverParameter.test_iter) } inline void SolverParameter::add_test_iter(::google::protobuf::int32 value) { test_iter_.Add(value); + // @@protoc_insertion_point(field_add:caffe.SolverParameter.test_iter) } inline const ::google::protobuf::RepeatedField< ::google::protobuf::int32 >& SolverParameter::test_iter() const { + // @@protoc_insertion_point(field_list:caffe.SolverParameter.test_iter) return test_iter_; } inline ::google::protobuf::RepeatedField< ::google::protobuf::int32 >* SolverParameter::mutable_test_iter() { + // @@protoc_insertion_point(field_mutable_list:caffe.SolverParameter.test_iter) return &test_iter_; } @@ -11696,11 +12877,13 @@ inline void SolverParameter::clear_test_interval() { clear_has_test_interval(); } inline ::google::protobuf::int32 SolverParameter::test_interval() const { + // @@protoc_insertion_point(field_get:caffe.SolverParameter.test_interval) return test_interval_; } inline void SolverParameter::set_test_interval(::google::protobuf::int32 value) { set_has_test_interval(); test_interval_ = value; + // @@protoc_insertion_point(field_set:caffe.SolverParameter.test_interval) } // optional bool test_compute_loss = 19 [default = false]; @@ -11718,11 +12901,13 @@ inline void SolverParameter::clear_test_compute_loss() { clear_has_test_compute_loss(); } inline bool SolverParameter::test_compute_loss() const { + // @@protoc_insertion_point(field_get:caffe.SolverParameter.test_compute_loss) return test_compute_loss_; } inline void SolverParameter::set_test_compute_loss(bool value) { set_has_test_compute_loss(); test_compute_loss_ = value; + // @@protoc_insertion_point(field_set:caffe.SolverParameter.test_compute_loss) } // optional bool test_initialization = 32 [default = true]; @@ -11740,11 +12925,13 @@ inline void SolverParameter::clear_test_initialization() { clear_has_test_initialization(); } inline bool SolverParameter::test_initialization() const { + // @@protoc_insertion_point(field_get:caffe.SolverParameter.test_initialization) return test_initialization_; } inline void SolverParameter::set_test_initialization(bool value) { set_has_test_initialization(); test_initialization_ = value; + // @@protoc_insertion_point(field_set:caffe.SolverParameter.test_initialization) } // optional float base_lr = 5; @@ -11762,11 +12949,13 @@ inline void SolverParameter::clear_base_lr() { clear_has_base_lr(); } inline float SolverParameter::base_lr() const { + // @@protoc_insertion_point(field_get:caffe.SolverParameter.base_lr) return base_lr_; } inline void SolverParameter::set_base_lr(float value) { set_has_base_lr(); base_lr_ = value; + // @@protoc_insertion_point(field_set:caffe.SolverParameter.base_lr) } // optional int32 display = 6; @@ -11784,11 +12973,13 @@ inline void SolverParameter::clear_display() { clear_has_display(); } inline ::google::protobuf::int32 SolverParameter::display() const { + // @@protoc_insertion_point(field_get:caffe.SolverParameter.display) return display_; } inline void SolverParameter::set_display(::google::protobuf::int32 value) { set_has_display(); display_ = value; + // @@protoc_insertion_point(field_set:caffe.SolverParameter.display) } // optional int32 average_loss = 33 [default = 1]; @@ -11806,11 +12997,13 @@ inline void SolverParameter::clear_average_loss() { clear_has_average_loss(); } inline ::google::protobuf::int32 SolverParameter::average_loss() const { + // @@protoc_insertion_point(field_get:caffe.SolverParameter.average_loss) return average_loss_; } inline void SolverParameter::set_average_loss(::google::protobuf::int32 value) { set_has_average_loss(); average_loss_ = value; + // @@protoc_insertion_point(field_set:caffe.SolverParameter.average_loss) } // optional int32 max_iter = 7; @@ -11828,11 +13021,13 @@ inline void SolverParameter::clear_max_iter() { clear_has_max_iter(); } inline ::google::protobuf::int32 SolverParameter::max_iter() const { + // @@protoc_insertion_point(field_get:caffe.SolverParameter.max_iter) return max_iter_; } inline void SolverParameter::set_max_iter(::google::protobuf::int32 value) { set_has_max_iter(); max_iter_ = value; + // @@protoc_insertion_point(field_set:caffe.SolverParameter.max_iter) } // optional int32 iter_size = 36 [default = 1]; @@ -11850,11 +13045,13 @@ inline void SolverParameter::clear_iter_size() { clear_has_iter_size(); } inline ::google::protobuf::int32 SolverParameter::iter_size() const { + // @@protoc_insertion_point(field_get:caffe.SolverParameter.iter_size) return iter_size_; } inline void SolverParameter::set_iter_size(::google::protobuf::int32 value) { set_has_iter_size(); iter_size_ = value; + // @@protoc_insertion_point(field_set:caffe.SolverParameter.iter_size) } // optional string lr_policy = 8; @@ -11868,63 +13065,47 @@ inline void SolverParameter::clear_has_lr_policy() { _has_bits_[0] &= ~0x00020000u; } inline void SolverParameter::clear_lr_policy() { - if (lr_policy_ != &::google::protobuf::internal::kEmptyString) { - lr_policy_->clear(); - } + lr_policy_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); clear_has_lr_policy(); } inline const ::std::string& SolverParameter::lr_policy() const { - return *lr_policy_; + // @@protoc_insertion_point(field_get:caffe.SolverParameter.lr_policy) + return lr_policy_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } inline void SolverParameter::set_lr_policy(const ::std::string& value) { set_has_lr_policy(); - if (lr_policy_ == &::google::protobuf::internal::kEmptyString) { - lr_policy_ = new ::std::string; - } - lr_policy_->assign(value); + lr_policy_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); + // @@protoc_insertion_point(field_set:caffe.SolverParameter.lr_policy) } inline void SolverParameter::set_lr_policy(const char* value) { set_has_lr_policy(); - if (lr_policy_ == &::google::protobuf::internal::kEmptyString) { - lr_policy_ = new ::std::string; - } - lr_policy_->assign(value); + lr_policy_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); + // @@protoc_insertion_point(field_set_char:caffe.SolverParameter.lr_policy) } inline void SolverParameter::set_lr_policy(const char* value, size_t size) { set_has_lr_policy(); - if (lr_policy_ == &::google::protobuf::internal::kEmptyString) { - lr_policy_ = new ::std::string; - } - lr_policy_->assign(reinterpret_cast(value), size); + lr_policy_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), + ::std::string(reinterpret_cast(value), size)); + // @@protoc_insertion_point(field_set_pointer:caffe.SolverParameter.lr_policy) } inline ::std::string* SolverParameter::mutable_lr_policy() { set_has_lr_policy(); - if (lr_policy_ == &::google::protobuf::internal::kEmptyString) { - lr_policy_ = new ::std::string; - } - return lr_policy_; + // @@protoc_insertion_point(field_mutable:caffe.SolverParameter.lr_policy) + return lr_policy_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } inline ::std::string* SolverParameter::release_lr_policy() { + // @@protoc_insertion_point(field_release:caffe.SolverParameter.lr_policy) clear_has_lr_policy(); - if (lr_policy_ == &::google::protobuf::internal::kEmptyString) { - return NULL; - } else { - ::std::string* temp = lr_policy_; - lr_policy_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); - return temp; - } + return lr_policy_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } inline void SolverParameter::set_allocated_lr_policy(::std::string* lr_policy) { - if (lr_policy_ != &::google::protobuf::internal::kEmptyString) { - delete lr_policy_; - } - if (lr_policy) { + if (lr_policy != NULL) { set_has_lr_policy(); - lr_policy_ = lr_policy; } else { clear_has_lr_policy(); - lr_policy_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); } + lr_policy_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), lr_policy); + // @@protoc_insertion_point(field_set_allocated:caffe.SolverParameter.lr_policy) } // optional float gamma = 9; @@ -11942,11 +13123,13 @@ inline void SolverParameter::clear_gamma() { clear_has_gamma(); } inline float SolverParameter::gamma() const { + // @@protoc_insertion_point(field_get:caffe.SolverParameter.gamma) return gamma_; } inline void SolverParameter::set_gamma(float value) { set_has_gamma(); gamma_ = value; + // @@protoc_insertion_point(field_set:caffe.SolverParameter.gamma) } // optional float power = 10; @@ -11964,11 +13147,13 @@ inline void SolverParameter::clear_power() { clear_has_power(); } inline float SolverParameter::power() const { + // @@protoc_insertion_point(field_get:caffe.SolverParameter.power) return power_; } inline void SolverParameter::set_power(float value) { set_has_power(); power_ = value; + // @@protoc_insertion_point(field_set:caffe.SolverParameter.power) } // optional float momentum = 11; @@ -11986,11 +13171,13 @@ inline void SolverParameter::clear_momentum() { clear_has_momentum(); } inline float SolverParameter::momentum() const { + // @@protoc_insertion_point(field_get:caffe.SolverParameter.momentum) return momentum_; } inline void SolverParameter::set_momentum(float value) { set_has_momentum(); momentum_ = value; + // @@protoc_insertion_point(field_set:caffe.SolverParameter.momentum) } // optional float weight_decay = 12; @@ -12008,11 +13195,13 @@ inline void SolverParameter::clear_weight_decay() { clear_has_weight_decay(); } inline float SolverParameter::weight_decay() const { + // @@protoc_insertion_point(field_get:caffe.SolverParameter.weight_decay) return weight_decay_; } inline void SolverParameter::set_weight_decay(float value) { set_has_weight_decay(); weight_decay_ = value; + // @@protoc_insertion_point(field_set:caffe.SolverParameter.weight_decay) } // optional string regularization_type = 29 [default = "L2"]; @@ -12026,63 +13215,47 @@ inline void SolverParameter::clear_has_regularization_type() { _has_bits_[0] &= ~0x00400000u; } inline void SolverParameter::clear_regularization_type() { - if (regularization_type_ != _default_regularization_type_) { - regularization_type_->assign(*_default_regularization_type_); - } + regularization_type_.ClearToDefaultNoArena(_default_regularization_type_); clear_has_regularization_type(); } inline const ::std::string& SolverParameter::regularization_type() const { - return *regularization_type_; + // @@protoc_insertion_point(field_get:caffe.SolverParameter.regularization_type) + return regularization_type_.GetNoArena(_default_regularization_type_); } inline void SolverParameter::set_regularization_type(const ::std::string& value) { set_has_regularization_type(); - if (regularization_type_ == _default_regularization_type_) { - regularization_type_ = new ::std::string; - } - regularization_type_->assign(value); + regularization_type_.SetNoArena(_default_regularization_type_, value); + // @@protoc_insertion_point(field_set:caffe.SolverParameter.regularization_type) } inline void SolverParameter::set_regularization_type(const char* value) { set_has_regularization_type(); - if (regularization_type_ == _default_regularization_type_) { - regularization_type_ = new ::std::string; - } - regularization_type_->assign(value); + regularization_type_.SetNoArena(_default_regularization_type_, ::std::string(value)); + // @@protoc_insertion_point(field_set_char:caffe.SolverParameter.regularization_type) } inline void SolverParameter::set_regularization_type(const char* value, size_t size) { set_has_regularization_type(); - if (regularization_type_ == _default_regularization_type_) { - regularization_type_ = new ::std::string; - } - regularization_type_->assign(reinterpret_cast(value), size); + regularization_type_.SetNoArena(_default_regularization_type_, + ::std::string(reinterpret_cast(value), size)); + // @@protoc_insertion_point(field_set_pointer:caffe.SolverParameter.regularization_type) } inline ::std::string* SolverParameter::mutable_regularization_type() { set_has_regularization_type(); - if (regularization_type_ == _default_regularization_type_) { - regularization_type_ = new ::std::string(*_default_regularization_type_); - } - return regularization_type_; + // @@protoc_insertion_point(field_mutable:caffe.SolverParameter.regularization_type) + return regularization_type_.MutableNoArena(_default_regularization_type_); } inline ::std::string* SolverParameter::release_regularization_type() { + // @@protoc_insertion_point(field_release:caffe.SolverParameter.regularization_type) clear_has_regularization_type(); - if (regularization_type_ == _default_regularization_type_) { - return NULL; - } else { - ::std::string* temp = regularization_type_; - regularization_type_ = const_cast< ::std::string*>(_default_regularization_type_); - return temp; - } + return regularization_type_.ReleaseNoArena(_default_regularization_type_); } inline void SolverParameter::set_allocated_regularization_type(::std::string* regularization_type) { - if (regularization_type_ != _default_regularization_type_) { - delete regularization_type_; - } - if (regularization_type) { + if (regularization_type != NULL) { set_has_regularization_type(); - regularization_type_ = regularization_type; } else { clear_has_regularization_type(); - regularization_type_ = const_cast< ::std::string*>(_default_regularization_type_); } + regularization_type_.SetAllocatedNoArena(_default_regularization_type_, regularization_type); + // @@protoc_insertion_point(field_set_allocated:caffe.SolverParameter.regularization_type) } // optional int32 stepsize = 13; @@ -12100,11 +13273,13 @@ inline void SolverParameter::clear_stepsize() { clear_has_stepsize(); } inline ::google::protobuf::int32 SolverParameter::stepsize() const { + // @@protoc_insertion_point(field_get:caffe.SolverParameter.stepsize) return stepsize_; } inline void SolverParameter::set_stepsize(::google::protobuf::int32 value) { set_has_stepsize(); stepsize_ = value; + // @@protoc_insertion_point(field_set:caffe.SolverParameter.stepsize) } // repeated int32 stepvalue = 34; @@ -12115,20 +13290,25 @@ inline void SolverParameter::clear_stepvalue() { stepvalue_.Clear(); } inline ::google::protobuf::int32 SolverParameter::stepvalue(int index) const { + // @@protoc_insertion_point(field_get:caffe.SolverParameter.stepvalue) return stepvalue_.Get(index); } inline void SolverParameter::set_stepvalue(int index, ::google::protobuf::int32 value) { stepvalue_.Set(index, value); + // @@protoc_insertion_point(field_set:caffe.SolverParameter.stepvalue) } inline void SolverParameter::add_stepvalue(::google::protobuf::int32 value) { stepvalue_.Add(value); + // @@protoc_insertion_point(field_add:caffe.SolverParameter.stepvalue) } inline const ::google::protobuf::RepeatedField< ::google::protobuf::int32 >& SolverParameter::stepvalue() const { + // @@protoc_insertion_point(field_list:caffe.SolverParameter.stepvalue) return stepvalue_; } inline ::google::protobuf::RepeatedField< ::google::protobuf::int32 >* SolverParameter::mutable_stepvalue() { + // @@protoc_insertion_point(field_mutable_list:caffe.SolverParameter.stepvalue) return &stepvalue_; } @@ -12147,11 +13327,13 @@ inline void SolverParameter::clear_clip_gradients() { clear_has_clip_gradients(); } inline float SolverParameter::clip_gradients() const { + // @@protoc_insertion_point(field_get:caffe.SolverParameter.clip_gradients) return clip_gradients_; } inline void SolverParameter::set_clip_gradients(float value) { set_has_clip_gradients(); clip_gradients_ = value; + // @@protoc_insertion_point(field_set:caffe.SolverParameter.clip_gradients) } // optional int32 snapshot = 14 [default = 0]; @@ -12169,11 +13351,13 @@ inline void SolverParameter::clear_snapshot() { clear_has_snapshot(); } inline ::google::protobuf::int32 SolverParameter::snapshot() const { + // @@protoc_insertion_point(field_get:caffe.SolverParameter.snapshot) return snapshot_; } inline void SolverParameter::set_snapshot(::google::protobuf::int32 value) { set_has_snapshot(); snapshot_ = value; + // @@protoc_insertion_point(field_set:caffe.SolverParameter.snapshot) } // optional string snapshot_prefix = 15; @@ -12187,63 +13371,47 @@ inline void SolverParameter::clear_has_snapshot_prefix() { _has_bits_[0] &= ~0x08000000u; } inline void SolverParameter::clear_snapshot_prefix() { - if (snapshot_prefix_ != &::google::protobuf::internal::kEmptyString) { - snapshot_prefix_->clear(); - } + snapshot_prefix_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); clear_has_snapshot_prefix(); } inline const ::std::string& SolverParameter::snapshot_prefix() const { - return *snapshot_prefix_; + // @@protoc_insertion_point(field_get:caffe.SolverParameter.snapshot_prefix) + return snapshot_prefix_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } inline void SolverParameter::set_snapshot_prefix(const ::std::string& value) { set_has_snapshot_prefix(); - if (snapshot_prefix_ == &::google::protobuf::internal::kEmptyString) { - snapshot_prefix_ = new ::std::string; - } - snapshot_prefix_->assign(value); + snapshot_prefix_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); + // @@protoc_insertion_point(field_set:caffe.SolverParameter.snapshot_prefix) } inline void SolverParameter::set_snapshot_prefix(const char* value) { set_has_snapshot_prefix(); - if (snapshot_prefix_ == &::google::protobuf::internal::kEmptyString) { - snapshot_prefix_ = new ::std::string; - } - snapshot_prefix_->assign(value); + snapshot_prefix_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); + // @@protoc_insertion_point(field_set_char:caffe.SolverParameter.snapshot_prefix) } inline void SolverParameter::set_snapshot_prefix(const char* value, size_t size) { set_has_snapshot_prefix(); - if (snapshot_prefix_ == &::google::protobuf::internal::kEmptyString) { - snapshot_prefix_ = new ::std::string; - } - snapshot_prefix_->assign(reinterpret_cast(value), size); + snapshot_prefix_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), + ::std::string(reinterpret_cast(value), size)); + // @@protoc_insertion_point(field_set_pointer:caffe.SolverParameter.snapshot_prefix) } inline ::std::string* SolverParameter::mutable_snapshot_prefix() { set_has_snapshot_prefix(); - if (snapshot_prefix_ == &::google::protobuf::internal::kEmptyString) { - snapshot_prefix_ = new ::std::string; - } - return snapshot_prefix_; + // @@protoc_insertion_point(field_mutable:caffe.SolverParameter.snapshot_prefix) + return snapshot_prefix_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } inline ::std::string* SolverParameter::release_snapshot_prefix() { + // @@protoc_insertion_point(field_release:caffe.SolverParameter.snapshot_prefix) clear_has_snapshot_prefix(); - if (snapshot_prefix_ == &::google::protobuf::internal::kEmptyString) { - return NULL; - } else { - ::std::string* temp = snapshot_prefix_; - snapshot_prefix_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); - return temp; - } + return snapshot_prefix_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } inline void SolverParameter::set_allocated_snapshot_prefix(::std::string* snapshot_prefix) { - if (snapshot_prefix_ != &::google::protobuf::internal::kEmptyString) { - delete snapshot_prefix_; - } - if (snapshot_prefix) { + if (snapshot_prefix != NULL) { set_has_snapshot_prefix(); - snapshot_prefix_ = snapshot_prefix; } else { clear_has_snapshot_prefix(); - snapshot_prefix_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); } + snapshot_prefix_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), snapshot_prefix); + // @@protoc_insertion_point(field_set_allocated:caffe.SolverParameter.snapshot_prefix) } // optional bool snapshot_diff = 16 [default = false]; @@ -12261,11 +13429,13 @@ inline void SolverParameter::clear_snapshot_diff() { clear_has_snapshot_diff(); } inline bool SolverParameter::snapshot_diff() const { + // @@protoc_insertion_point(field_get:caffe.SolverParameter.snapshot_diff) return snapshot_diff_; } inline void SolverParameter::set_snapshot_diff(bool value) { set_has_snapshot_diff(); snapshot_diff_ = value; + // @@protoc_insertion_point(field_set:caffe.SolverParameter.snapshot_diff) } // optional .caffe.SolverParameter.SolverMode solver_mode = 17 [default = GPU]; @@ -12283,12 +13453,14 @@ inline void SolverParameter::clear_solver_mode() { clear_has_solver_mode(); } inline ::caffe::SolverParameter_SolverMode SolverParameter::solver_mode() const { + // @@protoc_insertion_point(field_get:caffe.SolverParameter.solver_mode) return static_cast< ::caffe::SolverParameter_SolverMode >(solver_mode_); } inline void SolverParameter::set_solver_mode(::caffe::SolverParameter_SolverMode value) { assert(::caffe::SolverParameter_SolverMode_IsValid(value)); set_has_solver_mode(); solver_mode_ = value; + // @@protoc_insertion_point(field_set:caffe.SolverParameter.solver_mode) } // optional int32 device_id = 18 [default = 0]; @@ -12306,11 +13478,13 @@ inline void SolverParameter::clear_device_id() { clear_has_device_id(); } inline ::google::protobuf::int32 SolverParameter::device_id() const { + // @@protoc_insertion_point(field_get:caffe.SolverParameter.device_id) return device_id_; } inline void SolverParameter::set_device_id(::google::protobuf::int32 value) { set_has_device_id(); device_id_ = value; + // @@protoc_insertion_point(field_set:caffe.SolverParameter.device_id) } // optional int64 random_seed = 20 [default = -1]; @@ -12328,11 +13502,13 @@ inline void SolverParameter::clear_random_seed() { clear_has_random_seed(); } inline ::google::protobuf::int64 SolverParameter::random_seed() const { + // @@protoc_insertion_point(field_get:caffe.SolverParameter.random_seed) return random_seed_; } inline void SolverParameter::set_random_seed(::google::protobuf::int64 value) { set_has_random_seed(); random_seed_ = value; + // @@protoc_insertion_point(field_set:caffe.SolverParameter.random_seed) } // optional .caffe.SolverParameter.SolverType solver_type = 30 [default = SGD]; @@ -12350,12 +13526,14 @@ inline void SolverParameter::clear_solver_type() { clear_has_solver_type(); } inline ::caffe::SolverParameter_SolverType SolverParameter::solver_type() const { + // @@protoc_insertion_point(field_get:caffe.SolverParameter.solver_type) return static_cast< ::caffe::SolverParameter_SolverType >(solver_type_); } inline void SolverParameter::set_solver_type(::caffe::SolverParameter_SolverType value) { assert(::caffe::SolverParameter_SolverType_IsValid(value)); set_has_solver_type(); solver_type_ = value; + // @@protoc_insertion_point(field_set:caffe.SolverParameter.solver_type) } // optional float delta = 31 [default = 1e-08]; @@ -12373,11 +13551,13 @@ inline void SolverParameter::clear_delta() { clear_has_delta(); } inline float SolverParameter::delta() const { + // @@protoc_insertion_point(field_get:caffe.SolverParameter.delta) return delta_; } inline void SolverParameter::set_delta(float value) { set_has_delta(); delta_ = value; + // @@protoc_insertion_point(field_set:caffe.SolverParameter.delta) } // optional bool debug_info = 23 [default = false]; @@ -12395,11 +13575,13 @@ inline void SolverParameter::clear_debug_info() { clear_has_debug_info(); } inline bool SolverParameter::debug_info() const { + // @@protoc_insertion_point(field_get:caffe.SolverParameter.debug_info) return debug_info_; } inline void SolverParameter::set_debug_info(bool value) { set_has_debug_info(); debug_info_ = value; + // @@protoc_insertion_point(field_set:caffe.SolverParameter.debug_info) } // optional bool snapshot_after_train = 28 [default = true]; @@ -12417,13 +13599,18 @@ inline void SolverParameter::clear_snapshot_after_train() { clear_has_snapshot_after_train(); } inline bool SolverParameter::snapshot_after_train() const { + // @@protoc_insertion_point(field_get:caffe.SolverParameter.snapshot_after_train) return snapshot_after_train_; } inline void SolverParameter::set_snapshot_after_train(bool value) { set_has_snapshot_after_train(); snapshot_after_train_ = value; + // @@protoc_insertion_point(field_set:caffe.SolverParameter.snapshot_after_train) } +inline const SolverParameter* SolverParameter::internal_default_instance() { + return &SolverParameter_default_instance_.get(); +} // ------------------------------------------------------------------- // SolverState @@ -12443,11 +13630,13 @@ inline void SolverState::clear_iter() { clear_has_iter(); } inline ::google::protobuf::int32 SolverState::iter() const { + // @@protoc_insertion_point(field_get:caffe.SolverState.iter) return iter_; } inline void SolverState::set_iter(::google::protobuf::int32 value) { set_has_iter(); iter_ = value; + // @@protoc_insertion_point(field_set:caffe.SolverState.iter) } // optional string learned_net = 2; @@ -12461,63 +13650,47 @@ inline void SolverState::clear_has_learned_net() { _has_bits_[0] &= ~0x00000002u; } inline void SolverState::clear_learned_net() { - if (learned_net_ != &::google::protobuf::internal::kEmptyString) { - learned_net_->clear(); - } + learned_net_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); clear_has_learned_net(); } inline const ::std::string& SolverState::learned_net() const { - return *learned_net_; + // @@protoc_insertion_point(field_get:caffe.SolverState.learned_net) + return learned_net_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } inline void SolverState::set_learned_net(const ::std::string& value) { set_has_learned_net(); - if (learned_net_ == &::google::protobuf::internal::kEmptyString) { - learned_net_ = new ::std::string; - } - learned_net_->assign(value); + learned_net_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); + // @@protoc_insertion_point(field_set:caffe.SolverState.learned_net) } inline void SolverState::set_learned_net(const char* value) { set_has_learned_net(); - if (learned_net_ == &::google::protobuf::internal::kEmptyString) { - learned_net_ = new ::std::string; - } - learned_net_->assign(value); + learned_net_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); + // @@protoc_insertion_point(field_set_char:caffe.SolverState.learned_net) } inline void SolverState::set_learned_net(const char* value, size_t size) { set_has_learned_net(); - if (learned_net_ == &::google::protobuf::internal::kEmptyString) { - learned_net_ = new ::std::string; - } - learned_net_->assign(reinterpret_cast(value), size); + learned_net_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), + ::std::string(reinterpret_cast(value), size)); + // @@protoc_insertion_point(field_set_pointer:caffe.SolverState.learned_net) } inline ::std::string* SolverState::mutable_learned_net() { set_has_learned_net(); - if (learned_net_ == &::google::protobuf::internal::kEmptyString) { - learned_net_ = new ::std::string; - } - return learned_net_; + // @@protoc_insertion_point(field_mutable:caffe.SolverState.learned_net) + return learned_net_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } inline ::std::string* SolverState::release_learned_net() { + // @@protoc_insertion_point(field_release:caffe.SolverState.learned_net) clear_has_learned_net(); - if (learned_net_ == &::google::protobuf::internal::kEmptyString) { - return NULL; - } else { - ::std::string* temp = learned_net_; - learned_net_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); - return temp; - } + return learned_net_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } inline void SolverState::set_allocated_learned_net(::std::string* learned_net) { - if (learned_net_ != &::google::protobuf::internal::kEmptyString) { - delete learned_net_; - } - if (learned_net) { + if (learned_net != NULL) { set_has_learned_net(); - learned_net_ = learned_net; } else { clear_has_learned_net(); - learned_net_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); } + learned_net_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), learned_net); + // @@protoc_insertion_point(field_set_allocated:caffe.SolverState.learned_net) } // repeated .caffe.BlobProto history = 3; @@ -12528,22 +13701,27 @@ inline void SolverState::clear_history() { history_.Clear(); } inline const ::caffe::BlobProto& SolverState::history(int index) const { + // @@protoc_insertion_point(field_get:caffe.SolverState.history) return history_.Get(index); } inline ::caffe::BlobProto* SolverState::mutable_history(int index) { + // @@protoc_insertion_point(field_mutable:caffe.SolverState.history) return history_.Mutable(index); } inline ::caffe::BlobProto* SolverState::add_history() { + // @@protoc_insertion_point(field_add:caffe.SolverState.history) return history_.Add(); } -inline const ::google::protobuf::RepeatedPtrField< ::caffe::BlobProto >& -SolverState::history() const { - return history_; -} inline ::google::protobuf::RepeatedPtrField< ::caffe::BlobProto >* SolverState::mutable_history() { + // @@protoc_insertion_point(field_mutable_list:caffe.SolverState.history) return &history_; } +inline const ::google::protobuf::RepeatedPtrField< ::caffe::BlobProto >& +SolverState::history() const { + // @@protoc_insertion_point(field_list:caffe.SolverState.history) + return history_; +} // optional int32 current_step = 4 [default = 0]; inline bool SolverState::has_current_step() const { @@ -12560,13 +13738,18 @@ inline void SolverState::clear_current_step() { clear_has_current_step(); } inline ::google::protobuf::int32 SolverState::current_step() const { + // @@protoc_insertion_point(field_get:caffe.SolverState.current_step) return current_step_; } inline void SolverState::set_current_step(::google::protobuf::int32 value) { set_has_current_step(); current_step_ = value; + // @@protoc_insertion_point(field_set:caffe.SolverState.current_step) } +inline const SolverState* SolverState::internal_default_instance() { + return &SolverState_default_instance_.get(); +} // ------------------------------------------------------------------- // NetState @@ -12586,12 +13769,14 @@ inline void NetState::clear_phase() { clear_has_phase(); } inline ::caffe::Phase NetState::phase() const { + // @@protoc_insertion_point(field_get:caffe.NetState.phase) return static_cast< ::caffe::Phase >(phase_); } inline void NetState::set_phase(::caffe::Phase value) { assert(::caffe::Phase_IsValid(value)); set_has_phase(); phase_ = value; + // @@protoc_insertion_point(field_set:caffe.NetState.phase) } // optional int32 level = 2 [default = 0]; @@ -12609,11 +13794,13 @@ inline void NetState::clear_level() { clear_has_level(); } inline ::google::protobuf::int32 NetState::level() const { + // @@protoc_insertion_point(field_get:caffe.NetState.level) return level_; } inline void NetState::set_level(::google::protobuf::int32 value) { set_has_level(); level_ = value; + // @@protoc_insertion_point(field_set:caffe.NetState.level) } // repeated string stage = 3; @@ -12624,42 +13811,56 @@ inline void NetState::clear_stage() { stage_.Clear(); } inline const ::std::string& NetState::stage(int index) const { + // @@protoc_insertion_point(field_get:caffe.NetState.stage) return stage_.Get(index); } inline ::std::string* NetState::mutable_stage(int index) { + // @@protoc_insertion_point(field_mutable:caffe.NetState.stage) return stage_.Mutable(index); } inline void NetState::set_stage(int index, const ::std::string& value) { + // @@protoc_insertion_point(field_set:caffe.NetState.stage) stage_.Mutable(index)->assign(value); } inline void NetState::set_stage(int index, const char* value) { stage_.Mutable(index)->assign(value); + // @@protoc_insertion_point(field_set_char:caffe.NetState.stage) } inline void NetState::set_stage(int index, const char* value, size_t size) { stage_.Mutable(index)->assign( reinterpret_cast(value), size); + // @@protoc_insertion_point(field_set_pointer:caffe.NetState.stage) } inline ::std::string* NetState::add_stage() { + // @@protoc_insertion_point(field_add_mutable:caffe.NetState.stage) return stage_.Add(); } inline void NetState::add_stage(const ::std::string& value) { stage_.Add()->assign(value); + // @@protoc_insertion_point(field_add:caffe.NetState.stage) } inline void NetState::add_stage(const char* value) { stage_.Add()->assign(value); + // @@protoc_insertion_point(field_add_char:caffe.NetState.stage) } inline void NetState::add_stage(const char* value, size_t size) { stage_.Add()->assign(reinterpret_cast(value), size); + // @@protoc_insertion_point(field_add_pointer:caffe.NetState.stage) } inline const ::google::protobuf::RepeatedPtrField< ::std::string>& NetState::stage() const { + // @@protoc_insertion_point(field_list:caffe.NetState.stage) return stage_; } inline ::google::protobuf::RepeatedPtrField< ::std::string>* NetState::mutable_stage() { + // @@protoc_insertion_point(field_mutable_list:caffe.NetState.stage) return &stage_; } +inline const NetState* NetState::internal_default_instance() { + return &NetState_default_instance_.get(); +} // ------------------------------------------------------------------- // NetStateRule @@ -12679,12 +13880,14 @@ inline void NetStateRule::clear_phase() { clear_has_phase(); } inline ::caffe::Phase NetStateRule::phase() const { + // @@protoc_insertion_point(field_get:caffe.NetStateRule.phase) return static_cast< ::caffe::Phase >(phase_); } inline void NetStateRule::set_phase(::caffe::Phase value) { assert(::caffe::Phase_IsValid(value)); set_has_phase(); phase_ = value; + // @@protoc_insertion_point(field_set:caffe.NetStateRule.phase) } // optional int32 min_level = 2; @@ -12702,11 +13905,13 @@ inline void NetStateRule::clear_min_level() { clear_has_min_level(); } inline ::google::protobuf::int32 NetStateRule::min_level() const { + // @@protoc_insertion_point(field_get:caffe.NetStateRule.min_level) return min_level_; } inline void NetStateRule::set_min_level(::google::protobuf::int32 value) { set_has_min_level(); min_level_ = value; + // @@protoc_insertion_point(field_set:caffe.NetStateRule.min_level) } // optional int32 max_level = 3; @@ -12724,11 +13929,13 @@ inline void NetStateRule::clear_max_level() { clear_has_max_level(); } inline ::google::protobuf::int32 NetStateRule::max_level() const { + // @@protoc_insertion_point(field_get:caffe.NetStateRule.max_level) return max_level_; } inline void NetStateRule::set_max_level(::google::protobuf::int32 value) { set_has_max_level(); max_level_ = value; + // @@protoc_insertion_point(field_set:caffe.NetStateRule.max_level) } // repeated string stage = 4; @@ -12739,39 +13946,50 @@ inline void NetStateRule::clear_stage() { stage_.Clear(); } inline const ::std::string& NetStateRule::stage(int index) const { + // @@protoc_insertion_point(field_get:caffe.NetStateRule.stage) return stage_.Get(index); } inline ::std::string* NetStateRule::mutable_stage(int index) { + // @@protoc_insertion_point(field_mutable:caffe.NetStateRule.stage) return stage_.Mutable(index); } inline void NetStateRule::set_stage(int index, const ::std::string& value) { + // @@protoc_insertion_point(field_set:caffe.NetStateRule.stage) stage_.Mutable(index)->assign(value); } inline void NetStateRule::set_stage(int index, const char* value) { stage_.Mutable(index)->assign(value); + // @@protoc_insertion_point(field_set_char:caffe.NetStateRule.stage) } inline void NetStateRule::set_stage(int index, const char* value, size_t size) { stage_.Mutable(index)->assign( reinterpret_cast(value), size); + // @@protoc_insertion_point(field_set_pointer:caffe.NetStateRule.stage) } inline ::std::string* NetStateRule::add_stage() { + // @@protoc_insertion_point(field_add_mutable:caffe.NetStateRule.stage) return stage_.Add(); } inline void NetStateRule::add_stage(const ::std::string& value) { stage_.Add()->assign(value); + // @@protoc_insertion_point(field_add:caffe.NetStateRule.stage) } inline void NetStateRule::add_stage(const char* value) { stage_.Add()->assign(value); + // @@protoc_insertion_point(field_add_char:caffe.NetStateRule.stage) } inline void NetStateRule::add_stage(const char* value, size_t size) { stage_.Add()->assign(reinterpret_cast(value), size); + // @@protoc_insertion_point(field_add_pointer:caffe.NetStateRule.stage) } inline const ::google::protobuf::RepeatedPtrField< ::std::string>& NetStateRule::stage() const { + // @@protoc_insertion_point(field_list:caffe.NetStateRule.stage) return stage_; } inline ::google::protobuf::RepeatedPtrField< ::std::string>* NetStateRule::mutable_stage() { + // @@protoc_insertion_point(field_mutable_list:caffe.NetStateRule.stage) return &stage_; } @@ -12783,42 +14001,56 @@ inline void NetStateRule::clear_not_stage() { not_stage_.Clear(); } inline const ::std::string& NetStateRule::not_stage(int index) const { + // @@protoc_insertion_point(field_get:caffe.NetStateRule.not_stage) return not_stage_.Get(index); } inline ::std::string* NetStateRule::mutable_not_stage(int index) { + // @@protoc_insertion_point(field_mutable:caffe.NetStateRule.not_stage) return not_stage_.Mutable(index); } inline void NetStateRule::set_not_stage(int index, const ::std::string& value) { + // @@protoc_insertion_point(field_set:caffe.NetStateRule.not_stage) not_stage_.Mutable(index)->assign(value); } inline void NetStateRule::set_not_stage(int index, const char* value) { not_stage_.Mutable(index)->assign(value); + // @@protoc_insertion_point(field_set_char:caffe.NetStateRule.not_stage) } inline void NetStateRule::set_not_stage(int index, const char* value, size_t size) { not_stage_.Mutable(index)->assign( reinterpret_cast(value), size); + // @@protoc_insertion_point(field_set_pointer:caffe.NetStateRule.not_stage) } inline ::std::string* NetStateRule::add_not_stage() { + // @@protoc_insertion_point(field_add_mutable:caffe.NetStateRule.not_stage) return not_stage_.Add(); } inline void NetStateRule::add_not_stage(const ::std::string& value) { not_stage_.Add()->assign(value); + // @@protoc_insertion_point(field_add:caffe.NetStateRule.not_stage) } inline void NetStateRule::add_not_stage(const char* value) { not_stage_.Add()->assign(value); + // @@protoc_insertion_point(field_add_char:caffe.NetStateRule.not_stage) } inline void NetStateRule::add_not_stage(const char* value, size_t size) { not_stage_.Add()->assign(reinterpret_cast(value), size); + // @@protoc_insertion_point(field_add_pointer:caffe.NetStateRule.not_stage) } inline const ::google::protobuf::RepeatedPtrField< ::std::string>& NetStateRule::not_stage() const { + // @@protoc_insertion_point(field_list:caffe.NetStateRule.not_stage) return not_stage_; } inline ::google::protobuf::RepeatedPtrField< ::std::string>* NetStateRule::mutable_not_stage() { + // @@protoc_insertion_point(field_mutable_list:caffe.NetStateRule.not_stage) return ¬_stage_; } +inline const NetStateRule* NetStateRule::internal_default_instance() { + return &NetStateRule_default_instance_.get(); +} // ------------------------------------------------------------------- // ParamSpec @@ -12834,63 +14066,47 @@ inline void ParamSpec::clear_has_name() { _has_bits_[0] &= ~0x00000001u; } inline void ParamSpec::clear_name() { - if (name_ != &::google::protobuf::internal::kEmptyString) { - name_->clear(); - } + name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); clear_has_name(); } inline const ::std::string& ParamSpec::name() const { - return *name_; + // @@protoc_insertion_point(field_get:caffe.ParamSpec.name) + return name_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } inline void ParamSpec::set_name(const ::std::string& value) { set_has_name(); - if (name_ == &::google::protobuf::internal::kEmptyString) { - name_ = new ::std::string; - } - name_->assign(value); + name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); + // @@protoc_insertion_point(field_set:caffe.ParamSpec.name) } inline void ParamSpec::set_name(const char* value) { set_has_name(); - if (name_ == &::google::protobuf::internal::kEmptyString) { - name_ = new ::std::string; - } - name_->assign(value); + name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); + // @@protoc_insertion_point(field_set_char:caffe.ParamSpec.name) } inline void ParamSpec::set_name(const char* value, size_t size) { set_has_name(); - if (name_ == &::google::protobuf::internal::kEmptyString) { - name_ = new ::std::string; - } - name_->assign(reinterpret_cast(value), size); + name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), + ::std::string(reinterpret_cast(value), size)); + // @@protoc_insertion_point(field_set_pointer:caffe.ParamSpec.name) } inline ::std::string* ParamSpec::mutable_name() { set_has_name(); - if (name_ == &::google::protobuf::internal::kEmptyString) { - name_ = new ::std::string; - } - return name_; + // @@protoc_insertion_point(field_mutable:caffe.ParamSpec.name) + return name_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } inline ::std::string* ParamSpec::release_name() { + // @@protoc_insertion_point(field_release:caffe.ParamSpec.name) clear_has_name(); - if (name_ == &::google::protobuf::internal::kEmptyString) { - return NULL; - } else { - ::std::string* temp = name_; - name_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); - return temp; - } + return name_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } inline void ParamSpec::set_allocated_name(::std::string* name) { - if (name_ != &::google::protobuf::internal::kEmptyString) { - delete name_; - } - if (name) { + if (name != NULL) { set_has_name(); - name_ = name; } else { clear_has_name(); - name_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); } + name_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), name); + // @@protoc_insertion_point(field_set_allocated:caffe.ParamSpec.name) } // optional .caffe.ParamSpec.DimCheckMode share_mode = 2; @@ -12908,12 +14124,14 @@ inline void ParamSpec::clear_share_mode() { clear_has_share_mode(); } inline ::caffe::ParamSpec_DimCheckMode ParamSpec::share_mode() const { + // @@protoc_insertion_point(field_get:caffe.ParamSpec.share_mode) return static_cast< ::caffe::ParamSpec_DimCheckMode >(share_mode_); } inline void ParamSpec::set_share_mode(::caffe::ParamSpec_DimCheckMode value) { assert(::caffe::ParamSpec_DimCheckMode_IsValid(value)); set_has_share_mode(); share_mode_ = value; + // @@protoc_insertion_point(field_set:caffe.ParamSpec.share_mode) } // optional float lr_mult = 3 [default = 1]; @@ -12931,11 +14149,13 @@ inline void ParamSpec::clear_lr_mult() { clear_has_lr_mult(); } inline float ParamSpec::lr_mult() const { + // @@protoc_insertion_point(field_get:caffe.ParamSpec.lr_mult) return lr_mult_; } inline void ParamSpec::set_lr_mult(float value) { set_has_lr_mult(); lr_mult_ = value; + // @@protoc_insertion_point(field_set:caffe.ParamSpec.lr_mult) } // optional float decay_mult = 4 [default = 1]; @@ -12953,13 +14173,18 @@ inline void ParamSpec::clear_decay_mult() { clear_has_decay_mult(); } inline float ParamSpec::decay_mult() const { + // @@protoc_insertion_point(field_get:caffe.ParamSpec.decay_mult) return decay_mult_; } inline void ParamSpec::set_decay_mult(float value) { set_has_decay_mult(); decay_mult_ = value; + // @@protoc_insertion_point(field_set:caffe.ParamSpec.decay_mult) } +inline const ParamSpec* ParamSpec::internal_default_instance() { + return &ParamSpec_default_instance_.get(); +} // ------------------------------------------------------------------- // LayerParameter @@ -12975,63 +14200,47 @@ inline void LayerParameter::clear_has_name() { _has_bits_[0] &= ~0x00000001u; } inline void LayerParameter::clear_name() { - if (name_ != &::google::protobuf::internal::kEmptyString) { - name_->clear(); - } + name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); clear_has_name(); } inline const ::std::string& LayerParameter::name() const { - return *name_; + // @@protoc_insertion_point(field_get:caffe.LayerParameter.name) + return name_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } inline void LayerParameter::set_name(const ::std::string& value) { set_has_name(); - if (name_ == &::google::protobuf::internal::kEmptyString) { - name_ = new ::std::string; - } - name_->assign(value); + name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); + // @@protoc_insertion_point(field_set:caffe.LayerParameter.name) } inline void LayerParameter::set_name(const char* value) { set_has_name(); - if (name_ == &::google::protobuf::internal::kEmptyString) { - name_ = new ::std::string; - } - name_->assign(value); + name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); + // @@protoc_insertion_point(field_set_char:caffe.LayerParameter.name) } inline void LayerParameter::set_name(const char* value, size_t size) { set_has_name(); - if (name_ == &::google::protobuf::internal::kEmptyString) { - name_ = new ::std::string; - } - name_->assign(reinterpret_cast(value), size); + name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), + ::std::string(reinterpret_cast(value), size)); + // @@protoc_insertion_point(field_set_pointer:caffe.LayerParameter.name) } inline ::std::string* LayerParameter::mutable_name() { set_has_name(); - if (name_ == &::google::protobuf::internal::kEmptyString) { - name_ = new ::std::string; - } - return name_; + // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.name) + return name_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } inline ::std::string* LayerParameter::release_name() { + // @@protoc_insertion_point(field_release:caffe.LayerParameter.name) clear_has_name(); - if (name_ == &::google::protobuf::internal::kEmptyString) { - return NULL; - } else { - ::std::string* temp = name_; - name_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); - return temp; - } + return name_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } inline void LayerParameter::set_allocated_name(::std::string* name) { - if (name_ != &::google::protobuf::internal::kEmptyString) { - delete name_; - } - if (name) { + if (name != NULL) { set_has_name(); - name_ = name; } else { clear_has_name(); - name_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); } + name_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), name); + // @@protoc_insertion_point(field_set_allocated:caffe.LayerParameter.name) } // optional string type = 2; @@ -13045,63 +14254,47 @@ inline void LayerParameter::clear_has_type() { _has_bits_[0] &= ~0x00000002u; } inline void LayerParameter::clear_type() { - if (type_ != &::google::protobuf::internal::kEmptyString) { - type_->clear(); - } + type_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); clear_has_type(); } inline const ::std::string& LayerParameter::type() const { - return *type_; + // @@protoc_insertion_point(field_get:caffe.LayerParameter.type) + return type_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } inline void LayerParameter::set_type(const ::std::string& value) { set_has_type(); - if (type_ == &::google::protobuf::internal::kEmptyString) { - type_ = new ::std::string; - } - type_->assign(value); + type_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); + // @@protoc_insertion_point(field_set:caffe.LayerParameter.type) } inline void LayerParameter::set_type(const char* value) { set_has_type(); - if (type_ == &::google::protobuf::internal::kEmptyString) { - type_ = new ::std::string; - } - type_->assign(value); + type_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); + // @@protoc_insertion_point(field_set_char:caffe.LayerParameter.type) } inline void LayerParameter::set_type(const char* value, size_t size) { set_has_type(); - if (type_ == &::google::protobuf::internal::kEmptyString) { - type_ = new ::std::string; - } - type_->assign(reinterpret_cast(value), size); + type_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), + ::std::string(reinterpret_cast(value), size)); + // @@protoc_insertion_point(field_set_pointer:caffe.LayerParameter.type) } inline ::std::string* LayerParameter::mutable_type() { set_has_type(); - if (type_ == &::google::protobuf::internal::kEmptyString) { - type_ = new ::std::string; - } - return type_; + // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.type) + return type_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } inline ::std::string* LayerParameter::release_type() { + // @@protoc_insertion_point(field_release:caffe.LayerParameter.type) clear_has_type(); - if (type_ == &::google::protobuf::internal::kEmptyString) { - return NULL; - } else { - ::std::string* temp = type_; - type_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); - return temp; - } + return type_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } inline void LayerParameter::set_allocated_type(::std::string* type) { - if (type_ != &::google::protobuf::internal::kEmptyString) { - delete type_; - } - if (type) { + if (type != NULL) { set_has_type(); - type_ = type; } else { clear_has_type(); - type_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); } + type_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), type); + // @@protoc_insertion_point(field_set_allocated:caffe.LayerParameter.type) } // repeated string bottom = 3; @@ -13112,39 +14305,50 @@ inline void LayerParameter::clear_bottom() { bottom_.Clear(); } inline const ::std::string& LayerParameter::bottom(int index) const { + // @@protoc_insertion_point(field_get:caffe.LayerParameter.bottom) return bottom_.Get(index); } inline ::std::string* LayerParameter::mutable_bottom(int index) { + // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.bottom) return bottom_.Mutable(index); } inline void LayerParameter::set_bottom(int index, const ::std::string& value) { + // @@protoc_insertion_point(field_set:caffe.LayerParameter.bottom) bottom_.Mutable(index)->assign(value); } inline void LayerParameter::set_bottom(int index, const char* value) { bottom_.Mutable(index)->assign(value); + // @@protoc_insertion_point(field_set_char:caffe.LayerParameter.bottom) } inline void LayerParameter::set_bottom(int index, const char* value, size_t size) { bottom_.Mutable(index)->assign( reinterpret_cast(value), size); + // @@protoc_insertion_point(field_set_pointer:caffe.LayerParameter.bottom) } inline ::std::string* LayerParameter::add_bottom() { + // @@protoc_insertion_point(field_add_mutable:caffe.LayerParameter.bottom) return bottom_.Add(); } inline void LayerParameter::add_bottom(const ::std::string& value) { bottom_.Add()->assign(value); + // @@protoc_insertion_point(field_add:caffe.LayerParameter.bottom) } inline void LayerParameter::add_bottom(const char* value) { bottom_.Add()->assign(value); + // @@protoc_insertion_point(field_add_char:caffe.LayerParameter.bottom) } inline void LayerParameter::add_bottom(const char* value, size_t size) { bottom_.Add()->assign(reinterpret_cast(value), size); + // @@protoc_insertion_point(field_add_pointer:caffe.LayerParameter.bottom) } inline const ::google::protobuf::RepeatedPtrField< ::std::string>& LayerParameter::bottom() const { + // @@protoc_insertion_point(field_list:caffe.LayerParameter.bottom) return bottom_; } inline ::google::protobuf::RepeatedPtrField< ::std::string>* LayerParameter::mutable_bottom() { + // @@protoc_insertion_point(field_mutable_list:caffe.LayerParameter.bottom) return &bottom_; } @@ -13156,39 +14360,50 @@ inline void LayerParameter::clear_top() { top_.Clear(); } inline const ::std::string& LayerParameter::top(int index) const { + // @@protoc_insertion_point(field_get:caffe.LayerParameter.top) return top_.Get(index); } inline ::std::string* LayerParameter::mutable_top(int index) { + // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.top) return top_.Mutable(index); } inline void LayerParameter::set_top(int index, const ::std::string& value) { + // @@protoc_insertion_point(field_set:caffe.LayerParameter.top) top_.Mutable(index)->assign(value); } inline void LayerParameter::set_top(int index, const char* value) { top_.Mutable(index)->assign(value); + // @@protoc_insertion_point(field_set_char:caffe.LayerParameter.top) } inline void LayerParameter::set_top(int index, const char* value, size_t size) { top_.Mutable(index)->assign( reinterpret_cast(value), size); + // @@protoc_insertion_point(field_set_pointer:caffe.LayerParameter.top) } inline ::std::string* LayerParameter::add_top() { + // @@protoc_insertion_point(field_add_mutable:caffe.LayerParameter.top) return top_.Add(); } inline void LayerParameter::add_top(const ::std::string& value) { top_.Add()->assign(value); + // @@protoc_insertion_point(field_add:caffe.LayerParameter.top) } inline void LayerParameter::add_top(const char* value) { top_.Add()->assign(value); + // @@protoc_insertion_point(field_add_char:caffe.LayerParameter.top) } inline void LayerParameter::add_top(const char* value, size_t size) { top_.Add()->assign(reinterpret_cast(value), size); + // @@protoc_insertion_point(field_add_pointer:caffe.LayerParameter.top) } inline const ::google::protobuf::RepeatedPtrField< ::std::string>& LayerParameter::top() const { + // @@protoc_insertion_point(field_list:caffe.LayerParameter.top) return top_; } inline ::google::protobuf::RepeatedPtrField< ::std::string>* LayerParameter::mutable_top() { + // @@protoc_insertion_point(field_mutable_list:caffe.LayerParameter.top) return &top_; } @@ -13207,12 +14422,14 @@ inline void LayerParameter::clear_phase() { clear_has_phase(); } inline ::caffe::Phase LayerParameter::phase() const { + // @@protoc_insertion_point(field_get:caffe.LayerParameter.phase) return static_cast< ::caffe::Phase >(phase_); } inline void LayerParameter::set_phase(::caffe::Phase value) { assert(::caffe::Phase_IsValid(value)); set_has_phase(); phase_ = value; + // @@protoc_insertion_point(field_set:caffe.LayerParameter.phase) } // repeated float loss_weight = 5; @@ -13223,20 +14440,25 @@ inline void LayerParameter::clear_loss_weight() { loss_weight_.Clear(); } inline float LayerParameter::loss_weight(int index) const { + // @@protoc_insertion_point(field_get:caffe.LayerParameter.loss_weight) return loss_weight_.Get(index); } inline void LayerParameter::set_loss_weight(int index, float value) { loss_weight_.Set(index, value); + // @@protoc_insertion_point(field_set:caffe.LayerParameter.loss_weight) } inline void LayerParameter::add_loss_weight(float value) { loss_weight_.Add(value); + // @@protoc_insertion_point(field_add:caffe.LayerParameter.loss_weight) } inline const ::google::protobuf::RepeatedField< float >& LayerParameter::loss_weight() const { + // @@protoc_insertion_point(field_list:caffe.LayerParameter.loss_weight) return loss_weight_; } inline ::google::protobuf::RepeatedField< float >* LayerParameter::mutable_loss_weight() { + // @@protoc_insertion_point(field_mutable_list:caffe.LayerParameter.loss_weight) return &loss_weight_; } @@ -13248,22 +14470,27 @@ inline void LayerParameter::clear_param() { param_.Clear(); } inline const ::caffe::ParamSpec& LayerParameter::param(int index) const { + // @@protoc_insertion_point(field_get:caffe.LayerParameter.param) return param_.Get(index); } inline ::caffe::ParamSpec* LayerParameter::mutable_param(int index) { + // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.param) return param_.Mutable(index); } inline ::caffe::ParamSpec* LayerParameter::add_param() { + // @@protoc_insertion_point(field_add:caffe.LayerParameter.param) return param_.Add(); } -inline const ::google::protobuf::RepeatedPtrField< ::caffe::ParamSpec >& -LayerParameter::param() const { - return param_; -} inline ::google::protobuf::RepeatedPtrField< ::caffe::ParamSpec >* LayerParameter::mutable_param() { + // @@protoc_insertion_point(field_mutable_list:caffe.LayerParameter.param) return ¶m_; } +inline const ::google::protobuf::RepeatedPtrField< ::caffe::ParamSpec >& +LayerParameter::param() const { + // @@protoc_insertion_point(field_list:caffe.LayerParameter.param) + return param_; +} // repeated .caffe.BlobProto blobs = 7; inline int LayerParameter::blobs_size() const { @@ -13273,22 +14500,27 @@ inline void LayerParameter::clear_blobs() { blobs_.Clear(); } inline const ::caffe::BlobProto& LayerParameter::blobs(int index) const { + // @@protoc_insertion_point(field_get:caffe.LayerParameter.blobs) return blobs_.Get(index); } inline ::caffe::BlobProto* LayerParameter::mutable_blobs(int index) { + // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.blobs) return blobs_.Mutable(index); } inline ::caffe::BlobProto* LayerParameter::add_blobs() { + // @@protoc_insertion_point(field_add:caffe.LayerParameter.blobs) return blobs_.Add(); } -inline const ::google::protobuf::RepeatedPtrField< ::caffe::BlobProto >& -LayerParameter::blobs() const { - return blobs_; -} inline ::google::protobuf::RepeatedPtrField< ::caffe::BlobProto >* LayerParameter::mutable_blobs() { + // @@protoc_insertion_point(field_mutable_list:caffe.LayerParameter.blobs) return &blobs_; } +inline const ::google::protobuf::RepeatedPtrField< ::caffe::BlobProto >& +LayerParameter::blobs() const { + // @@protoc_insertion_point(field_list:caffe.LayerParameter.blobs) + return blobs_; +} // repeated bool propagate_down = 11; inline int LayerParameter::propagate_down_size() const { @@ -13298,20 +14530,25 @@ inline void LayerParameter::clear_propagate_down() { propagate_down_.Clear(); } inline bool LayerParameter::propagate_down(int index) const { + // @@protoc_insertion_point(field_get:caffe.LayerParameter.propagate_down) return propagate_down_.Get(index); } inline void LayerParameter::set_propagate_down(int index, bool value) { propagate_down_.Set(index, value); + // @@protoc_insertion_point(field_set:caffe.LayerParameter.propagate_down) } inline void LayerParameter::add_propagate_down(bool value) { propagate_down_.Add(value); + // @@protoc_insertion_point(field_add:caffe.LayerParameter.propagate_down) } inline const ::google::protobuf::RepeatedField< bool >& LayerParameter::propagate_down() const { + // @@protoc_insertion_point(field_list:caffe.LayerParameter.propagate_down) return propagate_down_; } inline ::google::protobuf::RepeatedField< bool >* LayerParameter::mutable_propagate_down() { + // @@protoc_insertion_point(field_mutable_list:caffe.LayerParameter.propagate_down) return &propagate_down_; } @@ -13323,22 +14560,27 @@ inline void LayerParameter::clear_include() { include_.Clear(); } inline const ::caffe::NetStateRule& LayerParameter::include(int index) const { + // @@protoc_insertion_point(field_get:caffe.LayerParameter.include) return include_.Get(index); } inline ::caffe::NetStateRule* LayerParameter::mutable_include(int index) { + // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.include) return include_.Mutable(index); } inline ::caffe::NetStateRule* LayerParameter::add_include() { + // @@protoc_insertion_point(field_add:caffe.LayerParameter.include) return include_.Add(); } -inline const ::google::protobuf::RepeatedPtrField< ::caffe::NetStateRule >& -LayerParameter::include() const { - return include_; -} inline ::google::protobuf::RepeatedPtrField< ::caffe::NetStateRule >* LayerParameter::mutable_include() { + // @@protoc_insertion_point(field_mutable_list:caffe.LayerParameter.include) return &include_; } +inline const ::google::protobuf::RepeatedPtrField< ::caffe::NetStateRule >& +LayerParameter::include() const { + // @@protoc_insertion_point(field_list:caffe.LayerParameter.include) + return include_; +} // repeated .caffe.NetStateRule exclude = 9; inline int LayerParameter::exclude_size() const { @@ -13348,22 +14590,27 @@ inline void LayerParameter::clear_exclude() { exclude_.Clear(); } inline const ::caffe::NetStateRule& LayerParameter::exclude(int index) const { + // @@protoc_insertion_point(field_get:caffe.LayerParameter.exclude) return exclude_.Get(index); } inline ::caffe::NetStateRule* LayerParameter::mutable_exclude(int index) { + // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.exclude) return exclude_.Mutable(index); } inline ::caffe::NetStateRule* LayerParameter::add_exclude() { + // @@protoc_insertion_point(field_add:caffe.LayerParameter.exclude) return exclude_.Add(); } -inline const ::google::protobuf::RepeatedPtrField< ::caffe::NetStateRule >& -LayerParameter::exclude() const { - return exclude_; -} inline ::google::protobuf::RepeatedPtrField< ::caffe::NetStateRule >* LayerParameter::mutable_exclude() { + // @@protoc_insertion_point(field_mutable_list:caffe.LayerParameter.exclude) return &exclude_; } +inline const ::google::protobuf::RepeatedPtrField< ::caffe::NetStateRule >& +LayerParameter::exclude() const { + // @@protoc_insertion_point(field_list:caffe.LayerParameter.exclude) + return exclude_; +} // optional .caffe.TransformationParameter transform_param = 100; inline bool LayerParameter::has_transform_param() const { @@ -13380,14 +14627,20 @@ inline void LayerParameter::clear_transform_param() { clear_has_transform_param(); } inline const ::caffe::TransformationParameter& LayerParameter::transform_param() const { - return transform_param_ != NULL ? *transform_param_ : *default_instance_->transform_param_; + // @@protoc_insertion_point(field_get:caffe.LayerParameter.transform_param) + return transform_param_ != NULL ? *transform_param_ + : *::caffe::TransformationParameter::internal_default_instance(); } inline ::caffe::TransformationParameter* LayerParameter::mutable_transform_param() { set_has_transform_param(); - if (transform_param_ == NULL) transform_param_ = new ::caffe::TransformationParameter; + if (transform_param_ == NULL) { + transform_param_ = new ::caffe::TransformationParameter; + } + // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.transform_param) return transform_param_; } inline ::caffe::TransformationParameter* LayerParameter::release_transform_param() { + // @@protoc_insertion_point(field_release:caffe.LayerParameter.transform_param) clear_has_transform_param(); ::caffe::TransformationParameter* temp = transform_param_; transform_param_ = NULL; @@ -13401,6 +14654,7 @@ inline void LayerParameter::set_allocated_transform_param(::caffe::Transformatio } else { clear_has_transform_param(); } + // @@protoc_insertion_point(field_set_allocated:caffe.LayerParameter.transform_param) } // optional .caffe.LossParameter loss_param = 101; @@ -13418,14 +14672,20 @@ inline void LayerParameter::clear_loss_param() { clear_has_loss_param(); } inline const ::caffe::LossParameter& LayerParameter::loss_param() const { - return loss_param_ != NULL ? *loss_param_ : *default_instance_->loss_param_; + // @@protoc_insertion_point(field_get:caffe.LayerParameter.loss_param) + return loss_param_ != NULL ? *loss_param_ + : *::caffe::LossParameter::internal_default_instance(); } inline ::caffe::LossParameter* LayerParameter::mutable_loss_param() { set_has_loss_param(); - if (loss_param_ == NULL) loss_param_ = new ::caffe::LossParameter; + if (loss_param_ == NULL) { + loss_param_ = new ::caffe::LossParameter; + } + // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.loss_param) return loss_param_; } inline ::caffe::LossParameter* LayerParameter::release_loss_param() { + // @@protoc_insertion_point(field_release:caffe.LayerParameter.loss_param) clear_has_loss_param(); ::caffe::LossParameter* temp = loss_param_; loss_param_ = NULL; @@ -13439,6 +14699,7 @@ inline void LayerParameter::set_allocated_loss_param(::caffe::LossParameter* los } else { clear_has_loss_param(); } + // @@protoc_insertion_point(field_set_allocated:caffe.LayerParameter.loss_param) } // optional .caffe.AccuracyParameter accuracy_param = 102; @@ -13456,14 +14717,20 @@ inline void LayerParameter::clear_accuracy_param() { clear_has_accuracy_param(); } inline const ::caffe::AccuracyParameter& LayerParameter::accuracy_param() const { - return accuracy_param_ != NULL ? *accuracy_param_ : *default_instance_->accuracy_param_; + // @@protoc_insertion_point(field_get:caffe.LayerParameter.accuracy_param) + return accuracy_param_ != NULL ? *accuracy_param_ + : *::caffe::AccuracyParameter::internal_default_instance(); } inline ::caffe::AccuracyParameter* LayerParameter::mutable_accuracy_param() { set_has_accuracy_param(); - if (accuracy_param_ == NULL) accuracy_param_ = new ::caffe::AccuracyParameter; + if (accuracy_param_ == NULL) { + accuracy_param_ = new ::caffe::AccuracyParameter; + } + // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.accuracy_param) return accuracy_param_; } inline ::caffe::AccuracyParameter* LayerParameter::release_accuracy_param() { + // @@protoc_insertion_point(field_release:caffe.LayerParameter.accuracy_param) clear_has_accuracy_param(); ::caffe::AccuracyParameter* temp = accuracy_param_; accuracy_param_ = NULL; @@ -13477,6 +14744,7 @@ inline void LayerParameter::set_allocated_accuracy_param(::caffe::AccuracyParame } else { clear_has_accuracy_param(); } + // @@protoc_insertion_point(field_set_allocated:caffe.LayerParameter.accuracy_param) } // optional .caffe.ArgMaxParameter argmax_param = 103; @@ -13494,14 +14762,20 @@ inline void LayerParameter::clear_argmax_param() { clear_has_argmax_param(); } inline const ::caffe::ArgMaxParameter& LayerParameter::argmax_param() const { - return argmax_param_ != NULL ? *argmax_param_ : *default_instance_->argmax_param_; + // @@protoc_insertion_point(field_get:caffe.LayerParameter.argmax_param) + return argmax_param_ != NULL ? *argmax_param_ + : *::caffe::ArgMaxParameter::internal_default_instance(); } inline ::caffe::ArgMaxParameter* LayerParameter::mutable_argmax_param() { set_has_argmax_param(); - if (argmax_param_ == NULL) argmax_param_ = new ::caffe::ArgMaxParameter; + if (argmax_param_ == NULL) { + argmax_param_ = new ::caffe::ArgMaxParameter; + } + // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.argmax_param) return argmax_param_; } inline ::caffe::ArgMaxParameter* LayerParameter::release_argmax_param() { + // @@protoc_insertion_point(field_release:caffe.LayerParameter.argmax_param) clear_has_argmax_param(); ::caffe::ArgMaxParameter* temp = argmax_param_; argmax_param_ = NULL; @@ -13515,6 +14789,7 @@ inline void LayerParameter::set_allocated_argmax_param(::caffe::ArgMaxParameter* } else { clear_has_argmax_param(); } + // @@protoc_insertion_point(field_set_allocated:caffe.LayerParameter.argmax_param) } // optional .caffe.ConcatParameter concat_param = 104; @@ -13532,14 +14807,20 @@ inline void LayerParameter::clear_concat_param() { clear_has_concat_param(); } inline const ::caffe::ConcatParameter& LayerParameter::concat_param() const { - return concat_param_ != NULL ? *concat_param_ : *default_instance_->concat_param_; + // @@protoc_insertion_point(field_get:caffe.LayerParameter.concat_param) + return concat_param_ != NULL ? *concat_param_ + : *::caffe::ConcatParameter::internal_default_instance(); } inline ::caffe::ConcatParameter* LayerParameter::mutable_concat_param() { set_has_concat_param(); - if (concat_param_ == NULL) concat_param_ = new ::caffe::ConcatParameter; + if (concat_param_ == NULL) { + concat_param_ = new ::caffe::ConcatParameter; + } + // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.concat_param) return concat_param_; } inline ::caffe::ConcatParameter* LayerParameter::release_concat_param() { + // @@protoc_insertion_point(field_release:caffe.LayerParameter.concat_param) clear_has_concat_param(); ::caffe::ConcatParameter* temp = concat_param_; concat_param_ = NULL; @@ -13553,6 +14834,7 @@ inline void LayerParameter::set_allocated_concat_param(::caffe::ConcatParameter* } else { clear_has_concat_param(); } + // @@protoc_insertion_point(field_set_allocated:caffe.LayerParameter.concat_param) } // optional .caffe.ContrastiveLossParameter contrastive_loss_param = 105; @@ -13570,14 +14852,20 @@ inline void LayerParameter::clear_contrastive_loss_param() { clear_has_contrastive_loss_param(); } inline const ::caffe::ContrastiveLossParameter& LayerParameter::contrastive_loss_param() const { - return contrastive_loss_param_ != NULL ? *contrastive_loss_param_ : *default_instance_->contrastive_loss_param_; + // @@protoc_insertion_point(field_get:caffe.LayerParameter.contrastive_loss_param) + return contrastive_loss_param_ != NULL ? *contrastive_loss_param_ + : *::caffe::ContrastiveLossParameter::internal_default_instance(); } inline ::caffe::ContrastiveLossParameter* LayerParameter::mutable_contrastive_loss_param() { set_has_contrastive_loss_param(); - if (contrastive_loss_param_ == NULL) contrastive_loss_param_ = new ::caffe::ContrastiveLossParameter; + if (contrastive_loss_param_ == NULL) { + contrastive_loss_param_ = new ::caffe::ContrastiveLossParameter; + } + // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.contrastive_loss_param) return contrastive_loss_param_; } inline ::caffe::ContrastiveLossParameter* LayerParameter::release_contrastive_loss_param() { + // @@protoc_insertion_point(field_release:caffe.LayerParameter.contrastive_loss_param) clear_has_contrastive_loss_param(); ::caffe::ContrastiveLossParameter* temp = contrastive_loss_param_; contrastive_loss_param_ = NULL; @@ -13591,6 +14879,7 @@ inline void LayerParameter::set_allocated_contrastive_loss_param(::caffe::Contra } else { clear_has_contrastive_loss_param(); } + // @@protoc_insertion_point(field_set_allocated:caffe.LayerParameter.contrastive_loss_param) } // optional .caffe.ConvolutionParameter convolution_param = 106; @@ -13608,14 +14897,20 @@ inline void LayerParameter::clear_convolution_param() { clear_has_convolution_param(); } inline const ::caffe::ConvolutionParameter& LayerParameter::convolution_param() const { - return convolution_param_ != NULL ? *convolution_param_ : *default_instance_->convolution_param_; + // @@protoc_insertion_point(field_get:caffe.LayerParameter.convolution_param) + return convolution_param_ != NULL ? *convolution_param_ + : *::caffe::ConvolutionParameter::internal_default_instance(); } inline ::caffe::ConvolutionParameter* LayerParameter::mutable_convolution_param() { set_has_convolution_param(); - if (convolution_param_ == NULL) convolution_param_ = new ::caffe::ConvolutionParameter; + if (convolution_param_ == NULL) { + convolution_param_ = new ::caffe::ConvolutionParameter; + } + // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.convolution_param) return convolution_param_; } inline ::caffe::ConvolutionParameter* LayerParameter::release_convolution_param() { + // @@protoc_insertion_point(field_release:caffe.LayerParameter.convolution_param) clear_has_convolution_param(); ::caffe::ConvolutionParameter* temp = convolution_param_; convolution_param_ = NULL; @@ -13629,6 +14924,7 @@ inline void LayerParameter::set_allocated_convolution_param(::caffe::Convolution } else { clear_has_convolution_param(); } + // @@protoc_insertion_point(field_set_allocated:caffe.LayerParameter.convolution_param) } // optional .caffe.CropParameter crop_param = 137; @@ -13646,14 +14942,20 @@ inline void LayerParameter::clear_crop_param() { clear_has_crop_param(); } inline const ::caffe::CropParameter& LayerParameter::crop_param() const { - return crop_param_ != NULL ? *crop_param_ : *default_instance_->crop_param_; + // @@protoc_insertion_point(field_get:caffe.LayerParameter.crop_param) + return crop_param_ != NULL ? *crop_param_ + : *::caffe::CropParameter::internal_default_instance(); } inline ::caffe::CropParameter* LayerParameter::mutable_crop_param() { set_has_crop_param(); - if (crop_param_ == NULL) crop_param_ = new ::caffe::CropParameter; + if (crop_param_ == NULL) { + crop_param_ = new ::caffe::CropParameter; + } + // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.crop_param) return crop_param_; } inline ::caffe::CropParameter* LayerParameter::release_crop_param() { + // @@protoc_insertion_point(field_release:caffe.LayerParameter.crop_param) clear_has_crop_param(); ::caffe::CropParameter* temp = crop_param_; crop_param_ = NULL; @@ -13667,6 +14969,7 @@ inline void LayerParameter::set_allocated_crop_param(::caffe::CropParameter* cro } else { clear_has_crop_param(); } + // @@protoc_insertion_point(field_set_allocated:caffe.LayerParameter.crop_param) } // optional .caffe.DataParameter data_param = 107; @@ -13684,14 +14987,20 @@ inline void LayerParameter::clear_data_param() { clear_has_data_param(); } inline const ::caffe::DataParameter& LayerParameter::data_param() const { - return data_param_ != NULL ? *data_param_ : *default_instance_->data_param_; + // @@protoc_insertion_point(field_get:caffe.LayerParameter.data_param) + return data_param_ != NULL ? *data_param_ + : *::caffe::DataParameter::internal_default_instance(); } inline ::caffe::DataParameter* LayerParameter::mutable_data_param() { set_has_data_param(); - if (data_param_ == NULL) data_param_ = new ::caffe::DataParameter; + if (data_param_ == NULL) { + data_param_ = new ::caffe::DataParameter; + } + // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.data_param) return data_param_; } inline ::caffe::DataParameter* LayerParameter::release_data_param() { + // @@protoc_insertion_point(field_release:caffe.LayerParameter.data_param) clear_has_data_param(); ::caffe::DataParameter* temp = data_param_; data_param_ = NULL; @@ -13705,6 +15014,7 @@ inline void LayerParameter::set_allocated_data_param(::caffe::DataParameter* dat } else { clear_has_data_param(); } + // @@protoc_insertion_point(field_set_allocated:caffe.LayerParameter.data_param) } // optional .caffe.DetectionOutputParameter detection_output_param = 141; @@ -13722,14 +15032,20 @@ inline void LayerParameter::clear_detection_output_param() { clear_has_detection_output_param(); } inline const ::caffe::DetectionOutputParameter& LayerParameter::detection_output_param() const { - return detection_output_param_ != NULL ? *detection_output_param_ : *default_instance_->detection_output_param_; + // @@protoc_insertion_point(field_get:caffe.LayerParameter.detection_output_param) + return detection_output_param_ != NULL ? *detection_output_param_ + : *::caffe::DetectionOutputParameter::internal_default_instance(); } inline ::caffe::DetectionOutputParameter* LayerParameter::mutable_detection_output_param() { set_has_detection_output_param(); - if (detection_output_param_ == NULL) detection_output_param_ = new ::caffe::DetectionOutputParameter; + if (detection_output_param_ == NULL) { + detection_output_param_ = new ::caffe::DetectionOutputParameter; + } + // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.detection_output_param) return detection_output_param_; } inline ::caffe::DetectionOutputParameter* LayerParameter::release_detection_output_param() { + // @@protoc_insertion_point(field_release:caffe.LayerParameter.detection_output_param) clear_has_detection_output_param(); ::caffe::DetectionOutputParameter* temp = detection_output_param_; detection_output_param_ = NULL; @@ -13743,6 +15059,7 @@ inline void LayerParameter::set_allocated_detection_output_param(::caffe::Detect } else { clear_has_detection_output_param(); } + // @@protoc_insertion_point(field_set_allocated:caffe.LayerParameter.detection_output_param) } // optional .caffe.DropoutParameter dropout_param = 108; @@ -13760,14 +15077,20 @@ inline void LayerParameter::clear_dropout_param() { clear_has_dropout_param(); } inline const ::caffe::DropoutParameter& LayerParameter::dropout_param() const { - return dropout_param_ != NULL ? *dropout_param_ : *default_instance_->dropout_param_; + // @@protoc_insertion_point(field_get:caffe.LayerParameter.dropout_param) + return dropout_param_ != NULL ? *dropout_param_ + : *::caffe::DropoutParameter::internal_default_instance(); } inline ::caffe::DropoutParameter* LayerParameter::mutable_dropout_param() { set_has_dropout_param(); - if (dropout_param_ == NULL) dropout_param_ = new ::caffe::DropoutParameter; + if (dropout_param_ == NULL) { + dropout_param_ = new ::caffe::DropoutParameter; + } + // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.dropout_param) return dropout_param_; } inline ::caffe::DropoutParameter* LayerParameter::release_dropout_param() { + // @@protoc_insertion_point(field_release:caffe.LayerParameter.dropout_param) clear_has_dropout_param(); ::caffe::DropoutParameter* temp = dropout_param_; dropout_param_ = NULL; @@ -13781,6 +15104,7 @@ inline void LayerParameter::set_allocated_dropout_param(::caffe::DropoutParamete } else { clear_has_dropout_param(); } + // @@protoc_insertion_point(field_set_allocated:caffe.LayerParameter.dropout_param) } // optional .caffe.DummyDataParameter dummy_data_param = 109; @@ -13798,14 +15122,20 @@ inline void LayerParameter::clear_dummy_data_param() { clear_has_dummy_data_param(); } inline const ::caffe::DummyDataParameter& LayerParameter::dummy_data_param() const { - return dummy_data_param_ != NULL ? *dummy_data_param_ : *default_instance_->dummy_data_param_; + // @@protoc_insertion_point(field_get:caffe.LayerParameter.dummy_data_param) + return dummy_data_param_ != NULL ? *dummy_data_param_ + : *::caffe::DummyDataParameter::internal_default_instance(); } inline ::caffe::DummyDataParameter* LayerParameter::mutable_dummy_data_param() { set_has_dummy_data_param(); - if (dummy_data_param_ == NULL) dummy_data_param_ = new ::caffe::DummyDataParameter; + if (dummy_data_param_ == NULL) { + dummy_data_param_ = new ::caffe::DummyDataParameter; + } + // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.dummy_data_param) return dummy_data_param_; } inline ::caffe::DummyDataParameter* LayerParameter::release_dummy_data_param() { + // @@protoc_insertion_point(field_release:caffe.LayerParameter.dummy_data_param) clear_has_dummy_data_param(); ::caffe::DummyDataParameter* temp = dummy_data_param_; dummy_data_param_ = NULL; @@ -13819,6 +15149,7 @@ inline void LayerParameter::set_allocated_dummy_data_param(::caffe::DummyDataPar } else { clear_has_dummy_data_param(); } + // @@protoc_insertion_point(field_set_allocated:caffe.LayerParameter.dummy_data_param) } // optional .caffe.EltwiseParameter eltwise_param = 110; @@ -13836,14 +15167,20 @@ inline void LayerParameter::clear_eltwise_param() { clear_has_eltwise_param(); } inline const ::caffe::EltwiseParameter& LayerParameter::eltwise_param() const { - return eltwise_param_ != NULL ? *eltwise_param_ : *default_instance_->eltwise_param_; + // @@protoc_insertion_point(field_get:caffe.LayerParameter.eltwise_param) + return eltwise_param_ != NULL ? *eltwise_param_ + : *::caffe::EltwiseParameter::internal_default_instance(); } inline ::caffe::EltwiseParameter* LayerParameter::mutable_eltwise_param() { set_has_eltwise_param(); - if (eltwise_param_ == NULL) eltwise_param_ = new ::caffe::EltwiseParameter; + if (eltwise_param_ == NULL) { + eltwise_param_ = new ::caffe::EltwiseParameter; + } + // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.eltwise_param) return eltwise_param_; } inline ::caffe::EltwiseParameter* LayerParameter::release_eltwise_param() { + // @@protoc_insertion_point(field_release:caffe.LayerParameter.eltwise_param) clear_has_eltwise_param(); ::caffe::EltwiseParameter* temp = eltwise_param_; eltwise_param_ = NULL; @@ -13857,6 +15194,7 @@ inline void LayerParameter::set_allocated_eltwise_param(::caffe::EltwiseParamete } else { clear_has_eltwise_param(); } + // @@protoc_insertion_point(field_set_allocated:caffe.LayerParameter.eltwise_param) } // optional .caffe.ExpParameter exp_param = 111; @@ -13874,14 +15212,20 @@ inline void LayerParameter::clear_exp_param() { clear_has_exp_param(); } inline const ::caffe::ExpParameter& LayerParameter::exp_param() const { - return exp_param_ != NULL ? *exp_param_ : *default_instance_->exp_param_; + // @@protoc_insertion_point(field_get:caffe.LayerParameter.exp_param) + return exp_param_ != NULL ? *exp_param_ + : *::caffe::ExpParameter::internal_default_instance(); } inline ::caffe::ExpParameter* LayerParameter::mutable_exp_param() { set_has_exp_param(); - if (exp_param_ == NULL) exp_param_ = new ::caffe::ExpParameter; + if (exp_param_ == NULL) { + exp_param_ = new ::caffe::ExpParameter; + } + // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.exp_param) return exp_param_; } inline ::caffe::ExpParameter* LayerParameter::release_exp_param() { + // @@protoc_insertion_point(field_release:caffe.LayerParameter.exp_param) clear_has_exp_param(); ::caffe::ExpParameter* temp = exp_param_; exp_param_ = NULL; @@ -13895,6 +15239,7 @@ inline void LayerParameter::set_allocated_exp_param(::caffe::ExpParameter* exp_p } else { clear_has_exp_param(); } + // @@protoc_insertion_point(field_set_allocated:caffe.LayerParameter.exp_param) } // optional .caffe.FlattenParameter flatten_param = 135; @@ -13912,14 +15257,20 @@ inline void LayerParameter::clear_flatten_param() { clear_has_flatten_param(); } inline const ::caffe::FlattenParameter& LayerParameter::flatten_param() const { - return flatten_param_ != NULL ? *flatten_param_ : *default_instance_->flatten_param_; + // @@protoc_insertion_point(field_get:caffe.LayerParameter.flatten_param) + return flatten_param_ != NULL ? *flatten_param_ + : *::caffe::FlattenParameter::internal_default_instance(); } inline ::caffe::FlattenParameter* LayerParameter::mutable_flatten_param() { set_has_flatten_param(); - if (flatten_param_ == NULL) flatten_param_ = new ::caffe::FlattenParameter; + if (flatten_param_ == NULL) { + flatten_param_ = new ::caffe::FlattenParameter; + } + // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.flatten_param) return flatten_param_; } inline ::caffe::FlattenParameter* LayerParameter::release_flatten_param() { + // @@protoc_insertion_point(field_release:caffe.LayerParameter.flatten_param) clear_has_flatten_param(); ::caffe::FlattenParameter* temp = flatten_param_; flatten_param_ = NULL; @@ -13933,6 +15284,7 @@ inline void LayerParameter::set_allocated_flatten_param(::caffe::FlattenParamete } else { clear_has_flatten_param(); } + // @@protoc_insertion_point(field_set_allocated:caffe.LayerParameter.flatten_param) } // optional .caffe.HDF5DataParameter hdf5_data_param = 112; @@ -13950,14 +15302,20 @@ inline void LayerParameter::clear_hdf5_data_param() { clear_has_hdf5_data_param(); } inline const ::caffe::HDF5DataParameter& LayerParameter::hdf5_data_param() const { - return hdf5_data_param_ != NULL ? *hdf5_data_param_ : *default_instance_->hdf5_data_param_; + // @@protoc_insertion_point(field_get:caffe.LayerParameter.hdf5_data_param) + return hdf5_data_param_ != NULL ? *hdf5_data_param_ + : *::caffe::HDF5DataParameter::internal_default_instance(); } inline ::caffe::HDF5DataParameter* LayerParameter::mutable_hdf5_data_param() { set_has_hdf5_data_param(); - if (hdf5_data_param_ == NULL) hdf5_data_param_ = new ::caffe::HDF5DataParameter; + if (hdf5_data_param_ == NULL) { + hdf5_data_param_ = new ::caffe::HDF5DataParameter; + } + // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.hdf5_data_param) return hdf5_data_param_; } inline ::caffe::HDF5DataParameter* LayerParameter::release_hdf5_data_param() { + // @@protoc_insertion_point(field_release:caffe.LayerParameter.hdf5_data_param) clear_has_hdf5_data_param(); ::caffe::HDF5DataParameter* temp = hdf5_data_param_; hdf5_data_param_ = NULL; @@ -13971,6 +15329,7 @@ inline void LayerParameter::set_allocated_hdf5_data_param(::caffe::HDF5DataParam } else { clear_has_hdf5_data_param(); } + // @@protoc_insertion_point(field_set_allocated:caffe.LayerParameter.hdf5_data_param) } // optional .caffe.HDF5OutputParameter hdf5_output_param = 113; @@ -13988,14 +15347,20 @@ inline void LayerParameter::clear_hdf5_output_param() { clear_has_hdf5_output_param(); } inline const ::caffe::HDF5OutputParameter& LayerParameter::hdf5_output_param() const { - return hdf5_output_param_ != NULL ? *hdf5_output_param_ : *default_instance_->hdf5_output_param_; + // @@protoc_insertion_point(field_get:caffe.LayerParameter.hdf5_output_param) + return hdf5_output_param_ != NULL ? *hdf5_output_param_ + : *::caffe::HDF5OutputParameter::internal_default_instance(); } inline ::caffe::HDF5OutputParameter* LayerParameter::mutable_hdf5_output_param() { set_has_hdf5_output_param(); - if (hdf5_output_param_ == NULL) hdf5_output_param_ = new ::caffe::HDF5OutputParameter; + if (hdf5_output_param_ == NULL) { + hdf5_output_param_ = new ::caffe::HDF5OutputParameter; + } + // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.hdf5_output_param) return hdf5_output_param_; } inline ::caffe::HDF5OutputParameter* LayerParameter::release_hdf5_output_param() { + // @@protoc_insertion_point(field_release:caffe.LayerParameter.hdf5_output_param) clear_has_hdf5_output_param(); ::caffe::HDF5OutputParameter* temp = hdf5_output_param_; hdf5_output_param_ = NULL; @@ -14009,6 +15374,7 @@ inline void LayerParameter::set_allocated_hdf5_output_param(::caffe::HDF5OutputP } else { clear_has_hdf5_output_param(); } + // @@protoc_insertion_point(field_set_allocated:caffe.LayerParameter.hdf5_output_param) } // optional .caffe.HingeLossParameter hinge_loss_param = 114; @@ -14026,14 +15392,20 @@ inline void LayerParameter::clear_hinge_loss_param() { clear_has_hinge_loss_param(); } inline const ::caffe::HingeLossParameter& LayerParameter::hinge_loss_param() const { - return hinge_loss_param_ != NULL ? *hinge_loss_param_ : *default_instance_->hinge_loss_param_; + // @@protoc_insertion_point(field_get:caffe.LayerParameter.hinge_loss_param) + return hinge_loss_param_ != NULL ? *hinge_loss_param_ + : *::caffe::HingeLossParameter::internal_default_instance(); } inline ::caffe::HingeLossParameter* LayerParameter::mutable_hinge_loss_param() { set_has_hinge_loss_param(); - if (hinge_loss_param_ == NULL) hinge_loss_param_ = new ::caffe::HingeLossParameter; + if (hinge_loss_param_ == NULL) { + hinge_loss_param_ = new ::caffe::HingeLossParameter; + } + // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.hinge_loss_param) return hinge_loss_param_; } inline ::caffe::HingeLossParameter* LayerParameter::release_hinge_loss_param() { + // @@protoc_insertion_point(field_release:caffe.LayerParameter.hinge_loss_param) clear_has_hinge_loss_param(); ::caffe::HingeLossParameter* temp = hinge_loss_param_; hinge_loss_param_ = NULL; @@ -14047,6 +15419,7 @@ inline void LayerParameter::set_allocated_hinge_loss_param(::caffe::HingeLossPar } else { clear_has_hinge_loss_param(); } + // @@protoc_insertion_point(field_set_allocated:caffe.LayerParameter.hinge_loss_param) } // optional .caffe.ImageDataParameter image_data_param = 115; @@ -14064,14 +15437,20 @@ inline void LayerParameter::clear_image_data_param() { clear_has_image_data_param(); } inline const ::caffe::ImageDataParameter& LayerParameter::image_data_param() const { - return image_data_param_ != NULL ? *image_data_param_ : *default_instance_->image_data_param_; + // @@protoc_insertion_point(field_get:caffe.LayerParameter.image_data_param) + return image_data_param_ != NULL ? *image_data_param_ + : *::caffe::ImageDataParameter::internal_default_instance(); } inline ::caffe::ImageDataParameter* LayerParameter::mutable_image_data_param() { set_has_image_data_param(); - if (image_data_param_ == NULL) image_data_param_ = new ::caffe::ImageDataParameter; + if (image_data_param_ == NULL) { + image_data_param_ = new ::caffe::ImageDataParameter; + } + // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.image_data_param) return image_data_param_; } inline ::caffe::ImageDataParameter* LayerParameter::release_image_data_param() { + // @@protoc_insertion_point(field_release:caffe.LayerParameter.image_data_param) clear_has_image_data_param(); ::caffe::ImageDataParameter* temp = image_data_param_; image_data_param_ = NULL; @@ -14085,6 +15464,7 @@ inline void LayerParameter::set_allocated_image_data_param(::caffe::ImageDataPar } else { clear_has_image_data_param(); } + // @@protoc_insertion_point(field_set_allocated:caffe.LayerParameter.image_data_param) } // optional .caffe.InfogainLossParameter infogain_loss_param = 116; @@ -14102,14 +15482,20 @@ inline void LayerParameter::clear_infogain_loss_param() { clear_has_infogain_loss_param(); } inline const ::caffe::InfogainLossParameter& LayerParameter::infogain_loss_param() const { - return infogain_loss_param_ != NULL ? *infogain_loss_param_ : *default_instance_->infogain_loss_param_; + // @@protoc_insertion_point(field_get:caffe.LayerParameter.infogain_loss_param) + return infogain_loss_param_ != NULL ? *infogain_loss_param_ + : *::caffe::InfogainLossParameter::internal_default_instance(); } inline ::caffe::InfogainLossParameter* LayerParameter::mutable_infogain_loss_param() { set_has_infogain_loss_param(); - if (infogain_loss_param_ == NULL) infogain_loss_param_ = new ::caffe::InfogainLossParameter; + if (infogain_loss_param_ == NULL) { + infogain_loss_param_ = new ::caffe::InfogainLossParameter; + } + // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.infogain_loss_param) return infogain_loss_param_; } inline ::caffe::InfogainLossParameter* LayerParameter::release_infogain_loss_param() { + // @@protoc_insertion_point(field_release:caffe.LayerParameter.infogain_loss_param) clear_has_infogain_loss_param(); ::caffe::InfogainLossParameter* temp = infogain_loss_param_; infogain_loss_param_ = NULL; @@ -14123,6 +15509,7 @@ inline void LayerParameter::set_allocated_infogain_loss_param(::caffe::InfogainL } else { clear_has_infogain_loss_param(); } + // @@protoc_insertion_point(field_set_allocated:caffe.LayerParameter.infogain_loss_param) } // optional .caffe.InnerProductParameter inner_product_param = 117; @@ -14140,14 +15527,20 @@ inline void LayerParameter::clear_inner_product_param() { clear_has_inner_product_param(); } inline const ::caffe::InnerProductParameter& LayerParameter::inner_product_param() const { - return inner_product_param_ != NULL ? *inner_product_param_ : *default_instance_->inner_product_param_; + // @@protoc_insertion_point(field_get:caffe.LayerParameter.inner_product_param) + return inner_product_param_ != NULL ? *inner_product_param_ + : *::caffe::InnerProductParameter::internal_default_instance(); } inline ::caffe::InnerProductParameter* LayerParameter::mutable_inner_product_param() { set_has_inner_product_param(); - if (inner_product_param_ == NULL) inner_product_param_ = new ::caffe::InnerProductParameter; + if (inner_product_param_ == NULL) { + inner_product_param_ = new ::caffe::InnerProductParameter; + } + // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.inner_product_param) return inner_product_param_; } inline ::caffe::InnerProductParameter* LayerParameter::release_inner_product_param() { + // @@protoc_insertion_point(field_release:caffe.LayerParameter.inner_product_param) clear_has_inner_product_param(); ::caffe::InnerProductParameter* temp = inner_product_param_; inner_product_param_ = NULL; @@ -14161,6 +15554,7 @@ inline void LayerParameter::set_allocated_inner_product_param(::caffe::InnerProd } else { clear_has_inner_product_param(); } + // @@protoc_insertion_point(field_set_allocated:caffe.LayerParameter.inner_product_param) } // optional .caffe.LogParameter log_param = 134; @@ -14178,14 +15572,20 @@ inline void LayerParameter::clear_log_param() { clear_has_log_param(); } inline const ::caffe::LogParameter& LayerParameter::log_param() const { - return log_param_ != NULL ? *log_param_ : *default_instance_->log_param_; + // @@protoc_insertion_point(field_get:caffe.LayerParameter.log_param) + return log_param_ != NULL ? *log_param_ + : *::caffe::LogParameter::internal_default_instance(); } inline ::caffe::LogParameter* LayerParameter::mutable_log_param() { set_has_log_param(); - if (log_param_ == NULL) log_param_ = new ::caffe::LogParameter; + if (log_param_ == NULL) { + log_param_ = new ::caffe::LogParameter; + } + // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.log_param) return log_param_; } inline ::caffe::LogParameter* LayerParameter::release_log_param() { + // @@protoc_insertion_point(field_release:caffe.LayerParameter.log_param) clear_has_log_param(); ::caffe::LogParameter* temp = log_param_; log_param_ = NULL; @@ -14199,6 +15599,7 @@ inline void LayerParameter::set_allocated_log_param(::caffe::LogParameter* log_p } else { clear_has_log_param(); } + // @@protoc_insertion_point(field_set_allocated:caffe.LayerParameter.log_param) } // optional .caffe.LRNParameter lrn_param = 118; @@ -14216,14 +15617,20 @@ inline void LayerParameter::clear_lrn_param() { clear_has_lrn_param(); } inline const ::caffe::LRNParameter& LayerParameter::lrn_param() const { - return lrn_param_ != NULL ? *lrn_param_ : *default_instance_->lrn_param_; + // @@protoc_insertion_point(field_get:caffe.LayerParameter.lrn_param) + return lrn_param_ != NULL ? *lrn_param_ + : *::caffe::LRNParameter::internal_default_instance(); } inline ::caffe::LRNParameter* LayerParameter::mutable_lrn_param() { set_has_lrn_param(); - if (lrn_param_ == NULL) lrn_param_ = new ::caffe::LRNParameter; + if (lrn_param_ == NULL) { + lrn_param_ = new ::caffe::LRNParameter; + } + // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.lrn_param) return lrn_param_; } inline ::caffe::LRNParameter* LayerParameter::release_lrn_param() { + // @@protoc_insertion_point(field_release:caffe.LayerParameter.lrn_param) clear_has_lrn_param(); ::caffe::LRNParameter* temp = lrn_param_; lrn_param_ = NULL; @@ -14237,6 +15644,7 @@ inline void LayerParameter::set_allocated_lrn_param(::caffe::LRNParameter* lrn_p } else { clear_has_lrn_param(); } + // @@protoc_insertion_point(field_set_allocated:caffe.LayerParameter.lrn_param) } // optional .caffe.MemoryDataParameter memory_data_param = 119; @@ -14254,14 +15662,20 @@ inline void LayerParameter::clear_memory_data_param() { clear_has_memory_data_param(); } inline const ::caffe::MemoryDataParameter& LayerParameter::memory_data_param() const { - return memory_data_param_ != NULL ? *memory_data_param_ : *default_instance_->memory_data_param_; + // @@protoc_insertion_point(field_get:caffe.LayerParameter.memory_data_param) + return memory_data_param_ != NULL ? *memory_data_param_ + : *::caffe::MemoryDataParameter::internal_default_instance(); } inline ::caffe::MemoryDataParameter* LayerParameter::mutable_memory_data_param() { set_has_memory_data_param(); - if (memory_data_param_ == NULL) memory_data_param_ = new ::caffe::MemoryDataParameter; + if (memory_data_param_ == NULL) { + memory_data_param_ = new ::caffe::MemoryDataParameter; + } + // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.memory_data_param) return memory_data_param_; } inline ::caffe::MemoryDataParameter* LayerParameter::release_memory_data_param() { + // @@protoc_insertion_point(field_release:caffe.LayerParameter.memory_data_param) clear_has_memory_data_param(); ::caffe::MemoryDataParameter* temp = memory_data_param_; memory_data_param_ = NULL; @@ -14275,6 +15689,7 @@ inline void LayerParameter::set_allocated_memory_data_param(::caffe::MemoryDataP } else { clear_has_memory_data_param(); } + // @@protoc_insertion_point(field_set_allocated:caffe.LayerParameter.memory_data_param) } // optional .caffe.MVNParameter mvn_param = 120; @@ -14292,14 +15707,20 @@ inline void LayerParameter::clear_mvn_param() { clear_has_mvn_param(); } inline const ::caffe::MVNParameter& LayerParameter::mvn_param() const { - return mvn_param_ != NULL ? *mvn_param_ : *default_instance_->mvn_param_; + // @@protoc_insertion_point(field_get:caffe.LayerParameter.mvn_param) + return mvn_param_ != NULL ? *mvn_param_ + : *::caffe::MVNParameter::internal_default_instance(); } inline ::caffe::MVNParameter* LayerParameter::mutable_mvn_param() { set_has_mvn_param(); - if (mvn_param_ == NULL) mvn_param_ = new ::caffe::MVNParameter; + if (mvn_param_ == NULL) { + mvn_param_ = new ::caffe::MVNParameter; + } + // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.mvn_param) return mvn_param_; } inline ::caffe::MVNParameter* LayerParameter::release_mvn_param() { + // @@protoc_insertion_point(field_release:caffe.LayerParameter.mvn_param) clear_has_mvn_param(); ::caffe::MVNParameter* temp = mvn_param_; mvn_param_ = NULL; @@ -14313,6 +15734,7 @@ inline void LayerParameter::set_allocated_mvn_param(::caffe::MVNParameter* mvn_p } else { clear_has_mvn_param(); } + // @@protoc_insertion_point(field_set_allocated:caffe.LayerParameter.mvn_param) } // optional .caffe.NormalizeBBoxParameter normalize_bbox_param = 139; @@ -14330,14 +15752,20 @@ inline void LayerParameter::clear_normalize_bbox_param() { clear_has_normalize_bbox_param(); } inline const ::caffe::NormalizeBBoxParameter& LayerParameter::normalize_bbox_param() const { - return normalize_bbox_param_ != NULL ? *normalize_bbox_param_ : *default_instance_->normalize_bbox_param_; + // @@protoc_insertion_point(field_get:caffe.LayerParameter.normalize_bbox_param) + return normalize_bbox_param_ != NULL ? *normalize_bbox_param_ + : *::caffe::NormalizeBBoxParameter::internal_default_instance(); } inline ::caffe::NormalizeBBoxParameter* LayerParameter::mutable_normalize_bbox_param() { set_has_normalize_bbox_param(); - if (normalize_bbox_param_ == NULL) normalize_bbox_param_ = new ::caffe::NormalizeBBoxParameter; + if (normalize_bbox_param_ == NULL) { + normalize_bbox_param_ = new ::caffe::NormalizeBBoxParameter; + } + // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.normalize_bbox_param) return normalize_bbox_param_; } inline ::caffe::NormalizeBBoxParameter* LayerParameter::release_normalize_bbox_param() { + // @@protoc_insertion_point(field_release:caffe.LayerParameter.normalize_bbox_param) clear_has_normalize_bbox_param(); ::caffe::NormalizeBBoxParameter* temp = normalize_bbox_param_; normalize_bbox_param_ = NULL; @@ -14351,6 +15779,7 @@ inline void LayerParameter::set_allocated_normalize_bbox_param(::caffe::Normaliz } else { clear_has_normalize_bbox_param(); } + // @@protoc_insertion_point(field_set_allocated:caffe.LayerParameter.normalize_bbox_param) } // optional .caffe.PermuteParameter permute_param = 138; @@ -14368,14 +15797,20 @@ inline void LayerParameter::clear_permute_param() { clear_has_permute_param(); } inline const ::caffe::PermuteParameter& LayerParameter::permute_param() const { - return permute_param_ != NULL ? *permute_param_ : *default_instance_->permute_param_; + // @@protoc_insertion_point(field_get:caffe.LayerParameter.permute_param) + return permute_param_ != NULL ? *permute_param_ + : *::caffe::PermuteParameter::internal_default_instance(); } inline ::caffe::PermuteParameter* LayerParameter::mutable_permute_param() { set_has_permute_param(); - if (permute_param_ == NULL) permute_param_ = new ::caffe::PermuteParameter; + if (permute_param_ == NULL) { + permute_param_ = new ::caffe::PermuteParameter; + } + // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.permute_param) return permute_param_; } inline ::caffe::PermuteParameter* LayerParameter::release_permute_param() { + // @@protoc_insertion_point(field_release:caffe.LayerParameter.permute_param) clear_has_permute_param(); ::caffe::PermuteParameter* temp = permute_param_; permute_param_ = NULL; @@ -14389,6 +15824,7 @@ inline void LayerParameter::set_allocated_permute_param(::caffe::PermuteParamete } else { clear_has_permute_param(); } + // @@protoc_insertion_point(field_set_allocated:caffe.LayerParameter.permute_param) } // optional .caffe.PoolingParameter pooling_param = 121; @@ -14406,14 +15842,20 @@ inline void LayerParameter::clear_pooling_param() { clear_has_pooling_param(); } inline const ::caffe::PoolingParameter& LayerParameter::pooling_param() const { - return pooling_param_ != NULL ? *pooling_param_ : *default_instance_->pooling_param_; + // @@protoc_insertion_point(field_get:caffe.LayerParameter.pooling_param) + return pooling_param_ != NULL ? *pooling_param_ + : *::caffe::PoolingParameter::internal_default_instance(); } inline ::caffe::PoolingParameter* LayerParameter::mutable_pooling_param() { set_has_pooling_param(); - if (pooling_param_ == NULL) pooling_param_ = new ::caffe::PoolingParameter; + if (pooling_param_ == NULL) { + pooling_param_ = new ::caffe::PoolingParameter; + } + // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.pooling_param) return pooling_param_; } inline ::caffe::PoolingParameter* LayerParameter::release_pooling_param() { + // @@protoc_insertion_point(field_release:caffe.LayerParameter.pooling_param) clear_has_pooling_param(); ::caffe::PoolingParameter* temp = pooling_param_; pooling_param_ = NULL; @@ -14427,6 +15869,7 @@ inline void LayerParameter::set_allocated_pooling_param(::caffe::PoolingParamete } else { clear_has_pooling_param(); } + // @@protoc_insertion_point(field_set_allocated:caffe.LayerParameter.pooling_param) } // optional .caffe.PowerParameter power_param = 122; @@ -14444,14 +15887,20 @@ inline void LayerParameter::clear_power_param() { clear_has_power_param(); } inline const ::caffe::PowerParameter& LayerParameter::power_param() const { - return power_param_ != NULL ? *power_param_ : *default_instance_->power_param_; + // @@protoc_insertion_point(field_get:caffe.LayerParameter.power_param) + return power_param_ != NULL ? *power_param_ + : *::caffe::PowerParameter::internal_default_instance(); } inline ::caffe::PowerParameter* LayerParameter::mutable_power_param() { set_has_power_param(); - if (power_param_ == NULL) power_param_ = new ::caffe::PowerParameter; + if (power_param_ == NULL) { + power_param_ = new ::caffe::PowerParameter; + } + // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.power_param) return power_param_; } inline ::caffe::PowerParameter* LayerParameter::release_power_param() { + // @@protoc_insertion_point(field_release:caffe.LayerParameter.power_param) clear_has_power_param(); ::caffe::PowerParameter* temp = power_param_; power_param_ = NULL; @@ -14465,6 +15914,7 @@ inline void LayerParameter::set_allocated_power_param(::caffe::PowerParameter* p } else { clear_has_power_param(); } + // @@protoc_insertion_point(field_set_allocated:caffe.LayerParameter.power_param) } // optional .caffe.PReLUParameter prelu_param = 131; @@ -14482,14 +15932,20 @@ inline void LayerParameter::clear_prelu_param() { clear_has_prelu_param(); } inline const ::caffe::PReLUParameter& LayerParameter::prelu_param() const { - return prelu_param_ != NULL ? *prelu_param_ : *default_instance_->prelu_param_; + // @@protoc_insertion_point(field_get:caffe.LayerParameter.prelu_param) + return prelu_param_ != NULL ? *prelu_param_ + : *::caffe::PReLUParameter::internal_default_instance(); } inline ::caffe::PReLUParameter* LayerParameter::mutable_prelu_param() { set_has_prelu_param(); - if (prelu_param_ == NULL) prelu_param_ = new ::caffe::PReLUParameter; + if (prelu_param_ == NULL) { + prelu_param_ = new ::caffe::PReLUParameter; + } + // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.prelu_param) return prelu_param_; } inline ::caffe::PReLUParameter* LayerParameter::release_prelu_param() { + // @@protoc_insertion_point(field_release:caffe.LayerParameter.prelu_param) clear_has_prelu_param(); ::caffe::PReLUParameter* temp = prelu_param_; prelu_param_ = NULL; @@ -14503,6 +15959,7 @@ inline void LayerParameter::set_allocated_prelu_param(::caffe::PReLUParameter* p } else { clear_has_prelu_param(); } + // @@protoc_insertion_point(field_set_allocated:caffe.LayerParameter.prelu_param) } // optional .caffe.PriorBoxParameter prior_box_param = 140; @@ -14520,14 +15977,20 @@ inline void LayerParameter::clear_prior_box_param() { clear_has_prior_box_param(); } inline const ::caffe::PriorBoxParameter& LayerParameter::prior_box_param() const { - return prior_box_param_ != NULL ? *prior_box_param_ : *default_instance_->prior_box_param_; + // @@protoc_insertion_point(field_get:caffe.LayerParameter.prior_box_param) + return prior_box_param_ != NULL ? *prior_box_param_ + : *::caffe::PriorBoxParameter::internal_default_instance(); } inline ::caffe::PriorBoxParameter* LayerParameter::mutable_prior_box_param() { set_has_prior_box_param(); - if (prior_box_param_ == NULL) prior_box_param_ = new ::caffe::PriorBoxParameter; + if (prior_box_param_ == NULL) { + prior_box_param_ = new ::caffe::PriorBoxParameter; + } + // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.prior_box_param) return prior_box_param_; } inline ::caffe::PriorBoxParameter* LayerParameter::release_prior_box_param() { + // @@protoc_insertion_point(field_release:caffe.LayerParameter.prior_box_param) clear_has_prior_box_param(); ::caffe::PriorBoxParameter* temp = prior_box_param_; prior_box_param_ = NULL; @@ -14541,6 +16004,7 @@ inline void LayerParameter::set_allocated_prior_box_param(::caffe::PriorBoxParam } else { clear_has_prior_box_param(); } + // @@protoc_insertion_point(field_set_allocated:caffe.LayerParameter.prior_box_param) } // optional .caffe.PythonParameter python_param = 130; @@ -14558,14 +16022,20 @@ inline void LayerParameter::clear_python_param() { clear_has_python_param(); } inline const ::caffe::PythonParameter& LayerParameter::python_param() const { - return python_param_ != NULL ? *python_param_ : *default_instance_->python_param_; + // @@protoc_insertion_point(field_get:caffe.LayerParameter.python_param) + return python_param_ != NULL ? *python_param_ + : *::caffe::PythonParameter::internal_default_instance(); } inline ::caffe::PythonParameter* LayerParameter::mutable_python_param() { set_has_python_param(); - if (python_param_ == NULL) python_param_ = new ::caffe::PythonParameter; + if (python_param_ == NULL) { + python_param_ = new ::caffe::PythonParameter; + } + // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.python_param) return python_param_; } inline ::caffe::PythonParameter* LayerParameter::release_python_param() { + // @@protoc_insertion_point(field_release:caffe.LayerParameter.python_param) clear_has_python_param(); ::caffe::PythonParameter* temp = python_param_; python_param_ = NULL; @@ -14579,6 +16049,7 @@ inline void LayerParameter::set_allocated_python_param(::caffe::PythonParameter* } else { clear_has_python_param(); } + // @@protoc_insertion_point(field_set_allocated:caffe.LayerParameter.python_param) } // optional .caffe.ReductionParameter reduction_param = 136; @@ -14596,14 +16067,20 @@ inline void LayerParameter::clear_reduction_param() { clear_has_reduction_param(); } inline const ::caffe::ReductionParameter& LayerParameter::reduction_param() const { - return reduction_param_ != NULL ? *reduction_param_ : *default_instance_->reduction_param_; + // @@protoc_insertion_point(field_get:caffe.LayerParameter.reduction_param) + return reduction_param_ != NULL ? *reduction_param_ + : *::caffe::ReductionParameter::internal_default_instance(); } inline ::caffe::ReductionParameter* LayerParameter::mutable_reduction_param() { set_has_reduction_param(); - if (reduction_param_ == NULL) reduction_param_ = new ::caffe::ReductionParameter; + if (reduction_param_ == NULL) { + reduction_param_ = new ::caffe::ReductionParameter; + } + // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.reduction_param) return reduction_param_; } inline ::caffe::ReductionParameter* LayerParameter::release_reduction_param() { + // @@protoc_insertion_point(field_release:caffe.LayerParameter.reduction_param) clear_has_reduction_param(); ::caffe::ReductionParameter* temp = reduction_param_; reduction_param_ = NULL; @@ -14617,6 +16094,7 @@ inline void LayerParameter::set_allocated_reduction_param(::caffe::ReductionPara } else { clear_has_reduction_param(); } + // @@protoc_insertion_point(field_set_allocated:caffe.LayerParameter.reduction_param) } // optional .caffe.ReLUParameter relu_param = 123; @@ -14634,14 +16112,20 @@ inline void LayerParameter::clear_relu_param() { clear_has_relu_param(); } inline const ::caffe::ReLUParameter& LayerParameter::relu_param() const { - return relu_param_ != NULL ? *relu_param_ : *default_instance_->relu_param_; + // @@protoc_insertion_point(field_get:caffe.LayerParameter.relu_param) + return relu_param_ != NULL ? *relu_param_ + : *::caffe::ReLUParameter::internal_default_instance(); } inline ::caffe::ReLUParameter* LayerParameter::mutable_relu_param() { set_has_relu_param(); - if (relu_param_ == NULL) relu_param_ = new ::caffe::ReLUParameter; + if (relu_param_ == NULL) { + relu_param_ = new ::caffe::ReLUParameter; + } + // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.relu_param) return relu_param_; } inline ::caffe::ReLUParameter* LayerParameter::release_relu_param() { + // @@protoc_insertion_point(field_release:caffe.LayerParameter.relu_param) clear_has_relu_param(); ::caffe::ReLUParameter* temp = relu_param_; relu_param_ = NULL; @@ -14655,6 +16139,7 @@ inline void LayerParameter::set_allocated_relu_param(::caffe::ReLUParameter* rel } else { clear_has_relu_param(); } + // @@protoc_insertion_point(field_set_allocated:caffe.LayerParameter.relu_param) } // optional .caffe.ReshapeParameter reshape_param = 133; @@ -14672,14 +16157,20 @@ inline void LayerParameter::clear_reshape_param() { clear_has_reshape_param(); } inline const ::caffe::ReshapeParameter& LayerParameter::reshape_param() const { - return reshape_param_ != NULL ? *reshape_param_ : *default_instance_->reshape_param_; + // @@protoc_insertion_point(field_get:caffe.LayerParameter.reshape_param) + return reshape_param_ != NULL ? *reshape_param_ + : *::caffe::ReshapeParameter::internal_default_instance(); } inline ::caffe::ReshapeParameter* LayerParameter::mutable_reshape_param() { set_has_reshape_param(); - if (reshape_param_ == NULL) reshape_param_ = new ::caffe::ReshapeParameter; + if (reshape_param_ == NULL) { + reshape_param_ = new ::caffe::ReshapeParameter; + } + // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.reshape_param) return reshape_param_; } inline ::caffe::ReshapeParameter* LayerParameter::release_reshape_param() { + // @@protoc_insertion_point(field_release:caffe.LayerParameter.reshape_param) clear_has_reshape_param(); ::caffe::ReshapeParameter* temp = reshape_param_; reshape_param_ = NULL; @@ -14693,6 +16184,7 @@ inline void LayerParameter::set_allocated_reshape_param(::caffe::ReshapeParamete } else { clear_has_reshape_param(); } + // @@protoc_insertion_point(field_set_allocated:caffe.LayerParameter.reshape_param) } // optional .caffe.SigmoidParameter sigmoid_param = 124; @@ -14710,14 +16202,20 @@ inline void LayerParameter::clear_sigmoid_param() { clear_has_sigmoid_param(); } inline const ::caffe::SigmoidParameter& LayerParameter::sigmoid_param() const { - return sigmoid_param_ != NULL ? *sigmoid_param_ : *default_instance_->sigmoid_param_; + // @@protoc_insertion_point(field_get:caffe.LayerParameter.sigmoid_param) + return sigmoid_param_ != NULL ? *sigmoid_param_ + : *::caffe::SigmoidParameter::internal_default_instance(); } inline ::caffe::SigmoidParameter* LayerParameter::mutable_sigmoid_param() { set_has_sigmoid_param(); - if (sigmoid_param_ == NULL) sigmoid_param_ = new ::caffe::SigmoidParameter; + if (sigmoid_param_ == NULL) { + sigmoid_param_ = new ::caffe::SigmoidParameter; + } + // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.sigmoid_param) return sigmoid_param_; } inline ::caffe::SigmoidParameter* LayerParameter::release_sigmoid_param() { + // @@protoc_insertion_point(field_release:caffe.LayerParameter.sigmoid_param) clear_has_sigmoid_param(); ::caffe::SigmoidParameter* temp = sigmoid_param_; sigmoid_param_ = NULL; @@ -14731,6 +16229,7 @@ inline void LayerParameter::set_allocated_sigmoid_param(::caffe::SigmoidParamete } else { clear_has_sigmoid_param(); } + // @@protoc_insertion_point(field_set_allocated:caffe.LayerParameter.sigmoid_param) } // optional .caffe.SliceParameter slice_param = 126; @@ -14748,14 +16247,20 @@ inline void LayerParameter::clear_slice_param() { clear_has_slice_param(); } inline const ::caffe::SliceParameter& LayerParameter::slice_param() const { - return slice_param_ != NULL ? *slice_param_ : *default_instance_->slice_param_; + // @@protoc_insertion_point(field_get:caffe.LayerParameter.slice_param) + return slice_param_ != NULL ? *slice_param_ + : *::caffe::SliceParameter::internal_default_instance(); } inline ::caffe::SliceParameter* LayerParameter::mutable_slice_param() { set_has_slice_param(); - if (slice_param_ == NULL) slice_param_ = new ::caffe::SliceParameter; + if (slice_param_ == NULL) { + slice_param_ = new ::caffe::SliceParameter; + } + // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.slice_param) return slice_param_; } inline ::caffe::SliceParameter* LayerParameter::release_slice_param() { + // @@protoc_insertion_point(field_release:caffe.LayerParameter.slice_param) clear_has_slice_param(); ::caffe::SliceParameter* temp = slice_param_; slice_param_ = NULL; @@ -14769,6 +16274,7 @@ inline void LayerParameter::set_allocated_slice_param(::caffe::SliceParameter* s } else { clear_has_slice_param(); } + // @@protoc_insertion_point(field_set_allocated:caffe.LayerParameter.slice_param) } // optional .caffe.SoftmaxParameter softmax_param = 125; @@ -14786,14 +16292,20 @@ inline void LayerParameter::clear_softmax_param() { clear_has_softmax_param(); } inline const ::caffe::SoftmaxParameter& LayerParameter::softmax_param() const { - return softmax_param_ != NULL ? *softmax_param_ : *default_instance_->softmax_param_; + // @@protoc_insertion_point(field_get:caffe.LayerParameter.softmax_param) + return softmax_param_ != NULL ? *softmax_param_ + : *::caffe::SoftmaxParameter::internal_default_instance(); } inline ::caffe::SoftmaxParameter* LayerParameter::mutable_softmax_param() { set_has_softmax_param(); - if (softmax_param_ == NULL) softmax_param_ = new ::caffe::SoftmaxParameter; + if (softmax_param_ == NULL) { + softmax_param_ = new ::caffe::SoftmaxParameter; + } + // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.softmax_param) return softmax_param_; } inline ::caffe::SoftmaxParameter* LayerParameter::release_softmax_param() { + // @@protoc_insertion_point(field_release:caffe.LayerParameter.softmax_param) clear_has_softmax_param(); ::caffe::SoftmaxParameter* temp = softmax_param_; softmax_param_ = NULL; @@ -14807,6 +16319,7 @@ inline void LayerParameter::set_allocated_softmax_param(::caffe::SoftmaxParamete } else { clear_has_softmax_param(); } + // @@protoc_insertion_point(field_set_allocated:caffe.LayerParameter.softmax_param) } // optional .caffe.SPPParameter spp_param = 132; @@ -14824,14 +16337,20 @@ inline void LayerParameter::clear_spp_param() { clear_has_spp_param(); } inline const ::caffe::SPPParameter& LayerParameter::spp_param() const { - return spp_param_ != NULL ? *spp_param_ : *default_instance_->spp_param_; + // @@protoc_insertion_point(field_get:caffe.LayerParameter.spp_param) + return spp_param_ != NULL ? *spp_param_ + : *::caffe::SPPParameter::internal_default_instance(); } inline ::caffe::SPPParameter* LayerParameter::mutable_spp_param() { set_has_spp_param(); - if (spp_param_ == NULL) spp_param_ = new ::caffe::SPPParameter; + if (spp_param_ == NULL) { + spp_param_ = new ::caffe::SPPParameter; + } + // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.spp_param) return spp_param_; } inline ::caffe::SPPParameter* LayerParameter::release_spp_param() { + // @@protoc_insertion_point(field_release:caffe.LayerParameter.spp_param) clear_has_spp_param(); ::caffe::SPPParameter* temp = spp_param_; spp_param_ = NULL; @@ -14845,6 +16364,7 @@ inline void LayerParameter::set_allocated_spp_param(::caffe::SPPParameter* spp_p } else { clear_has_spp_param(); } + // @@protoc_insertion_point(field_set_allocated:caffe.LayerParameter.spp_param) } // optional .caffe.TanHParameter tanh_param = 127; @@ -14862,14 +16382,20 @@ inline void LayerParameter::clear_tanh_param() { clear_has_tanh_param(); } inline const ::caffe::TanHParameter& LayerParameter::tanh_param() const { - return tanh_param_ != NULL ? *tanh_param_ : *default_instance_->tanh_param_; + // @@protoc_insertion_point(field_get:caffe.LayerParameter.tanh_param) + return tanh_param_ != NULL ? *tanh_param_ + : *::caffe::TanHParameter::internal_default_instance(); } inline ::caffe::TanHParameter* LayerParameter::mutable_tanh_param() { set_has_tanh_param(); - if (tanh_param_ == NULL) tanh_param_ = new ::caffe::TanHParameter; + if (tanh_param_ == NULL) { + tanh_param_ = new ::caffe::TanHParameter; + } + // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.tanh_param) return tanh_param_; } inline ::caffe::TanHParameter* LayerParameter::release_tanh_param() { + // @@protoc_insertion_point(field_release:caffe.LayerParameter.tanh_param) clear_has_tanh_param(); ::caffe::TanHParameter* temp = tanh_param_; tanh_param_ = NULL; @@ -14883,6 +16409,7 @@ inline void LayerParameter::set_allocated_tanh_param(::caffe::TanHParameter* tan } else { clear_has_tanh_param(); } + // @@protoc_insertion_point(field_set_allocated:caffe.LayerParameter.tanh_param) } // optional .caffe.ThresholdParameter threshold_param = 128; @@ -14900,14 +16427,20 @@ inline void LayerParameter::clear_threshold_param() { clear_has_threshold_param(); } inline const ::caffe::ThresholdParameter& LayerParameter::threshold_param() const { - return threshold_param_ != NULL ? *threshold_param_ : *default_instance_->threshold_param_; + // @@protoc_insertion_point(field_get:caffe.LayerParameter.threshold_param) + return threshold_param_ != NULL ? *threshold_param_ + : *::caffe::ThresholdParameter::internal_default_instance(); } inline ::caffe::ThresholdParameter* LayerParameter::mutable_threshold_param() { set_has_threshold_param(); - if (threshold_param_ == NULL) threshold_param_ = new ::caffe::ThresholdParameter; + if (threshold_param_ == NULL) { + threshold_param_ = new ::caffe::ThresholdParameter; + } + // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.threshold_param) return threshold_param_; } inline ::caffe::ThresholdParameter* LayerParameter::release_threshold_param() { + // @@protoc_insertion_point(field_release:caffe.LayerParameter.threshold_param) clear_has_threshold_param(); ::caffe::ThresholdParameter* temp = threshold_param_; threshold_param_ = NULL; @@ -14921,6 +16454,7 @@ inline void LayerParameter::set_allocated_threshold_param(::caffe::ThresholdPara } else { clear_has_threshold_param(); } + // @@protoc_insertion_point(field_set_allocated:caffe.LayerParameter.threshold_param) } // optional .caffe.WindowDataParameter window_data_param = 129; @@ -14938,14 +16472,20 @@ inline void LayerParameter::clear_window_data_param() { clear_has_window_data_param(); } inline const ::caffe::WindowDataParameter& LayerParameter::window_data_param() const { - return window_data_param_ != NULL ? *window_data_param_ : *default_instance_->window_data_param_; + // @@protoc_insertion_point(field_get:caffe.LayerParameter.window_data_param) + return window_data_param_ != NULL ? *window_data_param_ + : *::caffe::WindowDataParameter::internal_default_instance(); } inline ::caffe::WindowDataParameter* LayerParameter::mutable_window_data_param() { set_has_window_data_param(); - if (window_data_param_ == NULL) window_data_param_ = new ::caffe::WindowDataParameter; + if (window_data_param_ == NULL) { + window_data_param_ = new ::caffe::WindowDataParameter; + } + // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.window_data_param) return window_data_param_; } inline ::caffe::WindowDataParameter* LayerParameter::release_window_data_param() { + // @@protoc_insertion_point(field_release:caffe.LayerParameter.window_data_param) clear_has_window_data_param(); ::caffe::WindowDataParameter* temp = window_data_param_; window_data_param_ = NULL; @@ -14959,8 +16499,12 @@ inline void LayerParameter::set_allocated_window_data_param(::caffe::WindowDataP } else { clear_has_window_data_param(); } + // @@protoc_insertion_point(field_set_allocated:caffe.LayerParameter.window_data_param) } +inline const LayerParameter* LayerParameter::internal_default_instance() { + return &LayerParameter_default_instance_.get(); +} // ------------------------------------------------------------------- // TransformationParameter @@ -14980,11 +16524,13 @@ inline void TransformationParameter::clear_scale() { clear_has_scale(); } inline float TransformationParameter::scale() const { + // @@protoc_insertion_point(field_get:caffe.TransformationParameter.scale) return scale_; } inline void TransformationParameter::set_scale(float value) { set_has_scale(); scale_ = value; + // @@protoc_insertion_point(field_set:caffe.TransformationParameter.scale) } // optional bool mirror = 2 [default = false]; @@ -15002,11 +16548,13 @@ inline void TransformationParameter::clear_mirror() { clear_has_mirror(); } inline bool TransformationParameter::mirror() const { + // @@protoc_insertion_point(field_get:caffe.TransformationParameter.mirror) return mirror_; } inline void TransformationParameter::set_mirror(bool value) { set_has_mirror(); mirror_ = value; + // @@protoc_insertion_point(field_set:caffe.TransformationParameter.mirror) } // optional uint32 crop_size = 3 [default = 0]; @@ -15024,11 +16572,13 @@ inline void TransformationParameter::clear_crop_size() { clear_has_crop_size(); } inline ::google::protobuf::uint32 TransformationParameter::crop_size() const { + // @@protoc_insertion_point(field_get:caffe.TransformationParameter.crop_size) return crop_size_; } inline void TransformationParameter::set_crop_size(::google::protobuf::uint32 value) { set_has_crop_size(); crop_size_ = value; + // @@protoc_insertion_point(field_set:caffe.TransformationParameter.crop_size) } // optional string mean_file = 4; @@ -15042,63 +16592,47 @@ inline void TransformationParameter::clear_has_mean_file() { _has_bits_[0] &= ~0x00000008u; } inline void TransformationParameter::clear_mean_file() { - if (mean_file_ != &::google::protobuf::internal::kEmptyString) { - mean_file_->clear(); - } + mean_file_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); clear_has_mean_file(); } inline const ::std::string& TransformationParameter::mean_file() const { - return *mean_file_; + // @@protoc_insertion_point(field_get:caffe.TransformationParameter.mean_file) + return mean_file_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } inline void TransformationParameter::set_mean_file(const ::std::string& value) { set_has_mean_file(); - if (mean_file_ == &::google::protobuf::internal::kEmptyString) { - mean_file_ = new ::std::string; - } - mean_file_->assign(value); + mean_file_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); + // @@protoc_insertion_point(field_set:caffe.TransformationParameter.mean_file) } inline void TransformationParameter::set_mean_file(const char* value) { set_has_mean_file(); - if (mean_file_ == &::google::protobuf::internal::kEmptyString) { - mean_file_ = new ::std::string; - } - mean_file_->assign(value); + mean_file_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); + // @@protoc_insertion_point(field_set_char:caffe.TransformationParameter.mean_file) } inline void TransformationParameter::set_mean_file(const char* value, size_t size) { set_has_mean_file(); - if (mean_file_ == &::google::protobuf::internal::kEmptyString) { - mean_file_ = new ::std::string; - } - mean_file_->assign(reinterpret_cast(value), size); + mean_file_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), + ::std::string(reinterpret_cast(value), size)); + // @@protoc_insertion_point(field_set_pointer:caffe.TransformationParameter.mean_file) } inline ::std::string* TransformationParameter::mutable_mean_file() { set_has_mean_file(); - if (mean_file_ == &::google::protobuf::internal::kEmptyString) { - mean_file_ = new ::std::string; - } - return mean_file_; + // @@protoc_insertion_point(field_mutable:caffe.TransformationParameter.mean_file) + return mean_file_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } inline ::std::string* TransformationParameter::release_mean_file() { + // @@protoc_insertion_point(field_release:caffe.TransformationParameter.mean_file) clear_has_mean_file(); - if (mean_file_ == &::google::protobuf::internal::kEmptyString) { - return NULL; - } else { - ::std::string* temp = mean_file_; - mean_file_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); - return temp; - } + return mean_file_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } inline void TransformationParameter::set_allocated_mean_file(::std::string* mean_file) { - if (mean_file_ != &::google::protobuf::internal::kEmptyString) { - delete mean_file_; - } - if (mean_file) { + if (mean_file != NULL) { set_has_mean_file(); - mean_file_ = mean_file; } else { clear_has_mean_file(); - mean_file_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); } + mean_file_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), mean_file); + // @@protoc_insertion_point(field_set_allocated:caffe.TransformationParameter.mean_file) } // repeated float mean_value = 5; @@ -15109,20 +16643,25 @@ inline void TransformationParameter::clear_mean_value() { mean_value_.Clear(); } inline float TransformationParameter::mean_value(int index) const { + // @@protoc_insertion_point(field_get:caffe.TransformationParameter.mean_value) return mean_value_.Get(index); } inline void TransformationParameter::set_mean_value(int index, float value) { mean_value_.Set(index, value); + // @@protoc_insertion_point(field_set:caffe.TransformationParameter.mean_value) } inline void TransformationParameter::add_mean_value(float value) { mean_value_.Add(value); + // @@protoc_insertion_point(field_add:caffe.TransformationParameter.mean_value) } inline const ::google::protobuf::RepeatedField< float >& TransformationParameter::mean_value() const { + // @@protoc_insertion_point(field_list:caffe.TransformationParameter.mean_value) return mean_value_; } inline ::google::protobuf::RepeatedField< float >* TransformationParameter::mutable_mean_value() { + // @@protoc_insertion_point(field_mutable_list:caffe.TransformationParameter.mean_value) return &mean_value_; } @@ -15141,11 +16680,13 @@ inline void TransformationParameter::clear_force_color() { clear_has_force_color(); } inline bool TransformationParameter::force_color() const { + // @@protoc_insertion_point(field_get:caffe.TransformationParameter.force_color) return force_color_; } inline void TransformationParameter::set_force_color(bool value) { set_has_force_color(); force_color_ = value; + // @@protoc_insertion_point(field_set:caffe.TransformationParameter.force_color) } // optional bool force_gray = 7 [default = false]; @@ -15163,13 +16704,18 @@ inline void TransformationParameter::clear_force_gray() { clear_has_force_gray(); } inline bool TransformationParameter::force_gray() const { + // @@protoc_insertion_point(field_get:caffe.TransformationParameter.force_gray) return force_gray_; } inline void TransformationParameter::set_force_gray(bool value) { set_has_force_gray(); force_gray_ = value; + // @@protoc_insertion_point(field_set:caffe.TransformationParameter.force_gray) } +inline const TransformationParameter* TransformationParameter::internal_default_instance() { + return &TransformationParameter_default_instance_.get(); +} // ------------------------------------------------------------------- // LossParameter @@ -15189,11 +16735,13 @@ inline void LossParameter::clear_ignore_label() { clear_has_ignore_label(); } inline ::google::protobuf::int32 LossParameter::ignore_label() const { + // @@protoc_insertion_point(field_get:caffe.LossParameter.ignore_label) return ignore_label_; } inline void LossParameter::set_ignore_label(::google::protobuf::int32 value) { set_has_ignore_label(); ignore_label_ = value; + // @@protoc_insertion_point(field_set:caffe.LossParameter.ignore_label) } // optional bool normalize = 2 [default = true]; @@ -15211,13 +16759,18 @@ inline void LossParameter::clear_normalize() { clear_has_normalize(); } inline bool LossParameter::normalize() const { + // @@protoc_insertion_point(field_get:caffe.LossParameter.normalize) return normalize_; } inline void LossParameter::set_normalize(bool value) { set_has_normalize(); normalize_ = value; + // @@protoc_insertion_point(field_set:caffe.LossParameter.normalize) } +inline const LossParameter* LossParameter::internal_default_instance() { + return &LossParameter_default_instance_.get(); +} // ------------------------------------------------------------------- // AccuracyParameter @@ -15237,11 +16790,13 @@ inline void AccuracyParameter::clear_top_k() { clear_has_top_k(); } inline ::google::protobuf::uint32 AccuracyParameter::top_k() const { + // @@protoc_insertion_point(field_get:caffe.AccuracyParameter.top_k) return top_k_; } inline void AccuracyParameter::set_top_k(::google::protobuf::uint32 value) { set_has_top_k(); top_k_ = value; + // @@protoc_insertion_point(field_set:caffe.AccuracyParameter.top_k) } // optional int32 axis = 2 [default = 1]; @@ -15259,11 +16814,13 @@ inline void AccuracyParameter::clear_axis() { clear_has_axis(); } inline ::google::protobuf::int32 AccuracyParameter::axis() const { + // @@protoc_insertion_point(field_get:caffe.AccuracyParameter.axis) return axis_; } inline void AccuracyParameter::set_axis(::google::protobuf::int32 value) { set_has_axis(); axis_ = value; + // @@protoc_insertion_point(field_set:caffe.AccuracyParameter.axis) } // optional int32 ignore_label = 3; @@ -15281,13 +16838,18 @@ inline void AccuracyParameter::clear_ignore_label() { clear_has_ignore_label(); } inline ::google::protobuf::int32 AccuracyParameter::ignore_label() const { + // @@protoc_insertion_point(field_get:caffe.AccuracyParameter.ignore_label) return ignore_label_; } inline void AccuracyParameter::set_ignore_label(::google::protobuf::int32 value) { set_has_ignore_label(); ignore_label_ = value; + // @@protoc_insertion_point(field_set:caffe.AccuracyParameter.ignore_label) } +inline const AccuracyParameter* AccuracyParameter::internal_default_instance() { + return &AccuracyParameter_default_instance_.get(); +} // ------------------------------------------------------------------- // ArgMaxParameter @@ -15307,11 +16869,13 @@ inline void ArgMaxParameter::clear_out_max_val() { clear_has_out_max_val(); } inline bool ArgMaxParameter::out_max_val() const { + // @@protoc_insertion_point(field_get:caffe.ArgMaxParameter.out_max_val) return out_max_val_; } inline void ArgMaxParameter::set_out_max_val(bool value) { set_has_out_max_val(); out_max_val_ = value; + // @@protoc_insertion_point(field_set:caffe.ArgMaxParameter.out_max_val) } // optional uint32 top_k = 2 [default = 1]; @@ -15329,13 +16893,18 @@ inline void ArgMaxParameter::clear_top_k() { clear_has_top_k(); } inline ::google::protobuf::uint32 ArgMaxParameter::top_k() const { + // @@protoc_insertion_point(field_get:caffe.ArgMaxParameter.top_k) return top_k_; } inline void ArgMaxParameter::set_top_k(::google::protobuf::uint32 value) { set_has_top_k(); top_k_ = value; + // @@protoc_insertion_point(field_set:caffe.ArgMaxParameter.top_k) } +inline const ArgMaxParameter* ArgMaxParameter::internal_default_instance() { + return &ArgMaxParameter_default_instance_.get(); +} // ------------------------------------------------------------------- // ConcatParameter @@ -15355,11 +16924,13 @@ inline void ConcatParameter::clear_axis() { clear_has_axis(); } inline ::google::protobuf::int32 ConcatParameter::axis() const { + // @@protoc_insertion_point(field_get:caffe.ConcatParameter.axis) return axis_; } inline void ConcatParameter::set_axis(::google::protobuf::int32 value) { set_has_axis(); axis_ = value; + // @@protoc_insertion_point(field_set:caffe.ConcatParameter.axis) } // optional uint32 concat_dim = 1 [default = 1]; @@ -15377,13 +16948,18 @@ inline void ConcatParameter::clear_concat_dim() { clear_has_concat_dim(); } inline ::google::protobuf::uint32 ConcatParameter::concat_dim() const { + // @@protoc_insertion_point(field_get:caffe.ConcatParameter.concat_dim) return concat_dim_; } inline void ConcatParameter::set_concat_dim(::google::protobuf::uint32 value) { set_has_concat_dim(); concat_dim_ = value; + // @@protoc_insertion_point(field_set:caffe.ConcatParameter.concat_dim) } +inline const ConcatParameter* ConcatParameter::internal_default_instance() { + return &ConcatParameter_default_instance_.get(); +} // ------------------------------------------------------------------- // ContrastiveLossParameter @@ -15403,11 +16979,13 @@ inline void ContrastiveLossParameter::clear_margin() { clear_has_margin(); } inline float ContrastiveLossParameter::margin() const { + // @@protoc_insertion_point(field_get:caffe.ContrastiveLossParameter.margin) return margin_; } inline void ContrastiveLossParameter::set_margin(float value) { set_has_margin(); margin_ = value; + // @@protoc_insertion_point(field_set:caffe.ContrastiveLossParameter.margin) } // optional bool legacy_version = 2 [default = false]; @@ -15425,13 +17003,18 @@ inline void ContrastiveLossParameter::clear_legacy_version() { clear_has_legacy_version(); } inline bool ContrastiveLossParameter::legacy_version() const { + // @@protoc_insertion_point(field_get:caffe.ContrastiveLossParameter.legacy_version) return legacy_version_; } inline void ContrastiveLossParameter::set_legacy_version(bool value) { set_has_legacy_version(); legacy_version_ = value; + // @@protoc_insertion_point(field_set:caffe.ContrastiveLossParameter.legacy_version) } +inline const ContrastiveLossParameter* ContrastiveLossParameter::internal_default_instance() { + return &ContrastiveLossParameter_default_instance_.get(); +} // ------------------------------------------------------------------- // ConvolutionParameter @@ -15451,11 +17034,13 @@ inline void ConvolutionParameter::clear_num_output() { clear_has_num_output(); } inline ::google::protobuf::uint32 ConvolutionParameter::num_output() const { + // @@protoc_insertion_point(field_get:caffe.ConvolutionParameter.num_output) return num_output_; } inline void ConvolutionParameter::set_num_output(::google::protobuf::uint32 value) { set_has_num_output(); num_output_ = value; + // @@protoc_insertion_point(field_set:caffe.ConvolutionParameter.num_output) } // optional bool bias_term = 2 [default = true]; @@ -15473,11 +17058,13 @@ inline void ConvolutionParameter::clear_bias_term() { clear_has_bias_term(); } inline bool ConvolutionParameter::bias_term() const { + // @@protoc_insertion_point(field_get:caffe.ConvolutionParameter.bias_term) return bias_term_; } inline void ConvolutionParameter::set_bias_term(bool value) { set_has_bias_term(); bias_term_ = value; + // @@protoc_insertion_point(field_set:caffe.ConvolutionParameter.bias_term) } // optional uint32 pad = 3 [default = 0]; @@ -15495,11 +17082,13 @@ inline void ConvolutionParameter::clear_pad() { clear_has_pad(); } inline ::google::protobuf::uint32 ConvolutionParameter::pad() const { + // @@protoc_insertion_point(field_get:caffe.ConvolutionParameter.pad) return pad_; } inline void ConvolutionParameter::set_pad(::google::protobuf::uint32 value) { set_has_pad(); pad_ = value; + // @@protoc_insertion_point(field_set:caffe.ConvolutionParameter.pad) } // optional uint32 pad_h = 9 [default = 0]; @@ -15517,11 +17106,13 @@ inline void ConvolutionParameter::clear_pad_h() { clear_has_pad_h(); } inline ::google::protobuf::uint32 ConvolutionParameter::pad_h() const { + // @@protoc_insertion_point(field_get:caffe.ConvolutionParameter.pad_h) return pad_h_; } inline void ConvolutionParameter::set_pad_h(::google::protobuf::uint32 value) { set_has_pad_h(); pad_h_ = value; + // @@protoc_insertion_point(field_set:caffe.ConvolutionParameter.pad_h) } // optional uint32 pad_w = 10 [default = 0]; @@ -15539,11 +17130,13 @@ inline void ConvolutionParameter::clear_pad_w() { clear_has_pad_w(); } inline ::google::protobuf::uint32 ConvolutionParameter::pad_w() const { + // @@protoc_insertion_point(field_get:caffe.ConvolutionParameter.pad_w) return pad_w_; } inline void ConvolutionParameter::set_pad_w(::google::protobuf::uint32 value) { set_has_pad_w(); pad_w_ = value; + // @@protoc_insertion_point(field_set:caffe.ConvolutionParameter.pad_w) } // optional uint32 kernel_size = 4; @@ -15561,11 +17154,13 @@ inline void ConvolutionParameter::clear_kernel_size() { clear_has_kernel_size(); } inline ::google::protobuf::uint32 ConvolutionParameter::kernel_size() const { + // @@protoc_insertion_point(field_get:caffe.ConvolutionParameter.kernel_size) return kernel_size_; } inline void ConvolutionParameter::set_kernel_size(::google::protobuf::uint32 value) { set_has_kernel_size(); kernel_size_ = value; + // @@protoc_insertion_point(field_set:caffe.ConvolutionParameter.kernel_size) } // optional uint32 kernel_h = 11; @@ -15583,11 +17178,13 @@ inline void ConvolutionParameter::clear_kernel_h() { clear_has_kernel_h(); } inline ::google::protobuf::uint32 ConvolutionParameter::kernel_h() const { + // @@protoc_insertion_point(field_get:caffe.ConvolutionParameter.kernel_h) return kernel_h_; } inline void ConvolutionParameter::set_kernel_h(::google::protobuf::uint32 value) { set_has_kernel_h(); kernel_h_ = value; + // @@protoc_insertion_point(field_set:caffe.ConvolutionParameter.kernel_h) } // optional uint32 kernel_w = 12; @@ -15605,11 +17202,13 @@ inline void ConvolutionParameter::clear_kernel_w() { clear_has_kernel_w(); } inline ::google::protobuf::uint32 ConvolutionParameter::kernel_w() const { + // @@protoc_insertion_point(field_get:caffe.ConvolutionParameter.kernel_w) return kernel_w_; } inline void ConvolutionParameter::set_kernel_w(::google::protobuf::uint32 value) { set_has_kernel_w(); kernel_w_ = value; + // @@protoc_insertion_point(field_set:caffe.ConvolutionParameter.kernel_w) } // optional uint32 group = 5 [default = 1]; @@ -15627,11 +17226,13 @@ inline void ConvolutionParameter::clear_group() { clear_has_group(); } inline ::google::protobuf::uint32 ConvolutionParameter::group() const { + // @@protoc_insertion_point(field_get:caffe.ConvolutionParameter.group) return group_; } inline void ConvolutionParameter::set_group(::google::protobuf::uint32 value) { set_has_group(); group_ = value; + // @@protoc_insertion_point(field_set:caffe.ConvolutionParameter.group) } // optional uint32 stride = 6 [default = 1]; @@ -15649,11 +17250,13 @@ inline void ConvolutionParameter::clear_stride() { clear_has_stride(); } inline ::google::protobuf::uint32 ConvolutionParameter::stride() const { + // @@protoc_insertion_point(field_get:caffe.ConvolutionParameter.stride) return stride_; } inline void ConvolutionParameter::set_stride(::google::protobuf::uint32 value) { set_has_stride(); stride_ = value; + // @@protoc_insertion_point(field_set:caffe.ConvolutionParameter.stride) } // optional uint32 stride_h = 13; @@ -15671,11 +17274,13 @@ inline void ConvolutionParameter::clear_stride_h() { clear_has_stride_h(); } inline ::google::protobuf::uint32 ConvolutionParameter::stride_h() const { + // @@protoc_insertion_point(field_get:caffe.ConvolutionParameter.stride_h) return stride_h_; } inline void ConvolutionParameter::set_stride_h(::google::protobuf::uint32 value) { set_has_stride_h(); stride_h_ = value; + // @@protoc_insertion_point(field_set:caffe.ConvolutionParameter.stride_h) } // optional uint32 stride_w = 14; @@ -15693,11 +17298,13 @@ inline void ConvolutionParameter::clear_stride_w() { clear_has_stride_w(); } inline ::google::protobuf::uint32 ConvolutionParameter::stride_w() const { + // @@protoc_insertion_point(field_get:caffe.ConvolutionParameter.stride_w) return stride_w_; } inline void ConvolutionParameter::set_stride_w(::google::protobuf::uint32 value) { set_has_stride_w(); stride_w_ = value; + // @@protoc_insertion_point(field_set:caffe.ConvolutionParameter.stride_w) } // optional .caffe.FillerParameter weight_filler = 7; @@ -15715,14 +17322,20 @@ inline void ConvolutionParameter::clear_weight_filler() { clear_has_weight_filler(); } inline const ::caffe::FillerParameter& ConvolutionParameter::weight_filler() const { - return weight_filler_ != NULL ? *weight_filler_ : *default_instance_->weight_filler_; + // @@protoc_insertion_point(field_get:caffe.ConvolutionParameter.weight_filler) + return weight_filler_ != NULL ? *weight_filler_ + : *::caffe::FillerParameter::internal_default_instance(); } inline ::caffe::FillerParameter* ConvolutionParameter::mutable_weight_filler() { set_has_weight_filler(); - if (weight_filler_ == NULL) weight_filler_ = new ::caffe::FillerParameter; + if (weight_filler_ == NULL) { + weight_filler_ = new ::caffe::FillerParameter; + } + // @@protoc_insertion_point(field_mutable:caffe.ConvolutionParameter.weight_filler) return weight_filler_; } inline ::caffe::FillerParameter* ConvolutionParameter::release_weight_filler() { + // @@protoc_insertion_point(field_release:caffe.ConvolutionParameter.weight_filler) clear_has_weight_filler(); ::caffe::FillerParameter* temp = weight_filler_; weight_filler_ = NULL; @@ -15736,6 +17349,7 @@ inline void ConvolutionParameter::set_allocated_weight_filler(::caffe::FillerPar } else { clear_has_weight_filler(); } + // @@protoc_insertion_point(field_set_allocated:caffe.ConvolutionParameter.weight_filler) } // optional .caffe.FillerParameter bias_filler = 8; @@ -15753,14 +17367,20 @@ inline void ConvolutionParameter::clear_bias_filler() { clear_has_bias_filler(); } inline const ::caffe::FillerParameter& ConvolutionParameter::bias_filler() const { - return bias_filler_ != NULL ? *bias_filler_ : *default_instance_->bias_filler_; + // @@protoc_insertion_point(field_get:caffe.ConvolutionParameter.bias_filler) + return bias_filler_ != NULL ? *bias_filler_ + : *::caffe::FillerParameter::internal_default_instance(); } inline ::caffe::FillerParameter* ConvolutionParameter::mutable_bias_filler() { set_has_bias_filler(); - if (bias_filler_ == NULL) bias_filler_ = new ::caffe::FillerParameter; + if (bias_filler_ == NULL) { + bias_filler_ = new ::caffe::FillerParameter; + } + // @@protoc_insertion_point(field_mutable:caffe.ConvolutionParameter.bias_filler) return bias_filler_; } inline ::caffe::FillerParameter* ConvolutionParameter::release_bias_filler() { + // @@protoc_insertion_point(field_release:caffe.ConvolutionParameter.bias_filler) clear_has_bias_filler(); ::caffe::FillerParameter* temp = bias_filler_; bias_filler_ = NULL; @@ -15774,6 +17394,7 @@ inline void ConvolutionParameter::set_allocated_bias_filler(::caffe::FillerParam } else { clear_has_bias_filler(); } + // @@protoc_insertion_point(field_set_allocated:caffe.ConvolutionParameter.bias_filler) } // optional .caffe.ConvolutionParameter.Engine engine = 15 [default = DEFAULT]; @@ -15791,12 +17412,14 @@ inline void ConvolutionParameter::clear_engine() { clear_has_engine(); } inline ::caffe::ConvolutionParameter_Engine ConvolutionParameter::engine() const { + // @@protoc_insertion_point(field_get:caffe.ConvolutionParameter.engine) return static_cast< ::caffe::ConvolutionParameter_Engine >(engine_); } inline void ConvolutionParameter::set_engine(::caffe::ConvolutionParameter_Engine value) { assert(::caffe::ConvolutionParameter_Engine_IsValid(value)); set_has_engine(); engine_ = value; + // @@protoc_insertion_point(field_set:caffe.ConvolutionParameter.engine) } // optional uint32 dilation_h = 18; @@ -15814,11 +17437,13 @@ inline void ConvolutionParameter::clear_dilation_h() { clear_has_dilation_h(); } inline ::google::protobuf::uint32 ConvolutionParameter::dilation_h() const { + // @@protoc_insertion_point(field_get:caffe.ConvolutionParameter.dilation_h) return dilation_h_; } inline void ConvolutionParameter::set_dilation_h(::google::protobuf::uint32 value) { set_has_dilation_h(); dilation_h_ = value; + // @@protoc_insertion_point(field_set:caffe.ConvolutionParameter.dilation_h) } // optional uint32 dilation_w = 19; @@ -15836,11 +17461,13 @@ inline void ConvolutionParameter::clear_dilation_w() { clear_has_dilation_w(); } inline ::google::protobuf::uint32 ConvolutionParameter::dilation_w() const { + // @@protoc_insertion_point(field_get:caffe.ConvolutionParameter.dilation_w) return dilation_w_; } inline void ConvolutionParameter::set_dilation_w(::google::protobuf::uint32 value) { set_has_dilation_w(); dilation_w_ = value; + // @@protoc_insertion_point(field_set:caffe.ConvolutionParameter.dilation_w) } // optional uint32 dilation = 20; @@ -15858,13 +17485,18 @@ inline void ConvolutionParameter::clear_dilation() { clear_has_dilation(); } inline ::google::protobuf::uint32 ConvolutionParameter::dilation() const { + // @@protoc_insertion_point(field_get:caffe.ConvolutionParameter.dilation) return dilation_; } inline void ConvolutionParameter::set_dilation(::google::protobuf::uint32 value) { set_has_dilation(); dilation_ = value; + // @@protoc_insertion_point(field_set:caffe.ConvolutionParameter.dilation) } +inline const ConvolutionParameter* ConvolutionParameter::internal_default_instance() { + return &ConvolutionParameter_default_instance_.get(); +} // ------------------------------------------------------------------- // DataParameter @@ -15880,63 +17512,47 @@ inline void DataParameter::clear_has_source() { _has_bits_[0] &= ~0x00000001u; } inline void DataParameter::clear_source() { - if (source_ != &::google::protobuf::internal::kEmptyString) { - source_->clear(); - } + source_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); clear_has_source(); } inline const ::std::string& DataParameter::source() const { - return *source_; + // @@protoc_insertion_point(field_get:caffe.DataParameter.source) + return source_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } inline void DataParameter::set_source(const ::std::string& value) { set_has_source(); - if (source_ == &::google::protobuf::internal::kEmptyString) { - source_ = new ::std::string; - } - source_->assign(value); + source_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); + // @@protoc_insertion_point(field_set:caffe.DataParameter.source) } inline void DataParameter::set_source(const char* value) { set_has_source(); - if (source_ == &::google::protobuf::internal::kEmptyString) { - source_ = new ::std::string; - } - source_->assign(value); + source_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); + // @@protoc_insertion_point(field_set_char:caffe.DataParameter.source) } inline void DataParameter::set_source(const char* value, size_t size) { set_has_source(); - if (source_ == &::google::protobuf::internal::kEmptyString) { - source_ = new ::std::string; - } - source_->assign(reinterpret_cast(value), size); + source_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), + ::std::string(reinterpret_cast(value), size)); + // @@protoc_insertion_point(field_set_pointer:caffe.DataParameter.source) } inline ::std::string* DataParameter::mutable_source() { set_has_source(); - if (source_ == &::google::protobuf::internal::kEmptyString) { - source_ = new ::std::string; - } - return source_; + // @@protoc_insertion_point(field_mutable:caffe.DataParameter.source) + return source_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } inline ::std::string* DataParameter::release_source() { + // @@protoc_insertion_point(field_release:caffe.DataParameter.source) clear_has_source(); - if (source_ == &::google::protobuf::internal::kEmptyString) { - return NULL; - } else { - ::std::string* temp = source_; - source_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); - return temp; - } + return source_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } inline void DataParameter::set_allocated_source(::std::string* source) { - if (source_ != &::google::protobuf::internal::kEmptyString) { - delete source_; - } - if (source) { + if (source != NULL) { set_has_source(); - source_ = source; } else { clear_has_source(); - source_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); } + source_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), source); + // @@protoc_insertion_point(field_set_allocated:caffe.DataParameter.source) } // optional uint32 batch_size = 4; @@ -15954,11 +17570,13 @@ inline void DataParameter::clear_batch_size() { clear_has_batch_size(); } inline ::google::protobuf::uint32 DataParameter::batch_size() const { + // @@protoc_insertion_point(field_get:caffe.DataParameter.batch_size) return batch_size_; } inline void DataParameter::set_batch_size(::google::protobuf::uint32 value) { set_has_batch_size(); batch_size_ = value; + // @@protoc_insertion_point(field_set:caffe.DataParameter.batch_size) } // optional uint32 rand_skip = 7 [default = 0]; @@ -15976,11 +17594,13 @@ inline void DataParameter::clear_rand_skip() { clear_has_rand_skip(); } inline ::google::protobuf::uint32 DataParameter::rand_skip() const { + // @@protoc_insertion_point(field_get:caffe.DataParameter.rand_skip) return rand_skip_; } inline void DataParameter::set_rand_skip(::google::protobuf::uint32 value) { set_has_rand_skip(); rand_skip_ = value; + // @@protoc_insertion_point(field_set:caffe.DataParameter.rand_skip) } // optional .caffe.DataParameter.DB backend = 8 [default = LEVELDB]; @@ -15998,12 +17618,14 @@ inline void DataParameter::clear_backend() { clear_has_backend(); } inline ::caffe::DataParameter_DB DataParameter::backend() const { + // @@protoc_insertion_point(field_get:caffe.DataParameter.backend) return static_cast< ::caffe::DataParameter_DB >(backend_); } inline void DataParameter::set_backend(::caffe::DataParameter_DB value) { assert(::caffe::DataParameter_DB_IsValid(value)); set_has_backend(); backend_ = value; + // @@protoc_insertion_point(field_set:caffe.DataParameter.backend) } // optional float scale = 2 [default = 1]; @@ -16021,11 +17643,13 @@ inline void DataParameter::clear_scale() { clear_has_scale(); } inline float DataParameter::scale() const { + // @@protoc_insertion_point(field_get:caffe.DataParameter.scale) return scale_; } inline void DataParameter::set_scale(float value) { set_has_scale(); scale_ = value; + // @@protoc_insertion_point(field_set:caffe.DataParameter.scale) } // optional string mean_file = 3; @@ -16039,63 +17663,47 @@ inline void DataParameter::clear_has_mean_file() { _has_bits_[0] &= ~0x00000020u; } inline void DataParameter::clear_mean_file() { - if (mean_file_ != &::google::protobuf::internal::kEmptyString) { - mean_file_->clear(); - } + mean_file_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); clear_has_mean_file(); } inline const ::std::string& DataParameter::mean_file() const { - return *mean_file_; + // @@protoc_insertion_point(field_get:caffe.DataParameter.mean_file) + return mean_file_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } inline void DataParameter::set_mean_file(const ::std::string& value) { set_has_mean_file(); - if (mean_file_ == &::google::protobuf::internal::kEmptyString) { - mean_file_ = new ::std::string; - } - mean_file_->assign(value); + mean_file_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); + // @@protoc_insertion_point(field_set:caffe.DataParameter.mean_file) } inline void DataParameter::set_mean_file(const char* value) { set_has_mean_file(); - if (mean_file_ == &::google::protobuf::internal::kEmptyString) { - mean_file_ = new ::std::string; - } - mean_file_->assign(value); + mean_file_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); + // @@protoc_insertion_point(field_set_char:caffe.DataParameter.mean_file) } inline void DataParameter::set_mean_file(const char* value, size_t size) { set_has_mean_file(); - if (mean_file_ == &::google::protobuf::internal::kEmptyString) { - mean_file_ = new ::std::string; - } - mean_file_->assign(reinterpret_cast(value), size); + mean_file_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), + ::std::string(reinterpret_cast(value), size)); + // @@protoc_insertion_point(field_set_pointer:caffe.DataParameter.mean_file) } inline ::std::string* DataParameter::mutable_mean_file() { set_has_mean_file(); - if (mean_file_ == &::google::protobuf::internal::kEmptyString) { - mean_file_ = new ::std::string; - } - return mean_file_; + // @@protoc_insertion_point(field_mutable:caffe.DataParameter.mean_file) + return mean_file_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } inline ::std::string* DataParameter::release_mean_file() { + // @@protoc_insertion_point(field_release:caffe.DataParameter.mean_file) clear_has_mean_file(); - if (mean_file_ == &::google::protobuf::internal::kEmptyString) { - return NULL; - } else { - ::std::string* temp = mean_file_; - mean_file_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); - return temp; - } + return mean_file_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } inline void DataParameter::set_allocated_mean_file(::std::string* mean_file) { - if (mean_file_ != &::google::protobuf::internal::kEmptyString) { - delete mean_file_; - } - if (mean_file) { + if (mean_file != NULL) { set_has_mean_file(); - mean_file_ = mean_file; } else { clear_has_mean_file(); - mean_file_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); } + mean_file_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), mean_file); + // @@protoc_insertion_point(field_set_allocated:caffe.DataParameter.mean_file) } // optional uint32 crop_size = 5 [default = 0]; @@ -16113,11 +17721,13 @@ inline void DataParameter::clear_crop_size() { clear_has_crop_size(); } inline ::google::protobuf::uint32 DataParameter::crop_size() const { + // @@protoc_insertion_point(field_get:caffe.DataParameter.crop_size) return crop_size_; } inline void DataParameter::set_crop_size(::google::protobuf::uint32 value) { set_has_crop_size(); crop_size_ = value; + // @@protoc_insertion_point(field_set:caffe.DataParameter.crop_size) } // optional bool mirror = 6 [default = false]; @@ -16135,11 +17745,13 @@ inline void DataParameter::clear_mirror() { clear_has_mirror(); } inline bool DataParameter::mirror() const { + // @@protoc_insertion_point(field_get:caffe.DataParameter.mirror) return mirror_; } inline void DataParameter::set_mirror(bool value) { set_has_mirror(); mirror_ = value; + // @@protoc_insertion_point(field_set:caffe.DataParameter.mirror) } // optional bool force_encoded_color = 9 [default = false]; @@ -16157,13 +17769,18 @@ inline void DataParameter::clear_force_encoded_color() { clear_has_force_encoded_color(); } inline bool DataParameter::force_encoded_color() const { + // @@protoc_insertion_point(field_get:caffe.DataParameter.force_encoded_color) return force_encoded_color_; } inline void DataParameter::set_force_encoded_color(bool value) { set_has_force_encoded_color(); force_encoded_color_ = value; + // @@protoc_insertion_point(field_set:caffe.DataParameter.force_encoded_color) } +inline const DataParameter* DataParameter::internal_default_instance() { + return &DataParameter_default_instance_.get(); +} // ------------------------------------------------------------------- // DropoutParameter @@ -16183,13 +17800,18 @@ inline void DropoutParameter::clear_dropout_ratio() { clear_has_dropout_ratio(); } inline float DropoutParameter::dropout_ratio() const { + // @@protoc_insertion_point(field_get:caffe.DropoutParameter.dropout_ratio) return dropout_ratio_; } inline void DropoutParameter::set_dropout_ratio(float value) { set_has_dropout_ratio(); dropout_ratio_ = value; + // @@protoc_insertion_point(field_set:caffe.DropoutParameter.dropout_ratio) } +inline const DropoutParameter* DropoutParameter::internal_default_instance() { + return &DropoutParameter_default_instance_.get(); +} // ------------------------------------------------------------------- // DummyDataParameter @@ -16202,22 +17824,27 @@ inline void DummyDataParameter::clear_data_filler() { data_filler_.Clear(); } inline const ::caffe::FillerParameter& DummyDataParameter::data_filler(int index) const { + // @@protoc_insertion_point(field_get:caffe.DummyDataParameter.data_filler) return data_filler_.Get(index); } inline ::caffe::FillerParameter* DummyDataParameter::mutable_data_filler(int index) { + // @@protoc_insertion_point(field_mutable:caffe.DummyDataParameter.data_filler) return data_filler_.Mutable(index); } inline ::caffe::FillerParameter* DummyDataParameter::add_data_filler() { + // @@protoc_insertion_point(field_add:caffe.DummyDataParameter.data_filler) return data_filler_.Add(); } -inline const ::google::protobuf::RepeatedPtrField< ::caffe::FillerParameter >& -DummyDataParameter::data_filler() const { - return data_filler_; -} inline ::google::protobuf::RepeatedPtrField< ::caffe::FillerParameter >* DummyDataParameter::mutable_data_filler() { + // @@protoc_insertion_point(field_mutable_list:caffe.DummyDataParameter.data_filler) return &data_filler_; } +inline const ::google::protobuf::RepeatedPtrField< ::caffe::FillerParameter >& +DummyDataParameter::data_filler() const { + // @@protoc_insertion_point(field_list:caffe.DummyDataParameter.data_filler) + return data_filler_; +} // repeated .caffe.BlobShape shape = 6; inline int DummyDataParameter::shape_size() const { @@ -16227,22 +17854,27 @@ inline void DummyDataParameter::clear_shape() { shape_.Clear(); } inline const ::caffe::BlobShape& DummyDataParameter::shape(int index) const { + // @@protoc_insertion_point(field_get:caffe.DummyDataParameter.shape) return shape_.Get(index); } inline ::caffe::BlobShape* DummyDataParameter::mutable_shape(int index) { + // @@protoc_insertion_point(field_mutable:caffe.DummyDataParameter.shape) return shape_.Mutable(index); } inline ::caffe::BlobShape* DummyDataParameter::add_shape() { + // @@protoc_insertion_point(field_add:caffe.DummyDataParameter.shape) return shape_.Add(); } -inline const ::google::protobuf::RepeatedPtrField< ::caffe::BlobShape >& -DummyDataParameter::shape() const { - return shape_; -} inline ::google::protobuf::RepeatedPtrField< ::caffe::BlobShape >* DummyDataParameter::mutable_shape() { + // @@protoc_insertion_point(field_mutable_list:caffe.DummyDataParameter.shape) return &shape_; } +inline const ::google::protobuf::RepeatedPtrField< ::caffe::BlobShape >& +DummyDataParameter::shape() const { + // @@protoc_insertion_point(field_list:caffe.DummyDataParameter.shape) + return shape_; +} // repeated uint32 num = 2; inline int DummyDataParameter::num_size() const { @@ -16252,20 +17884,25 @@ inline void DummyDataParameter::clear_num() { num_.Clear(); } inline ::google::protobuf::uint32 DummyDataParameter::num(int index) const { + // @@protoc_insertion_point(field_get:caffe.DummyDataParameter.num) return num_.Get(index); } inline void DummyDataParameter::set_num(int index, ::google::protobuf::uint32 value) { num_.Set(index, value); + // @@protoc_insertion_point(field_set:caffe.DummyDataParameter.num) } inline void DummyDataParameter::add_num(::google::protobuf::uint32 value) { num_.Add(value); + // @@protoc_insertion_point(field_add:caffe.DummyDataParameter.num) } inline const ::google::protobuf::RepeatedField< ::google::protobuf::uint32 >& DummyDataParameter::num() const { + // @@protoc_insertion_point(field_list:caffe.DummyDataParameter.num) return num_; } inline ::google::protobuf::RepeatedField< ::google::protobuf::uint32 >* DummyDataParameter::mutable_num() { + // @@protoc_insertion_point(field_mutable_list:caffe.DummyDataParameter.num) return &num_; } @@ -16277,20 +17914,25 @@ inline void DummyDataParameter::clear_channels() { channels_.Clear(); } inline ::google::protobuf::uint32 DummyDataParameter::channels(int index) const { + // @@protoc_insertion_point(field_get:caffe.DummyDataParameter.channels) return channels_.Get(index); } inline void DummyDataParameter::set_channels(int index, ::google::protobuf::uint32 value) { channels_.Set(index, value); + // @@protoc_insertion_point(field_set:caffe.DummyDataParameter.channels) } inline void DummyDataParameter::add_channels(::google::protobuf::uint32 value) { channels_.Add(value); + // @@protoc_insertion_point(field_add:caffe.DummyDataParameter.channels) } inline const ::google::protobuf::RepeatedField< ::google::protobuf::uint32 >& DummyDataParameter::channels() const { + // @@protoc_insertion_point(field_list:caffe.DummyDataParameter.channels) return channels_; } inline ::google::protobuf::RepeatedField< ::google::protobuf::uint32 >* DummyDataParameter::mutable_channels() { + // @@protoc_insertion_point(field_mutable_list:caffe.DummyDataParameter.channels) return &channels_; } @@ -16302,20 +17944,25 @@ inline void DummyDataParameter::clear_height() { height_.Clear(); } inline ::google::protobuf::uint32 DummyDataParameter::height(int index) const { + // @@protoc_insertion_point(field_get:caffe.DummyDataParameter.height) return height_.Get(index); } inline void DummyDataParameter::set_height(int index, ::google::protobuf::uint32 value) { height_.Set(index, value); + // @@protoc_insertion_point(field_set:caffe.DummyDataParameter.height) } inline void DummyDataParameter::add_height(::google::protobuf::uint32 value) { height_.Add(value); + // @@protoc_insertion_point(field_add:caffe.DummyDataParameter.height) } inline const ::google::protobuf::RepeatedField< ::google::protobuf::uint32 >& DummyDataParameter::height() const { + // @@protoc_insertion_point(field_list:caffe.DummyDataParameter.height) return height_; } inline ::google::protobuf::RepeatedField< ::google::protobuf::uint32 >* DummyDataParameter::mutable_height() { + // @@protoc_insertion_point(field_mutable_list:caffe.DummyDataParameter.height) return &height_; } @@ -16327,23 +17974,31 @@ inline void DummyDataParameter::clear_width() { width_.Clear(); } inline ::google::protobuf::uint32 DummyDataParameter::width(int index) const { + // @@protoc_insertion_point(field_get:caffe.DummyDataParameter.width) return width_.Get(index); } inline void DummyDataParameter::set_width(int index, ::google::protobuf::uint32 value) { width_.Set(index, value); + // @@protoc_insertion_point(field_set:caffe.DummyDataParameter.width) } inline void DummyDataParameter::add_width(::google::protobuf::uint32 value) { width_.Add(value); + // @@protoc_insertion_point(field_add:caffe.DummyDataParameter.width) } inline const ::google::protobuf::RepeatedField< ::google::protobuf::uint32 >& DummyDataParameter::width() const { + // @@protoc_insertion_point(field_list:caffe.DummyDataParameter.width) return width_; } inline ::google::protobuf::RepeatedField< ::google::protobuf::uint32 >* DummyDataParameter::mutable_width() { + // @@protoc_insertion_point(field_mutable_list:caffe.DummyDataParameter.width) return &width_; } +inline const DummyDataParameter* DummyDataParameter::internal_default_instance() { + return &DummyDataParameter_default_instance_.get(); +} // ------------------------------------------------------------------- // EltwiseParameter @@ -16363,12 +18018,14 @@ inline void EltwiseParameter::clear_operation() { clear_has_operation(); } inline ::caffe::EltwiseParameter_EltwiseOp EltwiseParameter::operation() const { + // @@protoc_insertion_point(field_get:caffe.EltwiseParameter.operation) return static_cast< ::caffe::EltwiseParameter_EltwiseOp >(operation_); } inline void EltwiseParameter::set_operation(::caffe::EltwiseParameter_EltwiseOp value) { assert(::caffe::EltwiseParameter_EltwiseOp_IsValid(value)); set_has_operation(); operation_ = value; + // @@protoc_insertion_point(field_set:caffe.EltwiseParameter.operation) } // repeated float coeff = 2; @@ -16379,20 +18036,25 @@ inline void EltwiseParameter::clear_coeff() { coeff_.Clear(); } inline float EltwiseParameter::coeff(int index) const { + // @@protoc_insertion_point(field_get:caffe.EltwiseParameter.coeff) return coeff_.Get(index); } inline void EltwiseParameter::set_coeff(int index, float value) { coeff_.Set(index, value); + // @@protoc_insertion_point(field_set:caffe.EltwiseParameter.coeff) } inline void EltwiseParameter::add_coeff(float value) { coeff_.Add(value); + // @@protoc_insertion_point(field_add:caffe.EltwiseParameter.coeff) } inline const ::google::protobuf::RepeatedField< float >& EltwiseParameter::coeff() const { + // @@protoc_insertion_point(field_list:caffe.EltwiseParameter.coeff) return coeff_; } inline ::google::protobuf::RepeatedField< float >* EltwiseParameter::mutable_coeff() { + // @@protoc_insertion_point(field_mutable_list:caffe.EltwiseParameter.coeff) return &coeff_; } @@ -16411,13 +18073,18 @@ inline void EltwiseParameter::clear_stable_prod_grad() { clear_has_stable_prod_grad(); } inline bool EltwiseParameter::stable_prod_grad() const { + // @@protoc_insertion_point(field_get:caffe.EltwiseParameter.stable_prod_grad) return stable_prod_grad_; } inline void EltwiseParameter::set_stable_prod_grad(bool value) { set_has_stable_prod_grad(); stable_prod_grad_ = value; + // @@protoc_insertion_point(field_set:caffe.EltwiseParameter.stable_prod_grad) } +inline const EltwiseParameter* EltwiseParameter::internal_default_instance() { + return &EltwiseParameter_default_instance_.get(); +} // ------------------------------------------------------------------- // ExpParameter @@ -16437,11 +18104,13 @@ inline void ExpParameter::clear_base() { clear_has_base(); } inline float ExpParameter::base() const { + // @@protoc_insertion_point(field_get:caffe.ExpParameter.base) return base_; } inline void ExpParameter::set_base(float value) { set_has_base(); base_ = value; + // @@protoc_insertion_point(field_set:caffe.ExpParameter.base) } // optional float scale = 2 [default = 1]; @@ -16459,11 +18128,13 @@ inline void ExpParameter::clear_scale() { clear_has_scale(); } inline float ExpParameter::scale() const { + // @@protoc_insertion_point(field_get:caffe.ExpParameter.scale) return scale_; } inline void ExpParameter::set_scale(float value) { set_has_scale(); scale_ = value; + // @@protoc_insertion_point(field_set:caffe.ExpParameter.scale) } // optional float shift = 3 [default = 0]; @@ -16481,13 +18152,18 @@ inline void ExpParameter::clear_shift() { clear_has_shift(); } inline float ExpParameter::shift() const { + // @@protoc_insertion_point(field_get:caffe.ExpParameter.shift) return shift_; } inline void ExpParameter::set_shift(float value) { set_has_shift(); shift_ = value; + // @@protoc_insertion_point(field_set:caffe.ExpParameter.shift) } +inline const ExpParameter* ExpParameter::internal_default_instance() { + return &ExpParameter_default_instance_.get(); +} // ------------------------------------------------------------------- // FlattenParameter @@ -16507,11 +18183,13 @@ inline void FlattenParameter::clear_axis() { clear_has_axis(); } inline ::google::protobuf::int32 FlattenParameter::axis() const { + // @@protoc_insertion_point(field_get:caffe.FlattenParameter.axis) return axis_; } inline void FlattenParameter::set_axis(::google::protobuf::int32 value) { set_has_axis(); axis_ = value; + // @@protoc_insertion_point(field_set:caffe.FlattenParameter.axis) } // optional int32 end_axis = 2 [default = -1]; @@ -16529,13 +18207,18 @@ inline void FlattenParameter::clear_end_axis() { clear_has_end_axis(); } inline ::google::protobuf::int32 FlattenParameter::end_axis() const { + // @@protoc_insertion_point(field_get:caffe.FlattenParameter.end_axis) return end_axis_; } inline void FlattenParameter::set_end_axis(::google::protobuf::int32 value) { set_has_end_axis(); end_axis_ = value; + // @@protoc_insertion_point(field_set:caffe.FlattenParameter.end_axis) } +inline const FlattenParameter* FlattenParameter::internal_default_instance() { + return &FlattenParameter_default_instance_.get(); +} // ------------------------------------------------------------------- // HDF5DataParameter @@ -16551,63 +18234,47 @@ inline void HDF5DataParameter::clear_has_source() { _has_bits_[0] &= ~0x00000001u; } inline void HDF5DataParameter::clear_source() { - if (source_ != &::google::protobuf::internal::kEmptyString) { - source_->clear(); - } + source_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); clear_has_source(); } inline const ::std::string& HDF5DataParameter::source() const { - return *source_; + // @@protoc_insertion_point(field_get:caffe.HDF5DataParameter.source) + return source_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } inline void HDF5DataParameter::set_source(const ::std::string& value) { set_has_source(); - if (source_ == &::google::protobuf::internal::kEmptyString) { - source_ = new ::std::string; - } - source_->assign(value); + source_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); + // @@protoc_insertion_point(field_set:caffe.HDF5DataParameter.source) } inline void HDF5DataParameter::set_source(const char* value) { set_has_source(); - if (source_ == &::google::protobuf::internal::kEmptyString) { - source_ = new ::std::string; - } - source_->assign(value); + source_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); + // @@protoc_insertion_point(field_set_char:caffe.HDF5DataParameter.source) } inline void HDF5DataParameter::set_source(const char* value, size_t size) { set_has_source(); - if (source_ == &::google::protobuf::internal::kEmptyString) { - source_ = new ::std::string; - } - source_->assign(reinterpret_cast(value), size); + source_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), + ::std::string(reinterpret_cast(value), size)); + // @@protoc_insertion_point(field_set_pointer:caffe.HDF5DataParameter.source) } inline ::std::string* HDF5DataParameter::mutable_source() { set_has_source(); - if (source_ == &::google::protobuf::internal::kEmptyString) { - source_ = new ::std::string; - } - return source_; + // @@protoc_insertion_point(field_mutable:caffe.HDF5DataParameter.source) + return source_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } inline ::std::string* HDF5DataParameter::release_source() { + // @@protoc_insertion_point(field_release:caffe.HDF5DataParameter.source) clear_has_source(); - if (source_ == &::google::protobuf::internal::kEmptyString) { - return NULL; - } else { - ::std::string* temp = source_; - source_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); - return temp; - } + return source_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } inline void HDF5DataParameter::set_allocated_source(::std::string* source) { - if (source_ != &::google::protobuf::internal::kEmptyString) { - delete source_; - } - if (source) { + if (source != NULL) { set_has_source(); - source_ = source; } else { clear_has_source(); - source_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); } + source_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), source); + // @@protoc_insertion_point(field_set_allocated:caffe.HDF5DataParameter.source) } // optional uint32 batch_size = 2; @@ -16625,11 +18292,13 @@ inline void HDF5DataParameter::clear_batch_size() { clear_has_batch_size(); } inline ::google::protobuf::uint32 HDF5DataParameter::batch_size() const { + // @@protoc_insertion_point(field_get:caffe.HDF5DataParameter.batch_size) return batch_size_; } inline void HDF5DataParameter::set_batch_size(::google::protobuf::uint32 value) { set_has_batch_size(); batch_size_ = value; + // @@protoc_insertion_point(field_set:caffe.HDF5DataParameter.batch_size) } // optional bool shuffle = 3 [default = false]; @@ -16647,13 +18316,18 @@ inline void HDF5DataParameter::clear_shuffle() { clear_has_shuffle(); } inline bool HDF5DataParameter::shuffle() const { + // @@protoc_insertion_point(field_get:caffe.HDF5DataParameter.shuffle) return shuffle_; } inline void HDF5DataParameter::set_shuffle(bool value) { set_has_shuffle(); shuffle_ = value; + // @@protoc_insertion_point(field_set:caffe.HDF5DataParameter.shuffle) } +inline const HDF5DataParameter* HDF5DataParameter::internal_default_instance() { + return &HDF5DataParameter_default_instance_.get(); +} // ------------------------------------------------------------------- // HDF5OutputParameter @@ -16669,65 +18343,52 @@ inline void HDF5OutputParameter::clear_has_file_name() { _has_bits_[0] &= ~0x00000001u; } inline void HDF5OutputParameter::clear_file_name() { - if (file_name_ != &::google::protobuf::internal::kEmptyString) { - file_name_->clear(); - } + file_name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); clear_has_file_name(); } inline const ::std::string& HDF5OutputParameter::file_name() const { - return *file_name_; + // @@protoc_insertion_point(field_get:caffe.HDF5OutputParameter.file_name) + return file_name_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } inline void HDF5OutputParameter::set_file_name(const ::std::string& value) { set_has_file_name(); - if (file_name_ == &::google::protobuf::internal::kEmptyString) { - file_name_ = new ::std::string; - } - file_name_->assign(value); + file_name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); + // @@protoc_insertion_point(field_set:caffe.HDF5OutputParameter.file_name) } inline void HDF5OutputParameter::set_file_name(const char* value) { set_has_file_name(); - if (file_name_ == &::google::protobuf::internal::kEmptyString) { - file_name_ = new ::std::string; - } - file_name_->assign(value); + file_name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); + // @@protoc_insertion_point(field_set_char:caffe.HDF5OutputParameter.file_name) } inline void HDF5OutputParameter::set_file_name(const char* value, size_t size) { set_has_file_name(); - if (file_name_ == &::google::protobuf::internal::kEmptyString) { - file_name_ = new ::std::string; - } - file_name_->assign(reinterpret_cast(value), size); + file_name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), + ::std::string(reinterpret_cast(value), size)); + // @@protoc_insertion_point(field_set_pointer:caffe.HDF5OutputParameter.file_name) } inline ::std::string* HDF5OutputParameter::mutable_file_name() { set_has_file_name(); - if (file_name_ == &::google::protobuf::internal::kEmptyString) { - file_name_ = new ::std::string; - } - return file_name_; + // @@protoc_insertion_point(field_mutable:caffe.HDF5OutputParameter.file_name) + return file_name_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } inline ::std::string* HDF5OutputParameter::release_file_name() { + // @@protoc_insertion_point(field_release:caffe.HDF5OutputParameter.file_name) clear_has_file_name(); - if (file_name_ == &::google::protobuf::internal::kEmptyString) { - return NULL; - } else { - ::std::string* temp = file_name_; - file_name_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); - return temp; - } + return file_name_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } inline void HDF5OutputParameter::set_allocated_file_name(::std::string* file_name) { - if (file_name_ != &::google::protobuf::internal::kEmptyString) { - delete file_name_; - } - if (file_name) { + if (file_name != NULL) { set_has_file_name(); - file_name_ = file_name; } else { clear_has_file_name(); - file_name_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); } + file_name_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), file_name); + // @@protoc_insertion_point(field_set_allocated:caffe.HDF5OutputParameter.file_name) } +inline const HDF5OutputParameter* HDF5OutputParameter::internal_default_instance() { + return &HDF5OutputParameter_default_instance_.get(); +} // ------------------------------------------------------------------- // HingeLossParameter @@ -16747,14 +18408,19 @@ inline void HingeLossParameter::clear_norm() { clear_has_norm(); } inline ::caffe::HingeLossParameter_Norm HingeLossParameter::norm() const { + // @@protoc_insertion_point(field_get:caffe.HingeLossParameter.norm) return static_cast< ::caffe::HingeLossParameter_Norm >(norm_); } inline void HingeLossParameter::set_norm(::caffe::HingeLossParameter_Norm value) { assert(::caffe::HingeLossParameter_Norm_IsValid(value)); set_has_norm(); norm_ = value; + // @@protoc_insertion_point(field_set:caffe.HingeLossParameter.norm) } +inline const HingeLossParameter* HingeLossParameter::internal_default_instance() { + return &HingeLossParameter_default_instance_.get(); +} // ------------------------------------------------------------------- // ImageDataParameter @@ -16770,63 +18436,47 @@ inline void ImageDataParameter::clear_has_source() { _has_bits_[0] &= ~0x00000001u; } inline void ImageDataParameter::clear_source() { - if (source_ != &::google::protobuf::internal::kEmptyString) { - source_->clear(); - } + source_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); clear_has_source(); } inline const ::std::string& ImageDataParameter::source() const { - return *source_; + // @@protoc_insertion_point(field_get:caffe.ImageDataParameter.source) + return source_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } inline void ImageDataParameter::set_source(const ::std::string& value) { set_has_source(); - if (source_ == &::google::protobuf::internal::kEmptyString) { - source_ = new ::std::string; - } - source_->assign(value); + source_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); + // @@protoc_insertion_point(field_set:caffe.ImageDataParameter.source) } inline void ImageDataParameter::set_source(const char* value) { set_has_source(); - if (source_ == &::google::protobuf::internal::kEmptyString) { - source_ = new ::std::string; - } - source_->assign(value); + source_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); + // @@protoc_insertion_point(field_set_char:caffe.ImageDataParameter.source) } inline void ImageDataParameter::set_source(const char* value, size_t size) { set_has_source(); - if (source_ == &::google::protobuf::internal::kEmptyString) { - source_ = new ::std::string; - } - source_->assign(reinterpret_cast(value), size); + source_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), + ::std::string(reinterpret_cast(value), size)); + // @@protoc_insertion_point(field_set_pointer:caffe.ImageDataParameter.source) } inline ::std::string* ImageDataParameter::mutable_source() { set_has_source(); - if (source_ == &::google::protobuf::internal::kEmptyString) { - source_ = new ::std::string; - } - return source_; + // @@protoc_insertion_point(field_mutable:caffe.ImageDataParameter.source) + return source_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } inline ::std::string* ImageDataParameter::release_source() { + // @@protoc_insertion_point(field_release:caffe.ImageDataParameter.source) clear_has_source(); - if (source_ == &::google::protobuf::internal::kEmptyString) { - return NULL; - } else { - ::std::string* temp = source_; - source_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); - return temp; - } + return source_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } inline void ImageDataParameter::set_allocated_source(::std::string* source) { - if (source_ != &::google::protobuf::internal::kEmptyString) { - delete source_; - } - if (source) { + if (source != NULL) { set_has_source(); - source_ = source; } else { clear_has_source(); - source_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); } + source_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), source); + // @@protoc_insertion_point(field_set_allocated:caffe.ImageDataParameter.source) } // optional uint32 batch_size = 4; @@ -16844,11 +18494,13 @@ inline void ImageDataParameter::clear_batch_size() { clear_has_batch_size(); } inline ::google::protobuf::uint32 ImageDataParameter::batch_size() const { + // @@protoc_insertion_point(field_get:caffe.ImageDataParameter.batch_size) return batch_size_; } inline void ImageDataParameter::set_batch_size(::google::protobuf::uint32 value) { set_has_batch_size(); batch_size_ = value; + // @@protoc_insertion_point(field_set:caffe.ImageDataParameter.batch_size) } // optional uint32 rand_skip = 7 [default = 0]; @@ -16866,11 +18518,13 @@ inline void ImageDataParameter::clear_rand_skip() { clear_has_rand_skip(); } inline ::google::protobuf::uint32 ImageDataParameter::rand_skip() const { + // @@protoc_insertion_point(field_get:caffe.ImageDataParameter.rand_skip) return rand_skip_; } inline void ImageDataParameter::set_rand_skip(::google::protobuf::uint32 value) { set_has_rand_skip(); rand_skip_ = value; + // @@protoc_insertion_point(field_set:caffe.ImageDataParameter.rand_skip) } // optional bool shuffle = 8 [default = false]; @@ -16888,11 +18542,13 @@ inline void ImageDataParameter::clear_shuffle() { clear_has_shuffle(); } inline bool ImageDataParameter::shuffle() const { + // @@protoc_insertion_point(field_get:caffe.ImageDataParameter.shuffle) return shuffle_; } inline void ImageDataParameter::set_shuffle(bool value) { set_has_shuffle(); shuffle_ = value; + // @@protoc_insertion_point(field_set:caffe.ImageDataParameter.shuffle) } // optional uint32 new_height = 9 [default = 0]; @@ -16910,11 +18566,13 @@ inline void ImageDataParameter::clear_new_height() { clear_has_new_height(); } inline ::google::protobuf::uint32 ImageDataParameter::new_height() const { + // @@protoc_insertion_point(field_get:caffe.ImageDataParameter.new_height) return new_height_; } inline void ImageDataParameter::set_new_height(::google::protobuf::uint32 value) { set_has_new_height(); new_height_ = value; + // @@protoc_insertion_point(field_set:caffe.ImageDataParameter.new_height) } // optional uint32 new_width = 10 [default = 0]; @@ -16932,11 +18590,13 @@ inline void ImageDataParameter::clear_new_width() { clear_has_new_width(); } inline ::google::protobuf::uint32 ImageDataParameter::new_width() const { + // @@protoc_insertion_point(field_get:caffe.ImageDataParameter.new_width) return new_width_; } inline void ImageDataParameter::set_new_width(::google::protobuf::uint32 value) { set_has_new_width(); new_width_ = value; + // @@protoc_insertion_point(field_set:caffe.ImageDataParameter.new_width) } // optional bool is_color = 11 [default = true]; @@ -16954,11 +18614,13 @@ inline void ImageDataParameter::clear_is_color() { clear_has_is_color(); } inline bool ImageDataParameter::is_color() const { + // @@protoc_insertion_point(field_get:caffe.ImageDataParameter.is_color) return is_color_; } inline void ImageDataParameter::set_is_color(bool value) { set_has_is_color(); is_color_ = value; + // @@protoc_insertion_point(field_set:caffe.ImageDataParameter.is_color) } // optional float scale = 2 [default = 1]; @@ -16976,11 +18638,13 @@ inline void ImageDataParameter::clear_scale() { clear_has_scale(); } inline float ImageDataParameter::scale() const { + // @@protoc_insertion_point(field_get:caffe.ImageDataParameter.scale) return scale_; } inline void ImageDataParameter::set_scale(float value) { set_has_scale(); scale_ = value; + // @@protoc_insertion_point(field_set:caffe.ImageDataParameter.scale) } // optional string mean_file = 3; @@ -16994,63 +18658,47 @@ inline void ImageDataParameter::clear_has_mean_file() { _has_bits_[0] &= ~0x00000100u; } inline void ImageDataParameter::clear_mean_file() { - if (mean_file_ != &::google::protobuf::internal::kEmptyString) { - mean_file_->clear(); - } + mean_file_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); clear_has_mean_file(); } inline const ::std::string& ImageDataParameter::mean_file() const { - return *mean_file_; + // @@protoc_insertion_point(field_get:caffe.ImageDataParameter.mean_file) + return mean_file_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } inline void ImageDataParameter::set_mean_file(const ::std::string& value) { set_has_mean_file(); - if (mean_file_ == &::google::protobuf::internal::kEmptyString) { - mean_file_ = new ::std::string; - } - mean_file_->assign(value); + mean_file_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); + // @@protoc_insertion_point(field_set:caffe.ImageDataParameter.mean_file) } inline void ImageDataParameter::set_mean_file(const char* value) { set_has_mean_file(); - if (mean_file_ == &::google::protobuf::internal::kEmptyString) { - mean_file_ = new ::std::string; - } - mean_file_->assign(value); + mean_file_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); + // @@protoc_insertion_point(field_set_char:caffe.ImageDataParameter.mean_file) } inline void ImageDataParameter::set_mean_file(const char* value, size_t size) { set_has_mean_file(); - if (mean_file_ == &::google::protobuf::internal::kEmptyString) { - mean_file_ = new ::std::string; - } - mean_file_->assign(reinterpret_cast(value), size); + mean_file_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), + ::std::string(reinterpret_cast(value), size)); + // @@protoc_insertion_point(field_set_pointer:caffe.ImageDataParameter.mean_file) } inline ::std::string* ImageDataParameter::mutable_mean_file() { set_has_mean_file(); - if (mean_file_ == &::google::protobuf::internal::kEmptyString) { - mean_file_ = new ::std::string; - } - return mean_file_; + // @@protoc_insertion_point(field_mutable:caffe.ImageDataParameter.mean_file) + return mean_file_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } inline ::std::string* ImageDataParameter::release_mean_file() { + // @@protoc_insertion_point(field_release:caffe.ImageDataParameter.mean_file) clear_has_mean_file(); - if (mean_file_ == &::google::protobuf::internal::kEmptyString) { - return NULL; - } else { - ::std::string* temp = mean_file_; - mean_file_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); - return temp; - } + return mean_file_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } inline void ImageDataParameter::set_allocated_mean_file(::std::string* mean_file) { - if (mean_file_ != &::google::protobuf::internal::kEmptyString) { - delete mean_file_; - } - if (mean_file) { + if (mean_file != NULL) { set_has_mean_file(); - mean_file_ = mean_file; } else { clear_has_mean_file(); - mean_file_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); } + mean_file_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), mean_file); + // @@protoc_insertion_point(field_set_allocated:caffe.ImageDataParameter.mean_file) } // optional uint32 crop_size = 5 [default = 0]; @@ -17068,11 +18716,13 @@ inline void ImageDataParameter::clear_crop_size() { clear_has_crop_size(); } inline ::google::protobuf::uint32 ImageDataParameter::crop_size() const { + // @@protoc_insertion_point(field_get:caffe.ImageDataParameter.crop_size) return crop_size_; } inline void ImageDataParameter::set_crop_size(::google::protobuf::uint32 value) { set_has_crop_size(); crop_size_ = value; + // @@protoc_insertion_point(field_set:caffe.ImageDataParameter.crop_size) } // optional bool mirror = 6 [default = false]; @@ -17090,11 +18740,13 @@ inline void ImageDataParameter::clear_mirror() { clear_has_mirror(); } inline bool ImageDataParameter::mirror() const { + // @@protoc_insertion_point(field_get:caffe.ImageDataParameter.mirror) return mirror_; } inline void ImageDataParameter::set_mirror(bool value) { set_has_mirror(); mirror_ = value; + // @@protoc_insertion_point(field_set:caffe.ImageDataParameter.mirror) } // optional string root_folder = 12 [default = ""]; @@ -17108,65 +18760,52 @@ inline void ImageDataParameter::clear_has_root_folder() { _has_bits_[0] &= ~0x00000800u; } inline void ImageDataParameter::clear_root_folder() { - if (root_folder_ != &::google::protobuf::internal::kEmptyString) { - root_folder_->clear(); - } + root_folder_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); clear_has_root_folder(); } inline const ::std::string& ImageDataParameter::root_folder() const { - return *root_folder_; + // @@protoc_insertion_point(field_get:caffe.ImageDataParameter.root_folder) + return root_folder_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } inline void ImageDataParameter::set_root_folder(const ::std::string& value) { set_has_root_folder(); - if (root_folder_ == &::google::protobuf::internal::kEmptyString) { - root_folder_ = new ::std::string; - } - root_folder_->assign(value); + root_folder_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); + // @@protoc_insertion_point(field_set:caffe.ImageDataParameter.root_folder) } inline void ImageDataParameter::set_root_folder(const char* value) { set_has_root_folder(); - if (root_folder_ == &::google::protobuf::internal::kEmptyString) { - root_folder_ = new ::std::string; - } - root_folder_->assign(value); + root_folder_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); + // @@protoc_insertion_point(field_set_char:caffe.ImageDataParameter.root_folder) } inline void ImageDataParameter::set_root_folder(const char* value, size_t size) { set_has_root_folder(); - if (root_folder_ == &::google::protobuf::internal::kEmptyString) { - root_folder_ = new ::std::string; - } - root_folder_->assign(reinterpret_cast(value), size); + root_folder_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), + ::std::string(reinterpret_cast(value), size)); + // @@protoc_insertion_point(field_set_pointer:caffe.ImageDataParameter.root_folder) } inline ::std::string* ImageDataParameter::mutable_root_folder() { set_has_root_folder(); - if (root_folder_ == &::google::protobuf::internal::kEmptyString) { - root_folder_ = new ::std::string; - } - return root_folder_; + // @@protoc_insertion_point(field_mutable:caffe.ImageDataParameter.root_folder) + return root_folder_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } inline ::std::string* ImageDataParameter::release_root_folder() { + // @@protoc_insertion_point(field_release:caffe.ImageDataParameter.root_folder) clear_has_root_folder(); - if (root_folder_ == &::google::protobuf::internal::kEmptyString) { - return NULL; - } else { - ::std::string* temp = root_folder_; - root_folder_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); - return temp; - } + return root_folder_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } inline void ImageDataParameter::set_allocated_root_folder(::std::string* root_folder) { - if (root_folder_ != &::google::protobuf::internal::kEmptyString) { - delete root_folder_; - } - if (root_folder) { + if (root_folder != NULL) { set_has_root_folder(); - root_folder_ = root_folder; } else { clear_has_root_folder(); - root_folder_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); } + root_folder_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), root_folder); + // @@protoc_insertion_point(field_set_allocated:caffe.ImageDataParameter.root_folder) } +inline const ImageDataParameter* ImageDataParameter::internal_default_instance() { + return &ImageDataParameter_default_instance_.get(); +} // ------------------------------------------------------------------- // InfogainLossParameter @@ -17182,65 +18821,52 @@ inline void InfogainLossParameter::clear_has_source() { _has_bits_[0] &= ~0x00000001u; } inline void InfogainLossParameter::clear_source() { - if (source_ != &::google::protobuf::internal::kEmptyString) { - source_->clear(); - } + source_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); clear_has_source(); } inline const ::std::string& InfogainLossParameter::source() const { - return *source_; + // @@protoc_insertion_point(field_get:caffe.InfogainLossParameter.source) + return source_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } inline void InfogainLossParameter::set_source(const ::std::string& value) { set_has_source(); - if (source_ == &::google::protobuf::internal::kEmptyString) { - source_ = new ::std::string; - } - source_->assign(value); + source_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); + // @@protoc_insertion_point(field_set:caffe.InfogainLossParameter.source) } inline void InfogainLossParameter::set_source(const char* value) { set_has_source(); - if (source_ == &::google::protobuf::internal::kEmptyString) { - source_ = new ::std::string; - } - source_->assign(value); + source_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); + // @@protoc_insertion_point(field_set_char:caffe.InfogainLossParameter.source) } inline void InfogainLossParameter::set_source(const char* value, size_t size) { set_has_source(); - if (source_ == &::google::protobuf::internal::kEmptyString) { - source_ = new ::std::string; - } - source_->assign(reinterpret_cast(value), size); + source_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), + ::std::string(reinterpret_cast(value), size)); + // @@protoc_insertion_point(field_set_pointer:caffe.InfogainLossParameter.source) } inline ::std::string* InfogainLossParameter::mutable_source() { set_has_source(); - if (source_ == &::google::protobuf::internal::kEmptyString) { - source_ = new ::std::string; - } - return source_; + // @@protoc_insertion_point(field_mutable:caffe.InfogainLossParameter.source) + return source_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } inline ::std::string* InfogainLossParameter::release_source() { + // @@protoc_insertion_point(field_release:caffe.InfogainLossParameter.source) clear_has_source(); - if (source_ == &::google::protobuf::internal::kEmptyString) { - return NULL; - } else { - ::std::string* temp = source_; - source_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); - return temp; - } + return source_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } inline void InfogainLossParameter::set_allocated_source(::std::string* source) { - if (source_ != &::google::protobuf::internal::kEmptyString) { - delete source_; - } - if (source) { + if (source != NULL) { set_has_source(); - source_ = source; } else { clear_has_source(); - source_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); } + source_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), source); + // @@protoc_insertion_point(field_set_allocated:caffe.InfogainLossParameter.source) } +inline const InfogainLossParameter* InfogainLossParameter::internal_default_instance() { + return &InfogainLossParameter_default_instance_.get(); +} // ------------------------------------------------------------------- // InnerProductParameter @@ -17260,11 +18886,13 @@ inline void InnerProductParameter::clear_num_output() { clear_has_num_output(); } inline ::google::protobuf::uint32 InnerProductParameter::num_output() const { + // @@protoc_insertion_point(field_get:caffe.InnerProductParameter.num_output) return num_output_; } inline void InnerProductParameter::set_num_output(::google::protobuf::uint32 value) { set_has_num_output(); num_output_ = value; + // @@protoc_insertion_point(field_set:caffe.InnerProductParameter.num_output) } // optional bool bias_term = 2 [default = true]; @@ -17282,11 +18910,13 @@ inline void InnerProductParameter::clear_bias_term() { clear_has_bias_term(); } inline bool InnerProductParameter::bias_term() const { + // @@protoc_insertion_point(field_get:caffe.InnerProductParameter.bias_term) return bias_term_; } inline void InnerProductParameter::set_bias_term(bool value) { set_has_bias_term(); bias_term_ = value; + // @@protoc_insertion_point(field_set:caffe.InnerProductParameter.bias_term) } // optional .caffe.FillerParameter weight_filler = 3; @@ -17304,14 +18934,20 @@ inline void InnerProductParameter::clear_weight_filler() { clear_has_weight_filler(); } inline const ::caffe::FillerParameter& InnerProductParameter::weight_filler() const { - return weight_filler_ != NULL ? *weight_filler_ : *default_instance_->weight_filler_; + // @@protoc_insertion_point(field_get:caffe.InnerProductParameter.weight_filler) + return weight_filler_ != NULL ? *weight_filler_ + : *::caffe::FillerParameter::internal_default_instance(); } inline ::caffe::FillerParameter* InnerProductParameter::mutable_weight_filler() { set_has_weight_filler(); - if (weight_filler_ == NULL) weight_filler_ = new ::caffe::FillerParameter; + if (weight_filler_ == NULL) { + weight_filler_ = new ::caffe::FillerParameter; + } + // @@protoc_insertion_point(field_mutable:caffe.InnerProductParameter.weight_filler) return weight_filler_; } inline ::caffe::FillerParameter* InnerProductParameter::release_weight_filler() { + // @@protoc_insertion_point(field_release:caffe.InnerProductParameter.weight_filler) clear_has_weight_filler(); ::caffe::FillerParameter* temp = weight_filler_; weight_filler_ = NULL; @@ -17325,6 +18961,7 @@ inline void InnerProductParameter::set_allocated_weight_filler(::caffe::FillerPa } else { clear_has_weight_filler(); } + // @@protoc_insertion_point(field_set_allocated:caffe.InnerProductParameter.weight_filler) } // optional .caffe.FillerParameter bias_filler = 4; @@ -17342,14 +18979,20 @@ inline void InnerProductParameter::clear_bias_filler() { clear_has_bias_filler(); } inline const ::caffe::FillerParameter& InnerProductParameter::bias_filler() const { - return bias_filler_ != NULL ? *bias_filler_ : *default_instance_->bias_filler_; + // @@protoc_insertion_point(field_get:caffe.InnerProductParameter.bias_filler) + return bias_filler_ != NULL ? *bias_filler_ + : *::caffe::FillerParameter::internal_default_instance(); } inline ::caffe::FillerParameter* InnerProductParameter::mutable_bias_filler() { set_has_bias_filler(); - if (bias_filler_ == NULL) bias_filler_ = new ::caffe::FillerParameter; + if (bias_filler_ == NULL) { + bias_filler_ = new ::caffe::FillerParameter; + } + // @@protoc_insertion_point(field_mutable:caffe.InnerProductParameter.bias_filler) return bias_filler_; } inline ::caffe::FillerParameter* InnerProductParameter::release_bias_filler() { + // @@protoc_insertion_point(field_release:caffe.InnerProductParameter.bias_filler) clear_has_bias_filler(); ::caffe::FillerParameter* temp = bias_filler_; bias_filler_ = NULL; @@ -17363,6 +19006,7 @@ inline void InnerProductParameter::set_allocated_bias_filler(::caffe::FillerPara } else { clear_has_bias_filler(); } + // @@protoc_insertion_point(field_set_allocated:caffe.InnerProductParameter.bias_filler) } // optional int32 axis = 5 [default = 1]; @@ -17380,13 +19024,18 @@ inline void InnerProductParameter::clear_axis() { clear_has_axis(); } inline ::google::protobuf::int32 InnerProductParameter::axis() const { + // @@protoc_insertion_point(field_get:caffe.InnerProductParameter.axis) return axis_; } inline void InnerProductParameter::set_axis(::google::protobuf::int32 value) { set_has_axis(); axis_ = value; + // @@protoc_insertion_point(field_set:caffe.InnerProductParameter.axis) } +inline const InnerProductParameter* InnerProductParameter::internal_default_instance() { + return &InnerProductParameter_default_instance_.get(); +} // ------------------------------------------------------------------- // LogParameter @@ -17406,11 +19055,13 @@ inline void LogParameter::clear_base() { clear_has_base(); } inline float LogParameter::base() const { + // @@protoc_insertion_point(field_get:caffe.LogParameter.base) return base_; } inline void LogParameter::set_base(float value) { set_has_base(); base_ = value; + // @@protoc_insertion_point(field_set:caffe.LogParameter.base) } // optional float scale = 2 [default = 1]; @@ -17428,11 +19079,13 @@ inline void LogParameter::clear_scale() { clear_has_scale(); } inline float LogParameter::scale() const { + // @@protoc_insertion_point(field_get:caffe.LogParameter.scale) return scale_; } inline void LogParameter::set_scale(float value) { set_has_scale(); scale_ = value; + // @@protoc_insertion_point(field_set:caffe.LogParameter.scale) } // optional float shift = 3 [default = 0]; @@ -17450,13 +19103,18 @@ inline void LogParameter::clear_shift() { clear_has_shift(); } inline float LogParameter::shift() const { + // @@protoc_insertion_point(field_get:caffe.LogParameter.shift) return shift_; } inline void LogParameter::set_shift(float value) { set_has_shift(); shift_ = value; + // @@protoc_insertion_point(field_set:caffe.LogParameter.shift) } +inline const LogParameter* LogParameter::internal_default_instance() { + return &LogParameter_default_instance_.get(); +} // ------------------------------------------------------------------- // LRNParameter @@ -17476,11 +19134,13 @@ inline void LRNParameter::clear_local_size() { clear_has_local_size(); } inline ::google::protobuf::uint32 LRNParameter::local_size() const { + // @@protoc_insertion_point(field_get:caffe.LRNParameter.local_size) return local_size_; } inline void LRNParameter::set_local_size(::google::protobuf::uint32 value) { set_has_local_size(); local_size_ = value; + // @@protoc_insertion_point(field_set:caffe.LRNParameter.local_size) } // optional float alpha = 2 [default = 1]; @@ -17498,11 +19158,13 @@ inline void LRNParameter::clear_alpha() { clear_has_alpha(); } inline float LRNParameter::alpha() const { + // @@protoc_insertion_point(field_get:caffe.LRNParameter.alpha) return alpha_; } inline void LRNParameter::set_alpha(float value) { set_has_alpha(); alpha_ = value; + // @@protoc_insertion_point(field_set:caffe.LRNParameter.alpha) } // optional float beta = 3 [default = 0.75]; @@ -17520,11 +19182,13 @@ inline void LRNParameter::clear_beta() { clear_has_beta(); } inline float LRNParameter::beta() const { + // @@protoc_insertion_point(field_get:caffe.LRNParameter.beta) return beta_; } inline void LRNParameter::set_beta(float value) { set_has_beta(); beta_ = value; + // @@protoc_insertion_point(field_set:caffe.LRNParameter.beta) } // optional .caffe.LRNParameter.NormRegion norm_region = 4 [default = ACROSS_CHANNELS]; @@ -17542,12 +19206,14 @@ inline void LRNParameter::clear_norm_region() { clear_has_norm_region(); } inline ::caffe::LRNParameter_NormRegion LRNParameter::norm_region() const { + // @@protoc_insertion_point(field_get:caffe.LRNParameter.norm_region) return static_cast< ::caffe::LRNParameter_NormRegion >(norm_region_); } inline void LRNParameter::set_norm_region(::caffe::LRNParameter_NormRegion value) { assert(::caffe::LRNParameter_NormRegion_IsValid(value)); set_has_norm_region(); norm_region_ = value; + // @@protoc_insertion_point(field_set:caffe.LRNParameter.norm_region) } // optional float k = 5 [default = 1]; @@ -17565,13 +19231,18 @@ inline void LRNParameter::clear_k() { clear_has_k(); } inline float LRNParameter::k() const { + // @@protoc_insertion_point(field_get:caffe.LRNParameter.k) return k_; } inline void LRNParameter::set_k(float value) { set_has_k(); k_ = value; + // @@protoc_insertion_point(field_set:caffe.LRNParameter.k) } +inline const LRNParameter* LRNParameter::internal_default_instance() { + return &LRNParameter_default_instance_.get(); +} // ------------------------------------------------------------------- // MemoryDataParameter @@ -17591,11 +19262,13 @@ inline void MemoryDataParameter::clear_batch_size() { clear_has_batch_size(); } inline ::google::protobuf::uint32 MemoryDataParameter::batch_size() const { + // @@protoc_insertion_point(field_get:caffe.MemoryDataParameter.batch_size) return batch_size_; } inline void MemoryDataParameter::set_batch_size(::google::protobuf::uint32 value) { set_has_batch_size(); batch_size_ = value; + // @@protoc_insertion_point(field_set:caffe.MemoryDataParameter.batch_size) } // optional uint32 channels = 2; @@ -17613,11 +19286,13 @@ inline void MemoryDataParameter::clear_channels() { clear_has_channels(); } inline ::google::protobuf::uint32 MemoryDataParameter::channels() const { + // @@protoc_insertion_point(field_get:caffe.MemoryDataParameter.channels) return channels_; } inline void MemoryDataParameter::set_channels(::google::protobuf::uint32 value) { set_has_channels(); channels_ = value; + // @@protoc_insertion_point(field_set:caffe.MemoryDataParameter.channels) } // optional uint32 height = 3; @@ -17635,11 +19310,13 @@ inline void MemoryDataParameter::clear_height() { clear_has_height(); } inline ::google::protobuf::uint32 MemoryDataParameter::height() const { + // @@protoc_insertion_point(field_get:caffe.MemoryDataParameter.height) return height_; } inline void MemoryDataParameter::set_height(::google::protobuf::uint32 value) { set_has_height(); height_ = value; + // @@protoc_insertion_point(field_set:caffe.MemoryDataParameter.height) } // optional uint32 width = 4; @@ -17657,13 +19334,18 @@ inline void MemoryDataParameter::clear_width() { clear_has_width(); } inline ::google::protobuf::uint32 MemoryDataParameter::width() const { + // @@protoc_insertion_point(field_get:caffe.MemoryDataParameter.width) return width_; } inline void MemoryDataParameter::set_width(::google::protobuf::uint32 value) { set_has_width(); width_ = value; + // @@protoc_insertion_point(field_set:caffe.MemoryDataParameter.width) } +inline const MemoryDataParameter* MemoryDataParameter::internal_default_instance() { + return &MemoryDataParameter_default_instance_.get(); +} // ------------------------------------------------------------------- // MVNParameter @@ -17683,11 +19365,13 @@ inline void MVNParameter::clear_normalize_variance() { clear_has_normalize_variance(); } inline bool MVNParameter::normalize_variance() const { + // @@protoc_insertion_point(field_get:caffe.MVNParameter.normalize_variance) return normalize_variance_; } inline void MVNParameter::set_normalize_variance(bool value) { set_has_normalize_variance(); normalize_variance_ = value; + // @@protoc_insertion_point(field_set:caffe.MVNParameter.normalize_variance) } // optional bool across_channels = 2 [default = false]; @@ -17705,11 +19389,13 @@ inline void MVNParameter::clear_across_channels() { clear_has_across_channels(); } inline bool MVNParameter::across_channels() const { + // @@protoc_insertion_point(field_get:caffe.MVNParameter.across_channels) return across_channels_; } inline void MVNParameter::set_across_channels(bool value) { set_has_across_channels(); across_channels_ = value; + // @@protoc_insertion_point(field_set:caffe.MVNParameter.across_channels) } // optional float eps = 3 [default = 1e-09]; @@ -17727,13 +19413,18 @@ inline void MVNParameter::clear_eps() { clear_has_eps(); } inline float MVNParameter::eps() const { + // @@protoc_insertion_point(field_get:caffe.MVNParameter.eps) return eps_; } inline void MVNParameter::set_eps(float value) { set_has_eps(); eps_ = value; + // @@protoc_insertion_point(field_set:caffe.MVNParameter.eps) } +inline const MVNParameter* MVNParameter::internal_default_instance() { + return &MVNParameter_default_instance_.get(); +} // ------------------------------------------------------------------- // PoolingParameter @@ -17753,12 +19444,14 @@ inline void PoolingParameter::clear_pool() { clear_has_pool(); } inline ::caffe::PoolingParameter_PoolMethod PoolingParameter::pool() const { + // @@protoc_insertion_point(field_get:caffe.PoolingParameter.pool) return static_cast< ::caffe::PoolingParameter_PoolMethod >(pool_); } inline void PoolingParameter::set_pool(::caffe::PoolingParameter_PoolMethod value) { assert(::caffe::PoolingParameter_PoolMethod_IsValid(value)); set_has_pool(); pool_ = value; + // @@protoc_insertion_point(field_set:caffe.PoolingParameter.pool) } // optional uint32 pad = 4 [default = 0]; @@ -17776,11 +19469,13 @@ inline void PoolingParameter::clear_pad() { clear_has_pad(); } inline ::google::protobuf::uint32 PoolingParameter::pad() const { + // @@protoc_insertion_point(field_get:caffe.PoolingParameter.pad) return pad_; } inline void PoolingParameter::set_pad(::google::protobuf::uint32 value) { set_has_pad(); pad_ = value; + // @@protoc_insertion_point(field_set:caffe.PoolingParameter.pad) } // optional uint32 pad_h = 9 [default = 0]; @@ -17798,11 +19493,13 @@ inline void PoolingParameter::clear_pad_h() { clear_has_pad_h(); } inline ::google::protobuf::uint32 PoolingParameter::pad_h() const { + // @@protoc_insertion_point(field_get:caffe.PoolingParameter.pad_h) return pad_h_; } inline void PoolingParameter::set_pad_h(::google::protobuf::uint32 value) { set_has_pad_h(); pad_h_ = value; + // @@protoc_insertion_point(field_set:caffe.PoolingParameter.pad_h) } // optional uint32 pad_w = 10 [default = 0]; @@ -17820,11 +19517,13 @@ inline void PoolingParameter::clear_pad_w() { clear_has_pad_w(); } inline ::google::protobuf::uint32 PoolingParameter::pad_w() const { + // @@protoc_insertion_point(field_get:caffe.PoolingParameter.pad_w) return pad_w_; } inline void PoolingParameter::set_pad_w(::google::protobuf::uint32 value) { set_has_pad_w(); pad_w_ = value; + // @@protoc_insertion_point(field_set:caffe.PoolingParameter.pad_w) } // optional uint32 kernel_size = 2; @@ -17842,11 +19541,13 @@ inline void PoolingParameter::clear_kernel_size() { clear_has_kernel_size(); } inline ::google::protobuf::uint32 PoolingParameter::kernel_size() const { + // @@protoc_insertion_point(field_get:caffe.PoolingParameter.kernel_size) return kernel_size_; } inline void PoolingParameter::set_kernel_size(::google::protobuf::uint32 value) { set_has_kernel_size(); kernel_size_ = value; + // @@protoc_insertion_point(field_set:caffe.PoolingParameter.kernel_size) } // optional uint32 kernel_h = 5; @@ -17864,11 +19565,13 @@ inline void PoolingParameter::clear_kernel_h() { clear_has_kernel_h(); } inline ::google::protobuf::uint32 PoolingParameter::kernel_h() const { + // @@protoc_insertion_point(field_get:caffe.PoolingParameter.kernel_h) return kernel_h_; } inline void PoolingParameter::set_kernel_h(::google::protobuf::uint32 value) { set_has_kernel_h(); kernel_h_ = value; + // @@protoc_insertion_point(field_set:caffe.PoolingParameter.kernel_h) } // optional uint32 kernel_w = 6; @@ -17886,11 +19589,13 @@ inline void PoolingParameter::clear_kernel_w() { clear_has_kernel_w(); } inline ::google::protobuf::uint32 PoolingParameter::kernel_w() const { + // @@protoc_insertion_point(field_get:caffe.PoolingParameter.kernel_w) return kernel_w_; } inline void PoolingParameter::set_kernel_w(::google::protobuf::uint32 value) { set_has_kernel_w(); kernel_w_ = value; + // @@protoc_insertion_point(field_set:caffe.PoolingParameter.kernel_w) } // optional uint32 stride = 3 [default = 1]; @@ -17908,11 +19613,13 @@ inline void PoolingParameter::clear_stride() { clear_has_stride(); } inline ::google::protobuf::uint32 PoolingParameter::stride() const { + // @@protoc_insertion_point(field_get:caffe.PoolingParameter.stride) return stride_; } inline void PoolingParameter::set_stride(::google::protobuf::uint32 value) { set_has_stride(); stride_ = value; + // @@protoc_insertion_point(field_set:caffe.PoolingParameter.stride) } // optional uint32 stride_h = 7; @@ -17930,11 +19637,13 @@ inline void PoolingParameter::clear_stride_h() { clear_has_stride_h(); } inline ::google::protobuf::uint32 PoolingParameter::stride_h() const { + // @@protoc_insertion_point(field_get:caffe.PoolingParameter.stride_h) return stride_h_; } inline void PoolingParameter::set_stride_h(::google::protobuf::uint32 value) { set_has_stride_h(); stride_h_ = value; + // @@protoc_insertion_point(field_set:caffe.PoolingParameter.stride_h) } // optional uint32 stride_w = 8; @@ -17952,11 +19661,13 @@ inline void PoolingParameter::clear_stride_w() { clear_has_stride_w(); } inline ::google::protobuf::uint32 PoolingParameter::stride_w() const { + // @@protoc_insertion_point(field_get:caffe.PoolingParameter.stride_w) return stride_w_; } inline void PoolingParameter::set_stride_w(::google::protobuf::uint32 value) { set_has_stride_w(); stride_w_ = value; + // @@protoc_insertion_point(field_set:caffe.PoolingParameter.stride_w) } // optional .caffe.PoolingParameter.Engine engine = 11 [default = DEFAULT]; @@ -17974,12 +19685,14 @@ inline void PoolingParameter::clear_engine() { clear_has_engine(); } inline ::caffe::PoolingParameter_Engine PoolingParameter::engine() const { + // @@protoc_insertion_point(field_get:caffe.PoolingParameter.engine) return static_cast< ::caffe::PoolingParameter_Engine >(engine_); } inline void PoolingParameter::set_engine(::caffe::PoolingParameter_Engine value) { assert(::caffe::PoolingParameter_Engine_IsValid(value)); set_has_engine(); engine_ = value; + // @@protoc_insertion_point(field_set:caffe.PoolingParameter.engine) } // optional bool global_pooling = 12 [default = false]; @@ -17997,13 +19710,18 @@ inline void PoolingParameter::clear_global_pooling() { clear_has_global_pooling(); } inline bool PoolingParameter::global_pooling() const { + // @@protoc_insertion_point(field_get:caffe.PoolingParameter.global_pooling) return global_pooling_; } inline void PoolingParameter::set_global_pooling(bool value) { set_has_global_pooling(); global_pooling_ = value; + // @@protoc_insertion_point(field_set:caffe.PoolingParameter.global_pooling) } +inline const PoolingParameter* PoolingParameter::internal_default_instance() { + return &PoolingParameter_default_instance_.get(); +} // ------------------------------------------------------------------- // PowerParameter @@ -18023,11 +19741,13 @@ inline void PowerParameter::clear_power() { clear_has_power(); } inline float PowerParameter::power() const { + // @@protoc_insertion_point(field_get:caffe.PowerParameter.power) return power_; } inline void PowerParameter::set_power(float value) { set_has_power(); power_ = value; + // @@protoc_insertion_point(field_set:caffe.PowerParameter.power) } // optional float scale = 2 [default = 1]; @@ -18045,11 +19765,13 @@ inline void PowerParameter::clear_scale() { clear_has_scale(); } inline float PowerParameter::scale() const { + // @@protoc_insertion_point(field_get:caffe.PowerParameter.scale) return scale_; } inline void PowerParameter::set_scale(float value) { set_has_scale(); scale_ = value; + // @@protoc_insertion_point(field_set:caffe.PowerParameter.scale) } // optional float shift = 3 [default = 0]; @@ -18067,13 +19789,18 @@ inline void PowerParameter::clear_shift() { clear_has_shift(); } inline float PowerParameter::shift() const { + // @@protoc_insertion_point(field_get:caffe.PowerParameter.shift) return shift_; } inline void PowerParameter::set_shift(float value) { set_has_shift(); shift_ = value; + // @@protoc_insertion_point(field_set:caffe.PowerParameter.shift) } +inline const PowerParameter* PowerParameter::internal_default_instance() { + return &PowerParameter_default_instance_.get(); +} // ------------------------------------------------------------------- // PythonParameter @@ -18089,63 +19816,47 @@ inline void PythonParameter::clear_has_module() { _has_bits_[0] &= ~0x00000001u; } inline void PythonParameter::clear_module() { - if (module_ != &::google::protobuf::internal::kEmptyString) { - module_->clear(); - } + module_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); clear_has_module(); } inline const ::std::string& PythonParameter::module() const { - return *module_; + // @@protoc_insertion_point(field_get:caffe.PythonParameter.module) + return module_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } inline void PythonParameter::set_module(const ::std::string& value) { set_has_module(); - if (module_ == &::google::protobuf::internal::kEmptyString) { - module_ = new ::std::string; - } - module_->assign(value); + module_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); + // @@protoc_insertion_point(field_set:caffe.PythonParameter.module) } inline void PythonParameter::set_module(const char* value) { set_has_module(); - if (module_ == &::google::protobuf::internal::kEmptyString) { - module_ = new ::std::string; - } - module_->assign(value); + module_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); + // @@protoc_insertion_point(field_set_char:caffe.PythonParameter.module) } inline void PythonParameter::set_module(const char* value, size_t size) { set_has_module(); - if (module_ == &::google::protobuf::internal::kEmptyString) { - module_ = new ::std::string; - } - module_->assign(reinterpret_cast(value), size); + module_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), + ::std::string(reinterpret_cast(value), size)); + // @@protoc_insertion_point(field_set_pointer:caffe.PythonParameter.module) } inline ::std::string* PythonParameter::mutable_module() { set_has_module(); - if (module_ == &::google::protobuf::internal::kEmptyString) { - module_ = new ::std::string; - } - return module_; + // @@protoc_insertion_point(field_mutable:caffe.PythonParameter.module) + return module_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } inline ::std::string* PythonParameter::release_module() { + // @@protoc_insertion_point(field_release:caffe.PythonParameter.module) clear_has_module(); - if (module_ == &::google::protobuf::internal::kEmptyString) { - return NULL; - } else { - ::std::string* temp = module_; - module_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); - return temp; - } + return module_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } inline void PythonParameter::set_allocated_module(::std::string* module) { - if (module_ != &::google::protobuf::internal::kEmptyString) { - delete module_; - } - if (module) { + if (module != NULL) { set_has_module(); - module_ = module; } else { clear_has_module(); - module_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); } + module_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), module); + // @@protoc_insertion_point(field_set_allocated:caffe.PythonParameter.module) } // optional string layer = 2; @@ -18159,65 +19870,52 @@ inline void PythonParameter::clear_has_layer() { _has_bits_[0] &= ~0x00000002u; } inline void PythonParameter::clear_layer() { - if (layer_ != &::google::protobuf::internal::kEmptyString) { - layer_->clear(); - } + layer_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); clear_has_layer(); } inline const ::std::string& PythonParameter::layer() const { - return *layer_; + // @@protoc_insertion_point(field_get:caffe.PythonParameter.layer) + return layer_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } inline void PythonParameter::set_layer(const ::std::string& value) { set_has_layer(); - if (layer_ == &::google::protobuf::internal::kEmptyString) { - layer_ = new ::std::string; - } - layer_->assign(value); + layer_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); + // @@protoc_insertion_point(field_set:caffe.PythonParameter.layer) } inline void PythonParameter::set_layer(const char* value) { set_has_layer(); - if (layer_ == &::google::protobuf::internal::kEmptyString) { - layer_ = new ::std::string; - } - layer_->assign(value); + layer_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); + // @@protoc_insertion_point(field_set_char:caffe.PythonParameter.layer) } inline void PythonParameter::set_layer(const char* value, size_t size) { set_has_layer(); - if (layer_ == &::google::protobuf::internal::kEmptyString) { - layer_ = new ::std::string; - } - layer_->assign(reinterpret_cast(value), size); + layer_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), + ::std::string(reinterpret_cast(value), size)); + // @@protoc_insertion_point(field_set_pointer:caffe.PythonParameter.layer) } inline ::std::string* PythonParameter::mutable_layer() { set_has_layer(); - if (layer_ == &::google::protobuf::internal::kEmptyString) { - layer_ = new ::std::string; - } - return layer_; + // @@protoc_insertion_point(field_mutable:caffe.PythonParameter.layer) + return layer_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } inline ::std::string* PythonParameter::release_layer() { + // @@protoc_insertion_point(field_release:caffe.PythonParameter.layer) clear_has_layer(); - if (layer_ == &::google::protobuf::internal::kEmptyString) { - return NULL; - } else { - ::std::string* temp = layer_; - layer_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); - return temp; - } + return layer_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } inline void PythonParameter::set_allocated_layer(::std::string* layer) { - if (layer_ != &::google::protobuf::internal::kEmptyString) { - delete layer_; - } - if (layer) { + if (layer != NULL) { set_has_layer(); - layer_ = layer; } else { clear_has_layer(); - layer_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); } + layer_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), layer); + // @@protoc_insertion_point(field_set_allocated:caffe.PythonParameter.layer) } +inline const PythonParameter* PythonParameter::internal_default_instance() { + return &PythonParameter_default_instance_.get(); +} // ------------------------------------------------------------------- // ReductionParameter @@ -18237,12 +19935,14 @@ inline void ReductionParameter::clear_operation() { clear_has_operation(); } inline ::caffe::ReductionParameter_ReductionOp ReductionParameter::operation() const { + // @@protoc_insertion_point(field_get:caffe.ReductionParameter.operation) return static_cast< ::caffe::ReductionParameter_ReductionOp >(operation_); } inline void ReductionParameter::set_operation(::caffe::ReductionParameter_ReductionOp value) { assert(::caffe::ReductionParameter_ReductionOp_IsValid(value)); set_has_operation(); operation_ = value; + // @@protoc_insertion_point(field_set:caffe.ReductionParameter.operation) } // optional int32 axis = 2 [default = 0]; @@ -18260,11 +19960,13 @@ inline void ReductionParameter::clear_axis() { clear_has_axis(); } inline ::google::protobuf::int32 ReductionParameter::axis() const { + // @@protoc_insertion_point(field_get:caffe.ReductionParameter.axis) return axis_; } inline void ReductionParameter::set_axis(::google::protobuf::int32 value) { set_has_axis(); axis_ = value; + // @@protoc_insertion_point(field_set:caffe.ReductionParameter.axis) } // optional float coeff = 3 [default = 1]; @@ -18282,13 +19984,18 @@ inline void ReductionParameter::clear_coeff() { clear_has_coeff(); } inline float ReductionParameter::coeff() const { + // @@protoc_insertion_point(field_get:caffe.ReductionParameter.coeff) return coeff_; } inline void ReductionParameter::set_coeff(float value) { set_has_coeff(); coeff_ = value; + // @@protoc_insertion_point(field_set:caffe.ReductionParameter.coeff) } +inline const ReductionParameter* ReductionParameter::internal_default_instance() { + return &ReductionParameter_default_instance_.get(); +} // ------------------------------------------------------------------- // ReLUParameter @@ -18308,11 +20015,13 @@ inline void ReLUParameter::clear_negative_slope() { clear_has_negative_slope(); } inline float ReLUParameter::negative_slope() const { + // @@protoc_insertion_point(field_get:caffe.ReLUParameter.negative_slope) return negative_slope_; } inline void ReLUParameter::set_negative_slope(float value) { set_has_negative_slope(); negative_slope_ = value; + // @@protoc_insertion_point(field_set:caffe.ReLUParameter.negative_slope) } // optional .caffe.ReLUParameter.Engine engine = 2 [default = DEFAULT]; @@ -18330,14 +20039,19 @@ inline void ReLUParameter::clear_engine() { clear_has_engine(); } inline ::caffe::ReLUParameter_Engine ReLUParameter::engine() const { + // @@protoc_insertion_point(field_get:caffe.ReLUParameter.engine) return static_cast< ::caffe::ReLUParameter_Engine >(engine_); } inline void ReLUParameter::set_engine(::caffe::ReLUParameter_Engine value) { assert(::caffe::ReLUParameter_Engine_IsValid(value)); set_has_engine(); engine_ = value; + // @@protoc_insertion_point(field_set:caffe.ReLUParameter.engine) } +inline const ReLUParameter* ReLUParameter::internal_default_instance() { + return &ReLUParameter_default_instance_.get(); +} // ------------------------------------------------------------------- // ReshapeParameter @@ -18357,14 +20071,20 @@ inline void ReshapeParameter::clear_shape() { clear_has_shape(); } inline const ::caffe::BlobShape& ReshapeParameter::shape() const { - return shape_ != NULL ? *shape_ : *default_instance_->shape_; + // @@protoc_insertion_point(field_get:caffe.ReshapeParameter.shape) + return shape_ != NULL ? *shape_ + : *::caffe::BlobShape::internal_default_instance(); } inline ::caffe::BlobShape* ReshapeParameter::mutable_shape() { set_has_shape(); - if (shape_ == NULL) shape_ = new ::caffe::BlobShape; + if (shape_ == NULL) { + shape_ = new ::caffe::BlobShape; + } + // @@protoc_insertion_point(field_mutable:caffe.ReshapeParameter.shape) return shape_; } inline ::caffe::BlobShape* ReshapeParameter::release_shape() { + // @@protoc_insertion_point(field_release:caffe.ReshapeParameter.shape) clear_has_shape(); ::caffe::BlobShape* temp = shape_; shape_ = NULL; @@ -18378,6 +20098,7 @@ inline void ReshapeParameter::set_allocated_shape(::caffe::BlobShape* shape) { } else { clear_has_shape(); } + // @@protoc_insertion_point(field_set_allocated:caffe.ReshapeParameter.shape) } // optional int32 axis = 2 [default = 0]; @@ -18395,11 +20116,13 @@ inline void ReshapeParameter::clear_axis() { clear_has_axis(); } inline ::google::protobuf::int32 ReshapeParameter::axis() const { + // @@protoc_insertion_point(field_get:caffe.ReshapeParameter.axis) return axis_; } inline void ReshapeParameter::set_axis(::google::protobuf::int32 value) { set_has_axis(); axis_ = value; + // @@protoc_insertion_point(field_set:caffe.ReshapeParameter.axis) } // optional int32 num_axes = 3 [default = -1]; @@ -18417,13 +20140,18 @@ inline void ReshapeParameter::clear_num_axes() { clear_has_num_axes(); } inline ::google::protobuf::int32 ReshapeParameter::num_axes() const { + // @@protoc_insertion_point(field_get:caffe.ReshapeParameter.num_axes) return num_axes_; } inline void ReshapeParameter::set_num_axes(::google::protobuf::int32 value) { set_has_num_axes(); num_axes_ = value; + // @@protoc_insertion_point(field_set:caffe.ReshapeParameter.num_axes) } +inline const ReshapeParameter* ReshapeParameter::internal_default_instance() { + return &ReshapeParameter_default_instance_.get(); +} // ------------------------------------------------------------------- // SigmoidParameter @@ -18443,14 +20171,19 @@ inline void SigmoidParameter::clear_engine() { clear_has_engine(); } inline ::caffe::SigmoidParameter_Engine SigmoidParameter::engine() const { + // @@protoc_insertion_point(field_get:caffe.SigmoidParameter.engine) return static_cast< ::caffe::SigmoidParameter_Engine >(engine_); } inline void SigmoidParameter::set_engine(::caffe::SigmoidParameter_Engine value) { assert(::caffe::SigmoidParameter_Engine_IsValid(value)); set_has_engine(); engine_ = value; + // @@protoc_insertion_point(field_set:caffe.SigmoidParameter.engine) } +inline const SigmoidParameter* SigmoidParameter::internal_default_instance() { + return &SigmoidParameter_default_instance_.get(); +} // ------------------------------------------------------------------- // SliceParameter @@ -18470,11 +20203,13 @@ inline void SliceParameter::clear_axis() { clear_has_axis(); } inline ::google::protobuf::int32 SliceParameter::axis() const { + // @@protoc_insertion_point(field_get:caffe.SliceParameter.axis) return axis_; } inline void SliceParameter::set_axis(::google::protobuf::int32 value) { set_has_axis(); axis_ = value; + // @@protoc_insertion_point(field_set:caffe.SliceParameter.axis) } // repeated uint32 slice_point = 2; @@ -18485,20 +20220,25 @@ inline void SliceParameter::clear_slice_point() { slice_point_.Clear(); } inline ::google::protobuf::uint32 SliceParameter::slice_point(int index) const { + // @@protoc_insertion_point(field_get:caffe.SliceParameter.slice_point) return slice_point_.Get(index); } inline void SliceParameter::set_slice_point(int index, ::google::protobuf::uint32 value) { slice_point_.Set(index, value); + // @@protoc_insertion_point(field_set:caffe.SliceParameter.slice_point) } inline void SliceParameter::add_slice_point(::google::protobuf::uint32 value) { slice_point_.Add(value); + // @@protoc_insertion_point(field_add:caffe.SliceParameter.slice_point) } inline const ::google::protobuf::RepeatedField< ::google::protobuf::uint32 >& SliceParameter::slice_point() const { + // @@protoc_insertion_point(field_list:caffe.SliceParameter.slice_point) return slice_point_; } inline ::google::protobuf::RepeatedField< ::google::protobuf::uint32 >* SliceParameter::mutable_slice_point() { + // @@protoc_insertion_point(field_mutable_list:caffe.SliceParameter.slice_point) return &slice_point_; } @@ -18517,13 +20257,18 @@ inline void SliceParameter::clear_slice_dim() { clear_has_slice_dim(); } inline ::google::protobuf::uint32 SliceParameter::slice_dim() const { + // @@protoc_insertion_point(field_get:caffe.SliceParameter.slice_dim) return slice_dim_; } inline void SliceParameter::set_slice_dim(::google::protobuf::uint32 value) { set_has_slice_dim(); slice_dim_ = value; + // @@protoc_insertion_point(field_set:caffe.SliceParameter.slice_dim) } +inline const SliceParameter* SliceParameter::internal_default_instance() { + return &SliceParameter_default_instance_.get(); +} // ------------------------------------------------------------------- // SoftmaxParameter @@ -18543,12 +20288,14 @@ inline void SoftmaxParameter::clear_engine() { clear_has_engine(); } inline ::caffe::SoftmaxParameter_Engine SoftmaxParameter::engine() const { + // @@protoc_insertion_point(field_get:caffe.SoftmaxParameter.engine) return static_cast< ::caffe::SoftmaxParameter_Engine >(engine_); } inline void SoftmaxParameter::set_engine(::caffe::SoftmaxParameter_Engine value) { assert(::caffe::SoftmaxParameter_Engine_IsValid(value)); set_has_engine(); engine_ = value; + // @@protoc_insertion_point(field_set:caffe.SoftmaxParameter.engine) } // optional int32 axis = 2 [default = 1]; @@ -18566,13 +20313,18 @@ inline void SoftmaxParameter::clear_axis() { clear_has_axis(); } inline ::google::protobuf::int32 SoftmaxParameter::axis() const { + // @@protoc_insertion_point(field_get:caffe.SoftmaxParameter.axis) return axis_; } inline void SoftmaxParameter::set_axis(::google::protobuf::int32 value) { set_has_axis(); axis_ = value; + // @@protoc_insertion_point(field_set:caffe.SoftmaxParameter.axis) } +inline const SoftmaxParameter* SoftmaxParameter::internal_default_instance() { + return &SoftmaxParameter_default_instance_.get(); +} // ------------------------------------------------------------------- // TanHParameter @@ -18592,14 +20344,19 @@ inline void TanHParameter::clear_engine() { clear_has_engine(); } inline ::caffe::TanHParameter_Engine TanHParameter::engine() const { + // @@protoc_insertion_point(field_get:caffe.TanHParameter.engine) return static_cast< ::caffe::TanHParameter_Engine >(engine_); } inline void TanHParameter::set_engine(::caffe::TanHParameter_Engine value) { assert(::caffe::TanHParameter_Engine_IsValid(value)); set_has_engine(); engine_ = value; + // @@protoc_insertion_point(field_set:caffe.TanHParameter.engine) } +inline const TanHParameter* TanHParameter::internal_default_instance() { + return &TanHParameter_default_instance_.get(); +} // ------------------------------------------------------------------- // ThresholdParameter @@ -18619,13 +20376,18 @@ inline void ThresholdParameter::clear_threshold() { clear_has_threshold(); } inline float ThresholdParameter::threshold() const { + // @@protoc_insertion_point(field_get:caffe.ThresholdParameter.threshold) return threshold_; } inline void ThresholdParameter::set_threshold(float value) { set_has_threshold(); threshold_ = value; + // @@protoc_insertion_point(field_set:caffe.ThresholdParameter.threshold) } +inline const ThresholdParameter* ThresholdParameter::internal_default_instance() { + return &ThresholdParameter_default_instance_.get(); +} // ------------------------------------------------------------------- // WindowDataParameter @@ -18641,63 +20403,47 @@ inline void WindowDataParameter::clear_has_source() { _has_bits_[0] &= ~0x00000001u; } inline void WindowDataParameter::clear_source() { - if (source_ != &::google::protobuf::internal::kEmptyString) { - source_->clear(); - } + source_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); clear_has_source(); } inline const ::std::string& WindowDataParameter::source() const { - return *source_; + // @@protoc_insertion_point(field_get:caffe.WindowDataParameter.source) + return source_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } inline void WindowDataParameter::set_source(const ::std::string& value) { set_has_source(); - if (source_ == &::google::protobuf::internal::kEmptyString) { - source_ = new ::std::string; - } - source_->assign(value); + source_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); + // @@protoc_insertion_point(field_set:caffe.WindowDataParameter.source) } inline void WindowDataParameter::set_source(const char* value) { set_has_source(); - if (source_ == &::google::protobuf::internal::kEmptyString) { - source_ = new ::std::string; - } - source_->assign(value); + source_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); + // @@protoc_insertion_point(field_set_char:caffe.WindowDataParameter.source) } inline void WindowDataParameter::set_source(const char* value, size_t size) { set_has_source(); - if (source_ == &::google::protobuf::internal::kEmptyString) { - source_ = new ::std::string; - } - source_->assign(reinterpret_cast(value), size); + source_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), + ::std::string(reinterpret_cast(value), size)); + // @@protoc_insertion_point(field_set_pointer:caffe.WindowDataParameter.source) } inline ::std::string* WindowDataParameter::mutable_source() { set_has_source(); - if (source_ == &::google::protobuf::internal::kEmptyString) { - source_ = new ::std::string; - } - return source_; + // @@protoc_insertion_point(field_mutable:caffe.WindowDataParameter.source) + return source_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } inline ::std::string* WindowDataParameter::release_source() { + // @@protoc_insertion_point(field_release:caffe.WindowDataParameter.source) clear_has_source(); - if (source_ == &::google::protobuf::internal::kEmptyString) { - return NULL; - } else { - ::std::string* temp = source_; - source_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); - return temp; - } + return source_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } inline void WindowDataParameter::set_allocated_source(::std::string* source) { - if (source_ != &::google::protobuf::internal::kEmptyString) { - delete source_; - } - if (source) { + if (source != NULL) { set_has_source(); - source_ = source; } else { clear_has_source(); - source_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); } + source_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), source); + // @@protoc_insertion_point(field_set_allocated:caffe.WindowDataParameter.source) } // optional float scale = 2 [default = 1]; @@ -18715,11 +20461,13 @@ inline void WindowDataParameter::clear_scale() { clear_has_scale(); } inline float WindowDataParameter::scale() const { + // @@protoc_insertion_point(field_get:caffe.WindowDataParameter.scale) return scale_; } inline void WindowDataParameter::set_scale(float value) { set_has_scale(); scale_ = value; + // @@protoc_insertion_point(field_set:caffe.WindowDataParameter.scale) } // optional string mean_file = 3; @@ -18733,63 +20481,47 @@ inline void WindowDataParameter::clear_has_mean_file() { _has_bits_[0] &= ~0x00000004u; } inline void WindowDataParameter::clear_mean_file() { - if (mean_file_ != &::google::protobuf::internal::kEmptyString) { - mean_file_->clear(); - } + mean_file_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); clear_has_mean_file(); } inline const ::std::string& WindowDataParameter::mean_file() const { - return *mean_file_; + // @@protoc_insertion_point(field_get:caffe.WindowDataParameter.mean_file) + return mean_file_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } inline void WindowDataParameter::set_mean_file(const ::std::string& value) { set_has_mean_file(); - if (mean_file_ == &::google::protobuf::internal::kEmptyString) { - mean_file_ = new ::std::string; - } - mean_file_->assign(value); + mean_file_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); + // @@protoc_insertion_point(field_set:caffe.WindowDataParameter.mean_file) } inline void WindowDataParameter::set_mean_file(const char* value) { set_has_mean_file(); - if (mean_file_ == &::google::protobuf::internal::kEmptyString) { - mean_file_ = new ::std::string; - } - mean_file_->assign(value); + mean_file_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); + // @@protoc_insertion_point(field_set_char:caffe.WindowDataParameter.mean_file) } inline void WindowDataParameter::set_mean_file(const char* value, size_t size) { set_has_mean_file(); - if (mean_file_ == &::google::protobuf::internal::kEmptyString) { - mean_file_ = new ::std::string; - } - mean_file_->assign(reinterpret_cast(value), size); + mean_file_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), + ::std::string(reinterpret_cast(value), size)); + // @@protoc_insertion_point(field_set_pointer:caffe.WindowDataParameter.mean_file) } inline ::std::string* WindowDataParameter::mutable_mean_file() { set_has_mean_file(); - if (mean_file_ == &::google::protobuf::internal::kEmptyString) { - mean_file_ = new ::std::string; - } - return mean_file_; + // @@protoc_insertion_point(field_mutable:caffe.WindowDataParameter.mean_file) + return mean_file_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } inline ::std::string* WindowDataParameter::release_mean_file() { + // @@protoc_insertion_point(field_release:caffe.WindowDataParameter.mean_file) clear_has_mean_file(); - if (mean_file_ == &::google::protobuf::internal::kEmptyString) { - return NULL; - } else { - ::std::string* temp = mean_file_; - mean_file_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); - return temp; - } + return mean_file_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } inline void WindowDataParameter::set_allocated_mean_file(::std::string* mean_file) { - if (mean_file_ != &::google::protobuf::internal::kEmptyString) { - delete mean_file_; - } - if (mean_file) { + if (mean_file != NULL) { set_has_mean_file(); - mean_file_ = mean_file; } else { clear_has_mean_file(); - mean_file_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); } + mean_file_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), mean_file); + // @@protoc_insertion_point(field_set_allocated:caffe.WindowDataParameter.mean_file) } // optional uint32 batch_size = 4; @@ -18807,11 +20539,13 @@ inline void WindowDataParameter::clear_batch_size() { clear_has_batch_size(); } inline ::google::protobuf::uint32 WindowDataParameter::batch_size() const { + // @@protoc_insertion_point(field_get:caffe.WindowDataParameter.batch_size) return batch_size_; } inline void WindowDataParameter::set_batch_size(::google::protobuf::uint32 value) { set_has_batch_size(); batch_size_ = value; + // @@protoc_insertion_point(field_set:caffe.WindowDataParameter.batch_size) } // optional uint32 crop_size = 5 [default = 0]; @@ -18829,11 +20563,13 @@ inline void WindowDataParameter::clear_crop_size() { clear_has_crop_size(); } inline ::google::protobuf::uint32 WindowDataParameter::crop_size() const { + // @@protoc_insertion_point(field_get:caffe.WindowDataParameter.crop_size) return crop_size_; } inline void WindowDataParameter::set_crop_size(::google::protobuf::uint32 value) { set_has_crop_size(); crop_size_ = value; + // @@protoc_insertion_point(field_set:caffe.WindowDataParameter.crop_size) } // optional bool mirror = 6 [default = false]; @@ -18851,11 +20587,13 @@ inline void WindowDataParameter::clear_mirror() { clear_has_mirror(); } inline bool WindowDataParameter::mirror() const { + // @@protoc_insertion_point(field_get:caffe.WindowDataParameter.mirror) return mirror_; } inline void WindowDataParameter::set_mirror(bool value) { set_has_mirror(); mirror_ = value; + // @@protoc_insertion_point(field_set:caffe.WindowDataParameter.mirror) } // optional float fg_threshold = 7 [default = 0.5]; @@ -18873,11 +20611,13 @@ inline void WindowDataParameter::clear_fg_threshold() { clear_has_fg_threshold(); } inline float WindowDataParameter::fg_threshold() const { + // @@protoc_insertion_point(field_get:caffe.WindowDataParameter.fg_threshold) return fg_threshold_; } inline void WindowDataParameter::set_fg_threshold(float value) { set_has_fg_threshold(); fg_threshold_ = value; + // @@protoc_insertion_point(field_set:caffe.WindowDataParameter.fg_threshold) } // optional float bg_threshold = 8 [default = 0.5]; @@ -18895,11 +20635,13 @@ inline void WindowDataParameter::clear_bg_threshold() { clear_has_bg_threshold(); } inline float WindowDataParameter::bg_threshold() const { + // @@protoc_insertion_point(field_get:caffe.WindowDataParameter.bg_threshold) return bg_threshold_; } inline void WindowDataParameter::set_bg_threshold(float value) { set_has_bg_threshold(); bg_threshold_ = value; + // @@protoc_insertion_point(field_set:caffe.WindowDataParameter.bg_threshold) } // optional float fg_fraction = 9 [default = 0.25]; @@ -18917,11 +20659,13 @@ inline void WindowDataParameter::clear_fg_fraction() { clear_has_fg_fraction(); } inline float WindowDataParameter::fg_fraction() const { + // @@protoc_insertion_point(field_get:caffe.WindowDataParameter.fg_fraction) return fg_fraction_; } inline void WindowDataParameter::set_fg_fraction(float value) { set_has_fg_fraction(); fg_fraction_ = value; + // @@protoc_insertion_point(field_set:caffe.WindowDataParameter.fg_fraction) } // optional uint32 context_pad = 10 [default = 0]; @@ -18939,11 +20683,13 @@ inline void WindowDataParameter::clear_context_pad() { clear_has_context_pad(); } inline ::google::protobuf::uint32 WindowDataParameter::context_pad() const { + // @@protoc_insertion_point(field_get:caffe.WindowDataParameter.context_pad) return context_pad_; } inline void WindowDataParameter::set_context_pad(::google::protobuf::uint32 value) { set_has_context_pad(); context_pad_ = value; + // @@protoc_insertion_point(field_set:caffe.WindowDataParameter.context_pad) } // optional string crop_mode = 11 [default = "warp"]; @@ -18957,63 +20703,47 @@ inline void WindowDataParameter::clear_has_crop_mode() { _has_bits_[0] &= ~0x00000400u; } inline void WindowDataParameter::clear_crop_mode() { - if (crop_mode_ != _default_crop_mode_) { - crop_mode_->assign(*_default_crop_mode_); - } + crop_mode_.ClearToDefaultNoArena(_default_crop_mode_); clear_has_crop_mode(); } inline const ::std::string& WindowDataParameter::crop_mode() const { - return *crop_mode_; + // @@protoc_insertion_point(field_get:caffe.WindowDataParameter.crop_mode) + return crop_mode_.GetNoArena(_default_crop_mode_); } inline void WindowDataParameter::set_crop_mode(const ::std::string& value) { set_has_crop_mode(); - if (crop_mode_ == _default_crop_mode_) { - crop_mode_ = new ::std::string; - } - crop_mode_->assign(value); + crop_mode_.SetNoArena(_default_crop_mode_, value); + // @@protoc_insertion_point(field_set:caffe.WindowDataParameter.crop_mode) } inline void WindowDataParameter::set_crop_mode(const char* value) { set_has_crop_mode(); - if (crop_mode_ == _default_crop_mode_) { - crop_mode_ = new ::std::string; - } - crop_mode_->assign(value); + crop_mode_.SetNoArena(_default_crop_mode_, ::std::string(value)); + // @@protoc_insertion_point(field_set_char:caffe.WindowDataParameter.crop_mode) } inline void WindowDataParameter::set_crop_mode(const char* value, size_t size) { set_has_crop_mode(); - if (crop_mode_ == _default_crop_mode_) { - crop_mode_ = new ::std::string; - } - crop_mode_->assign(reinterpret_cast(value), size); + crop_mode_.SetNoArena(_default_crop_mode_, + ::std::string(reinterpret_cast(value), size)); + // @@protoc_insertion_point(field_set_pointer:caffe.WindowDataParameter.crop_mode) } inline ::std::string* WindowDataParameter::mutable_crop_mode() { set_has_crop_mode(); - if (crop_mode_ == _default_crop_mode_) { - crop_mode_ = new ::std::string(*_default_crop_mode_); - } - return crop_mode_; + // @@protoc_insertion_point(field_mutable:caffe.WindowDataParameter.crop_mode) + return crop_mode_.MutableNoArena(_default_crop_mode_); } inline ::std::string* WindowDataParameter::release_crop_mode() { + // @@protoc_insertion_point(field_release:caffe.WindowDataParameter.crop_mode) clear_has_crop_mode(); - if (crop_mode_ == _default_crop_mode_) { - return NULL; - } else { - ::std::string* temp = crop_mode_; - crop_mode_ = const_cast< ::std::string*>(_default_crop_mode_); - return temp; - } + return crop_mode_.ReleaseNoArena(_default_crop_mode_); } inline void WindowDataParameter::set_allocated_crop_mode(::std::string* crop_mode) { - if (crop_mode_ != _default_crop_mode_) { - delete crop_mode_; - } - if (crop_mode) { + if (crop_mode != NULL) { set_has_crop_mode(); - crop_mode_ = crop_mode; } else { clear_has_crop_mode(); - crop_mode_ = const_cast< ::std::string*>(_default_crop_mode_); } + crop_mode_.SetAllocatedNoArena(_default_crop_mode_, crop_mode); + // @@protoc_insertion_point(field_set_allocated:caffe.WindowDataParameter.crop_mode) } // optional bool cache_images = 12 [default = false]; @@ -19031,11 +20761,13 @@ inline void WindowDataParameter::clear_cache_images() { clear_has_cache_images(); } inline bool WindowDataParameter::cache_images() const { + // @@protoc_insertion_point(field_get:caffe.WindowDataParameter.cache_images) return cache_images_; } inline void WindowDataParameter::set_cache_images(bool value) { set_has_cache_images(); cache_images_ = value; + // @@protoc_insertion_point(field_set:caffe.WindowDataParameter.cache_images) } // optional string root_folder = 13 [default = ""]; @@ -19049,65 +20781,52 @@ inline void WindowDataParameter::clear_has_root_folder() { _has_bits_[0] &= ~0x00001000u; } inline void WindowDataParameter::clear_root_folder() { - if (root_folder_ != &::google::protobuf::internal::kEmptyString) { - root_folder_->clear(); - } + root_folder_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); clear_has_root_folder(); } inline const ::std::string& WindowDataParameter::root_folder() const { - return *root_folder_; + // @@protoc_insertion_point(field_get:caffe.WindowDataParameter.root_folder) + return root_folder_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } inline void WindowDataParameter::set_root_folder(const ::std::string& value) { set_has_root_folder(); - if (root_folder_ == &::google::protobuf::internal::kEmptyString) { - root_folder_ = new ::std::string; - } - root_folder_->assign(value); + root_folder_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); + // @@protoc_insertion_point(field_set:caffe.WindowDataParameter.root_folder) } inline void WindowDataParameter::set_root_folder(const char* value) { set_has_root_folder(); - if (root_folder_ == &::google::protobuf::internal::kEmptyString) { - root_folder_ = new ::std::string; - } - root_folder_->assign(value); + root_folder_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); + // @@protoc_insertion_point(field_set_char:caffe.WindowDataParameter.root_folder) } inline void WindowDataParameter::set_root_folder(const char* value, size_t size) { set_has_root_folder(); - if (root_folder_ == &::google::protobuf::internal::kEmptyString) { - root_folder_ = new ::std::string; - } - root_folder_->assign(reinterpret_cast(value), size); + root_folder_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), + ::std::string(reinterpret_cast(value), size)); + // @@protoc_insertion_point(field_set_pointer:caffe.WindowDataParameter.root_folder) } inline ::std::string* WindowDataParameter::mutable_root_folder() { set_has_root_folder(); - if (root_folder_ == &::google::protobuf::internal::kEmptyString) { - root_folder_ = new ::std::string; - } - return root_folder_; + // @@protoc_insertion_point(field_mutable:caffe.WindowDataParameter.root_folder) + return root_folder_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } inline ::std::string* WindowDataParameter::release_root_folder() { + // @@protoc_insertion_point(field_release:caffe.WindowDataParameter.root_folder) clear_has_root_folder(); - if (root_folder_ == &::google::protobuf::internal::kEmptyString) { - return NULL; - } else { - ::std::string* temp = root_folder_; - root_folder_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); - return temp; - } + return root_folder_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } inline void WindowDataParameter::set_allocated_root_folder(::std::string* root_folder) { - if (root_folder_ != &::google::protobuf::internal::kEmptyString) { - delete root_folder_; - } - if (root_folder) { + if (root_folder != NULL) { set_has_root_folder(); - root_folder_ = root_folder; } else { clear_has_root_folder(); - root_folder_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); } + root_folder_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), root_folder); + // @@protoc_insertion_point(field_set_allocated:caffe.WindowDataParameter.root_folder) } +inline const WindowDataParameter* WindowDataParameter::internal_default_instance() { + return &WindowDataParameter_default_instance_.get(); +} // ------------------------------------------------------------------- // SPPParameter @@ -19127,11 +20846,13 @@ inline void SPPParameter::clear_pyramid_height() { clear_has_pyramid_height(); } inline ::google::protobuf::uint32 SPPParameter::pyramid_height() const { + // @@protoc_insertion_point(field_get:caffe.SPPParameter.pyramid_height) return pyramid_height_; } inline void SPPParameter::set_pyramid_height(::google::protobuf::uint32 value) { set_has_pyramid_height(); pyramid_height_ = value; + // @@protoc_insertion_point(field_set:caffe.SPPParameter.pyramid_height) } // optional .caffe.SPPParameter.PoolMethod pool = 2 [default = MAX]; @@ -19149,12 +20870,14 @@ inline void SPPParameter::clear_pool() { clear_has_pool(); } inline ::caffe::SPPParameter_PoolMethod SPPParameter::pool() const { + // @@protoc_insertion_point(field_get:caffe.SPPParameter.pool) return static_cast< ::caffe::SPPParameter_PoolMethod >(pool_); } inline void SPPParameter::set_pool(::caffe::SPPParameter_PoolMethod value) { assert(::caffe::SPPParameter_PoolMethod_IsValid(value)); set_has_pool(); pool_ = value; + // @@protoc_insertion_point(field_set:caffe.SPPParameter.pool) } // optional .caffe.SPPParameter.Engine engine = 6 [default = DEFAULT]; @@ -19172,14 +20895,19 @@ inline void SPPParameter::clear_engine() { clear_has_engine(); } inline ::caffe::SPPParameter_Engine SPPParameter::engine() const { + // @@protoc_insertion_point(field_get:caffe.SPPParameter.engine) return static_cast< ::caffe::SPPParameter_Engine >(engine_); } inline void SPPParameter::set_engine(::caffe::SPPParameter_Engine value) { assert(::caffe::SPPParameter_Engine_IsValid(value)); set_has_engine(); engine_ = value; + // @@protoc_insertion_point(field_set:caffe.SPPParameter.engine) } +inline const SPPParameter* SPPParameter::internal_default_instance() { + return &SPPParameter_default_instance_.get(); +} // ------------------------------------------------------------------- // V1LayerParameter @@ -19192,39 +20920,50 @@ inline void V1LayerParameter::clear_bottom() { bottom_.Clear(); } inline const ::std::string& V1LayerParameter::bottom(int index) const { + // @@protoc_insertion_point(field_get:caffe.V1LayerParameter.bottom) return bottom_.Get(index); } inline ::std::string* V1LayerParameter::mutable_bottom(int index) { + // @@protoc_insertion_point(field_mutable:caffe.V1LayerParameter.bottom) return bottom_.Mutable(index); } inline void V1LayerParameter::set_bottom(int index, const ::std::string& value) { + // @@protoc_insertion_point(field_set:caffe.V1LayerParameter.bottom) bottom_.Mutable(index)->assign(value); } inline void V1LayerParameter::set_bottom(int index, const char* value) { bottom_.Mutable(index)->assign(value); + // @@protoc_insertion_point(field_set_char:caffe.V1LayerParameter.bottom) } inline void V1LayerParameter::set_bottom(int index, const char* value, size_t size) { bottom_.Mutable(index)->assign( reinterpret_cast(value), size); + // @@protoc_insertion_point(field_set_pointer:caffe.V1LayerParameter.bottom) } inline ::std::string* V1LayerParameter::add_bottom() { + // @@protoc_insertion_point(field_add_mutable:caffe.V1LayerParameter.bottom) return bottom_.Add(); } inline void V1LayerParameter::add_bottom(const ::std::string& value) { bottom_.Add()->assign(value); + // @@protoc_insertion_point(field_add:caffe.V1LayerParameter.bottom) } inline void V1LayerParameter::add_bottom(const char* value) { bottom_.Add()->assign(value); + // @@protoc_insertion_point(field_add_char:caffe.V1LayerParameter.bottom) } inline void V1LayerParameter::add_bottom(const char* value, size_t size) { bottom_.Add()->assign(reinterpret_cast(value), size); + // @@protoc_insertion_point(field_add_pointer:caffe.V1LayerParameter.bottom) } inline const ::google::protobuf::RepeatedPtrField< ::std::string>& V1LayerParameter::bottom() const { + // @@protoc_insertion_point(field_list:caffe.V1LayerParameter.bottom) return bottom_; } inline ::google::protobuf::RepeatedPtrField< ::std::string>* V1LayerParameter::mutable_bottom() { + // @@protoc_insertion_point(field_mutable_list:caffe.V1LayerParameter.bottom) return &bottom_; } @@ -19236,39 +20975,50 @@ inline void V1LayerParameter::clear_top() { top_.Clear(); } inline const ::std::string& V1LayerParameter::top(int index) const { + // @@protoc_insertion_point(field_get:caffe.V1LayerParameter.top) return top_.Get(index); } inline ::std::string* V1LayerParameter::mutable_top(int index) { + // @@protoc_insertion_point(field_mutable:caffe.V1LayerParameter.top) return top_.Mutable(index); } inline void V1LayerParameter::set_top(int index, const ::std::string& value) { + // @@protoc_insertion_point(field_set:caffe.V1LayerParameter.top) top_.Mutable(index)->assign(value); } inline void V1LayerParameter::set_top(int index, const char* value) { top_.Mutable(index)->assign(value); + // @@protoc_insertion_point(field_set_char:caffe.V1LayerParameter.top) } inline void V1LayerParameter::set_top(int index, const char* value, size_t size) { top_.Mutable(index)->assign( reinterpret_cast(value), size); + // @@protoc_insertion_point(field_set_pointer:caffe.V1LayerParameter.top) } inline ::std::string* V1LayerParameter::add_top() { + // @@protoc_insertion_point(field_add_mutable:caffe.V1LayerParameter.top) return top_.Add(); } inline void V1LayerParameter::add_top(const ::std::string& value) { top_.Add()->assign(value); + // @@protoc_insertion_point(field_add:caffe.V1LayerParameter.top) } inline void V1LayerParameter::add_top(const char* value) { top_.Add()->assign(value); + // @@protoc_insertion_point(field_add_char:caffe.V1LayerParameter.top) } inline void V1LayerParameter::add_top(const char* value, size_t size) { top_.Add()->assign(reinterpret_cast(value), size); + // @@protoc_insertion_point(field_add_pointer:caffe.V1LayerParameter.top) } inline const ::google::protobuf::RepeatedPtrField< ::std::string>& V1LayerParameter::top() const { + // @@protoc_insertion_point(field_list:caffe.V1LayerParameter.top) return top_; } inline ::google::protobuf::RepeatedPtrField< ::std::string>* V1LayerParameter::mutable_top() { + // @@protoc_insertion_point(field_mutable_list:caffe.V1LayerParameter.top) return &top_; } @@ -19283,63 +21033,47 @@ inline void V1LayerParameter::clear_has_name() { _has_bits_[0] &= ~0x00000004u; } inline void V1LayerParameter::clear_name() { - if (name_ != &::google::protobuf::internal::kEmptyString) { - name_->clear(); - } + name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); clear_has_name(); } inline const ::std::string& V1LayerParameter::name() const { - return *name_; + // @@protoc_insertion_point(field_get:caffe.V1LayerParameter.name) + return name_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } inline void V1LayerParameter::set_name(const ::std::string& value) { set_has_name(); - if (name_ == &::google::protobuf::internal::kEmptyString) { - name_ = new ::std::string; - } - name_->assign(value); + name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); + // @@protoc_insertion_point(field_set:caffe.V1LayerParameter.name) } inline void V1LayerParameter::set_name(const char* value) { set_has_name(); - if (name_ == &::google::protobuf::internal::kEmptyString) { - name_ = new ::std::string; - } - name_->assign(value); + name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); + // @@protoc_insertion_point(field_set_char:caffe.V1LayerParameter.name) } inline void V1LayerParameter::set_name(const char* value, size_t size) { set_has_name(); - if (name_ == &::google::protobuf::internal::kEmptyString) { - name_ = new ::std::string; - } - name_->assign(reinterpret_cast(value), size); + name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), + ::std::string(reinterpret_cast(value), size)); + // @@protoc_insertion_point(field_set_pointer:caffe.V1LayerParameter.name) } inline ::std::string* V1LayerParameter::mutable_name() { set_has_name(); - if (name_ == &::google::protobuf::internal::kEmptyString) { - name_ = new ::std::string; - } - return name_; + // @@protoc_insertion_point(field_mutable:caffe.V1LayerParameter.name) + return name_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } inline ::std::string* V1LayerParameter::release_name() { + // @@protoc_insertion_point(field_release:caffe.V1LayerParameter.name) clear_has_name(); - if (name_ == &::google::protobuf::internal::kEmptyString) { - return NULL; - } else { - ::std::string* temp = name_; - name_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); - return temp; - } + return name_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } inline void V1LayerParameter::set_allocated_name(::std::string* name) { - if (name_ != &::google::protobuf::internal::kEmptyString) { - delete name_; - } - if (name) { + if (name != NULL) { set_has_name(); - name_ = name; } else { clear_has_name(); - name_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); } + name_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), name); + // @@protoc_insertion_point(field_set_allocated:caffe.V1LayerParameter.name) } // repeated .caffe.NetStateRule include = 32; @@ -19350,22 +21084,27 @@ inline void V1LayerParameter::clear_include() { include_.Clear(); } inline const ::caffe::NetStateRule& V1LayerParameter::include(int index) const { + // @@protoc_insertion_point(field_get:caffe.V1LayerParameter.include) return include_.Get(index); } inline ::caffe::NetStateRule* V1LayerParameter::mutable_include(int index) { + // @@protoc_insertion_point(field_mutable:caffe.V1LayerParameter.include) return include_.Mutable(index); } inline ::caffe::NetStateRule* V1LayerParameter::add_include() { + // @@protoc_insertion_point(field_add:caffe.V1LayerParameter.include) return include_.Add(); } -inline const ::google::protobuf::RepeatedPtrField< ::caffe::NetStateRule >& -V1LayerParameter::include() const { - return include_; -} inline ::google::protobuf::RepeatedPtrField< ::caffe::NetStateRule >* V1LayerParameter::mutable_include() { + // @@protoc_insertion_point(field_mutable_list:caffe.V1LayerParameter.include) return &include_; } +inline const ::google::protobuf::RepeatedPtrField< ::caffe::NetStateRule >& +V1LayerParameter::include() const { + // @@protoc_insertion_point(field_list:caffe.V1LayerParameter.include) + return include_; +} // repeated .caffe.NetStateRule exclude = 33; inline int V1LayerParameter::exclude_size() const { @@ -19375,22 +21114,27 @@ inline void V1LayerParameter::clear_exclude() { exclude_.Clear(); } inline const ::caffe::NetStateRule& V1LayerParameter::exclude(int index) const { + // @@protoc_insertion_point(field_get:caffe.V1LayerParameter.exclude) return exclude_.Get(index); } inline ::caffe::NetStateRule* V1LayerParameter::mutable_exclude(int index) { + // @@protoc_insertion_point(field_mutable:caffe.V1LayerParameter.exclude) return exclude_.Mutable(index); } inline ::caffe::NetStateRule* V1LayerParameter::add_exclude() { + // @@protoc_insertion_point(field_add:caffe.V1LayerParameter.exclude) return exclude_.Add(); } -inline const ::google::protobuf::RepeatedPtrField< ::caffe::NetStateRule >& -V1LayerParameter::exclude() const { - return exclude_; -} inline ::google::protobuf::RepeatedPtrField< ::caffe::NetStateRule >* V1LayerParameter::mutable_exclude() { + // @@protoc_insertion_point(field_mutable_list:caffe.V1LayerParameter.exclude) return &exclude_; } +inline const ::google::protobuf::RepeatedPtrField< ::caffe::NetStateRule >& +V1LayerParameter::exclude() const { + // @@protoc_insertion_point(field_list:caffe.V1LayerParameter.exclude) + return exclude_; +} // optional .caffe.V1LayerParameter.LayerType type = 5; inline bool V1LayerParameter::has_type() const { @@ -19407,12 +21151,14 @@ inline void V1LayerParameter::clear_type() { clear_has_type(); } inline ::caffe::V1LayerParameter_LayerType V1LayerParameter::type() const { + // @@protoc_insertion_point(field_get:caffe.V1LayerParameter.type) return static_cast< ::caffe::V1LayerParameter_LayerType >(type_); } inline void V1LayerParameter::set_type(::caffe::V1LayerParameter_LayerType value) { assert(::caffe::V1LayerParameter_LayerType_IsValid(value)); set_has_type(); type_ = value; + // @@protoc_insertion_point(field_set:caffe.V1LayerParameter.type) } // repeated .caffe.BlobProto blobs = 6; @@ -19423,22 +21169,27 @@ inline void V1LayerParameter::clear_blobs() { blobs_.Clear(); } inline const ::caffe::BlobProto& V1LayerParameter::blobs(int index) const { + // @@protoc_insertion_point(field_get:caffe.V1LayerParameter.blobs) return blobs_.Get(index); } inline ::caffe::BlobProto* V1LayerParameter::mutable_blobs(int index) { + // @@protoc_insertion_point(field_mutable:caffe.V1LayerParameter.blobs) return blobs_.Mutable(index); } inline ::caffe::BlobProto* V1LayerParameter::add_blobs() { + // @@protoc_insertion_point(field_add:caffe.V1LayerParameter.blobs) return blobs_.Add(); } -inline const ::google::protobuf::RepeatedPtrField< ::caffe::BlobProto >& -V1LayerParameter::blobs() const { - return blobs_; -} inline ::google::protobuf::RepeatedPtrField< ::caffe::BlobProto >* V1LayerParameter::mutable_blobs() { + // @@protoc_insertion_point(field_mutable_list:caffe.V1LayerParameter.blobs) return &blobs_; } +inline const ::google::protobuf::RepeatedPtrField< ::caffe::BlobProto >& +V1LayerParameter::blobs() const { + // @@protoc_insertion_point(field_list:caffe.V1LayerParameter.blobs) + return blobs_; +} // repeated string param = 1001; inline int V1LayerParameter::param_size() const { @@ -19448,39 +21199,50 @@ inline void V1LayerParameter::clear_param() { param_.Clear(); } inline const ::std::string& V1LayerParameter::param(int index) const { + // @@protoc_insertion_point(field_get:caffe.V1LayerParameter.param) return param_.Get(index); } inline ::std::string* V1LayerParameter::mutable_param(int index) { + // @@protoc_insertion_point(field_mutable:caffe.V1LayerParameter.param) return param_.Mutable(index); } inline void V1LayerParameter::set_param(int index, const ::std::string& value) { + // @@protoc_insertion_point(field_set:caffe.V1LayerParameter.param) param_.Mutable(index)->assign(value); } inline void V1LayerParameter::set_param(int index, const char* value) { param_.Mutable(index)->assign(value); + // @@protoc_insertion_point(field_set_char:caffe.V1LayerParameter.param) } inline void V1LayerParameter::set_param(int index, const char* value, size_t size) { param_.Mutable(index)->assign( reinterpret_cast(value), size); + // @@protoc_insertion_point(field_set_pointer:caffe.V1LayerParameter.param) } inline ::std::string* V1LayerParameter::add_param() { + // @@protoc_insertion_point(field_add_mutable:caffe.V1LayerParameter.param) return param_.Add(); } inline void V1LayerParameter::add_param(const ::std::string& value) { param_.Add()->assign(value); + // @@protoc_insertion_point(field_add:caffe.V1LayerParameter.param) } inline void V1LayerParameter::add_param(const char* value) { param_.Add()->assign(value); + // @@protoc_insertion_point(field_add_char:caffe.V1LayerParameter.param) } inline void V1LayerParameter::add_param(const char* value, size_t size) { param_.Add()->assign(reinterpret_cast(value), size); + // @@protoc_insertion_point(field_add_pointer:caffe.V1LayerParameter.param) } inline const ::google::protobuf::RepeatedPtrField< ::std::string>& V1LayerParameter::param() const { + // @@protoc_insertion_point(field_list:caffe.V1LayerParameter.param) return param_; } inline ::google::protobuf::RepeatedPtrField< ::std::string>* V1LayerParameter::mutable_param() { + // @@protoc_insertion_point(field_mutable_list:caffe.V1LayerParameter.param) return ¶m_; } @@ -19492,22 +21254,27 @@ inline void V1LayerParameter::clear_blob_share_mode() { blob_share_mode_.Clear(); } inline ::caffe::V1LayerParameter_DimCheckMode V1LayerParameter::blob_share_mode(int index) const { + // @@protoc_insertion_point(field_get:caffe.V1LayerParameter.blob_share_mode) return static_cast< ::caffe::V1LayerParameter_DimCheckMode >(blob_share_mode_.Get(index)); } inline void V1LayerParameter::set_blob_share_mode(int index, ::caffe::V1LayerParameter_DimCheckMode value) { assert(::caffe::V1LayerParameter_DimCheckMode_IsValid(value)); blob_share_mode_.Set(index, value); + // @@protoc_insertion_point(field_set:caffe.V1LayerParameter.blob_share_mode) } inline void V1LayerParameter::add_blob_share_mode(::caffe::V1LayerParameter_DimCheckMode value) { assert(::caffe::V1LayerParameter_DimCheckMode_IsValid(value)); blob_share_mode_.Add(value); + // @@protoc_insertion_point(field_add:caffe.V1LayerParameter.blob_share_mode) } inline const ::google::protobuf::RepeatedField& V1LayerParameter::blob_share_mode() const { + // @@protoc_insertion_point(field_list:caffe.V1LayerParameter.blob_share_mode) return blob_share_mode_; } inline ::google::protobuf::RepeatedField* V1LayerParameter::mutable_blob_share_mode() { + // @@protoc_insertion_point(field_mutable_list:caffe.V1LayerParameter.blob_share_mode) return &blob_share_mode_; } @@ -19519,20 +21286,25 @@ inline void V1LayerParameter::clear_blobs_lr() { blobs_lr_.Clear(); } inline float V1LayerParameter::blobs_lr(int index) const { + // @@protoc_insertion_point(field_get:caffe.V1LayerParameter.blobs_lr) return blobs_lr_.Get(index); } inline void V1LayerParameter::set_blobs_lr(int index, float value) { blobs_lr_.Set(index, value); + // @@protoc_insertion_point(field_set:caffe.V1LayerParameter.blobs_lr) } inline void V1LayerParameter::add_blobs_lr(float value) { blobs_lr_.Add(value); + // @@protoc_insertion_point(field_add:caffe.V1LayerParameter.blobs_lr) } inline const ::google::protobuf::RepeatedField< float >& V1LayerParameter::blobs_lr() const { + // @@protoc_insertion_point(field_list:caffe.V1LayerParameter.blobs_lr) return blobs_lr_; } inline ::google::protobuf::RepeatedField< float >* V1LayerParameter::mutable_blobs_lr() { + // @@protoc_insertion_point(field_mutable_list:caffe.V1LayerParameter.blobs_lr) return &blobs_lr_; } @@ -19544,20 +21316,25 @@ inline void V1LayerParameter::clear_weight_decay() { weight_decay_.Clear(); } inline float V1LayerParameter::weight_decay(int index) const { + // @@protoc_insertion_point(field_get:caffe.V1LayerParameter.weight_decay) return weight_decay_.Get(index); } inline void V1LayerParameter::set_weight_decay(int index, float value) { weight_decay_.Set(index, value); + // @@protoc_insertion_point(field_set:caffe.V1LayerParameter.weight_decay) } inline void V1LayerParameter::add_weight_decay(float value) { weight_decay_.Add(value); + // @@protoc_insertion_point(field_add:caffe.V1LayerParameter.weight_decay) } inline const ::google::protobuf::RepeatedField< float >& V1LayerParameter::weight_decay() const { + // @@protoc_insertion_point(field_list:caffe.V1LayerParameter.weight_decay) return weight_decay_; } inline ::google::protobuf::RepeatedField< float >* V1LayerParameter::mutable_weight_decay() { + // @@protoc_insertion_point(field_mutable_list:caffe.V1LayerParameter.weight_decay) return &weight_decay_; } @@ -19569,20 +21346,25 @@ inline void V1LayerParameter::clear_loss_weight() { loss_weight_.Clear(); } inline float V1LayerParameter::loss_weight(int index) const { + // @@protoc_insertion_point(field_get:caffe.V1LayerParameter.loss_weight) return loss_weight_.Get(index); } inline void V1LayerParameter::set_loss_weight(int index, float value) { loss_weight_.Set(index, value); + // @@protoc_insertion_point(field_set:caffe.V1LayerParameter.loss_weight) } inline void V1LayerParameter::add_loss_weight(float value) { loss_weight_.Add(value); + // @@protoc_insertion_point(field_add:caffe.V1LayerParameter.loss_weight) } inline const ::google::protobuf::RepeatedField< float >& V1LayerParameter::loss_weight() const { + // @@protoc_insertion_point(field_list:caffe.V1LayerParameter.loss_weight) return loss_weight_; } inline ::google::protobuf::RepeatedField< float >* V1LayerParameter::mutable_loss_weight() { + // @@protoc_insertion_point(field_mutable_list:caffe.V1LayerParameter.loss_weight) return &loss_weight_; } @@ -19601,14 +21383,20 @@ inline void V1LayerParameter::clear_accuracy_param() { clear_has_accuracy_param(); } inline const ::caffe::AccuracyParameter& V1LayerParameter::accuracy_param() const { - return accuracy_param_ != NULL ? *accuracy_param_ : *default_instance_->accuracy_param_; + // @@protoc_insertion_point(field_get:caffe.V1LayerParameter.accuracy_param) + return accuracy_param_ != NULL ? *accuracy_param_ + : *::caffe::AccuracyParameter::internal_default_instance(); } inline ::caffe::AccuracyParameter* V1LayerParameter::mutable_accuracy_param() { set_has_accuracy_param(); - if (accuracy_param_ == NULL) accuracy_param_ = new ::caffe::AccuracyParameter; + if (accuracy_param_ == NULL) { + accuracy_param_ = new ::caffe::AccuracyParameter; + } + // @@protoc_insertion_point(field_mutable:caffe.V1LayerParameter.accuracy_param) return accuracy_param_; } inline ::caffe::AccuracyParameter* V1LayerParameter::release_accuracy_param() { + // @@protoc_insertion_point(field_release:caffe.V1LayerParameter.accuracy_param) clear_has_accuracy_param(); ::caffe::AccuracyParameter* temp = accuracy_param_; accuracy_param_ = NULL; @@ -19622,6 +21410,7 @@ inline void V1LayerParameter::set_allocated_accuracy_param(::caffe::AccuracyPara } else { clear_has_accuracy_param(); } + // @@protoc_insertion_point(field_set_allocated:caffe.V1LayerParameter.accuracy_param) } // optional .caffe.ArgMaxParameter argmax_param = 23; @@ -19639,14 +21428,20 @@ inline void V1LayerParameter::clear_argmax_param() { clear_has_argmax_param(); } inline const ::caffe::ArgMaxParameter& V1LayerParameter::argmax_param() const { - return argmax_param_ != NULL ? *argmax_param_ : *default_instance_->argmax_param_; + // @@protoc_insertion_point(field_get:caffe.V1LayerParameter.argmax_param) + return argmax_param_ != NULL ? *argmax_param_ + : *::caffe::ArgMaxParameter::internal_default_instance(); } inline ::caffe::ArgMaxParameter* V1LayerParameter::mutable_argmax_param() { set_has_argmax_param(); - if (argmax_param_ == NULL) argmax_param_ = new ::caffe::ArgMaxParameter; + if (argmax_param_ == NULL) { + argmax_param_ = new ::caffe::ArgMaxParameter; + } + // @@protoc_insertion_point(field_mutable:caffe.V1LayerParameter.argmax_param) return argmax_param_; } inline ::caffe::ArgMaxParameter* V1LayerParameter::release_argmax_param() { + // @@protoc_insertion_point(field_release:caffe.V1LayerParameter.argmax_param) clear_has_argmax_param(); ::caffe::ArgMaxParameter* temp = argmax_param_; argmax_param_ = NULL; @@ -19660,6 +21455,7 @@ inline void V1LayerParameter::set_allocated_argmax_param(::caffe::ArgMaxParamete } else { clear_has_argmax_param(); } + // @@protoc_insertion_point(field_set_allocated:caffe.V1LayerParameter.argmax_param) } // optional .caffe.ConcatParameter concat_param = 9; @@ -19677,14 +21473,20 @@ inline void V1LayerParameter::clear_concat_param() { clear_has_concat_param(); } inline const ::caffe::ConcatParameter& V1LayerParameter::concat_param() const { - return concat_param_ != NULL ? *concat_param_ : *default_instance_->concat_param_; + // @@protoc_insertion_point(field_get:caffe.V1LayerParameter.concat_param) + return concat_param_ != NULL ? *concat_param_ + : *::caffe::ConcatParameter::internal_default_instance(); } inline ::caffe::ConcatParameter* V1LayerParameter::mutable_concat_param() { set_has_concat_param(); - if (concat_param_ == NULL) concat_param_ = new ::caffe::ConcatParameter; + if (concat_param_ == NULL) { + concat_param_ = new ::caffe::ConcatParameter; + } + // @@protoc_insertion_point(field_mutable:caffe.V1LayerParameter.concat_param) return concat_param_; } inline ::caffe::ConcatParameter* V1LayerParameter::release_concat_param() { + // @@protoc_insertion_point(field_release:caffe.V1LayerParameter.concat_param) clear_has_concat_param(); ::caffe::ConcatParameter* temp = concat_param_; concat_param_ = NULL; @@ -19698,6 +21500,7 @@ inline void V1LayerParameter::set_allocated_concat_param(::caffe::ConcatParamete } else { clear_has_concat_param(); } + // @@protoc_insertion_point(field_set_allocated:caffe.V1LayerParameter.concat_param) } // optional .caffe.ContrastiveLossParameter contrastive_loss_param = 40; @@ -19715,14 +21518,20 @@ inline void V1LayerParameter::clear_contrastive_loss_param() { clear_has_contrastive_loss_param(); } inline const ::caffe::ContrastiveLossParameter& V1LayerParameter::contrastive_loss_param() const { - return contrastive_loss_param_ != NULL ? *contrastive_loss_param_ : *default_instance_->contrastive_loss_param_; + // @@protoc_insertion_point(field_get:caffe.V1LayerParameter.contrastive_loss_param) + return contrastive_loss_param_ != NULL ? *contrastive_loss_param_ + : *::caffe::ContrastiveLossParameter::internal_default_instance(); } inline ::caffe::ContrastiveLossParameter* V1LayerParameter::mutable_contrastive_loss_param() { set_has_contrastive_loss_param(); - if (contrastive_loss_param_ == NULL) contrastive_loss_param_ = new ::caffe::ContrastiveLossParameter; + if (contrastive_loss_param_ == NULL) { + contrastive_loss_param_ = new ::caffe::ContrastiveLossParameter; + } + // @@protoc_insertion_point(field_mutable:caffe.V1LayerParameter.contrastive_loss_param) return contrastive_loss_param_; } inline ::caffe::ContrastiveLossParameter* V1LayerParameter::release_contrastive_loss_param() { + // @@protoc_insertion_point(field_release:caffe.V1LayerParameter.contrastive_loss_param) clear_has_contrastive_loss_param(); ::caffe::ContrastiveLossParameter* temp = contrastive_loss_param_; contrastive_loss_param_ = NULL; @@ -19736,6 +21545,7 @@ inline void V1LayerParameter::set_allocated_contrastive_loss_param(::caffe::Cont } else { clear_has_contrastive_loss_param(); } + // @@protoc_insertion_point(field_set_allocated:caffe.V1LayerParameter.contrastive_loss_param) } // optional .caffe.ConvolutionParameter convolution_param = 10; @@ -19753,14 +21563,20 @@ inline void V1LayerParameter::clear_convolution_param() { clear_has_convolution_param(); } inline const ::caffe::ConvolutionParameter& V1LayerParameter::convolution_param() const { - return convolution_param_ != NULL ? *convolution_param_ : *default_instance_->convolution_param_; + // @@protoc_insertion_point(field_get:caffe.V1LayerParameter.convolution_param) + return convolution_param_ != NULL ? *convolution_param_ + : *::caffe::ConvolutionParameter::internal_default_instance(); } inline ::caffe::ConvolutionParameter* V1LayerParameter::mutable_convolution_param() { set_has_convolution_param(); - if (convolution_param_ == NULL) convolution_param_ = new ::caffe::ConvolutionParameter; + if (convolution_param_ == NULL) { + convolution_param_ = new ::caffe::ConvolutionParameter; + } + // @@protoc_insertion_point(field_mutable:caffe.V1LayerParameter.convolution_param) return convolution_param_; } inline ::caffe::ConvolutionParameter* V1LayerParameter::release_convolution_param() { + // @@protoc_insertion_point(field_release:caffe.V1LayerParameter.convolution_param) clear_has_convolution_param(); ::caffe::ConvolutionParameter* temp = convolution_param_; convolution_param_ = NULL; @@ -19774,6 +21590,7 @@ inline void V1LayerParameter::set_allocated_convolution_param(::caffe::Convoluti } else { clear_has_convolution_param(); } + // @@protoc_insertion_point(field_set_allocated:caffe.V1LayerParameter.convolution_param) } // optional .caffe.DataParameter data_param = 11; @@ -19791,14 +21608,20 @@ inline void V1LayerParameter::clear_data_param() { clear_has_data_param(); } inline const ::caffe::DataParameter& V1LayerParameter::data_param() const { - return data_param_ != NULL ? *data_param_ : *default_instance_->data_param_; + // @@protoc_insertion_point(field_get:caffe.V1LayerParameter.data_param) + return data_param_ != NULL ? *data_param_ + : *::caffe::DataParameter::internal_default_instance(); } inline ::caffe::DataParameter* V1LayerParameter::mutable_data_param() { set_has_data_param(); - if (data_param_ == NULL) data_param_ = new ::caffe::DataParameter; + if (data_param_ == NULL) { + data_param_ = new ::caffe::DataParameter; + } + // @@protoc_insertion_point(field_mutable:caffe.V1LayerParameter.data_param) return data_param_; } inline ::caffe::DataParameter* V1LayerParameter::release_data_param() { + // @@protoc_insertion_point(field_release:caffe.V1LayerParameter.data_param) clear_has_data_param(); ::caffe::DataParameter* temp = data_param_; data_param_ = NULL; @@ -19812,6 +21635,7 @@ inline void V1LayerParameter::set_allocated_data_param(::caffe::DataParameter* d } else { clear_has_data_param(); } + // @@protoc_insertion_point(field_set_allocated:caffe.V1LayerParameter.data_param) } // optional .caffe.DropoutParameter dropout_param = 12; @@ -19829,14 +21653,20 @@ inline void V1LayerParameter::clear_dropout_param() { clear_has_dropout_param(); } inline const ::caffe::DropoutParameter& V1LayerParameter::dropout_param() const { - return dropout_param_ != NULL ? *dropout_param_ : *default_instance_->dropout_param_; + // @@protoc_insertion_point(field_get:caffe.V1LayerParameter.dropout_param) + return dropout_param_ != NULL ? *dropout_param_ + : *::caffe::DropoutParameter::internal_default_instance(); } inline ::caffe::DropoutParameter* V1LayerParameter::mutable_dropout_param() { set_has_dropout_param(); - if (dropout_param_ == NULL) dropout_param_ = new ::caffe::DropoutParameter; + if (dropout_param_ == NULL) { + dropout_param_ = new ::caffe::DropoutParameter; + } + // @@protoc_insertion_point(field_mutable:caffe.V1LayerParameter.dropout_param) return dropout_param_; } inline ::caffe::DropoutParameter* V1LayerParameter::release_dropout_param() { + // @@protoc_insertion_point(field_release:caffe.V1LayerParameter.dropout_param) clear_has_dropout_param(); ::caffe::DropoutParameter* temp = dropout_param_; dropout_param_ = NULL; @@ -19850,6 +21680,7 @@ inline void V1LayerParameter::set_allocated_dropout_param(::caffe::DropoutParame } else { clear_has_dropout_param(); } + // @@protoc_insertion_point(field_set_allocated:caffe.V1LayerParameter.dropout_param) } // optional .caffe.DummyDataParameter dummy_data_param = 26; @@ -19867,14 +21698,20 @@ inline void V1LayerParameter::clear_dummy_data_param() { clear_has_dummy_data_param(); } inline const ::caffe::DummyDataParameter& V1LayerParameter::dummy_data_param() const { - return dummy_data_param_ != NULL ? *dummy_data_param_ : *default_instance_->dummy_data_param_; + // @@protoc_insertion_point(field_get:caffe.V1LayerParameter.dummy_data_param) + return dummy_data_param_ != NULL ? *dummy_data_param_ + : *::caffe::DummyDataParameter::internal_default_instance(); } inline ::caffe::DummyDataParameter* V1LayerParameter::mutable_dummy_data_param() { set_has_dummy_data_param(); - if (dummy_data_param_ == NULL) dummy_data_param_ = new ::caffe::DummyDataParameter; + if (dummy_data_param_ == NULL) { + dummy_data_param_ = new ::caffe::DummyDataParameter; + } + // @@protoc_insertion_point(field_mutable:caffe.V1LayerParameter.dummy_data_param) return dummy_data_param_; } inline ::caffe::DummyDataParameter* V1LayerParameter::release_dummy_data_param() { + // @@protoc_insertion_point(field_release:caffe.V1LayerParameter.dummy_data_param) clear_has_dummy_data_param(); ::caffe::DummyDataParameter* temp = dummy_data_param_; dummy_data_param_ = NULL; @@ -19888,6 +21725,7 @@ inline void V1LayerParameter::set_allocated_dummy_data_param(::caffe::DummyDataP } else { clear_has_dummy_data_param(); } + // @@protoc_insertion_point(field_set_allocated:caffe.V1LayerParameter.dummy_data_param) } // optional .caffe.EltwiseParameter eltwise_param = 24; @@ -19905,14 +21743,20 @@ inline void V1LayerParameter::clear_eltwise_param() { clear_has_eltwise_param(); } inline const ::caffe::EltwiseParameter& V1LayerParameter::eltwise_param() const { - return eltwise_param_ != NULL ? *eltwise_param_ : *default_instance_->eltwise_param_; + // @@protoc_insertion_point(field_get:caffe.V1LayerParameter.eltwise_param) + return eltwise_param_ != NULL ? *eltwise_param_ + : *::caffe::EltwiseParameter::internal_default_instance(); } inline ::caffe::EltwiseParameter* V1LayerParameter::mutable_eltwise_param() { set_has_eltwise_param(); - if (eltwise_param_ == NULL) eltwise_param_ = new ::caffe::EltwiseParameter; + if (eltwise_param_ == NULL) { + eltwise_param_ = new ::caffe::EltwiseParameter; + } + // @@protoc_insertion_point(field_mutable:caffe.V1LayerParameter.eltwise_param) return eltwise_param_; } inline ::caffe::EltwiseParameter* V1LayerParameter::release_eltwise_param() { + // @@protoc_insertion_point(field_release:caffe.V1LayerParameter.eltwise_param) clear_has_eltwise_param(); ::caffe::EltwiseParameter* temp = eltwise_param_; eltwise_param_ = NULL; @@ -19926,6 +21770,7 @@ inline void V1LayerParameter::set_allocated_eltwise_param(::caffe::EltwiseParame } else { clear_has_eltwise_param(); } + // @@protoc_insertion_point(field_set_allocated:caffe.V1LayerParameter.eltwise_param) } // optional .caffe.ExpParameter exp_param = 41; @@ -19943,14 +21788,20 @@ inline void V1LayerParameter::clear_exp_param() { clear_has_exp_param(); } inline const ::caffe::ExpParameter& V1LayerParameter::exp_param() const { - return exp_param_ != NULL ? *exp_param_ : *default_instance_->exp_param_; + // @@protoc_insertion_point(field_get:caffe.V1LayerParameter.exp_param) + return exp_param_ != NULL ? *exp_param_ + : *::caffe::ExpParameter::internal_default_instance(); } inline ::caffe::ExpParameter* V1LayerParameter::mutable_exp_param() { set_has_exp_param(); - if (exp_param_ == NULL) exp_param_ = new ::caffe::ExpParameter; + if (exp_param_ == NULL) { + exp_param_ = new ::caffe::ExpParameter; + } + // @@protoc_insertion_point(field_mutable:caffe.V1LayerParameter.exp_param) return exp_param_; } inline ::caffe::ExpParameter* V1LayerParameter::release_exp_param() { + // @@protoc_insertion_point(field_release:caffe.V1LayerParameter.exp_param) clear_has_exp_param(); ::caffe::ExpParameter* temp = exp_param_; exp_param_ = NULL; @@ -19964,6 +21815,7 @@ inline void V1LayerParameter::set_allocated_exp_param(::caffe::ExpParameter* exp } else { clear_has_exp_param(); } + // @@protoc_insertion_point(field_set_allocated:caffe.V1LayerParameter.exp_param) } // optional .caffe.HDF5DataParameter hdf5_data_param = 13; @@ -19981,14 +21833,20 @@ inline void V1LayerParameter::clear_hdf5_data_param() { clear_has_hdf5_data_param(); } inline const ::caffe::HDF5DataParameter& V1LayerParameter::hdf5_data_param() const { - return hdf5_data_param_ != NULL ? *hdf5_data_param_ : *default_instance_->hdf5_data_param_; + // @@protoc_insertion_point(field_get:caffe.V1LayerParameter.hdf5_data_param) + return hdf5_data_param_ != NULL ? *hdf5_data_param_ + : *::caffe::HDF5DataParameter::internal_default_instance(); } inline ::caffe::HDF5DataParameter* V1LayerParameter::mutable_hdf5_data_param() { set_has_hdf5_data_param(); - if (hdf5_data_param_ == NULL) hdf5_data_param_ = new ::caffe::HDF5DataParameter; + if (hdf5_data_param_ == NULL) { + hdf5_data_param_ = new ::caffe::HDF5DataParameter; + } + // @@protoc_insertion_point(field_mutable:caffe.V1LayerParameter.hdf5_data_param) return hdf5_data_param_; } inline ::caffe::HDF5DataParameter* V1LayerParameter::release_hdf5_data_param() { + // @@protoc_insertion_point(field_release:caffe.V1LayerParameter.hdf5_data_param) clear_has_hdf5_data_param(); ::caffe::HDF5DataParameter* temp = hdf5_data_param_; hdf5_data_param_ = NULL; @@ -20002,6 +21860,7 @@ inline void V1LayerParameter::set_allocated_hdf5_data_param(::caffe::HDF5DataPar } else { clear_has_hdf5_data_param(); } + // @@protoc_insertion_point(field_set_allocated:caffe.V1LayerParameter.hdf5_data_param) } // optional .caffe.HDF5OutputParameter hdf5_output_param = 14; @@ -20019,14 +21878,20 @@ inline void V1LayerParameter::clear_hdf5_output_param() { clear_has_hdf5_output_param(); } inline const ::caffe::HDF5OutputParameter& V1LayerParameter::hdf5_output_param() const { - return hdf5_output_param_ != NULL ? *hdf5_output_param_ : *default_instance_->hdf5_output_param_; + // @@protoc_insertion_point(field_get:caffe.V1LayerParameter.hdf5_output_param) + return hdf5_output_param_ != NULL ? *hdf5_output_param_ + : *::caffe::HDF5OutputParameter::internal_default_instance(); } inline ::caffe::HDF5OutputParameter* V1LayerParameter::mutable_hdf5_output_param() { set_has_hdf5_output_param(); - if (hdf5_output_param_ == NULL) hdf5_output_param_ = new ::caffe::HDF5OutputParameter; + if (hdf5_output_param_ == NULL) { + hdf5_output_param_ = new ::caffe::HDF5OutputParameter; + } + // @@protoc_insertion_point(field_mutable:caffe.V1LayerParameter.hdf5_output_param) return hdf5_output_param_; } inline ::caffe::HDF5OutputParameter* V1LayerParameter::release_hdf5_output_param() { + // @@protoc_insertion_point(field_release:caffe.V1LayerParameter.hdf5_output_param) clear_has_hdf5_output_param(); ::caffe::HDF5OutputParameter* temp = hdf5_output_param_; hdf5_output_param_ = NULL; @@ -20040,6 +21905,7 @@ inline void V1LayerParameter::set_allocated_hdf5_output_param(::caffe::HDF5Outpu } else { clear_has_hdf5_output_param(); } + // @@protoc_insertion_point(field_set_allocated:caffe.V1LayerParameter.hdf5_output_param) } // optional .caffe.HingeLossParameter hinge_loss_param = 29; @@ -20057,14 +21923,20 @@ inline void V1LayerParameter::clear_hinge_loss_param() { clear_has_hinge_loss_param(); } inline const ::caffe::HingeLossParameter& V1LayerParameter::hinge_loss_param() const { - return hinge_loss_param_ != NULL ? *hinge_loss_param_ : *default_instance_->hinge_loss_param_; + // @@protoc_insertion_point(field_get:caffe.V1LayerParameter.hinge_loss_param) + return hinge_loss_param_ != NULL ? *hinge_loss_param_ + : *::caffe::HingeLossParameter::internal_default_instance(); } inline ::caffe::HingeLossParameter* V1LayerParameter::mutable_hinge_loss_param() { set_has_hinge_loss_param(); - if (hinge_loss_param_ == NULL) hinge_loss_param_ = new ::caffe::HingeLossParameter; + if (hinge_loss_param_ == NULL) { + hinge_loss_param_ = new ::caffe::HingeLossParameter; + } + // @@protoc_insertion_point(field_mutable:caffe.V1LayerParameter.hinge_loss_param) return hinge_loss_param_; } inline ::caffe::HingeLossParameter* V1LayerParameter::release_hinge_loss_param() { + // @@protoc_insertion_point(field_release:caffe.V1LayerParameter.hinge_loss_param) clear_has_hinge_loss_param(); ::caffe::HingeLossParameter* temp = hinge_loss_param_; hinge_loss_param_ = NULL; @@ -20078,6 +21950,7 @@ inline void V1LayerParameter::set_allocated_hinge_loss_param(::caffe::HingeLossP } else { clear_has_hinge_loss_param(); } + // @@protoc_insertion_point(field_set_allocated:caffe.V1LayerParameter.hinge_loss_param) } // optional .caffe.ImageDataParameter image_data_param = 15; @@ -20095,14 +21968,20 @@ inline void V1LayerParameter::clear_image_data_param() { clear_has_image_data_param(); } inline const ::caffe::ImageDataParameter& V1LayerParameter::image_data_param() const { - return image_data_param_ != NULL ? *image_data_param_ : *default_instance_->image_data_param_; + // @@protoc_insertion_point(field_get:caffe.V1LayerParameter.image_data_param) + return image_data_param_ != NULL ? *image_data_param_ + : *::caffe::ImageDataParameter::internal_default_instance(); } inline ::caffe::ImageDataParameter* V1LayerParameter::mutable_image_data_param() { set_has_image_data_param(); - if (image_data_param_ == NULL) image_data_param_ = new ::caffe::ImageDataParameter; + if (image_data_param_ == NULL) { + image_data_param_ = new ::caffe::ImageDataParameter; + } + // @@protoc_insertion_point(field_mutable:caffe.V1LayerParameter.image_data_param) return image_data_param_; } inline ::caffe::ImageDataParameter* V1LayerParameter::release_image_data_param() { + // @@protoc_insertion_point(field_release:caffe.V1LayerParameter.image_data_param) clear_has_image_data_param(); ::caffe::ImageDataParameter* temp = image_data_param_; image_data_param_ = NULL; @@ -20116,6 +21995,7 @@ inline void V1LayerParameter::set_allocated_image_data_param(::caffe::ImageDataP } else { clear_has_image_data_param(); } + // @@protoc_insertion_point(field_set_allocated:caffe.V1LayerParameter.image_data_param) } // optional .caffe.InfogainLossParameter infogain_loss_param = 16; @@ -20133,14 +22013,20 @@ inline void V1LayerParameter::clear_infogain_loss_param() { clear_has_infogain_loss_param(); } inline const ::caffe::InfogainLossParameter& V1LayerParameter::infogain_loss_param() const { - return infogain_loss_param_ != NULL ? *infogain_loss_param_ : *default_instance_->infogain_loss_param_; + // @@protoc_insertion_point(field_get:caffe.V1LayerParameter.infogain_loss_param) + return infogain_loss_param_ != NULL ? *infogain_loss_param_ + : *::caffe::InfogainLossParameter::internal_default_instance(); } inline ::caffe::InfogainLossParameter* V1LayerParameter::mutable_infogain_loss_param() { set_has_infogain_loss_param(); - if (infogain_loss_param_ == NULL) infogain_loss_param_ = new ::caffe::InfogainLossParameter; + if (infogain_loss_param_ == NULL) { + infogain_loss_param_ = new ::caffe::InfogainLossParameter; + } + // @@protoc_insertion_point(field_mutable:caffe.V1LayerParameter.infogain_loss_param) return infogain_loss_param_; } inline ::caffe::InfogainLossParameter* V1LayerParameter::release_infogain_loss_param() { + // @@protoc_insertion_point(field_release:caffe.V1LayerParameter.infogain_loss_param) clear_has_infogain_loss_param(); ::caffe::InfogainLossParameter* temp = infogain_loss_param_; infogain_loss_param_ = NULL; @@ -20154,6 +22040,7 @@ inline void V1LayerParameter::set_allocated_infogain_loss_param(::caffe::Infogai } else { clear_has_infogain_loss_param(); } + // @@protoc_insertion_point(field_set_allocated:caffe.V1LayerParameter.infogain_loss_param) } // optional .caffe.InnerProductParameter inner_product_param = 17; @@ -20171,14 +22058,20 @@ inline void V1LayerParameter::clear_inner_product_param() { clear_has_inner_product_param(); } inline const ::caffe::InnerProductParameter& V1LayerParameter::inner_product_param() const { - return inner_product_param_ != NULL ? *inner_product_param_ : *default_instance_->inner_product_param_; + // @@protoc_insertion_point(field_get:caffe.V1LayerParameter.inner_product_param) + return inner_product_param_ != NULL ? *inner_product_param_ + : *::caffe::InnerProductParameter::internal_default_instance(); } inline ::caffe::InnerProductParameter* V1LayerParameter::mutable_inner_product_param() { set_has_inner_product_param(); - if (inner_product_param_ == NULL) inner_product_param_ = new ::caffe::InnerProductParameter; + if (inner_product_param_ == NULL) { + inner_product_param_ = new ::caffe::InnerProductParameter; + } + // @@protoc_insertion_point(field_mutable:caffe.V1LayerParameter.inner_product_param) return inner_product_param_; } inline ::caffe::InnerProductParameter* V1LayerParameter::release_inner_product_param() { + // @@protoc_insertion_point(field_release:caffe.V1LayerParameter.inner_product_param) clear_has_inner_product_param(); ::caffe::InnerProductParameter* temp = inner_product_param_; inner_product_param_ = NULL; @@ -20192,6 +22085,7 @@ inline void V1LayerParameter::set_allocated_inner_product_param(::caffe::InnerPr } else { clear_has_inner_product_param(); } + // @@protoc_insertion_point(field_set_allocated:caffe.V1LayerParameter.inner_product_param) } // optional .caffe.LRNParameter lrn_param = 18; @@ -20209,14 +22103,20 @@ inline void V1LayerParameter::clear_lrn_param() { clear_has_lrn_param(); } inline const ::caffe::LRNParameter& V1LayerParameter::lrn_param() const { - return lrn_param_ != NULL ? *lrn_param_ : *default_instance_->lrn_param_; + // @@protoc_insertion_point(field_get:caffe.V1LayerParameter.lrn_param) + return lrn_param_ != NULL ? *lrn_param_ + : *::caffe::LRNParameter::internal_default_instance(); } inline ::caffe::LRNParameter* V1LayerParameter::mutable_lrn_param() { set_has_lrn_param(); - if (lrn_param_ == NULL) lrn_param_ = new ::caffe::LRNParameter; + if (lrn_param_ == NULL) { + lrn_param_ = new ::caffe::LRNParameter; + } + // @@protoc_insertion_point(field_mutable:caffe.V1LayerParameter.lrn_param) return lrn_param_; } inline ::caffe::LRNParameter* V1LayerParameter::release_lrn_param() { + // @@protoc_insertion_point(field_release:caffe.V1LayerParameter.lrn_param) clear_has_lrn_param(); ::caffe::LRNParameter* temp = lrn_param_; lrn_param_ = NULL; @@ -20230,6 +22130,7 @@ inline void V1LayerParameter::set_allocated_lrn_param(::caffe::LRNParameter* lrn } else { clear_has_lrn_param(); } + // @@protoc_insertion_point(field_set_allocated:caffe.V1LayerParameter.lrn_param) } // optional .caffe.MemoryDataParameter memory_data_param = 22; @@ -20247,14 +22148,20 @@ inline void V1LayerParameter::clear_memory_data_param() { clear_has_memory_data_param(); } inline const ::caffe::MemoryDataParameter& V1LayerParameter::memory_data_param() const { - return memory_data_param_ != NULL ? *memory_data_param_ : *default_instance_->memory_data_param_; + // @@protoc_insertion_point(field_get:caffe.V1LayerParameter.memory_data_param) + return memory_data_param_ != NULL ? *memory_data_param_ + : *::caffe::MemoryDataParameter::internal_default_instance(); } inline ::caffe::MemoryDataParameter* V1LayerParameter::mutable_memory_data_param() { set_has_memory_data_param(); - if (memory_data_param_ == NULL) memory_data_param_ = new ::caffe::MemoryDataParameter; + if (memory_data_param_ == NULL) { + memory_data_param_ = new ::caffe::MemoryDataParameter; + } + // @@protoc_insertion_point(field_mutable:caffe.V1LayerParameter.memory_data_param) return memory_data_param_; } inline ::caffe::MemoryDataParameter* V1LayerParameter::release_memory_data_param() { + // @@protoc_insertion_point(field_release:caffe.V1LayerParameter.memory_data_param) clear_has_memory_data_param(); ::caffe::MemoryDataParameter* temp = memory_data_param_; memory_data_param_ = NULL; @@ -20268,6 +22175,7 @@ inline void V1LayerParameter::set_allocated_memory_data_param(::caffe::MemoryDat } else { clear_has_memory_data_param(); } + // @@protoc_insertion_point(field_set_allocated:caffe.V1LayerParameter.memory_data_param) } // optional .caffe.MVNParameter mvn_param = 34; @@ -20285,14 +22193,20 @@ inline void V1LayerParameter::clear_mvn_param() { clear_has_mvn_param(); } inline const ::caffe::MVNParameter& V1LayerParameter::mvn_param() const { - return mvn_param_ != NULL ? *mvn_param_ : *default_instance_->mvn_param_; + // @@protoc_insertion_point(field_get:caffe.V1LayerParameter.mvn_param) + return mvn_param_ != NULL ? *mvn_param_ + : *::caffe::MVNParameter::internal_default_instance(); } inline ::caffe::MVNParameter* V1LayerParameter::mutable_mvn_param() { set_has_mvn_param(); - if (mvn_param_ == NULL) mvn_param_ = new ::caffe::MVNParameter; + if (mvn_param_ == NULL) { + mvn_param_ = new ::caffe::MVNParameter; + } + // @@protoc_insertion_point(field_mutable:caffe.V1LayerParameter.mvn_param) return mvn_param_; } inline ::caffe::MVNParameter* V1LayerParameter::release_mvn_param() { + // @@protoc_insertion_point(field_release:caffe.V1LayerParameter.mvn_param) clear_has_mvn_param(); ::caffe::MVNParameter* temp = mvn_param_; mvn_param_ = NULL; @@ -20306,6 +22220,7 @@ inline void V1LayerParameter::set_allocated_mvn_param(::caffe::MVNParameter* mvn } else { clear_has_mvn_param(); } + // @@protoc_insertion_point(field_set_allocated:caffe.V1LayerParameter.mvn_param) } // optional .caffe.PoolingParameter pooling_param = 19; @@ -20323,14 +22238,20 @@ inline void V1LayerParameter::clear_pooling_param() { clear_has_pooling_param(); } inline const ::caffe::PoolingParameter& V1LayerParameter::pooling_param() const { - return pooling_param_ != NULL ? *pooling_param_ : *default_instance_->pooling_param_; + // @@protoc_insertion_point(field_get:caffe.V1LayerParameter.pooling_param) + return pooling_param_ != NULL ? *pooling_param_ + : *::caffe::PoolingParameter::internal_default_instance(); } inline ::caffe::PoolingParameter* V1LayerParameter::mutable_pooling_param() { set_has_pooling_param(); - if (pooling_param_ == NULL) pooling_param_ = new ::caffe::PoolingParameter; + if (pooling_param_ == NULL) { + pooling_param_ = new ::caffe::PoolingParameter; + } + // @@protoc_insertion_point(field_mutable:caffe.V1LayerParameter.pooling_param) return pooling_param_; } inline ::caffe::PoolingParameter* V1LayerParameter::release_pooling_param() { + // @@protoc_insertion_point(field_release:caffe.V1LayerParameter.pooling_param) clear_has_pooling_param(); ::caffe::PoolingParameter* temp = pooling_param_; pooling_param_ = NULL; @@ -20344,6 +22265,7 @@ inline void V1LayerParameter::set_allocated_pooling_param(::caffe::PoolingParame } else { clear_has_pooling_param(); } + // @@protoc_insertion_point(field_set_allocated:caffe.V1LayerParameter.pooling_param) } // optional .caffe.PowerParameter power_param = 21; @@ -20361,14 +22283,20 @@ inline void V1LayerParameter::clear_power_param() { clear_has_power_param(); } inline const ::caffe::PowerParameter& V1LayerParameter::power_param() const { - return power_param_ != NULL ? *power_param_ : *default_instance_->power_param_; + // @@protoc_insertion_point(field_get:caffe.V1LayerParameter.power_param) + return power_param_ != NULL ? *power_param_ + : *::caffe::PowerParameter::internal_default_instance(); } inline ::caffe::PowerParameter* V1LayerParameter::mutable_power_param() { set_has_power_param(); - if (power_param_ == NULL) power_param_ = new ::caffe::PowerParameter; + if (power_param_ == NULL) { + power_param_ = new ::caffe::PowerParameter; + } + // @@protoc_insertion_point(field_mutable:caffe.V1LayerParameter.power_param) return power_param_; } inline ::caffe::PowerParameter* V1LayerParameter::release_power_param() { + // @@protoc_insertion_point(field_release:caffe.V1LayerParameter.power_param) clear_has_power_param(); ::caffe::PowerParameter* temp = power_param_; power_param_ = NULL; @@ -20382,6 +22310,7 @@ inline void V1LayerParameter::set_allocated_power_param(::caffe::PowerParameter* } else { clear_has_power_param(); } + // @@protoc_insertion_point(field_set_allocated:caffe.V1LayerParameter.power_param) } // optional .caffe.ReLUParameter relu_param = 30; @@ -20399,14 +22328,20 @@ inline void V1LayerParameter::clear_relu_param() { clear_has_relu_param(); } inline const ::caffe::ReLUParameter& V1LayerParameter::relu_param() const { - return relu_param_ != NULL ? *relu_param_ : *default_instance_->relu_param_; + // @@protoc_insertion_point(field_get:caffe.V1LayerParameter.relu_param) + return relu_param_ != NULL ? *relu_param_ + : *::caffe::ReLUParameter::internal_default_instance(); } inline ::caffe::ReLUParameter* V1LayerParameter::mutable_relu_param() { set_has_relu_param(); - if (relu_param_ == NULL) relu_param_ = new ::caffe::ReLUParameter; + if (relu_param_ == NULL) { + relu_param_ = new ::caffe::ReLUParameter; + } + // @@protoc_insertion_point(field_mutable:caffe.V1LayerParameter.relu_param) return relu_param_; } inline ::caffe::ReLUParameter* V1LayerParameter::release_relu_param() { + // @@protoc_insertion_point(field_release:caffe.V1LayerParameter.relu_param) clear_has_relu_param(); ::caffe::ReLUParameter* temp = relu_param_; relu_param_ = NULL; @@ -20420,6 +22355,7 @@ inline void V1LayerParameter::set_allocated_relu_param(::caffe::ReLUParameter* r } else { clear_has_relu_param(); } + // @@protoc_insertion_point(field_set_allocated:caffe.V1LayerParameter.relu_param) } // optional .caffe.SigmoidParameter sigmoid_param = 38; @@ -20437,14 +22373,20 @@ inline void V1LayerParameter::clear_sigmoid_param() { clear_has_sigmoid_param(); } inline const ::caffe::SigmoidParameter& V1LayerParameter::sigmoid_param() const { - return sigmoid_param_ != NULL ? *sigmoid_param_ : *default_instance_->sigmoid_param_; + // @@protoc_insertion_point(field_get:caffe.V1LayerParameter.sigmoid_param) + return sigmoid_param_ != NULL ? *sigmoid_param_ + : *::caffe::SigmoidParameter::internal_default_instance(); } inline ::caffe::SigmoidParameter* V1LayerParameter::mutable_sigmoid_param() { set_has_sigmoid_param(); - if (sigmoid_param_ == NULL) sigmoid_param_ = new ::caffe::SigmoidParameter; + if (sigmoid_param_ == NULL) { + sigmoid_param_ = new ::caffe::SigmoidParameter; + } + // @@protoc_insertion_point(field_mutable:caffe.V1LayerParameter.sigmoid_param) return sigmoid_param_; } inline ::caffe::SigmoidParameter* V1LayerParameter::release_sigmoid_param() { + // @@protoc_insertion_point(field_release:caffe.V1LayerParameter.sigmoid_param) clear_has_sigmoid_param(); ::caffe::SigmoidParameter* temp = sigmoid_param_; sigmoid_param_ = NULL; @@ -20458,6 +22400,7 @@ inline void V1LayerParameter::set_allocated_sigmoid_param(::caffe::SigmoidParame } else { clear_has_sigmoid_param(); } + // @@protoc_insertion_point(field_set_allocated:caffe.V1LayerParameter.sigmoid_param) } // optional .caffe.SoftmaxParameter softmax_param = 39; @@ -20475,14 +22418,20 @@ inline void V1LayerParameter::clear_softmax_param() { clear_has_softmax_param(); } inline const ::caffe::SoftmaxParameter& V1LayerParameter::softmax_param() const { - return softmax_param_ != NULL ? *softmax_param_ : *default_instance_->softmax_param_; + // @@protoc_insertion_point(field_get:caffe.V1LayerParameter.softmax_param) + return softmax_param_ != NULL ? *softmax_param_ + : *::caffe::SoftmaxParameter::internal_default_instance(); } inline ::caffe::SoftmaxParameter* V1LayerParameter::mutable_softmax_param() { set_has_softmax_param(); - if (softmax_param_ == NULL) softmax_param_ = new ::caffe::SoftmaxParameter; + if (softmax_param_ == NULL) { + softmax_param_ = new ::caffe::SoftmaxParameter; + } + // @@protoc_insertion_point(field_mutable:caffe.V1LayerParameter.softmax_param) return softmax_param_; } inline ::caffe::SoftmaxParameter* V1LayerParameter::release_softmax_param() { + // @@protoc_insertion_point(field_release:caffe.V1LayerParameter.softmax_param) clear_has_softmax_param(); ::caffe::SoftmaxParameter* temp = softmax_param_; softmax_param_ = NULL; @@ -20496,6 +22445,7 @@ inline void V1LayerParameter::set_allocated_softmax_param(::caffe::SoftmaxParame } else { clear_has_softmax_param(); } + // @@protoc_insertion_point(field_set_allocated:caffe.V1LayerParameter.softmax_param) } // optional .caffe.SliceParameter slice_param = 31; @@ -20513,14 +22463,20 @@ inline void V1LayerParameter::clear_slice_param() { clear_has_slice_param(); } inline const ::caffe::SliceParameter& V1LayerParameter::slice_param() const { - return slice_param_ != NULL ? *slice_param_ : *default_instance_->slice_param_; + // @@protoc_insertion_point(field_get:caffe.V1LayerParameter.slice_param) + return slice_param_ != NULL ? *slice_param_ + : *::caffe::SliceParameter::internal_default_instance(); } inline ::caffe::SliceParameter* V1LayerParameter::mutable_slice_param() { set_has_slice_param(); - if (slice_param_ == NULL) slice_param_ = new ::caffe::SliceParameter; + if (slice_param_ == NULL) { + slice_param_ = new ::caffe::SliceParameter; + } + // @@protoc_insertion_point(field_mutable:caffe.V1LayerParameter.slice_param) return slice_param_; } inline ::caffe::SliceParameter* V1LayerParameter::release_slice_param() { + // @@protoc_insertion_point(field_release:caffe.V1LayerParameter.slice_param) clear_has_slice_param(); ::caffe::SliceParameter* temp = slice_param_; slice_param_ = NULL; @@ -20534,6 +22490,7 @@ inline void V1LayerParameter::set_allocated_slice_param(::caffe::SliceParameter* } else { clear_has_slice_param(); } + // @@protoc_insertion_point(field_set_allocated:caffe.V1LayerParameter.slice_param) } // optional .caffe.TanHParameter tanh_param = 37; @@ -20551,14 +22508,20 @@ inline void V1LayerParameter::clear_tanh_param() { clear_has_tanh_param(); } inline const ::caffe::TanHParameter& V1LayerParameter::tanh_param() const { - return tanh_param_ != NULL ? *tanh_param_ : *default_instance_->tanh_param_; + // @@protoc_insertion_point(field_get:caffe.V1LayerParameter.tanh_param) + return tanh_param_ != NULL ? *tanh_param_ + : *::caffe::TanHParameter::internal_default_instance(); } inline ::caffe::TanHParameter* V1LayerParameter::mutable_tanh_param() { set_has_tanh_param(); - if (tanh_param_ == NULL) tanh_param_ = new ::caffe::TanHParameter; + if (tanh_param_ == NULL) { + tanh_param_ = new ::caffe::TanHParameter; + } + // @@protoc_insertion_point(field_mutable:caffe.V1LayerParameter.tanh_param) return tanh_param_; } inline ::caffe::TanHParameter* V1LayerParameter::release_tanh_param() { + // @@protoc_insertion_point(field_release:caffe.V1LayerParameter.tanh_param) clear_has_tanh_param(); ::caffe::TanHParameter* temp = tanh_param_; tanh_param_ = NULL; @@ -20572,6 +22535,7 @@ inline void V1LayerParameter::set_allocated_tanh_param(::caffe::TanHParameter* t } else { clear_has_tanh_param(); } + // @@protoc_insertion_point(field_set_allocated:caffe.V1LayerParameter.tanh_param) } // optional .caffe.ThresholdParameter threshold_param = 25; @@ -20589,14 +22553,20 @@ inline void V1LayerParameter::clear_threshold_param() { clear_has_threshold_param(); } inline const ::caffe::ThresholdParameter& V1LayerParameter::threshold_param() const { - return threshold_param_ != NULL ? *threshold_param_ : *default_instance_->threshold_param_; + // @@protoc_insertion_point(field_get:caffe.V1LayerParameter.threshold_param) + return threshold_param_ != NULL ? *threshold_param_ + : *::caffe::ThresholdParameter::internal_default_instance(); } inline ::caffe::ThresholdParameter* V1LayerParameter::mutable_threshold_param() { set_has_threshold_param(); - if (threshold_param_ == NULL) threshold_param_ = new ::caffe::ThresholdParameter; + if (threshold_param_ == NULL) { + threshold_param_ = new ::caffe::ThresholdParameter; + } + // @@protoc_insertion_point(field_mutable:caffe.V1LayerParameter.threshold_param) return threshold_param_; } inline ::caffe::ThresholdParameter* V1LayerParameter::release_threshold_param() { + // @@protoc_insertion_point(field_release:caffe.V1LayerParameter.threshold_param) clear_has_threshold_param(); ::caffe::ThresholdParameter* temp = threshold_param_; threshold_param_ = NULL; @@ -20610,6 +22580,7 @@ inline void V1LayerParameter::set_allocated_threshold_param(::caffe::ThresholdPa } else { clear_has_threshold_param(); } + // @@protoc_insertion_point(field_set_allocated:caffe.V1LayerParameter.threshold_param) } // optional .caffe.WindowDataParameter window_data_param = 20; @@ -20627,14 +22598,20 @@ inline void V1LayerParameter::clear_window_data_param() { clear_has_window_data_param(); } inline const ::caffe::WindowDataParameter& V1LayerParameter::window_data_param() const { - return window_data_param_ != NULL ? *window_data_param_ : *default_instance_->window_data_param_; + // @@protoc_insertion_point(field_get:caffe.V1LayerParameter.window_data_param) + return window_data_param_ != NULL ? *window_data_param_ + : *::caffe::WindowDataParameter::internal_default_instance(); } inline ::caffe::WindowDataParameter* V1LayerParameter::mutable_window_data_param() { set_has_window_data_param(); - if (window_data_param_ == NULL) window_data_param_ = new ::caffe::WindowDataParameter; + if (window_data_param_ == NULL) { + window_data_param_ = new ::caffe::WindowDataParameter; + } + // @@protoc_insertion_point(field_mutable:caffe.V1LayerParameter.window_data_param) return window_data_param_; } inline ::caffe::WindowDataParameter* V1LayerParameter::release_window_data_param() { + // @@protoc_insertion_point(field_release:caffe.V1LayerParameter.window_data_param) clear_has_window_data_param(); ::caffe::WindowDataParameter* temp = window_data_param_; window_data_param_ = NULL; @@ -20648,6 +22625,7 @@ inline void V1LayerParameter::set_allocated_window_data_param(::caffe::WindowDat } else { clear_has_window_data_param(); } + // @@protoc_insertion_point(field_set_allocated:caffe.V1LayerParameter.window_data_param) } // optional .caffe.TransformationParameter transform_param = 36; @@ -20665,14 +22643,20 @@ inline void V1LayerParameter::clear_transform_param() { clear_has_transform_param(); } inline const ::caffe::TransformationParameter& V1LayerParameter::transform_param() const { - return transform_param_ != NULL ? *transform_param_ : *default_instance_->transform_param_; + // @@protoc_insertion_point(field_get:caffe.V1LayerParameter.transform_param) + return transform_param_ != NULL ? *transform_param_ + : *::caffe::TransformationParameter::internal_default_instance(); } inline ::caffe::TransformationParameter* V1LayerParameter::mutable_transform_param() { set_has_transform_param(); - if (transform_param_ == NULL) transform_param_ = new ::caffe::TransformationParameter; + if (transform_param_ == NULL) { + transform_param_ = new ::caffe::TransformationParameter; + } + // @@protoc_insertion_point(field_mutable:caffe.V1LayerParameter.transform_param) return transform_param_; } inline ::caffe::TransformationParameter* V1LayerParameter::release_transform_param() { + // @@protoc_insertion_point(field_release:caffe.V1LayerParameter.transform_param) clear_has_transform_param(); ::caffe::TransformationParameter* temp = transform_param_; transform_param_ = NULL; @@ -20686,6 +22670,7 @@ inline void V1LayerParameter::set_allocated_transform_param(::caffe::Transformat } else { clear_has_transform_param(); } + // @@protoc_insertion_point(field_set_allocated:caffe.V1LayerParameter.transform_param) } // optional .caffe.LossParameter loss_param = 42; @@ -20703,14 +22688,20 @@ inline void V1LayerParameter::clear_loss_param() { clear_has_loss_param(); } inline const ::caffe::LossParameter& V1LayerParameter::loss_param() const { - return loss_param_ != NULL ? *loss_param_ : *default_instance_->loss_param_; + // @@protoc_insertion_point(field_get:caffe.V1LayerParameter.loss_param) + return loss_param_ != NULL ? *loss_param_ + : *::caffe::LossParameter::internal_default_instance(); } inline ::caffe::LossParameter* V1LayerParameter::mutable_loss_param() { set_has_loss_param(); - if (loss_param_ == NULL) loss_param_ = new ::caffe::LossParameter; + if (loss_param_ == NULL) { + loss_param_ = new ::caffe::LossParameter; + } + // @@protoc_insertion_point(field_mutable:caffe.V1LayerParameter.loss_param) return loss_param_; } inline ::caffe::LossParameter* V1LayerParameter::release_loss_param() { + // @@protoc_insertion_point(field_release:caffe.V1LayerParameter.loss_param) clear_has_loss_param(); ::caffe::LossParameter* temp = loss_param_; loss_param_ = NULL; @@ -20724,6 +22715,7 @@ inline void V1LayerParameter::set_allocated_loss_param(::caffe::LossParameter* l } else { clear_has_loss_param(); } + // @@protoc_insertion_point(field_set_allocated:caffe.V1LayerParameter.loss_param) } // optional .caffe.V0LayerParameter layer = 1; @@ -20741,14 +22733,20 @@ inline void V1LayerParameter::clear_layer() { clear_has_layer(); } inline const ::caffe::V0LayerParameter& V1LayerParameter::layer() const { - return layer_ != NULL ? *layer_ : *default_instance_->layer_; + // @@protoc_insertion_point(field_get:caffe.V1LayerParameter.layer) + return layer_ != NULL ? *layer_ + : *::caffe::V0LayerParameter::internal_default_instance(); } inline ::caffe::V0LayerParameter* V1LayerParameter::mutable_layer() { set_has_layer(); - if (layer_ == NULL) layer_ = new ::caffe::V0LayerParameter; + if (layer_ == NULL) { + layer_ = new ::caffe::V0LayerParameter; + } + // @@protoc_insertion_point(field_mutable:caffe.V1LayerParameter.layer) return layer_; } inline ::caffe::V0LayerParameter* V1LayerParameter::release_layer() { + // @@protoc_insertion_point(field_release:caffe.V1LayerParameter.layer) clear_has_layer(); ::caffe::V0LayerParameter* temp = layer_; layer_ = NULL; @@ -20762,8 +22760,12 @@ inline void V1LayerParameter::set_allocated_layer(::caffe::V0LayerParameter* lay } else { clear_has_layer(); } + // @@protoc_insertion_point(field_set_allocated:caffe.V1LayerParameter.layer) } +inline const V1LayerParameter* V1LayerParameter::internal_default_instance() { + return &V1LayerParameter_default_instance_.get(); +} // ------------------------------------------------------------------- // V0LayerParameter @@ -20779,63 +22781,47 @@ inline void V0LayerParameter::clear_has_name() { _has_bits_[0] &= ~0x00000001u; } inline void V0LayerParameter::clear_name() { - if (name_ != &::google::protobuf::internal::kEmptyString) { - name_->clear(); - } + name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); clear_has_name(); } inline const ::std::string& V0LayerParameter::name() const { - return *name_; + // @@protoc_insertion_point(field_get:caffe.V0LayerParameter.name) + return name_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } inline void V0LayerParameter::set_name(const ::std::string& value) { set_has_name(); - if (name_ == &::google::protobuf::internal::kEmptyString) { - name_ = new ::std::string; - } - name_->assign(value); + name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); + // @@protoc_insertion_point(field_set:caffe.V0LayerParameter.name) } inline void V0LayerParameter::set_name(const char* value) { set_has_name(); - if (name_ == &::google::protobuf::internal::kEmptyString) { - name_ = new ::std::string; - } - name_->assign(value); + name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); + // @@protoc_insertion_point(field_set_char:caffe.V0LayerParameter.name) } inline void V0LayerParameter::set_name(const char* value, size_t size) { set_has_name(); - if (name_ == &::google::protobuf::internal::kEmptyString) { - name_ = new ::std::string; - } - name_->assign(reinterpret_cast(value), size); + name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), + ::std::string(reinterpret_cast(value), size)); + // @@protoc_insertion_point(field_set_pointer:caffe.V0LayerParameter.name) } inline ::std::string* V0LayerParameter::mutable_name() { set_has_name(); - if (name_ == &::google::protobuf::internal::kEmptyString) { - name_ = new ::std::string; - } - return name_; + // @@protoc_insertion_point(field_mutable:caffe.V0LayerParameter.name) + return name_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } inline ::std::string* V0LayerParameter::release_name() { + // @@protoc_insertion_point(field_release:caffe.V0LayerParameter.name) clear_has_name(); - if (name_ == &::google::protobuf::internal::kEmptyString) { - return NULL; - } else { - ::std::string* temp = name_; - name_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); - return temp; - } + return name_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } inline void V0LayerParameter::set_allocated_name(::std::string* name) { - if (name_ != &::google::protobuf::internal::kEmptyString) { - delete name_; - } - if (name) { + if (name != NULL) { set_has_name(); - name_ = name; } else { clear_has_name(); - name_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); } + name_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), name); + // @@protoc_insertion_point(field_set_allocated:caffe.V0LayerParameter.name) } // optional string type = 2; @@ -20849,63 +22835,47 @@ inline void V0LayerParameter::clear_has_type() { _has_bits_[0] &= ~0x00000002u; } inline void V0LayerParameter::clear_type() { - if (type_ != &::google::protobuf::internal::kEmptyString) { - type_->clear(); - } + type_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); clear_has_type(); } inline const ::std::string& V0LayerParameter::type() const { - return *type_; + // @@protoc_insertion_point(field_get:caffe.V0LayerParameter.type) + return type_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } inline void V0LayerParameter::set_type(const ::std::string& value) { set_has_type(); - if (type_ == &::google::protobuf::internal::kEmptyString) { - type_ = new ::std::string; - } - type_->assign(value); + type_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); + // @@protoc_insertion_point(field_set:caffe.V0LayerParameter.type) } inline void V0LayerParameter::set_type(const char* value) { set_has_type(); - if (type_ == &::google::protobuf::internal::kEmptyString) { - type_ = new ::std::string; - } - type_->assign(value); + type_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); + // @@protoc_insertion_point(field_set_char:caffe.V0LayerParameter.type) } inline void V0LayerParameter::set_type(const char* value, size_t size) { set_has_type(); - if (type_ == &::google::protobuf::internal::kEmptyString) { - type_ = new ::std::string; - } - type_->assign(reinterpret_cast(value), size); + type_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), + ::std::string(reinterpret_cast(value), size)); + // @@protoc_insertion_point(field_set_pointer:caffe.V0LayerParameter.type) } inline ::std::string* V0LayerParameter::mutable_type() { set_has_type(); - if (type_ == &::google::protobuf::internal::kEmptyString) { - type_ = new ::std::string; - } - return type_; + // @@protoc_insertion_point(field_mutable:caffe.V0LayerParameter.type) + return type_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } inline ::std::string* V0LayerParameter::release_type() { + // @@protoc_insertion_point(field_release:caffe.V0LayerParameter.type) clear_has_type(); - if (type_ == &::google::protobuf::internal::kEmptyString) { - return NULL; - } else { - ::std::string* temp = type_; - type_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); - return temp; - } + return type_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } inline void V0LayerParameter::set_allocated_type(::std::string* type) { - if (type_ != &::google::protobuf::internal::kEmptyString) { - delete type_; - } - if (type) { + if (type != NULL) { set_has_type(); - type_ = type; } else { clear_has_type(); - type_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); } + type_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), type); + // @@protoc_insertion_point(field_set_allocated:caffe.V0LayerParameter.type) } // optional uint32 num_output = 3; @@ -20923,11 +22893,13 @@ inline void V0LayerParameter::clear_num_output() { clear_has_num_output(); } inline ::google::protobuf::uint32 V0LayerParameter::num_output() const { + // @@protoc_insertion_point(field_get:caffe.V0LayerParameter.num_output) return num_output_; } inline void V0LayerParameter::set_num_output(::google::protobuf::uint32 value) { set_has_num_output(); num_output_ = value; + // @@protoc_insertion_point(field_set:caffe.V0LayerParameter.num_output) } // optional bool biasterm = 4 [default = true]; @@ -20945,11 +22917,13 @@ inline void V0LayerParameter::clear_biasterm() { clear_has_biasterm(); } inline bool V0LayerParameter::biasterm() const { + // @@protoc_insertion_point(field_get:caffe.V0LayerParameter.biasterm) return biasterm_; } inline void V0LayerParameter::set_biasterm(bool value) { set_has_biasterm(); biasterm_ = value; + // @@protoc_insertion_point(field_set:caffe.V0LayerParameter.biasterm) } // optional .caffe.FillerParameter weight_filler = 5; @@ -20967,14 +22941,20 @@ inline void V0LayerParameter::clear_weight_filler() { clear_has_weight_filler(); } inline const ::caffe::FillerParameter& V0LayerParameter::weight_filler() const { - return weight_filler_ != NULL ? *weight_filler_ : *default_instance_->weight_filler_; + // @@protoc_insertion_point(field_get:caffe.V0LayerParameter.weight_filler) + return weight_filler_ != NULL ? *weight_filler_ + : *::caffe::FillerParameter::internal_default_instance(); } inline ::caffe::FillerParameter* V0LayerParameter::mutable_weight_filler() { set_has_weight_filler(); - if (weight_filler_ == NULL) weight_filler_ = new ::caffe::FillerParameter; + if (weight_filler_ == NULL) { + weight_filler_ = new ::caffe::FillerParameter; + } + // @@protoc_insertion_point(field_mutable:caffe.V0LayerParameter.weight_filler) return weight_filler_; } inline ::caffe::FillerParameter* V0LayerParameter::release_weight_filler() { + // @@protoc_insertion_point(field_release:caffe.V0LayerParameter.weight_filler) clear_has_weight_filler(); ::caffe::FillerParameter* temp = weight_filler_; weight_filler_ = NULL; @@ -20988,6 +22968,7 @@ inline void V0LayerParameter::set_allocated_weight_filler(::caffe::FillerParamet } else { clear_has_weight_filler(); } + // @@protoc_insertion_point(field_set_allocated:caffe.V0LayerParameter.weight_filler) } // optional .caffe.FillerParameter bias_filler = 6; @@ -21005,14 +22986,20 @@ inline void V0LayerParameter::clear_bias_filler() { clear_has_bias_filler(); } inline const ::caffe::FillerParameter& V0LayerParameter::bias_filler() const { - return bias_filler_ != NULL ? *bias_filler_ : *default_instance_->bias_filler_; + // @@protoc_insertion_point(field_get:caffe.V0LayerParameter.bias_filler) + return bias_filler_ != NULL ? *bias_filler_ + : *::caffe::FillerParameter::internal_default_instance(); } inline ::caffe::FillerParameter* V0LayerParameter::mutable_bias_filler() { set_has_bias_filler(); - if (bias_filler_ == NULL) bias_filler_ = new ::caffe::FillerParameter; + if (bias_filler_ == NULL) { + bias_filler_ = new ::caffe::FillerParameter; + } + // @@protoc_insertion_point(field_mutable:caffe.V0LayerParameter.bias_filler) return bias_filler_; } inline ::caffe::FillerParameter* V0LayerParameter::release_bias_filler() { + // @@protoc_insertion_point(field_release:caffe.V0LayerParameter.bias_filler) clear_has_bias_filler(); ::caffe::FillerParameter* temp = bias_filler_; bias_filler_ = NULL; @@ -21026,6 +23013,7 @@ inline void V0LayerParameter::set_allocated_bias_filler(::caffe::FillerParameter } else { clear_has_bias_filler(); } + // @@protoc_insertion_point(field_set_allocated:caffe.V0LayerParameter.bias_filler) } // optional uint32 pad = 7 [default = 0]; @@ -21043,11 +23031,13 @@ inline void V0LayerParameter::clear_pad() { clear_has_pad(); } inline ::google::protobuf::uint32 V0LayerParameter::pad() const { + // @@protoc_insertion_point(field_get:caffe.V0LayerParameter.pad) return pad_; } inline void V0LayerParameter::set_pad(::google::protobuf::uint32 value) { set_has_pad(); pad_ = value; + // @@protoc_insertion_point(field_set:caffe.V0LayerParameter.pad) } // optional uint32 kernelsize = 8; @@ -21065,11 +23055,13 @@ inline void V0LayerParameter::clear_kernelsize() { clear_has_kernelsize(); } inline ::google::protobuf::uint32 V0LayerParameter::kernelsize() const { + // @@protoc_insertion_point(field_get:caffe.V0LayerParameter.kernelsize) return kernelsize_; } inline void V0LayerParameter::set_kernelsize(::google::protobuf::uint32 value) { set_has_kernelsize(); kernelsize_ = value; + // @@protoc_insertion_point(field_set:caffe.V0LayerParameter.kernelsize) } // optional uint32 group = 9 [default = 1]; @@ -21087,11 +23079,13 @@ inline void V0LayerParameter::clear_group() { clear_has_group(); } inline ::google::protobuf::uint32 V0LayerParameter::group() const { + // @@protoc_insertion_point(field_get:caffe.V0LayerParameter.group) return group_; } inline void V0LayerParameter::set_group(::google::protobuf::uint32 value) { set_has_group(); group_ = value; + // @@protoc_insertion_point(field_set:caffe.V0LayerParameter.group) } // optional uint32 stride = 10 [default = 1]; @@ -21109,11 +23103,13 @@ inline void V0LayerParameter::clear_stride() { clear_has_stride(); } inline ::google::protobuf::uint32 V0LayerParameter::stride() const { + // @@protoc_insertion_point(field_get:caffe.V0LayerParameter.stride) return stride_; } inline void V0LayerParameter::set_stride(::google::protobuf::uint32 value) { set_has_stride(); stride_ = value; + // @@protoc_insertion_point(field_set:caffe.V0LayerParameter.stride) } // optional .caffe.V0LayerParameter.PoolMethod pool = 11 [default = MAX]; @@ -21131,12 +23127,14 @@ inline void V0LayerParameter::clear_pool() { clear_has_pool(); } inline ::caffe::V0LayerParameter_PoolMethod V0LayerParameter::pool() const { + // @@protoc_insertion_point(field_get:caffe.V0LayerParameter.pool) return static_cast< ::caffe::V0LayerParameter_PoolMethod >(pool_); } inline void V0LayerParameter::set_pool(::caffe::V0LayerParameter_PoolMethod value) { assert(::caffe::V0LayerParameter_PoolMethod_IsValid(value)); set_has_pool(); pool_ = value; + // @@protoc_insertion_point(field_set:caffe.V0LayerParameter.pool) } // optional float dropout_ratio = 12 [default = 0.5]; @@ -21154,11 +23152,13 @@ inline void V0LayerParameter::clear_dropout_ratio() { clear_has_dropout_ratio(); } inline float V0LayerParameter::dropout_ratio() const { + // @@protoc_insertion_point(field_get:caffe.V0LayerParameter.dropout_ratio) return dropout_ratio_; } inline void V0LayerParameter::set_dropout_ratio(float value) { set_has_dropout_ratio(); dropout_ratio_ = value; + // @@protoc_insertion_point(field_set:caffe.V0LayerParameter.dropout_ratio) } // optional uint32 local_size = 13 [default = 5]; @@ -21176,11 +23176,13 @@ inline void V0LayerParameter::clear_local_size() { clear_has_local_size(); } inline ::google::protobuf::uint32 V0LayerParameter::local_size() const { + // @@protoc_insertion_point(field_get:caffe.V0LayerParameter.local_size) return local_size_; } inline void V0LayerParameter::set_local_size(::google::protobuf::uint32 value) { set_has_local_size(); local_size_ = value; + // @@protoc_insertion_point(field_set:caffe.V0LayerParameter.local_size) } // optional float alpha = 14 [default = 1]; @@ -21198,11 +23200,13 @@ inline void V0LayerParameter::clear_alpha() { clear_has_alpha(); } inline float V0LayerParameter::alpha() const { + // @@protoc_insertion_point(field_get:caffe.V0LayerParameter.alpha) return alpha_; } inline void V0LayerParameter::set_alpha(float value) { set_has_alpha(); alpha_ = value; + // @@protoc_insertion_point(field_set:caffe.V0LayerParameter.alpha) } // optional float beta = 15 [default = 0.75]; @@ -21220,11 +23224,13 @@ inline void V0LayerParameter::clear_beta() { clear_has_beta(); } inline float V0LayerParameter::beta() const { + // @@protoc_insertion_point(field_get:caffe.V0LayerParameter.beta) return beta_; } inline void V0LayerParameter::set_beta(float value) { set_has_beta(); beta_ = value; + // @@protoc_insertion_point(field_set:caffe.V0LayerParameter.beta) } // optional float k = 22 [default = 1]; @@ -21242,11 +23248,13 @@ inline void V0LayerParameter::clear_k() { clear_has_k(); } inline float V0LayerParameter::k() const { + // @@protoc_insertion_point(field_get:caffe.V0LayerParameter.k) return k_; } inline void V0LayerParameter::set_k(float value) { set_has_k(); k_ = value; + // @@protoc_insertion_point(field_set:caffe.V0LayerParameter.k) } // optional string source = 16; @@ -21260,63 +23268,47 @@ inline void V0LayerParameter::clear_has_source() { _has_bits_[0] &= ~0x00010000u; } inline void V0LayerParameter::clear_source() { - if (source_ != &::google::protobuf::internal::kEmptyString) { - source_->clear(); - } + source_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); clear_has_source(); } inline const ::std::string& V0LayerParameter::source() const { - return *source_; + // @@protoc_insertion_point(field_get:caffe.V0LayerParameter.source) + return source_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } inline void V0LayerParameter::set_source(const ::std::string& value) { set_has_source(); - if (source_ == &::google::protobuf::internal::kEmptyString) { - source_ = new ::std::string; - } - source_->assign(value); + source_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); + // @@protoc_insertion_point(field_set:caffe.V0LayerParameter.source) } inline void V0LayerParameter::set_source(const char* value) { set_has_source(); - if (source_ == &::google::protobuf::internal::kEmptyString) { - source_ = new ::std::string; - } - source_->assign(value); + source_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); + // @@protoc_insertion_point(field_set_char:caffe.V0LayerParameter.source) } inline void V0LayerParameter::set_source(const char* value, size_t size) { set_has_source(); - if (source_ == &::google::protobuf::internal::kEmptyString) { - source_ = new ::std::string; - } - source_->assign(reinterpret_cast(value), size); + source_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), + ::std::string(reinterpret_cast(value), size)); + // @@protoc_insertion_point(field_set_pointer:caffe.V0LayerParameter.source) } inline ::std::string* V0LayerParameter::mutable_source() { set_has_source(); - if (source_ == &::google::protobuf::internal::kEmptyString) { - source_ = new ::std::string; - } - return source_; + // @@protoc_insertion_point(field_mutable:caffe.V0LayerParameter.source) + return source_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } inline ::std::string* V0LayerParameter::release_source() { + // @@protoc_insertion_point(field_release:caffe.V0LayerParameter.source) clear_has_source(); - if (source_ == &::google::protobuf::internal::kEmptyString) { - return NULL; - } else { - ::std::string* temp = source_; - source_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); - return temp; - } + return source_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } inline void V0LayerParameter::set_allocated_source(::std::string* source) { - if (source_ != &::google::protobuf::internal::kEmptyString) { - delete source_; - } - if (source) { + if (source != NULL) { set_has_source(); - source_ = source; } else { clear_has_source(); - source_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); } + source_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), source); + // @@protoc_insertion_point(field_set_allocated:caffe.V0LayerParameter.source) } // optional float scale = 17 [default = 1]; @@ -21334,11 +23326,13 @@ inline void V0LayerParameter::clear_scale() { clear_has_scale(); } inline float V0LayerParameter::scale() const { + // @@protoc_insertion_point(field_get:caffe.V0LayerParameter.scale) return scale_; } inline void V0LayerParameter::set_scale(float value) { set_has_scale(); scale_ = value; + // @@protoc_insertion_point(field_set:caffe.V0LayerParameter.scale) } // optional string meanfile = 18; @@ -21352,63 +23346,47 @@ inline void V0LayerParameter::clear_has_meanfile() { _has_bits_[0] &= ~0x00040000u; } inline void V0LayerParameter::clear_meanfile() { - if (meanfile_ != &::google::protobuf::internal::kEmptyString) { - meanfile_->clear(); - } + meanfile_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); clear_has_meanfile(); } inline const ::std::string& V0LayerParameter::meanfile() const { - return *meanfile_; + // @@protoc_insertion_point(field_get:caffe.V0LayerParameter.meanfile) + return meanfile_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } inline void V0LayerParameter::set_meanfile(const ::std::string& value) { set_has_meanfile(); - if (meanfile_ == &::google::protobuf::internal::kEmptyString) { - meanfile_ = new ::std::string; - } - meanfile_->assign(value); + meanfile_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); + // @@protoc_insertion_point(field_set:caffe.V0LayerParameter.meanfile) } inline void V0LayerParameter::set_meanfile(const char* value) { set_has_meanfile(); - if (meanfile_ == &::google::protobuf::internal::kEmptyString) { - meanfile_ = new ::std::string; - } - meanfile_->assign(value); + meanfile_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); + // @@protoc_insertion_point(field_set_char:caffe.V0LayerParameter.meanfile) } inline void V0LayerParameter::set_meanfile(const char* value, size_t size) { set_has_meanfile(); - if (meanfile_ == &::google::protobuf::internal::kEmptyString) { - meanfile_ = new ::std::string; - } - meanfile_->assign(reinterpret_cast(value), size); + meanfile_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), + ::std::string(reinterpret_cast(value), size)); + // @@protoc_insertion_point(field_set_pointer:caffe.V0LayerParameter.meanfile) } inline ::std::string* V0LayerParameter::mutable_meanfile() { set_has_meanfile(); - if (meanfile_ == &::google::protobuf::internal::kEmptyString) { - meanfile_ = new ::std::string; - } - return meanfile_; + // @@protoc_insertion_point(field_mutable:caffe.V0LayerParameter.meanfile) + return meanfile_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } inline ::std::string* V0LayerParameter::release_meanfile() { + // @@protoc_insertion_point(field_release:caffe.V0LayerParameter.meanfile) clear_has_meanfile(); - if (meanfile_ == &::google::protobuf::internal::kEmptyString) { - return NULL; - } else { - ::std::string* temp = meanfile_; - meanfile_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); - return temp; - } + return meanfile_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } inline void V0LayerParameter::set_allocated_meanfile(::std::string* meanfile) { - if (meanfile_ != &::google::protobuf::internal::kEmptyString) { - delete meanfile_; - } - if (meanfile) { + if (meanfile != NULL) { set_has_meanfile(); - meanfile_ = meanfile; } else { clear_has_meanfile(); - meanfile_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); } + meanfile_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), meanfile); + // @@protoc_insertion_point(field_set_allocated:caffe.V0LayerParameter.meanfile) } // optional uint32 batchsize = 19; @@ -21426,11 +23404,13 @@ inline void V0LayerParameter::clear_batchsize() { clear_has_batchsize(); } inline ::google::protobuf::uint32 V0LayerParameter::batchsize() const { + // @@protoc_insertion_point(field_get:caffe.V0LayerParameter.batchsize) return batchsize_; } inline void V0LayerParameter::set_batchsize(::google::protobuf::uint32 value) { set_has_batchsize(); batchsize_ = value; + // @@protoc_insertion_point(field_set:caffe.V0LayerParameter.batchsize) } // optional uint32 cropsize = 20 [default = 0]; @@ -21448,11 +23428,13 @@ inline void V0LayerParameter::clear_cropsize() { clear_has_cropsize(); } inline ::google::protobuf::uint32 V0LayerParameter::cropsize() const { + // @@protoc_insertion_point(field_get:caffe.V0LayerParameter.cropsize) return cropsize_; } inline void V0LayerParameter::set_cropsize(::google::protobuf::uint32 value) { set_has_cropsize(); cropsize_ = value; + // @@protoc_insertion_point(field_set:caffe.V0LayerParameter.cropsize) } // optional bool mirror = 21 [default = false]; @@ -21470,11 +23452,13 @@ inline void V0LayerParameter::clear_mirror() { clear_has_mirror(); } inline bool V0LayerParameter::mirror() const { + // @@protoc_insertion_point(field_get:caffe.V0LayerParameter.mirror) return mirror_; } inline void V0LayerParameter::set_mirror(bool value) { set_has_mirror(); mirror_ = value; + // @@protoc_insertion_point(field_set:caffe.V0LayerParameter.mirror) } // repeated .caffe.BlobProto blobs = 50; @@ -21485,22 +23469,27 @@ inline void V0LayerParameter::clear_blobs() { blobs_.Clear(); } inline const ::caffe::BlobProto& V0LayerParameter::blobs(int index) const { + // @@protoc_insertion_point(field_get:caffe.V0LayerParameter.blobs) return blobs_.Get(index); } inline ::caffe::BlobProto* V0LayerParameter::mutable_blobs(int index) { + // @@protoc_insertion_point(field_mutable:caffe.V0LayerParameter.blobs) return blobs_.Mutable(index); } inline ::caffe::BlobProto* V0LayerParameter::add_blobs() { + // @@protoc_insertion_point(field_add:caffe.V0LayerParameter.blobs) return blobs_.Add(); } -inline const ::google::protobuf::RepeatedPtrField< ::caffe::BlobProto >& -V0LayerParameter::blobs() const { - return blobs_; -} inline ::google::protobuf::RepeatedPtrField< ::caffe::BlobProto >* V0LayerParameter::mutable_blobs() { + // @@protoc_insertion_point(field_mutable_list:caffe.V0LayerParameter.blobs) return &blobs_; } +inline const ::google::protobuf::RepeatedPtrField< ::caffe::BlobProto >& +V0LayerParameter::blobs() const { + // @@protoc_insertion_point(field_list:caffe.V0LayerParameter.blobs) + return blobs_; +} // repeated float blobs_lr = 51; inline int V0LayerParameter::blobs_lr_size() const { @@ -21510,20 +23499,25 @@ inline void V0LayerParameter::clear_blobs_lr() { blobs_lr_.Clear(); } inline float V0LayerParameter::blobs_lr(int index) const { + // @@protoc_insertion_point(field_get:caffe.V0LayerParameter.blobs_lr) return blobs_lr_.Get(index); } inline void V0LayerParameter::set_blobs_lr(int index, float value) { blobs_lr_.Set(index, value); + // @@protoc_insertion_point(field_set:caffe.V0LayerParameter.blobs_lr) } inline void V0LayerParameter::add_blobs_lr(float value) { blobs_lr_.Add(value); + // @@protoc_insertion_point(field_add:caffe.V0LayerParameter.blobs_lr) } inline const ::google::protobuf::RepeatedField< float >& V0LayerParameter::blobs_lr() const { + // @@protoc_insertion_point(field_list:caffe.V0LayerParameter.blobs_lr) return blobs_lr_; } inline ::google::protobuf::RepeatedField< float >* V0LayerParameter::mutable_blobs_lr() { + // @@protoc_insertion_point(field_mutable_list:caffe.V0LayerParameter.blobs_lr) return &blobs_lr_; } @@ -21535,20 +23529,25 @@ inline void V0LayerParameter::clear_weight_decay() { weight_decay_.Clear(); } inline float V0LayerParameter::weight_decay(int index) const { + // @@protoc_insertion_point(field_get:caffe.V0LayerParameter.weight_decay) return weight_decay_.Get(index); } inline void V0LayerParameter::set_weight_decay(int index, float value) { weight_decay_.Set(index, value); + // @@protoc_insertion_point(field_set:caffe.V0LayerParameter.weight_decay) } inline void V0LayerParameter::add_weight_decay(float value) { weight_decay_.Add(value); + // @@protoc_insertion_point(field_add:caffe.V0LayerParameter.weight_decay) } inline const ::google::protobuf::RepeatedField< float >& V0LayerParameter::weight_decay() const { + // @@protoc_insertion_point(field_list:caffe.V0LayerParameter.weight_decay) return weight_decay_; } inline ::google::protobuf::RepeatedField< float >* V0LayerParameter::mutable_weight_decay() { + // @@protoc_insertion_point(field_mutable_list:caffe.V0LayerParameter.weight_decay) return &weight_decay_; } @@ -21567,11 +23566,13 @@ inline void V0LayerParameter::clear_rand_skip() { clear_has_rand_skip(); } inline ::google::protobuf::uint32 V0LayerParameter::rand_skip() const { + // @@protoc_insertion_point(field_get:caffe.V0LayerParameter.rand_skip) return rand_skip_; } inline void V0LayerParameter::set_rand_skip(::google::protobuf::uint32 value) { set_has_rand_skip(); rand_skip_ = value; + // @@protoc_insertion_point(field_set:caffe.V0LayerParameter.rand_skip) } // optional float det_fg_threshold = 54 [default = 0.5]; @@ -21589,11 +23590,13 @@ inline void V0LayerParameter::clear_det_fg_threshold() { clear_has_det_fg_threshold(); } inline float V0LayerParameter::det_fg_threshold() const { + // @@protoc_insertion_point(field_get:caffe.V0LayerParameter.det_fg_threshold) return det_fg_threshold_; } inline void V0LayerParameter::set_det_fg_threshold(float value) { set_has_det_fg_threshold(); det_fg_threshold_ = value; + // @@protoc_insertion_point(field_set:caffe.V0LayerParameter.det_fg_threshold) } // optional float det_bg_threshold = 55 [default = 0.5]; @@ -21611,11 +23614,13 @@ inline void V0LayerParameter::clear_det_bg_threshold() { clear_has_det_bg_threshold(); } inline float V0LayerParameter::det_bg_threshold() const { + // @@protoc_insertion_point(field_get:caffe.V0LayerParameter.det_bg_threshold) return det_bg_threshold_; } inline void V0LayerParameter::set_det_bg_threshold(float value) { set_has_det_bg_threshold(); det_bg_threshold_ = value; + // @@protoc_insertion_point(field_set:caffe.V0LayerParameter.det_bg_threshold) } // optional float det_fg_fraction = 56 [default = 0.25]; @@ -21633,11 +23638,13 @@ inline void V0LayerParameter::clear_det_fg_fraction() { clear_has_det_fg_fraction(); } inline float V0LayerParameter::det_fg_fraction() const { + // @@protoc_insertion_point(field_get:caffe.V0LayerParameter.det_fg_fraction) return det_fg_fraction_; } inline void V0LayerParameter::set_det_fg_fraction(float value) { set_has_det_fg_fraction(); det_fg_fraction_ = value; + // @@protoc_insertion_point(field_set:caffe.V0LayerParameter.det_fg_fraction) } // optional uint32 det_context_pad = 58 [default = 0]; @@ -21655,11 +23662,13 @@ inline void V0LayerParameter::clear_det_context_pad() { clear_has_det_context_pad(); } inline ::google::protobuf::uint32 V0LayerParameter::det_context_pad() const { + // @@protoc_insertion_point(field_get:caffe.V0LayerParameter.det_context_pad) return det_context_pad_; } inline void V0LayerParameter::set_det_context_pad(::google::protobuf::uint32 value) { set_has_det_context_pad(); det_context_pad_ = value; + // @@protoc_insertion_point(field_set:caffe.V0LayerParameter.det_context_pad) } // optional string det_crop_mode = 59 [default = "warp"]; @@ -21673,63 +23682,47 @@ inline void V0LayerParameter::clear_has_det_crop_mode() { _has_bits_[0] &= ~0x40000000u; } inline void V0LayerParameter::clear_det_crop_mode() { - if (det_crop_mode_ != _default_det_crop_mode_) { - det_crop_mode_->assign(*_default_det_crop_mode_); - } + det_crop_mode_.ClearToDefaultNoArena(_default_det_crop_mode_); clear_has_det_crop_mode(); } inline const ::std::string& V0LayerParameter::det_crop_mode() const { - return *det_crop_mode_; + // @@protoc_insertion_point(field_get:caffe.V0LayerParameter.det_crop_mode) + return det_crop_mode_.GetNoArena(_default_det_crop_mode_); } inline void V0LayerParameter::set_det_crop_mode(const ::std::string& value) { set_has_det_crop_mode(); - if (det_crop_mode_ == _default_det_crop_mode_) { - det_crop_mode_ = new ::std::string; - } - det_crop_mode_->assign(value); + det_crop_mode_.SetNoArena(_default_det_crop_mode_, value); + // @@protoc_insertion_point(field_set:caffe.V0LayerParameter.det_crop_mode) } inline void V0LayerParameter::set_det_crop_mode(const char* value) { set_has_det_crop_mode(); - if (det_crop_mode_ == _default_det_crop_mode_) { - det_crop_mode_ = new ::std::string; - } - det_crop_mode_->assign(value); + det_crop_mode_.SetNoArena(_default_det_crop_mode_, ::std::string(value)); + // @@protoc_insertion_point(field_set_char:caffe.V0LayerParameter.det_crop_mode) } inline void V0LayerParameter::set_det_crop_mode(const char* value, size_t size) { set_has_det_crop_mode(); - if (det_crop_mode_ == _default_det_crop_mode_) { - det_crop_mode_ = new ::std::string; - } - det_crop_mode_->assign(reinterpret_cast(value), size); + det_crop_mode_.SetNoArena(_default_det_crop_mode_, + ::std::string(reinterpret_cast(value), size)); + // @@protoc_insertion_point(field_set_pointer:caffe.V0LayerParameter.det_crop_mode) } inline ::std::string* V0LayerParameter::mutable_det_crop_mode() { set_has_det_crop_mode(); - if (det_crop_mode_ == _default_det_crop_mode_) { - det_crop_mode_ = new ::std::string(*_default_det_crop_mode_); - } - return det_crop_mode_; + // @@protoc_insertion_point(field_mutable:caffe.V0LayerParameter.det_crop_mode) + return det_crop_mode_.MutableNoArena(_default_det_crop_mode_); } inline ::std::string* V0LayerParameter::release_det_crop_mode() { + // @@protoc_insertion_point(field_release:caffe.V0LayerParameter.det_crop_mode) clear_has_det_crop_mode(); - if (det_crop_mode_ == _default_det_crop_mode_) { - return NULL; - } else { - ::std::string* temp = det_crop_mode_; - det_crop_mode_ = const_cast< ::std::string*>(_default_det_crop_mode_); - return temp; - } + return det_crop_mode_.ReleaseNoArena(_default_det_crop_mode_); } inline void V0LayerParameter::set_allocated_det_crop_mode(::std::string* det_crop_mode) { - if (det_crop_mode_ != _default_det_crop_mode_) { - delete det_crop_mode_; - } - if (det_crop_mode) { + if (det_crop_mode != NULL) { set_has_det_crop_mode(); - det_crop_mode_ = det_crop_mode; } else { clear_has_det_crop_mode(); - det_crop_mode_ = const_cast< ::std::string*>(_default_det_crop_mode_); } + det_crop_mode_.SetAllocatedNoArena(_default_det_crop_mode_, det_crop_mode); + // @@protoc_insertion_point(field_set_allocated:caffe.V0LayerParameter.det_crop_mode) } // optional int32 new_num = 60 [default = 0]; @@ -21747,11 +23740,13 @@ inline void V0LayerParameter::clear_new_num() { clear_has_new_num(); } inline ::google::protobuf::int32 V0LayerParameter::new_num() const { + // @@protoc_insertion_point(field_get:caffe.V0LayerParameter.new_num) return new_num_; } inline void V0LayerParameter::set_new_num(::google::protobuf::int32 value) { set_has_new_num(); new_num_ = value; + // @@protoc_insertion_point(field_set:caffe.V0LayerParameter.new_num) } // optional int32 new_channels = 61 [default = 0]; @@ -21769,11 +23764,13 @@ inline void V0LayerParameter::clear_new_channels() { clear_has_new_channels(); } inline ::google::protobuf::int32 V0LayerParameter::new_channels() const { + // @@protoc_insertion_point(field_get:caffe.V0LayerParameter.new_channels) return new_channels_; } inline void V0LayerParameter::set_new_channels(::google::protobuf::int32 value) { set_has_new_channels(); new_channels_ = value; + // @@protoc_insertion_point(field_set:caffe.V0LayerParameter.new_channels) } // optional int32 new_height = 62 [default = 0]; @@ -21791,11 +23788,13 @@ inline void V0LayerParameter::clear_new_height() { clear_has_new_height(); } inline ::google::protobuf::int32 V0LayerParameter::new_height() const { + // @@protoc_insertion_point(field_get:caffe.V0LayerParameter.new_height) return new_height_; } inline void V0LayerParameter::set_new_height(::google::protobuf::int32 value) { set_has_new_height(); new_height_ = value; + // @@protoc_insertion_point(field_set:caffe.V0LayerParameter.new_height) } // optional int32 new_width = 63 [default = 0]; @@ -21813,11 +23812,13 @@ inline void V0LayerParameter::clear_new_width() { clear_has_new_width(); } inline ::google::protobuf::int32 V0LayerParameter::new_width() const { + // @@protoc_insertion_point(field_get:caffe.V0LayerParameter.new_width) return new_width_; } inline void V0LayerParameter::set_new_width(::google::protobuf::int32 value) { set_has_new_width(); new_width_ = value; + // @@protoc_insertion_point(field_set:caffe.V0LayerParameter.new_width) } // optional bool shuffle_images = 64 [default = false]; @@ -21835,11 +23836,13 @@ inline void V0LayerParameter::clear_shuffle_images() { clear_has_shuffle_images(); } inline bool V0LayerParameter::shuffle_images() const { + // @@protoc_insertion_point(field_get:caffe.V0LayerParameter.shuffle_images) return shuffle_images_; } inline void V0LayerParameter::set_shuffle_images(bool value) { set_has_shuffle_images(); shuffle_images_ = value; + // @@protoc_insertion_point(field_set:caffe.V0LayerParameter.shuffle_images) } // optional uint32 concat_dim = 65 [default = 1]; @@ -21857,11 +23860,13 @@ inline void V0LayerParameter::clear_concat_dim() { clear_has_concat_dim(); } inline ::google::protobuf::uint32 V0LayerParameter::concat_dim() const { + // @@protoc_insertion_point(field_get:caffe.V0LayerParameter.concat_dim) return concat_dim_; } inline void V0LayerParameter::set_concat_dim(::google::protobuf::uint32 value) { set_has_concat_dim(); concat_dim_ = value; + // @@protoc_insertion_point(field_set:caffe.V0LayerParameter.concat_dim) } // optional .caffe.HDF5OutputParameter hdf5_output_param = 1001; @@ -21879,14 +23884,20 @@ inline void V0LayerParameter::clear_hdf5_output_param() { clear_has_hdf5_output_param(); } inline const ::caffe::HDF5OutputParameter& V0LayerParameter::hdf5_output_param() const { - return hdf5_output_param_ != NULL ? *hdf5_output_param_ : *default_instance_->hdf5_output_param_; + // @@protoc_insertion_point(field_get:caffe.V0LayerParameter.hdf5_output_param) + return hdf5_output_param_ != NULL ? *hdf5_output_param_ + : *::caffe::HDF5OutputParameter::internal_default_instance(); } inline ::caffe::HDF5OutputParameter* V0LayerParameter::mutable_hdf5_output_param() { set_has_hdf5_output_param(); - if (hdf5_output_param_ == NULL) hdf5_output_param_ = new ::caffe::HDF5OutputParameter; + if (hdf5_output_param_ == NULL) { + hdf5_output_param_ = new ::caffe::HDF5OutputParameter; + } + // @@protoc_insertion_point(field_mutable:caffe.V0LayerParameter.hdf5_output_param) return hdf5_output_param_; } inline ::caffe::HDF5OutputParameter* V0LayerParameter::release_hdf5_output_param() { + // @@protoc_insertion_point(field_release:caffe.V0LayerParameter.hdf5_output_param) clear_has_hdf5_output_param(); ::caffe::HDF5OutputParameter* temp = hdf5_output_param_; hdf5_output_param_ = NULL; @@ -21900,8 +23911,12 @@ inline void V0LayerParameter::set_allocated_hdf5_output_param(::caffe::HDF5Outpu } else { clear_has_hdf5_output_param(); } + // @@protoc_insertion_point(field_set_allocated:caffe.V0LayerParameter.hdf5_output_param) } +inline const V0LayerParameter* V0LayerParameter::internal_default_instance() { + return &V0LayerParameter_default_instance_.get(); +} // ------------------------------------------------------------------- // PReLUParameter @@ -21921,14 +23936,20 @@ inline void PReLUParameter::clear_filler() { clear_has_filler(); } inline const ::caffe::FillerParameter& PReLUParameter::filler() const { - return filler_ != NULL ? *filler_ : *default_instance_->filler_; + // @@protoc_insertion_point(field_get:caffe.PReLUParameter.filler) + return filler_ != NULL ? *filler_ + : *::caffe::FillerParameter::internal_default_instance(); } inline ::caffe::FillerParameter* PReLUParameter::mutable_filler() { set_has_filler(); - if (filler_ == NULL) filler_ = new ::caffe::FillerParameter; + if (filler_ == NULL) { + filler_ = new ::caffe::FillerParameter; + } + // @@protoc_insertion_point(field_mutable:caffe.PReLUParameter.filler) return filler_; } inline ::caffe::FillerParameter* PReLUParameter::release_filler() { + // @@protoc_insertion_point(field_release:caffe.PReLUParameter.filler) clear_has_filler(); ::caffe::FillerParameter* temp = filler_; filler_ = NULL; @@ -21942,6 +23963,7 @@ inline void PReLUParameter::set_allocated_filler(::caffe::FillerParameter* fille } else { clear_has_filler(); } + // @@protoc_insertion_point(field_set_allocated:caffe.PReLUParameter.filler) } // optional bool channel_shared = 2 [default = false]; @@ -21959,13 +23981,18 @@ inline void PReLUParameter::clear_channel_shared() { clear_has_channel_shared(); } inline bool PReLUParameter::channel_shared() const { + // @@protoc_insertion_point(field_get:caffe.PReLUParameter.channel_shared) return channel_shared_; } inline void PReLUParameter::set_channel_shared(bool value) { set_has_channel_shared(); channel_shared_ = value; + // @@protoc_insertion_point(field_set:caffe.PReLUParameter.channel_shared) } +inline const PReLUParameter* PReLUParameter::internal_default_instance() { + return &PReLUParameter_default_instance_.get(); +} // ------------------------------------------------------------------- // NormalizedBBox @@ -21985,11 +24012,13 @@ inline void NormalizedBBox::clear_xmin() { clear_has_xmin(); } inline float NormalizedBBox::xmin() const { + // @@protoc_insertion_point(field_get:caffe.NormalizedBBox.xmin) return xmin_; } inline void NormalizedBBox::set_xmin(float value) { set_has_xmin(); xmin_ = value; + // @@protoc_insertion_point(field_set:caffe.NormalizedBBox.xmin) } // optional float ymin = 2; @@ -22007,11 +24036,13 @@ inline void NormalizedBBox::clear_ymin() { clear_has_ymin(); } inline float NormalizedBBox::ymin() const { + // @@protoc_insertion_point(field_get:caffe.NormalizedBBox.ymin) return ymin_; } inline void NormalizedBBox::set_ymin(float value) { set_has_ymin(); ymin_ = value; + // @@protoc_insertion_point(field_set:caffe.NormalizedBBox.ymin) } // optional float xmax = 3; @@ -22029,11 +24060,13 @@ inline void NormalizedBBox::clear_xmax() { clear_has_xmax(); } inline float NormalizedBBox::xmax() const { + // @@protoc_insertion_point(field_get:caffe.NormalizedBBox.xmax) return xmax_; } inline void NormalizedBBox::set_xmax(float value) { set_has_xmax(); xmax_ = value; + // @@protoc_insertion_point(field_set:caffe.NormalizedBBox.xmax) } // optional float ymax = 4; @@ -22051,11 +24084,13 @@ inline void NormalizedBBox::clear_ymax() { clear_has_ymax(); } inline float NormalizedBBox::ymax() const { + // @@protoc_insertion_point(field_get:caffe.NormalizedBBox.ymax) return ymax_; } inline void NormalizedBBox::set_ymax(float value) { set_has_ymax(); ymax_ = value; + // @@protoc_insertion_point(field_set:caffe.NormalizedBBox.ymax) } // optional int32 label = 5; @@ -22073,11 +24108,13 @@ inline void NormalizedBBox::clear_label() { clear_has_label(); } inline ::google::protobuf::int32 NormalizedBBox::label() const { + // @@protoc_insertion_point(field_get:caffe.NormalizedBBox.label) return label_; } inline void NormalizedBBox::set_label(::google::protobuf::int32 value) { set_has_label(); label_ = value; + // @@protoc_insertion_point(field_set:caffe.NormalizedBBox.label) } // optional bool difficult = 6; @@ -22095,11 +24132,13 @@ inline void NormalizedBBox::clear_difficult() { clear_has_difficult(); } inline bool NormalizedBBox::difficult() const { + // @@protoc_insertion_point(field_get:caffe.NormalizedBBox.difficult) return difficult_; } inline void NormalizedBBox::set_difficult(bool value) { set_has_difficult(); difficult_ = value; + // @@protoc_insertion_point(field_set:caffe.NormalizedBBox.difficult) } // optional float score = 7; @@ -22117,11 +24156,13 @@ inline void NormalizedBBox::clear_score() { clear_has_score(); } inline float NormalizedBBox::score() const { + // @@protoc_insertion_point(field_get:caffe.NormalizedBBox.score) return score_; } inline void NormalizedBBox::set_score(float value) { set_has_score(); score_ = value; + // @@protoc_insertion_point(field_set:caffe.NormalizedBBox.score) } // optional float size = 8; @@ -22139,12 +24180,130 @@ inline void NormalizedBBox::clear_size() { clear_has_size(); } inline float NormalizedBBox::size() const { + // @@protoc_insertion_point(field_get:caffe.NormalizedBBox.size) return size_; } inline void NormalizedBBox::set_size(float value) { set_has_size(); size_ = value; + // @@protoc_insertion_point(field_set:caffe.NormalizedBBox.size) +} + +inline const NormalizedBBox* NormalizedBBox::internal_default_instance() { + return &NormalizedBBox_default_instance_.get(); } +#endif // !PROTOBUF_INLINE_NOT_IN_HEADERS +// ------------------------------------------------------------------- + +// ------------------------------------------------------------------- + +// ------------------------------------------------------------------- + +// ------------------------------------------------------------------- + +// ------------------------------------------------------------------- + +// ------------------------------------------------------------------- + +// ------------------------------------------------------------------- + +// ------------------------------------------------------------------- + +// ------------------------------------------------------------------- + +// ------------------------------------------------------------------- + +// ------------------------------------------------------------------- + +// ------------------------------------------------------------------- + +// ------------------------------------------------------------------- + +// ------------------------------------------------------------------- + +// ------------------------------------------------------------------- + +// ------------------------------------------------------------------- + +// ------------------------------------------------------------------- + +// ------------------------------------------------------------------- + +// ------------------------------------------------------------------- + +// ------------------------------------------------------------------- + +// ------------------------------------------------------------------- + +// ------------------------------------------------------------------- + +// ------------------------------------------------------------------- + +// ------------------------------------------------------------------- + +// ------------------------------------------------------------------- + +// ------------------------------------------------------------------- + +// ------------------------------------------------------------------- + +// ------------------------------------------------------------------- + +// ------------------------------------------------------------------- + +// ------------------------------------------------------------------- + +// ------------------------------------------------------------------- + +// ------------------------------------------------------------------- + +// ------------------------------------------------------------------- + +// ------------------------------------------------------------------- + +// ------------------------------------------------------------------- + +// ------------------------------------------------------------------- + +// ------------------------------------------------------------------- + +// ------------------------------------------------------------------- + +// ------------------------------------------------------------------- + +// ------------------------------------------------------------------- + +// ------------------------------------------------------------------- + +// ------------------------------------------------------------------- + +// ------------------------------------------------------------------- + +// ------------------------------------------------------------------- + +// ------------------------------------------------------------------- + +// ------------------------------------------------------------------- + +// ------------------------------------------------------------------- + +// ------------------------------------------------------------------- + +// ------------------------------------------------------------------- + +// ------------------------------------------------------------------- + +// ------------------------------------------------------------------- + +// ------------------------------------------------------------------- + +// ------------------------------------------------------------------- + +// ------------------------------------------------------------------- + +// ------------------------------------------------------------------- + +// ------------------------------------------------------------------- // @@protoc_insertion_point(namespace_scope) @@ -22155,101 +24314,124 @@ inline void NormalizedBBox::set_size(float value) { namespace google { namespace protobuf { +template <> struct is_proto_enum< ::caffe::PriorBoxParameter_CodeType> : ::google::protobuf::internal::true_type {}; template <> inline const EnumDescriptor* GetEnumDescriptor< ::caffe::PriorBoxParameter_CodeType>() { return ::caffe::PriorBoxParameter_CodeType_descriptor(); } +template <> struct is_proto_enum< ::caffe::FillerParameter_VarianceNorm> : ::google::protobuf::internal::true_type {}; template <> inline const EnumDescriptor* GetEnumDescriptor< ::caffe::FillerParameter_VarianceNorm>() { return ::caffe::FillerParameter_VarianceNorm_descriptor(); } +template <> struct is_proto_enum< ::caffe::SolverParameter_SolverMode> : ::google::protobuf::internal::true_type {}; template <> inline const EnumDescriptor* GetEnumDescriptor< ::caffe::SolverParameter_SolverMode>() { return ::caffe::SolverParameter_SolverMode_descriptor(); } +template <> struct is_proto_enum< ::caffe::SolverParameter_SolverType> : ::google::protobuf::internal::true_type {}; template <> inline const EnumDescriptor* GetEnumDescriptor< ::caffe::SolverParameter_SolverType>() { return ::caffe::SolverParameter_SolverType_descriptor(); } +template <> struct is_proto_enum< ::caffe::ParamSpec_DimCheckMode> : ::google::protobuf::internal::true_type {}; template <> inline const EnumDescriptor* GetEnumDescriptor< ::caffe::ParamSpec_DimCheckMode>() { return ::caffe::ParamSpec_DimCheckMode_descriptor(); } +template <> struct is_proto_enum< ::caffe::ConvolutionParameter_Engine> : ::google::protobuf::internal::true_type {}; template <> inline const EnumDescriptor* GetEnumDescriptor< ::caffe::ConvolutionParameter_Engine>() { return ::caffe::ConvolutionParameter_Engine_descriptor(); } +template <> struct is_proto_enum< ::caffe::DataParameter_DB> : ::google::protobuf::internal::true_type {}; template <> inline const EnumDescriptor* GetEnumDescriptor< ::caffe::DataParameter_DB>() { return ::caffe::DataParameter_DB_descriptor(); } +template <> struct is_proto_enum< ::caffe::EltwiseParameter_EltwiseOp> : ::google::protobuf::internal::true_type {}; template <> inline const EnumDescriptor* GetEnumDescriptor< ::caffe::EltwiseParameter_EltwiseOp>() { return ::caffe::EltwiseParameter_EltwiseOp_descriptor(); } +template <> struct is_proto_enum< ::caffe::HingeLossParameter_Norm> : ::google::protobuf::internal::true_type {}; template <> inline const EnumDescriptor* GetEnumDescriptor< ::caffe::HingeLossParameter_Norm>() { return ::caffe::HingeLossParameter_Norm_descriptor(); } +template <> struct is_proto_enum< ::caffe::LRNParameter_NormRegion> : ::google::protobuf::internal::true_type {}; template <> inline const EnumDescriptor* GetEnumDescriptor< ::caffe::LRNParameter_NormRegion>() { return ::caffe::LRNParameter_NormRegion_descriptor(); } +template <> struct is_proto_enum< ::caffe::PoolingParameter_PoolMethod> : ::google::protobuf::internal::true_type {}; template <> inline const EnumDescriptor* GetEnumDescriptor< ::caffe::PoolingParameter_PoolMethod>() { return ::caffe::PoolingParameter_PoolMethod_descriptor(); } +template <> struct is_proto_enum< ::caffe::PoolingParameter_Engine> : ::google::protobuf::internal::true_type {}; template <> inline const EnumDescriptor* GetEnumDescriptor< ::caffe::PoolingParameter_Engine>() { return ::caffe::PoolingParameter_Engine_descriptor(); } +template <> struct is_proto_enum< ::caffe::ReductionParameter_ReductionOp> : ::google::protobuf::internal::true_type {}; template <> inline const EnumDescriptor* GetEnumDescriptor< ::caffe::ReductionParameter_ReductionOp>() { return ::caffe::ReductionParameter_ReductionOp_descriptor(); } +template <> struct is_proto_enum< ::caffe::ReLUParameter_Engine> : ::google::protobuf::internal::true_type {}; template <> inline const EnumDescriptor* GetEnumDescriptor< ::caffe::ReLUParameter_Engine>() { return ::caffe::ReLUParameter_Engine_descriptor(); } +template <> struct is_proto_enum< ::caffe::SigmoidParameter_Engine> : ::google::protobuf::internal::true_type {}; template <> inline const EnumDescriptor* GetEnumDescriptor< ::caffe::SigmoidParameter_Engine>() { return ::caffe::SigmoidParameter_Engine_descriptor(); } +template <> struct is_proto_enum< ::caffe::SoftmaxParameter_Engine> : ::google::protobuf::internal::true_type {}; template <> inline const EnumDescriptor* GetEnumDescriptor< ::caffe::SoftmaxParameter_Engine>() { return ::caffe::SoftmaxParameter_Engine_descriptor(); } +template <> struct is_proto_enum< ::caffe::TanHParameter_Engine> : ::google::protobuf::internal::true_type {}; template <> inline const EnumDescriptor* GetEnumDescriptor< ::caffe::TanHParameter_Engine>() { return ::caffe::TanHParameter_Engine_descriptor(); } +template <> struct is_proto_enum< ::caffe::SPPParameter_PoolMethod> : ::google::protobuf::internal::true_type {}; template <> inline const EnumDescriptor* GetEnumDescriptor< ::caffe::SPPParameter_PoolMethod>() { return ::caffe::SPPParameter_PoolMethod_descriptor(); } +template <> struct is_proto_enum< ::caffe::SPPParameter_Engine> : ::google::protobuf::internal::true_type {}; template <> inline const EnumDescriptor* GetEnumDescriptor< ::caffe::SPPParameter_Engine>() { return ::caffe::SPPParameter_Engine_descriptor(); } +template <> struct is_proto_enum< ::caffe::V1LayerParameter_LayerType> : ::google::protobuf::internal::true_type {}; template <> inline const EnumDescriptor* GetEnumDescriptor< ::caffe::V1LayerParameter_LayerType>() { return ::caffe::V1LayerParameter_LayerType_descriptor(); } +template <> struct is_proto_enum< ::caffe::V1LayerParameter_DimCheckMode> : ::google::protobuf::internal::true_type {}; template <> inline const EnumDescriptor* GetEnumDescriptor< ::caffe::V1LayerParameter_DimCheckMode>() { return ::caffe::V1LayerParameter_DimCheckMode_descriptor(); } +template <> struct is_proto_enum< ::caffe::V0LayerParameter_PoolMethod> : ::google::protobuf::internal::true_type {}; template <> inline const EnumDescriptor* GetEnumDescriptor< ::caffe::V0LayerParameter_PoolMethod>() { return ::caffe::V0LayerParameter_PoolMethod_descriptor(); } +template <> struct is_proto_enum< ::caffe::Phase> : ::google::protobuf::internal::true_type {}; template <> inline const EnumDescriptor* GetEnumDescriptor< ::caffe::Phase>() { return ::caffe::Phase_descriptor(); } -} // namespace google } // namespace protobuf +} // namespace google #endif // SWIG // @@protoc_insertion_point(global_scope)