Doxygen
ParserManager类 参考

Manages programming language parsers. 更多...

#include <parserintf.h>

+ ParserManager 的协作图:

struct  ParserPair
 

Public 成员函数

 ParserManager (OutlineParserFactory outlineParserFactory, CodeParserFactory codeParserFactory)
 Create the parser manager 更多...
 
void registerParser (const QCString &name, OutlineParserFactory outlineParserFactory, CodeParserFactory codeParserFactory)
 Registers an additional parser. 更多...
 
bool registerExtension (const QCString &extension, const QCString &parserName)
 Registers a file extension with a parser with name parserName. 更多...
 
std::unique_ptr< OutlineParserInterfacegetOutlineParser (const QCString &extension)
 Gets the interface to the parser associated with a given extension. 更多...
 
std::unique_ptr< CodeParserInterfacegetCodeParser (const QCString &extension)
 Gets the interface to the parser associated with a given extension. 更多...
 
CodeParserFactorygetCodeParserFactory (const QCString &extension)
 Get the factory for create code parser objects with a given extension. 更多...
 
QCString getParserName (const QCString &extension)
 Gets the name of the parser associated with given extension. 更多...
 

Private 成员函数

ParserPairgetParsers (const QCString &extension)
 

Private 属性

std::map< std::string, ParserPairm_parsers
 
std::map< std::string, ParserPair & > m_extensions
 
ParserPair m_defaultParsers
 

详细描述

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.

在文件 parserintf.h145 行定义.

构造及析构函数说明

◆ ParserManager()

ParserManager::ParserManager ( OutlineParserFactory  outlineParserFactory,
CodeParserFactory  codeParserFactory 
)
inline

Create the parser manager

参数
outlineParserFactorythe fallback outline parser factory to use for unknown extensions
codeParserFactorythe fallback code parser factory to use for unknown extensions

在文件 parserintf.h165 行定义.

167  : m_defaultParsers(outlineParserFactory,codeParserFactory, QCString())
168  {
169  }

成员函数说明

◆ getCodeParser()

std::unique_ptr<CodeParserInterface> ParserManager::getCodeParser ( const QCString extension)
inline

Gets the interface to the parser associated with a given extension.

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

在文件 parserintf.h217 行定义.

218  {
219  auto factory = getCodeParserFactory(extension);
220  return factory();
221  }

引用了 getCodeParserFactory().

被这些函数引用 MemberDefImpl::_writeMultiLineInitializer(), generateExampleDocs(), parseCode(), FileDefImpl::parseSource(), ConceptDefImpl::writeDefinition(), DefinitionImpl::writeInlineCode(), VhdlDocGen::writeSource(), FileDefImpl::writeSourceBody() , 以及 writeXMLCodeBlock().

◆ getCodeParserFactory()

CodeParserFactory& ParserManager::getCodeParserFactory ( const QCString extension)
inline

Get the factory for create code parser objects with a given extension.

在文件 parserintf.h224 行定义.

225  {
226  return getParsers(extension).codeParserFactory;
227  }

引用了 ParserManager::ParserPair::codeParserFactory , 以及 getParsers().

被这些函数引用 getCodeParser().

◆ getOutlineParser()

std::unique_ptr<OutlineParserInterface> ParserManager::getOutlineParser ( const QCString extension)
inline

Gets the interface to the parser associated with a given extension.

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

在文件 parserintf.h208 行定义.

209  {
210  return getParsers(extension).outlineParserFactory();
211  }

引用了 getParsers() , 以及 ParserManager::ParserPair::outlineParserFactory.

被这些函数引用 VhdlDocGen::createFlowChart(), getParserForFile() , 以及 MarkdownOutlineParser::parsePrototype().

◆ getParserName()

QCString ParserManager::getParserName ( const QCString extension)
inline

Gets the name of the parser associated with given extension.

If there is no parser explicitly registered for the supplied extension, te empty string will be reurned.

在文件 parserintf.h233 行定义.

234  {
235  return getParsers(extension).parserName;
236  }

引用了 getParsers() , 以及 ParserManager::ParserPair::parserName.

被这些函数引用 convertFileNameFortranParserCode().

◆ getParsers()

ParserPair& ParserManager::getParsers ( const QCString extension)
inlineprivate

在文件 parserintf.h239 行定义.

240  {
241  QCString ext = extension.lower();
242  if (ext.isEmpty()) ext=".no_extension";
243  auto it = m_extensions.find(ext.data());
244  if (it==m_extensions.end() && ext.length()>4)
245  {
246  it = m_extensions.find(ext.left(4).data());
247  }
248  return it!=m_extensions.end() ? it->second : m_defaultParsers;
249  }

