CppParser
Loading...
Searching...
No Matches
CppProgram Class Reference

Represents an entire C++ program. More...

#include <cppprog.h>

Collaboration diagram for CppProgram:
Collaboration graph

Public Member Functions

 CppProgram (const std::string &folder, CppParser parser=CppParser(), const CppProgFileSelecter &fileSelector=selectHeadersOnly)
 
 CppProgram (const std::vector< std::string > &files, CppParser parser=CppParser())
 
const CppTypeTreeNodenameLookup (const std::string &name, const CppTypeTreeNode *beginFrom=nullptr) const
 Finds the CppTypeTreeNode object corresponding to a given name. More...
 
const CppTypeTreeNodesearchTypeNode (const std::string &name, const CppTypeTreeNode *parentNode=nullptr) const
 Searches down (in breadth first manner) the CppTypeTreeNode object corresponding to a given name. More...
 
const CppTypeTreeNodetypeTreeNodeFromCppObj (CppObj *cppObj) const
 
CppCompoundArraygetFileAsts ()
 
void addCppAst (CppCompoundPtr cppAst)
 Adds a new file AST to this program. More...
 
void addCompound (CppCompound *compound, CppCompound *parent)
 
void addCompound (CppCompound *compound, CppTypeTreeNode *parentTypeNode)
 

Private Types

using CppObjToTypeNodeMap = std::map< CppObj *, CppTypeTreeNode * >
 

Private Member Functions

void loadType (CppCompound *cppCompound, CppTypeTreeNode *typeNode)
 

Private Attributes

CppCompoundArray fileAsts_
 Array of all top level ASTs corresponding to files. More...
 
CppTypeTreeNode cppTypeTreeRoot_
 Repository of all compound objects arranged as type-tree. More...
 
CppObjToTypeNodeMap cppObjToTypeNode_
 

Detailed Description

Represents an entire C++ program.

Definition at line 58 of file cppprog.h.

Member Typedef Documentation

◆ CppObjToTypeNodeMap

Definition at line 115 of file cppprog.h.

Constructor & Destructor Documentation

◆ CppProgram() [1/2]

CppProgram::CppProgram ( const std::string &  folder,
CppParser  parser = CppParser(),
const CppProgFileSelecter fileSelector = selectHeadersOnly 
)

Definition at line 50 of file cppprog.cpp.

◆ CppProgram() [2/2]

CppProgram::CppProgram ( const std::vector< std::string > &  files,
CppParser  parser = CppParser() 
)

Definition at line 37 of file cppprog.cpp.

Here is the call graph for this function:

Member Function Documentation

◆ addCompound() [1/2]

void CppProgram::addCompound ( CppCompound compound,
CppCompound parent 
)

Definition at line 74 of file cppprog.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ addCompound() [2/2]

void CppProgram::addCompound ( CppCompound compound,
CppTypeTreeNode parentTypeNode 
)

Definition at line 63 of file cppprog.cpp.

Here is the call graph for this function:

◆ addCppAst()

void CppProgram::addCppAst ( CppCompoundPtr  cppAst)

Adds a new file AST to this program.

Warning
It is a no-op if cppAst is not of CppCompoundType::kCppFile type.

Definition at line 55 of file cppprog.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getFileAsts()

CppCompoundArray & CppProgram::getFileAsts ( )
inline
Returns
An array of CppCompound each element of which represents AST of a C++ file.

Definition at line 122 of file cppprog.h.

◆ loadType()

void CppProgram::loadType ( CppCompound cppCompound,
CppTypeTreeNode typeNode 
)
private

Definition at line 81 of file cppprog.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ nameLookup()

const CppTypeTreeNode * CppProgram::nameLookup ( const std::string &  name,
const CppTypeTreeNode beginFrom = nullptr 
) const

Finds the CppTypeTreeNode object corresponding to a given name.

Parameters
nameName of type for which CppTypeTreeNode needs to be found.
beginFromCppTypeTreeNode object from where the find should begin. It can be nullptr, in that case the global space is looked for the name.
Returns
CppTypeTreeNode corresponding to given name.
Note
Name can contain scope resolution operator(::).
Remarks
  1. The search moves upward. E.g. if beginFrom does not contain the type whose name is name then it is searched in parent node and keeps moving upward till a match is found or type-hierarchy ends without a match.
  2. It is supposed to work exactly like how compiler looks for name.

Definition at line 141 of file cppprog.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ searchTypeNode()

const CppTypeTreeNode * CppProgram::searchTypeNode ( const std::string &  name,
const CppTypeTreeNode parentNode = nullptr 
) const

Searches down (in breadth first manner) the CppTypeTreeNode object corresponding to a given name.

Parameters
nameName of type for which CppTypeTreeNode needs to be found.
parentNodeCppTypeTreeNode object from where the search should begin. It can be nullptr, in that case search starts from the top.
Returns
CppTypeTreeNode corresponding to given name.
Note
Name should NOT contain scope resolution operator(::).
Remarks
The search moves downward. E.g. if parentNode does not contain the type whose name is name then it is searched in child nodes and keeps going downwards till a match is found or type-hierarchy ends without a match.

Definition at line 181 of file cppprog.cpp.

Here is the call graph for this function:

◆ typeTreeNodeFromCppObj()

const CppTypeTreeNode * CppProgram::typeTreeNodeFromCppObj ( CppObj cppObj) const
inline
Returns
CppTypeTreeNode for CppObj.
Note
Return value may be nullptr if CppObj does not represent a valid type.

Definition at line 127 of file cppprog.h.

Member Data Documentation

◆ cppObjToTypeNode_

CppObjToTypeNodeMap CppProgram::cppObjToTypeNode_
private

Definition at line 119 of file cppprog.h.

◆ cppTypeTreeRoot_

CppTypeTreeNode CppProgram::cppTypeTreeRoot_
private

Repository of all compound objects arranged as type-tree.

Definition at line 118 of file cppprog.h.

◆ fileAsts_

CppCompoundArray CppProgram::fileAsts_
private

Array of all top level ASTs corresponding to files.

Definition at line 117 of file cppprog.h.


The documentation for this class was generated from the following files: