Helper class to insert a set of map file into an output file
更多...
#include <dotfilepatcher.h>
|
| DotFilePatcher (const QCString &patchFile) |
|
int | addMap (const QCString &mapFile, const QCString &relPath, bool urlOnly, const QCString &context, const QCString &label) |
|
int | addFigure (const QCString &baseName, const QCString &figureName, bool heightCheck) |
|
int | addSVGConversion (const QCString &relPath, bool urlOnly, const QCString &context, bool zoomable, int graphId) |
|
int | addSVGObject (const QCString &baseName, const QCString &figureName, const QCString &relPath) |
|
bool | run () const |
|
bool | isSVGFile () const |
|
Helper class to insert a set of map file into an output file
在文件 dotfilepatcher.h 第 26 行定义.
◆ DotFilePatcher()
DotFilePatcher::DotFilePatcher |
( |
const QCString & |
patchFile | ) |
|
◆ addFigure()
int DotFilePatcher::addFigure |
( |
const QCString & |
baseName, |
|
|
const QCString & |
figureName, |
|
|
bool |
heightCheck |
|
) |
| |
◆ addMap()
◆ addSVGConversion()
int DotFilePatcher::addSVGConversion |
( |
const QCString & |
relPath, |
|
|
bool |
urlOnly, |
|
|
const QCString & |
context, |
|
|
bool |
zoomable, |
|
|
int |
graphId |
|
) |
| |
◆ addSVGObject()
◆ convertMapFile()
converts the rectangles in a client site image map into a stream
- 参数
-
t | the stream to which the result is written. |
mapName | the name of the map file. |
relPath | the relative path to the root of the output directory (used in case CREATE_SUBDIRS is enabled). |
urlOnly | if FALSE the url field in the map contains an external references followed by a $ and then the URL. |
context | the context (file, class, or namespace) in which the map file was found |
- 返回
- TRUE if successful.
在文件 dotfilepatcher.cpp 第 214 行定义.
218 std::ifstream f(mapName.
str(),std::ifstream::in);
221 err(
"problems opening map file %s for inclusion in the docs!\n"
222 "If you installed Graphviz/dot after a previous failing run, \n"
223 "try deleting the output directory and rerun doxygen.\n",
qPrint(mapName));
227 while (getline(f,line))
230 if (buf.
left(5)==
"<area")
234 int indexS = replBuf.
find(
"id=\""), indexE;
235 if (indexS>0 && (indexE=replBuf.
find(
'"',indexS+4))!=-1)
237 t << replBuf.
left(indexS-1) << replBuf.
right(replBuf.
length() - indexE - 1);
引用了 err(), FALSE, QCString::find(), QCString::left(), QCString::length(), qPrint(), replaceRef(), QCString::right(), QCString::str() , 以及 TRUE.
被这些函数引用 insertMapFile(), run() , 以及 writeDotImageMapFromFile().
◆ isSVGFile()
bool DotFilePatcher::isSVGFile |
( |
| ) |
const |
◆ run()
bool DotFilePatcher::run |
( |
| ) |
const |
在文件 dotfilepatcher.cpp 第 292 行定义.
301 const Map &map =
m_maps.front();
302 interactiveSVG_local = interactiveSVG_local && map.zoomable;
303 graphId = map.graphId;
304 relPath = map.relPath;
311 if (!thisDir.
rename(patchFile,tmpName))
316 std::ifstream fi(tmpName, std::ifstream::in);
317 std::ofstream fo(patchFile, std::ofstream::out | std::ofstream::binary);
320 err(
"problem opening file %s for patching!\n",tmpName.c_str());
321 thisDir.
rename(tmpName,patchFile);
327 thisDir.
rename(tmpName,patchFile);
332 bool insideHeader=
FALSE;
333 bool replacedHeader=
FALSE;
334 bool foundSize=
FALSE;
337 static const reg::Ex reSVG(R
"([\[<]!-- SVG [0-9]+)");
338 static const reg::Ex reMAP(R
"(<!-- MAP [0-9]+)");
339 static const reg::Ex reFIG(R
"(% FIG [0-9]+)");
341 while (getline(fi,lineStr))
348 if (interactiveSVG_local)
350 if (line.
find(
"<svg")!=-1 && !replacedHeader)
353 count = sscanf(line.
data(),
"<svg width=\"%dpt\" height=\"%dpt\"",&width,&height);
355 foundSize = count==2 && (width>500 || height>450);
356 if (foundSize) insideHeader=
TRUE;
358 else if (insideHeader && !replacedHeader && line.
find(
"<title>")!=-1)
363 t <<
"<!--zoomable " << height <<
" -->\n";
365 t <<
"var viewWidth = " << width <<
";\n";
366 t <<
"var viewHeight = " << height <<
";\n";
369 t <<
"var sectionId = 'dynsection-" << graphId <<
"';\n";
372 t <<
"<script xlink:href=\"" << relPath <<
"svgpan.js\"/>\n";
373 t <<
"<svg id=\"graph\" class=\"graph\">\n";
374 t <<
"<g id=\"viewport\">\n";
380 if (!insideHeader || !foundSize)
384 const Map &map =
m_maps.front();
385 t <<
replaceRef(line,map.relPath,map.urlOnly,map.context,
"_top");
393 int n = sscanf(line.
data()+i+1,
"!-- SVG %d",&mapId);
394 if (n==1 && mapId>=0 && mapId<(
int)
m_maps.size())
396 int e = std::max(line.
find(
"--]"),line.
find(
"-->"));
397 const Map &map =
m_maps.at(mapId);
402 err(
"Problem extracting size from SVG file %s\n",
qPrint(map.mapFile));
404 if (e!=-1) t << line.
mid(e+3);
416 int n = sscanf(line.
data()+i,
"<!-- MAP %d",&mapId);
417 if (n==1 && mapId>=0 && mapId<(
int)
m_maps.size())
420 const Map &map =
m_maps.at(mapId);
423 convertMapFile(tt,map.mapFile,map.relPath,map.urlOnly,map.context);
426 t <<
"<map name=\"" <<
correctId(map.label) <<
"\" id=\"" <<
correctId(map.label) <<
"\">\n";
440 int n = sscanf(line.
data()+i+2,
"FIG %d",&mapId);
442 if (n==1 && mapId>=0 && mapId<(
int)
m_maps.size())
444 const Map &map =
m_maps.at(mapId);
449 err(
"problem writing FIG %d figure!\n",mapId);
466 if (
isSVGFile && interactiveSVG_local && replacedHeader)
474 fi.open(tmpName,std::ifstream::in);
475 fo.open(orgName.
str(),std::ofstream::out | std::ofstream::binary);
478 err(
"problem opening file %s for reading!\n",tmpName.c_str());
483 err(
"problem opening file %s for writing!\n",
qPrint(orgName));
487 while (getline(fi,lineStr))
489 std::string line = lineStr+
'\n';
490 const Map &map =
m_maps.front();
491 t <<
replaceRef(line.c_str(),map.relPath,map.urlOnly,map.context,
"_top");
引用了 Config_getBool, DotFilePatcher::Map::context, convertMapFile(), correctId(), QCString::data(), TextStream::empty(), err(), FALSE, QCString::find(), findIndex(), TextStream::flush(), DotFilePatcher::Map::graphId, isSVGFile(), DotFilePatcher::Map::label, QCString::left(), QCString::length(), m_maps, m_patchFile, DotFilePatcher::Map::mapFile, QCString::mid(), qPrint(), DotFilePatcher::Map::relPath, Dir::remove(), Dir::rename(), replaceRef(), QCString::right(), TextStream::setStream(), TextStream::str(), QCString::str(), stripPath(), substitute(), svgZoomFooter, svgZoomHeader, TRUE, DotFilePatcher::Map::urlOnly, writeSVGFigureLink(), writeVecGfxFigure() , 以及 DotFilePatcher::Map::zoomable.
被这些函数引用 writeDotImageMapFromFile().
◆ writeSVGFigureLink()
Check if a reference to a SVG figure can be written and do so if possible.
Returns FALSE if not possible (for instance because the SVG file is not yet generated).
在文件 dotfilepatcher.cpp 第 539 行定义.
542 int width=600,height=600;
549 if (height<=60) height=300;
else height+=300;
550 if (height>600) height=600;
551 out <<
"<div class=\"zoom\">";
554 out <<
"<iframe scrolling=\"no\" frameborder=\"0\" src=\""
555 << relPath << baseName <<
".svg\" width=\"100%\" height=\"" << height <<
"\">";
561 out <<
"<iframe scrolling=\"no\" frameborder=\"0\" src=\""
562 << relPath << baseName <<
".svg\" width=\""
563 << ((width*96+48)/72) <<
"\" height=\""
564 << ((height*96+48)/72) <<
"\">";
引用了 FALSE, readSVGSize(), TRUE , 以及 writeSVGNotSupported().
被这些函数引用 DotGraph::generateCode(), run() , 以及 writeDotImageMapFromFile().
◆ writeVecGfxFigure()
在文件 dotfilepatcher.cpp 第 578 行定义.
581 int width=400,height=550;
601 out <<
"\\nopagebreak\n"
602 "\\begin{figure}[H]\n"
605 if (width>maxWidth || height>maxHeight)
608 if (width*maxHeight>height*maxWidth)
610 out <<
"\\includegraphics[width=" << maxWidth <<
"pt]";
614 out <<
"\\includegraphics[height=" << maxHeight <<
"pt]";
619 out <<
"\\includegraphics[width=" << width <<
"pt]";
622 out <<
"{" << baseName <<
"}\n"
引用了 Config_getBool, FALSE, DotRunner::readBoundingBox() , 以及 TRUE.
被这些函数引用 DotGraph::generateCode() , 以及 run().
◆ m_maps
std::vector<Map> DotFilePatcher::m_maps |
|
private |
◆ m_patchFile
该类的文档由以下文件生成:
bool remove(const std::string &path, bool acceptsAbsPath=true) const
Class representing a directory in the file system
uint length() const
Returns the length of the string, not counting the 0-terminator.
static bool readSVGSize(const QCString &fileName, int *width, int *height)
static const char svgZoomFooter[]
static bool writeVecGfxFigure(TextStream &out, const QCString &baseName, const QCString &figureName)
void err(const char *fmt,...)
Text streaming class that buffers data.
std::vector< Map > m_maps
int find(char c, int index=0, bool cs=TRUE) const
bool empty() const
Returns true iff the buffer is empty
static bool readBoundingBox(const QCString &fileName, int *width, int *height, bool isEps)
bool rename(const std::string &orgName, const std::string &newName, bool acceptsAbsPath=true) const
QCString left(size_t len) const
static const char svgZoomHeader[]
QCString stripPath(const QCString &s)
static bool writeSVGFigureLink(TextStream &out, const QCString &relPath, const QCString &baseName, const QCString &absImgName)
Check if a reference to a SVG figure can be written and do so if possible.
static void writeSVGNotSupported(TextStream &out)
std::string str() const
Return the contents of the buffer as a std::string object
QCString mid(size_t index, size_t len=static_cast< size_t >(-1)) const
QCString substitute(const QCString &s, const QCString &src, const QCString &dst)
substitute all occurrences of src in s by dst
#define Config_getBool(name)
Class representing a regular expression.
const char * qPrint(const char *s)
const char * data() const
Returns a pointer to the contents of the string in the form of a 0-terminated C string
static bool convertMapFile(TextStream &t, const QCString &mapName, const QCString &relPath, bool urlOnly=FALSE, const QCString &context=QCString())
static QCString replaceRef(const QCString &buf, const QCString &relPath, bool urlOnly, const QCString &context, const QCString &target=QCString())
QCString right(size_t len) const
QCString correctId(const QCString &s)
int findIndex(const StringVector &sv, const std::string &s)
find the index of a string in a vector of strings, returns -1 if the string could not be found
This is an alternative implementation of QCString.