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