Pinned to some recent date
drivers/Stream.h@0:fb7af294d5d9, 2016-11-17 (annotated)
- Committer:
- Simon Cooksey
- Date:
- Thu Nov 17 16:43:53 2016 +0000
- Revision:
- 0:fb7af294d5d9
Initial commit
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Simon Cooksey |
0:fb7af294d5d9 | 1 | /* mbed Microcontroller Library |
Simon Cooksey |
0:fb7af294d5d9 | 2 | * Copyright (c) 2006-2013 ARM Limited |
Simon Cooksey |
0:fb7af294d5d9 | 3 | * |
Simon Cooksey |
0:fb7af294d5d9 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
Simon Cooksey |
0:fb7af294d5d9 | 5 | * you may not use this file except in compliance with the License. |
Simon Cooksey |
0:fb7af294d5d9 | 6 | * You may obtain a copy of the License at |
Simon Cooksey |
0:fb7af294d5d9 | 7 | * |
Simon Cooksey |
0:fb7af294d5d9 | 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
Simon Cooksey |
0:fb7af294d5d9 | 9 | * |
Simon Cooksey |
0:fb7af294d5d9 | 10 | * Unless required by applicable law or agreed to in writing, software |
Simon Cooksey |
0:fb7af294d5d9 | 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
Simon Cooksey |
0:fb7af294d5d9 | 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
Simon Cooksey |
0:fb7af294d5d9 | 13 | * See the License for the specific language governing permissions and |
Simon Cooksey |
0:fb7af294d5d9 | 14 | * limitations under the License. |
Simon Cooksey |
0:fb7af294d5d9 | 15 | */ |
Simon Cooksey |
0:fb7af294d5d9 | 16 | #ifndef MBED_STREAM_H |
Simon Cooksey |
0:fb7af294d5d9 | 17 | #define MBED_STREAM_H |
Simon Cooksey |
0:fb7af294d5d9 | 18 | |
Simon Cooksey |
0:fb7af294d5d9 | 19 | #include "platform/platform.h" |
Simon Cooksey |
0:fb7af294d5d9 | 20 | #include "drivers/FileLike.h" |
Simon Cooksey |
0:fb7af294d5d9 | 21 | #include <cstdarg> |
Simon Cooksey |
0:fb7af294d5d9 | 22 | |
Simon Cooksey |
0:fb7af294d5d9 | 23 | namespace mbed { |
Simon Cooksey |
0:fb7af294d5d9 | 24 | /** \addtogroup drivers */ |
Simon Cooksey |
0:fb7af294d5d9 | 25 | /** @{*/ |
Simon Cooksey |
0:fb7af294d5d9 | 26 | |
Simon Cooksey |
0:fb7af294d5d9 | 27 | extern void mbed_set_unbuffered_stream(FILE *_file); |
Simon Cooksey |
0:fb7af294d5d9 | 28 | extern int mbed_getc(FILE *_file); |
Simon Cooksey |
0:fb7af294d5d9 | 29 | extern char* mbed_gets(char *s, int size, FILE *_file); |
Simon Cooksey |
0:fb7af294d5d9 | 30 | |
Simon Cooksey |
0:fb7af294d5d9 | 31 | /** File stream |
Simon Cooksey |
0:fb7af294d5d9 | 32 | * |
Simon Cooksey |
0:fb7af294d5d9 | 33 | * @Note Synchronization level: Set by subclass |
Simon Cooksey |
0:fb7af294d5d9 | 34 | */ |
Simon Cooksey |
0:fb7af294d5d9 | 35 | class Stream : public FileLike { |
Simon Cooksey |
0:fb7af294d5d9 | 36 | |
Simon Cooksey |
0:fb7af294d5d9 | 37 | public: |
Simon Cooksey |
0:fb7af294d5d9 | 38 | Stream(const char *name=NULL); |
Simon Cooksey |
0:fb7af294d5d9 | 39 | virtual ~Stream(); |
Simon Cooksey |
0:fb7af294d5d9 | 40 | |
Simon Cooksey |
0:fb7af294d5d9 | 41 | int putc(int c); |
Simon Cooksey |
0:fb7af294d5d9 | 42 | int puts(const char *s); |
Simon Cooksey |
0:fb7af294d5d9 | 43 | int getc(); |
Simon Cooksey |
0:fb7af294d5d9 | 44 | char *gets(char *s, int size); |
Simon Cooksey |
0:fb7af294d5d9 | 45 | int printf(const char* format, ...); |
Simon Cooksey |
0:fb7af294d5d9 | 46 | int scanf(const char* format, ...); |
Simon Cooksey |
0:fb7af294d5d9 | 47 | int vprintf(const char* format, std::va_list args); |
Simon Cooksey |
0:fb7af294d5d9 | 48 | int vscanf(const char* format, std::va_list args); |
Simon Cooksey |
0:fb7af294d5d9 | 49 | |
Simon Cooksey |
0:fb7af294d5d9 | 50 | operator std::FILE*() {return _file;} |
Simon Cooksey |
0:fb7af294d5d9 | 51 | |
Simon Cooksey |
0:fb7af294d5d9 | 52 | protected: |
Simon Cooksey |
0:fb7af294d5d9 | 53 | virtual int close(); |
Simon Cooksey |
0:fb7af294d5d9 | 54 | virtual ssize_t write(const void* buffer, size_t length); |
Simon Cooksey |
0:fb7af294d5d9 | 55 | virtual ssize_t read(void* buffer, size_t length); |
Simon Cooksey |
0:fb7af294d5d9 | 56 | virtual off_t lseek(off_t offset, int whence); |
Simon Cooksey |
0:fb7af294d5d9 | 57 | virtual int isatty(); |
Simon Cooksey |
0:fb7af294d5d9 | 58 | virtual int fsync(); |
Simon Cooksey |
0:fb7af294d5d9 | 59 | virtual off_t flen(); |
Simon Cooksey |
0:fb7af294d5d9 | 60 | |
Simon Cooksey |
0:fb7af294d5d9 | 61 | virtual int _putc(int c) = 0; |
Simon Cooksey |
0:fb7af294d5d9 | 62 | virtual int _getc() = 0; |
Simon Cooksey |
0:fb7af294d5d9 | 63 | |
Simon Cooksey |
0:fb7af294d5d9 | 64 | std::FILE *_file; |
Simon Cooksey |
0:fb7af294d5d9 | 65 | |
Simon Cooksey |
0:fb7af294d5d9 | 66 | /* disallow copy constructor and assignment operators */ |
Simon Cooksey |
0:fb7af294d5d9 | 67 | private: |
Simon Cooksey |
0:fb7af294d5d9 | 68 | Stream(const Stream&); |
Simon Cooksey |
0:fb7af294d5d9 | 69 | Stream & operator = (const Stream&); |
Simon Cooksey |
0:fb7af294d5d9 | 70 | }; |
Simon Cooksey |
0:fb7af294d5d9 | 71 | |
Simon Cooksey |
0:fb7af294d5d9 | 72 | } // namespace mbed |
Simon Cooksey |
0:fb7af294d5d9 | 73 | |
Simon Cooksey |
0:fb7af294d5d9 | 74 | #endif |
Simon Cooksey |
0:fb7af294d5d9 | 75 | |
Simon Cooksey |
0:fb7af294d5d9 | 76 | /** @}*/ |