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