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