@@ -329,12 +329,91 @@ A scalar message field can have one of the following types – the table shows t
329
329
type specified in the ` .proto ` file, and the corresponding type in the
330
330
automatically generated class:
331
331
332
- <div style = " overflow : auto ; width : 100 % ; " >
333
- <table style = " width : 110 % ; " >
332
+ <div >
333
+ <table >
334
334
<tbody>
335
335
<tr>
336
- <th>.proto Type</th>
336
+ <th>Proto Type</th>
337
337
<th>Notes</th>
338
+ </tr>
339
+ <tr>
340
+ <td>double</td>
341
+ <td></td>
342
+ </tr>
343
+ <tr>
344
+ <td>float</td>
345
+ <td></td>
346
+ </tr>
347
+ <tr>
348
+ <td>int32</td>
349
+ <td>Uses variable-length encoding. Inefficient for encoding negative
350
+ numbers – if your field is likely to have negative values, use sint32
351
+ instead.</td>
352
+ </tr>
353
+ <tr>
354
+ <td>int64</td>
355
+ <td>Uses variable-length encoding. Inefficient for encoding negative
356
+ numbers – if your field is likely to have negative values, use sint64
357
+ instead.</td>
358
+ </tr>
359
+ <tr>
360
+ <td>uint32</td>
361
+ <td>Uses variable-length encoding.</td>
362
+ </tr>
363
+ <tr>
364
+ <td>uint64</td>
365
+ <td>Uses variable-length encoding.</td>
366
+ </tr>
367
+ <tr>
368
+ <td>sint32</td>
369
+ <td>Uses variable-length encoding. Signed int value. These more
370
+ efficiently encode negative numbers than regular int32s.</td>
371
+ </tr>
372
+ <tr>
373
+ <td>sint64</td>
374
+ <td>Uses variable-length encoding. Signed int value. These more
375
+ efficiently encode negative numbers than regular int64s.</td>
376
+ </tr>
377
+ <tr>
378
+ <td>fixed32</td>
379
+ <td>Always four bytes. More efficient than uint32 if values are often
380
+ greater than 2<sup>28</sup>.</td>
381
+ </tr>
382
+ <tr>
383
+ <td>fixed64</td>
384
+ <td>Always eight bytes. More efficient than uint64 if values are often
385
+ greater than 2<sup>56</sup>.</td>
386
+ </tr>
387
+ <tr>
388
+ <td>sfixed32</td>
389
+ <td>Always four bytes.</td>
390
+ </tr>
391
+ <tr>
392
+ <td>sfixed64</td>
393
+ <td>Always eight bytes.</td>
394
+ </tr>
395
+ <tr>
396
+ <td>bool</td>
397
+ <td></td>
398
+ </tr>
399
+ <tr>
400
+ <td>string</td>
401
+ <td>A string must always contain UTF-8 encoded or 7-bit ASCII text, and cannot
402
+ be longer than 2<sup>32</sup>.</td>
403
+ </tr>
404
+ <tr>
405
+ <td>bytes</td>
406
+ <td>May contain any arbitrary sequence of bytes no longer than 2<sup>32</sup>.</td>
407
+ </tr>
408
+ </tbody>
409
+ </table >
410
+ </div >
411
+
412
+ <div >
413
+ <table style =" width : 100% ;overflow-x : scroll ;" >
414
+ <tbody>
415
+ <tr>
416
+ <th>Proto Type</th>
338
417
<th>C++ Type</th>
339
418
<th>Java/Kotlin Type<sup>[1]</sup></th>
340
419
<th>Python Type<sup>[3]</sup></th>
@@ -347,7 +426,6 @@ automatically generated class:
347
426
</tr>
348
427
<tr>
349
428
<td>double</td>
350
- <td></td>
351
429
<td>double</td>
352
430
<td>double</td>
353
431
<td>float</td>
@@ -360,7 +438,6 @@ automatically generated class:
360
438
</tr>
361
439
<tr>
362
440
<td>float</td>
363
- <td></td>
364
441
<td>float</td>
365
442
<td>float</td>
366
443
<td>float</td>
@@ -373,9 +450,6 @@ automatically generated class:
373
450
</tr>
374
451
<tr>
375
452
<td>int32</td>
376
- <td>Uses variable-length encoding. Inefficient for encoding negative
377
- numbers – if your field is likely to have negative values, use sint32
378
- instead.</td>
379
453
<td>int32_t</td>
380
454
<td>int</td>
381
455
<td>int</td>
@@ -388,9 +462,6 @@ automatically generated class:
388
462
</tr>
389
463
<tr>
390
464
<td>int64</td>
391
- <td>Uses variable-length encoding. Inefficient for encoding negative
392
- numbers – if your field is likely to have negative values, use sint64
393
- instead.</td>
394
465
<td>int64_t</td>
395
466
<td>long</td>
396
467
<td>int/long<sup>[4]</sup></td>
@@ -403,7 +474,6 @@ automatically generated class:
403
474
</tr>
404
475
<tr>
405
476
<td>uint32</td>
406
- <td>Uses variable-length encoding.</td>
407
477
<td>uint32_t</td>
408
478
<td>int<sup>[2]</sup></td>
409
479
<td>int/long<sup>[4]</sup></td>
@@ -416,7 +486,6 @@ automatically generated class:
416
486
</tr>
417
487
<tr>
418
488
<td>uint64</td>
419
- <td>Uses variable-length encoding.</td>
420
489
<td>uint64_t</td>
421
490
<td>long<sup>[2]</sup></td>
422
491
<td>int/long<sup>[4]</sup></td>
@@ -429,8 +498,6 @@ automatically generated class:
429
498
</tr>
430
499
<tr>
431
500
<td>sint32</td>
432
- <td>Uses variable-length encoding. Signed int value. These more
433
- efficiently encode negative numbers than regular int32s.</td>
434
501
<td>int32_t</td>
435
502
<td>int</td>
436
503
<td>int</td>
@@ -443,8 +510,6 @@ automatically generated class:
443
510
</tr>
444
511
<tr>
445
512
<td>sint64</td>
446
- <td>Uses variable-length encoding. Signed int value. These more
447
- efficiently encode negative numbers than regular int64s.</td>
448
513
<td>int64_t</td>
449
514
<td>long</td>
450
515
<td>int/long<sup>[4]</sup></td>
@@ -457,8 +522,6 @@ automatically generated class:
457
522
</tr>
458
523
<tr>
459
524
<td>fixed32</td>
460
- <td>Always four bytes. More efficient than uint32 if values are often
461
- greater than 2<sup>28</sup>.</td>
462
525
<td>uint32_t</td>
463
526
<td>int<sup>[2]</sup></td>
464
527
<td>int/long<sup>[4]</sup></td>
@@ -471,8 +534,6 @@ automatically generated class:
471
534
</tr>
472
535
<tr>
473
536
<td>fixed64</td>
474
- <td>Always eight bytes. More efficient than uint64 if values are often
475
- greater than 2<sup>56</sup>.</td>
476
537
<td>uint64_t</td>
477
538
<td>long<sup>[2]</sup></td>
478
539
<td>int/long<sup>[4]</sup></td>
@@ -485,7 +546,6 @@ automatically generated class:
485
546
</tr>
486
547
<tr>
487
548
<td>sfixed32</td>
488
- <td>Always four bytes.</td>
489
549
<td>int32_t</td>
490
550
<td>int</td>
491
551
<td>int</td>
@@ -498,7 +558,6 @@ automatically generated class:
498
558
</tr>
499
559
<tr>
500
560
<td>sfixed64</td>
501
- <td>Always eight bytes.</td>
502
561
<td>int64_t</td>
503
562
<td>long</td>
504
563
<td>int/long<sup>[4]</sup></td>
@@ -511,7 +570,6 @@ automatically generated class:
511
570
</tr>
512
571
<tr>
513
572
<td>bool</td>
514
- <td></td>
515
573
<td>bool</td>
516
574
<td>boolean</td>
517
575
<td>bool</td>
@@ -524,8 +582,6 @@ automatically generated class:
524
582
</tr>
525
583
<tr>
526
584
<td>string</td>
527
- <td>A string must always contain UTF-8 encoded or 7-bit ASCII text, and cannot
528
- be longer than 2<sup>32</sup>.</td>
529
585
<td>string</td>
530
586
<td>String</td>
531
587
<td>str/unicode<sup>[5]</sup></td>
@@ -538,10 +594,9 @@ automatically generated class:
538
594
</tr>
539
595
<tr>
540
596
<td>bytes</td>
541
- <td>May contain any arbitrary sequence of bytes no longer than 2<sup>32</sup>.</td>
542
597
<td>string</td>
543
598
<td>ByteString</td>
544
- <td>str (Python 2)<br/> bytes (Python 3)</td>
599
+ <td>str (Python 2), bytes (Python 3)</td>
545
600
<td>[]byte</td>
546
601
<td>String (ASCII-8BIT)</td>
547
602
<td>ByteString</td>
@@ -1440,7 +1495,17 @@ language in the relevant [API reference](/reference/).
1440
1495
```
1441
1496
1442
1497
* If the parser encounters multiple members of the same oneof on the wire,
1443
- only the last member seen is used in the parsed message.
1498
+ only the last member seen is used in the parsed message. When parsing data
1499
+ on the wire, starting at the beginning of the bytes, evaluate the next
1500
+ value, and apply the following parsing rules:
1501
+
1502
+ * First, check if a * different* field in the same oneof is currently set,
1503
+ and if so clear it.
1504
+
1505
+ * Then apply the contents as though the field was not in a oneof:
1506
+
1507
+ * A primitive will overwrite any value already set
1508
+ * A message will merge into any value already set
1444
1509
1445
1510
* Extensions are not supported for oneof.
1446
1511
0 commit comments