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


C++ dictionary_del函数代码示例

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


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

示例1: Test_iniparser_getsecname

void Test_iniparser_getsecname(CuTest *tc)
{
    unsigned i;
    char sec_name[32];
    dictionary *dic;
    /* NULL test */
    CuAssertTrue(tc, iniparser_getsecname(NULL, 0) == NULL);

    /* Empty dictionary */
    dic = dictionary_new(10);
    CuAssertPtrEquals(tc, NULL, iniparser_getsecname(dic, 0));
    dictionary_del(dic);

    /* Sections without entries dictionary */
    dic = generate_dictionary(100, 0);
    for (i = 0; i < 100; ++i) {
        sprintf(sec_name, "sec%d", i);
        CuAssertStrEquals(tc, sec_name, iniparser_getsecname(dic, i));
    }
    dictionary_del(dic);

    /* Generic dictionary */
    dic = generate_dictionary(10, 100);
    for (i = 0; i < 10; ++i) {
        sprintf(sec_name, "sec%d", i);
        CuAssertStrEquals(tc, sec_name, iniparser_getsecname(dic, i));
    }
    dictionary_del(dic);
}
开发者ID:2ion,项目名称:iniparser,代码行数:29,代码来源:test_iniparser.c

示例2: Test_iniparser_getnsec

void Test_iniparser_getnsec(CuTest *tc)
{
    int i;
    char sec_name[32];
    dictionary *dic;

    /* NULL test */
    CuAssertIntEquals(tc, -1, iniparser_getnsec(NULL));

    /* Empty dictionary */
    dic = dictionary_new(10);
    CuAssertIntEquals(tc, 0, iniparser_getnsec(dic));
    dictionary_del(dic);

    /* Regular dictionary */
    dic = generate_dictionary(512, 0);
    CuAssertIntEquals(tc, 512, iniparser_getnsec(dic));

    /* Check after removing sections */
    for (i = 1; i < 512; ++i) {
        sprintf(sec_name, "sec%d", i);
        dictionary_unset(dic, sec_name);
        CuAssertIntEquals(tc, 512 - i, iniparser_getnsec(dic));
    }
    dictionary_del(dic);

    /* Mix sections and regular keys */
    dic = generate_dictionary(10, 512);
    CuAssertIntEquals(tc, 10, iniparser_getnsec(dic));
    dictionary_del(dic);
}
开发者ID:2ion,项目名称:iniparser,代码行数:31,代码来源:test_iniparser.c

示例3: Test_iniparser_getseckeys

void Test_iniparser_getseckeys(CuTest *tc)
{
    unsigned i;
    char key_name[64];
    dictionary *dic;
    int nkeys;
    const char * keys[10]; /* At most 10 elements per section */
    /* NULL test */
    CuAssertPtrEquals(tc, NULL, iniparser_getseckeys(NULL, NULL, NULL));
    CuAssertPtrEquals(tc, NULL, iniparser_getseckeys(NULL, "dummy", NULL));
    CuAssertPtrEquals(tc, NULL, iniparser_getseckeys(NULL, "dummy", keys));

    /* Empty dictionary */
    dic = dictionary_new(10);
    CuAssertPtrEquals(tc, NULL, iniparser_getseckeys(dic, NULL, keys));
    CuAssertPtrEquals(tc, NULL, iniparser_getseckeys(dic, "dummy", keys));
    dictionary_del(dic);

    /* Generic dictionary */

    dic = generate_dictionary(100, 10);
    CuAssertPtrEquals(tc, NULL, iniparser_getseckeys(dic, NULL, keys));
    CuAssertPtrEquals(tc, NULL, iniparser_getseckeys(dic, "dummy", keys));
    CuAssertPtrEquals(tc, NULL, iniparser_getseckeys(dic, "sec0", NULL));
    nkeys = iniparser_getsecnkeys(dic, "sec42");
    CuAssertIntEquals(tc, nkeys, 10);
    CuAssertPtrEquals(tc, keys, iniparser_getseckeys(dic, "sec42", keys));
    for (i = 0; i < 10; ++i) {
        sprintf(key_name, "sec42:key%d", i);
        CuAssertStrEquals(tc, key_name, keys[i]);
    }

    /* Remove some keys to make the dictionary more real */
    dictionary_unset(dic, "sec42");
    dictionary_unset(dic, "sec99:key9");
    dictionary_unset(dic, "sec0:key0");
    dictionary_unset(dic, "sec0:key1");
    dictionary_unset(dic, "sec0:key2");

    CuAssertPtrEquals(tc, NULL, iniparser_getseckeys(dic, "sec42", keys));
    nkeys = iniparser_getsecnkeys(dic, "sec99");
    CuAssertIntEquals(tc, nkeys, 9);
    CuAssertPtrEquals(tc, keys, iniparser_getseckeys(dic, "sec99", keys));
    for (i = 0; i < 9; ++i) {
        sprintf(key_name, "sec99:key%d", i);
        CuAssertStrEquals(tc, key_name, keys[i]);
    }

    nkeys = iniparser_getsecnkeys(dic, "sec0");
    CuAssertIntEquals(tc, nkeys, 7);
    CuAssertPtrEquals(tc, keys, iniparser_getseckeys(dic, "sec0", keys));
    for (i = 0; i < 7; ++i) {
        sprintf(key_name, "sec0:key%d", i + 3);
        CuAssertStrEquals(tc, key_name, keys[i]);
    }

    dictionary_del(dic);
}
开发者ID:2ion,项目名称:iniparser,代码行数:58,代码来源:test_iniparser.c

