Functions | Variables
plantuml.cpp File Reference
#include "plantuml.h"
#include "portable.h"
#include "config.h"
#include "message.h"
#include <qdir.h>

Go to the source code of this file.

Functions

QCString writePlantUMLSource (const QCString &outDir, const QCString &fileName, const QCString &content)
 
void generatePlantUMLOutput (const char *baseName, const char *outDir, PlantUMLOutputFormat format)
 

Variables

static const int maxCmdLine = 40960
 

Function Documentation

void generatePlantUMLOutput ( const char *  baseName,
const char *  outDir,
PlantUMLOutputFormat  format 
)

Convert a PlantUML file to an image.

Parameters
[in]baseNamethe name of the generated file (as returned by writePlantUMLSource())
[in]outDirthe directory to write the resulting image into.
[in]formatthe image format to generate.

Definition at line 54 of file plantuml.cpp.

55 {
56  static QCString plantumlJarPath = Config_getString("PLANTUML_JAR_PATH");
57 
58  QCString pumlExe = "java";
59  QCString pumlArgs = "";
60 
61  QStrList &pumlIncludePathList = Config_getList("PLANTUML_INCLUDE_PATH");
62  char *s=pumlIncludePathList.first();
63  if (s)
64  {
65  pumlArgs += "-Dplantuml.include.path=\"";
66  pumlArgs += s;
67  s = pumlIncludePathList.next();
68  }
69  while (s)
70  {
71  pumlArgs += portable_pathListSeparator();
72  pumlArgs += s;
73  s = pumlIncludePathList.next();
74  }
75  if (pumlIncludePathList.first()) pumlArgs += "\" ";
76  pumlArgs += "-Djava.awt.headless=true -jar \""+plantumlJarPath+"plantuml.jar\" ";
77  pumlArgs+="-o \"";
78  pumlArgs+=outDir;
79  pumlArgs+="\" ";
80  QCString extension;
81  switch (format)
82  {
83  case PUML_BITMAP:
84  pumlArgs+="-tpng";
85  extension=".png";
86  break;
87  case PUML_EPS:
88  pumlArgs+="-teps";
89  extension=".eps";
90  break;
91  case PUML_SVG:
92  pumlArgs+="-tsvg";
93  extension=".svg";
94  break;
95  }
96  pumlArgs+=" \"";
97  pumlArgs+=baseName;
98  pumlArgs+=".pu\" ";
99  pumlArgs+="-charset UTF-8 ";
100  int exitCode;
101  //printf("*** running: %s %s outDir:%s %s\n",pumlExe.data(),pumlArgs.data(),outDir,outFile);
102  msg("Running PlantUML on generated file %s.pu\n",baseName);
104  if ((exitCode=portable_system(pumlExe,pumlArgs,TRUE))!=0)
105  {
106  err("Problems running PlantUML. Verify that the command 'java -jar \"%splantuml.jar\" -h' works from the command line. Exit code: %d\n",
107  plantumlJarPath.data(),exitCode);
108  }
109  else if (Config_getBool("DOT_CLEANUP"))
110  {
111  QFile(QCString(baseName)+".pu").remove();
112  }
114  if ( (format==PUML_EPS) && (Config_getBool("USE_PDFLATEX")) )
115  {
116  QCString epstopdfArgs(maxCmdLine);
117  epstopdfArgs.sprintf("\"%s.eps\" --outfile=\"%s.pdf\"",baseName,baseName);
119  if ((exitCode=portable_system("epstopdf",epstopdfArgs))!=0)
120  {
121  err("Problems running epstopdf. Check your TeX installation! Exit code: %d\n",exitCode);
122  }
124  }
125 }
void portable_sysTimerStop()
Definition: portable.cpp:415
static const int maxCmdLine
Definition: plantuml.cpp:23
void msg(const char *fmt,...)
Definition: message.cpp:107
type * first()
Definition: qinternallist.h:87
static bool format(QChar::Decomposition tag, QString &str, int index, int len)
Definition: qstring.cpp:11496
#define Config_getList(val)
Definition: config.cpp:662
void portable_sysTimerStart()
Definition: portable.cpp:410
const char * data() const
Definition: qcstring.h:207
char portable_pathListSeparator()
Definition: portable.cpp:364
#define Config_getString(val)
Definition: config.cpp:660
#define Config_getBool(val)
Definition: config.cpp:664
type * next()
Definition: qinternallist.h:89
void err(const char *fmt,...)
Definition: message.cpp:226
The QFile class is an I/O device that operates on files.
Definition: qfile.h:50
bool remove()
Definition: qfile.cpp:205
static QCString baseName
Definition: scanner.cpp:10890
static QCString * s
Definition: config.cpp:1042
const bool TRUE
Definition: qglobal.h:371
int portable_system(const char *command, const char *args, bool commandHasConsole)
Definition: portable.cpp:33
QCString writePlantUMLSource ( const QCString outDir,
const QCString fileName,
const QCString content 
)

Write a PlantUML compatible file.

Parameters
[in]outDirthe output directory to write the file to.
[in]fileNamethe name of the file. If empty a name will be chosen automatically.
[in]contentthe contents of the PlantUML file.
Returns
The name of the generated file.

Definition at line 25 of file plantuml.cpp.

26 {
27  QCString baseName(4096);
28  static int umlindex=1;
29 
30  if (fileName.isEmpty()) // generate name
31  {
32  baseName = outDir+"/inline_umlgraph_"+QCString().setNum(umlindex++);
33  }
34  else // user specified name
35  {
37  int i=baseName.findRev('.');
38  if (i!=-1) baseName = baseName.left(i);
39  baseName.prepend(outDir+"/");
40  }
41  QFile file(baseName+".pu");
42  if (!file.open(IO_WriteOnly))
43  {
44  err("Could not open file %s for writing\n",baseName.data());
45  }
46  QCString text = "@startuml";
47  text+=content;
48  text+="@enduml\n";
49  file.writeBlock( text, text.length() );
50  file.close();
51  return baseName;
52 }
bool isEmpty() const
Definition: qcstring.h:189
#define IO_WriteOnly
Definition: qiodevice.h:62
QCString left(uint len) const
Definition: qcstring.cpp:213
int findRev(char c, int index=-1, bool cs=TRUE) const
Definition: qcstring.cpp:95
fileName
Definition: dumpTree.py:9
QCString & prepend(const char *s)
Definition: qcstring.cpp:387
const char * data() const
Definition: qcstring.h:207
void err(const char *fmt,...)
Definition: message.cpp:226
The QFile class is an I/O device that operates on files.
Definition: qfile.h:50
QCString & setNum(short n)
Definition: qcstring.cpp:469
static QCString baseName
Definition: scanner.cpp:10890

Variable Documentation

const int maxCmdLine = 40960
static

Definition at line 23 of file plantuml.cpp.