本文整理汇总了C++中SpecReader类的典型用法代码示例。如果您正苦于以下问题:C++ SpecReader类的具体用法?C++ SpecReader怎么用?C++ SpecReader使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了SpecReader类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: TEST
TEST (SpecReader, withNeedsResolved)
{
using namespace kdb;
using namespace kdb::tools;
std::shared_ptr<MockPluginDatabase> mpd = std::make_shared<MockPluginDatabase> ();
mpd->data[PluginSpec ("a")]["provides"] = "storage";
mpd->data[PluginSpec ("b")]["provides"] = "resolver";
BackendBuilderInit mpi (mpd);
SpecReader sr (mpi);
// clang-format off
sr.readSpecification(KeySet(5,
*Key ("spec", KEY_END),
*Key ("spec/mp", KEY_META, "mountpoint", "file.ini",
KEY_META, "config/needs/something", "here",
KEY_META, "infos/needs", "resolver storage",
KEY_END),
*Key ("spec/mp/below",
KEY_META, "config/needs/else", "too",
KEY_META, "infos/needs", "a b",
KEY_END),
KS_END));
// clang-format on
SpecBackendBuilder bi = sr.getBackends ()[Key ("spec/mp", KEY_END)];
EXPECT_EQ (bi.nodes, 2);
EXPECT_EQ (bi.getMountpoint (), "/mp");
EXPECT_EQ (bi.getConfigFile (), "file.ini");
EXPECT_EQ (bi.getBackendConfig (),
KeySet (5, *Key ("user/something", KEY_VALUE, "here", KEY_END), *Key ("user/else", KEY_VALUE, "too", KEY_END), KS_END));
bi.resolveNeeds ();
ASSERT_EQ (std::distance (bi.begin (), bi.end ()), 2) << "there should be a resolver and storage added";
EXPECT_EQ (bi.begin ()[0], PluginSpec ("b", "resolver"));
EXPECT_EQ (bi.begin ()[1], PluginSpec ("a", "storage"));
}
示例2: buildBackend
void SpecMountCommand::buildBackend (Cmdline const & cl)
{
SpecReader sr;
kdb::KeySet specToRead;
kdb.get (specToRead, "spec" + mp);
specToRead = specToRead.cut (Key ("spec" + mp, KEY_END));
sr.readSpecification (specToRead);
SpecReader::Backends const & backends = sr.getBackends ();
for (auto & p : backends)
{
auto backend = p.second;
if (cl.verbose)
{
std::cout << "Got mountpoint from " << p.first.getName () << " with " << backend.nodes
<< " nodes, configfile: " << backend.getConfigFile () << " and mountpoint: " << backend.getMountpoint ()
<< std::endl;
}
backend.setBackendConfig (cl.getPluginsConfig ("system/"));
backend.needPlugin (cl.resolver);
backend.needPlugin ("storage");
backend.addPlugins (parseArguments (cl.plugins));
const int alreadyRead = 1; // we already read mountpoint
if (cl.arguments.size () <= alreadyRead)
{
backend.addPlugins (parseArguments (cl.arguments.begin () + alreadyRead, cl.arguments.end ()));
}
// Call it a day
outputMissingRecommends (backend.resolveNeeds (cl.withRecommends));
Backends::umount (backend.getMountpoint (), mountConf);
backend.serialize (mountConf);
}
if (!cl.quiet && backends.empty ())
{
std::cout << "No metadata \"mountpoint\" found below spec" << mp << std::endl;
}
}