SDCard version

Fork of gr-peach-opencv-project-sd-card by the do

Committer:
thedo
Date:
Fri Jul 21 01:26:54 2017 +0000
Revision:
167:2ee3e82cb6f5
Parent:
166:240bc5a0f42a
gr-peach-opencv-project-sd-card

Who changed what in which revision?

UserRevisionLine numberNew contents of line
thedo 166:240bc5a0f42a 1 /* mbed Microcontroller Library
thedo 166:240bc5a0f42a 2 * Copyright (c) 2006-2013 ARM Limited
thedo 166:240bc5a0f42a 3 *
thedo 166:240bc5a0f42a 4 * Licensed under the Apache License, Version 2.0 (the "License");
thedo 166:240bc5a0f42a 5 * you may not use this file except in compliance with the License.
thedo 166:240bc5a0f42a 6 * You may obtain a copy of the License at
thedo 166:240bc5a0f42a 7 *
thedo 166:240bc5a0f42a 8 * http://www.apache.org/licenses/LICENSE-2.0
thedo 166:240bc5a0f42a 9 *
thedo 166:240bc5a0f42a 10 * Unless required by applicable law or agreed to in writing, software
thedo 166:240bc5a0f42a 11 * distributed under the License is distributed on an "AS IS" BASIS,
thedo 166:240bc5a0f42a 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
thedo 166:240bc5a0f42a 13 * See the License for the specific language governing permissions and
thedo 166:240bc5a0f42a 14 * limitations under the License.
thedo 166:240bc5a0f42a 15 */
thedo 166:240bc5a0f42a 16 #ifndef MBED_STREAM_H
thedo 166:240bc5a0f42a 17 #define MBED_STREAM_H
thedo 166:240bc5a0f42a 18
thedo 166:240bc5a0f42a 19 #include "platform/platform.h"
thedo 166:240bc5a0f42a 20 #include "platform/FileLike.h"
thedo 166:240bc5a0f42a 21 #include "platform/FileHandle.h"
thedo 166:240bc5a0f42a 22 #include <cstdio>
thedo 166:240bc5a0f42a 23 #include <cstdarg>
thedo 166:240bc5a0f42a 24
thedo 166:240bc5a0f42a 25 namespace mbed {
thedo 166:240bc5a0f42a 26 /** \addtogroup platform */
thedo 166:240bc5a0f42a 27 /** @{*/
thedo 166:240bc5a0f42a 28
thedo 166:240bc5a0f42a 29 extern void mbed_set_unbuffered_stream(std::FILE *_file);
thedo 166:240bc5a0f42a 30 extern int mbed_getc(std::FILE *_file);
thedo 166:240bc5a0f42a 31 extern char* mbed_gets(char *s, int size, std::FILE *_file);
thedo 166:240bc5a0f42a 32 /** @}*/
thedo 166:240bc5a0f42a 33
thedo 166:240bc5a0f42a 34 /** File stream
thedo 166:240bc5a0f42a 35 *
thedo 166:240bc5a0f42a 36 * @note Synchronization level: Set by subclass
thedo 166:240bc5a0f42a 37 * @ingroup platform
thedo 166:240bc5a0f42a 38 */
thedo 166:240bc5a0f42a 39 class Stream : public FileLike {
thedo 166:240bc5a0f42a 40
thedo 166:240bc5a0f42a 41 public:
thedo 166:240bc5a0f42a 42 Stream(const char *name=NULL);
thedo 166:240bc5a0f42a 43 virtual ~Stream();
thedo 166:240bc5a0f42a 44
thedo 166:240bc5a0f42a 45 int putc(int c);
thedo 166:240bc5a0f42a 46 int puts(const char *s);
thedo 166:240bc5a0f42a 47 int getc();
thedo 166:240bc5a0f42a 48 char *gets(char *s, int size);
thedo 166:240bc5a0f42a 49 int printf(const char* format, ...);
thedo 166:240bc5a0f42a 50 int scanf(const char* format, ...);
thedo 166:240bc5a0f42a 51 int vprintf(const char* format, std::va_list args);
thedo 166:240bc5a0f42a 52 int vscanf(const char* format, std::va_list args);
thedo 166:240bc5a0f42a 53
thedo 166:240bc5a0f42a 54 operator std::FILE*() {return _file;}
thedo 166:240bc5a0f42a 55
thedo 166:240bc5a0f42a 56 protected:
thedo 166:240bc5a0f42a 57 virtual int close();
thedo 166:240bc5a0f42a 58 virtual ssize_t write(const void* buffer, size_t length);
thedo 166:240bc5a0f42a 59 virtual ssize_t read(void* buffer, size_t length);
thedo 166:240bc5a0f42a 60 virtual off_t seek(off_t offset, int whence);
thedo 166:240bc5a0f42a 61 virtual off_t tell();
thedo 166:240bc5a0f42a 62 virtual void rewind();
thedo 166:240bc5a0f42a 63 virtual int isatty();
thedo 166:240bc5a0f42a 64 virtual int sync();
thedo 166:240bc5a0f42a 65 virtual off_t size();
thedo 166:240bc5a0f42a 66
thedo 166:240bc5a0f42a 67 virtual int _putc(int c) = 0;
thedo 166:240bc5a0f42a 68 virtual int _getc() = 0;
thedo 166:240bc5a0f42a 69
thedo 166:240bc5a0f42a 70 std::FILE *_file;
thedo 166:240bc5a0f42a 71
thedo 166:240bc5a0f42a 72 /** Acquire exclusive access to this object.
thedo 166:240bc5a0f42a 73 */
thedo 166:240bc5a0f42a 74 virtual void lock() {
thedo 166:240bc5a0f42a 75 // Stub
thedo 166:240bc5a0f42a 76 }
thedo 166:240bc5a0f42a 77
thedo 166:240bc5a0f42a 78 /** Release exclusive access to this object.
thedo 166:240bc5a0f42a 79 */
thedo 166:240bc5a0f42a 80 virtual void unlock() {
thedo 166:240bc5a0f42a 81 // Stub
thedo 166:240bc5a0f42a 82 }
thedo 166:240bc5a0f42a 83
thedo 166:240bc5a0f42a 84 /* disallow copy constructor and assignment operators */
thedo 166:240bc5a0f42a 85 private:
thedo 166:240bc5a0f42a 86 Stream(const Stream&);
thedo 166:240bc5a0f42a 87 Stream & operator = (const Stream&);
thedo 166:240bc5a0f42a 88 };
thedo 166:240bc5a0f42a 89
thedo 166:240bc5a0f42a 90 } // namespace mbed
thedo 166:240bc5a0f42a 91
thedo 166:240bc5a0f42a 92 #endif
thedo 166:240bc5a0f42a 93
thedo 166:240bc5a0f42a 94