本文整理汇总了C++中ConfigFile::dump_results方法的典型用法代码示例。如果您正苦于以下问题:C++ ConfigFile::dump_results方法的具体用法?C++ ConfigFile::dump_results怎么用?C++ ConfigFile::dump_results使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ConfigFile
的用法示例。
在下文中一共展示了ConfigFile::dump_results方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
//.........这里部分代码省略.........
ok(ini->items[0].found, "Test presence of char[]");
ok(!strcmp(ini->items[0].val.nameval, "datastore1"), "Test char[]");
ok(ini->items[1].found, "Test presence of char*");
ok(!strcmp(ini->items[1].val.strval, "host1"), "Test char*");
ok(ini->items[2].found, "Test presence of int");
ok(ini->items[2].val.int64val == 10, "Test int");
ok(ini->items[4].val.boolval == true, "Test bool");
ok(ini->items[6].val.int32val == 100, "Test int 32");
alist *list = ini->items[3].val.alistval;
nok(ini->items[3].found, "Test presence of alist");
fprintf(fp, "list=a\nlist=b\nlist=c\n");
fflush(fp);
ini->clear_items();
ok(ini->parse("test.cfg"), "Test with all members");
list = ini->items[3].val.alistval;
ok(ini->items[3].found, "Test presence of alist");
ok(list != NULL, "Test list member");
ok(list->size() == 3, "Test list size");
ok(!strcmp((char *)list->get(0), "a"), "Testing alist[0]");
ok(!strcmp((char *)list->get(1), "b"), "Testing alist[1]");
ok(!strcmp((char *)list->get(2), "c"), "Testing alist[2]");
system("cp -f test.cfg test3.cfg");
fprintf(fp, "pouet='10, 11, 12'\n");
fprintf(fp, "pint=-100\n");
fprintf(fp, "int64val=-100\n"); /* TODO: fix negative numbers */
fflush(fp);
ini->clear_items();
ok(ini->parse("test.cfg"), "Test with errors");
nok(ini->items[5].found, "Test presence of positive int");
fclose(fp);
ini->clear_items();
ini->free_items();
/* Test */
if ((fp = fopen("test2.cfg", "w")) == NULL) {
exit (1);
}
fprintf(fp,
"# this is a comment\n"
"optprompt=\"Datastore Name\"\n"
"[email protected]@\n"
"optprompt=\"New Hostname to create\"\n"
"[email protected]@\n"
"optprompt=\"Some 64 integer\"\n"
"optrequired=yes\n"
"[email protected]@\n"
"[email protected]@\n"
"[email protected]@\n"
"[email protected]@\n"
"[email protected]@\n"
"[email protected]@\n"
"[email protected]@\n"
);
fclose(fp);
buf = new POOL_MEM(PM_BSOCK);
ok(ini->unserialize("test2.cfg"), "Test dynamic parse");
ok(ini->serialize("test4.cfg"), "Try to dump the item table in a file");
ok(ini->serialize(buf) > 0, "Try to dump the item table in a buffer");
ok(ini->parse("test3.cfg"), "Parse test file with dynamic grammar");
ok((pos = ini->get_item("datastore")) == 0, "Check datastore definition");
ok(ini->items[pos].found, "Test presence of char[]");
ok(!strcmp(ini->items[pos].val.nameval, "datastore1"), "Test char[]");
ok(!strcmp(ini->items[pos].comment, "Datastore Name"), "Check comment");
ok(ini->items[pos].required == false, "Check required");
ok((pos = ini->get_item("newhost")) == 1, "Check newhost definition");
ok(ini->items[pos].found, "Test presence of char*");
ok(!strcmp(ini->items[pos].val.strval, "host1"), "Test char*");
ok(ini->items[pos].required == false, "Check required");
ok((pos = ini->get_item("int64val")) == 2, "Check int64val definition");
ok(ini->items[pos].found, "Test presence of int");
ok(ini->items[pos].val.int64val == 10, "Test int");
ok(ini->items[pos].required == true, "Check required");
ok((pos = ini->get_item("bool")) == 4, "Check bool definition");
ok(ini->items[pos].val.boolval == true, "Test bool");
ok(ini->dump_results(buf), "Test to dump results");
printf("<%s>\n", buf);
ini->clear_items();
ini->free_items();
report();
delete buf;
exit (0);
}