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


C++ showUsage函数代码示例

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


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

示例1: ledctrl_main

int ledctrl_main(int argc, char **argv)
{
    PLED_NAME_MAP namePtr = ledNameMap;
    PLED_STATE_MAP statePtr = ledStateMap;

    if (argc < 3)
        showUsage();

    while (namePtr->validLedName)
        if (strcmp(namePtr->validLedName, argv[1]) == 0)
            break;
        else
            namePtr++;
    if (!namePtr->validLedName)
        showUsage();

    while (statePtr->validLedState)
        if (strcmp(statePtr->validLedState, argv[2]) == 0)
            break;
        else
            statePtr++;

    if (!statePtr->validLedState)
        showUsage();

    sysLedCtrl(namePtr->ledName, statePtr->ledState);

	return 0;

}
开发者ID:dronixdevteam,项目名称:AGA-devel,代码行数:30,代码来源:ledctrl.c

示例2: main

/*------------------------------------------------------------------------------
 *  Program entry point
 *----------------------------------------------------------------------------*/
int
main (
    int     argc,
    char  * argv[] )
{
    int     res = -1;

    std::cout << "DarkIce " << VERSION
         << " live audio streamer, http://darkice.sourceforge.net"
         << std::endl
         << "Copyright (c) 2000-2004, Tyrell Hungary, http://tyrell.hu"
         << std::endl << std::endl;

    try {
        const char    * configFileName = 0;
        unsigned int    verbosity      = 1;
        int             i;
        const char      opts[] = "hc:v:";

        while ( (i = getopt( argc, argv, opts)) != -1 ) {
            switch ( i ) {
                case 'c':
                    configFileName = optarg;
                    break;

                case 'v':
                    verbosity = Util::strToL( optarg);
                    break;

                default:
                case ':':
                case '?':
                case 'h':
                    showUsage( std::cout);
                    return 1;
            }
        }

        if ( !configFileName ) {
            showUsage( std::cout);
            throw Exception( __FILE__, __LINE__,
                             "no configuration file specified");
        }

        std::cout << "Using config file: " << configFileName << std::endl;

        std::ifstream       configFile( configFileName);
        Config              config( configFile);
        Ref<DarkIce>        di = new DarkIce( config);
        di->setReportVerbosity( verbosity );
        di->setReportOutputStream( std::cout );

        res = di->run();

    } catch ( Exception   & e ) {
        std::cout << "DarkIce: " << e << std::endl << std::flush;
    }

    return res;
}
开发者ID:bryangrim,项目名称:darkice,代码行数:63,代码来源:main.cpp

示例3: n64_main

int n64_main(int argc, char* argv[]) {
	init();
	if (argc==1) {
		test();
		dumpCutoffs();
	}
	else if (!strcmp("generateFlipFunctions", argv[1])) {
		extern void generateFlipFunctions();
		generateFlipFunctions();
	}
	else if (!strcmp("generateSolverTestPositions", argv[1])) {
		if (argc < 3) {
			showUsage();
		}
		else {
			const int depth = atoi(argv[2]);
			generateSolverTestPositions(depth);
		}
	}
	else if (!strcmp("timeSolves", argv[1])) {
		if (argc < 3) {
			showUsage();
		}
		else {
			const int depth = atoi(argv[2]);
			timeSolves(1, depth, false);
		}
	}
	else if (!strcmp("timeWld", argv[1])) {
		if (argc < 3) {
			showUsage();
		}
		else {
			const int depth = atoi(argv[2]);
			timeSolves(1, depth, true);
		}
	}
	else if (!strcmp("stats", argv[1])) {
		if (argc < 3) {
			showUsage();
		}
		else {
			const int depth = atoi(argv[2]);
			timeSolves(1, depth, true);
		}
		dumpCutoffs();
	}
	else if (!strcmp("timeMobility", argv[1])) {
		extern void timeMobility();
		timeMobility();
	}
	else {
		showUsage();
	}

	return 0;
}
开发者ID:hongfei1988,项目名称:ntest,代码行数:57,代码来源:n64.cpp

