本文整理汇总了C++中boost::program_options::variables_map::count方法的典型用法代码示例。如果您正苦于以下问题:C++ variables_map::count方法的具体用法?C++ variables_map::count怎么用?C++ variables_map::count使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类boost::program_options::variables_map
的用法示例。
在下文中一共展示了variables_map::count方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: hpx_main
int hpx_main(boost::program_options::variables_map& vm)
{
unsigned int seed = (unsigned int)std::time(nullptr);
if (vm.count("seed"))
seed = vm["seed"].as<unsigned int>();
std::cout << "using seed: " << seed << std::endl;
std::srand(seed);
for_loop_strided_test();
for_loop_strided_test_idx();
return hpx::finalize();
}
示例2: hpx_main
int hpx_main(boost::program_options::variables_map& vm)
{
unsigned int seed = (unsigned int)std::time(nullptr);
if (vm.count("seed"))
seed = vm["seed"].as<unsigned int>();
std::cout << "using seed: " << seed << std::endl;
std::srand(seed);
rotate_test();
rotate_exception_test();
rotate_bad_alloc_test();
return hpx::finalize();
}
示例3: do_matchFirstNumeric
void do_matchFirstNumeric(const boost::program_options::variables_map &vm, const std::string key, std::string &target, const std::string var, const std::string bound, const std::string op) {
if (vm.count(key)) {
std::vector<std::string> bounds = vm[key].as<std::vector<std::string> >();
if (bounds.size() > 1 || !target.empty())
NSC_DEBUG_MSG("Multiple boundries of the same kind is not supported");
if (bounds.size() > 0) {
std::string value = bounds.front();
if (value.size() > 3 && value[2] == ':')
target = var + "=" + bound + " " + value.substr(0,2) + " " + value.substr(3);
else
target = var + "=" + bound + op + bounds.front();
}
}
}
示例4: loadTFMFromProgramOptions
void SpinReader::loadTFMFromProgramOptions(const bpo::variables_map & vm)
{
RobotModel model;
if( vm.count("robot_description") )
model.addFile(vm["robot_description"].as<std::string>());
else if( ! ros::param::has("/driving/robot_description") )
BOOST_THROW_EXCEPTION(stdr::ex::ExceptionBase() <<stdr::ex::MsgInfo(
"You must provide a model description, either on the command line, or as a rosparam."));
model.addParam("/driving/robot_description");
BOOST_FOREACH(const tf::StampedTransform& t, model.getStaticTransforms()) {
tf_listener_.addStaticTransform(t);
}
}
示例5: ri
shared_ptr<mat> filtering(const mat& mrating, mpq& msim){
cout<<"collaborative filtering..."<<endl;
shared_ptr<mat> pm_predict(new mat(mrating));
mat& m_predict = *pm_predict;
int max_row_index = base ? nitem : nuser;
for(mpq_i i=msim.begin(); i!=msim.end(); ++i){
cout<<(i->first+1) * 100 / max_row_index<<"%\r"; cout.flush();
// get current row
row ri(m_predict, i->first);
pq& q = i->second;
// pop all sim rows
for(;!q.empty(); q.pop()){
int index = q.top().first;
double sim = q.top().second;
crow rj(mrating, index);
switch(sim_summing){
case 0:
ri += rj * sim;
break;
case 1:
for(crow::const_iterator j=rj.begin(); j!=rj.end(); ++j){
int col = j.index();
double v = 1 - ( 1 - ri(col) ) * ( 1 - *j * sim );
if(v) ri(col) = v;
}
break;
default:
break;
}
}
}
cout<<endl;
if(vm.count("verbose")) cout<<"prediction matrix:\n"<<m_predict<<endl;
return pm_predict;
}
示例6: parse_commandline
bool parse_commandline(int argc, char *argv[], po::variables_map& vm)
{
try {
po::options_description desc_cmdline ("Usage: fibonacci2 [options]");
desc_cmdline.add_options()
("help,h", "print out program usage (this message)")
("run_agas_server,r", "run AGAS server as part of this runtime instance")
("worker,w", "run this instance in worker (non-console) mode")
("config", po::value<std::string>(),
"load the specified file as an application configuration file")
("agas,a", po::value<std::string>(),
"the IP address the AGAS server is running on (default taken "
"from hpx.ini), expected format: 192.168.1.1:7912")
("hpx,x", po::value<std::string>(),
"the IP address the HPX parcelport is listening on (default "
"is localhost:7910), expected format: 192.168.1.1:7913")
("localities,l", po::value<int>(),
"the number of localities to wait for at application startup "
"(default is 1)")
("threads,t", po::value<int>(),
"the number of operating system threads to spawn for this "
"HPX locality")
("queueing,q", po::value<std::string>(),
"the queue scheduling policy to use, options are 'global' "
" and 'local' (default is 'global')")
("value,v", po::value<int>(),
"the number to be used as the argument to fib (default is 10)")
("csv,s", "generate statistics of the run in comma separated format")
("busywait,b", po::value<int>(),
"add this amount of busy wait workload to each of the iterations"
" [in microseconds], i.e. -b1000 == 1 millisecond")
;
po::store(po::command_line_parser(argc, argv)
.options(desc_cmdline).run(), vm);
po::notify(vm);
// print help screen
if (vm.count("help")) {
std::cout << desc_cmdline;
return false;
}
}
catch (std::exception const& e) {
std::cerr << "fibonacci2: exception caught: " << e.what() << std::endl;
return false;
}
return true;
}
示例7: readGridGraph
bool readGridGraph(boost::program_options::variables_map& variableMap, int& gridDimension, std::string& message)
{
if(variableMap.count("gridGraph") != 1)
{
message = "Please enter a single value for `input' gridGraph";
return false;
}
gridDimension = variableMap["gridGraph"].as<int>();
if(gridDimension <= 0)
{
message = "Input `gridGraph' must be a positive number";
return false;
}
return true;
}
示例8: local_tests
void local_tests(boost::program_options::variables_map& vm)
{
std::size_t pxthreads = 0;
if (vm.count("pxthreads"))
pxthreads = vm["pxthreads"].as<std::size_t>();
std::size_t iterations = 0;
if (vm.count("iterations"))
iterations = vm["iterations"].as<std::size_t>();
hpx::id_type here = hpx::find_here();
for (std::size_t i = 0; i < iterations; ++i)
{
boost::atomic<std::size_t> c(0);
for (std::size_t j = 0; j < pxthreads; ++j)
{
hpx::async(hpx::util::bind(&barrier_test, pxthreads + 1, j, std::ref(c)));
}
hpx::lcos::barrier b("local_barrier_test", pxthreads + 1, pxthreads);
b.wait(); // wait for all threads to enter the barrier
HPX_TEST_EQ(pxthreads, c.load());
}
}
示例9: checkParameters
int checkParameters(int argc,char **argv,po::variables_map & vm) {
po::options_description desc("Allowed options");
desc.add_options()
("help,h", "produce help message")
("r1,1", po::value<string>(), "read 1 in fastq format (gzip allowed)")
("r2,2", po::value<string>(), "read 2 in fastq format (gzip allowed)")
("output-prefix,O", po::value<string>(), "output prefix")
("rc", "reverse-complement reads");
po::store(po::parse_command_line(argc, argv, desc), vm);
po::notify(vm);
if (vm.count("help") || argc==1) {
cout << desc << "\n";
exit(1);
}
if (!vm.count("r1") || !vm.count("r2") || !vm.count("output-prefix")) {
cout << "Missing input!"<<endl;
exit(1);
}
return(0);
}
示例10: listLabels
void listLabels( const boost::program_options::variables_map & options )
{
std::string labelRegex = ".*";
if ( options.count( "arg1" ) > 0 )
labelRegex = options[ "arg1" ].as< std::string >();
boost::regex testExpression( labelRegex );
Osmosis::Chain::Chain chain( options[ "objectStores" ].as< std::string >(), false, false );
if ( chain.count() > 1 )
THROW( Error, "--objectStores must contain one object store in a list operation" );
Osmosis::Client::LabelOps instance( chain.single() );
std::list< std::string > result = instance.listLabels( labelRegex );
for ( auto & i : result )
std::cout << i << std::endl;
}
示例11: hpx_main
int hpx_main(boost::program_options::variables_map& vm)
{
bool print_header = vm.count("no-header") == 0;
bool do_child = vm.count("no-child") == 0; // fork only
bool do_parent = vm.count("no-parent") == 0; // async only
std::size_t num_cores = hpx::get_os_thread_count();
if (vm.count("num_cores") != 0)
num_cores = vm["num_cores"].as<std::size_t>();
// first collect child stealing times
double child_stealing_time = 0;
if (do_parent)
child_stealing_time = measure(hpx::launch::async);
// now collect parent stealing times
double parent_stealing_time = 0;
if (do_child)
parent_stealing_time = measure(hpx::launch::fork);
if (print_header)
{
hpx::cout
<< "num_cores,num_threads,child_stealing_time[s],parent_stealing_time[s]"
<< hpx::endl;
}
hpx::cout
<< (boost::format("%d,%d,%f,%f") %
num_cores %
iterations %
child_stealing_time %
parent_stealing_time)
<< hpx::endl;
return hpx::finalize();
}
示例12: runConsole
void runConsole(const bpo::variables_map& vm)
{
boost::asio::io_service srv;
Drone drone(vm["address"].as<string>(), srv);
std::auto_ptr<UdpLogger> logger;
std::string logfileName;
if (vm.count("autolog")) {
logfileName = createLogFileName();
} else if (vm.count("loggfile")) {
logfileName = vm["logfile"].as<string>();
}
if (!logfileName.empty()) {
logger.reset(new UdpLogger(srv, 7778, logfileName));
logger->start();
}
if (vm.count("joystick")) {
runJoystickControlled(drone, vm["joystick"].as<string>());
} else {
runKeyboardControlled(drone);
}
}
示例13: hpx_main
int hpx_main(boost::program_options::variables_map& vm)
{
unsigned int seed = (unsigned int)std::time(nullptr);
if (vm.count("seed"))
seed = vm["seed"].as<unsigned int>();
std::cout << "using seed: " << seed << std::endl;
std::srand(seed);
test_sort1();
test_sort2();
sort_benchmark();
return hpx::finalize();
}
示例14: readNGraphs
bool readNGraphs(boost::program_options::variables_map& variableMap, int& out)
{
if(variableMap.count("nGraphs") != 1)
{
std::cout << "Please enter a single option value for input `nGraphs'" << std::endl;
return false;
}
out = variableMap["nGraphs"].as<int>();
if(out <= 0)
{
std::cout << "Input `nGraphs' must be positive" << std::endl;
return false;
}
return true;
}
示例15: readInitialRadius
bool readInitialRadius(boost::program_options::variables_map& variableMap, int& out)
{
if(variableMap.count("initialRadius") != 1)
{
std::cout << "Please enter a single value for input `initialRadius'" << std::endl;
return false;
}
out = variableMap["initialRadius"].as<int>();
if(out < 0)
{
std::cout << "Input `initialRadius' must be nonnegative" << std::endl;
return false;
}
return true;
}