Skip to main content

The namespacedef.cpp File Reference

Included Headers

#include "namespacedef.h" #include "outputlist.h" #include "util.h" #include "language.h" #include "classdef.h" #include "classlist.h" #include "memberlist.h" #include "doxygen.h" #include "message.h" #include "docparser.h" #include "searchindex.h" #include "vhdldocgen.h" #include "layout.h" #include "membergroup.h" #include "config.h" #include "definitionimpl.h" #include "membername.h" #include "conceptdef.h"

Classes Index

classNamespaceDefImpl
classNamespaceDefAliasImpl

Functions Index

static QCStringmakeDisplayName (const NamespaceDef *nd, bool includeScope)
std::unique_ptr< NamespaceDef >createNamespaceDef (const QCString &defFileName, int defLine, int defColumn, const QCString &name, const QCString &ref, const QCString &refFile, const QCString &type, bool isPublished)

Factory method to create new NamespaceDef instance. More...

std::unique_ptr< NamespaceDef >createNamespaceDefAlias (const Definition *newScope, const NamespaceDef *nd)

Factory method to create an alias of an existing namespace. More...

static boolhasNonReferenceNestedNamespaceRec (const NamespaceDef *nd, int level)
NamespaceDef *toNamespaceDef (Definition *d)
NamespaceDef *toNamespaceDef (DefinitionMutable *md)
const NamespaceDef *toNamespaceDef (const Definition *d)
NamespaceDefMutable *toNamespaceDefMutable (Definition *d)
static NamespaceDef *getResolvedNamespaceRec (StringSet &namespacesTried, const NamespaceAliasInfo &aliasInfo)
static QCStringreplaceNamespaceAliasesRec (StringSet &namespacesTried, const QCString &name)
voidreplaceNamespaceAliases (QCString &name)
NamespaceDef *getResolvedNamespace (const QCString &name)
boolnamespaceHasNestedNamespace (const NamespaceDef *nd)
boolnamespaceHasNestedConcept (const NamespaceDef *nd)
boolnamespaceHasNestedClass (const NamespaceDef *nd, bool filterClasses, ClassDef::CompoundType ct)

Functions

createNamespaceDef()

std::unique_ptr< NamespaceDef > createNamespaceDef (const QCString & defFileName, int defLine, int defColumn, const QCString & name, const QCString & ref, const QCString & refFile, const QCString & type, bool isPublished)

Factory method to create new NamespaceDef instance.

Definition at line 174 of file namespacedef.cpp.

174std::unique_ptr<NamespaceDef> createNamespaceDef(const QCString &defFileName,int defLine,int defColumn,
175 const QCString &name,const QCString &ref,
176 const QCString &refFile,const QCString &type,
177 bool isPublished)
178{
179 //printf("createNamespaceDef(%s)\n",qPrint(name));
180 return std::make_unique<NamespaceDefImpl>(defFileName,defLine,defColumn,name,ref,refFile,type,isPublished);
181}

Referenced by adjustConfiguration, buildNamespaceList, buildScopeFromQualifiedName, findUsingDirectives and NamespaceDefMutable::setInline.

createNamespaceDefAlias()

std::unique_ptr< NamespaceDef > createNamespaceDefAlias (const Definition * newScope, const NamespaceDef * nd)

Factory method to create an alias of an existing namespace.

Used for inline namespaces.

Definition at line 262 of file namespacedef.cpp.

262std::unique_ptr<NamespaceDef> createNamespaceDefAlias(const Definition *newScope,const NamespaceDef *nd)
263{
264 auto alnd = std::make_unique<NamespaceDefAliasImpl>(newScope,nd);
265 //printf("alnd name=%s localName=%s qualifiedName=%s displayName()=%s\n",
266 // qPrint(alnd->name()),qPrint(alnd->localName()),qPrint(alnd->qualifiedName()),
267 // qPrint(alnd->displayName()));
268 return alnd;
269}

Referenced by buildNamespaceList and NamespaceDefMutable::setInline.

getResolvedNamespace()

NamespaceDef * getResolvedNamespace (const QCString & name)

Definition at line 1789 of file namespacedef.cpp.

