X-Git-Url: http://git.tdb.fi/?p=libs%2Fcore.git;a=blobdiff_plain;f=source%2Fio%2Fconsole.h;h=ac66288832966bd4bf67355519ce2bed5d43170a;hp=7b7887be80332fea89ddb24b320e7fc93a606e1a;hb=HEAD;hpb=651cfe05e867ffdef9028a831add3eca54d19d0d diff --git a/source/io/console.h b/source/io/console.h index 7b7887b..fe777cc 100644 --- a/source/io/console.h +++ b/source/io/console.h @@ -1,6 +1,7 @@ #ifndef MSP_IO_CONSOLE_H_ #define MSP_IO_CONSOLE_H_ +#include #include "eventobject.h" #include "handle.h" @@ -12,7 +13,7 @@ Provides access to standard input, output and error streams. This class can't be instantiated directly - use one of the cin, cout and cerr references instead. */ -class Console: public EventObject +class MSPCORE_API Console: public EventObject { public: enum Stream @@ -27,10 +28,12 @@ private: Handle handle; Console(Stream); + void platform_init(); public: ~Console(); - virtual void set_block(bool); + void set_block(bool) override; + void set_inherit(bool) override; /** If local echo is enabled, characters will appear on the console as they are typed. Can only be used on an input Console. */ @@ -52,18 +55,20 @@ public: void redirect(Base &); protected: - virtual unsigned do_write(const char *, unsigned); - virtual unsigned do_read(char *, unsigned); + std::size_t do_write(const char *, std::size_t) override; + std::size_t do_read(char *, std::size_t) override; public: - virtual const Handle &get_event_handle() { return handle; } + const Handle &get_handle(Mode) override; + const Handle &get_event_handle() override { return handle; } static Console &instance(Stream); }; -extern Console &cin; -extern Console &cout; -extern Console &cerr; +// TODO make these inline instead of static when upgrading to C++17. +static Console &cin = Console::instance(Console::CIN); +static Console &cout = Console::instance(Console::COUT); +static Console &cerr = Console::instance(Console::CERR); } // namespace IO } // namespace Msp