本文整理汇总了C++中abstractconfiguration::Keys::begin方法的典型用法代码示例。如果您正苦于以下问题:C++ Keys::begin方法的具体用法?C++ Keys::begin怎么用?C++ Keys::begin使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类abstractconfiguration::Keys
的用法示例。
在下文中一共展示了Keys::begin方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: 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"));
}
示例3: 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");
}
示例4: 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");
}
示例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 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&)
{
}
}
示例7: 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());
}
示例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: writeObject
void AMFWriter::writeObject(const AMFObject& amfObject) {
beginObject();
AbstractConfiguration::Keys keys;
amfObject.keys(keys);
AbstractConfiguration::Keys::const_iterator it;
for(it=keys.begin();it!=keys.end();++it) {
string name = *it;
_writer.writeString16(name);
int type = amfObject.getInt(name+".type",-1);
switch(type) {
case AMF_BOOLEAN:
writeBool(amfObject.getBool(name));
break;
case AMF_STRING:
write(amfObject.getString(name));
break;
case AMF_NUMBER:
writeNumber(amfObject.getDouble(name));
break;
case AMF_UNDEFINED:
write("");
break;
case AMF_NULL:
writeNull();
break;
default:
ERROR("Unknown AMF '%d' type",type);
}
}
endObject();
}
示例10: prepareApplicationLoggingFiles
//============================================================================//
void Configuration::prepareApplicationLoggingFiles(AbstractConfiguration &config, const string &prefix)
{
// find all files loggers
AbstractConfiguration::Keys channelsKeys;
AbstractConfiguration::Keys::iterator keyIt;
config.keys("logging.channels", channelsKeys);
config.setString("application.logger", prefix);
for(keyIt = channelsKeys.begin(); keyIt != channelsKeys.end(); ++keyIt) {
if(!config.getString("logging.channels." + *keyIt + ".class", "").
compare("FileChannel")) {
config.setString("logging.channels." + *keyIt + ".path",
Path(config.getString("logging.channels." + *keyIt + ".path", "") +
Path::separator()).makeAbsolute().
setFileName(
"UpSys" + prefix +
config.getString("args.software_identifier")
+ ".log").toString());
}
}
}
示例11: printProperties
void printProperties(const std::string& base)
{
AbstractConfiguration::Keys keys;
config().keys(base, keys);
if (keys.empty())
{
if (config().hasProperty(base))
{
std::string msg;
msg.append(base);
msg.append(" = ");
msg.append(config().getString(base));
logger().information(msg);
}
}
else
{
for (AbstractConfiguration::Keys::const_iterator it = keys.begin(); it != keys.end(); ++it)
{
std::string fullKey = base;
if (!fullKey.empty()) fullKey += '.';
fullKey.append(*it);
printProperties(fullKey);
}
}
}
示例12: writeSimpleObject
void AMFWriter::writeSimpleObject(const AMFSimpleObject& object) {
beginObject();
AbstractConfiguration::Keys keys;
object.keys(keys);
AbstractConfiguration::Keys::const_iterator it;
for(it=keys.begin();it!=keys.end();++it) {
string name = *it;
int type = object.getInt(name+".type",-1);
switch(type) {
case AMF::Boolean:
writeObjectProperty(name,object.getBool(name));
break;
case AMF::String:
writeObjectProperty(name,object.getString(name));
break;
case AMF::Number:
writeObjectProperty(name,object.getDouble(name));
break;
case AMF::Integer:
writeObjectProperty(name,object.getInt(name));
break;
case AMF::Date: {
Timestamp date((Timestamp::TimeVal)object.getDouble(name)*1000);
writeObjectProperty(name,date);
break;
}
case AMF::Null:
writeObjectProperty(name);
break;
default:
ERROR("Unknown AMFObject %d type",type);
}
}
endObject();
}
示例13: 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"));
}
示例14: createChannel
Channel* LoggingConfigurator::createChannel(AbstractConfiguration* pConfig)
{
AutoPtr<Channel> pChannel(LoggingFactory::defaultFactory().createChannel(pConfig->getString("class")));
AutoPtr<Channel> pWrapper(pChannel);
AbstractConfiguration::Keys props;
pConfig->keys(props);
for (AbstractConfiguration::Keys::const_iterator it = props.begin(); it != props.end(); ++it)
{
if (*it == "pattern")
{
AutoPtr<Formatter> pPatternFormatter(new PatternFormatter(pConfig->getString(*it)));
pWrapper = new FormattingChannel(pPatternFormatter, pChannel);
}
else if (*it == "formatter")
{
AutoPtr<FormattingChannel> pFormattingChannel(new FormattingChannel(0, pChannel));
if (pConfig->hasProperty("formatter.class"))
{
AutoPtr<AbstractConfiguration> pFormatterConfig(pConfig->createView(*it));
AutoPtr<Formatter> pFormatter(createFormatter(pFormatterConfig));
pFormattingChannel->setFormatter(pFormatter);
}
else pFormattingChannel->setProperty(*it, pConfig->getString(*it));
#if defined(__GNUC__) && __GNUC__ < 3
pWrapper = pFormattingChannel.duplicate();
#else
pWrapper = pFormattingChannel;
#endif
}
}
return pWrapper.duplicate();
}
示例15: configureChannels
void LoggingConfigurator::configureChannels(AbstractConfiguration* pConfig)
{
AbstractConfiguration::Keys channels;
pConfig->keys(channels);
for (AbstractConfiguration::Keys::const_iterator it = channels.begin(); it != channels.end(); ++it)
{
AutoPtr<AbstractConfiguration> pChannelConfig(pConfig->createView(*it));
AutoPtr<Channel> pChannel = createChannel(pChannelConfig);
LoggingRegistry::defaultRegistry().registerChannel(*it, pChannel);
}
for (AbstractConfiguration::Keys::const_iterator it = channels.begin(); it != channels.end(); ++it)
{
AutoPtr<AbstractConfiguration> pChannelConfig(pConfig->createView(*it));
Channel* pChannel = LoggingRegistry::defaultRegistry().channelForName(*it);
configureChannel(pChannel, pChannelConfig);
}
}