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


C++ KDB::close方法代码示例

本文整理汇总了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";
}
开发者ID:BernhardDenner,项目名称:libelektra,代码行数:26,代码来源:testkdb_simple.cpp

示例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";
}
开发者ID:BernhardDenner,项目名称:libelektra,代码行数:25,代码来源:testkdb_simple.cpp

示例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;
}
开发者ID:KurtMi,项目名称:libelektra,代码行数:33,代码来源:benchmark_crypto_comparison.cpp

示例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;
}
开发者ID:KurtMi,项目名称:libelektra,代码行数:38,代码来源:benchmark_crypto_comparison.cpp


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