• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ qdict_new函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: qdict_haskey_test

static void qdict_haskey_test(void)
{
    const char *key = "test";
    QDict *tests_dict = qdict_new();

    qdict_put(tests_dict, key, qint_from_int(0));
    g_assert(qdict_haskey(tests_dict, key) == 1);

    QDECREF(tests_dict);
}
开发者ID:JunaidLoonat,项目名称:qemu,代码行数:10,代码来源:check-qdict.c


示例2: qdict_array_entries_test

static void qdict_array_entries_test(void)
{
    QDict *dict = qdict_new();

    g_assert_cmpint(qdict_array_entries(dict, "foo."), ==, 0);

    qdict_put_int(dict, "bar", 0);
    qdict_put_int(dict, "baz.0", 0);
    g_assert_cmpint(qdict_array_entries(dict, "foo."), ==, 0);

    qdict_put_int(dict, "foo.1", 0);
    g_assert_cmpint(qdict_array_entries(dict, "foo."), ==, -EINVAL);
    qdict_put_int(dict, "foo.0", 0);
    g_assert_cmpint(qdict_array_entries(dict, "foo."), ==, 2);
    qdict_put_int(dict, "foo.bar", 0);
    g_assert_cmpint(qdict_array_entries(dict, "foo."), ==, -EINVAL);
    qdict_del(dict, "foo.bar");

    qdict_put_int(dict, "foo.2.a", 0);
    qdict_put_int(dict, "foo.2.b", 0);
    qdict_put_int(dict, "foo.2.c", 0);
    g_assert_cmpint(qdict_array_entries(dict, "foo."), ==, 3);
    g_assert_cmpint(qdict_array_entries(dict, ""), ==, -EINVAL);

    qobject_unref(dict);

    dict = qdict_new();
    qdict_put_int(dict, "1", 0);
    g_assert_cmpint(qdict_array_entries(dict, ""), ==, -EINVAL);
    qdict_put_int(dict, "0", 0);
    g_assert_cmpint(qdict_array_entries(dict, ""), ==, 2);
    qdict_put_int(dict, "bar", 0);
    g_assert_cmpint(qdict_array_entries(dict, ""), ==, -EINVAL);
    qdict_del(dict, "bar");

    qdict_put_int(dict, "2.a", 0);
    qdict_put_int(dict, "2.b", 0);
    qdict_put_int(dict, "2.c", 0);
    g_assert_cmpint(qdict_array_entries(dict, ""), ==, 3);

    qobject_unref(dict);
}
开发者ID:mcayland,项目名称:qemu,代码行数:42,代码来源:check-block-qdict.c


示例3: test_event_d

/* Complex type */
static void test_event_d(TestEventData *data,
                         const void *unused)
{
    UserDefOne struct1;
    EventStructOne a;
    QDict *d, *d_data, *d_a, *d_struct1;

    struct1.integer = 2;
    struct1.string = g_strdup("test1");
    struct1.has_enum1 = true;
    struct1.enum1 = ENUM_ONE_VALUE1;

    a.struct1 = &struct1;
    a.string = g_strdup("test2");
    a.has_enum2 = true;
    a.enum2 = ENUM_ONE_VALUE2;

    d_struct1 = qdict_new();
    qdict_put(d_struct1, "integer", qint_from_int(2));
    qdict_put(d_struct1, "string", qstring_from_str("test1"));
    qdict_put(d_struct1, "enum1", qstring_from_str("value1"));

    d_a = qdict_new();
    qdict_put(d_a, "struct1", d_struct1);
    qdict_put(d_a, "string", qstring_from_str("test2"));
    qdict_put(d_a, "enum2", qstring_from_str("value2"));

    d_data = qdict_new();
    qdict_put(d_data, "a", d_a);
    qdict_put(d_data, "b", qstring_from_str("test3"));
    qdict_put(d_data, "enum3", qstring_from_str("value3"));

    d = data->expect;
    qdict_put(d, "event", qstring_from_str("EVENT_D"));
    qdict_put(d, "data", d_data);

    qapi_event_send_event_d(&a, "test3", false, NULL, true, ENUM_ONE_VALUE3,
                           &error_abort);

    g_free(struct1.string);
    g_free(a.string);
}
开发者ID:AmesianX,项目名称:panda,代码行数:43,代码来源:test-qmp-event.c


