Classes | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | Static Private Attributes | Friends | List of all members
DefineManager Class Reference

Singleton that manages the defines available while proprocessing files. More...

Classes

class  DefinesPerFile
 

Public Member Functions

void startContext (const char *fileName)
 
void endContext ()
 
void addFileToContext (const char *fileName)
 
void addDefine (const char *fileName, Define *def)
 
void addInclude (const char *fromFileName, const char *toFileName)
 
DefineisDefined (const char *name) const
 
const DefineDictdefineContext () const
 

Static Public Member Functions

static DefineManagerinstance ()
 
static void deleteInstance ()
 

Private Member Functions

void collectDefinesForFile (const char *fileName, DefineDict *dict)
 
DefinesPerFilefind (const char *fileName) const
 
 DefineManager ()
 
virtual ~DefineManager ()
 

Private Attributes

QDict< DefinesPerFilem_fileMap
 
DefineDict m_contextDefines
 

Static Private Attributes

static DefineManagertheInstance = 0
 

Friends

class DefinesPerFile
 

Detailed Description

Singleton that manages the defines available while proprocessing files.

Definition at line 2595 of file pre.cpp.

Constructor & Destructor Documentation

DefineManager::DefineManager ( )
inlineprivate

Creates a new DefineManager object

Definition at line 2777 of file pre.cpp.

2777  : m_fileMap(1009), m_contextDefines(1009)
2778  {
2779  m_fileMap.setAutoDelete(TRUE);
2780  }
QDict< DefinesPerFile > m_fileMap
Definition: pre.cpp:2787
DefineDict m_contextDefines
Definition: pre.cpp:2788
const bool TRUE
Definition: qglobal.h:371
virtual DefineManager::~DefineManager ( )
inlineprivatevirtual

Destroys the object

Definition at line 2783 of file pre.cpp.

2784  {
2785  }

Member Function Documentation

void DefineManager::addDefine ( const char *  fileName,
Define def 
)
inline

Add a define to the manager object.

Parameters
fileNameThe file in which the define was found
defThe Define object to add.

Definition at line 2703 of file pre.cpp.

2704  {
2705  if (fileName==0) return;
2706  //printf("DefineManager::addDefine(%s,%s)\n",fileName,def->name.data());
2707  Define *d = m_contextDefines.find(def->name);
2708  if (d!=0) // redefine
2709  {
2710  m_contextDefines.remove(d->name);
2711  }
2712  m_contextDefines.insert(def->name,def);
2713 
2714  DefinesPerFile *dpf = m_fileMap.find(fileName);
2715  if (dpf==0)
2716  {
2717  dpf = new DefinesPerFile;
2718  m_fileMap.insert(fileName,dpf);
2719  }
2720  dpf->addDefine(def);
2721  }
friend class DefinesPerFile
Definition: pre.cpp:2637
QDict< DefinesPerFile > m_fileMap
Definition: pre.cpp:2787
fileName
Definition: dumpTree.py:9
Definition: define.h:27
DefineDict m_contextDefines
Definition: pre.cpp:2788
QCString name
Definition: define.h:34
void DefineManager::addFileToContext ( const char *  fileName)
inline

Add an included file to the current context. If the file has been pre-processed already, all defines are added to the context.

Parameters
fileNameThe name of the include file to add to the context.

Definition at line 2680 of file pre.cpp.

2681  {
2682  if (fileName==0) return;
2683  //printf("DefineManager::addFileToContext(%s)\n",fileName);
2684  DefinesPerFile *dpf = m_fileMap.find(fileName);
2685  if (dpf==0)
2686  {
2687  //printf("New file!\n");
2688  dpf = new DefinesPerFile;
2689  m_fileMap.insert(fileName,dpf);
2690  }
2691  else
2692  {
2693  //printf("existing file!\n");
2694  QDict<void> includeStack(17);
2695  dpf->collectDefines(&m_contextDefines,includeStack);
2696  }
2697  }
friend class DefinesPerFile
Definition: pre.cpp:2637
QDict< DefinesPerFile > m_fileMap
Definition: pre.cpp:2787
static QStack< ConfigFileState > includeStack
Definition: config.cpp:1048
fileName
Definition: dumpTree.py:9
DefineDict m_contextDefines
Definition: pre.cpp:2788
void DefineManager::addInclude ( const char *  fromFileName,
const char *  toFileName 
)
inline

Add an include relation to the manager object.

Parameters
fromFileNamefile name in which the include was found.
toFileNamefile name that is included.

Definition at line 2727 of file pre.cpp.

