2015-06-24 00:44:16 +02:00
|
|
|
#ifndef APPLICATIONUTILITIES_COMMANDLINEUTILS_H
|
|
|
|
#define APPLICATIONUTILITIES_COMMANDLINEUTILS_H
|
|
|
|
|
2016-08-29 15:35:48 +02:00
|
|
|
#include "../global.h"
|
2015-06-24 00:44:16 +02:00
|
|
|
|
2016-10-02 21:53:58 +02:00
|
|
|
#include <ostream>
|
|
|
|
|
2015-06-24 00:44:16 +02:00
|
|
|
namespace ApplicationUtilities {
|
|
|
|
|
2016-07-02 02:02:47 +02:00
|
|
|
/*!
|
|
|
|
* \brief The Response enum is used to specify the default response for the confirmPrompt() method.
|
|
|
|
*/
|
2015-06-24 00:44:16 +02:00
|
|
|
enum class Response
|
|
|
|
{
|
|
|
|
None,
|
|
|
|
Yes,
|
|
|
|
No
|
|
|
|
};
|
|
|
|
|
2016-08-29 15:35:48 +02:00
|
|
|
bool CPP_UTILITIES_EXPORT confirmPrompt(const char *message, Response defaultResponse = Response::None);
|
2015-06-24 00:44:16 +02:00
|
|
|
|
2015-09-01 20:05:38 +02:00
|
|
|
#ifdef PLATFORM_WINDOWS
|
2016-08-29 15:35:48 +02:00
|
|
|
void CPP_UTILITIES_EXPORT startConsole();
|
2016-01-27 02:17:06 +01:00
|
|
|
# define CMD_UTILS_START_CONSOLE ::ApplicationUtilities::startConsole();
|
2015-09-01 20:05:38 +02:00
|
|
|
#else
|
2016-01-27 02:17:06 +01:00
|
|
|
# define CMD_UTILS_START_CONSOLE
|
2015-09-01 20:05:38 +02:00
|
|
|
#endif
|
|
|
|
|
2016-10-02 21:53:58 +02:00
|
|
|
/*!
|
|
|
|
* \brief The Indent class allows printing indentation conveniently, eg. cout << Ident(4) << ...
|
|
|
|
*/
|
|
|
|
class CPP_UTILITIES_EXPORT Indentation
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
Indentation(unsigned char level = 4, char character = ' ') :
|
|
|
|
level(level),
|
|
|
|
character(character)
|
|
|
|
{}
|
|
|
|
|
|
|
|
Indentation operator +(unsigned char level)
|
|
|
|
{
|
|
|
|
return Indentation(this->level + level, character);
|
|
|
|
}
|
|
|
|
|
|
|
|
unsigned char level;
|
|
|
|
char character;
|
|
|
|
};
|
|
|
|
|
|
|
|
inline CPP_UTILITIES_EXPORT std::ostream &operator<< (std::ostream &out, Indentation indentation)
|
|
|
|
{
|
|
|
|
for(unsigned char i = 0; i < indentation.level; ++i) {
|
|
|
|
out << indentation.character;
|
|
|
|
}
|
|
|
|
return out;
|
|
|
|
}
|
|
|
|
|
2015-06-24 00:44:16 +02:00
|
|
|
} // namespace ApplicationUtilities
|
|
|
|
|
|
|
|
#endif // APPLICATIONUTILITIES_COMMANDLINEUTILS_H
|