Aggie Student Toolkit — Load Balancer CSCE 412 Project 4
Arnav Fotedar · Fall 2026 · C++ load balancer simulation
Loading...
Searching...
No Matches
Config.cpp File Reference

Implements command-line parsing, interactive prompts and validation for Config. More...

#include "Config.h"
#include <istream>
#include <ostream>
#include <random>
#include <sstream>
#include <type_traits>
#include "Firewall.h"

Go to the source code of this file.

Functions

void printUsage (std::ostream &out, const std::string &program)
 Prints the list of command-line options.
bool parseArguments (int argc, char *argv[], Config &config, std::string &error)
 Reads command-line options into a Config.
void promptForSettings (Config &config, std::istream &in, std::ostream &out)
 Asks the user for the main settings, keeping the current value when the answer is blank.
bool validateConfig (const Config &config, std::string &error)
 Checks that the settings are consistent.

Detailed Description

Implements command-line parsing, interactive prompts and validation for Config.

Author
Arnav Fotedar

Definition in file Config.cpp.

Function Documentation

◆ printUsage()

void printUsage ( std::ostream & out,
const std::string & program )

Prints the list of command-line options.

Parameters
outStream to write to.
programProgram name shown in the usage line.

Definition at line 61 of file Config.cpp.

◆ parseArguments()

bool parseArguments ( int argc,
char * argv[],
Config & config,
std::string & error )

Reads command-line options into a Config.

Running with no options (or only –no-color) turns on interactive mode so the user is asked for the main settings.

Parameters
argcArgument count from main().
argvArgument values from main().
configReceives the parsed settings.
errorReceives a message when parsing fails.
Returns
False if an option is unknown or a value is malformed.

Definition at line 95 of file Config.cpp.

◆ promptForSettings()

void promptForSettings ( Config & config,
std::istream & in,
std::ostream & out )

Asks the user for the main settings, keeping the current value when the answer is blank.

Parameters
configSettings to update.
inStream to read answers from.
outStream to write questions to.

Definition at line 201 of file Config.cpp.

◆ validateConfig()

bool validateConfig ( const Config & config,
std::string & error )

Checks that the settings are consistent.

Parameters
configSettings to check.
errorReceives a message describing the first problem found.
Returns
True if the settings can be simulated.

Definition at line 214 of file Config.cpp.