• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ options类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中options的典型用法代码示例。如果您正苦于以下问题:C++ options类的具体用法?C++ options怎么用?C++ options使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了options类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: set_config_option

options set_config_option(options const & opts, char const * in) {
    if (!in) return opts;
    while (*in && std::isspace(*in))
        ++in;
    std::string in_str(in);
    auto pos = in_str.find('=');
    if (pos == std::string::npos)
        throw lean::exception("invalid -D parameter, argument must contain '='");
    lean::name opt = lean::string_to_name(in_str.substr(0, pos));
    std::string val = in_str.substr(pos+1);
    auto decls = lean::get_option_declarations();
    auto it = decls.find(opt);
    if (it != decls.end()) {
        switch (it->second.kind()) {
        case lean::BoolOption:
            if (val == "true")
                return opts.update(opt, true);
            else if (val == "false")
                return opts.update(opt, false);
            else
                throw lean::exception(lean::sstream() << "invalid -D parameter, invalid configuration option '" << opt
                                      << "' value, it must be true/false");
        case lean::IntOption:
        case lean::UnsignedOption:
            return opts.update(opt, atoi(val.c_str()));
        default:
            throw lean::exception(lean::sstream() << "invalid -D parameter, configuration option '" << opt
                                  << "' cannot be set in the command line, use set_option command");
        }
    } else {
        throw lean::exception(lean::sstream() << "invalid -D parameter, unknown configuration option '" << opt << "'");
    }
}
开发者ID:codyroux,项目名称:lean,代码行数:33,代码来源:lean.cpp


示例2: has_show

static bool has_show(options const & opts, name const & kind, unsigned & line, unsigned & col) {
    if (opts.get_bool(kind)) {
        line = opts.get_unsigned("line", 0);
        col  = opts.get_unsigned("column", 0);
        return true;
    } else {
        return false;
    }
}
开发者ID:GallagherCommaJack,项目名称:lean,代码行数:9,代码来源:opt_cmd.cpp


示例3: context

 context(const benchmark_info& info, const options& opts)
     : d_timer_on(false)
     , d_start()
     , d_duration()
     , d_benchtime(std::chrono::seconds(opts.get_benchtime()))
     , d_num_iterations(1)
     , d_num_threads(opts.get_cpu())
     , d_num_bytes(0)
     , d_benchmark(info)
 {}
开发者ID:ymglez,项目名称:jsonpack,代码行数:10,代码来源:benchpress.hpp


示例4: display

void display(options& opt, spec::runner::result const& res)
{
    // stdout is default so this is valid
    std::ostream output( std::cout.rdbuf() );
    bool file_output = false;
    std::ofstream file_stream;

    std::string const& format = opt.format();
    std::string const& output_method = opt.output_method();

    boost::shared_ptr<output_format::base> outformat;
    std::string file_extension;

    if( output_method == "stderr" )
        output.rdbuf( std::cerr.rdbuf() );
    else if( output_method == "file" )
        file_output = true;

// Add you output format the same way as bellow DON'T FORGET TO ADD
// FILE EXTENSION 
// ---------------------------------------------------------------------------
    if( format == "compiler" )
    {
        outformat.reset( new output_format::compiler() );
        file_extension = ".txt";
    }
// ---------------------------------------------------------------------------
    else if( format == "xml" )
    {
        outformat.reset( new output_format::xml() );
        file_extension = ".xml";
    }
// ---------------------------------------------------------------------------
    else
    {
        throw std::runtime_error( "output format not supported" );
    }

    if( file_output )
    {
        std::string filename = opt.filename()+file_extension;
        file_stream.open(filename.c_str(), std::ios_base::out|std::ios_base::trunc);
        if( file_stream.is_open() )
            output.rdbuf( file_stream.rdbuf() );
    }

    spec::output out( outformat, res, output );
    out.display();

}
开发者ID:fen,项目名称:specpp,代码行数:50,代码来源:display.hpp


示例5: runTests

std::size_t TestFixture::runTests(const options& args)
{
    std::string classname(args.which_test());
    std::string testname("");
    if (classname.find("::") != std::string::npos) {
        testname = classname.substr(classname.find("::") + 2);
        classname.erase(classname.find("::"));
    }

    countTests = 0;
    errmsg.str("");

    const std::list<TestFixture *> &tests = TestRegistry::theInstance().tests();

    for (std::list<TestFixture *>::const_iterator it = tests.begin(); it != tests.end(); ++it) {
        if (classname.empty() || (*it)->classname == classname) {
            (*it)->processOptions(args);
            (*it)->run(testname);
        }
    }

    std::cout << "\n\nTesting Complete\nNumber of tests: " << countTests << std::endl;
    std::cout << "Number of todos: " << todos_counter;
    if (succeeded_todos_counter > 0)
        std::cout << " (" << succeeded_todos_counter << " succeeded)";
    std::cout << std::endl;
    // calling flush here, to do all output before the error messages (in case the output is buffered)
    std::cout.flush();

    std::cerr << "Tests failed: " << fails_counter << std::endl << std::endl;
    std::cerr << errmsg.str();
    std::cerr.flush();
    return fails_counter;
}
开发者ID:NightOfTwelve,项目名称:cppcheck,代码行数:34,代码来源:testsuite.cpp


