Doxygen
Loading...
Searching...
No Matches
HtmlEntityMapper Class Reference

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

#include <src/htmlentity.h>

+ Collaboration diagram for HtmlEntityMapper:

Classes

struct  PerlSymb
 

Public Types

enum  SymType {
  Sym_Unknown = -1 , Sym_nbsp , Sym_iexcl , Sym_cent ,
  Sym_pound , Sym_curren , Sym_yen , Sym_brvbar ,
  Sym_sect , Sym_uml , Sym_copy , Sym_ordf ,
  Sym_laquo , Sym_not , Sym_shy , Sym_reg ,
  Sym_macr , Sym_deg , Sym_plusmn , Sym_sup2 ,
  Sym_sup3 , Sym_acute , Sym_micro , Sym_para ,
  Sym_middot , Sym_cedil , Sym_sup1 , Sym_ordm ,
  Sym_raquo , Sym_frac14 , Sym_frac12 , Sym_frac34 ,
  Sym_iquest , Sym_Agrave , Sym_Aacute , Sym_Acirc ,
  Sym_Atilde , Sym_Auml , Sym_Aring , Sym_AElig ,
  Sym_Ccedil , Sym_Egrave , Sym_Eacute , Sym_Ecirc ,
  Sym_Euml , Sym_Igrave , Sym_Iacute , Sym_Icirc ,
  Sym_Iuml , Sym_ETH , Sym_Ntilde , Sym_Ograve ,
  Sym_Oacute , Sym_Ocirc , Sym_Otilde , Sym_Ouml ,
  Sym_times , Sym_Oslash , Sym_Ugrave , Sym_Uacute ,
  Sym_Ucirc , Sym_Uuml , Sym_Yacute , Sym_THORN ,
  Sym_szlig , Sym_agrave , Sym_aacute , Sym_acirc ,
  Sym_atilde , Sym_auml , Sym_aring , Sym_aelig ,
  Sym_ccedil , Sym_egrave , Sym_eacute , Sym_ecirc ,
  Sym_euml , Sym_igrave , Sym_iacute , Sym_icirc ,
  Sym_iuml , Sym_eth , Sym_ntilde , Sym_ograve ,
  Sym_oacute , Sym_ocirc , Sym_otilde , Sym_ouml ,
  Sym_divide , Sym_oslash , Sym_ugrave , Sym_uacute ,
  Sym_ucirc , Sym_uuml , Sym_yacute , Sym_thorn ,
  Sym_yuml , Sym_fnof , Sym_Alpha , Sym_Beta ,
  Sym_Gamma , Sym_Delta , Sym_Epsilon , Sym_Zeta ,
  Sym_Eta , Sym_Theta , Sym_Iota , Sym_Kappa ,
  Sym_Lambda , Sym_Mu , Sym_Nu , Sym_Xi ,
  Sym_Omicron , Sym_Pi , Sym_Rho , Sym_Sigma ,
  Sym_Tau , Sym_Upsilon , Sym_Phi , Sym_Chi ,
  Sym_Psi , Sym_Omega , Sym_alpha , Sym_beta ,
  Sym_gamma , Sym_delta , Sym_epsilon , Sym_zeta ,
  Sym_eta , Sym_theta , Sym_iota , Sym_kappa ,
  Sym_lambda , Sym_mu , Sym_nu , Sym_xi ,
  Sym_omicron , Sym_pi , Sym_rho , Sym_sigmaf ,
  Sym_sigma , Sym_tau , Sym_upsilon , Sym_phi ,
  Sym_chi , Sym_psi , Sym_omega , Sym_thetasym ,
  Sym_upsih , Sym_piv , Sym_bull , Sym_hellip ,
  Sym_prime , Sym_Prime , Sym_oline , Sym_frasl ,
  Sym_weierp , Sym_image , Sym_real , Sym_trade ,
  Sym_alefsym , Sym_larr , Sym_uarr , Sym_rarr ,
  Sym_darr , Sym_harr , Sym_crarr , Sym_lArr ,
  Sym_uArr , Sym_rArr , Sym_dArr , Sym_hArr ,
  Sym_forall , Sym_part , Sym_exist , Sym_empty ,
  Sym_nabla , Sym_isin , Sym_notin , Sym_ni ,
  Sym_prod , Sym_sum , Sym_minus , Sym_lowast ,
  Sym_radic , Sym_prop , Sym_infin , Sym_ang ,
  Sym_and , Sym_or , Sym_cap , Sym_cup ,
  Sym_int , Sym_there4 , Sym_sim , Sym_cong ,
  Sym_asymp , Sym_ne , Sym_equiv , Sym_le ,
  Sym_ge , Sym_sub , Sym_sup , Sym_nsub ,
  Sym_sube , Sym_supe , Sym_oplus , Sym_otimes ,
  Sym_perp , Sym_sdot , Sym_lceil , Sym_rceil ,
  Sym_lfloor , Sym_rfloor , Sym_lang , Sym_rang ,
  Sym_loz , Sym_spades , Sym_clubs , Sym_hearts ,
  Sym_diams , Sym_quot , Sym_amp , Sym_lt ,
  Sym_gt , Sym_OElig , Sym_oelig , Sym_Scaron ,
  Sym_scaron , Sym_Yuml , Sym_circ , Sym_tilde ,
  Sym_ensp , Sym_emsp , Sym_thinsp , Sym_zwnj ,
  Sym_zwj , Sym_lrm , Sym_rlm , Sym_ndash ,
  Sym_mdash , Sym_lsquo , Sym_rsquo , Sym_sbquo ,
  Sym_ldquo , Sym_rdquo , Sym_bdquo , Sym_dagger ,
  Sym_Dagger , Sym_permil , Sym_lsaquo , Sym_rsaquo ,
  Sym_euro , Sym_tm , Sym_apos , Sym_BSlash ,
  Sym_At , Sym_Less , Sym_Greater , Sym_Amp ,
  Sym_Dollar , Sym_Hash , Sym_DoubleColon , Sym_Percent ,
  Sym_Pipe , Sym_Quot , Sym_Minus , Sym_Plus ,
  Sym_Dot , Sym_Colon , Sym_Equal , Sym_Exclam ,
  Sym_Quest
}
 