示例4: Test_iniparser_getseckeys

void Test_iniparser_getseckeys(CuTest *tc)
{
    unsigned i;
    char key_name[64];
    dictionary *dic;
    const char ** sections;
    /* NULL test */
    CuAssertPtrEquals(tc, NULL, iniparser_getseckeys(NULL, NULL));
    CuAssertPtrEquals(tc, NULL, iniparser_getseckeys(NULL, "dummy"));

    /* Empty dictionary */
    dic = dictionary_new(10);
    CuAssertPtrEquals(tc, NULL, iniparser_getseckeys(dic, NULL));
    CuAssertPtrEquals(tc, NULL, iniparser_getseckeys(dic, "dummy"));
    dictionary_del(dic);

    /* Generic dictionary */
    dic = generate_dictionary(100, 10);
    CuAssertPtrEquals(tc, NULL, iniparser_getseckeys(dic, NULL));
    CuAssertPtrEquals(tc, NULL, iniparser_getseckeys(dic, "dummy"));
    sections = iniparser_getseckeys(dic, "sec42");
    CuAssertPtrNotNull(tc, sections);
    for (i = 0; i < 10; ++i) {
        sprintf(key_name, "sec42:key%d", i);
        CuAssertStrEquals(tc, key_name, sections[i]);
    }
    free(sections);

    /* Remove some keys to make the dictionary more real */
    dictionary_unset(dic, "sec42");
    dictionary_unset(dic, "sec99:key9");
    dictionary_unset(dic, "sec0:key0");
    dictionary_unset(dic, "sec0:key1");
    dictionary_unset(dic, "sec0:key2");

    CuAssertPtrEquals(tc, NULL, iniparser_getseckeys(dic, "sec42"));
    sections = iniparser_getseckeys(dic, "sec99");
    CuAssertPtrNotNull(tc, sections);
    for (i = 0; i < 9; ++i) {
        sprintf(key_name, "sec99:key%d", i);
        CuAssertStrEquals(tc, key_name, sections[i]);
    }
    free(sections);
    sections = iniparser_getseckeys(dic, "sec0");
    CuAssertPtrNotNull(tc, sections);
    for (i = 0; i < 7; ++i) {
        sprintf(key_name, "sec0:key%d", i + 3);
        CuAssertStrEquals(tc, key_name, sections[i]);
    }
    free(sections);

    dictionary_del(dic);
}
开发者ID:HsiangHoLin,项目名称:iniparser4,代码行数:53,代码来源:test_iniparser.c

示例5: do_signal_sighup