示例4: qdict_array_entries_test

static void qdict_array_entries_test(void)
{
    QDict *dict = qdict_new();

    g_assert_cmpint(qdict_array_entries(dict, "foo."), ==, 0);

    qdict_put(dict, "bar", qint_from_int(0));
    qdict_put(dict, "baz.0", qint_from_int(0));
    g_assert_cmpint(qdict_array_entries(dict, "foo."), ==, 0);

    qdict_put(dict, "foo.1", qint_from_int(0));
    g_assert_cmpint(qdict_array_entries(dict, "foo."), ==, -EINVAL);
    qdict_put(dict, "foo.0", qint_from_int(0));
    g_assert_cmpint(qdict_array_entries(dict, "foo."), ==, 2);
    qdict_put(dict, "foo.bar", qint_from_int(0));
    g_assert_cmpint(qdict_array_entries(dict, "foo."), ==, -EINVAL);
    qdict_del(dict, "foo.bar");

    qdict_put(dict, "foo.2.a", qint_from_int(0));
    qdict_put(dict, "foo.2.b", qint_from_int(0));
    qdict_put(dict, "foo.2.c", qint_from_int(0));
    g_assert_cmpint(qdict_array_entries(dict, "foo."), ==, 3);
    g_assert_cmpint(qdict_array_entries(dict, ""), ==, -EINVAL);

    QDECREF(dict);

    dict = qdict_new();
    qdict_put(dict, "1", qint_from_int(0));
    g_assert_cmpint(qdict_array_entries(dict, ""), ==, -EINVAL);
    qdict_put(dict, "0", qint_from_int(0));
    g_assert_cmpint(qdict_array_entries(dict, ""), ==, 2);
    qdict_put(dict, "bar", qint_from_int(0));
    g_assert_cmpint(qdict_array_entries(dict, ""), ==, -EINVAL);
    qdict_del(dict, "bar");

    qdict_put(dict, "2.a", qint_from_int(0));
    qdict_put(dict, "2.b", qint_from_int(0));
    qdict_put(dict, "2.c", qint_from_int(0));
    g_assert_cmpint(qdict_array_entries(dict, ""), ==, 3);

    QDECREF(dict);
}
开发者ID:AmesianX,项目名称:panda,代码行数:42,代码来源:check-qdict.c


示例5: qdict_defaults_test

static void qdict_defaults_test(void)
{
    QDict *dict, *copy;

    dict = qdict_new();
    copy = qdict_new();

    qdict_set_default_str(dict, "foo", "abc");
    qdict_set_default_str(dict, "foo", "def");
    g_assert_cmpstr(qdict_get_str(dict, "foo"), ==, "abc");
    qdict_set_default_str(dict, "bar", "ghi");

    qdict_copy_default(copy, dict, "foo");
    g_assert_cmpstr(qdict_get_str(copy, "foo"), ==, "abc");
    qdict_set_default_str(copy, "bar", "xyz");
    qdict_copy_default(copy, dict, "bar");
    g_assert_cmpstr(qdict_get_str(copy, "bar"), ==, "xyz");

    QDECREF(copy);
    QDECREF(dict);
}
开发者ID:AmesianX,项目名称:panda,代码行数:21,代码来源:check-qdict.c


示例6: qdict_crumple_test_bad_inputs

