nothing changed
Fork of mbed by
Stream.h@1:27d81db81dd7, 2015-03-03 (annotated)
- Committer:
- Jing_Qiu
- Date:
- Tue Mar 03 00:55:57 2015 +0000
- Revision:
- 1:27d81db81dd7
- Parent:
- 0:a8fa94490a0a
revise
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
gokmenascioglu | 0:a8fa94490a0a | 1 | /* mbed Microcontroller Library - Stream |
gokmenascioglu | 0:a8fa94490a0a | 2 | * Copyright (c) 2007-2009 ARM Limited. All rights reserved. |
gokmenascioglu | 0:a8fa94490a0a | 3 | */ |
gokmenascioglu | 0:a8fa94490a0a | 4 | |
gokmenascioglu | 0:a8fa94490a0a | 5 | #ifndef MBED_STREAM_H |
gokmenascioglu | 0:a8fa94490a0a | 6 | #define MBED_STREAM_H |
gokmenascioglu | 0:a8fa94490a0a | 7 | |
gokmenascioglu | 0:a8fa94490a0a | 8 | #include "FileLike.h" |
gokmenascioglu | 0:a8fa94490a0a | 9 | #include "platform.h" |
gokmenascioglu | 0:a8fa94490a0a | 10 | #include <cstdio> |
gokmenascioglu | 0:a8fa94490a0a | 11 | |
gokmenascioglu | 0:a8fa94490a0a | 12 | namespace mbed { |
gokmenascioglu | 0:a8fa94490a0a | 13 | |
gokmenascioglu | 0:a8fa94490a0a | 14 | class Stream : public FileLike { |
gokmenascioglu | 0:a8fa94490a0a | 15 | |
gokmenascioglu | 0:a8fa94490a0a | 16 | public: |
gokmenascioglu | 0:a8fa94490a0a | 17 | |
gokmenascioglu | 0:a8fa94490a0a | 18 | Stream(const char *name = NULL); |
gokmenascioglu | 0:a8fa94490a0a | 19 | virtual ~Stream(); |
gokmenascioglu | 0:a8fa94490a0a | 20 | |
gokmenascioglu | 0:a8fa94490a0a | 21 | int putc(int c) { |
gokmenascioglu | 0:a8fa94490a0a | 22 | fflush(_file); |
gokmenascioglu | 0:a8fa94490a0a | 23 | return std::fputc(c, _file); |
gokmenascioglu | 0:a8fa94490a0a | 24 | } |
gokmenascioglu | 0:a8fa94490a0a | 25 | int puts(const char *s) { |
gokmenascioglu | 0:a8fa94490a0a | 26 | fflush(_file); |
gokmenascioglu | 0:a8fa94490a0a | 27 | return std::fputs(s, _file); |
gokmenascioglu | 0:a8fa94490a0a | 28 | } |
gokmenascioglu | 0:a8fa94490a0a | 29 | int getc() { |
gokmenascioglu | 0:a8fa94490a0a | 30 | fflush(_file); |
gokmenascioglu | 0:a8fa94490a0a | 31 | return std::fgetc(_file); |
gokmenascioglu | 0:a8fa94490a0a | 32 | } |
gokmenascioglu | 0:a8fa94490a0a | 33 | char *gets(char *s, int size) { |
gokmenascioglu | 0:a8fa94490a0a | 34 | fflush(_file); |
gokmenascioglu | 0:a8fa94490a0a | 35 | return std::fgets(s,size,_file);; |
gokmenascioglu | 0:a8fa94490a0a | 36 | } |
gokmenascioglu | 0:a8fa94490a0a | 37 | int printf(const char* format, ...); |
gokmenascioglu | 0:a8fa94490a0a | 38 | int scanf(const char* format, ...); |
gokmenascioglu | 0:a8fa94490a0a | 39 | |
gokmenascioglu | 0:a8fa94490a0a | 40 | operator std::FILE*() { return _file; } |
gokmenascioglu | 0:a8fa94490a0a | 41 | |
gokmenascioglu | 0:a8fa94490a0a | 42 | #ifdef MBED_RPC |
gokmenascioglu | 0:a8fa94490a0a | 43 | virtual const struct rpc_method *get_rpc_methods(); |
gokmenascioglu | 0:a8fa94490a0a | 44 | #endif |
gokmenascioglu | 0:a8fa94490a0a | 45 | |
gokmenascioglu | 0:a8fa94490a0a | 46 | protected: |
gokmenascioglu | 0:a8fa94490a0a | 47 | |
gokmenascioglu | 0:a8fa94490a0a | 48 | virtual int close(); |
gokmenascioglu | 0:a8fa94490a0a | 49 | virtual ssize_t write(const void* buffer, size_t length); |
gokmenascioglu | 0:a8fa94490a0a | 50 | virtual ssize_t read(void* buffer, size_t length); |
gokmenascioglu | 0:a8fa94490a0a | 51 | virtual off_t lseek(off_t offset, int whence); |
gokmenascioglu | 0:a8fa94490a0a | 52 | virtual int isatty(); |
gokmenascioglu | 0:a8fa94490a0a | 53 | virtual int fsync(); |
gokmenascioglu | 0:a8fa94490a0a | 54 | virtual off_t flen(); |
gokmenascioglu | 0:a8fa94490a0a | 55 | |
gokmenascioglu | 0:a8fa94490a0a | 56 | virtual int _putc(int c) = 0; |
gokmenascioglu | 0:a8fa94490a0a | 57 | virtual int _getc() = 0; |
gokmenascioglu | 0:a8fa94490a0a | 58 | |
gokmenascioglu | 0:a8fa94490a0a | 59 | std::FILE *_file; |
gokmenascioglu | 0:a8fa94490a0a | 60 | |
gokmenascioglu | 0:a8fa94490a0a | 61 | }; |
gokmenascioglu | 0:a8fa94490a0a | 62 | |
gokmenascioglu | 0:a8fa94490a0a | 63 | } // namespace mbed |
gokmenascioglu | 0:a8fa94490a0a | 64 | |
gokmenascioglu | 0:a8fa94490a0a | 65 | #endif |
gokmenascioglu | 0:a8fa94490a0a | 66 |