|
libmx2 2.2.1
C++20 multimedia and game-engine library (SDL2 / OpenGL / Vulkan)
|
Lightweight, header-only, template command-line argument parser. More...
#include <algorithm>#include <iomanip>#include <iostream>#include <string>#include <type_traits>#include <unordered_map>#include <utility>#include <vector>Go to the source code of this file.
Classes | |
| struct | Argument< String > |
| Describes a single parsed argument entry returned by Argz::proc(). More... | |
| struct | ArgumentData< String > |
Holds the raw argv strings converted to the target String type. More... | |
| class | ArgException< String > |
| Exception thrown by Argz::proc() on unrecognised or malformed options. More... | |
| class | Argz< String > |
| Template command-line argument parser. More... | |
| struct | Arguments |
| Plain data structure returned by proc_args() with all common libmx2 CLI options. More... | |
Concepts | |
| concept | StringType |
| Models a string-like class with indexing, concatenation, length, and value_type. | |
Enumerations | |
| enum class | ArgType { ARG_SINGLE , ARG_SINGLE_VALUE , ARG_DOUBLE , ARG_DOUBLE_VALUE , ARG_NONE } |
| Discriminator for option kind used inside Argument. More... | |
Functions | |
| Arguments | proc_args (int &argc, char **argv) |
| Parse standard libmx2 command-line options from main()'s argv. | |
Lightweight, header-only, template command-line argument parser.
Supports both short options (-x) and long options (--name), with or without values, for any string type that satisfies the StringType concept (typically std::string or std::wstring).
Typical usage:
A convenience wrapper proc_args() provides a pre-built parser that handles the options common to all libmx2 applications (-p path, -r resolution, -f fullscreen, …).
Definition in file argz.hpp.
|
strong |
|
inline |
Parse standard libmx2 command-line options from main()'s argv.
Registers and processes the following options:
| Flag | Long form | Description |
|---|---|---|
| -h | Print help and exit | |
| -p | –path | Asset directory path |
| -r | –resolution | Resolution as WxH (e.g. 1920x1080) |
| -f | –fullscreen | Enable fullscreen |
| –filename | Input filename | |
| –texture | Texture file | |
| -S | –shader-path | SPV shader folder (must contain index.txt) |
| argc | Reference to argc from main(). |
| argv | argv from main(). |
Definition at line 532 of file argz.hpp.
References Argz< String >::addOptionSingle(), Argument< String >::arg_value, Arguments::filename, Arguments::fullscreen, Arguments::height, Argz< String >::help(), Arguments::path, Argz< String >::proc(), Arguments::shaderPath, ArgException< String >::text(), Arguments::texture, and Arguments::width.