1790{
1791 //printf("> getResolvedNamespace(%s)\n",qPrint(name));
1792 if (name.isEmpty()) return nullptr;
1793 StringSet namespacesTried;
1794 auto ns = getResolvedNamespaceRec(namespacesTried,NamespaceAliasInfo(name.str()));
1795 //printf("< getResolvedNamespace(%s)=%s\n",qPrint(name),ns?qPrint(ns->qualifiedName()):"nullptr");
1796 return ns;
1797}

References getResolvedNamespaceRec, QCString::isEmpty and QCString::str.

Referenced by addMemberFunction, buildFunctionList, buildTypedefList, extractNamespaceName, findUsedNamespace, findUsingDeclImports, findUsingDirectives, generateClassOrGlobalLink, generateClassOrGlobalLink, getResolvedNamespaceMutable, CCodeParser::parseCode, setCallContextForVar, NamespaceDefMutable::setInline and writeAlphabeticalClassList.

getResolvedNamespaceRec()

NamespaceDef * getResolvedNamespaceRec (StringSet & namespacesTried, const NamespaceAliasInfo & aliasInfo)
static

Definition at line 1740 of file namespacedef.cpp.

1740static NamespaceDef *getResolvedNamespaceRec(StringSet &namespacesTried,const NamespaceAliasInfo &aliasInfo)
1741{
1742 size_t j = aliasInfo.context.length();
1743 for (;;)
1744 {
1745 if (j>0)
1746 {
1747 //printf("candidate %s|::%s\n",qPrint(aliasInfo.context.substr(0,j)),qPrint(aliasInfo.alias));
1748 auto candidate = replaceNamespaceAliasesRec(namespacesTried,aliasInfo.context.substr(0,j)+"::"+aliasInfo.alias);
1749 auto nd = Doxygen::namespaceLinkedMap->find(candidate);
1750 if (nd)
1751 {
1752 return nd;
1753 }
1754 }
1755 if (j>0) // strip one level from context, i.e. given N1::N2::N3
1756 // j==10 -> j==6 (N1::N2::N3->N1::N2), and then
1757 // j==6 -> j==2 (N1::N2->N1), and then
1758 // j==2 -> j==std::string::npos (N1->"")
1759 {
1760 j = aliasInfo.context.rfind("::",j-1);
1761 }
1762 else
1763 {
1764 j = std::string::npos;
1765 }
1766 if (j==std::string::npos)
1767 {
1768 //printf("candidate %s\n",qPrint(aliasInfo.alias));
1769 auto candidate = replaceNamespaceAliasesRec(namespacesTried,QCString(aliasInfo.alias));
1770 auto nd = Doxygen::namespaceLinkedMap->find(candidate);
1771 if (nd)
1772 {
1773 return nd;
1774 }
1775 break;
1776 }
1777 }
1778 return nullptr;
1779}

References NamespaceAliasInfo::alias, NamespaceAliasInfo::context, Doxygen::namespaceLinkedMap and replaceNamespaceAliasesRec.

Referenced by getResolvedNamespace and replaceNamespaceAliasesRec.

hasNonReferenceNestedNamespaceRec()

bool hasNonReferenceNestedNamespaceRec (const NamespaceDef * nd, int level)
static

Definition at line 1501 of file namespacedef.cpp.

1501static bool hasNonReferenceNestedNamespaceRec(const NamespaceDef *nd,int level)
1502{
1503 if (level>30)
1504 {
1505 err("Possible recursive namespace relation while inside {}\n",nd->name());
1506 return false;
1507 }
1508 bool found=nd->isLinkableInProject();
1509 if (found)
1510 {
1511 return true;
1512 }
1513 else
1514 {
1515 for (const auto &ind : nd->getNamespaces())
1516 {
1517 found = found || hasNonReferenceNestedNamespaceRec(ind,level+1);
1518 if (found) break;
1519 }
1520 }
1521 return found;
1522}

References err, NamespaceDef::getNamespaces, hasNonReferenceNestedNamespaceRec, Definition::isLinkableInProject and Definition::name.

Referenced by hasNonReferenceNestedNamespaceRec and NamespaceDefImpl::isVisibleInHierarchy.

makeDisplayName()

QCString makeDisplayName (const NamespaceDef * nd, bool includeScope)
static

Definition at line 38 of file namespacedef.cpp.

