Doxygen
HtmlCodeGenerator类 参考

#include <htmlgen.h>

+ 类 HtmlCodeGenerator 继承关系图:
+ HtmlCodeGenerator 的协作图:

Public 成员函数

 HtmlCodeGenerator (TextStream &t, const QCString &relPath)
 
 HtmlCodeGenerator (TextStream &t)
 
int id () const
 Identifier for the output file 更多...
 
void setId (int id)
 
void setRelativePath (const QCString &path)
 
void codify (const QCString &text)
 
void writeCodeLink (CodeSymbolType type, const QCString &ref, const QCString &file, const QCString &anchor, const QCString &name, const QCString &tooltip)
 
void writeTooltip (const QCString &id, const DocLinkInfo &docInfo, const QCString &decl, const QCString &desc, const SourceLinkInfo &defInfo, const SourceLinkInfo &declInfo)
 
void writeLineNumber (const QCString &, const QCString &, const QCString &, int, bool)
 
void startCodeLine (bool)
 
void endCodeLine ()
 
void startFontClass (const QCString &s)
 
void endFontClass ()
 
void writeCodeAnchor (const QCString &anchor)
 
void setCurrentDoc (const Definition *, const QCString &, bool)
 
void addWord (const QCString &, bool)
 
void startCodeFragment (const QCString &style)
 
void endCodeFragment (const QCString &)
 
- Public 成员函数 继承自 CodeOutputInterface
virtual ~CodeOutputInterface ()
 
 CodeOutputInterface ()
 
 CodeOutputInterface (const CodeOutputInterface &)=delete
 
CodeOutputInterfaceoperator= (const CodeOutputInterface &)=delete
 

Private 成员函数

void _writeCodeLink (const QCString &className, const QCString &ref, const QCString &file, const QCString &anchor, const QCString &name, const QCString &tooltip)
 
void docify (const QCString &str)
 

Private 属性

TextStreamm_t
 
int m_col = 0
 
QCString m_relPath
 
bool m_lineOpen = false
 
int m_id = 0
 

详细描述

在文件 htmlgen.h21 行定义.

构造及析构函数说明

◆ HtmlCodeGenerator() [1/2]

HtmlCodeGenerator::HtmlCodeGenerator ( TextStream t,
const QCString relPath 
)

在文件 htmlgen.cpp577 行定义.

578  : m_t(t), m_relPath(relPath)
579 {
580 }

◆ HtmlCodeGenerator() [2/2]

HtmlCodeGenerator::HtmlCodeGenerator ( TextStream t)

在文件 htmlgen.cpp573 行定义.

573  : m_t(t)
574 {
575 }

成员函数说明

◆ _writeCodeLink()

void HtmlCodeGenerator::_writeCodeLink ( const QCString className,
const QCString ref,
const QCString file,
const QCString anchor,
const QCString name,
const QCString tooltip 
)
private

在文件 htmlgen.cpp742 行定义.

746 {
747  if (!ref.isEmpty())
748  {
749  m_t << "<a class=\"" << className << "Ref\" ";
750  m_t << externalLinkTarget();
751  }
752  else
753  {
754  m_t << "<a class=\"" << className << "\" ";
755  }
756  m_t << "href=\"";
757  m_t << externalRef(m_relPath,ref,TRUE);
758  if (!f.isEmpty()) m_t << addHtmlExtensionIfMissing(f);
759  if (!anchor.isEmpty()) m_t << "#" << anchor;
760  m_t << "\"";
761  if (!tooltip.isEmpty()) m_t << " title=\"" << convertToHtml(tooltip) << "\"";
762  m_t << ">";
763  docify(name);
764  m_t << "</a>";
765  m_col+=name.length();
766 }

引用了 addHtmlExtensionIfMissing(), convertToHtml(), docify(), externalLinkTarget(), externalRef(), QCString::isEmpty(), QCString::length(), m_col, m_relPath, m_t , 以及 TRUE.

被这些函数引用 writeCodeLink() , 以及 writeLineNumber().

◆ addWord()

void HtmlCodeGenerator::addWord ( const QCString ,
bool   
)
inlinevirtual

实现了 CodeOutputInterface.

在文件 htmlgen.h61 行定义.

66 : public OutputGenerator

◆ codify()

void HtmlCodeGenerator::codify ( const QCString s)
virtual

Writes an code fragment to the output. This function should keep spaces visible, should break lines at a newline and should convert tabs to the right number of spaces.

实现了 CodeOutputInterface.

在文件 htmlgen.cpp587 行定义.

