Example of command line parsing.
#include <iomanip>
#include <sstream>
#include <stdio.h>
#include <visp3/core/vpConfig.h>
#include <visp3/core/vpDebug.h>
#include <visp3/io/vpParseArgv.h>
int main(int argc, const char **argv)
{
#ifdef ENABLE_VISP_NAMESPACE
#endif
try {
using ::std::cout;
using ::std::endl;
bool bool_val = false;
int int_val = 3;
long long_val = 33333333;
float float_val = 3.14f;
double double_val = 3.1415;
char *string_val = nullptr;
vpParseArgv::vpArgvInfo argTable[] = {
return EXIT_FAILURE;
}
cout << "Your parameters: " << endl;
cout << " Bool value: " << bool_val << endl;
cout << " Integer value: " << int_val << endl;
cout << " Long value: " << long_val << endl;
cout << " Float value: " << float_val << endl;
cout << " Double value: " << double_val << endl;
if (string_val != nullptr)
cout << " String value: " << string_val << endl;
else
cout << " String value: \"\"" << endl << endl;
cout << "Call " << argv[0] << " -h to see how to change these parameters." << endl;
return EXIT_SUCCESS;
}
return EXIT_FAILURE;
}
}
error that can be emitted by ViSP classes.
const std::string & getStringMessage() const
static bool parse(int *argcPtr, const char **argv, vpArgvInfo *argTable, int flags)
@ ARGV_NO_DEFAULTS
No default options like -help.
@ ARGV_DOUBLE
Argument is associated to a double.
@ ARGV_LONG
Argument is associated to a long.
@ ARGV_STRING
Argument is associated to a char * string.
@ ARGV_FLOAT
Argument is associated to a float.
@ ARGV_INT
Argument is associated to an int.
@ ARGV_CONSTANT_BOOL
Stand alone argument associated to a bool var that is set to true.
@ ARGV_END
End of the argument list.
@ ARGV_HELP
Argument is for help displaying.