LibCppCmd v1.0 Beta 15
C++ Command Line Parsing Library
|
LibCppCmdLine is a modern, lightweight, and cross-platform C++ command line parsing library. It provides a series of classes for parsing command line arguments passed to a program via the main function and populating command line parameters with values as a result of parsing. A program that uses this library will:
The library uses the C++ Standard Template Library (STL) and thus has no major external dependencies (see note below). It is lightweight enough that it is designed to be added directly to a program's code base. However, the program can still be precompiled and statically or dynamically linked if desired. This library also uses exceptions, but only for enforcing class invariants to prevent programming errors; the library will only generate exceptions if the programmer defines parameters wrong or adds duplicate parameters, thus no try / catch blocks are necessary for final code.
Everything in this library is contained within the CmdLine namespace.
The following classes are necessary to parse command line arguments.
Class (* base) | Purpose |
---|---|
CmdLine::Parser | Parses command line arguments |
CmdLine::Param * | A variable that stores data from the command line |
CmdLine::ArgParam * | A CmdLine::Param populated by CommandLine arguments |
CmdLine::ProgParam | A CmdLine::ArgParam populated by the program name argument |
CmdLine::Option | A CmdLine::ArgParam that represents an option |
CmdLine::ValueOption | A CmdLine::Option populated with values |
CmdLine::OptionParam | Provides parameters for CmdLine::ValueOption values |
CmdLine::PosParam | A Positional CmdLine::ArgParam |
CmdLine::MultiPos | A multi-value positional CmdLine::ArgParam |
The following structs are necessary to define command line parameters.
Struct | Purpose |
---|---|
CmdLine::ProgParam::Definition | Used to construct a CmdLine::ProgParam |
CmdLine::Option::Definition | Used to construct a CmdLine::Option |
CmdLine::ValueOption::Definition | Used to construct a CmdLine::ValueOption |
CmdLine::OptionParam::Definition | Used to construct a CmdLine::OptionParam |
CmdLine::PosParam::Definition | Used to construct a CmdLine::PosParam |
CmdLine::MultiPosParam::Definition | Used to construct a CmdLine::MultiPosParam |