1 /******************************************************************************
6 * Copyright (C) 1997-2015 by Dimitri van Heesch.
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.
14 * Documents produced by Doxygen are derivative works derived from the
15 * input used in their production; they are not affected by this license.
22 #include "vhdldocgen.h"
32 #include <qfileinfo.h>
33 #include <qtextstream.h>
35 static const char layout_default[] =
36 #include "layout_default.xml.h"
39 #define ADD_OPTION(langId,text) "|"+QCString().setNum(langId)+"="+text
41 #define COMPILE_FOR_1_OPTION(def,langId1,text1) \
42 def+ADD_OPTION(langId1,text1)
44 #define COMPILE_FOR_2_OPTIONS(def,langId1,text1,langId2,text2) \
45 COMPILE_FOR_1_OPTION(def,langId1,text1)+ADD_OPTION(langId2,text2)
47 #define COMPILE_FOR_3_OPTIONS(def,langId1,text1,langId2,text2,langId3,text3) \
48 COMPILE_FOR_2_OPTIONS(def,langId1,text1,langId2,text2)+ADD_OPTION(langId3,text3)
50 #define COMPILE_FOR_4_OPTIONS(def,langId1,text1,langId2,text2,langId3,text3,langId4,text4) \
51 COMPILE_FOR_3_OPTIONS(def,langId1,text1,langId2,text2,langId3,text3)+ADD_OPTION(langId4,text4)
53 static bool elemIsVisible(const QXmlAttributes &attrib,bool defVal=TRUE)
55 QCString visible = attrib.value("visible").utf8();
56 if (visible.isEmpty()) return defVal;
57 if (visible.at(0)=='$' && visible.length()>1)
59 QCString id = visible.mid(1);
60 const ConfigValues::Info *opt = ConfigValues::instance().get(id);
61 if (opt && opt->type==ConfigValues::Info::Bool)
63 return ConfigValues::instance().*((ConfigValues::InfoBool*)opt)->item;
67 err("found unsupported value %s for visible attribute in layout file\n",
71 return visible!="no" && visible!="0";
74 //---------------------------------------------------------------------------------
76 LayoutNavEntry *LayoutNavEntry::find(LayoutNavEntry::Kind kind,
77 const char *file) const
79 LayoutNavEntry *result=0;
80 QListIterator<LayoutNavEntry> li(m_children);
81 LayoutNavEntry *entry;
82 for (li.toFirst();(entry=li.current());++li)
84 // depth first search, needed to find the entry furthest from the
85 // root in case an entry is in the tree twice
86 result = entry->find(kind,file);
87 if (result) return result;
88 if (entry->kind()==kind && (file==0 || entry->baseFile()==file))
96 QCString LayoutNavEntry::url() const
98 QCString url = baseFile().stripWhiteSpace();
99 if ((kind()!=LayoutNavEntry::User && kind()!=LayoutNavEntry::UserGroup) ||
100 (kind()==LayoutNavEntry::UserGroup && url.left(9)=="usergroup"))
102 url+=Doxygen::htmlFileExtension;
104 else if (url.left(5)=="@ref " || url.left(5)=="\\ref ")
109 if (resolveLink(0,url.mid(5).stripWhiteSpace(),TRUE,&d,anchor))
111 if (d && d->isLinkable())
113 url=d->getOutputFileBase()+Doxygen::htmlFileExtension;
114 if (!anchor.isEmpty())
123 msg("explicit link request to '%s' in layout file '%s' could not be resolved\n",qPrint(url.mid(5)),qPrint(Config_getString(LAYOUT_FILE)));
126 //printf("LayoutNavEntry::url()=%s\n",url.data());
130 //---------------------------------------------------------------------------------
132 class LayoutParser : public QXmlDefaultHandler
135 class StartElementHandler
137 typedef void (LayoutParser::*Handler)(const QXmlAttributes &attrib);
139 StartElementHandler(LayoutParser *parent, Handler h)
140 : m_parent(parent), m_handler(h) {}
141 virtual ~StartElementHandler() {}
142 virtual void operator()(const QXmlAttributes &attrib)
144 (m_parent->*m_handler)(attrib);
147 StartElementHandler() : m_parent(0), m_handler(0) {}
149 LayoutParser *m_parent;
153 class StartElementHandlerKind : public StartElementHandler
155 typedef void (LayoutParser::*Handler)(LayoutDocEntry::Kind kind,
156 const QXmlAttributes &attrib);
158 StartElementHandlerKind(LayoutParser *parent, LayoutDocEntry::Kind k,Handler h)
159 : m_parent(parent), m_kind(k), m_handler(h) {}
160 void operator()(const QXmlAttributes &attrib)
162 (m_parent->*m_handler)(m_kind,attrib);
165 LayoutParser *m_parent;
166 LayoutDocEntry::Kind m_kind;
170 class StartElementHandlerSection : public StartElementHandler
172 typedef void (LayoutParser::*Handler)(LayoutDocEntry::Kind kind,
173 const QXmlAttributes &attrib,
174 const QCString &title);
176 StartElementHandlerSection(LayoutParser *parent, LayoutDocEntry::Kind k,Handler h,
177 const QCString &title)
178 : m_parent(parent), m_kind(k), m_handler(h), m_title(title) {}
179 void operator()(const QXmlAttributes &attrib)
181 (m_parent->*m_handler)(m_kind,attrib,m_title);
184 LayoutParser *m_parent;
185 LayoutDocEntry::Kind m_kind;
190 class StartElementHandlerMember : public StartElementHandler
192 typedef void (LayoutParser::*Handler)(const QXmlAttributes &attrib,
194 const QCString &title,
195 const QCString &subtitle);
197 StartElementHandlerMember(LayoutParser *parent,
201 const QCString &ss = QCString()
203 : m_parent(parent), m_handler(h), m_type(type),
204 m_title(tl), m_subscript(ss) {}
205 void operator()(const QXmlAttributes &attrib)
207 (m_parent->*m_handler)(attrib,m_type,m_title,m_subscript);
210 LayoutParser *m_parent;
212 MemberListType m_type;
214 QCString m_subscript;
217 class StartElementHandlerNavEntry : public StartElementHandler
219 typedef void (LayoutParser::*Handler)(LayoutNavEntry::Kind kind,
220 const QXmlAttributes &attrib,
221 const QCString &title);
223 StartElementHandlerNavEntry(LayoutParser *parent,
224 LayoutNavEntry::Kind kind,
228 : m_parent(parent), m_kind(kind), m_handler(h), m_title(tl) {}
229 void operator()(const QXmlAttributes &attrib)
231 (m_parent->*m_handler)(m_kind,attrib,m_title);
234 LayoutParser *m_parent;
235 LayoutNavEntry::Kind m_kind;
240 class EndElementHandler
242 typedef void (LayoutParser::*Handler)();
244 EndElementHandler(LayoutParser *parent, Handler h) : m_parent(parent), m_handler(h) {}
245 void operator()() { (m_parent->*m_handler)(); }
247 LayoutParser *m_parent;
253 static LayoutParser &instance()
255 static LayoutParser *theInstance = new LayoutParser;
260 m_sHandler.setAutoDelete(TRUE);
261 m_eHandler.setAutoDelete(TRUE);
262 m_part = -1; // invalid
265 //bool fortranOpt = Config_getBool(OPTIMIZE_FOR_FORTRAN);
266 //bool vhdlOpt = Config_getBool(OPTIMIZE_OUTPUT_VHDL);
267 //bool javaOpt = Config_getBool(OPTIMIZE_OUTPUT_JAVA);
269 // start & end handlers
270 m_sHandler.insert("doxygenlayout",
271 new StartElementHandler(this,&LayoutParser::startLayout));
272 m_eHandler.insert("doxygenlayout",
273 new EndElementHandler(this,&LayoutParser::endLayout));
275 // class layout handlers
276 m_sHandler.insert("navindex",
277 new StartElementHandler(this,&LayoutParser::startNavIndex));
278 m_sHandler.insert("navindex/tab",
279 new StartElementHandler(this,&LayoutParser::startNavEntry));
280 m_eHandler.insert("navindex/tab",
281 new EndElementHandler(this,&LayoutParser::endNavEntry));
282 m_eHandler.insert("navindex",
283 new EndElementHandler(this,&LayoutParser::endNavIndex));
285 // class layout handlers
286 m_sHandler.insert("class",
287 new StartElementHandler(this,&LayoutParser::startClass));
288 m_sHandler.insert("class/briefdescription",
289 new StartElementHandlerKind(this,LayoutDocEntry::BriefDesc,&LayoutParser::startSimpleEntry));
290 m_sHandler.insert("class/detaileddescription",
291 new StartElementHandlerSection(this,LayoutDocEntry::DetailedDesc,&LayoutParser::startSectionEntry,
292 theTranslator->trDetailedDescription()));
293 m_sHandler.insert("class/authorsection",
294 new StartElementHandlerKind(this,LayoutDocEntry::AuthorSection,&LayoutParser::startSimpleEntry));
295 m_sHandler.insert("class/includes",
296 new StartElementHandlerKind(this,LayoutDocEntry::ClassIncludes,&LayoutParser::startSimpleEntry));
297 m_sHandler.insert("class/inheritancegraph",
298 new StartElementHandlerKind(this,LayoutDocEntry::ClassInheritanceGraph,&LayoutParser::startSimpleEntry));
299 m_sHandler.insert("class/collaborationgraph",
300 new StartElementHandlerKind(this,LayoutDocEntry::ClassCollaborationGraph,&LayoutParser::startSimpleEntry));
301 m_sHandler.insert("class/allmemberslink",
302 new StartElementHandlerKind(this,LayoutDocEntry::ClassAllMembersLink,&LayoutParser::startSimpleEntry));
303 m_sHandler.insert("class/usedfiles",
304 new StartElementHandlerKind(this,LayoutDocEntry::ClassUsedFiles,&LayoutParser::startSimpleEntry));
305 m_sHandler.insert("class/memberdecl",
306 new StartElementHandler(this,&LayoutParser::startMemberDecl));
307 m_sHandler.insert("class/memberdecl/membergroups",
308 new StartElementHandlerKind(this,LayoutDocEntry::MemberGroups,&LayoutParser::startSimpleEntry));
309 m_sHandler.insert("class/memberdecl/nestedclasses",
310 new StartElementHandlerSection(this,LayoutDocEntry::ClassNestedClasses,&LayoutParser::startSectionEntry,
311 COMPILE_FOR_2_OPTIONS(
312 theTranslator->trCompounds(),
313 SrcLangExt_VHDL,VhdlDocGen::trVhdlType(VhdlDocGen::ENTITY,FALSE),
314 SrcLangExt_Fortran,theTranslator->trDataTypes()
316 m_sHandler.insert("class/memberdecl/services",
317 new StartElementHandlerMember(this,&LayoutParser::startMemberDeclEntry,
318 MemberListType_services,theTranslator->trServices()));
319 m_sHandler.insert("class/memberdecl/interfaces",
320 new StartElementHandlerMember(this,&LayoutParser::startMemberDeclEntry,
321 MemberListType_interfaces,theTranslator->trInterfaces()));
322 m_sHandler.insert("class/memberdecl/publictypes",
323 new StartElementHandlerMember(this,&LayoutParser::startMemberDeclEntry,
324 MemberListType_pubTypes,theTranslator->trPublicTypes()));
325 m_sHandler.insert("class/memberdecl/publicslots",
326 new StartElementHandlerMember(this,&LayoutParser::startMemberDeclEntry,
327 MemberListType_pubSlots,theTranslator->trPublicSlots()));
328 m_sHandler.insert("class/memberdecl/signals",
329 new StartElementHandlerMember(this,&LayoutParser::startMemberDeclEntry,
330 MemberListType_signals,theTranslator->trSignals()));
331 m_sHandler.insert("class/memberdecl/publicmethods",
332 new StartElementHandlerMember(this,&LayoutParser::startMemberDeclEntry,
333 MemberListType_pubMethods,
334 COMPILE_FOR_1_OPTION(
335 theTranslator->trPublicMembers(),
336 SrcLangExt_ObjC,theTranslator->trInstanceMethods()
338 m_sHandler.insert("class/memberdecl/publicstaticmethods",
339 new StartElementHandlerMember(this,&LayoutParser::startMemberDeclEntry,
340 MemberListType_pubStaticMethods,
341 COMPILE_FOR_1_OPTION(
342 theTranslator->trStaticPublicMembers(),
343 SrcLangExt_ObjC,theTranslator->trClassMethods()
345 m_sHandler.insert("class/memberdecl/publicattributes",
346 new StartElementHandlerMember(this,&LayoutParser::startMemberDeclEntry,
347 MemberListType_pubAttribs,theTranslator->trPublicAttribs()));
348 m_sHandler.insert("class/memberdecl/publicstaticattributes",
349 new StartElementHandlerMember(this,&LayoutParser::startMemberDeclEntry,
350 MemberListType_pubStaticAttribs,theTranslator->trStaticPublicAttribs()));
351 m_sHandler.insert("class/memberdecl/protectedtypes",
352 new StartElementHandlerMember(this,&LayoutParser::startMemberDeclEntry,
353 MemberListType_proTypes,theTranslator->trProtectedTypes()));
354 m_sHandler.insert("class/memberdecl/protectedslots",
355 new StartElementHandlerMember(this,&LayoutParser::startMemberDeclEntry,
356 MemberListType_proSlots,theTranslator->trProtectedSlots()));
357 m_sHandler.insert("class/memberdecl/protectedmethods",
358 new StartElementHandlerMember(this,&LayoutParser::startMemberDeclEntry,
359 MemberListType_proMethods,theTranslator->trProtectedMembers()));
360 m_sHandler.insert("class/memberdecl/protectedstaticmethods",
361 new StartElementHandlerMember(this,&LayoutParser::startMemberDeclEntry,
362 MemberListType_proStaticMethods,theTranslator->trStaticProtectedMembers()));
363 m_sHandler.insert("class/memberdecl/protectedattributes",
364 new StartElementHandlerMember(this,&LayoutParser::startMemberDeclEntry,
365 MemberListType_proAttribs,theTranslator->trProtectedAttribs()));
366 m_sHandler.insert("class/memberdecl/protectedstaticattributes",
367 new StartElementHandlerMember(this,&LayoutParser::startMemberDeclEntry,
368 MemberListType_proStaticAttribs,theTranslator->trStaticProtectedAttribs()));
369 m_sHandler.insert("class/memberdecl/packagetypes",
370 new StartElementHandlerMember(this,&LayoutParser::startMemberDeclEntry,
371 MemberListType_pacTypes,theTranslator->trPackageTypes()));
372 m_sHandler.insert("class/memberdecl/packagemethods",
373 new StartElementHandlerMember(this,&LayoutParser::startMemberDeclEntry,
374 MemberListType_pacMethods,theTranslator->trPackageMembers()));
375 m_sHandler.insert("class/memberdecl/packagestaticmethods",
376 new StartElementHandlerMember(this,&LayoutParser::startMemberDeclEntry,
377 MemberListType_pacStaticMethods,theTranslator->trStaticPackageMembers()));
378 m_sHandler.insert("class/memberdecl/packageattributes",
379 new StartElementHandlerMember(this,&LayoutParser::startMemberDeclEntry,
380 MemberListType_pacAttribs,theTranslator->trPackageAttribs()));
381 m_sHandler.insert("class/memberdecl/packagestaticattributes",
382 new StartElementHandlerMember(this,&LayoutParser::startMemberDeclEntry,
383 MemberListType_pacStaticAttribs,theTranslator->trStaticPackageAttribs()));
384 m_sHandler.insert("class/memberdecl/properties",
385 new StartElementHandlerMember(this,&LayoutParser::startMemberDeclEntry,
386 MemberListType_properties,theTranslator->trProperties()));
387 m_sHandler.insert("class/memberdecl/events",
388 new StartElementHandlerMember(this,&LayoutParser::startMemberDeclEntry,
389 MemberListType_events,theTranslator->trEvents()));
390 m_sHandler.insert("class/memberdecl/privatetypes",
391 new StartElementHandlerMember(this,&LayoutParser::startMemberDeclEntry,
392 MemberListType_priTypes,theTranslator->trPrivateTypes()));
393 m_sHandler.insert("class/memberdecl/privateslots",
394 new StartElementHandlerMember(this,&LayoutParser::startMemberDeclEntry,
395 MemberListType_priSlots,theTranslator->trPrivateSlots()));
396 m_sHandler.insert("class/memberdecl/privatemethods",
397 new StartElementHandlerMember(this,&LayoutParser::startMemberDeclEntry,
398 MemberListType_priMethods,theTranslator->trPrivateMembers()));
399 m_sHandler.insert("class/memberdecl/privatestaticmethods",
400 new StartElementHandlerMember(this,&LayoutParser::startMemberDeclEntry,
401 MemberListType_priStaticMethods,theTranslator->trStaticPrivateMembers()));
402 m_sHandler.insert("class/memberdecl/privateattributes",
403 new StartElementHandlerMember(this,&LayoutParser::startMemberDeclEntry,
404 MemberListType_priAttribs,theTranslator->trPrivateAttribs()));
405 m_sHandler.insert("class/memberdecl/privatestaticattributes",
406 new StartElementHandlerMember(this,&LayoutParser::startMemberDeclEntry,
407 MemberListType_priStaticAttribs,theTranslator->trStaticPrivateAttribs()));
408 m_sHandler.insert("class/memberdecl/friends",
409 new StartElementHandlerMember(this,&LayoutParser::startMemberDeclEntry,
410 MemberListType_friends,theTranslator->trFriends()));
411 m_sHandler.insert("class/memberdecl/related",
412 new StartElementHandlerMember(this,&LayoutParser::startMemberDeclEntry,
413 MemberListType_related,theTranslator->trRelatedFunctions(),
414 theTranslator->trRelatedSubscript()));
415 m_eHandler.insert("class/memberdecl",
416 new EndElementHandler(this,&LayoutParser::endMemberDecl));
417 m_sHandler.insert("class/memberdef",
418 new StartElementHandler(this,&LayoutParser::startMemberDef));
419 m_sHandler.insert("class/memberdef/inlineclasses",
420 new StartElementHandlerSection(this,LayoutDocEntry::ClassInlineClasses,&LayoutParser::startSectionEntry,
421 COMPILE_FOR_1_OPTION(
422 theTranslator->trClassDocumentation(),
423 SrcLangExt_Fortran,theTranslator->trTypeDocumentation()
425 m_sHandler.insert("class/memberdef/typedefs",
426 new StartElementHandlerMember(this,&LayoutParser::startMemberDefEntry,
427 MemberListType_typedefMembers,theTranslator->trMemberTypedefDocumentation()));
428 m_sHandler.insert("class/memberdef/enums",
429 new StartElementHandlerMember(this,&LayoutParser::startMemberDefEntry,
430 MemberListType_enumMembers,theTranslator->trMemberEnumerationDocumentation()));
431 m_sHandler.insert("class/memberdef/services",
432 new StartElementHandlerMember(this,&LayoutParser::startMemberDefEntry,
433 MemberListType_serviceMembers,theTranslator->trInterfaces()));
434 m_sHandler.insert("class/memberdef/interfaces",
435 new StartElementHandlerMember(this,&LayoutParser::startMemberDefEntry,
436 MemberListType_interfaceMembers,theTranslator->trInterfaces()));
437 m_sHandler.insert("class/memberdef/constructors",
438 new StartElementHandlerMember(this,&LayoutParser::startMemberDefEntry,
439 MemberListType_constructors,theTranslator->trConstructorDocumentation()));
440 m_sHandler.insert("class/memberdef/functions",
441 new StartElementHandlerMember(this,&LayoutParser::startMemberDefEntry,
442 MemberListType_functionMembers,
443 COMPILE_FOR_2_OPTIONS(
444 theTranslator->trMemberFunctionDocumentation(),
445 SrcLangExt_ObjC,theTranslator->trMethodDocumentation(),
446 SrcLangExt_Fortran,theTranslator->trMemberFunctionDocumentationFortran()
448 m_sHandler.insert("class/memberdef/related",
449 new StartElementHandlerMember(this,&LayoutParser::startMemberDefEntry,
450 MemberListType_relatedMembers,theTranslator->trRelatedFunctionDocumentation()));
451 m_sHandler.insert("class/memberdef/variables",
452 new StartElementHandlerMember(this,&LayoutParser::startMemberDefEntry,
453 MemberListType_variableMembers,theTranslator->trMemberDataDocumentation()));
454 m_sHandler.insert("class/memberdef/properties",
455 new StartElementHandlerMember(this,&LayoutParser::startMemberDefEntry,
456 MemberListType_propertyMembers,theTranslator->trPropertyDocumentation()));
457 m_sHandler.insert("class/memberdef/events",
458 new StartElementHandlerMember(this,&LayoutParser::startMemberDefEntry,
459 MemberListType_eventMembers,theTranslator->trEventDocumentation()));
460 m_eHandler.insert("class/memberdef",
461 new EndElementHandler(this,&LayoutParser::endMemberDef));
462 m_eHandler.insert("class",
463 new EndElementHandler(this,&LayoutParser::endClass));
466 // namespace layout handlers
467 m_sHandler.insert("namespace",
468 new StartElementHandler(this,&LayoutParser::startNamespace));
469 m_sHandler.insert("namespace/briefdescription",
470 new StartElementHandlerKind(this,LayoutDocEntry::BriefDesc,&LayoutParser::startSimpleEntry));
471 m_sHandler.insert("namespace/detaileddescription",
472 new StartElementHandlerSection(this,LayoutDocEntry::DetailedDesc,&LayoutParser::startSectionEntry,
473 theTranslator->trDetailedDescription()));
474 m_sHandler.insert("namespace/authorsection",
475 new StartElementHandlerKind(this,LayoutDocEntry::AuthorSection,&LayoutParser::startSimpleEntry));
476 m_sHandler.insert("namespace/memberdecl",
477 new StartElementHandler(this,&LayoutParser::startMemberDecl));
478 m_sHandler.insert("namespace/memberdecl/nestednamespaces",
479 new StartElementHandlerSection(this,LayoutDocEntry::NamespaceNestedNamespaces,&LayoutParser::startSectionEntry,
480 COMPILE_FOR_4_OPTIONS(
481 theTranslator->trNamespaces(),
482 SrcLangExt_Java,theTranslator->trPackages(),
483 SrcLangExt_VHDL,theTranslator->trPackages(),
484 SrcLangExt_IDL,theTranslator->trModules(),
485 SrcLangExt_Fortran,theTranslator->trModules()
487 m_sHandler.insert("namespace/memberdecl/constantgroups",
488 new StartElementHandlerSection(this,LayoutDocEntry::NamespaceNestedConstantGroups,&LayoutParser::startSectionEntry,
489 theTranslator->trConstantGroups()));
490 m_sHandler.insert("namespace/memberdecl/classes",
491 new StartElementHandlerSection(this,LayoutDocEntry::NamespaceClasses,&LayoutParser::startSectionEntry,
492 COMPILE_FOR_2_OPTIONS(
493 theTranslator->trCompounds(),
494 SrcLangExt_VHDL,VhdlDocGen::trVhdlType(VhdlDocGen::ENTITY,FALSE),
495 SrcLangExt_Fortran,theTranslator->trDataTypes()
497 m_sHandler.insert("namespace/memberdecl/membergroups",
498 new StartElementHandlerKind(this,LayoutDocEntry::MemberGroups,&LayoutParser::startSimpleEntry));
499 m_sHandler.insert("namespace/memberdecl/typedefs",
500 new StartElementHandlerMember(this,&LayoutParser::startMemberDeclEntry,
501 MemberListType_decTypedefMembers,theTranslator->trTypedefs()));
502 m_sHandler.insert("namespace/memberdecl/enums",
503 new StartElementHandlerMember(this,&LayoutParser::startMemberDeclEntry,
504 MemberListType_decEnumMembers,theTranslator->trEnumerations()));
505 m_sHandler.insert("namespace/memberdecl/functions",
506 new StartElementHandlerMember(this,&LayoutParser::startMemberDeclEntry,
507 MemberListType_decFuncMembers,
508 COMPILE_FOR_2_OPTIONS(
509 theTranslator->trFunctions(),
510 SrcLangExt_Fortran,theTranslator->trSubprograms(),
511 SrcLangExt_VHDL,VhdlDocGen::trFunctionAndProc()
513 m_sHandler.insert("namespace/memberdecl/variables",
514 new StartElementHandlerMember(this,&LayoutParser::startMemberDeclEntry,
515 MemberListType_decVarMembers,theTranslator->trVariables()));
516 m_eHandler.insert("namespace/memberdecl",
517 new EndElementHandler(this,&LayoutParser::endMemberDecl));
518 m_sHandler.insert("namespace/memberdef",
519 new StartElementHandler(this,&LayoutParser::startMemberDef));
520 m_sHandler.insert("namespace/memberdef/inlineclasses",
521 new StartElementHandlerSection(this,LayoutDocEntry::NamespaceInlineClasses,&LayoutParser::startSectionEntry,
522 COMPILE_FOR_1_OPTION(
523 theTranslator->trClassDocumentation(),
524 SrcLangExt_Fortran,theTranslator->trTypeDocumentation()
526 m_sHandler.insert("namespace/memberdef/typedefs",
527 new StartElementHandlerMember(this,&LayoutParser::startMemberDefEntry,
528 MemberListType_docTypedefMembers,theTranslator->trTypedefDocumentation()));
529 m_sHandler.insert("namespace/memberdef/enums",
530 new StartElementHandlerMember(this,&LayoutParser::startMemberDefEntry,
531 MemberListType_docEnumMembers,theTranslator->trEnumerationTypeDocumentation()));
532 m_sHandler.insert("namespace/memberdef/functions",
533 new StartElementHandlerMember(this,&LayoutParser::startMemberDefEntry,
534 MemberListType_docFuncMembers,
535 COMPILE_FOR_1_OPTION(
536 theTranslator->trFunctionDocumentation(),
537 SrcLangExt_Fortran,theTranslator->trSubprogramDocumentation()
539 m_sHandler.insert("namespace/memberdef/variables",
540 new StartElementHandlerMember(this,&LayoutParser::startMemberDefEntry,
541 MemberListType_docVarMembers,theTranslator->trVariableDocumentation()));
542 m_eHandler.insert("namespace/memberdef",
543 new EndElementHandler(this,&LayoutParser::endMemberDef));
544 m_eHandler.insert("namespace",
545 new EndElementHandler(this,&LayoutParser::endNamespace));
547 // file layout handlers
548 m_sHandler.insert("file",
549 new StartElementHandler(this,&LayoutParser::startFile));
550 m_sHandler.insert("file/briefdescription",
551 new StartElementHandlerKind(this,LayoutDocEntry::BriefDesc,&LayoutParser::startSimpleEntry));
552 m_sHandler.insert("file/detaileddescription",
553 new StartElementHandlerSection(this,LayoutDocEntry::DetailedDesc,&LayoutParser::startSectionEntry,
554 theTranslator->trDetailedDescription()));
555 m_sHandler.insert("file/authorsection",
556 new StartElementHandlerKind(this,LayoutDocEntry::AuthorSection,&LayoutParser::startSimpleEntry));
557 m_sHandler.insert("file/includes",
558 new StartElementHandlerKind(this,LayoutDocEntry::FileIncludes,&LayoutParser::startSimpleEntry));
559 m_sHandler.insert("file/includegraph",
560 new StartElementHandlerKind(this,LayoutDocEntry::FileIncludeGraph,&LayoutParser::startSimpleEntry));
561 m_sHandler.insert("file/includedbygraph",
562 new StartElementHandlerKind(this,LayoutDocEntry::FileIncludedByGraph,&LayoutParser::startSimpleEntry));
563 m_sHandler.insert("file/sourcelink",
564 new StartElementHandlerKind(this,LayoutDocEntry::FileSourceLink,&LayoutParser::startSimpleEntry));
565 m_sHandler.insert("file/memberdecl/membergroups",
566 new StartElementHandlerKind(this,LayoutDocEntry::MemberGroups,&LayoutParser::startSimpleEntry));
567 m_sHandler.insert("file/memberdecl",
568 new StartElementHandler(this,&LayoutParser::startMemberDecl));
569 m_sHandler.insert("file/memberdecl/classes",
570 new StartElementHandlerSection(this,LayoutDocEntry::FileClasses,&LayoutParser::startSectionEntry,
571 COMPILE_FOR_2_OPTIONS(
572 theTranslator->trCompounds(),
573 SrcLangExt_VHDL,VhdlDocGen::trVhdlType(VhdlDocGen::ENTITY,FALSE),
574 SrcLangExt_Fortran,theTranslator->trDataTypes()
576 m_sHandler.insert("file/memberdecl/namespaces",
577 new StartElementHandlerSection(this,LayoutDocEntry::FileNamespaces,&LayoutParser::startSectionEntry,
578 COMPILE_FOR_3_OPTIONS(
579 theTranslator->trNamespaces(),
580 SrcLangExt_Java,theTranslator->trPackages(),
581 SrcLangExt_IDL,theTranslator->trModules(),
582 SrcLangExt_Fortran,theTranslator->trModules()
584 m_sHandler.insert("file/memberdecl/constantgroups",
585 new StartElementHandlerSection(this,LayoutDocEntry::FileConstantGroups,&LayoutParser::startSectionEntry,
586 theTranslator->trConstantGroups()));
587 m_sHandler.insert("file/memberdecl/defines",
588 new StartElementHandlerMember(this,&LayoutParser::startMemberDeclEntry,
589 MemberListType_decDefineMembers,theTranslator->trDefines()));
590 m_sHandler.insert("file/memberdecl/typedefs",
591 new StartElementHandlerMember(this,&LayoutParser::startMemberDeclEntry,
592 MemberListType_decTypedefMembers,theTranslator->trTypedefs()));
593 m_sHandler.insert("file/memberdecl/enums",
594 new StartElementHandlerMember(this,&LayoutParser::startMemberDeclEntry,
595 MemberListType_decEnumMembers,theTranslator->trEnumerations()));
596 m_sHandler.insert("file/memberdecl/functions",
597 new StartElementHandlerMember(this,&LayoutParser::startMemberDeclEntry,
598 MemberListType_decFuncMembers,
599 COMPILE_FOR_2_OPTIONS(
600 theTranslator->trFunctions(),
601 SrcLangExt_Fortran,theTranslator->trSubprograms(),
602 SrcLangExt_VHDL,VhdlDocGen::trFunctionAndProc()
604 m_sHandler.insert("file/memberdecl/variables",
605 new StartElementHandlerMember(this,&LayoutParser::startMemberDeclEntry,
606 MemberListType_decVarMembers,theTranslator->trVariables()));
608 m_eHandler.insert("file/memberdecl",
609 new EndElementHandler(this,&LayoutParser::endMemberDecl));
610 m_sHandler.insert("file/memberdef",
611 new StartElementHandler(this,&LayoutParser::startMemberDef));
612 m_sHandler.insert("file/memberdef/inlineclasses",
613 new StartElementHandlerSection(this,LayoutDocEntry::FileInlineClasses,&LayoutParser::startSectionEntry,
614 COMPILE_FOR_1_OPTION(
615 theTranslator->trClassDocumentation(),
616 SrcLangExt_Fortran,theTranslator->trTypeDocumentation()
618 m_sHandler.insert("file/memberdef/defines",
619 new StartElementHandlerMember(this,&LayoutParser::startMemberDefEntry,
620 MemberListType_docDefineMembers,theTranslator->trDefineDocumentation()));
621 m_sHandler.insert("file/memberdef/typedefs",
622 new StartElementHandlerMember(this,&LayoutParser::startMemberDefEntry,
623 MemberListType_docTypedefMembers,theTranslator->trTypedefDocumentation()));
624 m_sHandler.insert("file/memberdef/enums",
625 new StartElementHandlerMember(this,&LayoutParser::startMemberDefEntry,
626 MemberListType_docEnumMembers,
627 theTranslator->trEnumerationTypeDocumentation()));
628 m_sHandler.insert("file/memberdef/functions",
629 new StartElementHandlerMember(this,&LayoutParser::startMemberDefEntry,
630 MemberListType_docFuncMembers,
631 COMPILE_FOR_1_OPTION(
632 theTranslator->trFunctionDocumentation(),
633 SrcLangExt_Fortran,theTranslator->trSubprogramDocumentation()
635 m_sHandler.insert("file/memberdef/variables",
636 new StartElementHandlerMember(this,&LayoutParser::startMemberDefEntry,
637 MemberListType_docVarMembers,theTranslator->trVariableDocumentation()));
638 m_eHandler.insert("file/memberdef",
639 new EndElementHandler(this,&LayoutParser::endMemberDef));
640 m_eHandler.insert("file",
641 new EndElementHandler(this,&LayoutParser::endFile));
643 // group layout handlers
644 m_sHandler.insert("group",
645 new StartElementHandler(this,&LayoutParser::startGroup));
646 m_sHandler.insert("group/briefdescription",
647 new StartElementHandlerKind(this,LayoutDocEntry::BriefDesc,&LayoutParser::startSimpleEntry));
648 m_sHandler.insert("group/detaileddescription",
649 new StartElementHandlerSection(this,LayoutDocEntry::DetailedDesc,&LayoutParser::startSectionEntry,
650 theTranslator->trDetailedDescription()));
651 m_sHandler.insert("group/authorsection",
652 new StartElementHandlerKind(this,LayoutDocEntry::AuthorSection,&LayoutParser::startSimpleEntry));
653 m_sHandler.insert("group/groupgraph",
654 new StartElementHandlerKind(this,LayoutDocEntry::GroupGraph,&LayoutParser::startSimpleEntry));
655 m_sHandler.insert("group/memberdecl/membergroups",
656 new StartElementHandlerKind(this,LayoutDocEntry::MemberGroups,&LayoutParser::startSimpleEntry));
657 m_sHandler.insert("group/memberdecl",
658 new StartElementHandler(this,&LayoutParser::startMemberDecl));
659 m_sHandler.insert("group/memberdecl/classes",
660 new StartElementHandlerSection(this,LayoutDocEntry::GroupClasses,&LayoutParser::startSectionEntry,
661 COMPILE_FOR_2_OPTIONS(
662 theTranslator->trCompounds(),
663 SrcLangExt_VHDL,VhdlDocGen::trVhdlType(VhdlDocGen::ENTITY,FALSE),
664 SrcLangExt_Fortran,theTranslator->trDataTypes()
666 m_sHandler.insert("group/memberdecl/namespaces",
667 new StartElementHandlerSection(this,LayoutDocEntry::GroupNamespaces,&LayoutParser::startSectionEntry,
668 COMPILE_FOR_2_OPTIONS(
669 theTranslator->trNamespaces(),
670 SrcLangExt_Java,theTranslator->trPackages(),
671 SrcLangExt_Fortran,theTranslator->trModules()
673 m_sHandler.insert("group/memberdecl/dirs",
674 new StartElementHandlerSection(this,LayoutDocEntry::GroupDirs,&LayoutParser::startSectionEntry,
675 theTranslator->trDirectories()
677 m_sHandler.insert("group/memberdecl/nestedgroups",
678 new StartElementHandlerSection(this,LayoutDocEntry::GroupNestedGroups,&LayoutParser::startSectionEntry,
679 theTranslator->trModules()
681 m_sHandler.insert("group/memberdecl/files",
682 new StartElementHandlerSection(this,LayoutDocEntry::GroupFiles,&LayoutParser::startSectionEntry,
683 theTranslator->trFile(TRUE,FALSE)
686 m_sHandler.insert("group/memberdecl/defines",
687 new StartElementHandlerMember(this,&LayoutParser::startMemberDeclEntry,
688 MemberListType_decDefineMembers,theTranslator->trDefines()));
689 m_sHandler.insert("group/memberdecl/typedefs",
690 new StartElementHandlerMember(this,&LayoutParser::startMemberDeclEntry,
691 MemberListType_decTypedefMembers,theTranslator->trTypedefs()));
692 m_sHandler.insert("group/memberdecl/enums",
693 new StartElementHandlerMember(this,&LayoutParser::startMemberDeclEntry,
694 MemberListType_decEnumMembers,theTranslator->trEnumerations()));
695 m_sHandler.insert("group/memberdecl/enumvalues",
696 new StartElementHandlerMember(this,&LayoutParser::startMemberDeclEntry,
697 MemberListType_decEnumValMembers,theTranslator->trEnumerationValues()));
698 m_sHandler.insert("group/memberdecl/functions",
699 new StartElementHandlerMember(this,&LayoutParser::startMemberDeclEntry,
700 MemberListType_decFuncMembers,
701 COMPILE_FOR_2_OPTIONS(
702 theTranslator->trFunctions(),
703 SrcLangExt_Fortran,theTranslator->trSubprograms(),
704 SrcLangExt_VHDL,VhdlDocGen::trFunctionAndProc()
706 m_sHandler.insert("group/memberdecl/variables",
707 new StartElementHandlerMember(this,&LayoutParser::startMemberDeclEntry,
708 MemberListType_decVarMembers,theTranslator->trVariables()));
709 m_sHandler.insert("group/memberdecl/signals",
710 new StartElementHandlerMember(this,&LayoutParser::startMemberDeclEntry,
711 MemberListType_decSignalMembers,theTranslator->trSignals()));
712 m_sHandler.insert("group/memberdecl/publicslots",
713 new StartElementHandlerMember(this,&LayoutParser::startMemberDeclEntry,
714 MemberListType_decPubSlotMembers,theTranslator->trPublicSlots()));
715 m_sHandler.insert("group/memberdecl/protectedslots",
716 new StartElementHandlerMember(this,&LayoutParser::startMemberDeclEntry,
717 MemberListType_decProSlotMembers,theTranslator->trProtectedSlots()));
718 m_sHandler.insert("group/memberdecl/privateslots",
719 new StartElementHandlerMember(this,&LayoutParser::startMemberDeclEntry,
720 MemberListType_decPriSlotMembers,theTranslator->trPrivateSlots()));
721 m_sHandler.insert("group/memberdecl/events",
722 new StartElementHandlerMember(this,&LayoutParser::startMemberDeclEntry,
723 MemberListType_decEventMembers,theTranslator->trEvents()));
724 m_sHandler.insert("group/memberdecl/properties",
725 new StartElementHandlerMember(this,&LayoutParser::startMemberDeclEntry,
726 MemberListType_decPropMembers,theTranslator->trProperties()));
727 m_sHandler.insert("group/memberdecl/friends",
728 new StartElementHandlerMember(this,&LayoutParser::startMemberDeclEntry,
729 MemberListType_decFriendMembers,theTranslator->trFriends()));
730 m_eHandler.insert("group/memberdecl",
731 new EndElementHandler(this,&LayoutParser::endMemberDecl));
732 m_sHandler.insert("group/memberdef",
733 new StartElementHandler(this,&LayoutParser::startMemberDef));
734 m_sHandler.insert("group/memberdef/pagedocs",
735 new StartElementHandlerKind(this,LayoutDocEntry::GroupPageDocs,&LayoutParser::startSimpleEntry));
736 m_sHandler.insert("group/memberdef/inlineclasses",
737 new StartElementHandlerSection(this,LayoutDocEntry::GroupInlineClasses,&LayoutParser::startSectionEntry,
738 COMPILE_FOR_1_OPTION(
739 theTranslator->trClassDocumentation(),
740 SrcLangExt_Fortran,theTranslator->trTypeDocumentation()
742 m_sHandler.insert("group/memberdef/defines",
743 new StartElementHandlerMember(this,&LayoutParser::startMemberDefEntry,
744 MemberListType_docDefineMembers,theTranslator->trDefineDocumentation()));
745 m_sHandler.insert("group/memberdef/typedefs",
746 new StartElementHandlerMember(this,&LayoutParser::startMemberDefEntry,
747 MemberListType_docTypedefMembers,theTranslator->trTypedefDocumentation()));
748 m_sHandler.insert("group/memberdef/enums",
749 new StartElementHandlerMember(this,&LayoutParser::startMemberDefEntry,
750 MemberListType_docEnumMembers,theTranslator->trEnumerationTypeDocumentation()));
751 m_sHandler.insert("group/memberdef/enumvalues",
752 new StartElementHandlerMember(this,&LayoutParser::startMemberDefEntry,
753 MemberListType_docEnumValMembers,theTranslator->trEnumerationValueDocumentation()));
754 m_sHandler.insert("group/memberdef/functions",
755 new StartElementHandlerMember(this,&LayoutParser::startMemberDefEntry,
756 MemberListType_docFuncMembers,
757 COMPILE_FOR_1_OPTION(
758 theTranslator->trFunctionDocumentation(),
759 SrcLangExt_Fortran,theTranslator->trSubprogramDocumentation()
761 m_sHandler.insert("group/memberdef/variables",
762 new StartElementHandlerMember(this,&LayoutParser::startMemberDefEntry,
763 MemberListType_docVarMembers,theTranslator->trVariableDocumentation()));
764 m_sHandler.insert("group/memberdef/signals",
765 new StartElementHandlerMember(this,&LayoutParser::startMemberDefEntry,
766 MemberListType_docSignalMembers,theTranslator->trSignals()));
767 m_sHandler.insert("group/memberdef/publicslots",
768 new StartElementHandlerMember(this,&LayoutParser::startMemberDefEntry,
769 MemberListType_docPubSlotMembers,theTranslator->trPublicSlots()));
770 m_sHandler.insert("group/memberdef/protectedslots",
771 new StartElementHandlerMember(this,&LayoutParser::startMemberDefEntry,
772 MemberListType_docProSlotMembers,theTranslator->trProtectedSlots()));
773 m_sHandler.insert("group/memberdef/privateslots",
774 new StartElementHandlerMember(this,&LayoutParser::startMemberDefEntry,
775 MemberListType_docPriSlotMembers,theTranslator->trPrivateSlots()));
776 m_sHandler.insert("group/memberdef/events",
777 new StartElementHandlerMember(this,&LayoutParser::startMemberDefEntry,
778 MemberListType_docEventMembers,theTranslator->trEvents()));
779 m_sHandler.insert("group/memberdef/properties",
780 new StartElementHandlerMember(this,&LayoutParser::startMemberDefEntry,
781 MemberListType_docPropMembers,theTranslator->trProperties()));
782 m_sHandler.insert("group/memberdef/friends",
783 new StartElementHandlerMember(this,&LayoutParser::startMemberDefEntry,
784 MemberListType_docFriendMembers,theTranslator->trFriends()));
785 m_eHandler.insert("group/memberdef",
786 new EndElementHandler(this,&LayoutParser::endMemberDef));
787 m_eHandler.insert("group",
788 new EndElementHandler(this,&LayoutParser::endGroup));
790 // directory layout handlers
791 m_sHandler.insert("directory",
792 new StartElementHandler(this,&LayoutParser::startDirectory));
793 m_sHandler.insert("directory/briefdescription",
794 new StartElementHandlerKind(this,LayoutDocEntry::BriefDesc,&LayoutParser::startSimpleEntry));
795 m_sHandler.insert("directory/detaileddescription",
796 new StartElementHandlerSection(this,LayoutDocEntry::DetailedDesc,&LayoutParser::startSectionEntry,
797 theTranslator->trDetailedDescription()));
798 m_sHandler.insert("directory/directorygraph",
799 new StartElementHandlerKind(this,LayoutDocEntry::DirGraph,&LayoutParser::startSimpleEntry));
800 m_sHandler.insert("directory/memberdecl",
801 new StartElementHandler(this,&LayoutParser::startMemberDecl));
802 m_sHandler.insert("directory/memberdecl/dirs",
803 new StartElementHandlerKind(this,LayoutDocEntry::DirSubDirs,&LayoutParser::startSimpleEntry));
804 m_sHandler.insert("directory/memberdecl/files",
805 new StartElementHandlerKind(this,LayoutDocEntry::DirFiles,&LayoutParser::startSimpleEntry));
806 m_eHandler.insert("directory/memberdecl",
807 new EndElementHandler(this,&LayoutParser::endMemberDecl));
808 m_eHandler.insert("directory",
809 new EndElementHandler(this,&LayoutParser::endDirectory));
812 void startSimpleEntry(LayoutDocEntry::Kind k,const QXmlAttributes &attrib)
814 bool isVisible = elemIsVisible(attrib);
815 if (m_part!=-1 && isVisible)
817 LayoutDocManager::instance().addEntry((LayoutDocManager::LayoutPart)m_part,
818 new LayoutDocEntrySimple(k));
822 void startSectionEntry(LayoutDocEntry::Kind k,const QXmlAttributes &attrib,
823 const QCString &title)
825 bool isVisible = elemIsVisible(attrib);
826 QCString userTitle = attrib.value("title").utf8();
827 //printf("startSectionEntry: title='%s' userTitle='%s'\n",
828 // title.data(),userTitle.data());
829 if (userTitle.isEmpty()) userTitle = title;
830 if (m_part!=-1 && isVisible)
832 LayoutDocManager::instance().addEntry((LayoutDocManager::LayoutPart)m_part,
833 new LayoutDocEntrySection(k,userTitle));
838 void startMemberDeclEntry(const QXmlAttributes &attrib,MemberListType type,
839 const QCString &title,const QCString &subscript)
841 //QCString visible = convertToQCString(attrib.value("visible"));
842 //bool isVisible = visible.isEmpty() || (visible!="no" && visible!="0");
843 QCString userTitle = attrib.value("title").utf8();
844 QCString userSubscript = attrib.value("subtitle").utf8();
845 if (userTitle.isEmpty()) userTitle = title;
846 if (userSubscript.isEmpty()) userSubscript = subscript;
847 //printf("memberdecl: %s\n",userTitle.data());
848 if (m_part!=-1 /*&& isVisible*/)
850 LayoutDocManager::instance().addEntry((LayoutDocManager::LayoutPart)m_part,
851 new LayoutDocEntryMemberDecl(type,userTitle,userSubscript));
855 void startMemberDefEntry(const QXmlAttributes &attrib,MemberListType type,
856 const QCString &title,const QCString &)
858 QCString userTitle = attrib.value("title").utf8();
859 if (userTitle.isEmpty()) userTitle = title;
860 //printf("memberdef: %s\n",userTitle.data());
861 if (m_part!=-1 /*&& isVisible*/)
863 LayoutDocManager::instance().addEntry((LayoutDocManager::LayoutPart)m_part,
864 new LayoutDocEntryMemberDef(type,userTitle));
868 void startLayout(const QXmlAttributes &)
876 void startNavIndex(const QXmlAttributes &)
879 m_rootNav = LayoutDocManager::instance().rootNavEntry();
880 if (m_rootNav) m_rootNav->clear();
886 if (m_rootNav && !m_rootNav->find(LayoutNavEntry::MainPage))
888 // no MainPage node... add one as the first item of the root node...
889 new LayoutNavEntry(m_rootNav,LayoutNavEntry::MainPage, TRUE,
890 /*Config_getBool(GENERATE_TREEVIEW) ? "main" :*/ "index",
891 theTranslator->trMainPage(),"",TRUE);
895 void startNavEntry(const QXmlAttributes &attrib)
897 static bool javaOpt = Config_getBool(OPTIMIZE_OUTPUT_JAVA);
898 static bool fortranOpt = Config_getBool(OPTIMIZE_FOR_FORTRAN);
899 static bool vhdlOpt = Config_getBool(OPTIMIZE_OUTPUT_VHDL);
900 static bool hasGraphicalHierarchy = Config_getBool(HAVE_DOT) &&
901 Config_getBool(GRAPHICAL_HIERARCHY);
902 static bool extractAll = Config_getBool(EXTRACT_ALL);
903 static struct NavEntryMap
905 const char *typeStr; // type attribute name in the XML file
906 LayoutNavEntry::Kind kind; // corresponding enum name
907 QCString mainName; // default title for an item if it has children
908 QCString subName; // optional name for an item if it is rendered as a child
909 QCString intro; // introduction text to be put on the index page
910 QCString baseFile; // base name of the file containing the index page
914 LayoutNavEntry::MainPage,
915 theTranslator->trMainPage(),
921 LayoutNavEntry::Pages,
922 theTranslator->trRelatedPages(),
924 theTranslator->trRelatedPagesDescription(),
928 LayoutNavEntry::Modules,
929 theTranslator->trModules(),
931 theTranslator->trModulesDescription(),
935 LayoutNavEntry::Namespaces,
936 javaOpt || vhdlOpt ? theTranslator->trPackages() : fortranOpt ? theTranslator->trModules() : theTranslator->trNamespaces(),
937 javaOpt || vhdlOpt ? theTranslator->trPackages() : fortranOpt ? theTranslator->trModulesList() : theTranslator->trNamespaceList(),
938 javaOpt || vhdlOpt ? theTranslator->trPackageListDescription() : fortranOpt ? theTranslator->trModulesListDescription(extractAll) : theTranslator->trNamespaceListDescription(extractAll),
942 LayoutNavEntry::NamespaceList,
943 javaOpt || vhdlOpt ? theTranslator->trPackages() : fortranOpt ? theTranslator->trModulesList() : theTranslator->trNamespaceList(),
945 javaOpt || vhdlOpt ? theTranslator->trPackageListDescription() : fortranOpt ? theTranslator->trModulesListDescription(extractAll) : theTranslator->trNamespaceListDescription(extractAll),
948 { "namespacemembers",
949 LayoutNavEntry::NamespaceMembers,
950 javaOpt || vhdlOpt ? theTranslator->trPackageMembers() : fortranOpt ? theTranslator->trModulesMembers() : theTranslator->trNamespaceMembers(),
952 fortranOpt ? theTranslator->trModulesMemberDescription(extractAll) : theTranslator->trNamespaceMemberDescription(extractAll),
956 LayoutNavEntry::ClassIndex,
957 fortranOpt ? theTranslator->trDataTypes() : vhdlOpt ? VhdlDocGen::trDesignUnits() : theTranslator->trCompoundIndex(),
963 LayoutNavEntry::Classes,
964 fortranOpt ? theTranslator->trCompoundListFortran() : vhdlOpt ? VhdlDocGen::trDesignUnitList() : theTranslator->trClasses(),
965 theTranslator->trCompoundList(),
966 fortranOpt ? theTranslator->trCompoundListDescriptionFortran() : vhdlOpt ? VhdlDocGen::trDesignUnitListDescription() : theTranslator->trCompoundListDescription(),
970 LayoutNavEntry::ClassList,
971 fortranOpt ? theTranslator->trCompoundListFortran() : vhdlOpt ? VhdlDocGen::trDesignUnitList() : theTranslator->trCompoundList(),
973 fortranOpt ? theTranslator->trCompoundListDescriptionFortran() : vhdlOpt ? VhdlDocGen::trDesignUnitListDescription() : theTranslator->trCompoundListDescription(),
977 LayoutNavEntry::ClassHierarchy,
978 vhdlOpt ? VhdlDocGen::trDesignUnitHierarchy() : theTranslator->trClassHierarchy(),
980 theTranslator->trClassHierarchyDescription(),
981 hasGraphicalHierarchy ? "inherits" : "hierarchy"
984 LayoutNavEntry::ClassMembers,
985 fortranOpt ? theTranslator->trCompoundMembersFortran() : vhdlOpt ? VhdlDocGen::trDesignUnitMembers() : theTranslator->trCompoundMembers(),
987 fortranOpt ? theTranslator->trCompoundMembersDescriptionFortran(extractAll) : theTranslator->trCompoundMembersDescription(extractAll),
991 LayoutNavEntry::Files,
992 theTranslator->trFile(TRUE,FALSE),
993 theTranslator->trFileList(),
994 theTranslator->trFileListDescription(extractAll),
998 LayoutNavEntry::FileList,
999 theTranslator->trFileList(),
1001 theTranslator->trFileListDescription(extractAll),
1005 LayoutNavEntry::FileGlobals,
1006 theTranslator->trFileMembers(),
1008 theTranslator->trFileMembersDescription(extractAll),
1012 // LayoutNavEntry::Dirs,
1013 // theTranslator->trDirectories(),
1015 // theTranslator->trDirDescription(),
1019 LayoutNavEntry::Examples,
1020 theTranslator->trExamples(),
1022 theTranslator->trExamplesDescription(),
1026 LayoutNavEntry::User,
1033 LayoutNavEntry::UserGroup,
1040 (LayoutNavEntry::Kind)0,
1047 LayoutNavEntry::Kind kind;
1048 // find type in the table
1050 QString type = attrib.value("type");
1051 while (mapping[i].typeStr)
1053 if (mapping[i].typeStr==type)
1055 kind = mapping[i].kind;
1060 if (mapping[i].typeStr==0)
1064 err("an entry tag within a navindex has no type attribute! Check your layout file!\n");
1068 err("the type '%s' is not supported for the entry tag within a navindex! Check your layout file!\n",type.data());
1070 m_invalidEntry=TRUE;
1073 QCString baseFile = mapping[i].baseFile;
1074 QCString title = attrib.value("title").utf8();
1075 bool isVisible = elemIsVisible(attrib);
1076 if (title.isEmpty()) // use default title
1078 title = mapping[i].mainName; // use title for main row
1079 if (m_rootNav!=LayoutDocManager::instance().rootNavEntry() && !mapping[i].subName.isEmpty())
1081 title = mapping[i].subName; // if this is a child of another row, use the subName if available
1082 // this is mainly done to get compatible naming with older versions.
1085 QCString intro = attrib.value("intro").utf8();
1086 if (intro.isEmpty()) // use default intro text
1088 intro = mapping[i].intro;
1090 QCString url = attrib.value("url").utf8();
1091 if (mapping[i].kind==LayoutNavEntry::User && !url.isEmpty())
1095 else if (kind==LayoutNavEntry::UserGroup)
1103 baseFile+=QCString().sprintf("%d",m_userGroupCount++);
1106 // create new item and make it the new root
1107 m_rootNav = new LayoutNavEntry(m_rootNav,kind,isVisible,baseFile,title,intro);
1112 // set the root back to the parent
1113 if (m_rootNav && !m_invalidEntry) m_rootNav = m_rootNav->parent();
1114 m_invalidEntry=FALSE;
1117 void startClass(const QXmlAttributes &)
1119 LayoutDocManager::instance().clear(LayoutDocManager::Class);
1121 m_part = (int)LayoutDocManager::Class;
1130 void startNamespace(const QXmlAttributes &)
1132 LayoutDocManager::instance().clear(LayoutDocManager::Namespace);
1133 m_scope="namespace/";
1134 m_part = (int)LayoutDocManager::Namespace;
1143 void startFile(const QXmlAttributes &)
1145 LayoutDocManager::instance().clear(LayoutDocManager::File);
1147 m_part = (int)LayoutDocManager::File;
1156 void startGroup(const QXmlAttributes &)
1158 LayoutDocManager::instance().clear(LayoutDocManager::Group);
1160 m_part = (int)LayoutDocManager::Group;
1169 void startDirectory(const QXmlAttributes &)
1171 LayoutDocManager::instance().clear(LayoutDocManager::Directory);
1172 m_scope="directory/";
1173 m_part = (int)LayoutDocManager::Directory;
1182 void startMemberDef(const QXmlAttributes &)
1184 m_scope+="memberdef/";
1187 LayoutDocManager::instance().addEntry((LayoutDocManager::LayoutPart)m_part,
1188 new LayoutDocEntrySimple(LayoutDocEntry::MemberDefStart));
1194 int i=m_scope.findRev("memberdef/");
1197 m_scope=m_scope.left(i);
1200 LayoutDocManager::instance().addEntry((LayoutDocManager::LayoutPart)m_part,
1201 new LayoutDocEntrySimple(LayoutDocEntry::MemberDefEnd));
1206 void startMemberDecl(const QXmlAttributes &)
1208 m_scope+="memberdecl/";
1211 LayoutDocManager::instance().addEntry((LayoutDocManager::LayoutPart)m_part,
1212 new LayoutDocEntrySimple(LayoutDocEntry::MemberDeclStart));
1216 void endMemberDecl()
1218 int i=m_scope.findRev("memberdecl/");
1221 m_scope=m_scope.left(i);
1224 LayoutDocManager::instance().addEntry((LayoutDocManager::LayoutPart)m_part,
1225 new LayoutDocEntrySimple(LayoutDocEntry::MemberDeclEnd));
1230 // reimplemented from QXmlDefaultHandler
1231 bool startElement( const QString&, const QString&,
1232 const QString& name, const QXmlAttributes& attrib )
1234 //printf("startElement [%s]::[%s]\n",m_scope.data(),name.data());
1235 StartElementHandler *handler = m_sHandler[m_scope+name.utf8()];
1242 err("Unexpected start tag `%s' found in scope='%s'!\n",
1243 name.data(),m_scope.data());
1247 bool endElement( const QString&, const QString&, const QString& name )
1249 //printf("endElement [%s]::[%s]\n",m_scope.data(),name.data());
1250 EndElementHandler *handler;
1251 if (!m_scope.isEmpty() && m_scope.right(name.length()+1)==name.utf8()+"/")
1252 { // element ends current scope
1253 handler = m_eHandler[m_scope.left(m_scope.length()-1)];
1255 else // continue with current scope
1257 handler = m_eHandler[m_scope+name.utf8()];
1265 bool startDocument()
1271 LayoutParser() : m_sHandler(163), m_eHandler(17), m_invalidEntry(FALSE) { }
1272 ~LayoutParser() { delete m_rootNav; }
1274 QDict<StartElementHandler> m_sHandler;
1275 QDict<EndElementHandler> m_eHandler;
1278 LayoutNavEntry *m_rootNav;
1279 bool m_invalidEntry;
1280 static int m_userGroupCount;
1283 int LayoutParser::m_userGroupCount=0;
1285 //---------------------------------------------------------------------------------
1287 class LayoutErrorHandler : public QXmlErrorHandler
1290 LayoutErrorHandler(const char *fn) : fileName(fn) {}
1291 bool warning( const QXmlParseException &exception )
1293 warn_uncond("at line %d column %d of %s: %s\n",
1294 exception.lineNumber(),exception.columnNumber(),fileName.data(),
1295 exception.message().data());
1298 bool error( const QXmlParseException &exception )
1300 err("at line %d column %d of %s: %s\n",
1301 exception.lineNumber(),exception.columnNumber(),fileName.data(),
1302 exception.message().data());
1305 bool fatalError( const QXmlParseException &exception )
1307 err("fatal: at line %d column %d of %s: %s\n",
1308 exception.lineNumber(),exception.columnNumber(),fileName.data(),
1309 exception.message().data());
1312 QString errorString() { return ""; }
1319 //---------------------------------------------------------------------------------
1321 class LayoutDocManager::Private
1324 QList<LayoutDocEntry> docEntries[LayoutDocManager::NrParts];
1325 LayoutNavEntry *rootNav;
1328 LayoutDocManager::LayoutDocManager()
1332 for (i=0;i<LayoutDocManager::NrParts;i++)
1334 d->docEntries[i].setAutoDelete(TRUE);
1336 d->rootNav = new LayoutNavEntry;
1337 LayoutParser::instance().init();
1341 void LayoutDocManager::init()
1343 // parse the default layout
1344 LayoutErrorHandler errorHandler( "layout_default.xml" );
1345 QXmlInputSource source;
1346 source.setData( layout_default );
1347 QXmlSimpleReader reader;
1348 reader.setContentHandler( &LayoutParser::instance() );
1349 reader.setErrorHandler( &errorHandler );
1350 reader.parse( source );
1353 LayoutDocManager::~LayoutDocManager()
1359 LayoutDocManager & LayoutDocManager::instance()
1361 static LayoutDocManager *theInstance = new LayoutDocManager;
1362 return *theInstance;
1365 const QList<LayoutDocEntry> &LayoutDocManager::docEntries(LayoutDocManager::LayoutPart part) const
1367 return d->docEntries[(int)part];
1370 LayoutNavEntry* LayoutDocManager::rootNavEntry() const
1375 void LayoutDocManager::addEntry(LayoutDocManager::LayoutPart p,LayoutDocEntry *e)
1377 d->docEntries[(int)p].append(e);
1380 void LayoutDocManager::clear(LayoutDocManager::LayoutPart p)
1382 d->docEntries[(int)p].clear();
1385 void LayoutDocManager::parse(QTextStream &t,const char *fileName)
1387 LayoutErrorHandler errorHandler(fileName);
1388 QXmlInputSource source( t );
1389 QXmlSimpleReader reader;
1390 reader.setContentHandler( &LayoutParser::instance() );
1391 reader.setErrorHandler( &errorHandler );
1392 reader.parse( source );
1395 //---------------------------------------------------------------------------------
1397 void writeDefaultLayoutFile(const char *fileName)
1400 bool ok = openOutputFile(fileName,f);
1403 err("Failed to open file %s for writing!\n",fileName);
1407 t << substitute(layout_default,"$doxygenversion",versionString);
1410 //----------------------------------------------------------------------------------
1412 // Convert input to a title.
1413 // The format of input can be a simple title "A title" or in case there are different
1414 // titles for some programming languages they can take the following form:
1415 // "A title|16=Another title|8=Yet Another title"
1416 // where the number is a value of SrcLangExt in decimal notation (i.e. 16=Java, 8=IDL).
1417 QCString extractLanguageSpecificTitle(const QCString &input,SrcLangExt lang)
1419 int i,s=0,e=input.find('|');
1420 if (e==-1) return input; // simple title case
1422 while (e!=-1) // look for 'number=title' pattern separated by '|'
1425 e=input.find('|',s);
1426 i=input.find('=',s);
1428 int key=input.mid(s,i-s).toInt();
1429 if (key==(int)lang) // found matching key
1431 if (e==-1) e=input.length();
1432 return input.mid(i+1,e-i-1);
1435 return input.left(e1); // fallback, no explicit language key found
1438 //----------------------------------------------------------------------------------
1440 QCString LayoutDocEntrySection::title(SrcLangExt lang) const
1442 return extractLanguageSpecificTitle(m_title,lang);
1445 //----------------------------------------------------------------------------------
1447 QCString LayoutDocEntryMemberDecl::title(SrcLangExt lang) const
1449 return extractLanguageSpecificTitle(m_title,lang);
1452 QCString LayoutDocEntryMemberDecl::subtitle(SrcLangExt lang) const
1454 return extractLanguageSpecificTitle(m_subscript,lang);
1457 //----------------------------------------------------------------------------------
1459 QCString LayoutDocEntryMemberDef::title(SrcLangExt lang) const
1461 return extractLanguageSpecificTitle(m_title,lang);