|
1D Heat Equation Solver 1.0
Computational Methods Assignment 2025
|
Utility functions for safe user input from the console. More...
#include <functional>#include <iostream>#include <limits>#include <string>

Go to the source code of this file.
Functions | |
| template<typename T> | |
| T | askForNumber (const std::string &prompt, const std::function< bool(T)> &isValid, const std::string &errorMessage) |
| Generic template for asking a numeric value from the user. | |
| int | askForInteger (const std::string &prompt, const std::function< bool(int)> &isValid, const std::string &errorMessage) |
| Ask for an integer value from the user. | |
| double | askForDouble (const std::string &prompt, const std::function< bool(double)> &isValid, const std::string &errorMessage) |
| Ask for a floating-point value from the user. | |
Utility functions for safe user input from the console.
Provides generic and typed functions to read and validate numeric values from the standard input stream, with customizable prompts and validation rules.
Definition in file user_input.h.
| double askForDouble | ( | const std::string & | prompt, |
| const std::function< bool(double)> & | isValid, | ||
| const std::string & | errorMessage ) |
Ask for a floating-point value from the user.
| prompt | Message shown before user input. |
| isValid | Validation function returning true if the input is acceptable. |
| errorMessage | Message displayed when validation fails. |
Ask for a floating-point value from the user.
Definition at line 17 of file user_input.cpp.


| int askForInteger | ( | const std::string & | prompt, |
| const std::function< bool(int)> & | isValid, | ||
| const std::string & | errorMessage ) |
Ask for an integer value from the user.
| prompt | Message shown before user input. |
| isValid | Validation function returning true if the input is acceptable. |
| errorMessage | Message displayed when validation fails. |
Ask for an integer value from the user.
Definition at line 6 of file user_input.cpp.

| T askForNumber | ( | const std::string & | prompt, |
| const std::function< bool(T)> & | isValid, | ||
| const std::string & | errorMessage ) |
Generic template for asking a numeric value from the user.
This function continuously asks the user for input until a valid number is provided and passes the validation rule.
| T | Type of number (int, double, etc.) |
| prompt | Message shown before user input. |
| isValid | Validation function returning true if the input is acceptable. |
| errorMessage | Message displayed when validation fails. |
Definition at line 30 of file user_input.h.