enum  PerlType {
  Perl_unknown = 0 , Perl_string , Perl_char , Perl_symbol ,
  Perl_umlaut , Perl_acute , Perl_grave , Perl_circ ,
  Perl_slash , Perl_tilde , Perl_cedilla , Perl_ring
}
 

Public Member Functions

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

Static Public Member Functions

static HtmlEntityMapperinstance ()
 Returns the one and only instance of the HTML entity mapper.
 

Private Member Functions

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

Private Attributes

std::unordered_map< std::string, SymTypem_name2sym
 

Static Private Attributes

static HtmlEntityMappers_instance
 

Detailed Description

Singleton helper class to map html entities to other formats.

Definition at line 27 of file htmlentity.h.

Member Enumeration Documentation

◆ PerlType

Enumerator
Perl_unknown 
Perl_string 
Perl_char 
Perl_symbol 
Perl_umlaut 
Perl_acute 
Perl_grave 
Perl_circ 
Perl_slash 
Perl_tilde 
Perl_cedilla 
Perl_ring 

Definition at line 92 of file htmlentity.h.

◆ SymType

Enumerator
Sym_Unknown 
Sym_nbsp 
Sym_iexcl 
Sym_cent 
Sym_pound 
Sym_curren 
Sym_yen 
Sym_brvbar 
Sym_sect 
Sym_uml 
Sym_copy 
Sym_ordf 
Sym_laquo 
Sym_not 
Sym_shy 
Sym_reg 
Sym_macr 
Sym_deg 
Sym_plusmn 
Sym_sup2 
Sym_sup3 
Sym_acute 
Sym_micro 
Sym_para 
Sym_middot 
Sym_cedil 
Sym_sup1 
Sym_ordm 
Sym_raquo 
Sym_frac14 
Sym_frac12 
Sym_frac34 
Sym_iquest 
Sym_Agrave 
Sym_Aacute 
Sym_Acirc 
Sym_Atilde 
Sym_Auml 
Sym_Aring 
Sym_AElig 
Sym_Ccedil 
Sym_Egrave 
Sym_Eacute 
Sym_Ecirc 
Sym_Euml 
Sym_Igrave 
Sym_Iacute 
Sym_Icirc 
Sym_Iuml 
Sym_ETH 
Sym_Ntilde 
Sym_Ograve 
Sym_Oacute 
Sym_Ocirc 
Sym_Otilde 
Sym_Ouml 
Sym_times 
Sym_Oslash 
Sym_Ugrave 
Sym_Uacute 
Sym_Ucirc 
Sym_Uuml 
Sym_Yacute 
Sym_THORN 
Sym_szlig 
Sym_agrave 
Sym_aacute 
Sym_acirc 
Sym_atilde 
Sym_auml 
Sym_aring 
Sym_aelig 
Sym_ccedil 
Sym_egrave 
Sym_eacute 
Sym_ecirc 
Sym_euml 
Sym_igrave 
Sym_iacute 
Sym_icirc 
Sym_iuml 
Sym_eth 
Sym_ntilde 
Sym_ograve 
Sym_oacute 
Sym_ocirc 
Sym_otilde 
Sym_ouml 
Sym_divide 
Sym_oslash 
Sym_ugrave 
Sym_uacute 
Sym_ucirc 
Sym_uuml 
Sym_yacute 
Sym_thorn 
Sym_yuml 
Sym_fnof 
Sym_Alpha 
Sym_Beta 
Sym_Gamma 
Sym_Delta 
Sym_Epsilon 
Sym_Zeta 
Sym_Eta 
Sym_Theta 
Sym_Iota 
Sym_Kappa 
Sym_Lambda 
Sym_Mu 
Sym_Nu 
Sym_Xi 
Sym_Omicron 
Sym_Pi 
Sym_Rho 
Sym_Sigma 
Sym_Tau 
Sym_Upsilon 
Sym_Phi 
Sym_Chi 
Sym_Psi 
Sym_Omega 
Sym_alpha 
Sym_beta 
Sym_gamma 
Sym_delta 
Sym_epsilon 
Sym_zeta 
Sym_eta 
Sym_theta 
Sym_iota 
Sym_kappa 
Sym_lambda 
Sym_mu 
Sym_nu 
Sym_xi 
Sym_omicron 
Sym_pi 
Sym_rho 
Sym_sigmaf 
Sym_sigma 
Sym_tau 
Sym_upsilon 
Sym_phi 
Sym_chi 
Sym_psi 
Sym_omega 
Sym_thetasym 
Sym_upsih 
Sym_piv 
Sym_bull 
Sym_hellip 
Sym_prime 
Sym_Prime 
Sym_oline 
Sym_frasl 
Sym_weierp 
Sym_image 
Sym_real 
Sym_trade 
Sym_alefsym 
Sym_larr 
Sym_uarr 
Sym_rarr 
Sym_darr 
Sym_harr 
Sym_crarr 
Sym_lArr 
Sym_uArr 
Sym_rArr 
Sym_dArr 
Sym_hArr 
Sym_forall 
Sym_part 
Sym_exist 
Sym_empty 
Sym_nabla 
Sym_isin 
Sym_notin 
Sym_ni 
Sym_prod 
Sym_sum 
Sym_minus 
Sym_lowast 
Sym_radic 
Sym_prop 
Sym_infin 
Sym_ang 
Sym_and 
Sym_or 
Sym_cap 
Sym_cup 
Sym_int 
Sym_there4 
Sym_sim 
Sym_cong 
Sym_asymp 
Sym_ne 
Sym_equiv 
Sym_le 
Sym_ge 
Sym_sub 
Sym_sup 
Sym_nsub 
Sym_sube 
Sym_supe 
Sym_oplus 
Sym_otimes 
Sym_perp 
Sym_sdot 
Sym_lceil 
Sym_rceil 
Sym_lfloor 
Sym_rfloor 
Sym_lang 
Sym_rang 
Sym_loz 
Sym_spades 
Sym_clubs 
Sym_hearts 
Sym_diams 
Sym_quot 
Sym_amp 
Sym_lt 
Sym_gt 
Sym_OElig 
Sym_oelig 
Sym_Scaron 
Sym_scaron 
Sym_Yuml 
Sym_circ 
Sym_tilde 
Sym_ensp 
Sym_emsp 
Sym_thinsp 
Sym_zwnj 
Sym_zwj 
Sym_lrm 
Sym_rlm 
Sym_ndash 
Sym_mdash 
Sym_lsquo 
Sym_rsquo 
Sym_sbquo 
Sym_ldquo 
Sym_rdquo 
Sym_bdquo 
Sym_dagger 
Sym_Dagger 
Sym_permil 
Sym_lsaquo 
Sym_rsaquo 
Sym_euro 
Sym_tm 
Sym_apos 
Sym_BSlash 
Sym_At 
Sym_Less 
Sym_Greater 
Sym_Amp 
Sym_Dollar 
Sym_Hash 
Sym_DoubleColon 
Sym_Percent 
Sym_Pipe 
Sym_Quot 
Sym_Minus 
Sym_Plus 
Sym_Dot 
Sym_Colon 
Sym_Equal 
Sym_Exclam 
Sym_Quest 

