2023-06-05 00:16:05 +01:00
|
|
|
/* SPDX-License-Identifier: MPL-2.0 */
|
2013-03-12 15:26:07 +01:00
|
|
|
|
|
|
|
#ifndef __ZMQ_V2_DECODER_HPP_INCLUDED__
|
|
|
|
#define __ZMQ_V2_DECODER_HPP_INCLUDED__
|
|
|
|
|
|
|
|
#include "decoder.hpp"
|
2015-06-14 19:00:52 +02:00
|
|
|
#include "decoder_allocators.hpp"
|
2013-03-12 15:26:07 +01:00
|
|
|
|
|
|
|
namespace zmq
|
|
|
|
{
|
2015-05-29 23:54:43 +02:00
|
|
|
// Decoder for ZMTP/2.x framing protocol. Converts data stream into messages.
|
|
|
|
// The class has to inherit from shared_message_memory_allocator because
|
|
|
|
// the base class calls allocate in its constructor.
|
2019-12-24 10:39:26 +01:00
|
|
|
class v2_decoder_t ZMQ_FINAL
|
2018-05-24 09:25:01 +02:00
|
|
|
: public decoder_base_t<v2_decoder_t, shared_message_memory_allocator>
|
2015-05-29 23:54:43 +02:00
|
|
|
{
|
|
|
|
public:
|
2018-03-05 13:19:20 +01:00
|
|
|
v2_decoder_t (size_t bufsize_, int64_t maxmsgsize_, bool zero_copy_);
|
2020-02-04 11:57:58 +01:00
|
|
|
~v2_decoder_t ();
|
2013-03-12 15:26:07 +01:00
|
|
|
|
2015-05-29 23:54:43 +02:00
|
|
|
// i_decoder interface.
|
2020-02-04 11:57:58 +01:00
|
|
|
msg_t *msg () { return &_in_progress; }
|
2015-05-29 23:54:43 +02:00
|
|
|
|
2018-02-01 11:46:09 +01:00
|
|
|
private:
|
2015-05-29 23:54:43 +02:00
|
|
|
int flags_ready (unsigned char const *);
|
|
|
|
int one_byte_size_ready (unsigned char const *);
|
|
|
|
int eight_byte_size_ready (unsigned char const *);
|
|
|
|
int message_ready (unsigned char const *);
|
2013-03-12 15:26:07 +01:00
|
|
|
|
|
|
|
int size_ready (uint64_t size_, unsigned char const *);
|
|
|
|
|
2018-05-27 11:10:39 +02:00
|
|
|
unsigned char _tmpbuf[8];
|
|
|
|
unsigned char _msg_flags;
|
|
|
|
msg_t _in_progress;
|
2013-03-12 15:26:07 +01:00
|
|
|
|
2018-05-27 11:10:39 +02:00
|
|
|
const bool _zero_copy;
|
|
|
|
const int64_t _max_msg_size;
|
2013-03-12 15:26:07 +01:00
|
|
|
|
2019-12-08 19:22:04 +01:00
|
|
|
ZMQ_NON_COPYABLE_NOR_MOVABLE (v2_decoder_t)
|
2018-02-01 11:46:09 +01:00
|
|
|
};
|
2013-03-12 15:26:07 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|