Steppable 0.0.1
A CAS project written from scratch in C++
Loading...
Searching...
No Matches
steppable::__internals::utils Namespace Reference

The namespace containing utility functions for the Steppable library. More...

Namespaces

namespace  colors
 A namespace containing functions to set the text color in an output stream.
 
namespace  colorsBg
 A namespace containing functions to set the background color in an output stream.
 
namespace  formats
 A namespace containing functions to set the text format in an output stream.
 

Classes

class  ProgramArgs
 This class is used by the program to parse command-line arguments. The class uses regular expressions to match and parse the command-line arguments. It supports switches, positional arguments, and keyword arguments. More...
 
struct  setw
 
struct  StringLiteral
 String literal workaround for templates. More...
 
class  Utf8CodePage
 A class that sets the console output code page to UTF-8 and enables VT mode. More...
 

Typedefs

using PosArgs = std::vector<std::string>
 This is the type of the positional arguments. It is equivalent to a vector of string_views.
 

Functions

bool isTerminal (const std::ostream &stream)
 Check if the output stream is a terminal.
 
std::ostream & reset (std::ostream &stream)
 Reset the text color and format to the default values.
 
std::filesystem::path getHomeDirectory ()
 
std::filesystem::path getConfDirectory ()
 
const std::regex KEYWORD_ARG_REGEX (R"(^-([a-zA-Z]*):(-?[0-9]+)$)")
 This is the correct format of a keyword argument.
 
const std::regex SWITCH_REGEX (R"(^([-+])([a-zA-Z]*)$)")
 This is the correct format of a switch.
 
void programSafeExit (const int status)
 Exit the program safely.
 
std::tm localtime_xp (std::time_t *timer)
 
template<typename NumberT>
void checkDecimalArg (const NumberT *decimal)
 Checks whether the decimal number is correctly specified.
 

Detailed Description

The namespace containing utility functions for the Steppable library.

Namespace for internal functions.

Note
This namespace should not be used by other programs outside of the Steppable core.

Typedef Documentation

◆ PosArgs

using steppable::__internals::utils::PosArgs = std::vector<std::string>

This is the type of the positional arguments. It is equivalent to a vector of string_views.

Function Documentation

◆ checkDecimalArg()

template<typename NumberT>
void steppable::__internals::utils::checkDecimalArg ( const NumberT * decimal)

Checks whether the decimal number is correctly specified.

Compares the argument decimal to MAX_DECIMALS. If too much decimals are requested, prints an error and quits the program.

Template Parameters
NumberTType of the number.
Parameters
decimalA pointer to the number of decimals.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ getConfDirectory()

std::filesystem::path steppable::__internals::utils::getConfDirectory ( )
Here is the call graph for this function:
Here is the caller graph for this function:

◆ getHomeDirectory()

std::filesystem::path steppable::__internals::utils::getHomeDirectory ( )
Here is the call graph for this function:
Here is the caller graph for this function:

◆ isTerminal()

bool steppable::__internals::utils::isTerminal ( const std::ostream & stream)

Check if the output stream is a terminal.

This function checks if the given output stream is associated with a terminal.

Parameters
[in]streamThe output stream to check.
Returns
true if the output stream is a terminal, false otherwise.
Here is the caller graph for this function:

◆ KEYWORD_ARG_REGEX()

const std::regex steppable::__internals::utils::KEYWORD_ARG_REGEX ( R"(^-([a-zA-Z]*):(-?[0-9]+)$)" )

This is the correct format of a keyword argument.

Here is the caller graph for this function:

◆ localtime_xp()

std::tm steppable::__internals::utils::localtime_xp ( std::time_t * timer)
inline
Here is the caller graph for this function:

◆ programSafeExit()

void steppable::__internals::utils::programSafeExit ( const int status)
inline

Exit the program safely.

This function exits the program safely with the given status code. On Windows, it uses std::quick_exit, and on macOS, it uses exit, because std::quick_exit is not implemented on macOS.

Parameters
[in]statusThe status code to exit with
Here is the caller graph for this function:

◆ reset()

std::ostream & steppable::__internals::utils::reset ( std::ostream & stream)

Reset the text color and format to the default values.

This function resets the text color and format to the default values.

Parameters
[in]streamThe output stream to reset.
Returns
The modified output stream.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ SWITCH_REGEX()

const std::regex steppable::__internals::utils::SWITCH_REGEX ( R"(^([-+])([a-zA-Z]*)$)" )

This is the correct format of a switch.

Here is the caller graph for this function:
Untitled