1package foo; 2 3import "protobuf-c/protobuf-c.proto"; 4 5option (pb_c_file).const_strings = true; 6 7message SubMess { 8 required int32 test = 4; 9 10 optional int32 val1 = 6; 11 optional int32 val2 = 7; 12 repeated int32 rep = 8; 13 message SubSubMess { 14 optional int32 val1 = 1 [default = 100]; 15 repeated int32 rep = 4; 16 optional bytes bytes1 = 2 [default = "a \0 char"]; 17 optional string str1 = 3 [default = "hello world\n"]; 18 optional string str2 = 5 [default = "hello\0world\n", 19 (pb_c_field).string_as_bytes = true]; 20 } 21 optional SubSubMess sub1 = 9; 22 optional SubSubMess sub2 = 10; 23}; 24 25enum TestEnumSmall { 26 NEG_VALUE = -1; 27 VALUE = 0; 28 OTHER_VALUE = 1; 29} 30 31// these number are specifically chosen to test the 32// boundaries of when an enum requires a certain number of bytes. 33// e.g. 16383 requires 3 bytes; 16384 requires 4. 34enum TestEnum { 35 VALUENEG123456 = -123456; 36 VALUENEG1 = -1; 37 VALUE0 = 0; 38 VALUE1 = 1; 39 VALUE127 = 127; 40 VALUE128 = 128; 41 VALUE16383 = 16383; 42 VALUE16384 = 16384; 43 VALUE2097151 = 2097151; 44 VALUE2097152 = 2097152; 45 VALUE268435455 = 268435455; 46 VALUE268435456 = 268435456; 47} 48enum TestEnumDupValues { 49 VALUE_A = 42; 50 VALUE_B = 42; 51 VALUE_C = 42; 52 VALUE_D = 666; 53 VALUE_E = 666; 54 VALUE_F = 1000; 55 VALUE_AA = 1000; 56 VALUE_BB = 1001; 57 option allow_alias = true; 58} 59 60message TestFieldNo15 { // should use 1 byte header 61 required string test = 15; 62} 63message TestFieldNo16 { // requires 2 byte header 64 required string test = 16; 65} 66message TestFieldNo2047 { // should use 2 byte header 67 required string test = 2047; 68} 69message TestFieldNo2048 { // requires 3 byte header 70 required string test = 2048; 71} 72message TestFieldNo262143 { // should use 3 byte header 73 required string test = 262143; 74} 75message TestFieldNo262144 { // requires 4 byte header 76 required string test = 262144; 77} 78message TestFieldNo33554431 { // should use 4 byte header 79 required string test = 33554431; 80} 81message TestFieldNo33554432 { // requires 5 byte header 82 required string test = 33554432; 83} 84 85message TestMess { 86 repeated int32 test_int32 = 1; 87 repeated sint32 test_sint32 = 2; 88 repeated sfixed32 test_sfixed32 = 3; 89 repeated int64 test_int64 = 4; 90 repeated sint64 test_sint64 = 5; 91 repeated sfixed64 test_sfixed64 = 6; 92 repeated uint32 test_uint32 = 7; 93 repeated fixed32 test_fixed32 = 8; 94 repeated uint64 test_uint64 = 9; 95 repeated fixed64 test_fixed64 = 10; 96 repeated float test_float = 11; 97 repeated double test_double = 12; 98 repeated bool test_boolean = 13; 99 repeated TestEnumSmall test_enum_small = 14; 100 repeated TestEnum test_enum = 15; 101 repeated string test_string = 16; 102 repeated bytes test_bytes = 17; 103 repeated SubMess test_message = 18; 104} 105message TestMessPacked { 106 repeated int32 test_int32 = 1 [packed=true]; 107 repeated sint32 test_sint32 = 2 [packed=true]; 108 repeated sfixed32 test_sfixed32 = 3 [packed=true]; 109 repeated int64 test_int64 = 4 [packed=true]; 110 repeated sint64 test_sint64 = 5 [packed=true]; 111 repeated sfixed64 test_sfixed64 = 6 [packed=true]; 112 repeated uint32 test_uint32 = 7 [packed=true]; 113 repeated fixed32 test_fixed32 = 8 [packed=true]; 114 repeated uint64 test_uint64 = 9 [packed=true]; 115 repeated fixed64 test_fixed64 = 10 [packed=true]; 116 repeated float test_float = 11 [packed=true]; 117 repeated double test_double = 12 [packed=true]; 118 repeated bool test_boolean = 13 [packed=true]; 119 repeated TestEnumSmall test_enum_small = 14 [packed=true]; 120 repeated TestEnum test_enum = 15 [packed=true]; 121} 122 123message TestMessOptional { 124 option (pb_c_msg).gen_pack_helpers = false; 125 option (pb_c_msg).gen_init_helpers = false; 126 optional int32 test_int32 = 1; 127 optional sint32 test_sint32 = 2; 128 optional sfixed32 test_sfixed32 = 3; 129 optional int64 test_int64 = 4; 130 optional sint64 test_sint64 = 5; 131 optional sfixed64 test_sfixed64 = 6; 132 optional uint32 test_uint32 = 7; 133 optional fixed32 test_fixed32 = 8; 134 optional uint64 test_uint64 = 9; 135 optional fixed64 test_fixed64 = 10; 136 optional float test_float = 11; 137 optional double test_double = 12; 138 optional bool test_boolean = 13; 139 optional TestEnumSmall test_enum_small = 14; 140 optional TestEnum test_enum = 15; 141 optional string test_string = 16; 142 optional bytes test_bytes = 17; 143 optional SubMess test_message = 18; 144} 145 146message TestMessOneof { 147 oneof test_oneof { 148 int32 test_int32 = 1; 149 sint32 test_sint32 = 2; 150 sfixed32 test_sfixed32 = 3; 151 int64 test_int64 = 4; 152 sint64 test_sint64 = 5; 153 sfixed64 test_sfixed64 = 6; 154 uint32 test_uint32 = 7; 155 fixed32 test_fixed32 = 8; 156 uint64 test_uint64 = 9; 157 fixed64 test_fixed64 = 10; 158 float test_float = 11; 159 double test_double = 12; 160 bool test_boolean = 13; 161 TestEnumSmall test_enum_small = 14; 162 TestEnum test_enum = 15; 163 string test_string = 16; 164 bytes test_bytes = 17; 165 SubMess test_message = 18; 166 } 167 optional int32 opt_int = 19; 168} 169 170message TestMessRequiredInt32 { 171 required int32 test = 42; 172} 173message TestMessRequiredSInt32 { 174 required sint32 test = 43; 175} 176message TestMessRequiredSFixed32 { 177 required sfixed32 test = 100; 178} 179message TestMessRequiredInt64 { 180 required int64 test = 1; 181} 182message TestMessRequiredSInt64 { 183 required sint64 test = 11; 184} 185message TestMessRequiredSFixed64 { 186 required sfixed64 test = 12; 187} 188message TestMessRequiredUInt32 { 189 required uint32 test = 1; 190} 191message TestMessRequiredFixed32 { 192 required fixed32 test = 1; 193} 194message TestMessRequiredUInt64 { 195 required uint64 test = 1; 196} 197message TestMessRequiredFixed64 { 198 required fixed64 test = 1; 199} 200message TestMessRequiredFloat { 201 required float test = 1; 202} 203message TestMessRequiredDouble { 204 required double test = 1; 205} 206message TestMessRequiredBool { 207 required bool test = 1; 208} 209message TestMessRequiredEnum { 210 required TestEnum test = 1; 211} 212message TestMessRequiredEnumSmall { 213 required TestEnumSmall test = 1; 214} 215message TestMessRequiredString { 216 required string test = 1; 217} 218message TestMessRequiredBytes { 219 required bytes test = 1; 220} 221message TestMessRequiredMessage { 222 required SubMess test = 1; 223} 224message EmptyMess { 225} 226message DefaultRequiredValues { 227 required int32 v_int32 = 1 [default = -42]; 228 required uint32 v_uint32 = 2 [default = 666]; 229 required int32 v_int64 = 3 [default = 100000]; 230 required uint32 v_uint64 = 4 [default = 100001]; 231 required float v_float = 5 [default = 2.5]; 232 required double v_double = 6 [default = 4.5]; 233 required string v_string = 7 [default = "hi mom\n"]; 234 required bytes v_bytes = 8 [default = "a \0 character"]; 235} 236message DefaultOptionalValues { 237 optional int32 v_int32 = 1 [default = -42]; 238 optional uint32 v_uint32 = 2 [default = 666]; 239 optional int32 v_int64 = 3 [default = 100000]; 240 optional uint32 v_uint64 = 4 [default = 100001]; 241 optional float v_float = 5 [default = 2.5]; 242 optional double v_double = 6 [default = 4.5]; 243 optional string v_string = 7 [default = "hi mom\n"]; 244 optional bytes v_bytes = 8 [default = "a \0 character"]; 245} 246message LowerCase { 247 enum CaseEnum { 248 UPPER = 1; 249 lower = 2; 250 } 251 optional CaseEnum value = 1 [default = lower]; 252} 253message AllocValues { 254 optional bytes o_bytes = 1; 255 repeated string r_string = 2; 256 required string a_string = 3; 257 required bytes a_bytes = 4; 258 required DefaultRequiredValues a_mess = 5; 259} 260 261message TestRequiredFieldsBitmap { 262 required string field1 = 1; 263 optional string field2 = 2; 264 optional string field3 = 3; 265 optional string field4 = 4; 266 optional string field5 = 5; 267 optional string field6 = 6; 268 optional string field7 = 7; 269 optional string field8 = 8; 270 optional string field9 = 9; 271 optional string field10 = 10; 272 optional string field11 = 11; 273 optional string field12 = 12; 274 optional string field13 = 13; 275 optional string field14 = 14; 276 optional string field15 = 15; 277 optional string field16 = 16; 278 optional string field17 = 17; 279 optional string field18 = 18; 280 optional string field19 = 19; 281 optional string field20 = 20; 282 optional string field21 = 21; 283 optional string field22 = 22; 284 optional string field23 = 23; 285 optional string field24 = 24; 286 optional string field25 = 25; 287 optional string field26 = 26; 288 optional string field27 = 27; 289 optional string field28 = 28; 290 optional string field29 = 29; 291 optional string field30 = 30; 292 optional string field31 = 31; 293 optional string field32 = 32; 294 optional string field33 = 33; 295 optional string field34 = 34; 296 optional string field35 = 35; 297 optional string field36 = 36; 298 optional string field37 = 37; 299 optional string field38 = 38; 300 optional string field39 = 39; 301 optional string field40 = 40; 302 optional string field41 = 41; 303 optional string field42 = 42; 304 optional string field43 = 43; 305 optional string field44 = 44; 306 optional string field45 = 45; 307 optional string field46 = 46; 308 optional string field47 = 47; 309 optional string field48 = 48; 310 optional string field49 = 49; 311 optional string field50 = 50; 312 optional string field51 = 51; 313 optional string field52 = 52; 314 optional string field53 = 53; 315 optional string field54 = 54; 316 optional string field55 = 55; 317 optional string field56 = 56; 318 optional string field57 = 57; 319 optional string field58 = 58; 320 optional string field59 = 59; 321 optional string field60 = 60; 322 optional string field61 = 61; 323 optional string field62 = 62; 324 optional string field63 = 63; 325 optional string field64 = 64; 326 optional string field65 = 65; 327 optional string field66 = 66; 328 optional string field67 = 67; 329 optional string field68 = 68; 330 optional string field69 = 69; 331 optional string field70 = 70; 332 optional string field71 = 71; 333 optional string field72 = 72; 334 optional string field73 = 73; 335 optional string field74 = 74; 336 optional string field75 = 75; 337 optional string field76 = 76; 338 optional string field77 = 77; 339 optional string field78 = 78; 340 optional string field79 = 79; 341 optional string field80 = 80; 342 optional string field81 = 81; 343 optional string field82 = 82; 344 optional string field83 = 83; 345 optional string field84 = 84; 346 optional string field85 = 85; 347 optional string field86 = 86; 348 optional string field87 = 87; 349 optional string field88 = 88; 350 optional string field89 = 89; 351 optional string field90 = 90; 352 optional string field91 = 91; 353 optional string field92 = 92; 354 optional string field93 = 93; 355 optional string field94 = 94; 356 optional string field95 = 95; 357 optional string field96 = 96; 358 optional string field97 = 97; 359 optional string field98 = 98; 360 optional string field99 = 99; 361 optional string field100 = 100; 362 optional string field101 = 101; 363 optional string field102 = 102; 364 optional string field103 = 103; 365 optional string field104 = 104; 366 optional string field105 = 105; 367 optional string field106 = 106; 368 optional string field107 = 107; 369 optional string field108 = 108; 370 optional string field109 = 109; 371 optional string field110 = 110; 372 optional string field111 = 111; 373 optional string field112 = 112; 374 optional string field113 = 113; 375 optional string field114 = 114; 376 optional string field115 = 115; 377 optional string field116 = 116; 378 optional string field117 = 117; 379 optional string field118 = 118; 380 optional string field119 = 119; 381 optional string field120 = 120; 382 optional string field121 = 121; 383 optional string field122 = 122; 384 optional string field123 = 123; 385 optional string field124 = 124; 386 optional string field125 = 125; 387 optional string field126 = 126; 388 optional string field127 = 127; 389 optional string field128 = 128; 390 required string field129 = 129; 391} 392 393message TestFieldFlags { 394 optional int32 no_flags1 = 1; 395 required int32 no_flags2 = 2; 396 repeated int32 no_flags3 = 3; 397 repeated int32 packed = 4 [packed=true]; 398 repeated int32 packed_deprecated = 5 [packed=true, deprecated=true]; 399 repeated int32 deprecated = 6 [deprecated=true]; 400} 401 402message TestMessageCheck { 403 message SubMessage { 404 required string str = 1; 405 } 406 required SubMessage required_msg = 1; 407 repeated SubMessage repeated_msg = 2; 408 optional SubMessage optional_msg = 3; 409 required string required_string = 4; 410 repeated string repeated_string = 5; 411 optional string optional_string = 6; 412 required bytes required_bytes = 7; 413 repeated bytes repeated_bytes = 8; 414 optional bytes optional_bytes = 9; 415} 416 417message TestMessSubMess { 418 required TestMess rep_mess = 1; 419 required TestMessOptional opt_mess = 2; 420 required TestMessOneof oneof_mess = 3; 421 required SubMess req_mess = 4; 422 required DefaultOptionalValues def_mess = 5; 423} 424