Definition at line 30 of file htmlentity.h.

30 { Sym_Unknown = -1,
82
83 /* doxygen extensions */
85
86 /* doxygen commands mapped */
91 };

Constructor & Destructor Documentation

◆ HtmlEntityMapper()

HtmlEntityMapper::HtmlEntityMapper ( )
private

Definition at line 329 of file htmlentity.cpp.

330{
331 for (const auto &entity : g_htmlEntities)
332 {
333 m_name2sym.emplace(entity.item,entity.symb);
334 }
335 validate();
336}
std::unordered_map< std::string, SymType > m_name2sym
Definition htmlentity.h:118
void validate()
Routine to check if the entries of the html_entities are numbered correctly.
static const std::vector< HtmlEntityInfo > g_htmlEntities

References g_htmlEntities, m_name2sym, and validate().

Referenced by instance().

◆ ~HtmlEntityMapper()

HtmlEntityMapper::~HtmlEntityMapper ( )
private

Definition at line 338 of file htmlentity.cpp.

339{
340}

Member Function Documentation

◆ docbook()

const char * HtmlEntityMapper::docbook ( HtmlEntityMapper::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 nullptr is returned.

Definition at line 406 of file htmlentity.cpp.

407{
408 return g_htmlEntities[symb].docbook;
409}

References g_htmlEntities.

Referenced by DocbookDocVisitor::operator()().

◆ html()

const char * HtmlEntityMapper::html ( HtmlEntityMapper::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 nullptr is returned.

Definition at line 377 of file htmlentity.cpp.

378{
379 if (useInPrintf && symb==HtmlEntityMapper::Sym_Percent)
380 {
381 return "%%"; // escape for printf
382 }
383 else
384 {
385 return g_htmlEntities[symb].html;
386 }
387}

References g_htmlEntities, and Sym_Percent.

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

◆ instance()

◆ latex()

const char * HtmlEntityMapper::latex ( HtmlEntityMapper::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 nullptr is returned.

Definition at line 417 of file htmlentity.cpp.

418{
419 return g_htmlEntities[symb].latex;
420}

References g_htmlEntities.

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

◆ man()

const char * HtmlEntityMapper::man ( HtmlEntityMapper::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 nullptr is returned.

Definition at line 428 of file htmlentity.cpp.

429{
430 return g_htmlEntities[symb].man;
431}

References g_htmlEntities.

Referenced by ManDocVisitor::operator()().

◆ name2sym()

HtmlEntityMapper::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 HtmlEntityMapper::Sym_unknown is returned.

Definition at line 462 of file htmlentity.cpp.

463{
464 auto it = m_name2sym.find(symName.str());
465 return it!=m_name2sym.end() ? it->second : HtmlEntityMapper::Sym_Unknown;
466}
const std::string & str() const
Definition qcstring.h:537

References m_name2sym, QCString::str(), and Sym_Unknown.

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

◆ perl()

const HtmlEntityMapper::PerlSymb * HtmlEntityMapper::perl ( HtmlEntityMapper::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 nullptr pointer is entered in the symb field and in the HtmlEntityMapper::Perl_unknown in the type field.

Definition at line 451 of file htmlentity.cpp.

452{
453 return &g_htmlEntities[symb].perl;
454}

References g_htmlEntities.

Referenced by PerlModDocVisitor::operator()().

◆ rtf()

const char * HtmlEntityMapper::rtf ( HtmlEntityMapper::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 nullptr is returned.

Definition at line 439 of file htmlentity.cpp.

440{
441 return g_htmlEntities[symb].rtf;
442}

References g_htmlEntities.

Referenced by RTFDocVisitor::operator()().

◆ utf8()

const char * HtmlEntityMapper::utf8 ( HtmlEntityMapper::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 nullptr is returned.

Definition at line 357 of file htmlentity.cpp.

358{
359 if (useInPrintf && symb==HtmlEntityMapper::Sym_Percent)
360 {
361 return "%%"; // escape for printf
362 }
363 else
364 {
365 return g_htmlEntities[symb].UTF8;
366 }
367}

References g_htmlEntities, and Sym_Percent.

Referenced by PrintDocVisitor::operator()().

◆ validate()

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 484 of file htmlentity.cpp.

485{
486 int i=0;
487 for (const auto &entity : g_htmlEntities)
488 {
489 if (i != entity.symb)
490 {
491 warn_uncond("Internal inconsistency, htmlentries code %d (item=%s)\n",i,entity.item);
492 }
493 i++;
494 }
495}
#define warn_uncond(fmt,...)
Definition message.h:79

References g_htmlEntities, and warn_uncond.

Referenced by HtmlEntityMapper().

◆ writeXMLSchema()

void HtmlEntityMapper::writeXMLSchema ( TextStream & t)

Definition at line 468 of file htmlentity.cpp.

469{
470 for (size_t i=0;i<g_htmlEntities.size() - g_numberHtmlMappedCmds;i++)
471 {
472 QCString bareName = g_htmlEntities[i].xml;
473 if (!bareName.isEmpty() && bareName.at(0)=='<' && bareName.endsWith("/>"))
474 {
475 bareName = bareName.mid(1,bareName.length()-3); // strip < and />
476 t << " <xsd:element name=\"" << bareName << "\" type=\"docEmptyType\" />\n";
477 }
478 }
479}
size_t length() const
Returns the length of the string, not counting the 0-terminator.
Definition qcstring.h:153
QCString mid(size_t index, size_t len=static_cast< size_t >(-1)) const
Definition qcstring.h:226
bool endsWith(const char *s) const
Definition qcstring.h:509
char & at(size_t i)
Returns a reference to the character at index i.
Definition qcstring.h:578
bool isEmpty() const
Returns TRUE iff the string is empty.
Definition qcstring.h:150
static const int g_numberHtmlMappedCmds
Number of doxygen commands mapped as if it were HTML entities.

References QCString::at(), QCString::endsWith(), g_htmlEntities, g_numberHtmlMappedCmds, QCString::isEmpty(), QCString::length(), and QCString::mid().

Referenced by generateXML().

◆ xml()

const char * HtmlEntityMapper::xml ( HtmlEntityMapper::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 nullptr is returned.

Definition at line 395 of file htmlentity.cpp.

396{
397 return g_htmlEntities[symb].xml;
398}

References g_htmlEntities.

Referenced by XmlDocVisitor::operator()().

Member Data Documentation

◆ m_name2sym

std::unordered_map<std::string,SymType> HtmlEntityMapper::m_name2sym
private

Definition at line 118 of file htmlentity.h.

Referenced by HtmlEntityMapper(), and name2sym().

◆ s_instance

HtmlEntityMapper* HtmlEntityMapper::s_instance
staticprivate

Definition at line 117 of file htmlentity.h.


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