本文整理汇总了C++中AnyOption::getFlag方法的典型用法代码示例。如果您正苦于以下问题:C++ AnyOption::getFlag方法的具体用法?C++ AnyOption::getFlag怎么用?C++ AnyOption::getFlag使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AnyOption
的用法示例。
在下文中一共展示了AnyOption::getFlag方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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;
}
示例2: 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;
}
示例3: parse
void UpdaterOptions::parse(int argc, char** argv)
{
AnyOption parser;
parser.setOption("install-dir");
parser.setOption("package-dir");
parser.setOption("script");
parser.setOption("wait");
parser.setOption("mode");
parser.setFlag("version");
parser.setFlag("force-elevated");
parser.setFlag("auto-close");
parser.processCommandArgs(argc,argv);
if (parser.getValue("mode"))
{
mode = stringToMode(parser.getValue("mode"));
}
if (parser.getValue("install-dir"))
{
installDir = parser.getValue("install-dir");
}
if (parser.getValue("package-dir"))
{
packageDir = parser.getValue("package-dir");
}
if (parser.getValue("script"))
{
scriptPath = parser.getValue("script");
}
if (parser.getValue("wait"))
{
waitPid = static_cast<PLATFORM_PID>(atoll(parser.getValue("wait")));
}
showVersion = parser.getFlag("version");
forceElevated = parser.getFlag("force-elevated");
autoClose = parser.getFlag("auto-close");
if (installDir.empty())
{
// if no --install-dir argument is present, try parsing
// the command-line arguments in the old format (which uses
// a list of 'Key=Value' args)
parseOldFormatArgs(argc,argv);
}
}
示例4: 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;
}
示例5: 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;
}
示例6: AnyOption
void
simple( int argc, char* argv[] )
{
AnyOption *opt = new AnyOption();
opt->noPOSIX(); /* use simpler option type */
opt->setOption( "width" );
opt->setOption( "height" );
opt->setFlag( "convert");
opt->setCommandOption( "name" );
opt->setFileOption( "title" );
if ( ! opt->processFile( "sample.txt" ) )
cout << "Failed processing the resource file" << endl ;
opt->processCommandArgs( argc, argv );
cout << "THE OPTIONS : " << endl << 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( "title" ) != NULL )
cout << "title : " << opt->getValue( "title" ) << endl ;
if( opt->getFlag( "convert" ) )
cout << "convert : set " << endl ;
cout << endl ;
cout << "THE ARGUMENTS : " << endl << endl ;
for( int i = 0 ; i < opt->getArgc() ; i++ ){
cout << opt->getArgv( i ) << endl ;
}
cout << endl;
delete opt;
}
示例7: 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();
}
}
示例8: 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);
//.........这里部分代码省略.........
示例9: 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);
}
}
}
}
示例10: 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();
//
//////////////////////////////////////////////////////////////////////////////
//.........这里部分代码省略.........
示例11: 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;
}
示例12: main
//.........这里部分代码省略.........
int tempskips = atoi( opt->getValue( "skips" ));
maxskips = tempskips < 0 ? 0 : (unsigned int)tempskips;
}
if (opt->getValue( "wind_units" ) != NULL) {
if (strcmp(opt->getValue( "wind_units" ),"kmpersec") == 0) {
inMPS = false;
}
}
// Process azimuth vector. Since azimuths can wrap around from 360 to 0, we can't
// easily put it into a for loop.
int naz = 0;
double *azvec;
if (filetype != SLICEFILE) {
bool azwraps = (maxazimuth < azimuth0);
if (azwraps) {
maxazimuth += 360.0;
}
naz = (int)floor((maxazimuth-azimuth0)/dazimuth + 0.5) + 1;
azvec = new double[ naz ];
int i = 0;
for (double d = azimuth0; d <= maxazimuth; d += dazimuth) {
azvec[ i++ ] = (d >= 360.0 ? d - 360.0 : d );
}
if (azwraps) {
maxazimuth -= 360.0;
}
}
// Flags
//bool rangeDependent = !opt->getFlag( "norange" );
bool rangeDependent = false; // this will be set to true depending on the type of atmosphere used
bool partial = opt->getFlag( "partial" );
// Initialize the atmospheric profile
AtmosphericSpecification *spec = 0;
// Declare these but don't allocate yet. We'll only use one of them, but if we declare
// them inside the switch statement then they go out of scope too fast.
JetProfile *jet;
SampledProfile *sound;
Slice *slice;
string order;
int skiplines;
switch (filetype) {
case JETFILE:
jet = new JetProfile( atmosfile );
spec = new Sounding( jet );
break;
case ATMOSFILE:
skiplines = 0;
if (opt->getValue("skiplines") != NULL) {
skiplines = atoi( opt->getValue( "skiplines" ) );
}
if (opt->getValue( "atmosfileorder" ) != NULL) {
order = opt->getValue( "atmosfileorder" );
} else {
delete opt;
throw invalid_argument( "Option --atmosfileorder is required for ATMOSFILE files!" );
}
sound = new SampledProfile( atmosfile, order.c_str(), skiplines, inMPS ); // Will be deleted when spec is deleted
//sound->resample( 0.01 * stepsize );
spec = new Sounding( sound );
示例13: parsecmd
/**
Utilizing AnyOption class, take the command line and parse it for valid options. Handle usage printout as well.
@param argc argc from main()
@param char**argv array of char* directly from main()
@returns If an error occurs, return false. Currently no errors. Always returns true.
*/
bool parsecmd(int argc, char**argv)
{
stringstream str;
// Setup all default values if not already set by simple strings and values above.
if (getenv("WEBRTC_SERVER"))
mainserver = xGetDefaultServerName();
if (getenv("WEBRTC_CONNECT"))
{
stunserver = "STUN ";
stunserver += xGetPeerConnectionString();
}
peername = xGetPeerName();
AnyOption *opt = new AnyOption();
opt->addUsage("Usage: ");
opt->addUsage("");
opt->addUsage(" -h --help Prints this help ");
opt->addUsage(" --server <servername|IP>[:<serverport>] Main sever and optional port.");
opt->addUsage(
" --stun <stunserver|IP>[:<port>] STUN server (and optionally port).\n Default is " STUNSERVER_DEFAULT);
opt->addUsage(
" --peername <Name> Use this name as my client/peer name online.");
opt->addUsage(" --avopts <none|audio|video|audiovideo> Enable audio, video, or audiovideo.");
opt->addUsage("");
opt->addUsage("Environment variables can be used as defaults as well.");
opt->addUsage(" WEBRTC_SERVER - Main server name.");
opt->addUsage(" WEBRTC_CONNECT - STUN server name with port.");
opt->addUsage(" USERNAME - Peer user name.");
opt->addUsage("");
opt->setFlag("help", 'h');
opt->setOption("server");
opt->setOption("stun");
opt->setOption("peername");
opt->setOption("avopts");
opt->processCommandArgs(argc, argv);
/* 6. GET THE VALUES */
if (opt->getFlag("help") || opt->getFlag('h'))
{
opt->printUsage();
exit(1);
}
if (opt->getValue("server"))
{
cout << "New main server is " << opt->getValue("server") << endl;
string serverloc = opt->getValue("server");
size_t colonpos = serverloc.find(':');
mainserver = serverloc.substr(0,colonpos);
if(colonpos != string::npos)
{
stringstream sstrm;
sstrm << serverloc.substr(colonpos+1);
sstrm >> mainserver_port;
}
示例14: main
/**
* @brief Main function for oaextendmpi and oaextendsingle
* @param argc
* @param argv[]
* @return
*/
int main (int argc, char *argv[]) {
#ifdef OAEXTEND_SINGLECORE
const int n_processors = 1;
const int this_rank = 0;
#else
MPI::Init (argc, argv);
const int n_processors = MPI::COMM_WORLD.Get_size ();
const int this_rank = MPI::COMM_WORLD.Get_rank ();
#endif
// printf("MPI: this_rank %d\n", this_rank);
/*----------SET STARTING ARRAY(S)-----------*/
if (this_rank != MASTER) {
#ifdef OAEXTEND_MULTICORE
slave_print (QUIET, "M: running core %d/%d\n", this_rank, n_processors);
#endif
algorithm_t algorithm = MODE_INVALID;
AnyOption *opt = parseOptions (argc, argv, algorithm);
OAextend oaextend;
oaextend.setAlgorithm (algorithm);
#ifdef OAEXTEND_MULTICORE
log_print (NORMAL, "slave: receiving algorithm int\n");
algorithm = (algorithm_t)receive_int_slave ();
oaextend.setAlgorithm (algorithm);
// printf("slave %d: receive algorithm %d\n", this_rank, algorithm);
#endif
extend_slave_code (this_rank, oaextend);
delete opt;
} else {
double Tstart = get_time_ms ();
int nr_extensions;
arraylist_t solutions, extensions;
algorithm_t algorithm = MODE_INVALID;
AnyOption *opt = parseOptions (argc, argv, algorithm);
print_copyright ();
int loglevel = opt->getIntValue ('l', NORMAL);
setloglevel (loglevel);
int dosort = opt->getIntValue ('s', 1);
int userowsymm = opt->getIntValue ("rowsymmetry", 1);
int maxk = opt->getIntValue ("maxk", 100000);
int initcolprev = opt->getIntValue ("initcolprev", 1);
const bool streaming = opt->getFlag ("streaming");
bool restart = false;
if (opt->getValue ("restart") != NULL || opt->getValue ('r') != NULL) {
restart = true;
}
const char *oaconfigfile = opt->getStringValue ('c', "oaconfig.txt");
const char *resultprefix = opt->getStringValue ('o', "result");
arrayfile::arrayfilemode_t mode = arrayfile_t::parseModeString (opt->getStringValue ('f', "T"));
OAextend oaextend;
oaextend.setAlgorithm (algorithm);
if (streaming) {
logstream (SYSTEM) << "operating in streaming mode, sorting of arrays will not work "
<< std::endl;
oaextend.extendarraymode = OAextend::STOREARRAY;
}
// J5_45
int xx = opt->getFlag ('x');
if (xx) {
oaextend.j5structure = J5_45;
}
if (userowsymm == 0) {
oaextend.use_row_symmetry = userowsymm;
printf ("use row symmetry -> %d\n", oaextend.use_row_symmetry);
}
if (opt->getFlag ('g')) {
std::cout << "only generating arrays (no LMC check)" << endl;
oaextend.checkarrays = 0;
}
if (opt->getFlag ("help") || (opt->getValue ("coptions") != NULL)) {
if (opt->getFlag ("help")) {
opt->printUsage ();
}
if (opt->getValue ("coptions") != NULL) {
print_options (cout);
}
} else {
//.........这里部分代码省略.........
示例15: 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;
}