本文整理汇总了C++中abstractconfiguration::Keys类的典型用法代码示例。如果您正苦于以下问题:C++ Keys类的具体用法?C++ Keys怎么用?C++ Keys使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Keys类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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);
}
}
}
示例2: 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"));
}
示例3: testEmpty
void LayeredConfigurationTest::testEmpty()
{
AutoPtr<LayeredConfiguration> pLC = new LayeredConfiguration;
AbstractConfiguration::Keys keys;
pLC->keys(keys);
assert (keys.empty());
assert (!pLC->hasProperty("foo"));
try
{
pLC->setString("foo", "bar");
fail("empty LayeredConfiguration - must throw");
}
catch (RuntimeException&)
{
}
try
{
std::string s = pLC->getString("foo");
fail("empty LayeredConfiguration - must throw");
}
catch (NotFoundException&)
{
}
}
示例4: 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();
}
示例5: 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");
}
示例6: 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());
}
}
}
示例7: 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();
}
示例8: 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();
}
示例9: configureFormatters
void LoggingConfigurator::configureFormatters(AbstractConfiguration* pConfig)
{
AbstractConfiguration::Keys formatters;
pConfig->keys(formatters);
for (AbstractConfiguration::Keys::const_iterator it = formatters.begin(); it != formatters.end(); ++it)
{
AutoPtr<AbstractConfiguration> pFormatterConfig(pConfig->createView(*it));
AutoPtr<Formatter> pFormatter(createFormatter(pFormatterConfig));
LoggingRegistry::defaultRegistry().registerFormatter(*it, pFormatter);
}
}
示例10: configureChannel
void LoggingConfigurator::configureChannel(Channel* pChannel, AbstractConfiguration* pConfig)
{
AbstractConfiguration::Keys props;
pConfig->keys(props);
for (AbstractConfiguration::Keys::const_iterator it = props.begin(); it != props.end(); ++it)
{
if (*it != "pattern" && *it != "formatter" && *it != "class")
{
pChannel->setProperty(*it, pConfig->getString(*it));
}
}
}
示例11: createFormatter
Formatter* LoggingConfigurator::createFormatter(AbstractConfiguration* pConfig)
{
AutoPtr<Formatter> pFormatter(LoggingFactory::defaultFactory().createFormatter(pConfig->getString("class")));
AbstractConfiguration::Keys props;
pConfig->keys(props);
for (AbstractConfiguration::Keys::const_iterator it = props.begin(); it != props.end(); ++it)
{
if (*it != "class")
pFormatter->setProperty(*it, pConfig->getString(*it));
}
return pFormatter.duplicate();
}
示例12: 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");
}
示例13: createConfiguration
void ConfigurationMapperTest::testMapper4()
{
AutoPtr<AbstractConfiguration> pConf = createConfiguration();
AutoPtr<AbstractConfiguration> pMapper = new ConfigurationMapper("prop5", "", pConf);
assert (pMapper->hasProperty("string1"));
assert (pMapper->hasProperty("string2"));
AbstractConfiguration::Keys keys;
pMapper->keys(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("string1") == "foo");
assert (pMapper->getString("sub1.string1") == "FOO");
pMapper->setString("string3", "baz");
assert (pMapper->getString("string3") == "baz");
assert (pConf->getString("prop5.string3") == "baz");
pMapper->remove("string3");
assert (!pMapper->hasProperty("string3"));
assert (!pConf->hasProperty("prop5.string3"));
}
示例14: copyProperties
void Client::copyProperties(const AbstractConfiguration& abstractConfigs,const string& root) {
AbstractConfiguration::Keys keys;
abstractConfigs.keys(root,keys);
AbstractConfiguration::Keys::const_iterator it;
for(it=keys.begin();it!=keys.end();++it) {
string key(root);
if(!key.empty())
key+=".";
key += (*it);
if(abstractConfigs.hasOption(key))
setString(key,abstractConfigs.getString(key));
else
copyProperties(abstractConfigs,key);
}
}
示例15: prepareApplicationLoggingDisableConsole
//============================================================================//
void Configuration::prepareApplicationLoggingDisableConsole(AbstractConfiguration &config)
{
// find all files loggers
AbstractConfiguration::Keys channelsKeys;
AbstractConfiguration::Keys::iterator keyIt;
config.keys("logging.channels", channelsKeys);
for(keyIt = channelsKeys.begin(); keyIt != channelsKeys.end(); ++keyIt) {
if(!config.getString("logging.channels." + *keyIt + ".class", "").
compare("ConsoleChannel")) {
config.setString("logging.channels." + *keyIt + ".class",
"NullChannel");
}
}
}