Doxygen
Loading...
Searching...
No Matches
PlantumlManager Class Reference

Singleton that manages plantuml relation actions. More...

#include <src/plantuml.h>

Public Types

enum  OutputFormat { PUML_BITMAP , PUML_EPS , PUML_SVG }
 Plant UML output image formats. More...
 
using FilesMap = std::map< std::string, StringVector >
 
using ContentMap = std::map< std::string, PlantumlContent >
 

Public Member Functions

void run ()
 Run plant UML tool for all images.
 
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.
 
void generatePlantUMLOutput (const QCString &baseName, const QCString &outDir, OutputFormat format)
 Convert a PlantUML file to an image.
 

Static Public Member Functions

static PlantumlManagerinstance ()
 

Private Member Functions

 PlantumlManager ()
 
void insert (const std::string &key, const std::string &value, const QCString &outDir, OutputFormat format, const QCString &puContent, const QCString &srcFile, int srcLine)
 

Private Attributes

FilesMap m_pngPlantumlFiles
 
FilesMap m_svgPlantumlFiles
 
FilesMap m_epsPlantumlFiles
 
ContentMap m_pngPlantumlContent
 
ContentMap m_svgPlantumlContent
 
ContentMap m_epsPlantumlContent
 

Detailed Description

Singleton that manages plantuml relation actions.

Definition at line 40 of file plantuml.h.

Member Typedef Documentation

◆ ContentMap

using PlantumlManager::ContentMap = std::map< std::string, PlantumlContent >

Definition at line 76 of file plantuml.h.

◆ FilesMap

using PlantumlManager::FilesMap = std::map< std::string, StringVector >

Definition at line 75 of file plantuml.h.

Member Enumeration Documentation

◆ OutputFormat

Plant UML output image formats.

Enumerator
PUML_BITMAP 
PUML_EPS 
PUML_SVG 

Definition at line 44 of file plantuml.h.

Constructor & Destructor Documentation

◆ PlantumlManager()

PlantumlManager::PlantumlManager ( )
private

Definition at line 162 of file plantuml.cpp.

163{
164}

Referenced by instance().

Member Function Documentation

◆ generatePlantUMLOutput()