static void qdict_crumple_test_bad_inputs(void)
{
    QDict *src;
    Error *error = NULL;

    src = qdict_new();
    /* rule.0 can't be both a string and a dict */
    qdict_put(src, "rule.0", qstring_from_str("fred"));
    qdict_put(src, "rule.0.policy", qstring_from_str("allow"));

    g_assert(qdict_crumple(src, &error) == NULL);
    g_assert(error != NULL);
    error_free(error);
    error = NULL;
    QDECREF(src);

    src = qdict_new();
    /* rule can't be both a list and a dict */
    qdict_put(src, "rule.0", qstring_from_str("fred"));
    qdict_put(src, "rule.a", qstring_from_str("allow"));

    g_assert(qdict_crumple(src, &error) == NULL);
    g_assert(error != NULL);
    error_free(error);
    error = NULL;
    QDECREF(src);

    src = qdict_new();
    /* The input should be flat, ie no dicts or lists */
    qdict_put(src, "rule.a", qdict_new());
    qdict_put(src, "rule.b", qstring_from_str("allow"));

    g_assert(qdict_crumple(src, &error) == NULL);
    g_assert(error != NULL);
    error_free(error);
    error = NULL;
    QDECREF(src);

    src = qdict_new();
    /* List indexes must not have gaps */
    qdict_put(src, "rule.0", qstring_from_str("deny"));
    qdict_put(src, "rule.3", qstring_from_str("allow"));

    g_assert(qdict_crumple(src, &error) == NULL);
    g_assert(error != NULL);
    error_free(error);
    error = NULL;
    QDECREF(src);

    src = qdict_new();
    /* List indexes must be in %zu format */
    qdict_put(src, "rule.0", qstring_from_str("deny"));
    qdict_put(src, "rule.+1", qstring_from_str("allow"));

    g_assert(qdict_crumple(src, &error) == NULL);
    g_assert(error != NULL);
    error_free(error);
    error = NULL;
    QDECREF(src);
}
开发者ID:AmesianX,项目名称:panda,代码行数:60,代码来源:check-qdict.c


示例7: ssh_create

static int ssh_create(const char *filename, QemuOpts *opts, Error **errp)
{
    int r, ret;
    int64_t total_size = 0;
    QDict *uri_options = NULL;
    BDRVSSHState s;
    ssize_t r2;
    char c[1] = { '\0' };

    ssh_state_init(&s);

    /* Get desired file size. */
    total_size = ROUND_UP(qemu_opt_get_size_del(opts, BLOCK_OPT_SIZE, 0),
                          BDRV_SECTOR_SIZE);
    DPRINTF("total_size=%" PRIi64, total_size);

    uri_options = qdict_new();
    r = parse_uri(filename, uri_options, errp);
    if (r < 0) {
        ret = r;
        goto out;
    }

    r = connect_to_ssh(&s, uri_options,
                       LIBSSH2_FXF_READ|LIBSSH2_FXF_WRITE|
                       LIBSSH2_FXF_CREAT|LIBSSH2_FXF_TRUNC,
                       0644, errp);
    if (r < 0) {
        ret = r;
        goto out;
    }

    if (total_size > 0) {
        libssh2_sftp_seek64(s.sftp_handle, total_size-1);
        r2 = libssh2_sftp_write(s.sftp_handle, c, 1);
        if (r2 < 0) {
            sftp_error_setg(errp, &s, "truncate failed");
            ret = -EINVAL;
            goto out;
        }
        s.attrs.filesize = total_size;
    }

    ret = 0;

 out:
    ssh_state_free(&s);
    if (uri_options != NULL) {
        QDECREF(uri_options);
    }
    return ret;
}
开发者ID:Pating,项目名称:qemu-colo,代码行数:52,代码来源:ssh.c


示例8: qdict_crumple_test_empty

static void qdict_crumple_test_empty(void)
{
    QDict *src, *dst;

    src = qdict_new();

    dst = (QDict *)qdict_crumple(src, &error_abort);

    g_assert_cmpint(qdict_size(dst), ==, 0);

    QDECREF(src);
    QDECREF(dst);
}
开发者ID:AmesianX,项目名称:panda,代码行数:13,代码来源:check-qdict.c


示例9: qdict_new_test

static void qdict_new_test(void)
{
    QDict *qdict;

    qdict = qdict_new();
    g_assert(qdict != NULL);
    g_assert(qdict_size(qdict) == 0);
    g_assert(qdict->base.refcnt == 1);
    g_assert(qobject_type(QOBJECT(qdict)) == QTYPE_QDICT);

    // destroy doesn't exit yet
    g_free(qdict);
}
开发者ID:AmesianX,项目名称:panda,代码行数:13,代码来源:check-qdict.c


