WPILibC++ 2027.0.0-alpha-3
Loading...
Searching...
No Matches
encode.h
Go to the documentation of this file.
1// Protocol Buffers - Google's data interchange format
2// Copyright 2023 Google LLC. All rights reserved.
3//
4// Use of this source code is governed by a BSD-style
5// license that can be found in the LICENSE file or at
6// https://developers.google.com/open-source/licenses/bsd
7
8#ifndef UPB_MINI_DESCRIPTOR_INTERNAL_ENCODE_H_
9#define UPB_MINI_DESCRIPTOR_INTERNAL_ENCODE_H_
10
11#include <stdint.h>
12
14
15// Must be last.
16#include "upb/port/def.inc"
17
18// If the input buffer has at least this many bytes available, the encoder call
19// is guaranteed to succeed (as long as field number order is maintained).
20#define kUpb_MtDataEncoder_MinSize 16
21
22typedef struct {
23 char* end; // Limit of the buffer passed as a parameter.
24 // Aliased to internal-only members in .cc.
25 char internal[32];
27
28#ifdef __cplusplus
29extern "C" {
30#endif
31
32// Encodes field/oneof information for a given message. The sequence of calls
33// should look like:
34//
35// upb_MtDataEncoder e;
36// char buf[256];
37// char* ptr = buf;
38// e.end = ptr + sizeof(buf);
39// unit64_t msg_mod = ...; // bitwise & of kUpb_MessageModifiers or zero
40// ptr = upb_MtDataEncoder_StartMessage(&e, ptr, msg_mod);
41// // Fields *must* be in field number order.
42// ptr = upb_MtDataEncoder_PutField(&e, ptr, ...);
43// ptr = upb_MtDataEncoder_PutField(&e, ptr, ...);
44// ptr = upb_MtDataEncoder_PutField(&e, ptr, ...);
45//
46// // If oneofs are present. Oneofs must be encoded after regular fields.
47// ptr = upb_MiniTable_StartOneof(&e, ptr)
48// ptr = upb_MiniTable_PutOneofField(&e, ptr, ...);
49// ptr = upb_MiniTable_PutOneofField(&e, ptr, ...);
50//
51// ptr = upb_MiniTable_StartOneof(&e, ptr);
52// ptr = upb_MiniTable_PutOneofField(&e, ptr, ...);
53// ptr = upb_MiniTable_PutOneofField(&e, ptr, ...);
54//
55// Oneofs must be encoded after all regular fields.
57 uint64_t msg_mod);
59 upb_FieldType type, uint32_t field_num,
60 uint64_t field_mod);
63 uint32_t field_num);
64
65// Encodes the set of values for a given enum. The values must be given in
66// order (after casting to uint32_t), and repeats are not allowed.
69 uint32_t val);
71
72// Encodes an entire mini descriptor for an extension.
74 upb_FieldType type, uint32_t field_num,
75 uint64_t field_mod);
76
77// Encodes an entire mini descriptor for a map.
79 upb_FieldType key_type,
80 upb_FieldType value_type, uint64_t key_mod,
81 uint64_t value_mod);
82
83// Encodes an entire mini descriptor for a message set.
85
86#ifdef __cplusplus
87} /* extern "C" */
88#endif
89
90#include "upb/port/undef.inc"
91
92#endif /* UPB_MINI_DESCRIPTOR_INTERNAL_ENCODE_H_ */
upb_FieldType
Definition descriptor_constants.h:40
auto ptr(T p) -> const void *
Converts p to const void* for pointer formatting.
Definition format.h:3963
char * upb_MtDataEncoder_PutEnumValue(upb_MtDataEncoder *e, char *ptr, uint32_t val)
char * upb_MtDataEncoder_EndEnum(upb_MtDataEncoder *e, char *ptr)
char * upb_MtDataEncoder_EncodeExtension(upb_MtDataEncoder *e, char *ptr, upb_FieldType type, uint32_t field_num, uint64_t field_mod)
char * upb_MtDataEncoder_StartEnum(upb_MtDataEncoder *e, char *ptr)
char * upb_MtDataEncoder_StartOneof(upb_MtDataEncoder *e, char *ptr)
char * upb_MtDataEncoder_EncodeMap(upb_MtDataEncoder *e, char *ptr, upb_FieldType key_type, upb_FieldType value_type, uint64_t key_mod, uint64_t value_mod)
char * upb_MtDataEncoder_PutField(upb_MtDataEncoder *e, char *ptr, upb_FieldType type, uint32_t field_num, uint64_t field_mod)
char * upb_MtDataEncoder_StartMessage(upb_MtDataEncoder *e, char *ptr, uint64_t msg_mod)
char * upb_MtDataEncoder_EncodeMessageSet(upb_MtDataEncoder *e, char *ptr)
char * upb_MtDataEncoder_PutOneofField(upb_MtDataEncoder *e, char *ptr, uint32_t field_num)
Definition encode.h:22
char * end
Definition encode.h:23