2012-01-23 07:41:05 +00:00
|
|
|
#ifndef CONSOLE_H
|
|
|
|
#define CONSOLE_H
|
|
|
|
|
|
|
|
#include <iostream>
|
|
|
|
#include <string>
|
2012-01-28 12:10:44 +00:00
|
|
|
#include <sstream>
|
2012-01-23 07:41:05 +00:00
|
|
|
|
|
|
|
// Just a Console Utility Library
|
|
|
|
class Console
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
// Basic
|
|
|
|
static void Get(char* value);
|
|
|
|
static void Get(std::string& value);
|
|
|
|
static void Print(const char* value);
|
|
|
|
static void Error(const char* value);
|
|
|
|
|
|
|
|
// Upper-Basic
|
|
|
|
static void PrintLn(const char* value);
|
|
|
|
static void ErrorLn(const char* value);
|
|
|
|
|
|
|
|
// Higher
|
2012-01-28 12:10:44 +00:00
|
|
|
//static void Ask(const char* question, char* answer);
|
|
|
|
//static void Ask(const char* question, std::string& answer);
|
2012-01-23 07:41:05 +00:00
|
|
|
|
2012-01-28 12:10:44 +00:00
|
|
|
template<class T>
|
|
|
|
static void Ask(const char* question, T& answer, std::ios_base::fmtflags flags = std::ios_base::dec)
|
|
|
|
{
|
|
|
|
std::stringstream _tmpstr;
|
|
|
|
std::string _tmp;
|
|
|
|
|
|
|
|
Print(question);
|
|
|
|
Get(_tmp);
|
|
|
|
|
|
|
|
_tmpstr << _tmp;
|
|
|
|
_tmpstr.flags(flags);
|
|
|
|
_tmpstr >> answer;
|
|
|
|
}
|
2012-01-23 07:41:05 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // CONSOLE_H
|