Protocol Buffers - Google's data interchange format (grpc依赖) https://developers.google.com/protocol-buffers/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

185 lines
5.5 KiB

// Protocol Buffers - Google's data interchange format
// Copyright 2023 Google LLC. All rights reserved.
// https://developers.google.com/protocol-buffers/
//
// 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 LLC 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.
syntax = "proto2";
package protos_generator.test;
import "upb/protos_generator/tests/child_model.proto";
message TestModelContainer {
repeated TestModel models = 1;
optional ChildModel3 proto_3_child = 2;
}
message TestModel {
optional int32 value = 1;
repeated int32 value_array = 2; // _UPB_MODE_ARRAY
repeated int32 value_packed_array = 3
[packed = true]; // _UPB_MODE_ARRAY | _UPB_MODE_IS_PACKED
repeated int32 value_deprec = 4 [deprecated = true];
optional string str1 = 115;
optional bool b1 = 9;
optional bool b2 = 10;
optional string str2 = 50;
optional string str3 = 11;
optional float optional_float = 14;
optional double optional_double = 15;
optional int64 optional_int64 = 16;
optional uint32 optional_uint32 = 17;
optional uint64 optional_uint64 = 18;
optional sint32 optional_sint32 = 19;
optional sint64 optional_sint64 = 20;
optional fixed32 optional_fixed32 = 21;
optional fixed64 optional_fixed64 = 22;
optional sfixed32 optional_sfixed32 = 23;
optional sfixed64 optional_sfixed64 = 24;
repeated int64 repeated_int64 = 25;
repeated uint64 repeated_uint64 = 26;
repeated fixed64 repeated_fixed64 = 27;
repeated sfixed64 repeated_sfixed64 = 28;
repeated bool repeated_bool = 29;
repeated string repeated_string = 35;
optional bytes optional_bytes = 36;
message NestedChild {
optional string nested_child_name = 211;
}
optional NestedChild nested_child_1 = 212;
optional ChildModel1 child_model_1 = 222;
repeated ChildModel1 child_models = 223;
optional ChildModel1 bar = 224;
oneof child_oneof1 {
string oneof_member1 = 98;
bool oneof_member2 = 99;
}
optional int32 int_value_with_default = 31
[default = 65]; // Not supported yet
optional string string_value_with_default = 32
[default = "hello"]; // Not supported yet
optional float float_value_with_default = 33 [default = inf];
optional float double_value_with_default = 34 [default = -inf];
map<int32, ChildModel1> child_map = 225;
optional TestModel recursive_child = 226;
map<string, ChildModel1> child_str_map = 227;
map<string, int32> str_to_int_map = 228;
map<string, string> str_to_str_map = 229;
extend TestAnnotation {
optional OtherExtension in_message_ext = 15000;
}
enum Category {
IMAGES = 5;
NEWS = 6;
VIDEO = 7;
RADIO = 8 [deprecated = true];
}
optional Category category = 37;
// keyword collisions (double, template, ...)
oneof type {
string string = 230;
int64 int64 = 231;
double double = 232;
}
optional string template = 233;
optional string msg = 234;
optional string arena = 235;
// Tests publicly imported enum.
optional TestEnum imported_enum = 238;
optional string phase = 239;
optional bool clear_phase = 240;
optional string doc_id = 241;
optional bool set_doc_id = 242;
extensions 10000 to max;
}
// Old version with fewer fields to test backward/forward compatibility.
message TestModelContainerV1 {
repeated TestModelV1 models = 1;
}
message TestModelV1 {
optional int32 value = 1;
repeated int32 value2 = 2;
repeated int32 value3 = 3 [packed = true];
repeated int32 value4 = 4 [deprecated = true];
optional bool b1 = 9;
optional bool b2 = 10;
optional string str2 = 50;
}
enum PrimaryColors {
RED = 1;
GREEN = 2;
BLUE = 3;
}
// TestModel extension.
message ThemeExtension {
extend TestModel {
optional ThemeExtension theme_extension = 12003;
}
optional string ext_name = 1;
optional bool ext_bool = 2;
}
extend TestModel {
optional ThemeExtension theme = 12001;
}
message OtherExtension {
optional string ext2_name = 1;
}
extend TestModel {
optional OtherExtension other_ext = 12002;
}
message TestAnnotation {
extensions 10000 to max;
}
message TestMessageHasEnum {
optional EnumDeclaredAfterMessage enum_declared_after_message = 1;
}
enum EnumDeclaredAfterMessage {
ZERO = 0;
ONE = 1;
TWO = 2;
THREE = 3;
}