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 // Public APIs for message operations that do not depend on the schema. 9 // 10 // MiniTable-based accessors live in accessors.h. 11 12 #ifndef UPB_MESSAGE_MESSAGE_H_ 13 #define UPB_MESSAGE_MESSAGE_H_ 14 15 #include <stddef.h> 16 17 #include "upb/mem/arena.h" 18 #include "upb/message/internal/message.h" 19 #include "upb/message/internal/types.h" 20 #include "upb/mini_table/message.h" 21 22 // Must be last. 23 #include "upb/port/def.inc" 24 25 typedef struct upb_Message upb_Message; 26 27 #ifdef __cplusplus 28 extern "C" { 29 #endif 30 31 // Creates a new message with the given mini_table on the given arena. 32 UPB_API upb_Message* upb_Message_New(const upb_MiniTable* m, upb_Arena* arena); 33 34 // Returns a reference to the message's unknown data. 35 const char* upb_Message_GetUnknown(const upb_Message* msg, size_t* len); 36 37 // Removes partial unknown data from message. 38 void upb_Message_DeleteUnknown(upb_Message* msg, const char* data, size_t len); 39 40 // Returns the number of extensions present in this message. 41 size_t upb_Message_ExtensionCount(const upb_Message* msg); 42 43 // Mark a message and all of its descendents as frozen/immutable. 44 UPB_API void upb_Message_Freeze(upb_Message* msg, const upb_MiniTable* m); 45 46 // Returns whether a message has been frozen. 47 UPB_API_INLINE bool upb_Message_IsFrozen(const upb_Message* msg); 48 49 #ifdef UPB_TRACING_ENABLED 50 UPB_API void upb_Message_LogNewMessage(const upb_MiniTable* m, 51 const upb_Arena* arena); 52 53 UPB_API void upb_Message_SetNewMessageTraceHandler( 54 void (*handler)(const upb_MiniTable* m, const upb_Arena* arena)); 55 #endif // UPB_TRACING_ENABLED 56 57 #ifdef __cplusplus 58 } /* extern "C" */ 59 #endif 60 61 #include "upb/port/undef.inc" 62 63 #endif /* UPB_MESSAGE_MESSAGE_H_ */ 64