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


C++ KeySet类代码示例

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


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

示例1: TEST

TEST (test_contextual_policy, root)
{
	using namespace kdb;
	KeySet ks;
	ks.append (Key ("user/available", KEY_VALUE, "12", KEY_END));
	Context c;
	// clang-format off
	ContextualValue<int, GetPolicyIs<MyDynamicGetPolicy>> cv
		(ks, c, Key("/",
			KEY_CASCADING_NAME,
			KEY_META, "default", "88",
			KEY_META, "override/#0", "user/available",
			KEY_END));
	// clang-format on

	EXPECT_EQ (cv, 12);
	EXPECT_EQ (cv, cv);
	cv = 40;
	EXPECT_EQ (cv, 40);
	c.activate<RootLayer> ();
	EXPECT_EQ (cv, 40);

	ContextualValue<int, GetPolicyIs<MyDynamicGetPolicy>> cv2 (cv);
	EXPECT_EQ (cv, cv2);
}
开发者ID:BernhardDenner,项目名称:libelektra,代码行数:25,代码来源:testcpp_contextual_policy.cpp

示例2: TEST

TEST(type, version)
{
	try {
		KeySet config;
		config.append(
			Key("system/require_version",
				KEY_VALUE, "3",
				KEY_END)
			);
		TypeChecker tc(config);
		succeed_if (false, "version should not match");
	}
	catch (const char *text)
	{
		succeed_if (true, "version should not match");
		succeed_if (!strcmp(text, "Required Version does not match 2"),
			"failed version text does not match");
	}

	try {
		KeySet config;
		config.append(
			Key("system/require_version",
				KEY_VALUE, "2",
				KEY_END)
			);
		TypeChecker tc(config);
		succeed_if (true, "version should match");
	}
	catch (const char *text)
	{
		succeed_if (false, "version should match");
	}
}
开发者ID:strahlex,项目名称:libelektra,代码行数:34,代码来源:testmod_type.cpp

示例3: getBackendInfo

/**
 * @brief give info about current mounted backends
 *
 * @param mountConf a keyset that contains everything below
 * Backends::mountpointsPath
 *
 * @return an vector of information about mounted backends
 */
Backends::BackendInfoVector Backends::getBackendInfo (KeySet mountConf)
{
	std::vector<BackendInfo> ret;
	Key rootKey (Backends::mountpointsPath, KEY_END);
	Key cur;

	mountConf.rewind ();
	while ((cur = mountConf.next ()))
	{
		if (cur.isDirectBelow (rootKey))
		{
			BackendInfo bi;

			Key path = mountConf.lookup (cur.getName () + "/config/path");
			if (path)
			{
				bi.path = path.getString ();
			}
			Key mp = mountConf.lookup (cur.getName () + "/mountpoint");
			if (mp)
			{
				bi.mountpoint = mp.getString ();
			}
			bi.name = cur.getBaseName ();

			ret.push_back (bi);
		}
	}
	return ret;
}
开发者ID:0003088,项目名称:libelektra,代码行数:38,代码来源:backends.cpp

示例4: invalid_argument

int MetaRemoveCommand::execute (Cmdline const & cl)
{
	if (cl.arguments.size () != 2)
	{
		throw invalid_argument ("Need 2 arguments");
	}
	Key parentKey = cl.createKey (0);
	string metaname = cl.arguments[1];

	KeySet conf;
	kdb.get (conf, parentKey);
	printWarnings (cerr, parentKey);

	Key k = conf.lookup (parentKey);

	if (!k)
	{
		cerr << "Key not found" << endl;
		return 1;
	}

	k.delMeta (metaname);

	kdb.set (conf, parentKey);

	return 0;
}
开发者ID:KurtMi,项目名称:libelektra,代码行数:27,代码来源:metaremove.cpp

示例5: keys

/* ************************************************************************* */
GaussianFactorGraph::Keys GaussianFactorGraph::keys() const {
    KeySet keys;
    BOOST_FOREACH(const sharedFactor& factor, *this)
    if (factor)
        keys.insert(factor->begin(), factor->end());
    return keys;
}
开发者ID:exoter-rover,项目名称:slam-gtsam,代码行数:8,代码来源:GaussianFactorGraph.cpp

示例6: 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

示例7: detectConflicts

