本文整理汇总了C++中CommandLineOptions类的典型用法代码示例。如果您正苦于以下问题:C++ CommandLineOptions类的具体用法?C++ CommandLineOptions怎么用?C++ CommandLineOptions使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CommandLineOptions类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: hash
//****************************************************************************
ErrorCode MD5UtilCore::processDigest (const CommandLineOptions& options, std::string& output) {
if (options.getHelpMode ()) {
std::cout << MSG_DIGEST_HELP << std::endl;
return ErrorCode::NONE;
}
if (options.getInputText ().length () == 0) {
return ErrorCode::DIGEST_USAGE_ERROR;
}
output = hash (options.getInputText ());
if (options.getOutputFilename ().length () != 0) {
if (!saveToFile (options.getOutputFilename (), output)) {
return ErrorCode::FILE_WRITE_ERROR;
}
}
return ErrorCode::NONE;
}
示例2: log_info
void
PingusMain::read_rc_file (void)
{
if (!cmd_options.no_config_file.is_set() ||
!cmd_options.no_config_file.get())
{
std::string filename = System::get_userdir() + "config";
if (!System::exist(filename))
{
log_info(filename << ": config file not found");
}
else
{
try
{
CommandLineOptions options;
options.merge(Options::from_file(Pathname(filename, Pathname::SYSTEM_PATH)));
options.merge(cmd_options);
cmd_options = options;
}
catch(const std::exception& err)
{
log_error(err.what());
}
}
}
}
示例3: main
int main( int argc, const char *argv[] )
{
CommandLineOptions opt;
opt.define<bool>("usage", 'u', "", "Print usage.");
opt.define<bool>("help", 'h', "", "Print usage and options.");
opt.define<bool>("realtime", 'r', "", "Use real-time thread priority.");
opt.define<int>("count", 'N', "<number>", "Perform <number> amount of ticks.");
opt.define<mrs_real>("samplerate", 's', "<number>", "Override sampling rate.");
opt.define<mrs_natural>("block", 'b', "<samples>", "Block size in samples.");
opt.define<mrs_string>("controls", 'c', "definitions",
"A series of control definitions of form \"name=value:name=value:...\"");
opt.define<int>("OSC-receive", "<port>", "UDP port on which to receive OSC control messages.");
opt.define<mrs_string>("OSC-send", "<subscriptions>",
"Subscriptions for OSC control change notifications, of form: "
"\"host:port:control,control,...;host...\".");
if (!opt.readOptions(argc, argv))
return 1;
if (opt.value<bool>("usage"))
{
print_usage();
return 0;
}
if (opt.value<bool>("help"))
{
print_help(opt);
return 0;
}
const vector<string> & arguments = opt.getRemaining();
if (arguments.size() < 1)
{
print_usage();
return 0;
}
string system_filename = arguments[0];
MarSystem *system = load_network(system_filename);
if (!system) {
cerr << "Could not load network definition file: "
<< system_filename << endl;
return 1;
}
int error = apply_control_options(system, opt);
if (error)
return error;
return run(system, opt);
}
示例4:
//****************************************************************************
bool MD5UtilCore::findCollision (const CommandLineOptions& options, std::string& output) {
bool solutionFound = false;
unsigned int threadCount = 1;
std::thread* threads = nullptr;
std::string* threadOutputs = nullptr;
if (options.getThreadCount () > 1) {
threadCount = options.getThreadCount ();
}
// Create threads.
threads = new std::thread[threadCount];
threadOutputs = new std::string[threadCount];
for (unsigned int i = 0; i < threadCount; i++) {
threads[i] = std::thread (&MD5UtilCore::checkCollisionRange, std::ref (options), std::ref (solutionFound), std::ref (threadOutputs[i]), i);
}
// Wait for threads.
for (unsigned int j = 0; j < threadCount; j++) {
threads[j].join ();
}
// Get solution.
if (solutionFound) {
for (unsigned int k = 0; k < threadCount; k++) {
if (threadOutputs[k].length () != 0) {
output = threadOutputs[k];
break;
}
}
}
// Reclaim memory.
delete[]threadOutputs;
delete[] threads;
return solutionFound;
}
示例5: MRSDIAG
int
main(int argc, const char **argv)
{
MRSDIAG("recvUDP.cpp - main");
string progName = argv[0];
progName = progName.erase(0,3);
initOptions();
cmd_options.readOptions(argc, argv);
loadOptions();
vector<string> soundfiles = cmd_options.getRemaining();
vector<string>::iterator sfi;
if (helpopt)
printHelp(progName);
if (usageopt)
printUsage(progName);
for (sfi = soundfiles.begin(); sfi != soundfiles.end(); ++sfi)
play(gain, *sfi);
exit(1);
}
示例6: MRSDIAG
int
main(int argc, const char **argv)
{
MRSDIAG("carfac_testing.cpp - main");
string progName = argv[0];
if (argc == 1)
printUsage(progName);
// handling of command-line options
initOptions();
cmd_options.readOptions(argc, argv);
loadOptions();
vector<string> files = cmd_options.getRemaining();
if (helpopt_)
printHelp(progName);
if (usageopt_)
printUsage(progName);
carfac_testing(files[0]);
exit(0);
}
示例7:
int
main(int argc, const char **argv)
{
MRSDIAG("speakerSeg.cpp - main");
string progName = argv[0];
if (argc == 1)
printUsage(progName);
// handling of command-line options
initOptions();
cmd_options.readOptions(argc, argv);
loadOptions();
vector<string> soundfiles = cmd_options.getRemaining();
if (helpopt)
printHelp(progName);
if (usageopt)
printUsage(progName);
// play the soundfiles/collections
speakerSeg(soundfiles);
exit(0);
}
示例8: Sfname
int
main(int argc, const char **argv)
{
initOptions();
cmd_options.readOptions(argc, argv);
loadOptions();
vector<string> soundfiles = cmd_options.getRemaining();
vector<string>::iterator sfi;
cout << "vocalEffort Marsyas implementation" << endl;
cout<<"LPC and LSP order: " <<lpcOrder <<endl;
cout<<"hopSize: " <<hopSize <<endl;
for (sfi=soundfiles.begin() ; sfi!=soundfiles.end() ; sfi++)
{
cout << "Sound to analyze: " << *sfi << endl;
FileName Sfname(*sfi);
outName = outputDirectory + "/" + Sfname.name();
process(*sfi, outName);
}
cout << endl << "LPC and LSP processing finished!";
}
示例9:
void
loadOptions()
{
helpopt = cmd_options.getBoolOption("help");
usageopt = cmd_options.getBoolOption("usage");
verboseopt = cmd_options.getBoolOption("verbose");
pluginName = cmd_options.getStringOption("classifier");
}
示例10:
void
loadOptions()
{
helpopt = cmd_options.getBoolOption("help");
usageopt = cmd_options.getBoolOption("usage");
verboseopt = cmd_options.getBoolOption("verbose");
toy_with = cmd_options.getStringOption("toy_with");
}
示例11:
void
loadOptions()
{
helpopt = cmd_options.getBoolOption("help");
usageopt = cmd_options.getBoolOption("usage");
gain = cmd_options.getRealOption("gain");
port = cmd_options.getNaturalOption("port");
}
示例12: if
int
main(int argc, const char **argv)
{
string progName = argv[0];
if (argc == 1)
printUsage(progName);
// handling of command-line options
initOptions();
cmd_options.readOptions(argc, argv);
loadOptions();
vector<string> soundfiles = cmd_options.getRemaining();
string fname0 = EMPTYSTRING;
string fname1 = EMPTYSTRING;
string fname2 = EMPTYSTRING;
string fname3 = EMPTYSTRING;
string fname4 = EMPTYSTRING;
string fname5 = EMPTYSTRING;
if (soundfiles.size() > 0)
fname0 = soundfiles[0];
if (soundfiles.size() > 1)
fname1 = soundfiles[1];
if (soundfiles.size() > 2)
fname2 = soundfiles[2];
if (soundfiles.size() > 3)
fname3 = soundfiles[3];
if (soundfiles.size() > 4)
fname4 = soundfiles[4];
if (soundfiles.size() > 5)
fname5 = soundfiles[5];
cout << "Marsyas toy_with name = " << toy_with << endl;
cout << "fname0 = " << fname0 << endl;
cout << "fname1 = " << fname1 << endl;
if (toy_with == "null")
toy_with_null(fname0);
else if (toy_with == "harmonics")
toy_with_harmonicStrength(fname0);
else if (toy_with == "spectral_single")
toy_with_spectral_single(fname0);
else if (toy_with == "csv_input")
toy_with_csv_input(fname0);
else if (toy_with == "arff_in_out")
toy_with_arff_in_out(fname0, fname1);
else if (toy_with == "mel")
toy_with_mel(fname0);
else
{
cout << "Unsupported toy_with " << endl;
printHelp(progName);
}
}
示例13:
void
initOptions()
{
cmd_options.addBoolOption("help", "h", false);
cmd_options.addBoolOption("usage", "u", false);
cmd_options.addStringOption("filename", "f", EMPTYSTRING);
cmd_options.addRealOption("gain", "g", 1.0);
cmd_options.addNaturalOption("port", "p", 0);
}
示例14:
void
loadOptions()
{
helpopt = cmd_options.getBoolOption("help");
usageopt = cmd_options.getBoolOption("usage");
collectionName = cmd_options.getStringOption("collectionName");
labelopt = cmd_options.getStringOption("label");
marsyas_datadir_opt = cmd_options.getBoolOption("marsyasdatadir");
}
示例15: MRSDIAG
int
main(int argc, const char **argv)
{
MRSDIAG("record.cpp - main");
string progName = argv[0];
if (argc == 1)
printUsage(progName);
// read command-line options
initOptions();
cmd_options.readOptions(argc, argv);
loadOptions();
if (helpopt)
printHelp(progName);
if (usageopt)
printUsage(progName);
int i;
i =0;
vector<string> soundfiles = cmd_options.getRemaining();
vector<string>::iterator sfi;
/*
cout << "Recording to year" << yearopt << endl;
string id1;
string id2;
string id3;
string id4;
id1 = soundfiles[0];
id2 = soundfiles[1];
id3 = soundfiles[2];
id4 = soundfiles[3];
xrecord_orcas(lengthopt, yearopt, id1, id2, id3, id4);
*/
for (sfi = soundfiles.begin(); sfi != soundfiles.end(); ++sfi)
{
cout << "Recording " << lengthopt << " seconds to file " << *sfi << endl;
record(lengthopt,gopt, *sfi);
}
exit(0);
}