pure-cpp 1.0.0
A C++ physics simulation benchmark comparing performance with Python implementations
CmdLine Namespace Reference

Namespace for command-line parsing logic. More...

Classes

struct  CmdLineArgs
 Holds and parses command-line arguments. More...
 
struct  OptionDefinition
 A struct to hold the definition of a single command-line option. More...
 

Enumerations

enum class  ExitCode : int {
  Success = 0 , CmdLineError = -1 , NotEnoughIterations = -2 , NotEnoughBodies = -3 ,
  NegativeDensity = -4 , NegativeTimeStep = -5 , NegativeGravity = -6 , NegativeEpsilon = -7 ,
  OutOfRange = -8 , BadAlloc = -9 , StdException = -10 , UnknownException = -11
}
 Exit codes for the application. More...
 
enum class  LogLevel {
  Debug , Info , Warning , Critical ,
  Fatal
}
 Log level for the application. More...
 

Functions

std::ostream & operator<< (std::ostream &os, const LogLevel &level)
 Overload of operator<< for LogLevel to enable streaming. More...
 
std::string toStringWithPrecision (double value, int precision=1, bool use_scientific=true)
 Converts a double to a string with a specified precision for display. More...
 
void validateIsPositive ( const std::size_t &value, const std::string &option_name, const std::function< QString(const char *)> &tr_func)
 Validates that an unsigned integer option is greater than zero. More...
 
std::istream & operator>> (std::istream &is, LogLevel &level)
 Overload of operator>> for Boost.Program_Options to parse LogLevel. More...
 

Detailed Description

Namespace for command-line parsing logic.

Enumeration Type Documentation

◆ ExitCode

enum class CmdLine::ExitCode : int
strong

Exit codes for the application.

Definition at line 45 of file cmd_line_parser.hpp.

◆ LogLevel

enum class CmdLine::LogLevel
strong

Log level for the application.

Definition at line 61 of file cmd_line_parser.hpp.

Function Documentation

◆ operator<<()

std::ostream & CmdLine::operator<< ( std::ostream &  os,
const LogLevel level 
)
inline

Overload of operator<< for LogLevel to enable streaming.

This is required by boost::program_options for displaying default values in the help message.

Parameters
osThe output stream.
levelThe LogLevel enum to stream.
Returns
The output stream.

Definition at line 79 of file cmd_line_parser.hpp.

◆ operator>>()

std::istream & CmdLine::operator>> ( std::istream &  is,
LogLevel level 
)
inline

Overload of operator>> for Boost.Program_Options to parse LogLevel.

Parameters
isThe input stream.
levelThe LogLevel enum to populate.
Returns
The input stream.

Definition at line 133 of file cmd_line_parser.hpp.

◆ toStringWithPrecision()

std::string CmdLine::toStringWithPrecision ( double  value,
int  precision = 1,
bool  use_scientific = true 
)
inline

Converts a double to a string with a specified precision for display.

Parameters
valueThe double value to convert.
precisionThe number of digits of precision.
use_scientificIf true, uses scientific notation; otherwise, uses fixed.
Returns
A string representation of the double.

Definition at line 106 of file cmd_line_parser.hpp.

◆ validateIsPositive()

void CmdLine::validateIsPositive ( const std::size_t &  value,
const std::string &  option_name,
const std::function< QString(const char *)> &  tr_func 
)
inline

Validates that an unsigned integer option is greater than zero.

Parameters
valueThe value of the option to validate.
option_nameThe name of the option, used for the error message.
Exceptions
po::validation_errorif the value is zero.

This is a custom validator for use with Boost.Program_Options.

Definition at line 690 of file cmd_line_parser.hpp.

Here is the caller graph for this function: