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


C++ ConfigurationTable::remove方法代码示例

本文整理汇总了C++中ConfigurationTable::remove方法的典型用法代码示例。如果您正苦于以下问题:C++ ConfigurationTable::remove方法的具体用法?C++ ConfigurationTable::remove怎么用?C++ ConfigurationTable::remove使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ConfigurationTable的用法示例。


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

示例1: testConfig

/* Run sanity check on configuration table
 *     The global table constructor cannot provide notification in the
 *     event of failure. Make sure that we can access the database,
 *     write to it, and that it contains the bare minimum required keys.
 */
bool testConfig()
{
    int val = 9999;
    std::string test = "asldfkjsaldkf";
    const char *key = "Log.Level";

    /* Attempt to query */
    try {
        gConfig.getStr(key);
    } catch (...) {
        std::cerr << std::endl;
        std::cerr << "Config: Failed query required key " << key
                  << std::endl;
        return false;
    }

    /* Attempt to set a test value in the global config */
    if (!gConfig.set(test, val)) {
        std::cerr << std::endl;
        std::cerr << "Config: Failed to set test key" << std::endl;
        return false;
    } else {
        gConfig.remove(test);
    }

    return true;
}
开发者ID:kkroo,项目名称:osmo-trx,代码行数:32,代码来源:osmo-trx.cpp

示例2: main

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

	gConfig.setUpdateHook(purgeConfig);

	const char *keys[5] = {"key1", "key2", "key3", "key4", "key5"};

	for (int i=0; i<5; i++) {
		gConfig.set(keys[i],i);
	}

	for (int i=0; i<5; i++) {
		cout << "table[" << keys[i] << "]=" << gConfig.getStr(keys[i]) <<  endl;
		cout << "table[" << keys[i] << "]=" << gConfig.getNum(keys[i]) <<  endl;
	}

	for (int i=0; i<5; i++) {
		cout << "defined table[" << keys[i] << "]=" << gConfig.defines(keys[i]) <<  endl;
	}

	gConfig.set("key5","100 200 300  400 ");
	std::vector<unsigned> vect = gConfig.getVector("key5");
	cout << "vect length " << vect.size() << ": ";
	for (unsigned i=0; i<vect.size(); i++) cout << " " << vect[i];
	cout << endl;
	std::vector<string> svect = gConfig.getVectorOfStrings("key5");
	cout << "vect length " << svect.size() << ": ";
	for (unsigned i=0; i<svect.size(); i++) cout << " " << svect[i] << ":";
	cout << endl;

	cout << "bool " << gConfig.getBool("booltest") << endl;
	gConfig.set("booltest",1);
	cout << "bool " << gConfig.getBool("booltest") << endl;
	gConfig.set("booltest",0);
	cout << "bool " << gConfig.getBool("booltest") << endl;

	gConfig.getStr("newstring");
	gConfig.getNum("numnumber");


	SimpleKeyValue pairs;
	pairs.addItems(" a=1 b=34 dd=143 ");
	cout<< pairs.get("a") << endl;
	cout<< pairs.get("b") << endl;
	cout<< pairs.get("dd") << endl;

	gConfig.set("fkey","123.456");
	float fval = gConfig.getFloat("fkey");
	cout << "fkey " << fval << endl;

	cout << "search fkey:" << endl;
	gConfig.find("fkey",cout);
	cout << "search fkey:" << endl;
	gConfig.find("fkey",cout);
	gConfig.remove("fkey");
	cout << "search fkey:" << endl;
	gConfig.find("fkey",cout);

	try {
		gConfig.getNum("supposedtoabort");
	} catch (ConfigurationTableKeyNotFound) {
		cout << "ConfigurationTableKeyNotFound exception successfully caught." << endl;
	}
}
开发者ID:5728136cs,项目名称:CommonLibs,代码行数:64,代码来源:ConfigurationTest.cpp


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