Include ZMTP properties in message metadata

Metadata are built in stream_engine now.
This makes it easy to extend metadata with user-defined properties.
This commit is contained in:
Martin Hurton
2014-05-02 12:33:26 +02:00
parent 55c06924c8
commit 8d82cc2a0b
6 changed files with 60 additions and 22 deletions

View File

@@ -18,7 +18,6 @@
*/
#include <string.h>
#include <map>
#include "mechanism.hpp"
#include "options.hpp"
@@ -27,16 +26,12 @@
#include "wire.hpp"
zmq::mechanism_t::mechanism_t (const options_t &options_) :
metadata (NULL),
options (options_)
{
}
zmq::mechanism_t::~mechanism_t ()
{
if (metadata != NULL)
if (metadata->drop_ref ())
delete metadata;
}
void zmq::mechanism_t::set_peer_identity (const void *id_ptr, size_t id_size)
@@ -90,7 +85,6 @@ size_t zmq::mechanism_t::add_property (unsigned char *ptr, const char *name,
int zmq::mechanism_t::parse_metadata (const unsigned char *ptr_,
size_t length_, bool zap_flag)
{
std::map <const std::string, const std::string> dict;
size_t bytes_left = length_;
while (bytes_left > 1) {
@@ -132,19 +126,19 @@ int zmq::mechanism_t::parse_metadata (const unsigned char *ptr_,
return -1;
}
dict.insert (
std::map <const std::string, const std::string>::value_type (
name, std::string ((char *) value, value_length)));
if (zap_flag)
zap_properties.insert (
metadata_t::dict_t::value_type (
name, std::string ((char *) value, value_length)));
else
zmtp_properties.insert (
metadata_t::dict_t::value_type (
name, std::string ((char *) value, value_length)));
}
if (bytes_left > 0) {
errno = EPROTO;
return -1;
}
if (zap_flag) {
assert (metadata == NULL);
if (!dict.empty ())
metadata = new (std::nothrow) metadata_t (dict);
}
return 0;
}