33 const QCString &srcFile,
int srcLine,
bool inlineCode)
46 while ((l=outDir.
length())>0 && (outDir.
at(l-1)==
'/' || outDir.
at(l-1)==
'\\'))
48 outDir = outDir.
left(l-1);
58 if (inlineCode) text =
"@start"+engine+
" "+imgName+
"\n";
60 const char *p = content.
data();
64 bool insideComment =
false;
71 case '\'': insideComment=
true;
break;
72 case '\n': insideComment=
false;
break;
81 while ((c=*p++) &&
isId(c))
90 if (*p && (c==
' ' || c==
'\t'))
92 while ((c=*p++) && (c==
' ' || c==
'\t')) {}
95 enum State { InName, InExt, InRest };
102 if (
isId(c) || c==
'-') inpName+=c;
103 else if (c==
'.') state=InExt;
104 else rest+=c, state=InRest;
107 if (!
isId(c) && c!=
'-') rest+=c, state=InRest;
129 else if (!insideComment && strncmp(p,(
"end"+locEngine).data(), 3+strlen(engine.
data()))==0)
131 text +=
"end"+locEngine+
"\n";
136 uint32_t pos = qcOutDir.
findRev(
"/");
141 baseNameVector.push_back(baseName.
str());
154 text +=
"@end"+engine+
"\n";
157 uint32_t pos = qcOutDir.
findRev(
"/");
162 baseNameVector.push_back(baseName.
str());
165 return baseNameVector;
171 static int umlindex=1;
177 baseName = outDir+
"/inline_umlgraph_"+
QCString().
setNum(umlindex++);
183 if (i!=-1) baseName = baseName.
left(i);
191 imgName =puName+
".png";
194 imgName =puName+
".eps";
197 imgName =puName+
".svg";
210 imgName=imgName.
mid(i+1);
265 auto it = pumlIncludePathList.begin();
266 if (it!=pumlIncludePathList.end())
268 pumlArgs +=
"-Dplantuml.include.path=\"";
269 pumlArgs += it->c_str();
272 while (it!=pumlIncludePathList.end())
275 pumlArgs += it->c_str();
279 if (!pumlIncludePathList.empty()) pumlArgs +=
"\" ";
280 pumlArgs +=
"-Djava.awt.headless=true -jar \""+plantumlJarPath+
"\" ";
281 if (!plantumlConfigFile.
isEmpty())
283 pumlArgs +=
"-config \"";
284 pumlArgs += plantumlConfigFile;
293 pumlArgs +=
"-graphvizdot \"";
311 for (
const auto &[name,nb] : plantumlContent)
313 if (nb.content.isEmpty())
continue;
316 msg(
"Generating PlantUML {} Files in {}\n",pumlType,name);
317 pumlArguments+=
"-o \"";
318 pumlArguments+=nb.outDir;
319 pumlArguments+=
"\" ";
320 pumlArguments+=
"-charset UTF-8 -t";
321 pumlArguments+=pumlType;
325 puFileName+=nb.outDir;
327 pumlOutDir=puFileName;
328 puFileName+=
"inline_umlgraph_";
329 puFileName+=pumlType;
330 puFileName+=name.c_str();
334 pumlArguments+=puFileName;
335 pumlArguments+=
"\" ";
348 err_full(nb.srcFile,nb.srcLine,
"Could not open file {} for writing",puFileName);
350 file.write( nb.content.data(), nb.content.length() );
354 if (cachedContent == nb.content)
continue;
358 err_full(nb.srcFile,nb.srcLine,
"Problems running PlantUML. Verify that the command 'java -jar \"{}\" -h' works from the command line. Exit code: {}.",
359 plantumlJarPath,exitCode);
365 auto files_kv = plantumlFiles.find(name);
366 if (files_kv!=plantumlFiles.end())
368 for (
const auto &str : files_kv->second)
372 epstopdfArgs.
sprintf(
"\"%s%s.eps\" --outfile=\"%s%s.pdf\"",
373 pumlOutDir.
data(),str.c_str(), pumlOutDir.
data(),str.c_str());
376 err_full(nb.srcFile,nb.srcLine,
"Problems running epstopdf. Check your TeX installation! Exit code: {}.",exitCode);
401 for (
const auto &[key,list] : plantumlFiles)
404 for (
const auto &s : list)
416 for (
const auto &[key,content] : plantumlContent)
425 const std::string &key,
const std::string &value)
427 auto kv = plantumlFiles.find(key);
428 if (kv==plantumlFiles.end())
432 kv->second.push_back(value);
437 const QCString &srcFile,
int srcLine)
439 auto kv = plantumlContent.find(key);
440 if (kv==plantumlContent.end())
442 kv = plantumlContent.emplace(key,
PlantumlContent(
"",outDir,srcFile,srcLine)).first;
444 kv->second.content+=puContent;
449 const QCString &srcFile,
int srcLine)
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.
ContentMap m_pngPlantumlContent
std::map< std::string, PlantumlContent > ContentMap
OutputFormat
Plant UML output image formats.
ContentMap m_epsPlantumlContent
void generatePlantUmlFileNames(const QCString &fileName, OutputFormat format, const QCString &outDir, QCString &baseName, QCString &puName, QCString &imgName)
std::map< std::string, StringVector > FilesMap
void insert(const std::string &key, const std::string &value, const QCString &outDir, OutputFormat format, const QCString &puContent, const QCString &srcFile, int srcLine)
StringVector writePlantUMLSource(const QCString &outDirArg, const QCString &fileName, const QCString &content, OutputFormat format, const QCString &engine, const QCString &srcFile, int srcLine, bool inlineCode)
Write a PlantUML compatible file.
ContentMap m_svgPlantumlContent
FilesMap m_pngPlantumlFiles
static PlantumlManager & instance()
FilesMap m_svgPlantumlFiles
void run()
Run plant UML tool for all images.
void generatePlantUMLOutput(const QCString &baseName, const QCString &outDir, OutputFormat format)
Convert a PlantUML file to an image.
FilesMap m_epsPlantumlFiles
This is an alternative implementation of QCString.
QCString & prepend(const char *s)
size_t length() const
Returns the length of the string, not counting the 0-terminator.
QCString mid(size_t index, size_t len=static_cast< size_t >(-1)) const
char & at(size_t i)
Returns a reference to the character at index i.
bool isEmpty() const
Returns TRUE iff the string is empty.
const std::string & str() const
QCString & setNum(short n)
QCString right(size_t len) const
void reserve(size_t size)
Reserve space for size bytes without changing the string contents.
QCString & sprintf(const char *format,...)
int findRev(char c, int index=-1, bool cs=TRUE) const
const char * data() const
Returns a pointer to the contents of the string in the form of a 0-terminated C string.
QCString left(size_t len) const
#define Config_getList(name)
#define Config_getBool(name)
#define Config_getString(name)
std::vector< std::string > StringVector
static const int maxCmdLine
#define err_full(file, line, fmt,...)
std::ofstream openOutputStream(const QCString &name, bool append=false)
QCString pathListSeparator()
int system(const QCString &command, const QCString &args, bool commandHasConsole=true)
static void runPlantumlContent(const PlantumlManager::FilesMap &plantumlFiles, const PlantumlManager::ContentMap &plantumlContent, PlantumlManager::OutputFormat format)
static std::mutex g_PlantUmlMutex
static void addPlantumlContent(PlantumlManager::ContentMap &plantumlContent, const std::string &key, const QCString &outDir, const QCString &puContent, const QCString &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.
QCString substitute(const QCString &s, const QCString &src, const QCString &dst)
substitute all occurrences of src in s by dst
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
QCString fileToString(const QCString &name, bool filter, bool isSourceCode)
A bunch of utility functions.