void PlantumlManager::generatePlantUMLOutput ( const QCString & baseName,
const QCString & outDir,
OutputFormat 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 127 of file plantuml.cpp.

128{
129 QCString imgName = baseName;
130 // The basename contains path, we need to strip the path from the filename in order
131 // to create the image file name which should be included in the index.qhp (Qt help index file).
132 int i = imgName.findRev('/');
133 if (i!=-1) // strip path
134 {
135 imgName=imgName.mid(i+1);
136 }
137 switch (format)
138 {
139 case PUML_BITMAP:
140 imgName+=".png";
141 break;
142 case PUML_EPS:
143 imgName+=".eps";
144 break;
145 case PUML_SVG:
146 imgName+=".svg";
147 break;
148 }
149
151}
static IndexList * indexList
Definition doxygen.h:134
void addImageFile(const QCString &name)
Definition indexlist.h:126
QCString mid(size_t index, size_t len=static_cast< size_t >(-1)) const
Definition qcstring.h:226
int findRev(char c, int index=-1, bool cs=TRUE) const
Definition qcstring.cpp:91

References IndexList::addImageFile(), QCString::findRev(), Doxygen::indexList, QCString::mid(), PUML_BITMAP, PUML_EPS, and PUML_SVG.

Referenced by FlowChart::printUmlTree(), DocbookDocVisitor::startPlantUmlFile(), LatexDocVisitor::startPlantUmlFile(), DocbookDocVisitor::writePlantUMLFile(), HtmlDocVisitor::writePlantUMLFile(), LatexDocVisitor::writePlantUMLFile(), and RTFDocVisitor::writePlantUMLFile().

◆ insert()

void PlantumlManager::insert ( const std::string & key,
const std::string & value,
const QCString & outDir,
OutputFormat format,
const QCString & puContent,
const QCString & srcFile,
int srcLine )
private

Definition at line 372 of file plantuml.cpp.

375{
376 Debug::print(Debug::Plantuml,0,"*** PlantumlManager::insert key:%s ,value:%s\n",qPrint(key),qPrint(value));
377
378 switch (format)
379 {
380 case PUML_BITMAP:
383 addPlantumlContent(m_pngPlantumlContent,key,outDir,puContent,srcFile,srcLine);
385 break;
386 case PUML_EPS:
389 addPlantumlContent(m_epsPlantumlContent,key,outDir,puContent,srcFile,srcLine);
391 break;
392 case PUML_SVG:
395 addPlantumlContent(m_svgPlantumlContent,key,outDir,puContent,srcFile,srcLine);
397 break;
398 }
399}
@ Plantuml
Definition debug.h:38
static void print(DebugMask mask, int prio, const char *fmt,...)
Definition debug.cpp:81
ContentMap m_pngPlantumlContent
Definition plantuml.h:90
ContentMap m_epsPlantumlContent
Definition plantuml.h:92
ContentMap m_svgPlantumlContent
Definition plantuml.h:91
FilesMap m_pngPlantumlFiles
Definition plantuml.h:87
FilesMap m_svgPlantumlFiles
Definition plantuml.h:88
FilesMap m_epsPlantumlFiles
Definition plantuml.h:89
static void addPlantumlContent(PlantumlManager::ContentMap &plantumlContent, const std::string &key, const QCString &outDir, const QCString &puContent, const QCString &srcFile, int srcLine)
Definition plantuml.cpp:360
static void print(const PlantumlManager::FilesMap &plantumlFiles)
Definition plantuml.cpp:322
static void addPlantumlFiles(PlantumlManager::FilesMap &plantumlFiles, const std::string &key, const std::string &value)
Definition plantuml.cpp:349
const char * qPrint(const char *s)
Definition qcstring.h:661

References addPlantumlContent(), addPlantumlFiles(), m_epsPlantumlContent, m_epsPlantumlFiles, m_pngPlantumlContent, m_pngPlantumlFiles, m_svgPlantumlContent, m_svgPlantumlFiles, Debug::Plantuml, Debug::print(), print(), PUML_BITMAP, PUML_EPS, PUML_SVG, and qPrint().

Referenced by writePlantUMLSource().

◆ instance()

◆ run()

void PlantumlManager::run ( )

Run plant UML tool for all images.

Definition at line 314 of file plantuml.cpp.

315{
316 Debug::print(Debug::Plantuml,0,"*** %s\n","PlantumlManager::run");
320}
static void runPlantumlContent(const PlantumlManager::FilesMap &plantumlFiles, const PlantumlManager::ContentMap &plantumlContent, PlantumlManager::OutputFormat format)
Definition plantuml.cpp:166

References m_epsPlantumlContent, m_epsPlantumlFiles, m_pngPlantumlContent, m_pngPlantumlFiles, m_svgPlantumlContent, m_svgPlantumlFiles, Debug::Plantuml, Debug::print(), PUML_BITMAP, PUML_EPS, PUML_SVG, and runPlantumlContent().

Referenced by generateOutput().

◆ writePlantUMLSource()

QCString PlantumlManager::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.

Parameters
[in]outDirArgthe 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.
[in]formatthe image format to generate.
[in]enginethe plantuml engine to use.
[in]srcFilethe source file resulting in the write command.
[in]srcLinethe line number resulting in the write command.
[in]inlineCodethe code is coming from the \statuml ... \enduml (true) command or from the \planumlfile command (false)
Returns
The name of the generated file.

Definition at line 27 of file plantuml.cpp.

30{
31 QCString baseName;
32 QCString puName;
33 QCString imgName;
34 QCString outDir(outDirArg);
35 static int umlindex=1;
36
37 Debug::print(Debug::Plantuml,0,"*** %s fileName: %s\n","writePlantUMLSource",qPrint(fileName));
38 Debug::print(Debug::Plantuml,0,"*** %s outDir: %s\n","writePlantUMLSource",qPrint(outDir));
39
40 // strip any trailing slashes and backslashes
41 size_t l = 0;
42 while ((l=outDir.length())>0 && (outDir.at(l-1)=='/' || outDir.at(l-1)=='\\'))
43 {
44 outDir = outDir.left(l-1);
45 }
46
47 if (fileName.isEmpty()) // generate name
48 {
49 puName = "inline_umlgraph_"+QCString().setNum(umlindex);
50 baseName = outDir+"/inline_umlgraph_"+QCString().setNum(umlindex++);
51 }
52 else // user specified name
53 {
54 baseName = fileName;
55 int i=baseName.findRev('.');
56 if (i!=-1) baseName = baseName.left(i);
57 puName = baseName;
58 baseName.prepend(outDir+"/");
59 }
60
61 switch (format)
62 {
63 case PUML_BITMAP:
64 imgName =puName+".png";
65 break;
66 case PUML_EPS:
67 imgName =puName+".eps";
68 break;
69 case PUML_SVG:
70 imgName =puName+".svg";
71 break;
72 }
73
74 Debug::print(Debug::Plantuml,0,"*** %s baseName: %s\n","writePlantUMLSource",qPrint(baseName));
75 Debug::print(Debug::Plantuml,0,"*** %s puName: %s\n","writePlantUMLSource",qPrint(puName));
76 Debug::print(Debug::Plantuml,0,"*** %s imgName: %s\n","writePlantUMLSource",qPrint(imgName));
77
78 QCString text;
79 if (inlineCode) text = "@start"+engine+" "+imgName+"\n";
80 text.reserve(text.length()+content.length()+100); // add room for image name and end marker
81 const char *p = content.data();
82 if (p)
83 {
84 char c = 0;
85 bool insideComment = false;
86 bool initial = true;
87 while ((c=*p++))
88 {
89 text+=c;
90 switch (c)
91 {
92 case '\'': insideComment=true; break;
93 case '\n': insideComment=false; break;
94 case '\t': break;
95 case ' ': break;
96 case '@':
97 if (initial && qstrncmp(p,"start",5)==0) // @start...
98 {
99 while ((c=*p++) && isId(c)) text+=c;
100 // insert the image name
101 text+=' ';
102 text+=imgName;
103 if (c) text+=c;
104 }
105 break;
106 default:
107 if (!insideComment) initial=false;
108 break;
109 }
110 }
111 text+='\n';
112 }
113 if (inlineCode) text +="@end"+engine+"\n";
114
115 //printf("content\n====\n%s\n=====\n->\n-----\n%s\n------\n",qPrint(content),qPrint(text));
116
117 QCString qcOutDir(substitute(outDir,"\\","/"));
118 uint32_t pos = qcOutDir.findRev("/");
119 QCString generateType(qcOutDir.right(qcOutDir.length() - (pos + 1)) );
120 Debug::print(Debug::Plantuml,0,"*** %s generateType: %s\n","writePlantUMLSource",qPrint(generateType));
121 PlantumlManager::instance().insert(generateType.str(),puName.str(),outDir,format,text,srcFile,srcLine);
122 Debug::print(Debug::Plantuml,0,"*** %s generateType: %s\n","writePlantUMLSource",qPrint(generateType));
123
124 return baseName;
125}
void insert(const std::string &key, const std::string &value, const QCString &outDir, OutputFormat format, const QCString &puContent, const QCString &srcFile, int srcLine)
Definition plantuml.cpp:372
static PlantumlManager & instance()
Definition plantuml.cpp:156
QCString & prepend(const char *s)
Definition qcstring.h:407
size_t length() const
Returns the length of the string, not counting the 0-terminator.
Definition qcstring.h:153
bool isEmpty() const
Returns TRUE iff the string is empty.
Definition qcstring.h:150
const std::string & str() const
Definition qcstring.h:526
QCString & setNum(short n)
Definition qcstring.h:444
void reserve(size_t size)
Reserve space for size bytes without changing the string contents.
Definition qcstring.h:172
const char * data() const
Returns a pointer to the contents of the string in the form of a 0-terminated C string.
Definition qcstring.h:159
QCString left(size_t len) const
Definition qcstring.h:214
QCString substitute(const QCString &s, const QCString &src, const QCString &dst)
substitute all occurrences of src in s by dst
Definition qcstring.cpp:477
int qstrncmp(const char *str1, const char *str2, size_t len)
Definition qcstring.h:75
bool isId(int c)
Definition util.h:202

References QCString::at(), QCString::data(), QCString::findRev(), insert(), instance(), QCString::isEmpty(), isId(), QCString::left(), QCString::length(), Debug::Plantuml, QCString::prepend(), Debug::print(), PUML_BITMAP, PUML_EPS, PUML_SVG, qPrint(), qstrncmp(), QCString::reserve(), QCString::right(), QCString::setNum(), QCString::str(), and substitute().

Referenced by DocbookDocVisitor::operator()(), HtmlDocVisitor::operator()(), HtmlDocVisitor::operator()(), LatexDocVisitor::operator()(), RTFDocVisitor::operator()(), RTFDocVisitor::operator()(), FlowChart::printUmlTree(), DocbookDocVisitor::startPlantUmlFile(), and LatexDocVisitor::startPlantUmlFile().

Member Data Documentation

◆ m_epsPlantumlContent

ContentMap PlantumlManager::m_epsPlantumlContent
private

Definition at line 92 of file plantuml.h.

Referenced by insert(), and run().

◆ m_epsPlantumlFiles

FilesMap PlantumlManager::m_epsPlantumlFiles
private

Definition at line 89 of file plantuml.h.

Referenced by insert(), and run().

◆ m_pngPlantumlContent

ContentMap PlantumlManager::m_pngPlantumlContent
private

Definition at line 90 of file plantuml.h.

Referenced by insert(), and run().

◆ m_pngPlantumlFiles

FilesMap PlantumlManager::m_pngPlantumlFiles
private

Definition at line 87 of file plantuml.h.

Referenced by insert(), and run().

◆ m_svgPlantumlContent

ContentMap PlantumlManager::m_svgPlantumlContent
private

Definition at line 91 of file plantuml.h.

Referenced by insert(), and run().

◆ m_svgPlantumlFiles

FilesMap PlantumlManager::m_svgPlantumlFiles
private

Definition at line 88 of file plantuml.h.

Referenced by insert(), and run().


The documentation for this class was generated from the following files: