Skip to main content

The plantuml.cpp File Reference

Included Headers

#include "plantuml.h" #include "util.h" #include "portable.h" #include "config.h" #include "doxygen.h" #include "message.h" #include "debug.h" #include "fileinfo.h" #include "dir.h" #include "indexlist.h" #include "stringutil.h"

Functions Index

static voidrunPlantumlContent (const PlantumlManager::FilesMap &plantumlFiles, const PlantumlManager::ContentMap &plantumlContent, PlantumlManager::OutputFormat format)
static voidprint (const PlantumlManager::FilesMap &plantumlFiles)
static voidprint (const PlantumlManager::ContentMap &plantumlContent)
static voidaddPlantumlFiles (PlantumlManager::FilesMap &plantumlFiles, const std::string &key, const std::string &value)
static voidaddPlantumlContent (PlantumlManager::ContentMap &plantumlContent, const std::string &key, const QCString &outDir, const QCString &puContent, const QCString &srcFile, int srcLine)

Functions

addPlantumlContent()

void addPlantumlContent (PlantumlManager::ContentMap & plantumlContent, const std::string & key, const QCString & outDir, const QCString & puContent, const QCString & srcFile, int srcLine)
static

Definition at line 361 of file plantuml.cpp.

362 const std::string &key, const QCString &outDir, const QCString &puContent,
363 const QCString &srcFile,int srcLine)
364{
365 auto kv = plantumlContent.find(key);
366 if (kv==plantumlContent.end())
367 {
368 kv = plantumlContent.emplace(key,PlantumlContent("",outDir,srcFile,srcLine)).first;
369 }
370 kv->second.content+=puContent;
371}

Referenced by PlantumlManager::insert.

addPlantumlFiles()

void addPlantumlFiles (PlantumlManager::FilesMap & plantumlFiles, const std::string & key, const std::string & value)
static

Definition at line 350 of file plantuml.cpp.

351 const std::string &key, const std::string &value)
352{
353 auto kv = plantumlFiles.find(key);
354 if (kv==plantumlFiles.end())
355 {
356 kv = plantumlFiles.emplace(key,StringVector()).first;
357 }
358 kv->second.push_back(value);
359}

Referenced by PlantumlManager::insert.

print()

void print (const PlantumlManager::FilesMap & plantumlFiles)
static

Definition at line 323 of file plantuml.cpp.

323static void print(const PlantumlManager::FilesMap &plantumlFiles)
324{
326 {
327 for (const auto &[key,list] : plantumlFiles)
328 {
329 Debug::print(Debug::Plantuml,0,"*** PlantumlManager::print Files PlantumlFiles key:{} size:{}\n",key,list.size());
330 for (const auto &s : list)
331 {
332 Debug::print(Debug::Plantuml,0,"*** PlantumlManager::print list:{}\n",s);
333 }
334 }
335 }
336}

References Debug::isFlagSet, Debug::Plantuml and Debug::print.

Referenced by PlantumlManager::insert.

print()

void print (const PlantumlManager::ContentMap & plantumlContent)
static

Definition at line 338 of file plantuml.cpp.

338static void print(const PlantumlManager::ContentMap &plantumlContent)
339{
341 {
342 for (const auto &[key,content] : plantumlContent)
343 {
344 Debug::print(Debug::Plantuml,0,"*** PlantumlManager::print Content PlantumlContent key: {}\n",key);
345 Debug::print(Debug::Plantuml,0,"*** PlantumlManager::print Content:\n{}\n",content.content);
346 }
347 }
348}

References Debug::isFlagSet, Debug::Plantuml and Debug::print.

runPlantumlContent()

void runPlantumlContent (const PlantumlManager::FilesMap & plantumlFiles, const PlantumlManager::ContentMap & plantumlContent, PlantumlManager::OutputFormat format)
static

Definition at line 167 of file plantuml.cpp.

