29 const QCString &srcFile,
int srcLine,
bool inlineCode)
34 QCString outDir(outDirArg);
35 static int umlindex=1;
42 while ((l=outDir.
length())>0 && (outDir.
at(l-1)==
'/' || outDir.
at(l-1)==
'\\'))
44 outDir = outDir.
left(l-1);
49 puName =
"inline_umlgraph_"+QCString().
setNum(umlindex);
50 baseName = outDir+
"/inline_umlgraph_"+QCString().
setNum(umlindex++);
56 if (i!=-1) baseName = baseName.
left(i);
64 imgName =puName+
".png";
67 imgName =puName+
".eps";
70 imgName =puName+
".svg";
79 if (inlineCode) text =
"@start"+engine+
" "+imgName+
"\n";
81 const char *p = content.
data();
85 bool insideComment =
false;
92 case '\'': insideComment=
true;
break;
93 case '\n': insideComment=
false;
break;
97 if (initial &&
qstrncmp(p,
"start",5)==0)
99 while ((c=*p++) &&
isId(c)) text+=c;
107 if (!insideComment) initial=
false;
113 if (inlineCode) text +=
"@end"+engine+
"\n";
117 QCString qcOutDir(
substitute(outDir,
"\\",
"/"));
118 uint32_t pos = qcOutDir.
findRev(
"/");
119 QCString generateType(qcOutDir.
right(qcOutDir.
length() - (pos + 1)) );
129 QCString imgName = baseName;
135 imgName=imgName.
mid(i+1);
190 auto it = pumlIncludePathList.begin();
191 if (it!=pumlIncludePathList.end())
193 pumlArgs +=
"-Dplantuml.include.path=\"";
194 pumlArgs += it->c_str();
197 while (it!=pumlIncludePathList.end())
200 pumlArgs += it->c_str();
204 if (!pumlIncludePathList.empty()) pumlArgs +=
"\" ";
205 pumlArgs +=
"-Djava.awt.headless=true -jar \""+plantumlJarPath+
"\" ";
206 if (!plantumlConfigFile.
isEmpty())
208 pumlArgs +=
"-config \"";
209 pumlArgs += plantumlConfigFile;
218 pumlArgs +=
"-graphvizdot \"";
236 for (
const auto &[name,nb] : plantumlContent)
238 if (nb.content.isEmpty())
continue;
241 msg(
"Generating PlantUML %s Files in %s\n",
qPrint(pumlType),name.c_str());
242 pumlArguments+=
"-o \"";
243 pumlArguments+=nb.outDir;
244 pumlArguments+=
"\" ";
245 pumlArguments+=
"-charset UTF-8 -t";
246 pumlArguments+=pumlType;
250 puFileName+=nb.outDir;
252 pumlOutDir=puFileName;
253 puFileName+=
"inline_umlgraph_";
254 puFileName+=pumlType;
255 puFileName+=name.c_str();
259 pumlArguments+=puFileName;
260 pumlArguments+=
"\" ";
273 err_full(nb.srcFile,nb.srcLine,
"Could not open file %s for writing",puFileName.
data());
275 file.write( nb.content.data(), nb.content.length() );
279 if (cachedContent == nb.content)
continue;
283 err_full(nb.srcFile,nb.srcLine,
"Problems running PlantUML. Verify that the command 'java -jar \"%s\" -h' works from the command line. Exit code: %d.",
284 plantumlJarPath.
data(),exitCode);
290 auto files_kv = plantumlFiles.find(name);
291 if (files_kv!=plantumlFiles.end())
293 for (
const auto &str : files_kv->second)
297 epstopdfArgs.
sprintf(
"\"%s%s.eps\" --outfile=\"%s%s.pdf\"",
298 pumlOutDir.
data(),str.c_str(), pumlOutDir.
data(),str.c_str());
301 err_full(nb.srcFile,nb.srcLine,
"Problems running epstopdf. Check your TeX installation! Exit code: %d.",exitCode);
326 for (
const auto &[key,list] : plantumlFiles)
329 for (
const auto &s : list)
341 for (
const auto &[key,content] : plantumlContent)
350 const std::string &key,
const std::string &value)
352 auto kv = plantumlFiles.find(key);
353 if (kv==plantumlFiles.end())
357 kv->second.push_back(value);
362 const QCString &srcFile,
int srcLine)
364 auto kv = plantumlContent.find(key);
365 if (kv==plantumlContent.end())
367 kv = plantumlContent.emplace(key,
PlantumlContent(
"",outDir,srcFile,srcLine)).first;
369 kv->second.content+=puContent;
374 const QCString &srcFile,
int srcLine)
static void print(DebugMask mask, int prio, const char *fmt,...)
static bool isFlagSet(const DebugMask mask)
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 QCString &name)
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
void msg(const char *fmt,...)
#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
int qstrncmp(const char *str1, const char *str2, size_t len)
const char * qPrint(const char *s)
QCString fileToString(const QCString &name, bool filter, bool isSourceCode)
A bunch of utility functions.