summaryrefslogtreecommitdiffstats
path: root/src/dotfilepatcher.cpp
diff options
context:
space:
mode:
authorDimitri van Heesch <doxygen@gmail.com>2021-04-11 19:22:59 (GMT)
committerDimitri van Heesch <doxygen@gmail.com>2021-04-22 17:34:13 (GMT)
commit592aaa4f17d73ec8c475df0f44efaea8cc4d575c (patch)
tree3cfd68cec756661045ee25c906a8d8f4bddf7a6a /src/dotfilepatcher.cpp
parent98c67549bc3cd855873e0ef5eeab7c6410699d78 (diff)
downloadDoxygen-592aaa4f17d73ec8c475df0f44efaea8cc4d575c.zip
Doxygen-592aaa4f17d73ec8c475df0f44efaea8cc4d575c.tar.gz
Doxygen-592aaa4f17d73ec8c475df0f44efaea8cc4d575c.tar.bz2
Refactoring: remove implicit conversion from QCString to const char *
This commit changes the following in relation to string use - The implicit convert from 'QCString' to 'const char *' is removed - Strings parameters use 'const QCString &' as much as possible in favor over 'const char *' - 'if (s)' where s is a QCString has been replaced by 'if(!s.isEmpty())' - data() now always returns a valid C-string and not a 0-pointer. - when passing a string 's' to printf and related functions 'qPrint(s)' is used instead of 's.data()' - for empty string arguments 'QCString()' is used instead of '0' - The copy() operation has been removed - Where possible 'qstrcmp(a,b)==0' has been replaces by 'a==b' and 'qstrcmp(a,b)<0' has been replaced by 'a<b' - Parameters of string type that were default initialized with '= 0' are no initialized with '= QCString()'
Diffstat (limited to 'src/dotfilepatcher.cpp')
-rw-r--r--src/dotfilepatcher.cpp46
1 files changed, 23 insertions, 23 deletions
diff --git a/src/dotfilepatcher.cpp b/src/dotfilepatcher.cpp
index bb2bf15..326c1e1 100644
--- a/src/dotfilepatcher.cpp
+++ b/src/dotfilepatcher.cpp
@@ -123,7 +123,7 @@ static const char svgZoomFooter[] =
"</svg>\n"
;
-static QCString replaceRef(const QCString &buf,const QCString relPath,
+static QCString replaceRef(const QCString &buf,const QCString &relPath,
bool urlOnly,const QCString &context,const QCString &target=QCString())
{
// search for href="...", store ... part in link
@@ -152,7 +152,7 @@ static QCString replaceRef(const QCString &buf,const QCString relPath,
DocRef *df = new DocRef( (DocNode*) 0, link.mid(5), context );
result+=externalRef(relPath,df->ref(),TRUE);
if (!df->file().isEmpty())
- result += df->file().data() + Doxygen::htmlFileExtension;
+ result += df->file() + Doxygen::htmlFileExtension;
if (!df->anchor().isEmpty())
result += "#" + df->anchor();
delete df;
@@ -191,7 +191,7 @@ static QCString replaceRef(const QCString &buf,const QCString relPath,
QCString leftPart = buf.left(indexS);
QCString rightPart = buf.mid(indexE+1);
//printf("replaceRef(\n'%s'\n)->\n'%s+%s+%s'\n",
- // buf.data(),leftPart.data(),result.data(),rightPart.data());
+ // qPrint(buf),qPrint(leftPart),qPrint(result),qPrint(rightPart));
return leftPart + result + rightPart;
}
else
@@ -211,16 +211,16 @@ static QCString replaceRef(const QCString &buf,const QCString relPath,
* map file was found
* \returns TRUE if successful.
*/
-bool DotFilePatcher::convertMapFile(TextStream &t,const char *mapName,
- const QCString relPath, bool urlOnly,
+bool DotFilePatcher::convertMapFile(TextStream &t,const QCString &mapName,
+ const QCString &relPath, bool urlOnly,
const QCString &context)
{
- std::ifstream f(mapName,std::ifstream::in);
+ std::ifstream f(mapName.str(),std::ifstream::in);
if (!f.is_open())
{
err("problems opening map file %s for inclusion in the docs!\n"
"If you installed Graphviz/dot after a previous failing run, \n"
- "try deleting the output directory and rerun doxygen.\n",mapName);
+ "try deleting the output directory and rerun doxygen.\n",qPrint(mapName));
return FALSE;
}
std::string line;
@@ -245,7 +245,7 @@ bool DotFilePatcher::convertMapFile(TextStream &t,const char *mapName,
return TRUE;
}
-DotFilePatcher::DotFilePatcher(const char *patchFile)
+DotFilePatcher::DotFilePatcher(const QCString &patchFile)
: m_patchFile(patchFile)
{
}
@@ -291,7 +291,7 @@ int DotFilePatcher::addSVGObject(const QCString &baseName,
bool DotFilePatcher::run() const
{
- //printf("DotFilePatcher::run(): %s\n",m_patchFile.data());
+ //printf("DotFilePatcher::run(): %s\n",qPrint(m_patchFile));
bool interactiveSVG_local = Config_getBool(INTERACTIVE_SVG);
bool isSVGFile = m_patchFile.right(4)==".svg";
int graphId = -1;
@@ -303,14 +303,14 @@ bool DotFilePatcher::run() const
graphId = map.graphId;
relPath = map.relPath;
//printf("DotFilePatcher::addSVGConversion: file=%s zoomable=%d\n",
- // m_patchFile.data(),map->zoomable);
+ // qPrint(m_patchFile),map->zoomable);
}
std::string tmpName = m_patchFile.str()+".tmp";
std::string patchFile = m_patchFile.str();
Dir thisDir;
if (!thisDir.rename(patchFile,tmpName))
{
- err("Failed to rename file %s to %s!\n",m_patchFile.data(),tmpName.c_str());
+ err("Failed to rename file %s to %s!\n",qPrint(m_patchFile),tmpName.c_str());
return FALSE;
}
std::ifstream fi(tmpName, std::ifstream::in);
@@ -323,7 +323,7 @@ bool DotFilePatcher::run() const
}
if (!fo.is_open())
{
- err("problem opening file %s for patching!\n",m_patchFile.data());
+ err("problem opening file %s for patching!\n",qPrint(m_patchFile));
thisDir.rename(tmpName,patchFile);
return FALSE;
}
@@ -337,7 +337,7 @@ bool DotFilePatcher::run() const
while (getline(fi,lineStr))
{
QCString line = lineStr+'\n';
- //printf("line=[%s]\n",line.stripWhiteSpace().data());
+ //printf("line=[%s]\n",qPrint(line.stripWhiteSpace()));
int i;
if (isSVGFile)
{
@@ -392,16 +392,16 @@ bool DotFilePatcher::run() const
int e = std::max(line.find("--]"),line.find("-->"));
const Map &map = m_maps.at(mapId);
//printf("DotFilePatcher::writeSVGFigure: file=%s zoomable=%d\n",
- // m_patchFile.data(),map.zoomable);
+ // qPrint(m_patchFile),map.zoomable);
if (!writeSVGFigureLink(t,map.relPath,map.label,map.mapFile))
{
- err("Problem extracting size from SVG file %s\n",map.mapFile.data());
+ err("Problem extracting size from SVG file %s\n",qPrint(map.mapFile));
}
if (e!=-1) t << line.mid(e+3);
}
else // error invalid map id!
{
- err("Found invalid SVG id in file %s!\n",m_patchFile.data());
+ err("Found invalid SVG id in file %s!\n",qPrint(m_patchFile));
t << line.mid(i);
}
}
@@ -415,7 +415,7 @@ bool DotFilePatcher::run() const
TextStream tt;
const Map &map = m_maps.at(mapId);
//printf("patching MAP %d in file %s with contents of %s\n",
- // mapId,m_patchFile.data(),map.mapFile.data());
+ // mapId,qPrint(m_patchFile),qPrint(map.mapFile));
convertMapFile(tt,map.mapFile,map.relPath,map.urlOnly,map.context);
if (!tt.empty())
{
@@ -426,7 +426,7 @@ bool DotFilePatcher::run() const
}
else // error invalid map id!
{
- err("Found invalid MAP id in file %s!\n",m_patchFile.data());
+ err("Found invalid MAP id in file %s!\n",qPrint(m_patchFile));
t << line.mid(i);
}
}
@@ -434,12 +434,12 @@ bool DotFilePatcher::run() const
{
int mapId=-1;
int n = sscanf(line.data()+i+2,"FIG %d",&mapId);
- //printf("line='%s' n=%d\n",line.data()+i,n);
+ //printf("line='%s' n=%d\n",qPrint(line)+i,n);
if (n==1 && mapId>=0 && mapId<(int)m_maps.size())
{
const Map &map = m_maps.at(mapId);
//printf("patching FIG %d in file %s with contents of %s\n",
- // mapId,m_patchFile.data(),map.mapFile.data());
+ // mapId,qPrint(m_patchFile),qPrint(map.mapFile));
if (!writeVecGfxFigure(t,map.label,map.mapFile))
{
err("problem writing FIG %d figure!\n",mapId);
@@ -448,7 +448,7 @@ bool DotFilePatcher::run() const
}
else // error invalid map id!
{
- err("Found invalid bounding FIG %d in file %s!\n",mapId,m_patchFile.data());
+ err("Found invalid bounding FIG %d in file %s!\n",mapId,qPrint(m_patchFile));
t << line;
}
}
@@ -468,7 +468,7 @@ bool DotFilePatcher::run() const
// keep original SVG file so we can refer to it, we do need to replace
// dummy link by real ones
fi.open(tmpName,std::ifstream::in);
- fo.open(orgName,std::ofstream::out | std::ofstream::binary);
+ fo.open(orgName.str(),std::ofstream::out | std::ofstream::binary);
if (!fi.is_open())
{
err("problem opening file %s for reading!\n",tmpName.c_str());
@@ -476,7 +476,7 @@ bool DotFilePatcher::run() const
}
if (!fo.is_open())
{
- err("problem opening file %s for writing!\n",orgName.data());
+ err("problem opening file %s for writing!\n",qPrint(orgName));
return FALSE;
}
t.setStream(&fo);