From e6f54449c5b688cdc6647f80558d67dcaa03b30d Mon Sep 17 00:00:00 2001 From: Dimitri van Heesch Date: Sat, 15 May 2021 19:29:42 +0200 Subject: Template engine: allow listing list and struct variables as strings For easier debugging one can do e.g. `{% msg %}value={{ variable }}{% endmsg %}` to list the value of a variable also when it is a list or struct. --- src/configgen.py | 67 ++++++--- src/context.cpp | 322 ++++++++++++++++++++++++++++++++++++++++++ src/context.h | 37 +++++ src/template.cpp | 58 ++++++++ src/template.h | 12 +- templates/html/htmllayout.tpl | 4 +- 6 files changed, 473 insertions(+), 27 deletions(-) diff --git a/src/configgen.py b/src/configgen.py index 5c4c39a..b7736c4 100755 --- a/src/configgen.py +++ b/src/configgen.py @@ -696,34 +696,35 @@ def main(): print(" static ConfigValues &instance() { static ConfigValues theInstance; return theInstance; }") for n in elem.childNodes: if n.nodeType == Node.ELEMENT_NODE: - if (n.nodeName == "group"): + if n.nodeName == "group": parseGroupMapGetter(n) for n in elem.childNodes: if n.nodeType == Node.ELEMENT_NODE: - if (n.nodeName == "group"): + if n.nodeName == "group": parseGroupMapSetter(n) print(" void init();") - print(" struct Info"); - print(" {"); - print(" enum Type { Bool, Int, String, List, Unknown };"); - print(" Info(Type t,bool ConfigValues::*b) : type(t), value(b) {}"); - print(" Info(Type t,int ConfigValues::*i) : type(t), value(i) {}"); - print(" Info(Type t,QCString ConfigValues::*s) : type(t), value(s) {}"); - print(" Info(Type t,StringVector ConfigValues::*l) : type(t), value(l) {}"); - print(" Type type;"); - print(" union Item"); - print(" {"); - print(" Item(bool ConfigValues::*v) : b(v) {}"); - print(" Item(int ConfigValues::*v) : i(v) {}"); - print(" Item(QCString ConfigValues::*v) : s(v) {}"); - print(" Item(StringVector ConfigValues::*v) : l(v) {}"); - print(" bool ConfigValues::*b;"); - print(" int ConfigValues::*i;"); - print(" QCString ConfigValues::*s;"); - print(" StringVector ConfigValues::*l;"); - print(" } value;"); - print(" };"); - print(" const Info *get(const QCString &tag) const;"); + print(" StringVector fields() const;") + print(" struct Info") + print(" {") + print(" enum Type { Bool, Int, String, List, Unknown };") + print(" Info(Type t,bool ConfigValues::*b) : type(t), value(b) {}") + print(" Info(Type t,int ConfigValues::*i) : type(t), value(i) {}") + print(" Info(Type t,QCString ConfigValues::*s) : type(t), value(s) {}") + print(" Info(Type t,StringVector ConfigValues::*l) : type(t), value(l) {}") + print(" Type type;") + print(" union Item") + print(" {") + print(" Item(bool ConfigValues::*v) : b(v) {}") + print(" Item(int ConfigValues::*v) : i(v) {}") + print(" Item(QCString ConfigValues::*v) : s(v) {}") + print(" Item(StringVector ConfigValues::*v) : l(v) {}") + print(" bool ConfigValues::*b;") + print(" int ConfigValues::*i;") + print(" QCString ConfigValues::*s;") + print(" StringVector ConfigValues::*l;") + print(" } value;") + print(" };") + print(" const Info *get(const QCString &tag) const;") print(" private:") for n in elem.childNodes: if n.nodeType == Node.ELEMENT_NODE: @@ -765,6 +766,26 @@ def main(): if (n.nodeName == "group"): parseGroupInit(n) print("}") + print("") + print("StringVector ConfigValues::fields() const") + print("{") + print(" return {"); + first=True + for n in elem.childNodes: + if n.nodeType == Node.ELEMENT_NODE: + if (n.nodeName == "group"): + for c in n.childNodes: + if c.nodeType == Node.ELEMENT_NODE: + name = c.getAttribute('id') + type = c.getAttribute('type') + if type!='obsolete': + if not first: + print(",") + first=False + sys.stdout.write(' "'+name+'"') + print("") + print(" };") + print("}") elif (sys.argv[1] == "-cpp"): print("/* WARNING: This file is generated!") print(" * Do not edit this file, but edit config.xml instead and run") diff --git a/src/context.cpp b/src/context.cpp index fc7a586..ff5815e 100644 --- a/src/context.cpp +++ b/src/context.cpp @@ -279,6 +279,17 @@ class PropertyMapper return it!=m_map.end() ? (*it->second)(obj) : TemplateVariant(); } + StringVector fields() const + { + StringVector result; + for (const auto &kv : m_map) + { + result.push_back(kv.first); + } + std::sort(result.begin(),result.end()); + return result; + } + private: std::unordered_map> m_map; }; @@ -364,6 +375,11 @@ TemplateVariant ConfigContext::get(const QCString &name) const return result; } +StringVector ConfigContext::fields() const +{ + return ConfigValues::instance().fields(); +} + //------------------------------------------------------------------------ //%% struct Doxygen: global information @@ -401,6 +417,10 @@ class DoxygenContext::Private { return s_inst.get(this,n); } + StringVector fields() const + { + return s_inst.fields(); + } private: struct Cachable { @@ -430,6 +450,11 @@ TemplateVariant DoxygenContext::get(const QCString &n) const return p->get(n); } +StringVector DoxygenContext::fields() const +{ + return p->fields(); +} + //------------------------------------------------------------------------ //%% struct Translator: translation methods @@ -1227,6 +1252,10 @@ class TranslateContext::Private { return s_inst.get(this,n); } + StringVector fields() const + { + return s_inst.fields(); + } private: bool m_javaOpt; bool m_fortranOpt; @@ -1253,6 +1282,11 @@ TemplateVariant TranslateContext::get(const QCString &n) const return p->get(n); } +StringVector TranslateContext::fields() const +{ + return p->fields(); +} + static TemplateVariant parseDoc(const Definition *def,const QCString &file,int line, const QCString &relPath,const QCString &docStr,bool isBrief) { @@ -1698,6 +1732,10 @@ class IncludeInfoContext::Private { return s_inst.get(this,n); } + StringVector fields() const + { + return s_inst.fields(); + } TemplateVariant isLocal() const { bool isIDLorJava = m_lang==SrcLangExt_IDL || m_lang==SrcLangExt_Java; @@ -1749,6 +1787,12 @@ TemplateVariant IncludeInfoContext::get(const QCString &n) const { return p->get(n); } + +StringVector IncludeInfoContext::fields() const +{ + return p->fields(); +} + //%% } //------------------------------------------------------------------------ @@ -1881,6 +1925,10 @@ class ClassContext::Private : public DefinitionContext { return s_inst.get(this,n); } + StringVector fields() const + { + return s_inst.fields(); + } TemplateVariant title() const { return TemplateVariant(m_classDef->title()); @@ -2652,6 +2700,11 @@ TemplateVariant ClassContext::get(const QCString &n) const return p->get(n); } +StringVector ClassContext::fields() const +{ + return p->fields(); +} + //------------------------------------------------------------------------ //%% struct Namespace(Symbol): namespace information @@ -2698,6 +2751,10 @@ class NamespaceContext::Private : public DefinitionContexttitle()); @@ -2943,6 +3000,11 @@ TemplateVariant NamespaceContext::get(const QCString &n) const return p->get(n); } +StringVector NamespaceContext::fields() const +{ + return p->fields(); +} + //------------------------------------------------------------------------ //%% struct File(Symbol): file information @@ -2999,6 +3061,10 @@ class FileContext::Private : public DefinitionContext { return s_inst.get(this,n); } + StringVector fields() const + { + return s_inst.fields(); + } TemplateVariant title() const { return m_fileDef->title(); @@ -3395,6 +3461,11 @@ TemplateVariant FileContext::get(const QCString &n) const return p->get(n); } +StringVector FileContext::fields() const +{ + return p->fields(); +} + //------------------------------------------------------------------------ //%% struct Dir(Symbol): directory information @@ -3427,6 +3498,10 @@ class DirContext::Private : public DefinitionContext { return s_inst.get(this,n); } + StringVector fields() const + { + return s_inst.fields(); + } TemplateVariant title() const { return TemplateVariant(m_dirDef->shortTitle()); @@ -3584,6 +3659,11 @@ TemplateVariant DirContext::get(const QCString &n) const return p->get(n); } +StringVector DirContext::fields() const +{ + return p->fields(); +} + //------------------------------------------------------------------------ //%% struct Page(Symbol): page information @@ -3612,6 +3692,10 @@ class PageContext::Private : public DefinitionContext { return s_inst.get(this,n); } + StringVector fields() const + { + return s_inst.fields(); + } TemplateVariant title() const { if (m_isMainPage) @@ -3717,6 +3801,11 @@ TemplateVariant PageContext::get(const QCString &n) const return p->get(n); } +StringVector PageContext::fields() const +{ + return p->fields(); +} + //------------------------------------------------------------------------ class TextGeneratorHtml : public TextGeneratorIntf @@ -4063,6 +4152,10 @@ class MemberContext::Private : public DefinitionContext { return s_inst.get(this,n); } + StringVector fields() const + { + return s_inst.fields(); + } TemplateVariant fieldType() const { return createLinkedText(m_memberDef,relPathAsString(),m_memberDef->fieldType()); @@ -5164,6 +5257,10 @@ TemplateVariant MemberContext::get(const QCString &n) const return p->get(n); } +StringVector MemberContext::fields() const +{ + return p->fields(); +} //------------------------------------------------------------------------ @@ -5229,6 +5326,10 @@ class ModuleContext::Private : public DefinitionContext { return s_inst.get(this,n); } + StringVector fields() const + { + return s_inst.fields(); + } TemplateVariant title() const { return TemplateVariant(m_groupDef->groupTitle()); @@ -5675,6 +5776,11 @@ TemplateVariant ModuleContext::get(const QCString &n) const return p->get(n); } +StringVector ModuleContext::fields() const +{ + return p->fields(); +} + //------------------------------------------------------------------------ //%% list ClassList[Class] : list of classes @@ -5753,6 +5859,10 @@ class ClassIndexContext::Private { return s_inst.get(this,n); } + StringVector fields() const + { + return s_inst.fields(); + } TemplateVariant list() const { if (!m_cache.classes) @@ -5840,6 +5950,11 @@ TemplateVariant ClassIndexContext::get(const QCString &n) const return p->get(n); } +StringVector ClassIndexContext::fields() const +{ + return p->fields(); +} + //------------------------------------------------------------------------ static int computeMaxDepth(const TemplateListIntf *list) @@ -5945,6 +6060,10 @@ class ClassHierarchyContext::Private { return s_inst.get(this,n); } + StringVector fields() const + { + return s_inst.fields(); + } TemplateVariant tree() const { return m_classTree.get(); @@ -6053,6 +6172,11 @@ TemplateVariant ClassHierarchyContext::get(const QCString &name) const return p->get(name); } +StringVector ClassHierarchyContext::fields() const +{ + return p->fields(); +} + //------------------------------------------------------------------------ //%% struct NestingNode: node is a nesting relation tree @@ -6112,6 +6236,10 @@ class NestingNodeContext::Private { return s_inst.get(this,n); } + StringVector fields() const + { + return s_inst.fields(); + } TemplateVariant isLeafNode() const { return m_children->count()==0; @@ -6375,6 +6503,11 @@ TemplateVariant NestingNodeContext::get(const QCString &n) const return p->get(n); } +StringVector NestingNodeContext::fields() const +{ + return p->fields(); +} + QCString NestingNodeContext::id() const { return p->id().toString(); @@ -6740,6 +6873,10 @@ class ClassTreeContext::Private { return s_inst.get(this,n); } + StringVector fields() const + { + return s_inst.fields(); + } TemplateVariant tree() const { return m_classTree.get(); @@ -6828,6 +6965,11 @@ TemplateVariant ClassTreeContext::get(const QCString &name) const return p->get(name); } +StringVector ClassTreeContext::fields() const +{ + return p->fields(); +} + //------------------------------------------------------------------------ //%% list NamespaceList[Namespace] : list of namespaces @@ -6904,6 +7046,10 @@ class NamespaceTreeContext::Private { return s_inst.get(this,n); } + StringVector fields() const + { + return s_inst.fields(); + } TemplateVariant tree() const { return m_namespaceTree.get(); @@ -6994,6 +7140,12 @@ TemplateVariant NamespaceTreeContext::get(const QCString &name) const return p->get(name); } +StringVector NamespaceTreeContext::fields() const +{ + return p->fields(); +} + + //------------------------------------------------------------------------ //%% list FileList[File] : list of files @@ -7174,6 +7326,10 @@ class FileTreeContext::Private { return s_inst.get(this,n); } + StringVector fields() const + { + return s_inst.fields(); + } TemplateVariant tree() const { return m_dirFileTree.get(); @@ -7249,6 +7405,11 @@ TemplateVariant FileTreeContext::get(const QCString &name) const return p->get(name); } +StringVector FileTreeContext::fields() const +{ + return p->fields(); +} + //------------------------------------------------------------------------ //%% struct PageTree: tree of related pages @@ -7282,6 +7443,10 @@ class PageTreeContext::Private { return s_inst.get(this,n); } + StringVector fields() const + { + return s_inst.fields(); + } TemplateVariant tree() const { return m_pageTree.get(); @@ -7357,6 +7522,11 @@ TemplateVariant PageTreeContext::get(const QCString &name) const return p->get(name); } +StringVector PageTreeContext::fields() const +{ + return p->fields(); +} + //------------------------------------------------------------------------ //%% list PageList[Page]: list of pages @@ -7524,6 +7694,10 @@ class ModuleTreeContext::Private { return s_inst.get(this,n); } + StringVector fields() const + { + return s_inst.fields(); + } TemplateVariant tree() const { return m_moduleTree.get(); @@ -7599,6 +7773,11 @@ TemplateVariant ModuleTreeContext::get(const QCString &name) const return p->get(name); } +StringVector ModuleTreeContext::fields() const +{ + return p->fields(); +} + //------------------------------------------------------------------------ //%% struct NavPathElem: list of examples page @@ -7624,6 +7803,10 @@ class NavPathElemContext::Private { return s_inst.get(this,n); } + StringVector fields() const + { + return s_inst.fields(); + } TemplateVariant isLinkable() const { return m_def->isLinkable(); @@ -7693,6 +7876,10 @@ TemplateVariant NavPathElemContext::get(const QCString &name) const return p->get(name); } +StringVector NavPathElemContext::fields() const +{ + return p->fields(); +} //------------------------------------------------------------------------ @@ -7726,6 +7913,10 @@ class ExampleTreeContext::Private { return s_inst.get(this,n); } + StringVector fields() const + { + return s_inst.fields(); + } TemplateVariant tree() const { return m_exampleTree.get(); @@ -7801,6 +7992,11 @@ TemplateVariant ExampleTreeContext::get(const QCString &name) const return p->get(name); } +StringVector ExampleTreeContext::fields() const +{ + return p->fields(); +} + //------------------------------------------------------------------------ //%% struct GlobalsIndex: list of examples page @@ -7835,6 +8031,10 @@ class GlobalsIndexContext::Private { return s_inst.get(this,n); } + StringVector fields() const + { + return s_inst.fields(); + } typedef bool (MemberDef::*MemberFunc)() const; TemplateVariant getMembersFiltered(SharedPtr &listRef,MemberFunc filter) const { @@ -7954,6 +8154,12 @@ TemplateVariant GlobalsIndexContext::get(const QCString &name) const return p->get(name); } +StringVector GlobalsIndexContext::fields() const +{ + return p->fields(); +} + + //------------------------------------------------------------------------ //%% struct ClassMembersIndex: list of examples page @@ -7988,6 +8194,10 @@ class ClassMembersIndexContext::Private { return s_inst.get(this,n); } + StringVector fields() const + { + return s_inst.fields(); + } typedef bool (MemberDef::*MemberFunc)() const; TemplateVariant getMembersFiltered(SharedPtr &listRef,MemberFunc filter) const { @@ -8109,6 +8319,11 @@ TemplateVariant ClassMembersIndexContext::get(const QCString &name) const return p->get(name); } +StringVector ClassMembersIndexContext::fields() const +{ + return p->fields(); +} + //------------------------------------------------------------------------ //%% struct NamespaceMembersIndex: list of examples page @@ -8143,6 +8358,10 @@ class NamespaceMembersIndexContext::Private { return s_inst.get(this,n); } + StringVector fields() const + { + return s_inst.fields(); + } typedef bool (MemberDef::*MemberFunc)() const; TemplateVariant getMembersFiltered(SharedPtr &listRef,MemberFunc filter) const { @@ -8261,6 +8480,11 @@ TemplateVariant NamespaceMembersIndexContext::get(const QCString &name) const return p->get(name); } +StringVector NamespaceMembersIndexContext::fields() const +{ + return p->fields(); +} + //------------------------------------------------------------------------ //%% struct InheritanceGraph: a connected graph representing part of the overall inheritance tree @@ -8281,6 +8505,10 @@ class InheritanceGraphContext::Private { return s_inst.get(this,n); } + StringVector fields() const + { + return s_inst.fields(); + } TemplateVariant graph() const { TextStream t; @@ -8322,6 +8550,10 @@ TemplateVariant InheritanceGraphContext::get(const QCString &name) const return p->get(name); } +StringVector InheritanceGraphContext::fields() const +{ + return p->fields(); +} //------------------------------------------------------------------------ @@ -8344,6 +8576,10 @@ class InheritanceNodeContext::Private { return s_inst.get(this,n); } + StringVector fields() const + { + return s_inst.fields(); + } TemplateVariant getClass() const { if (!m_classContext) @@ -8381,6 +8617,11 @@ TemplateVariant InheritanceNodeContext::get(const QCString &name) const return p->get(name); } +StringVector InheritanceNodeContext::fields() const +{ + return p->fields(); +} + //------------------------------------------------------------------------ //%% list InheritanceList[InheritanceNode] : list of inherited classes @@ -8528,6 +8769,10 @@ class MemberInfoContext::Private { return s_inst.get(this,n); } + StringVector fields() const + { + return s_inst.fields(); + } TemplateVariant protection() const { switch (m_memberInfo->prot()) @@ -8592,6 +8837,10 @@ TemplateVariant MemberInfoContext::get(const QCString &name) const return p->get(name); } +StringVector MemberInfoContext::fields() const +{ + return p->fields(); +} //------------------------------------------------------------------------ @@ -8680,6 +8929,10 @@ class MemberGroupInfoContext::Private { return s_inst.get(this,n); } + StringVector fields() const + { + return s_inst.fields(); + } TemplateVariant members() const { if (!m_cache.memberListContext) @@ -8764,6 +9017,11 @@ TemplateVariant MemberGroupInfoContext::get(const QCString &name) const return p->get(name); } +StringVector MemberGroupInfoContext::fields() const +{ + return p->fields(); +} + //------------------------------------------------------------------------ //%% list MemberGroupList[MemberGroupInfo] : list of member groups @@ -8854,6 +9112,10 @@ class MemberListInfoContext::Private { return s_inst.get(this,n); } + StringVector fields() const + { + return s_inst.fields(); + } TemplateVariant members() const { if (!m_cache.memberListContext) @@ -8936,6 +9198,11 @@ TemplateVariant MemberListInfoContext::get(const QCString &name) const return p->get(name); } +StringVector MemberListInfoContext::fields() const +{ + return p->fields(); +} + //------------------------------------------------------------------------ //%% struct InheritedMemberInfo: inherited member information @@ -8961,6 +9228,10 @@ class InheritedMemberInfoContext::Private { return s_inst.get(this,n); } + StringVector fields() const + { + return s_inst.fields(); + } virtual ~Private() { delete m_memberList; @@ -9030,6 +9301,11 @@ TemplateVariant InheritedMemberInfoContext::get(const QCString &name) const return p->get(name); } +StringVector InheritedMemberInfoContext::fields() const +{ + return p->fields(); +} + //------------------------------------------------------------------------ //%% list InheritedMemberList[InheritedMemberInfo] : list of inherited classes @@ -9193,6 +9469,10 @@ class ArgumentContext::Private { return s_inst.get(this,n); } + StringVector fields() const + { + return s_inst.fields(); + } TemplateVariant type() const { return createLinkedText(m_def,m_relPath,m_argument.type); @@ -9271,6 +9551,11 @@ TemplateVariant ArgumentContext::get(const QCString &name) const return p->get(name); } +StringVector ArgumentContext::fields() const +{ + return p->fields(); +} + //------------------------------------------------------------------------ //%% list ArgumentList[Argument] : list of inherited classes @@ -9360,6 +9645,10 @@ class SymbolContext::Private { return s_inst.get(this,n); } + StringVector fields() const + { + return s_inst.fields(); + } TemplateVariant fileName() const { return m_def->getOutputFileBase(); @@ -9486,6 +9775,11 @@ TemplateVariant SymbolContext::get(const QCString &name) const return p->get(name); } +StringVector SymbolContext::fields() const +{ + return p->fields(); +} + //------------------------------------------------------------------------ //%% list SymbolList[Symbol] : list of search symbols with the same name @@ -9558,6 +9852,10 @@ class SymbolGroupContext::Private { return s_inst.get(this,n); } + StringVector fields() const + { + return s_inst.fields(); + } TemplateVariant id() const { return searchId(*m_start); @@ -9605,6 +9903,11 @@ TemplateVariant SymbolGroupContext::get(const QCString &name) const return p->get(name); } +StringVector SymbolGroupContext::fields() const +{ + return p->fields(); +} + //------------------------------------------------------------------------ //%% list SymbolGroupList[SymbolGroup] : list of search groups one per by name @@ -9688,6 +9991,10 @@ class SymbolIndexContext::Private { return s_inst.get(this,n); } + StringVector fields() const + { + return s_inst.fields(); + } TemplateVariant name() const { return m_name; @@ -9735,6 +10042,11 @@ TemplateVariant SymbolIndexContext::get(const QCString &name) const return p->get(name); } +StringVector SymbolIndexContext::fields() const +{ + return p->fields(); +} + //------------------------------------------------------------------------ //%% list SymbolIndices[SymbolIndex] : list of search indices one per by type @@ -9799,6 +10111,10 @@ class SearchIndexContext::Private { return s_inst.get(this,n); } + StringVector fields() const + { + return s_inst.fields(); + } TemplateVariant name() const { return m_info.name; @@ -9844,6 +10160,12 @@ TemplateVariant SearchIndexContext::get(const QCString &name) const return p->get(name); } +StringVector SearchIndexContext::fields() const +{ + return p->fields(); +} + + //------------------------------------------------------------------------ //%% list SearchIndices[SearchIndex] : list of search indices one per by type diff --git a/src/context.h b/src/context.h index 1fb934e..42da981 100644 --- a/src/context.h +++ b/src/context.h @@ -135,6 +135,7 @@ class ConfigContext : public RefCountedContext, public TemplateStructIntf // TemplateStructIntf methods virtual TemplateVariant get(const QCString &name) const; + virtual StringVector fields() const; virtual int addRef() { return RefCountedContext::addRef(); } virtual int release() { return RefCountedContext::release(); } @@ -154,6 +155,7 @@ class DoxygenContext : public RefCountedContext, public TemplateStructIntf // TemplateStructIntf methods virtual TemplateVariant get(const QCString &name) const; + virtual StringVector fields() const; virtual int addRef() { return RefCountedContext::addRef(); } virtual int release() { return RefCountedContext::release(); } @@ -173,6 +175,7 @@ class TranslateContext : public RefCountedContext, public TemplateStructIntf // TemplateStructIntf methods virtual TemplateVariant get(const QCString &name) const; + virtual StringVector fields() const; virtual int addRef() { return RefCountedContext::addRef(); } virtual int release() { return RefCountedContext::release(); } @@ -217,6 +220,7 @@ class IncludeInfoContext : public RefCountedContext, public TemplateStructIntf // TemplateStructIntf methods virtual TemplateVariant get(const QCString &name) const; + virtual StringVector fields() const; virtual int addRef() { return RefCountedContext::addRef(); } virtual int release() { return RefCountedContext::release(); } @@ -259,6 +263,7 @@ class ClassContext : public RefCountedContext, public TemplateStructIntf // TemplateStructIntf methods virtual TemplateVariant get(const QCString &name) const; + virtual StringVector fields() const; virtual int addRef() { return RefCountedContext::addRef(); } virtual int release() { return RefCountedContext::release(); } @@ -278,6 +283,7 @@ class NamespaceContext : public RefCountedContext, public TemplateStructIntf // TemplateStructIntf methods virtual TemplateVariant get(const QCString &name) const; + virtual StringVector fields() const; virtual int addRef() { return RefCountedContext::addRef(); } virtual int release() { return RefCountedContext::release(); } @@ -297,6 +303,7 @@ class FileContext : public RefCountedContext, public TemplateStructIntf // TemplateStructIntf methods virtual TemplateVariant get(const QCString &name) const; + virtual StringVector fields() const; virtual int addRef() { return RefCountedContext::addRef(); } virtual int release() { return RefCountedContext::release(); } @@ -315,6 +322,7 @@ class DirContext : public RefCountedContext, public TemplateStructIntf // TemplateStructIntf methods virtual TemplateVariant get(const QCString &name) const; + virtual StringVector fields() const; virtual int addRef() { return RefCountedContext::addRef(); } virtual int release() { return RefCountedContext::release(); } @@ -335,6 +343,7 @@ class PageContext : public RefCountedContext, public TemplateStructIntf // TemplateStructIntf methods virtual TemplateVariant get(const QCString &name) const; + virtual StringVector fields() const; virtual int addRef() { return RefCountedContext::addRef(); } virtual int release() { return RefCountedContext::release(); } @@ -354,6 +363,7 @@ class MemberContext : public RefCountedContext, public TemplateStructIntf // TemplateStructIntf methods virtual TemplateVariant get(const QCString &name) const; + virtual StringVector fields() const; virtual int addRef() { return RefCountedContext::addRef(); } virtual int release() { return RefCountedContext::release(); } @@ -374,6 +384,7 @@ class ModuleContext : public RefCountedContext, public TemplateStructIntf // TemplateStructIntf methods virtual TemplateVariant get(const QCString &name) const; + virtual StringVector fields() const; virtual int addRef() { return RefCountedContext::addRef(); } virtual int release() { return RefCountedContext::release(); } @@ -414,6 +425,7 @@ class ClassIndexContext : public RefCountedContext, public TemplateStructIntf // TemplateStructIntf methods virtual TemplateVariant get(const QCString &name) const; + virtual StringVector fields() const; virtual int addRef() { return RefCountedContext::addRef(); } virtual int release() { return RefCountedContext::release(); } @@ -434,6 +446,7 @@ class InheritanceGraphContext : public RefCountedContext, public TemplateStructI // TemplateStructIntf methods virtual TemplateVariant get(const QCString &name) const; + virtual StringVector fields() const; virtual int addRef() { return RefCountedContext::addRef(); } virtual int release() { return RefCountedContext::release(); } @@ -454,6 +467,7 @@ class ClassInheritanceNodeContext : public RefCountedContext, public TemplateStr // TemplateStructIntf methods virtual TemplateVariant get(const QCString &name) const; + virtual StringVector fields() const; virtual int addRef() { return RefCountedContext::addRef(); } virtual int release() { return RefCountedContext::release(); } @@ -496,6 +510,7 @@ class ClassHierarchyContext : public RefCountedContext, public TemplateStructInt // TemplateStructIntf methods virtual TemplateVariant get(const QCString &name) const; + virtual StringVector fields() const; virtual int addRef() { return RefCountedContext::addRef(); } virtual int release() { return RefCountedContext::release(); } @@ -520,6 +535,7 @@ class NestingNodeContext : public RefCountedContext, public TemplateStructIntf // TemplateStructIntf methods virtual TemplateVariant get(const QCString &name) const; + virtual StringVector fields() const; virtual int addRef() { return RefCountedContext::addRef(); } virtual int release() { return RefCountedContext::release(); } @@ -579,6 +595,7 @@ class ClassTreeContext : public RefCountedContext, public TemplateStructIntf // TemplateStructIntf methods virtual TemplateVariant get(const QCString &name) const; + virtual StringVector fields() const; virtual int addRef() { return RefCountedContext::addRef(); } virtual int release() { return RefCountedContext::release(); } @@ -619,6 +636,7 @@ class NamespaceTreeContext : public RefCountedContext, public TemplateStructIntf // TemplateStructIntf methods virtual TemplateVariant get(const QCString &name) const; + virtual StringVector fields() const; virtual int addRef() { return RefCountedContext::addRef(); } virtual int release() { return RefCountedContext::release(); } @@ -680,6 +698,7 @@ class FileTreeContext : public RefCountedContext, public TemplateStructIntf // TemplateStructIntf methods virtual TemplateVariant get(const QCString &name) const; + virtual StringVector fields() const; virtual int addRef() { return RefCountedContext::addRef(); } virtual int release() { return RefCountedContext::release(); } @@ -722,6 +741,7 @@ class PageTreeContext : public RefCountedContext, public TemplateStructIntf // TemplateStructIntf methods virtual TemplateVariant get(const QCString &name) const; + virtual StringVector fields() const; virtual int addRef() { return RefCountedContext::addRef(); } virtual int release() { return RefCountedContext::release(); } @@ -741,6 +761,7 @@ class ModuleNodeContext : public RefCountedContext, public TemplateStructIntf // TemplateStructIntf methods virtual TemplateVariant get(const QCString &name) const; + virtual StringVector fields() const; virtual int addRef() { return RefCountedContext::addRef(); } virtual int release() { return RefCountedContext::release(); } @@ -784,6 +805,7 @@ class ModuleTreeContext : public RefCountedContext, public TemplateStructIntf // TemplateStructIntf methods virtual TemplateVariant get(const QCString &name) const; + virtual StringVector fields() const; virtual int addRef() { return RefCountedContext::addRef(); } virtual int release() { return RefCountedContext::release(); } @@ -825,6 +847,7 @@ class ExampleTreeContext : public RefCountedContext, public TemplateStructIntf // TemplateStructIntf methods virtual TemplateVariant get(const QCString &name) const; + virtual StringVector fields() const; virtual int addRef() { return RefCountedContext::addRef(); } virtual int release() { return RefCountedContext::release(); } @@ -844,6 +867,7 @@ class GlobalsIndexContext : public RefCountedContext, public TemplateStructIntf // TemplateStructIntf methods virtual TemplateVariant get(const QCString &name) const; + virtual StringVector fields() const; virtual int addRef() { return RefCountedContext::addRef(); } virtual int release() { return RefCountedContext::release(); } @@ -863,6 +887,7 @@ class ClassMembersIndexContext : public RefCountedContext, public TemplateStruct // TemplateStructIntf methods virtual TemplateVariant get(const QCString &name) const; + virtual StringVector fields() const; virtual int addRef() { return RefCountedContext::addRef(); } virtual int release() { return RefCountedContext::release(); } @@ -882,6 +907,7 @@ class NamespaceMembersIndexContext : public RefCountedContext, public TemplateSt // TemplateStructIntf methods virtual TemplateVariant get(const QCString &name) const; + virtual StringVector fields() const; virtual int addRef() { return RefCountedContext::addRef(); } virtual int release() { return RefCountedContext::release(); } @@ -901,6 +927,7 @@ class NavPathElemContext : public RefCountedContext, public TemplateStructIntf // TemplateStructIntf methods virtual TemplateVariant get(const QCString &name) const; + virtual StringVector fields() const; virtual int addRef() { return RefCountedContext::addRef(); } virtual int release() { return RefCountedContext::release(); } @@ -922,6 +949,7 @@ class InheritanceNodeContext : public RefCountedContext, public TemplateStructIn // TemplateStructIntf methods virtual TemplateVariant get(const QCString &name) const; + virtual StringVector fields() const; virtual int addRef() { return RefCountedContext::addRef(); } virtual int release() { return RefCountedContext::release(); } @@ -992,6 +1020,7 @@ class MemberGroupInfoContext : public RefCountedContext, public TemplateStructIn // TemplateStructIntf methods virtual TemplateVariant get(const QCString &name) const; + virtual StringVector fields() const; virtual int addRef() { return RefCountedContext::addRef(); } virtual int release() { return RefCountedContext::release(); } @@ -1043,6 +1072,7 @@ class MemberListInfoContext : public RefCountedContext, public TemplateStructInt // TemplateStructIntf methods virtual TemplateVariant get(const QCString &name) const; + virtual StringVector fields() const; virtual int addRef() { return RefCountedContext::addRef(); } virtual int release() { return RefCountedContext::release(); } @@ -1064,6 +1094,7 @@ class MemberInfoContext : public RefCountedContext, public TemplateStructIntf // TemplateStructIntf methods virtual TemplateVariant get(const QCString &name) const; + virtual StringVector fields() const; virtual int addRef() { return RefCountedContext::addRef(); } virtual int release() { return RefCountedContext::release(); } @@ -1084,6 +1115,7 @@ class InheritedMemberInfoContext : public RefCountedContext, public TemplateStru // TemplateStructIntf methods virtual TemplateVariant get(const QCString &name) const; + virtual StringVector fields() const; virtual int addRef() { return RefCountedContext::addRef(); } virtual int release() { return RefCountedContext::release(); } @@ -1148,6 +1180,7 @@ class ArgumentContext : public RefCountedContext, public TemplateStructIntf // TemplateStructIntf methods virtual TemplateVariant get(const QCString &name) const; + virtual StringVector fields() const; virtual int addRef() { return RefCountedContext::addRef(); } virtual int release() { return RefCountedContext::release(); } @@ -1192,6 +1225,7 @@ class SymbolContext : public RefCountedContext, public TemplateStructIntf // TemplateStructIntf methods virtual TemplateVariant get(const QCString &name) const; + virtual StringVector fields() const; virtual int addRef() { return RefCountedContext::addRef(); } virtual int release() { return RefCountedContext::release(); } @@ -1237,6 +1271,7 @@ class SymbolGroupContext : public RefCountedContext, public TemplateStructIntf // TemplateStructIntf methods virtual TemplateVariant get(const QCString &name) const; + virtual StringVector fields() const; virtual int addRef() { return RefCountedContext::addRef(); } virtual int release() { return RefCountedContext::release(); } @@ -1281,6 +1316,7 @@ class SymbolIndexContext : public RefCountedContext, public TemplateStructIntf // TemplateStructIntf methods virtual TemplateVariant get(const QCString &name) const; + virtual StringVector fields() const; virtual int addRef() { return RefCountedContext::addRef(); } virtual int release() { return RefCountedContext::release(); } @@ -1323,6 +1359,7 @@ class SearchIndexContext : public RefCountedContext, public TemplateStructIntf // TemplateStructIntf methods virtual TemplateVariant get(const QCString &name) const; + virtual StringVector fields() const; virtual int addRef() { return RefCountedContext::addRef(); } virtual int release() { return RefCountedContext::release(); } diff --git a/src/template.cpp b/src/template.cpp index a9c5421..86780be 100755 --- a/src/template.cpp +++ b/src/template.cpp @@ -291,6 +291,17 @@ TemplateVariant TemplateStruct::get(const QCString &name) const return it!=p->fields.end() ? it->second : TemplateVariant(); } +StringVector TemplateStruct::fields() const +{ + StringVector result; + for (const auto &kv : p->fields) + { + result.push_back(kv.first); + } + std::sort(result.begin(),result.end()); + return result; +} + TemplateStruct *TemplateStruct::alloc() { return new TemplateStruct; @@ -2360,6 +2371,7 @@ class TemplateStructWeakRef : public TemplateStructIntf public: TemplateStructWeakRef(TemplateStructIntf *ref) : m_ref(ref), m_refCount(0) {} virtual TemplateVariant get(const QCString &name) const { return m_ref->get(name); } + virtual StringVector fields() const { return m_ref->fields(); } virtual int addRef() { return ++m_refCount; } virtual int release() { int count=--m_refCount; if (count<=0) { delete this; } return count; } private: @@ -5301,4 +5313,50 @@ void TemplateEngine::setTemplateDir(const QCString &dirName) p->setTemplateDir(dirName); } +//----------------------------------------------------------------------------------------- + +QCString TemplateVariant::listToString() const +{ + QCString result="["; + TemplateListIntf *list = toList(); + if (list) + { + bool first=true; + TemplateVariant ve; + TemplateListIntf::ConstIterator *it = list->createIterator(); + for (it->toFirst();it->current(ve);it->toNext()) + { + if (!first) result+=",\n"; + result+="'"+ve.toString()+"'"; + first=false; + } + delete it; + } + result+="]"; + return result; +} + +QCString TemplateVariant::structToString() const +{ + QCString result="{"; + TemplateStructIntf *strukt = toStruct(); + if (strukt) + { + bool first=true; + for (const auto &s : strukt->fields()) + { + if (!first) result+=","; + result+=s; + if (dynamic_cast(strukt)==0) // avoid endless recursion + { + result+=":'"; + result+=strukt->get(QCString(s)).toString(); + result+="'"; + } + first=false; + } + } + result+="}"; + return result; +} diff --git a/src/template.h b/src/template.h index 18e8b06..7d803a3 100644 --- a/src/template.h +++ b/src/template.h @@ -19,6 +19,7 @@ #include #include "qcstring.h" +#include "containers.h" class TemplateListIntf; class TemplateStructIntf; @@ -231,6 +232,9 @@ class TemplateVariant } } + QCString listToString() const; + QCString structToString() const; + /** Returns the variant as a string. */ QCString toString() const { @@ -240,8 +244,8 @@ class TemplateVariant case Bool: return m_boolVal ? "true" : "false"; case Integer: return QCString().setNum(m_intVal); case String: return m_strVal; - case Struct: return "[struct]"; - case List: return "[list]"; + case Struct: return structToString(); + case List: return listToString(); case Function: return "[function]"; } return QCString(); @@ -417,6 +421,9 @@ class TemplateStructIntf */ virtual TemplateVariant get(const QCString &name) const = 0; + /** Return the list of fields. */ + virtual StringVector fields() const = 0; + /** Increase object's reference count */ virtual int addRef() = 0; @@ -431,6 +438,7 @@ class TemplateStruct : public TemplateStructIntf public: // TemplateStructIntf methods virtual TemplateVariant get(const QCString &name) const; + virtual StringVector fields() const; virtual int addRef(); virtual int release(); diff --git a/templates/html/htmllayout.tpl b/templates/html/htmllayout.tpl index 736a624..a0bb6f0 100644 --- a/templates/html/htmllayout.tpl +++ b/templates/html/htmllayout.tpl @@ -180,7 +180,7 @@ {# --- namespaces --- #} {% if namespaceList %} - {% indexentry nav name=tr.namespaces file='' anchor='' isReference=False %} + {% indexentry nav name=tr.namespaces file='namespaces' anchor='' isReference=False %} {% opensubindex nav %} {% if namespaceTree.tree %} @@ -244,7 +244,7 @@ {# --- files --- #} {% if fileList %} - {% indexentry nav name=tr.files file='' anchor='' isReference=False %} + {% indexentry nav name=tr.files file='files' anchor='' isReference=False %} {% opensubindex nav %} {# write the directory/file hierarchy #} -- cgit v0.12