mbed library sources. Supersedes mbed-src.
Dependents: SPIne CH_Communicatuin_Test CH_Communicatuin_Test2 MCP_SPIne ... more
Fork of mbed-dev-f303 by
platform/Stream.h@168:9672193075cf, 2017-07-06 (annotated)
- Committer:
- AnnaBridge
- Date:
- Thu Jul 06 15:42:05 2017 +0100
- Revision:
- 168:9672193075cf
- Parent:
- 167:e84263d55307
This updates the lib to the mbed lib v 146
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
AnnaBridge | 167:e84263d55307 | 1 | /* mbed Microcontroller Library |
AnnaBridge | 167:e84263d55307 | 2 | * Copyright (c) 2006-2013 ARM Limited |
AnnaBridge | 167:e84263d55307 | 3 | * |
AnnaBridge | 167:e84263d55307 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
AnnaBridge | 167:e84263d55307 | 5 | * you may not use this file except in compliance with the License. |
AnnaBridge | 167:e84263d55307 | 6 | * You may obtain a copy of the License at |
AnnaBridge | 167:e84263d55307 | 7 | * |
AnnaBridge | 167:e84263d55307 | 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
AnnaBridge | 167:e84263d55307 | 9 | * |
AnnaBridge | 167:e84263d55307 | 10 | * Unless required by applicable law or agreed to in writing, software |
AnnaBridge | 167:e84263d55307 | 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
AnnaBridge | 167:e84263d55307 | 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
AnnaBridge | 167:e84263d55307 | 13 | * See the License for the specific language governing permissions and |
AnnaBridge | 167:e84263d55307 | 14 | * limitations under the License. |
AnnaBridge | 167:e84263d55307 | 15 | */ |
AnnaBridge | 167:e84263d55307 | 16 | #ifndef MBED_STREAM_H |
AnnaBridge | 167:e84263d55307 | 17 | #define MBED_STREAM_H |
AnnaBridge | 167:e84263d55307 | 18 | |
AnnaBridge | 167:e84263d55307 | 19 | #include "platform/platform.h" |
AnnaBridge | 167:e84263d55307 | 20 | #include "platform/FileLike.h" |
AnnaBridge | 167:e84263d55307 | 21 | #include "platform/FileHandle.h" |
AnnaBridge | 168:9672193075cf | 22 | #include "platform/NonCopyable.h" |
AnnaBridge | 167:e84263d55307 | 23 | #include <cstdio> |
AnnaBridge | 167:e84263d55307 | 24 | #include <cstdarg> |
AnnaBridge | 167:e84263d55307 | 25 | |
AnnaBridge | 167:e84263d55307 | 26 | namespace mbed { |
AnnaBridge | 167:e84263d55307 | 27 | /** \addtogroup platform */ |
AnnaBridge | 167:e84263d55307 | 28 | /** @{*/ |
AnnaBridge | 167:e84263d55307 | 29 | |
AnnaBridge | 167:e84263d55307 | 30 | extern void mbed_set_unbuffered_stream(std::FILE *_file); |
AnnaBridge | 167:e84263d55307 | 31 | extern int mbed_getc(std::FILE *_file); |
AnnaBridge | 167:e84263d55307 | 32 | extern char* mbed_gets(char *s, int size, std::FILE *_file); |
AnnaBridge | 167:e84263d55307 | 33 | /** @}*/ |
AnnaBridge | 167:e84263d55307 | 34 | |
AnnaBridge | 167:e84263d55307 | 35 | /** File stream |
AnnaBridge | 167:e84263d55307 | 36 | * |
AnnaBridge | 167:e84263d55307 | 37 | * @note Synchronization level: Set by subclass |
AnnaBridge | 167:e84263d55307 | 38 | * @ingroup platform |
AnnaBridge | 167:e84263d55307 | 39 | */ |
AnnaBridge | 168:9672193075cf | 40 | class Stream : public FileLike, private NonCopyable<Stream> { |
AnnaBridge | 167:e84263d55307 | 41 | |
AnnaBridge | 167:e84263d55307 | 42 | public: |
AnnaBridge | 167:e84263d55307 | 43 | Stream(const char *name=NULL); |
AnnaBridge | 167:e84263d55307 | 44 | virtual ~Stream(); |
AnnaBridge | 167:e84263d55307 | 45 | |
AnnaBridge | 167:e84263d55307 | 46 | int putc(int c); |
AnnaBridge | 167:e84263d55307 | 47 | int puts(const char *s); |
AnnaBridge | 167:e84263d55307 | 48 | int getc(); |
AnnaBridge | 167:e84263d55307 | 49 | char *gets(char *s, int size); |
AnnaBridge | 167:e84263d55307 | 50 | int printf(const char* format, ...); |
AnnaBridge | 167:e84263d55307 | 51 | int scanf(const char* format, ...); |
AnnaBridge | 167:e84263d55307 | 52 | int vprintf(const char* format, std::va_list args); |
AnnaBridge | 167:e84263d55307 | 53 | int vscanf(const char* format, std::va_list args); |
AnnaBridge | 167:e84263d55307 | 54 | |
AnnaBridge | 167:e84263d55307 | 55 | operator std::FILE*() {return _file;} |
AnnaBridge | 167:e84263d55307 | 56 | |
AnnaBridge | 167:e84263d55307 | 57 | protected: |
AnnaBridge | 167:e84263d55307 | 58 | virtual int close(); |
AnnaBridge | 167:e84263d55307 | 59 | virtual ssize_t write(const void* buffer, size_t length); |
AnnaBridge | 167:e84263d55307 | 60 | virtual ssize_t read(void* buffer, size_t length); |
AnnaBridge | 167:e84263d55307 | 61 | virtual off_t seek(off_t offset, int whence); |
AnnaBridge | 167:e84263d55307 | 62 | virtual off_t tell(); |
AnnaBridge | 167:e84263d55307 | 63 | virtual void rewind(); |
AnnaBridge | 167:e84263d55307 | 64 | virtual int isatty(); |
AnnaBridge | 167:e84263d55307 | 65 | virtual int sync(); |
AnnaBridge | 167:e84263d55307 | 66 | virtual off_t size(); |
AnnaBridge | 167:e84263d55307 | 67 | |
AnnaBridge | 167:e84263d55307 | 68 | virtual int _putc(int c) = 0; |
AnnaBridge | 167:e84263d55307 | 69 | virtual int _getc() = 0; |
AnnaBridge | 167:e84263d55307 | 70 | |
AnnaBridge | 167:e84263d55307 | 71 | std::FILE *_file; |
AnnaBridge | 167:e84263d55307 | 72 | |
AnnaBridge | 167:e84263d55307 | 73 | /** Acquire exclusive access to this object. |
AnnaBridge | 167:e84263d55307 | 74 | */ |
AnnaBridge | 167:e84263d55307 | 75 | virtual void lock() { |
AnnaBridge | 167:e84263d55307 | 76 | // Stub |
AnnaBridge | 167:e84263d55307 | 77 | } |
AnnaBridge | 167:e84263d55307 | 78 | |
AnnaBridge | 167:e84263d55307 | 79 | /** Release exclusive access to this object. |
AnnaBridge | 167:e84263d55307 | 80 | */ |
AnnaBridge | 167:e84263d55307 | 81 | virtual void unlock() { |
AnnaBridge | 167:e84263d55307 | 82 | // Stub |
AnnaBridge | 167:e84263d55307 | 83 | } |
AnnaBridge | 167:e84263d55307 | 84 | }; |
AnnaBridge | 167:e84263d55307 | 85 | |
AnnaBridge | 167:e84263d55307 | 86 | } // namespace mbed |
AnnaBridge | 167:e84263d55307 | 87 | |
AnnaBridge | 167:e84263d55307 | 88 | #endif |
AnnaBridge | 167:e84263d55307 | 89 |