39 const DString &srcFile,
int srcLine,
bool inlineCode)
52 while ((l=outDir.
length())>0 && (outDir.
at(l-1)==
'/' || outDir.
at(l-1)==
'\\'))
54 outDir = outDir.
left(l-1);
64 if (inlineCode) text =
"@start"+engine+
" "+imgName+
"\n";
66 const char *p = content.
data();
70 bool insideComment =
false;
77 case '\'': insideComment=
true;
break;
78 case '\n': insideComment=
false;
break;
87 while ((c=*p++) &&
isId(c))
96 if (*p && (c==
' ' || c==
'\t'))
98 while ((c=*p++) && (c==
' ' || c==
'\t')) {}
101 enum State { InName, InExt, InRest };
102 State state = InName;
103 while (*p && c!=
'\n')
108 if (
isId(c) || c==
'-') { inpName+=c; }
109 else if (c==
'.') { state=InExt; }
110 else { rest+=c; state=InRest; }
113 if (!
isId(c) && c!=
'-') { rest+=c; state=InRest; }
135 else if (!insideComment && strncmp(p,(
"end"+locEngine).data(), 3+strlen(engine.
data()))==0)
137 text +=
"end"+locEngine+
"\n";
142 size_t pos = qcOutDir.
rfind(
'/');
147 baseNameVector.push_back(baseName.
str());
160 text +=
"@end"+engine+
"\n";
163 size_t pos = qcOutDir.
rfind(
"/");
168 baseNameVector.push_back(baseName.
str());
171 return baseNameVector;
177 static int umlindex=1;
179 if (fileName.
empty())
183 baseName = outDir+
"/inline_umlgraph_"+
DString().
setNum(umlindex++);
196 imgName =puName+
".png";
199 imgName =puName+
".eps";
202 imgName =puName+
".svg";
209 if (!toIndex)
return;
215 imgName=imgName.
mid(i+1);
256 if (!javaPath.
empty())
return javaPath;
258 if (!javaHome.
empty())
284 bool useJar = plantumlTool.
empty();
294 auto it = pumlIncludePathList.begin();
295 if (it!=pumlIncludePathList.end())
297 pumlArgs +=
"-Dplantuml.include.path=\"";
298 pumlArgs += it->
c_str();
301 while (it!=pumlIncludePathList.end())
304 pumlArgs += it->
c_str();
307 if (!pumlIncludePathList.empty()) pumlArgs +=
"\" ";
308 pumlArgs +=
"-Djava.awt.headless=true -jar \""+plantumlJarPath+
"\" ";
310 else if (!pumlIncludePathList.empty())
316 for (
const auto &path : pumlIncludePathList)
319 includePath += path.
c_str();
324 if (!plantumlConfigFile.
empty())
326 pumlArgs +=
"-config \"";
327 pumlArgs += plantumlConfigFile;
336 pumlArgs +=
"-graphvizdot \"";
354 for (
const auto &[name,nb] : plantumlContent)
356 if (nb.content.empty())
continue;
358 DString pumlArguments = pumlArgs;
359 msg(
"Generating PlantUML {} Files in {}\n",pumlType,name);
360 pumlArguments+=
"-o \"";
361 pumlArguments+=nb.outDir;
362 pumlArguments+=
"\" ";
363 pumlArguments+=
"-charset UTF-8 -t";
364 pumlArguments+=pumlType;
368 puFileName+=nb.outDir;
370 pumlOutDir=puFileName;
371 puFileName+=
"inline_umlgraph_";
372 puFileName+=pumlType;
373 puFileName+=name.
c_str();
377 pumlArguments+=puFileName;
378 pumlArguments+=
"\" ";
391 err_full(nb.srcFile,nb.srcLine,
"Could not open file {} for writing",puFileName);
393 file.write( nb.content.data(), nb.content.length() );
397 if (cachedContent == nb.content)
continue;
401 err_full(nb.srcFile,nb.srcLine,
"Problems running PlantUML. Verify that the command '{} -h' works from the command line. Exit code: {}.",
402 useJar ? pumlExe+
" -jar \""+plantumlJarPath+
"\"" : pumlExe,exitCode);
408 auto files_kv = plantumlFiles.find(name);
409 if (files_kv!=plantumlFiles.end())
411 for (
const auto &str : files_kv->second)
413 const int maxCmdLine = 40960;
415 epstopdfArgs.
sprintf(
"\"%s%s.eps\" --outfile=\"%s%s.pdf\"",
416 pumlOutDir.
data(),str.c_str(), pumlOutDir.
data(),str.c_str());
419 err_full(nb.srcFile,nb.srcLine,
"Problems running epstopdf. Check your TeX installation! Exit code: {}.",exitCode);
444 for (
const auto &[key,list] : plantumlFiles)
447 for (
const auto &s : list)
459 for (
const auto &[key,content] : plantumlContent)
468 const std::string &key,
const std::string &value)
470 auto kv = plantumlFiles.find(key);
471 if (kv==plantumlFiles.end())
475 kv->second.push_back(value);
479 const std::string &key,
const DString &outDir,
const DString &puContent,
480 const DString &srcFile,
int srcLine)
482 auto kv = plantumlContent.find(key);
483 if (kv==plantumlContent.end())
485 kv = plantumlContent.emplace(key,
PlantumlContent(
"",outDir,srcFile,srcLine)).first;
487 kv->second.content+=puContent;
492 const DString &srcFile,
int srcLine)
A String class for use with Doxygen wrapping std::string and adding some additional functionality off...
DString & setNum(short n)
size_t rfind(char c, size_t pos=npos) const
DString mid(size_t index, size_t len=npos) const
bool empty() const
Returns true iff the string is empty (std::string compatible alias for isEmpty()).
const char * c_str() const
Returns a pointer to the contents of the string in the form of a 0-terminated C string.
static constexpr size_t npos
value used to indicate 'not found' or 'to the end of the string', matching std::string::npos
char & at(size_t i)
Returns a reference to the character at index i.
DString & prepend(const char *s)
DString & sprintf(const char *format,...)
void reserve(size_t size)
Reserve space for size bytes without changing the string contents.
DString left(size_t len) const
const std::string & str() const
const char * data() const
Returns a pointer to the contents of the string in the form of a 0-terminated C string.
size_t length() const
Returns the length of the string, not counting the 0-terminator.
static bool isFlagSet(const DebugMask mask)
static void print(DebugMask mask, int prio, fmt::format_string< Args... > fmt, Args &&... args)
Class representing a directory in the file system.
bool remove(const std::string &path, bool acceptsAbsPath=true) const
static IndexList * indexList
Minimal replacement for QFileInfo.
void addImageFile(const DString &name)
ContentMap m_pngPlantumlContent
void generatePlantUMLOutput(const DString &baseName, const DString &outDir, OutputFormat format, bool toIndex)
Convert a PlantUML file to an image.
std::map< std::string, PlantumlContent > ContentMap
void insert(const std::string &key, const std::string &value, const DString &outDir, OutputFormat format, const DString &puContent, const DString &srcFile, int srcLine)
OutputFormat
Plant UML output image formats.
ContentMap m_epsPlantumlContent
std::map< std::string, StringVector > FilesMap
StringVector writePlantUMLSource(const DString &outDirArg, const DString &fileName, const DString &content, OutputFormat format, const DString &engine, const DString &srcFile, int srcLine, bool inlineCode)
Write a PlantUML compatible file.
void generatePlantUmlFileNames(const DString &fileName, OutputFormat format, const DString &outDir, DString &baseName, DString &puName, DString &imgName)
static bool isEnabled()
Returns true if doxygen has been configured to run PlantUML, i.e.
ContentMap m_svgPlantumlContent
FilesMap m_pngPlantumlFiles
static PlantumlManager & instance()
FilesMap m_svgPlantumlFiles
void run()
Run plant UML tool for all images.
FilesMap m_epsPlantumlFiles
#define Config_getList(name)
#define Config_getBool(name)
#define Config_getString(name)
std::vector< std::string > StringVector
DString substitute(const DString &s, const DString &src, const DString &dst)
substitute all occurrences of src in s by dst
bool isId(int c)
Returns true if c is a valid character for an identifier.
#define err_full(file, line, fmt,...)
void setenv(const DString &variable, const DString &value)
int system(const DString &command, const DString &args, bool commandHasConsole=true)
DString getenv(const DString &variable)
DString pathListSeparator()
std::ofstream openOutputStream(const DString &name, bool append=false)
const char * commandExtension()
static void runPlantumlContent(const PlantumlManager::FilesMap &plantumlFiles, const PlantumlManager::ContentMap &plantumlContent, PlantumlManager::OutputFormat format)
static DString javaExecutable()
Returns the java executable used to run the PlantUML jar file.
static std::mutex g_PlantUmlMutex
static void addPlantumlContent(PlantumlManager::ContentMap &plantumlContent, const std::string &key, const DString &outDir, const DString &puContent, const DString &srcFile, int srcLine)
static void print(const PlantumlManager::FilesMap &plantumlFiles)
static void addPlantumlFiles(PlantumlManager::FilesMap &plantumlFiles, const std::string &key, const std::string &value)
Portable versions of functions that are platform dependent.
Some helper functions for std::string.
bool literal_at(const char *data, const char(&str)[N])
returns true iff data points to a substring that matches string literal str
DString fileToString(const DString &name, bool filter, bool isSourceCode)
A bunch of utility functions.