示例4: main

int main(int argc, char** argv) {
	std::vector<Argument> arguments = createArguments();
	ArgumentParser argumentParser;
	try {
		argumentParser.parse(argc, argv, arguments);
	} catch(const GeneralException& exception) {
		std::cout << exception.what() << std::endl;
		showUsage(arguments);
		return -1;
	}
	if (argumentParser.isArgumentPresent('h')) {
		showUsage(arguments);
		return 0;
	}
	if (!areAllMandatoryArgumentsPresent(argumentParser)) {
		showUsage(arguments);
		return -1;
	}
	try {
		FractalParser parser;
		FractalParams params = parser.readFractal(argumentParser.getStringArgument('f'));
		Database* database;
		int hardwareConcurrency = std::thread::hardware_concurrency();
		if (hardwareConcurrency == 0) {
			hardwareConcurrency = 1;
		}
		int numberOfThreads = argumentParser.getIntArgumentOrReturnDefault('t', hardwareConcurrency);
		bool saveTemporaryResult = !argumentParser.isArgumentPresent('s');
		std::cout << "Number of threads: " << numberOfThreads << std::endl;
		if (argumentParser.isArgumentPresent('b')) {
			database = new Database();
		} else {
			database = new Database(argumentParser.getStringArgumentOrReturnDefault('d', "points.ff"));
		}
		ValueProvider* valueProvider = new ValueProvider(database, params, numberOfThreads);
		valueProvider->setIterationCountToConsiderInteresting(argumentParser.getIntArgumentOrReturnDefault('i', 100));
		if (argumentParser.isArgumentPresent('o')) {
			valueProvider->setReadOnlyFile(true);
		}
		if (argumentParser.isArgumentPresent('b')) {
			valueProvider->setNoDb(true);
		}
		for (double d = params.startPower; d <= params.endPower; d+= params.increment) {
			valueProvider->deleteSavedValues();
			Fractal fractal(valueProvider, params);
			fractal.draw(d, numberOfThreads, saveTemporaryResult);
		}
		delete database;
		delete valueProvider;
	} catch(const GeneralException& ex) {
		std::cout << "Exception occured: " << ex.what() << std::endl;
		return -1;
	}
	return 0;
}
开发者ID:helospark,项目名称:buddhabrot,代码行数:55,代码来源:main.cpp

示例5: main

int main(int argc, char** argv)
{
   bool daemon = true;
   char *ip = 0, *dest = 0;
   int opt, port = 0;
   while((opt = getopt(argc, argv, "hi:p:d:f")) != -1)
   {
      switch(opt)
      {
         case 'i':
            ip = strdup(optarg);
            break;
         case 'p':
            port = atoi(optarg);
            break;
         case 'd':
            dest = strdup(optarg);
            break;
         case 'h':
            showUsage();
            return 0;
            break;
         case 'f':
            daemon = false;
            break;
         case '?':
            showUsage();
            return 0;
            break;
      }
   }

   if((! port) || (! dest))
   {
      showUsage();
      return 1;
   }

   syslog(LOG_INFO, "Routing: %s:%d to: %s", (ip ? ip : "ALL"), port, dest);

   try
   {
      IpAddress ipAddr(ip, port);
      IpAddress destAddr(dest);
      SnmpRouted server(ipAddr, destAddr, daemon);
      syslog(LOG_INFO, "Started");
      server.run();
   }
   catch(NetErr& e)
   {
      syslog(LOG_ERR, "Exception %s", e.errm);
   }

   return 0;
}
开发者ID:jortel,项目名称:libs,代码行数:55,代码来源:snmpRouted.cpp

示例6: invalidArgs

