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).
|
Abstract base class for output drivers/server implementations. More...
#include <EmbAJAX.h>
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 *,...) |
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().
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. |
void EmbAJAXOutputDriverBase::_printContentF | ( | const char * | fmt, |
... | |||
) |
Print a static string with parameters replaced, somewhat similar to printf
See there for further info. This function is really just the internal implementation, public for technical reasons.
|
pure virtual |
Set up the given page to be served on the given path.
change_callback | See EmbAJAXPage::handleRequest() for details. |
Implemented in EmbAJAXOutputDriverGeneric, and EmbAJAXOutputDriverESPAsync.
|
pure virtual |
Insert this hook into loop(). Takes care of the appropriate server calls, if needed.
Implemented in EmbAJAXOutputDriverGeneric, and EmbAJAXOutputDriverESPAsync.
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.
name | name of the attribute |
value | value of the attribute. Will be quoted. |
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.
name | name of the attribute |
value | value of the attribute. |
|
inline |
Print the given value filtered according to the parameters:
quoted | If true, add double-quotes around the string, and esacpe any double quotes within the string as ". |
HTMLescaped | If true, escape any "<" and "&" in the input as "\<" and "\&" such that it will appear as plain text if rendered as HTML (safe for untrusted user input). |
|
inline |
Shorthand for printFiltered(value, HTMLQuoted, false);
|
inline |
Shorthand for printFiltered(value, JSQuoted, false);