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

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

#include <args.h>

Public Types

using arg_map = std::unordered_map<std::string, std::string>

Public Member Functions

 args () noexcept
 Default constructor.
 ~args ()
 Destructor.
 args (const args &other)
 Copy constructor.
args & operator= (const args &other)
 Copy assignment operator.
 args (args &&other) noexcept
 Move constructor.
args & operator= (args &&other) noexcept
 Move assignment operator.
bool parse (const std::vector< std::string > &arguments, bool has_program_name_as_first_arg=false) const noexcept
 Parse program arguments from a vector of strings.
bool parse (const std::string &arguments, bool has_program_name_as_first_arg=false) const noexcept
 Parse program arguments from a string.
bool parse (int argc, char **argv, bool has_program_name_as_first_arg=false) const noexcept
 Parse program arguments from argc/argv.
void set (std::vector< arg_map > maps) const noexcept
 Replace all argument maps.
void clear () const noexcept
 Clear the arguments map.
std::optional< std::string > get (const std::string &key) const noexcept
 Get a value.
arg_map front () const noexcept
 Get args from front.
bool pop_front () const noexcept
 Remove the first parsed argument map.
std::vector< arg_map > get () const noexcept
 Get entire args map.
std::size_t count () const noexcept
 Get the number of argument maps.

Static Public Attributes

static constexpr auto APP_KEY = "app"
static constexpr auto ALGO_ID_FLAG_STR = "-a"
static constexpr auto ALGO_ID_OPTION_STR = "--algo"
static constexpr auto ALGO_ID_WORD_STR = "algo"
static constexpr auto ROW_FLAG_STR = "-r"
static constexpr auto ROW_OPTION_STR = "--rows"
static constexpr auto ROW_WORD_STR = "rows"
static constexpr auto COLUMN_FLAG_STR = "-c"
static constexpr auto COLUMN_OPTION_STR = "--columns"
static constexpr auto COLUMN_WORD_STR = "columns"
static constexpr auto LEVEL_FLAG_STR = "-l"
static constexpr auto LEVEL_OPTION_STR = "--levels"
static constexpr auto LEVEL_WORD_STR = "levels"
static constexpr auto JSON_FLAG_STR = "-j"
static constexpr auto JSON_OPTION_STR = "--json"
static constexpr auto JSON_WORD_STR = "json"
static constexpr auto OUTPUT_ID_FLAG_STR = "-o"
static constexpr auto OUTPUT_ID_OPTION_STR = "--output"
static constexpr auto OUTPUT_ID_WORD_STR = "output"
static constexpr auto SEED_FLAG_STR = "-s"
static constexpr auto SEED_OPTION_STR = "--seed"
static constexpr auto SEED_WORD_STR = "seed"
static constexpr auto DISTANCES_FLAG_STR = "-d"
static constexpr auto DISTANCES_OPTION_STR = "--distances"
static constexpr auto DISTANCES_WORD_STR = "distances"
static constexpr auto DISTANCES_START_VAL_STR = "distances_start"
static constexpr auto DISTANCES_END_VAL_STR = "distances_end"
static constexpr auto MASK_FLAG_STR = "-m"
static constexpr auto MASK_OPTION_STR = "--mask"
static constexpr auto MASK_WORD_STR = "mask"
static constexpr auto RAW_WORD_STR = "raw"
static constexpr auto TRUE_VALUE = "true"

Detailed Description

Command-line argument handler with 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)
noexcept

Move constructor.

Parameters
otherThe other args object to move from

Member Function Documentation

◆ count()

std::size_t mazes::args::count ( ) const
nodiscardnoexcept

Get the number of argument maps.

Returns
The number of argument maps

◆ front()

arg_map mazes::args::front ( ) const
nodiscardnoexcept

Get args from front.

Returns
The internal arguments map or empty map if not valid

◆ get() [1/2]

std::vector< arg_map > mazes::args::get ( ) const
nodiscardnoexcept

Get entire args map.

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
nodiscardnoexcept

Get a value.

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

◆ operator=() [1/2]

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

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 ) const
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 ) const
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 ) const
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

◆ pop_front()

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

Remove the first parsed argument map.

Returns
True if an argument map was removed

◆ set()

void mazes::args::set ( std::vector< arg_map > maps) const
noexcept

Replace all argument maps.

Parameters
mapsThe new argument maps

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