Doxygen
Loading...
Searching...
No Matches
namespacedef.h File Reference

#include <src/namespacedef.h>

Include dependency graph for namespacedef.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  NamespaceLinkedMap
class  NamespaceLinkedRefMap
class  NamespaceDef
 An abstract interface of a namespace symbol. More...
class  NamespaceDefMutable

Typedefs

using NamespaceDefSet = std::unordered_set<const NamespaceDef*>

Functions

std::unique_ptr< NamespaceDef > createNamespaceDef (const DString &defFileName, int defLine, size_t defColumn, const DString &name, const DString &ref=DString(), const DString &refFile=DString(), const DString &type=DString(), bool isPublished=false)
 Factory method to create new NamespaceDef instance.
std::unique_ptr< NamespaceDef > createNamespaceDefAlias (const Definition *newScope, const NamespaceDef *nd)
 Factory method to create an alias of an existing namespace.
NamespaceDef * toNamespaceDef (Definition *d)
NamespaceDef * toNamespaceDef (DefinitionMutable *d)
const NamespaceDef * toNamespaceDef (const Definition *d)
NamespaceDefMutable * toNamespaceDefMutable (Definition *d)
void replaceNamespaceAliases (DString &name)
NamespaceDef * getResolvedNamespace (const DString &key)
NamespaceDefMutable * getResolvedNamespaceMutable (const DString &key)
bool namespaceHasNestedNamespace (const NamespaceDef *nd)
bool namespaceHasNestedConcept (const NamespaceDef *nd)
bool namespaceHasNestedClass (const NamespaceDef *nd, bool filterClasses, ClassDef::CompoundType ct)

Typedef Documentation

◆ NamespaceDefSet

using NamespaceDefSet = std::unordered_set<const NamespaceDef*>

Definition at line 39 of file namespacedef.h.

Function Documentation

◆ createNamespaceDef()

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

Factory method to create new NamespaceDef instance.

Definition at line 182 of file namespacedef.cpp.

186{
187 //printf("createNamespaceDef(%s)\n",qPrint(name));
188 return std::make_unique<NamespaceDefImpl>(defFileName,defLine,defColumn,name,ref,refFile,type,isPublished);
189}

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 272 of file namespacedef.cpp.

273{
274 auto alnd = std::make_unique<NamespaceDefAliasImpl>(newScope,nd);
275 //printf("alnd name=%s localName=%s qualifiedName=%s displayName()=%s\n",
276 // qPrint(alnd->name()),qPrint(alnd->localName()),qPrint(alnd->qualifiedName()),
277 // qPrint(alnd->displayName()));
278 return alnd;
279}

Referenced by buildNamespaceList(), and NamespaceDefMutable::setInline().

◆ getResolvedNamespace()

NamespaceDef * getResolvedNamespace ( const DString & key)

Definition at line 1940 of file namespacedef.cpp.

1941{
1942 //printf("> getResolvedNamespace(%s)\n",qPrint(name));
1943 if (name.empty()) return nullptr;
1944 StringSet namespacesTried;
1945 auto ns = getResolvedNamespaceRec(namespacesTried,NamespaceAliasInfo(name.str()));
1946 //printf("< getResolvedNamespace(%s)=%s\n",qPrint(name),ns?qPrint(ns->qualifiedName()):"nullptr");
1947 return ns;
1948}
std::set< std::string > StringSet
Definition containers.h:31
const char * name(int level)
Definition latexgen.h:368
static NamespaceDef * getResolvedNamespaceRec(StringSet &namespacesTried, const NamespaceAliasInfo &aliasInfo)

References getResolvedNamespaceRec().

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

◆ getResolvedNamespaceMutable()

NamespaceDefMutable * getResolvedNamespaceMutable ( const DString & key)
inline

Definition at line 155 of file namespacedef.h.

156{
158}
NamespaceDef * getResolvedNamespace(const DString &key)
NamespaceDefMutable * toNamespaceDefMutable(Definition *d)

References getResolvedNamespace(), getResolvedNamespaceMutable(), and toNamespaceDefMutable().

Referenced by addEnumValuesToEnums(), addGlobalFunction(), addVariableToFile(), findEnums(), findUsingDeclarations(), findUsingDirectives(), and getResolvedNamespaceMutable().

◆ namespaceHasNestedClass()

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

Definition at line 1988 of file namespacedef.cpp.

