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


C++ OptionParser类代码示例

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


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

示例1: RunBenchmark

// ****************************************************************************
// Function: RunBenchmark
//
// Purpose:
//   Measures the floating point capability of the device for a variety of 
//   combinations of arithmetic operations.
//
// Arguments:
//   op: the options parser / parameter database
//
// Returns:  nothing
//
// Programmer: Zhi Ying([email protected])
//             Jun Jin([email protected])
//
// Creation: May 23, 2011
//
// Modifications:
// 12/12/12 - Kyle Spafford - Code style and minor integration updates
//
// ****************************************************************************
void RunBenchmark(OptionParser &op, ResultDatabase &resultDB)
{
    const bool verbose = op.getOptionBool("verbose");
    // Quiet == no progress bar.
    const bool quiet   = op.getOptionBool("quiet");
    const unsigned int passes = op.getOptionInt("passes");
    const int micdev = op.getOptionInt("target");

    double repeatF = 3;
    cout << "Adjust repeat factor = " << repeatF << "\n";

    // Initialize progress bar
    int totalRuns = 16*passes*2;
    ProgressBar pb(totalRuns);
    if (!verbose && !quiet) 
    {
        pb.Show(stdout);
    }

    RunTest<float>(resultDB, passes, verbose, quiet,
                   repeatF, pb, "-SP", micdev);
    RunTest<double>(resultDB, passes, verbose, quiet,
                    repeatF, pb, "-DP", micdev);

    if (!verbose) cout << endl;
}
开发者ID:optimus-prime,项目名称:shoc-mic,代码行数:47,代码来源:MaxFlops.cpp

示例2: main

int main (int argc, const char* argv[]) {
	OptionParser parser;
	parser.description("split input file by odd lines and even lines into two files\n"
		"input from stdin, output odd lines to stdout, even lines to stderr")
		.usage("%prog [OPTIONS] < INPUT > ODD_LINES 2> EVEN_LINES")
		.version("1.0")
		.epilog("By jadesoul @ 2013-11-19 14:47:14\n"
			"please report bugs to " JADESOUL_EMAIL);
	parser.add_option("-v", "--verbose")
		.action("store_true")
		.dest("verbose")
		.set_default("0")
		.help("print status messages to stdlog");
	OptionArgs& optargs = parser.parse_args(argc, argv);
	bool verbose=optargs.get("verbose");
	
	if (verbose) cout<<"begin ..."<<endl;
	
	uint i=0;
	string s;
	while (getline(cin, s))
		if (++i%2==1) cout<<s<<endl;
		else cerr<<s<<endl;
		
	if (verbose) cout<<"finished"<<endl;
	return 0;
}
开发者ID:jadesoul,项目名称:tools,代码行数:27,代码来源:odd.cpp

示例3: main

int CDECL main(int aArgc, char* aArgv[])
{
	InitialisationParams* initParams = InitialisationParams::Create();

    OptionParser parser;
    OptionUint optionDuration("-d", "--duration", 30, "Number of seconds to run the test");
    parser.AddOption(&optionDuration);
    if (!parser.Parse(aArgc, aArgv)) {
        return (1);
    }

    Library* lib = new Library(initParams);
    std::vector<NetworkAdapter*>* subnetList = lib->CreateSubnetList();
    TIpAddress subnet = (*subnetList)[0]->Subnet();
    Library::DestroySubnetList(subnetList);
    CpStack* cpStack = lib->StartCp(subnet);

    // Debug::SetLevel(Debug::kTopology);

	ReceiverManager1Logger* logger = new ReceiverManager1Logger(*cpStack);
	
    Blocker* blocker = new Blocker(lib->Env());
    blocker->Wait(optionDuration.Value());
    delete blocker;
	
	delete (logger);

	Print("Closing ... ");
	delete lib;
	Print("closed\n");
}
开发者ID:DoomHammer,项目名称:ohSongcast,代码行数:31,代码来源:TestReceiverManager1.cpp

示例4: TestNetwork

