diff --git a/Sming/Core/Data/Stream/SectionTemplate.cpp b/Sming/Core/Data/Stream/SectionTemplate.cpp index 5f236d095e..c8a00acf5e 100644 --- a/Sming/Core/Data/Stream/SectionTemplate.cpp +++ b/Sming/Core/Data/Stream/SectionTemplate.cpp @@ -313,7 +313,7 @@ String SectionTemplate::evaluate(char*& expr) } auto exprStart = expr; - *expr = '_'; + *expr = 'Q'; // Process conditional expressions such as {length:varname}, {width:10:text to pad} ArgList args(*this); @@ -333,16 +333,16 @@ String SectionTemplate::evaluate(char*& expr) expr = ptr; switch(field) { - case Command::_unknown: + case Command::Qunknown: break; - case Command::_as_int: + case Command::Qas_int: return String(args[0].toInt()); - case Command::_as_float: + case Command::Qas_float: return String(args[0].toFloat()); - case Command::_as_string: { + case Command::Qas_string: { /* * TODO: Find/write strQuote() helper function to ensure any containing quotes are escaped. * This will be format-specific so perhaps another callback or look at putting Stream/Format @@ -355,24 +355,24 @@ String SectionTemplate::evaluate(char*& expr) return s; } - case Command::_kb: + case Command::Qkb: return String(args[0].toFloat() / 1024); - case Command::_replace: { + case Command::Qreplace: { String value = args[0]; value.replace(args[1], args[2]); return value; } - case Command::_length: + case Command::Qlength: return String(args[0].toString().length()); - case Command::_mime_type: { + case Command::Qmime_type: { String s = ContentType::fromFullFileName(args[0]); return s ?: ""; } - case Command::_pad: { + case Command::Qpad: { String value = args[0]; int strlen = value.length(); int padlen = args[1].toInt(); @@ -392,7 +392,7 @@ String SectionTemplate::evaluate(char*& expr) return value; } - case Command::_repeat: { + case Command::Qrepeat: { int count = args[1].toInt(); if(count <= 0) { return ""; @@ -406,52 +406,52 @@ String SectionTemplate::evaluate(char*& expr) return value; } - case Command::_ifdef: + case Command::Qifdef: return openTag(args[0].toString().length() != 0); - case Command::_ifndef: + case Command::Qifndef: return openTag(args[0].toString().length() == 0); - case Command::_ifeq: + case Command::Qifeq: return openTag(args[0].compare(args[1]) == 0); - case Command::_ifneq: + case Command::Qifneq: return openTag(args[0].compare(args[1]) != 0); - case Command::_ifgt: + case Command::Qifgt: return openTag(args[0].compare(args[1]) > 0); - case Command::_iflt: + case Command::Qiflt: return openTag(args[0].compare(args[1]) < 0); - case Command::_ifge: + case Command::Qifge: return openTag(args[0].compare(args[1]) >= 0); - case Command::_ifle: + case Command::Qifle: return openTag(args[0].compare(args[1]) <= 0); - case Command::_ifbtw: + case Command::Qifbtw: return openTag(args[0].compare(args[1]) >= 0 && args[0].compare(args[2]) <= 0); - case Command::_ifin: + case Command::Qifin: return openTag(String(args[0]).indexOf(args[1]) >= 0); - case Command::_ifnin: + case Command::Qifnin: return openTag(String(args[0]).indexOf(args[1]) < 0); - case Command::_add: + case Command::Qadd: return args[0].add(args[1]); - case Command::_sub: + case Command::Qsub: return args[0].sub(args[1]); - case Command::_else: + case Command::Qelse: return elseTag(); - case Command::_endif: + case Command::Qendif: return closeTag(); - case Command::_goto: + case Command::Qgoto: if(isOutputEnabled()) { int n = args[0].toInt(); if(unsigned(n) >= sectionStream.count()) { @@ -462,7 +462,7 @@ String SectionTemplate::evaluate(char*& expr) } return ""; - case Command::_count: { + case Command::Qcount: { auto section = sectionStream.getSection(args[0].toInt()); if(section == nullptr) { return nullptr; @@ -470,7 +470,7 @@ String SectionTemplate::evaluate(char*& expr) return String(section->recordCount); } - case Command::_index: { + case Command::Qindex: { auto section = sectionStream.getSection(args[0].toInt()); if(section == nullptr) { return nullptr; diff --git a/Sming/Core/Data/Stream/SectionTemplate.h b/Sming/Core/Data/Stream/SectionTemplate.h index f675aa74f5..d396952c98 100644 --- a/Sming/Core/Data/Stream/SectionTemplate.h +++ b/Sming/Core/Data/Stream/SectionTemplate.h @@ -28,38 +28,38 @@ * Anything else is treated as a variable name. * Separator is : * - * @note Command tags are prefixed with _ to allow use of reserved words + * @note Command tags are prefixed with 'Q' to allow use of reserved words * in the Command enumeration. This represents the ! prefix in actual use. */ #define SECTION_TEMPLATE_COMMAND_MAP(XX) \ - XX(_as_int, "{!int:A} Output A as integer") \ - XX(_as_float, "{!float:A} Output A as float") \ - XX(_as_string, "{!string:A} Output A as quoted string") \ - XX(_mime_type, "{!mime_type:A} Get MIME type string for a filename") \ - XX(_replace, "{!replace:A:B:C} Copy of A with all occurrences of B replaced with C") \ - XX(_length, "{!length:A} Number of characters in A") \ - XX(_pad, \ + XX(Qas_int, "{!int:A} Output A as integer") \ + XX(Qas_float, "{!float:A} Output A as float") \ + XX(Qas_string, "{!string:A} Output A as quoted string") \ + XX(Qmime_type, "{!mime_type:A} Get MIME type string for a filename") \ + XX(Qreplace, "{!replace:A:B:C} Copy of A with all occurrences of B replaced with C") \ + XX(Qlength, "{!length:A} Number of characters in A") \ + XX(Qpad, \ "{!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") \ - XX(_repeat, "{!repeat:A:B} Repeat A, number of iterations is B") \ - XX(_kb, "{!kb:A} Convert A to KB") \ - XX(_ifdef, "{!ifdef:A}block{/if} emit block if A is not zero-length") \ - XX(_ifndef, "{!ifdef:A}block{/if} emit block if A is zero-length") \ - XX(_ifeq, "{!ifeq:A:B} emit block if A == B") \ - XX(_ifneq, "{!ifneq:A:B} emit block if A != B") \ - XX(_ifgt, "{!ifgt:A:B} emit block if A > B") \ - XX(_iflt, "{!iflt:A:B} emit block if A < B") \ - XX(_ifge, "{!ifge:A:B} emit block if A >= B") \ - XX(_ifle, "{!ifle:A:B} emit block if A <= B") \ - XX(_ifbtw, "{!ifbtw:A:B:C} emit block if B <= A <= C") \ - XX(_ifin, "{!ifin:A:B} emit block if A contains B") \ - XX(_ifnin, "{!ifin:A:B} emit block if A does not contain B") \ - XX(_else, "{!else}") \ - XX(_endif, "{!endif}") \ - XX(_add, "{!add:A:B} A - B") \ - XX(_sub, "{!sub:A:B} A - B") \ - XX(_goto, "{!goto:A} move to section A") \ - XX(_count, "{!count:A} emit number of records in section A") \ - XX(_index, "{!index:A} emit current record index for section A") + XX(Qrepeat, "{!repeat:A:B} Repeat A, number of iterations is B") \ + XX(Qkb, "{!kb:A} Convert A to KB") \ + XX(Qifdef, "{!ifdef:A}block{/if} emit block if A is not zero-length") \ + XX(Qifndef, "{!ifdef:A}block{/if} emit block if A is zero-length") \ + XX(Qifeq, "{!ifeq:A:B} emit block if A == B") \ + XX(Qifneq, "{!ifneq:A:B} emit block if A != B") \ + XX(Qifgt, "{!ifgt:A:B} emit block if A > B") \ + XX(Qiflt, "{!iflt:A:B} emit block if A < B") \ + XX(Qifge, "{!ifge:A:B} emit block if A >= B") \ + XX(Qifle, "{!ifle:A:B} emit block if A <= B") \ + XX(Qifbtw, "{!ifbtw:A:B:C} emit block if B <= A <= C") \ + XX(Qifin, "{!ifin:A:B} emit block if A contains B") \ + XX(Qifnin, "{!ifin:A:B} emit block if A does not contain B") \ + XX(Qelse, "{!else}") \ + XX(Qendif, "{!endif}") \ + XX(Qadd, "{!add:A:B} A - B") \ + XX(Qsub, "{!sub:A:B} A - B") \ + XX(Qgoto, "{!goto:A} move to section A") \ + XX(Qcount, "{!count:A} emit number of records in section A") \ + XX(Qindex, "{!index:A} emit current record index for section A") #define SECTION_TEMPLATE_FIELD_MAP(XX) \ XX(section, "{$section} Current section index") \ @@ -72,7 +72,7 @@ class SectionTemplate : public TemplateStream { public: enum class Command { - _unknown = 0, + Qunknown = 0, #define XX(name, comment) name, SECTION_TEMPLATE_COMMAND_MAP(XX) #undef XX