X-Git-Url: http://git.tdb.fi/?p=libs%2Fcore.git;a=blobdiff_plain;f=source%2Fconsole.h;fp=source%2Fconsole.h;h=439ee7b8a9ae0a53bdb974d4453a296314cfae42;hp=0000000000000000000000000000000000000000;hb=33a5613489bbb9d4eab5c8761af88f4c1352aad4;hpb=5ed3d4f2ff489d02661aaabb24d4182f76499926 diff --git a/source/console.h b/source/console.h new file mode 100644 index 0000000..439ee7b --- /dev/null +++ b/source/console.h @@ -0,0 +1,57 @@ +/* $Id$ + +This file is part of libmspio +Copyright © 2008 Mikko Rasa, Mikkosoft Productions +Distributed under the LGPL +*/ + +#ifndef MSP_IO_CONSOLE_H_ +#define MSP_IO_CONSOLE_H_ + +#include "base.h" + +namespace Msp { +namespace IO { + +/** +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 Base +{ +private: + Handle handle; + + Console(unsigned); +public: + ~Console(); + + virtual void set_block(bool); + + /** If local echo is enabled, characters will appear on the console as they + are typed. Can only be used on an input Console. */ + void set_local_echo(bool); + + /** If line buffering is enabled, input will only be available when a + newline is encountered. On some systems, this may also enable line editing. + Can only be used on an input Console. + */ + void set_line_buffer(bool); + + virtual Handle get_event_handle(); +private: + virtual unsigned do_write(const char *, unsigned); + virtual unsigned do_read(char *, unsigned); +public: + static Console &instance(unsigned); +}; + +extern Console &cin; +extern Console &cout; +extern Console &cerr; + +} // namespace IO +} // namespace Msp + +#endif