bool invalidArgs(int argc, char *argv[]) {
    if (argc < 2 || argc > 3) {
        fprintf(stderr, "Erro! Quantidade invalida de argumentos.\n");
        showUsage();
        return true;
    }
    if (strcmp(argv[1], "-S") != 0 && strcmp(argv[1], "host") != 0) {
        fprintf(stderr, "Erro! Argumento invalido: %s\n", argv[1]);
        showUsage();
        return true;
    }
    return false;
}
开发者ID:gabrielnaves,项目名称:TD_Final_01_2016,代码行数:13,代码来源:main.c

示例7: parseArguments

static void parseArguments(int argc, char **argv)
{
  int i;

  programName = argv[0];

  /* Check for existence of at least the filename argument */

  if (argc < 2)
    {
      fprintf(stderr, "Invalid number of arguments\n");
      showUsage(); 
    }

  /* Parse any optional command line arguments */

  for (i = 1; i < argc-1; i++)
    {
      char *ptr = argv[i];
      if (ptr[0] == '-')
        {
          switch (ptr[1])
            {
            case 'I' :
              if (nIncPathes >= MAX_INCPATHES)
                {
                  fprintf(stderr, "Unrecognized [option]\n");
                  showUsage(); 
                }
              else
                {
                  includePath[nIncPathes] = &ptr[2];
                  nIncPathes++;
                }
              break;
            default:
              fprintf(stderr, "Unrecognized [option]\n");
              showUsage(); 
            }
        }
      else
        {
          fprintf(stderr, "Unrecognized [option]\n");
          showUsage(); 
        }
    }

  /* Extract the Pascal program name from the command line */

  sourceFileName = argv[argc-1];
}
开发者ID:0919061,项目名称:PX4NuttX,代码行数:51,代码来源:pas.c

示例8: parseCommandLine

/** \brief parse legacy nfd-status command line, and show usage if necessary
 *  \return if first item is -1, caller should retrieve and display StatusReport;
 *          otherwise, caller should immediately exit with the specified exit code
 */
static std::tuple<int, StatusReportOptions>
parseCommandLine(const std::vector<std::string>& args)
{
  StatusReportOptions options;

  namespace po = boost::program_options;
  po::options_description cmdOptions("StatusReportOptions");
  cmdOptions.add_options()
    ("help,h", "print this help message")
    ("version,V", "show program version")
    ("general,v", po::bool_switch(&options.wantForwarderGeneral), "show general status")
    ("channels,c", po::bool_switch(&options.wantChannels), "show channels")
    ("faces,f", po::bool_switch(&options.wantFaces), "show faces")
    ("fib,b", po::bool_switch(&options.wantFib), "show FIB entries")
    ("rib,r", po::bool_switch(&options.wantRib), "show RIB routes")
    ("sc,s", po::bool_switch(&options.wantStrategyChoice), "show strategy choice entries")
    ("xml,x", "output as XML instead of text (implies -vcfbrs)");
  po::variables_map vm;
  try {
    po::store(po::command_line_parser(args).options(cmdOptions).run(), vm);
    po::notify(vm);
  }
  catch (const po::error& e) {
    std::cerr << e.what() << "\n";
    showUsage(std::cerr, cmdOptions);
    return std::make_tuple(2, options);
  }

  if (vm.count("help") > 0) {
    showUsage(std::cout, cmdOptions);
    return std::make_tuple(0, options);
  }
  if (vm.count("version") > 0) {
    std::cout << "nfd-status " << NFD_VERSION_BUILD_STRING << "\n";
    return std::make_tuple(0, options);
  }

  if (vm.count("xml") > 0) {
    options.output = ReportFormat::XML;
  }
  if (options.output == ReportFormat::XML ||
      (!options.wantForwarderGeneral && !options.wantChannels && !options.wantFaces &&
       !options.wantFib && !options.wantRib && !options.wantStrategyChoice)) {
    options.wantForwarderGeneral = options.wantChannels = options.wantFaces =
      options.wantFib = options.wantRib = options.wantStrategyChoice = true;
  }

  return std::make_tuple(-1, options);
}
开发者ID:named-data-ndnSIM,项目名称:NFD,代码行数:53,代码来源:legacy-status.cpp