void TestNetwork(const std::vector<Brn>& aArgs)
{
    OptionParser parser;
    OptionUint adapter("-i", "--interface", 0, "index of network adapter to use");
    parser.AddOption(&adapter);
    if (!parser.Parse(aArgs) || parser.HelpDisplayed()) {
        return;
    }

    std::vector<NetworkAdapter*>* ifs = Os::NetworkListAdapters(Net::InitialisationParams::ELoopbackUse, "TestNetwork");
    ASSERT(ifs->size() > 0 && adapter.Value() < ifs->size());
    TIpAddress addr = (*ifs)[adapter.Value()]->Address();
    for (TUint i=0; i<ifs->size(); i++) {
        (*ifs)[i]->RemoveRef("TestNetwork");
    }
    delete ifs;
    Endpoint endpt(0, addr);
    Endpoint::AddressBuf buf;
    endpt.AppendAddress(buf);
    Print("Using network interface %s\n\n", buf.Ptr());
    Thread* th = new MainNetworkTestThread(addr);
    th->Start();
    th->Wait();
    delete th;
}
开发者ID:chinshou,项目名称:ohNet,代码行数:25,代码来源:TestNetwork.cpp

示例5: CheckOptions

// validate stencil-independent values
void
CheckOptions( const OptionParser& opts )
{
    // check matrix dimensions - must be 2d, must be positive
    std::vector<long long> arrayDims = opts.getOptionVecInt( "customSize" );
    if( arrayDims.size() != 2 )
    {
        throw InvalidArgValue( "overall size must have two dimensions" );
    }
    if( (arrayDims[0] < 0) || (arrayDims[1] < 0) )
    {
        throw InvalidArgValue( "each size dimension must be positive" );
    }

    // validation error threshold must be positive
    float valThreshold = opts.getOptionFloat( "val-threshold" );
    if( valThreshold <= 0.0f )
    {
        throw InvalidArgValue( "validation threshold must be positive" );
    }

    // number of validation errors to print must be non-negative
    int nErrsToPrint = opts.getOptionInt( "val-print-limit" );
    if( nErrsToPrint < 0 )
    {
        throw InvalidArgValue( "number of validation errors to print must be non-negative" );
    }

    int nWarmupPasses = opts.getOptionInt( "warmupPasses" );
    if( nWarmupPasses < 0 )
    {
        throw InvalidArgValue( "number of warmup passes must be non-negative" );
    }
}
开发者ID:adityaatluri,项目名称:shoc-1,代码行数:35,代码来源:Stencil2Dmain.cpp

示例6: nkeys

// parse a STATA command 
DwUseOptions* DwUseOptionParser::Parse(vector<string> words) {	

	// there are 10 keywords we expect to see
	string keys[] = {"variables", "if", "using", "limit",
					 "nulldata", "lowercase", "uppercase", 
					 "label_variable", "label_values", 
					 "username", "password", "database"};
	size_t nkeys(sizeof(keys) / sizeof(string));
	// create parser that accepts these keywords
	OptionParser* parser = new OptionParser( set<string>(keys, keys + nkeys) );

	// prepare another vector where we can search 

	// see if we have a using anywhere, if we do, the first part is the varlist, if not it is the tablename
	bool hasUsing = hasKeyword(words, "using");

	// if it contains using somewhere we can start with variables (if missing it will be an empty string, if the list is there it will be expected)
	if( !hasUsing ) 
		words.insert(words.begin(), "using"); 
	else if( lowerCase(words[0]) != "if" && lowerCase(words[0]) != "using" )
		words.insert(words.begin(), "variables");

	// parse the options
	map<string,string> options = parser->Parse( words );
	delete parser;

	// create a meaningful options object
	DwUseOptions* useOptions = new DwUseOptions( options );	
	return useOptions;
}
开发者ID:aakoshh,项目名称:StataDwPlugin,代码行数:31,代码来源:Options.cpp

示例7: GPUSetup

// ****************************************************************************
// Function: GPUSetup
//
// Purpose:
//  do the necessary OpenCL setup for GPU part of the test
//
// Arguments:
//   op: the options parser / parameter database
//   mympirank: for printing errors in case of failure
//   mynoderank: this is typically the device ID (the mapping done in main)
//
// Returns: success/failure
//
// Creation: 2009
//
// Modifications:
//
// ****************************************************************************
//
int GPUSetup(OptionParser &op, int mympirank, int mynoderank)
{
    addBenchmarkSpecOptions(op);
    
    if (op.getOptionBool("infoDevices"))
    {
        OpenCLNodePlatformContainer ndc1;
        ndc1.Print (cout);
        return (0);
    }
    
    // The device option supports specifying more than one device
    int platform = op.getOptionInt("platform");
    int deviceIdx = mynoderank;
    if( deviceIdx >= op.getOptionVecInt( "device" ).size() )
    {
        std::ostringstream estr;
        estr << "Warning: not enough devices specified with --device flag for task "
            << mympirank
            << " ( node rank " << mynoderank
            << ") to claim its own device; forcing to use first device ";
        std::cerr << estr.str() << std::endl;
        deviceIdx = 0;
    }
    int device = op.getOptionVecInt("device")[deviceIdx];

    // Initialization
    _mpicontention_ocldev = new cl::Device( ListDevicesAndGetDevice(platform, device) );
    std::vector<cl::Device> ctxDevices;
    ctxDevices.push_back( *_mpicontention_ocldev );
    _mpicontention_ocldriver_ctx   = new cl::Context( ctxDevices );
    _mpicontention_ocldriver_queue = new cl::CommandQueue( *_mpicontention_ocldriver_ctx, *_mpicontention_ocldev, CL_QUEUE_PROFILING_ENABLE );
    _mpicontention_gpuop = op;
    return 0;
}
开发者ID:Poojachitral,项目名称:shoc,代码行数:54,代码来源:OCLDriver.cpp

