123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170 |
- #ifndef PB_ENCODE_H_INCLUDED
- #define PB_ENCODE_H_INCLUDED
- #include "pb.h"
- #ifdef __cplusplus
- extern "C" {
- #endif
- struct pb_ostream_s
- {
- #ifdef PB_BUFFER_ONLY
-
- int *callback;
- #else
- bool (*callback)(pb_ostream_t *stream, const pb_byte_t *buf, size_t count);
- #endif
- void *state;
- size_t max_size;
- size_t bytes_written;
-
- #ifndef PB_NO_ERRMSG
- const char *errmsg;
- #endif
- };
- bool pb_encode(pb_ostream_t *stream, const pb_field_t fields[], const void *src_struct);
- bool pb_encode_delimited(pb_ostream_t *stream, const pb_field_t fields[], const void *src_struct);
- bool pb_encode_nullterminated(pb_ostream_t *stream, const pb_field_t fields[], const void *src_struct);
- bool pb_get_encoded_size(size_t *size, const pb_field_t fields[], const void *src_struct);
- pb_ostream_t pb_ostream_from_buffer(pb_byte_t *buf, size_t bufsize);
- #ifndef PB_NO_ERRMSG
- #define PB_OSTREAM_SIZING {0,0,0,0,0}
- #else
- #define PB_OSTREAM_SIZING {0,0,0,0}
- #endif
- bool pb_write(pb_ostream_t *stream, const pb_byte_t *buf, size_t count);
- bool pb_encode_tag_for_field(pb_ostream_t *stream, const pb_field_t *field);
- bool pb_encode_tag(pb_ostream_t *stream, pb_wire_type_t wiretype, uint32_t field_number);
- #ifndef PB_WITHOUT_64BIT
- bool pb_encode_varint(pb_ostream_t *stream, uint64_t value);
- #else
- bool pb_encode_varint(pb_ostream_t *stream, uint32_t value);
- #endif
- #ifndef PB_WITHOUT_64BIT
- bool pb_encode_svarint(pb_ostream_t *stream, int64_t value);
- #else
- bool pb_encode_svarint(pb_ostream_t *stream, int32_t value);
- #endif
- bool pb_encode_string(pb_ostream_t *stream, const pb_byte_t *buffer, size_t size);
- bool pb_encode_fixed32(pb_ostream_t *stream, const void *value);
- #ifndef PB_WITHOUT_64BIT
- bool pb_encode_fixed64(pb_ostream_t *stream, const void *value);
- #endif
- bool pb_encode_submessage(pb_ostream_t *stream, const pb_field_t fields[], const void *src_struct);
- #ifdef __cplusplus
- }
- #endif
- #endif
|