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

#include <latexgen.h>

Inheritance diagram for LatexCodeGenerator:
CodeOutputInterface

Public Member Functions

 LatexCodeGenerator (FTextStream &t, const QCString &relPath, const QCString &sourceFile)
 
 LatexCodeGenerator ()
 
void setTextStream (FTextStream &t)
 
void setRelativePath (const QCString &path)
 
void setSourceFileName (const QCString &sourceFileName)
 
void codify (const char *text)
 
void writeCodeLink (const char *ref, const char *file, const char *anchor, const char *name, const char *tooltip)
 
void writeTooltip (const char *, const DocLinkInfo &, const char *, const char *, const SourceLinkInfo &, const SourceLinkInfo &)
 
void writeLineNumber (const char *, const char *, const char *, int)
 
void startCodeLine (bool)
 
void endCodeLine ()
 
void startFontClass (const char *)
 
void endFontClass ()
 
void writeCodeAnchor (const char *)
 
void setCurrentDoc (Definition *, const char *, bool)
 
void addWord (const char *, bool)
 
- Public Member Functions inherited from CodeOutputInterface
virtual ~CodeOutputInterface ()
 

Private Member Functions

void _writeCodeLink (const char *className, const char *ref, const char *file, const char *anchor, const char *name, const char *tooltip)
 
void docify (const char *str)
 

Private Attributes

bool m_streamSet
 
FTextStream m_t
 
QCString m_relPath
 
QCString m_sourceFileName
 
int m_col
 
bool m_prettyCode
 

Detailed Description

Definition at line 27 of file latexgen.h.

Constructor & Destructor Documentation

LatexCodeGenerator::LatexCodeGenerator ( FTextStream t,
const QCString &  relPath,
const QCString &  sourceFile 
)

Definition at line 43 of file latexgen.cpp.

References Config_getBool, m_prettyCode, and setTextStream().

: m_relPath(relPath), m_sourceFileName(sourceFileName), m_col(0)
{
m_prettyCode=Config_getBool(LATEX_SOURCE_CODE);
}
LatexCodeGenerator::LatexCodeGenerator ( )

Definition at line 50 of file latexgen.cpp.

References Config_getBool, and m_prettyCode.

: m_streamSet(FALSE), m_col(0)
{
m_prettyCode=Config_getBool(LATEX_SOURCE_CODE);
}

Member Function Documentation

void LatexCodeGenerator::_writeCodeLink ( const char *  className,
const char *  ref,
const char *  file,
const char *  anchor,
const char *  name,
const char *  tooltip 
)
private
void LatexCodeGenerator::addWord ( const char *  ,
bool   
)
inlinevirtual

Implements CodeOutputInterface.

Definition at line 53 of file latexgen.h.

{}
void LatexCodeGenerator::codify ( const char *  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.

Implements CodeOutputInterface.

Definition at line 71 of file latexgen.cpp.

References Config_getInt, COPYCHAR, filterLatexString(), m_col, m_t, and Doxygen::spaces.

Referenced by LatexGenerator::codify(), endCodeLine(), writeCodeLink(), and writeLineNumber().

{
if (str)
{
const char *p=str;
char c;
//char cs[5];
int spacesToNextTabStop;
static int tabSize = Config_getInt(TAB_SIZE);
const int maxLineLen = 108;
QCString result(4*maxLineLen+1); // worst case for 1 line of 4-byte chars
int i;
while ((c=*p))
{
switch(c)
{
case 0x0c: p++; // remove ^L
break;
case '\t': spacesToNextTabStop =
tabSize - (m_col%tabSize);
m_t << Doxygen::spaces.left(spacesToNextTabStop);
m_col+=spacesToNextTabStop;
p++;
break;
case '\n': m_t << '\n'; m_col=0; p++;
break;
default:
i=0;
#undef COPYCHAR
// helper macro to copy a single utf8 character, dealing with multibyte chars.
#define COPYCHAR() do { \
result[i++]=c; p++; \
if (c<0) /* multibyte utf-8 character */ \
{ \
/* 1xxx.xxxx: >=2 byte character */ \
result[i++]=*p++; \
if (((uchar)c&0xE0)==0xE0) \
{ \
/* 111x.xxxx: >=3 byte character */ \
result[i++]=*p++; \
} \
if (((uchar)c&0xF0)==0xF0) \
{ \
/* 1111.xxxx: 4 byte character */ \
result[i++]=*p++; \
} \
} \
m_col++; \
} while(0)
// gather characters until we find whitespace or are at
// the end of a line
if (m_col>=maxLineLen) // force line break
{
m_t << "\n ";
m_col=0;
}
else // copy more characters
{
while (m_col<maxLineLen && (c=*p) &&
c!=0x0c && c!='\t' && c!='\n' && c!=' '
)
{
}
if (m_col>=maxLineLen) // force line break
{
m_t << "\n ";
m_col=0;
}
}
result[i]=0; // add terminator
//if (m_prettyCode)
//{
filterLatexString(m_t,result,FALSE,TRUE);
//}
//else
//{
// t << result;
//}
break;
}
}
}
}
void LatexCodeGenerator::docify ( const char *  str)
private
void LatexCodeGenerator::endCodeLine ( )
virtual

Ends a line of code started with startCodeLine()

Implements CodeOutputInterface.

Definition at line 228 of file latexgen.cpp.

References codify().

Referenced by LatexGenerator::endCodeLine().

{
codify("\n");
}
void LatexCodeGenerator::endFontClass ( )
virtual

Ends a block started with startFontClass()

