This fork captures the mbed lib v125 for ease of integration into older projects.

Fork of mbed-dev by mbed official

Committer:
apluscw
Date:
Fri Jul 20 21:24:42 2018 +0000
Revision:
187:92cbb9eec47b
Mbed library with source code from mbed lib v125. Posted to ease integration with some older projects.

Who changed what in which revision?

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