本文整理汇总了C++中abstractconfiguration::Keys::size方法的典型用法代码示例。如果您正苦于以下问题:C++ Keys::size方法的具体用法?C++ Keys::size怎么用?C++ Keys::size使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类abstractconfiguration::Keys
的用法示例。
在下文中一共展示了Keys::size方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: createConfiguration
void ConfigurationMapperTest::testMapper2()
{
AutoPtr<AbstractConfiguration> pConf = createConfiguration();
AutoPtr<AbstractConfiguration> pMapper = new ConfigurationMapper("config", "root.conf", pConf);
assert (pMapper->hasProperty("root.conf.value1"));
assert (pMapper->hasProperty("root.conf.value2"));
AbstractConfiguration::Keys keys;
pMapper->keys(keys);
assert (keys.size() == 1);
assert (std::find(keys.begin(), keys.end(), "root") != keys.end());
pMapper->keys("root", keys);
assert (keys.size() == 1);
assert (std::find(keys.begin(), keys.end(), "conf") != keys.end());
pMapper->keys("root.conf", keys);
assert (keys.size() == 3);
assert (std::find(keys.begin(), keys.end(), "value1") != keys.end());
assert (std::find(keys.begin(), keys.end(), "value2") != keys.end());
assert (std::find(keys.begin(), keys.end(), "sub") != keys.end());
assert (pMapper->getString("root.conf.value1") == "v1");
assert (pMapper->getString("root.conf.sub.value2") == "v4");
pMapper->setString("root.conf.value3", "v5");
assert (pMapper->getString("root.conf.value3") == "v5");
assert (pConf->getString("config.value3") == "v5");
}
示例2: testRemove
void LayeredConfigurationTest::testRemove()
{
AutoPtr<LayeredConfiguration> pLC = new LayeredConfiguration;
AutoPtr<MapConfiguration> pMC1 = new MapConfiguration;
AutoPtr<MapConfiguration> pMC2 = new MapConfiguration;
pMC1->setString("prop1", "value1");
pMC1->setString("prop2", "value2");
pMC2->setString("prop2", "value3");
pMC2->setString("prop3", "value4");
pLC->add(pMC1, 0);
pLC->add(pMC2, -1);
AbstractConfiguration::Keys keys;
pLC->keys(keys);
assert (keys.size() == 3);
assert (std::find(keys.begin(), keys.end(), "prop1") != keys.end());
assert (std::find(keys.begin(), keys.end(), "prop2") != keys.end());
assert (std::find(keys.begin(), keys.end(), "prop3") != keys.end());
assert (pLC->getString("prop1") == "value1");
assert (pLC->getString("prop2") == "value3");
assert (pLC->getString("prop3") == "value4");
pLC->removeConfiguration(pMC2);
keys.clear();
pLC->keys(keys);
assert (keys.size() == 2);
assert (pLC->getString("prop1") == "value1");
assert (pLC->getString("prop2") == "value2");
}
示例3: testKeys
void SystemConfigurationTest::testKeys()
{
AutoPtr<SystemConfiguration> pConf = new SystemConfiguration;
AbstractConfiguration::Keys keys;
pConf->keys(keys);
assert (keys.size() == 1);
assert (std::find(keys.begin(), keys.end(), "system") != keys.end());
pConf->keys("system", keys);
#if defined(POCO_VXWORKS)
assert (keys.size() == 10);
#else
assert (keys.size() == 11);
#endif
assert (std::find(keys.begin(), keys.end(), "osName") != keys.end());
assert (std::find(keys.begin(), keys.end(), "osVersion") != keys.end());
assert (std::find(keys.begin(), keys.end(), "osArchitecture") != keys.end());
assert (std::find(keys.begin(), keys.end(), "nodeName") != keys.end());
assert (std::find(keys.begin(), keys.end(), "nodeId") != keys.end());
assert (std::find(keys.begin(), keys.end(), "currentDir") != keys.end());
assert (std::find(keys.begin(), keys.end(), "homeDir") != keys.end());
assert (std::find(keys.begin(), keys.end(), "tempDir") != keys.end());
assert (std::find(keys.begin(), keys.end(), "dateTime") != keys.end());
#if !defined(POCO_VXWORKS)
assert (std::find(keys.begin(), keys.end(), "pid") != keys.end());
#endif
assert (std::find(keys.begin(), keys.end(), "env") != keys.end());
}
示例4: createConfiguration
void ConfigurationMapperTest::testMapper2()
{
AutoPtr<AbstractConfiguration> pConf = createConfiguration();
AutoPtr<AbstractConfiguration> pMapper = new ConfigurationMapper("prop5", "root.conf", pConf);
assert (pMapper->hasProperty("root.conf.string1"));
assert (pMapper->hasProperty("root.conf.string2"));
AbstractConfiguration::Keys keys;
pMapper->keys(keys);
assert (keys.size() == 1);
assert (std::find(keys.begin(), keys.end(), "root") != keys.end());
pMapper->keys("root", keys);
assert (keys.size() == 1);
assert (std::find(keys.begin(), keys.end(), "conf") != keys.end());
pMapper->keys("root.conf", keys);
assert (keys.size() == 4);
assert (std::find(keys.begin(), keys.end(), "string1") != keys.end());
assert (std::find(keys.begin(), keys.end(), "string2") != keys.end());
assert (std::find(keys.begin(), keys.end(), "sub1") != keys.end());
assert (std::find(keys.begin(), keys.end(), "sub2") != keys.end());
assert (pMapper->getString("root.conf.string1") == "foo");
assert (pMapper->getString("root.conf.sub1.string1") == "FOO");
pMapper->setString("root.conf.string3", "baz");
assert (pMapper->getString("root.conf.string3") == "baz");
assert (pConf->getString("prop5.string3") == "baz");
pMapper->remove("root.conf.string3");
assert (!pMapper->hasProperty("root.conf.string3"));
assert (!pConf->hasProperty("prop5.string3"));
}
示例5: testLoad
void IniFileConfigurationTest::testLoad()
{
static const std::string iniFile =
"; comment\n"
" ; comment \n"
"prop1=value1\n"
" prop2 = value2 \n"
"[section1]\n"
"prop1 = value3\r\n"
"\tprop2=value4\r\n"
";prop3=value7\r\n"
"\n"
" [ section 2 ]\n"
"prop1 = value 5\n"
"\t \n"
"Prop2 = value6";
std::istringstream istr(iniFile);
AutoPtr<IniFileConfiguration> pConf = new IniFileConfiguration(istr);
assert (pConf->getString("prop1") == "value1");
assert (pConf->getString("prop2") == "value2");
assert (pConf->getString("section1.prop1") == "value3");
assert (pConf->getString("Section1.Prop2") == "value4");
assert (pConf->getString("section 2.prop1") == "value 5");
assert (pConf->getString("section 2.prop2") == "value6");
assert (pConf->getString("SECTION 2.PROP2") == "value6");
AbstractConfiguration::Keys keys;
pConf->keys(keys);
assert (keys.size() == 4);
assert (std::find(keys.begin(), keys.end(), "prop1") != keys.end());
assert (std::find(keys.begin(), keys.end(), "prop2") != keys.end());
assert (std::find(keys.begin(), keys.end(), "section1") != keys.end());
assert (std::find(keys.begin(), keys.end(), "section 2") != keys.end());
pConf->keys("Section1", keys);
assert (keys.size() == 2);
assert (std::find(keys.begin(), keys.end(), "prop1") != keys.end());
assert (std::find(keys.begin(), keys.end(), "prop2") != keys.end());
try
{
pConf->setString("foo", "bar");
fail("Not supported - must throw");
}
catch (NotImplementedException&)
{
}
try
{
std::string s = pConf->getString("foo");
fail("No property - must throw");
}
catch (NotFoundException&)
{
}
}
示例6: testLoad
void IniFileConfigurationTest::testLoad()
{
static const std::string iniFile =
"; comment\n"
" ; comment \n"
"prop1=value1\n"
" prop2 = value2 \n"
"[section1]\n"
"prop1 = value3\r\n"
"\tprop2=value4\r\n"
";prop3=value7\r\n"
"\n"
" [ section 2 ]\n"
"prop1 = value 5\n"
"\t \n"
"Prop2 = value6";
std::istringstream istr(iniFile);
AutoPtr<IniFileConfiguration> pConf = new IniFileConfiguration(istr);
assert (pConf->getString("prop1") == "value1");
assert (pConf->getString("prop2") == "value2");
assert (pConf->getString("section1.prop1") == "value3");
assert (pConf->getString("Section1.Prop2") == "value4");
assert (pConf->getString("section 2.prop1") == "value 5");
assert (pConf->getString("section 2.prop2") == "value6");
assert (pConf->getString("SECTION 2.PROP2") == "value6");
AbstractConfiguration::Keys keys;
pConf->keys(keys);
assert (keys.size() == 4);
assert (std::find(keys.begin(), keys.end(), "prop1") != keys.end());
assert (std::find(keys.begin(), keys.end(), "prop2") != keys.end());
assert (std::find(keys.begin(), keys.end(), "section1") != keys.end());
assert (std::find(keys.begin(), keys.end(), "section 2") != keys.end());
pConf->keys("Section1", keys);
assert (keys.size() == 2);
assert (std::find(keys.begin(), keys.end(), "prop1") != keys.end());
assert (std::find(keys.begin(), keys.end(), "prop2") != keys.end());
pConf->setString("prop1", "value11");
assert (pConf->getString("PROP1") == "value11");
pConf->setString("Prop1", "value12");
assert (pConf->getString("prop1") == "value12");
pConf->keys(keys);
assert (keys.size() == 4);
assert (std::find(keys.begin(), keys.end(), "prop1") != keys.end());
assert (std::find(keys.begin(), keys.end(), "prop2") != keys.end());
assert (std::find(keys.begin(), keys.end(), "section1") != keys.end());
assert (std::find(keys.begin(), keys.end(), "section 2") != keys.end());
assert (std::find(keys.begin(), keys.end(), "Prop1") == keys.end());
}
示例7: testLoad
void PropertyFileConfigurationTest::testLoad()
{
static const std::string propFile =
"! comment\n"
"! comment\n"
"prop1=value1\n"
"prop2 = value2 \n"
"prop3.prop31: value3\n"
"# comment\n"
" prop3.prop32: value 4\n"
"prop3.prop33: value5, value6, \\\n"
"value7, value8, \\\r\n"
"value9\n"
"prop4 = escaped[\\t\\r\\n\\f]\n"
"#prop4 = foo\n"
"prop5:foo";
std::istringstream istr(propFile);
AutoPtr<PropertyFileConfiguration> pConf = new PropertyFileConfiguration(istr);
assert (pConf->getString("prop1") == "value1");
assert (pConf->getString("prop2") == "value2");
assert (pConf->getString("prop3.prop31") == "value3");
assert (pConf->getString("prop3.prop32") == "value 4");
assert (pConf->getString("prop3.prop33") == "value5, value6, value7, value8, value9");
assert (pConf->getString("prop4") == "escaped[\t\r\n\f]");
assert (pConf->getString("prop5") == "foo");
AbstractConfiguration::Keys keys;
pConf->keys(keys);
assert (keys.size() == 5);
assert (std::find(keys.begin(), keys.end(), "prop1") != keys.end());
assert (std::find(keys.begin(), keys.end(), "prop2") != keys.end());
assert (std::find(keys.begin(), keys.end(), "prop3") != keys.end());
assert (std::find(keys.begin(), keys.end(), "prop4") != keys.end());
assert (std::find(keys.begin(), keys.end(), "prop5") != keys.end());
pConf->keys("prop3", keys);
assert (keys.size() == 3);
assert (std::find(keys.begin(), keys.end(), "prop31") != keys.end());
assert (std::find(keys.begin(), keys.end(), "prop32") != keys.end());
assert (std::find(keys.begin(), keys.end(), "prop33") != keys.end());
try
{
std::string s = pConf->getString("foo");
fail("No property - must throw");
}
catch (NotFoundException&)
{
}
}
示例8: testLoad
void XMLConfigurationTest::testLoad()
{
static const std::string xmlFile =
"<config>"
" <prop1>value1</prop1>"
" <prop2>value2</prop2>"
" <prop3>"
" <prop4 attr='value3'/>"
" <prop4 attr='value4'/>"
" </prop3>"
" <prop5>value5</prop5>"
" <prop5>value6</prop5>"
"</config>";
std::istringstream istr(xmlFile);
AutoPtr<XMLConfiguration> pConf = new XMLConfiguration(istr);
assert (pConf->getString("prop1") == "value1");
assert (pConf->getString("prop2") == "value2");
assert (pConf->getString("prop3.prop4[@attr]") == "value3");
assert (pConf->getString("prop3.prop4[1][@attr]") == "value4");
assert (pConf->getString("prop5") == "value5");
assert (pConf->getString("prop5[0]") == "value5");
assert (pConf->getString("prop5[1]") == "value6");
AbstractConfiguration::Keys keys;
pConf->keys(keys);
assert (keys.size() == 5);
assert (std::find(keys.begin(), keys.end(), "prop1") != keys.end());
assert (std::find(keys.begin(), keys.end(), "prop2") != keys.end());
assert (std::find(keys.begin(), keys.end(), "prop3") != keys.end());
assert (std::find(keys.begin(), keys.end(), "prop5") != keys.end());
assert (std::find(keys.begin(), keys.end(), "prop5[1]") != keys.end());
pConf->keys("prop3", keys);
assert (keys.size() == 2);
assert (std::find(keys.begin(), keys.end(), "prop4") != keys.end());
assert (std::find(keys.begin(), keys.end(), "prop4[1]") != keys.end());
try
{
std::string s = pConf->getString("foo");
fail("No property - must throw");
}
catch (NotFoundException&)
{
}
}
示例9: testTwoLayers
void LayeredConfigurationTest::testTwoLayers()
{
AutoPtr<LayeredConfiguration> pLC = new LayeredConfiguration;
AutoPtr<MapConfiguration> pMC1 = new MapConfiguration;
AutoPtr<MapConfiguration> pMC2 = new MapConfiguration;
pMC1->setString("prop1", "value1");
pMC1->setString("prop2", "value2");
pMC2->setString("prop2", "value3");
pMC2->setString("prop3", "value4");
pLC->add(pMC1, 0);
pLC->addWriteable(pMC2, 1);
AbstractConfiguration::Keys keys;
pLC->keys(keys);
assert (keys.size() == 3);
assert (std::find(keys.begin(), keys.end(), "prop1") != keys.end());
assert (std::find(keys.begin(), keys.end(), "prop2") != keys.end());
assert (std::find(keys.begin(), keys.end(), "prop3") != keys.end());
assert (pLC->getString("prop1") == "value1");
assert (pLC->getString("prop2") == "value2");
assert (pLC->getString("prop3") == "value4");
pLC->setString("prop4", "value4");
assert (pLC->getString("prop4") == "value4");
assert (!pMC1->hasProperty("prop4"));
assert (pMC2->hasProperty("prop4"));
pLC->setString("prop1", "value11");
assert (pLC->getString("prop1") == "value1");
assert (pMC2->getString("prop1") == "value11");
}
示例10: testOneLayer
void LayeredConfigurationTest::testOneLayer()
{
AutoPtr<LayeredConfiguration> pLC = new LayeredConfiguration;
AutoPtr<MapConfiguration> pMC = new MapConfiguration;
pMC->setString("prop1", "value1");
pMC->setString("prop2", "value2");
pLC->addWriteable(pMC, 0);
AbstractConfiguration::Keys keys;
pLC->keys(keys);
assert (keys.size() == 2);
assert (std::find(keys.begin(), keys.end(), "prop1") != keys.end());
assert (std::find(keys.begin(), keys.end(), "prop2") != keys.end());
assert (pLC->getString("prop1") == "value1");
assert (pLC->getString("prop2") == "value2");
pLC->setString("prop3", "value3");
assert (pLC->getString("prop3") == "value3");
pLC->remove("prop3");
assert (!pLC->hasProperty("prop3"));
}
示例11: testFilesystemConfiguration
void FilesystemConfigurationTest::testFilesystemConfiguration()
{
AutoPtr<FilesystemConfiguration> config = new FilesystemConfiguration("TestConfiguration");
config->setString("logging.loggers.root.channel.class", "ConsoleChannel");
config->setString("logging.loggers.app.name", "Application");
config->setString("logging.loggers.app.channel", "c1");
config->setString("logging.formatters.f1.class", "PatternFormatter");
config->setString("logging.formatters.f1.pattern", "[%p] %t");
config->setString("logging.channels.c1.class", "ConsoleChannel");
assert (config->getString("logging.loggers.root.channel.class") == "ConsoleChannel");
assert (config->getString("logging.loggers.app.name") == "Application");
assert (config->getString("logging.loggers.app.channel") == "c1");
assert (config->getString("logging.formatters.f1.class") == "PatternFormatter");
assert (config->getString("logging.formatters.f1.pattern") == "[%p] %t");
config->setString("logging.loggers.app.channel", "c2");
assert (config->getString("logging.loggers.app.channel") == "c2");
AbstractConfiguration::Keys keys;
config->keys(keys);
assert (keys.size() == 1);
assert (std::find(keys.begin(), keys.end(), "logging") != keys.end());
config->keys("logging", keys);
assert (keys.size() == 3);
assert (std::find(keys.begin(), keys.end(), "loggers") != keys.end());
assert (std::find(keys.begin(), keys.end(), "formatters") != keys.end());
assert (std::find(keys.begin(), keys.end(), "channels") != keys.end());
config->keys("logging.formatters", keys);
assert (keys.size() == 1);
assert (std::find(keys.begin(), keys.end(), "f1") != keys.end());
config->keys("logging.formatters.f1", keys);
assert (keys.size() == 2);
assert (std::find(keys.begin(), keys.end(), "class") != keys.end());
assert (std::find(keys.begin(), keys.end(), "pattern") != keys.end());
assert (config->hasProperty("logging.loggers.root.channel.class"));
config->clear();
assert (!config->hasProperty("logging.loggers.root.channel.class"));
}
示例12: testCaseInsensitiveRemove
void IniFileConfigurationTest::testCaseInsensitiveRemove()
{
AutoPtr<AbstractConfiguration> pConf = createConfiguration();
AbstractConfiguration::Keys keys;
assert (pConf->hasProperty("Prop1"));
assert (pConf->hasProperty("prop4.BOOL1"));
assert (pConf->hasProperty("Prop4.bool2"));
assert (pConf->hasProperty("PROP4.Bool3"));
pConf->keys(keys);
assert (keys.size() == 13);
pConf->keys("prop4", keys);
assert (keys.size() == 17);
pConf->remove("PROP4.Bool1");
assert (pConf->hasProperty("Prop1"));
assert (!pConf->hasProperty("prop4.BOOL1"));
assert (pConf->hasProperty("Prop4.bool2"));
assert (pConf->hasProperty("PROP4.Bool3"));
pConf->keys(keys);
assert (keys.size() == 13);
pConf->keys("PROP4", keys);
assert (keys.size() == 16);
pConf->remove("Prop4");
assert (pConf->hasProperty("Prop1"));
assert (!pConf->hasProperty("prop4.BOOL1"));
assert (!pConf->hasProperty("Prop4.bool2"));
assert (!pConf->hasProperty("PROP4.Bool3"));
pConf->keys(keys);
assert (keys.size() == 12);
pConf->keys("prop4", keys);
assert (keys.size() == 0);
}
示例13: testView
void ConfigurationViewTest::testView()
{
AutoPtr<AbstractConfiguration> pConf = createConfiguration();
AutoPtr<AbstractConfiguration> pView = pConf->createView("");
assert (pView->hasProperty("prop1"));
assert (pView->hasProperty("prop2"));
AbstractConfiguration::Keys keys;
pView->keys(keys);
assert (keys.size() == 4);
assert (std::find(keys.begin(), keys.end(), "prop1") != keys.end());
assert (std::find(keys.begin(), keys.end(), "prop2") != keys.end());
assert (std::find(keys.begin(), keys.end(), "prop3") != keys.end());
assert (std::find(keys.begin(), keys.end(), "prop4") != keys.end());
assert (pView->getString("prop1") == "foo");
assert (pView->getString("prop3.string1") == "foo");
pView->setString("prop5", "foobar");
assert (pConf->getString("prop5") == "foobar");
pView = pConf->createView("prop1");
pView->keys(keys);
assert (keys.empty());
assert (pView->hasProperty("prop1"));
pView->setString("prop11", "foobar");
assert (pConf->getString("prop1.prop11") == "foobar");
pView = pConf->createView("prop3");
pView->keys(keys);
assert (keys.size() == 2);
assert (std::find(keys.begin(), keys.end(), "string1") != keys.end());
assert (std::find(keys.begin(), keys.end(), "string2") != keys.end());
assert (pView->getString("string1") == "foo");
assert (pView->getString("string2") == "bar");
pView->setString("string3", "foobar");
assert (pConf->getString("prop3.string3") == "foobar");
pView = pConf->createView("prop4");
pView->keys(keys);
assert (keys.size() == 2);
assert (std::find(keys.begin(), keys.end(), "prop41") != keys.end());
assert (std::find(keys.begin(), keys.end(), "prop42") != keys.end());
assert (pView->getString("prop41.string1") == "FOO");
assert (pView->getString("prop42.string2") == "Bar");
pView = pConf->createView("prop4.prop41");
pView->keys(keys);
assert (keys.size() == 2);
assert (std::find(keys.begin(), keys.end(), "string1") != keys.end());
assert (std::find(keys.begin(), keys.end(), "string2") != keys.end());
assert (pView->getString("string1") == "FOO");
assert (pView->getString("string2") == "BAR");
pView->setString("string3", "foobar");
assert (pConf->getString("prop4.prop41.string3") == "foobar");
}
示例14: LoadConfig
void XplDevice::LoadConfig()
{
poco_trace ( devLog, "loading config for " + GetCompleteId() );
Poco::Path p = GetConfigFileLocation();
PropertyFileConfiguration* cfgp;
try{
cfgp = new PropertyFileConfiguration(p.toString());
} catch (Poco::FileException e) {
poco_debug ( devLog, "Failed to parse " + p.toString() );
cfgp = (new PropertyFileConfiguration());
}
m_configStore = cfgp;
m_bConfigRequired = true;
AbstractConfiguration::Keys itemKeys;
m_configStore->keys(itemKeys);
for ( AbstractConfiguration::Keys::iterator iter = itemKeys.begin(); iter != itemKeys.end(); ++iter )
{
poco_debug ( devLog, " item: " + *iter );
}
if ( m_configStore->hasProperty ( "instanceId" ) )
{
//looks like we really have a config
poco_debug ( devLog, "found instance ID" );
m_bConfigRequired = false;
SetInstanceId ( m_configStore->getString ( "instanceId" ) );
if ( m_configStore->hasProperty ( "configItems" )) {
AbstractConfiguration::Keys confItemKeys;
m_configStore->keys("configItems", confItemKeys);
poco_debug ( devLog, "found " + NumberFormatter::format(confItemKeys.size()) + "keys" );
for ( AbstractConfiguration::Keys::iterator iter = confItemKeys.begin(); iter != confItemKeys.end(); ++iter )
{
if(m_configStore->hasProperty ( "configItems."+(*iter)+".numValues" )){
// we have a config item entry with the required parts, but should only restore it if it matches a programatically-added configitem.
AutoPtr<XplConfigItem> cfgItem = GetConfigItem(*iter);
if (cfgItem.get()== NULL){
poco_warning ( devLog, "Found a config item for name " + *iter + ", but no programatically-created config item exists with that name" );
continue;
}
poco_trace ( devLog, "Config item: " + *iter );
int numValues = m_configStore->getInt ( "configItems."+(*iter)+".numValues");
for (int i= 0; i<numValues; i++) {
poco_trace( devLog, "Value " );
string valname = "configItems."+(*iter)+".value" + NumberFormatter::format(i);
if(m_configStore->hasProperty (valname) ){
cfgItem->AddValue(m_configStore->getString ( valname ));
}
}
}
}
}
}
// // If the config data was read ok, then configure this device.
if( !m_bConfigRequired )
{
// Configure the XplDevice
Configure();
m_bConfigRequired = false;
// Set the config event
//SetEvent( m_hConfig );
// m_hConfig.notifyAsync(NULL, m_hConfig);
}
}