MergeResult ThreeWayMerge::mergeKeySet (const MergeTask & task)
{

	MergeResult result;
	detectConflicts (task, result);
	detectConflicts (task.reverse (), result, true);

	if (!result.hasConflicts ()) return result;


	// TODO: test this behaviour (would probably need mocks)
	Key current;
	KeySet conflicts = result.getConflictSet ();
	conflicts.rewind ();
	while ((current = conflicts.next ()))
	{
		for (auto & elem : strategies)
		{
			(elem)->resolveConflict (task, current, result);

			if (!result.isConflict (current)) break;
		}
	}

	return result;
}
开发者ID:fberlakovich,项目名称:libelektra,代码行数:26,代码来源:threewaymerge.cpp

示例8: doBasicTest

void TestCommand::doBasicTest ()
{
	{
		KDB kdb;
		Key t = root.dup ();
		t.addBaseName ("basic");
		t.setString ("BasicString");
		KeySet basic;
		basic.append (t);

		KeySet test;
		kdb.get (test, root);
		kdb.set (basic, root);
	}

	{
		KDB kdb;
		Key t = root.dup ();
		t.addBaseName ("basic");
		t.setString ("BasicString");

		KeySet test;
		kdb.get (test, root);

		nrTest++;
		if (!test.lookup (t))
		{
			nrError++;
			cerr << "Basic test failed" << endl;
		}
	}
}
开发者ID:mpranj,项目名称:libelektra,代码行数:32,代码来源:test.cpp

示例9: execute

int GetCommand::execute (Cmdline const & cl)
{
	if (cl.arguments.size () != 1) throw invalid_argument ("Need one argument");

	KeySet conf;

	kdb::Key root = cl.createKey (0);
	kdb::KDB kdb (root);

	std::string n;
	if (cl.all)
	{
		n = root.getName ();
		root.setName ("/");
	}

	kdb.get (conf, root);

	if (cl.all)
	{
		root.setName (n);
	}

	// do a lookup without tracer to warm up default cache
	conf.lookup (root);

	root.setCallback (warnOnMeta);
	if (cl.verbose)
	{
		cout << "got " << conf.size () << " keys" << std::endl;
		root.setCallback (printTrace);
	}
	Key k = conf.lookup (root);

	int ret = 0;

	if (k)
	{
		if (cl.verbose)
		{
			cout << "The resulting keyname is " << k.getName () << std::endl;
		}
		cout << k.getString ();
	}
	else
	{
		cerr << "Did not find key";
		ret = 1;
	}

	if (!cl.noNewline)
	{
		cout << endl;
	}

	printWarnings (cerr, root);
	printError (cerr, root);

	return ret;
}
开发者ID:fberlakovich,项目名称:libelektra,代码行数:60,代码来源:get.cpp

示例10: TypeChecker

	TypeChecker(KeySet config)
	{
		enforce = config.lookup("/enforce");
		Key k = config.lookup("/require_version");
		if (k && k.getString() != "2") throw "Required Version does not match 2";

		types.insert (pair<string, Type*>("short", new MType<kdb::short_t>()));
		types.insert (pair<string, Type*>("unsigned_short", new MType<kdb::unsigned_short_t>()));
		types.insert (pair<string, Type*>("long", new MType<kdb::long_t>()));
		types.insert (pair<string, Type*>("unsigned_long", new MType<kdb::unsigned_long_t>()));
		types.insert (pair<string, Type*>("long_long", new MType<kdb::long_long_t>()));
		types.insert (pair<string, Type*>("unsigned_long_long", new MType<kdb::unsigned_long_long_t>()));

		types.insert (pair<string, Type*>("float", new TType<kdb::float_t>()));
		types.insert (pair<string, Type*>("double", new TType<kdb::double_t>()));
		types.insert (pair<string, Type*>("long_double", new TType<kdb::long_double_t>()));
		types.insert (pair<string, Type*>("char", new TType<kdb::char_t>()));
		types.insert (pair<string, Type*>("boolean", new TType<kdb::boolean_t>()));
		types.insert (pair<string, Type*>("octet", new TType<kdb::octet_t>()));

		// non-standard types (deprecated, just for
		// compatibility):
		types.insert (pair<string, Type*>("any", new AnyType()));
		types.insert (pair<string, Type*>("empty", new EmptyType()));
		types.insert (pair<string, Type*>("FSType", new FSType()));
		types.insert (pair<string, Type*>("string", new StringType()));
	}
开发者ID:intfrr,项目名称:libelektra,代码行数:27,代码来源:type_checker.hpp

示例11: existingParent