示例6: join

options join(options const & opts1, options const & opts2) {
    sexpr r = opts2.m_value;
    for_each(opts1.m_value, [&](sexpr const & p) {
            if (!opts2.contains(to_name(car(p))))
                r = cons(p, r);
        });
    return options(r);
}
开发者ID:cpehle,项目名称:lean,代码行数:8,代码来源:options.cpp


示例7: run_benchmarks

/*
 * The run_benchmarks function will run the registered benchmarks.
 */
void run_benchmarks(const options& opts) {
    std::regex match_r(opts.get_bench());
    auto benchmarks = registration::get_ptr()->get_benchmarks();
    for (auto& info : benchmarks) {
        if (std::regex_match(info.get_name(), match_r)) {
            context c(info, opts);
            auto r = c.run();
            std::cout << std::setw(35) << std::left << info.get_name() << r.to_string() << std::endl;
        }
    }
}
开发者ID:ymglez,项目名称:jsonpack,代码行数:14,代码来源:benchpress.hpp


示例8: parse_options

int parse_options(int argc, const char** argv, options& opts) {

	eagine::program_args args(argc, argv);

	for(auto a = args.first(); a; a = a.next()) {
		if(a.is_help_arg()) {
			opts.print_usage(std::cout);
			return 1;
		} else if(!parse_argument(a, opts)) {
			opts.print_usage(std::cerr);
			return 2;
		}
	}

	if(!opts.check(std::cerr)) {
		opts.print_usage(std::cerr);
		return 3;
	}

	return 0;
}
开发者ID:matus-chochlik,项目名称:oglplu2,代码行数:21,代码来源:bake_program_source.cpp


示例9: parse_argument

bool parse_argument(eagine::program_arg& a, options& opts) {

	if(!opts.parse(a, std::cerr)) {
		std::cerr
			<< "Failed to parse argument '"
			<< a.get()
			<< "'"
			<< std::endl;
		return false;
	}
	return true;
}
开发者ID:matus-chochlik,项目名称:oglplu2,代码行数:12,代码来源:bake_program_source.cpp


示例10:

bool options::operator==(const options &rhs)
{
	// iterate over options in the first list
	for (entry *curentry = m_entrylist.first(); curentry != nullptr; curentry = curentry->next())
		if (!curentry->is_header())
		{
			// if the values differ, return false
			if (strcmp(curentry->value(), rhs.value(curentry->name())) != 0)
				return false;
		}

	return true;
}
开发者ID:cdrr,项目名称:mameui,代码行数:13,代码来源:win_options.cpp


示例11: display_pos

void display_pos(std::ostream & out, options const & o, char const * strm_name, unsigned line, unsigned pos) {
    out << strm_name << ":";
    if (o.get_bool("flycheck", false)) {
        // generate valid line and column for flycheck mode
        if (line == static_cast<unsigned>(-1))
            line = 1;
        if (pos == static_cast<unsigned>(-1))
            pos = 0;
    }
    if (line != static_cast<unsigned>(-1))
        out << line << ":";
    if (pos != static_cast<unsigned>(-1))
        out << pos << ":";
}
开发者ID:skbaek,项目名称:lean,代码行数:14,代码来源:error_handling.cpp


示例12: is

void
augd::createsslctxs(sslctxs& sslctxs, const options& options, char* frobpass)
{
    const char* contexts = options.get("ssl.contexts", 0);

    if (contexts) {

        istringstream is(contexts);
        string name;
        while (is >> name)
            sslctxs.insert(make_pair(name, createsslctx(name, options,
                                                        frobpass)));
    }
}
开发者ID:marayl,项目名称:aug,代码行数:14,代码来源:ssl.cpp


示例13: get_elaborator_lift_coercions

bool get_elaborator_lift_coercions(options const & opts) {
    return opts.get_bool(*g_elaborator_lift_coercions, LEAN_DEFAULT_ELABORATOR_LIFT_COERCIONS);
}
开发者ID:fgdorais,项目名称:lean,代码行数:3,代码来源:elaborator_context.cpp


示例14: get_elaborator_fail_missing_field

