本文整理汇总了C++中KeySet::clear方法的典型用法代码示例。如果您正苦于以下问题:C++ KeySet::clear方法的具体用法?C++ KeySet::clear怎么用?C++ KeySet::clear使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类KeySet
的用法示例。
在下文中一共展示了KeySet::clear方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
TEST_F (Simple, RemoveFile)
{
using namespace kdb;
KDB kdb;
KeySet ks;
kdb.get (ks, testRoot);
ks.append (Key ("system" + testRoot + "remove", KEY_END));
ASSERT_EQ (ks.size (), 1) << "could not append key\n" << ks;
kdb.set (ks, testRoot);
ASSERT_EQ (ks.size (), 1) << "key gone after kdb.set?\n" << ks;
struct stat buf;
ASSERT_EQ (stat (mp->systemConfigFile.c_str (), &buf), 0) << "found no file";
Key parentKey;
kdb.close (parentKey);
kdb.open (parentKey);
kdb.get (ks, testRoot);
ks.clear ();
ASSERT_EQ (ks.size (), 0) << "keyset should be empty after clearing it\n" << ks;
kdb.set (ks, testRoot);
ASSERT_EQ (stat (mp->systemConfigFile.c_str (), &buf), -1) << "found wrong file";
}
示例2: ksToIterate
std::vector<PluginSpec> PluginVariantDatabase::getPluginVariantsFromGenconf (PluginSpec const & whichplugin, KeySet const & genconf,
KeySet const & sysconf) const
{
std::vector<PluginSpec> result;
KeySet ksToIterate (genconf);
for (auto kCurrent : ksToIterate)
{
Key kCurrentTest (kCurrent.getNamespace () + "/", KEY_END);
kCurrentTest.addBaseName (kCurrent.getBaseName ()); // e.g. system/space
if (kCurrentTest == kCurrent)
{
PluginSpec variant (whichplugin);
KeySet ksVariantConfToAdd;
// new base for plugin conf
Key kVariantPluginConf ("system/", KEY_END);
// take variant config from genconf and transform it to proper plugin conf,
// e.g. system/space/config/format -> system/format
Key kVariantConf (kCurrentTest);
kVariantConf.addBaseName ("config"); // e.g. system/space/config
this->addKeysBelowKeyToConf (kVariantConf, genconf, kVariantPluginConf, ksVariantConfToAdd);
// TODO plugin infos
// check if the variant was disabled : system/elektra/plugins/simpleini/variants/space/disable
Key kDisable = sysconf.lookup (this->buildVariantSysconfKey (whichplugin, kCurrent.getBaseName (), "disable"));
if (kDisable && kDisable.getString () == "1")
{
continue; // skip this variant
}
// check if an override is available : system/elektra/plugins/simpleini/variants/space/override
Key kOverride = sysconf.lookup (this->buildVariantSysconfKey (whichplugin, kCurrent.getBaseName (), "override"));
if (kOverride && kOverride.getString () == "1")
{
// first delete config from genconf entirely
ksVariantConfToAdd.clear ();
Key kVariantSysconf (this->buildVariantSysconfKey (whichplugin, kCurrent.getBaseName (), "config"));
this->addKeysBelowKeyToConf (kVariantSysconf, sysconf, kVariantPluginConf, ksVariantConfToAdd);
}
if (ksVariantConfToAdd.size () == 0)
{
continue; // no config means no variant
}
variant.appendConfig (ksVariantConfToAdd);
result.push_back (variant);
}
}
std::vector<PluginSpec> resFromSysconf (this->getPluginVariantsFromSysconf (whichplugin, sysconf, genconf));
result.insert (result.end (), resFromSysconf.begin (), resFromSysconf.end ());
return result;
}