Adam Cozzette | 501ecec | 2023-09-26 14:36:20 -0700 | [diff] [blame] | 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_TEXT_ENCODE_H_ |
| 9 | #define UPB_TEXT_ENCODE_H_ |
| 10 | |
| 11 | #include "upb/reflection/def.h" |
| 12 | |
| 13 | // Must be last. |
| 14 | #include "upb/port/def.inc" |
| 15 | |
| 16 | #ifdef __cplusplus |
| 17 | extern "C" { |
| 18 | #endif |
| 19 | |
| 20 | enum { |
| 21 | // When set, prints everything on a single line. |
| 22 | UPB_TXTENC_SINGLELINE = 1, |
| 23 | |
| 24 | // When set, unknown fields are not printed. |
| 25 | UPB_TXTENC_SKIPUNKNOWN = 2, |
| 26 | |
| 27 | // When set, maps are *not* sorted (this avoids allocating tmp mem). |
| 28 | UPB_TXTENC_NOSORT = 4 |
| 29 | }; |
| 30 | |
| 31 | /* Encodes the given |msg| to text format. The message's reflection is given in |
| 32 | * |m|. The symtab in |symtab| is used to find extensions (if NULL, extensions |
| 33 | * will not be printed). |
| 34 | * |
| 35 | * Output is placed in the given buffer, and always NULL-terminated. The output |
| 36 | * size (excluding NULL) is returned. This means that a return value >= |size| |
| 37 | * implies that the output was truncated. (These are the same semantics as |
| 38 | * snprintf()). */ |
| 39 | size_t upb_TextEncode(const upb_Message* msg, const upb_MessageDef* m, |
| 40 | const upb_DefPool* ext_pool, int options, char* buf, |
| 41 | size_t size); |
| 42 | |
| 43 | #ifdef __cplusplus |
| 44 | } /* extern "C" */ |
| 45 | #endif |
| 46 | |
| 47 | #include "upb/port/undef.inc" |
| 48 | |
| 49 | #endif /* UPB_TEXT_ENCODE_H_ */ |