upb/upb/util/compare.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2009-2021, Google LLC
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions are met:
7  * * Redistributions of source code must retain the above copyright
8  * notice, this list of conditions and the following disclaimer.
9  * * Redistributions in binary form must reproduce the above copyright
10  * notice, this list of conditions and the following disclaimer in the
11  * documentation and/or other materials provided with the distribution.
12  * * Neither the name of Google LLC nor the
13  * names of its contributors may be used to endorse or promote products
14  * derived from this software without specific prior written permission.
15  *
16  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
17  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19  * ARE DISCLAIMED. IN NO EVENT SHALL Google LLC BE LIABLE FOR ANY DIRECT,
20  * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26  */
27 
28 #ifndef UPB_UTIL_COMPARE_H_
29 #define UPB_UTIL_COMPARE_H_
30 
31 #include "upb/def.h"
32 
33 #ifdef __cplusplus
34 extern "C" {
35 #endif
36 
37 // Returns true if unknown fields from the two messages are equal when sorted
38 // and varints are made canonical.
39 //
40 // This function is discouraged, as the comparison is inherently lossy without
41 // schema data:
42 //
43 // 1. We don't know whether delimited fields are sub-messages. Unknown
44 // sub-messages will therefore not have their fields sorted and varints
45 // canonicalized.
46 // 2. We don't know about oneof/non-repeated fields, which should semantically
47 // discard every value except the last.
48 
49 typedef enum {
55 
57  size_t size1,
58  const char* buf2,
59  size_t size2,
60  int max_depth);
61 
62 #ifdef __cplusplus
63 } /* extern "C" */
64 #endif
65 
66 #endif /* UPB_UTIL_COMPARE_H_ */
kUpb_UnknownCompareResult_NotEqual
@ kUpb_UnknownCompareResult_NotEqual
Definition: upb/upb/util/compare.h:51
upb_UnknownCompareResult
upb_UnknownCompareResult
Definition: upb/upb/util/compare.h:49
kUpb_UnknownCompareResult_Equal
@ kUpb_UnknownCompareResult_Equal
Definition: upb/upb/util/compare.h:50
def.h
kUpb_UnknownCompareResult_MaxDepthExceeded
@ kUpb_UnknownCompareResult_MaxDepthExceeded
Definition: upb/upb/util/compare.h:53
buf2
static char buf2[32]
Definition: test-fs.c:127
kUpb_UnknownCompareResult_OutOfMemory
@ kUpb_UnknownCompareResult_OutOfMemory
Definition: upb/upb/util/compare.h:52
upb_Message_UnknownFieldsAreEqual
upb_UnknownCompareResult upb_Message_UnknownFieldsAreEqual(const char *buf1, size_t size1, const char *buf2, size_t size2, int max_depth)
Definition: compare.c:263


grpc
Author(s):
autogenerated on Fri May 16 2025 02:58:00