#include <string>
int main(int argc, char* argv[])
{
std::string string("none");
real_t flNumber = 1.0;
bool boolean = false;
std::string plainString;
std::vector<index_t> intvec;
gsCmdLine cmd(
"Tutorial Command Line Arguments");
cmd.addString("s", "stringArg",
"Description of string command line argument.",
string);
cmd.addInt ("i", "num",
"Description of int command line argument",
number);
cmd.addNewInt ("j", "numj",
"Description of another int command line argument",
2);
cmd.addReal ("r", "real",
"Description of float command line argument",
flNumber);
cmd.addSwitch("bool","Description of the switch argument.", boolean);
std::string value = "default_plain_value";
cmd.addPlainString("plain", "Description of the plain command line argument.", plainString);
cmd.addMultiInt("m", "multiint", "Description of multiint command line argument.", intvec);
try { cmd.getValues(argc,argv); } catch (int rv) { return rv; }
cmd.printVersion();
gsInfo <<
"\nPrinting command line arguments:\n\n"
<< "Plain string: " << plainString << "\n"
<< "String: " << string << "\n"
<< "Float: " << flNumber << "\n"
<< "Integer: " << number << "\n"
<< "Switch: " << boolean << "\n"
<< "MultiInt {";
std::copy(intvec.begin(), intvec.end(),
std::ostream_iterator<int>(
gsInfo,
", "));
gsInfo <<
"\nPrinting command line arguments again (using names):\n\n"
<< "Plain string: " << cmd.getString("plain") << "\n"
<< "String: " << cmd.getString("stringArg") << "\n"
<< "Float: " << cmd.getReal("real") << "\n"
<< "Integer: " << cmd.getInt("num") << "\n"
<< "Another one: " << cmd.getInt("numj") << "\n"
<< "Switch: " << cmd.getSwitch("bool") << "\n"
;
gsInfo<<
"\nPrint out as an Option list. "<< cmd <<
"\n";
return 0;
}
Class for command-line argument parsing.
Definition gsCmdLine.h:57
Main header to be included by clients using the G+Smo library.
#define index_t
Definition gsConfig.h:32
#define gsInfo
Definition gsDebug.h:43
The G+Smo namespace, containing all definitions for the library.