Public Member Functions | Private Attributes | List of all members
DefineManager::DefinesPerFile Class Reference

Public Member Functions

 DefinesPerFile ()
 
virtual ~DefinesPerFile ()
 
void addDefine (Define *def)
 
void addInclude (const char *fileName)
 
void collectDefines (DefineDict *dict, QDict< void > &includeStack)
 

Private Attributes

DefineDict m_defines
 
QDict< void > m_includedFiles
 

Detailed Description

Local class used to hold the defines for a single file

Definition at line 2598 of file pre.cpp.

Constructor & Destructor Documentation

DefineManager::DefinesPerFile::DefinesPerFile ( )
inline

Creates an empty container for defines

Definition at line 2602 of file pre.cpp.

2602  : m_defines(257), m_includedFiles(17)
2603  {
2604  m_defines.setAutoDelete(TRUE);
2605  }
QDict< void > m_includedFiles
Definition: pre.cpp:2633
const bool TRUE
Definition: qglobal.h:371
virtual DefineManager::DefinesPerFile::~DefinesPerFile ( )
inlinevirtual

Destroys the object

Definition at line 2607 of file pre.cpp.

2608  {
2609  }

Member Function Documentation

void DefineManager::DefinesPerFile::addDefine ( Define def)
inline

Adds a define in the context of a file. Will replace an existing define with the same name (redefinition)

Parameters
defThe Define object to add.

Definition at line 2614 of file pre.cpp.

2615  {
2616  Define *d = m_defines.find(def->name);
2617  if (d!=0) // redefine
2618  {
2619  m_defines.remove(d->name);
2620  }
2621  m_defines.insert(def->name,def);
2622  }
Definition: define.h:27
QCString name
Definition: define.h:34
void DefineManager::DefinesPerFile::addInclude ( const char *  fileName)
inline

Adds an include file for this file

Parameters
fileNameThe name of the include file

Definition at line 2626 of file pre.cpp.

2627  {
2628  m_includedFiles.insert(fileName,(void*)0x8);
2629  }
fileName
Definition: dumpTree.py:9
QDict< void > m_includedFiles
Definition: pre.cpp:2633
void DefineManager::DefinesPerFile::collectDefines ( DefineDict dict,
QDict< void > &  includeStack 
)

Collects all defines for a file and all files that the file includes. This function will recursively call itself for each file.

Parameters
dictThe dictionary to fill with the defines. A redefine will replace a previous definition.
includeStackThe stack of includes, used to stop recursion in case there is a cyclic include dependency.

Definition at line 2801 of file pre.cpp.

2803 {
2804  //printf("DefinesPerFile::collectDefines #defines=%d\n",m_defines.count());
2805  {
2806  QDictIterator<void> di(m_includedFiles);
2807  for (di.toFirst();(di.current());++di)
2808  {
2809  QCString incFile = di.currentKey();
2810  DefinesPerFile *dpf = DefineManager::instance().find(incFile);
2811  if (dpf && includeStack.find(incFile)==0)
2812  {
2813  //printf(" processing include %s\n",incFile.data());
2814  includeStack.insert(incFile,(void*)0x8);
2815  dpf->collectDefines(dict,includeStack);
2816  }
2817  }
2818  }
2819  {
2820  QDictIterator<Define> di(m_defines);
2821  Define *def;
2822  for (di.toFirst();(def=di.current());++di)
2823  {
2824  Define *d = dict->find(def->name);
2825  if (d!=0) // redefine
2826  {
2827  dict->remove(d->name);
2828  }
2829  dict->insert(def->name,def);
2830  //printf(" adding define %s\n",def->name.data());
2831  }
2832  }
2833 }
DefinesPerFile * find(const char *fileName) const
Definition: pre.cpp:2770
static DefineManager & instance()
Definition: pre.cpp:2639
static QStack< ConfigFileState > includeStack
Definition: config.cpp:1048
Definition: define.h:27
QDict< void > m_includedFiles
Definition: pre.cpp:2633
QCString name
Definition: define.h:34

Member Data Documentation

DefineDict DefineManager::DefinesPerFile::m_defines
private

Definition at line 2632 of file pre.cpp.

QDict<void> DefineManager::DefinesPerFile::m_includedFiles
private

Definition at line 2633 of file pre.cpp.


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