test

Committer:
elijahsj
Date:
Mon Nov 09 00:33:19 2020 -0500
Revision:
2:4364577b5ad8
Parent:
1:8a094db1347f
copied mbed library

Who changed what in which revision?

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