38static QCString makeDisplayName(const NamespaceDef *nd,bool includeScope)
39{
40 QCString result=includeScope ? nd->name() : nd->localName();
41 SrcLangExt lang = nd->getLanguage();
43 if (sep!="::")
44 {
45 result = substitute(result,"::",sep);
46 }
47 if (nd->isAnonymous())
48 {
49 result = removeAnonymousScopes(result);
50 }
51 //printf("makeDisplayName() %s->%s lang=%d\n",qPrint(name()),qPrint(result),lang);
52 return result;
53}

References Definition::getLanguage, getLanguageSpecificSeparator, Definition::isAnonymous, Definition::localName, Definition::name, removeAnonymousScopes and substitute.

Referenced by NamespaceDefAliasImpl::displayName and NamespaceDefImpl::displayName.

namespaceHasNestedClass()

bool namespaceHasNestedClass (const NamespaceDef * nd, bool filterClasses, ClassDef::CompoundType ct)

Definition at line 1837 of file namespacedef.cpp.

1838{
1839 //printf(">namespaceHasNestedClass(%s,filterClasses=%d)\n",qPrint(nd->name()),filterClasses);
1840 for (const auto &cnd : nd->getNamespaces())
1841 {
1842 if (namespaceHasNestedClass(cnd,filterClasses,ct))
1843 {
1844 //printf("<namespaceHasNestedClass(%s,filterClasses=%d): case1\n",qPrint(nd->name()),filterClasses);
1845 return true;
1846 }
1847 }
1848
1849 ClassLinkedRefMap list = nd->getClasses();
1850 if (filterClasses)
1851 {
1852 switch (ct)
1853 {
1855 list = nd->getInterfaces();
1856 break;
1857 case ClassDef::Struct:
1858 list = nd->getStructs();
1859 break;
1861 list = nd->getExceptions();
1862 break;
1863 default:
1864 break;
1865 }
1866 }
1867
1868 for (const auto &cd : list)
1869 {
1870 //printf("candidate %s isLinkableInProject()=%d\n",qPrint(cd->name()),cd->isLinkableInProject());
1871 if (cd->isLinkableInProject())
1872 {
1873 //printf("<namespaceHasNestedClass(%s,filterClasses=%d): case2\n",qPrint(nd->name()),filterClasses);
1874 return true;
1875 }
1876 }
1877 //printf("<namespaceHasNestedClass(%s,filterClasses=%d): case3\n",qPrint(nd->name()),filterClasses);
1878 return false;
1879}

References ClassDef::Exception, NamespaceDef::getClasses, NamespaceDef::getExceptions, NamespaceDef::getInterfaces, NamespaceDef::getNamespaces, NamespaceDef::getStructs, ClassDef::Interface, namespaceHasNestedClass and ClassDef::Struct.

Referenced by namespaceHasNestedClass, writeClassTreeInsideNamespaceElement and writeNamespaceTreeElement.

namespaceHasNestedConcept()

bool namespaceHasNestedConcept (const NamespaceDef * nd)

Definition at line 1813 of file namespacedef.cpp.

1814{
1815 //printf(">namespaceHasNestedConcept(%s)\n",qPrint(nd->name()));
1816 for (const auto &cnd : nd->getNamespaces())
1817 {
1819 {
1820 //printf("<namespaceHasNestedConcept(%s): case1\n",qPrint(nd->name()));
1821 return true;
1822 }
1823 }
1824 for (const auto &cnd : nd->getConcepts())
1825 {
1826 //printf("candidate %s isLinkableInProject()=%d\n",qPrint(cnd->name()),cnd->isLinkableInProject());
1827 if (cnd->isLinkableInProject())
1828 {
1829 //printf("<namespaceHasNestedConcept(%s): case2\n",qPrint(nd->name()));
1830 return true;
1831 }
1832 }
1833 //printf("<namespaceHasNestedConcept(%s): case3\n",qPrint(nd->name()));
1834 return false;
1835}

References NamespaceDef::getConcepts, NamespaceDef::getNamespaces and namespaceHasNestedConcept.

Referenced by namespaceHasNestedConcept, writeConceptTreeInsideNamespaceElement and writeNamespaceTreeElement.

namespaceHasNestedNamespace()

bool namespaceHasNestedNamespace (const NamespaceDef * nd)

Definition at line 1801 of file namespacedef.cpp.

