2014-04-30 14:17:38 +02:00
|
|
|
/*
|
2016-01-28 15:07:31 +01:00
|
|
|
Copyright (c) 2007-2016 Contributors as noted in the AUTHORS file
|
2014-04-30 14:17:38 +02:00
|
|
|
|
2015-06-02 22:33:55 +02:00
|
|
|
This file is part of libzmq, the ZeroMQ core engine in C++.
|
2014-04-30 14:17:38 +02:00
|
|
|
|
2015-06-02 22:33:55 +02:00
|
|
|
libzmq is free software; you can redistribute it and/or modify it under
|
|
|
|
the terms of the GNU Lesser General Public License (LGPL) as published
|
|
|
|
by the Free Software Foundation; either version 3 of the License, or
|
2014-04-30 14:17:38 +02:00
|
|
|
(at your option) any later version.
|
|
|
|
|
2015-06-02 22:33:55 +02:00
|
|
|
As a special exception, the Contributors give you permission to link
|
|
|
|
this library with independent modules to produce an executable,
|
|
|
|
regardless of the license terms of these independent modules, and to
|
|
|
|
copy and distribute the resulting executable under terms of your choice,
|
|
|
|
provided that you also meet, for each linked independent module, the
|
|
|
|
terms and conditions of the license of that module. An independent
|
|
|
|
module is a module which is not derived from or based on this library.
|
|
|
|
If you modify this library, you must extend this exception to your
|
|
|
|
version of the library.
|
|
|
|
|
|
|
|
libzmq is distributed in the hope that it will be useful, but WITHOUT
|
|
|
|
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
|
|
FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
|
|
|
License for more details.
|
2014-04-30 14:17:38 +02:00
|
|
|
|
|
|
|
You should have received a copy of the GNU Lesser General Public License
|
|
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
2016-02-18 10:56:52 -06:00
|
|
|
#include "precompiled.hpp"
|
2014-04-30 14:17:38 +02:00
|
|
|
#include "metadata.hpp"
|
|
|
|
|
2018-05-27 11:10:39 +02:00
|
|
|
zmq::metadata_t::metadata_t (const dict_t &dict_) : _ref_cnt (1), _dict (dict_)
|
2014-04-30 14:17:38 +02:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2018-05-24 17:58:30 +02:00
|
|
|
const char *zmq::metadata_t::get (const std::string &property_) const
|
2014-04-30 14:17:38 +02:00
|
|
|
{
|
2019-12-25 13:51:21 +01:00
|
|
|
const dict_t::const_iterator it = _dict.find (property_);
|
2018-05-27 11:10:39 +02:00
|
|
|
if (it == _dict.end ()) {
|
2017-09-07 09:55:56 +02:00
|
|
|
/** \todo remove this when support for the deprecated name "Identity" is dropped */
|
2018-05-24 17:58:30 +02:00
|
|
|
if (property_ == "Identity")
|
2017-09-07 09:55:56 +02:00
|
|
|
return get (ZMQ_MSG_PROPERTY_ROUTING_ID);
|
|
|
|
|
2014-04-30 14:17:38 +02:00
|
|
|
return NULL;
|
2018-05-25 23:10:10 +02:00
|
|
|
}
|
|
|
|
return it->second.c_str ();
|
2014-04-30 14:17:38 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void zmq::metadata_t::add_ref ()
|
|
|
|
{
|
2018-05-27 11:10:39 +02:00
|
|
|
_ref_cnt.add (1);
|
2014-04-30 14:17:38 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
bool zmq::metadata_t::drop_ref ()
|
|
|
|
{
|
2018-05-27 11:10:39 +02:00
|
|
|
return !_ref_cnt.sub (1);
|
2014-04-30 14:17:38 +02:00
|
|
|
}
|