bool get_elaborator_fail_missing_field(options const & opts) {
    return opts.get_bool(*g_elaborator_fail_missing_field, LEAN_DEFAULT_ELABORATOR_FAIL_MISSING_FIELD);
}
开发者ID:fgdorais,项目名称:lean,代码行数:3,代码来源:elaborator_context.cpp


示例15: get_elaborator_flycheck_goals

bool get_elaborator_flycheck_goals(options const & opts) {
    return opts.get_bool(*g_elaborator_flycheck_goals, LEAN_DEFAULT_ELABORATOR_FLYCHECK_GOALS);
}
开发者ID:fgdorais,项目名称:lean,代码行数:3,代码来源:elaborator_context.cpp


示例16: get_elaborator_ignore_instances

bool get_elaborator_ignore_instances(options const & opts) {
    return opts.get_bool(*g_elaborator_ignore_instances, LEAN_DEFAULT_ELABORATOR_IGNORE_INSTANCES);
}
开发者ID:fgdorais,项目名称:lean,代码行数:3,代码来源:elaborator_context.cpp


示例17: get_elaborator_local_instances

bool get_elaborator_local_instances(options const & opts) {
    return opts.get_bool(*g_elaborator_local_instances, LEAN_DEFAULT_ELABORATOR_LOCAL_INSTANCES);
}
开发者ID:fgdorais,项目名称:lean,代码行数:3,代码来源:elaborator_context.cpp


示例18: hpx_main

int hpx_main(int argc, char* argv[]) {
	printf("Running\n");
// 	auto test_fut = hpx::async([]() {
//		while(1){hpx::this_thread::yield();}
// 	});
// 	test_fut.get();

	try {
		if (opts.process_options(argc, argv)) {

			auto all_locs = hpx::find_all_localities();
			std::vector<hpx::future<void>> futs;
            futs.reserve(all_locs.size());
			for (auto i = all_locs.begin(); i != all_locs.end(); ++i) {
				futs.push_back(hpx::async < initialize_action > (*i, opts));
			}
            hpx::when_all(futs).get();

			node_client root_id = hpx::new_ < node_server > (hpx::find_here());
			node_client root_client(root_id);

			if (opts.found_restart_file) {
				set_problem(null_problem);
				const std::string fname = opts.restart_filename;
				printf("Loading from %s...\n", fname.c_str());
				if (opts.output_only) {
					const std::string oname = opts.output_filename;
					root_client.get_ptr().get()->load_from_file_and_output(fname, oname);
				} else {
					root_client.get_ptr().get()->load_from_file(fname);
					root_client.regrid(root_client.get_gid(), true).get();
				}
				printf("Done. \n");
			} else {
				for (integer l = 0; l < opts.max_level; ++l) {
					root_client.regrid(root_client.get_gid(), false).get();
					printf("---------------Created Level %i---------------\n\n", int(l + 1));
				}
				root_client.regrid(root_client.get_gid(), false).get();
				printf("---------------Regridded Level %i---------------\n\n", int(opts.max_level));
			}

			std::vector < hpx::id_type > null_sibs(geo::direction::count());
			printf("Forming tree connections------------\n");
			root_client.form_tree(root_client.get_gid(), hpx::invalid_id, null_sibs).get();
			if (gravity_on) {
				//real tstart = MPI_Wtime();
				root_client.solve_gravity(false).get();
				//	printf("Gravity Solve Time = %e\n", MPI_Wtime() - tstart);
			}
			printf("...done\n");

			if (!opts.output_only) {
				//	set_problem(null_problem);
				root_client.start_run(opts.problem == DWD && !opts.found_restart_file).get();
			}
            root_client.report_timing();
		}
	} catch (...) {
        throw;
	}
	printf("Exiting...\n");
	return hpx::finalize();
}
开发者ID:sithhell,项目名称:octotiger,代码行数:64,代码来源:main.cpp


示例19: get_apply_class_instance

bool get_apply_class_instance(options const & opts) {
    return opts.get_bool(*g_apply_class_instance, LEAN_DEFAULT_APPLY_CLASS_INSTANCE);
}
开发者ID:fgdorais,项目名称:lean,代码行数:3,代码来源:apply_tactic.cpp


示例20: processOptions

void TestFixture::processOptions(const options& args)
{
    quiet_tests = args.quiet();
    gcc_style_errors = args.gcc_style_errors();
}
开发者ID:NightOfTwelve,项目名称:cppcheck,代码行数:5,代码来源:testsuite.cpp



注:本文中的options类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ options_description类代码示例发布时间:2022-05-31
下一篇:
C++ optional_device类代码示例发布时间:2022-05-31
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap