Go to the documentation of this file.
65 bool initialize(
int argc,
char *argv[],
bool pretty =
true) noexcept
override;
67 void process()
override;
69 void shutDown()
override;
79 std::vector<double>
dub;
87 :
BasicFramework(applName,
"Example application for CommandOption"),
88 numOpt(
'n',
"num",
"your choice of integer"),
89 floatOpt(
'D',
"data",
"specify any number of decimal numbers"),
90 timeOpt(
't',
"time",
"%Y/%m/%d %H:%M:%S",
91 "specify a time (%Y/%m/%d %H:%M:%S)", true),
105 if (numOpt.getCount() > 0)
111 if (floatOpt.getCount() > 0)
113 const std::vector<std::string>& vals(floatOpt.getValue());
116 dub.resize(vals.size(), 0.);
117 for (
unsigned i = 0; i < vals.size(); i++)
123 beginTime = timeOpt.getTime()[0];
132 cout <<
"Your number is " <<
num << endl;
133 cout <<
"Data:" << endl;
134 for (
unsigned i = 0; i <
dub.size(); i++)
136 cout <<
" dub[" << i <<
"] = " <<
dub[i] << endl;
138 cout <<
"Requested time:"
147 cout <<
"Shutting down" << endl;
151 int main(
int argc,
char *argv[])
166 catch (std::exception& e)
168 cerr << e.
what() << endl;
172 cerr <<
"Caught unknown exception" << endl;
CommandOptionWithCommonTimeArg timeOpt
Command-line option example for time.
long asInt(const std::string &s)
void shutDown() override
Clean up.
bool initialize(int argc, char *argv[], bool pretty=true) noexcept override
Process command-line arguments.
int main(int argc, char *argv[])
std::string what() const
Dump to a string.
static const int EXCEPTION_ERROR
CommandOptionWithDecimalArg floatOpt
Command-line option example with float checks.
int initialize(string &errors)
std::vector< double > dub
the decimal choices
void process() override
Do the processing.
int num
storage for integer
double asDouble(const std::string &s)
CommandOption2Example(const string &applName)
Initialize command-line arguments.
std::string printTime(const CommonTime &t, const std::string &fmt)
gnsstk::CommonTime beginTime
requested start time
CommandOption & setMaxCount(const unsigned long l)
CommandOptionWithNumberArg numOpt
Command-line option example with integer checks.
gnsstk
Author(s):
autogenerated on Wed Oct 25 2023 02:40:38