30 const QCString &srcFile,
int srcLine,
bool inlineCode)
36 static int umlindex=1;
43 while ((l=outDir.
length())>0 && (outDir.
at(l-1)==
'/' || outDir.
at(l-1)==
'\\'))
45 outDir = outDir.
left(l-1);
51 baseName = outDir+
"/inline_umlgraph_"+
QCString().
setNum(umlindex++);
57 if (i!=-1) baseName = baseName.
left(i);
65 imgName =puName+
".png";
68 imgName =puName+
".eps";
71 imgName =puName+
".svg";
80 if (inlineCode) text =
"@start"+engine+
" "+imgName+
"\n";
82 const char *p = content.
data();
86 bool insideComment =
false;
93 case '\'': insideComment=
true;
break;
94 case '\n': insideComment=
false;
break;
100 while ((c=*p++) &&
isId(c)) text+=c;
108 if (!insideComment) initial=
false;
114 if (inlineCode) text +=
"@end"+engine+
"\n";
119 uint32_t pos = qcOutDir.
findRev(
"/");
136 imgName=imgName.
mid(i+1);
191 auto it = pumlIncludePathList.begin();
192 if (it!=pumlIncludePathList.end())
194 pumlArgs +=
"-Dplantuml.include.path=\"";
195 pumlArgs += it->c_str();
198 while (it!=pumlIncludePathList.end())
201 pumlArgs += it->c_str();
205 if (!pumlIncludePathList.empty()) pumlArgs +=
"\" ";
206 pumlArgs +=
"-Djava.awt.headless=true -jar \""+plantumlJarPath+
"\" ";
207 if (!plantumlConfigFile.
isEmpty())
209 pumlArgs +=
"-config \"";
210 pumlArgs += plantumlConfigFile;
219 pumlArgs +=
"-graphvizdot \"";
237 for (
const auto &[name,nb] : plantumlContent)
239 if (nb.content.isEmpty())
continue;
242 msg(
"Generating PlantUML {} Files in {}\n",pumlType,name);
243 pumlArguments+=
"-o \"";
244 pumlArguments+=nb.outDir;
245 pumlArguments+=
"\" ";
246 pumlArguments+=
"-charset UTF-8 -t";
247 pumlArguments+=pumlType;
251 puFileName+=nb.outDir;
253 pumlOutDir=puFileName;
254 puFileName+=
"inline_umlgraph_";
255 puFileName+=pumlType;
256 puFileName+=name.c_str();
260 pumlArguments+=puFileName;
261 pumlArguments+=
"\" ";
274 err_full(nb.srcFile,nb.srcLine,
"Could not open file {} for writing",puFileName);
276 file.write( nb.content.data(), nb.content.length() );
280 if (cachedContent == nb.content)
continue;
284 err_full(nb.srcFile,nb.srcLine,
"Problems running PlantUML. Verify that the command 'java -jar \"{}\" -h' works from the command line. Exit code: {}.",
285 plantumlJarPath,exitCode);
291 auto files_kv = plantumlFiles.find(name);
292 if (files_kv!=plantumlFiles.end())
294 for (
const auto &str : files_kv->second)
298 epstopdfArgs.
sprintf(
"\"%s%s.eps\" --outfile=\"%s%s.pdf\"",
299 pumlOutDir.
data(),str.c_str(), pumlOutDir.
data(),str.c_str());
302 err_full(nb.srcFile,nb.srcLine,
"Problems running epstopdf. Check your TeX installation! Exit code: {}.",exitCode);
327 for (
const auto &[key,list] : plantumlFiles)
330 for (
const auto &s : list)
342 for (
const auto &[key,content] : plantumlContent)
351 const std::string &key,
const std::string &value)
353 auto kv = plantumlFiles.find(key);
354 if (kv==plantumlFiles.end())
358 kv->second.push_back(value);
363 const QCString &srcFile,
int srcLine)
365 auto kv = plantumlContent.find(key);
366 if (kv==plantumlContent.end())
368 kv = plantumlContent.emplace(key,
PlantumlContent(
"",outDir,srcFile,srcLine)).first;
370 kv->second.content+=puContent;
375 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
QCString 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.
OutputFormat
Plant UML output image formats.
ContentMap m_epsPlantumlContent
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)
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 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.