#include <CommandLineParser.hpp>
Public Member Functions | |
template<typename HandlerType> | |
bool | Parse (const char *LongName, char ShortName, HandlerType &&Handler, bool RemoveArgument=true) |
template<typename ValType> | |
bool | Parse (const char *LongName, char ShortName, ValType &Val, bool RemoveArgument=true) |
template<typename ValType> | |
bool | Parse (const char *LongName, ValType &Val, bool RemoveArgument=true) |
Short version that only takes LongName parameter. | |
template<typename EnumType> | |
bool | ParseEnum (const char *LongName, char ShortName, const std::vector< std::pair< const char *, EnumType > > &EnumVals, EnumType &Val, bool CaseSensitive=false, bool RemoveArgument=true) |
Simple command line parser.
Command line example: –mode vk –width 1024 -h 768 –path=my/path –use_alpha true
Usage example:
CommandLineParser ArgsParser{argc, argv}; const std::vector<std::pair<const char*, RENDER_DEVICE_TYPE>> DeviceTypeEnumVals = { {"d3d11", RENDER_DEVICE_TYPE_D3D11}, {"d3d12", RENDER_DEVICE_TYPE_D3D12}, {"vk", RENDER_DEVICE_TYPE_VULKAN} }; RENDER_DEVICE_TYPE DeviceType = RENDER_DEVICE_TYPE_UNDEFINED; ArgsParser.ParseEnum("mode", 'm', DeviceTypeEnumVals, DeviceType); int Width = 0; ArgsParser.Parse("width", 'w', Width); int Height = 0; ArgsParser.Parse("height", 'h', Height); std::string Path; ArgsParser.Parse("path", 'p', Path); bool UseAlpha = false; ArgsParser.Parse("use_alpha", 'a', UseAlpha);
|
inline |
Parses command line argument with long name LongName and short name ShortName. If parameter is found, calls Handler passing the value string as parameter. If RemoveArgument is true, the argument will be removed from the arguments list if parsed successfully. Returns true if the argument was parsed successfully, and false otherwise.
bool Diligent::CommandLineParser::Parse | ( | const char * | LongName, |
char | ShortName, | ||
ValType & | Val, | ||
bool | RemoveArgument = true ) |
Parses command line argument with long name LongName and short name ShortName as type ValType. If RemoveArgument is true, the argument will be removed from the arguments list if parsed successfully. Returns true if the argument was parsed successfully, and false otherwise.
|
inline |
Parses command line argument with long name LongName and short name ShortName as enumeration with values EnumVals. If RemoveArgument is true, the argument will be removed from the arguments list if parsed successfully. Returns true if the argument was parsed successfully, and false otherwise.