588 {
589  int tabSize = Config_getInt(TAB_SIZE);
590  if (!str.isEmpty())
591  {
592  const char *p=str.data();
593  char c;
594  int spacesToNextTabStop;
595  while (*p)
596  {
597  c=*p++;
598  switch(c)
599  {
600  case '\t': spacesToNextTabStop =
601  tabSize - (m_col%tabSize);
602  m_t << Doxygen::spaces.left(spacesToNextTabStop);
603  m_col+=spacesToNextTabStop;
604  break;
605  case '\n': m_t << "\n"; m_col=0;
606  break;
607  case '\r': break;
608  case '<': m_t << "&lt;"; m_col++;
609  break;
610  case '>': m_t << "&gt;"; m_col++;
611  break;
612  case '&': m_t << "&amp;"; m_col++;
613  break;
614  case '\'': m_t << "&#39;"; m_col++; // &apos; is not valid XHTML
615  break;
616  case '"': m_t << "&quot;"; m_col++;
617  break;
618  case '\\':
619  if (*p=='<')
620  { m_t << "&lt;"; p++; }
621  else if (*p=='>')
622  { m_t << "&gt;"; p++; }
623  else if (*p=='(')
624  { m_t << "\\&zwj;("; m_col++;p++; }
625  else if (*p==')')
626  { m_t << "\\&zwj;)"; m_col++;p++; }
627  else
628  m_t << "\\";
629  m_col++;
630  break;
631  default:
632  {
633  uchar uc = static_cast<uchar>(c);
634  if (uc<32)
635  {
636  m_t << "&#x24" << hex[uc>>4] << hex[uc&0xF] << ";";
637  m_col++;
638  }
639  else
640  {
641  p=writeUTF8Char(m_t,p-1);
642  m_col++;
643  }
644  }
645  break;
646  }
647  }
648  }
649 }

引用了 Config_getInt, QCString::data(), hex, QCString::isEmpty(), QCString::left(), m_col, m_t, Doxygen::spaces , 以及 writeUTF8Char().

被这些函数引用 HtmlGenerator::codify() , 以及 writeLineNumber().

◆ docify()

void HtmlCodeGenerator::docify ( const QCString str)
private

在文件 htmlgen.cpp651 行定义.

652 {
653  //m_t << getHtmlDirEmbeddingChar(getTextDirByConfig(str));
654 
655  if (!str.isEmpty())
656  {
657  const char *p=str.data();
658  char c;
659  while (*p)
660  {
661  c=*p++;
662  switch(c)
663  {
664  case '<': m_t << "&lt;"; break;
665  case '>': m_t << "&gt;"; break;
666  case '&': m_t << "&amp;"; break;
667  case '"': m_t << "&quot;"; break;
668  case '\\':
669  if (*p=='<')
670  { m_t << "&lt;"; p++; }
671  else if (*p=='>')
672  { m_t << "&gt;"; p++; }
673  else if (*p=='(')
674  { m_t << "\\&zwj;("; p++; }
675  else if (*p==')')
676  { m_t << "\\&zwj;)"; p++; }
677  else
678  m_t << "\\";
679  break;
680  default:
681  {
682  uchar uc = static_cast<uchar>(c);
683  if (uc<32 && !isspace(c))
684  {
685  m_t << "&#x24" << hex[uc>>4] << hex[uc&0xF] << ";";
686  }
687  else
688  {
689  m_t << c;
690  }
691  }
692  break;
693  }
694  }
695  }
696 }

引用了 QCString::data(), hex, QCString::isEmpty(), reg::isspace() , 以及 m_t.

被这些函数引用 _writeCodeLink() , 以及 writeTooltip().

◆ endCodeFragment()

void HtmlCodeGenerator::endCodeFragment ( const QCString style)
virtual

Ends a block of code

实现了 CodeOutputInterface.

在文件 htmlgen.cpp894 行定义.

895 {
896  //endCodeLine checks is there is still an open code line, if so closes it.
897  endCodeLine();
898 
899  m_t << "</div><!-- fragment -->";
900 }

引用了 endCodeLine() , 以及 m_t.

被这些函数引用 HtmlGenerator::endCodeFragment().

◆ endCodeLine()

void HtmlCodeGenerator::endCodeLine ( )
virtual

Ends a line of code started with startCodeLine()

实现了 CodeOutputInterface.

在文件 htmlgen.cpp860 行定义.

861 {
862  if (m_col == 0)
863  {
864  m_t << " ";
865  m_col++;
866  }
867  if (m_lineOpen)
868  {
869  m_t << "</div>\n";
870  m_lineOpen = FALSE;
871  }
872 }

引用了 FALSE, m_col, m_lineOpen , 以及 m_t.

