本文整理汇总了C++中AnyOption::printUsage方法的典型用法代码示例。如果您正苦于以下问题:C++ AnyOption::printUsage方法的具体用法?C++ AnyOption::printUsage怎么用?C++ AnyOption::printUsage使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AnyOption
的用法示例。
在下文中一共展示了AnyOption::printUsage方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: readoption
void readoption(int argc, char *argv[], bool *convertDir,
QString *filename, QString *dir, QString *path)
{
/* 1. CREATE AN OBJECT */
AnyOption *opt = new AnyOption();
/* 2. SET PREFERENCES */
//opt->noPOSIX(); /* do not check for POSIX style character options */
//opt->setVerbose(); /* print warnings about unknown options */
//opt->autoUsagePrint(true); /* print usage for bad options */
/* 3. SET THE USAGE/HELP */
opt->addUsage( "" );
opt->addUsage( "Usage: " );
opt->addUsage( "" );
opt->addUsage( " -h --help Prints this help " );
opt->addUsage( " -f --filename FILENAME Filename to be converted " );
opt->addUsage( " -d --dir DIRECTORY File dir to be converted " );
opt->addUsage( " -p --path PATH Path where converted file saves " );
opt->addUsage( "" );
/* 4. SET THE OPTION STRINGS/CHARACTERS */
/* by default all options will be checked on the command line and from option/resource file */
opt->setFlag( "help", 'h' ); /* a flag (takes no argument), supporting long and short form */
opt->setOption( "filename", 'f' ); /* an option (takes an argument), supporting long and short form */
opt->setOption( "dir", 'd' ); /* an option (takes an argument), supporting long and short form */
opt->setOption( "path", 'p' ); /* an option (takes an argument), supporting long and short form */
/* 5. PROCESS THE COMMANDLINE AND RESOURCE FILE */
/* go through the command line and get the options */
opt->processCommandArgs( argc, argv );
if( ! opt->hasOptions()) { /* print usage if no options */
opt->printUsage();
delete opt;
return;
}
/* 6. GET THE VALUES */
if( opt->getFlag( "help" ) || opt->getFlag( 'h' ) )
opt->printUsage();
if( opt->getValue( 'f' ) != NULL || opt->getValue( "filename" ) != NULL ) {
*convertDir = false;
filename->append(QString(opt->getValue( 'f' )));
}
if( opt->getValue( 'd' ) != NULL || opt->getValue( "dir" ) != NULL ) {
*convertDir = true;
dir->append(QString(opt->getValue( 'd' )));
}
if( opt->getValue( 'p' ) != NULL || opt->getValue( "path" ) != NULL ) {
path->append(QString(opt->getValue( 'p' )));
}
/* 8. DONE */
delete opt;
}
示例2: main
/**
* @brief Read in files with arrays and join them into a single file
* @param argc
* @param argv[]
* @return
*/
int main (int argc, char *argv[]) {
AnyOption opt;
opt.setFlag ("help", 'h'); /* a flag (takes no argument), supporting long and short form */
opt.setOption ("verbose", 'v');
opt.setOption ("random", 'r');
opt.addUsage ("OA: unittest: Perform some checks on the code");
opt.addUsage ("Usage: unittest [OPTIONS]");
opt.addUsage ("");
opt.addUsage (" -v --verbose Print documentation");
opt.addUsage (" -r --random Seed for random number generator");
opt.processCommandArgs (argc, argv);
int verbose = opt.getIntValue ('v', 1);
int random = opt.getIntValue ('r', 0);
if (opt.getFlag ("help") || opt.getFlag ('h')) {
opt.printUsage ();
exit (0);
}
if (verbose) {
print_copyright ();
}
if (verbose >= 2) {
print_options (std::cout);
}
oaunittest (verbose, 1, random);
return 0;
}
示例3: main
/**
* @brief Read in files with arrays and join them into a single file
* @param argc
* @param argv[]
* @return
*/
int main (int argc, char *argv[]) {
AnyOption opt;
/* parse command line options */
opt.setFlag ("help", 'h'); /* a flag (takes no argument), supporting long and short form */
opt.setOption ("output", 'o');
opt.setOption ("format", 'f');
opt.setOption ("verbose", 'v');
opt.addUsage ("Orthonal Array Convert: convert array file into a different format");
opt.addUsage ("Usage: oaconvert [OPTIONS] [INPUTFILE] [OUTPUTFILE]");
opt.addUsage ("");
opt.addUsage (" -h --help Prints this help ");
opt.addUsage (" -f [FORMAT] Output format (default: TEXT, or BINARY) ");
opt.processCommandArgs (argc, argv);
int verbose = opt.getIntValue ("verbose", 2);
if (verbose > 0)
print_copyright ();
/* parse options */
if (opt.getFlag ("help") || opt.getFlag ('h') || opt.getArgc () == 0) {
opt.printUsage ();
exit (0);
}
const std::string outputprefix = opt.getStringValue ('o', "");
std::string format = opt.getStringValue ('f', "BINARY");
arrayfile::arrayfilemode_t mode = arrayfile_t::parseModeString (format);
if (opt.getArgc () != 2) {
opt.printUsage ();
exit (0);
}
std::string infile = opt.getArgv (0);
std::string outfile = opt.getArgv (1);
convert_array_file(infile, outfile, mode, verbose);
return 0;
}
示例4: main
int main(int argc, char* argv[])
{
AnyOption opt;
// Usage
opt.addUsage( "Example: " );
opt.addUsage( " cppbitmessage -p 8444" );
opt.addUsage( " " );
opt.addUsage( "Usage: " );
opt.addUsage( "" );
opt.addUsage( " -p --port Port to listen on");
opt.addUsage( " -V --version Show version number");
opt.addUsage( " --help Show help");
opt.addUsage( "" );
opt.setOption( "port", 'p' );
opt.setFlag( "version", 'V' );
opt.setFlag( "help" );
opt.processCommandArgs(argc, argv);
if ((!opt.hasOptions()) || (opt.getFlag( "help" )))
{
// print usage if no options
opt.printUsage();
return 0;
}
if ((opt.getFlag("version")) || (opt.getFlag('V')))
{
std::cout << "Version " << VERSION << std::endl;
return 0;
}
int port = 8444;
if ((opt.getValue("port") != NULL) || (opt.getValue('p')))
{
std::stringstream ss;
ss << opt.getValue("port");
ss >> port;
}
示例5: main
int main(int argc, char** argv)
{
int ret = EXIT_SUCCESS;
// Setup default error handling strategy.
// ...
// Setup the default log stream.
Log logger;
LogSetDefault(&logger);
// Setup the command line handling.
AnyOption options;
// Use this to active debug mode.
options.setFlag("debug", 'd');
options.setVerbose();
options.autoUsagePrint(true);
// Process the command line arguments.
options.processCommandArgs(argc, argv);
String file;
ret = ValidateOptions(options, file);
if( ret != EXIT_SUCCESS )
{
options.printUsage();
return ret;
}
Runtime runtime;
runtime.init();
runtime.shutdown();
return ret;
}
示例6: main
/**
* @brief Read in a list of array and check for each of the arrays whether they are in LMC form or not
* @param argc
* @param argv[]
* @return
*/
int main (int argc, char *argv[]) {
char *fname;
int correct = 0, wrong = 0;
/* parse command line options */
AnyOption opt;
opt.setFlag ("help", 'h'); /* a flag (takes no argument), supporting long and short form */
opt.setOption ("loglevel", 'l');
opt.setOption ("oaconfig", 'c');
opt.setOption ("check");
opt.setOption ("strength", 's');
opt.setOption ("prune", 'p');
opt.setOption ("output", 'o');
opt.setOption ("mode", 'm');
opt.addUsage ("oacheck: Check arrays for LMC form or reduce to LMC form");
opt.addUsage ("Usage: oacheck [OPTIONS] [ARRAYFILE]");
opt.addUsage ("");
opt.addUsage (" -h --help Prints this help");
opt.addUsage (" -l [LEVEL] --loglevel [LEVEL] Set loglevel to number");
opt.addUsage (" -s [STRENGTH] --strength [STRENGTH] Set strength to use in checking");
std::string ss = " --check [MODE] Select mode: ";
ss +=
printfstring ("%d (default: check ), %d (reduce to LMC form), %d (apply random transformation and reduce)",
MODE_CHECK, MODE_REDUCE, MODE_REDUCERANDOM); //
for (int i = 3; i < ncheckopts; ++i)
ss += printfstring (", %d (%s)", static_cast< checkmode_t > (i), modeString ((checkmode_t)i).c_str ());
opt.addUsage (ss.c_str ());
opt.addUsage (" -o [OUTPUTFILE] Output file for LMC reduction");
opt.processCommandArgs (argc, argv);
algorithm_t algmethod = (algorithm_t)opt.getIntValue ("mode", MODE_AUTOSELECT);
int loglevel = NORMAL;
if (opt.getValue ("loglevel") != NULL || opt.getValue ('l') != NULL)
loglevel = atoi (opt.getValue ('l')); // set custom loglevel
setloglevel (loglevel);
if (checkloglevel (QUIET)) {
print_copyright ();
}
if (opt.getFlag ("help") || opt.getFlag ('h') || opt.getArgc () == 0) {
opt.printUsage ();
return 0;
}
checkmode_t mode = MODE_CHECK;
if (opt.getValue ("check") != NULL)
mode = (checkmode_t)atoi (opt.getValue ("check")); // set custom loglevel
if (mode >= ncheckopts)
mode = MODE_CHECK;
logstream (QUIET) << "#time start: " << currenttime () << std::endl;
double t = get_time_ms ();
t = 1e3 * (t - floor (t));
srand (t);
int prune = opt.getIntValue ('p', 0);
fname = opt.getArgv (0);
setloglevel (loglevel);
int strength = opt.getIntValue ('s', 2);
if (strength < 1 || strength > 10) {
printf ("Strength specfied (t=%d) is invalid\n", strength);
exit (1);
} else {
log_print (NORMAL, "Using strength %d to increase speed of checking arrays\n", strength);
}
arraylist_t outputlist;
char *outputfile = 0;
bool writeoutput = false;
if (opt.getValue ("output") != NULL) {
writeoutput = true;
outputfile = opt.getValue ('o');
}
arrayfile_t *afile = new arrayfile_t (fname);
if (!afile->isopen ()) {
printf ("Problem opening %s\n", fname);
exit (1);
}
logstream (NORMAL) << "Check mode: " << mode << " (" << modeString (mode) << ")" << endl;
/* start checking */
double Tstart = get_time_ms (), dt;
int index;
array_link al (afile->nrows, afile->ncols, -1);
//.........这里部分代码省略.........
示例7: main
int main(int argc, char **argv)
{
AnyOption *opt = new AnyOption();
opt->addUsage("");
opt->addUsage("Usage: ");
opt->addUsage("");
opt->addUsage(" -h --help Print usage ");
opt->addUsage(" -L --subsecLet Letter of Subsector (A-P) to generate, if omitted will generate entire sector ");
opt->addUsage(" -d --detail %|zero|rift|sparse|scattered|dense ");
opt->addUsage(" -m --maturity Tech level, backwater|frontier|mature|cluster ");
opt->addUsage(" -a --ac Two-letter system alignment code ");
opt->addUsage(" -s --secName Name of sector. For default output file name and sectorName_names.txt file");
opt->addUsage(" -p --path Path to sectorName_names.txt file ");
opt->addUsage(" -o --outFormat 1|2|3|4|5|6 : v1.0, v2.0, v2.1 v2.1b, v2.2, v2.5 ");
opt->addUsage(" -u --outPath Path and name of output file ");
opt->addUsage("");
opt->setCommandFlag("main", 'm');
opt->setCommandFlag("system", 'S');
opt->setCommandFlag("sector", 's');
opt->setCommandFlag("subsector", 'u');
opt->setCommandFlag("help", 'h');
opt->setCommandOption("", 'x');
opt->setCommandOption("", 'y');
opt->setCommandOption("", 'z');
opt->setCommandOption("detail", 'd');
opt->setCommandOption("seed");
//opt->setVerbose(); /* print warnings about unknown options */
//opt->autoUsagePrint(true); /* print usage for bad options */
opt->processCommandArgs(argc, argv);
#if 0
if(! opt->hasOptions()) { /* print usage if no options */
opt->printUsage();
delete opt;
return 0;
}
#endif
if(opt->getFlag("help") || opt->getFlag('h')) {
opt->printUsage();
delete opt;
return 0;
}
//long seed = 12345;
long x = 0;
long y = 10;
long z = 0;
int detail = 3;
if(opt->getValue('x') != NULL) {
x = atol(opt->getValue('x'));
}
if(opt->getValue('y') != NULL) {
y = atol(opt->getValue('y'));
}
if(opt->getValue('z') != NULL) {
z = atol(opt->getValue('z'));
}
if(opt->getValue("seed") != NULL) {
//seed = atol(opt->getValue("seed"));
}
if(opt->getValue("detail") != NULL) {
detail = atol(opt->getValue("detail"));
}
long startX, startY, startZ;
long endX, endY, endZ;
long sectorX = 8 * 4;
long sectorY = 10 * 4;
long sectorZ = 1;
if(opt->getFlag("sector")) {
startX = x / sectorX;
endX = startX + sectorX - 1;
startY = y / sectorY;
endY = startY + sectorY - 1;
startZ = z / sectorZ;
endZ = startZ + sectorZ - 1;
} else {
startX = x;
endX = x;
startY = y;
endY = y;
startZ = z;
endZ = z;
}
for(int i = startX; i <= endX; i++) {
for(int j = startY; j <= endY; j++) {
for(int k = startZ; k <= endZ; k++) {
printSystem(x, y, z, detail);
}
}
}
}
示例8: pfs
//+----------------------------------------------------------------------------+
//| main() |
//-----------------------------------------------------------------------------+
int
main(int argc, char** argv)
{
common::PathFileString pfs(argv[0]);
//////////////////////////////////////////////////////////////////////////////
// User command line parser
AnyOption *opt = new AnyOption();
opt->autoUsagePrint(true);
opt->addUsage( "" );
opt->addUsage( "Usage: " );
char buff[256];
sprintf(buff, " Example: %s -r example1_noisy.cfg", pfs.getFileName().c_str());
opt->addUsage( buff );
opt->addUsage( " -h --help Prints this help" );
opt->addUsage( " -r --readfile <filename> Reads the polyhedra description file" );
opt->addUsage( " -t --gltopic <topic name> (opt) ROS Topic to send OpenGL commands " );
opt->addUsage( "" );
opt->setFlag( "help", 'h' );
opt->setOption( "readfile", 'r' );
opt->processCommandArgs( argc, argv );
if( opt->getFlag( "help" ) || opt->getFlag( 'h' ) ) {opt->printUsage(); delete opt; return(1);}
std::string gltopic("OpenGLRosComTopic");
if( opt->getValue( 't' ) != NULL || opt->getValue( "gltopic" ) != NULL ) gltopic = opt->getValue( 't' );
std::cerr << "[OpenGL communication topic is set to : \"" << gltopic << "\"]\n";
std::string readfile;
if( opt->getValue( 'r' ) != NULL || opt->getValue( "readfile" ) != NULL )
{
readfile = opt->getValue( 'r' );
std::cerr << "[ World description is read from \"" << readfile << "\"]\n";
}
else{opt->printUsage(); delete opt; return(-1);}
delete opt;
//
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
// Initialize ROS and OpenGLRosCom node (visualization)
std::cerr << "["<<pfs.getFileName()<<"]:" << "[Initializing ROS]"<< std::endl;
ros::init(argc, argv, pfs.getFileName().c_str());
if(ros::isInitialized())
std::cerr << "["<<pfs.getFileName()<<"]:" << "[Initializing ROS]:[OK]\n"<< std::endl;
else{
std::cerr << "["<<pfs.getFileName()<<"]:" << "[Initializing ROS]:[FAILED]\n"<< std::endl;
return(1);
}
COpenGLRosCom glNode;
glNode.CreateNode(gltopic);
//
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
// Reading the input file
std::cerr << "Reading the input file..." << std::endl;
ShapeVector shapes;
PoseVector poses;
IDVector ID;
if(ReadPolyhedraConfigFile(readfile, shapes, poses, ID)==false)
{
std::cerr << "["<<pfs.getFileName()<<"]:" << "Error reading file \"" << readfile << "\"\n";
return(-1);
}
std::cerr << "Read " << poses.size() << " poses of " << shapes.size() << " shapes with " << ID.size() << " IDs.\n";
//
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
// Visualizing the configuration of objects
std::cerr << "Visualizing the configuration of objects..." << std::endl;
for(unsigned int i=0; i<shapes.size(); i++)
{
for(size_t j=0; j<shapes[i].F.size(); j++)
{
glNode.LineWidth(1.0f);
glNode.AddColor3(0.3f, 0.6f, 0.5f);
glNode.AddBegin("LINE_LOOP");
for(size_t k=0; k<shapes[i].F[j].Idx.size(); k++)
{
int idx = shapes[i].F[j].Idx[k];
Eigen::Matrix<Real,3,1> Vt = poses[i]*shapes[i].V[ idx ];
glNode.AddVertex(Vt.x(), Vt.y(), Vt.z());
}
glNode.AddEnd();
}
}
glNode.SendCMDbuffer();
ros::spinOnce();
common::PressEnterToContinue();
//
//////////////////////////////////////////////////////////////////////////////
//.........这里部分代码省略.........
示例9: AnyOption
//.........这里部分代码省略.........
opt->addUsage( " R_start_km" );
opt->addUsage( "" );
opt->addUsage(" Additional parameters:" );
opt->addUsage( " --R_start_km The grid (viewing window) starts at R_start_km" );
opt->addUsage( " --width_km Grid width" );
opt->addUsage( " --max_celerity Reference speed [m/s]; in conjunction with R_start_km");
opt->addUsage( " it is determining where inside the grid the field is at");
opt->addUsage( " a time step; a value smaller than the speed of sound");
opt->addUsage( " at the ground is suggested." );
opt->addUsage( " --tmstep 2D pressure field is calculated at this specified time step." );
opt->addUsage( " --ntsteps Number of times the 2D pressure field is calculated");
opt->addUsage( " 'tmstep' seconds apart." );
opt->addUsage( "" );
opt->addUsage( " OPTIONAL [defaults]:" );
opt->addUsage( " --height_km The height of the 2D grid. [maximum height]" );
opt->addUsage( " --frame_file_stub Each 2D grid is saved into a file with the name");
opt->addUsage( " frame_file_stub_<time_of_start>; Default:[Pressure2D]." );
opt->addUsage( "" );
opt->addUsage( " Example: >> ../bin/ModBB --pulse_prop_grid mydispersionFolder --R_start_km 220 --width_km 50 --height_km 25 --max_celerity 300 --tmstep 30 --ntsteps 5 --frame_file_stub myPressure --use_builtin_pulse" );
opt->addUsage( "" );
*/
// Set up the actual flags, etc.
opt->setFlag( "help", 'h' );
opt->setFlag( "use_modess" );
opt->setFlag( "use_wmod" );
opt->setFlag( "get_impulse_resp" );
opt->setFlag( "use_builtin_pulse1" );
opt->setFlag( "use_builtin_pulse2" );
opt->setFlag( "turnoff_WKB");
opt->setFlag( "plot");
opt->setFlag( "use_zero_attn");
opt->setFlag( "wvnum_filter");
opt->setOption( "atmosfile" );
opt->setOption( "atmosfileorder" );
opt->setOption( "wind_units" );
opt->setOption( "skiplines" );
opt->setOption( "azimuth" );
opt->setOption( "maxrange_km" );
opt->setOption( "sourceheight_km" );
opt->setOption( "receiverheight_km" );
opt->setOption( "maxheight_km" );
opt->setOption( "zground_km" );
opt->setOption( "stepsize" );
opt->setOption( "Nz_grid" );
opt->setOption( "Nrng_steps" );
opt->setOption( "out_TL_2D" );
opt->setOption( "ground_impedance_model" );
opt->setOption( "Lamb_wave_BC" );
opt->setOption( "f_min" );
opt->setOption( "f_step" );
opt->setOption( "f_max" );
opt->setOption( "f_center" );
opt->setOption( "pulse_prop_grid" );
opt->setOption( "pulse_prop_src2rcv" );
opt->setOption( "pulse_prop_src2rcv_grid" );
opt->setOption( "R_start_km" );
opt->setOption( "R_end_km" );
opt->setOption( "DR_km" );
opt->setOption( "max_celerity" );
opt->setOption( "range_R_km" );
opt->setOption( "out_dispersion_files" );
opt->setOption( "out_disp_src2rcv_file" );
opt->setOption( "waveform_out_file" );
opt->setOption( "width_km" );
opt->setOption( "height_km" );
opt->setOption( "tmstep" );
opt->setOption( "ntsteps" );
opt->setOption( "frame_file_stub" );
opt->setOption( "disp_dirname" );
opt->setOption( "src_spectrum_file" );
opt->setOption( "src_waveform_file" );
opt->setOption( "nfft" );
opt->setOption( "use_attn_file" );
opt->setOption( "c_min" );
opt->setOption( "c_max" );
// Process the command-line arguments
opt->processFile( "./ModBB.options" );
opt->processCommandArgs( argc, argv );
if( ! opt->hasOptions()) { // print usage if no options
opt->printUsage();
delete opt;
exit( 1 );
}
// Check to see if help text was requested
if ( opt->getFlag( "help" ) || opt->getFlag( 'h' ) ) {
opt->printUsage();
exit( 1 );
}
return opt;
}
示例10: AnyOption
void
detailed( int argc, char* argv[] )
{
/* 1. CREATE AN OBJECT */
AnyOption *opt = new AnyOption();
/* 2. SET PREFERENCES */
//opt->noPOSIX(); /* do not check for POSIX style character options */
//opt->setVerbose(); /* print warnings about unknown options */
//opt->noUsage(); /* stop printing Usage */
/* 3. SET THE USAGE/HELP */
opt->addUsage( "Usage: foo [OPTIONS]... [IMAGE FOLDER] " );
opt->addUsage( "Unknown options/arguments encountered " );
opt->addUsage( "Use -h or --help for a complete list of options" );
/* 4. SET THE OPTION STRINGS/CHARACTERS */
opt->setFlag( "help", 'h' ); /* for help */
opt->setOption( "width", 'w' );
opt->setOption( "height" );
opt->setFlag( "convert");
opt->setCommandOption( "name", 'n' );
opt->setCommandFlag( "help" );
opt->setFileOption( "title" );
/* 5. PROVIDE THE COMMANDLINE AND RESOURCE FILE */
if ( ! opt->processFile( "sample.txt" ) )
cout << "Failed processing the resource file" << endl ;
opt->processCommandArgs( argc, argv );
/* 6. GET THE VALUES */
/* help */
if( opt->getFlag( "help" ) || opt->getFlag( 'h' ) ){
opt->printUsage();
/* print help here */
}
cout << "THE OPTIONS : " << endl << endl ;
if( opt->getValue( 'w' ) != NULL )
cout << "w : " << opt->getValue( 'w' ) << endl ;
if( opt->getValue( "width" ) != NULL )
cout << "width : " << opt->getValue( "width" ) << endl ;
if( opt->getValue( "height" ) != NULL )
cout << "height : " << opt->getValue( "height" ) << endl ;
if( opt->getValue( "name" ) != NULL )
cout << "name : " << opt->getValue( "name" ) << endl ;
if( opt->getValue( 'n' ) != NULL )
cout << "n : " << opt->getValue( 'n' ) << endl ;
if( opt->getValue( "title" ) != NULL )
cout << "title : " << opt->getValue( "title" ) << endl ;
if( opt->getFlag( "convert" ) )
cout << "convert : set " << endl ;
cout << endl ;
/* 7. GET THE ACTUAL ARGUMNETS AFTER THE OPTIONS */
cout << "THE ARGUMENTS : " << endl << endl ;
for( int i = 0 ; i < opt->getArgc() ; i++ ){
cout << opt->getArgv( i ) << endl ;
}
cout << endl;
/* 7. DONE */
delete opt;
}
示例11: main
int main(int argc, char** argv)
#endif
/*
#else
int WinMain(
HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow)
#endif
*/
{
string datapath;
AnyOption *opt = new AnyOption();
opt->addUsage( "" );
opt->addUsage( "Usage: " );
opt->addUsage( "" );
opt->addUsage( " -h --help Prints this help " );
opt->addUsage( " -d --data-path /dir Data files path " );
opt->addUsage( "" );
opt->setFlag( "help", 'h' );
opt->setOption( "data-path", 'd' );
opt->processCommandArgs( argc, argv );
if( opt->getFlag( "help" ) || opt->getFlag( 'h' ) )
{
GWDBG_OUTPUT("Usage")
opt->printUsage();
delete opt;
return 0;
}
if( opt->getValue( 'd' ) != NULL || opt->getValue( "data-size" ) != NULL )
datapath = opt->getValue('d');
delete opt;
try
{
#ifdef GP2X
GW_PlatformGP2X platform;
#elif defined(GW_PLAT_PANDORA)
GW_PlatformPandora platform;
#elif defined(GW_PLAT_S60)
GW_PlatformS60 platform;
#elif defined(GW_PLAT_WIZ)
GW_PlatformWIZ platform;
#elif defined(GW_PLAT_ANDROID)
GW_PlatformAndroid platform;
#elif defined(GW_PLAT_IOS)
GW_PlatformIOS platform;
#else
GW_PlatformSDL platform(640, 480);
#endif
if (!datapath.empty())
platform.datapath_set(datapath);
platform.initialize();
GW_GameList gamelist(&platform);
GW_Menu menu(&platform, &gamelist);
menu.Run();
platform.finalize();
} catch (GW_Exception &e) {
GWDBG_OUTPUT(e.what().c_str())
fprintf(stderr, "%s\n", e.what().c_str());
return 1;
}
return 0;
}
示例12: main
int main(int argc, char * argv[], MPI_Comm commWorld)
{
#else
int main(int argc, char * argv[])
{
MPI_Comm commWorld;
#endif
std::string fileName;
int reduceDM = 10;
int reduceS= 1;
#ifndef PARTICLESRENDERER
std::string fullScreenMode = "";
bool stereo = false;
#endif
int nmaxsample = 200000;
std::string display;
bool inSitu = false;
bool quickSync = true;
int sleeptime = 1;
{
AnyOption opt;
#define ADDUSAGE(line) {{std::stringstream oss; oss << line; opt.addUsage(oss.str());}}
ADDUSAGE(" ");
ADDUSAGE("Usage:");
ADDUSAGE(" ");
ADDUSAGE(" -h --help Prints this help ");
ADDUSAGE(" -i --infile # Input snapshot filename ");
ADDUSAGE(" -I --insitu Enable in-situ rendering ");
ADDUSAGE(" --sleep # start up sleep in sec [1] ");
ADDUSAGE(" --noquicksync disable syncing with simulation [enabled] ");
ADDUSAGE(" --reduceDM # cut down DM dataset by # factor [10]. 0-disable DM");
ADDUSAGE(" --reduceS # cut down stars dataset by # factor [1]. 0-disable S");
#ifndef PARTICLESRENDERER
ADDUSAGE(" --fullscreen # set fullscreen mode string");
ADDUSAGE(" --stereo enable stereo rendering");
#endif
ADDUSAGE(" -s --nmaxsample # set max number of samples for DD [" << nmaxsample << "]");
ADDUSAGE(" -D --display # set DISPLAY=display, otherwise inherited from environment");
opt.setFlag ( "help" , 'h');
opt.setOption( "infile", 'i');
opt.setFlag ( "insitu", 'I');
opt.setOption( "reduceDM");
opt.setOption( "sleep");
opt.setOption( "reduceS");
opt.setOption( "fullscreen");
opt.setFlag("stereo");
opt.setOption("nmaxsample", 's');
opt.setOption("display", 'D');
opt.setFlag ( "noquicksync");
opt.processCommandArgs( argc, argv );
if( ! opt.hasOptions() || opt.getFlag( "help" ) || opt.getFlag( 'h' ) )
{
/* print usage if no options or requested help */
opt.printUsage();
::exit(0);
}
char *optarg = NULL;
if (opt.getFlag("insitu")) inSitu = true;
if ((optarg = opt.getValue("infile"))) fileName = std::string(optarg);
if ((optarg = opt.getValue("reduceDM"))) reduceDM = atoi(optarg);
if ((optarg = opt.getValue("reduceS"))) reduceS = atoi(optarg);
#ifndef PARTICLESRENDERER
if ((optarg = opt.getValue("fullscreen"))) fullScreenMode = std::string(optarg);
if (opt.getFlag("stereo")) stereo = true;
#endif
if ((optarg = opt.getValue("nmaxsample"))) nmaxsample = atoi(optarg);
if ((optarg = opt.getValue("display"))) display = std::string(optarg);
if ((optarg = opt.getValue("sleep"))) sleeptime = atoi(optarg);
if (opt.getValue("noquicksync")) quickSync = false;
if ((fileName.empty() && !inSitu) ||
reduceDM < 0 || reduceS < 0)
{
opt.printUsage();
::exit(0);
}
#undef ADDUSAGE
}
MPI_Comm comm = MPI_COMM_WORLD;
int mpiInitialized = 0;
MPI_Initialized(&mpiInitialized);
if (!mpiInitialized)
MPI_Init(&argc, &argv);
else
comm = commWorld;
int nranks, rank;
//.........这里部分代码省略.........
示例13: AnyOption
//.........这里部分代码省略.........
opt->addUsage( " requested in the propagation. Note that underscores" );
opt->addUsage( " are necessary to separate the numbers." );
opt->addUsage( " Note also that these are requested ranges;" );
opt->addUsage( " however the left-closest profile available" );
opt->addUsage( " in the .env file will actually be used; " );
opt->addUsage( " for instance we request the profile at 300 km " );
opt->addUsage( " but in the .env file the left-closest profile" );
opt->addUsage( " may be available at 290 km and it is the one used." );
opt->addUsage( " Example: >> ../bin/ModessRD2WCM --atmosfile g2sgcp2011012606L.jordan.env ");
opt->addUsage( " --atmosfileorder zuvwtdp --azimuth 90 --freq 0.01 ");
opt->addUsage( " --use_profiles_ranges_km 100_200_250 --maxrange_km 500 ");
opt->addUsage( "" );
opt->addUsage( " --use_profiles_at_steps_km" );
opt->addUsage( " e.g. --use_profiles_at_steps_km 100" );
opt->addUsage( " The profiles are requested at equidistant intervals " );
opt->addUsage( " specified by this option [1000]" );
opt->addUsage( "" );
opt->addUsage( " --use_1D_profiles_from_dir" );
opt->addUsage( " e.g. --use_1D_profiles_from_dir myprofiles" );
opt->addUsage( " This option allows to use the ascii profiles stored in" );
opt->addUsage( " the specified directory. The profiles must have names" );
opt->addUsage( " 'profiles0001', 'profiles0002', etc. and will be" );
opt->addUsage( " used in alphabetical order at the provided ranges" );
opt->addUsage( " e.g. in conjunction with either" );
opt->addUsage( " option '--use_profile_ranges_km' " );
opt->addUsage( " or option '--use_profiles_at_steps_km'" );
opt->addUsage( " If there are more requested ranges than existing" );
opt->addUsage( " profiles then the last profile is used repeatedly" );
opt->addUsage( " as necessary." );
opt->addUsage( " Example: >> ../bin/ModessRD2WCM --atmosfileorder zuvwtdp --skiplines 1" );
opt->addUsage( " --azimuth 90 --freq 0.1 --use_1D_profiles_from_dir myprofiles" );
opt->addUsage( " --use_profile_ranges_km 0_100_300_500 " );
opt->addUsage( "" );
opt->addUsage( "FLAGS (no value required):" );
opt->addUsage( " --write_2D_TLoss Outputs the 2D transmission loss to" );
opt->addUsage( " default file: tloss_rd2wcm_2d.nm" );
opt->addUsage( "" );
opt->addUsage( "" );
opt->addUsage( " The format of the output files are as follows (column order):" );
opt->addUsage( " tloss_rd2wcm_1d.nm: r, 4*PI*Re(P), 4*PI*Im(P), (incoherent TL)" );
opt->addUsage( " tloss_rd2wcm_1d.lossless.nm:" );
opt->addUsage( " tloss_rd2wcm_2d.nm: r, z, 4*PI*Re(P), 4*PI*Im(P)" );
opt->addUsage( "" );
opt->addUsage( " Examples to run (in the 'samples' directory):" );
opt->addUsage( "" );
opt->addUsage( " ../bin/ModessRD2WCM --use_1D_profiles_from_dir profiles --atmosfileorder zuvwtdp --skiplines 1 --azimuth 90 --freq 0.1 --use_profile_ranges_km 0_100_200_300 --maxrange_km 500" );
opt->addUsage( "" );
opt->addUsage( " ../bin/ModessRD2WCM --g2senvfile g2sgcp2011012606L.jordan.env --atmosfileorder zuvwtdp --skiplines 1 --azimuth 90 --freq 0.1 --use_profile_ranges_km 0_100_200_250 --maxrange_km 500" );
opt->addUsage( "" );
opt->addUsage( " ../bin/ModessRD2WCM --use_1D_profiles_from_dir profiles --atmosfileorder zuvwtdp --skiplines 1 --azimuth 90 --freq 0.1 --maxrange_km 500" );
opt->addUsage( "" );
opt->addUsage( " Note: if options --use_profile_ranges_km/--use_profiles_at_steps_km are not used then we fall back on the range-independent case using the first available atm. profile." );
opt->addUsage( "" );
// Set up the actual flags, etc.
opt->setFlag( "help", 'h' );
opt->setFlag( "write_2D_TLoss" );
opt->setFlag( "plot" );
opt->setOption( "atmosfile" );
opt->setOption( "atmosfileorder" );
opt->setOption( "g2senvfile" );
opt->setOption( "wind_units" );
opt->setOption( "use_1D_profiles_from_dir" );
opt->setOption( "slicefile" );
opt->setOption( "skiplines" );
opt->setOption( "azimuth" );
opt->setOption( "freq" );
opt->setOption( "maxrange_km" );
opt->setOption( "sourceheight_km" );
opt->setOption( "receiverheight_km" );
opt->setOption( "maxheight_km" );
opt->setOption( "zground_km" );
opt->setOption( "stepsize" );
opt->setOption( "Nz_grid" );
opt->setOption( "Nrng_steps" );
opt->setOption( "ground_impedance_model" );
opt->setOption( "Lamb_wave_BC" );
opt->setOption( "use_profile_ranges_km" );
opt->setOption( "use_profiles_at_steps_km" );
opt->setOption( "use_attn_file" );
// Process the command-line arguments
opt->processFile( "./ModessRD2WCM.options" );
opt->processCommandArgs( argc, argv );
if( ! opt->hasOptions()) { // print usage if no options
opt->printUsage();
delete opt;
exit( 1 );
}
// Check to see if help text was requested
if ( opt->getFlag( "help" ) || opt->getFlag( 'h' ) ) {
opt->printUsage();
exit( 1 );
}
return opt;
}
示例14: main
/**
* @brief Filter arrays in a file and write filtered arrays to output file
* @param argc Number of command line arguments
* @param argv Command line arguments
* @return
*/
int main (int argc, char *argv[]) {
AnyOption opt;
/* parse command line options */
opt.setFlag ("help", 'h'); /* a flag (takes no argument), supporting long and short form */
opt.setOption ("output", 'o');
opt.setOption ("verbose", 'v');
opt.setOption ("na", 'a');
opt.setOption ("index", 'i');
opt.setOption ("format", 'f');
opt.addUsage ("Orthonal Array Filter: filter arrays");
opt.addUsage ("Usage: oaanalyse [OPTIONS] [INPUTFILE] [VALUESFILE] [THRESHOLD] [OUTPUTFILE]");
opt.addUsage (" The VALUESFILE is a binary file with k*N double values. Here N is the number of arrays");
opt.addUsage (" and k the number of analysis values.");
opt.addUsage ("");
opt.addUsage (" -h --help Prints this help ");
opt.addUsage (" -v --verbose Verbose level (default: 1) ");
opt.addUsage (" -a Number of values in analysis file (default: 1) ");
opt.addUsage (" --index Index of value to compare (default: 0) ");
opt.addUsage (" -f [FORMAT] Output format (default: TEXT, or BINARY; B) ");
opt.processCommandArgs (argc, argv);
print_copyright ();
/* parse options */
if (opt.getFlag ("help") || opt.getFlag ('h') || opt.getArgc () < 4) {
opt.printUsage ();
exit (0);
}
int verbose = opt.getIntValue ('v', 1);
int na = opt.getIntValue ('a', 1);
int index = opt.getIntValue ("index", 0);
std::string format = opt.getStringValue ('f', "BINARY");
arrayfile::arrayfilemode_t mode = arrayfile_t::parseModeString (format);
/* read in the arrays */
std::string infile = opt.getArgv (0);
std::string anafile = opt.getArgv (1);
double threshold = atof (opt.getArgv (2));
std::string outfile = opt.getArgv (3);
if (verbose)
printf ("oafilter: input %s, threshold %f (analysisfile %d values, index %d)\n", infile.c_str (),
threshold, na, index);
arraylist_t *arraylist = new arraylist_t;
int n = readarrayfile (opt.getArgv (0), arraylist);
if (verbose)
printf ("oafilter: filtering %d arrays\n", n);
// read analysis file
FILE *afid = fopen (anafile.c_str (), "rb");
if (afid == 0) {
printf (" could not read analysisfile %s\n", anafile.c_str ());
exit (0);
}
double *a = new double[n * na];
fread (a, sizeof (double), n * na, afid);
fclose (afid);
std::vector< int > gidx;
;
for (int jj = 0; jj < n; jj++) {
double val = a[jj * na + index];
if (val >= threshold)
gidx.push_back (jj);
if (verbose >= 2)
printf ("jj %d: val %f, threshold %f\n", val >= threshold, val, threshold);
}
// filter
arraylist_t *filtered = new arraylist_t;
selectArrays (*arraylist, gidx, *filtered);
/* write arrays to file */
if (verbose)
cout << "Writing " << filtered->size () << " arrays (input " << arraylist->size () << ") to file "
<< outfile << endl;
writearrayfile (outfile.c_str (), *filtered, mode);
/* free allocated structures */
delete[] a;
delete arraylist;
delete filtered;
return 0;
}
示例15: main
int main(int argc, char** argv)
{
QApplication app(argc, argv);
AnyOption options;
options.addUsage(QString("Usage: %1 --help | --console | [--output path --prefix prefixName --suffix suffixName --type typeName").arg(argv[0]).toAscii());
options.addUsage("");
options.addUsage("--help Displays this message.");
options.addUsage("--console Run the gui version.");
options.addUsage("--output [path] Output directory for the plugin skeleton.");
options.addUsage("--prefix [prefixName] Prefix to use for the plugin.");
options.addUsage("--suffix [suffixName] Suffix to use for the plugin.");
options.addUsage("--type [typeName] Type to use for the plugin.");
options.addUsage("--quiet Process quietly (non gui generation only).");
options.setFlag("help");
options.setFlag("console");
options.setOption("output");
options.setOption("prefix");
options.setOption("suffix");
options.setOption("type");
options.setOption("quiet");
options.processCommandArgs(argc, argv);
if(options.getFlag("help")) {
options.printUsage();
return 0;
}
if(options.getFlag("console")) {
bool paramsOk = options.getValue("output") && options.getValue("prefix") && options.getValue("type") && options.getValue("suffix");
if( !paramsOk ) {
options.printUsage();
return 1;
}
if(!options.getFlag("quiet")) {
qDebug() << "output = " << options.getValue("output");
qDebug() << "prefix = " << options.getValue("prefix");
qDebug() << "suffix = " << options.getValue("suffix");
qDebug() << "type = " << options.getValue("type");
}
dtkPluginGenerator generator;
generator.setOutputDirectory(options.getValue("output"));
generator.setPrefix(options.getValue("prefix"));
generator.setSuffix(options.getValue("suffix"));
generator.setType(options.getValue("type"));
bool resultGenerator = generator.run();
if(!options.getFlag("quiet")) {
if(resultGenerator)
qDebug() << "Generation succeeded.";
else
qDebug() << "Plugin generation: Generation failed.";
}
} else {
dtkPluginGeneratorMainWindow generator;
generator.show();
generator.raise();
return app.exec();
}
}