本文整理汇总了C++中boost::program_options::variables_map::at方法的典型用法代码示例。如果您正苦于以下问题:C++ variables_map::at方法的具体用法?C++ variables_map::at怎么用?C++ variables_map::at使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类boost::program_options::variables_map
的用法示例。
在下文中一共展示了variables_map::at方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: parse
void parse(std::string const & appName, boost::program_options::variables_map const & cmdLine)
{
ReflectionOptions options;
options.generatorPath = appName;
options.targetName = cmdLine.at(kSwitchTargetName).as<std::string>();
options.inputPath = cmdLine.at(kSwitchInput).as<std::string>();
options.outputPath = cmdLine.at(kSwitchOutput).as<std::string>();
options.buildDirectory = cmdLine.at(kSwitchBuildDirectory).as<std::string>();
// default arguments
options.arguments =
{ {
"-analyzer-display-progress",
"-x",
"c++",
"-D__SC_REFLECTION_PARSER__",
"-std=c++11"
} };
if (cmdLine.count(kSwitchCompilerFlags))
{
auto flagsList = cmdLine.at(kSwitchCompilerFlags).as<std::vector<std::string>>();
for (std::string & flags : flagsList)
{
while (1)
{
size_t pos = flags.find(";");
if (pos == std::string::npos)
break;
std::string f = flags.substr(0, pos);
options.arguments.emplace_back(f);
flags = flags.substr(pos + 1);
}
}
//for (auto & flag : flags)
// options.arguments.emplace_back(flag.c_str());
}
std::cout << "Generate reflection code for \"" << options.targetName << "\"" << std::endl;
ReflectionParser parser(options);
try
{
parser.Parse();
}
catch (Exception e)
{
std::cerr << "Error: " << e.GetDescription() << std::endl;
}
}
示例2: initialize
void application::initialize(const fc::path& data_dir, const boost::program_options::variables_map& options)
{
my->_data_dir = data_dir;
my->_options = &options;
if( options.count("create-genesis-json") )
{
fc::path genesis_out = options.at("create-genesis-json").as<boost::filesystem::path>();
genesis_state_type genesis_state = detail::create_example_genesis();
if( fc::exists(genesis_out) )
{
try {
genesis_state = fc::json::from_file(genesis_out).as<genesis_state_type>();
} catch(const fc::exception& e) {
std::cerr << "Unable to parse existing genesis file:\n" << e.to_string()
<< "\nWould you like to replace it? [y/N] ";
char response = std::cin.get();
if( toupper(response) != 'Y' )
return;
}
std::cerr << "Updating genesis state in file " << genesis_out.generic_string() << "\n";
} else {
std::cerr << "Creating example genesis state in file " << genesis_out.generic_string() << "\n";
}
fc::json::save_to_file(genesis_state, genesis_out);
std::exit(EXIT_SUCCESS);
}
}
示例3: plugin_initialize
void delayed_node_plugin::plugin_initialize(const boost::program_options::variables_map& options)
{
FC_ASSERT( options.count( "trusted-node" ) > 0 );
my->remote_endpoint = "ws://" + options.at("trusted-node").as<std::string>();
}
示例4: pimpl
configuration::configuration(const boost::program_options::variables_map& vars, logger::logger& log) : basic_configuration(vars, log), pimpl(std::make_unique<impl>())
{
if (vars.count("input"))
set_input_filename(vars.at("input").as<std::string>());
}
示例5: pimpl
basic_configuration::basic_configuration(const boost::program_options::variables_map& vars, logger::logger& log) : pimpl(std::make_unique<impl>(&log))
{
if (vars.count("working_directory"))
set_workspace(vars.at("working_directory").as<std::string>());
}