Maze Builder Docs 6.7.5
Loading...
Searching...
No Matches
mazes::args Class Referencefinal

Command-line argument handler with JSON support. More...

#include <args.h>

Public Member Functions

 args () noexcept
 Default constructor.
 
 ~args ()
 Destructor.
 
 args (const args &other)
 Copy constructor.
 
argsoperator= (const args &other)
 Copy assignment operator.
 
 args (args &&other) noexcept=default
 Move constructor.
 
argsoperator= (args &&other) noexcept=default
 Move assignment operator.
 
bool parse (const std::vector< std::string > &arguments) noexcept
 Parse program arguments from a vector of strings.
 
bool parse (const std::string &arguments) noexcept
 Parse program arguments from a string.
 
bool parse (int argc, char **argv) noexcept
 Parse program arguments from argc/argv.
 
void clear () noexcept
 Clear the arguments map.
 
std::optional< std::string > get (const std::string &key) const noexcept
 Get a value from the args map.
 
const std::unordered_map< std::string, std::string > & get () const noexcept
 Get entire args map.
 
bool has_multiple_configurations () const noexcept
 Check if we have multiple configurations (from JSON array)
 
size_t get_configuration_count () const noexcept
 Get the number of configurations stored.
 
std::optional< std::unordered_map< std::string, std::string > > get_configuration (size_t index) const noexcept
 Get configuration by index (0-based)
 
std::vector< std::unordered_map< std::string, std::string > > get_all_configurations () const noexcept
 Get all configurations as a vector.
 
bool add_option (const std::string &flags, const std::string &description) noexcept
 Add a new option to the CLI parser.
 
bool add_flag (const std::string &flags, const std::string &description) noexcept
 Add a new flag to the CLI parser.
 

Static Public Attributes

static constexpr const char * ALGO_ID_FLAG_STR = "-a"
 
static constexpr const char * ALGO_ID_OPTION_STR = "--algo"
 
static constexpr const char * ALGO_ID_WORD_STR = "algo"
 
static constexpr const char * ALGO_ID_SHORT_STR = "a"
 
static constexpr const char * BLOCK_ID_FLAG_STR = "-b"
 
static constexpr const char * BLOCK_ID_OPTION_STR = "--block"
 
static constexpr const char * BLOCK_ID_WORD_STR = "block"
 
static constexpr const char * BLOCK_ID_SHORT_STR = "b"
 
static constexpr const char * ROW_FLAG_STR = "-r"
 
static constexpr const char * ROW_OPTION_STR = "--rows"
 
static constexpr const char * ROW_WORD_STR = "rows"
 
static constexpr const char * ROW_SHORT_STR = "r"
 
static constexpr const char * COLUMN_FLAG_STR = "-c"
 
static constexpr const char * COLUMN_OPTION_STR = "--columns"
 
static constexpr const char * COLUMN_WORD_STR = "columns"
 
static constexpr const char * COLUMN_SHORT_STR = "c"
 
static constexpr const char * LEVEL_FLAG_STR = "-l"
 
static constexpr const char * LEVEL_OPTION_STR = "--levels"
 
static constexpr const char * LEVEL_WORD_STR = "levels"
 
static constexpr const char * LEVEL_SHORT_STR = "l"
 
static constexpr const char * JSON_FLAG_STR = "-j"
 
static constexpr const char * JSON_OPTION_STR = "--json"
 
static constexpr const char * JSON_WORD_STR = "json"
 
static constexpr const char * JSON_SHORT_STR = "j"
 
static constexpr const char * OUTPUT_ID_FLAG_STR = "-o"
 
static constexpr const char * OUTPUT_ID_OPTION_STR = "--output"
 
static constexpr const char * OUTPUT_ID_WORD_STR = "output"
 
static constexpr const char * OUTPUT_ID_SHORT_STR = "o"
 
static constexpr const char * DEFAULT_OUTPUT_FILENAME = "output.json"
 
static constexpr const char * SEED_FLAG_STR = "-s"
 
static constexpr const char * SEED_OPTION_STR = "--seed"
 
static constexpr const char * SEED_WORD_STR = "seed"
 
static constexpr const char * SEED_SHORT_STR = "s"
 
static constexpr const char * DISTANCES_FLAG_STR = "-d"
 
static constexpr const char * DISTANCES_OPTION_STR = "--distances"
 
static constexpr const char * DISTANCES_WORD_STR = "distances"
 
static constexpr const char * DISTANCES_SHORT_STR = "d"
 
static constexpr const char * DISTANCES_START_STR = "distances_start"
 
static constexpr const char * DISTANCES_END_STR = "distances_end"
 
static constexpr const char * DISTANCES_DEFAULT_START = "0"
 
static constexpr const char * DISTANCES_DEFAULT_END = "-1"
 
static constexpr const char * HELP_FLAG_STR = "-h"
 
static constexpr const char * HELP_OPTION_STR = "--help"
 
static constexpr const char * HELP_WORD_STR = "help"
 
static constexpr const char * HELP_SHORT_STR = "h"
 
static constexpr const char * VERSION_FLAG_STR = "-v"
 
static constexpr const char * VERSION_OPTION_STR = "--version"
 
static constexpr const char * VERSION_WORD_STR = "version"
 
static constexpr const char * VERSION_SHORT_STR = "v"
 
static constexpr const char * TRUE_VALUE = "true"
 

Detailed Description

Command-line argument handler with JSON support.

Uses PIMPL pattern to wrap CLI11 functionality with additional JSON support

Constructor & Destructor Documentation

◆ args() [1/3]

mazes::args::args ( )
noexcept

Default constructor.

Initializes the CLI11 app and sets up common options

◆ ~args()

mazes::args::~args ( )

Destructor.

Cleans up the internal implementation pointer

◆ args() [2/3]

mazes::args::args ( const args & other)

Copy constructor.

Parameters
otherThe other args object to copy from

◆ args() [3/3]

mazes::args::args ( args && other)
defaultnoexcept

Move constructor.

Parameters
otherThe other args object to move from

Member Function Documentation

◆ add_flag()

bool mazes::args::add_flag ( const std::string & flags,
const std::string & description )
noexcept

Add a new flag to the CLI parser.

Parameters
flagsCommand line flags (e.g., "-f,--flag")
descriptionHelp description for the flag
Returns
True if the flag was successfully added

◆ add_option()

bool mazes::args::add_option ( const std::string & flags,
const std::string & description )
noexcept

Add a new option to the CLI parser.

Parameters
flagsCommand line flags (e.g., "-x,--extra")
descriptionHelp description for the option
Returns
True if the option was successfully added

◆ get() [1/2]

const std::unordered_map< std::string, std::string > & mazes::args::get ( ) const
noexcept

Get entire args map.

Returns
Reference to the internal arguments map

◆ get() [2/2]

std::optional< std::string > mazes::args::get ( const std::string & key) const
noexcept

Get a value from the args map.

Parameters
keyThe key to look up
Returns
The value if found, std::nullopt otherwise

◆ get_all_configurations()

std::vector< std::unordered_map< std::string, std::string > > mazes::args::get_all_configurations ( ) const
noexcept

Get all configurations as a vector.

Returns
Vector of configuration maps

◆ get_configuration()

std::optional< std::unordered_map< std::string, std::string > > mazes::args::get_configuration ( size_t index) const
noexcept

Get configuration by index (0-based)

Parameters
indexThe index of the configuration to retrieve
Returns
Configuration map if index is valid, std::nullopt otherwise

◆ get_configuration_count()

size_t mazes::args::get_configuration_count ( ) const
noexcept

Get the number of configurations stored.

Returns
Number of configurations (1 for single config, >1 for arrays)

◆ has_multiple_configurations()

bool mazes::args::has_multiple_configurations ( ) const
noexcept

Check if we have multiple configurations (from JSON array)

Returns
True if multiple configurations are stored

◆ operator=() [1/2]

args & mazes::args::operator= ( args && other)
defaultnoexcept

Move assignment operator.

Parameters
otherThe other args object to move from
Returns
Reference to this object

◆ operator=() [2/2]

args & mazes::args::operator= ( const args & other)

Copy assignment operator.

Parameters
otherThe other args object to copy from
Returns
Reference to this object

◆ parse() [1/3]

bool mazes::args::parse ( const std::string & arguments)
noexcept

Parse program arguments from a string.

Parameters
argumentsSpace-delimited command-line arguments
Returns
True if parsing was successful

◆ parse() [2/3]

bool mazes::args::parse ( const std::vector< std::string > & arguments)
noexcept

Parse program arguments from a vector of strings.

Parameters
argumentsCommand-line arguments
Returns
True if parsing was successful

◆ parse() [3/3]

bool mazes::args::parse ( int argc,
char ** argv )
noexcept

Parse program arguments from argc/argv.

Parameters
argcArgument count
argvArgument values
Returns
True if parsing was successful

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