MolSim
Loading...
Searching...
No Matches
Namespaces | Macros | Functions | Variables
CLIUtils.h File Reference

Utility functions for console input / output. More...

#include <cstdlib>
#include <iostream>
#include <spdlog/spdlog.h>
#include <string>
#include <string_view>
#include <unordered_map>

Go to the source code of this file.

Namespaces

namespace  CLIUtils
 Namespace defining utility functions for handling console output.
 

Macros

#define OPTSTRING   "s:e:d:f:g:b:o:p:t:B:D:R:h"
 
#define BOLD_ON   "\033[1m"
 
#define BOLD_OFF   "\033[0m"
 
#define RED   "\e[0;31m"
 
#define YEL   "\e[0;33m"
 
#define GRN   "\e[0;32m"
 
#define RST   "\e[0m"
 

Functions

static std::string CLIUtils::getCompilerName ()
 Gets the name of the compiler used to build the program executable (or "unknown" if the compiler is not identifiable via macros).
 
static std::string CLIUtils::getBuildDate ()
 Gets the build date and time of the built executable as a string.
 
static void CLIUtils::printUsage ()
 Prints a usage string explaining the syntax of the main program.
 
static void CLIUtils::printHelp ()
 Prints a help string explaining the functionality of the main program.
 
static int CLIUtils::getPercentage (int x, int y)
 Gets the percentage as an integer from a fraction x / y.
 
static void CLIUtils::error (const char *msg, const std::string &opt="", bool usage=true, bool close=true)
 Prints an error message to stderr with the prefix "ERROR: ", optionally prints the usage string and exits with EXIT_FAILURE.
 

Variables

static std::string_view CLIUtils::filename {"./MolSim"}
 The filename of the executable (default: "./MolSim").
 
static std::unordered_map< char, std::string > CLIUtils::optionNames
 Mapping from getopt option characters to their full names.
 

Detailed Description

Utility functions for console input / output.

Date
2024-10-21

Macro Definition Documentation

◆ BOLD_OFF

#define BOLD_OFF   "\033[0m"

◆ BOLD_ON

#define BOLD_ON   "\033[1m"

◆ GRN

#define GRN   "\e[0;32m"

◆ OPTSTRING

#define OPTSTRING   "s:e:d:f:g:b:o:p:t:B:D:R:h"

◆ RED

#define RED   "\e[0;31m"

◆ RST

#define RST   "\e[0m"

◆ YEL

#define YEL   "\e[0;33m"