18 #include "../Format.h" 34 #define SECTION_TEMPLATE_COMMAND_MAP(XX) \ 35 XX(Qas_int, "{!int:A} Output A as integer") \ 36 XX(Qas_float, "{!float:A} Output A as float") \ 37 XX(Qas_string, "{!string:A} Output A as quoted string") \ 38 XX(Qmime_type, "{!mime_type:A} Get MIME type string for a filename") \ 39 XX(Qreplace, "{!replace:A:B:C} Copy of A with all occurrences of B replaced with C") \ 40 XX(Qlength, "{!length:A} Number of characters in A") \ 42 "{!pad:A:B:C} Copy of A padded to at least B characters with C (default is space). Use -ve B to left-pad. C") \ 43 XX(Qrepeat, "{!repeat:A:B} Repeat A, number of iterations is B") \ 44 XX(Qkb, "{!kb:A} Convert A to KB") \ 45 XX(Qifdef, "{!ifdef:A}block{/if} emit block if A is not zero-length") \ 46 XX(Qifndef, "{!ifdef:A}block{/if} emit block if A is zero-length") \ 47 XX(Qifeq, "{!ifeq:A:B} emit block if A == B") \ 48 XX(Qifneq, "{!ifneq:A:B} emit block if A != B") \ 49 XX(Qifgt, "{!ifgt:A:B} emit block if A > B") \ 50 XX(Qiflt, "{!iflt:A:B} emit block if A < B") \ 51 XX(Qifge, "{!ifge:A:B} emit block if A >= B") \ 52 XX(Qifle, "{!ifle:A:B} emit block if A <= B") \ 53 XX(Qifbtw, "{!ifbtw:A:B:C} emit block if B <= A <= C") \ 54 XX(Qifin, "{!ifin:A:B} emit block if A contains B") \ 55 XX(Qifnin, "{!ifin:A:B} emit block if A does not contain B") \ 56 XX(Qelse, "{!else}") \ 57 XX(Qendif, "{!endif}") \ 58 XX(Qadd, "{!add:A:B} A - B") \ 59 XX(Qsub, "{!sub:A:B} A - B") \ 60 XX(Qgoto, "{!goto:A} move to section A") \ 61 XX(Qcount, "{!count:A} emit number of records in section A") \ 62 XX(Qindex, "{!index:A} emit current record index for section A") 64 #define SECTION_TEMPLATE_FIELD_MAP(XX) \ 65 XX(section, "{$section} Current section index") \ 66 XX(record, "{$record} Current record index") 76 #define XX(name, comment) name, 83 #define XX(name, comment) name, 104 getValueCallback = callback;
114 return *activeFormatter;
119 return activeFormatter->mimeType();
124 return sectionStream;
129 return sectionStream.sectionIndex();
134 return sectionStream.count();
139 return sectionStream.recordIndex();
146 nextRecordCallback = callback;
159 if(nextRecordCallback) {
160 return nextRecordCallback();
168 String openTag(
bool enable);
177 uint8_t conditionalLevel{0};
178 int8_t newSection{-1};
void onNextRecord(NextRecord callback)
Definition: SectionTemplate.h:144
int recordIndex() const
Definition: SectionTemplate.h:137
String getValue(const char *name) override
Fetch a templated value.
Command
Definition: SectionTemplate.h:74
bool gotoSection(uint8_t index)
Base class for read-only stream.
Definition: DataSourceStream.h:40
#define SECTION_TEMPLATE_FIELD_MAP(XX)
Definition: SectionTemplate.h:64
void onGetValue(GetValue callback)
Definition: SectionTemplate.h:102
void setFormatter(Formatter &formatter)
Definition: SectionTemplate.h:107
Delegate< bool()> NextRecord
Application callback to move to next record.
Definition: SectionStream.h:52
The String class.
Definition: WString.h:136
#define SECTION_TEMPLATE_COMMAND_MAP(XX)
Command map.
Definition: SectionTemplate.h:34
SectionTemplate(IDataSourceStream *source)
Field
Definition: SectionTemplate.h:81
virtual bool nextRecord()
Move to next record.
Definition: SectionTemplate.h:157
Stream which performs variable-value substitution on-the-fly.
Definition: TemplateStream.h:32
uint8_t sectionCount() const
Definition: SectionTemplate.h:132
MimeType getMimeType() const override
Get MIME type for stream content.
Definition: SectionTemplate.h:117
Provides enhanced template tag processing for use with a SectionStream.
Definition: SectionTemplate.h:71
Presents each section within a source stream as a separate stream.
Definition: SectionStream.h:26
int sectionIndex() const
Definition: SectionTemplate.h:127
MimeType
Definition: WebConstants.h:53
const SectionStream & stream() const
Definition: SectionTemplate.h:122
Formatter & formatter() const
Definition: SectionTemplate.h:112
String evaluate(char *&expr) override