-
Notifications
You must be signed in to change notification settings - Fork 14
/
classdef.cpp
4245 lines (3248 loc) · 118 KB
/
classdef.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/************************************************************************
*
* Copyright (c) 2014-2021 Barbara Geller & Ansel Sermersheim
* Copyright (c) 1997-2014 Dimitri van Heesch
*
* DoxyPress is free software: you can redistribute it and/or
* modify it under the terms of the GNU General Public License version 2
* as published by the Free Software Foundation.
*
* DoxyPress is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*
* Documents produced by DoxyPress are derivative works derived from the
* input used in their production; they are not affected by this license.
*
*************************************************************************/
#include <QFile>
#include <QRegularExpression>
#include <stdio.h>
#include <classdef.h>
#include <config.h>
#include <dot.h>
#include <default_args.h>
#include <docparser.h>
#include <doxy_globals.h>
#include <diagram.h>
#include <entry.h>
#include <example.h>
#include <language.h>
#include <layout.h>
#include <message.h>
#include <util.h>
ClassDef::ClassDef(const QString &defFileName, int defLine, int defColumn, const QString &fullName, CompoundType ct,
const QString &tag, const QString &tagFileName, bool isSymbol, bool isJavaEnum)
: Definition(defFileName, defLine, defColumn, removeRedundantWhiteSpace(fullName), "", "", isSymbol)
{
setReference(tag);
m_compType = ct;
m_isJavaEnum = isJavaEnum;
m_visited = false;
QString tname = name();
const QString ctStr = compoundTypeString();
if (tagFileName.isEmpty()) {
m_fileName = ctStr + tname;
} else {
m_fileName = stripExtension(tagFileName);
}
m_parents = 0;
m_inheritedBy = 0;;
m_taggedInnerClasses = 0;
m_prot = Public;
m_subGrouping = Config::getBool("allow-sub-grouping");
m_isSimple = Config::getBool("inline-simple-struct");
m_isAbstract = false;
m_isStatic = false;
m_isTemplArg = false;
m_membersMerged = false;
m_usedOnly = false;
m_classTraits = Entry::Traits{};
// can not use getLanguage at this point, setLanguage() has not been called
SrcLangExt lang = getLanguageFromFileName(defFileName);
if ((lang == SrcLangExt_Cpp || lang == SrcLangExt_ObjC) && determineSection(defFileName) == Entry::SOURCE_SEC) {
m_isLocal = true;
} else {
m_isLocal = false;
}
m_isGeneric = (lang == SrcLangExt_CSharp || lang == SrcLangExt_Java) && tname.indexOf('<') != -1;
m_isAnonymous = tname.contains('@');
}
ClassDef::~ClassDef()
{
delete m_parents;
delete m_inheritedBy;
delete m_taggedInnerClasses;
}
QString ClassDef::getMemberListFileName() const
{
return convertNameToFile(compoundTypeString() + name() + "-members");
}
QString ClassDef::displayName(bool includeScope) const
{
// static const bool optimizeJava = Config::getBool("optimize-java");
SrcLangExt lang = getLanguage();
QString retval;
if (includeScope) {
retval = qualifiedNameWithTemplateParameters();
} else {
retval = className();
}
QString sep = getLanguageSpecificSeparator(lang);
if (sep != "::") {
retval = substitute(retval, "::", sep);
}
if (m_compType == CompoundType::Protocol && retval.endsWith("-p")) {
retval = "<" + retval.left(retval.length() - 2) + ">";
}
retval = renameNS_Aliases(retval);
if (retval.contains('@')) {
return removeAnonymousScopes(retval);
} else {
return retval;
}
}
// inserts a base/super class in the inheritance list
void ClassDef::insertBaseClass(QSharedPointer<ClassDef> cd, const QString &n, Protection p, Specifier s, const QString &t)
{
if (m_parents == 0) {
m_parents = new SortedList<BaseClassDef *>;
}
m_parents->append(new BaseClassDef(cd, n, p, s, t));
m_isSimple = false;
}
// inserts a derived/sub class in the inherited-by list
void ClassDef::insertSubClass(QSharedPointer<ClassDef> cd, Protection p, Specifier s, const QString &t)
{
static const bool extractPrivate = Config::getBool("extract-private");
if (! extractPrivate && cd->protection() == Private) {
return;
}
if (m_inheritedBy == 0) {
m_inheritedBy = new SortedList<BaseClassDef *>;
}
SortedList<BaseClassDef *> *temp = m_inheritedBy;
temp->inSort(new BaseClassDef(cd, QString(), p, s, t));
m_isSimple = false;
}
void ClassDef::addMembersToMemberGroup()
{
QSharedPointer<ClassDef> self = sharedFrom(this);
for (auto item : m_memberLists ) {
if ( (item->listType() & MemberListType_detailedLists) == 0) {
::addMembersToMemberGroup(item, m_memberGroupSDict, self);
}
}
// add members inside sections to their groups
for (auto item : m_memberGroupSDict ) {
if (item->allMembersInSameSection() && m_subGrouping) {
item->addToDeclarationSection();
}
}
}
// adds new member definition to the class
void ClassDef::internalInsertMember(QSharedPointer<MemberDef> md, Protection prot, bool addToAllList)
{
static const bool hideFriendCompound = Config::getBool("hide-friend-compounds");
if (md->isHidden()) {
return;
}
bool isSimple = false;
if (md->isRelated() && protectionLevelVisible(prot)) {
addMemberToList(MemberListType_related, md, true);
} else if (md->isFriend()) {
addMemberToList(MemberListType_friends, md, true);
} else {
switch (md->memberType()) {
case MemberDefType::Service: // UNO IDL
addMemberToList(MemberListType_services, md, true);
break;
case MemberDefType::Interface: // UNO IDL
addMemberToList(MemberListType_interfaces, md, true);
break;
case MemberDefType::DCOP: // KDE2 specific
addMemberToList(MemberListType_dcopMethods, md, true);
break;
case MemberDefType::Property:
addMemberToList(MemberListType_properties, md, true);
break;
case MemberDefType::Event:
addMemberToList(MemberListType_events, md, true);
break;
case MemberDefType::Signal: // Qt and CS specific
switch (prot) {
case Public:
addMemberToList(MemberListType_pubSignals, md, true);
break;
case Protected:
case Package: // signals in packages are not possible
addMemberToList(MemberListType_proSignals, md, true);
break;
case Private:
addMemberToList(MemberListType_priSignals, md, true);
break;
}
break;
case MemberDefType::Slot: // Qt and CS specific
switch (prot) {
case Public:
addMemberToList(MemberListType_pubSlots, md, true);
break;
case Protected:
case Package: // slots in packages are not possible
addMemberToList(MemberListType_proSlots, md, true);
break;
case Private:
addMemberToList(MemberListType_priSlots, md, true);
break;
}
break;
default:
// any of the other members
if (md->isStatic()) {
if (md->isVariable()) {
switch (prot) {
case Protected:
addMemberToList(MemberListType_proStaticAttribs, md, true);
break;
case Package:
addMemberToList(MemberListType_pacStaticAttribs, md, true);
break;
case Public:
addMemberToList(MemberListType_pubStaticAttribs, md, true);
break;
case Private:
addMemberToList(MemberListType_priStaticAttribs, md, true);
break;
}
} else {
// function
switch (prot) {
case Protected:
addMemberToList(MemberListType_proStaticMethods, md, true);
break;
case Package:
addMemberToList(MemberListType_pacStaticMethods, md, true);
break;
case Public:
addMemberToList(MemberListType_pubStaticMethods, md, true);
break;
case Private:
addMemberToList(MemberListType_priStaticMethods, md, true);
break;
}
}
} else {
// not static
if (md->isVariable()) {
switch (prot) {
case Protected:
addMemberToList(MemberListType_proAttribs, md, true);
break;
case Package:
addMemberToList(MemberListType_pacAttribs, md, true);
break;
case Public:
addMemberToList(MemberListType_pubAttribs, md, true);
isSimple = ! md->isFunctionPtr();
break;
case Private:
addMemberToList(MemberListType_priAttribs, md, true);
break;
}
} else if (md->isTypedef()) {
switch (prot) {
case Protected:
addMemberToList(MemberListType_proTypedefs, md, true);
break;
case Package:
addMemberToList(MemberListType_pacTypedefs, md, true);
break;
case Public:
addMemberToList(MemberListType_pubTypedefs, md, true);
isSimple = md->typeString().indexOf(")(") == -1;
break;
case Private:
addMemberToList(MemberListType_priTypedefs, md, true);
break;
}
} else if (md->isEnumerate() || md->isEnumValue()) {
switch (prot) {
case Protected:
addMemberToList(MemberListType_proTypes, md, true);
break;
case Package:
addMemberToList(MemberListType_pacTypes, md, true);
break;
case Public:
addMemberToList(MemberListType_pubTypes, md, true);
isSimple = false;
break;
case Private:
addMemberToList(MemberListType_priTypes, md, true);
break;
}
} else {
// member function
switch (prot) {
case Protected:
addMemberToList(MemberListType_proMethods, md, true);
break;
case Package:
addMemberToList(MemberListType_pacMethods, md, true);
break;
case Public:
addMemberToList(MemberListType_pubMethods, md, true);
break;
case Private:
addMemberToList(MemberListType_priMethods, md, true);
break;
}
}
}
break;
}
}
if (! isSimple) {
// not a simple field -> not a simple struct
m_isSimple = false;
}
// insert member in the detailed documentation section
if ((md->isRelated() && protectionLevelVisible(prot)) || md->isFriend()) {
addMemberToList(MemberListType_relatedMembers, md, false);
} else {
switch (md->memberType()) {
case MemberDefType::Service: // UNO IDL
addMemberToList(MemberListType_serviceMembers, md, false);
break;
case MemberDefType::Interface: // UNO IDL
addMemberToList(MemberListType_interfaceMembers, md, false);
break;
case MemberDefType::Property:
addMemberToList(MemberListType_propertyMembers, md, false);
break;
case MemberDefType::Event:
addMemberToList(MemberListType_eventMembers, md, false);
break;
case MemberDefType::DCOP:
addMemberToList(MemberListType_functionMembers, md, false);
break;
case MemberDefType::Signal:
if (protectionLevelVisible(prot)) {
addMemberToList(MemberListType_functionMembers, md, false);
}
break;
case MemberDefType::Slot:
if (protectionLevelVisible(prot)) {
addMemberToList(MemberListType_functionMembers, md, false);
}
break;
default:
// any of the other members
if (protectionLevelVisible(prot)) {
switch (md->memberType()) {
case MemberDefType::Typedef:
addMemberToList(MemberListType_typedefMembers, md, false);
break;
case MemberDefType::Enumeration:
addMemberToList(MemberListType_enumMembers, md, false);
break;
case MemberDefType::EnumValue:
addMemberToList(MemberListType_enumValMembers, md, false);
break;
case MemberDefType::Function:
if (md->isConstructor() || md->isDestructor()) {
QSharedPointer<MemberList> ml = createMemberList(MemberListType_constructors);
ml->append(md);
} else {
addMemberToList(MemberListType_functionMembers, md, false);
}
break;
case MemberDefType::Variable:
addMemberToList(MemberListType_variableMembers, md, false);
break;
case MemberDefType::Define:
warn(md->getDefFileName(),md->getDefLine()-1,"Define for (%s) can not be a member of %s",
csPrintable(md->name()), csPrintable(this->name()));
break;
default:
err("Unexpected member type %d found\n", md->memberType());
}
}
break;
}
}
// insert member in the appropriate member group
// do this ONLY AFTER inserting the member in the regular groups, addMemberToGroup(md,groupId);
if (md->virtualness() == Pure) {
m_isAbstract = true;
}
if (md->name() == "operator->") {
m_arrowOperator = md;
}
if (addToAllList && ! (hideFriendCompound && md->isFriend() && (md->typeString() == "friend class" ||
md->typeString() == "friend struct" || md->typeString() == "friend union"))) {
MemberInfo mi = MemberInfo(md, prot, md->virtualness(), false);
QSharedPointer<MemberNameInfo> mni;
if ((mni = m_allMemberNameInfoSDict.find(md->name()))) {
mni->append(mi);
} else {
mni = QMakeShared<MemberNameInfo>(md->name());
mni->append(mi);
m_allMemberNameInfoSDict.insert(mni->memberName(), mni);
}
}
}
void ClassDef::insertMember(QSharedPointer<MemberDef> md)
{
internalInsertMember(md, md->protection(), true);
}
// compute the anchors for all members
void ClassDef::computeAnchors()
{
for (auto ml : m_memberLists ) {
if ((ml->listType()&MemberListType_detailedLists) == 0) {
setAnchors(ml);
}
}
for (auto mg : m_memberGroupSDict) {
mg->setAnchors();
}
}
void ClassDef::distributeMemberGroupDocumentation()
{
for (auto mg : m_memberGroupSDict) {
mg->distributeMemberGroupDocumentation();
}
}
void ClassDef::findSectionsInDocumentation()
{
QSharedPointer<ClassDef> self = sharedFrom(this);
docFindSections(documentation(), self, QSharedPointer<MemberGroup>(), docFile());
for (auto item : m_memberGroupSDict) {
item->findSectionsInDocumentation();
}
for (auto item : m_memberLists) {
if ((item->listType() & MemberListType_detailedLists) == 0) {
item->findSectionsInDocumentation();
}
}
}
// add a file name to the used files set
void ClassDef::insertUsedFile(QSharedPointer<FileDef> fd)
{
if (fd == nullptr) {
return;
}
if (! m_files.contains(fd)) {
m_files.append(fd);
}
for (auto &item : m_templateInstances) {
item->insertUsedFile(fd);
}
}
static void writeInheritanceSpecifier(OutputList &ol, BaseClassDef *bcd)
{
if (bcd->prot != Public || bcd->virt != Normal) {
ol.startTypewriter();
ol.docify(" [");
QStringList sl;
if (bcd->prot == Protected) {
sl.append("protected");
} else if (bcd->prot == Private) {
sl.append("private");
}
if (bcd->virt == Virtual) {
sl.append("virtual");
}
QStringListIterator it(sl);
while (it.hasNext()) {
QString s = it.next();
ol.docify(s);
if (it.hasNext()) {
ol.docify(", ");
}
}
ol.docify("]");
ol.endTypewriter();
}
}
void ClassDef::setIncludeFile(QSharedPointer<FileDef> fd, const QString &includeName, bool local, bool force)
{
if ((! includeName.isEmpty() && m_incInfo.includeName.isEmpty()) || (fd != nullptr && m_incInfo.fileDef == nullptr) ) {
m_incInfo.fileDef = fd;
m_incInfo.includeName = includeName;
m_incInfo.local = local;
}
if (force && ! includeName.isEmpty()) {
m_incInfo.includeName = includeName;
m_incInfo.local = local;
}
}
// TODO: fix this: a nested template class can have multiple outer templates
//ArgumentList *ClassDef::outerTemplateArguments() const
//{
// int ti;
// ClassDef *pcd=0;
// int pi=0;
// if (m_tempArgs) return m_tempArgs;
// // find the outer most class scope
// while ((ti=name().find("::",pi))!=-1 &&
// (pcd=getClass(name().left(ti)))==0
// ) pi=ti+2;
// if (pcd)
// {
// return pcd->templateArguments();
// }
// return 0;
//}
static void searchTemplateSpecs(QSharedPointer<Definition> d, QVector<ArgumentList> &result,
QString &name, SrcLangExt lang)
{
if (d->definitionType() == Definition::TypeClass) {
if (d->getOuterScope()) {
searchTemplateSpecs(d->getOuterScope(), result, name, lang);
}
QSharedPointer<ClassDef> cd = d.dynamicCast<ClassDef>();
if (! name.isEmpty()) {
name += "::";
}
QString clName = d->localName();
if (clName.endsWith("-p")) {
clName.chop(2);
}
name += clName;
bool isSpecialization = d->localName().indexOf('<') != -1;
const ArgumentList &tmpList = cd->getTemplateArgumentList();
if (! tmpList.listEmpty()) {
result.append(tmpList);
if (! isSpecialization) {
name += tempArgListToString(tmpList, lang);
}
}
} else {
name += d->qualifiedName();
}
}
static void writeTemplateSpec(OutputList &ol, QSharedPointer<Definition> d, const QString &type, SrcLangExt lang)
{
QVector<ArgumentList> specs;
QString name;
searchTemplateSpecs(d, specs, name, lang);
if (specs.count() > 0) {
// class has template scope specifiers
ol.startSubsubsection();
for (auto al : specs ) {
ol.docify("template<");
auto nextItem = al.begin();
for (auto a : al) {
++nextItem;
ol.docify(a.type);
if (! a.name.isEmpty()) {
ol.docify(" ");
ol.docify(a.name);
}
if (a.defval.length() != 0) {
ol.docify(" = ");
ol.docify(a.defval);
}
if (nextItem != al.end()) {
ol.docify(", ");
}
}
ol.docify(">");
ol.lineBreak();
}
// concepts
const QString & str = d->getRequires();
if (! str.isEmpty()) {
ol.docify("requires " + str);
ol.lineBreak();
}
ol.docify(type.toLower() + " " + name);
ol.endSubsubsection();
ol.writeString("\n");
}
}
void ClassDef::writeBriefDescription(OutputList &ol, bool exampleFlag)
{
QSharedPointer<ClassDef> self = sharedFrom(this);
if (hasBriefDescription()) {
ol.startParagraph();
ol.pushGeneratorState();
ol.disableAllBut(OutputGenerator::Man);
ol.writeString(" - ");
ol.popGeneratorState();
ol.generateDoc(briefFile(), briefLine(), self, QSharedPointer<MemberDef>(),
briefDescription(), true, false, QString(), true, false);
ol.pushGeneratorState();
ol.disable(OutputGenerator::RTF);
ol.writeString(" \n");
ol.enable(OutputGenerator::RTF);
ol.popGeneratorState();
if (hasDetailedDescription() || exampleFlag) {
writeMoreLink(ol, anchor());
}
ol.endParagraph();
}
ol.writeSynopsis();
}
void ClassDef::writeDetailedDocumentationBody(OutputList &ol)
{
static const bool repeatBrief = Config::getBool("repeat-brief");
QSharedPointer<ClassDef> self = sharedFrom(this);
const QString docText = documentation();
ol.startTextBlock();
if (getLanguage() == SrcLangExt_Cpp) {
writeTemplateSpec(ol, self, compoundTypeString(), getLanguage());
}
// repeat brief description
QString brief = briefDescription();
if (! brief.isEmpty() && repeatBrief) {
ol.generateDoc(briefFile(), briefLine(), self, QSharedPointer<MemberDef>(), brief, false, false);
if (! docText.isEmpty()) {
ol.pushGeneratorState();
ol.disable(OutputGenerator::Html);
ol.writeString("\n\n");
ol.popGeneratorState();
}
}
// write documentation
if (! docText.isEmpty()) {
ol.generateDoc(docFile(), docLine(), self, QSharedPointer<MemberDef>(), docText, true, false);
}
// write type constraints
writeTypeConstraints_internal(ol, self, m_typeConstraints);
// write examples
if (hasExamples()) {
ol.startSimpleSect(DocGenerator::Examples, QString(), QString(), theTranslator->trExamples() + ": ");
ol.startDescForItem();
writeExample(ol, m_exampleSDict);
ol.endDescForItem();
ol.endSimpleSect();
}
// ol.newParagraph();
writeSourceDef(ol, name());
ol.endTextBlock();
}
bool ClassDef::hasDetailedDescription() const
{
static const bool repeatBrief = Config::getBool("repeat-brief");
static const bool sourceCode = Config::getBool("source-code");
return ((! briefDescription().isEmpty() && repeatBrief) || ! documentation().isEmpty() ||
(sourceCode && getStartBodyLine() != -1 && getBodyDef()));
}
// write the detailed description for this class
void ClassDef::writeDetailedDescription(OutputList &ol, const QString &, bool exampleFlag,
const QString &title, const QString &anchor)
{
if (hasDetailedDescription() || exampleFlag) {
ol.pushGeneratorState();
ol.disable(OutputGenerator::Html);
ol.writeRuler();
ol.popGeneratorState();
ol.pushGeneratorState();
ol.disableAllBut(OutputGenerator::Html);
ol.writeAnchor("", anchor.isEmpty() ? QString("details") : anchor);
ol.popGeneratorState();
if (! anchor.isEmpty()) {
ol.pushGeneratorState();
ol.disable(OutputGenerator::Html);
ol.disable(OutputGenerator::Man);
ol.writeAnchor(getOutputFileBase(), anchor);
ol.popGeneratorState();
}
ol.startGroupHeader();
ol.parseText(title);
ol.endGroupHeader();
writeDetailedDocumentationBody(ol);
} else {
// writeTemplateSpec(ol,this,pageType);
}
}
QString ClassDef::generatedFromFiles() const
{
QString result;
SrcLangExt lang = getLanguage();
if (lang == SrcLangExt_Fortran) {
result = theTranslator->trGeneratedFromFilesFortran(getLanguage() == SrcLangExt_ObjC &&
m_compType == CompoundType::Interface ? CompoundType::Class : m_compType, m_files.count() == 1);
} else if (isJavaEnum()) {
result = theTranslator->trEnumGeneratedFromFiles(m_files.count() == 1);
} else if (m_compType == CompoundType::Service) {
result = theTranslator->trServiceGeneratedFromFiles(m_files.count() == 1);
} else if (m_compType == CompoundType::Singleton) {
result = theTranslator->trSingletonGeneratedFromFiles(m_files.count() == 1);
} else {
result = theTranslator->trGeneratedFromFiles(
getLanguage() == SrcLangExt_ObjC &&
m_compType == CompoundType::Interface ? CompoundType::Class : m_compType, m_files.count() == 1);
}
return result;
}
void ClassDef::showUsedFiles(OutputList &ol)
{
static const bool fullPathNames = Config::getBool("full-path-names");
ol.pushGeneratorState();
ol.disable(OutputGenerator::Man);
ol.writeRuler();
ol.pushGeneratorState();
ol.disableAllBut(OutputGenerator::Docbook);
ol.startParagraph();
ol.parseText(generatedFromFiles());
ol.endParagraph();
ol.popGeneratorState();
ol.disable(OutputGenerator::Docbook);
ol.parseText(generatedFromFiles());
ol.enable(OutputGenerator::Docbook);
bool first = true;
for (auto fd : m_files) {
if (first) {
first = false;
ol.startItemList();
}
ol.startItemListItem();
QString path = fd->getPath();
if (fullPathNames) {
ol.docify(stripFromPath(path));
}
QString fname = fd->name();
if (! fd->getVersion().isEmpty()) {
// append version if available
fname += " (" + fd->getVersion() + ")";
}
// for HTML
ol.pushGeneratorState();
ol.disableAllBut(OutputGenerator::Html);
if (fd->generateSourceFile()) {
ol.writeObjectLink(QString(), fd->getSourceFileBase(), QString(), fname);
} else if (fd->isLinkable()) {
ol.writeObjectLink(fd->getReference(), fd->getOutputFileBase(), QString(), fname);
} else {
ol.docify(fname);
}
ol.popGeneratorState();
// for other output formats
ol.pushGeneratorState();
ol.disable(OutputGenerator::Html);
if (fd->isLinkable()) {
ol.writeObjectLink(fd->getReference(), fd->getOutputFileBase(), QString(), fname);
} else {
ol.docify(fname);
}
ol.popGeneratorState();
ol.endItemListItem();
}
if (!first) {
ol.endItemList();
}
ol.popGeneratorState();
}
int ClassDef::countInheritanceNodes()
{
int count = 0;
if (m_inheritedBy) {
for (auto ibcd : *m_inheritedBy) {
QSharedPointer<ClassDef> icd = ibcd->classDef;
if ( icd->isVisibleInHierarchy()) {
count++;
}
}
}
if (m_parents) {
for (auto ibcd : *m_parents) {
QSharedPointer<ClassDef> icd = ibcd->classDef;
if ( icd->isVisibleInHierarchy()) {
count++;
}
}
}
return count;
}
void ClassDef::writeInheritanceGraph(OutputList &ol)
{
static const bool haveDot = Config::getBool("have-dot");
static const bool classDiagrams = Config::getBool("class-diagrams");
static const bool classGraph = Config::getBool("dot-class-graph");
static const int maxNodes = Config::getInt("dot-graph-max-nodes");
QSharedPointer<ClassDef> self = sharedFrom(this);
// count direct inheritance relations
const int count = countInheritanceNodes();
bool renderDiagram = false;
if (haveDot && (classDiagrams || classGraph)) {
// write class diagram using dot
DotClassGraph inheritanceGraph(self, DotNode::Inheritance);