strat des robots

Fork of CRAC-Strat_2017 by CRAC Team

Committer:
ClementBreteau
Date:
Fri May 19 17:14:07 2017 +0000
Revision:
17:d1594579eec6
Parent:
0:ad97421fb1fb
strat du robot, 19-05-2017, 19h

Who changed what in which revision?

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