Mistake on this page?
Report an issue in GitHub or email us
Public Member Functions | Protected Member Functions | Protected Attributes
mbed::Stream Class Referenceabstract

#include <Stream.h>

Inheritance diagram for mbed::Stream:
mbed::FileLike mbed::NonCopyable< Stream > mbed::FileHandle mbed::FileBase mbed::NonCopyable< FileLike > mbed::NonCopyable< FileHandle > mbed::NonCopyable< 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=NULL)
 
- Public Member Functions inherited from mbed::FileHandle
virtual off_t lseek (off_t offset, int whence)
 
virtual int fsync ()
 
virtual off_t flen ()
 
virtual int set_blocking (bool blocking)
 
virtual bool is_blocking () const
 
virtual short poll (short events) const
 
bool writable () const
 
bool readable () const
 
virtual void sigio (Callback< void()> func)
 
- 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 seek (off_t offset, int whence)
 
virtual off_t tell ()
 
virtual void rewind ()
 
virtual int isatty ()
 
virtual int sync ()
 
virtual off_t size ()
 
virtual int _putc (int c)=0
 
virtual int _getc ()=0
 
virtual void lock ()
 
virtual void unlock ()
 

Protected Attributes

std::FILE * _file
 

Additional Inherited Members

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

Detailed Description

File stream

Note
Synchronization level: Set by subclass

Member Function Documentation

int Stream::close ( )
protectedvirtual

Close a file

Returns
0 on success, negative error code on failure

Implements mbed::FileHandle.

int Stream::isatty ( )
protectedvirtual

Check if the file in an interactive terminal device

Returns
True if the file is a terminal
False if the file is not a terminal
Negative error code on failure

Reimplemented from mbed::FileHandle.

virtual void mbed::Stream::lock ( void  )
inlineprotectedvirtual

Acquire exclusive access to this object.

Reimplemented in mbed::Serial.

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

Read the contents of a file into a buffer

Devices acting as FileHandles should follow POSIX semantics:

  • if no data is available, and non-blocking set return -EAGAIN
  • if no data is available, and blocking set, wait until some data is available
  • If any data is available, call returns immediately
Parameters
bufferThe buffer to read in to
sizeThe number of bytes to read
Returns
The number of bytes read, 0 at end of file, negative error on failure

Implements mbed::FileHandle.

void Stream::rewind ( )
protectedvirtual

Rewind the file position to the beginning of the file

Note
This is equivalent to seek(0, SEEK_SET)

Reimplemented from mbed::FileHandle.

off_t Stream::seek ( off_t  offset,
int  whence 
)
protectedvirtual

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

Parameters
offsetThe offset from whence to move to
whenceThe start of where to seek SEEK_SET to start from beginning of file, SEEK_CUR to start from current position in file, SEEK_END to start from end of file
Returns
The new offset of the file, negative error code on failure

Implements mbed::FileHandle.

off_t Stream::size ( )
protectedvirtual

Get the size of the file

Returns
Size of the file in bytes

Reimplemented from mbed::FileHandle.

int Stream::sync ( )
protectedvirtual

Flush any buffers associated with the file

Returns
0 on success, negative error code on failure

Reimplemented from mbed::FileHandle.

off_t Stream::tell ( )
protectedvirtual

Get the file position of the file

Note
This is equivalent to seek(0, SEEK_CUR)
Returns
The current offset in the file, negative error code on failure

Reimplemented from mbed::FileHandle.

virtual void mbed::Stream::unlock ( void  )
inlineprotectedvirtual

Release exclusive access to this object.

Reimplemented in mbed::Serial.

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

Write the contents of a buffer to a file

Devices acting as FileHandles should follow POSIX semantics:

  • if blocking, block until all data is written
  • if no data can be written, and non-blocking set, return -EAGAIN
  • if some data can be written, and non-blocking set, write partial

    Parameters
    bufferThe buffer to write from
    sizeThe number of bytes to write
    Returns
    The number of bytes written, negative error on failure

Implements mbed::FileHandle.


The documentation for this class was generated from the following files:
Important Information for this Arm website

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies. If you are not happy with the use of these cookies, please review our Cookie Policy to learn how they can be disabled. By disabling cookies, some features of the site will not work.