R-Type  2
Doom but in better
Loading...
Searching...
No Matches
RealMain.cpp File Reference

Entry point for processing command-line arguments and running the main application logic. More...

#include "RealMain.hpp"
Include dependency graph for RealMain.cpp:

Go to the source code of this file.

Functions

std::vector< std::string > extract_argument (char *arg)
 Extracts the flag and value from a command-line argument.
 
void process_given_argument (Main &main, const std::vector< std::string > &args, std::string const &binName)
 Process the single argument that is provided.
 
void process_arguments (Main &main, int argc, char **argv)
 Processes the command-line arguments and applies them to the main application object.
 
int RealMain (int argc, char **argv)
 The main function for initializing and running the application.
 

Detailed Description

Entry point for processing command-line arguments and running the main application logic.

Definition in file RealMain.cpp.

Function Documentation

◆ extract_argument()

std::vector< std::string > extract_argument ( char * arg)

Extracts the flag and value from a command-line argument.

This function parses a command-line argument to split it into a flag and value. For example, if the argument is --key=value, it will return a tuple ("key", "value"). If there is no = sign, it returns the flag with an empty value.

Parameters
argThe command-line argument as a C-style string.
Returns
A tuple containing the flag (as the first element) and the value (as the second element).

Definition at line 26 of file RealMain.cpp.

◆ process_arguments()

void process_arguments ( Main & main,
int argc,
char ** argv )

Processes the command-line arguments and applies them to the main application object.

This function iterates through the provided command-line arguments, parses them using extract_argument, and applies relevant changes to the application state.

Parameters
mainA reference to the main application object.
argcThe number of command-line arguments.
argvThe array of command-line arguments as C-style strings.

Definition at line 251 of file RealMain.cpp.

◆ process_given_argument()

void process_given_argument ( Main & main,
const std::vector< std::string > & args,
std::string const & binName )

Process the single argument that is provided.

Parameters
mainThe main class, initialised.
argsThe current argument
binNameThe name of the program binary.
Exceptions
CustomExceptions::HelpFound();This is an information that allows the program to know that the help flag was passed.
CustomExceptions::VersionFound();This is an information that allows the program to know that the version flag was passed.
CustomExceptions::InvalidPort(args[1]);This is an error informing the user that the port value they passed is invalid.
CustomExceptions::NoFlagParameter(args[0]);This is an error informing the user that a parameter was expected for the flag but was not found.
CustomExceptions::UnknownArgument(args[0]);This is an error informing the user that the flag they passed is unknown.
CustomExceptions::InvalidFrameLimit(args[1]);This is an error informing the user that the frame limit that was passed is invalid.
CustomExceptions::InvalidWindowWidth(args[1]);This is an error informing the user that the value for the window's width is invalid.
CustomExceptions::InvalidWindowHeight(args[1]);This is an error informing the user the the value for the window's height is invalid.

Definition at line 73 of file RealMain.cpp.

◆ RealMain()

int RealMain ( int argc,
char ** argv )

The main function for initializing and running the application.

This function serves as the entry point for the R-Type GUI application. It initializes the main application object, processes command-line arguments, and starts the application's execution loop. Exceptions are caught and logged, and an error code is returned if any issues occur.

Parameters
argcThe number of command-line arguments.
argvThe array of command-line arguments as C-style strings.
Returns
An integer status code: MY_SUCCESS (0) on successful execution, MY_ERROR (non-zero) on failure.

Definition at line 277 of file RealMain.cpp.