示例9: parseArguments

void parseArguments(const std::list<std::string>& args)
{
    std::list<std::string>::const_iterator i;

    // Set up defaults
    options.verbose = false;
    options.minTime = 1;
    options.bitsPerPixel = 16;
    options.listTests = false;

    for (i = args.begin(), i++; i != args.end(); ++i)
    {
        if (*i == "-h" || *i == "--help")
        {
            showUsage();
            exit(0);
        }
        else if (*i == "-i" && ++i != args.end())
        {
            options.includedTests.push_back(*i);
        }
        else if (*i == "-e" && ++i != args.end())
        {
            options.excludedTests.push_back(*i);
        }
        else if (*i == "-t" && ++i != args.end())
        {
            options.minTime = atoi((*i).c_str());
        }
        else if (*i == "-b" && ++i != args.end())
        {
            options.bitsPerPixel = atoi((*i).c_str());
        }
        else if (*i == "-v")
        {
            options.verbose = true;
        }
        else if (*i == "-l")
        {
            options.listTests = true;
        }
        else
        {
            std::cerr << "Invalid option: " << *i << std::endl;
            showUsage();
            exit(1);
        }
    }
}
开发者ID:akallabeth,项目名称:glmemperf,代码行数:49,代码来源:runner_cli.cpp

示例10: main

int main(int argc,char** argv)
{
    /*
    arg1 : ID
    */
    if(argc < 2)
    {
        showUsage();
        exit(0);
    }

    pairing_t pairing;
    element_t s,Sa,Qa;
    pairing_from_file(pairing,"globalParam/pairingParam");
    element_init_G1(Sa,pairing);
    element_init_G1(Qa,pairing);
    element_init_Zr(s,pairing);

    element_from_file(s,"masterKey/s");
    element_from_hash(Qa,argv[1],strlen(argv[1]));
    element_mul_zn(Sa,Qa,s);

    char loc[100] = "privateKey/";
    strcat(loc,argv[1]);
    strcat(loc,".priv");
    element_to_file(Sa,loc);

    return 0;
}
开发者ID:pigeon119,项目名称:LabProjects,代码行数:29,代码来源:extract.cpp

示例11: parseArguments

/*!
 * @brief コマンドライン引数の解析を行う
 *
 * 引数argvのうち、オプションに関係しないものは、後ろに並び替えられる。
 * その開始インデックスを返り値とする
 * @param [in]     argc      コマンドライン引数の数
 * @param [in,out] argv      コマンドライン引数
 * @param [out]    lang      音声合成の言語
 * @param [out]    filename  出力ファイル名
 * @return  残った引数のインデックス
 */
static int parseArguments(
    int          argc,
    char        *argv[],
    std::string &lang,
    std::string &filename)
{
  static const struct option opts[] = {
    {"help",     no_argument,       NULL, 'h'},
    {"language", required_argument, NULL, 'l'},
    {"output",   required_argument, NULL, 'o'},
    {0, 0, 0, 0}   // must be filled with zero
  };

  int ret;
  int optidx;
  while ((ret = getopt_long(argc, argv, "hl:o:", opts, &optidx)) != -1) {
    switch (ret) {
      case 'h':  // -h or --help
        showUsage(argv[0], EXIT_SUCCESS);
        break;
      case 'l':  // -l or --language
        lang = optarg;
        break;
      case 'o':  // -o or --output
        filename = optarg;
        break;
    }
  }
  return optind;
}
开发者ID:koturn,项目名称:sayss,代码行数:41,代码来源:sayss.cpp

示例12: parse_arg

