本文整理汇总了C++中blob_t::empty方法的典型用法代码示例。如果您正苦于以下问题:C++ blob_t::empty方法的具体用法?C++ blob_t::empty怎么用?C++ blob_t::empty使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类blob_t
的用法示例。
在下文中一共展示了blob_t::empty方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: if
void zmq::named_session_t::attached (const blob_t &peer_identity_)
{
if (!name.empty ()) {
// If both IDs are temporary, no checking is needed.
// TODO: Old ID should be reused in this case...
if (name.empty () || name [0] != 0 ||
peer_identity_.empty () || peer_identity_ [0] != 0) {
// If we already know the peer name do nothing, just check whether
// it haven't changed.
zmq_assert (name == peer_identity_);
}
}
else if (!peer_identity_.empty ()) {
// Store the peer identity.
name = peer_identity_;
// Register the session using the peer name.
if (!register_session (name, this)) {
// TODO: There's already a session with the specified
// identity. We should presumably syslog it and drop the
// session.
zmq_assert (false);
}
}
}
示例2: malloc
void zmq::object_t::send_bind (socket_base_t *destination_,
reader_t *in_pipe_, writer_t *out_pipe_, const blob_t &peer_identity_,
bool inc_seqnum_)
{
if (inc_seqnum_)
destination_->inc_seqnum ();
command_t cmd;
cmd.destination = destination_;
cmd.type = command_t::bind;
cmd.args.bind.in_pipe = in_pipe_;
cmd.args.bind.out_pipe = out_pipe_;
if (peer_identity_.empty ()) {
cmd.args.bind.peer_identity_size = 0;
cmd.args.bind.peer_identity = NULL;
}
else {
zmq_assert (peer_identity_.size () <= 0xff);
cmd.args.bind.peer_identity_size =
(unsigned char) peer_identity_.size ();
cmd.args.bind.peer_identity =
(unsigned char*) malloc (peer_identity_.size ());
zmq_assert (cmd.args.bind.peer_identity_size);
memcpy (cmd.args.bind.peer_identity, peer_identity_.data (),
peer_identity_.size ());
}
send_command (cmd);
}
示例3: memset
void zmq::object_t::send_bind (own_t *destination_, reader_t *in_pipe_,
writer_t *out_pipe_, const blob_t &peer_identity_, bool inc_seqnum_)
{
if (inc_seqnum_)
destination_->inc_seqnum ();
command_t cmd;
#if defined ZMQ_MAKE_VALGRIND_HAPPY
memset (&cmd, 0, sizeof (cmd));
#endif
cmd.destination = destination_;
cmd.type = command_t::bind;
cmd.args.bind.in_pipe = in_pipe_;
cmd.args.bind.out_pipe = out_pipe_;
if (peer_identity_.empty ()) {
cmd.args.bind.peer_identity_size = 0;
cmd.args.bind.peer_identity = NULL;
}
else {
zmq_assert (peer_identity_.size () <= 0xff);
cmd.args.bind.peer_identity_size =
(unsigned char) peer_identity_.size ();
cmd.args.bind.peer_identity =
(unsigned char*) malloc (peer_identity_.size ());
zmq_assert (cmd.args.bind.peer_identity_size);
memcpy (cmd.args.bind.peer_identity, peer_identity_.data (),
peer_identity_.size ());
}
send_command (cmd);
}
示例4: copy
void copy(const blob_t& other) {
if(other.empty()) {
return;
}
m_data = other.m_data;
m_size = other.m_size;
m_ref_counter = other.m_ref_counter;
++*m_ref_counter;
}
示例5: log
bool zmq::connect_session_t::attached (const blob_t &peer_identity_)
{
// If there was no previous connection...
if (!connected) {
// Peer has transient identity.
if (peer_identity_.empty () || peer_identity_ [0] == 0) {
connected = true;
return true;
}
// Peer has strong identity. Let's register it and check whether noone
// else is using the same identity.
if (!register_session (peer_identity_, this)) {
log ("DPID: duplicate peer identity - disconnecting peer");
return false;
}
connected = true;
peer_identity = peer_identity_;
return true;
}
// New engine from listener can conflict with existing engine.
// Alternatively, new engine created by reconnection process can
// conflict with engine supplied by listener in the meantime.
if (has_engine ()) {
log ("DPID: duplicate peer identity - disconnecting peer");
return false;
}
// If there have been a connection before, we have to check whether
// peer's identity haven't changed in the meantime.
if ((peer_identity_.empty () || peer_identity_ [0] == 0) &&
peer_identity.empty ())
return true;
if (peer_identity != peer_identity_) {
log ("CHID: peer have changed identity - disconnecting peer");
return false;
}
return true;
}
示例6: if
void zmq::session_t::process_attach (i_engine *engine_,
const blob_t &peer_identity_)
{
if (!peer_identity.empty ()) {
// If both IDs are temporary, no checking is needed.
// TODO: Old ID should be reused in this case...
if (peer_identity.empty () || peer_identity [0] != 0 ||
peer_identity_.empty () || peer_identity_ [0] != 0) {
// If we already know the peer name do nothing, just check whether
// it haven't changed.
zmq_assert (peer_identity == peer_identity_);
}
}
else if (!peer_identity_.empty ()) {
// Store the peer identity.
peer_identity = peer_identity_;
// If the session is not registered with the ordinal, let's register
// it using the peer name.
if (!ordinal) {
if (!owner->register_session (peer_identity, this)) {
// TODO: There's already a session with the specified
// identity. We should presumably syslog it and drop the
// session.
zmq_assert (false);
}
}
}
// Check whether the required pipes already exist. If not so, we'll
// create them and bind them to the socket object.
reader_t *socket_reader = NULL;
writer_t *socket_writer = NULL;
if (options.requires_in && !out_pipe) {
pipe_t *pipe = new (std::nothrow) pipe_t (owner, this, options.hwm, options.swap);
zmq_assert (pipe);
out_pipe = &pipe->writer;
out_pipe->set_endpoint (this);
socket_reader = &pipe->reader;
}
if (options.requires_out && !in_pipe) {
pipe_t *pipe = new (std::nothrow) pipe_t (this, owner, options.hwm, options.swap);
zmq_assert (pipe);
in_pipe = &pipe->reader;
in_pipe->set_endpoint (this);
socket_writer = &pipe->writer;
}
if (socket_reader || socket_writer)
send_bind (owner, socket_reader, socket_writer, peer_identity);
// Plug in the engine.
zmq_assert (!engine);
zmq_assert (engine_);
engine = engine_;
engine->plug (this);
}