当前位置: 首页>>代码示例>>C++>>正文


C++ DOWNCAST函数代码示例

本文整理汇总了C++中DOWNCAST函数的典型用法代码示例。如果您正苦于以下问题:C++ DOWNCAST函数的具体用法?C++ DOWNCAST怎么用?C++ DOWNCAST使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了DOWNCAST函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: DOWNCAST

void UpnpCache::removeTrack( Meta::TrackPtr t )
{
#define DOWNCAST( Type, item ) Meta::Upnp##Type##Ptr::staticCast( item )
    Meta::UpnpTrackPtr track = DOWNCAST( Track, t );
    DOWNCAST( Artist, m_artistMap[ track->artist()->name() ] )->removeTrack( track );
    DOWNCAST( Album, m_albumMap.value( track->album() ) )->removeTrack( track );
    DOWNCAST( Genre, m_genreMap[ track->genre()->name() ] )->removeTrack( track );
    DOWNCAST( Year, m_yearMap[ track->year()->year() ] )->removeTrack( track );
#undef DOWNCAST
    m_trackMap.remove( track->uidUrl() );
}
开发者ID:ErrAza,项目名称:amarok,代码行数:11,代码来源:UpnpCache.cpp

示例2: sip_deserialize

static void sip_deserialize(struct proto_info *info_, uint8_t const **buf)
{
    struct sip_proto_info *info = DOWNCAST(info_, info, sip_proto_info);
    proto_info_deserialize(info_, buf);
    info->set_values = deserialize_2(buf);
    if (info->set_values & SIP_CMD_SET)
        info->cmd = deserialize_1(buf);
    if (info->set_values & SIP_FROM_SET)
        deserialize_str(buf, info->from, sizeof(info->from));
    if (info->set_values & SIP_TO_SET)
        deserialize_str(buf, info->to, sizeof(info->to));
    if (info->set_values & SIP_CALLID_SET)
        deserialize_str(buf, info->call_id, sizeof(info->call_id));
    if (info->set_values & SIP_MIME_SET)
        deserialize_str(buf, info->mime_type, sizeof(info->mime_type));
    if (info->set_values & SIP_VIA_SET) {
        info->via.protocol = deserialize_1(buf);
        ip_addr_deserialize(&info->via.addr, buf);
        info->via.port = deserialize_2(buf);
    }
    if (info->set_values & SIP_LENGTH_SET)
        info->content_length = deserialize_4(buf);
    if (info->set_values & SIP_CODE_SET)
        info->code = deserialize_4(buf);
    if (info->set_values & SIP_CSEQ_SET)
        info->cseq = deserialize_4(buf);
}
开发者ID:bsmr-c-cpp,项目名称:junkie,代码行数:27,代码来源:sip.c

示例3: pg_sbuf_parse

static enum proto_parse_status pg_sbuf_parse(struct parser *parser, struct proto_info *parent, unsigned way, uint8_t const *payload, size_t cap_len, size_t wire_len, struct timeval const *now, size_t tot_cap_len, uint8_t const *tot_packet)
{
    struct pgsql_parser *pg_parser = DOWNCAST(parser, parser, pgsql_parser);

    // If this is the first time we are called, init c2s_way
    if (pg_parser->c2s_way == UNSET) {
        SLOG(LOG_DEBUG, "First packet, init c2s_way to %u", way);
        pg_parser->c2s_way = way;
    }

    // Now build the proto_info
    struct sql_proto_info info;
    proto_info_ctor(&info.info, parser, parent, wire_len, 0);
    info.is_query = way == pg_parser->c2s_way;
    info.set_values = 0;

    switch (pg_parser->phase) {
        case NONE:    return pg_parse_init   (pg_parser, &info, way, payload, cap_len, wire_len, now, tot_cap_len, tot_packet);
        case STARTUP: return pg_parse_startup(pg_parser, &info, way, payload, cap_len, wire_len, now, tot_cap_len, tot_packet);
        case QUERY:   return pg_parse_query  (pg_parser, &info, way, payload, cap_len, wire_len, now, tot_cap_len, tot_packet);
        case EXIT:    return PROTO_PARSE_ERR;   // we do not expect payload after a termination message
    }

    return PROTO_PARSE_ERR;
}
开发者ID:IAmAnubhavSaini,项目名称:junkie,代码行数:25,代码来源:postgres.c

示例4: sip_serialize