Implements CodeOutputInterface.

Definition at line 238 of file latexgen.cpp.

References m_t.

Referenced by LatexGenerator::endFontClass().

{
m_t << "}";
}
void LatexCodeGenerator::setCurrentDoc ( Definition ,
const char *  ,
bool   
)
inlinevirtual

Implements CodeOutputInterface.

Definition at line 52 of file latexgen.h.

{}
void LatexCodeGenerator::setRelativePath ( const QCString &  path)

Definition at line 61 of file latexgen.cpp.

References m_relPath.

Referenced by LatexGenerator::startFile().

{
m_relPath = path;
}
void LatexCodeGenerator::setSourceFileName ( const QCString &  sourceFileName)

Definition at line 66 of file latexgen.cpp.

References m_sourceFileName.

Referenced by LatexGenerator::endFile(), and LatexGenerator::startFile().

{
}
void LatexCodeGenerator::setTextStream ( FTextStream t)
void LatexCodeGenerator::startCodeLine ( bool  )
virtual

Implements CodeOutputInterface.

Definition at line 223 of file latexgen.cpp.

References m_col.

Referenced by LatexGenerator::startCodeLine().

{
m_col=0;
}
void LatexCodeGenerator::startFontClass ( const char *  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'.

Parameters
clsNameThe category name.

Implements CodeOutputInterface.

Definition at line 233 of file latexgen.cpp.

References m_t.

Referenced by LatexGenerator::startFontClass().

{
m_t << "\\textcolor{" << name << "}{";
}
void LatexCodeGenerator::writeCodeAnchor ( const char *  name)
inlinevirtual

Write an anchor to a source listing.

Parameters
nameThe name of the anchor.

Implements CodeOutputInterface.

Definition at line 51 of file latexgen.h.

Referenced by LatexGenerator::writeCodeAnchor().

{}
void LatexCodeGenerator::writeCodeLink ( const char *  ref,
const char *  file,
const char *  anchor,
const char *  name,
const char *  tooltip 
)
virtual

Writes a link to an object in a code fragment.

Parameters
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.

Implements CodeOutputInterface.

Definition at line 160 of file latexgen.cpp.

References codify(), Config_getBool, m_col, m_t, and stripPath().

Referenced by LatexGenerator::writeCodeLink(), and writeLineNumber().

{
static bool pdfHyperlinks = Config_getBool(PDF_HYPERLINKS);
static bool usePDFLatex = Config_getBool(USE_PDFLATEX);
int l = qstrlen(name);
if (m_col+l>80)
{
m_t << "\n ";
m_col=0;
}
if (!ref && usePDFLatex && pdfHyperlinks)
{
m_t << "\\hyperlink{";
if (f) m_t << stripPath(f);
if (f && anchor) m_t << "_";
if (anchor) m_t << anchor;
m_t << "}{";
codify(name);
m_t << "}";
}
else
{
m_t << name;
}
m_col+=l;
}
void LatexCodeGenerator::writeLineNumber ( const char *  ref,
const char *  file,
const char *  anchor,
int  lineNumber 
)
virtual

Writes the line number of a source listing

Parameters
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

Implements CodeOutputInterface.

Definition at line 189 of file latexgen.cpp.

References codify(), Config_getBool, m_prettyCode, m_sourceFileName, m_t, stripExtensionGeneral(), stripPath(), and writeCodeLink().

Referenced by LatexGenerator::writeLineNumber().

{
static bool usePDFLatex = Config_getBool(USE_PDFLATEX);
static bool pdfHyperlinks = Config_getBool(PDF_HYPERLINKS);
{
QCString lineNumber;
lineNumber.sprintf("%05d",l);
if (fileName && !m_sourceFileName.isEmpty())
{
QCString lineAnchor;
lineAnchor.sprintf("_l%05d",l);
lineAnchor.prepend(stripExtensionGeneral(m_sourceFileName, ".tex"));
//if (!m_prettyCode) return;
if (usePDFLatex && pdfHyperlinks)
{
m_t << "\\hypertarget{" << stripPath(lineAnchor) << "}{}";
}
writeCodeLink(ref,fileName,anchor,lineNumber,0);
}
else
{
codify(lineNumber);
}
m_t << " ";
}
else
{
m_t << l << " ";
}
}
void LatexCodeGenerator::writeTooltip ( const char *  id,
const DocLinkInfo docInfo,
const char *  decl,
const char *  desc,
const SourceLinkInfo defInfo,
const SourceLinkInfo declInfo 
)
inlinevirtual

Writes a tool tip definition

Parameters
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

Implements CodeOutputInterface.

Definition at line 39 of file latexgen.h.

Referenced by LatexGenerator::writeTooltip().

{}

Member Data Documentation

int LatexCodeGenerator::m_col
private

Definition at line 65 of file latexgen.h.

Referenced by codify(), startCodeLine(), and writeCodeLink().

bool LatexCodeGenerator::m_prettyCode
private

Definition at line 66 of file latexgen.h.

Referenced by LatexCodeGenerator(), and writeLineNumber().

QCString LatexCodeGenerator::m_relPath
private

Definition at line 63 of file latexgen.h.

Referenced by setRelativePath().

QCString LatexCodeGenerator::m_sourceFileName
private

Definition at line 64 of file latexgen.h.

Referenced by setSourceFileName(), and writeLineNumber().

bool LatexCodeGenerator::m_streamSet
private

Definition at line 61 of file latexgen.h.

Referenced by setTextStream().

FTextStream LatexCodeGenerator::m_t
private

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