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. More...
 
const char * utf8 (DocSymbol::SymType symb, bool useInPrintf=FALSE) const
 Access routine to the UTF8 code of the HTML entity. More...
 
const char * html (DocSymbol::SymType symb, bool useInPrintf=FALSE) const
 Access routine to the html code of the HTML entity. More...
 
const char * xml (DocSymbol::SymType symb) const
 Access routine to the XML code of the HTML entity. More...
 
const char * docbook (DocSymbol::SymType symb) const
 Access routine to the docbook code of the HTML entity. More...
 
const char * latex (DocSymbol::SymType symb) const
 Access routine to the LaTeX code of the HTML entity. More...
 
const char * man (DocSymbol::SymType symb) const
 Access routine to the man code of the HTML entity. More...
 
const char * rtf (DocSymbol::SymType symb) const
 Access routine to the RTF code of the HTML entity. More...
 
const DocSymbol::PerlSymbperl (DocSymbol::SymType symb) const
 Access routine to the perl struct with the perl code of the HTML entity. More...
 
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. More...
 
 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.

325 {
326  m_name2sym = new QDict<int>(1009);
327  m_name2sym->setAutoDelete(TRUE);
328  for (int i = 0; i < g_numHtmlEntities; i++)
329  {
330  m_name2sym->insert(g_htmlEntities[i].item,new int(g_htmlEntities[i].symb));
331  }
332  validate();
333 }
QDict< int > * m_name2sym
Definition: htmlentity.h:44
void validate()
Routine to check if the entries of the html_entities are numbered correctly.
Definition: htmlentity.cpp:493
static struct htmlEntityInfo g_htmlEntities[]
static const int g_numHtmlEntities
Definition: htmlentity.cpp:320
const bool TRUE
Definition: qglobal.h:371
HtmlEntityMapper::~HtmlEntityMapper ( )
private

Definition at line 335 of file htmlentity.cpp.

336 {
337  delete m_name2sym;
338 }
QDict< int > * m_name2sym
Definition: htmlentity.h:44

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.

352 {
353  delete s_instance;
354  s_instance=0;
355 }
static HtmlEntityMapper * s_instance
Definition: htmlentity.h:43
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.

416 {
417  return g_htmlEntities[symb].docbook;
418 }
static struct htmlEntityInfo g_htmlEntities[]
const char * docbook
Definition: htmlentity.cpp:34
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.

387 {
388  if (useInPrintf && symb==DocSymbol::Sym_Percent)
389  {
390  return "%%"; // escape for printf
391  }
392  else
393  {
394  return g_htmlEntities[symb].html;
395  }
396 }
static struct htmlEntityInfo g_htmlEntities[]
const char * html
Definition: htmlentity.cpp:32
HtmlEntityMapper * HtmlEntityMapper::instance ( )
static

Returns the one and only instance of the HTML entity mapper

Definition at line 341 of file htmlentity.cpp.

342 {
343  if (s_instance==0)
344  {
346  }
347  return s_instance;
348 }
static HtmlEntityMapper * s_instance
Definition: htmlentity.h:43
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.

427 {
428  return g_htmlEntities[symb].latex;
429 }
static struct htmlEntityInfo g_htmlEntities[]
const char * latex
Definition: htmlentity.cpp:35
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.

438 {
439  return g_htmlEntities[symb].man;
440 }
const char * man
Definition: htmlentity.cpp:36
static struct htmlEntityInfo g_htmlEntities[]
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.

472 {
473  int *pSymb = m_name2sym->find(symName);
474  return pSymb ? ((DocSymbol::SymType)*pSymb) : DocSymbol::Sym_Unknown;
475 }
QDict< int > * m_name2sym
Definition: htmlentity.h:44
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.

461 {
462  return &g_htmlEntities[symb].perl;
463 }
static struct htmlEntityInfo g_htmlEntities[]
DocSymbol::PerlSymb perl
Definition: htmlentity.cpp:38
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.

449 {
450  return g_htmlEntities[symb].rtf;
451 }
static struct htmlEntityInfo g_htmlEntities[]
const char * rtf
Definition: htmlentity.cpp:37
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.

367 {
368  if (useInPrintf && symb==DocSymbol::Sym_Percent)
369  {
370  return "%%"; // escape for printf
371  }
372  else
373  {
374  return g_htmlEntities[symb].UTF8;
375  }
376 }
const char * UTF8
Definition: htmlentity.cpp:31
static struct htmlEntityInfo g_htmlEntities[]
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.

494 {
495  for (int i = 0; i < g_numHtmlEntities; i++)
496  {
497  if (i != g_htmlEntities[i].symb)
498  {
499  warn_uncond("Internal inconsistency, htmlentries code %d (item=%s)\n",i,g_htmlEntities[i].item);
500  }
501  }
502 }
static struct htmlEntityInfo g_htmlEntities[]
static const int g_numHtmlEntities
Definition: htmlentity.cpp:320
void warn_uncond(const char *fmt,...)
Definition: message.cpp:218
void HtmlEntityMapper::writeXMLSchema ( FTextStream t)

Definition at line 477 of file htmlentity.cpp.

478 {
479  for (int i=0;i<g_numHtmlEntities - g_numberHtmlMappedCmds;i++)
480  {
481  QCString bareName = g_htmlEntities[i].xml;
482  if (!bareName.isEmpty() && bareName.at(0)=='<' && bareName.right(2)=="/>")
483  {
484  bareName = bareName.mid(1,bareName.length()-3); // strip < and />
485  t << " <xsd:element name=\"" << bareName << "\" type=\"docEmptyType\" />\n";
486  }
487  }
488 }
bool isEmpty() const
Definition: qcstring.h:189
uint length() const
Definition: qcstring.h:195
char & at(uint i) const
Definition: qcstring.h:326
const char * xml
Definition: htmlentity.cpp:33
static struct htmlEntityInfo g_htmlEntities[]
QCString right(uint len) const
Definition: qcstring.cpp:231
static const int g_numberHtmlMappedCmds
Number of doxygen commands mapped as if it were HTML entities.
Definition: htmlentity.cpp:21
QCString mid(uint index, uint len=0xffffffff) const
Definition: qcstring.cpp:246
static const int g_numHtmlEntities
Definition: htmlentity.cpp:320
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.

405 {
406  return g_htmlEntities[symb].xml;
407 }
const char * xml
Definition: htmlentity.cpp:33
static struct htmlEntityInfo g_htmlEntities[]

Member Data Documentation

QDict<int>* HtmlEntityMapper::m_name2sym
private

Definition at line 44 of file htmlentity.h.

HtmlEntityMapper * HtmlEntityMapper::s_instance = 0
staticprivate

Definition at line 43 of file htmlentity.h.


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