Sming Framework API
Sming - Open Source framework for high efficiency WiFi SoC ESP8266 native development with C++ language.
TemplateFileStream Class Reference

Template file stream class. More...

#include <DataSourceStream.h>

Inheritance diagram for TemplateFileStream:
FileStream IDataSourceStream

Public Member Functions

 TemplateFileStream (String templateFileName)
 Create a template file stream. More...
 
virtual StreamType getStreamType ()
 Get the stream type. More...
 
virtual uint16_t readMemoryBlock (char *data, int bufSize)
 Read a block of memory. More...
 
virtual bool seek (int len)
 Move read cursor. More...
 
void setVar (String name, String value)
 Set value of a variable in the template file. More...
 
void setVarsFromRequest (const HttpRequest &request)
 Set the value of variables from the content of a HTTP request. More...
 
TemplateVariablesvariables ()
 Get the template variables. More...
 
virtual bool attach (String fileName, FileOpenFlags openFlags)
 
virtual size_t write (uint8_t charToWrite)
 
virtual size_t write (const uint8_t *buffer, size_t size)
 
virtual bool isFinished ()
 Check if stream is finished. More...
 
String fileName ()
 Filename of file stream is attached to. More...
 
bool fileExist ()
 True if file exists. More...
 
int getPos ()
 Get the offset of cursor from beginning of data. More...
 

Detailed Description

Template file stream class.

Constructor & Destructor Documentation

TemplateFileStream::TemplateFileStream ( String  templateFileName)

Create a template file stream.

Parameters
templateFileNameTemplate filename

Member Function Documentation

bool FileStream::fileExist ( )
inherited

True if file exists.

String FileStream::fileName ( )
inherited

Filename of file stream is attached to.

int FileStream::getPos ( )
inlineinherited

Get the offset of cursor from beginning of data.

Return values
intCursor offset
virtual StreamType TemplateFileStream::getStreamType ( )
inlinevirtual

Get the stream type.

Return values
StreamTypeThe stream type.
Todo:
Return value of IDataSourceStream:getStreamType base class function should be of type StreamType, e.g. eSST_User

Reimplemented from FileStream.

virtual bool FileStream::isFinished ( )
virtualinherited

Check if stream is finished.

Return values
boolTrue on success.

Implements IDataSourceStream.

virtual uint16_t TemplateFileStream::readMemoryBlock ( char *  data,
int  bufSize 
)
virtual

Read a block of memory.

Parameters
dataPointer to the data to be read
bufSizeQuantity of chars to read
Return values
uint16_tQuantity of chars read
Todo:
Should IDataSourceStream::readMemoryBlock return same data type as its bufSize param?

Reimplemented from FileStream.

virtual bool TemplateFileStream::seek ( int  len)
virtual

Move read cursor.

Parameters
lenPosition within stream to move cursor to
Return values
boolTrue on success.

Reimplemented from FileStream.

void TemplateFileStream::setVar ( String  name,
String  value 
)

Set value of a variable in the template file.

Parameters
nameName of variable
valueValue to assign to the variable
Note
Sets and existing varible or adds a new variable if variable does not already exist
void TemplateFileStream::setVarsFromRequest ( const HttpRequest request)

Set the value of variables from the content of a HTTP request.

Parameters
requestHTTP request
TemplateVariables& TemplateFileStream::variables ( )
inline

Get the template variables.

Return values
TemplateVariablesReference to the template variables