示例10: qdict_crumple_test_empty

static void qdict_crumple_test_empty(void)
{
    QDict *src, *dst;

    src = qdict_new();

    dst = qobject_to(QDict, qdict_crumple(src, &error_abort));

    g_assert_cmpint(qdict_size(dst), ==, 0);

    qobject_unref(src);
    qobject_unref(dst);
}
开发者ID:mcayland,项目名称:qemu,代码行数:13,代码来源:check-block-qdict.c


示例11: test_dispatch_cmd

/* test commands with no input and no return value */
static void test_dispatch_cmd(void)
{
    QDict *req = qdict_new();
    QDict *resp;

    qdict_put_str(req, "execute", "user_def_cmd");

    resp = qmp_dispatch(&qmp_commands, QOBJECT(req), false);
    assert(resp != NULL);
    assert(!qdict_haskey(resp, "error"));

    qobject_unref(resp);
    qobject_unref(req);
}
开发者ID:JayFoxRox,项目名称:xqemu,代码行数:15,代码来源:test-qmp-cmds.c


示例12: test_dispatch_cmd

/* test commands with no input and no return value */
static void test_dispatch_cmd(void)
{
    QDict *req = qdict_new();
    QObject *resp;

    qdict_put_obj(req, "execute", QOBJECT(qstring_from_str("user_def_cmd")));

    resp = qmp_dispatch(&qmp_commands, QOBJECT(req));
    assert(resp != NULL);
    assert(!qdict_haskey(qobject_to_qdict(resp), "error"));

    qobject_decref(resp);
    QDECREF(req);
}
开发者ID:JunaidLoonat,项目名称:qemu,代码行数:15,代码来源:test-qmp-commands.c


示例13: iscsi_create

static int iscsi_create(const char *filename, QEMUOptionParameter *options)
{
    int ret = 0;
    int64_t total_size = 0;
    BlockDriverState bs;
    IscsiLun *iscsilun = NULL;
    QDict *bs_options;

    memset(&bs, 0, sizeof(BlockDriverState));

    /* Read out options */
    while (options && options->name) {
        if (!strcmp(options->name, "size")) {
            total_size = options->value.n / BDRV_SECTOR_SIZE;
        }
        options++;
    }

    bs.opaque = g_malloc0(sizeof(struct IscsiLun));
    iscsilun = bs.opaque;

    bs_options = qdict_new();
    qdict_put(bs_options, "filename", qstring_from_str(filename));
    ret = iscsi_open(&bs, bs_options, 0);
    QDECREF(bs_options);

    if (ret != 0) {
        goto out;
    }
    if (iscsilun->nop_timer) {
        qemu_del_timer(iscsilun->nop_timer);
        qemu_free_timer(iscsilun->nop_timer);
    }
    if (iscsilun->type != TYPE_DISK) {
        ret = -ENODEV;
        goto out;
    }
    if (bs.total_sectors < total_size) {
        ret = -ENOSPC;
        goto out;
    }

    ret = 0;
out:
    if (iscsilun->iscsi != NULL) {
        iscsi_destroy_context(iscsilun->iscsi);
    }
    g_free(bs.opaque);
    return ret;
}
开发者ID:JaonLin,项目名称:hypershell,代码行数:50,代码来源:iscsi.c


示例14: qdict_get_int_test

static void qdict_get_int_test(void)
{
    int ret;
    const int value = 100;
    const char *key = "int";
    QDict *tests_dict = qdict_new();

    qdict_put(tests_dict, key, qint_from_int(value));

    ret = qdict_get_int(tests_dict, key);
    g_assert(ret == value);

    QDECREF(tests_dict);
}
开发者ID:AmesianX,项目名称:panda,代码行数:14,代码来源:check-qdict.c


示例15: test_dispatch_cmd_error

