Public Member Functions | Private Attributes | List of all members
ParserManager Class Reference

Manages programming language parsers. More...

#include <parserintf.h>

Public Member Functions

 ParserManager ()
 
 ~ParserManager ()
 
void registerDefaultParser (ParserInterface *parser)
 
void registerParser (const char *name, ParserInterface *parser)
 
bool registerExtension (const char *extension, const char *parserName)
 
ParserInterfacegetParser (const char *extension)
 

Private Attributes

QDict< ParserInterfacem_parsers
 
QDict< ParserInterfacem_extensions
 
ParserInterfacem_defaultParser
 

Detailed Description

Manages programming language parsers.

This class manages the language parsers in the system. One can register parsers, and obtain a parser given a file extension.

Definition at line 143 of file parserintf.h.

Constructor & Destructor Documentation

ParserManager::ParserManager ( )
inline

Creates the parser manager object.

Definition at line 148 of file parserintf.h.

149  : m_defaultParser(0) { m_parsers.setAutoDelete(TRUE); }
QDict< ParserInterface > m_parsers
Definition: parserintf.h:204
ParserInterface * m_defaultParser
Definition: parserintf.h:206
const bool TRUE
Definition: qglobal.h:371
ParserManager::~ParserManager ( )
inline

Definition at line 150 of file parserintf.h.

151  {
152  delete m_defaultParser;
153  }
ParserInterface * m_defaultParser
Definition: parserintf.h:206

Member Function Documentation

ParserInterface* ParserManager::getParser ( const char *  extension)
inline

Gets the interface to the parser associated with given extension. If there is no parser explicitly registered for the supplied extension, the interface to the default parser will be returned.

Definition at line 191 of file parserintf.h.

192  {
193  QCString ext = QCString(extension).lower();
194  if (ext.isEmpty()) ext=".no_extension";
195  ParserInterface *intf = m_extensions.find(ext);
196  if (intf==0 && ext.length()>4)
197  {
198  intf = m_extensions.find(ext.left(4));
199  }
200  return intf ? intf : m_defaultParser;
201  }
bool isEmpty() const
Definition: qcstring.h:189
uint length() const
Definition: qcstring.h:195
Abstract interface for programming language parsers.
Definition: parserintf.h:38
QCString left(uint len) const
Definition: qcstring.cpp:213
ParserInterface * m_defaultParser
Definition: parserintf.h:206
QDict< ParserInterface > m_extensions
Definition: parserintf.h:205
QCString lower() const
Definition: qcstring.cpp:263
void ParserManager::registerDefaultParser ( ParserInterface parser)
inline

Definition at line 155 of file parserintf.h.

156  {
158  }
ParserInterface * m_defaultParser
Definition: parserintf.h:206
bool ParserManager::registerExtension ( const char *  extension,
const char *  parserName 
)
inline

Registers a file extension with a parser with name parserName. Returns TRUE if the extension was successfully registered.

Definition at line 174 of file parserintf.h.

175  {
176  if (parserName==0 || extension==0) return FALSE;
177  ParserInterface *intf = m_parsers.find(parserName);
178  if (intf==0) return FALSE;
179  if (m_extensions.find(extension)!=0) // extension already exists
180  {
181  m_extensions.remove(extension); // remove it
182  }
183  m_extensions.insert(extension,intf); // add new mapping
184  return TRUE;
185  }
QDict< ParserInterface > m_parsers
Definition: parserintf.h:204
Abstract interface for programming language parsers.
Definition: parserintf.h:38
const bool FALSE
Definition: qglobal.h:370
QDict< ParserInterface > m_extensions
Definition: parserintf.h:205
const bool TRUE
Definition: qglobal.h:371
void ParserManager::registerParser ( const char *  name,
ParserInterface parser 
)
inline

Registers an additional parser.

Parameters
[in]nameA symbolic name of the parser, i.e. "c", "python", "fortran", "vhdl", ...
[in]parserThe parser that is to be used for the given name.

Definition at line 166 of file parserintf.h.

167  {
168  m_parsers.insert(name,parser);
169  }
static QCString name
Definition: declinfo.cpp:673
QDict< ParserInterface > m_parsers
Definition: parserintf.h:204

Member Data Documentation

ParserInterface* ParserManager::m_defaultParser
private

Definition at line 206 of file parserintf.h.

QDict<ParserInterface> ParserManager::m_extensions
private

Definition at line 205 of file parserintf.h.

QDict<ParserInterface> ParserManager::m_parsers
private

Definition at line 204 of file parserintf.h.


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