t

Fork of mbed-dev by mbed official

Committer:
AnnaBridge
Date:
Wed Jun 21 17:46:44 2017 +0100
Revision:
168:e84263d55307
Child:
169:9672193075cf
This updates the lib to the mbed lib v 145

Who changed what in which revision?

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