Nicolas Borla / Mbed OS ROME2_Robot_Firmware
Committer:
boro
Date:
Mon Mar 16 13:12:31 2020 +0000
Revision:
0:4beb2ea291ec
a

Who changed what in which revision?

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