Doxygen
rtfgen.cpp 文件参考
#include <chrono>
#include <ctime>
#include <stdlib.h>
#include "rtfgen.h"
#include "config.h"
#include "message.h"
#include "doxygen.h"
#include "util.h"
#include "diagram.h"
#include "language.h"
#include "dot.h"
#include "dotcallgraph.h"
#include "dotclassgraph.h"
#include "dotdirdeps.h"
#include "dotincldepgraph.h"
#include "version.h"
#include "pagedef.h"
#include "rtfstyle.h"
#include "rtfdocvisitor.h"
#include "docparser.h"
#include "dirdef.h"
#include "vhdldocgen.h"
#include "portable.h"
#include "groupdef.h"
#include "classlist.h"
#include "filename.h"
#include "namespacedef.h"
#include "dir.h"
#include "utf8.h"
#include "debug.h"
+ rtfgen.cpp 的引用(Include)关系图:

浏览源代码.

宏定义

#define DBG_RTF(x)
 

函数

static QCString dateToRTFDateString ()
 
static QCString makeIndexName (const QCString &s, int i)
 
bool isLeadBytes (int c)
 
static void encodeForOutput (TextStream &t, const QCString &s)
 
static bool preProcessFile (Dir &d, const QCString &infName, TextStream &t, bool bIncludeHeader=TRUE)
 VERY brittle routine inline RTF's included by other RTF's. 更多...
 
void testRTFOutput (const QCString &name)
 Tests the integrity of the result by counting brackets. 更多...
 

宏定义说明

◆ DBG_RTF

#define DBG_RTF (   x)

在文件 rtfgen.cpp54 行定义.

函数说明

◆ dateToRTFDateString()

static QCString dateToRTFDateString ( )
static

在文件 rtfgen.cpp56 行定义.

57 {
58  auto now = std::chrono::system_clock::now();
59  auto time = std::chrono::system_clock::to_time_t(now);
60  auto tm = *localtime(&time);
61 
62  QCString result;
63  result.sprintf("\\yr%d\\mo%d\\dy%d\\hr%d\\min%d\\sec%d",
64  tm.tm_year+1900, tm.tm_mon+1, tm.tm_mday,
65  tm.tm_hour, tm.tm_min, tm.tm_sec);
66  return result;
67 }

引用了 QCString::sprintf().

被这些函数引用 RTFGenerator::endIndexSection().

◆ encodeForOutput()

static void encodeForOutput ( TextStream t,
const QCString s 
)
static

在文件 rtfgen.cpp2019 行定义.

2020 {
2021  if (s==0) return;
2022  QCString encoding;
2023  bool converted=FALSE;
2024  int l = (int)s.length();
2025  static std::vector<char> enc;
2026  if (l*4>(int)enc.size()) enc.resize(l*4); // worst case
2027  encoding.sprintf("CP%s",qPrint(theTranslator->trRTFansicp()));
2028  if (!encoding.isEmpty())
2029  {
2030  // convert from UTF-8 back to the output encoding
2031  void *cd = portable_iconv_open(encoding.data(),"UTF-8");
2032  if (cd!=(void *)(-1))
2033  {
2034  size_t iLeft=l;
2035  size_t oLeft=enc.size();
2036  const char *inputPtr = s.data();
2037  char *outputPtr = &enc[0];
2038  if (!portable_iconv(cd, &inputPtr, &iLeft, &outputPtr, &oLeft))
2039  {
2040  enc.resize(enc.size()-(unsigned int)oLeft);
2041  converted=TRUE;
2042  }
2044  }
2045  }
2046  if (!converted) // if we did not convert anything, copy as is.
2047  {
2048  memcpy(enc.data(),s.data(),l);
2049  enc.resize(l);
2050  }
2051  uint i;
2052  bool multiByte = FALSE;
2053 
2054  for (i=0;i<enc.size();i++)
2055  {
2056  uchar c = (uchar)enc.at(i);
2057 
2058  if (c>=0x80 || multiByte)
2059  {
2060  char esc[10];
2061  sprintf(esc,"\\'%X",c); // escape sequence for SBCS and DBCS(1st&2nd bytes).
2062  t << esc;
2063 
2064  if (!multiByte)
2065  {
2066  multiByte = isLeadBytes(c); // It may be DBCS Codepages.
2067  }
2068  else
2069  {
2070  multiByte = FALSE; // end of Double Bytes Character.
2071  }
2072  }
2073  else
2074  {
2075  t << (char)c;
2076  }
2077  }
2078 }