2728  {
2729  //printf("DefineManager::addInclude(%s,%s)\n",fromFileName,toFileName);
2730  if (fromFileName==0 || toFileName==0) return;
2731  DefinesPerFile *dpf = m_fileMap.find(fromFileName);
2732  if (dpf==0)
2733  {
2734  dpf = new DefinesPerFile;
2735  m_fileMap.insert(fromFileName,dpf);
2736  }
2737  dpf->addInclude(toFileName);
2738  }
friend class DefinesPerFile
Definition: pre.cpp:2637
QDict< DefinesPerFile > m_fileMap
Definition: pre.cpp:2787
void DefineManager::collectDefinesForFile ( const char *  fileName,
DefineDict dict 
)
inlineprivate

Helper function to collect all define for a given file

Definition at line 2758 of file pre.cpp.

2759  {
2760  if (fileName==0) return;
2761  DefinesPerFile *dpf = m_fileMap.find(fileName);
2762  if (dpf)
2763  {
2764  QDict<void> includeStack(17);
2765  dpf->collectDefines(dict,includeStack);
2766  }
2767  }
friend class DefinesPerFile
Definition: pre.cpp:2637
QDict< DefinesPerFile > m_fileMap
Definition: pre.cpp:2787
static QStack< ConfigFileState > includeStack
Definition: config.cpp:1048
fileName
Definition: dumpTree.py:9
const DefineDict& DefineManager::defineContext ( ) const
inline

Returns a reference to the defines found in the current context.

Definition at line 2750 of file pre.cpp.

2751  {
2752  return m_contextDefines;
2753  }
DefineDict m_contextDefines
Definition: pre.cpp:2788
static void DefineManager::deleteInstance ( )
inlinestatic

Deletes the singleton

Definition at line 2645 of file pre.cpp.

2646  {
2647  delete theInstance;
2648  theInstance = 0;
2649  }
static DefineManager * theInstance
Definition: pre.cpp:2755
void DefineManager::endContext ( )
inline

Ends the context started with startContext() freeing any defines collected within in this context.

Definition at line 2670 of file pre.cpp.

2671  {
2672  //printf("DefineManager::endContext()\n");
2673  m_contextDefines.clear();
2674  }
DefineDict m_contextDefines
Definition: pre.cpp:2788
DefinesPerFile* DefineManager::find ( const char *  fileName) const
inlineprivate

Helper function to return the DefinesPerFile object for a given file name.

Definition at line 2770 of file pre.cpp.

2771  {
2772  if (fileName==0) return 0;
2773  return m_fileMap.find(fileName);
2774  }
QDict< DefinesPerFile > m_fileMap
Definition: pre.cpp:2787
fileName
Definition: dumpTree.py:9
static DefineManager& DefineManager::instance ( )
inlinestatic

Returns a reference to the singleton

Definition at line 2639 of file pre.cpp.

2640  {
2641  if (theInstance==0) theInstance = new DefineManager;
2642  return *theInstance;
2643  }
DefineManager()
Definition: pre.cpp:2777
static DefineManager * theInstance
Definition: pre.cpp:2755
Define* DefineManager::isDefined ( const char *  name) const
inline

Returns a Define object given its name or 0 if the Define does not exist.

Definition at line 2742 of file pre.cpp.

2743  {
2744  Define *d = m_contextDefines.find(name);
2745  if (d && d->undef) d=0;
2746  //printf("isDefined(%s)=%p\n",name,d);
2747  return d;
2748  }
static QCString name
Definition: declinfo.cpp:673
Definition: define.h:27
DefineDict m_contextDefines
Definition: pre.cpp:2788
bool undef
Definition: define.h:45
void DefineManager::startContext ( const char *  fileName)
inline

Starts a context in which defines are collected. Called at the start of a new file that is preprocessed.

Parameters
fileNamethe name of the file to process.

Definition at line 2654 of file pre.cpp.

2655  {
2656  //printf("DefineManager::startContext()\n");
2657  m_contextDefines.clear();
2658  if (fileName==0) return;
2659  DefinesPerFile *dpf = m_fileMap.find(fileName);
2660  if (dpf==0)
2661  {
2662  //printf("New file!\n");
2663  dpf = new DefinesPerFile;
2664  m_fileMap.insert(fileName,dpf);
2665  }
2666  }
friend class DefinesPerFile
Definition: pre.cpp:2637
QDict< DefinesPerFile > m_fileMap
Definition: pre.cpp:2787
fileName
Definition: dumpTree.py:9
DefineDict m_contextDefines
Definition: pre.cpp:2788

Friends And Related Function Documentation

friend class DefinesPerFile
friend

Definition at line 2637 of file pre.cpp.

Member Data Documentation

DefineDict DefineManager::m_contextDefines
private

Definition at line 2788 of file pre.cpp.

QDict<DefinesPerFile> DefineManager::m_fileMap
private

Definition at line 2787 of file pre.cpp.

DefineManager * DefineManager::theInstance = 0
staticprivate

Singleton instance

Definition at line 2755 of file pre.cpp.


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