Doxygen
Loading...
Searching...
No Matches
layout.cpp
Go to the documentation of this file.
1/******************************************************************************
2 *
3 *
4 *
5 *
6 * Copyright (C) 1997-2015 by Dimitri van Heesch.
7 *
8 * Permission to use, copy, modify, and distribute this software and its
9 * documentation under the terms of the GNU General Public License is hereby
10 * granted. No representations are made about the suitability of this software
11 * for any purpose. It is provided "as is" without express or implied warranty.
12 * See the GNU General Public License for more details.
13 *
14 * Documents produced by Doxygen are derivative works derived from the
15 * input used in their production; they are not affected by this license.
16 *
17 */
18
19#include <array>
20
21#include <assert.h>
22
23#include "types.h"
24#include "layout.h"
25#include "message.h"
26#include "language.h"
27#include "util.h"
28#include "doxygen.h"
29#include "version.h"
30#include "config.h"
31#include "xml.h"
32#include "resourcemgr.h"
33#include "docparser.h"
34#include "docnode.h"
35#include "debug.h"
36
38{
39 return def;
40}
41
42inline QCString compileOptions(const QCString &def,SrcLangExt langId1,const QCString &value1)
43{
44 return compileOptions(def)+"|"+QCString().setNum(static_cast<long>(langId1))+"="+value1;
45}
46
47inline QCString compileOptions(const QCString &def,SrcLangExt langId1,const QCString &value1,
48 SrcLangExt langId2,const QCString &value2)
49{
50 return compileOptions(def,langId1,value1)+
51 "|"+QCString().setNum(static_cast<long>(langId2))+"="+value2;
52}
53
54inline QCString compileOptions(const QCString &def,SrcLangExt langId1,const QCString &value1,
55 SrcLangExt langId2,const QCString &value2,
56 SrcLangExt langId3,const QCString &value3)
57{
58 return compileOptions(def,langId1,value1,langId2,value2)+
59 "|"+QCString().setNum(static_cast<long>(langId3))+"="+value3;
60}
61
62inline QCString compileOptions(const QCString &def,SrcLangExt langId1,const QCString &value1,
63 SrcLangExt langId2,const QCString &value2,
64 SrcLangExt langId3,const QCString &value3,
65 SrcLangExt langId4,const QCString &value4)
66{
67 return compileOptions(def,langId1,value1,langId2,value2,langId3,value3)+
68 "|"+QCString().setNum(static_cast<long>(langId4))+"="+value4;
69}
70
71inline QCString compileOptions(const QCString &def,SrcLangExt langId1,const QCString &value1,
72 SrcLangExt langId2,const QCString &value2,
73 SrcLangExt langId3,const QCString &value3,
74 SrcLangExt langId4,const QCString &value4,
75 SrcLangExt langId5,const QCString &value5)
76{
77 return compileOptions(def,langId1,value1,langId2,value2,langId3,value3,langId4,value4)+
78 "|"+QCString().setNum(static_cast<long>(langId5))+"="+value5;
79}
80
81static bool elemIsVisible(const XMLHandlers::Attributes &attrib,bool defVal=TRUE)
82{
83 QCString visible = XMLHandlers::value(attrib,"visible");
84 if (visible.isEmpty()) return defVal;
85 if (visible.at(0)=='$' && visible.length()>1)
86 {
87 QCString id = visible.mid(1);
88 const ConfigValues::Info *opt = ConfigValues::instance().get(id);
89 if (opt && opt->type==ConfigValues::Info::Bool)
90 {
91 return ConfigValues::instance().*(opt->value.b);
92 }
93 else if (opt && opt->type==ConfigValues::Info::String)
94 {
95 return opt->getBooleanRepresentation();
96 }
97 else if (!opt)
98 {
99 err("found unsupported value '%s' for visible attribute in layout file, reverting to '%s'\n",
100 qPrint(visible),(defVal?"yes":"no"));
101 return defVal;
102 }
103 }
104 QCString visibleLow = visible.lower();
105 if (visibleLow=="no" || visibleLow=="false" || visibleLow=="0") return FALSE;
106 else if (visibleLow=="yes" || visibleLow=="true" || visibleLow=="1") return TRUE;
107 else
108 {
109 err("found unsupported value '%s' for visible attribute in layout file, reverting to '%s'\n",
110 qPrint(visible),(defVal?"yes":"no"));
111 return defVal;
112 }
113}
114
116{
117 return parent==nullptr || parent->visible();
118}
119
120//---------------------------------------------------------------------------------
121
123 const QCString &file) const
124{
125 LayoutNavEntry *result=nullptr;
126 for (const auto &entry : m_children)
127 {
128 // depth first search, needed to find the entry furthest from the
129 // root in case an entry is in the tree twice
130 result = entry->find(kind,file);
131 if (result) return result;
132 if (entry->kind()==kind && (file==QCString() || entry->baseFile()==file))
133 {
134 return entry.get();
135 }
136 }
137 return result;
138}
139
141{
143 if ((kind()!=LayoutNavEntry::User && kind()!=LayoutNavEntry::UserGroup) ||
144 (kind()==LayoutNavEntry::UserGroup && url.startsWith("usergroup")))
145 {
147 }
148 else if (url.startsWith("@ref ") || url.startsWith("\\ref "))
149 {
150 bool found=false;
151 QCString relPath = "";
152 QCString context = QCString();
153 auto parser { createDocParser() };
154 auto dfAst { createRef( *parser.get(), url.mid(5).stripWhiteSpace(), context ) };
155 auto dfAstImpl = dynamic_cast<const DocNodeAST*>(dfAst.get());
156 const DocRef *df = std::get_if<DocRef>(&dfAstImpl->root);
157 if (!df->file().isEmpty() || !df->anchor().isEmpty())
158 {
159 found = true;
160 url=externalRef(relPath,df->ref(),TRUE);
161 if (!df->file().isEmpty())
162 {
163 QCString fn = df->file();
165 url += fn;
166 }
167 if (!df->anchor().isEmpty())
168 {
169 url += "#" + df->anchor();
170 }
171 }
172 if (!found)
173 {
174 msg("explicit link request to '%s' in layout file '%s' could not be resolved\n",qPrint(url.mid(5)),qPrint(Config_getString(LAYOUT_FILE)));
175 }
176 }
177 //printf("LayoutNavEntry::url()=%s\n",qPrint(url));
178 return url;
179}
180
181//---------------------------------------------------------------------------------
182
184{
185 public:
187 {
188 static LayoutParser theInstance;
189 return theInstance;
190 }
191
192 // =========== XMLHandler events
193 void setDocumentLocator(const XMLLocator *locator)
194 {
195 m_locator = locator;
196 }
197 void error( const std::string &fileName,int lineNr,const std::string &msg)
198 {
199 warn(fileName.c_str(),lineNr,"%s",msg.c_str());
200 }
201 void startElement( const std::string &name, const XMLHandlers::Attributes& attrib );
202 void endElement( const std::string &name );
203
205 {
206 bool isVisible = m_visible && elemIsVisible(attrib) && parentIsVisible(m_rootNav);
207 if (m_part!=LayoutDocManager::Undefined && isVisible)
208 {
209 LayoutDocManager::instance().addEntry(m_part,std::make_unique<LayoutDocEntrySimple>(k,isVisible));
210 }
211 }
212
213 // ============ Specific callbacks
214
216 const QCString &title)
217 {
218 bool isVisible = m_visible && elemIsVisible(attrib) && parentIsVisible(m_rootNav);
219 QCString userTitle = XMLHandlers::value(attrib,"title");
220 //printf("startSectionEntry: title='%s' userTitle='%s'\n",
221 // qPrint(title),qPrint(userTitle));
222 if (userTitle.isEmpty()) userTitle = title;
223 if (m_part!=LayoutDocManager::Undefined && isVisible)
224 {
225 LayoutDocManager::instance().addEntry(m_part,std::make_unique<LayoutDocEntrySection>(k,userTitle,isVisible));
226 }
227 }
228
229
231 const QCString &title,const QCString &subscript)
232 {
233 QCString userTitle = XMLHandlers::value(attrib,"title");
234 QCString userSubscript = XMLHandlers::value(attrib,"subtitle");
235 if (userTitle.isEmpty()) userTitle = title;
236 if (userSubscript.isEmpty()) userSubscript = subscript;
237 bool isVisible = m_visible && elemIsVisible(attrib) && parentIsVisible(m_rootNav);
238 if (m_part!=LayoutDocManager::Undefined && isVisible)
239 {
240 LayoutDocManager::instance().addEntry(m_part,std::make_unique<LayoutDocEntryMemberDecl>(type,userTitle,userSubscript));
241 }
242 }
243
245 const QCString &title,const QCString &)
246 {
247 QCString userTitle = XMLHandlers::value(attrib,"title");
248 if (userTitle.isEmpty()) userTitle = title;
249 //printf("memberdef: %s\n",qPrint(userTitle));
250 bool isVisible = m_visible && elemIsVisible(attrib) && parentIsVisible(m_rootNav);
251 if (m_part!=LayoutDocManager::Undefined && isVisible)
252 {
253 LayoutDocManager::instance().addEntry(m_part,std::make_unique<LayoutDocEntryMemberDef>(type,userTitle));
254 }
255 }
256
258 {
259 }
260
262 {
263 m_scope="navindex/";
265 if (m_rootNav)
266 {
267 m_rootNav->clear();
268 }
269 }
270
272 {
273 m_scope="";
274 if (m_rootNav && !m_rootNav->find(LayoutNavEntry::MainPage))
275 {
276 // no MainPage node... add one as the first item of the root node...
277 m_rootNav->prependChild(std::make_unique<LayoutNavEntry>(m_rootNav,LayoutNavEntry::MainPage, TRUE,
278 "index",theTranslator->trMainPage(),""));
279 }
280 }
281
283 {
284 bool javaOpt = Config_getBool(OPTIMIZE_OUTPUT_JAVA);
285 bool fortranOpt = Config_getBool(OPTIMIZE_FOR_FORTRAN);
286 bool vhdlOpt = Config_getBool(OPTIMIZE_OUTPUT_VHDL);
287 bool sliceOpt = Config_getBool(OPTIMIZE_OUTPUT_SLICE);
288 bool hasGraphicalHierarchy = Config_getBool(HAVE_DOT) &&
289 Config_getBool(GRAPHICAL_HIERARCHY);
290 bool extractAll = Config_getBool(EXTRACT_ALL);
291 static struct NavEntryMap
292 {
293 const char *typeStr; // type attribute name in the XML file
294 LayoutNavEntry::Kind kind; // corresponding enum name
295 QCString mainName; // default title for an item if it has children
296 QCString subName; // optional name for an item if it is rendered as a child
297 QCString intro; // introduction text to be put on the index page
298 QCString baseFile; // base name of the file containing the index page
299 } mapping[] =
300 {
301 { "mainpage",
302 LayoutNavEntry::MainPage,
303 theTranslator->trMainPage(),
304 QCString(),
305 QCString(),
306 "index"
307 },
308 { "pages",
309 LayoutNavEntry::Pages,
310 theTranslator->trRelatedPages(),
311 QCString(),
312 theTranslator->trRelatedPagesDescription(),
313 "pages"
314 },
315 { "topics",
316 LayoutNavEntry::Topics,
317 theTranslator->trTopics(),
318 QCString(),
319 theTranslator->trTopicListDescription(),
320 "topics"
321 },
322 { "modules",
323 LayoutNavEntry::Modules,
324 theTranslator->trModules(),
325 theTranslator->trModulesList(),
326 theTranslator->trModulesDescription(),
327 "modules"
328 },
329 { "modulelist",
330 LayoutNavEntry::ModuleList,
331 theTranslator->trModulesList(),
332 QCString(),
333 theTranslator->trModulesListDescription(extractAll),
334 "modules"
335 },
336 { "modulemembers",
337 LayoutNavEntry::ModuleMembers,
338 theTranslator->trModulesMembers(),
339 QCString(),
340 theTranslator->trModulesMemberDescription(extractAll),
341 "modulemembers"
342 },
343 { "namespaces",
344 LayoutNavEntry::Namespaces,
345 javaOpt || vhdlOpt ? theTranslator->trPackages() : fortranOpt || sliceOpt ? theTranslator->trModules() : theTranslator->trNamespaces(),
346 javaOpt || vhdlOpt ? theTranslator->trPackageList() : fortranOpt || sliceOpt ? theTranslator->trModulesList() : theTranslator->trNamespaceList(),
347 javaOpt || vhdlOpt ? theTranslator->trPackageListDescription() : fortranOpt || sliceOpt ? theTranslator->trModulesListDescription(extractAll) : theTranslator->trNamespaceListDescription(extractAll),
348 "namespaces"
349 },
350 { "namespacelist",
351 LayoutNavEntry::NamespaceList,
352 javaOpt || vhdlOpt ? theTranslator->trPackageList() : fortranOpt || sliceOpt ? theTranslator->trModulesList() : theTranslator->trNamespaceList(),
353 QCString(),
354 javaOpt || vhdlOpt ? theTranslator->trPackageListDescription() : fortranOpt || sliceOpt ? theTranslator->trModulesListDescription(extractAll) : theTranslator->trNamespaceListDescription(extractAll),
355 "namespaces"
356 },
357 { "namespacemembers",
358 LayoutNavEntry::NamespaceMembers,
359 javaOpt || vhdlOpt ? theTranslator->trPackageMembers() : fortranOpt || sliceOpt ? theTranslator->trModulesMembers() : theTranslator->trNamespaceMembers(),
360 QCString(),
361 fortranOpt || sliceOpt ? theTranslator->trModulesMemberDescription(extractAll) : theTranslator->trNamespaceMemberDescription(extractAll),
362 "namespacemembers"
363 },
364 { "concepts",
365 LayoutNavEntry::Concepts,
366 theTranslator->trConcept(true,false),
367 theTranslator->trConceptList(),
368 theTranslator->trConceptListDescription(extractAll),
369 "concepts"
370 },
371 { "classindex",
372 LayoutNavEntry::ClassIndex,
373 fortranOpt ? theTranslator->trCompoundIndexFortran() : vhdlOpt ? theTranslator->trDesignUnitIndex() : theTranslator->trCompoundIndex(),
374 QCString(),
375 QCString(),
376 "classes"
377 },
378 { "classes",
379 LayoutNavEntry::Classes,
380 fortranOpt ? theTranslator->trDataTypes() : vhdlOpt ? theTranslator->trDesignUnits() : theTranslator->trClasses(),
381 theTranslator->trCompoundList(),
382 fortranOpt ? theTranslator->trCompoundListDescriptionFortran() : vhdlOpt ? theTranslator->trDesignUnitListDescription() : theTranslator->trCompoundListDescription(),
383 "annotated"
384 },
385 { "classlist",
386 LayoutNavEntry::ClassList,
387 fortranOpt ? theTranslator->trCompoundListFortran() : vhdlOpt ? theTranslator->trDesignUnitList() : theTranslator->trCompoundList(),
388 QCString(),
389 fortranOpt ? theTranslator->trCompoundListDescriptionFortran() : vhdlOpt ? theTranslator->trDesignUnitListDescription() : theTranslator->trCompoundListDescription(),
390 "annotated"
391 },
392 { "hierarchy",
393 LayoutNavEntry::ClassHierarchy,
394 vhdlOpt ? theTranslator->trDesignUnitHierarchy() : theTranslator->trClassHierarchy(),
395 QCString(),
396 theTranslator->trClassHierarchyDescription(),
397 hasGraphicalHierarchy ? "inherits" : "hierarchy"
398 },
399 { "classmembers",
400 LayoutNavEntry::ClassMembers,
401 fortranOpt ? theTranslator->trCompoundMembersFortran() : vhdlOpt ? theTranslator->trDesignUnitMembers() : theTranslator->trCompoundMembers(),
402 QCString(),
403 fortranOpt ? theTranslator->trCompoundMembersDescriptionFortran(extractAll) : theTranslator->trCompoundMembersDescription(extractAll),
404 "functions"
405 },
406 { "interfaceindex",
407 LayoutNavEntry::InterfaceIndex,
408 theTranslator->trInterfaceIndex(),
409 QCString(),
410 QCString(),
411 "interfaces"
412 },
413 { "interfaces",
414 LayoutNavEntry::Interfaces,
415 theTranslator->trSliceInterfaces(),
416 theTranslator->trInterfaceList(),
417 theTranslator->trInterfaceListDescription(),
418 "annotatedinterfaces"
419 },
420 { "interfacelist",
421 LayoutNavEntry::InterfaceList,
422 theTranslator->trInterfaceList(),
423 QCString(),
424 theTranslator->trInterfaceListDescription(),
425 "annotatedinterfaces"
426 },
427 { "interfacehierarchy",
428 LayoutNavEntry::InterfaceHierarchy,
429 theTranslator->trInterfaceHierarchy(),
430 QCString(),
431 theTranslator->trInterfaceHierarchyDescription(),
432 hasGraphicalHierarchy ? "interfaceinherits" : "interfacehierarchy"
433 },
434 { "structindex",
435 LayoutNavEntry::StructIndex,
436 theTranslator->trStructIndex(),
437 QCString(),
438 QCString(),
439 "structs"
440 },
441 { "structs",
442 LayoutNavEntry::Structs,
443 theTranslator->trStructs(),
444 theTranslator->trStructList(),
445 theTranslator->trStructListDescription(),
446 "annotatedstructs"
447 },
448 { "structlist",
449 LayoutNavEntry::StructList,
450 theTranslator->trStructList(),
451 QCString(),
452 theTranslator->trStructListDescription(),
453 "annotatedstructs"
454 },
455 { "exceptionindex",
456 LayoutNavEntry::ExceptionIndex,
457 theTranslator->trExceptionIndex(),
458 QCString(),
459 QCString(),
460 "exceptions"
461 },
462 { "exceptions",
463 LayoutNavEntry::Exceptions,
464 theTranslator->trExceptions(),
465 theTranslator->trExceptionList(),
466 theTranslator->trExceptionListDescription(),
467 "annotatedexceptions"
468 },
469 { "exceptionlist",
470 LayoutNavEntry::ExceptionList,
471 theTranslator->trExceptionList(),
472 QCString(),
473 theTranslator->trExceptionListDescription(),
474 "annotatedexceptions"
475 },
476 { "exceptionhierarchy",
477 LayoutNavEntry::ExceptionHierarchy,
478 theTranslator->trExceptionHierarchy(),
479 QCString(),
480 theTranslator->trExceptionHierarchyDescription(),
481 hasGraphicalHierarchy ? "exceptioninherits" : "exceptionhierarchy"
482 },
483 { "files",
484 LayoutNavEntry::Files,
485 theTranslator->trFile(TRUE,FALSE),
486 theTranslator->trFileList(),
487 theTranslator->trFileListDescription(extractAll),
488 "files"
489 },
490 { "filelist",
491 LayoutNavEntry::FileList,
492 theTranslator->trFileList(),
493 QCString(),
494 theTranslator->trFileListDescription(extractAll),
495 "files"
496 },
497 { "globals",
498 LayoutNavEntry::FileGlobals,
499 theTranslator->trFileMembers(),
500 QCString(),
501 theTranslator->trFileMembersDescription(extractAll),
502 "globals"
503 },
504 { "examples",
505 LayoutNavEntry::Examples,
506 theTranslator->trExamples(),
507 QCString(),
508 theTranslator->trExamplesDescription(),
509 "examples"
510 },
511 { "user",
512 LayoutNavEntry::User,
513 QCString(),
514 QCString(),
515 QCString(),
516 "user"
517 },
518 { "usergroup",
519 LayoutNavEntry::UserGroup,
520 QCString(),
521 QCString(),
522 QCString(),
523 "usergroup"
524 },
525 { nullptr, // end of list
526 static_cast<LayoutNavEntry::Kind>(0),
527 QCString(),
528 QCString(),
529 QCString(),
530 QCString()
531 }
532 };
533 // find type in the table
534 int i=0;
535 QCString type = XMLHandlers::value(attrib,"type");
536 while (mapping[i].typeStr)
537 {
538 if (mapping[i].typeStr==type)
539 break;
540 i++;
541 }
542 if (mapping[i].typeStr==nullptr)
543 {
544 std::string fileName = m_locator->fileName();
545 if (type.isEmpty())
546 {
547 warn(fileName.c_str(),m_locator->lineNr(),"an entry tag within a navindex has no type attribute! Check your layout file!");
548 }
549 else
550 {
551 warn(fileName.c_str(),m_locator->lineNr(),"the type '%s' is not supported for the entry tag within a navindex! Check your layout file!",qPrint(type));
552 }
554 return;
555 }
556 LayoutNavEntry::Kind kind = mapping[i].kind;
557 QCString baseFile = mapping[i].baseFile;
558 QCString title = XMLHandlers::value(attrib,"title");
559 bool isVisible = m_visible && elemIsVisible(attrib) && parentIsVisible(m_rootNav);
560 if (title.isEmpty()) // use default title
561 {
562 title = mapping[i].mainName; // use title for main row
563 if (m_rootNav!=LayoutDocManager::instance().rootNavEntry() && !mapping[i].subName.isEmpty())
564 {
565 title = mapping[i].subName; // if this is a child of another row, use the subName if available
566 // this is mainly done to get compatible naming with older versions.
567 }
568 }
569 QCString intro = XMLHandlers::value(attrib,"intro");
570 if (intro.isEmpty()) // use default intro text
571 {
572 intro = mapping[i].intro;
573 }
574 QCString url = XMLHandlers::value(attrib,"url");
575 if (mapping[i].kind==LayoutNavEntry::User && !url.isEmpty())
576 {
577 baseFile=url;
578 }
579 else if (kind==LayoutNavEntry::UserGroup)
580 {
581 if (!url.isEmpty())
582 {
583 if (url == "[none]")
584 {
585 baseFile = QCString();
586 }
587 else
588 {
589 baseFile=url;
590 }
591 }
592 else
593 {
594 baseFile+=QCString().sprintf("%d",m_userGroupCount++);
595 }
596 }
597 // create new item and make it the new root
598 m_rootNav = LayoutDocManager::instance().createChildNavEntry(m_rootNav,kind,isVisible,baseFile,title,intro);
599 }
600
602 {
603 // set the root back to the parent
604 if (m_rootNav && !m_invalidEntry) m_rootNav = m_rootNav->parent();
606 }
607
609 {
610 bool vis = lne.visible();
611 for (const auto &lne1 : lne.children())
612 {
613 lne1->setVisible(vis && lne1->visible());
615 }
616 }
617
619 const QCString &scope, LayoutNavEntry::Kind nav)
620 {
622 m_scope = scope;
623 m_part = part;
624 m_visible = elemIsVisible(attrib);
625 auto *lne = LayoutDocManager::instance().rootNavEntry()->find(nav);
626 if (lne)
627 {
628 m_visible = m_visible && lne->visible();
629 lne->setVisible(m_visible);
631 }
632 }
633
634 void endTop()
635 {
636 m_scope="";
637 m_part = LayoutDocManager::Undefined;
638 }
639
641 {
642 m_scope+="memberdef/";
643 if (m_part!=LayoutDocManager::Undefined)
644 {
645 bool isVisible = m_visible && elemIsVisible(attrib) && parentIsVisible(m_rootNav);
646 LayoutDocManager::instance().addEntry(m_part,std::make_unique<LayoutDocEntrySimple>(LayoutDocEntry::MemberDefStart,isVisible));
647 }
648 }
649
651 {
652 QCString scopeOrg = m_scope;
653 int i=m_scope.findRev("memberdef/");
654 if (i!=-1)
655 {
656 m_scope=m_scope.left(i);
657 if (m_part!=LayoutDocManager::Undefined)
658 {
659 bool isVisible = true;
660 for (const auto &lde : LayoutDocManager::instance().docEntries(m_part))
661 {
662 if (lde->kind() == LayoutDocEntry::MemberDefStart)
663 {
664 isVisible = static_cast<const LayoutDocEntrySimple*>(lde.get())->visible();
665 }
666 }
667 LayoutDocManager::instance().addEntry(m_part,std::make_unique<LayoutDocEntrySimple>(LayoutDocEntry::MemberDefEnd,isVisible));
668 }
669 }
670 }
671
673 {
674 m_scope+="memberdecl/";
675 if (m_part!=LayoutDocManager::Undefined)
676 {
677 bool isVisible = m_visible && elemIsVisible(attrib) && parentIsVisible(m_rootNav);
678 LayoutDocManager::instance().addEntry(m_part,std::make_unique<LayoutDocEntrySimple>(LayoutDocEntry::MemberDeclStart,isVisible));
679 }
680 }
681
683 {
684 int i=m_scope.findRev("memberdecl/");
685 if (i!=-1)
686 {
687 m_scope=m_scope.left(i);
688 if (m_part!=LayoutDocManager::Undefined)
689 {
690 bool isVisible = true;
691 for (const auto &lde : LayoutDocManager::instance().docEntries(m_part))
692 {
693 if (lde->kind() == LayoutDocEntry::MemberDeclStart)
694 {
695 isVisible = static_cast<const LayoutDocEntrySimple*>(lde.get())->visible();
696 }
697 }
698 LayoutDocManager::instance().addEntry(m_part,std::make_unique<LayoutDocEntrySimple>(LayoutDocEntry::MemberDeclEnd,isVisible));
699 }
700 }
701 }
702
703 private:
705 LayoutDocManager::LayoutPart m_part = LayoutDocManager::Undefined;
707 bool m_invalidEntry = false;
708 bool m_visible = true;
710 const XMLLocator *m_locator = nullptr;
711};
712
713//---------------------------------------------------------------------------------
714
715namespace {
716
718{
719 using StartCallback = std::function<void(LayoutParser&,const XMLHandlers::Attributes&)>;
720 using EndCallback = std::function<void(LayoutParser&)>;
721
724};
725
726template<class...Args>
727static auto startCb(void (LayoutParser::*fn)(Args...))
728{
729 return [=](LayoutParser &parser,const XMLHandlers::Attributes &attr) { (parser.*fn)(attr); };
730}
731
732template<class...Args>
733static auto startCb(void (LayoutParser::*fn)(Args...),
735 )
736{
737 return [=](LayoutParser &parser,const XMLHandlers::Attributes &attr) { (parser.*fn)(kind,attr); };
738}
739
740template<class...Args>
741static auto startCb(void (LayoutParser::*fn)(Args...),
743 const std::function<QCString()> &title
744 )
745{
746 return [=](LayoutParser &parser,const XMLHandlers::Attributes &attr) { (parser.*fn)(kind,attr,title()); };
747}
748
749template<class...Args>
750static auto startCb(void (LayoutParser::*fn)(Args...),
751 MemberListType type,
752 const std::function<QCString()> &title
753 )
754{
755 return [=](LayoutParser &parser,const XMLHandlers::Attributes &attr) { (parser.*fn)(attr,type,title(),QCString()); };
756}
757
758template<class...Args>
759static auto startCb(void (LayoutParser::*fn)(Args...),
760 MemberListType type,
761 const std::function<QCString()> &title,
762 const std::function<QCString()> &subtitle
763 )
764{
765 return [=](LayoutParser &parser,const XMLHandlers::Attributes &attr) { (parser.*fn)(attr,type,title(),subtitle()); };
766}
767
768template<class...Args>
769static auto startCb(void (LayoutParser::*fn)(Args...),
771 const QCString &scope,
773 )
774{
775 return [=](LayoutParser &parser,const XMLHandlers::Attributes &attr) { (parser.*fn)(attr,part,scope,nav); };
776}
777
778static auto endCb(void (LayoutParser::*fn)())
779{
780 return [=](LayoutParser &parser) { (parser.*fn)(); };
781}
782
783static const std::map< std::string, ElementCallbacks > g_elementHandlers =
784{
785 // path/name
786 { "doxygenlayout", { startCb(&LayoutParser::startLayout) } },
788 { "navindex/tab", { startCb(&LayoutParser::startNavEntry),
790 } },
791
792 // class layout handlers
793 { "class", { startCb(&LayoutParser::startTop,LayoutDocManager::Class,"class/",LayoutNavEntry::Classes),
795 } },
796 { "class/briefdescription", { startCb(&LayoutParser::startSimpleEntry,LayoutDocEntry::BriefDesc) } },
797 { "class/detaileddescription", { startCb(&LayoutParser::startSectionEntry,LayoutDocEntry::DetailedDesc,
798 [](){ return compileOptions(theTranslator->trDetailedDescription()); })
799 } },
800 { "class/authorsection", { startCb(&LayoutParser::startSimpleEntry,LayoutDocEntry::AuthorSection) } },
801 { "class/includes", { startCb(&LayoutParser::startSimpleEntry,LayoutDocEntry::ClassIncludes) } },
802 { "class/inheritancegraph", { startCb(&LayoutParser::startSimpleEntry,LayoutDocEntry::ClassInheritanceGraph) } },
803 { "class/collaborationgraph", { startCb(&LayoutParser::startSimpleEntry,LayoutDocEntry::ClassCollaborationGraph) } },
804 { "class/allmemberslink", { startCb(&LayoutParser::startSimpleEntry,LayoutDocEntry::ClassAllMembersLink) } },
805 { "class/usedfiles", { startCb(&LayoutParser::startSimpleEntry,LayoutDocEntry::ClassUsedFiles) } },
807 { "class/memberdecl/membergroups", { startCb(&LayoutParser::startSimpleEntry,LayoutDocEntry::MemberGroups) } },
808 { "class/memberdecl/nestedclasses", { startCb(&LayoutParser::startSectionEntry,LayoutDocEntry::ClassNestedClasses,
809 []() { return compileOptions(/*default*/ theTranslator->trCompounds(),
811 SrcLangExt::Fortran,theTranslator->trDataTypes()); })
812 } },
813 { "class/memberdecl/services", { startCb(&LayoutParser::startMemberDeclEntry,MemberListType::Services(),
814 []() { return compileOptions(theTranslator->trServices()); })
815 } },
816 { "class/memberdecl/interfaces", { startCb(&LayoutParser::startMemberDeclEntry,MemberListType::Interfaces(),
817 []() { return compileOptions(theTranslator->trInterfaces()); })
818 } },
819 { "class/memberdecl/publictypes", { startCb(&LayoutParser::startMemberDeclEntry,MemberListType::PubTypes(),
820 []() { return compileOptions(theTranslator->trPublicTypes()); })
821 } },
822 { "class/memberdecl/publicslots", { startCb(&LayoutParser::startMemberDeclEntry,MemberListType::PubSlots(),
823 []() { return compileOptions(theTranslator->trPublicSlots()); })
824 } },
825 { "class/memberdecl/signals", { startCb(&LayoutParser::startMemberDeclEntry,MemberListType::Signals(),
826 []() { return compileOptions(theTranslator->trSignals()); })
827 } },
828 { "class/memberdecl/publicmethods", { startCb(&LayoutParser::startMemberDeclEntry, MemberListType::PubMethods(),
829 []() { return compileOptions(/* default */ theTranslator->trPublicMembers(),
830 SrcLangExt::ObjC, theTranslator->trInstanceMethods(),
831 SrcLangExt::Slice,theTranslator->trOperations()); })
832 } },
833 { "class/memberdecl/publicstaticmethods", { startCb(&LayoutParser::startMemberDeclEntry, MemberListType::PubStaticMethods(),
834 []() { return compileOptions(/* default */ theTranslator->trStaticPublicMembers(),
835 SrcLangExt::ObjC, theTranslator->trClassMethods()); })
836 } },
837 { "class/memberdecl/publicattributes", { startCb(&LayoutParser::startMemberDeclEntry, MemberListType::PubAttribs(),
838 []() { return compileOptions(/* default */ theTranslator->trPublicAttribs(),
839 SrcLangExt::Slice,theTranslator->trDataMembers()); })
840 } },
841 { "class/memberdecl/publicstaticattributes", { startCb(&LayoutParser::startMemberDeclEntry, MemberListType::PubStaticAttribs(),
842 []() { return compileOptions(theTranslator->trStaticPublicAttribs()); })
843 } },
844 { "class/memberdecl/protectedtypes", { startCb(&LayoutParser::startMemberDeclEntry, MemberListType::ProTypes(),
845 []() { return compileOptions(theTranslator->trProtectedTypes()); })
846 } },
847 { "class/memberdecl/protectedslots", { startCb(&LayoutParser::startMemberDeclEntry, MemberListType::ProSlots(),
848 []() { return compileOptions(theTranslator->trProtectedSlots()); })
849 } },
850 { "class/memberdecl/protectedmethods", { startCb(&LayoutParser::startMemberDeclEntry, MemberListType::ProMethods(),
851 []() { return compileOptions(theTranslator->trProtectedMembers()); })
852 } },
853 { "class/memberdecl/protectedstaticmethods", { startCb(&LayoutParser::startMemberDeclEntry, MemberListType::ProStaticMethods(),
854 []() { return compileOptions(theTranslator->trStaticProtectedMembers()); })
855 } },
856 { "class/memberdecl/protectedattributes", { startCb(&LayoutParser::startMemberDeclEntry, MemberListType::ProAttribs(),
857 []() { return compileOptions(theTranslator->trProtectedAttribs()); })
858 } },
859 { "class/memberdecl/protectedstaticattributes", { startCb(&LayoutParser::startMemberDeclEntry, MemberListType::ProStaticAttribs(),
860 []() { return compileOptions(theTranslator->trStaticProtectedAttribs()); })
861 } },
862 { "class/memberdecl/packagetypes", { startCb(&LayoutParser::startMemberDeclEntry, MemberListType::PacTypes(),
863 []() { return compileOptions(theTranslator->trPackageTypes()); })
864 } },
865 { "class/memberdecl/packagemethods", { startCb(&LayoutParser::startMemberDeclEntry, MemberListType::PacMethods(),
866 []() { return compileOptions(theTranslator->trPackageFunctions()); })
867 } },
868 { "class/memberdecl/packagestaticmethods", { startCb(&LayoutParser::startMemberDeclEntry, MemberListType::PacStaticMethods(),
869 []() { return compileOptions(theTranslator->trStaticPackageFunctions()); })
870 } },
871 { "class/memberdecl/packageattributes", { startCb(&LayoutParser::startMemberDeclEntry, MemberListType::PacAttribs(),
872 []() { return compileOptions(theTranslator->trPackageAttribs()); })
873 } },
874 { "class/memberdecl/packagestaticattributes", { startCb(&LayoutParser::startMemberDeclEntry, MemberListType::PacStaticAttribs(),
875 []() { return compileOptions(theTranslator->trStaticPackageAttribs()); })
876 } },
877 { "class/memberdecl/properties", { startCb(&LayoutParser::startMemberDeclEntry, MemberListType::Properties(),
878 []() { return compileOptions(theTranslator->trProperties()); })
879 } },
880 { "class/memberdecl/events", { startCb(&LayoutParser::startMemberDeclEntry, MemberListType::Events(),
881 []() { return compileOptions(theTranslator->trEvents()); })
882 } },
883 { "class/memberdecl/privatetypes", { startCb(&LayoutParser::startMemberDeclEntry, MemberListType::PriTypes(),
884 []() { return compileOptions(theTranslator->trPrivateTypes()); })
885 } },
886 { "class/memberdecl/privateslots", { startCb(&LayoutParser::startMemberDeclEntry, MemberListType::PriSlots(),
887 []() { return compileOptions(theTranslator->trPrivateSlots()); })
888 } },
889 { "class/memberdecl/privatemethods", { startCb(&LayoutParser::startMemberDeclEntry, MemberListType::PriMethods(),
890 []() { return compileOptions(theTranslator->trPrivateMembers()); })
891 } },
892 { "class/memberdecl/privatestaticmethods", { startCb(&LayoutParser::startMemberDeclEntry, MemberListType::PriStaticMethods(),
893 []() { return compileOptions(theTranslator->trStaticPrivateMembers()); })
894 } },
895 { "class/memberdecl/privateattributes", { startCb(&LayoutParser::startMemberDeclEntry, MemberListType::PriAttribs(),
896 []() { return compileOptions(theTranslator->trPrivateAttribs()); })
897 } },
898 { "class/memberdecl/privatestaticattributes", { startCb(&LayoutParser::startMemberDeclEntry, MemberListType::PriStaticAttribs(),
899 []() { return compileOptions(theTranslator->trStaticPrivateAttribs()); })
900 } },
901 { "class/memberdecl/friends", { startCb(&LayoutParser::startMemberDeclEntry, MemberListType::Friends(),
902 []() { return compileOptions(theTranslator->trFriends()); })
903 } },
904 { "class/memberdecl/related", { startCb(&LayoutParser::startMemberDeclEntry, MemberListType::Related(),
905 []() { return compileOptions(theTranslator->trRelatedSymbols()); },
906 []() { return compileOptions(theTranslator->trRelatedSymbolsSubscript()); })
907 } },
909 { "class/memberdef/inlineclasses", { startCb(&LayoutParser::startSectionEntry, LayoutDocEntry::ClassInlineClasses,
910 []() { return compileOptions(/* default */ theTranslator->trClassDocumentation(),
911 SrcLangExt::Fortran,theTranslator->trTypeDocumentation()); })
912 } },
913 { "class/memberdef/typedefs", { startCb(&LayoutParser::startMemberDefEntry, MemberListType::TypedefMembers(),
914 []() { return compileOptions(theTranslator->trMemberTypedefDocumentation()); })
915 } },
916 { "class/memberdef/enums", { startCb(&LayoutParser::startMemberDefEntry, MemberListType::EnumMembers(),
917 []() { return compileOptions(theTranslator->trMemberEnumerationDocumentation()); })
918 } },
919 { "class/memberdef/services", { startCb(&LayoutParser::startMemberDefEntry, MemberListType::ServiceMembers(),
920 []() { return compileOptions(theTranslator->trInterfaces()); })
921 } },
922 { "class/memberdef/interfaces", { startCb(&LayoutParser::startMemberDefEntry, MemberListType::InterfaceMembers(),
923 []() { return compileOptions(theTranslator->trInterfaces()); })
924 } },
925 { "class/memberdef/constructors", { startCb(&LayoutParser::startMemberDefEntry, MemberListType::Constructors(),
926 []() { return compileOptions(theTranslator->trConstructorDocumentation()); })
927 } },
928 { "class/memberdef/functions", { startCb(&LayoutParser::startMemberDefEntry, MemberListType::FunctionMembers(),
929 []() { return compileOptions(/* default */ theTranslator->trMemberFunctionDocumentation(), SrcLangExt::ObjC, theTranslator->trMethodDocumentation(),
930 SrcLangExt::Fortran,theTranslator->trMemberFunctionDocumentationFortran(),
931 SrcLangExt::Slice, theTranslator->trOperationDocumentation()); })
932 } },
933 { "class/memberdef/related", { startCb(&LayoutParser::startMemberDefEntry, MemberListType::RelatedMembers(),
934 []() { return compileOptions(theTranslator->trRelatedSymbolDocumentation()); })
935 } },
936 { "class/memberdef/variables", { startCb(&LayoutParser::startMemberDefEntry, MemberListType::VariableMembers(),
937 []() { return compileOptions(/* default */ theTranslator->trMemberDataDocumentation(),
938 SrcLangExt::Slice, theTranslator->trDataMemberDocumentation()); })
939 } },
940 { "class/memberdef/properties", { startCb(&LayoutParser::startMemberDefEntry, MemberListType::PropertyMembers(),
941 []() { return compileOptions(theTranslator->trPropertyDocumentation()); })
942 } },
943 { "class/memberdef/events", { startCb(&LayoutParser::startMemberDefEntry, MemberListType::EventMembers(),
944 []() { return compileOptions(theTranslator->trEventDocumentation()); })
945 } },
946
947 // concept layout handlers
948 { "concept", { startCb(&LayoutParser::startTop,LayoutDocManager::Concept,"concept/",LayoutNavEntry::Concepts),
950 } },
951 { "concept/briefdescription", { startCb(&LayoutParser::startSimpleEntry, LayoutDocEntry::BriefDesc) } },
952 { "concept/definition", { startCb(&LayoutParser::startSectionEntry, LayoutDocEntry::ConceptDefinition,
953 []() { return compileOptions(theTranslator->trConceptDefinition()); }),
954 } },
955 { "concept/includes", { startCb(&LayoutParser::startSimpleEntry, LayoutDocEntry::ClassIncludes) } },
956 { "concept/sourcelink", { startCb(&LayoutParser::startSimpleEntry, LayoutDocEntry::FileSourceLink) } },
957 { "concept/detaileddescription", { startCb(&LayoutParser::startSectionEntry,LayoutDocEntry::DetailedDesc,
958 []() { return compileOptions(theTranslator->trDetailedDescription()); })
959 } },
960 { "concept/authorsection", { startCb(&LayoutParser::startSimpleEntry, LayoutDocEntry::AuthorSection) } },
961 // namespace layout handlers
962 { "namespace", { startCb(&LayoutParser::startTop,LayoutDocManager::Namespace,"namespace/",LayoutNavEntry::Namespaces),
964 } },
965 { "namespace/briefdescription", { startCb(&LayoutParser::startSimpleEntry, LayoutDocEntry::BriefDesc) } },
966 { "namespace/detaileddescription", { startCb(&LayoutParser::startSectionEntry,LayoutDocEntry::DetailedDesc,
967 []() { return compileOptions(theTranslator->trDetailedDescription()); })
968 } },
969 { "namespace/authorsection", { startCb(&LayoutParser::startSimpleEntry, LayoutDocEntry::AuthorSection) } },
970 { "namespace/memberdecl", { startCb(&LayoutParser::startMemberDecl),
972 } },
973 { "namespace/memberdecl/nestednamespaces", { startCb(&LayoutParser::startSectionEntry, LayoutDocEntry::NamespaceNestedNamespaces,
974 []() { return compileOptions(/* default */ theTranslator->trNamespaces(),
975 SrcLangExt::Java, theTranslator->trPackages(),
976 SrcLangExt::VHDL, theTranslator->trPackages(),
977 SrcLangExt::IDL, theTranslator->trModules(),
979 SrcLangExt::Slice,(Config_getBool(OPTIMIZE_OUTPUT_SLICE) ?
980 theTranslator->trModules() :
981 theTranslator->trNamespaces())); })
982 } },
983 { "namespace/memberdecl/constantgroups", { startCb(&LayoutParser::startSectionEntry, LayoutDocEntry::NamespaceNestedConstantGroups,
984 []() { return compileOptions(theTranslator->trConstantGroups()); })
985 } },
986 { "namespace/memberdecl/interfaces", { startCb(&LayoutParser::startSectionEntry,LayoutDocEntry::NamespaceInterfaces,
987 []() { return compileOptions(theTranslator->trSliceInterfaces()); })
988 } },
989 { "namespace/memberdecl/classes", { startCb(&LayoutParser::startSectionEntry,LayoutDocEntry::NamespaceClasses,
990 []() { return compileOptions(/* default */ theTranslator->trCompounds(),
992 SrcLangExt::Fortran,theTranslator->trDataTypes()); })
993 } },
994 { "namespace/memberdecl/concepts", { startCb(&LayoutParser::startSectionEntry, LayoutDocEntry::NamespaceConcepts,
995 []() { return compileOptions(theTranslator->trConcept(true,false)); })
996 } },
997 { "namespace/memberdecl/structs", { startCb(&LayoutParser::startSectionEntry,LayoutDocEntry::NamespaceStructs,
998 []() { return compileOptions(theTranslator->trStructs()); })
999 } },
1000 { "namespace/memberdecl/exceptions", { startCb(&LayoutParser::startSectionEntry,LayoutDocEntry::NamespaceExceptions,
1001 []() { return compileOptions(theTranslator->trExceptions()); })
1002 } },
1003 { "namespace/memberdecl/membergroups", { startCb(&LayoutParser::startSimpleEntry,LayoutDocEntry::MemberGroups) } },
1004 { "namespace/memberdecl/typedefs", { startCb(&LayoutParser::startMemberDeclEntry, MemberListType::DecTypedefMembers(),
1005 []() { return compileOptions(theTranslator->trTypedefs()); })
1006 } },
1007 { "namespace/memberdecl/sequences", { startCb(&LayoutParser::startMemberDeclEntry, MemberListType::DecSequenceMembers(),
1008 []() { return compileOptions(theTranslator->trSequences()); })
1009 } },
1010 { "namespace/memberdecl/dictionaries", { startCb(&LayoutParser::startMemberDeclEntry, MemberListType::DecDictionaryMembers(),
1011 []() { return compileOptions(theTranslator->trDictionaries()); })
1012 } },
1013 { "namespace/memberdecl/enums", { startCb(&LayoutParser::startMemberDeclEntry, MemberListType::DecEnumMembers(),
1014 []() { return compileOptions(theTranslator->trEnumerations()); })
1015 } },
1016 { "namespace/memberdecl/functions", { startCb(&LayoutParser::startMemberDeclEntry, MemberListType::DecFuncMembers(),
1017 []() { return compileOptions(/* default */ theTranslator->trFunctions(),
1018 SrcLangExt::Fortran,theTranslator->trSubprograms(),
1019 SrcLangExt::VHDL, theTranslator->trFunctionAndProc()); })
1020 } },
1021 { "namespace/memberdecl/variables", { startCb(&LayoutParser::startMemberDeclEntry, MemberListType::DecVarMembers(),
1022 []() { return compileOptions(Config_getBool(OPTIMIZE_OUTPUT_SLICE) ?
1023 theTranslator->trConstants() :
1024 theTranslator->trVariables()); })
1025 } },
1026 { "namespace/memberdecl/properties", { startCb(&LayoutParser::startMemberDeclEntry, MemberListType::Properties(),
1027 []() { return compileOptions(theTranslator->trProperties()); })
1028 } },
1029 { "namespace/memberdef", { startCb(&LayoutParser::startMemberDef), endCb(&LayoutParser::endMemberDef) } },
1030 { "namespace/memberdef/inlineclasses", { startCb(&LayoutParser::startSectionEntry, LayoutDocEntry::NamespaceInlineClasses,
1031 []() { return compileOptions(/* default */ theTranslator->trClassDocumentation(),
1032 SrcLangExt::Fortran,theTranslator->trTypeDocumentation()); })
1033 } },
1034 { "namespace/memberdef/typedefs", { startCb(&LayoutParser::startMemberDefEntry, MemberListType::DocTypedefMembers(),
1035 []() { return compileOptions(theTranslator->trTypedefDocumentation()); })
1036 } },
1037 { "namespace/memberdef/sequences", { startCb(&LayoutParser::startMemberDefEntry, MemberListType::DocSequenceMembers(),
1038 []() { return compileOptions(theTranslator->trSequenceDocumentation()); })
1039 } },
1040 { "namespace/memberdef/dictionaries", { startCb(&LayoutParser::startMemberDefEntry, MemberListType::DocDictionaryMembers(),
1041 []() { return compileOptions(theTranslator->trDictionaryDocumentation()); })
1042 } },
1043 { "namespace/memberdef/enums", { startCb(&LayoutParser::startMemberDefEntry, MemberListType::DocEnumMembers(),
1044 []() { return compileOptions(theTranslator->trEnumerationTypeDocumentation()); })
1045 } },
1046 { "namespace/memberdef/functions", { startCb(&LayoutParser::startMemberDefEntry, MemberListType::DocFuncMembers(),
1047 []() { return compileOptions(/* default */ theTranslator->trFunctionDocumentation(),
1048 SrcLangExt::Fortran,theTranslator->trSubprogramDocumentation()); })
1049 } },
1050 { "namespace/memberdef/variables", { startCb(&LayoutParser::startMemberDefEntry, MemberListType::DocVarMembers(),
1051 []() { return compileOptions(Config_getBool(OPTIMIZE_OUTPUT_SLICE) ?
1052 theTranslator->trConstantDocumentation() :
1053 theTranslator->trVariableDocumentation()); })
1054 } },
1055 { "namespace/memberdef/properties", { startCb(&LayoutParser::startMemberDefEntry, MemberListType::PropertyMembers(),
1056 []() { return compileOptions(theTranslator->trPropertyDocumentation()); })
1057 } },
1058
1059 // file layout handlers
1060 { "file", { startCb(&LayoutParser::startTop,LayoutDocManager::File,"file/",LayoutNavEntry::Files),
1062 } },
1063 { "file/briefdescription", { startCb(&LayoutParser::startSimpleEntry, LayoutDocEntry::BriefDesc) } },
1064 { "file/detaileddescription", { startCb(&LayoutParser::startSectionEntry, LayoutDocEntry::DetailedDesc,
1065 []() { return compileOptions(theTranslator->trDetailedDescription()); })
1066 } },
1067 { "file/authorsection", { startCb(&LayoutParser::startSimpleEntry, LayoutDocEntry::AuthorSection) } },
1068 { "file/includes", { startCb(&LayoutParser::startSimpleEntry, LayoutDocEntry::FileIncludes) } },
1069 { "file/includegraph", { startCb(&LayoutParser::startSimpleEntry, LayoutDocEntry::FileIncludeGraph) } },
1070 { "file/includedbygraph", { startCb(&LayoutParser::startSimpleEntry, LayoutDocEntry::FileIncludedByGraph) } },
1071 { "file/sourcelink", { startCb(&LayoutParser::startSimpleEntry, LayoutDocEntry::FileSourceLink) } },
1072 { "file/memberdecl/membergroups", { startCb(&LayoutParser::startSimpleEntry, LayoutDocEntry::MemberGroups) } },
1074 { "file/memberdecl/interfaces", { startCb(&LayoutParser::startSectionEntry,LayoutDocEntry::FileInterfaces,
1075 []() { return compileOptions(theTranslator->trSliceInterfaces()); })
1076 } },
1077 { "file/memberdecl/classes", { startCb(&LayoutParser::startSectionEntry,LayoutDocEntry::FileClasses,
1078 []() { return compileOptions(/* default */ theTranslator->trCompounds(),
1080 SrcLangExt::Fortran,theTranslator->trDataTypes()); })
1081 } },
1082 { "file/memberdecl/concepts", { startCb(&LayoutParser::startSectionEntry, LayoutDocEntry::FileConcepts,
1083 []() { return compileOptions(theTranslator->trConcept(true,false)); })
1084 } },
1085 { "file/memberdecl/structs", { startCb(&LayoutParser::startSectionEntry,LayoutDocEntry::FileStructs,
1086 []() { return compileOptions(theTranslator->trStructs()); })
1087 } },
1088 { "file/memberdecl/exceptions", { startCb(&LayoutParser::startSectionEntry,LayoutDocEntry::FileExceptions,
1089 []() { return compileOptions(theTranslator->trExceptions()); })
1090 } },
1091 { "file/memberdecl/namespaces", { startCb(&LayoutParser::startSectionEntry,LayoutDocEntry::FileNamespaces,
1092 []() { return compileOptions(/* default */ theTranslator->trNamespaces(),
1093 SrcLangExt::Java, theTranslator->trPackages(),
1094 SrcLangExt::IDL, theTranslator->trModules(),
1096 SrcLangExt::Slice, theTranslator->trModules()); })
1097 } },
1098 { "file/memberdecl/constantgroups", { startCb(&LayoutParser::startSectionEntry,LayoutDocEntry::FileConstantGroups,
1099 []() { return compileOptions(theTranslator->trConstantGroups()); })
1100 } },
1101 { "file/memberdecl/defines", { startCb(&LayoutParser::startMemberDeclEntry, MemberListType::DecDefineMembers(),
1102 []() { return compileOptions(theTranslator->trDefines()); })
1103 } },
1104 { "file/memberdecl/typedefs", { startCb(&LayoutParser::startMemberDeclEntry, MemberListType::DecTypedefMembers(),
1105 []() { return compileOptions(theTranslator->trTypedefs()); })
1106 } },
1107 { "file/memberdecl/sequences", { startCb(&LayoutParser::startMemberDeclEntry, MemberListType::DecSequenceMembers(),
1108 []() { return compileOptions(theTranslator->trSequences()); })
1109 } },
1110 { "file/memberdecl/dictionaries", { startCb(&LayoutParser::startMemberDeclEntry, MemberListType::DecDictionaryMembers(),
1111 []() { return compileOptions(theTranslator->trDictionaries()); })
1112 } },
1113 { "file/memberdecl/enums", { startCb(&LayoutParser::startMemberDeclEntry, MemberListType::DecEnumMembers(),
1114 []() { return compileOptions(theTranslator->trEnumerations()); })
1115 } },
1116 { "file/memberdecl/functions", { startCb(&LayoutParser::startMemberDeclEntry, MemberListType::DecFuncMembers(),
1117 []() { return compileOptions(/* default */ theTranslator->trFunctions(),
1118 SrcLangExt::Fortran,theTranslator->trSubprograms(),
1119 SrcLangExt::VHDL, theTranslator->trFunctionAndProc()); })
1120 } },
1121 { "file/memberdecl/variables", { startCb(&LayoutParser::startMemberDeclEntry, MemberListType::DecVarMembers(),
1122 []() { return compileOptions(Config_getBool(OPTIMIZE_OUTPUT_SLICE) ?
1123 theTranslator->trConstants() :
1124 theTranslator->trVariables()); })
1125 } },
1126 { "file/memberdecl/properties", { startCb(&LayoutParser::startMemberDeclEntry, MemberListType::Properties(),
1127 []() { return compileOptions(theTranslator->trProperties()); })
1128 } },
1130
1131 { "file/memberdef/inlineclasses", { startCb(&LayoutParser::startSectionEntry,LayoutDocEntry::FileInlineClasses,
1132 []() { return compileOptions(/* default */ theTranslator->trClassDocumentation(),
1133 SrcLangExt::Fortran, theTranslator->trTypeDocumentation()); })
1134 } },
1135 { "file/memberdef/defines", { startCb(&LayoutParser::startMemberDefEntry, MemberListType::DocDefineMembers(),
1136 []() { return compileOptions(theTranslator->trDefineDocumentation()); })
1137 } },
1138 { "file/memberdef/typedefs", { startCb(&LayoutParser::startMemberDefEntry, MemberListType::DocTypedefMembers(),
1139 []() { return compileOptions(theTranslator->trTypedefDocumentation()); })
1140 } },
1141 { "file/memberdef/sequences", { startCb(&LayoutParser::startMemberDefEntry, MemberListType::DocSequenceMembers(),
1142 []() { return compileOptions(theTranslator->trSequenceDocumentation()); })
1143 } },
1144 { "file/memberdef/dictionaries", { startCb(&LayoutParser::startMemberDefEntry, MemberListType::DocDictionaryMembers(),
1145 []() { return compileOptions(theTranslator->trDictionaryDocumentation()); })
1146 } },
1147 { "file/memberdef/enums", { startCb(&LayoutParser::startMemberDefEntry, MemberListType::DocEnumMembers(),
1148 []() { return compileOptions(theTranslator->trEnumerationTypeDocumentation()); })
1149 } },
1150 { "file/memberdef/functions", { startCb(&LayoutParser::startMemberDefEntry, MemberListType::DocFuncMembers(),
1151 []() { return compileOptions(/* default */ theTranslator->trFunctionDocumentation(),
1152 SrcLangExt::Fortran, theTranslator->trSubprogramDocumentation()); })
1153 } },
1154 { "file/memberdef/variables", { startCb(&LayoutParser::startMemberDefEntry, MemberListType::DocVarMembers(),
1155 []() { return compileOptions(theTranslator->trVariableDocumentation()); })
1156 } },
1157
1158 { "file/memberdef/properties", { startCb(&LayoutParser::startMemberDefEntry, MemberListType::PropertyMembers(),
1159 []() { return compileOptions(theTranslator->trPropertyDocumentation()); })
1160 } },
1161 // group layout handlers
1162 { "group", { startCb(&LayoutParser::startTop,LayoutDocManager::Group,"group/",LayoutNavEntry::None),
1164 } },
1165 { "group/briefdescription", { startCb(&LayoutParser::startSimpleEntry, LayoutDocEntry::BriefDesc) } },
1166 { "group/detaileddescription", { startCb(&LayoutParser::startSectionEntry, LayoutDocEntry::DetailedDesc,
1167 []() { return compileOptions(theTranslator->trDetailedDescription()); })
1168 } },
1169 { "group/authorsection", { startCb(&LayoutParser::startSimpleEntry, LayoutDocEntry::AuthorSection) } },
1170 { "group/groupgraph", { startCb(&LayoutParser::startSimpleEntry, LayoutDocEntry::GroupGraph) } },
1172 { "group/memberdecl/membergroups", { startCb(&LayoutParser::startSimpleEntry, LayoutDocEntry::MemberGroups) } },
1173 { "group/memberdecl/classes", { startCb(&LayoutParser::startSectionEntry, LayoutDocEntry::GroupClasses,
1174 []() { return compileOptions(/* default */ theTranslator->trCompounds(),
1176 SrcLangExt::Fortran, theTranslator->trDataTypes()); })
1177 } },
1178 { "group/memberdecl/concepts", { startCb(&LayoutParser::startSectionEntry, LayoutDocEntry::GroupConcepts,
1179 []() { return compileOptions(theTranslator->trConcept(true,false)); })
1180 } },
1181 { "group/memberdecl/modules", { startCb(&LayoutParser::startSectionEntry, LayoutDocEntry::GroupModules,
1182 []() { return compileOptions(theTranslator->trModule(true,false)); })
1183 } },
1184 { "group/memberdecl/namespaces", { startCb(&LayoutParser::startSectionEntry, LayoutDocEntry::GroupNamespaces,
1185 []() { return compileOptions(/* default */ theTranslator->trNamespaces(),
1186 SrcLangExt::Java, theTranslator->trPackages(),
1187 SrcLangExt::Fortran, theTranslator->trModules()); })
1188 } },
1189 { "group/memberdecl/dirs", { startCb(&LayoutParser::startSectionEntry, LayoutDocEntry::GroupDirs,
1190 []() { return compileOptions(theTranslator->trDirectories()); })
1191 } },
1192 { "group/memberdecl/nestedgroups", { startCb(&LayoutParser::startSectionEntry, LayoutDocEntry::GroupNestedGroups,
1193 []() { return compileOptions(theTranslator->trTopics()); })
1194 } },
1195 { "group/memberdecl/files", { startCb(&LayoutParser::startSectionEntry, LayoutDocEntry::GroupFiles,
1196 []() { return compileOptions(theTranslator->trFile(TRUE,FALSE)); })
1197 } },
1198 { "group/memberdecl/defines", { startCb(&LayoutParser::startMemberDeclEntry, MemberListType::DecDefineMembers(),
1199 []() { return compileOptions(theTranslator->trDefines()); })
1200 } },
1201 { "group/memberdecl/typedefs", { startCb(&LayoutParser::startMemberDeclEntry, MemberListType::DecTypedefMembers(),
1202 []() { return compileOptions(theTranslator->trTypedefs()); })
1203 } },
1204 { "group/memberdecl/sequences", { startCb(&LayoutParser::startMemberDeclEntry, MemberListType::DecSequenceMembers(),
1205 []() { return compileOptions(theTranslator->trSequences()); })
1206 } },
1207 { "group/memberdecl/dictionaries", { startCb(&LayoutParser::startMemberDeclEntry, MemberListType::DecDictionaryMembers(),
1208 []() { return compileOptions(theTranslator->trDictionaries()); })
1209 } },
1210 { "group/memberdecl/enums", { startCb(&LayoutParser::startMemberDeclEntry, MemberListType::DecEnumMembers(),
1211 []() { return compileOptions(theTranslator->trEnumerations()); })
1212 } },
1213 { "group/memberdecl/enumvalues", { startCb(&LayoutParser::startMemberDeclEntry, MemberListType::DecEnumValMembers(),
1214 []() { return compileOptions(theTranslator->trEnumerationValues()); })
1215 } },
1216 { "group/memberdecl/functions", { startCb(&LayoutParser::startMemberDeclEntry, MemberListType::DecFuncMembers(),
1217 []() { return compileOptions(/* default */ theTranslator->trFunctions(),
1218 SrcLangExt::Fortran,theTranslator->trSubprograms(),
1219 SrcLangExt::VHDL, theTranslator->trFunctionAndProc()); })
1220 } },
1221 { "group/memberdecl/variables", { startCb(&LayoutParser::startMemberDeclEntry, MemberListType::DecVarMembers(),
1222 []() { return compileOptions(theTranslator->trVariables()); })
1223 } },
1224 { "group/memberdecl/signals", { startCb(&LayoutParser::startMemberDeclEntry, MemberListType::DecSignalMembers(),
1225 []() { return compileOptions(theTranslator->trSignals()); })
1226 } },
1227 { "group/memberdecl/publicslots", { startCb(&LayoutParser::startMemberDeclEntry, MemberListType::DecPubSlotMembers(),
1228 []() { return compileOptions(theTranslator->trPublicSlots()); })
1229 } },
1230 { "group/memberdecl/protectedslots", { startCb(&LayoutParser::startMemberDeclEntry, MemberListType::DecProSlotMembers(),
1231 []() { return compileOptions(theTranslator->trProtectedSlots()); })
1232 } },
1233 { "group/memberdecl/privateslots", { startCb(&LayoutParser::startMemberDeclEntry, MemberListType::DecPriSlotMembers(),
1234 []() { return compileOptions(theTranslator->trPrivateSlots()); })
1235 } },
1236 { "group/memberdecl/events", { startCb(&LayoutParser::startMemberDeclEntry, MemberListType::DecEventMembers(),
1237 []() { return compileOptions(theTranslator->trEvents()); })
1238 } },
1239 { "group/memberdecl/properties", { startCb(&LayoutParser::startMemberDeclEntry, MemberListType::DecPropMembers(),
1240 []() { return compileOptions(theTranslator->trProperties()); })
1241 } },
1242 { "group/memberdecl/friends", { startCb(&LayoutParser::startMemberDeclEntry, MemberListType::DecFriendMembers(),
1243 []() { return compileOptions(theTranslator->trFriends()); })
1244 } },
1246 { "group/memberdef/pagedocs", { startCb(&LayoutParser::startSimpleEntry, LayoutDocEntry::GroupPageDocs) } },
1247 { "group/memberdef/inlineclasses", { startCb(&LayoutParser::startSectionEntry, LayoutDocEntry::GroupInlineClasses,
1248 []() { return compileOptions(/* default */ theTranslator->trClassDocumentation(),
1249 SrcLangExt::Fortran,theTranslator->trTypeDocumentation()); })
1250 } },
1251 { "group/memberdef/defines", { startCb(&LayoutParser::startMemberDefEntry, MemberListType::DocDefineMembers(),
1252 []() { return compileOptions(theTranslator->trDefineDocumentation()); })
1253 } },
1254 { "group/memberdef/typedefs", { startCb(&LayoutParser::startMemberDefEntry, MemberListType::DocTypedefMembers(),
1255 []() { return compileOptions(theTranslator->trTypedefDocumentation()); })
1256 } },
1257 { "group/memberdef/sequences", { startCb(&LayoutParser::startMemberDefEntry, MemberListType::DocSequenceMembers(),
1258 []() { return compileOptions(theTranslator->trSequenceDocumentation()); })
1259 } },
1260 { "group/memberdef/dictionaries", { startCb(&LayoutParser::startMemberDefEntry, MemberListType::DocDictionaryMembers(),
1261 []() { return compileOptions(theTranslator->trDictionaryDocumentation()); })
1262 } },
1263 { "group/memberdef/enums", { startCb(&LayoutParser::startMemberDefEntry, MemberListType::DocEnumMembers(),
1264 []() { return compileOptions(theTranslator->trEnumerationTypeDocumentation()); })
1265 } },
1266 { "group/memberdef/enumvalues", { startCb(&LayoutParser::startMemberDefEntry, MemberListType::DocEnumValMembers(),
1267 []() { return compileOptions(theTranslator->trEnumerationValueDocumentation()); })
1268 } },
1269 { "group/memberdef/functions", { startCb(&LayoutParser::startMemberDefEntry, MemberListType::DocFuncMembers(),
1270 []() { return compileOptions(/* default */ theTranslator->trFunctionDocumentation(),
1271 SrcLangExt::Fortran,theTranslator->trSubprogramDocumentation()); })
1272 } },
1273 { "group/memberdef/variables", { startCb(&LayoutParser::startMemberDefEntry, MemberListType::DocVarMembers(),
1274 []() { return compileOptions(theTranslator->trVariableDocumentation()); })
1275 } },
1276 { "group/memberdef/signals", { startCb(&LayoutParser::startMemberDefEntry, MemberListType::DocSignalMembers(),
1277 []() { return compileOptions(theTranslator->trSignals()); })
1278 } },
1279 { "group/memberdef/publicslots", { startCb(&LayoutParser::startMemberDefEntry, MemberListType::DocPubSlotMembers(),
1280 []() { return compileOptions(theTranslator->trPublicSlots()); })
1281 } },
1282 { "group/memberdef/protectedslots", { startCb(&LayoutParser::startMemberDefEntry, MemberListType::DocProSlotMembers(),
1283 []() { return compileOptions(theTranslator->trProtectedSlots()); })
1284 } },
1285 { "group/memberdef/privateslots", { startCb(&LayoutParser::startMemberDefEntry, MemberListType::DocPriSlotMembers(),
1286 []() { return compileOptions(theTranslator->trPrivateSlots()); })
1287 } },
1288 { "group/memberdef/events", { startCb(&LayoutParser::startMemberDefEntry, MemberListType::DocEventMembers(),
1289 []() { return compileOptions(theTranslator->trEvents()); })
1290 } },
1291 { "group/memberdef/properties", { startCb(&LayoutParser::startMemberDefEntry, MemberListType::DocPropMembers(),
1292 []() { return compileOptions(theTranslator->trProperties()); })
1293 } },
1294 { "group/memberdef/friends", { startCb(&LayoutParser::startMemberDefEntry, MemberListType::DocFriendMembers(),
1295 []() { return compileOptions(theTranslator->trFriends()); })
1296 } },
1297
1298 // module layout handlers
1299 { "module", { startCb(&LayoutParser::startTop,LayoutDocManager::Module,"module/",LayoutNavEntry::Modules),
1301 } },
1302 { "module/briefdescription", { startCb(&LayoutParser::startSimpleEntry, LayoutDocEntry::BriefDesc) } },
1303 { "module/exportedmodules", { startCb(&LayoutParser::startSectionEntry, LayoutDocEntry::ModuleExports,
1304 []() { return compileOptions(theTranslator->trExportedModules()); })
1305 } },
1306 { "module/detaileddescription", { startCb(&LayoutParser::startSectionEntry, LayoutDocEntry::DetailedDesc,
1307 []() { return compileOptions(theTranslator->trDetailedDescription()); })
1308 } },
1309 { "module/authorsection", { startCb(&LayoutParser::startSimpleEntry, LayoutDocEntry::AuthorSection) } },
1311 { "module/memberdecl/concepts", { startCb(&LayoutParser::startSectionEntry, LayoutDocEntry::ModuleConcepts,
1312 []() { return compileOptions(theTranslator->trConcept(true,false)); })
1313 } },
1314 { "module/memberdecl/classes", { startCb(&LayoutParser::startSectionEntry, LayoutDocEntry::ModuleClasses,
1315 []() { return compileOptions(theTranslator->trCompounds()); })
1316 } },
1317 { "module/memberdecl/enums", { startCb(&LayoutParser::startMemberDeclEntry, MemberListType::DecEnumMembers(),
1318 []() { return compileOptions(theTranslator->trEnumerations()); })
1319 } },
1320 { "module/memberdecl/typedefs", { startCb(&LayoutParser::startMemberDeclEntry, MemberListType::DecTypedefMembers(),
1321 []() { return compileOptions(theTranslator->trTypedefs()); })
1322 } },
1323 { "module/memberdecl/functions", { startCb(&LayoutParser::startMemberDeclEntry, MemberListType::DecFuncMembers(),
1324 []() { return compileOptions(theTranslator->trFunctions()); })
1325 } },
1326 { "module/memberdecl/variables", { startCb(&LayoutParser::startMemberDeclEntry, MemberListType::DecVarMembers(),
1327 []() { return compileOptions(theTranslator->trVariables()); })
1328 } },
1329 { "module/memberdecl/membergroups", { startCb(&LayoutParser::startSimpleEntry, LayoutDocEntry::MemberGroups) } },
1330 { "module/memberdecl/files", { startCb(&LayoutParser::startSectionEntry, LayoutDocEntry::ModuleUsedFiles,
1331 []() { return compileOptions(theTranslator->trFile(TRUE,FALSE)); })
1332 } },
1333
1334 // directory layout handlers
1335 { "directory", { startCb(&LayoutParser::startTop,LayoutDocManager::Directory,"directory/",LayoutNavEntry::None),
1337 } },
1338 { "directory/briefdescription", { startCb(&LayoutParser::startSimpleEntry, LayoutDocEntry::BriefDesc) } },
1339 { "directory/detaileddescription", { startCb(&LayoutParser::startSectionEntry, LayoutDocEntry::DetailedDesc,
1340 []() { return compileOptions(theTranslator->trDetailedDescription()); })
1341 } },
1342 { "directory/directorygraph", { startCb(&LayoutParser::startSimpleEntry, LayoutDocEntry::DirGraph) } },
1343 { "directory/memberdecl", { startCb(&LayoutParser::startMemberDecl), endCb(&LayoutParser::endMemberDecl) } },
1344 { "directory/memberdecl/dirs", { startCb(&LayoutParser::startSimpleEntry, LayoutDocEntry::DirSubDirs) } },
1345 { "directory/memberdecl/files", { startCb(&LayoutParser::startSimpleEntry, LayoutDocEntry::DirFiles) } },
1346};
1347
1348} // namespace
1349
1350void LayoutParser::startElement( const std::string &name, const XMLHandlers::Attributes& attrib )
1351{
1352 //printf("startElement [%s]::[%s]\n",qPrint(m_scope),qPrint(name));
1353 auto it = g_elementHandlers.find(m_scope.str()+name);
1354 if (it!=g_elementHandlers.end())
1355 {
1356 it->second.startCb(*this,attrib);
1357 }
1358 else
1359 {
1360 std::string fileName = m_locator->fileName();
1361 warn(fileName.c_str(),m_locator->lineNr(),"Unexpected start tag '%s' found in scope='%s'!",
1362 qPrint(name),qPrint(m_scope));
1363 }
1364}
1365
1366void LayoutParser::endElement( const std::string &name )
1367{
1368 //printf("endElement [%s]::[%s]\n",qPrint(m_scope),qPrint(name));
1369 auto it=g_elementHandlers.end();
1370
1371 if (!m_scope.isEmpty() && m_scope.right(name.length()+1)==name+"/")
1372 { // element ends current scope
1373 it = g_elementHandlers.find(m_scope.left(m_scope.length()-1).str());
1374 }
1375 else // continue with current scope
1376 {
1377 it = g_elementHandlers.find(m_scope.str()+name);
1378 }
1379 if (it!=g_elementHandlers.end())
1380 {
1381 it->second.endCb(*this);
1382 }
1383}
1384
1385//---------------------------------------------------------------------------------
1386
1388
1389//---------------------------------------------------------------------------------
1390
1392{
1393 public:
1394 std::array<LayoutDocEntryList,LayoutDocManager::NrParts> docEntries;
1396};
1397
1399{
1400}
1401
1405
1407{
1408 LayoutParser &layoutParser = LayoutParser::instance();
1409 XMLHandlers handlers;
1410 handlers.startElement = [&layoutParser](const std::string &name,const XMLHandlers::Attributes &attrs) { layoutParser.startElement(name,attrs); };
1411 handlers.endElement = [&layoutParser](const std::string &name) { layoutParser.endElement(name); };
1412 handlers.error = [&layoutParser](const std::string &fileName,int lineNr,const std::string &msg) { layoutParser.error(fileName,lineNr,msg); };
1413 XMLParser parser(handlers);
1414 layoutParser.setDocumentLocator(&parser);
1415 constexpr auto layoutFile = "layout_default.xml";
1416 QCString layout_default = ResourceMgr::instance().getAsString(layoutFile);
1417 parser.parse(layoutFile,layout_default.data(),Debug::isFlagSet(Debug::Lex_xml),
1418 [&]() { DebugLex::print(Debug::Lex_xml,"Entering","libxml/xml.l",layoutFile); },
1419 [&]() { DebugLex::print(Debug::Lex_xml,"Finished", "libxml/xml.l",layoutFile); }
1420 );
1421}
1422
1424{
1425 static LayoutDocManager theInstance;
1426 return theInstance;
1427}
1428
1430{
1431 return d->docEntries[static_cast<int>(part)];
1432}
1433
1435{
1436 return &d->rootNav;
1437}
1438
1440 const QCString &tl,const QCString &intro)
1441{
1442 if (parent==nullptr) parent = &d->rootNav;
1443 auto ptr = std::make_unique<LayoutNavEntry>(parent,k,vs,bf,tl,intro);
1444 auto child = ptr.get();
1445 parent->addChild(std::move(ptr));
1446 return child;
1447}
1448
1450{
1451 d->docEntries[static_cast<int>(p)].push_back(std::move(e));
1452}
1453
1455{
1456 d->docEntries[static_cast<int>(p)].clear();
1457}
1458
1459void LayoutDocManager::parse(const QCString &fileName, const char *data)
1460{
1461 LayoutParser &layoutParser = LayoutParser::instance();
1462 XMLHandlers handlers;
1463 handlers.startElement = [&layoutParser](const std::string &name,const XMLHandlers::Attributes &attrs) { layoutParser.startElement(name,attrs); };
1464 handlers.endElement = [&layoutParser](const std::string &name) { layoutParser.endElement(name); };
1465 handlers.error = [&layoutParser](const std::string &fn,int lineNr,const std::string &msg) { layoutParser.error(fn,lineNr,msg); };
1466 XMLParser parser(handlers);
1467 layoutParser.setDocumentLocator(&parser);
1468 parser.parse(fileName.data(),
1469 data ? data : fileToString(fileName).data(),
1471 [&]() { DebugLex::print(Debug::Lex_xml,"Entering","libxml/xml.l",qPrint(fileName)); },
1472 [&]() { DebugLex::print(Debug::Lex_xml,"Finished", "libxml/xml.l",qPrint(fileName)); },
1474 );
1475}
1476
1477//---------------------------------------------------------------------------------
1478
1480{
1481 std::ofstream f;
1482 if (openOutputFile(fileName,f))
1483 {
1484 TextStream t(&f);
1485 QCString layout_default = ResourceMgr::instance().getAsString("layout_default.xml");
1486 t << substitute(layout_default,"$doxygenversion",getDoxygenVersion());
1487 }
1488 else
1489 {
1490 err("Failed to open file %s for writing!\n",qPrint(fileName));
1491 return;
1492 }
1493 f.close();
1494}
1495
1496//----------------------------------------------------------------------------------
1497
1498// Convert input to a title.
1499// The format of input can be a simple title "A title" or in case there are different
1500// titles for some programming languages they can take the following form:
1501// "A title|16=Another title|8=Yet Another title"
1502// where the number is a value of SrcLangExt in decimal notation (i.e. 16=Java, 8=IDL).
1504{
1505 int s=0,e=input.find('|');
1506 if (e==-1) return input; // simple title case
1507 int e1=e;
1508 while (e!=-1) // look for 'number=title' pattern separated by '|'
1509 {
1510 s=e+1;
1511 e=input.find('|',s);
1512 int i=input.find('=',s);
1513 assert(i>s);
1514 SrcLangExt key= static_cast<SrcLangExt>(input.mid(s,i-s).toUInt());
1515 if (key==lang) // found matching key
1516 {
1517 if (e==-1) e=static_cast<int>(input.length());
1518 return input.mid(i+1,e-i-1);
1519 }
1520 }
1521 return input.left(e1); // fallback, no explicit language key found
1522}
1523
1524//----------------------------------------------------------------------------------
1525
1530
1531//----------------------------------------------------------------------------------
1532
1537
1542
1543//----------------------------------------------------------------------------------
1544
1549
1550
1551
1552
@ Lex_xml
Definition debug.h:69
static bool isFlagSet(const DebugMask mask)
Definition debug.cpp:135
static void print(Debug::DebugMask mask, const char *state, const char *lexName, const char *fileName)
Definition debug.cpp:159
Class representing the abstract syntax tree of a documentation block.
Definition docnode.h:1460
Node representing a reference to some item.
Definition docnode.h:772
QCString anchor() const
Definition docnode.h:779
QCString file() const
Definition docnode.h:776
QCString ref() const
Definition docnode.h:778
std::array< LayoutDocEntryList, LayoutDocManager::NrParts > docEntries
Definition layout.cpp:1394
LayoutNavEntry rootNav
Definition layout.cpp:1395
std::unique_ptr< Private > d
Definition layout.h:271
LayoutNavEntry * createChildNavEntry(LayoutNavEntry *root, LayoutNavEntry::Kind k, bool vs, const QCString &bf, const QCString &tl, const QCString &intro)
Definition layout.cpp:1439
void clear(LayoutPart p)
Definition layout.cpp:1454
static LayoutDocManager & instance()
Returns a reference to this singleton.
Definition layout.cpp:1423
void parse(const QCString &fileName, const char *data=nullptr)
Parses a user provided layout.
Definition layout.cpp:1459
friend class LayoutParser
Definition layout.h:272
void addEntry(LayoutPart p, LayoutDocEntryPtr &&e)
Definition layout.cpp:1449
LayoutNavEntry * rootNavEntry() const
returns the (invisible) root of the navigation tree.
Definition layout.cpp:1434
const LayoutDocEntryList & docEntries(LayoutPart part) const
Returns the list of LayoutDocEntry's in representation order for a given page identified by part.
Definition layout.cpp:1429
void startMemberDef(const XMLHandlers::Attributes &attrib)
Definition layout.cpp:640
QCString m_scope
Definition layout.cpp:704
void startNavEntry(const XMLHandlers::Attributes &attrib)
Definition layout.cpp:282
void startSimpleEntry(LayoutDocEntry::Kind k, const XMLHandlers::Attributes &attrib)
Definition layout.cpp:204
void setDocumentLocator(const XMLLocator *locator)
Definition layout.cpp:193
static int m_userGroupCount
Definition layout.cpp:709
void startMemberDecl(const XMLHandlers::Attributes &attrib)
Definition layout.cpp:672
void endMemberDecl()
Definition layout.cpp:682
void error(const std::string &fileName, int lineNr, const std::string &msg)
Definition layout.cpp:197
void recurseNavEntryChildren(LayoutNavEntry &lne)
Definition layout.cpp:608
static LayoutParser & instance()
Definition layout.cpp:186
const XMLLocator * m_locator
Definition layout.cpp:710
void startLayout(const XMLHandlers::Attributes &)
Definition layout.cpp:257
void startTop(const XMLHandlers::Attributes &attrib, LayoutDocManager::LayoutPart part, const QCString &scope, LayoutNavEntry::Kind nav)
Definition layout.cpp:618
void startMemberDefEntry(const XMLHandlers::Attributes &attrib, MemberListType type, const QCString &title, const QCString &)
Definition layout.cpp:244
void startSectionEntry(LayoutDocEntry::Kind k, const XMLHandlers::Attributes &attrib, const QCString &title)
Definition layout.cpp:215
void endMemberDef()
Definition layout.cpp:650
bool m_invalidEntry
Definition layout.cpp:707
void startMemberDeclEntry(const XMLHandlers::Attributes &attrib, MemberListType type, const QCString &title, const QCString &subscript)
Definition layout.cpp:230
void endNavIndex()
Definition layout.cpp:271
bool m_visible
Definition layout.cpp:708
void startNavIndex(const XMLHandlers::Attributes &)
Definition layout.cpp:261
void endElement(const std::string &name)
Definition layout.cpp:1366
void endTop()
Definition layout.cpp:634
LayoutNavEntry * m_rootNav
Definition layout.cpp:706
void startElement(const std::string &name, const XMLHandlers::Attributes &attrib)
Definition layout.cpp:1350
LayoutDocManager::LayoutPart m_part
Definition layout.cpp:705
void endNavEntry()
Definition layout.cpp:601
Wrapper class for the MemberListType type.
Definition types.h:184
This is an alternative implementation of QCString.
Definition qcstring.h:101
int find(char c, int index=0, bool cs=TRUE) const
Definition qcstring.cpp:43
size_t length() const
Returns the length of the string, not counting the 0-terminator.
Definition qcstring.h:153
QCString mid(size_t index, size_t len=static_cast< size_t >(-1)) const
Definition qcstring.h:226
QCString lower() const
Definition qcstring.h:234
char & at(size_t i)
Returns a reference to the character at index i.
Definition qcstring.h:578
bool isEmpty() const
Returns TRUE iff the string is empty.
Definition qcstring.h:150
QCString stripWhiteSpace() const
returns a copy of this string with leading and trailing whitespace removed
Definition qcstring.h:245
QCString & setNum(short n)
Definition qcstring.h:444
QCString & sprintf(const char *format,...)
Definition qcstring.cpp:29
const char * data() const
Returns a pointer to the contents of the string in the form of a 0-terminated C string.
Definition qcstring.h:159
QCString left(size_t len) const
Definition qcstring.h:214
static ResourceMgr & instance()
Returns the one and only instance of this class.
QCString getAsString(const QCString &name) const
Gets the resource data as a C string.
Text streaming class that buffers data.
Definition textstream.h:36
Event handlers that can installed by the client and called while parsing a XML document.
Definition xml.h:27
std::unordered_map< std::string, std::string > Attributes
Definition xml.h:29
std::function< EndElementType > endElement
handler invoked when a closing tag has been found
Definition xml.h:40
std::function< StartElementType > startElement
handler invoked when an opening tag has been found
Definition xml.h:39
static std::string value(const Attributes &attrib, const std::string &key)
Definition xml.h:44
std::function< ErrorType > error
handler invoked when the parser encounters an error
Definition xml.h:42
void parse(const char *fileName, const char *inputString, bool debugEnabled, std::function< void()> debugStart, std::function< void()> debugEnd, std::function< Transcode > transcoder=[](std::string &s, const char *){ return true;})
Definition xml.l:447
#define Config_getBool(name)
Definition config.h:33
#define Config_getString(name)
Definition config.h:32
constexpr DocNodeVariant * parent(DocNodeVariant *n)
returns the parent node of a given node n or nullptr if the node has no parent.
Definition docnode.h:1324
IDocParserPtr createDocParser()
factory function to create a parser
Definition docparser.cpp:54
IDocNodeASTPtr createRef(IDocParser &parserIntf, const QCString &target, const QCString &context, const QCString &srcFile, int srcLine)
Translator * theTranslator
Definition language.cpp:71
static bool elemIsVisible(const XMLHandlers::Attributes &attrib, bool defVal=TRUE)
Definition layout.cpp:81
static bool parentIsVisible(LayoutNavEntry *parent)
Definition layout.cpp:115
void writeDefaultLayoutFile(const QCString &fileName)
Definition layout.cpp:1479
QCString compileOptions(const QCString &def)
Definition layout.cpp:37
QCString extractLanguageSpecificTitle(const QCString &input, SrcLangExt lang)
Definition layout.cpp:1503
std::unique_ptr< LayoutDocEntry > LayoutDocEntryPtr
Definition layout.h:224
std::vector< LayoutDocEntryPtr > LayoutDocEntryList
Definition layout.h:225
void msg(const char *fmt,...)
Definition message.cpp:98
#define warn(file, line, fmt,...)
Definition message.h:59
#define err(fmt,...)
Definition message.h:84
static auto startCb(void(LayoutParser::*fn)(Args...))
Definition layout.cpp:727
static const std::map< std::string, ElementCallbacks > g_elementHandlers
Definition layout.cpp:783
static auto endCb(void(LayoutParser::*fn)())
Definition layout.cpp:778
QCString substitute(const QCString &s, const QCString &src, const QCString &dst)
substitute all occurrences of src in s by dst
Definition qcstring.cpp:477
const char * qPrint(const char *s)
Definition qcstring.h:672
#define TRUE
Definition qcstring.h:37
#define FALSE
Definition qcstring.h:34
Kind
Definition layout.h:68
QCString title(SrcLangExt lang) const
Definition layout.cpp:1533
QCString subtitle(SrcLangExt lang) const
Definition layout.cpp:1538
QCString m_subscript
Definition layout.h:120
QCString m_title
Definition layout.h:119
QCString m_title
Definition layout.h:133
QCString title(SrcLangExt lang) const
Definition layout.cpp:1545
QCString title(SrcLangExt lang) const
Definition layout.cpp:1526
QCString m_title
Definition layout.h:104
Represents of a piece of a documentation page without configurable parts.
Definition layout.h:88
bool visible() const
Definition layout.h:92
Base class for the layout of a navigation item at the top of the HTML pages.
Definition layout.h:140
bool visible()
Definition layout.h:203
LayoutNavEntryList m_children
Definition layout.h:220
QCString url() const
Definition layout.cpp:140
const LayoutNavEntryList & children() const
Definition layout.h:209
QCString baseFile() const
Definition layout.h:198
LayoutNavEntry * find(LayoutNavEntry::Kind k, const QCString &file=QCString()) const
Definition layout.cpp:122
Kind kind() const
Definition layout.h:197
Kind
Definition layout.h:177
LayoutNavEntry(LayoutNavEntry *parent, Kind k, bool vs, const QCString &bf, const QCString &tl, const QCString &intro)
Definition layout.h:193
std::function< void(LayoutParser &, const XMLHandlers::Attributes &)> StartCallback
Definition layout.cpp:719
std::function< void(LayoutParser &)> EndCallback
Definition layout.cpp:720
This file contains a number of basic enums and types.
SrcLangExt
Language as given by extension.
Definition types.h:42
@ Fortran
Definition types.h:53
@ Slice
Definition types.h:59
QCString externalRef(const QCString &relPath, const QCString &ref, bool href)
Definition util.cpp:6066
bool transcodeCharacterStringToUTF8(std::string &input, const char *inputEncoding)
Definition util.cpp:1376
bool openOutputFile(const QCString &outFile, std::ofstream &f)
Definition util.cpp:6624
bool found
Definition util.cpp:984
QCString fileToString(const QCString &name, bool filter, bool isSourceCode)
Definition util.cpp:1414
void addHtmlExtensionIfMissing(QCString &fName)
Definition util.cpp:5243
A bunch of utility functions.