浏览该文件的文档.
20 #include <unordered_map>
35 #define ENABLE_TRACING 0
38 #define TRACE(x) printf x
48 bool allowEmptyEntries=
FALSE,
bool cleanup=
TRUE)
50 std::vector<QCString> lst;
53 int i = str.
find( sep, j );
65 lst.push_back(str.
mid(j,i-j));
68 else if (allowEmptyEntries)
85 lst.push_back(str.
mid(j,l-j+1));
88 else if (allowEmptyEntries)
113 while (j<l && (s[j]==
' '|| s[j]==
'='))
115 if (s[j]==
'=') found=
true;
138 if (result[i]==csrc) result[i]=cdst;
176 std::unordered_map<std::string,TemplateVariant>
m_fields;
212 result.push_back(kv.first);
214 std::sort(result.begin(),result.end());
220 return std::make_shared<TemplateStruct>();
242 m_index = count>0 ? count-1 : 0;
287 return std::make_unique< TemplateListGenericConstIterator<TemplateList> >(*this);
293 return std::make_shared<TemplateList>();
312 auto it =
m_elems.begin()+index;
313 m_elems.insert(it,list->m_elems.begin(),list->m_elems.end());
329 m_raw = std::move(v.m_raw);
331 v.m_variant.invalidate();
336 m_raw = std::move(v.m_raw);
338 v.m_variant.invalidate();
467 std::unordered_map<std::string,TemplateVariant>
fields;
471 std::initializer_list<StructField> fields)
472 : p(std::make_unique<
Private>(fields))
482 auto it =
p->fields.find(name.
str());
489 for (
const auto &kv :
p->fields)
491 result.push_back(kv.first);
493 std::sort(result.begin(),result.end());
499 return std::make_shared<TemplateImmutableStruct>(
fields);
515 : p(std::make_unique<
Private>(elements))
520 : p(std::make_unique<
Private>(elements))
530 return static_cast<uint>(
p->elems.size());
535 return std::make_unique< TemplateListGenericConstIterator<TemplateImmutableList> >(*this);
545 return std::make_shared<TemplateImmutableList>(elements);
550 return std::make_shared<TemplateImmutableList>(elements);
583 case Or:
return "or";
584 case And:
return "and";
585 case Not:
return "not";
586 case In:
return "in";
587 case Equal:
return "==";
589 case Less:
return "<";
593 case Plus:
return "+";
594 case Minus:
return "-";
599 case Colon:
return ":";
600 case Comma:
return ",";
603 case Last:
return "?";
646 using EscapeIntfMap = std::unordered_map<std::string, std::unique_ptr<TemplateEscapeIntf>>;
649 for (
const auto &kv : map)
666 int i=(!ext.
isEmpty() && ext.
at(0)==
'.') ? 1 : 0;
722 std::unordered_map< std::string, std::stack<TemplateVariant> >
m_indexStacks;
751 if (lhsIsInt && rhsIsInt)
753 return lhsValue+rhsValue;
833 for (it->toFirst();(it->current(item));it->toNext())
844 result->append(item);
852 return TemplateVariant(std::static_pointer_cast<TemplateListIntf>(result));
876 return TemplateVariant(std::static_pointer_cast<TemplateListIntf>(list));
1029 return TemplateVariant(std::static_pointer_cast<TemplateListIntf>(list));
1040 for (it->toFirst();(it->current(item));it->toNext())
1088 using SortList = std::vector<ListElem>;
1090 sortList.reserve(v.
toList()->count());
1091 for (it->toFirst();(it->current(item));it->toNext())
1097 sortList.emplace_back(sortKey,item);
1103 std::sort(sortList.begin(),
1105 [](
const auto &lhs,
const auto &rhs) { return lhs.key < rhs.key; });
1108 for (
const auto &elem : sortList)
1110 result->append(elem.value);
1112 return TemplateVariant(std::static_pointer_cast<TemplateListIntf>(result));
1123 while ((i=arg.
find(
"{{",p))!=-1)
1125 result+=arg.
mid(p,i-p);
1126 int j=arg.
find(
"}}",i+2);
1171 using SortList = std::vector<ListElem>;
1173 sortList.reserve(v.
toList()->count());
1174 for (it->toFirst();(it->current(item));it->toNext())
1180 sortList.emplace_back(sortKey,item);
1186 std::sort(sortList.begin(),
1188 [](
const auto &lhs,
const auto &rhs) { return lhs.key < rhs.key; });
1193 for (
const auto &elem : sortList)
1195 if (groupList==0 || elem.key!=prevKey)
1198 result->append(std::static_pointer_cast<TemplateListIntf>(groupList));
1201 groupList->
append(elem.value);
1203 return TemplateVariant(std::static_pointer_cast<TemplateListIntf>(result));
1247 int pageSize = args.
toInt();
1254 for (it->toFirst();(it->current(item));it->toNext())
1259 result->append(std::static_pointer_cast<TemplateListIntf>(pageList));
1261 pageList->append(item);
1269 return TemplateVariant(std::static_pointer_cast<TemplateListIntf>(result));
1293 const char *p = startLetter;
1303 const char hex[]=
"0123456789abcdef";
1306 result+=
hex[((
unsigned char)c)>>4];
1307 result+=
hex[((
unsigned char)c)&0xf];
1335 using SortList = std::vector<ListElem>;
1337 sortList.reserve(v.
toList()->count());
1338 for (it->toFirst();(it->current(item));it->toNext())
1344 sortList.emplace_back(sortKey,item);
1350 std::sort(sortList.begin(),
1352 [](
const auto &lhs,
const auto &rhs) { return lhs.key < rhs.key; });
1358 for (
const auto &elem : sortList)
1360 if (letter!=elem.key || indexNode==0)
1365 indexNode->set(
"letter", elem.key);
1366 indexNode->set(
"label",
keyToLabel(elem.key.c_str()));
1367 indexNode->set(
"items",std::static_pointer_cast<TemplateListIntf>(indexList));
1368 result->append(std::static_pointer_cast<TemplateStructIntf>(indexNode));
1371 indexList->append(elem.value);
1373 return TemplateVariant(std::static_pointer_cast<TemplateListIntf>(result));
1396 result=result.
mid(i+1);
1401 result=result.
mid(i+1);
1570 if (!s.
isEmpty() && (s.
at(0)==
'^' || s.
at(0)==
'!'))
1590 static std::unique_ptr<TemplateFilterFactory>
instance;
1601 return it->second(v,arg);
1678 {
TRACE((
"ExprAstNumber(%d)\n",num)); }
1711 {
TRACE((
"ExprAstFunctionVariable()\n"));
1715 std::vector<TemplateVariant> args;
1716 for (
const auto &exprArg :
m_args)
1743 if (ci==0)
return v;
1768 {
TRACE((
"ExprAstFilterAppl\n")); }
1783 {
TRACE((
"ExprAstLiteral(%s)\n",lit.
data())); }
1795 {
TRACE((
"ExprAstNegate\n")); }
1813 return -expr.
toInt();
1896 int denom = rhs.
toInt();
1903 ci->
warn(ci->
templateName(),ci->
line(),
"division by zero while evaluating expression is undefined");
1909 int denom = rhs.
toInt();
1916 ci->
warn(ci->
templateName(),ci->
line(),
"modulo zero while evaluating expression is undefined");
1973 TRACE((
"{TemplateNodeList::render\n"));
1974 for (
const auto &tn : *
this)
1978 TRACE((
"}TemplateNodeList::render\n"));
1999 void warn(
const QCString &fileName,
int line,
const char *fmt,...)
const;
2068 lhs = std::make_unique<ExprAstBinary>(
Operator::Or,std::move(lhs),std::move(rhs));
2086 lhs = std::make_unique<ExprAstBinary>(
Operator::And,std::move(lhs),std::move(rhs));
2107 result = std::make_unique<ExprAstNegate>(std::move(expr));
2136 lhs = std::make_unique<ExprAstBinary>(op,std::move(lhs),std::move(rhs));
2155 lhs = std::make_unique<ExprAstBinary>(op,std::move(lhs),std::move(rhs));
2174 lhs = std::make_unique<ExprAstBinary>(op,std::move(lhs),std::move(rhs));
2196 result = std::make_unique<ExprAstUnary>(
m_curToken.
op,std::move(rhs));
2260 TRACE((
"}parseNumber()\n"));
2269 TRACE((
"}parseIdentifier()\n"));
2278 TRACE((
"}parseLiteral()\n"));
2300 expr = std::make_unique<ExprAstFunctionVariable>(std::move(expr),std::move(args));
2303 TRACE((
"}parseIdentifierOptionalArgs()\n"));
2309 TRACE((
"{parseFilteredVariable()\n"));
2319 expr = std::make_unique<ExprAstFilterAppl>(std::move(expr),std::move(filter));
2322 TRACE((
"}parseFilteredVariable()\n"));
2338 ExprAstFilterPtr filter = std::make_unique<ExprAstFilter>(filterName,std::move(argExpr));
2339 TRACE((
"}parseFilter()\n"));
2349 if (p==0 || *p==
'\0')
return FALSE;
2350 while (*p==
' ') p++;
2361 if (c==
'=' && *(p+1)==
'=')
2368 if (c==
'!' && *(p+1)==
'=')
2375 if (c==
'<' && *(p+1)==
'=')
2387 if (c==
'>' && *(p+1)==
'=')
2439 if (strncmp(p,
"not ",4)==0)
2446 if (strncmp(p,
"and ",4)==0)
2453 if (strncmp(p,
"or ",3)==0)
2468 if (c>=
'0' && c<=
'9')
2473 while (*np>=
'0' && *np<=
'9')
2481 else if (c==
'_' || (c>=
'a' && c<=
'z') || (c>=
'A' && c<=
'Z'))
2488 (c==
'_' || c==
'.' ||
2489 (c>=
'a' && c<=
'z') ||
2490 (c>=
'A' && c<=
'Z') ||
2509 else if (c==
'"' || c==
'\'')
2516 while ((c=*p) && (c!=tokenChar || (c==tokenChar && cp==
'\\')))
2519 if (c!=
'\\' || cp==
'\\')
2526 if (*p==tokenChar) p++;
2538 TRACE((
"token type=%d op=%d num=%d id=%s\n",
2580 set(
"index",std::static_pointer_cast<TemplateStructIntf>(
m_indices));
2613 int oSize = iSize*4+1;
2615 size_t iLeft = iSize;
2616 size_t oLeft = oSize;
2617 const char *iPtr = s.
data();
2618 char *oPtr = output.
rawData();
2621 oSize -= (int)oLeft;
2623 output.
at(oSize)=
'\0';
2635 auto it = ctx.find(name.
str());
2640 ctx.insert(std::make_pair(name.
str(),v));
2648 int i=name.
find(
'.');
2666 i = propName.
find(
".");
2667 int l = i==-1 ? propName.
length() : i;
2668 v = s->get(propName.
left(l));
2675 objName = propName.
left(i);
2676 propName = propName.
mid(i+1);
2693 i = propName.
find(
".");
2694 int l = i==-1 ? propName.
length() : i;
2699 v = list->at(index);
2708 propName = propName.
mid(i+1);
2734 auto it = ctx.find(name.
str());
2751 m_contextStack.push_front(std::unordered_map<std::string,TemplateVariant>());
2786 if (kv==
m_indexStacks.end() || kv->second.empty() || kv->second.top().isList())
2792 auto &stack = kv->second;
2793 TemplateStructPtr entry = std::dynamic_pointer_cast<TemplateStruct>(stack.top().toStruct());
2798 stack.emplace(std::static_pointer_cast<TemplateListIntf>(list));
2799 entry->set(
"children",std::static_pointer_cast<TemplateListIntf>(list));
2800 entry->set(
"is_leaf_node",
false);
2814 auto &stack = kv->second;
2815 if (stack.top().isStruct() || stack.top().isWeakStruct())
2823 TemplateStructPtr entry = std::dynamic_pointer_cast<TemplateStruct>(stack.top().toStruct());
2826 entry->set(
"is_leaf_node",
true);
2842 list->append(entry);
2850 return std::static_pointer_cast<TemplateListIntf>(result);
2866 kv =
m_indexStacks.insert(std::make_pair(indexName.
str(),std::stack<TemplateVariant>())).first;
2869 auto &stack = kv->second;
2873 stack.emplace(std::static_pointer_cast<TemplateListIntf>(list));
2874 m_indices->set(indexName,std::static_pointer_cast<TemplateListIntf>(list));
2878 if (stack.top().isStruct() || stack.top().isWeakStruct())
2885 ASSERT(stack.top().isList());
2897 list = std::dynamic_pointer_cast<TemplateList>(stack.top().toList());
2901 for (
auto it=arguments.begin();it!=arguments.end();++it)
2903 entry->set((*it).key,(*it).value);
2905 if (list->count()>0)
2907 TemplateStructPtr lastEntry = std::dynamic_pointer_cast<TemplateStruct>(list->at(list->count()-1).toStruct());
2910 lastEntry->set(
"last",
false);
2913 entry->set(
"is_leaf_node",
true);
2914 entry->set(
"first",list->count()==0);
2915 entry->set(
"index",list->count());
2916 entry->set(
"parent",parent);
2919 entry->set(
"last",
true);
2920 stack.push(
TemplateVariant(std::static_pointer_cast<TemplateStructIntf>(entry)));
2921 list->append(
TemplateVariant(std::static_pointer_cast<TemplateStructIntf>(entry)));
2933 TRACE((
"TemplateNodeText('%s')\n",
replace(data,
'\n',
' ').data()));
2977 TRACE((
"TemplateNodeVariable(%s)\n",
qPrint(var)));
2991 TRACE((
"{TemplateNodeVariable::render\n"));
3025 TRACE((
"}TemplateNodeVariable::render\n"));
3049 return std::make_unique<T>(parser,
parent,line,data);
3054 while (root && root->
parent())
3063 size_t i=fileName.find(
'/');
3069 if (!rootDir.
mkdir(outputDir))
3071 err(
"tag OUTPUT_DIRECTORY: Output directory '%s' does not "
3072 "exist and cannot be created\n",outputDir.c_str());
3078 while (i!=std::string::npos)
3082 bool ok = d.
mkdir(fileName.substr(j,i-j));
3085 err(
"Failed to create directory '%s'\n",(fileName.substr(j,i-j)).c_str());
3088 std::string dirName = outputDir+
'/'+fileName.substr(0,i);
3092 i=fileName.find(
'/',i+1);
3120 guardedNodes->line = line;
3121 guardedNodes->guardAst = ex.
parse(data);
3122 parser->
parse(
this,line,stopAt,guardedNodes->trueNodes);
3127 while (tok && tok->data.left(5)==
"elif ")
3132 guardedNodes->line = tok->line;
3133 guardedNodes->guardAst = ex.
parse(tok->data.mid(5));
3134 parser->
parse(
this,tok->line,stopAt,guardedNodes->trueNodes);
3140 if (tok && tok->data==
"else")
3159 bool processed=
FALSE;
3162 if (nodes->guardAst)
3167 nodes->trueNodes.render(ts,c);
3202 TRACE((
"{TemplateNodeRepeat(%s)\n",
qPrint(data)));
3208 TRACE((
"}TemplateNodeRepeat(%s)\n",
qPrint(data)));
3218 int i, n = v.
toInt();
3222 s->set(
"counter0", (
int)i);
3223 s->set(
"counter", (
int)(i+1));
3224 s->set(
"revcounter", (
int)(n-i));
3225 s->set(
"revcounter0", (
int)(n-i-1));
3226 s->set(
"first",i==0);
3227 s->set(
"last", i==n-1);
3228 c->
set(
"repeatloop",std::static_pointer_cast<TemplateStructIntf>(s));
3254 int i1 = data.
find(
" from ");
3255 int i2 = data.
find(
" to ");
3256 int i3 = data.
find(
" downto ");
3263 else if (data==
"from")
3272 else if (i2==-1 && i3==-1)
3280 parser->
warn(
m_templateName,line,
"range is missing end value after 'downto' keyword");
3331 int l =
m_down ? s-e+1 : e-s+1;
3344 ls->set(
"counter0", (
int)index);
3345 ls->set(
"counter", (
int)(index+1));
3346 ls->set(
"revcounter", (
int)(l-index));
3347 ls->set(
"revcounter0", (
int)(l-index-1));
3348 ls->set(
"first",index==0);
3349 ls->set(
"last", (
int)index==l-1);
3351 c->
set(
"forloop",std::static_pointer_cast<TemplateStructIntf>(ls));
3376 s,
m_down?
"downto":
"to",e);
3379 else if (!vs.
isInt())
3383 else if (!ve.
isInt())
3417 int i = data.
find(
" in ");
3424 else if (data==
"in")
3441 int j = data.
find(
" reversed",i);
3444 if (j==-1) j=data.
length();
3447 exprStr = data.
mid(i+4,j-i-4);
3460 if (tok && tok->data==
"empty")
3486 uint listSize = list->count();
3499 for (
m_reversed ? it->toLast() : it->toFirst();
3504 s->set(
"counter0", (
int)index);
3505 s->set(
"counter", (
int)(index+1));
3506 s->set(
"revcounter", (
int)(listSize-index));
3507 s->set(
"revcounter0", (
int)(listSize-index-1));
3508 s->set(
"first",index==0);
3509 s->set(
"last", index==listSize-1);
3511 c->
set(
"forloop",std::static_pointer_cast<TemplateStructIntf>(s));
3532 for (;vi<
m_vars.size();vi++)
3568 TRACE((
"{TemplateNodeMsg()\n"));
3572 TRACE((
"}TemplateNodeMsg()\n"));
3576 TRACE((
"{TemplateNodeMsg::render\n"));
3590 TRACE((
"}TemplateNodeMsg::render\n"));
3634 if (sb && sb!=nb && sb!=
this)
3646 ci->
set(
"block",std::static_pointer_cast<TemplateStructIntf>(superBlock));
3683 TRACE((
"{TemplateNodeExtend(%s)\n",
qPrint(data)));
3692 TRACE((
"}TemplateNodeExtend(%s)\n",
qPrint(data)));
3735 baseTemplate->
render(ts,c);
3760 TRACE((
"TemplateNodeInclude(%s)\n",
qPrint(data)));
3789 incTemplate->
render(ts,c);
3809 bool skipSpaces=
true;
3810 const char *src = s.
data();
3815 if (c==
'\n') { *dst++=c; skipSpaces=
true; }
3816 else if (c==
' ' && skipSpaces) {}
3817 else { *dst++ = c; skipSpaces=
false; }
3834 int i = data.
find(
" from ");
3839 parser->
warn(
m_templateName,line,
"create is missing template name after 'from' keyword");
3841 else if (data==
"from")
3859 TRACE((
"{TemplateNodeCreate::render\n"));
3871 else if (outputFile.
isEmpty())
3884 extension=extension.
right(extension.
length()-i-1);
3897 std::ofstream f(outputFile.
str(),std::ofstream::out | std::ofstream::binary);
3904 createTemplate->
render(os,c);
3924 TRACE((
"}TemplateNodeCreate::render\n"));
3972 for (it->toFirst();(it->current(node));it->toNext())
3974 c->
set(
"node",node);
3975 bool hasChildren=
FALSE;
3983 if (list && list->count()>0)
3991 c->
set(
"children",children);
4053 TRACE((
"{TemplateNodeIndexEntry(%s)\n",
qPrint(data)));
4055 std::vector<QCString> args =
split(data,
" ");
4056 auto it = args.begin();
4057 if (it==args.end() || (*it).find(
'=')!=-1)
4059 parser->
warn(parser->
templateName(),line,
"Missing name for indexentry tag");
4065 while (it!=args.end())
4068 int j=arg.
find(
'=');
4074 m_args.emplace_back(arg.
left(j),std::move(expr));
4084 TRACE((
"}TemplateNodeIndexEntry(%s)\n",
qPrint(data)));
4093 std::vector<TemplateKeyValue> list;
4094 for (
const auto &mapping :
m_args)
4096 list.emplace_back(mapping.name,mapping.value->resolve(c));
4115 TRACE((
"{TemplateNodeOpenSubIndex(%s)\n",
qPrint(data)));
4119 parser->
warn(parser->
templateName(),line,
"Missing argument for opensubindex tag");
4123 parser->
warn(parser->
templateName(),line,
"Expected single argument for opensubindex tag got '%s'",
qPrint(data));
4126 TRACE((
"}TemplateNodeOpenSubIndex(%s)\n",
qPrint(data)));
4151 TRACE((
"{TemplateNodeCloseSubIndex(%s)\n",
qPrint(data)));
4155 parser->
warn(parser->
templateName(),line,
"Missing argument for closesubindex tag");
4159 parser->
warn(parser->
templateName(),line,
"Expected single argument for closesubindex tag got '%s'",
qPrint(data));
4162 TRACE((
"}TemplateNodeCloseSubIndex(%s)\n",
qPrint(data)));
4198 std::vector<QCString> args =
split(filteredData,
" ");
4199 auto it = args.begin();
4200 while (it!=args.end())
4203 int j=arg.
find(
'=');
4209 m_args.emplace_back(arg.
left(j),std::move(expr));
4232 for (
const auto &mapping :
m_args)
4235 ci->
set(mapping.name,value);
4257 std::vector<QCString> args =
split(data,
" ");
4258 auto it = args.begin();
4259 while (it!=args.end())
4264 m_args.emplace_back(std::move(expr));
4270 parser->
warn(parser->
templateName(),line,
"expected at least two arguments for cycle command, got %zu",
m_args.size());
4337 int j=data.
find(
'=');
4339 if (j>0 && (expr = expParser.
parse(data.
mid(j+1))))
4341 m_mapping = std::make_unique<Mapping>(data.
left(j),std::move(expr));
4372 TRACE((
"{TemplateNodeSpaceless()\n"));
4376 TRACE((
"}TemplateNodeSpaceless()\n"));
4401 TRACE((
"{TemplateNodeMarkers(%s)\n",
qPrint(data)));
4402 int i = data.
find(
" in ");
4403 int w = data.
find(
" with ");
4404 if (i==-1 || w==-1 || w<i)
4406 parser->
warn(
m_templateName,line,
"markers tag as wrong format. Expected: markers <var> in <list> with <string_with_markers>");
4418 TRACE((
"}TemplateNodeMarkers(%s)\n",
qPrint(data)));
4438 static const reg::Ex marker(R
"(@\d+)");
4442 for ( ; re_it!=
end ; ++re_it)
4444 const auto &
match = *re_it;
4445 size_t newIndex =
match.position();
4446 size_t matchLen =
match.length();
4447 std::string part = str.substr(index,newIndex-index);
4456 unsigned long entryIndex = std::stoul(
match.str().substr(1));
4460 for (it->toFirst(); (it->current(var)) && i<entryIndex; it->toNext(),i++) {}
4464 s->set(
"id",(
int)i);
4465 c->
set(
"markers",std::static_pointer_cast<TemplateStructIntf>(s));
4472 else if (i<entryIndex)
4476 index=newIndex+matchLen;
4480 ts << ci->
recode(str.substr(index));
4484 ts << str.substr(index);
4515 TRACE((
"{TemplateNodeTabbing()\n"));
4519 TRACE((
"}TemplateNodeTabbing()\n"));
4544 TRACE((
"{TemplateNodeResource(%s)\n",
qPrint(data)));
4553 else if ((i=data.
find(
" as "))!=-1)
4558 else if ((i=data.
find(
" append "))!=-1)
4569 TRACE((
"}TemplateNodeResource(%s)\n",
qPrint(data)));
4621 TRACE((
"{TemplateNodeEncoding(%s)\n",
qPrint(data)));
4635 TRACE((
"}TemplateNodeEncoding(%s)\n",
qPrint(data)));
4645 encStr =
m_encExpr->resolve(c).toString();
4673 static std::unique_ptr<TemplateNodeFactory>
instance;
4686 return it->second(parser,parent,line,data);
4740 if (it==
m_blocks.end() || it->second.empty())
4746 return it->second.back();
4753 if (it==
m_blocks.end() || it->second.empty())
4760 it->second.pop_back();
4772 it->second.push_front(block);
4779 for (
auto &nb : kv.second)
4798 it->second.push_back(block);
4814 const QCString &data,
int line,
int startPos,
int endPos,
4825 m_engine(engine), m_fileName(fileName), m_data(data)
4848 int state=StateText;
4852 bool emptyOutputLine=
TRUE;
4855 int markStartPos=-1;
4856 for (;(c=*p);p++,pos++)
4863 state=StateBeginTemplate;
4865 else if (c!=
' ' && c!=
'\t' && c!=
'\n')
4867 emptyOutputLine=
FALSE;
4870 case StateBeginTemplate:
4884 state=StateMaybeVar;
4888 state=StateVariable;
4894 emptyOutputLine=
FALSE;
4915 emptyOutputLine ? startLinePos : markStartPos,
4919 lastTokenPos = pos+1;
4939 state=StateEndComment;
4942 case StateEndComment:
4948 emptyOutputLine ? startLinePos : markStartPos,
4950 lastTokenPos = pos+1;
4974 state=StateVariable;
4979 emptyOutputLine=
FALSE;
4987 state=StateEndVariable;
4990 case StateEndVariable:
4996 emptyOutputLine ? startLinePos : markStartPos,
5000 lastTokenPos = pos+1;
5009 state=StateVariable;
5019 if (markStartPos!=-1 && emptyOutputLine) lastTokenPos = startLinePos;
5023 emptyOutputLine=
TRUE;
5026 if (lastTokenPos<pos)
5036 int startPos,
int endPos,
5039 if (startPos<endPos)
5041 int len = endPos-startPos;
5044 tokens.push_back(std::make_unique<TemplateToken>(type,text,line));
5053 m_engine(engine), m_templateName(templateName), m_tokens(tokens)
5061 TRACE((
"{TemplateParser::parse\n"));
5066 TRACE((
"%p:Token type=%d data='%s' line=%d\n",
5067 (
void*)parent,tok->type,
qPrint(tok->data),tok->line));
5071 nodes.push_back(std::make_unique<TemplateNodeText>(
this,parent,tok->line,tok->data));
5074 nodes.push_back(std::make_unique<TemplateNodeVariable>(
this,parent,tok->line,tok->data));
5079 int sep = command.
find(
' ');
5082 command=command.
left(sep);
5085 if (std::find(stopAt.begin(),stopAt.end(),command.
str())!=stopAt.end())
5088 TRACE((
"}TemplateParser::parse: stop\n"));
5094 arg = tok_ptr->
data.
mid(sep+1);
5097 command,
this,parent,tok_ptr->
line,arg);
5100 nodes.push_back(std::move(node));
5102 else if (command==
"empty" || command==
"else" ||
5103 command==
"endif" || command==
"endfor" ||
5104 command==
"endblock" || command==
"endwith" ||
5105 command==
"endrecursetree" || command==
"endspaceless" ||
5106 command==
"endmarkers" || command==
"endmsg" ||
5107 command==
"endrepeat" || command==
"elif" ||
5108 command==
"endrange" || command==
"endtabbing" ||
5109 command==
"endencoding")
5121 if (!stopAt.empty())
5124 for (
const auto &s : stopAt)
5126 if (!options.
isEmpty()) options+=
", ";
5132 TRACE((
"}TemplateParser::parse: last token\n"));
5143 auto tok = std::move(
m_tokens.front());
5160 m_tokens.push_front(std::move(token));
5167 va_warn(fileName,line,fmt,args);
5185 if (extension==
"tex")
5264 std::ifstream f(filePath.
str(),std::ifstream::in | std::ifstream::binary);
5268 int size=(int)fi.
size();
5274 std::make_pair(fileName.str(),
5284 std::make_pair(fileName.str(),
5289 err(
"Could not open template file %s\n",
qPrint(fileName));
5338 warn(fileName,line,
" included by block '%s' inside template '%s' at line %d",
qPrint(ie.
blockName()),
5378 return std::make_unique<TemplateContextImpl>(
this);
5383 return p->loadByName(fileName,line);
5393 p->enterBlock(fileName,blockName,line);
5403 p->printIncludeContext(fileName,line);
5408 p->setOutputExtension(extension);
5413 return p->outputExtension();
5418 p->setTemplateDir(dirName);
5432 for (it->toFirst();it->current(ve);it->toNext())
5434 if (!first) result+=
",\n";
5450 for (
const auto &s : strukt->fields())
5452 if (!first) result+=
",";
5457 result+=strukt->get(
QCString(s)).toString();
TemplateListGenericConstIterator(const List &l)
void render(TextStream &ts, TemplateContext *c)
TemplateStructIntfPtr toStruct()
Returns the pointer to struct referenced by this variant or 0 if this variant does not have struct ty...
void render(TextStream &, TemplateContext *c)
QCString encoding() const
std::vector< std::string > StringVector
void render(TextStream &, TemplateContext *c)
bool copyResource(const QCString &name, const QCString &targetDir) const
Copies a registered resource to a given target directory
static TemplateFilterFactory::AutoRegister< FilterListSort > fListSort("listsort")
std::vector< Mapping > m_args
static QCString keyToLabel(const char *startLetter)
void setEncoding(const QCString &file, int line, const QCString &enc)
static TemplateStructIntfPtr alloc(std::initializer_list< StructField > fields)
Creates an instance and returns a shared pointer to it
void warn(const QCString &fileName, int line, const char *fmt,...) const
TemplateNodeTree(TemplateParser *parser, TemplateNode *parent, int line, const QCString &data)
static TemplateVariant apply(const TemplateVariant &v, const TemplateVariant &arg)
Class representing an 'markers' tag in a template
TemplateNodeList m_loopNodes
bool copyResourceAs(const QCString &name, const QCString &targetDir, const QCString &targetName, bool append=false) const
Copies a registered resource to a given target directory under a given target name
void render(TextStream &ts, TemplateContext *c)
void prependToken(TemplateTokenPtr &&token)
ExprAstPtr parseIdentifier()
The implementation of the "default" filter
size_t portable_iconv(void *cd, const char **inbuf, size_t *inbytesleft, char **outbuf, size_t *outbytesleft)
TemplateNodeMsg(TemplateParser *parser, TemplateNode *parent, int line, const QCString &)
ExprAstFunctionVariable(ExprAstPtr &&var, ExprAstList &&args)
static TemplateVariant apply(const TemplateVariant &v, const TemplateVariant &args)
std::vector< TemplateVariant > TemplateVariantList
virtual bool current(TemplateVariant &v) const
static TemplateNodeFactory::AutoRegister< TemplateNodeTree > autoRefTree("recursetree")
virtual TemplateListIntf::ConstIteratorPtr createIterator() const
Creates a new iterator for this list.
static TemplateVariant apply(const TemplateVariant &v, const TemplateVariant &)
const TemplateStructPtr indices() const
static ResourceMgr & instance()
Returns the one and only instance of this class
TemplateVariant apply(const QCString &name, const TemplateVariant &v, const TemplateVariant &arg, bool &ok)
static TemplateNodeFactory::AutoRegister< TemplateNodeIndexEntry > autoRefIndexEntry("indexentry")
static TemplateNodeFactory::AutoRegister< TemplateNodeIf > autoRefIf("if")
void render(TextStream &ts, TemplateContext *c)
static TemplateFilterFactory::AutoRegister< FilterUpper > fUpper("upper")
The implementation of the "upper" filter
The implementation of the "paginate" filter
Class representing a variable in the AST
std::unique_ptr< ExprAstFilter > ExprAstFilterPtr
constexpr bool isList() const
Returns TRUE if the variant holds a list value
The implementation of the "upper" filter
virtual void set(const QCString &name, const TemplateVariant &v)
Sets the value the field of a struct
std::unique_ptr< Private > p
std::deque< TemplateTokenPtr > TemplateTokenStream
Class representing an 'opensubindex' tag in a template
static TemplateVariant apply(const TemplateVariant &v, const TemplateVariant &)
Class representing an 'cycle' tag in a template
void setActiveEscapeIntf(TemplateEscapeIntf *intf)
std::string replace(const std::string &str, const Ex &re, const std::string &replacement)
Searching in a given input string for parts that match regular expression re and replaces those parts...
Helper class for registering a filter function
char * rawData()
Returns a writable pointer to the data.
static TemplateNodePtr createInstance(TemplateParser *parser, TemplateNode *parent, int line, const QCString &data)
Class representing a filter applied to an expression in the AST
The implementation of the "default" filter
Operator::Type m_operator
std::unique_ptr< Private > p
static TemplateFilterFactory::AutoRegister< FilterGet > fGet("get")
static TemplateNodeFactory::AutoRegister< TemplateNodeExtend > autoRefExtend("extend")
TemplateNodeList m_loopNodes
ExprAstVariable(const QCString &name)
static void stripLeadingWhiteSpace(QCString &s)
void printIncludeContext(const QCString &fileName, int line) const
void mkpath(const TemplateContextImpl *ci, const std::string &fileName)
TemplateEngine()
Create a template engine.
QCString getAsString(const QCString &name) const
Gets the resource data as a C string
static TemplateVariant apply(const TemplateVariant &v, const TemplateVariant &)
Class representing an 'indexentry' tag in a template
virtual TemplateVariant resolve(TemplateContext *)
std::unordered_map< std::string, std::stack< TemplateVariant > > m_indexStacks
The implementation of the "raw" filter
virtual void enableTabbing(bool b)=0
Setting tabbing mode on or off (for LaTeX)
virtual TemplateVariant get(const QCString &name) const
Gets the value for a field name.
std::unordered_map< std::string, TemplateVariant > fields
Class representing a directory in the file system
static TemplateFilterFactory::AutoRegister< FilterEscape > fEscape("escape")
The implementation of the "e" filter
void setOutputExtension(const QCString &extension)
Class representing a negation (not) operator in the AST
void render(TextStream &ts, TemplateContext *c)
Class representing an 'create' tag in a template
Class representing a list of AST nodes in a template
Private(TemplateEngine *engine)
constexpr bool isFunction() const
Returns TRUE if the variant holds a function value
Private data of a template immutable list object
void render(TextStream &ts, TemplateContext *c)
uint length() const
Returns the length of the string, not counting the 0-terminator.
std::shared_ptr< TemplateList > TemplateListPtr
static TemplateFilterFactory::AutoRegister< FilterIsRelativeURL > fIsRelativeURL("isRelativeURL")
const TemplateToken * currentToken() const
TemplateVariant apply(const TemplateVariant &v, TemplateContext *c)
TemplateVariantList elems
TemplateImmutableList(std::initializer_list< TemplateVariant > elements)
Creates a list
TemplateEscapeIntf * escapeIntf()
void enableTabbing(bool b)
void setLocation(const QCString &templateName, int line)
int findRev(char c, int index=-1, bool cs=TRUE) const
TemplateBlockContext m_blockContext
QCString outputExtension() const
Returns the output extension, set via setOutputExtension()
TemplateEngine * m_engine
TemplateNodeTree * object
TemplateNodeBlock(TemplateParser *parser, TemplateNode *parent, int line, const QCString &data)
QCString structToString() const
bool isEmpty() const
Returns TRUE iff the string is empty
virtual TemplateVariant resolve(TemplateContext *c)
bool match(const std::string &str, Match &match, const Ex &re)
Matches a given string str for a match against regular expression re.
virtual TemplateVariant resolve(TemplateContext *c)
TemplateVariant call(const std::vector< TemplateVariant > &args=std::vector< TemplateVariant >())
Return the result of apply this function with args.
TemplateVariant() FilterFunction(const TemplateVariant &v, const TemplateVariant &arg)
Class representing a 'block' tag in a template
static TemplateNodeFactory::AutoRegister< TemplateNodeInclude > autoRefInclude("include")
void render(TextStream &ts, TemplateContext *c)
void registerFilter(const QCString &name, FilterFunction *func)
constexpr bool isBool() const
Returns TRUE if the variant holds a boolean value
void push(TemplateNodeBlock *block)
static QCString determineSortKey(const TemplateStructIntfPtr s, const QCString &arg)
The implementation of the "listsort" filter
Helper class for creating template AST tag nodes and returning the template for a given node.
TemplateNodeResource(TemplateParser *parser, TemplateNode *parent, int line, const QCString &data)
static TemplateVariant apply(const TemplateVariant &v, const TemplateVariant &arg)
static std::vector< QCString > split(const QCString &str, const QCString &sep, bool allowEmptyEntries=FALSE, bool cleanup=TRUE)
std::unique_ptr< TemplateToken > TemplateTokenPtr
TemplateNodeIndexEntry(TemplateParser *parser, TemplateNode *parent, int line, const QCString &data)
virtual void toFirst()
Moves iterator to the first element in the list
const QCString & name() const
virtual uint count() const
Returns the number of elements in the list
The implementation of the "divisibleby" filter
void render(TextStream &ts, TemplateContext *c)
Class representing a piece of plain text in a template
Template * loadByName(const QCString &fileName, int fromLine)
Creates a new template whose contents are in a file.
Factory singleton for registering and creating filters
TemplateNodeRepeat(TemplateParser *parser, TemplateNode *parent, int line, const QCString &data)
Default implementation of a context value of type struct.
The implementation of the "isRelativeURL" filter
QCString listToString() const
virtual QCString escape(const QCString &input)=0
Returns the input after escaping certain characters
static TemplateFilterFactory::AutoRegister< FilterAlphaIndex > fAlphaIndex("alphaIndex")
static TemplateVariant apply(const TemplateVariant &v, const TemplateVariant &)
TemplateNodeEncoding(TemplateParser *parser, TemplateNode *parent, int line, const QCString &data)
Class representing an 'set' tag in a template
TemplateEscapeIntf * m_activeEscapeIntf
std::unique_ptr< Private > p
Class representing the 'encoding' tag in a template
void setSpacelessIntf(std::unique_ptr< TemplateSpacelessIntf > intf)
Sets the interface that will be used inside a spaceless block to remove any redundant whitespace.
Abstract interface for a template.
static TemplateNodeFactory::AutoRegister< TemplateNodeResource > autoRefResource("resource")
TemplateContextImpl(const TemplateEngine *e)
Class representing a number in the AST
static TemplateFilterFactory::AutoRegister< FilterAppend > fAppend("append")
static TemplateVariant apply(const TemplateVariant &v, const TemplateVariant &)
TemplateVariant get(const QCString &name) const
Gets the value for a given key
static TemplateVariant apply(const TemplateVariant &v, const TemplateVariant &)
QCString templateName() const
The implementation of the "texindex" filter
constexpr bool isWeakStruct() const
Returns TRUE if the variant holds a struct value
Class representing an 'tree' tag in a template
void setOutputExtension(const QCString &extension)
Sets the extension of the output file.
TemplateNodeOpenSubIndex(TemplateParser *parser, TemplateNode *parent, int line, const QCString &data)
std::unique_ptr< Mapping > m_mapping
The implementation of the "flatten" filter
ExprAstPtr parseIdentifierOptionalArgs()
virtual void toNext()
Moves iterator to the next element in the list
virtual ~TemplateContextImpl()
void render(TextStream &, TemplateContext *c)
void err(const char *fmt,...)
The implementation of the "alphaIndex" filter
char & at(size_t i)
Returns a reference to the character at index i.
Class representing an 'closesubindex' tag in a template
Text streaming class that buffers data.
ListElem(std::string k, const TemplateVariant &v)
void * portable_iconv_open(const char *tocode, const char *fromcode)
void render(TextStream &ts, TemplateContext *c)
TemplateEngine * engine() const
int find(char c, int index=0, bool cs=TRUE) const
ExprAstPtr parseAdditiveExpression()
static TemplateVariant apply(const TemplateVariant &v, const TemplateVariant &arg)
void render(TextStream &ts, TemplateContext *c)
static TemplateFilterFactory::AutoRegister< FilterFlatten > fFlatten("flatten")
TemplateNodeWith(TemplateParser *parser, TemplateNode *parent, int line, const QCString &data)
ExprAstUnary(Operator::Type op, ExprAstPtr &&expr)
void printIncludeContext(const QCString &fileName, int line) const
Prints the current template file include stack
static TemplateFilterFactory::AutoRegister< FilterLower > fLower("lower")
void flush()
Flushes the buffer.
void render(TextStream &, TemplateContext *c)
Helper class for registering a template AST node
std::unordered_map< std::string, TemplateVariant > m_fields
TemplateImmutableStruct(std::initializer_list< StructField > fields)
Creates a struct
static TemplateVariant apply(const TemplateVariant &v, const TemplateVariant &args)
Lexer class for turning a template into a list of tokens
std::unique_ptr< TemplateSpacelessIntf > & spacelessIntf()
Internal class representing the implementation of a template
void warn(const QCString &file, int line, const char *fmt,...)
std::shared_ptr< TemplateStructIntf > TemplateStructIntfPtr
Abstract interface for a iterator of a list.
TemplateEngine * m_engine
Iterator class to iterator through matches.
static TemplateFilterFactory::AutoRegister< FilterIsAbsoluteURL > fIsAbsoluteURL("isAbsoluteURL")
virtual ~TemplateList()=default
Destroys the list
TreeContext(TemplateNodeTree *o, const TemplateListIntfPtr l, TemplateContext *c)
virtual void render(TextStream &ts, TemplateContext *c)=0
std::vector< std::unique_ptr< GuardedNodes > > m_ifGuardedNodes
DirIterator end(const DirIterator &) noexcept
TemplateNodeSet(TemplateParser *parser, TemplateNode *parent, int line, const QCString &data)
std::unique_ptr< ConstIterator > ConstIteratorPtr
Mapping(const QCString &n, ExprAstPtr &&e)
Abstract read-only interface for a context value of type list.
void addToken(TemplateTokenStream &tokens, const QCString &data, int line, int startPos, int endPos, TemplateToken::Type type)
Recursive decent parser for Django style template expressions.
virtual void toPrev()
Moves iterator to the previous element in the list
Class representing a 'for' tag in a template
The implementation of the "keep" filter
TemplateNodeList m_treeNodes
TemplateNodeFor(TemplateParser *parser, TemplateNode *parent, int line, const QCString &data)
TemplateNodeCloseSubIndex(TemplateParser *parser, TemplateNode *parent, int line, const QCString &data)
void render(TextStream &ts, TemplateContext *c)
The implementation of the "lower" filter
Class representing an 'markers' tag in a template
TemplateBlockContext * blockContext()
Type< index > & get()
Return a non-constant reference to the value held by the variant container.
Class holding stacks of blocks available in the context
void render(TextStream &ts, TemplateContext *c)
void render(TextStream &ts, TemplateContext *c)
ExprAstPtr parseUnaryExpression()
TemplateNodeList m_emptyNodes
ExprAstPtr parseNotExpression()
ExprAstPtr parseExpression()
TemplateTokenStream & m_tokens
constexpr bool valid() const
Returns true iff the Variant holds a valid type.
void warn(const QCString &fileName, int line, const char *fmt,...) const
virtual void remove(const QCString &name)
Removes the field from the struct
ExprAstPtr parseCompareExpression()
Class representing an 'with' tag in a template
std::unique_ptr< TemplateContext > createContext() const
Creates a new context that can be using to render a template.
Variant type which can hold one value of a fixed set of types.
std::vector< QCString > m_vars
ListElem(const QCString &k, const TemplateVariant &v)
QCString stripWhiteSpace() const
returns a copy of this string with leading and trailing whitespace removed
static TemplateNodeFactory::AutoRegister< TemplateNodeTabbing > autoRefTabbing("tabbing")
TemplateNodeInclude(TemplateParser *parser, TemplateNode *parent, int line, const QCString &data)
TemplateNodeText(TemplateParser *, TemplateNode *parent, int, const QCString &data)
Base class for all nodes in the abstract syntax tree of an expression.
static TemplateVariant apply(const TemplateVariant &v, const TemplateVariant &arg)
Class representing an 'tabbing' tag in a template
QCString left(size_t len) const
ExprAstFilter(const QCString &name, ExprAstPtr &&arg)
const TemplateVariant * getRef(const QCString &name) const
Returns a pointer to the value corresponding to a given key.
static TemplateVariant apply(const TemplateVariant &v, const TemplateVariant &)
Private data of the template engine
constexpr bool isInt() const
Returns TRUE if the variant holds an integer value
TemplateList()=default
Creates a list
static TemplateNodeFactory::AutoRegister< TemplateNodeRange > autoRefRange("range")
std::unordered_map< std::string, std::unique_ptr< TemplateEscapeIntf > > EscapeIntfMap
Private data of a template struct object
ExprAstPtr parseAndExpression()
virtual void append(const TemplateVariant &v)
Appends element v to the end of the list
TemplateContext * templateCtx
ExprAstPtr parse(const QCString &expr)
static const char * toString(Type op)
void closeSubIndex(const QCString &indexName)
virtual StringVector fields() const
Return the list of fields.
std::unordered_map< std::string, std::unique_ptr< Template > > m_templateCache
The implementation of the "list" filter
static TemplateNodeFactory::AutoRegister< TemplateNodeWith > autoRefWith("with")
bool hasNextToken() const
Class representing a token within an expression.
Template * loadByName(const QCString &fileName, int line)
TemplateVariant getPrimary(const QCString &name) const
static TemplateFilterFactory::AutoRegister< FilterDivisibleBy > fDivisibleBy("divisibleby")
The implementation of the "length" filter
void removeAt(uint index)
TemplateNodeRange(TemplateParser *parser, TemplateNode *parent, int line, const QCString &data)
bool tabbingEnabled() const
static TemplateVariant apply(const TemplateVariant &v, const TemplateVariant &args)
void render(TextStream &, TemplateContext *c)
void openSubIndex(const QCString &indexName)
virtual TemplateVariant at(uint index) const
Returns the element at index position index.
EscapeIntfMap m_escapeIntfMap
std::weak_ptr< TemplateStructIntf > TemplateStructIntfWeakPtr
static std::string determineSortKey(const TemplateStructIntfPtr s, const QCString &attribName)
Class representing an 'include' tag in a template
ExprAstLiteral(const QCString &lit)
TemplateNodeList m_falseNodes
static TemplateNodeFactory::AutoRegister< TemplateNodeCycle > autoRefCycle("cycle")
static TemplateFilterFactory::AutoRegister< FilterHex > fHex("hex")
QCString blockName() const
const TemplateListIntfPtr list
std::string getUTF8CharAt(const std::string &input, size_t pos)
Returns the UTF8 character found at byte position pos in the input string.
TemplateVariant()
Constructs an invalid variant.
Private(std::initializer_list< TemplateVariant > e)
void enableSpaceless(bool b)
static TemplateFilterFactory & instance()
const TemplateEngine * m_engine
Class representing a 'for' tag in a template
static TemplateVariant apply(const TemplateVariant &v, const TemplateVariant &)
void registerTemplateNode(const QCString &name, CreateFunc func)
void setEscapeIntf(const QCString &ext, std::unique_ptr< TemplateEscapeIntf > intf)
Sets the interface that will be used for escaping the result of variable expansion before writing it ...
Class representing a filter in the AST
TemplateNodeExtend(TemplateParser *parser, TemplateNode *parent, int line, const QCString &data)
The implementation of the "decodeURL" filter The leading character is removed from the value in case ...
static TemplateVariant getPathFunc(const TemplateStructIntfWeakPtr entryWeakRef)
QCString latexEscapeLabelName(const QCString &s)
virtual void set(const QCString &name, const TemplateVariant &v)=0
Sets a value in the current scope.
TemplateToken(Type t, const QCString &d, int l)
virtual ~ExpressionParser()
const TemplateParser * m_parser
static TemplateNodeFactory::AutoRegister< TemplateNodeSet > autoRefSet("set")
QCString outputDirectory() const
QCString recode(const QCString &s)
The implementation of the "relative" filter
void push()
Push a new scope on the stack.
void render(TextStream &, TemplateContext *c)
TemplateNodeCreate(TemplateParser *parser, TemplateNode *parent, int line, const QCString &data)
static TemplateFilterFactory::AutoRegister< FilterPrepend > fPrepend("prepend")
Class representing a variable in a template
The implementation of the "isRelativeURL" filter
int toInt(bool *ok=0, int base=10) const
virtual uint count() const
Returns the number of elements in the list
IncludeEntry(Type type, const QCString &fileName, const QCString &blockName, int line)
static TemplateFilterFactory::AutoRegister< FilterStripPath > fStripPath("stripPath")
The implementation of the "groupBy" filter
constexpr bool isStruct() const
Returns TRUE if the variant holds a struct value
static void getPathListFunc(const TemplateStructIntfPtr entry, TemplateListPtr list)
static TemplateFilterFactory::AutoRegister< FilterAdd > fAdd("add")
static TemplateFilterFactory::AutoRegister< FilterLength > fLength("length")
Abstract interface for a template context.
void setOpenCloseCharacters(char openChar, char closeChar)
TemplateImpl * getTemplate()
std::string str() const
Return the contents of the buffer as a std::string object
void va_warn(const QCString &file, int line, const char *fmt, va_list args)
static TemplateListPtr alloc()
Creates an instance and returns a shared pointer to it
void render(TextStream &, TemplateContext *c)
~TemplateEngine()
Destroys the template engine.
void render(TextStream &ts, TemplateContext *c)
static TemplateNodeFactory::AutoRegister< TemplateNodeCloseSubIndex > autoRefCloseSubIndex("closesubindex")
virtual TemplateVariant resolve(TemplateContext *c)
std::vector< IncludeEntry > m_includeStack
TemplateNodeMarkers(TemplateParser *parser, TemplateNode *parent, int line, const QCString &data)
void setOutputDirectory(const QCString &dir)
When files are created (i.e.
The implementation of the "add" filter
static TemplateVariant apply(const TemplateVariant &v, const TemplateVariant &)
std::vector< Mapping > m_args
TemplateKeyValue(const QCString &k, const TemplateVariant &v)
virtual ~TemplateListGenericConstIterator()
constexpr bool raw() const
Returns whether or not the value of the Value is raw.
Class representing a 'range' tag in a template
The implementation of the "texlabel" filter
ExpressionParser(const TemplateParser *parser, int line)
void add(TemplateNodeBlock *block)
void render(TextStream &ts, TemplateContext *c)
static TemplateVariant apply(const TemplateVariant &v, const TemplateVariant &)
Class representing a lexical token in a template
void parse(TemplateNode *parent, int line, const StringVector &stopAt, TemplateNodeList &nodes)
static TemplateVariant apply(const TemplateVariant &v, const TemplateVariant &args)
int getPrefixIndex(const QCString &name)
QCString & setNum(short n)
Class representing an 'if' tag in a template
TemplateNode(TemplateNode *parent)
QCString fileName() const
bool operator==(TemplateVariant &other) const
Compares this QVariant with v and returns true if they are equal; otherwise returns false.
ExprAstPtr parsePrimaryExpression()
void insertAt(uint index, TemplateListPtr list)
ListElem(const QCString &k, const TemplateVariant &v)
TemplateBlockContext m_blockContext
std::unique_ptr< ExprAst > ExprAstPtr
static TemplateVariant apply(const TemplateVariant &v, const TemplateVariant &)
Various UTF8 related helper functions.
bool needsRecoding() const
virtual TemplateVariant get(const QCString &name) const
Gets the value for a field name.
virtual TemplateVariant get(const QCString &name) const =0
Gets the value for a given key
virtual ~TemplateImmutableStruct()
Destroys the struct
A container to store a key-value pair
void copyEscapeIntfMap(const EscapeIntfMap &map)
static TemplateNodeFactory::AutoRegister< TemplateNodeFor > autoRefFor("for")
static TemplateVariant apply(const TemplateVariant &v, const TemplateVariant &)
ExprAstPtr parseMultiplicativeExpression()
Class representing a 'extend' tag in a template
std::deque< TemplateNodeBlock * > NodeBlockList
virtual TemplateListIntf::ConstIteratorPtr createIterator() const
Creates a new iterator for this list.
QCString mid(size_t index, size_t len=static_cast< size_t >(-1)) const
static TemplateNodeFactory::AutoRegister< TemplateNodeCreate > autoRefCreate("create")
QCString substitute(const QCString &s, const QCString &src, const QCString &dst)
substitute all occurrences of src in s by dst
std::shared_ptr< TemplateListIntf > TemplateListIntfPtr
Base class of all nodes in a template's AST
ExprAstFilterPtr parseFilter()
Abstract interface for a context value of type struct.
QCString renderChildren(const TreeContext *ctx)
static void removeSpacesAroundEquals(QCString &s)
Strips spaces surrounding = from string in, so ‘foo = 10 bar=5 baz= 'hello’will becomefoo=10 bar=5 ba...
std::unordered_map< std::string, FilterFunction * > m_registry
static TemplateFilterFactory::AutoRegister< FilterNoWrap > fNoWrap("nowrap")
static TemplateVariant apply(const TemplateVariant &v, const TemplateVariant &n)
QCString & append(char c)
QCString m_templateDirName
TemplateNodeList trueNodes
void tokenize(TemplateTokenStream &tokens)
static TemplateListIntfPtr alloc(std::initializer_list< TemplateVariant > elements)
Creates an instance and returns a shared pointer to it
TemplateLexer(const TemplateEngine *engine, const QCString &fileName, const QCString &data)
TemplateNodeBlock * get(const QCString &name) const
void addIndexEntry(const QCString &indexName, const std::vector< TemplateKeyValue > &arguments)
QCString toString() const
Returns the variant as a string.
TemplateStructPtr m_indices
Class representing a regular expression.
const TemplateEngine * m_engine
void msg(const char *fmt,...)
QCString outputExtension() const
TemplateNodeVariable(TemplateParser *parser, TemplateNode *parent, int line, const QCString &var)
const char * m_tokenStream
ExprAstPtr m_templateExpr
static TemplateFilterFactory::AutoRegister< FilterList > fList("list")
const QCString & literal() const
ExprAstNegate(ExprAstPtr &&expr)
const TemplateEngine * m_engine
bool endsWith(const char *s) const
void setTemplateDir(const QCString &dirName)
static TemplateVariant apply(const TemplateVariant &v, const TemplateVariant &)
TemplateVariantList m_elems
Minimal replacement for QFileInfo.
static TemplateFilterFactory::AutoRegister< FilterPaginate > fPaginate("paginate")
constexpr bool isValid() const
Returns TRUE if the variant holds a valid value, or FALSE otherwise
static TemplateNodeFactory::AutoRegister< TemplateNodeSpaceless > autoRefSpaceless("spaceless")
void set(const QCString &name, const TemplateVariant &v)
Sets a value in the current scope.
const char * qPrint(const char *s)
TemplateNodeCreator(TemplateParser *parser, TemplateNode *parent, int line)
virtual TemplateVariant resolve(TemplateContext *)
const std::unique_ptr< TemplateSpacelessIntf > & spacelessInfo() const
void setPath(const std::string &path)
virtual TemplateVariant resolve(TemplateContext *c)
ExprAstPtr parseOrExpression()
Operator::Type m_operator
virtual ~TemplateImmutableList()
Destroys the list
static int variantIntValue(const TemplateVariant &v, bool &isInt)
const char * typeAsString() const
Returns a string representation of this variant's type
void setRaw(bool b)
Sets whether or not the value of the Variant should be escaped or written as-is (raw).
bool toBool() const
Returns the variant as a boolean.
Interface used to escape characters in a string
TemplateNodeBlock * pop(const QCString &name)
Engine to create templates and template contexts.
TemplateNodeIf(TemplateParser *parser, TemplateNode *parent, int line, const QCString &data)
static TemplateVariant apply(const TemplateVariant &v, const TemplateVariant &)
void pop()
Pop the current scope from the stack.
ExprAstBinary(Operator::Type op, ExprAstPtr &&lhs, ExprAstPtr &&rhs)
static TemplateNodeFactory & instance()
const char * data() const
Returns a pointer to the contents of the string in the form of a 0-terminated C string
TemplateParser(const TemplateEngine *engine, const QCString &templateName, TemplateTokenStream &tokens)
void enterBlock(const QCString &fileName, const QCString &blockName, int line)
TemplateTokenPtr takeNextToken()
TemplateStruct()=default
Creates a struct
TemplateImpl(TemplateEngine *e, const QCString &name, const QCString &data, const QCString &extension)
virtual TemplateVariant at(uint index) const
Returns the element at index position index.
void enterBlock(const QCString &fileName, const QCString &blockName, int line)
Private(const TemplateVariantList &e)
static TemplateVariant apply(const TemplateVariant &v, const TemplateVariant &arg)
int toInt() const
Returns the variant as an integer.
std::unordered_map< std::string, CreateFunc > m_registry
TemplateNodeSpaceless(TemplateParser *parser, TemplateNode *parent, int line, const QCString &)
static TemplateFilterFactory::AutoRegister< FilterTexLabel > fTexLabel("texLabel")
static TemplateNodeFactory::AutoRegister< TemplateNodeRepeat > autoRefRepeat("repeat")
virtual void push()=0
Push a new scope on the stack.
static TemplateFilterFactory::AutoRegister< FilterRaw > fRaw("raw")
Class representing operators that can appear in template expressions
static TemplateFilterFactory::AutoRegister< FilterDecodeURL > fDecodeURL("decodeURL")
ExprAstFilterPtr m_filter
TemplateNodeCycle(TemplateParser *parser, TemplateNode *parent, int line, const QCString &data)
virtual ~TemplateStruct()=default
Destroys the struct
Internal class representing the implementation of a template context
Class representing an 'spaceless' tag in a template
virtual void toLast()
Moves iterator to the last element in the list
static TemplateNodeFactory::AutoRegister< TemplateNodeMarkers > autoRefMarkers("markers")
TemplateVariant & operator=(const TemplateVariant &v)=default
Assigns the value of the variant v to this variant.
Mapping(const QCString &n, std::unique_ptr< ExprAst > &&e)
void setTemplateDir(const QCString &dirName)
Sets the search directory where to look for template files
std::unique_ptr< TemplateSpacelessIntf > m_spacelessIntf
void unload(Template *t)
Indicates that template t is no longer needed.
static void flatten(const TemplateListIntfPtr tree, TemplateListPtr list)
static TemplateFilterFactory::AutoRegister< FilterDefault > fDefault("default")
The implementation of the "default" filter
virtual TemplateVariant resolve(TemplateContext *c)
Portable versions of functions that are platform dependent.
ExprAstPtr parseFilteredVariable()
std::string convertUTF8ToUpper(const std::string &input)
Converts the input string into a upper case version, also taking into account non-ASCII characters th...
TemplateBlockContext * blockContext()
static TemplateFilterFactory::AutoRegister< FilterGroupBy > fGroupBy("groupBy")
int portable_iconv_close(void *cd)
std::vector< ExprAstPtr > ExprAstList
void render(TextStream &ts, TemplateContext *c)
std::deque< std::unordered_map< std::string, TemplateVariant > > m_contextStack
The implementation of the "get" filter
Private(std::initializer_list< StructField > fs)
TemplateNodePtr(* CreateFunc)(TemplateParser *parser, TemplateNode *parent, int line, const QCString &data)
virtual const TemplateVariant * getRef(const QCString &name) const =0
Returns a pointer to the value corresponding to a given key.
void selectEscapeIntf(const QCString &ext)
TemplateNodeList m_repeatNodes
Default implementation of a context value of type list.
std::map< std::string, NodeBlockList > m_blocks
bool mkdir(const std::string &path, bool acceptsAbsPath=true) const
A bunch of utility functions.
virtual TemplateVariant resolve(TemplateContext *)
ExprAstFilterAppl(ExprAstPtr &&expr, ExprAstFilterPtr &&filter)
const TemplateEscapeIntf * escapeIntf() const
Factory class for creating tag AST nodes found in a template
The implementation of the "prepend" filter
TemplateNodeTabbing(TemplateParser *parser, TemplateNode *parent, int line, const QCString &)
TemplateNodePtr create(const QCString &name, TemplateParser *parser, TemplateNode *parent, int line, const QCString &data)
static TemplateVariant apply(const TemplateVariant &v, const TemplateVariant &)
void render(TextStream &ts, TemplateContext *c)
QCString latexEscapeIndexChars(const QCString &s)
static TemplateFilterFactory::AutoRegister< FilterTexIndex > fTexIndex("texIndex")
bool spacelessEnabled() const
The implementation of the "append" filter
const QCString & name() const
QCString templateName() const
void render(TextStream &ts, TemplateContext *c)
Mapping(const QCString &n, ExprAstPtr &&e)
TemplateListIntfPtr toList()
Returns the pointer to list referenced by this variant or 0 if this variant does not have list type.
virtual void pop()=0
Pop the current scope from the stack.
ExprAstPtr parseLiteral()
static TemplateVariant apply(const TemplateVariant &v, const TemplateVariant &args)
static TemplateNodeFactory::AutoRegister< TemplateNodeOpenSubIndex > autoRefOpenSubIndex("opensubindex")
static TemplateNodeFactory::AutoRegister< TemplateNodeMsg > autoRefMsg("msg")
QCString right(size_t len) const
QCString & prepend(const char *s)
virtual StringVector fields() const
Return the list of fields.
bool resize(size_t newlen)
Resizes the string to hold newlen characters (this value should also count the 0-terminator).
constexpr bool isString() const
Returns TRUE if the variant holds a string value
QCString & sprintf(const char *format,...)
Class representing a binary operator in the AST
QCString convertToHtml(const QCString &s, bool keepEntities)
Class representing an 'markers' tag in a template
std::unique_ptr< TemplateNode > TemplateNodePtr
static TemplateFilterFactory::AutoRegister< FilterKeep > fKeep("keep")
void render(TextStream &ts, TemplateContext *c)
constexpr Type type() const
Returns the type held by this variant
static TemplateFilterFactory::AutoRegister< FilterRelative > fRelative("relative")
static TemplateNodeFactory::AutoRegister< TemplateNodeEncoding > autoRefEncoding("encoding")
std::shared_ptr< TemplateStruct > TemplateStructPtr
static TemplateStructPtr alloc()
Creates an instance and returns a shared pointer to it
static QCString determineSortKey(const TemplateStructIntfPtr s, const QCString &attribName)
static TemplateVariant apply(const TemplateVariant &v, const TemplateVariant &)
static TemplateNodeFactory::AutoRegister< TemplateNodeBlock > autoRefBlock("block")
This is an alternative implementation of QCString.
virtual TemplateVariant resolve(TemplateContext *c)
Class representing a string literal in the AST