/**
 * Signal handler for HUP which tells us to swap the log file
 * and reload configuration file if specified
 *
 * @param sig
 */
void
do_signal_sighup(RunTimeOpts * rtOpts, PtpClock * ptpClock)
{



	NOTIFY("SIGHUP received\n");

#ifdef RUNTIME_DEBUG
	if(rtOpts->transport == UDP_IPV4 && rtOpts->ipMode != IPMODE_UNICAST) {
		DBG("SIGHUP - running an ipv4 multicast based mode, re-sending IGMP joins\n");
		netRefreshIGMP(&ptpClock->netPath, rtOpts, ptpClock);
	}
#endif /* RUNTIME_DEBUG */


	/* if we don't have a config file specified, we're done - just reopen log files*/
	if(strlen(rtOpts->configFile) !=  0) {

	    dictionary* tmpConfig = dictionary_new(0);

	    /* Try reloading the config file */
	    NOTIFY("Reloading configuration file: %s\n",rtOpts->configFile);

            if(!loadConfigFile(&tmpConfig, rtOpts)) {

		    dictionary_del(&tmpConfig);

	    } else {
		    dictionary_merge(rtOpts->cliConfig, tmpConfig, 1, 1, "from command line");
		    applyConfig(tmpConfig, rtOpts, ptpClock);
		    dictionary_del(&tmpConfig);

	    }

	}

	/* tell the service it can perform any HUP-triggered actions */
	ptpClock->timingService.reloadRequested = TRUE;

	if(rtOpts->recordLog.logEnabled ||
	    rtOpts->eventLog.logEnabled ||
	    (rtOpts->statisticsLog.logEnabled))
		INFO("Reopening log files\n");

	restartLogging(rtOpts);

	if(rtOpts->statisticsLog.logEnabled)
		ptpClock->resetStatisticsLog = TRUE;


}
开发者ID:skreuzer,项目名称:ptpd,代码行数:58,代码来源:startup.c

示例6: registry_free

void registry_free(void) {
    if(!registry.enabled) return;

    // we need to destroy the dictionaries ourselves
    // since the dictionaries use memory we allocated

    while(registry.persons->values_index.root) {
        REGISTRY_PERSON *p = ((NAME_VALUE *)registry.persons->values_index.root)->value;
        registry_person_del(p);
    }

    while(registry.machines->values_index.root) {
        REGISTRY_MACHINE *m = ((NAME_VALUE *)registry.machines->values_index.root)->value;

        // fprintf(stderr, "\nMACHINE: '%s', first: %u, last: %u, usages: %u\n", m->guid, m->first_t, m->last_t, m->usages);

        while(m->machine_urls->values_index.root) {
            REGISTRY_MACHINE_URL *mu = ((NAME_VALUE *)m->machine_urls->values_index.root)->value;

            // fprintf(stderr, "\tURL: '%s', first: %u, last: %u, usages: %u, flags: 0x%02x\n", mu->url->url, mu->first_t, mu->last_t, mu->usages, mu->flags);

            //debug(D_REGISTRY, "Registry: destroying persons dictionary from url '%s'", mu->url->url);
            //dictionary_destroy(mu->persons);

            debug(D_REGISTRY, "Registry: deleting url '%s' from person '%s'", mu->url->url, m->guid);
            dictionary_del(m->machine_urls, mu->url->url);

            debug(D_REGISTRY, "Registry: unlinking url '%s' from machine", mu->url->url);
            registry_url_unlink(mu->url);

            debug(D_REGISTRY, "Registry: freeing machine url");
            freez(mu);
        }

        debug(D_REGISTRY, "Registry: deleting machine '%s' from machines registry", m->guid);
        dictionary_del(registry.machines, m->guid);

        debug(D_REGISTRY, "Registry: destroying URL dictionary of machine '%s'", m->guid);
        dictionary_destroy(m->machine_urls);

        debug(D_REGISTRY, "Registry: freeing machine '%s'", m->guid);
        freez(m);
    }

    // and free the memory of remaining dictionary structures

    debug(D_REGISTRY, "Registry: destroying persons dictionary");
    dictionary_destroy(registry.persons);

    debug(D_REGISTRY, "Registry: destroying machines dictionary");
    dictionary_destroy(registry.machines);
}
开发者ID:FedericoCeratto,项目名称:netdata,代码行数:52,代码来源:registry_init.c

