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