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


C++ KeySet::size方法代码示例

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


在下文中一共展示了KeySet::size方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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";
}
开发者ID:BernhardDenner,项目名称:libelektra,代码行数:25,代码来源:testkdb_simple.cpp

示例2: yamlRead

/**
 * @brief Read a YAML file and add the resulting data to a given key set
 *
 * @param mappings The key set where the YAML data will be stored
 * @param parent This key stores the path to the YAML data file that should be read
 */
void yamlcpp::yamlRead (KeySet & mappings, Key & parent)
{
	YAML::Node config = YAML::LoadFile (parent.getString ());

#ifdef HAVE_LOGGER
	ostringstream data;
	data << config;
	ELEKTRA_LOG_DEBUG ("Read data “%s”", data.str ().c_str ());
#endif

	convertNodeToKeySet (config, mappings, parent);
	ELEKTRA_LOG_DEBUG ("Added %zd key%s", mappings.size (), mappings.size () == 1 ? "" : "s");
}
开发者ID:KurtMi,项目名称:libelektra,代码行数:19,代码来源:read.cpp

示例3:

TEST_F(ThreeWayMergeTest, DeleteModifyConflict)
{
	ours.lookup ("user/parento/config/key1", KDB_O_POP);
	theirs.lookup ("user/parentt/config/key1").setString ("modifiedvalue");

	MergeResult result = merger.mergeKeySet (base, ours, theirs, mergeParent);

	EXPECT_TRUE(result.hasConflicts()) << "No conflict detected although conflicts should exist";
	KeySet conflicts = result.getConflictSet ();
	ASSERT_EQ(1, conflicts.size())<< "Wrong number of conflicts";
	testConflictMeta (conflicts.at (0), CONFLICT_DELETE, CONFLICT_MODIFY);
	KeySet merged = result.getMergedKeys ();
	EXPECT_EQ(4, merged.size ());
	compareAllExceptKey1 (merged);
}
开发者ID:tryge,项目名称:libelektra,代码行数:15,代码来源:testtool_mergecases.cpp

示例4: execute

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

示例5: execute

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

示例6: parentKey

TEST_F (Simple, GetAppendMeta)
{
	using namespace kdb;
	KDB kdb;
	KeySet ks;
	ks.append (Key ("meta/key", KEY_META_NAME, KEY_END));
	Key parentKey (testRoot, KEY_END);
	kdb.get (ks, parentKey);
	ASSERT_EQ (ks.size (), 1) << "no key stayed";
	ks.rewind ();
	ks.next ();
	EXPECT_EQ (ks.current ().getName (), "meta/key") << "name of element in keyset wrong";
	EXPECT_EQ (ks.current ().getString (), "") << "string of element in keyset wrong";
	kdb.set (ks, parentKey);
	ks.rewind ();
	ks.next ();
	EXPECT_EQ (ks.current ().getName (), "meta/key") << "name of element in keyset wrong";
	EXPECT_EQ (ks.current ().getString (), "") << "string of element in keyset wrong";
	kdb.close (parentKey);

	KeySet ks2;
	kdb.open (parentKey);
	kdb.get (ks2, parentKey);
	ASSERT_EQ (ks2.size (), 0) << "got keys from freshly mounted backends";
}
开发者ID:BernhardDenner,项目名称:libelektra,代码行数:25,代码来源:testkdb_simple.cpp

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

示例8: cloneMountpoint

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

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

示例10: ksSysconf

std::vector<PluginSpec> PluginVariantDatabase::getPluginVariantsFromSysconf (PluginSpec const & whichplugin, KeySet const & sysconf,
									     KeySet const & genconfToIgnore) const
{
	std::vector<PluginSpec> result;

	KeySet ksSysconf (sysconf);

	// first find possible variants
	Key kVariantBase ("system/elektra/plugins", KEY_END);
	kVariantBase.addBaseName (whichplugin.getName ());
	kVariantBase.addBaseName ("variants");

	KeySet ksPluginVariantSysconf (ksSysconf.cut (kVariantBase));
	KeySet ksToIterate (ksPluginVariantSysconf);
	for (auto kCurrent : ksToIterate)
	{
		Key kCurrentTest (kVariantBase);
		kCurrentTest.addBaseName (kCurrent.getBaseName ());
		if (kCurrentTest == kCurrent)
		{
			PluginSpec variant (whichplugin);
			KeySet ksVariantConfToAdd;

			// new base for plugin conf
			Key kVariantPluginConf ("system/", KEY_END);

			// add system conf for plugin variant
			Key kVariantSysconf (this->buildVariantSysconfKey (whichplugin, kCurrent.getBaseName (), "config"));
			this->addKeysBelowKeyToConf (kVariantSysconf, ksPluginVariantSysconf, kVariantPluginConf, ksVariantConfToAdd);

			// 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 the variant is in the genconfToIgnore list
			Key kGenconfVariant (kVariantPluginConf);
			kGenconfVariant.addBaseName (kCurrent.getBaseName ());
			Key kIgnore = genconfToIgnore.lookup (kGenconfVariant);
			if (kIgnore)
			{
				continue; // this variant was added by genconf already
			}

			if (ksVariantConfToAdd.size () == 0)
			{
				continue; // no config means no variant
			}

			variant.appendConfig (ksVariantConfToAdd);
			result.push_back (variant);
		}
	}

	return result;
}
开发者ID:reox,项目名称:libelektra,代码行数:58,代码来源:plugindatabase.cpp