1989{
1990 //printf(">namespaceHasNestedClass(%s,filterClasses=%d)\n",qPrint(nd->name()),filterClasses);
1991 for (const auto &cnd : nd->getNamespaces())
1992 {
1993 if (namespaceHasNestedClass(cnd,filterClasses,ct))
1994 {
1995 //printf("<namespaceHasNestedClass(%s,filterClasses=%d): case1\n",qPrint(nd->name()),filterClasses);
1996 return true;
1997 }
1998 }
1999
2000 ClassLinkedRefMap list = nd->getClasses();
2001 if (filterClasses)
2002 {
2003 switch (ct)
2004 {
2006 list = nd->getInterfaces();
2007 break;
2008 case ClassDef::Struct:
2009 list = nd->getStructs();
2010 break;
2011 case ClassDef::Record:
2012 list = nd->getRecords();
2013 break;
2015 list = nd->getExceptions();
2016 break;
2017 default:
2018 break;
2019 }
2020 }
2021
2022 for (const auto &cd : list)
2023 {
2024 //printf("candidate %s isLinkableInProject()=%d\n",qPrint(cd->name()),cd->isLinkableInProject());
2025 if (cd->isLinkableInProject())
2026 {
2027 //printf("<namespaceHasNestedClass(%s,filterClasses=%d): case2\n",qPrint(nd->name()),filterClasses);
2028 return true;
2029 }
2030 }
2031 //printf("<namespaceHasNestedClass(%s,filterClasses=%d): case3\n",qPrint(nd->name()),filterClasses);
2032 return false;
2033}
@ Interface
Definition classdef.h:109
@ Exception
Definition classdef.h:112
virtual ClassLinkedRefMap getRecords() const =0
virtual ClassLinkedRefMap getStructs() const =0
virtual ClassLinkedRefMap getExceptions() const =0
virtual NamespaceLinkedRefMap getNamespaces() const =0
virtual ClassLinkedRefMap getClasses() const =0
virtual ClassLinkedRefMap getInterfaces() const =0
bool namespaceHasNestedClass(const NamespaceDef *nd, bool filterClasses, ClassDef::CompoundType ct)

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

Referenced by namespaceHasNestedClass(), writeClassTreeInsideNamespaceElement(), and writeNamespaceTreeElement().

◆ namespaceHasNestedConcept()

bool namespaceHasNestedConcept ( const NamespaceDef * nd)

Definition at line 1964 of file namespacedef.cpp.

1965{
1966 //printf(">namespaceHasNestedConcept(%s)\n",qPrint(nd->name()));
1967 for (const auto &cnd : nd->getNamespaces())
1968 {
1970 {
1971 //printf("<namespaceHasNestedConcept(%s): case1\n",qPrint(nd->name()));
1972 return true;
1973 }
1974 }
1975 for (const auto &cnd : nd->getConcepts())
1976 {
1977 //printf("candidate %s isLinkableInProject()=%d\n",qPrint(cnd->name()),cnd->isLinkableInProject());
1978 if (cnd->isLinkableInProject())
1979 {
1980 //printf("<namespaceHasNestedConcept(%s): case2\n",qPrint(nd->name()));
1981 return true;
1982 }
1983 }
1984 //printf("<namespaceHasNestedConcept(%s): case3\n",qPrint(nd->name()));
1985 return false;
1986}
virtual ConceptLinkedRefMap getConcepts() const =0
bool namespaceHasNestedConcept(const NamespaceDef *nd)

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

Referenced by namespaceHasNestedConcept(), and writeNamespaceTreeElement().

◆ namespaceHasNestedNamespace()

bool namespaceHasNestedNamespace ( const NamespaceDef * nd)

Definition at line 1952 of file namespacedef.cpp.

1953{
1954 for (const auto &cnd : nd->getNamespaces())
1955 {
1956 if (cnd->isLinkableInProject() && !cnd->isAnonymous())
1957 {
1958 return true;
1959 }
1960 }
1961 return false;
1962}

References NamespaceDef::getNamespaces().

Referenced by writeNamespaceTreeElement().

◆ replaceNamespaceAliases()

void replaceNamespaceAliases ( DString & name)

Definition at line 1932 of file namespacedef.cpp.

1933{
1934 //printf("> replaceNamespaceAliases(%s)\n",qPrint(name));
1935 StringSet namespacesTried;
1936 name = replaceNamespaceAliasesRec(namespacesTried,name);
1937 //printf("< replaceNamespaceAliases: result=%s\n",qPrint(name));
1938}
static DString replaceNamespaceAliasesRec(StringSet &namespacesTried, const DString &name)

References replaceNamespaceAliasesRec().

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

◆ toNamespaceDef() [1/3]

const NamespaceDef * toNamespaceDef ( const Definition * d)

Definition at line 1817 of file namespacedef.cpp.

1818{
1819 if (d && (typeid(*d)==typeid(NamespaceDefImpl) || typeid(*d)==typeid(NamespaceDefAliasImpl)))
1820 {
1821 return static_cast<const NamespaceDef*>(d);
1822 }
1823 else
1824 {
1825 return nullptr;
1826 }
1827}
An abstract interface of a namespace symbol.

◆ toNamespaceDef() [2/3]

◆ toNamespaceDef() [3/3]

NamespaceDef * toNamespaceDef ( DefinitionMutable * d)

Definition at line 1803 of file namespacedef.cpp.

1804{
1805 Definition *d = toDefinition(md);
1806 if (d && typeid(*d)==typeid(NamespaceDefImpl))
1807 {
1808 return static_cast<NamespaceDef*>(d);
1809 }
1810 else
1811 {
1812 return nullptr;
1813 }
1814}
The common base class of all entity definitions found in the sources.
Definition definition.h:77
Definition * toDefinition(DefinitionMutable *dm)

References toDefinition().

◆ toNamespaceDefMutable()