Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:13:18

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_TABLE_MESSAGE_H_
0009 #define UPB_MINI_TABLE_MESSAGE_H_
0010 
0011 #include "upb/mini_table/enum.h"
0012 #include "upb/mini_table/field.h"
0013 #include "upb/mini_table/internal/message.h"
0014 
0015 // Must be last.
0016 #include "upb/port/def.inc"
0017 
0018 typedef struct upb_MiniTable upb_MiniTable;
0019 
0020 #ifdef __cplusplus
0021 extern "C" {
0022 #endif
0023 
0024 UPB_API const upb_MiniTableField* upb_MiniTable_FindFieldByNumber(
0025     const upb_MiniTable* m, uint32_t number);
0026 
0027 UPB_API_INLINE const upb_MiniTableField* upb_MiniTable_GetFieldByIndex(
0028     const upb_MiniTable* m, uint32_t index);
0029 
0030 UPB_API_INLINE int upb_MiniTable_FieldCount(const upb_MiniTable* m);
0031 
0032 // DEPRECATED: use upb_MiniTable_SubMessage() instead
0033 // Returns the MiniTable for a message field, NULL if the field is unlinked.
0034 UPB_API_INLINE const upb_MiniTable* upb_MiniTable_GetSubMessageTable(
0035     const upb_MiniTable* m, const upb_MiniTableField* f);
0036 
0037 // Returns the MiniTable for a message field if it is a submessage, otherwise
0038 // returns NULL.
0039 //
0040 // WARNING: if dynamic tree shaking is in use, the return value may be the
0041 // "empty", zero-field placeholder message instead of the real message type.
0042 // If the message is later linked, this function will begin returning the real
0043 // message type.
0044 UPB_API_INLINE const upb_MiniTable* upb_MiniTable_SubMessage(
0045     const upb_MiniTable* m, const upb_MiniTableField* f);
0046 
0047 // Returns the MiniTable for a map field.  The given field must refer to a map.
0048 UPB_API_INLINE const upb_MiniTable* upb_MiniTable_MapEntrySubMessage(
0049     const upb_MiniTable* m, const upb_MiniTableField* f);
0050 
0051 // Returns the MiniTableEnum for a message field, NULL if the field is unlinked.
0052 UPB_API_INLINE const upb_MiniTableEnum* upb_MiniTable_GetSubEnumTable(
0053     const upb_MiniTable* m, const upb_MiniTableField* f);
0054 
0055 // Returns the MiniTableField for the key of a map.
0056 UPB_API_INLINE const upb_MiniTableField* upb_MiniTable_MapKey(
0057     const upb_MiniTable* m);
0058 
0059 // Returns the MiniTableField for the value of a map.
0060 UPB_API_INLINE const upb_MiniTableField* upb_MiniTable_MapValue(
0061     const upb_MiniTable* m);
0062 
0063 // Returns true if this MiniTable field is linked to a MiniTable for the
0064 // sub-message.
0065 UPB_API_INLINE bool upb_MiniTable_FieldIsLinked(const upb_MiniTable* m,
0066                                                 const upb_MiniTableField* f);
0067 
0068 // If this field is in a oneof, returns the first field in the oneof.
0069 //
0070 // Otherwise returns NULL.
0071 //
0072 // Usage:
0073 //   const upb_MiniTableField* field = upb_MiniTable_GetOneof(m, f);
0074 //   do {
0075 //       ..
0076 //   } while (upb_MiniTable_NextOneofField(m, &field);
0077 //
0078 const upb_MiniTableField* upb_MiniTable_GetOneof(const upb_MiniTable* m,
0079                                                  const upb_MiniTableField* f);
0080 
0081 // Iterates to the next field in the oneof. If this is the last field in the
0082 // oneof, returns false. The ordering of fields in the oneof is not
0083 // guaranteed.
0084 // REQUIRES: |f| is the field initialized by upb_MiniTable_GetOneof and updated
0085 //           by prior upb_MiniTable_NextOneofField calls.
0086 bool upb_MiniTable_NextOneofField(const upb_MiniTable* m,
0087                                   const upb_MiniTableField** f);
0088 
0089 #ifdef __cplusplus
0090 } /* extern "C" */
0091 #endif
0092 
0093 #include "upb/port/undef.inc"
0094 
0095 #endif /* UPB_MINI_TABLE_MESSAGE_H_ */