1802{
1803 for (const auto &cnd : nd->getNamespaces())
1804 {
1805 if (cnd->isLinkableInProject() && !cnd->isAnonymous())
1806 {
1807 return true;
1808 }
1809 }
1810 return false;
1811}

Reference NamespaceDef::getNamespaces.

Referenced by writeNamespaceTreeElement.

replaceNamespaceAliases()

void replaceNamespaceAliases (QCString & name)

Definition at line 1781 of file namespacedef.cpp.

1782{
1783 //printf("> replaceNamespaceAliases(%s)\n",qPrint(name));
1784 StringSet namespacesTried;
1785 name = replaceNamespaceAliasesRec(namespacesTried,name);
1786 //printf("< replaceNamespaceAliases: result=%s\n",qPrint(name));
1787}

Reference replaceNamespaceAliasesRec.

Referenced by findClassRelation, findUsedClassesForClass, getMemberFromSymbol, SymbolResolver::Private::getResolvedSymbolRec, SymbolResolver::Private::getResolvedTypeRec and NamespaceDefMutable::setInline.

replaceNamespaceAliasesRec()

QCString replaceNamespaceAliasesRec (StringSet & namespacesTried, const QCString & name)
static

Definition at line 1694 of file namespacedef.cpp.

1694static QCString replaceNamespaceAliasesRec(StringSet &namespacesTried,const QCString &name)
1695{
1696 QCString result = name;
1697 //printf("> replaceNamespaceAliasesRec(%s)\n",qPrint(name));
1698 if (namespacesTried.find(name.str())==namespacesTried.end())
1699 {
1700 namespacesTried.insert(name.str());
1701 size_t p = 0;
1702 for (;;)
1703 {
1704 size_t i = name.str().find("::",p);
1705 if (i==std::string::npos)
1706 {
1707 auto it = Doxygen::namespaceAliasMap.find(name.str());
1709 {
1710 //printf("found map %s->%s\n",qPrint(name),qPrint(it->second.alias));
1711 auto ns = getResolvedNamespaceRec(namespacesTried,it->second);
1712 if (ns)
1713 {
1714 result = replaceNamespaceAliasesRec(namespacesTried,ns->qualifiedName());
1715 }
1716 }
1717 break;
1718 }
1719 else
1720 {
1721 auto it = Doxygen::namespaceAliasMap.find(name.left(i).str());
1723 {
1724 //printf("found map %s|%s->%s\n",qPrint(name.left(i)),qPrint(name.mid(i)),qPrint(it->second.alias));
1725 auto ns = getResolvedNamespaceRec(namespacesTried,it->second);
1726 if (ns)
1727 {
1728 result = replaceNamespaceAliasesRec(namespacesTried,ns->qualifiedName()+name.mid(i));
1729 break;
1730 }
1731 }
1732 }
1733 p = i+2;
1734 }
1735 }
1736 //printf("< replaceNamespaceAliasesRec(%s)=%s\n",qPrint(name),qPrint(result));
1737 return result;
1738}

References end, getResolvedNamespaceRec, QCString::left, QCString::mid, Doxygen::namespaceAliasMap, replaceNamespaceAliasesRec and QCString::str.

Referenced by getResolvedNamespaceRec, replaceNamespaceAliases and replaceNamespaceAliasesRec.

toNamespaceDef()

toNamespaceDef()

NamespaceDef * toNamespaceDef (DefinitionMutable * md)

Definition at line 1652 of file namespacedef.cpp.

1653{
1654 Definition *d = toDefinition(md);
1655 if (d && typeid(*d)==typeid(NamespaceDefImpl))
1656 {
1657 return static_cast<NamespaceDef*>(d);
1658 }
1659 else
1660 {
1661 return nullptr;
1662 }
1663}

Reference toDefinition.

toNamespaceDef()

const NamespaceDef * toNamespaceDef (const Definition * d)

Definition at line 1666 of file namespacedef.cpp.

1667{
1668 if (d && (typeid(*d)==typeid(NamespaceDefImpl) || typeid(*d)==typeid(NamespaceDefAliasImpl)))
1669 {
1670 return static_cast<const NamespaceDef*>(d);
1671 }
1672 else
1673 {
1674 return nullptr;
1675 }
1676}

toNamespaceDefMutable()


Generated via doxygen2docusaurus by Doxygen 1.14.0.