static void sip_serialize(struct proto_info const *info_, uint8_t **buf)
{
    struct sip_proto_info const *info = DOWNCAST(info_, info, sip_proto_info);
    proto_info_serialize(info_, buf);
    serialize_2(buf, info->set_values);
    if (info->set_values & SIP_CMD_SET)
        serialize_1(buf, info->cmd);
    if (info->set_values & SIP_FROM_SET)
        serialize_str(buf, info->from);
    if (info->set_values & SIP_TO_SET)
        serialize_str(buf, info->to);
    if (info->set_values & SIP_CALLID_SET)
        serialize_str(buf, info->call_id);
    if (info->set_values & SIP_MIME_SET)
        serialize_str(buf, info->mime_type);
    if (info->set_values & SIP_VIA_SET) {
        serialize_1(buf, info->via.protocol);
        ip_addr_serialize(&info->via.addr, buf);
        serialize_2(buf, info->via.port);
    }
    if (info->set_values & SIP_LENGTH_SET)
        serialize_4(buf, info->content_length);
    if (info->set_values & SIP_CODE_SET)
        serialize_4(buf, info->code);
    if (info->set_values & SIP_CSEQ_SET)
        serialize_4(buf, info->cseq);
}
开发者ID:bsmr-c-cpp,项目名称:junkie,代码行数:27,代码来源:sip.c

示例5: sdp_parser_del

static void sdp_parser_del(struct parser *parser)
{
    struct sdp_parser *sdp_parser = DOWNCAST(parser, parser, sdp_parser);

    parser_dtor(parser);
    FREE(sdp_parser);
}
开发者ID:krissg,项目名称:junkie,代码行数:7,代码来源:sdp.c

示例6: test_conn_download_status_add_a_connection

static dir_connection_t *
test_conn_download_status_add_a_connection(const char *resource)
{
  dir_connection_t *conn = DOWNCAST(dir_connection_t,
                                    test_conn_get_connection(
                                                      TEST_CONN_STATE,
                                                      TEST_CONN_TYPE,
                                                      TEST_CONN_RSRC_PURPOSE));

  tt_assert(conn);
  assert_connection_ok(&conn->base_, time(NULL));

  /* Replace the existing resource with the one we want */
  if (resource) {
    if (conn->requested_resource) {
      tor_free(conn->requested_resource);
    }
    conn->requested_resource = tor_strdup(resource);
    assert_connection_ok(&conn->base_, time(NULL));
  }

  return conn;

 done:
  test_conn_get_rsrc_teardown(NULL, conn);
  return NULL;
}
开发者ID:isislovecruft,项目名称:tor,代码行数:27,代码来源:test_connection.c

示例7: test_conn_get_rsrc_teardown

static int
test_conn_get_rsrc_teardown(const struct testcase_t *tc, void *arg)
{
  int rv = 0;

  connection_t *conn = (connection_t *)arg;
  tt_assert(conn);
  assert_connection_ok(conn, time(NULL));

  if (conn->type == CONN_TYPE_DIR) {
    dir_connection_t *dir_conn = DOWNCAST(dir_connection_t, arg);

    tt_assert(dir_conn);
    assert_connection_ok(&dir_conn->base_, time(NULL));

    /* avoid a last-ditch attempt to refetch the consensus */
    dir_conn->base_.state = TEST_CONN_RSRC_STATE_SUCCESSFUL;
    assert_connection_ok(&dir_conn->base_, time(NULL));
  }

  /* connection_free_() cleans up requested_resource */
  rv = test_conn_get_basic_teardown(tc, conn);

 done:
  return rv;
}
开发者ID:isislovecruft,项目名称:tor,代码行数:26,代码来源:test_connection.c

示例8: test_conn_get_rend_setup

static void *
test_conn_get_rend_setup(const struct testcase_t *tc)
{
  dir_connection_t *conn = DOWNCAST(dir_connection_t,
                                    test_conn_get_basic_setup(tc));
  tt_assert(conn);
  assert_connection_ok(&conn->base_, time(NULL));

  rend_cache_init();

  /* TODO: use directory_initiate_command_rend() to do this - maybe? */
  conn->rend_data = tor_malloc_zero(sizeof(rend_data_t));
  tor_assert(strlen(TEST_CONN_REND_ADDR) == REND_SERVICE_ID_LEN_BASE32);
  memcpy(conn->rend_data->onion_address,
         TEST_CONN_REND_ADDR,
         REND_SERVICE_ID_LEN_BASE32+1);
  conn->rend_data->hsdirs_fp = smartlist_new();
  conn->base_.purpose = TEST_CONN_REND_PURPOSE;

  assert_connection_ok(&conn->base_, time(NULL));
  return conn;

  /* On failure */
 done:
  test_conn_get_rend_teardown(tc, conn);
  /* Returning NULL causes the unit test to fail */
  return NULL;
}
开发者ID:1833183060,项目名称:tor-1,代码行数:28,代码来源:test_connection.c

示例9: test_conn_get_rend

