Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of mbed by
Diff: Stream.h
- Revision:
- 4:5d1359a283bc
- Parent:
- 1:6b7f447ca868
- Child:
- 8:00a04e5cd407
--- a/Stream.h Fri Nov 14 15:25:20 2008 +0000 +++ b/Stream.h Thu Nov 27 16:23:24 2008 +0000 @@ -5,31 +5,53 @@ #ifndef MBED_STREAM_H #define MBED_STREAM_H -#include "Base.h" +#include "FileLike.h" +#include <cstdio> namespace mbed { -class Stream : public Base { +class Stream : protected FileLike { public: - - Stream(); + + Stream(const char *name = NULL); + virtual ~Stream(); - int putc(int c); - int getc(); + int putc(int c) { + fflush(_file); + return std::fputc(c, _file); + } + int puts(const char *s) { + fflush(_file); + return std::fputs(s, _file); + } + int getc() { + fflush(_file); + return std::fgetc(_file); + } + char *gets(char *s, int size) { + fflush(_file); + return std::fgets(s,size,_file);; + } int printf(const char* format, ...); int scanf(const char* format, ...); - - int _backspace(); - + + operator std::FILE*() { return _file; } + protected: - virtual int _putc(int c) = 0; - virtual int _getc() = 0; + virtual int close(); + virtual ssize_t write(const void* buffer, size_t length); + virtual ssize_t read(void* buffer, size_t length); + virtual off_t lseek(off_t offset, int whence); + virtual int isatty(); + virtual int fsync(); - int _back; - int _last; - + virtual int _putc(int c) = 0; + virtual int _getc() = 0; + + std::FILE *_file; + }; } // namespace mbed