• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_JSON_DECODE_H_
9 #define UPB_JSON_DECODE_H_
10 
11 #include <stddef.h>
12 
13 #include "upb/base/status.h"
14 #include "upb/mem/arena.h"
15 #include "upb/message/message.h"
16 #include "upb/reflection/def.h"
17 
18 // Must be last.
19 #include "upb/port/def.inc"
20 
21 #ifdef __cplusplus
22 extern "C" {
23 #endif
24 
25 enum { upb_JsonDecode_IgnoreUnknown = 1 };
26 
27 enum {
28   kUpb_JsonDecodeResult_Ok = 0,
29   kUpb_JsonDecodeResult_OkWithEmptyStringNumerics = 1,
30   kUpb_JsonDecodeResult_Error = 2,
31 };
32 
33 UPB_API int upb_JsonDecodeDetectingNonconformance(const char* buf, size_t size,
34                                                   upb_Message* msg,
35                                                   const upb_MessageDef* m,
36                                                   const upb_DefPool* symtab,
37                                                   int options, upb_Arena* arena,
38                                                   upb_Status* status);
39 
upb_JsonDecode(const char * buf,size_t size,upb_Message * msg,const upb_MessageDef * m,const upb_DefPool * symtab,int options,upb_Arena * arena,upb_Status * status)40 UPB_API_INLINE bool upb_JsonDecode(const char* buf, size_t size,
41                                    upb_Message* msg, const upb_MessageDef* m,
42                                    const upb_DefPool* symtab, int options,
43                                    upb_Arena* arena, upb_Status* status) {
44   return upb_JsonDecodeDetectingNonconformance(buf, size, msg, m, symtab,
45                                                options, arena, status) ==
46          kUpb_JsonDecodeResult_Ok;
47 }
48 
49 #ifdef __cplusplus
50 } /* extern "C" */
51 #endif
52 
53 #include "upb/port/undef.inc"
54 
55 #endif /* UPB_JSONDECODE_H_ */
56