Maze Builder Docs 7.5.6
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, bool has_program_name_as_first_arg=false) noexcept
 Parse program arguments from a vector of strings.
 
bool parse (const std::string &arguments, bool has_program_name_as_first_arg=false) noexcept
 Parse program arguments from a string.
 
bool parse (int argc, char **argv, bool has_program_name_as_first_arg=false) 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 (from front)
 
std::optional< std::unordered_map< std::string, std::string > > get () const noexcept
 Get entire args map (from front)
 
std::optional< std::vector< std::unordered_map< std::string, std::string > > > get_array () const noexcept
 Get vector of args maps (useful for JSON parsing with array of objects)
 

Static Public Attributes

static constexpr const auto APP_KEY = "app"
 
static constexpr const auto ALGO_ID_FLAG_STR = "-a"
 
static constexpr const auto ALGO_ID_OPTION_STR = "--algo"
 
static constexpr const auto ALGO_ID_WORD_STR = "algo"
 
static constexpr const auto BLOCK_ID_FLAG_STR = "-b"
 
static constexpr const auto BLOCK_ID_OPTION_STR = "--block"
 
static constexpr const auto BLOCK_ID_WORD_STR = "block"
 
static constexpr const auto ROW_FLAG_STR = "-r"
 
static constexpr const auto ROW_OPTION_STR = "--rows"
 
static constexpr const auto ROW_WORD_STR = "rows"
 
static constexpr const auto COLUMN_FLAG_STR = "-c"
 
static constexpr const auto COLUMN_OPTION_STR = "--columns"
 
static constexpr const auto COLUMN_WORD_STR = "columns"
 
static constexpr const auto LEVEL_FLAG_STR = "-l"
 
static constexpr const auto LEVEL_OPTION_STR = "--levels"
 
static constexpr const auto LEVEL_WORD_STR = "levels"
 
static constexpr const auto JSON_FLAG_STR = "-j"
 
static constexpr const auto JSON_OPTION_STR = "--json"
 
static constexpr const auto JSON_WORD_STR = "json"
 
static constexpr const auto OUTPUT_ID_FLAG_STR = "-o"
 
static constexpr const auto OUTPUT_ID_OPTION_STR = "--output"
 
static constexpr const auto OUTPUT_ID_WORD_STR = "output"
 
static constexpr const auto DEFAULT_OUTPUT_FILENAME = "maze.txt"
 
static constexpr const auto OUTPUT_FILENAME_WORD_STR = "output_filename"
 
static constexpr const auto SEED_FLAG_STR = "-s"
 
static constexpr const auto SEED_OPTION_STR = "--seed"
 
static constexpr const auto SEED_WORD_STR = "seed"
 
static constexpr const auto DISTANCES_FLAG_STR = "-d"
 
static constexpr const auto DISTANCES_OPTION_STR = "--distances"
 
static constexpr const auto DISTANCES_WORD_STR = "distances"
 
static constexpr const auto DISTANCES_START_STR = "distances_start"
 
static constexpr const auto DISTANCES_END_STR = "distances_end"
 
static constexpr const auto HELP_FLAG_STR = "-h"
 
static constexpr const auto HELP_OPTION_STR = "--help"
 
static constexpr const auto HELP_WORD_STR = "help"
 
static constexpr const auto VERSION_FLAG_STR = "-v"
 
static constexpr const auto VERSION_OPTION_STR = "--version"
 
static constexpr const auto VERSION_WORD_STR = "version"
 
static constexpr const auto TRUE_VALUE = "true"
 
static constexpr const auto FALSE_VALUE = "false"
 

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 implementation pointer

◆ ~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

◆ get() [1/2]

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

Get entire args map (from front)

Returns
The internal arguments map or empty map if not valid

◆ get() [2/2]

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

Get a value from the args map (from front)

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

◆ get_array()

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

Get vector of args maps (useful for JSON parsing with array of objects)

Returns
The internal arguments map vector or empty vector if not valid

◆ 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,
bool has_program_name_as_first_arg = false )
noexcept

Parse program arguments from a string.

Parameters
argumentsSpace-delimited command-line arguments
has_program_name_as_first_argWhether the first argument is the program name
Returns
True if parsing was successful

◆ parse() [2/3]

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

Parse program arguments from a vector of strings.

Parameters
argumentsCommand-line arguments
has_program_name_as_first_argWhether the first argument is the program name
Returns
True if parsing was successful

◆ parse() [3/3]

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

Parse program arguments from argc/argv.

Parameters
argcArgument count
argvArgument values
has_program_name_as_first_argWhether the first argument is the program name
Returns
True if parsing was successful

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