#include <iostream>
#include <string>
#include <stdexcept>
#include <sstream>
#include <functional>
Go to the source code of this file.
|
template<typename T > |
T | ReadValue (const std::string &prompt, std::function< bool(T)> validator) |
| Reads a value of the given type T from the console.
|
|
template<typename T > |
T | ReadValue (const std::string &prompt) |
| See ReadValue<T>(const std::string&, std::function<bool(T)>)
|
|
template<> |
std::string | ReadValue< std::string > (const std::string &prompt, std::function< bool(std::string)> validator) |
|
template<typename T >
T ReadValue |
( |
const std::string & |
prompt, |
|
|
std::function< bool(T)> |
validator |
|
) |
| |
Reads a value of the given type T from the console.
- Parameters
-
prompt | Message to display before requiring a value to be entered in the console |
validator | A function that accepts that read value as argument and it must return true for the value to be considered valid int value = ReadValue<int>("Age: ", [](int val) { return val > 0 && val < 150; } |
template<typename T >
T ReadValue |
( |
const std::string & |
prompt | ) |
|
See ReadValue<T>(const std::string&, std::function<bool(T)>)
template<>
std::string ReadValue< std::string > |
( |
const std::string & |
prompt, |
|
|
std::function< bool(std::string)> |
validator |
|
) |
| |