本文整理汇总了C++中KDB::close方法的典型用法代码示例。如果您正苦于以下问题:C++ KDB::close方法的具体用法?C++ KDB::close怎么用?C++ KDB::close使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类KDB
的用法示例。
在下文中一共展示了KDB::close方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: parentKey
TEST_F (Simple, SetSystemGetAppend2)
{
using namespace kdb;
KDB kdb;
KeySet ks;
Key parentKey (testRoot, KEY_END);
ks.append (Key ("system" + testRoot + "key", KEY_VALUE, "value1", KEY_END));
kdb.get (ks, parentKey);
ASSERT_EQ (ks.size (), 1) << "got keys from freshly mounted backends";
ks.rewind ();
ks.next ();
EXPECT_EQ (ks.current ().getName (), "system/tests/kdb/key") << "name of element in keyset wrong";
EXPECT_EQ (ks.current ().getString (), "value1") << "string of element in keyset wrong";
kdb.set (ks, parentKey);
kdb.close (parentKey);
KeySet ks2;
ks2.append (Key ("system" + testRoot + "key2", KEY_VALUE, "value2", KEY_END));
kdb.open (parentKey);
kdb.get (ks2, parentKey);
ks2.rewind ();
ks2.next ();
ASSERT_EQ (ks2.size (), 1) << "wrong size";
EXPECT_EQ (ks2.current ().getName (), "system/tests/kdb/key") << "name of element in keyset wrong";
EXPECT_EQ (ks2.current ().getString (), "value1") << "string of element in keyset wrong";
}
示例2:
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";
}
示例3: mountBackend
kdb::Key mountBackend (int iteration)
{
using namespace kdb;
using namespace kdb::tools;
Key mp = getMountpointForIteration<VARIANT> (iteration);
std::string cf = "benchmark_" + plugin_variant_names[VARIANT] + "_" + std::to_string (iteration) + ".ecf";
unlink (cf.c_str ());
KDB kdb;
KeySet mountConfig;
kdb.get (mountConfig, "system/elektra/mountpoints");
MountBackendBuilder b;
b.setMountpoint (mp, KeySet (0, KS_END));
b.addPlugin (PluginSpec ("resolver"));
b.useConfigFile (cf);
b.addPlugin (PluginSpec ("dump"));
if (VARIANT != NO_CRYPTO)
{
KeySet pluginConfig;
pluginConfig.append (Key ("user/encrypt/key", KEY_VALUE, GPG_TEST_KEY_ID, KEY_END));
pluginConfig.append (Key ("user/gpg/unit_test", KEY_VALUE, "1", KEY_END));
b.addPlugin (PluginSpec (plugin_variant_names[VARIANT], pluginConfig));
}
b.validated ();
b.serialize (mountConfig);
kdb.set (mountConfig, "system/elektra/mountpoints");
kdb.close ();
return mp;
}
示例4: t
__attribute__ ((noinline)) void benchmark_crypto_set (int iteration)
{
using namespace kdb;
using namespace kdb::tools;
static Timer t (plugin_variant_names[VARIANT]);
Key mp = mountBackend<VARIANT> (iteration);
{
KDB kdb;
KeySet ks;
kdb.get (ks, mp);
for (int i = 0; i < nr_keys; ++i)
{
// clang-format off
ks.append (Key (mp.getName () + "/k" + std::to_string (i),
KEY_VALUE, "value",
KEY_META, "crypto/encrypt", "1",
KEY_END));
// clang-format on
}
/***************************************************************************
* start of measurement
**************************************************************************/
t.start ();
kdb.set (ks, mp);
t.stop ();
/***************************************************************************
* end of measurement
**************************************************************************/
kdb.close ();
}
std::cout << t;
}