2016-02-12 23:18:13 +01:00
|
|
|
#pragma once
|
|
|
|
#ifndef MESSMER_CPPUTILS_IO_DONTECHOSTDINTOSTDOUTRAII_H
|
|
|
|
#define MESSMER_CPPUTILS_IO_DONTECHOSTDINTOSTDOUTRAII_H
|
|
|
|
|
2018-09-27 04:46:39 +02:00
|
|
|
#include <cpp-utils/pointer/unique_ref.h>
|
2016-02-12 23:18:13 +01:00
|
|
|
#include "../macros.h"
|
|
|
|
|
|
|
|
/**
|
|
|
|
* If you create an instance of this class in your scope, then any user input from stdin
|
|
|
|
* won't be echoed back to stdout until the instance leaves the scope.
|
|
|
|
* This can be very handy for password inputs where you don't want the password to be visible on screen.
|
|
|
|
*/
|
2018-05-19 15:29:28 +02:00
|
|
|
|
|
|
|
namespace cpputils {
|
|
|
|
|
2018-09-27 04:46:39 +02:00
|
|
|
namespace details {
|
|
|
|
class _DontEchoStdinToStdoutRAII;
|
2016-02-12 23:18:13 +01:00
|
|
|
}
|
|
|
|
|
2018-05-19 15:29:28 +02:00
|
|
|
class DontEchoStdinToStdoutRAII final {
|
|
|
|
public:
|
2018-09-27 04:46:39 +02:00
|
|
|
DontEchoStdinToStdoutRAII();
|
|
|
|
~DontEchoStdinToStdoutRAII();
|
2018-05-19 15:29:28 +02:00
|
|
|
private:
|
2018-09-27 04:46:39 +02:00
|
|
|
cpputils::unique_ref<details::_DontEchoStdinToStdoutRAII> raii;
|
2018-05-19 15:29:28 +02:00
|
|
|
|
|
|
|
DISALLOW_COPY_AND_ASSIGN(DontEchoStdinToStdoutRAII);
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|