t

Fork of mbed-dev by mbed official

Committer:
AnnaBridge
Date:
Thu Jul 06 15:42:05 2017 +0100
Revision:
169:9672193075cf
Parent:
168:e84263d55307
This updates the lib to the mbed lib v 146

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 169:9672193075cf 22 #include "platform/NonCopyable.h"
AnnaBridge 168:e84263d55307 23 #include <cstdio>
AnnaBridge 168:e84263d55307 24 #include <cstdarg>
AnnaBridge 168:e84263d55307 25
AnnaBridge 168:e84263d55307 26 namespace mbed {
AnnaBridge 168:e84263d55307 27 /** \addtogroup platform */
AnnaBridge 168:e84263d55307 28 /** @{*/
AnnaBridge 168:e84263d55307 29
AnnaBridge 168:e84263d55307 30 extern void mbed_set_unbuffered_stream(std::FILE *_file);
AnnaBridge 168:e84263d55307 31 extern int mbed_getc(std::FILE *_file);
AnnaBridge 168:e84263d55307 32 extern char* mbed_gets(char *s, int size, std::FILE *_file);
AnnaBridge 168:e84263d55307 33 /** @}*/
AnnaBridge 168:e84263d55307 34
AnnaBridge 168:e84263d55307 35 /** File stream
AnnaBridge 168:e84263d55307 36 *
AnnaBridge 168:e84263d55307 37 * @note Synchronization level: Set by subclass
AnnaBridge 168:e84263d55307 38 * @ingroup platform
AnnaBridge 168:e84263d55307 39 */
AnnaBridge 169:9672193075cf 40 class Stream : public FileLike, private NonCopyable<Stream> {
AnnaBridge 168:e84263d55307 41
AnnaBridge 168:e84263d55307 42 public:
AnnaBridge 168:e84263d55307 43 Stream(const char *name=NULL);
AnnaBridge 168:e84263d55307 44 virtual ~Stream();
AnnaBridge 168:e84263d55307 45
AnnaBridge 168:e84263d55307 46 int putc(int c);
AnnaBridge 168:e84263d55307 47 int puts(const char *s);
AnnaBridge 168:e84263d55307 48 int getc();
AnnaBridge 168:e84263d55307 49 char *gets(char *s, int size);
AnnaBridge 168:e84263d55307 50 int printf(const char* format, ...);
AnnaBridge 168:e84263d55307 51 int scanf(const char* format, ...);
AnnaBridge 168:e84263d55307 52 int vprintf(const char* format, std::va_list args);
AnnaBridge 168:e84263d55307 53 int vscanf(const char* format, std::va_list args);
AnnaBridge 168:e84263d55307 54
AnnaBridge 168:e84263d55307 55 operator std::FILE*() {return _file;}
AnnaBridge 168:e84263d55307 56
AnnaBridge 168:e84263d55307 57 protected:
AnnaBridge 168:e84263d55307 58 virtual int close();
AnnaBridge 168:e84263d55307 59 virtual ssize_t write(const void* buffer, size_t length);
AnnaBridge 168:e84263d55307 60 virtual ssize_t read(void* buffer, size_t length);
AnnaBridge 168:e84263d55307 61 virtual off_t seek(off_t offset, int whence);
AnnaBridge 168:e84263d55307 62 virtual off_t tell();
AnnaBridge 168:e84263d55307 63 virtual void rewind();
AnnaBridge 168:e84263d55307 64 virtual int isatty();
AnnaBridge 168:e84263d55307 65 virtual int sync();
AnnaBridge 168:e84263d55307 66 virtual off_t size();
AnnaBridge 168:e84263d55307 67
AnnaBridge 168:e84263d55307 68 virtual int _putc(int c) = 0;
AnnaBridge 168:e84263d55307 69 virtual int _getc() = 0;
AnnaBridge 168:e84263d55307 70
AnnaBridge 168:e84263d55307 71 std::FILE *_file;
AnnaBridge 168:e84263d55307 72
AnnaBridge 168:e84263d55307 73 /** Acquire exclusive access to this object.
AnnaBridge 168:e84263d55307 74 */
AnnaBridge 168:e84263d55307 75 virtual void lock() {
AnnaBridge 168:e84263d55307 76 // Stub
AnnaBridge 168:e84263d55307 77 }
AnnaBridge 168:e84263d55307 78
AnnaBridge 168:e84263d55307 79 /** Release exclusive access to this object.
AnnaBridge 168:e84263d55307 80 */
AnnaBridge 168:e84263d55307 81 virtual void unlock() {
AnnaBridge 168:e84263d55307 82 // Stub
AnnaBridge 168:e84263d55307 83 }
AnnaBridge 168:e84263d55307 84 };
AnnaBridge 168:e84263d55307 85
AnnaBridge 168:e84263d55307 86 } // namespace mbed
AnnaBridge 168:e84263d55307 87
AnnaBridge 168:e84263d55307 88 #endif
AnnaBridge 168:e84263d55307 89