• Home
  • Raw
  • Download

Lines Matching refs:stream

22 typedef bool (*pb_encoder_t)(pb_ostream_t *stream, const pb_field_t *field, const void *src) checkr…
24 static bool checkreturn buf_write(pb_ostream_t *stream, const uint8_t *buf, size_t count);
25 static bool checkreturn encode_array(pb_ostream_t *stream, const pb_field_t *field, const void *pDa…
26 static bool checkreturn encode_field(pb_ostream_t *stream, const pb_field_t *field, const void *pDa…
27 static bool checkreturn default_extension_encoder(pb_ostream_t *stream, const pb_extension_t *exten…
28 static bool checkreturn encode_extension_field(pb_ostream_t *stream, const pb_field_t *field, const…
29 static bool checkreturn pb_enc_varint(pb_ostream_t *stream, const pb_field_t *field, const void *sr…
30 static bool checkreturn pb_enc_uvarint(pb_ostream_t *stream, const pb_field_t *field, const void *s…
31 static bool checkreturn pb_enc_svarint(pb_ostream_t *stream, const pb_field_t *field, const void *s…
32 static bool checkreturn pb_enc_fixed32(pb_ostream_t *stream, const pb_field_t *field, const void *s…
33 static bool checkreturn pb_enc_fixed64(pb_ostream_t *stream, const pb_field_t *field, const void *s…
34 static bool checkreturn pb_enc_bytes(pb_ostream_t *stream, const pb_field_t *field, const void *src…
35 static bool checkreturn pb_enc_string(pb_ostream_t *stream, const pb_field_t *field, const void *sr…
36 static bool checkreturn pb_enc_submessage(pb_ostream_t *stream, const pb_field_t *field, const void…
58 static bool checkreturn buf_write(pb_ostream_t *stream, const uint8_t *buf, size_t count) in buf_write() argument
60 uint8_t *dest = (uint8_t*)stream->state; in buf_write()
61 stream->state = dest + count; in buf_write()
71 pb_ostream_t stream; in pb_ostream_from_buffer() local
73 stream.callback = (void*)1; /* Just a marker value */ in pb_ostream_from_buffer()
75 stream.callback = &buf_write; in pb_ostream_from_buffer()
77 stream.state = buf; in pb_ostream_from_buffer()
78 stream.max_size = bufsize; in pb_ostream_from_buffer()
79 stream.bytes_written = 0; in pb_ostream_from_buffer()
81 stream.errmsg = NULL; in pb_ostream_from_buffer()
83 return stream; in pb_ostream_from_buffer()
86 bool checkreturn pb_write(pb_ostream_t *stream, const uint8_t *buf, size_t count) in pb_write() argument
88 if (stream->callback != NULL) in pb_write()
90 if (stream->bytes_written + count > stream->max_size) in pb_write()
91 PB_RETURN_ERROR(stream, "stream full"); in pb_write()
94 if (!buf_write(stream, buf, count)) in pb_write()
95 PB_RETURN_ERROR(stream, "io error"); in pb_write()
97 if (!stream->callback(stream, buf, count)) in pb_write()
98 PB_RETURN_ERROR(stream, "io error"); in pb_write()
102 stream->bytes_written += count; in pb_write()
111 static bool checkreturn encode_array(pb_ostream_t *stream, const pb_field_t *field, in encode_array() argument
122 PB_RETURN_ERROR(stream, "array max size exceeded"); in encode_array()
127 if (!pb_encode_tag(stream, PB_WT_STRING, field->tag)) in encode_array()
152 if (!pb_encode_varint(stream, (uint64_t)size)) in encode_array()
155 if (stream->callback == NULL) in encode_array()
156 return pb_write(stream, NULL, size); /* Just sizing.. */ in encode_array()
162 if (!func(stream, field, p)) in encode_array()
172 if (!pb_encode_tag_for_field(stream, field)) in encode_array()
183 if (!func(stream, field, *(const void* const*)p)) in encode_array()
188 if (!func(stream, field, p)) in encode_array()
200 static bool checkreturn encode_basic_field(pb_ostream_t *stream, in encode_basic_field() argument
229 PB_RETURN_ERROR(stream, "missing required field"); in encode_basic_field()
230 if (!pb_encode_tag_for_field(stream, field)) in encode_basic_field()
232 if (!func(stream, field, pData)) in encode_basic_field()
239 if (!pb_encode_tag_for_field(stream, field)) in encode_basic_field()
242 if (!func(stream, field, pData)) in encode_basic_field()
248 if (!encode_array(stream, field, pData, *(const size_t*)pSize, func)) in encode_basic_field()
253 PB_RETURN_ERROR(stream, "invalid field type"); in encode_basic_field()
261 static bool checkreturn encode_callback_field(pb_ostream_t *stream, in encode_callback_field() argument
274 if (!callback->funcs.encode(stream, field, arg)) in encode_callback_field()
275 PB_RETURN_ERROR(stream, "callback error"); in encode_callback_field()
281 static bool checkreturn encode_field(pb_ostream_t *stream, in encode_field() argument
288 return encode_basic_field(stream, field, pData); in encode_field()
291 return encode_callback_field(stream, field, pData); in encode_field()
294 PB_RETURN_ERROR(stream, "invalid field type"); in encode_field()
300 static bool checkreturn default_extension_encoder(pb_ostream_t *stream, in default_extension_encoder() argument
304 return encode_field(stream, field, extension->dest); in default_extension_encoder()
309 static bool checkreturn encode_extension_field(pb_ostream_t *stream, in encode_extension_field() argument
319 status = extension->type->encode(stream, extension); in encode_extension_field()
321 status = default_extension_encoder(stream, extension); in encode_extension_field()
336 bool checkreturn pb_encode(pb_ostream_t *stream, const pb_field_t fields[], const void *src_struct) in pb_encode() argument
360 if (!encode_extension_field(stream, field, pData)) in pb_encode()
366 if (!encode_field(stream, field, pData)) in pb_encode()
376 bool pb_encode_delimited(pb_ostream_t *stream, const pb_field_t fields[], const void *src_struct) in pb_encode_delimited() argument
378 return pb_encode_submessage(stream, fields, src_struct); in pb_encode_delimited()
383 pb_ostream_t stream = PB_OSTREAM_SIZING; in pb_get_encoded_size() local
385 if (!pb_encode(&stream, fields, src_struct)) in pb_get_encoded_size()
388 *size = stream.bytes_written; in pb_get_encoded_size()
395 bool checkreturn pb_encode_varint(pb_ostream_t *stream, uint64_t value) in pb_encode_varint() argument
401 return pb_write(stream, (uint8_t*)&value, 1); in pb_encode_varint()
411 return pb_write(stream, buffer, i); in pb_encode_varint()
414 bool checkreturn pb_encode_svarint(pb_ostream_t *stream, int64_t value) in pb_encode_svarint() argument
422 return pb_encode_varint(stream, zigzagged); in pb_encode_svarint()
425 bool checkreturn pb_encode_fixed32(pb_ostream_t *stream, const void *value) in pb_encode_fixed32() argument
434 return pb_write(stream, lebytes, 4); in pb_encode_fixed32()
436 return pb_write(stream, (const uint8_t*)value, 4); in pb_encode_fixed32()
440 bool checkreturn pb_encode_fixed64(pb_ostream_t *stream, const void *value) in pb_encode_fixed64() argument
453 return pb_write(stream, lebytes, 8); in pb_encode_fixed64()
455 return pb_write(stream, (const uint8_t*)value, 8); in pb_encode_fixed64()
459 bool checkreturn pb_encode_tag(pb_ostream_t *stream, pb_wire_type_t wiretype, uint32_t field_number) in pb_encode_tag() argument
462 return pb_encode_varint(stream, tag); in pb_encode_tag()
465 bool checkreturn pb_encode_tag_for_field(pb_ostream_t *stream, const pb_field_t *field) in pb_encode_tag_for_field() argument
491 PB_RETURN_ERROR(stream, "invalid field type"); in pb_encode_tag_for_field()
494 return pb_encode_tag(stream, wiretype, field->tag); in pb_encode_tag_for_field()
497 bool checkreturn pb_encode_string(pb_ostream_t *stream, const uint8_t *buffer, size_t size) in pb_encode_string() argument
499 if (!pb_encode_varint(stream, (uint64_t)size)) in pb_encode_string()
502 return pb_write(stream, buffer, size); in pb_encode_string()
505 bool checkreturn pb_encode_submessage(pb_ostream_t *stream, const pb_field_t fields[], const void *… in pb_encode_submessage() argument
515 stream->errmsg = substream.errmsg; in pb_encode_submessage()
522 if (!pb_encode_varint(stream, (uint64_t)size)) in pb_encode_submessage()
525 if (stream->callback == NULL) in pb_encode_submessage()
526 return pb_write(stream, NULL, size); /* Just sizing */ in pb_encode_submessage()
528 if (stream->bytes_written + size > stream->max_size) in pb_encode_submessage()
529 PB_RETURN_ERROR(stream, "stream full"); in pb_encode_submessage()
533 substream.callback = stream->callback; in pb_encode_submessage()
534 substream.state = stream->state; in pb_encode_submessage()
543 stream->bytes_written += substream.bytes_written; in pb_encode_submessage()
544 stream->state = substream.state; in pb_encode_submessage()
546 stream->errmsg = substream.errmsg; in pb_encode_submessage()
550 PB_RETURN_ERROR(stream, "submsg size changed"); in pb_encode_submessage()
557 static bool checkreturn pb_enc_varint(pb_ostream_t *stream, const pb_field_t *field, const void *sr… in pb_enc_varint() argument
569 default: PB_RETURN_ERROR(stream, "invalid data_size"); in pb_enc_varint()
572 return pb_encode_varint(stream, (uint64_t)value); in pb_enc_varint()
575 static bool checkreturn pb_enc_uvarint(pb_ostream_t *stream, const pb_field_t *field, const void *s… in pb_enc_uvarint() argument
583 default: PB_RETURN_ERROR(stream, "invalid data_size"); in pb_enc_uvarint()
586 return pb_encode_varint(stream, value); in pb_enc_uvarint()
589 static bool checkreturn pb_enc_svarint(pb_ostream_t *stream, const pb_field_t *field, const void *s… in pb_enc_svarint() argument
597 default: PB_RETURN_ERROR(stream, "invalid data_size"); in pb_enc_svarint()
600 return pb_encode_svarint(stream, value); in pb_enc_svarint()
603 static bool checkreturn pb_enc_fixed64(pb_ostream_t *stream, const pb_field_t *field, const void *s… in pb_enc_fixed64() argument
606 return pb_encode_fixed64(stream, src); in pb_enc_fixed64()
609 static bool checkreturn pb_enc_fixed32(pb_ostream_t *stream, const pb_field_t *field, const void *s… in pb_enc_fixed32() argument
612 return pb_encode_fixed32(stream, src); in pb_enc_fixed32()
615 static bool checkreturn pb_enc_bytes(pb_ostream_t *stream, const pb_field_t *field, const void *src) in pb_enc_bytes() argument
622 return pb_encode_string(stream, NULL, 0); in pb_enc_bytes()
628 PB_RETURN_ERROR(stream, "bytes size exceeded"); in pb_enc_bytes()
631 return pb_encode_string(stream, bytes->bytes, bytes->size); in pb_enc_bytes()
634 static bool checkreturn pb_enc_string(pb_ostream_t *stream, const pb_field_t *field, const void *sr… in pb_enc_string() argument
657 return pb_encode_string(stream, (const uint8_t*)src, size); in pb_enc_string()
660 static bool checkreturn pb_enc_submessage(pb_ostream_t *stream, const pb_field_t *field, const void… in pb_enc_submessage() argument
663 PB_RETURN_ERROR(stream, "invalid field descriptor"); in pb_enc_submessage()
665 return pb_encode_submessage(stream, (const pb_field_t*)field->ptr, src); in pb_enc_submessage()