示例7: close_config

void close_config(dictionary *dict)
{
    if (dict != NULL) {
        dictionary_del(dict);
        dict = NULL;
    }
}
开发者ID:kyosold,项目名称:Carrots,代码行数:7,代码来源:ctserver.c

示例8: Test_dictionary_growing

void Test_dictionary_growing(CuTest *tc)
{
    int i, j;
    char sec_name[32];
    char key_name[64];
    dictionary *dic;

    dic = dictionary_new(DICTMINSZ);
    CuAssertPtrNotNull(tc, dic);
    CuAssertIntEquals(tc, 0, dic->n);

    /* Makes the dictionary grow */
    for (i = 1 ; i < 101; ++i) {
        sprintf(sec_name, "sec%d", i);
        CuAssertIntEquals(tc, 0, dictionary_set(dic, sec_name, ""));
        for (j = 1 ; j < 11; ++j) {
            sprintf(key_name, "%s:key%d", sec_name, j);
            CuAssertIntEquals(tc, 0, dictionary_set(dic, key_name, "dummy_value"));
            CuAssertIntEquals(tc, i + (i - 1) * 10 + j, dic->n);
        }
    }

    /* Shrink the dictionary */
    for (i = 100 ; i > 0; --i) {
        sprintf(sec_name, "sec%d", i);
        for (j = 10 ; j > 0; --j) {
            sprintf(key_name, "%s:key%d", sec_name, j);
            dictionary_unset(dic, key_name);
        }
        dictionary_unset(dic, sec_name);
        CuAssertIntEquals(tc, (i - 1) * (11), dic->n);
    }

    dictionary_del(dic);
}
开发者ID:DelusionalLogic,项目名称:iniparser,代码行数:35,代码来源:test_dictionary.c

示例9: camera_control_backup_system_settings

void camera_control_backup_system_settings(CameraControl* cc, const char* file) {
    int AutoAEC = 0;
    int AutoAGC = 0;
    int Gain = 0;
    int Exposure = 0;
    int Contrast = 0;
    int Brightness = 0;

    int fd = open_v4l2_device(cc->cameraID);

    if (fd != -1) {
        AutoAEC = v4l2_get_control(fd, V4L2_CID_EXPOSURE_AUTO);
        AutoAGC = v4l2_get_control(fd, V4L2_CID_AUTOGAIN);
        Gain = v4l2_get_control(fd, V4L2_CID_GAIN);
        Exposure = v4l2_get_control(fd, V4L2_CID_EXPOSURE);
        Contrast = v4l2_get_control(fd, V4L2_CID_CONTRAST);
        Brightness = v4l2_get_control(fd, V4L2_CID_BRIGHTNESS);
        v4l2_close(fd);

        dictionary* ini = dictionary_new(0);
        iniparser_set(ini, "PSEye", 0);
        iniparser_set_int(ini, "PSEye:AutoAEC", AutoAEC);
        iniparser_set_int(ini, "PSEye:AutoAGC", AutoAGC);
        iniparser_set_int(ini, "PSEye:Gain", Gain);
        iniparser_set_int(ini, "PSEye:Exposure", Exposure);
        iniparser_set_int(ini, "PSEye:Contrast", Contrast);
        iniparser_set_int(ini, "PSEye:Brightness", Brightness);
        iniparser_save_ini(ini, file);
        dictionary_del(ini);
    }
}
开发者ID:kdienes,项目名称:psmoveapi,代码行数:31,代码来源:camera_control_linux.c

示例10: registry_person_del

