EmbAJAX
Simplistic framework for creating and handling displays and controls on a web page served by an embeddable device (Arduino or other microcontroller with Arduino support).
Public Types | Public Member Functions | List of all members
EmbAJAXOutputDriverBase Class Referenceabstract

Abstract base class for output drivers/server implementations. More...

#include <EmbAJAX.h>

Inheritance diagram for EmbAJAXOutputDriverBase:
Inheritance graph
[legend]

Public Types

enum  QuoteMode { NotQuoted , JSQuoted , HTMLQuoted }
 

Public Member Functions

virtual void printHeader (bool html)=0
 
virtual void printContent (const char *content)=0
 
virtual const char * getArg (const char *name, char *buf, int buflen)=0
 
virtual void installPage (EmbAJAXPageBase *page, const char *path, void(*change_callback)()=0)=0
 
virtual void loopHook ()=0
 
uint16_t revision () const
 
uint16_t setChanged ()
 
void nextRevision ()
 
void printFiltered (const char *value, QuoteMode quoted, bool HTMLescaped)
 
void printJSQuoted (const char *value)
 
void printHTMLQuoted (const char *value)
 
void printAttribute (const char *name, const char *value)
 
void printAttribute (const char *name, const int32_t value)
 
void _printContentF (const char *fmt,...)
 
void _printContentF (const __FlashStringHelper *,...)
 

Detailed Description

Abstract base class for output drivers/server implementations.

Output driver as an abstraction over the server read/write commands. You will have to instantiate exactly one object of exactly one implementation, before using any EmbAJAX classes.

Providing your own driver is very easy. All you have to do it to wrap the basic functions for writing to the server and retrieving (POST) arguments: printHeader(), printContent(), and getArg().

Member Enumeration Documentation

◆ QuoteMode

Quotation modes. Used in printFiltered()

Enumerator
NotQuoted 

Will not be quoted.

JSQuoted 

Will be quoted suitable for JavaScript.

HTMLQuoted 

Will be quoted suitable for HTML attributes.

Member Function Documentation

◆ _printContentF()

void EmbAJAXOutputDriverBase::_printContentF ( const char *  fmt,
  ... 
)

Print a static string with parameters replaced, somewhat similar to printf

Note
It is genarally recommended to use the printFormatted(...) macro, wherever possible, instead of this.

See there for further info. This function is really just the internal implementation, public for technical reasons.

◆ installPage()

virtual void EmbAJAXOutputDriverBase::installPage ( EmbAJAXPageBase page,
const char *  path,
void(*)()  change_callback = 0 
)
pure virtual

Set up the given page to be served on the given path.

Parameters
change_callbackSee EmbAJAXPage::handleRequest() for details.

Implemented in EmbAJAXOutputDriverGeneric, and EmbAJAXOutputDriverESPAsync.

◆ loopHook()

virtual void EmbAJAXOutputDriverBase::loopHook ( )
pure virtual

Insert this hook into loop(). Takes care of the appropriate server calls, if needed.

Implemented in EmbAJAXOutputDriverGeneric, and EmbAJAXOutputDriverESPAsync.

◆ printAttribute() [1/2]

void EmbAJAXOutputDriverBase::printAttribute ( const char *  name,
const char *  value 
)

Convenience function to print an attribute inside an HTML tag. This function adds a space in front of the printed attribute.

Note
It is genarally recommended to use the printFormatted(...) macro, wherever possible, instead of this.
Parameters
namename of the attribute
valuevalue of the attribute. Will be quoted.

◆ printAttribute() [2/2]

void EmbAJAXOutputDriverBase::printAttribute ( const char *  name,
const int32_t  value 
)

Convenience function to print an integer attribute inside an HTML tag. This function adds a space in front of the printed attribute.

Note
It is genarally recommended to use the printFormatted(...) macro, wherever possible, instead of this.
Parameters
namename of the attribute
valuevalue of the attribute.

◆ printFiltered()

void EmbAJAXOutputDriverBase::printFiltered ( const char *  value,
QuoteMode  quoted,
bool  HTMLescaped 
)
inline

Print the given value filtered according to the parameters:

Note
It is genarally recommended to use the printFormatted(...) macro, wherever possible, instead of this.
Parameters
quotedIf true, add double-quotes around the string, and esacpe any double quotes within the string as ".
HTMLescapedIf true, escape any "<" and "&" in the input as "\&lt;" and "\&amp;" such that it will appear as plain text if rendered as HTML (safe for untrusted user input).

◆ printHTMLQuoted()

void EmbAJAXOutputDriverBase::printHTMLQuoted ( const char *  value)
inline

Shorthand for printFiltered(value, HTMLQuoted, false);

◆ printJSQuoted()

void EmbAJAXOutputDriverBase::printJSQuoted ( const char *  value)
inline

Shorthand for printFiltered(value, JSQuoted, false);


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