mbed library sources. Supersedes mbed-src.

Fork of mbed by teralytic

Committer:
rodriguise
Date:
Mon Oct 17 18:47:01 2016 +0000
Revision:
148:4802eb17e82b
Parent:
144:ef7eb2e8f9f7
backup

Who changed what in which revision?

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