pure-cpp 1.0.0
A C++ physics simulation benchmark comparing performance with Python implementations
cmd_line_parser.hpp File Reference

Command-line argument parsing and validation. More...

#include <QCoreApplication>
#include <QDebug>
#include <QObject>
#include <QString>
#include <boost/program_options.hpp>
#include <config.hpp>
#include <cstddef>
#include <iostream>
#include <memory>
#include <sstream>
#include <string>
#include "constants.hpp"
Include dependency graph for cmd_line_parser.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

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

Namespaces

namespace  CmdLine
 Namespace for command-line parsing logic.
 

Enumerations

enum class  CmdLine::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  CmdLine::LogLevel {
  Debug , Info , Warning , Critical ,
  Fatal
}
 Log level for the application. More...
 

Functions

std::ostream & CmdLine::operator<< (std::ostream &os, const LogLevel &level)
 Overload of operator<< for LogLevel to enable streaming. More...
 
std::string CmdLine::toStringWithPrecision (double value, int precision=1, bool use_scientific=true)
 Converts a double to a string with a specified precision for display. More...
 
void CmdLine::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 & CmdLine::operator>> (std::istream &is, LogLevel &level)
 Overload of operator>> for Boost.Program_Options to parse LogLevel. More...
 

Detailed Description

Command-line argument parsing and validation.

Author
Le Bars, Yoann

This file is part of the pure C++ benchmark.

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see https://www.gnu.org/licenses/.

Definition in file cmd_line_parser.hpp.