]> git.gir.st - tmk_keyboard.git/blob - tmk_core/tool/mbed/mbed-sdk/libraries/mbed/api/Stream.h
Merge commit '1fe4406f374291ab2e86e95a97341fd9c475fcb8'
[tmk_keyboard.git] / tmk_core / tool / mbed / mbed-sdk / libraries / mbed / api / 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 extern void mbed_set_unbuffered_stream(FILE *_file);
25 extern int mbed_getc(FILE *_file);
26 extern char* mbed_gets(char *s, int size, FILE *_file);
27
28 class Stream : public FileLike {
29
30 public:
31 Stream(const char *name=NULL);
32 virtual ~Stream();
33
34 int putc(int c);
35 int puts(const char *s);
36 int getc();
37 char *gets(char *s, int size);
38 int printf(const char* format, ...);
39 int scanf(const char* format, ...);
40
41 operator std::FILE*() {return _file;}
42
43 protected:
44 virtual int close();
45 virtual ssize_t write(const void* buffer, size_t length);
46 virtual ssize_t read(void* buffer, size_t length);
47 virtual off_t lseek(off_t offset, int whence);
48 virtual int isatty();
49 virtual int fsync();
50 virtual off_t flen();
51
52 virtual int _putc(int c) = 0;
53 virtual int _getc() = 0;
54
55 std::FILE *_file;
56
57 /* disallow copy constructor and assignment operators */
58 private:
59 Stream(const Stream&);
60 Stream & operator = (const Stream&);
61 };
62
63 } // namespace mbed
64
65 #endif
Imprint / Impressum