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