void parse_arg( int argc, char * argv[] )
{
	extern char *optarg ;
	int c ;

	while( ( c = getopt ( argc, argv, "h:p:c:m:w:s:v" )) != EOF ) {
		switch ( c ) {
			case 'h' :
				gHost = optarg;
				break;
			case 'p':
				gPort = atoi( optarg );
				break;
			case 'c' :
				gClients = atoi ( optarg );
				break;
			case 'm' :
				gMsgs = atoi( optarg );
				break;
			case 'w':
				gConnWait = atoi( optarg );
				break;
			case 's':
				gSockWait = atoi( optarg );
				break;
			case 'v' :
			case '?' :
				showUsage( argv[0] );
				exit( 0 );
		}
	}
}
开发者ID:CCoder123,项目名称:pproj,代码行数:32,代码来源:teststress.cpp

示例13: main

int main(int argc, char **argv) {
	if (argc != 3) {
		showUsage();
		return 1;
	}

	int securityLevel = atoi(argv[1]);
	string rngSeed(argv[2]);
	size_t rngSeedLength = 16;

	string fullLine;
	string line;
	while (getline(cin, line)) {
		fullLine.append(line);
	}
	byte *inputData = (byte *) fullLine.data();
	int inputLength = fullLine.length();

	RegisterFactories();
	rngSeed.resize(rngSeedLength);
	s_globalRNG.SetKeyWithIV((byte *)rngSeed.data(), rngSeedLength, (byte *)rngSeed.data());

	int securityIndex = 0;
	for (int i = 0; i < NUMBER_OF_SECURITY_LENGTHS; i++) {
		if (securityLevels[i] == securityLevel) {
			securityIndex = i;
			break;
		}
	}
	
	ProfileSignatureSchemes(inputData, inputLength, securityIndex);
}
开发者ID:chris-wood,项目名称:SignatureVerification,代码行数:32,代码来源:verifier.cpp

示例14: useCommandLine

// Return the image specified on the command line.
//
static cv::Mat useCommandLine(int ac, const char *av[])
{
    cv::Mat result;
    if (ac == 2) result = cv::imread(av[1]);
    if (!result.data) showUsage(av[0]);
    return result;
}
开发者ID:tbl3rd,项目名称:opencv-tutorials,代码行数:9,代码来源:brightContrast.cpp

示例15: cmdargParse

void
cmdargParse(const char **argv)
{
    argv0 = argv[0];
    for (argv++; *argv != NULL; argv++) {
	if ((*argv)[0] == '-') {
	    switch ((*argv)[1]) {
	    case 'c': /* -c <commx args>*/
		cmdarg.ttymode = CA_COMMX;
		cmdarg.commx = *++argv;
		if (cmdarg.commx == NULL) goto FEWARG;
		break;
	    case 'd': /* -d <pty_device>*/
		cmdarg.ttymode = CA_DEVGIVEN;
		cmdarg.dev = *++argv;
		if (cmdarg.dev == NULL) goto FEWARG;
		break;
	    case 'e': /* -e <atcommands>*/
		cmdarg.atcmd = *++argv;
		if (cmdarg.atcmd == NULL) goto FEWARG;
		break;
	    case 'h': /* -h */
		showUsage();
		exit(0);
	    case 's': /* -s */
		cmdarg.ttymode = CA_SHOWDEV;
		break;
	    case '\0': /* - */
		cmdarg.ttymode = CA_STDINOUT;
		break;
	    default:
		fprintf(stderr, "Unknown option -%c.\n", (*argv)[1]);
		showUsage();
		exit(1);
	    }
	} else {
	    fprintf(stderr, "Error in command line.\n");
	    showUsage();
	    exit(1);
	}
    }
    return;

 FEWARG:
    fprintf(stderr, "'-%c' requires an argument.\n", (*--argv)[1]);
    exit(1);
}
开发者ID:andrewbird,项目名称:dosemu2,代码行数:47,代码来源:cmdarg.c


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