示例8: main

int __cdecl main(int aArgc, char* aArgv[])
{
	InitialisationParams* initParams = InitialisationParams::Create();

    OptionParser parser;
    
    OptionUint optionDuration("-d", "--duration", 30, "Number of seconds to run the test");

    parser.AddOption(&optionDuration);
    
    if (!parser.Parse(aArgc, aArgv)) {
        return (1);
    }

    UpnpLibrary::Initialise(initParams);
    
    UpnpLibrary::StartCp();

    //Debug::SetLevel(Debug::kTopology);

	ReceiverManager2Logger* logger = new ReceiverManager2Logger();
	
    Blocker* blocker = new Blocker;
    blocker->Wait(optionDuration.Value());
    delete blocker;
	
	delete (logger);

	UpnpLibrary::Close();
}
开发者ID:wifigeek,项目名称:ohNet,代码行数:30,代码来源:TestReceiverManager2.cpp

示例9: PrepareHeader

BamHeader PrepareHeader(const OptionParser& parser, int argc, char** argv,
                        const vector<string>& files)
{
    using boost::algorithm::join;

    ProgramInfo program(parser.prog() + "-" + CCS_VERSION);
    program.Name(parser.prog())
    .CommandLine(parser.prog() + " " + join(vector<string>(argv + 1, argv + argc), " "))
    .Description(DESCRIPTION)
    .Version(CCS_VERSION);

    BamHeader header;
    header.PacBioBamVersion("3.0.1").SortOrder("unknown").Version("1.5").AddProgram(program);

    for (const auto& file : files) {
        BamFile bam(file);

        for (const auto& rg : bam.Header().ReadGroups()) {
            if (rg.ReadType() != "SUBREAD")
                parser.error("invalid input file, READTYPE must be SUBREAD");

            ReadGroupInfo readGroup(rg.MovieName(), "CCS");
            readGroup.BindingKit(rg.BindingKit())
            .SequencingKit(rg.SequencingKit())
            .BasecallerVersion(rg.BasecallerVersion())
            .FrameRateHz(rg.FrameRateHz());

            header.AddReadGroup(readGroup);
        }
    }

    return header;
}
开发者ID:ylipacbio,项目名称:pbccs,代码行数:33,代码来源:ccs.cpp

示例10: Options

    Options(int argc, char *argv[]) {

        parser = new OptionParser(argc, argv);

        this->init_options();

        // Personnalisation éventuelle du comportement : que faire si l'utilisateur
        // passe une option incorrecte ?  Les valeurs possibles sont :
        //      exit (par défaut), raise, warn, ignore
        // Ici, on veut afficher les clés erronées tout en continuant l'analyse.
        // parser->on_error("warn");
        // Ici, on veut arrêter le programme en cas d'option invalide.
        parser->on_error("exit");  // inutile car c'est "exit" par défaut

        // Permet des post-traitements (vérification de cohérence d'options,...)
        pre_process_options();

        // On peut lancer l'analyse ici ou bien le faire depuis le main() de la
        // du programme principal.
        parser->parse();

        // Permet des post-traitements (vérification de cohérence entre options,...)
        post_process_options();

        // Les attributs options étant affectés, on peut supprimer le parser
        // sauf si on souhaite exploiter quelques-unes de ses méthodes ou attributs
        // e.g parser->print_values() ou parser->params
        //  delete parser;
        //  parser = NULL; // Utile ssi on veut pouvoir tester l'existence de parser !
    }
开发者ID:Razzis,项目名称:projet_ECMA,代码行数:30,代码来源:options.hpp

示例11: main

