Doxygen
Loading...
Searching...
No Matches
tagreader.cpp
Go to the documentation of this file.
1/******************************************************************************
2 *
3 * Copyright (C) 1997-2023 by Dimitri van Heesch.
4 *
5 * Permission to use, copy, modify, and distribute this software and its
6 * documentation under the terms of the GNU General Public License is hereby
7 * granted. No representations are made about the suitability of this software
8 * for any purpose. It is provided "as is" without express or implied warranty.
9 * See the GNU General Public License for more details.
10 *
11 * Documents produced by Doxygen are derivative works derived from the
12 * input used in their production; they are not affected by this license.
13 *
14 */
15
16#include "tagreader.h"
17
18#include <map>
19#include <functional>
20#include <utility>
21#include <algorithm>
22#include <variant>
23
24#include <assert.h>
25#include <stdio.h>
26#include <stdarg.h>
27
28#include "xml.h"
29#include "entry.h"
30#include "doxygen.h"
31#include "util.h"
32#include "message.h"
33#include "defargs.h"
34#include "arguments.h"
35#include "filedef.h"
36#include "filename.h"
37#include "section.h"
38#include "containers.h"
39#include "debug.h"
40#include "anchor.h"
41#include "moduledef.h"
42
43// ----------------- private part -----------------------------------------------
44
45namespace {
46
47/** Information about an linkable anchor */
49{
50 public:
52 const QCString &l,
53 const QCString &t=QCString())
54 : label(l), fileName(f), title(t) {}
58};
59
60/** Container for enum values that are scoped within an enum */
69
70/** Container for include info that can be read from a tagfile */
82
83/** Container for member specific info that can be read from a tagfile */
85{
86 public:
94 std::vector<TagAnchorInfo> docAnchors;
95 Protection prot = Protection::Public;
96 Specifier virt = Specifier::Normal;
97 bool isStatic = false;
98 std::vector<TagEnumValueInfo> enumValues;
99 int lineNr;
100};
101
102/** Base class for all compound types */
104{
105 std::vector<TagMemberInfo> members;
108 std::vector<TagAnchorInfo> docAnchors;
109 int lineNr = 0;
110};
111
112
113/** Container for class specific info that can be read from a tagfile */
126
127using TagClassInfoPtr = std::unique_ptr<TagClassInfo>;
128
129/** Container for concept specific info that can be read from a tagfile */
134
135using TagConceptInfoPtr = std::unique_ptr<TagConceptInfo>;
136
137/** Container for module specific info that can be read from a tagfile */
142
143using TagModuleInfoPtr = std::unique_ptr<TagModuleInfo>;
144
145
146/** Container for namespace specific info that can be read from a tagfile */
154
155using TagNamespaceInfoPtr = std::unique_ptr<TagNamespaceInfo>;
156
157/** Container for package specific info that can be read from a tagfile */
162
163using TagPackageInfoPtr = std::unique_ptr<TagPackageInfo>;
164
165/** Container for file specific info that can be read from a tagfile */
174
175using TagFileInfoPtr = std::unique_ptr<TagFileInfo>;
176
177/** Container for group specific info that can be read from a tagfile */
190
191using TagGroupInfoPtr = std::unique_ptr<TagGroupInfo>;
192
193/** Container for page specific info that can be read from a tagfile */
199
200using TagPageInfoPtr = std::unique_ptr<TagPageInfo>;
201
202/** Container for directory specific info that can be read from a tagfile */
209
210using TagDirInfoPtr = std::unique_ptr<TagDirInfo>;
211
212/** Variant class that holds a unique pointer to one of the specific container types */
214{
215 public:
216 using VariantT = std::variant< std::monostate, // 0
217 TagClassInfoPtr, // 1
221 TagFileInfoPtr, // 5
222 TagGroupInfoPtr, // 6
223 TagPageInfoPtr, // 7
224 TagDirInfoPtr, // 8
225 TagModuleInfoPtr>; // 9
226
227 enum class Type : uint8_t
228 {
230 Class = 1,
234 File = 5,
235 Group = 6,
236 Page = 7,
237 Dir = 8,
239 };
240
242 explicit TagCompoundVariant(VariantT &&v) : m_variant(std::move(v)) {}
248
249 /** Generic non-const getter */
250 template<class R>
251 R *get()
252 {
253 std::unique_ptr<R> *p = std::get_if<std::unique_ptr<R>>(&m_variant);
254 return p ? p->get() : nullptr;
255 }
256 /** Generic const getter */
257 template<class R>
258 const R *get() const
259 {
260 const std::unique_ptr<R> *p = std::get_if<std::unique_ptr<R>>(&m_variant);
261 return p ? p->get() : nullptr;
262 }
263
264 /** Generic factory method to create a variant holding a unique pointer to a given compound type */
265 template<class R,typename... Args>
266 static TagCompoundVariant make(Args&&... args)
267 {
268 return TagCompoundVariant(VariantT(std::make_unique<R>(std::forward<Args>(args)...)));
269 }
270
271 /** @name convenience const and non-const getters for each variant component
272 * @{
273 */
275 const TagClassInfo *getClassInfo() const { return get<TagClassInfo >(); }
283 const TagFileInfo *getFileInfo() const { return get<TagFileInfo >(); }
285 const TagGroupInfo *getGroupInfo() const { return get<TagGroupInfo >(); }
287 const TagPageInfo *getPageInfo() const { return get<TagPageInfo >(); }
289 const TagDirInfo *getDirInfo() const { return get<TagDirInfo >(); }
292 /** @} */
293
294 /** Convenience method to get the shared compound info */
296 {
297 switch(type())
298 {
299 case Type::Uninitialized: return nullptr;
300 case Type::Class: return getClassInfo();
301 case Type::Concept: return getConceptInfo();
302 case Type::Namespace: return getNamespaceInfo();
303 case Type::Package: return getPackageInfo();
304 case Type::File: return getFileInfo();
305 case Type::Group: return getGroupInfo();
306 case Type::Page: return getPageInfo();
307 case Type::Dir: return getDirInfo();
308 case Type::Module: return getModuleInfo();
309 }
310 return nullptr;
311 }
312 Type type() const
313 {
314 return static_cast<Type>(m_variant.index());
315 }
316
317 private:
319};
320
321
322/** Tag file parser.
323 *
324 * Reads an XML-structured tagfile and builds up the structure in
325 * memory. The method buildLists() is used to transfer/translate
326 * the structures to the doxygen engine.
327 */
329{
330#define p_warn(fmt,...) do { \
331 warn(m_locator->fileName(),m_locator->lineNr(),fmt,##__VA_ARGS__); \
332 } while(0)
333
334 public:
335
336 explicit TagFileParser(const char *tagName) : m_tagName(tagName) {}
337
338 void setDocumentLocator ( const XMLLocator * locator )
339 {
340 m_locator = locator;
341 }
342
344 {
346 }
347
348 void startElement( const QCString &name, const XMLHandlers::Attributes& attrib );
349 void endElement( const QCString &name );
350 void characters ( const QCString & ch ) { m_curString+=ch; }
351 void error( const QCString &fileName,int lineNr,const QCString &msg)
352 {
353 warn(fileName,lineNr,"{}",msg);
354 }
355
356 void dump();
357 void buildLists(const std::shared_ptr<Entry> &root);
358 void addIncludes();
359 void startCompound( const XMLHandlers::Attributes& attrib );
360
362 {
363 switch (m_state)
364 {
365 case InClass:
366 case InConcept:
367 case InFile:
368 case InNamespace:
369 case InGroup:
370 case InPage:
371 case InDir:
372 case InModule:
373 case InPackage:
374 m_tagFileCompounds.push_back(std::move(m_curCompound));
375 break;
376 default:
377 p_warn("tag 'compound' was not expected!");
378 break;
379 }
380 }
381
383 {
385 m_curMember.kind = XMLHandlers::value(attrib,"kind");
386 QCString protStr = XMLHandlers::value(attrib,"protection");
387 QCString virtStr = XMLHandlers::value(attrib,"virtualness");
388 QCString staticStr = XMLHandlers::value(attrib,"static");
389 m_curMember.lineNr = m_locator->lineNr();
390 if (protStr=="protected")
391 {
392 m_curMember.prot = Protection::Protected;
393 }
394 else if (protStr=="private")
395 {
396 m_curMember.prot = Protection::Private;
397 }
398 if (virtStr=="virtual")
399 {
400 m_curMember.virt = Specifier::Virtual;
401 }
402 else if (virtStr=="pure")
403 {
404 m_curMember.virt = Specifier::Pure;
405 }
406 if (staticStr=="yes")
407 {
408 m_curMember.isStatic = TRUE;
409 }
410 m_stateStack.push(m_state);
412 }
413
415 {
416 m_state = m_stateStack.top();
417 m_stateStack.pop();
418 switch(m_state)
419 {
420 case InClass:
421 case InFile:
422 case InNamespace:
423 case InGroup:
424 case InPackage:
425 {
426 TagCompoundInfo *info = m_curCompound.getCompoundInfo();
427 if (info)
428 {
429 info->members.push_back(m_curMember);
430 }
431 }
432 break;
433 default:
434 p_warn("Unexpected tag 'member' found");
435 break;
436 }
437 }
438
440 {
441 if (m_state==InMember)
442 {
443 m_curString = "";
445 m_curEnumValue.file = XMLHandlers::value(attrib,"file");
446 m_curEnumValue.anchor = XMLHandlers::value(attrib,"anchor");
447 m_curEnumValue.clangid = XMLHandlers::value(attrib,"clangid");
448 m_stateStack.push(m_state);
450 }
451 else
452 {
453 p_warn("Found 'enumvalue' tag outside of member tag");
454 }
455 }
456
458 {
460 m_state = m_stateStack.top();
461 m_stateStack.pop();
462 if (m_state==InMember)
463 {
464 m_curMember.enumValues.push_back(m_curEnumValue);
466 }
467 }
468
470 {
471 // Check whether or not the tag is automatically generate, in that case ignore the tag.
472 switch(m_state)
473 {
474 case InClass:
475 case InConcept:
476 case InFile:
477 case InNamespace:
478 case InGroup:
479 case InPage:
480 case InMember:
481 case InPackage:
482 case InDir:
483 case InModule:
485 break;
486 default:
487 p_warn("Unexpected tag 'docanchor' found");
488 return;
489 }
490 switch(m_state)
491 {
492 case InClass:
493 case InConcept:
494 case InFile:
495 case InNamespace:
496 case InGroup:
497 case InPage:
498 case InPackage:
499 case InDir:
500 case InModule:
501 {
502 TagCompoundInfo *info = m_curCompound.getCompoundInfo();
503 if (info)
504 {
505 info->docAnchors.emplace_back(m_fileName,m_curString,m_title);
506 }
507 }
508 break;
509 case InMember:
510 m_curMember.docAnchors.emplace_back(m_fileName,m_curString,m_title);
511 break;
512 default: break; // will not be reached
513 }
514 }
515
516 void endClass()
517 {
518 switch(m_state)
519 {
520 case InClass:
521 {
522 TagClassInfo *info = m_curCompound.getClassInfo();
523 if (info) info->classList.push_back(m_curString.str());
524 }
525 break;
526 case InFile:
527 {
528 TagFileInfo *info = m_curCompound.getFileInfo();
529 if (info) info->classList.push_back(m_curString.str());
530 }
531 break;
532 case InNamespace:
533 {
534 TagNamespaceInfo *info = m_curCompound.getNamespaceInfo();
535 if (info) info->classList.push_back(m_curString.str());
536 }
537 break;
538 case InGroup:
539 {
540 TagGroupInfo *info = m_curCompound.getGroupInfo();
541 if (info) info->classList.push_back(m_curString.str());
542 }
543 break;
544 case InPackage:
545 {
546 TagPackageInfo *info = m_curCompound.getPackageInfo();
547 if (info) info->classList.push_back(m_curString.str());
548 }
549 break;
550 default:
551 p_warn("Unexpected tag 'class' found");
552 break;
553 }
554 }
555
557 {
558 switch(m_state)
559 {
560 case InNamespace:
561 {
562 TagNamespaceInfo *info = m_curCompound.getNamespaceInfo();
563 if (info) info->conceptList.push_back(m_curString.str());
564 }
565 break;
566 case InFile:
567 {
568 TagFileInfo *info = m_curCompound.getFileInfo();
569 if (info) info->conceptList.push_back(m_curString.str());
570 }
571 break;
572 case InGroup:
573 {
574 TagGroupInfo *info = m_curCompound.getGroupInfo();
575 if (info) info->conceptList.push_back(m_curString.str());
576 }
577 break;
578 default:
579 p_warn("Unexpected tag 'concept' found");
580 break;
581 }
582 }
583
585 {
586 switch(m_state)
587 {
588 case InGroup:
589 {
590 TagGroupInfo *info = m_curCompound.getGroupInfo();
591 if (info) info->moduleList.push_back(m_curString.str());
592 }
593 break;
594 default:
595 p_warn("Unexpected tag 'module' found");
596 break;
597 }
598 }
599
601 {
602 switch(m_state)
603 {
604 case InNamespace:
605 {
606 TagNamespaceInfo *info = m_curCompound.getNamespaceInfo();
607 if (info) info->namespaceList.push_back(m_curString.str());
608 }
609 break;
610 case InFile:
611 {
612 TagFileInfo *info = m_curCompound.getFileInfo();
613 if (info) info->namespaceList.push_back(m_curString.str());
614 }
615 break;
616 case InGroup:
617 {
618 TagGroupInfo *info = m_curCompound.getGroupInfo();
619 if (info) info->namespaceList.push_back(m_curString.str());
620 }
621 break;
622 default:
623 p_warn("Unexpected tag 'namespace' found");
624 break;
625 }
626 }
627
628 void endFile()
629 {
630 switch(m_state)
631 {
632 case InGroup:
633 {
634 TagGroupInfo *info = m_curCompound.getGroupInfo();
635 if (info) info->fileList.push_back(m_curString.str());
636 }
637 break;
638 case InDir:
639 {
640 TagDirInfo *info = m_curCompound.getDirInfo();
641 if (info) info->fileList.push_back(m_curString.str());
642 }
643 break;
644 default:
645 p_warn("Unexpected tag 'file' found");
646 break;
647 }
648 }
649
650 void endPage()
651 {
652 switch(m_state)
653 {
654 case InGroup:
655 {
656 TagGroupInfo *info = m_curCompound.getGroupInfo();
657 if (info) info->fileList.push_back(m_curString.str());
658 }
659 break;
660 default:
661 p_warn("Unexpected tag 'page' found");
662 break;
663 }
664 }
665
667 {
668 switch(m_state)
669 {
670 case InPage:
671 {
672 TagPageInfo *info = m_curCompound.getPageInfo();
673 if (info) info->subpages.push_back(m_curString.str());
674 }
675 break;
676 default:
677 p_warn("Unexpected tag 'subpage' found");
678 break;
679 }
680 }
681
682 void endDir()
683 {
684 switch(m_state)
685 {
686 case InDir:
687 {
688 TagDirInfo *info = m_curCompound.getDirInfo();
689 if (info) info->subdirList.push_back(m_curString.str());
690 }
691 break;
692 default:
693 p_warn("Unexpected tag 'dir' found");
694 break;
695 }
696 }
697
699 {
700 m_curString = "";
701 }
702
704 {
705 m_fileName = XMLHandlers::value(attrib,"file");
706 m_title = XMLHandlers::value(attrib,"title");
707 m_curString = "";
708 }
709
710 void endType()
711 {
712 if (m_state==InMember)
713 {
715 }
716 else
717 {
718 p_warn("Unexpected tag 'type' found");
719 }
720 }
721
722 void endName()
723 {
724 switch (m_state)
725 {
726 case InClass:
727 case InConcept:
728 case InFile:
729 case InNamespace:
730 case InGroup:
731 case InPage:
732 case InDir:
733 case InPackage:
734 case InModule:
735 {
736 TagCompoundInfo *info = m_curCompound.getCompoundInfo();
737 if (info) info->name = m_curString;
738 }
739 break;
740 case InMember:
742 break;
743 default:
744 p_warn("Unexpected tag 'name' found");
745 break;
746 }
747 }
748
750 {
751 m_curString="";
752 TagClassInfo *info = m_curCompound.getClassInfo();
753 if (m_state==InClass && info)
754 {
755 QCString protStr = XMLHandlers::value(attrib,"protection");
756 QCString virtStr = XMLHandlers::value(attrib,"virtualness");
757 Protection prot = Protection::Public;
758 Specifier virt = Specifier::Normal;
759 if (protStr=="protected")
760 {
761 prot = Protection::Protected;
762 }
763 else if (protStr=="private")
764 {
765 prot = Protection::Private;
766 }
767 if (virtStr=="virtual")
768 {
769 virt = Specifier::Virtual;
770 }
771 info->bases.emplace_back(m_curString,prot,virt);
772 }
773 else
774 {
775 p_warn("Unexpected tag 'base' found");
776 }
777 }
778
779 void endBase()
780 {
781 TagClassInfo *info = m_curCompound.getClassInfo();
782 if (m_state==InClass && info)
783 {
784 info->bases.back().name = m_curString;
785 }
786 else
787 {
788 p_warn("Unexpected tag 'base' found");
789 }
790 }
791
793 {
795 m_curIncludes.id = XMLHandlers::value(attrib,"id");
796 m_curIncludes.name = XMLHandlers::value(attrib,"name");
797 m_curIncludes.isLocal = XMLHandlers::value(attrib,"local")=="yes";
798 m_curIncludes.isImported = XMLHandlers::value(attrib,"imported")=="yes";
799 m_curIncludes.isModule = XMLHandlers::value(attrib,"module")=="yes";
800 m_curIncludes.isObjC = XMLHandlers::value(attrib,"objc")=="yes";
801 m_curString="";
802 }
803
805 {
807 TagFileInfo *info = m_curCompound.getFileInfo();
808 if (m_state==InFile && info)
809 {
810 info->includes.push_back(m_curIncludes);
811 }
812 else
813 {
814 p_warn("Unexpected tag 'includes' found");
815 }
816 }
817
819 {
820 TagClassInfo *info = m_curCompound.getClassInfo();
821 if (m_state==InClass && info)
822 {
823 info->templateArguments.push_back(m_curString.str());
824 }
825 else
826 {
827 p_warn("Unexpected tag 'templarg' found");
828 }
829 }
830
832 {
833 switch (m_state)
834 {
835 case InClass:
836 case InConcept:
837 case InNamespace:
838 case InFile:
839 case InGroup:
840 case InPage:
841 case InPackage:
842 case InDir:
843 case InModule:
844 {
845 TagCompoundInfo *info = m_curCompound.getCompoundInfo();
846 if (info) info->filename = m_curString;
847 }
848 break;
849 default:
850 p_warn("Unexpected tag 'filename' found");
851 break;
852 }
853 }
854
855 void endPath()
856 {
857 switch (m_state)
858 {
859 case InFile:
860 {
861 TagFileInfo *info = m_curCompound.getFileInfo();
862 if (info) info->path = m_curString;
863 }
864 break;
865 case InDir:
866 {
867 TagDirInfo *info = m_curCompound.getDirInfo();
868 if (info) info->path = m_curString;
869 }
870 break;
871 default:
872 p_warn("Unexpected tag 'path' found");
873 break;
874 }
875 }
876
878 {
879 if (m_state==InMember)
880 {
881 m_curMember.anchor = m_curString;
882 }
883 else if (m_state==InClass)
884 {
885 TagClassInfo *info = m_curCompound.getClassInfo();
886 if (info) info->anchor = m_curString;
887 }
888 else
889 {
890 p_warn("Unexpected tag 'anchor' found");
891 }
892 }
893
895 {
896 if (m_state==InMember)
897 {
898 m_curMember.clangId = m_curString;
899 }
900 else if (m_state==InClass)
901 {
902 TagClassInfo *info = m_curCompound.getClassInfo();
903 if (info) info->clangId = m_curString;
904 }
905 else if (m_state==InNamespace)
906 {
907 TagNamespaceInfo *info = m_curCompound.getNamespaceInfo();
908 if (info) info->clangId = m_curString;
909 }
910 else
911 {
912 p_warn("Unexpected tag 'clangid' found");
913 }
914 }
915
916
917
919 {
920 if (m_state==InMember)
921 {
922 m_curMember.anchorFile = m_curString;
923 }
924 else
925 {
926 p_warn("Unexpected tag 'anchorfile' found");
927 }
928 }
929
931 {
932 if (m_state==InMember)
933 {
934 m_curMember.arglist = m_curString;
935 }
936 else
937 {
938 p_warn("Unexpected tag 'arglist' found");
939 }
940 }
941
942 void endTitle()
943 {
944 switch (m_state)
945 {
946 case InGroup:
947 {
948 TagGroupInfo *info = m_curCompound.getGroupInfo();
949 if (info) info->title = m_curString;
950 }
951 break;
952 case InPage:
953 {
954 TagPageInfo *info = m_curCompound.getPageInfo();
955 if (info) info->title = m_curString;
956 }
957 break;
958 default:
959 p_warn("Unexpected tag 'title' found");
960 break;
961 }
962 }
963
965 {
966 if (m_state==InGroup)
967 {
968 TagGroupInfo *info = m_curCompound.getGroupInfo();
969 if (info) info->subgroupList.push_back(m_curString.str());
970 }
971 else
972 {
973 p_warn("Unexpected tag 'subgroup' found");
974 }
975 }
976
980
982 {
983 }
984
985 void buildMemberList(const std::shared_ptr<Entry> &ce,const std::vector<TagMemberInfo> &members);
986 void addDocAnchors(const std::shared_ptr<Entry> &e,const std::vector<TagAnchorInfo> &l);
987
988
1002 };
1003 private:
1004
1006 {
1007 ClassNode(const std::string &n) : name(n) {}
1008 std::string name;
1009 const TagClassInfo *tci = nullptr;
1010 std::unordered_map<std::string,std::unique_ptr<ClassNode>> children;
1011 };
1012
1013 void buildClassEntry(const std::shared_ptr<Entry> &root, const TagClassInfo *tci);
1014 void buildClassTree(const std::shared_ptr<Entry> &root, const ClassNode &node);
1015 //------------------------------------
1016
1017 std::vector< TagCompoundVariant > m_tagFileCompounds;
1019
1023
1029 std::stack<State> m_stateStack;
1030 const XMLLocator *m_locator = nullptr;
1031};
1032
1033//---------------------------------------------------------------------------------------------------------------
1034
1036{
1037 using StartCallback = std::function<void(TagFileParser&,const XMLHandlers::Attributes&)>;
1038 using EndCallback = std::function<void(TagFileParser&)>;
1039
1042};
1043
1045{
1046 return [fn](TagFileParser &parser,const XMLHandlers::Attributes &attr) { (parser.*fn)(attr); };
1047}
1048
1050{
1051 return [fn](TagFileParser &parser) { (parser.*fn)(); };
1052}
1053
1054static const std::map< std::string, ElementCallbacks > g_elementHandlers =
1055{
1056 // name, start element callback, end element callback
1083};
1084
1085//---------------------------------------------------------------------------------------------------------------
1086
1094
1095static const std::map< std::string, CompoundFactory > g_compoundFactory =
1096{
1097 // kind tag state creation function
1108 { "file", { TagFileParser::InFile, []() { return TagCompoundVariant::make<TagFileInfo>(); } } },
1109 { "namespace", { TagFileParser::InNamespace, []() { return TagCompoundVariant::make<TagNamespaceInfo>(); } } },
1110 { "concept", { TagFileParser::InConcept, []() { return TagCompoundVariant::make<TagConceptInfo>(); } } },
1111 { "module", { TagFileParser::InModule, []() { return TagCompoundVariant::make<TagModuleInfo>(); } } },
1112 { "group", { TagFileParser::InGroup, []() { return TagCompoundVariant::make<TagGroupInfo>(); } } },
1113 { "page", { TagFileParser::InPage, []() { return TagCompoundVariant::make<TagPageInfo>(); } } },
1114 { "package", { TagFileParser::InPackage, []() { return TagCompoundVariant::make<TagPackageInfo>(); } } },
1115 { "dir", { TagFileParser::InDir, []() { return TagCompoundVariant::make<TagDirInfo>(); } } }
1116};
1117
1118//---------------------------------------------------------------------------------------------------------------
1119
1121{
1122 //printf("startElement '%s'\n",qPrint(name));
1123 auto it = g_elementHandlers.find(name.str());
1124 if (it!=std::end(g_elementHandlers))
1125 {
1126 it->second.startCb(*this,attrib);
1127 }
1128 else
1129 {
1130 p_warn("Unknown start tag '{}' found!",name);
1131 }
1132}
1133
1135{
1136 //printf("endElement '%s'\n",qPrint(name));
1137 auto it = g_elementHandlers.find(name.str());
1138 if (it!=std::end(g_elementHandlers))
1139 {
1140 it->second.endCb(*this);
1141 }
1142 else
1143 {
1144 p_warn("Unknown end tag '{}' found!",name);
1145 }
1146}
1147
1149{
1150 m_curString = "";
1151 std::string kind = XMLHandlers::value(attrib,"kind");
1152 std::string isObjC = XMLHandlers::value(attrib,"objc");
1153
1154 auto it = g_compoundFactory.find(kind);
1155 if (it!=g_compoundFactory.end())
1156 {
1157 m_curCompound = it->second.make_instance();
1158 m_state = it->second.state;
1159 TagCompoundInfo *info = m_curCompound.getCompoundInfo();
1160 if (info) info->lineNr = m_locator->lineNr();
1161 }
1162 else
1163 {
1164 p_warn("Unknown compound attribute '{}' found!",kind);
1165 m_state = Invalid;
1166 }
1167
1168 TagClassInfo *classInfo = m_curCompound.getClassInfo();
1169 if (isObjC=="yes" && classInfo)
1170 {
1171 classInfo->isObjC = TRUE;
1172 }
1173}
1174
1175/*! Dumps the internal structures. For debugging only! */
1177{
1178 Debug::print(Debug::Tag,0,"-------- Results --------\n");
1179 //============== CLASSES
1180 for (const auto &comp : m_tagFileCompounds)
1181 {
1182 if (comp.type()==TagCompoundVariant::Type::Class)
1183 {
1184 const TagClassInfo *cd = comp.getClassInfo();
1185 Debug::print(Debug::Tag,0,"class '{}'\n",cd->name);
1186 Debug::print(Debug::Tag,0," filename '{}'\n",cd->filename);
1187 for (const BaseInfo &bi : cd->bases)
1188 {
1189 Debug::print(Debug::Tag,0, " base: {}\n",bi.name);
1190 }
1191
1192 for (const auto &md : cd->members)
1193 {
1194 Debug::print(Debug::Tag,0," member:\n");
1195 Debug::print(Debug::Tag,0," kind: '{}'\n",md.kind);
1196 Debug::print(Debug::Tag,0," name: '{}'\n",md.name);
1197 Debug::print(Debug::Tag,0," anchor: '{}'\n",md.anchor);
1198 Debug::print(Debug::Tag,0," arglist: '{}'\n",md.arglist);
1199 }
1200 }
1201 }
1202 //============== CONCEPTS
1203 for (const auto &comp : m_tagFileCompounds)
1204 {
1205 if (comp.type()==TagCompoundVariant::Type::Concept)
1206 {
1207 const TagConceptInfo *cd = comp.getConceptInfo();
1208
1209 Debug::print(Debug::Tag,0,"concept '{}'\n",cd->name);
1210 Debug::print(Debug::Tag,0," filename '{}'\n",cd->filename);
1211 }
1212 }
1213 //============== MODULES
1214 for (const auto &comp : m_tagFileCompounds)
1215 {
1216 if (comp.type()==TagCompoundVariant::Type::Module)
1217 {
1218 const TagModuleInfo *mi = comp.getModuleInfo();
1219
1220 Debug::print(Debug::Tag,0,"module '{}'\n",mi->name);
1221 Debug::print(Debug::Tag,0," filename '{}'\n",mi->filename);
1222 }
1223 }
1224 //============== NAMESPACES
1225 for (const auto &comp : m_tagFileCompounds)
1226 {
1227 if (comp.type()==TagCompoundVariant::Type::Namespace)
1228 {
1229 const TagNamespaceInfo *nd = comp.getNamespaceInfo();
1230
1231 Debug::print(Debug::Tag,0,"namespace '{}'\n",nd->name);
1232 Debug::print(Debug::Tag,0," filename '{}'\n",nd->filename);
1233 for (const auto &cls : nd->classList)
1234 {
1235 Debug::print(Debug::Tag,0, " class: {}\n",cls);
1236 }
1237
1238 for (const auto &md : nd->members)
1239 {
1240 Debug::print(Debug::Tag,0," member:\n");
1241 Debug::print(Debug::Tag,0," kind: '{}'\n",md.kind);
1242 Debug::print(Debug::Tag,0," name: '{}'\n",md.name);
1243 Debug::print(Debug::Tag,0," anchor: '{}'\n",md.anchor);
1244 Debug::print(Debug::Tag,0," arglist: '{}'\n",md.arglist);
1245 }
1246 }
1247 }
1248
1249 //============== FILES
1250 for (const auto &comp : m_tagFileCompounds)
1251 {
1252 if (comp.type()==TagCompoundVariant::Type::File)
1253 {
1254 const TagFileInfo *fd = comp.getFileInfo();
1255
1256 Debug::print(Debug::Tag,0,"file '{}'\n",fd->name);
1257 Debug::print(Debug::Tag,0," filename '{}'\n",fd->filename);
1258 for (const auto &ns : fd->namespaceList)
1259 {
1260 Debug::print(Debug::Tag,0, " namespace: {}\n",ns);
1261 }
1262 for (const auto &cs : fd->classList)
1263 {
1264 Debug::print(Debug::Tag,0, " class: {} \n",cs);
1265 }
1266
1267 for (const auto &md : fd->members)
1268 {
1269 Debug::print(Debug::Tag,0," member:\n");
1270 Debug::print(Debug::Tag,0," kind: '{}'\n",md.kind);
1271 Debug::print(Debug::Tag,0," name: '{}'\n",md.name);
1272 Debug::print(Debug::Tag,0," anchor: '{}'\n",md.anchor);
1273 Debug::print(Debug::Tag,0," arglist: '{}'\n",md.arglist);
1274 }
1275
1276 for (const auto &ii : fd->includes)
1277 {
1278 Debug::print(Debug::Tag,0," includes id: {} name: {}\n",ii.id,ii.name);
1279 }
1280 }
1281 }
1282
1283 //============== GROUPS
1284 for (const auto &comp : m_tagFileCompounds)
1285 {
1286 if (comp.type()==TagCompoundVariant::Type::Group)
1287 {
1288 const TagGroupInfo *gd = comp.getGroupInfo();
1289 Debug::print(Debug::Tag,0,"group '{}'\n",gd->name);
1290 Debug::print(Debug::Tag,0," filename '{}'\n",gd->filename);
1291
1292 for (const auto &ns : gd->namespaceList)
1293 {
1294 Debug::print(Debug::Tag,0, " namespace: {}\n",ns);
1295 }
1296 for (const auto &cs : gd->classList)
1297 {
1298 Debug::print(Debug::Tag,0, " class: {}\n",cs);
1299 }
1300 for (const auto &fi : gd->fileList)
1301 {
1302 Debug::print(Debug::Tag,0, " file: {}\n",fi);
1303 }
1304 for (const auto &sg : gd->subgroupList)
1305 {
1306 Debug::print(Debug::Tag,0, " subgroup: {}\n",sg);
1307 }
1308 for (const auto &pg : gd->pageList)
1309 {
1310 Debug::print(Debug::Tag,0, " page: {}\n",pg);
1311 }
1312
1313 for (const auto &md : gd->members)
1314 {
1315 Debug::print(Debug::Tag,0," member:\n");
1316 Debug::print(Debug::Tag,0," kind: '{}'\n",md.kind);
1317 Debug::print(Debug::Tag,0," name: '{}'\n",md.name);
1318 Debug::print(Debug::Tag,0," anchor: '{}'\n",md.anchor);
1319 Debug::print(Debug::Tag,0," arglist: '{}'\n",md.arglist);
1320 }
1321 }
1322 }
1323
1324 //============== PAGES
1325 for (const auto &comp : m_tagFileCompounds)
1326 {
1327 if (comp.type()==TagCompoundVariant::Type::Page)
1328 {
1329 const TagPageInfo *pd = comp.getPageInfo();
1330 Debug::print(Debug::Tag,0,"page '{}'\n",pd->name);
1331 Debug::print(Debug::Tag,0," title '{}'\n",pd->title);
1332 Debug::print(Debug::Tag,0," filename '{}'\n",pd->filename);
1333 }
1334 }
1335
1336 //============== DIRS
1337 for (const auto &comp : m_tagFileCompounds)
1338 {
1339 if (comp.type()==TagCompoundVariant::Type::Dir)
1340 {
1341 const TagDirInfo *dd = comp.getDirInfo();
1342 {
1343 Debug::print(Debug::Tag,0,"dir '{}'\n",dd->name);
1344 Debug::print(Debug::Tag,0," path '{}'\n",dd->path);
1345 for (const auto &fi : dd->fileList)
1346 {
1347 Debug::print(Debug::Tag,0, " file: {}\n",fi);
1348 }
1349 for (const auto &sd : dd->subdirList)
1350 {
1351 Debug::print(Debug::Tag,0, " subdir: {}\n",sd);
1352 }
1353 }
1354 }
1355 }
1356 Debug::print(Debug::Tag,0,"-------------------------\n");
1357}
1358
1359void TagFileParser::addDocAnchors(const std::shared_ptr<Entry> &e,const std::vector<TagAnchorInfo> &l)
1360{
1361 for (const auto &ta : l)
1362 {
1363 if (SectionManager::instance().find(QCString(ta.label))==nullptr)
1364 {
1365 //printf("New sectionInfo file=%s anchor=%s\n",
1366 // qPrint(ta->fileName),qPrint(ta->label));
1368 ta.label,ta.fileName,-1,ta.title,
1370 e->anchors.push_back(si);
1371 }
1372 else
1373 {
1374 //printf("Replace sectionInfo file=%s anchor=%s\n",
1375 // qPrint(ta->fileName),qPrint(ta->label));
1377 ta.label,ta.fileName,-1,ta.title,
1379 }
1380 }
1381}
1382
1383void TagFileParser::buildMemberList(const std::shared_ptr<Entry> &ce,const std::vector<TagMemberInfo> &members)
1384{
1385 for (const auto &tmi : members)
1386 {
1387 std::shared_ptr<Entry> me = std::make_shared<Entry>();
1388 me->type = tmi.type;
1389 me->name = tmi.name;
1390 me->args = tmi.arglist;
1391 if (!me->args.isEmpty())
1392 {
1393 me->argList = *stringToArgumentList(SrcLangExt::Cpp,me->args);
1394 }
1395 if (tmi.enumValues.size()>0)
1396 {
1397 me->spec.setStrong(true);
1398 for (const auto &evi : tmi.enumValues)
1399 {
1400 std::shared_ptr<Entry> ev = std::make_shared<Entry>();
1401 ev->type = "@";
1402 ev->name = evi.name;
1403 ev->id = evi.clangid;
1404 ev->section = EntryType::makeVariable();
1405 ev->tagInfoData.tagName = m_tagName;
1406 ev->tagInfoData.anchor = evi.anchor;
1407 ev->tagInfoData.fileName = evi.file;
1408 ev->hasTagInfo = TRUE;
1409 me->moveToSubEntryAndKeep(ev);
1410 }
1411 }
1412 me->protection = tmi.prot;
1413 me->virt = tmi.virt;
1414 me->isStatic = tmi.isStatic;
1415 me->fileName = ce->fileName;
1416 me->id = tmi.clangId;
1417 me->startLine = tmi.lineNr;
1418 if (ce->section.isGroupDoc())
1419 {
1420 me->groups.emplace_back(ce->name,Grouping::GROUPING_INGROUP);
1421 }
1422 addDocAnchors(me,tmi.docAnchors);
1423 me->tagInfoData.tagName = m_tagName;
1424 me->tagInfoData.anchor = tmi.anchor;
1425 me->tagInfoData.fileName = tmi.anchorFile;
1426 me->hasTagInfo = TRUE;
1427 if (tmi.kind=="define")
1428 {
1429 me->type="#define";
1430 me->section = EntryType::makeDefine();
1431 }
1432 else if (tmi.kind=="enumvalue")
1433 {
1434 me->section = EntryType::makeVariable();
1435 me->mtype = MethodTypes::Method;
1436 }
1437 else if (tmi.kind=="property")
1438 {
1439 me->section = EntryType::makeVariable();
1440 me->mtype = MethodTypes::Property;
1441 }
1442 else if (tmi.kind=="event")
1443 {
1444 me->section = EntryType::makeVariable();
1445 me->mtype = MethodTypes::Event;
1446 }
1447 else if (tmi.kind=="variable")
1448 {
1449 me->section = EntryType::makeVariable();
1450 me->mtype = MethodTypes::Method;
1451 }
1452 else if (tmi.kind=="typedef")
1453 {
1454 me->section = EntryType::makeVariable();
1455 me->type.prepend("typedef ");
1456 me->mtype = MethodTypes::Method;
1457 }
1458 else if (tmi.kind=="enumeration")
1459 {
1460 me->section = EntryType::makeEnum();
1461 me->mtype = MethodTypes::Method;
1462 }
1463 else if (tmi.kind=="function")
1464 {
1465 me->section = EntryType::makeFunction();
1466 me->mtype = MethodTypes::Method;
1467 }
1468 else if (tmi.kind=="signal")
1469 {
1470 me->section = EntryType::makeFunction();
1471 me->mtype = MethodTypes::Signal;
1472 }
1473 else if (tmi.kind=="prototype")
1474 {
1475 me->section = EntryType::makeFunction();
1476 me->mtype = MethodTypes::Method;
1477 }
1478 else if (tmi.kind=="friend")
1479 {
1480 me->section = EntryType::makeFunction();
1481 me->type.prepend("friend ");
1482 me->mtype = MethodTypes::Method;
1483 }
1484 else if (tmi.kind=="dcop")
1485 {
1486 me->section = EntryType::makeFunction();
1487 me->mtype = MethodTypes::DCOP;
1488 }
1489 else if (tmi.kind=="slot")
1490 {
1491 me->section = EntryType::makeFunction();
1492 me->mtype = MethodTypes::Slot;
1493 }
1494 ce->moveToSubEntryAndKeep(me);
1495 }
1496}
1497
1498void TagFileParser::buildClassEntry(const std::shared_ptr<Entry> &root, const TagClassInfo *tci)
1499{
1500 std::shared_ptr<Entry> ce = std::make_shared<Entry>();
1501 ce->section = EntryType::makeClass();
1502 switch (tci->kind)
1503 {
1504 case TagClassInfo::Kind::Class: break;
1505 case TagClassInfo::Kind::Struct: ce->spec = TypeSpecifier().setStruct(true); break;
1506 case TagClassInfo::Kind::Union: ce->spec = TypeSpecifier().setUnion(true); break;
1507 case TagClassInfo::Kind::Interface: ce->spec = TypeSpecifier().setInterface(true); break;
1508 case TagClassInfo::Kind::Enum: ce->spec = TypeSpecifier().setEnum(true); break;
1509 case TagClassInfo::Kind::Exception: ce->spec = TypeSpecifier().setException(true); break;
1510 case TagClassInfo::Kind::Protocol: ce->spec = TypeSpecifier().setProtocol(true); break;
1511 case TagClassInfo::Kind::Category: ce->spec = TypeSpecifier().setCategory(true); break;
1512 case TagClassInfo::Kind::Service: ce->spec = TypeSpecifier().setService(true); break;
1513 case TagClassInfo::Kind::Singleton: ce->spec = TypeSpecifier().setSingleton(true); break;
1514 case TagClassInfo::Kind::None: // should never happen, means not properly initialized
1515 assert(tci->kind != TagClassInfo::Kind::None);
1516 break;
1517 }
1518 ce->name = tci->name;
1520 {
1521 ce->name+="-p";
1522 }
1523 addDocAnchors(ce,tci->docAnchors);
1524 ce->tagInfoData.tagName = m_tagName;
1525 ce->tagInfoData.anchor = tci->anchor;
1526 ce->tagInfoData.fileName = tci->filename;
1527 ce->startLine = tci->lineNr;
1528 ce->fileName = m_tagName;
1529 ce->hasTagInfo = TRUE;
1530 ce->id = tci->clangId;
1531 ce->lang = tci->isObjC ? SrcLangExt::ObjC : SrcLangExt::Unknown;
1532 // transfer base class list
1533 ce->extends = tci->bases;
1534 if (!tci->templateArguments.empty())
1535 {
1536 ArgumentList al;
1537 for (const auto &argName : tci->templateArguments)
1538 {
1539 Argument a;
1540 a.type = "class";
1541 a.name = argName.c_str();
1542 al.push_back(a);
1543 }
1544 ce->tArgLists.push_back(al);
1545 }
1546
1547 buildMemberList(ce,tci->members);
1548 root->moveToSubEntryAndKeep(ce);
1549}
1550
1551void TagFileParser::buildClassTree(const std::shared_ptr<Entry> &root,const ClassNode &node)
1552{
1553 if (node.tci)
1554 {
1555 buildClassEntry(root,node.tci);
1556 }
1557 for (const auto &child : node.children)
1558 {
1559 buildClassTree(root,*child.second);
1560 }
1561}
1562
1563/*! Injects the info gathered by the XML parser into the Entry tree.
1564 * This tree contains the information extracted from the input in a
1565 * "unrelated" form.
1566 */
1567void TagFileParser::buildLists(const std::shared_ptr<Entry> &root)
1568{
1569 // First reorganize the entries in m_tagFileCompounds such that
1570 // outer scope is processed before the nested class scope.
1571 // To solve issue #11569, where a class nested in a specialization is
1572 // processed first, which later causes the wrong class to be used
1573 ClassNode classRoot("");
1574 for (const auto &comp : m_tagFileCompounds)
1575 {
1576 const TagClassInfo *tci = comp.getClassInfo();
1577 if (tci)
1578 {
1579 ClassNode *current = &classRoot;
1580 auto parts = split(tci->name.str(),"::");
1581 for (size_t i=0; i<parts.size(); ++i)
1582 {
1583 const auto &part = parts[i];
1584 if (current->children.find(part)==current->children.end()) // new child node
1585 {
1586 current->children[part] = std::make_unique<ClassNode>(part);
1587 }
1588 current = current->children[part].get();
1589 if (i==parts.size()-1)
1590 {
1591 current->tci = tci;
1592 }
1593 }
1594 }
1595 }
1596
1597 // now process the classes following the tree structure
1598 buildClassTree(root,classRoot);
1599
1600
1601 // build file list
1602 for (const auto &comp : m_tagFileCompounds)
1603 {
1604 const TagFileInfo *tfi = comp.getFileInfo();
1605 if (tfi)
1606 {
1607 std::shared_ptr<Entry> fe = std::make_shared<Entry>();
1608 fe->section = guessSection(tfi->name);
1609 fe->name = tfi->name;
1610 addDocAnchors(fe,tfi->docAnchors);
1611 fe->tagInfoData.tagName = m_tagName;
1612 fe->tagInfoData.fileName = tfi->filename;
1613 fe->hasTagInfo = TRUE;
1614
1615 QCString fullName = m_tagName+":"+tfi->path+stripPath(tfi->name);
1616 fe->fileName = fullName;
1617 fe->startLine = tfi->lineNr;
1618 //printf("createFileDef() filename=%s\n",qPrint(tfi->filename));
1619 QCString tagid = m_tagName+":"+tfi->path;
1620 auto fd = createFileDef(tagid, tfi->name,m_tagName, tfi->filename);
1621 FileName *mn = Doxygen::inputNameLinkedMap->find(tfi->name);
1622 if (mn)
1623 {
1624 mn->push_back(std::move(fd));
1625 }
1626 else
1627 {
1628 mn = Doxygen::inputNameLinkedMap->add(tfi->name,fullName);
1629 mn->push_back(std::move(fd));
1630 }
1631 buildMemberList(fe,tfi->members);
1632 root->moveToSubEntryAndKeep(fe);
1633 }
1634 }
1635
1636 // build concept list
1637 for (const auto &comp : m_tagFileCompounds)
1638 {
1639 const TagConceptInfo *tci = comp.getConceptInfo();
1640 if (tci)
1641 {
1642 std::shared_ptr<Entry> ce = std::make_shared<Entry>();
1643 ce->section = EntryType::makeConcept();
1644 ce->name = tci->name;
1645 addDocAnchors(ce,tci->docAnchors);
1646 ce->tagInfoData.tagName = m_tagName;
1647 ce->tagInfoData.fileName = tci->filename;
1648 ce->startLine = tci->lineNr;
1649 ce->fileName = m_tagName;
1650 ce->hasTagInfo = TRUE;
1651 ce->id = tci->clangId;
1652
1653 root->moveToSubEntryAndKeep(ce);
1654 }
1655 }
1656
1657 // build module list
1658 for (const auto &comp : m_tagFileCompounds)
1659 {
1660 const TagModuleInfo *tmi = comp.getModuleInfo();
1661 if (tmi)
1662 {
1663 auto &mm = ModuleManager::instance();
1664 mm.createModuleDef(tmi->filename,tmi->lineNr,1,true,tmi->name,QCString());
1665 mm.addTagInfo(tmi->filename,m_tagName,tmi->clangId);
1666
1667 ModuleDef *mod = mm.getPrimaryInterface(tmi->name);
1668 if (mod && !tmi->docAnchors.empty())
1669 {
1670 std::vector<const SectionInfo *> anchorList;
1671 for (const auto &ta : tmi->docAnchors)
1672 {
1673 if (SectionManager::instance().find(QCString(ta.label))==nullptr)
1674 {
1675 //printf("New sectionInfo file=%s anchor=%s\n",
1676 // qPrint(ta->fileName),qPrint(ta->label));
1678 ta.label,ta.fileName,-1,ta.title,
1680 anchorList.push_back(si);
1681 }
1682 else
1683 {
1684 p_warn("Duplicate anchor {} found",ta.label);
1685 }
1686 }
1687 mod->addSectionsToDefinition(anchorList);
1688 }
1689 }
1690 }
1691
1692
1693 // build namespace list
1694 for (const auto &comp : m_tagFileCompounds)
1695 {
1696 const TagNamespaceInfo *tni = comp.getNamespaceInfo();
1697 if (tni)
1698 {
1699 std::shared_ptr<Entry> ne = std::make_shared<Entry>();
1700 ne->section = EntryType::makeNamespace();
1701 ne->name = tni->name;
1702 addDocAnchors(ne,tni->docAnchors);
1703 ne->tagInfoData.tagName = m_tagName;
1704 ne->tagInfoData.fileName = tni->filename;
1705 ne->startLine = tni->lineNr;
1706 ne->fileName = m_tagName;
1707 ne->hasTagInfo = TRUE;
1708 ne->id = tni->clangId;
1709
1710 buildMemberList(ne,tni->members);
1711 root->moveToSubEntryAndKeep(ne);
1712 }
1713 }
1714
1715 // build package list
1716 for (const auto &comp : m_tagFileCompounds)
1717 {
1718 const TagPackageInfo *tpgi = comp.getPackageInfo();
1719 if (tpgi)
1720 {
1721 std::shared_ptr<Entry> pe = std::make_shared<Entry>();
1722 pe->section = EntryType::makePackage();
1723 pe->name = tpgi->name;
1724 addDocAnchors(pe,tpgi->docAnchors);
1725 pe->tagInfoData.tagName = m_tagName;
1726 pe->tagInfoData.fileName = tpgi->filename;
1727 pe->startLine = tpgi->lineNr;
1728 pe->fileName = m_tagName;
1729 pe->hasTagInfo = TRUE;
1730
1731 buildMemberList(pe,tpgi->members);
1732 root->moveToSubEntryAndKeep(pe);
1733 }
1734 }
1735
1736 // build group list
1737 for (const auto &comp : m_tagFileCompounds)
1738 {
1739 const TagGroupInfo *tgi = comp.getGroupInfo();
1740 if (tgi)
1741 {
1742 std::shared_ptr<Entry> ge = std::make_shared<Entry>();
1743 ge->section = EntryType::makeGroupDoc();
1744 ge->name = tgi->name;
1745 ge->type = tgi->title;
1746 addDocAnchors(ge,tgi->docAnchors);
1747 ge->tagInfoData.tagName = m_tagName;
1748 ge->tagInfoData.fileName = tgi->filename;
1749 ge->startLine = tgi->lineNr;
1750 ge->fileName = m_tagName;
1751 ge->hasTagInfo = TRUE;
1752
1753 buildMemberList(ge,tgi->members);
1754 root->moveToSubEntryAndKeep(ge);
1755 }
1756 }
1757
1758 for (const auto &comp : m_tagFileCompounds)
1759 {
1760 const TagGroupInfo *tgi = comp.getGroupInfo();
1761 if (tgi)
1762 {
1763 // set subgroup relations bug_774118
1764 for (const auto &sg : tgi->subgroupList)
1765 {
1766 const auto &children = root->children();
1767 auto i = std::find_if(children.begin(),children.end(),
1768 [&](const std::shared_ptr<Entry> &e) { return e->name == sg.c_str(); });
1769 if (i!=children.end())
1770 {
1771 (*i)->groups.emplace_back(tgi->name,Grouping::GROUPING_INGROUP);
1772 }
1773 }
1774 }
1775 }
1776
1777 // build page list
1778 for (const auto &comp : m_tagFileCompounds)
1779 {
1780 const TagPageInfo *tpi = comp.getPageInfo();
1781 if (tpi)
1782 {
1783 std::shared_ptr<Entry> pe = std::make_shared<Entry>();
1784 bool isIndex = (stripExtensionGeneral(tpi->filename,getFileNameExtension(tpi->filename))=="index");
1785 pe->section = isIndex ? EntryType::makeMainpageDoc() : EntryType::makePageDoc();
1786 pe->name = tpi->name;
1787 pe->args = tpi->title;
1788 for (const auto &subpage : tpi->subpages)
1789 {
1790 // we add subpage labels as a kind of "inheritance" relation to prevent
1791 // needing to add another list to the Entry class.
1792 pe->extends.emplace_back(stripExtension(QCString(subpage)),Protection::Public,Specifier::Normal);
1793 }
1794 addDocAnchors(pe,tpi->docAnchors);
1795 pe->tagInfoData.tagName = m_tagName;
1796 pe->tagInfoData.fileName = stripExtension(tpi->filename);
1797 pe->startLine = tpi->lineNr;
1798 pe->fileName = m_tagName;
1799 pe->hasTagInfo = TRUE;
1800 root->moveToSubEntryAndKeep(pe);
1801 }
1802 }
1803}
1804
1806{
1807 for (const auto &comp : m_tagFileCompounds)
1808 {
1809 const TagFileInfo *tfi = comp.getFileInfo();
1810 if (tfi)
1811 {
1812 //printf("tag file tagName=%s path=%s name=%s\n",qPrint(m_tagName),qPrint(tfi->path),qPrint(tfi->name));
1813 FileName *fn = Doxygen::inputNameLinkedMap->find(tfi->name);
1814 if (fn)
1815 {
1816 for (const auto &fd : *fn)
1817 {
1818 //printf("input file path=%s name=%s\n",qPrint(fd->getPath()),qPrint(fd->name()));
1819 if (fd->getPath()==QCString(m_tagName+":"+tfi->path))
1820 {
1821 //printf("found\n");
1822 for (const auto &ii : tfi->includes)
1823 {
1824 //printf("ii->name='%s'\n",qPrint(ii->name));
1825 FileName *ifn = Doxygen::inputNameLinkedMap->find(ii.name);
1826 ASSERT(ifn!=nullptr);
1827 if (ifn)
1828 {
1829 for (const auto &ifd : *ifn)
1830 {
1831 //printf("ifd->getOutputFileBase()=%s ii->id=%s\n",
1832 // qPrint(ifd->getOutputFileBase()),qPrint(ii->id));
1833 if (ifd->getOutputFileBase()==QCString(ii.id))
1834 {
1836 if (ii.isModule)
1837 {
1839 }
1840 else if (ii.isImported)
1841 {
1843 }
1844 else if (ii.isLocal)
1845 {
1847 }
1848 fd->addIncludeDependency(ifd.get(),ii.text,kind);
1849 }
1850 }
1851 }
1852 }
1853 }
1854 }
1855 }
1856 }
1857 }
1858}
1859
1860} // namespace
1861
1862// ----------------- public part -----------------------------------------------
1863
1864void parseTagFile(const std::shared_ptr<Entry> &root,const char *fullName)
1865{
1866 TagFileParser tagFileParser(fullName);
1867 QCString inputStr = fileToString(fullName);
1868 XMLHandlers handlers;
1869 // connect the generic events handlers of the XML parser to the specific handlers of the tagFileParser object
1870 handlers.startDocument = [&tagFileParser]() { tagFileParser.startDocument(); };
1871 handlers.startElement = [&tagFileParser](const std::string &name,const XMLHandlers::Attributes &attrs) { tagFileParser.startElement(QCString(name),attrs); };
1872 handlers.endElement = [&tagFileParser](const std::string &name) { tagFileParser.endElement(QCString(name)); };
1873 handlers.characters = [&tagFileParser](const std::string &chars) { tagFileParser.characters(QCString(chars)); };
1874 handlers.error = [&tagFileParser](const std::string &fileName,int lineNr,const std::string &msg) { tagFileParser.error(QCString(fileName),lineNr,QCString(msg)); };
1875 XMLParser parser(handlers);
1876 tagFileParser.setDocumentLocator(&parser);
1877 parser.parse(fullName,inputStr.data(),Debug::isFlagSet(Debug::Lex_xml),
1878 [&]() { DebugLex::print(Debug::Lex_xml,"Entering","libxml/xml.l",fullName); },
1879 [&]() { DebugLex::print(Debug::Lex_xml,"Finished", "libxml/xml.l",fullName); }
1880 );
1881 tagFileParser.buildLists(root);
1882 tagFileParser.addIncludes();
1884 {
1885 tagFileParser.dump();
1886 }
1887}
static bool looksGenerated(const std::string &anchor)
Returns true if anchor is a potentially generated anchor.
Definition anchor.cpp:140
This class represents an function or template argument list.
Definition arguments.h:65
void push_back(const Argument &a)
Definition arguments.h:102
@ Tag
Definition debug.h:45
@ Lex_xml
Definition debug.h:70
static bool isFlagSet(const DebugMask mask)
Definition debug.cpp:132
static void print(DebugMask mask, int prio, fmt::format_string< Args... > fmt, Args &&... args)
Definition debug.h:76
virtual void addSectionsToDefinition(const std::vector< const SectionInfo * > &anchorList)=0
static FileNameLinkedMap * inputNameLinkedMap
Definition doxygen.h:105
Class representing all files with a certain base name.
Definition filename.h:30
static ModuleManager & instance()
This is an alternative implementation of QCString.
Definition qcstring.h:101
QCString stripWhiteSpace() const
returns a copy of this string with leading and trailing whitespace removed
Definition qcstring.h:245
const std::string & str() const
Definition qcstring.h:537
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
class that provide information about a section.
Definition section.h:57
SectionInfo * replace(const QCString &label, const QCString &fileName, int lineNr, const QCString &title, SectionType type, int level, const QCString &ref=QCString())
Definition section.h:156
SectionInfo * add(const SectionInfo &si)
Definition section.h:138
static SectionManager & instance()
returns a reference to the singleton
Definition section.h:178
static constexpr int Anchor
Definition section.h:40
Wrapper class for a number of boolean properties.
Definition types.h:654
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
std::function< CharsType > characters
handler invoked when content between tags has been found
Definition xml.h:41
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
std::function< StartDocType > startDocument
handler invoked at the start of the document
Definition xml.h:37
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
TagAnchorInfo(const QCString &f, const QCString &l, const QCString &t=QCString())
Definition tagreader.cpp:51
Variant class that holds a unique pointer to one of the specific container types.
const R * get() const
Generic const getter.
std::variant< std::monostate, TagClassInfoPtr, TagConceptInfoPtr, TagNamespaceInfoPtr, TagPackageInfoPtr, TagFileInfoPtr, TagGroupInfoPtr, TagPageInfoPtr, TagDirInfoPtr, TagModuleInfoPtr > VariantT
TagCompoundVariant(const TagCompoundVariant &)=delete
static TagCompoundVariant make(Args &&... args)
Generic factory method to create a variant holding a unique pointer to a given compound type.
TagCompoundVariant & operator=(const TagCompoundVariant &)=delete
const TagNamespaceInfo * getNamespaceInfo() const
TagCompoundInfo * getCompoundInfo()
Convenience method to get the shared compound info.
TagCompoundVariant & operator=(TagCompoundVariant &&)=default
Container for enum values that are scoped within an enum.
Definition tagreader.cpp:62
void addDocAnchors(const std::shared_ptr< Entry > &e, const std::vector< TagAnchorInfo > &l)
void startIncludes(const XMLHandlers::Attributes &attrib)
void startDocAnchor(const XMLHandlers::Attributes &attrib)
void startElement(const QCString &name, const XMLHandlers::Attributes &attrib)
void startStringValue(const XMLHandlers::Attributes &)
void setDocumentLocator(const XMLLocator *locator)
void startBase(const XMLHandlers::Attributes &attrib)
void error(const QCString &fileName, int lineNr, const QCString &msg)
void startIgnoreElement(const XMLHandlers::Attributes &)
void buildLists(const std::shared_ptr< Entry > &root)
void startMember(const XMLHandlers::Attributes &attrib)
void buildMemberList(const std::shared_ptr< Entry > &ce, const std::vector< TagMemberInfo > &members)
void buildClassEntry(const std::shared_ptr< Entry > &root, const TagClassInfo *tci)
void startCompound(const XMLHandlers::Attributes &attrib)
void buildClassTree(const std::shared_ptr< Entry > &root, const ClassNode &node)
std::vector< TagCompoundVariant > m_tagFileCompounds
void startEnumValue(const XMLHandlers::Attributes &attrib)
Container for include info that can be read from a tagfile.
Definition tagreader.cpp:72
Container for member specific info that can be read from a tagfile.
Definition tagreader.cpp:85
std::vector< TagEnumValueInfo > enumValues
Definition tagreader.cpp:98
std::vector< std::string > StringVector
Definition containers.h:33
std::unique_ptr< ArgumentList > stringToArgumentList(SrcLangExt lang, const QCString &argsString, QCString *extraTypeChars=nullptr)
Definition defargs.l:814
std::unique_ptr< FileDef > createFileDef(const QCString &p, const QCString &n, const QCString &ref, const QCString &dn)
Definition filedef.cpp:268
IncludeKind
Definition filedef.h:47
@ ImportLocal
Definition filedef.h:54
@ ImportModule
Definition filedef.h:55
@ IncludeLocal
Definition filedef.h:50
@ IncludeSystem
Definition filedef.h:49
@ ImportSystem
Definition filedef.h:53
#define warn(file, line, fmt,...)
Definition message.h:97
#define msg(fmt,...)
Definition message.h:94
std::unique_ptr< TagPackageInfo > TagPackageInfoPtr
std::unique_ptr< TagFileInfo > TagFileInfoPtr
std::unique_ptr< TagClassInfo > TagClassInfoPtr
std::unique_ptr< TagNamespaceInfo > TagNamespaceInfoPtr
std::unique_ptr< TagDirInfo > TagDirInfoPtr
static const std::map< std::string, CompoundFactory > g_compoundFactory
std::unique_ptr< TagConceptInfo > TagConceptInfoPtr
std::unique_ptr< TagModuleInfo > TagModuleInfoPtr
std::unique_ptr< TagPageInfo > TagPageInfoPtr
ElementCallbacks::EndCallback endCb(void(TagFileParser::*fn)())
static const std::map< std::string, ElementCallbacks > g_elementHandlers
ElementCallbacks::StartCallback startCb(void(TagFileParser::*fn)(const XMLHandlers::Attributes &))
std::unique_ptr< TagGroupInfo > TagGroupInfoPtr
#define TRUE
Definition qcstring.h:37
#define ASSERT(x)
Definition qcstring.h:39
This class contains the information about the argument of a function or template.
Definition arguments.h:27
QCString type
Definition arguments.h:42
QCString name
Definition arguments.h:44
This class stores information about an inheritance relation.
Definition entry.h:90
QCString name
the name of the base class
Definition entry.h:94
@ GROUPING_INGROUP
membership in group was defined by @ingroup
Definition types.h:236
CompoundFactory(TagFileParser::State s, const CreateFunc &f)
std::function< TagCompoundVariant()> CreateFunc
std::function< void(TagFileParser &, const XMLHandlers::Attributes &)> StartCallback
std::function< void(TagFileParser &)> EndCallback
Container for class specific info that can be read from a tagfile.
Container for concept specific info that can be read from a tagfile.
Container for directory specific info that can be read from a tagfile.
Container for file specific info that can be read from a tagfile.
std::unordered_map< std::string, std::unique_ptr< ClassNode > > children
Container for group specific info that can be read from a tagfile.
Container for module specific info that can be read from a tagfile.
Container for namespace specific info that can be read from a tagfile.
Container for package specific info that can be read from a tagfile.
Container for page specific info that can be read from a tagfile.
void parseTagFile(const std::shared_ptr< Entry > &root, const char *fullName)
#define p_warn(fmt,...)
Protection
Definition types.h:32
Specifier
Definition types.h:80
QCString stripPath(const QCString &s)
Definition util.cpp:5461
QCString fileToString(const QCString &name, bool filter, bool isSourceCode)
Definition util.cpp:1442
QCString stripExtensionGeneral(const QCString &fName, const QCString &ext)
Definition util.cpp:5424
QCString stripExtension(const QCString &fName)
Definition util.cpp:5434
EntryType guessSection(const QCString &name)
Definition util.cpp:350
StringVector split(const std::string &s, const std::string &delimiter)
split input string s by string delimiter delimiter.
Definition util.cpp:7129
QCString getFileNameExtension(const QCString &fn)
Definition util.cpp:5760
A bunch of utility functions.