引用了 QCString::data(), QCString::isEmpty(), QCString::left(), QCString::length(), QCString::lower(), m_defaultParsers , 以及 m_extensions.

被这些函数引用 getCodeParserFactory(), getOutlineParser() , 以及 getParserName().

◆ registerExtension()

bool ParserManager::registerExtension ( const QCString extension,
const QCString parserName 
)
inline

Registers a file extension with a parser with name parserName.

Returns TRUE if the extension was successfully registered.

在文件 parserintf.h188 行定义.

189  {
190  if (parserName.isEmpty() || extension.isEmpty()) return FALSE;
191 
192  const auto &parserIt = m_parsers.find(parserName.str());
193  if (parserIt == m_parsers.end()) return FALSE;
194 
195  auto extensionIt = m_extensions.find(extension.str());
196  if (extensionIt != m_extensions.end()) // extension already exists
197  {
198  m_extensions.erase(extensionIt); // remove it (e.g. user specified extension overrules built in one)
199  }
200  m_extensions.emplace(extension.str(),parserIt->second); // add new mapping
201  return TRUE;
202  }

引用了 FALSE, QCString::isEmpty(), m_extensions, m_parsers, QCString::str() , 以及 TRUE.

◆ registerParser()

void ParserManager::registerParser ( const QCString name,
OutlineParserFactory  outlineParserFactory,
CodeParserFactory  codeParserFactory 
)
inline

Registers an additional parser.

参数
[in]nameA symbolic name of the parser, i.e. "c", "python", "fortran", "vhdl", ...
[in]outlineParserFactoryA factory method to create a language parser (scanner) that is to be used for the given name.
[in]codeParserFactoryA factory method to create a code parser that is to be used for the given name.

在文件 parserintf.h179 行定义.

181  {
182  m_parsers.emplace(name.str(),ParserPair(outlineParserFactory,codeParserFactory,name));
183  }

引用了 m_parsers , 以及 QCString::str().

被这些函数引用 initDoxygen().

类成员变量说明

◆ m_defaultParsers

ParserPair ParserManager::m_defaultParsers
private

在文件 parserintf.h253 行定义.

被这些函数引用 getParsers().

◆ m_extensions

std::map<std::string,ParserPair &> ParserManager::m_extensions
private

在文件 parserintf.h252 行定义.

被这些函数引用 getParsers() , 以及 registerExtension().

◆ m_parsers

std::map<std::string,ParserPair> ParserManager::m_parsers
private

在文件 parserintf.h251 行定义.

被这些函数引用 registerExtension() , 以及 registerParser().


该类的文档由以下文件生成:
ParserManager::m_defaultParsers
ParserPair m_defaultParsers
Definition: parserintf.h:253
QCString::length
uint length() const
Returns the length of the string, not counting the 0-terminator.
Definition: qcstring.h:147
QCString::isEmpty
bool isEmpty() const
Returns TRUE iff the string is empty
Definition: qcstring.h:144
ParserManager::getParsers
ParserPair & getParsers(const QCString &extension)
Definition: parserintf.h:239
ParserManager::m_parsers
std::map< std::string, ParserPair > m_parsers
Definition: parserintf.h:251
QCString::str
std::string str() const
Definition: qcstring.h:442
QCString::left
QCString left(size_t len) const
Definition: qcstring.h:212
QCString::lower
QCString lower() const
Definition: qcstring.h:232
ParserManager::getCodeParserFactory
CodeParserFactory & getCodeParserFactory(const QCString &extension)
Get the factory for create code parser objects with a given extension.
Definition: parserintf.h:224
ParserManager::ParserPair::parserName
QCString parserName
Definition: parserintf.h:157
TRUE
#define TRUE
Definition: qcstring.h:36
QCString::data
const char * data() const
Returns a pointer to the contents of the string in the form of a 0-terminated C string
Definition: qcstring.h:153
ParserManager::m_extensions
std::map< std::string, ParserPair & > m_extensions
Definition: parserintf.h:252
ParserManager::ParserPair::codeParserFactory
CodeParserFactory codeParserFactory
Definition: parserintf.h:156
ParserManager::ParserPair::outlineParserFactory
OutlineParserFactory outlineParserFactory
Definition: parserintf.h:155
FALSE
#define FALSE
Definition: qcstring.h:33
QCString
This is an alternative implementation of QCString.
Definition: qcstring.h:108