/* test commands that return an error due to invalid parameters */
static void test_dispatch_cmd_error(void)
{
    QDict *req = qdict_new();
    QObject *resp;

    qdict_put_obj(req, "execute", QOBJECT(qstring_from_str("user_def_cmd2")));

    resp = qmp_dispatch(QOBJECT(req));
    assert(resp != NULL);
    assert(qdict_haskey(qobject_to_qdict(resp), "error"));
    g_print("\nresp: %s\n", qstring_get_str(qobject_to_json_pretty(resp)));

    qobject_decref(resp);
    QDECREF(req);
}
开发者ID:B-Rich,项目名称:serialice,代码行数:16,代码来源:test-qmp-commands.c


示例16: qdict_del_test

static void qdict_del_test(void)
{
    const char *key = "key test";
    QDict *tests_dict = qdict_new();

    qdict_put(tests_dict, key, qstring_from_str("foo"));
    g_assert(qdict_size(tests_dict) == 1);

    qdict_del(tests_dict, key);

    g_assert(qdict_size(tests_dict) == 0);
    g_assert(qdict_haskey(tests_dict, key) == 0);

    QDECREF(tests_dict);
}
开发者ID:AmesianX,项目名称:panda,代码行数:15,代码来源:check-qdict.c


示例17: qdict_get_try_str_test

static void qdict_get_try_str_test(void)
{
    const char *p;
    const char *key = "key";
    const char *str = "string";
    QDict *tests_dict = qdict_new();

    qdict_put(tests_dict, key, qstring_from_str(str));

    p = qdict_get_try_str(tests_dict, key);
    g_assert(p != NULL);
    g_assert(strcmp(p, str) == 0);

    QDECREF(tests_dict);
}
开发者ID:AmesianX,项目名称:panda,代码行数:15,代码来源:check-qdict.c


示例18: qdict_new

static QObject *get_stats_qobject(VirtIOBalloon *dev)
{
    QDict *dict = qdict_new();
    uint64_t actual = ram_size - ((uint64_t) dev->actual <<
                                  VIRTIO_BALLOON_PFN_SHIFT);

    stat_put(dict, "actual", actual);
    stat_put(dict, "mem_swapped_in", dev->stats[VIRTIO_BALLOON_S_SWAP_IN]);
    stat_put(dict, "mem_swapped_out", dev->stats[VIRTIO_BALLOON_S_SWAP_OUT]);
    stat_put(dict, "major_page_faults", dev->stats[VIRTIO_BALLOON_S_MAJFLT]);
    stat_put(dict, "minor_page_faults", dev->stats[VIRTIO_BALLOON_S_MINFLT]);
    stat_put(dict, "free_mem", dev->stats[VIRTIO_BALLOON_S_MEMFREE]);
    stat_put(dict, "total_mem", dev->stats[VIRTIO_BALLOON_S_MEMTOT]);

    return QOBJECT(dict);
}
开发者ID:iggy,项目名称:qemu,代码行数:16,代码来源:virtio-balloon.c


示例19: qdict_put_exists_test

static void qdict_put_exists_test(void)
{
    int value;
    const char *key = "exists";
    QDict *tests_dict = qdict_new();

    qdict_put(tests_dict, key, qint_from_int(1));
    qdict_put(tests_dict, key, qint_from_int(2));

    value = qdict_get_int(tests_dict, key);
    g_assert(value == 2);

    g_assert(qdict_size(tests_dict) == 1);

    QDECREF(tests_dict);
}
开发者ID:AmesianX,项目名称:panda,代码行数:16,代码来源:check-qdict.c


示例20: qdict_new

static QObject *make_qobject(void)
{
    QDict *qdict = qdict_new();
    QList *list = qlist_new();

    qdict_put_int(qdict, "foo", 42);
    qdict_put_str(qdict, "bar", "hello world");
    qdict_put_null(qdict, "baz");

    qlist_append_int(list, 43);
    qlist_append_int(list, 44);
    qlist_append_bool(list, true);
    qdict_put(qdict, "bee", list);

    return QOBJECT(qdict);
}
开发者ID:CTU-IIG,项目名称:qemu,代码行数:16,代码来源:check-qlit.c



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ qdict_put函数代码示例发布时间:2022-05-30
下一篇:
C++ qdict_haskey函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap