18 if (ostream && field->tag == SubMsg3_strvalue_tag)
21 const char *str = *(
const char**)field->pData;
38 for (i = 0; i < 15; i++)
51 const char *str =
"mystring";
62 OneOfMessage msg = OneOfMessage_init_zero;
68 fprintf(
stderr,
"Usage: encode_oneof [number]\n");
80 msg.which_values = OneOfMessage_intvalue_tag;
81 msg.values.intvalue = 999;
85 msg.which_values = OneOfMessage_strvalue_tag;
86 strcpy(msg.values.strvalue,
"abcd");
90 msg.which_values = OneOfMessage_submsg1_tag;
95 msg.which_values = OneOfMessage_submsg2_tag;
100 msg.which_values = OneOfMessage_submsg3_tag;
101 msg.values.submsg3.which_values = SubMsg3_intvalue_tag;
102 msg.values.submsg3.values.intvalue = 1234;
104 else if (option == 6)
106 msg.which_values = OneOfMessage_submsg3_tag;
107 msg.values.submsg3.which_values = SubMsg3_strvalue_tag;
108 msg.values.submsg3.values.strvalue =
"efgh";
115 if (
pb_encode(&stream, OneOfMessage_fields, &msg))
MOSAPI char * strcpy(char *__restrict dest, const char *__restrict src)
size_t fwrite(const void *__restrict ptr, size_t size, size_t nmemb, FILE *__restrict stream)
MOSAPI s32 atoi(const char *nptr)
bool encode_int32_array(pb_ostream_t *stream, const pb_field_t *field, void *const *arg)
bool encode_string(pb_ostream_t *stream, const pb_field_t *field, void *const *arg)
bool SubMsg3_callback(pb_istream_t *istream, pb_ostream_t *ostream, const pb_field_t *field)
#define PB_GET_ERROR(stream)
pb_field_iter_t pb_field_t
bool pb_encode_tag_for_field(pb_ostream_t *stream, const pb_field_iter_t *field)
bool pb_encode_varint(pb_ostream_t *stream, uint64_t value)
pb_ostream_t pb_ostream_from_buffer(pb_byte_t *buf, size_t bufsize)
bool pb_encode(pb_ostream_t *stream, const pb_msgdesc_t *fields, const void *src_struct)
bool pb_encode_string(pb_ostream_t *stream, const pb_byte_t *buffer, size_t size)
static size_t strlen(const char *s)
#define SET_BINARY_MODE(file)