mbed library for NZ32-SC151

Committer:
modtronix-com
Date:
Fri Aug 19 15:46:42 2016 +1000
Revision:
17:639ed60ce759
Parent:
1:71204b8406f2
Added tag v1.1 for changeset 076cbe3e55be

Who changed what in which revision?

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