mbed-drivers
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
mbed::Stream Class Referenceabstract
Inheritance diagram for mbed::Stream:
mbed::FileLike mbed::FileHandle mbed::FileBase mbed::Serial

Public Member Functions

 Stream (const char *name=NULL)
 
int putc (int c)
 
int puts (const char *s)
 
int getc ()
 
char * gets (char *s, int size)
 
int printf (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 * ()
 
- Public Member Functions inherited from mbed::FileLike
 FileLike (const char *name)
 
- Public Member Functions inherited from mbed::FileBase
 FileBase (const char *name, PathType t)
 
const char * getName (void)
 
PathType getPathType (void)
 

Protected Member Functions

virtual int close ()
 
virtual ssize_t write (const void *buffer, size_t length)
 
virtual ssize_t read (void *buffer, size_t length)
 
virtual off_t lseek (off_t offset, int whence)
 
virtual int isatty ()
 
virtual int fsync ()
 
virtual off_t flen ()
 
virtual int _putc (int c)=0
 
virtual int _getc ()=0
 

Protected Attributes

std::FILE * _file
 
- Protected Attributes inherited from mbed::FileBase
FileBase_next
 
const char * _name
 
PathType _path_type
 

Additional Inherited Members

- Static Public Member Functions inherited from mbed::FileBase
static FileBaselookup (const char *name, unsigned int len)
 
static FileBaseget (int n)
 
- Static Protected Attributes inherited from mbed::FileBase
static FileBase_head = NULL
 

Member Function Documentation

int mbed::Stream::close ( )
protectedvirtual

Close the file

Returns
Zero on success, -1 on error.

Implements mbed::FileHandle.

int mbed::Stream::fsync ( )
protectedvirtual

Flush any buffers associated with the FileHandle, ensuring it is up to date on disk

Returns
0 on success or un-needed, -1 on error

Implements mbed::FileHandle.

int mbed::Stream::isatty ( )
protectedvirtual

Check if the handle is for a interactive terminal device. If so, line buffered behaviour is used by default

Returns
1 if it is a terminal, 0 otherwise

Implements mbed::FileHandle.

off_t mbed::Stream::lseek ( off_t  offset,
int  whence 
)
protectedvirtual

Move the file position to a given offset from a given location.

Parameters
offsetThe offset from whence to move to
whenceSEEK_SET for the start of the file, SEEK_CUR for the current file position, or SEEK_END for the end of the file.
Returns
new file position on success, -1 on failure or unsupported

Implements mbed::FileHandle.

ssize_t mbed::Stream::read ( void *  buffer,
size_t  length 
)
protectedvirtual

Function read Reads the contents of the file into a buffer

Parameters
bufferthe buffer to read in to
lengththe number of characters to read
Returns
The number of characters read (zero at end of file) on success, -1 on error.

Implements mbed::FileHandle.

ssize_t mbed::Stream::write ( const void *  buffer,
size_t  length 
)
protectedvirtual

Write the contents of a buffer to the file

Parameters
bufferthe buffer to write from
lengththe number of characters to write
Returns
The number of characters written (possibly 0) on success, -1 on error.

Implements mbed::FileHandle.


The documentation for this class was generated from the following files: