|
||||
File indexing completed on 2025-01-18 10:13:17
0001 // Protocol Buffers - Google's data interchange format 0002 // Copyright 2023 Google LLC. All rights reserved. 0003 // 0004 // Use of this source code is governed by a BSD-style 0005 // license that can be found in the LICENSE file or at 0006 // https://developers.google.com/open-source/licenses/bsd 0007 0008 #ifndef UPB_MINI_DESCRIPTOR_INTERNAL_ENCODE_H_ 0009 #define UPB_MINI_DESCRIPTOR_INTERNAL_ENCODE_H_ 0010 0011 #include <stdint.h> 0012 0013 #include "upb/base/descriptor_constants.h" 0014 0015 // Must be last. 0016 #include "upb/port/def.inc" 0017 0018 // If the input buffer has at least this many bytes available, the encoder call 0019 // is guaranteed to succeed (as long as field number order is maintained). 0020 #define kUpb_MtDataEncoder_MinSize 16 0021 0022 typedef struct { 0023 char* end; // Limit of the buffer passed as a parameter. 0024 // Aliased to internal-only members in .cc. 0025 char internal[32]; 0026 } upb_MtDataEncoder; 0027 0028 #ifdef __cplusplus 0029 extern "C" { 0030 #endif 0031 0032 // Encodes field/oneof information for a given message. The sequence of calls 0033 // should look like: 0034 // 0035 // upb_MtDataEncoder e; 0036 // char buf[256]; 0037 // char* ptr = buf; 0038 // e.end = ptr + sizeof(buf); 0039 // unit64_t msg_mod = ...; // bitwise & of kUpb_MessageModifiers or zero 0040 // ptr = upb_MtDataEncoder_StartMessage(&e, ptr, msg_mod); 0041 // // Fields *must* be in field number order. 0042 // ptr = upb_MtDataEncoder_PutField(&e, ptr, ...); 0043 // ptr = upb_MtDataEncoder_PutField(&e, ptr, ...); 0044 // ptr = upb_MtDataEncoder_PutField(&e, ptr, ...); 0045 // 0046 // // If oneofs are present. Oneofs must be encoded after regular fields. 0047 // ptr = upb_MiniTable_StartOneof(&e, ptr) 0048 // ptr = upb_MiniTable_PutOneofField(&e, ptr, ...); 0049 // ptr = upb_MiniTable_PutOneofField(&e, ptr, ...); 0050 // 0051 // ptr = upb_MiniTable_StartOneof(&e, ptr); 0052 // ptr = upb_MiniTable_PutOneofField(&e, ptr, ...); 0053 // ptr = upb_MiniTable_PutOneofField(&e, ptr, ...); 0054 // 0055 // Oneofs must be encoded after all regular fields. 0056 char* upb_MtDataEncoder_StartMessage(upb_MtDataEncoder* e, char* ptr, 0057 uint64_t msg_mod); 0058 char* upb_MtDataEncoder_PutField(upb_MtDataEncoder* e, char* ptr, 0059 upb_FieldType type, uint32_t field_num, 0060 uint64_t field_mod); 0061 char* upb_MtDataEncoder_StartOneof(upb_MtDataEncoder* e, char* ptr); 0062 char* upb_MtDataEncoder_PutOneofField(upb_MtDataEncoder* e, char* ptr, 0063 uint32_t field_num); 0064 0065 // Encodes the set of values for a given enum. The values must be given in 0066 // order (after casting to uint32_t), and repeats are not allowed. 0067 char* upb_MtDataEncoder_StartEnum(upb_MtDataEncoder* e, char* ptr); 0068 char* upb_MtDataEncoder_PutEnumValue(upb_MtDataEncoder* e, char* ptr, 0069 uint32_t val); 0070 char* upb_MtDataEncoder_EndEnum(upb_MtDataEncoder* e, char* ptr); 0071 0072 // Encodes an entire mini descriptor for an extension. 0073 char* upb_MtDataEncoder_EncodeExtension(upb_MtDataEncoder* e, char* ptr, 0074 upb_FieldType type, uint32_t field_num, 0075 uint64_t field_mod); 0076 0077 // Encodes an entire mini descriptor for a map. 0078 char* upb_MtDataEncoder_EncodeMap(upb_MtDataEncoder* e, char* ptr, 0079 upb_FieldType key_type, 0080 upb_FieldType value_type, uint64_t key_mod, 0081 uint64_t value_mod); 0082 0083 // Encodes an entire mini descriptor for a message set. 0084 char* upb_MtDataEncoder_EncodeMessageSet(upb_MtDataEncoder* e, char* ptr); 0085 0086 #ifdef __cplusplus 0087 } /* extern "C" */ 0088 #endif 0089 0090 #include "upb/port/undef.inc" 0091 0092 #endif /* UPB_MINI_DESCRIPTOR_INTERNAL_ENCODE_H_ */
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |