My Project
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | Static Private Attributes | List of all members
HtmlEntityMapper Class Reference

Singleton helper class to map html entities to other formats. More...

#include <htmlentity.h>

Public Member Functions

DocSymbol::SymType name2sym (const QCString &symName) const
 Give code of the requested HTML entity name.
 
const char * utf8 (DocSymbol::SymType symb, bool useInPrintf=FALSE) const
 Access routine to the UTF8 code of the HTML entity.
 
const char * html (DocSymbol::SymType symb, bool useInPrintf=FALSE) const
 Access routine to the html code of the HTML entity.
 
const char * xml (DocSymbol::SymType symb) const
 Access routine to the XML code of the HTML entity.
 
const char * docbook (DocSymbol::SymType symb) const
 Access routine to the docbook code of the HTML entity.
 
const char * latex (DocSymbol::SymType symb) const
 Access routine to the LaTeX code of the HTML entity.
 
const char * man (DocSymbol::SymType symb) const
 Access routine to the man code of the HTML entity.
 
const char * rtf (DocSymbol::SymType symb) const
 Access routine to the RTF code of the HTML entity.
 
const DocSymbol::PerlSymbperl (DocSymbol::SymType symb) const
 Access routine to the perl struct with the perl code of the HTML entity.
 
void writeXMLSchema (FTextStream &t)
 

Static Public Member Functions

static HtmlEntityMapperinstance ()
 
static void deleteInstance ()
 

Private Member Functions

void validate ()
 Routine to check if the entries of the html_entities are numbered correctly.
 
 HtmlEntityMapper ()
 
 ~HtmlEntityMapper ()
 

Private Attributes

QDict< int > * m_name2sym
 

Static Private Attributes

static HtmlEntityMappers_instance = 0
 

Detailed Description

Singleton helper class to map html entities to other formats.

Definition at line 24 of file htmlentity.h.

Constructor & Destructor Documentation

HtmlEntityMapper::HtmlEntityMapper ( )
private

Definition at line 324 of file htmlentity.cpp.

References g_htmlEntities, g_numHtmlEntities, m_name2sym, and validate().

Referenced by instance().

{
m_name2sym = new QDict<int>(1009);
m_name2sym->setAutoDelete(TRUE);
for (int i = 0; i < g_numHtmlEntities; i++)
{
m_name2sym->insert(g_htmlEntities[i].item,new int(g_htmlEntities[i].symb));
}
}
HtmlEntityMapper::~HtmlEntityMapper ( )
private

Definition at line 335 of file htmlentity.cpp.

References m_name2sym.

{
delete m_name2sym;
}

Member Function Documentation

void HtmlEntityMapper::deleteInstance ( )
static

Deletes the one and only instance of the HTML entity mapper

Definition at line 351 of file htmlentity.cpp.

References s_instance.

{
delete s_instance;
}
const char * HtmlEntityMapper::docbook ( DocSymbol::SymType  symb) const

Access routine to the docbook code of the HTML entity.

Parameters
symbCode of the requested HTML entity
Returns
the docbook code of the HTML entity, in case the docbook code is unknown NULL is returned.

Definition at line 415 of file htmlentity.cpp.

References htmlEntityInfo::docbook, and g_htmlEntities.

Referenced by DocbookDocVisitor::visit().

{
return g_htmlEntities[symb].docbook;
}
const char * HtmlEntityMapper::html ( DocSymbol::SymType  symb,
bool  useInPrintf = FALSE 
) const

Access routine to the html code of the HTML entity.

Parameters
symbCode of the requested HTML entity
useInPrintfIf TRUE the result will be escaped such that it can be used in a printf string pattern
Returns
the html representation of the HTML entity, in case the html code is unknown NULL is returned.

Definition at line 386 of file htmlentity.cpp.

References g_htmlEntities, htmlEntityInfo::html, and DocSymbol::Sym_Percent.

Referenced by TextDocVisitor::visit(), and HtmlDocVisitor::visit().

{
if (useInPrintf && symb==DocSymbol::Sym_Percent)
{
return "%%"; // escape for printf
}
else
{
return g_htmlEntities[symb].html;
}
}
HtmlEntityMapper * HtmlEntityMapper::instance ( )
static
const char * HtmlEntityMapper::latex ( DocSymbol::SymType  symb) const

Access routine to the LaTeX code of the HTML entity.

Parameters
symbCode of the requested HTML entity
Returns
the LaTeX code of the HTML entity, in case the LaTeX code is unknown NULL is returned.

Definition at line 426 of file htmlentity.cpp.

References g_htmlEntities, and htmlEntityInfo::latex.

Referenced by filterLatexString(), and LatexDocVisitor::visit().

{
return g_htmlEntities[symb].latex;
}
const char * HtmlEntityMapper::man ( DocSymbol::SymType  symb) const

Access routine to the man code of the HTML entity.

Parameters
symbCode of the requested HTML entity
Returns
the man of the HTML entity, in case the man code is unknown NULL is returned.

Definition at line 437 of file htmlentity.cpp.

References g_htmlEntities, and htmlEntityInfo::man.

Referenced by ManDocVisitor::visit().

{
return g_htmlEntities[symb].man;
}
DocSymbol::SymType HtmlEntityMapper::name2sym ( const QCString &  symName) const

Give code of the requested HTML entity name.

Parameters
symNameHTML entity name without & and ;
Returns
the code for the requested HTML entity name, in case the requested HTML item does not exist DocSymbol::Sym_unknown is returned.

Definition at line 471 of file htmlentity.cpp.

References m_name2sym, and DocSymbol::Sym_Unknown.

Referenced by convertCharEntitiesToUTF8(), DocSymbol::decodeSymbol(), and filterLatexString().

{
int *pSymb = m_name2sym->find(symName);
return pSymb ? ((DocSymbol::SymType)*pSymb) : DocSymbol::Sym_Unknown;
}
const DocSymbol::PerlSymb * HtmlEntityMapper::perl ( DocSymbol::SymType  symb) const

Access routine to the perl struct with the perl code of the HTML entity.

Parameters
symbCode of the requested HTML entity
Returns
the pointer to perl struct with the perl code of the HTML entity, in case the perl code does not exists the NULL pointer is entered in the symb field and in the DocSymbol::Perl_unknown in the type field.

Definition at line 460 of file htmlentity.cpp.

References g_htmlEntities, and htmlEntityInfo::perl.

Referenced by PerlModDocVisitor::visit().

{
return &g_htmlEntities[symb].perl;
}
const char * HtmlEntityMapper::rtf ( DocSymbol::SymType  symb) const

Access routine to the RTF code of the HTML entity.

Parameters
symbCode of the requested HTML entity
Returns
the RTF of the HTML entity, in case the RTF code is unknown NULL is returned.

Definition at line 448 of file htmlentity.cpp.

References g_htmlEntities, and htmlEntityInfo::rtf.

Referenced by RTFDocVisitor::visit().

{
return g_htmlEntities[symb].rtf;
}
const char * HtmlEntityMapper::utf8 ( DocSymbol::SymType  symb,
bool  useInPrintf = FALSE 
) const

Access routine to the UTF8 code of the HTML entity.

Parameters
symbCode of the requested HTML entity
useInPrintfIf TRUE the result will be escaped such that it can be used in a printf string pattern
Returns
the UTF8 code of the HTML entity, in case the UTF code is unknown NULL is returned.

Definition at line 366 of file htmlentity.cpp.

References g_htmlEntities, DocSymbol::Sym_Percent, and htmlEntityInfo::UTF8.

Referenced by PrintDocVisitor::visit().

{
if (useInPrintf && symb==DocSymbol::Sym_Percent)
{
return "%%"; // escape for printf
}
else
{
return g_htmlEntities[symb].UTF8;
}
}
void HtmlEntityMapper::validate ( )
private

Routine to check if the entries of the html_entities are numbered correctly.

in case of a mismatch a warning message is given.

Definition at line 493 of file htmlentity.cpp.

References g_htmlEntities, g_numHtmlEntities, and warn_uncond().

Referenced by HtmlEntityMapper().

{
for (int i = 0; i < g_numHtmlEntities; i++)
{
if (i != g_htmlEntities[i].symb)
{
warn_uncond("Internal inconsistency, htmlentries code %d (item=%s)\n",i,g_htmlEntities[i].item);
}
}
}
void HtmlEntityMapper::writeXMLSchema ( FTextStream t)

Definition at line 477 of file htmlentity.cpp.

References g_htmlEntities, g_numberHtmlMappedCmds, g_numHtmlEntities, and htmlEntityInfo::xml.

Referenced by generateXML().

{
{
QCString bareName = g_htmlEntities[i].xml;
if (!bareName.isEmpty() && bareName.at(0)=='<' && bareName.right(2)=="/>")
{
bareName = bareName.mid(1,bareName.length()-3); // strip < and />
t << " <xsd:element name=\"" << bareName << "\" type=\"docEmptyType\" />\n";
}
}
}
const char * HtmlEntityMapper::xml ( DocSymbol::SymType  symb) const

Access routine to the XML code of the HTML entity.

Parameters
symbCode of the requested HTML entity
Returns
the XML code of the HTML entity, in case the XML code is unknown NULL is returned.

Definition at line 404 of file htmlentity.cpp.

References g_htmlEntities, and htmlEntityInfo::xml.

Referenced by XmlDocVisitor::visit().

{
return g_htmlEntities[symb].xml;
}

Member Data Documentation

QDict<int>* HtmlEntityMapper::m_name2sym
private

Definition at line 44 of file htmlentity.h.

Referenced by HtmlEntityMapper(), name2sym(), and ~HtmlEntityMapper().

HtmlEntityMapper * HtmlEntityMapper::s_instance = 0
staticprivate

Definition at line 43 of file htmlentity.h.

Referenced by deleteInstance(), and instance().


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