void registry_person_del(REGISTRY_PERSON *p) {
    debug(D_REGISTRY, "Registry: registry_person_del('%s'): creating dictionary of urls", p->guid);

    while(p->person_urls.root)
        registry_person_unlink_from_url(p, (REGISTRY_PERSON_URL *)p->person_urls.root);

    debug(D_REGISTRY, "Registry: deleting person '%s' from persons registry", p->guid);
    dictionary_del(registry.persons, p->guid);

    debug(D_REGISTRY, "Registry: freeing person '%s'", p->guid);
    freez(p);
}
开发者ID:darrentangdt,项目名称:netdata,代码行数:12,代码来源:registry_person.c

示例11: Test_iniparser_load

void Test_iniparser_load(CuTest *tc)
{
    DIR *dir;
    struct dirent *curr;
    struct stat curr_stat;
    dictionary *dic;
    char ini_path[256];

    /* Dummy tests */
    dic = iniparser_load("/you/shall/not/path");
    CuAssertPtrEquals(tc, NULL, dic);

    /* Test all the good .ini files */
    dir = opendir(GOOD_INI_PATH);
    CuAssertPtrNotNullMsg(tc, "Cannot open good .ini conf directory", dir);
    for (curr = readdir(dir); curr != NULL; curr = readdir(dir)) {
        sprintf(ini_path, "%s/%s", GOOD_INI_PATH, curr->d_name);
        stat(ini_path, &curr_stat);
        if (S_ISREG(curr_stat.st_mode)) {
            dic = iniparser_load(ini_path);
            CuAssertPtrNotNullMsg(tc, ini_path, dic);
            dictionary_del(dic);
        }
    }
    closedir(dir);

    /* Test all the bad .ini files */
    dir = opendir(BAD_INI_PATH);
    CuAssertPtrNotNullMsg(tc, "Cannot open bad .ini conf directory", dir);
    for (curr = readdir(dir); curr != NULL; curr = readdir(dir)) {
        sprintf(ini_path, "%s/%s", BAD_INI_PATH, curr->d_name);
        stat(ini_path, &curr_stat);
        if (S_ISREG(curr_stat.st_mode)) {
            dic = iniparser_load(ini_path);
            CuAssertPtrEquals_Msg(tc, ini_path, NULL, dic);
            dictionary_del(dic);
        }
    }
    closedir(dir);
}
开发者ID:2ion,项目名称:iniparser,代码行数:40,代码来源:test_iniparser.c

示例12: main

int main(int argc, char* argv[])
{
    dictionary*     d ;
    char*       val ;
    int         i ;
    char        cval[90] ;

    /* Allocate dictionary */
    printf("allocating...\n");
    d = dictionary_new(0);

    /* Set values in dictionary */
    printf("setting %d values...\n", NVALS);

    for (i=0 ; i<NVALS ; i++)
    {
        sprintf(cval, "%04d", i);
        dictionary_set(d, cval, "salut");
    }

    printf("getting %d values...\n", NVALS);

    for (i=0 ; i<NVALS ; i++)
    {
        sprintf(cval, "%04d", i);
        val = dictionary_get(d, cval, DICT_INVALID_KEY);

        if (val==DICT_INVALID_KEY)
        {
            printf("cannot get value for key [%s]\n", cval);
        }
    }

    printf("unsetting %d values...\n", NVALS);

    for (i=0 ; i<NVALS ; i++)
    {
        sprintf(cval, "%04d", i);
        dictionary_unset(d, cval);
    }

    if (d->n != 0)
    {
        printf("error deleting values\n");
    }

    printf("deallocating...\n");
    dictionary_del(d);
    return 0 ;
}
开发者ID:freeeyes,项目名称:PSS,代码行数:50,代码来源:dictionary.c

示例13: Test_dictionary_dump

