molecular
Classes | Public Member Functions | List of all members
molecular::util::CommandLineParser Class Reference

Easy processing of argc and argv. More...

#include <CommandLineParser.h>

Classes

class  Arg
 
class  Flag
 Option without parameter. More...
 
class  HelpFlag
 Displays help. More...
 
class  Option
 Command line option with parameter. More...
 
class  OptionBase
 
class  PositionalArg
 
class  PositionalArgBase
 

Public Member Functions

void Parse (int argc, char **argv)
 Parse command line arguments. More...
 
void PrintHelp ()
 Print usage information. More...
 

Detailed Description

Easy processing of argc and argv.

Example:

int main(int argc, char** argv)
{
CommandLineParser cmd;
CommandLineParser::PositionalArg<std::string> inFileName(cmd, "input file", "Input mesh to compile");
CommandLineParser::PositionalArg<std::string> outFileName(cmd, "output file", "Output compiled mesh file");
CommandLineParser::Flag prt(cmd, "prt", "Enable radiance transfer precomputation");
CommandLineParser::Option<float> scale(cmd, "scale", "Mesh scale factor", 1.0);
CommandLineParser::HelpFlag help(cmd);
try
{
cmd.Parse(argc, argv);
}
catch(std::exception& e)
{
std::cerr << e.what() << std::endl;
cmd.PrintHelp();
return EXIT_FAILURE;
}
// Get value by dereferencing:
std::cerr << "Input file: " << *inFileName;
}

Member Function Documentation

void molecular::util::CommandLineParser::Parse ( int  argc,
char **  argv 
)

Parse command line arguments.

Throws on failure.

void molecular::util::CommandLineParser::PrintHelp ( )

Print usage information.

Alternatively, add a HelpFlag.


The documentation for this class was generated from the following files: