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