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