int CDECL main(int aArgc, char* aArgv[])
{
	InitialisationParams* initParams = InitialisationParams::Create();

    OptionParser parser;
    
    OptionUint optionDuration("-d", "--duration", 30, "Number of seconds to run the test");

    parser.AddOption(&optionDuration);
    
    if (!parser.Parse(aArgc, aArgv)) {
        return (1);
    }

    UpnpLibrary::Initialise(initParams);
    std::vector<NetworkAdapter*>* subnetList = UpnpLibrary::CreateSubnetList();
    TIpAddress subnet = (*subnetList)[0]->Subnet();
    UpnpLibrary::DestroySubnetList(subnetList);
    UpnpLibrary::StartCp(subnet);

    // Debug::SetLevel(Debug::kTopology);

	ReceiverManager2Logger* logger = new ReceiverManager2Logger();
	
    Blocker* blocker = new Blocker;
    blocker->Wait(optionDuration.Value());
    delete blocker;
	
	delete (logger);

	UpnpLibrary::Close();
}
开发者ID:cedric-andrieu,项目名称:ohSongcast,代码行数:32,代码来源:TestReceiverManager2.cpp

示例12: addBenchmarkSpecOptions

// ****************************************************************************
// Function: addBenchmarkSpecOptions
//
// Purpose:
//   Add benchmark specific options parsing.  The user is allowed to specify
//   the size of the input data in megabytes.
//
// Arguments:
//   op: the options parser / parameter database
//
// Programmer: Collin McCurdy
// Creation: September 08, 2009
// Returns:  nothing
//
// ****************************************************************************
	void
addBenchmarkSpecOptions(OptionParser &op)
{
	op.addOption("pts", OPT_INT, "0", "data size (in megabytes)");
	op.addOption("pts1", OPT_INT, "0", "data size (in megabytes)");
	op.addOption("pts2", OPT_INT, "0", "data size (in megabytes)");
	op.addOption("2D", OPT_BOOL, "false", "2D FFT");
}
开发者ID:Sable,项目名称:Ostrich,代码行数:23,代码来源:fft.cpp

示例13: addBenchmarkSpecOptions

// ****************************************************************************
// Function: addBenchmarkSpecOptions
//
// Purpose:
//   Add benchmark specific options parsing.  The user is allowed to specify
//   the size of the input data in megabytes.
//
// Arguments:
//   op: the options parser / parameter database
//
// Programmer: Collin McCurdy
// Creation: September 08, 2009
// Returns:  nothing
//
// ****************************************************************************
void 
addBenchmarkSpecOptions(OptionParser &op) 
{
    op.addOption("MB", OPT_INT, "0", "data size (in megabytes)");
    op.addOption("use-native", OPT_BOOL, "false", "call native (HW) versions of sin/cos");
    op.addOption("dump-sp", OPT_BOOL, "false", "dump result after SP fft/ifft");
    op.addOption("dump-dp", OPT_BOOL, "false", "dump result after DP fft/ifft");
}
开发者ID:Poojachitral,项目名称:shoc,代码行数:23,代码来源:FFT.cpp

示例14: addBenchmarkSpecOptions

// ****************************************************************************
// Function: addBenchmarkSpecOptions
//
// Purpose:
//   Add benchmark specific options parsing.
//
// Arguments:
//   op: the options parser / parameter database
//
// Programmer: Lukasz Wesolowski
// Creation: June 21, 2010
// Returns:  nothing
//
// ****************************************************************************
void addBenchmarkSpecOptions(OptionParser &op)
{
    op.addOption("iterations", OPT_INT, "100", "Number of SpMV iterations "
                 "per pass");
    op.addOption("mm_filename", OPT_STRING, "random", "Name of file "
                 "which stores the matrix in Matrix Market format");
    op.addOption("maxval", OPT_FLOAT, "10", "Maximum value for random "
                 "matrices");
}
开发者ID:bart-utahman,项目名称:shoc,代码行数:23,代码来源:Spmv.cpp

示例15:

void
StencilFactory<T>::ExtractOptions( const OptionParser& options,
                                T& wCenter,
                                T& wCardinal,
                                T& wDiagonal )
{
    wCenter = options.getOptionFloat( "weight-center" );
    wCardinal = options.getOptionFloat( "weight-cardinal" );
    wDiagonal = options.getOptionFloat( "weight-diagonal" );
}
开发者ID:ellen-hl,项目名称:shoc-mic,代码行数:10,代码来源:StencilFactory.cpp


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