Sming Framework API
Sming - Open Source framework for high efficiency WiFi SoC ESP8266 native development with C++ language.
|
File stream class. More...
#include <FileStream.h>
Public Member Functions | |
FileStream (const String &fileName, FileOpenFlags openFlags=eFO_ReadOnly) | |
Create a file stream. More... | |
void | attach (file_t file, size_t size) |
Attach this stream object to an open file handle. More... | |
bool | attach (const String &fileName, FileOpenFlags openFlags=eFO_ReadOnly) SMING_DEPRECATED |
bool | open (const String &fileName, FileOpenFlags openFlags=eFO_ReadOnly) |
Open a file and attach this stream object to it. More... | |
void | close () |
Close file. More... | |
StreamType | getStreamType () const override |
Get the stream type. More... | |
size_t | write (const uint8_t *buffer, size_t size) override |
Write chars to stream. More... | |
uint16_t | readMemoryBlock (char *data, int bufSize) override |
Read a block of memory. More... | |
bool | seek (int len) override |
Move read cursor. More... | |
bool | isFinished () override |
Check if all data has been read. More... | |
String | fileName () const |
Filename of file stream is attached to. More... | |
bool | fileExist () const |
Determine if file exists. More... | |
String | getName () const override |
Returns name of the resource. More... | |
bool | isValid () const override |
Determine if the stream object contains valid data. More... | |
size_t | getPos () const |
Get the offset of cursor from beginning of data. More... | |
int | available () override |
Return the total length of the stream. More... | |
String | id () const override |
Returns unique id of the resource. More... | |
int | getLastError () |
determine if an error occurred during operation More... | |
size_t | write (uint8_t charToWrite) override |
Write a single character to the stream. More... | |
size_t | write (const char *str) |
Writes a c-string to output stream. More... | |
size_t | write (const char *buffer, size_t size) |
Writes characters from a buffer to output stream. More... | |
int | read () override |
Read one character and moves the stream pointer. More... | |
int | peek () override |
Read a character without advancing the stream pointer. More... | |
int | length () SMING_DEPRECATED |
Return the total length of the stream. More... | |
void | flush () override |
void | setTimeout (unsigned long timeout) |
bool | find (char *target) |
bool | find (char *target, size_t length) |
bool | findUntil (char *target, char *terminator) |
bool | findUntil (char *target, size_t targetLen, char *terminate, size_t termLen) |
long | parseInt () |
float | parseFloat () |
size_t | readBytes (char *buffer, size_t length) |
size_t | readBytesUntil (char terminator, char *buffer, size_t length) |
String | readString () |
String | readStringUntil (char terminator) |
virtual int | indexOf (char c) |
int | getWriteError () |
Gets last error. More... | |
void | clearWriteError () |
Clears the last write error. More... | |
size_t | print (char) |
Prints a single character to output stream. More... | |
size_t | print (const char[]) |
Prints a c-string to output stream. More... | |
size_t | print (unsigned long, int base=DEC) |
Prints a number to output stream. More... | |
size_t | print (long, int base=DEC) |
Prints a number to output stream. More... | |
size_t | print (unsigned int, int base=DEC) |
size_t | print (unsigned char, int base=DEC) |
size_t | print (int, int base=DEC) |
Prints a number to output stream. More... | |
size_t | print (double, int digits=2) |
Prints number to output stream. More... | |
size_t | print (const Printable &p) |
Prints a Printable object to output stream. More... | |
size_t | print (const String &s) |
Prints a String to output stream. More... | |
size_t | println (void) |
Prints a newline to output stream. More... | |
size_t | println (const char[]) |
Prints a c-string to output stream, appending newline. More... | |
size_t | println (char) |
Prints a single character to output stream, appending newline. More... | |
size_t | println (unsigned char, int base=DEC) |
Prints a number to output stream, appending newline. More... | |
size_t | println (unsigned int, int base=DEC) |
size_t | println (unsigned long, int base=DEC) |
size_t | println (int, int base=DEC) |
Prints a number to output stream, appending newline. More... | |
size_t | println (long, int base=DEC) |
Prints a number to output stream, appending newline. More... | |
size_t | println (double, int digits=2) |
Prints a number to output stream, appending newline. More... | |
size_t | println (const Printable &p) |
Prints a Printable object to output stream, appending newline. More... | |
size_t | println (const String &s) |
Prints a String to output stream, appending newline. More... | |
size_t | printf (const char *fmt,...) |
Prints a formatted c-string to output stream. More... | |
Protected Member Functions | |
int | timedRead () |
int | timedPeek () |
int | peekNextDigit () |
long | parseInt (char skipChar) |
float | parseFloat (char skipChar) |
void | setWriteError (int err=1) |
Protected Attributes | |
unsigned long | receiveTimeout = 1000 |
unsigned long | startMillis = 0 |
File stream class.
|
inline |
Create a file stream.
fileName | Name of file to open |
void FileStream::attach | ( | file_t | file, |
size_t | size | ||
) |
Attach this stream object to an open file handle.
file | |
size |
|
inline |
open()
instead
|
inlineoverridevirtual |
Return the total length of the stream.
int | -1 is returned when the size cannot be determined |
Reimplemented from IDataSourceStream.
|
inlineinherited |
Clears the last write error.
void FileStream::close | ( | ) |
Close file.
|
inline |
Determine if file exists.
bool | true if stream contains valid file |
String FileStream::fileName | ( | ) | const |
Filename of file stream is attached to.
String | invalid if stream isn't open |
|
inline |
determine if an error occurred during operation
int | filesystem error code |
|
inlineoverridevirtual |
Returns name of the resource.
String |
Reimplemented from IDataSourceStream.
|
inline |
Get the offset of cursor from beginning of data.
size_t | Cursor offset |
|
inlineoverridevirtual |
|
inlineinherited |
Gets last error.
int | Error number of last write error |
|
overridevirtual |
Returns unique id of the resource.
String | the unique id of the stream. |
Reimplemented from IDataSourceStream.
|
inlineoverridevirtual |
|
inlineoverridevirtual |
Determine if the stream object contains valid data.
bool | true if valid, false if invalid |
Reimplemented from IDataSourceStream.
|
inlineinherited |
Return the total length of the stream.
int | -1 is returned when the size cannot be determined |
available()
instead bool FileStream::open | ( | const String & | fileName, |
FileOpenFlags | openFlags = eFO_ReadOnly |
||
) |
Open a file and attach this stream object to it.
fileName | |
openFlags |
bool | true on success, false on error |
|
overridevirtualinherited |
Read a character without advancing the stream pointer.
int | The character that was read or -1 if none is available |
Implements Stream.
Reimplemented in HardwareSerial.
|
inherited |
Prints a single character to output stream.
size_t | Quantity of characters written to stream |
|
inherited |
Prints a c-string to output stream.
char[] | c-string to print |
size_t | Quantity of characters written to output stream |
size_t | Quantity of characters written to stream |
|
inherited |
Prints a number to output stream.
unsigned long | Number to print |
base | The base for output (Default: Decimal (base 10)) |
size_t | Quantity of characters written to stream |
unsigned int | Number to print |
base | The base for output (Default: Decimal (base 10)) |
size_t | Quantity of characters written to stream |
unsigned char | Number to print |
base | The base for output (Default: Decimal (base 10)) |
size_t | Quantity of characters written to stream |
|
inherited |
Prints a number to output stream.
long | Number to print |
base | The base for output (Default: Decimal (base 10)) |
size_t | Quantity of characters written to stream |
|
inherited |
Prints a number to output stream.
int | Number to print |
base | The base for output (Default: Decimal (base 10)) |
size_t | Quantity of characters written to stream |
|
inherited |
Prints number to output stream.
Prints a number to output stream.
double | Number to print |
int | Decimal places to show |
size_t | Quantity of characters written to output stream |
double | Number to print |
digits | The decimal places to print (Default: 2, e.g. 21.35) |
size_t | Quantity of characters written to stream |
|
inherited |
Prints a Printable object to output stream.
p | Object to print |
size_t | Quantity of characters written to stream |
|
inherited |
|
inherited |
Prints a formatted c-string to output stream.
fmt | Pointer to formated c-string to print |
... | Parameters for placeholders within formated string |
size_t | Quantity of characters written to stream |
|
inherited |
Prints a newline to output stream.
Prints | newline to output stream |
size_t | Quantity of characters written to output stream |
size_t | Quantity of characters written to stream |
|
inherited |
Prints a c-string to output stream, appending newline.
char[] | c-string to print |
size_t | Quantity of characters written to stream |
|
inherited |
Prints a single character to output stream, appending newline.
char | Character to print |
size_t | Quantity of characters written to stream |
|
inherited |
Prints a number to output stream, appending newline.
unsigned char | Number to print |
base | The base for output (Default: Decimal (base 10)) |
size_t | Quantity of characters written to stream |
unsigned int | Number to print |
base | The base for output (Default: Decimal (base 10)) |
size_t | Quantity of characters written to stream |
unsigned long | Number to print |
base | The base for output (Default: Decimal (base 10)) |
size_t | Quantity of characters written to stream |
|
inherited |
Prints a number to output stream, appending newline.
int | Number to print |
base | The base for output (Default: Decimal (base 10)) |
size_t | Quantity of characters written to stream |
|
inherited |
Prints a number to output stream, appending newline.
long | Number to print |
base | The base for output (Default: Decimal (base 10)) |
size_t | Quantity of characters written to stream |
|
inherited |
Prints a number to output stream, appending newline.
double | Number to print |
digits | The decimal places to print (Default: 2, e.g. 21.35) |
size_t | Quantity of characters written to stream |
|
inherited |
Prints a Printable object to output stream, appending newline.
p | Object to print |
size_t | Quantity of characters written to stream |
|
inherited |
|
overridevirtualinherited |
Read one character and moves the stream pointer.
The | character that was read or -1 if none is available |
Implements Stream.
Reimplemented in HardwareSerial.
|
overridevirtual |
Read a block of memory.
data | Pointer to the data to be read |
bufSize | Quantity of chars to read |
uint16_t | Quantity of chars read |
Implements IDataSourceStream.
|
overridevirtual |
Move read cursor.
len | Relative cursor adjustment |
bool | True on success. |
Implements IDataSourceStream.
|
inlineoverridevirtualinherited |
Write a single character to the stream.
charToWrite |
size_t | Number of chars written (1 on success, 0 on failure) |
Reimplemented from IDataSourceStream.
|
inlineinherited |
Writes a c-string to output stream.
str | Pointer to c-string |
size_t | Quantity of characters written to stream |
|
inlineinherited |
Writes characters from a buffer to output stream.
buffer | Pointer to character buffer |
size | Quantity of characters to write |
size_t | Quantity of characters written to stream |
|
overridevirtual |
Write chars to stream.
buffer | Pointer to buffer to write to the stream |
size | Quantity of chars to write |
size_t | Quantity of chars written to stream |
Implements ReadWriteStream.