• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2 ** upb_encode: parsing into a upb_msg using a upb_msglayout.
3 */
4 
5 #ifndef UPB_ENCODE_H_
6 #define UPB_ENCODE_H_
7 
8 #include "upb/msg.h"
9 
10 /* Must be last. */
11 #include "upb/port_def.inc"
12 
13 #ifdef __cplusplus
14 extern "C" {
15 #endif
16 
17 enum {
18   /* If set, the results of serializing will be deterministic across all
19    * instances of this binary. There are no guarantees across different
20    * binary builds.
21    *
22    * If your proto contains maps, the encoder will need to malloc()/free()
23    * memory during encode. */
24   UPB_ENCODE_DETERMINISTIC = 1,
25 
26   /* When set, unknown fields are not printed. */
27   UPB_ENCODE_SKIPUNKNOWN = 2,
28 };
29 
30 #define UPB_ENCODE_MAXDEPTH(depth) ((depth) << 16)
31 
32 char *upb_encode_ex(const void *msg, const upb_msglayout *l, int options,
33                     upb_arena *arena, size_t *size);
34 
upb_encode(const void * msg,const upb_msglayout * l,upb_arena * arena,size_t * size)35 UPB_INLINE char *upb_encode(const void *msg, const upb_msglayout *l,
36                             upb_arena *arena, size_t *size) {
37   return upb_encode_ex(msg, l, 0, arena, size);
38 }
39 
40 #include "upb/port_undef.inc"
41 
42 #ifdef __cplusplus
43 }  /* extern "C" */
44 #endif
45 
46 #endif  /* UPB_ENCODE_H_ */
47