本文整理汇总了C++中AnyOption::getArgc方法的典型用法代码示例。如果您正苦于以下问题:C++ AnyOption::getArgc方法的具体用法?C++ AnyOption::getArgc怎么用?C++ AnyOption::getArgc使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AnyOption
的用法示例。
在下文中一共展示了AnyOption::getArgc方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ValidateOptions
static int ValidateOptions(AnyOption& options, String& file)
{
for( int i = 0; i < options.getArgc(); ++i )
{
file = options.getArgv(i);
break;
}
// If no file was passed then we have nothing to do.
if( file.empty() )
{
options.printAutoUsage();
return EXIT_FAILURE;
}
// Check that the file is a DLL.
String extension = PathGetFileExtension(file);
if( StringCompareInsensitive(extension, "dll") != 0 )
{
LogError("The file is not a DLL");
return EXIT_FAILURE;
}
// Check if the file exists.
if( !FileExists(file) )
{
LogError("The file could not be found");
return EXIT_FAILURE;
}
return EXIT_SUCCESS;
}
示例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;
/* 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;
}
示例3: 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;
}
示例4: 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);
//.........这里部分代码省略.........
示例5: 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;
}