当前位置: 首页>>代码示例>>C++>>正文


C++ options类代码示例

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


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


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