static void
test_conn_get_rend(void *arg)
{
  dir_connection_t *conn = DOWNCAST(dir_connection_t, arg);
  tt_assert(conn);
  assert_connection_ok(&conn->base_, time(NULL));

  tt_assert(connection_get_by_type_state_rendquery(
                                            conn->base_.type,
                                            conn->base_.state,
                                            conn->rend_data->onion_address)
            == TO_CONN(conn));
  tt_assert(connection_get_by_type_state_rendquery(
                                            TEST_CONN_TYPE,
                                            TEST_CONN_STATE,
                                            TEST_CONN_REND_ADDR)
            == TO_CONN(conn));
  tt_assert(connection_get_by_type_state_rendquery(TEST_CONN_REND_TYPE_2,
                                                   !conn->base_.state,
                                                   "")
            == NULL);
  tt_assert(connection_get_by_type_state_rendquery(TEST_CONN_REND_TYPE_2,
                                                   !TEST_CONN_STATE,
                                                   TEST_CONN_REND_ADDR_2)
            == NULL);

 done:
  ;
}
开发者ID:1833183060,项目名称:tor-1,代码行数:29,代码来源:test_connection.c

示例10: cap_deserialize

static void cap_deserialize(struct proto_info *info_, uint8_t const **buf)
{
    struct cap_proto_info *info = DOWNCAST(info_, info, cap_proto_info);
    proto_info_deserialize(info_, buf);
    info->dev_id = deserialize_2(buf);
    timeval_deserialize(&info->tv, buf);
}
开发者ID:bonnefoa,项目名称:junkie,代码行数:7,代码来源:cap.c

示例11: tcp_deserialize

static void tcp_deserialize(struct proto_info *info_, uint8_t const **buf)
{
    struct tcp_proto_info *info = DOWNCAST(info_, info, tcp_proto_info);
    proto_info_deserialize(info_, buf);
    info->key.port[0] = deserialize_2(buf);
    info->key.port[1] = deserialize_2(buf);
    unsigned flags = deserialize_1(buf);
    info->syn = !!(flags & 0x01);
    info->ack = !!(flags & 0x02);
    info->rst = !!(flags & 0x04);
    info->fin = !!(flags & 0x08);
    info->urg = !!(flags & 0x10);
    info->psh = !!(flags & 0x20);
    info->to_srv = !!(flags & 0x40);
    info->window = deserialize_2(buf);
    info->urg_ptr = deserialize_2(buf);
    info->ack_num = deserialize_4(buf);
    info->seq_num = deserialize_4(buf);
    info->rel_seq_num = deserialize_4(buf);
    info->set_values = deserialize_1(buf);
    info->mss = deserialize_2(buf);
    info->wsf = deserialize_1(buf);
    info->nb_options = deserialize_1(buf);
    for (unsigned o = 0; o < info->nb_options; o++) {
        info->options[o] = deserialize_1(buf);
    }
}
开发者ID:Mybrc91,项目名称:junkie,代码行数:27,代码来源:tcp.c

示例12: DOWNCAST

static char const *mgcp_info_2_str(struct proto_info const *info_)
{
    struct mgcp_proto_info const *info = DOWNCAST(info_, info, mgcp_proto_info);
    return tempstr_printf("%s, %s, %s",
        proto_info_2_str(info_),
        info->response ? mgcp_resp_2_str(&info->u.resp) : mgcp_query_2_str(&info->u.query),
        mgcp_params_2_str(info));
}
开发者ID:rixed,项目名称:junkie,代码行数:8,代码来源:mgcp.c

示例13: tns_parse

static enum proto_parse_status tns_parse(struct parser *parser, struct proto_info *parent, unsigned way, uint8_t const *payload, size_t cap_len, size_t wire_len, struct timeval const *now, size_t tot_cap_len, uint8_t const *tot_packet)
{
    struct tns_parser *tns_parser = DOWNCAST(parser, parser, tns_parser);

    enum proto_parse_status const status = streambuf_add(&tns_parser->sbuf, parser, parent, way, payload, cap_len, wire_len, now, tot_cap_len, tot_packet);

    return status;
}
开发者ID:awesome-security,项目名称:junkie,代码行数:8,代码来源:tns.c

示例14: assert

struct mux_subparser *udp_subparser_and_parser_new(struct parser *parser, struct proto *proto, struct proto *requestor, uint16_t src, uint16_t dst, unsigned way, struct timeval const *now)
{
    assert(parser->proto == proto_udp);
    struct mux_parser *mux_parser = DOWNCAST(parser, parser, mux_parser);
    struct port_key key;
    port_key_init(&key, src, dst, way);
    return mux_subparser_and_parser_new(mux_parser, proto, requestor, &key, now);
}
开发者ID:IAmAnubhavSaini,项目名称:junkie,代码行数:8,代码来源:udp.c

示例15: eth_serialize

static void eth_serialize(struct proto_info const *info_, uint8_t **buf)
{
    struct eth_proto_info const *info = DOWNCAST(info_, info, eth_proto_info);
    proto_info_serialize(info_, buf);
    serialize_3(buf, info->vlan_id);    // 16 bits for vlan itself, +we need to handle -1 for UNSET
    serialize_n(buf, info->addr[0], ETH_ADDR_LEN);
    serialize_n(buf, info->addr[1], ETH_ADDR_LEN);
    serialize_2(buf, info->protocol);
}
开发者ID:bsmr-c-cpp,项目名称:junkie,代码行数:9,代码来源:eth.c


注:本文中的DOWNCAST函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。