void Test_dictionary_dump(CuTest *tc)
{
    int i, j;
    char sec_name[32];
    char key_name[64];
    dictionary *dic;
    char *dump_buff;
    const char dump_real[] = "\
                sec1\t[]\n\
           sec1:key1\t[dummy_value]\n\
           sec1:key2\t[dummy_value]\n\
           sec1:key3\t[dummy_value]\n\
           sec1:key4\t[dummy_value]\n\
                sec2\t[]\n\
           sec2:key1\t[dummy_value]\n\
           sec2:key2\t[dummy_value]\n\
           sec2:key3\t[dummy_value]\n\
           sec2:key4\t[dummy_value]\n\
";

    dic = dictionary_new(DICTMINSZ);
    CuAssertPtrNotNull(tc, dic);

    /* Try dummy values */
    dictionary_dump(NULL, NULL);
    dictionary_dump(dic, NULL);

    /* Try with empty dictionary first */
    dump_buff = get_dump(dic);
    CuAssertStrEquals(tc, "empty dictionary\n", dump_buff);
    free(dump_buff);

    /* Populate the dictionary */
    for (i = 1 ; i < 3; ++i) {
        sprintf(sec_name, "sec%d", i);
        dictionary_set(dic, sec_name, "");
        for (j = 1 ; j < 5; ++j) {
            sprintf(key_name, "%s:key%d", sec_name, j);
            dictionary_set(dic, key_name, "dummy_value");
        }
    }

    /* Check the dump file */
    dump_buff = get_dump(dic);
    CuAssertStrEquals(tc, dump_real, dump_buff);
    free(dump_buff);

    dictionary_del(dic);
}
开发者ID:DelusionalLogic,项目名称:iniparser,代码行数:49,代码来源:test_dictionary.c

示例14: Test_iniparser_getstring

void Test_iniparser_getstring(CuTest *tc)
{
    dictionary *dic;
    /* NULL test */
    CuAssertPtrEquals(tc, NULL, iniparser_getstring(NULL, NULL, NULL));
    CuAssertPtrEquals(tc, NULL, iniparser_getstring(NULL, "dummy", NULL));

    /* Check the def return element */
    dic = dictionary_new(10);
    CuAssertPtrEquals(tc, NULL, iniparser_getstring(dic, "dummy", NULL));
    CuAssertStrEquals(tc, "def", iniparser_getstring(dic, NULL, "def"));
    CuAssertStrEquals(tc, "def", iniparser_getstring(dic, "dummy", "def"));
    dictionary_del(dic);

    /* Generic dictionary */
    dic = generate_dictionary(100, 10);
    CuAssertStrEquals(tc, "value-0/0",
                      iniparser_getstring(dic, "sec0:key0", NULL));
    CuAssertStrEquals(tc, "value-42/5",
                      iniparser_getstring(dic, "sec42:key5", NULL));
    CuAssertStrEquals(tc, "value-99/9",
                      iniparser_getstring(dic, "sec99:key9", NULL));
    dictionary_del(dic);
}
开发者ID:2ion,项目名称:iniparser,代码行数:24,代码来源:test_iniparser.c

示例15: printf

int main
    (int  argc,
     char *argv[])

{
    LPDICTIONARY lpDict;        // Ptr to workspace dictionary
    LPWCHAR      lpwVal;
    int          i;
    WCHAR        cval[90];

    /* Allocate dictionary */
    printf ("allocating...\n");
    lpDict = dictionary_new (0);

    /* Set values in dictionary */
    printf ("setting %d values...\n", NVALS);
    for (i = 0; i < NVALS; i++)
    {
        wsprintfW (cval, L"%04d", i);
        dictionary_set (lpDict, cval, L"salut");
    } // End FOR

    printf ("getting %d values...\n", NVALS);
    for (i = 0; i < NVALS; i++)
    {
        wsprintfW (cval, L"%04d", i);
        lpwVal = dictionary_get (lpDict, cval, DICT_INVALID_KEY, NULL);
        if (lpwVal EQ DICT_INVALID_KEY)
            printf ("cannot get value for key [%s]\n", cval);
    } // End FOR

    printf ("unsetting %d values...\n", NVALS);
    for (i = 0; i < NVALS; i++)
    {
        wsprintfW (cval, L"%04d", i);
        dictionary_unset (lpDict, cval);
    } // End FOR

    if (lpDict->n NE 0)
        printf ("error deleting values\n");

    printf ("deallocating...\n");
    dictionary_del (lpDict); lpDict = NULL;

    return 0;
} // End main
开发者ID:PlanetAPL,项目名称:nars2000,代码行数:46,代码来源:dictionary.c


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