Back to home page

EIC code displayed by LXR

 
 

    


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

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_JSON_ENCODE_H_
0009 #define UPB_JSON_ENCODE_H_
0010 
0011 #include "upb/reflection/def.h"
0012 
0013 // Must be last.
0014 #include "upb/port/def.inc"
0015 
0016 #ifdef __cplusplus
0017 extern "C" {
0018 #endif
0019 
0020 enum {
0021   /* When set, emits 0/default values.  TODO: proto3 only? */
0022   upb_JsonEncode_EmitDefaults = 1 << 0,
0023 
0024   /* When set, use normal (snake_case) field names instead of JSON (camelCase)
0025      names. */
0026   upb_JsonEncode_UseProtoNames = 1 << 1,
0027 
0028   /* When set, emits enums as their integer values instead of as their names. */
0029   upb_JsonEncode_FormatEnumsAsIntegers = 1 << 2
0030 };
0031 
0032 /* Encodes the given |msg| to JSON format.  The message's reflection is given in
0033  * |m|.  The DefPool in |ext_pool| is used to find extensions (if NULL,
0034  * extensions will not be printed).
0035  *
0036  * Output is placed in the given buffer, and always NULL-terminated.  The output
0037  * size (excluding NULL) is returned.  This means that a return value >= |size|
0038  * implies that the output was truncated.  (These are the same semantics as
0039  * snprintf()). */
0040 UPB_API size_t upb_JsonEncode(const upb_Message* msg, const upb_MessageDef* m,
0041                               const upb_DefPool* ext_pool, int options,
0042                               char* buf, size_t size, upb_Status* status);
0043 
0044 #ifdef __cplusplus
0045 } /* extern "C" */
0046 #endif
0047 
0048 #include "upb/port/undef.inc"
0049 
0050 #endif /* UPB_JSONENCODE_H_ */