被这些函数引用 endCodeFragment() , 以及 HtmlGenerator::endCodeLine().

◆ endFontClass()

void HtmlCodeGenerator::endFontClass ( )
virtual

Ends a block started with startFontClass()

实现了 CodeOutputInterface.

在文件 htmlgen.cpp879 行定义.

880 {
881  m_t << "</span>";
882 }

引用了 m_t.

被这些函数引用 HtmlGenerator::endFontClass().

◆ id()

int HtmlCodeGenerator::id ( ) const
inlinevirtual

Identifier for the output file

重载 CodeOutputInterface .

在文件 htmlgen.h39 行定义.

47 {}

◆ setCurrentDoc()

void HtmlCodeGenerator::setCurrentDoc ( const Definition ,
const QCString ,
bool   
)
inlinevirtual

实现了 CodeOutputInterface.

在文件 htmlgen.h60 行定义.

66 : public OutputGenerator

◆ setId()

void HtmlCodeGenerator::setId ( int  id)
inline

在文件 htmlgen.h40 行定义.

47 {}

被这些函数引用 HtmlGenerator::startFile() , 以及 HtmlGenerator::writeDoc().

◆ setRelativePath()

void HtmlCodeGenerator::setRelativePath ( const QCString path)

在文件 htmlgen.cpp582 行定义.

583 {
584  m_relPath = path;
585 }

引用了 m_relPath.

被这些函数引用 HtmlGenerator::startFile().

◆ startCodeFragment()

void HtmlCodeGenerator::startCodeFragment ( const QCString style)
virtual

Starts a source code fragment. The fragment will be fed to the code parser (see code.h) for syntax highlighting and cross-referencing. The fragment ends by a call to endCodeFragment()

参数
styleThe kind of code fragment.

实现了 CodeOutputInterface.

在文件 htmlgen.cpp889 行定义.

890 {
891  m_t << "<div class=\"fragment\">";
892 }

引用了 m_t.

被这些函数引用 HtmlGenerator::startCodeFragment().

◆ startCodeLine()

void HtmlCodeGenerator::startCodeLine ( bool  )
virtual

实现了 CodeOutputInterface.

在文件 htmlgen.cpp850 行定义.

851 {
852  m_col=0;
853  if (!m_lineOpen)
854  {
855  m_t << "<div class=\"line\">";
856  m_lineOpen = TRUE;
857  }
858 }

引用了 m_col, m_lineOpen, m_t , 以及 TRUE.

被这些函数引用 HtmlGenerator::startCodeLine().

◆ startFontClass()

void HtmlCodeGenerator::startFontClass ( const QCString clsName)
virtual

Starts a block with a certain meaning. Used for syntax highlighting, which elements of the same type are rendered using the same 'font class'.

参数
clsNameThe category name.

实现了 CodeOutputInterface.

在文件 htmlgen.cpp874 行定义.

875 {
876  m_t << "<span class=\"" << s << "\">";
877 }

引用了 m_t.

被这些函数引用 HtmlGenerator::startFontClass().

◆ writeCodeAnchor()

void HtmlCodeGenerator::writeCodeAnchor ( const QCString name)
virtual

Write an anchor to a source listing.

参数
nameThe name of the anchor.

实现了 CodeOutputInterface.

在文件 htmlgen.cpp884 行定义.

885 {
886  m_t << "<a id=\"" << anchor << "\" name=\"" << anchor << "\"></a>";
887 }

引用了 m_t.

被这些函数引用 HtmlGenerator::writeCodeAnchor().

◆ writeCodeLink()

void HtmlCodeGenerator::writeCodeLink ( CodeSymbolType  type,
const QCString ref,
const QCString file,
const QCString anchor,
const QCString name,
const QCString tooltip 
)
virtual

Writes a link to an object in a code fragment.

参数
typeThe type of symbol, used for semantic syntax highlighting, may be Default is no info is available.
refIf this is non-zero, the object is to be found in an external documentation file.
fileThe file in which the object is located.
anchorThe anchor uniquely identifying the object within the file.
nameThe text to display as a placeholder for the link.
tooltipThe tooltip to display when the mouse is on the link.

实现了 CodeOutputInterface.

在文件 htmlgen.cpp727 行定义.

731 {
732  const char *hl = codeSymbolType2Str(type);
733  QCString hlClass = "code";
734  if (hl)
735  {
736  hlClass+=" hl_";
737  hlClass+=hl;
738  }
739  _writeCodeLink(hlClass,ref,f,anchor,name,tooltip);
740 }

引用了 _writeCodeLink() , 以及 codeSymbolType2Str().