void RemountCommand::cloneMountpoint(Cmdline const & cl)
{
	Key existingParent (Backends::getBasePath(existingName), KEY_END);
	Key newParent (Backends::getBasePath(mp), KEY_END);

	KeySet existingBackend = mountConf.cut(existingParent);
	mountConf.append(existingBackend);
	KeySet newBackend(existingBackend.size(), KS_END);
	string configPath = newParent.getName() + "/config/path";
	string mpPath = newParent.getName() + "/mountpoint";
	existingBackend.rewind();
	while (Key current = existingBackend.next())
	{
		Key newKey = rebaseKey (current, existingParent, newParent);
		newBackend.append(newKey);

		if (newKey.getName() == mpPath)
		{
			newKey.setString(mp);
		}

		if (newKey.getName() == configPath)
		{
			newKey.setString(cl.arguments[0]);
		}
	}

	mountConf.append(newBackend);
}
开发者ID:0003088,项目名称:libelektra-qt-gui-test,代码行数:29,代码来源:remount.cpp

示例12: main

int main ()
{
	using namespace kdb;

	std::vector<Key> vc;
	vc.push_back (Key ("user/key3/1", KEY_META, "order", "2", KEY_END));
	vc.push_back (Key ("user/begin", KEY_META, "order", "1", KEY_END));
	vc.push_back (Key ("user/key3/4", KEY_META, "order", "3", KEY_END));
	vc.push_back (Key ("user/key3/dup", KEY_META, "order", "4", KEY_END));
	vc.push_back (Key ("user/key3/dup", KEY_END));
	vc.push_back (Key ("user/unordered", KEY_END));
	vc.push_back (Key ("user/end", KEY_META, "order", "5", KEY_END));

	std::sort (vc.begin (), vc.end (), keyOrder);

	KeySet ks (20, KS_END);
	std::cout << "Our Vector with special ordering:" << std::endl;
	for (auto k : vc)
	{

		std::cout << k.getName () << std::endl;
		ks.append (k);
	}
	// now we have a keyset (of course again with KeySet ordering and
	// duplicates removed.
	std::cout << "\nNow KeySet:" << std::endl;
	for (auto && ks_i : ks)
	{
		Key k (ks_i);
		std::cout << k.getName () << std::endl;
	}
}
开发者ID:nikonthethird,项目名称:libelektra,代码行数:32,代码来源:cpp_example_ordering.cpp

示例13: invalid_argument

int LsCommand::execute (Cmdline const & cl)
{
	if (cl.arguments.size () != 1)
	{
		throw invalid_argument ("1 argument required");
	}

	printWarnings (cerr, root);

	root = cl.createKey (0);

	kdb.get (ks, root);

	if (cl.verbose) cout << "size of all keys in mountpoint: " << ks.size () << endl;

	KeySet part (ks.cut (root));

	if (cl.verbose) cout << "size of requested keys: " << part.size () << endl;
	cout.setf (std::ios_base::unitbuf);
	if (cl.null)
	{
		cout.unsetf (std::ios_base::skipws);
	}

	cout << part;

	printWarnings (cerr, root);

	return 0;
}
开发者ID:BernhardDenner,项目名称:libelektra,代码行数:30,代码来源:ls.cpp

示例14: detectConflicts

MergeResult ThreeWayMerge::mergeKeySet(const MergeTask& task)
{

	MergeResult result;
	detectConflicts (task, result);
	detectConflicts (task.reverse (), result, true);

	if (!result.hasConflicts()) return result;


	// TODO: test this behaviour (would probably need mocks)
	Key current;
	KeySet conflicts = result.getConflictSet();
	conflicts.rewind();
	while ((current = conflicts.next ()))
	{
		for (vector<MergeConflictStrategy *>::iterator it = strategies.begin (); it != strategies.end (); ++it)
		{
			(*it)->resolveConflict (task, current, result);

			if (!result.isConflict(current))
				break;
		}
	}

	return result;
}
开发者ID:intfrr,项目名称:libelektra,代码行数:27,代码来源:threewaymerge.cpp

示例15: checkArguments

int LsCommand::execute (Cmdline const & cl)
{
	checkArguments (cl);

	printWarnings (cerr, root);

	root = cl.createKey (0);

	kdb.get (ks, root);

	if (cl.verbose) cout << "size of all keys in mountpoint: " << ks.size () << endl;

	KeySet part (ks.cut (root));

	if (cl.verbose) cout << "size of requested keys: " << part.size () << endl;
	cout.setf (std::ios_base::unitbuf);
	if (cl.null)
	{
		cout.unsetf (std::ios_base::skipws);
	}

	printResults (part, getDepth (root), cl);

	printWarnings (cerr, root);

	return 0;
}
开发者ID:waht,项目名称:libelektra,代码行数:27,代码来源:ls.cpp


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