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< NamespaceDefcreateNamespaceDef (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< NamespaceDefcreateNamespaceDefAlias (const Definition *newScope, const NamespaceDef *nd)
 Factory method to create an alias of an existing namespace.
NamespaceDeftoNamespaceDef (Definition *d)
NamespaceDeftoNamespaceDef (DefinitionMutable *d)
const NamespaceDeftoNamespaceDef (const Definition *d)
NamespaceDefMutabletoNamespaceDefMutable (Definition *d)
void replaceNamespaceAliases (DString &name)
NamespaceDefgetResolvedNamespace (const DString &key)
NamespaceDefMutablegetResolvedNamespaceMutable (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 177 of file namespacedef.cpp.

181{
182 //printf("createNamespaceDef(%s)\n",qPrint(name));
183 return std::make_unique<NamespaceDefImpl>(defFileName,defLine,defColumn,name,ref,refFile,type,isPublished);
184}

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

266{
267 auto alnd = std::make_unique<NamespaceDefAliasImpl>(newScope,nd);
268 //printf("alnd name=%s localName=%s qualifiedName=%s displayName()=%s\n",
269 // qPrint(alnd->name()),qPrint(alnd->localName()),qPrint(alnd->qualifiedName()),
270 // qPrint(alnd->displayName()));
271 return alnd;
272}

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

◆ getResolvedNamespace()

NamespaceDef * getResolvedNamespace ( const DString & key)

Definition at line 1905 of file namespacedef.cpp.

1906{
1907 //printf("> getResolvedNamespace(%s)\n",qPrint(name));
1908 if (name.empty()) return nullptr;
1909 StringSet namespacesTried;
1910 auto ns = getResolvedNamespaceRec(namespacesTried,NamespaceAliasInfo(name.str()));
1911 //printf("< getResolvedNamespace(%s)=%s\n",qPrint(name),ns?qPrint(ns->qualifiedName()):"nullptr");
1912 return ns;
1913}
std::set< std::string > StringSet
Definition containers.h:31
static NamespaceDef * getResolvedNamespaceRec(StringSet &namespacesTried, const NamespaceAliasInfo &aliasInfo)

References DString::empty(), getResolvedNamespaceRec(), and DString::str().

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 152 of file namespacedef.h.

153{
155}
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 1953 of file namespacedef.cpp.

1954{
1955 //printf(">namespaceHasNestedClass(%s,filterClasses=%d)\n",qPrint(nd->name()),filterClasses);
1956 for (const auto &cnd : nd->getNamespaces())
1957 {
1958 if (namespaceHasNestedClass(cnd,filterClasses,ct))
1959 {
1960 //printf("<namespaceHasNestedClass(%s,filterClasses=%d): case1\n",qPrint(nd->name()),filterClasses);
1961 return true;
1962 }
1963 }
1964
1965 ClassLinkedRefMap list = nd->getClasses();
1966 if (filterClasses)
1967 {
1968 switch (ct)
1969 {
1971 list = nd->getInterfaces();
1972 break;
1973 case ClassDef::Struct:
1974 list = nd->getStructs();
1975 break;
1977 list = nd->getExceptions();
1978 break;
1979 default:
1980 break;
1981 }
1982 }
1983
1984 for (const auto &cd : list)
1985 {
1986 //printf("candidate %s isLinkableInProject()=%d\n",qPrint(cd->name()),cd->isLinkableInProject());
1987 if (cd->isLinkableInProject())
1988 {
1989 //printf("<namespaceHasNestedClass(%s,filterClasses=%d): case2\n",qPrint(nd->name()),filterClasses);
1990 return true;
1991 }
1992 }
1993 //printf("<namespaceHasNestedClass(%s,filterClasses=%d): case3\n",qPrint(nd->name()),filterClasses);
1994 return false;
1995}
@ Interface
Definition classdef.h:108
@ Exception
Definition classdef.h:111
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::getStructs(), ClassDef::Interface, namespaceHasNestedClass(), and ClassDef::Struct.

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

◆ namespaceHasNestedConcept()

bool namespaceHasNestedConcept ( const NamespaceDef * nd)

Definition at line 1929 of file namespacedef.cpp.

1930{
1931 //printf(">namespaceHasNestedConcept(%s)\n",qPrint(nd->name()));
1932 for (const auto &cnd : nd->getNamespaces())
1933 {
1935 {
1936 //printf("<namespaceHasNestedConcept(%s): case1\n",qPrint(nd->name()));
1937 return true;
1938 }
1939 }
1940 for (const auto &cnd : nd->getConcepts())
1941 {
1942 //printf("candidate %s isLinkableInProject()=%d\n",qPrint(cnd->name()),cnd->isLinkableInProject());
1943 if (cnd->isLinkableInProject())
1944 {
1945 //printf("<namespaceHasNestedConcept(%s): case2\n",qPrint(nd->name()));
1946 return true;
1947 }
1948 }
1949 //printf("<namespaceHasNestedConcept(%s): case3\n",qPrint(nd->name()));
1950 return false;
1951}
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 1917 of file namespacedef.cpp.

1918{
1919 for (const auto &cnd : nd->getNamespaces())
1920 {
1921 if (cnd->isLinkableInProject() && !cnd->isAnonymous())
1922 {
1923 return true;
1924 }
1925 }
1926 return false;
1927}

References NamespaceDef::getNamespaces().

Referenced by writeNamespaceTreeElement().

◆ replaceNamespaceAliases()

void replaceNamespaceAliases ( DString & name)

Definition at line 1897 of file namespacedef.cpp.

1898{
1899 //printf("> replaceNamespaceAliases(%s)\n",qPrint(name));
1900 StringSet namespacesTried;
1901 name = replaceNamespaceAliasesRec(namespacesTried,name);
1902 //printf("< replaceNamespaceAliases: result=%s\n",qPrint(name));
1903}
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 1782 of file namespacedef.cpp.

1783{
1784 if (d && (typeid(*d)==typeid(NamespaceDefImpl) || typeid(*d)==typeid(NamespaceDefAliasImpl)))
1785 {
1786 return static_cast<const NamespaceDef*>(d);
1787 }
1788 else
1789 {
1790 return nullptr;
1791 }
1792}
An abstract interface of a namespace symbol.

◆ toNamespaceDef() [2/3]

◆ toNamespaceDef() [3/3]

NamespaceDef * toNamespaceDef ( DefinitionMutable * d)

Definition at line 1768 of file namespacedef.cpp.

1769{
1770 Definition *d = toDefinition(md);
1771 if (d && typeid(*d)==typeid(NamespaceDefImpl))
1772 {
1773 return static_cast<NamespaceDef*>(d);
1774 }
1775 else
1776 {
1777 return nullptr;
1778 }
1779}
The common base class of all entity definitions found in the sources.
Definition definition.h:77
Definition * toDefinition(DefinitionMutable *dm)

References toDefinition().

◆ toNamespaceDefMutable()