被这些函数引用 HtmlGenerator::writeCodeLink().

◆ writeLineNumber()

void HtmlCodeGenerator::writeLineNumber ( const QCString ref,
const QCString file,
const QCString anchor,
int  lineNumber,
bool  writeLineAnchor 
)
virtual

Writes the line number of a source listing

参数
refExternal reference (when imported from a tag file)
fileThe file part of the URL pointing to the docs.
anchorThe anchor part of the URL pointing to the docs.
lineNumberThe line number to write
writeLineAnchorIndicates if an anchor for the line number needs to be written

实现了 CodeOutputInterface.

在文件 htmlgen.cpp698 行定义.

700 {
701  const int maxLineNrStr = 10;
702  char lineNumber[maxLineNrStr];
703  char lineAnchor[maxLineNrStr];
704  qsnprintf(lineNumber,maxLineNrStr,"%5d",l);
705  qsnprintf(lineAnchor,maxLineNrStr,"l%05d",l);
706 
707  if (!m_lineOpen)
708  {
709  m_t << "<div class=\"line\">";
710  m_lineOpen = TRUE;
711  }
712 
713  if (writeLineAnchor) m_t << "<a id=\"" << lineAnchor << "\" name=\"" << lineAnchor << "\"></a>";
714  m_t << "<span class=\"lineno\">";
715  if (!filename.isEmpty())
716  {
717  _writeCodeLink("line",ref,filename,anchor,lineNumber,QCString());
718  }
719  else
720  {
721  codify(lineNumber);
722  }
723  m_t << "</span>";
724  m_col=0;
725 }

引用了 _writeCodeLink(), codify(), QCString::isEmpty(), m_col, m_lineOpen, m_t, qsnprintf , 以及 TRUE.

被这些函数引用 HtmlGenerator::writeLineNumber().

◆ writeTooltip()

void HtmlCodeGenerator::writeTooltip ( const QCString id,
const DocLinkInfo docInfo,
const QCString decl,
const QCString desc,
const SourceLinkInfo defInfo,
const SourceLinkInfo declInfo 
)
virtual

Writes a tool tip definition

参数
idunique identifier for the tooltip
docInfoInfo about the symbol's documentation.
declfull declaration of the symbol (for functions)
descbrief description for the symbol
defInfoInfo about the symbol's definition in the source code
declInfoInfo about the symbol's declaration in the source code

实现了 CodeOutputInterface.

在文件 htmlgen.cpp768 行定义.

772 {
773  m_t << "<div class=\"ttc\" id=\"" << id << "\">";
774  m_t << "<div class=\"ttname\">";
775  if (!docInfo.url.isEmpty())
776  {
777  m_t << "<a href=\"";
778  m_t << externalRef(m_relPath,docInfo.ref,TRUE);
779  m_t << addHtmlExtensionIfMissing(docInfo.url);
780  if (!docInfo.anchor.isEmpty())
781  {
782  m_t << "#" << docInfo.anchor;
783  }
784  m_t << "\">";
785  }
786  docify(docInfo.name);
787  if (!docInfo.url.isEmpty())
788  {
789  m_t << "</a>";
790  }
791  m_t << "</div>";
792  if (!decl.isEmpty())
793  {
794  m_t << "<div class=\"ttdeci\">";
795  docify(decl);
796  m_t << "</div>";
797  }
798  if (!desc.isEmpty())
799  {
800  m_t << "<div class=\"ttdoc\">";
801  docify(desc);
802  m_t << "</div>";
803  }
804  if (!defInfo.file.isEmpty())
805  {
806  m_t << "<div class=\"ttdef\"><b>Definition:</b> ";
807  if (!defInfo.url.isEmpty())
808  {
809  m_t << "<a href=\"";
810  m_t << externalRef(m_relPath,defInfo.ref,TRUE);
811  m_t << addHtmlExtensionIfMissing(defInfo.url);
812  if (!defInfo.anchor.isEmpty())
813  {
814  m_t << "#" << defInfo.anchor;
815  }
816  m_t << "\">";
817  }
818  m_t << defInfo.file << ":" << defInfo.line;
819  if (!defInfo.url.isEmpty())
820  {
821  m_t << "</a>";
822  }
823  m_t << "</div>";
824  }
825  if (!declInfo.file.isEmpty())
826  {
827  m_t << "<div class=\"ttdecl\"><b>Declaration:</b> ";
828  if (!declInfo.url.isEmpty())
829  {
830  m_t << "<a href=\"";
831  m_t << externalRef(m_relPath,declInfo.ref,TRUE);
832  m_t << addHtmlExtensionIfMissing(declInfo.url);
833  if (!declInfo.anchor.isEmpty())
834  {
835  m_t << "#" << declInfo.anchor;
836  }
837  m_t << "\">";
838  }
839  m_t << declInfo.file << ":" << declInfo.line;
840  if (!declInfo.url.isEmpty())
841  {
842  m_t << "</a>";
843  }
844  m_t << "</div>";
845  }
846  m_t << "</div>\n";
847 }

