Removed all uses of the Stream ( native mbed ) class in favor of the
[clinton/Smoothieware.git] / gcc4mbed / external / mbed / Stream.h
1 /* mbed Microcontroller Library - Stream
2 * Copyright (c) 2007-2009 ARM Limited. All rights reserved.
3 * sford
4 */
5
6 #ifndef MBED_STREAM_H
7 #define MBED_STREAM_H
8
9 #include "FileLike.h"
10 #include "platform.h"
11 #include <cstdio>
12
13 namespace mbed {
14
15 class Stream : public FileLike {
16
17 public:
18
19 Stream(const char *name = NULL);
20 virtual ~Stream();
21
22 int putc(int c) {
23 fflush(_file);
24 return std::fputc(c, _file);
25 }
26 int puts(const char *s) {
27 fflush(_file);
28 return std::fputs(s, _file);
29 }
30 int getc() {
31 fflush(_file);
32 return std::fgetc(_file);
33 }
34 char *gets(char *s, int size) {
35 fflush(_file);
36 return std::fgets(s,size,_file);;
37 }
38 int printf(const char* format, ...);
39 int scanf(const char* format, ...);
40
41 operator std::FILE*() { return _file; }
42
43 std::FILE *_file;
44 #ifdef MBED_RPC
45 virtual const struct rpc_method *get_rpc_methods();
46 #endif
47
48 protected:
49
50 virtual int close();
51 virtual ssize_t write(const void* buffer, size_t length);
52 virtual ssize_t read(void* buffer, size_t length);
53 virtual off_t lseek(off_t offset, int whence);
54 virtual int isatty();
55 virtual int fsync();
56 virtual off_t flen();
57
58 virtual int _putc(int c) = 0;
59 virtual int _getc() = 0;
60
61
62 };
63
64 } // namespace mbed
65
66 #endif
67