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