引用了 addHtmlExtensionIfMissing(), DocLinkInfo::anchor, SourceLinkInfo::anchor, docify(), externalRef(), SourceLinkInfo::file, QCString::isEmpty(), SourceLinkInfo::line, m_relPath, m_t, DocLinkInfo::name, DocLinkInfo::ref, SourceLinkInfo::ref, TRUE, DocLinkInfo::url , 以及 SourceLinkInfo::url.

被这些函数引用 HtmlGenerator::writeTooltip().

类成员变量说明

◆ m_col

int HtmlCodeGenerator::m_col = 0
private

在文件 htmlgen.h72 行定义.

被这些函数引用 _writeCodeLink(), codify(), endCodeLine(), startCodeLine() , 以及 writeLineNumber().

◆ m_id

int HtmlCodeGenerator::m_id = 0
private

在文件 htmlgen.h75 行定义.

◆ m_lineOpen

bool HtmlCodeGenerator::m_lineOpen = false
private

在文件 htmlgen.h74 行定义.

被这些函数引用 endCodeLine(), startCodeLine() , 以及 writeLineNumber().

◆ m_relPath

QCString HtmlCodeGenerator::m_relPath
private

在文件 htmlgen.h73 行定义.

被这些函数引用 _writeCodeLink(), setRelativePath() , 以及 writeTooltip().

◆ m_t


该类的文档由以下文件生成:
qsnprintf
#define qsnprintf
Definition: qcstring.h:57
HtmlCodeGenerator::_writeCodeLink
void _writeCodeLink(const QCString &className, const QCString &ref, const QCString &file, const QCString &anchor, const QCString &name, const QCString &tooltip)
Definition: htmlgen.cpp:742
HtmlCodeGenerator::m_t
TextStream & m_t
Definition: htmlgen.h:71
HtmlCodeGenerator::docify
void docify(const QCString &str)
Definition: htmlgen.cpp:651
HtmlCodeGenerator::m_lineOpen
bool m_lineOpen
Definition: htmlgen.h:74
QCString::length
uint length() const
Returns the length of the string, not counting the 0-terminator.
Definition: qcstring.h:147
HtmlCodeGenerator::m_col
int m_col
Definition: htmlgen.h:72
QCString::isEmpty
bool isEmpty() const
Returns TRUE iff the string is empty
Definition: qcstring.h:144
HtmlCodeGenerator::codify
void codify(const QCString &text)
Definition: htmlgen.cpp:587
addHtmlExtensionIfMissing
QCString addHtmlExtensionIfMissing(const QCString &fName)
Definition: util.cpp:5275
Config_getInt
#define Config_getInt(name)
Definition: config.h:34
reg::isspace
static bool isspace(char c)
Definition: regex.cpp:33
HtmlCodeGenerator::m_relPath
QCString m_relPath
Definition: htmlgen.h:73
uchar
unsigned char uchar
Definition: qcstring.h:38
QCString::left
QCString left(size_t len) const
Definition: qcstring.h:212
codeSymbolType2Str
constexpr const char * codeSymbolType2Str(CodeSymbolType type)
Definition: types.h:238
TRUE
#define TRUE
Definition: qcstring.h:36
externalLinkTarget
QCString externalLinkTarget(const bool parent)
Definition: util.cpp:6323
writeUTF8Char
const char * writeUTF8Char(TextStream &t, const char *s)
Writes the UTF8 character pointed to by s to stream t and returns a pointer to the next character.
Definition: utf8.cpp:197
OutputGenerator
Abstract output generator.
Definition: outputgen.h:330
hex
static const char * hex
Definition: htmlgen.cpp:64
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
externalRef
QCString externalRef(const QCString &relPath, const QCString &ref, bool href)
Definition: util.cpp:6334
HtmlCodeGenerator::endCodeLine
void endCodeLine()
Definition: htmlgen.cpp:860
convertToHtml
QCString convertToHtml(const QCString &s, bool keepEntities)
Definition: util.cpp:4063
Doxygen::spaces
static QCString spaces
Definition: doxygen.h:116
FALSE
#define FALSE
Definition: qcstring.h:33
QCString
This is an alternative implementation of QCString.
Definition: qcstring.h:108