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_MESSAGE_INTERNAL_COMPARE_UNKNOWN_H_ 9 #define UPB_MESSAGE_INTERNAL_COMPARE_UNKNOWN_H_ 10 11 #include <stddef.h> 12 13 // Must be last. 14 #include "upb/port/def.inc" 15 16 #ifdef __cplusplus 17 extern "C" { 18 #endif 19 20 // Returns true if unknown fields from the two messages are equal when sorted 21 // and varints are made canonical. 22 // 23 // This function is discouraged, as the comparison is inherently lossy without 24 // schema data: 25 // 26 // 1. We don't know whether delimited fields are sub-messages. Unknown 27 // sub-messages will therefore not have their fields sorted and varints 28 // canonicalized. 29 // 2. We don't know about oneof/non-repeated fields, which should semantically 30 // discard every value except the last. 31 32 typedef enum { 33 kUpb_UnknownCompareResult_Equal = 0, 34 kUpb_UnknownCompareResult_NotEqual = 1, 35 kUpb_UnknownCompareResult_OutOfMemory = 2, 36 kUpb_UnknownCompareResult_MaxDepthExceeded = 3, 37 } upb_UnknownCompareResult; 38 39 upb_UnknownCompareResult UPB_PRIVATE(_upb_Message_UnknownFieldsAreEqual)( 40 const char* buf1, size_t size1, const char* buf2, size_t size2, 41 int max_depth); 42 43 #ifdef __cplusplus 44 } /* extern "C" */ 45 #endif 46 47 #include "upb/port/undef.inc" 48 49 #endif /* UPB_MESSAGE_INTERNAL_COMPARE_UNKNOWN_H_ */ 50