Raven Engine v0.1
Loading...
Searching...
No Matches
Raven::ArgParser Class Reference

#include <ArgParser.h>

Public Member Functions

 ArgParser (int argc, char **argv)
 Constructs the ArgParser and parses the command line arguments.
bool HasFlag (std::string_view key) const noexcept
 Checks whether the specified flag (key without value) was provided.
std::optional< std::string_view > GetValue (std::string_view key) const noexcept
 Retrieves the value associated with the specified key.
const std::vector< std::string_view > & GetPositionalArgs () const noexcept
 Returns all positional arguments that were not parsed as flags or key-values.

Constructor & Destructor Documentation

◆ ArgParser()

Raven::ArgParser::ArgParser ( int argc,
char ** argv )
inline

Constructs the ArgParser and parses the command line arguments.

Parses the argc/argv array immediately on construction, storing flags, key-value pairs, and positional arguments for later querying.

Parameters
argcThe argument count.
argvThe argument vector.

Member Function Documentation

◆ GetPositionalArgs()

const std::vector< std::string_view > & Raven::ArgParser::GetPositionalArgs ( ) const
inlinenoexcept

Returns all positional arguments that were not parsed as flags or key-values.

Positional arguments are those without any leading "--", typically filenames or other inputs.

Returns
A const reference to the vector of positional argument string_views.

◆ GetValue()

std::optional< std::string_view > Raven::ArgParser::GetValue ( std::string_view key) const
inlinenoexcept

Retrieves the value associated with the specified key.

Key-value pairs are arguments where a key (starting with "--") is followed by a value, e.g. "--project MyProject.ravenproj".

Parameters
keyThe key name to look up, including the "--" prefix.
Returns
An optional containing the value if found; std::nullopt otherwise.

◆ HasFlag()

bool Raven::ArgParser::HasFlag ( std::string_view key) const
inlinenoexcept

Checks whether the specified flag (key without value) was provided.

Flags are command line arguments starting with "--" that do not have a following value, e.g. "--devmode".

Parameters
keyThe flag name to check, including the "--" prefix.
Returns
true if the flag is present; false otherwise.

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