引用了 QCString::data(), FALSE, QCString::isEmpty(), isLeadBytes(), QCString::length(), portable_iconv(), portable_iconv_close(), portable_iconv_open(), qPrint(), QCString::sprintf(), theTranslator, Translator::trRTFansicp() , 以及 TRUE.

被这些函数引用 preProcessFile().

◆ isLeadBytes()

bool isLeadBytes ( int  c)

在文件 rtfgen.cpp1987 行定义.

1988 {
1989  bool result;
1990 
1991  QCString codePage = theTranslator->trRTFansicp();
1992 
1993  if (codePage == "932") // cp932 (Japanese Shift-JIS)
1994  {
1995  result = (0x81<=c && c<=0x9f) || (0xe0<=c && c<=0xfc);
1996  }
1997  else if (codePage == "936") // cp936 (Simplified Chinese GBK)
1998  {
1999  result = 0x81<=c && c<=0xFE;
2000  }
2001  else if (codePage == "949") // cp949 (Korean)
2002  {
2003  result = 0x81<=c && c<=0xFE;
2004  }
2005  else if (codePage == "950") // cp950 (Traditional Chinese Big5)
2006  {
2007  result = 0x81<=c && c<=0xFE;
2008  }
2009  else // for SBCS Codepages (cp1252,1251 etc...)
2010  {
2011  result = false;
2012  }
2013 
2014  return result;
2015 }

引用了 theTranslator , 以及 Translator::trRTFansicp().

被这些函数引用 encodeForOutput().

◆ makeIndexName()

static QCString makeIndexName ( const QCString s,
int  i 
)
static

◆ preProcessFile()

static bool preProcessFile ( Dir d,
const QCString infName,
TextStream t,
bool  bIncludeHeader = TRUE 
)
static

VERY brittle routine inline RTF's included by other RTF's.

it is recursive and ugly.

在文件 rtfgen.cpp2084 行定义.

2085 {
2086  static bool rtfDebug = Debug::isFlagSet(Debug::Rtf);
2087  std::ifstream f(infName.str(),std::ifstream::in);
2088  if (!f.is_open())
2089  {
2090  err("problems opening rtf file '%s' for reading\n",infName.data());
2091  return false;
2092  }
2093 
2094  const int maxLineLength = 10240;
2095  static QCString lineBuf(maxLineLength);
2096 
2097  // scan until find end of header
2098  // this is EXTREEEEEEEMLY brittle. It works on OUR rtf
2099  // files because the first line before the body
2100  // ALWAYS contains "{\comment begin body}"
2101  std::string line;
2102  while (getline(f,line))
2103  {
2104  line+='\n';
2105  if (line.find("\\comment begin body")!=std::string::npos) break;
2106  if (bIncludeHeader) encodeForOutput(t,line.c_str());
2107  }
2108 
2109  std::string prevLine;
2110  bool first=true;
2111  while (getline(f,line))
2112  {
2113  line+='\n';
2114  size_t pos;
2115  if ((pos=prevLine.find("INCLUDETEXT \""))!=std::string::npos)
2116  {
2117  size_t startNamePos = prevLine.find('"',pos)+1;
2118  size_t endNamePos = prevLine.find('"',startNamePos);
2119  std::string fileName = prevLine.substr(startNamePos,endNamePos-startNamePos);
2120  DBG_RTF(m_t << "{\\comment begin include " << fileName << "}\n")
2121  if (!preProcessFile(d,fileName.c_str(),t,FALSE)) return FALSE;
2122  DBG_RTF(m_t << "{\\comment end include " << fileName << "}\n")
2123  }
2124  else if (!first) // no INCLUDETEXT on this line
2125  {
2126  encodeForOutput(t,prevLine.c_str());
2127  }
2128  prevLine = line;
2129  first=false;
2130  }
2131  if (!bIncludeHeader) // skip final '}' in case we don't include headers
2132  {
2133  size_t pos = line.rfind('}');
2134  if (pos==std::string::npos)
2135  {
2136  err("Strange, the last char was not a '}'\n");
2137  pos = line.length();
2138  }
2139  encodeForOutput(t,line.substr(0,pos).c_str());
2140  }
2141  else
2142  {
2143  encodeForOutput(t,line.c_str());
2144  }
2145  f.close();
2146  // remove temporary file
2147  if (!rtfDebug) d.remove(infName.str());
2148  return TRUE;
2149 }