示例11: parent

TEST_F (Simple, WrongParent)
{
	using namespace kdb;
	KDB kdb;
	Key parent ("meta", KEY_META_NAME, KEY_END);
	KeySet ks;
	EXPECT_THROW (kdb.set (ks, parent), kdb::KDBException);
	ASSERT_EQ (ks.size (), 0) << "got keys from freshly mounted backends" << ks;
}
开发者ID:BernhardDenner,项目名称:libelektra,代码行数:9,代码来源:testkdb_simple.cpp

示例12: rangesFromKeySets

MojErr MojDbQueryPlan::rangesFromKeySets(const KeySet& lowerKeys, const KeySet& upperKeys, const KeySet& prefixKeys,
		const MojDbQuery::WhereClause* clause)
{
	MojAssert(lowerKeys.size() == upperKeys.size() && lowerKeys.size() == prefixKeys.size());

	MojUInt32 index = 0;
	KeySet::ConstIterator lowerIter = lowerKeys.begin();
	KeySet::ConstIterator upperIter = upperKeys.begin();
	KeySet::ConstIterator prefixIter = prefixKeys.begin();
	while (lowerIter != lowerKeys.end()) {
		MojErr err = rangesFromKeys(*lowerIter, *upperIter, *prefixIter, index, clause);
		MojErrCheck(err);
		++index;
		++lowerIter;
		++upperIter;
		++prefixIter;
	}
	return MojErrNone;
}
开发者ID:KyleMaas,项目名称:db8,代码行数:19,代码来源:MojDbQueryPlan.cpp

示例13: k

TEST_F (Simple, TryChangeAfterSet)
{
	using namespace kdb;
	KDB kdb;
	KeySet ks;
	std::string name = "system" + testRoot + "try_change";
	Key k (name, KEY_END);
	EXPECT_EQ (k.getName (), name);
	ks.append (k);
	EXPECT_THROW (k.setName ("user/x"), kdb::KeyInvalidName);
	EXPECT_EQ (k.getName (), name);
	kdb.get (ks, testRoot);
	ASSERT_EQ (ks.size (), 1) << "lost keys in get\n" << ks;
	kdb.set (ks, testRoot);
	EXPECT_THROW (k.setName ("user/x"), kdb::KeyInvalidName);
	EXPECT_EQ (k.getName (), name);
	ASSERT_EQ (ks.size (), 1) << "got no keys\n" << ks;
	struct stat buf;
	ASSERT_EQ (stat (mp->systemConfigFile.c_str (), &buf), 0) << "did not find config file";
}
开发者ID:BernhardDenner,项目名称:libelektra,代码行数:20,代码来源:testkdb_simple.cpp

示例14:

TEST_F (AutoMergeStrategyTest, EqualsDeleteMerges)
{
	task.theirs.lookup ("user/parentt/config/key1", KDB_O_POP);
	Key conflictKey = mergeKeys.lookup (mk1);
	result.addConflict (conflictKey, CONFLICT_SAME, CONFLICT_DELETE);
	conflictKey = result.getConflictSet ().at (0);

	strategy.resolveConflict (task, conflictKey, result);

	EXPECT_FALSE (result.hasConflicts ()) << "Invalid conflict detected";
	KeySet merged = result.getMergedKeys ();
	EXPECT_EQ (3, merged.size ());

	/* key with index 1 should be deleted */
	compareAllExceptKey1 (merged);
}
开发者ID:BernhardDenner,项目名称:libelektra,代码行数:16,代码来源:testtool_automergestrategy.cpp

示例15: Key

TEST_F(NewKeyStrategyTest, EqualsAddKeyMerge)
{
	Key addedKey = Key ("user/parentt/config/key5", KEY_VALUE, "value5", KEY_END);
	task.theirs.append (addedKey);
	mergeKeys.append (mk5);
	Key conflictKey = mergeKeys.lookup (mk5);
	result.addConflict (conflictKey, CONFLICT_SAME, CONFLICT_ADD);
	conflictKey = result.getConflictSet ().at (0);

	strategy.resolveConflict (task, conflictKey, result);

	EXPECT_FALSE(result.hasConflicts()) << "Invalid conflict detected";
	KeySet merged = result.getMergedKeys ();
	EXPECT_EQ(5, merged.size ());
	compareAllKeys (merged);
}
开发者ID:0003088,项目名称:libelektra-qt-gui-test,代码行数:16,代码来源:testtool_newkeystrategy.cpp


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