My Project
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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.

References m_parsers.

: m_defaultParser(0) { m_parsers.setAutoDelete(TRUE); }
ParserManager::~ParserManager ( )
inline

Definition at line 150 of file parserintf.h.

References m_defaultParser.

{
}

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.

References m_defaultParser, and m_extensions.

Referenced by getParserForFile(), MarkdownFileParser::parseCode(), parseCode(), MarkdownFileParser::parsePrototype(), FileDef::parseSource(), MarkdownFileParser::resetCodeParserState(), DocbookDocVisitor::visit(), ManDocVisitor::visit(), RTFDocVisitor::visit(), XmlDocVisitor::visit(), HtmlDocVisitor::visit(), LatexDocVisitor::visit(), writeDocbookCodeBlock(), MemberDef::writeDocumentation(), Definition::writeInlineCode(), FileDef::writeSource(), VhdlDocGen::writeSource(), and writeXMLCodeBlock().

{
QCString ext = QCString(extension).lower();
if (ext.isEmpty()) ext=".no_extension";
ParserInterface *intf = m_extensions.find(ext);
if (intf==0 && ext.length()>4)
{
intf = m_extensions.find(ext.left(4));
}
return intf ? intf : m_defaultParser;
}
void ParserManager::registerDefaultParser ( ParserInterface parser)
inline

Definition at line 155 of file parserintf.h.

References m_defaultParser.

Referenced by initDoxygen().

{
m_defaultParser = parser;
}
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.

References m_extensions, and m_parsers.

{
if (parserName==0 || extension==0) return FALSE;
ParserInterface *intf = m_parsers.find(parserName);
if (intf==0) return FALSE;
if (m_extensions.find(extension)!=0) // extension already exists
{
m_extensions.remove(extension); // remove it
}
m_extensions.insert(extension,intf); // add new mapping
return TRUE;
}
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.

References m_parsers.

Referenced by initDoxygen().

{
m_parsers.insert(name,parser);
}

Member Data Documentation

ParserInterface* ParserManager::m_defaultParser
private

Definition at line 206 of file parserintf.h.

Referenced by getParser(), registerDefaultParser(), and ~ParserManager().

QDict<ParserInterface> ParserManager::m_extensions
private

Definition at line 205 of file parserintf.h.

Referenced by getParser(), and registerExtension().

QDict<ParserInterface> ParserManager::m_parsers
private

Definition at line 204 of file parserintf.h.

Referenced by ParserManager(), registerExtension(), and registerParser().


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