引用了 QCString::data(), DBG_RTF, encodeForOutput(), err(), FALSE, Debug::isFlagSet(), Dir::remove(), Debug::Rtf, QCString::str() , 以及 TRUE.

被这些函数引用 RTFGenerator::preProcessFileInplace().

◆ testRTFOutput()

void testRTFOutput ( const QCString name)

Tests the integrity of the result by counting brackets.

在文件 rtfgen.cpp2252 行定义.

2253 {
2254  int bcount=0;
2255  int line=1;
2256  int c;
2257  std::ifstream f(name.data(),std::ifstream::in);
2258  if (f.is_open())
2259  {
2260  while ((c=f.get())!=-1)
2261  {
2262  if (c=='\\') // escape char
2263  {
2264  c=f.get();
2265  if (c==-1) break;
2266  }
2267  else if (c=='{') // open bracket
2268  {
2269  bcount++;
2270  }
2271  else if (c=='}') // close bracket
2272  {
2273  bcount--;
2274  if (bcount<0)
2275  {
2276  goto err;
2277  break;
2278  }
2279  }
2280  else if (c=='\n') // newline
2281  {
2282  line++;
2283  }
2284  }
2285  }
2286  if (bcount==0) return; // file is OK.
2287 err:
2288  err("RTF integrity test failed at line %d of %s due to a bracket mismatch.\n"
2289  " Please try to create a small code example that produces this error \n"
2290  " and send that to doxygen@gmail.com.\n",line,qPrint(name));
2291 }

引用了 err(), Rtf_Style_Default::name , 以及 qPrint().

被这些函数引用 RTFGenerator::preProcessFileInplace().

portable_iconv
size_t portable_iconv(void *cd, const char **inbuf, size_t *inbytesleft, char **outbuf, size_t *outbytesleft)
QCString::length
uint length() const
Returns the length of the string, not counting the 0-terminator.
Definition: qcstring.h:147
QCString::isEmpty
bool isEmpty() const
Returns TRUE iff the string is empty
Definition: qcstring.h:144
QCString::str
std::string str() const
Definition: qcstring.h:442
err
void err(const char *fmt,...)
Definition: message.cpp:203
portable_iconv_open
void * portable_iconv_open(const char *tocode, const char *fromcode)
Debug::isFlagSet
static bool isFlagSet(DebugMask mask)
Definition: debug.cpp:99
DBG_RTF
#define DBG_RTF(x)
Definition: rtfgen.cpp:54
end
DirIterator end(const DirIterator &) noexcept
Definition: dir.cpp:128
preProcessFile
static bool preProcessFile(Dir &d, const QCString &infName, TextStream &t, bool bIncludeHeader=TRUE)
VERY brittle routine inline RTF's included by other RTF's.
Definition: rtfgen.cpp:2084
uint
unsigned uint
Definition: qcstring.h:40
uchar
unsigned char uchar
Definition: qcstring.h:38
theTranslator
Translator * theTranslator
Definition: language.cpp:156
TRUE
#define TRUE
Definition: qcstring.h:36
comment
const char * comment
Definition: vhdldocgen.cpp:2870
Translator::trRTFansicp
virtual QCString trRTFansicp()=0
isLeadBytes
bool isLeadBytes(int c)
Definition: rtfgen.cpp:1987
qPrint
const char * qPrint(const char *s)
Definition: qcstring.h:589
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
Debug::Rtf
@ Rtf
Definition: debug.h:44
portable_iconv_close
int portable_iconv_close(void *cd)
encodeForOutput
static void encodeForOutput(TextStream &t, const QCString &s)
Definition: rtfgen.cpp:2019
QCString::sprintf
QCString & sprintf(const char *format,...)
Definition: qcstring.cpp:24
FALSE
#define FALSE
Definition: qcstring.h:33
QCString
This is an alternative implementation of QCString.
Definition: qcstring.h:108