Merge pull request #1433 from sg-/enhance-stream

Enhance stream class
pull/2453/head^2
Martin Kojtal 2015-11-26 10:04:37 +00:00
commit f4b1d30ff4
2 changed files with 15 additions and 2 deletions

View File

@ -18,6 +18,7 @@
#include "platform.h" #include "platform.h"
#include "FileLike.h" #include "FileLike.h"
#include <cstdarg>
namespace mbed { namespace mbed {
@ -37,6 +38,8 @@ public:
char *gets(char *s, int size); char *gets(char *s, int size);
int printf(const char* format, ...); int printf(const char* format, ...);
int scanf(const char* format, ...); int scanf(const char* format, ...);
int vprintf(const char* format, std::va_list args);
int vscanf(const char* format, std::va_list args);
operator std::FILE*() {return _file;} operator std::FILE*() {return _file;}

View File

@ -15,8 +15,6 @@
*/ */
#include "Stream.h" #include "Stream.h"
#include <cstdarg>
namespace mbed { namespace mbed {
Stream::Stream(const char *name) : FileLike(name), _file(NULL) { Stream::Stream(const char *name) : FileLike(name), _file(NULL) {
@ -108,4 +106,16 @@ int Stream::scanf(const char* format, ...) {
return r; return r;
} }
int Stream::vprintf(const char* format, std::va_list args) {
fflush(_file);
int r = vfprintf(_file, format, args);
return r;
}
int Stream::vscanf(const char* format, std::va_list args) {
fflush(_file);
int r = vfscanf(_file, format, args);
return r;
}
} // namespace mbed } // namespace mbed