167static void runPlantumlContent(const PlantumlManager::FilesMap &plantumlFiles,
168 const PlantumlManager::ContentMap &plantumlContent,
170{
171 /* example : running: java -Djava.awt.headless=true
172 -jar "/usr/local/bin/plantuml.jar"
173 -o "test_doxygen/DOXYGEN_OUTPUT/html"
174 -tpng
175 "test_doxygen/DOXYGEN_OUTPUT/html/A.pu"
176 -charset UTF-8
177 outDir:test_doxygen/DOXYGEN_OUTPUT/html
178 test_doxygen/DOXYGEN_OUTPUT/html/A
179 */
180 int exitCode = 0;
181 QCString plantumlJarPath = Config_getString(PLANTUML_JAR_PATH);
182 QCString plantumlConfigFile = Config_getString(PLANTUML_CFG_FILE);
183
184 QCString pumlExe = "java";
185 QCString pumlArgs = "";
186 QCString pumlType = "";
187 QCString pumlOutDir = "";
188
189 const StringVector &pumlIncludePathList = Config_getList(PLANTUML_INCLUDE_PATH);
190 {
191 auto it = pumlIncludePathList.begin();
192 if (it!=pumlIncludePathList.end())
193 {
194 pumlArgs += "-Dplantuml.include.path=\"";
195 pumlArgs += it->c_str();
196 ++it;
197 }
198 while (it!=pumlIncludePathList.end())
199 {
200 pumlArgs += Portable::pathListSeparator();
201 pumlArgs += it->c_str();
202 ++it;
203 }
204 }
205 if (!pumlIncludePathList.empty()) pumlArgs += "\" ";
206 pumlArgs += "-Djava.awt.headless=true -jar \""+plantumlJarPath+"\" ";
207 if (!plantumlConfigFile.isEmpty())
208 {
209 pumlArgs += "-config \"";
210 pumlArgs += plantumlConfigFile;
211 pumlArgs += "\" ";
212 }
213 // the -graphvizdot option expects a relative or absolute path to the dot executable, so
214 // we need to use the unverified DOT_PATH option and check if it points to an existing file.
215 QCString dotPath = Config_getString(DOT_PATH);
216 FileInfo dp(dotPath.str());
217 if (Config_getBool(HAVE_DOT) && dp.exists() && dp.isFile())
218 {
219 pumlArgs += "-graphvizdot \"";
220 pumlArgs += dotPath;
221 pumlArgs += "\" ";
222 }
223 switch (format)
224 {
226 pumlType="png";
227 break;
229 pumlType="eps";
230 break;
232 pumlType="svg";
233 break;
234 }
235
236 {
237 for (const auto &[name,nb] : plantumlContent)
238 {
239 if (nb.content.isEmpty()) continue;
240
241 QCString pumlArguments = pumlArgs;
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;
248 pumlArguments+=" ";
249
250 QCString puFileName("");
251 puFileName+=nb.outDir;
252 puFileName+="/";
253 pumlOutDir=puFileName;
254 puFileName+="inline_umlgraph_";
255 puFileName+=pumlType;
256 puFileName+=name.c_str();
257 puFileName+=".pu";
258
259 pumlArguments+="\"";
260 pumlArguments+=puFileName;
261 pumlArguments+="\" ";
262
263
264 QCString cachedContent;
265 FileInfo fi(puFileName.str());
266 if (fi.exists())
267 {
268 cachedContent = fileToString(puFileName);
269 }
270
271 std::ofstream file = Portable::openOutputStream(puFileName);
272 if (!file.is_open())
273 {
274 err_full(nb.srcFile,nb.srcLine,"Could not open file {} for writing",puFileName);
275 }
276 file.write( nb.content.data(), nb.content.length() );
277 file.close();
278 Debug::print(Debug::Plantuml,0,"*** PlantumlManager::runPlantumlContent Running Plantuml arguments:{}\n",pumlArguments);
279
280 if (cachedContent == nb.content) continue;
281
282 if ((exitCode=Portable::system(pumlExe.data(),pumlArguments.data(),TRUE))!=0)
283 {
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);
286 }
287
288 if ( (format==PlantumlManager::PUML_EPS) && (Config_getBool(USE_PDFLATEX)) )
289 {
290 Debug::print(Debug::Plantuml,0,"*** PlantumlManager::runPlantumlContent Running epstopdf\n");
291 auto files_kv = plantumlFiles.find(name);
292 if (files_kv!=plantumlFiles.end())
293 {
294 for (const auto &str : files_kv->second)
295 {
296 const int maxCmdLine = 40960;
298 epstopdfArgs.sprintf("\"%s%s.eps\" --outfile=\"%s%s.pdf\"",
299 pumlOutDir.data(),str.c_str(), pumlOutDir.data(),str.c_str());
300 if ((exitCode=Portable::system("epstopdf",epstopdfArgs.data()))!=0)
301 {
302 err_full(nb.srcFile,nb.srcLine,"Problems running epstopdf. Check your TeX installation! Exit code: {}.",exitCode);
303 }
304 else
305 {
306 Dir().remove(pumlOutDir.str()+str+".eps");
307 }
308 }
309 }
310 }
311 }
312 }
313}

References Config_getBool, Config_getList, Config_getString, QCString::data, err_full, FileInfo::exists, QCString::ExplicitSize, fileToString, QCString::isEmpty, FileInfo::isFile, maxCmdLine, msg, Portable::openOutputStream, Portable::pathListSeparator, Debug::Plantuml, Debug::print, PlantumlManager::PUML_BITMAP, PlantumlManager::PUML_EPS, PlantumlManager::PUML_SVG, Dir::remove, QCString::sprintf, QCString::str, Portable::system and TRUE.

Referenced by PlantumlManager::run.


Generated via doxygen2docusaurus by Doxygen 1.14.0.