本文整理汇总了C++中ConfigSection类的典型用法代码示例。如果您正苦于以下问题:C++ ConfigSection类的具体用法?C++ ConfigSection怎么用?C++ ConfigSection使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ConfigSection类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ApplyConfigSection
void ApplyConfigSection(const ConfigSection &config)
{
config.Get("radial_rank", RadialRank);
config.Get("angular_rank", AngularRank);
//charge with sign
config.Get("charge", Charge);
}
示例2: ApplyConfigSection
/*
* Called once with the corresponding config section
* from the configuration file. Do all one time set up routines
* here.
*/
void ApplyConfigSection(const ConfigSection &config)
{
config.Get("zero_before", ZeroBefore);
config.Get("zero_after", ZeroAfter);
config.Get("step_rank", StepRank);
}
示例3: find_section
bool Config::get_allocated(const char* section, const char* key, char** ret, unsigned int& retsize) {
retsize = 0;
ConfigSection* cs = find_section(section);
if (!cs) {
errcode = CONF_ERR_SECTION;
return false;
}
ConfigEntry* ce = cs->find_entry(key);
if (!ce) {
errcode = CONF_ERR_KEY;
return false;
}
char* value = ce->value;
retsize = ce->valuelen;
*ret = new char[retsize + 1];
strncpy(*ret, value, retsize);
// terminate, since ce->valuelen does not contain terminating char
char* p = *ret;
p[retsize] = '\0';
return true;
}
示例4: if
shared_ptr<ndn::Transport>
Nrd::getLocalNfdTransport()
{
ConfigSection config;
if (!m_configFile.empty()) {
// Any format errors should have been caught already
// If error is thrown at this point, it is development error
boost::property_tree::read_info(m_configFile, config);
}
else
config = m_configSection;
if (config.get_child_optional("face_system.unix")) {
// unix socket enabled
auto&& socketPath = config.get<std::string>("face_system.unix.path", "/var/run/nfd.sock");
// default socketPath should be the same as in FaceManager::processSectionUnix
return make_shared<ndn::UnixTransport>(socketPath);
}
else if (config.get_child_optional("face_system.tcp") &&
config.get<std::string>("face_system.tcp.listen", "yes") == "yes") {
// tcp is enabled
auto&& port = config.get<std::string>("face_system.tcp.port", "6363");
// default port should be the same as in FaceManager::processSectionTcp
return make_shared<ndn::TcpTransport>("localhost", port);
}
else {
throw Error("No transport is available to communicate with NFD");
}
}
示例5: ApplyConfigSection
void ApplyConfigSection(const ConfigSection &config)
{
config.Get("radial_rank_1", RadialRank1);
config.Get("radial_rank_2", RadialRank2);
config.Get("inner_box_size", InnerBoxSize);
config.Get("width", Width);
}
示例6: ApplyConfigSection
virtual void ApplyConfigSection(const ConfigSection &config)
{
CustomPotentialSphericalBase<Rank>::ApplyConfigSection
(config);
config.Get("inter_nuclear_r", R);
config.Get("theta_inter_nucl", ThetaR);
}
示例7: onConfig
static void
onConfig(const ConfigSection& configSection,
bool isDryRun,
const std::string& filename)
{
// general
// {
// ; user "ndn-user"
// ; group "ndn-user"
// }
std::string user;
std::string group;
for (ConfigSection::const_iterator i = configSection.begin();
i != configSection.end();
++i)
{
if (i->first == "user")
{
try
{
user = i->second.get_value<std::string>("user");
if (user.empty())
{
throw ConfigFile::Error("Invalid value for \"user\""
" in \"general\" section");
}
}
catch (const boost::property_tree::ptree_error& error)
{
throw ConfigFile::Error("Invalid value for \"user\""
" in \"general\" section");
}
}
else if (i->first == "group")
{
try
{
group = i->second.get_value<std::string>("group");
if (group.empty())
{
throw ConfigFile::Error("Invalid value for \"group\""
" in \"general\" section");
}
}
catch (const boost::property_tree::ptree_error& error)
{
throw ConfigFile::Error("Invalid value for \"group\""
" in \"general\" section");
}
}
}
NFD_LOG_TRACE("using user \"" << user << "\" group \"" << group << "\"");
PrivilegeHelper::initialize(user, group);
}
示例8: ApplyConfigSection
/*
* Called once with the corresponding config section
* from the configuration file. Do all one time set up routines
* here.
*/
void ApplyConfigSection(const ConfigSection &config)
{
config.Get("field_strength", FieldStrength);
config.Get("frequency", Frequency);
config.Get("duration", Duration);
config.Get("peak_time", PeakTime);
config.Get("phase", Phase);
}
示例9:
void CombinedRepresentation<Rank>::ApplyConfigSection(const ConfigSection &config)
{
//Do this manually for each sub-representation
if (config.HasValue("innerproduct_algorithm"))
{
config.Get("innerproduct_algorithm", Algorithm);
}
}
示例10: add_section
void Config::set(const char* section, const char* key, double value) {
ConfigSection* sc = add_section(section);
char* locale = nls_locale_to_c();
char tmp[32];
snprintf(tmp, sizeof(tmp)-1, "%g", value);
nls_locale_from_c(locale);
sc->add_entry(key, tmp);
}
示例11: ApplyConfigSection
void ApplyConfigSection(const ConfigSection &config)
{
config.Get("charge", Charge);
config.Get("laser_frequency", LaserFrequency);
config.Get("laser_intensity", LaserIntensity);
double laserTurnOnCycles = 0;
config.Get("laser_turn_on_cycles", laserTurnOnCycles);
LaserTurnOnTime = laserTurnOnCycles * 2 * M_PI / LaserFrequency;
}
示例12: begin_config
void begin_config(const std::string& block, int *pln, int *pcode, int *cp) throw(ParserError) {
string block_name(block);
ConfigSection* section = g_Config.getSection(block_name);
if (section == NULL) {
g_throw_parser_error("unrecognized config section '", block_name.c_str(), "'");
}
// Don't do config blocks in safe mode (except in RC file)
GLEInterface* iface = GLEGetInterfacePointer();
if (iface->getCmdLine()->hasOption(GLE_OPT_SAFEMODE)) {
GLEGlobalConfig* config = iface->getConfig();
if (!config->allowConfigBlocks()) {
g_throw_parser_error("safe mode - config blocks not allowed");
}
}
// Start with pcode from the next line
(*pln)++;
begin_init();
while (true) {
int st = begin_token(&pcode,cp,pln,srclin,tk,&ntk,outbuff);
if (!st) {
/* exit loop */
break;
}
int ct = 1;
int mode = 0;
bool plus_is = false;
CmdLineOption* option = NULL;
while (ct <= ntk) {
skipspace;
if (section != NULL) {
if (mode == 0) {
option = section->getOption(tk[ct]);
if (option == NULL) {
gprint("Not a valid setting for section '%s': {%s}\n", block_name.c_str(), tk[ct]);
}
} else if (mode == 1) {
if (strcmp(tk[ct], "=") == 0) {
plus_is = false;
} else if (strcmp(tk[ct], "+=") == 0) {
plus_is = true;
} else {
gprint("Expected '=' or '+=', not {%s}\n", tk[ct]);
}
} else if (option != NULL) {
CmdLineOptionArg* arg = option->getArg(0);
if (!plus_is) arg->reset();
arg->appendValue(tk[ct]);
}
mode++;
}
ct++;
}
}
}
示例13: init_installed_versions
void init_installed_versions(CmdLineObj& cmdline, ConfigCollection* collection) {
CmdLineArgSet* versions = (CmdLineArgSet*)cmdline.getOption(GLE_OPT_VERSION)->getArg(0);
ConfigSection* gle = collection->getSection(GLE_CONFIG_GLE);
CmdLineArgSPairList* installs = (CmdLineArgSPairList*)gle->getOption(GLE_CONFIG_GLE_INSTALL)->getArg(0);
if (installs->size() == 0) {
versions->addPossibleValue("no older GLE versions found (run \"gle -finddeps\")");
} else {
for (int i = 0; i < installs->size(); i++) {
versions->addPossibleValue(installs->getValue1(i).c_str());
}
}
}
示例14: if
void
LoggerFactory::onConfig(const ConfigSection& section,
bool isDryRun,
const std::string& filename)
{
// log
// {
// ; default_level specifies the logging level for modules
// ; that are not explicitly named. All debugging levels
// ; listed above the selected value are enabled.
//
// default_level INFO
//
// ; You may also override the default for specific modules:
//
// FibManager DEBUG
// Forwarder WARN
// }
if (!isDryRun) {
ConfigSection::const_assoc_iterator item = section.find("default_level");
if (item != section.not_found()) {
LogLevel level = extractLevel(item->second, "default_level");
setDefaultLevel(level);
}
else {
setDefaultLevel(LOG_INFO);
}
}
for (const auto& i : section) {
LogLevel level = extractLevel(i.second, i.first);
if (i.first == "default_level") {
// do nothing
}
else {
std::unique_lock<std::mutex> lock(m_loggersGuard);
LoggerMap::iterator loggerIt = m_loggers.find(i.first);
if (loggerIt == m_loggers.end()) {
lock.unlock();
NFD_LOG_DEBUG("Failed to configure logging level for module \"" <<
i.first << "\" (module not found)");
}
else if (!isDryRun) {
loggerIt->second.setLogLevel(level);
lock.unlock();
NFD_LOG_DEBUG("Changing level for module " << i.first << " to " << level);
}
}
}
}
示例15: size_t
ConfigSection* ParserHelper::getSection(size_t* initial, std::string* line, size_t* lineNumber, std::string name)
{
#ifdef DEBUG_PARSERHELPER
std::cout << "\tsection\t pos='" << *initial << "'; char='" << line->at(*initial) << "'\n";
#endif // DEBUG_PARSERHELPER
std::string l = name + line->substr(*initial);
size_t* count = new size_t(0);
ConfigSection* cs = new ConfigSection();
cs->parse(&l, count, lineNumber);
*initial += *count - name.size();
delete count;
return cs;
}