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

#include <src/vhdldocgen.h>

+ Collaboration diagram for FlowChart:

Public Types

enum  nodeTypes {
  IF_NO = 1<<1 , ELSIF_NO = 1<<2 , ELSE_NO = 1<<3 , CASE_NO = 1<<4 ,
  WHEN_NO = 1<<5 , EXIT_NO = 1<<6 , END_NO = 1<<7 , TEXT_NO = 1<<8 ,
  START_NO = 1<<9 , ENDIF_NO = 1<<10 , FOR_NO = 1<<11 , WHILE_NO = 1<<12 ,
  END_LOOP = 1<<13 , END_CASE = 1<<14 , VARIABLE_NO = 1<<15 , RETURN_NO = 1<<16 ,
  LOOP_NO = 1<<17 , NEXT_NO = 1<<18 , EMPTY_NO = 1<<19 , COMMENT_NO = 1<<20 ,
  BEGIN_NO = 1<<21
}
 

Public Member Functions

 FlowChart (int typ, const QCString &t, const QCString &ex, const QCString &label=QCString())
 

Static Public Member Functions

static void createSVG ()
 
static void startDot (TextStream &t)
 
static void endDot (TextStream &t)
 
static void codify (TextStream &t, const QCString &str)
 
static void writeShape (TextStream &t, const FlowChart &fl)
 
static void writeEdge (TextStream &t, int fl_from, int fl_to, int i, bool bFrom=FALSE, bool bTo=FALSE)
 
static void writeEdge (TextStream &t, const FlowChart &fl_from, const FlowChart &fl_to, int i)
 
static void writeFlowLinks (TextStream &t)
 
static QCString getNodeName (int n)
 
static void colTextNodes ()
 
static size_t getNextIfLink (const FlowChart &, size_t)
 
static size_t getNextNode (size_t index, int stamp)
 
static size_t findNode (size_t index, int stamp, int type)
 
static size_t findNode (size_t index, int type)
 
static size_t findNextLoop (size_t j, int stamp)
 
static size_t findPrevLoop (size_t j, int stamp, bool endif=FALSE)
 
static size_t findLabel (size_t j, const QCString &)
 
static void delFlowList ()
 
static const char * getNodeType (int c)
 
static void addFlowChart (int type, const QCString &text, const QCString &exp, const QCString &label=QCString())
 
static void moveToPrevLevel ()
 
static int getTimeStamp ()
 
static void writeFlowChart ()
 
static void alignFuncProc (QCString &q, const ArgumentList &al, bool isFunc)
 
static QCString convertNameToFileName ()
 
static void printNode (const FlowChart &n)
 
static void printFlowTree ()
 
static void buildCommentNodes (TextStream &t)
 
static void alignCommentNode (TextStream &t, QCString com)
 
static void printUmlTree ()
 
static QCString printPlantUmlNode (const FlowChart &flo, bool, bool)
 

Private Attributes

int id = 0
 
int stamp = 0
 
int type = 0
 
int line = 0
 
QCString label
 
QCString text
 
QCString exp
 

Detailed Description

Definition at line 238 of file vhdldocgen.h.

Member Enumeration Documentation

◆ nodeTypes

Enumerator
IF_NO 
ELSIF_NO 
ELSE_NO 
CASE_NO 
WHEN_NO 
EXIT_NO 
END_NO 
TEXT_NO 
START_NO 
ENDIF_NO 
FOR_NO 
WHILE_NO 
END_LOOP 
END_CASE 
VARIABLE_NO 
RETURN_NO 
LOOP_NO 
NEXT_NO 
EMPTY_NO 
COMMENT_NO 
BEGIN_NO 

Definition at line 241 of file vhdldocgen.h.

241 {
242 IF_NO = 1<<1,
243 ELSIF_NO = 1<<2,
244 ELSE_NO = 1<<3,
245 CASE_NO = 1<<4,
246 WHEN_NO = 1<<5,
247 EXIT_NO = 1<<6,
248 END_NO = 1<<7,
249 TEXT_NO = 1<<8,
250 START_NO = 1<<9,
251 ENDIF_NO = 1<<10,
252 FOR_NO = 1<<11,
253 WHILE_NO = 1<<12,
254 END_LOOP = 1<<13,
255 END_CASE = 1<<14,
256 VARIABLE_NO = 1<<15,
257 RETURN_NO = 1<<16,
258 LOOP_NO = 1<<17,
259 NEXT_NO = 1<<18,
260 EMPTY_NO = 1<<19,
261 COMMENT_NO = 1<<20,
262 BEGIN_NO = 1<<21
263 };

Constructor & Destructor Documentation

◆ FlowChart()

FlowChart::FlowChart ( int typ,
const QCString & t,
const QCString & ex,
const QCString & label = QCString() )

Definition at line 2865 of file vhdldocgen.cpp.

2866{
2868
2869 if (typ & STARTL)
2870 {
2871 ifcounter++;
2872 }
2873
2874 text=t;
2875 exp=ex;
2876 type=typ;
2877 label=lab;
2878
2879 if (typ & (ELSE_NO | ELSIF_NO))
2880 {
2881 stamp--;
2882 }
2883
2884 if (typ & (START_NO | END_NO | VARIABLE_NO))
2885 {
2886 stamp=0;
2887 }
2888
2889 id=nodeCounter++;
2890}
QCString label
Definition vhdldocgen.h:311
QCString text
Definition vhdldocgen.h:312
QCString exp
Definition vhdldocgen.h:313
static int nodeCounter
static int ifcounter
#define STARTL

References ELSE_NO, ELSIF_NO, END_NO, exp, ifcounter, label, nodeCounter, stamp, START_NO, STARTL, text, type, and VARIABLE_NO.

Referenced by addFlowChart(), buildCommentNodes(), colTextNodes(), findLabel(), findNextLoop(), findNode(), findPrevLoop(), getNextIfLink(), getNextNode(), getTimeStamp(), printNode(), printPlantUmlNode(), printUmlTree(), writeEdge(), writeFlowLinks(), and writeShape().

Member Function Documentation

◆ addFlowChart()

void FlowChart::addFlowChart ( int type,
const QCString & text,
const QCString & exp,
const QCString & label = QCString() )
static

Definition at line 2892 of file vhdldocgen.cpp.

2893{
2894 if (!VhdlDocGen::getFlowMember()) return;
2895
2896 QCString typeString(text);
2897 QCString expression(exp);
2898
2899
2900 if (!text.isEmpty())
2901 {
2902 typeString=substitute(typeString,";","\n");
2903 }
2904
2905 if (!exp.isEmpty())
2906 {
2907 expression=substitute(expression,"\"","\\\"");
2908 }
2909
2910 if (type & VARIABLE_NO)
2911 {
2912 // Ignore the empty section of the VHDL variable definition.
2913 // This is section between `process` and `begin` keywords, where any source text is missing, probably a bug in the VHDL source parser.
2914 if(text.isEmpty()) return;
2915
2916 flowList.insert(flowList.begin(),FlowChart(type,typeString,expression,label));
2917 flowList.front().line=1; // TODO: use getLine(); of the parser
2918 }
2919 else if (type & START_NO)
2920 {
2921 flowList.insert(flowList.begin(),FlowChart(type,typeString,expression,label));
2922 flowList.front().line=1; // TODO: use getLine(); of the parser
2923 }
2924 else
2925 {
2926 flowList.emplace_back(type,typeString,expression,label);
2927 flowList.back().line=1; // TODO: use getLine(); of the parser
2928 }
2929}
FlowChart(int typ, const QCString &t, const QCString &ex, const QCString &label=QCString())
static const MemberDef * getFlowMember()
QCString substitute(const QCString &s, const QCString &src, const QCString &dst)
substitute all occurrences of src in s by dst
Definition qcstring.cpp:477
std::vector< FlowChart > flowList

References exp, FlowChart(), flowList, VhdlDocGen::getFlowMember(), label, START_NO, substitute(), text, type, and VARIABLE_NO.

Referenced by VHDLOutlineParser::createFlow(), and VHDLOutlineParser::handleFlowComment().

◆ alignCommentNode()

void FlowChart::alignCommentNode ( TextStream & t,
QCString com )
static

Definition at line 2722 of file vhdldocgen.cpp.

2723{
2724 size_t max=0;
2725 QCString s;
2726 StringVector ql=split(com.str(),"\n");
2727 for (size_t j=0;j<ql.size();j++)
2728 {
2729 s=ql[j];
2730 if (max<s.length()) max=s.length();
2731 }
2732
2733 s=ql.back();
2734 int diff=static_cast<int>(max-s.length());
2735
2736 QCString n;
2737 if (diff>0)
2738 {
2739 n.fill(' ',2*diff);
2740 n.append(".");
2741 s+=n;
2742 ql.pop_back();
2743 ql.push_back(s.str());
2744 }
2745
2746 for (size_t j=0;j<ql.size();j++)
2747 {
2748 s=ql[j];
2749 if (j<ql.size()-1)
2750 {
2751 s+="\n";
2752 }
2753 FlowChart::codify(t,s);
2754 }
2755}
static void codify(TextStream &t, const QCString &str)
void fill(char c, int len=-1)
Fills a string with a predefined character.
Definition qcstring.h:180
size_t length() const
Returns the length of the string, not counting the 0-terminator.
Definition qcstring.h:153
const std::string & str() const
Definition qcstring.h:526
QCString & append(char c)
Definition qcstring.h:381
std::vector< std::string > StringVector
Definition containers.h:33
StringVector split(const std::string &s, const std::string &delimiter)
split input string s by string delimiter delimiter.
Definition util.cpp:6945

References QCString::append(), codify(), QCString::fill(), QCString::length(), split(), and QCString::str().

Referenced by buildCommentNodes(), and writeShape().

◆ alignFuncProc()

void FlowChart::alignFuncProc ( QCString & q,
const ArgumentList & al,
bool isFunc )
static

Definition at line 3280 of file vhdldocgen.cpp.

3281{
3282 size_t index=al.size();
3283 if (index==0) return;
3284
3285 size_t len=q.length()+VhdlDocGen::getFlowMember()->name().length();
3286 QCString prev,temp;
3287 prev.fill(' ',static_cast<int>(len)+1);
3288
3289 q+="\n";
3290 for (const Argument &arg : al)
3291 {
3292 QCString attl=arg.defval+" ";
3293 attl+=arg.name+" ";
3294
3295 if (!isFunc)
3296 {
3297 attl+=arg.attrib+" ";
3298 }
3299 else
3300 {
3301 attl+=" in ";
3302 }
3303 attl+=arg.type;
3304 if (--index) attl+=",\n"; else attl+="\n";
3305
3306 attl.prepend(prev);
3307 temp+=attl;
3308 }
3309
3310 q+=temp;
3311}
size_t size() const
Definition arguments.h:93
virtual const QCString & name() const =0
QCString & prepend(const char *s)
Definition qcstring.h:407

References QCString::fill(), VhdlDocGen::getFlowMember(), QCString::length(), Definition::name(), QCString::prepend(), and ArgumentList::size().

Referenced by VHDLOutlineParser::createFlow().

◆ buildCommentNodes()

void FlowChart::buildCommentNodes ( TextStream & t)
static

Definition at line 2758 of file vhdldocgen.cpp.

2759{
2760 size_t size=flowList.size();
2761 bool begin=false;
2762
2763 if (size>0)
2764 {
2765 for (uint32_t j=0;j < size-1 ;j++)
2766 {
2767 FlowChart &fll = flowList[j];
2768 if (fll.type & COMMENT_NO)
2769 {
2770 FlowChart &to=flowList[j+1];
2771 if (to.type & COMMENT_NO)
2772 {
2773 to.label = fll.label+"\n"+to.label;
2774 flowList.erase(flowList.begin()+j);
2775 if (size>0) size--;
2776 if (j>0) j--;
2777 }
2778 }
2779 }// for
2780 }
2781
2782 for (size_t j=0;j <flowList.size() ;j++)
2783 {
2784 const FlowChart &fll=flowList[j];
2785
2786 if (fll.type & BEGIN_NO)
2787 {
2788 begin = true;
2789 continue;
2790 }
2791
2792 if (fll.type & COMMENT_NO)
2793 {
2794 const FlowChart *to = nullptr;
2795 if (!begin)
2796 {
2797 // comment between function/process .. begin is linked to start node
2798 to = &flowList[0];
2799 }
2800 else if (j>0 && flowList[j-1].line==fll.line)
2801 {
2802 to = &flowList[j-1];
2803 }
2804 else
2805 {
2806 to = &flowList[j+1];
2807 }
2808 t << getNodeName(fll.id);
2809 t << "[shape=none, label=<\n";
2810 t << "<TABLE BORDER=\"0\" CELLBORDER=\"1\" CELLSPACING=\"0\" CELLPADDING=\"2\" >\n ";
2811 t << "<TR><TD BGCOLOR=\"";
2812 t << flowCol.comment;
2813 t << "\" > ";
2814
2816 t << " </TD></TR></TABLE>>];";
2817 writeEdge(t,fll.id,to->id,2);
2818 }
2819 }// for
2820
2821 // delete comment nodes;
2822 size=flowList.size();
2823 for (size_t j=0; j<size; j++)
2824 {
2825 FlowChart &fll=flowList[j];
2826 if (fll.type & (COMMENT_NO | BEGIN_NO))
2827 {
2828 size_t diff=FLOWLEN-(j+1);
2829
2830 if ((fll.type & COMMENT_NO) && diff > 1)
2831 {
2832 flowList[j+1].label = fll.label;
2833 }
2834
2835 flowList.erase(flowList.begin()+j);
2836
2837 if (size>0) size--;
2838 if (j>0) j--;
2839 }
2840 }// for;
2841}
static void writeEdge(TextStream &t, int fl_from, int fl_to, int i, bool bFrom=FALSE, bool bTo=FALSE)
static QCString getNodeName(int n)
static void alignCommentNode(TextStream &t, QCString com)
DirIterator begin(DirIterator it) noexcept
Definition dir.cpp:170
#define FLOWLEN
static struct @262143045100337216022015277174266365223104043217 flowCol

References alignCommentNode(), begin(), BEGIN_NO, COMMENT_NO, FlowChart(), flowCol, FLOWLEN, flowList, getNodeName(), id, label, line, type, and writeEdge().

Referenced by writeFlowChart().

◆ codify()

void FlowChart::codify ( TextStream & t,
const QCString & str )
static

Definition at line 2843 of file vhdldocgen.cpp.

2844{
2845 if (!str.isEmpty())
2846 {
2847 const char *p=str.data();
2848 while (*p)
2849 {
2850 char c=*p++;
2851 switch(c)
2852 {
2853 case '<': t << "&lt;"; break;
2854 case '>': t << "&gt;"; break;
2855 case '&': t << "&amp;"; break;
2856 case '\'': t << "&#39;"; break;
2857 case '"': t << "&quot;"; break;
2858 case '\n': t <<"<BR ALIGN=\"LEFT\"/>"; break;
2859 default: t << c; break;
2860 }
2861 }
2862 }
2863}//codify
bool isEmpty() const
Returns TRUE iff the string is empty.
Definition qcstring.h:150
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

References QCString::data(), and QCString::isEmpty().

Referenced by alignCommentNode().

◆ colTextNodes()

void FlowChart::colTextNodes ( )
static

Definition at line 2658 of file vhdldocgen.cpp.

2659{
2660 FlowChart *flno = nullptr;
2661 bool found=FALSE;
2662 for (size_t j=0;j<flowList.size();j++)
2663 {
2664 FlowChart &flo = flowList[j];
2665 if (flo.type&TEXT_NO)
2666 {
2667 if (!found)
2668 {
2669 flno=&flo;
2670 }
2671 else
2672 {
2673 flno->text+=flo.text;
2674 flowList.erase(flowList.begin()+j);
2675 if (j>0) j=j-1;
2676 }
2677 found=TRUE;
2678 }
2679 else
2680 {
2681 found=FALSE;
2682 }
2683 }
2684
2685 // find if..endif without text
2686 // if..elseif without text
2687 if (!flowList.empty())
2688 {
2689 for (size_t j=0;j<flowList.size()-1;j++)
2690 {
2691 const FlowChart &flo = flowList[j];
2692 int kind = flo.type;
2693 if ( (kind & IFF) || (flo.type & ELSE_NO))
2694 {
2695 const FlowChart &ftemp = flowList[j+1];
2696 if (ftemp.type & EMPTY)
2697 {
2698 FlowChart fc(TEXT_NO,"empty ",QCString());
2699 fc.stamp = flo.stamp;
2700 flowList.insert(flowList.begin()+j+1,fc);
2701 }
2702 }
2703 }
2704 }
2705
2706}// colTextNode
#define TRUE
Definition qcstring.h:37
#define FALSE
Definition qcstring.h:34
bool found
Definition util.cpp:984
#define IFF
#define EMPTY

References ELSE_NO, EMPTY, FALSE, FlowChart(), flowList, found, IFF, stamp, text, TEXT_NO, TRUE, and type.

Referenced by writeFlowChart().

◆ convertNameToFileName()

QCString FlowChart::convertNameToFileName ( )
static

Definition at line 3017 of file vhdldocgen.cpp.

3018{
3019 return VhdlDocGen::getFlowMember()->name();
3020}

References VhdlDocGen::getFlowMember(), and Definition::name().

Referenced by createSVG(), HtmlDocVisitor::operator()(), and printUmlTree().

◆ createSVG()

void FlowChart::createSVG ( )
static

Definition at line 3051 of file vhdldocgen.cpp.

3052{
3053 QCString qcs("/");
3054 QCString ov = Config_getString(HTML_OUTPUT);
3055
3057
3058 //const MemberDef *m=VhdlDocGen::getFlowMember();
3059 //if (m)
3060 // fprintf(stderr,"\n creating flowchart : %s %s in file %s \n",theTranslator->trVhdlType(m->getMemberSpecifiers(),TRUE),qPrint(m->name()),qPrint(m->getFileDef()->name()));
3061
3062 QCString dir=" -o \""+ov+qcs+"\"";
3063 ov+="/flow_design.dot";
3064
3065 QCString vlargs="-Tsvg \""+ov+"\" "+dir ;
3066
3068 {
3069 err("could not create dot file\n");
3070 }
3071}
static QCString verifiedDotPath
Definition doxygen.h:139
static QCString convertNameToFileName()
#define Config_getString(name)
Definition config.h:32
#define err(fmt,...)
Definition message.h:84
int system(const QCString &command, const QCString &args, bool commandHasConsole=true)
Definition portable.cpp:106

References Config_getString, convertNameToFileName(), err, Portable::system(), and Doxygen::verifiedDotPath.

Referenced by writeFlowChart().

◆ delFlowList()

void FlowChart::delFlowList ( )
static

Definition at line 2715 of file vhdldocgen.cpp.

2716{
2717 ifcounter=0;
2718 nodeCounter=0;
2719 flowList.clear();
2720}

References QCString::clear(), flowList, ifcounter, and nodeCounter.

Referenced by writeFlowChart().

◆ endDot()

void FlowChart::endDot ( TextStream & t)
static

Definition at line 3081 of file vhdldocgen.cpp.

3082{
3083 t << " } \n";
3084}

Referenced by writeFlowChart().

◆ findLabel()

size_t FlowChart::findLabel ( size_t j,
const QCString & label )
static

Definition at line 3353 of file vhdldocgen.cpp.

3354{
3355 for (size_t j=index;j>0;j--)
3356 {
3357 const FlowChart &flo = flowList[j];
3358 if ((flo.type & LOOP) && !flo.label.isEmpty() && qstricmp(flo.label,label)==0)
3359 {
3360 return j;
3361 }
3362 }
3363 err("could not find label: '%s'\n",qPrint(label));
3364 return 0;
3365}
int qstricmp(const char *s1, const char *s2)
Definition qcstring.cpp:442
const char * qPrint(const char *s)
Definition qcstring.h:661
#define LOOP

References err, FlowChart(), flowList, QCString::isEmpty(), label, LOOP, qPrint(), qstricmp(), and type.

Referenced by writeFlowLinks().

◆ findNextLoop()

size_t FlowChart::findNextLoop ( size_t j,
int stamp )
static

Definition at line 3313 of file vhdldocgen.cpp.

3314{
3315 for (size_t j=index+1; j<flowList.size(); j++)
3316 {
3317 const FlowChart &flo = flowList[j];
3318 if (flo.stamp==stamp)
3319 {
3320 continue;
3321 }
3322 if (flo.type&END_LOOP)
3323 {
3324 return j;
3325 }
3326 }
3327 return flowList.size()-1;
3328}

References END_LOOP, FlowChart(), flowList, QCString::size(), stamp, and type.

Referenced by writeFlowLinks().

◆ findNode() [1/2]

size_t FlowChart::findNode ( size_t index,
int stamp,
int type )
static

Definition at line 3367 of file vhdldocgen.cpp.

3368{
3369 for (size_t j=index+1; j<flowList.size(); j++)
3370 {
3371 const FlowChart &flo = flowList[j];
3372 if (flo.type==type && flo.stamp==stamp)
3373 {
3374 return j;
3375 }
3376 }
3377 return 0;
3378}// findNode

References FlowChart(), flowList, stamp, and type.

Referenced by getNextIfLink(), getNextNode(), and writeFlowLinks().

◆ findNode() [2/2]

static size_t FlowChart::findNode ( size_t index,
int type )
static

References exp, label, stamp, text, and type.

◆ findPrevLoop()

size_t FlowChart::findPrevLoop ( size_t j,
int stamp,
bool endif = FALSE )
static

Definition at line 3330 of file vhdldocgen.cpp.

3331{
3332 for (size_t j=index;j>0;j--)
3333 {
3334 const FlowChart &flo = flowList[j];
3335 if (flo.type & LOOP)
3336 {
3337 if (flo.stamp==stamp && endif)
3338 {
3339 return j;
3340 }
3341 else
3342 {
3343 if (flo.stamp<stamp)
3344 {
3345 return j;
3346 }
3347 }
3348 }
3349 }
3350 return flowList.size()-1;
3351}

References FlowChart(), flowList, LOOP, stamp, and type.

Referenced by writeFlowLinks().

◆ getNextIfLink()

size_t FlowChart::getNextIfLink ( const FlowChart & fl,
size_t index )
static

Definition at line 3421 of file vhdldocgen.cpp.

3422{
3423 int stamp=fl.stamp;
3424 size_t start = index+1;
3425 size_t endifNode = findNode(start,stamp,ENDIF_NO);
3426 size_t elseifNode = findNode(start,stamp,ELSIF_NO);
3427 size_t elseNode = findNode(start,stamp,ELSE_NO);
3428
3429 if (elseifNode>0 && elseifNode<endifNode)
3430 {
3431 return elseifNode;
3432 }
3433
3434 if (elseNode>0 && elseNode<endifNode)
3435 {
3436 return elseNode+1;
3437 }
3438
3439 stamp=flowList[endifNode].stamp;
3440 return getNextNode(endifNode,stamp);
3441}
static size_t getNextNode(size_t index, int stamp)
static size_t findNode(size_t index, int stamp, int type)

References ELSE_NO, ELSIF_NO, ENDIF_NO, findNode(), FlowChart(), flowList, getNextNode(), and stamp.

Referenced by writeFlowLinks().

◆ getNextNode()

size_t FlowChart::getNextNode ( size_t index,
int stamp )
static

Definition at line 3380 of file vhdldocgen.cpp.

3381{
3382 for (size_t j=index+1; j<flowList.size(); j++)
3383 {
3384 const FlowChart &flo = flowList[j];
3385 int kind = flo.type;
3386 int s = flo.stamp;
3387 if (s>stamp)
3388 {
3389 continue;
3390 }
3391 if (kind & ENDIF_NO)
3392 {
3393 if (s<stamp && stamp>0)
3394 {
3395 stamp--;
3396 continue;
3397 }
3398 }
3399 if (kind & (ELSE_NO | ELSIF_NO))
3400 {
3401 if (s<stamp && stamp>0)
3402 {
3403 stamp--;
3404 }
3405 j=findNode(j,stamp,ENDIF_NO);
3406 continue;
3407 }
3408 if (kind & WHEN_NO)
3409 {
3410 if (s<stamp && stamp>0)
3411 {
3412 stamp--;
3413 }
3414 return findNode(j,stamp-1,END_CASE);
3415 }
3416 return j;
3417 }
3418 return FLOWLEN;
3419}

References ELSE_NO, ELSIF_NO, END_CASE, ENDIF_NO, findNode(), FlowChart(), FLOWLEN, flowList, stamp, type, and WHEN_NO.

Referenced by getNextIfLink(), and writeFlowLinks().

◆ getNodeName()

QCString FlowChart::getNodeName ( int n)
static

Definition at line 2708 of file vhdldocgen.cpp.

2709{
2710 QCString node;
2711 node.setNum(n);
2712 return node.prepend("node");
2713}
QCString & setNum(short n)
Definition qcstring.h:444

References QCString::prepend(), and QCString::setNum().

Referenced by buildCommentNodes(), writeEdge(), writeEdge(), and writeShape().

◆ getNodeType()

const char * FlowChart::getNodeType ( int c)
static

Definition at line 3022 of file vhdldocgen.cpp.

3023{
3024 switch(c)
3025 {
3026 case IF_NO: return "if ";
3027 case ELSIF_NO: return "elsif ";
3028 case ELSE_NO: return "else ";
3029 case CASE_NO: return "case ";
3030 case WHEN_NO: return "when ";
3031 case EXIT_NO: return "exit ";
3032 case END_NO: return "end ";
3033 case TEXT_NO: return "text ";
3034 case START_NO: return "start ";
3035 case ENDIF_NO: return "endif ";
3036 case FOR_NO: return "for ";
3037 case WHILE_NO: return "while ";
3038 case END_LOOP: return "end_loop ";
3039 case END_CASE: return "end_case ";
3040 case VARIABLE_NO: return "variable_decl ";
3041 case RETURN_NO: return "return ";
3042 case LOOP_NO: return "infinite loop ";
3043 case NEXT_NO: return "next ";
3044 case COMMENT_NO: return "comment ";
3045 case EMPTY_NO: return "empty ";
3046 case BEGIN_NO: return "<begin> ";
3047 default: return "--failure--";
3048 }
3049}

References BEGIN_NO, CASE_NO, COMMENT_NO, ELSE_NO, ELSIF_NO, EMPTY_NO, END_CASE, END_LOOP, END_NO, ENDIF_NO, EXIT_NO, FOR_NO, IF_NO, LOOP_NO, NEXT_NO, RETURN_NO, START_NO, TEXT_NO, VARIABLE_NO, WHEN_NO, and WHILE_NO.

Referenced by printNode().

◆ getTimeStamp()

static int FlowChart::getTimeStamp ( )
static

References FlowChart(), and label.

◆ moveToPrevLevel()

void FlowChart::moveToPrevLevel ( )
static

Definition at line 2931 of file vhdldocgen.cpp.

2932{
2933 if (!VhdlDocGen::getFlowMember()) return;
2934 ifcounter--;
2935}

References VhdlDocGen::getFlowMember(), and ifcounter.

◆ printFlowTree()

void FlowChart::printFlowTree ( )
static

Definition at line 2650 of file vhdldocgen.cpp.

2651{
2652 for (const auto &flowChart : flowList)
2653 {
2654 printNode(flowChart);
2655 }
2656}
static void printNode(const FlowChart &n)

References flowList, and printNode().

Referenced by writeFlowChart().

◆ printNode()

void FlowChart::printNode ( const FlowChart & n)
static

Definition at line 2590 of file vhdldocgen.cpp.

2591{
2592 QCString ui="-";
2593 std::string q;
2594 std::string t;
2595
2596 ui.fill('-',255);
2597
2598 if (flo.type & STARTL)
2599 {
2600 if (flo.stamp>0)
2601 {
2602 q=ui.left(2*flo.stamp).str();
2603 }
2604 else
2605 {
2606 q=" ";
2607 }
2608 QCString nn=flo.exp.stripWhiteSpace();
2609 printf("\nYES: %s%s[%d,%d]",qPrint(q),qPrint(nn),flo.stamp,flo.id);
2610 }
2611 else
2612 {
2613 if (flo.type & COMMENT_NO)
2614 {
2615 t=flo.label.str();
2616 }
2617 else
2618 {
2619 t=flo.text.str();
2620 }
2621 static const reg::Ex ep(R"(\s)");
2622 t = reg::replace(t,ep,std::string());
2623 if (t.empty())
2624 {
2625 t=" ";
2626 }
2627 if (flo.stamp>0)
2628 {
2629 q=ui.left(2*flo.stamp).str();
2630 }
2631 else
2632 {
2633 q=" ";
2634 }
2635 if (flo.type & EMPTNODE)
2636 {
2637 printf("\n NO: %s%s[%d,%d]",q.c_str(),FlowChart::getNodeType(flo.type),flo.stamp,flo.id);
2638 }
2639 else if (flo.type & COMMENT_NO)
2640 {
2641 printf("\n NO: %s%s[%d,%d]",t.c_str(),FlowChart::getNodeType(flo.type),flo.stamp,flo.id);
2642 }
2643 else
2644 {
2645 printf("\n NO: %s[%d,%d]",t.c_str(),flo.stamp,flo.id);
2646 }
2647 }
2648}
static const char * getNodeType(int c)
QCString left(size_t len) const
Definition qcstring.h:214
std::string replace(std::string_view str, const Ex &re, std::string_view replacement)
Searching in a given input string for parts that match regular expression re and replaces those parts...
Definition regex.cpp:770
#define EMPTNODE

References COMMENT_NO, EMPTNODE, exp, QCString::fill(), FlowChart(), getNodeType(), id, label, QCString::left(), qPrint(), reg::replace(), stamp, STARTL, QCString::str(), QCString::stripWhiteSpace(), text, and type.

Referenced by printFlowTree().

◆ printPlantUmlNode()

QCString FlowChart::printPlantUmlNode ( const FlowChart & flo,
bool ca,
bool endL )
static

Definition at line 2937 of file vhdldocgen.cpp.

2938{
2939 QCString t;
2940 QCString exp=flo.exp.stripWhiteSpace();
2941 QCString text=flo.text.stripWhiteSpace();
2942 switch (flo.type)
2943 {
2944 case START_NO: t=":"+text+"|"; break;
2945 case IF_NO : t="\nif ("+exp+") then (yes)"; break;
2946 case ELSIF_NO: t="\nelseif ("+exp+") then (yes)"; break;
2947 case ELSE_NO: t="\nelse"; break;
2948 case CASE_NO: t="\n:"+exp+";"; break;
2949 case WHEN_NO: t="\n";
2950 if (!ca) t+="else";
2951 t+="if ("+exp+") then (yes)";
2952 break;
2953 case EXIT_NO: break;
2954 case END_NO: if (text.contains(" function")==0) t="\n:"+text+";";
2955 break;
2956 case TEXT_NO: t="\n:"+text+"]"; break;
2957 case ENDIF_NO: t="\nendif"; break;
2958 case FOR_NO: t="\nwhile ("+exp+") is (yes)"; break;
2959 case WHILE_NO: t="\nwhile ("+exp+") is (yes)"; break;
2960 case END_LOOP: t="\nendwhile"; break;
2961 case END_CASE: t="\nendif\n:end case;"; break;
2962 case VARIABLE_NO:t="\n:"+text+";"; break;
2963 case RETURN_NO: t="\n:"+text+";";
2964 if (!endL) t+="\nstop";
2965 break;
2966 case LOOP_NO: t="\nwhile (infinite loop)"; break;
2967 case NEXT_NO: break;
2968 case EMPTY_NO: break;
2969 case COMMENT_NO: t="\n note left \n "+flo.label+"\nend note \n"; break;
2970 case BEGIN_NO: t="\n:begin;"; break;
2971 default: assert(false); break;
2972 }
2973 return t;
2974}
QCString stripWhiteSpace() const
returns a copy of this string with leading and trailing whitespace removed
Definition qcstring.h:245

References BEGIN_NO, CASE_NO, COMMENT_NO, ELSE_NO, ELSIF_NO, EMPTY_NO, END_CASE, END_LOOP, END_NO, ENDIF_NO, EXIT_NO, exp, FlowChart(), FOR_NO, IF_NO, label, LOOP_NO, NEXT_NO, RETURN_NO, START_NO, QCString::stripWhiteSpace(), text, TEXT_NO, type, VARIABLE_NO, WHEN_NO, and WHILE_NO.

Referenced by printUmlTree().

◆ printUmlTree()

void FlowChart::printUmlTree ( )
static

Definition at line 2976 of file vhdldocgen.cpp.

2977{
2978 int caseCounter = 0;
2979 int whenCounter = 0;
2980
2981 QCString qcs;
2982 size_t size=flowList.size();
2983 for (size_t j=0;j<size;j++)
2984 {
2985 bool endList = j==FLOWLEN;
2986 const FlowChart &flo = flowList[j];
2987 if (flo.type==CASE_NO)
2988 {
2989 caseCounter++;
2990 whenCounter=0;
2991 }
2992
2993 if (flo.type==END_CASE)
2994 {
2995 caseCounter--;
2996 }
2997
2998 bool ca = (caseCounter>0 && whenCounter==0);
2999
3000 qcs+=printPlantUmlNode(flo,ca,endList);
3001
3002 if (flo.type==WHEN_NO)
3003 {
3004 whenCounter++;
3005 }
3006
3007 }
3008 qcs+="\n";
3009
3010 QCString htmlOutDir = Config_getString(HTML_OUTPUT);
3011
3012 QCString n=convertNameToFileName();
3013 n=PlantumlManager::instance().writePlantUMLSource(htmlOutDir,n,qcs,PlantumlManager::PUML_SVG,"uml",n,1,true);
3015}
static QCString printPlantUmlNode(const FlowChart &flo, bool, bool)
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.
Definition plantuml.cpp:27
static PlantumlManager & instance()
Definition plantuml.cpp:156
void generatePlantUMLOutput(const QCString &baseName, const QCString &outDir, OutputFormat format)
Convert a PlantUML file to an image.
Definition plantuml.cpp:127

References CASE_NO, Config_getString, convertNameToFileName(), END_CASE, FlowChart(), FLOWLEN, flowList, PlantumlManager::generatePlantUMLOutput(), PlantumlManager::instance(), printPlantUmlNode(), PlantumlManager::PUML_SVG, QCString::size(), type, WHEN_NO, and PlantumlManager::writePlantUMLSource().

Referenced by writeFlowChart().

◆ startDot()

void FlowChart::startDot ( TextStream & t)
static

Definition at line 3073 of file vhdldocgen.cpp.

3074{
3075 t << " digraph G { \n";
3076 t << "rankdir=TB \n";
3077 t << "concentrate=true\n";
3078 t << "stylesheet=\"doxygen.css\"\n";
3079}

Referenced by writeFlowChart().

◆ writeEdge() [1/2]

void FlowChart::writeEdge ( TextStream & t,
const FlowChart & fl_from,
const FlowChart & fl_to,
int i )
static

Definition at line 3233 of file vhdldocgen.cpp.

3234{
3235 bool b=fl_from.type & STARTL;
3236 bool c=fl_to.type & STARTL;
3237
3238#ifdef DEBUGFLOW
3239 QCString s1(getNodeName(fl_from.id));
3240 QCString s2(getNodeName(fl_to.id));
3241 auto it = g_keyMap.find(s1.str());
3242 auto it1 = g_keyMap.find(s2.str());
3243 // checks if the link is connected to a valid node
3244 assert(it!=g_keyMap.end());
3245 assert(it1!=g_keyMap.end());
3246#endif
3247
3248 writeEdge(t,fl_from.id,fl_to.id,i,b,c);
3249}

References FlowChart(), getNodeName(), id, STARTL, QCString::str(), type, and writeEdge().

◆ writeEdge() [2/2]

void FlowChart::writeEdge ( TextStream & t,
int fl_from,
int fl_to,
int i,
bool bFrom = FALSE,
bool bTo = FALSE )
static

Definition at line 3251 of file vhdldocgen.cpp.

3252{
3253 QCString label,col;
3254
3255 if (i==0)
3256 {
3257 col=flowCol.yesNodeLink;
3258 label="yes";
3259 }
3260 else if (i==1)
3261 {
3262 col=flowCol.noNodeLink;
3263 label="no";
3264 }
3265 else
3266 {
3267 col=flowCol.textNodeLink;
3268 label="";
3269 }
3270
3271 t << "edge [color=\""+col+"\",label=\""+label+"\"]\n";
3272 t << getNodeName(fl_from);
3273 if (bFrom) t << ":s";
3274 t << "->";
3275 t << getNodeName(fl_to);
3276 if (bTo) t << ":n";
3277 t << "\n";
3278}

References flowCol, getNodeName(), and label.

Referenced by buildCommentNodes(), writeEdge(), and writeFlowLinks().

◆ writeFlowChart()

void FlowChart::writeFlowChart ( )
static

Definition at line 3086 of file vhdldocgen.cpp.

3087{
3088 // assert(VhdlDocGen::flowMember);
3089
3090 QCString ov = Config_getString(HTML_OUTPUT);
3091 QCString fileName = ov+"/flow_design.dot";
3092 std::ofstream f = Portable::openOutputStream(fileName);
3093 if (!f.is_open())
3094 {
3095 err("Cannot open file %s for writing\n",qPrint(fileName));
3096 return;
3097 }
3098 TextStream t(&f);
3099
3100 colTextNodes();
3101 // buildCommentNodes(t);
3102
3103#ifdef DEBUGFLOW
3104 printFlowTree();
3105#endif
3106
3107 if (!Config_getString(PLANTUML_JAR_PATH).isEmpty())
3108 {
3109 printUmlTree();
3110 delFlowList();
3111 t.flush();
3112 f.close();
3113 return;
3114 }
3115
3116 startDot(t);
3118 for (const auto &fll : flowList)
3119 {
3120 writeShape(t,fll);
3121 }
3122 writeFlowLinks(t);
3123
3125 delFlowList();
3126 t.flush();
3127 f.close();
3129}// writeFlowChart
static void printFlowTree()
static void startDot(TextStream &t)
static void delFlowList()
static void colTextNodes()
static void createSVG()
static void writeShape(TextStream &t, const FlowChart &fl)
static void buildCommentNodes(TextStream &t)
static void printUmlTree()
static void writeFlowLinks(TextStream &t)
static void endDot(TextStream &t)
std::ofstream openOutputStream(const QCString &name, bool append=false)
Definition portable.cpp:665

References buildCommentNodes(), colTextNodes(), Config_getString, createSVG(), delFlowList(), endDot(), err, flowList, TextStream::flush(), Portable::openOutputStream(), printFlowTree(), printUmlTree(), qPrint(), startDot(), writeFlowLinks(), and writeShape().

Referenced by VHDLOutlineParser::createFlow().

◆ writeFlowLinks()

void FlowChart::writeFlowLinks ( TextStream & t)
static

Definition at line 3443 of file vhdldocgen.cpp.

3444{
3445 size_t size=flowList.size();
3446 if (size<2) return;
3447
3448 // write start link
3449 writeEdge(t,flowList[0],flowList[1],2);
3450
3451 for (size_t j=0;j<size;j++)
3452 {
3453 const FlowChart &fll = flowList[j];
3454 int kind = fll.type;
3455 int stamp = fll.stamp;
3456 if (kind & EEND)
3457 {
3458 continue;
3459 }
3460
3461 if (kind & IFF)
3462 {
3463 writeEdge(t,fll,flowList[j+1],0);
3464 size_t z=getNextIfLink(fll,j);
3465 // assert(z>-1);
3466 writeEdge(t,fll,flowList[z],1);
3467 }
3468 else if (kind & LOOP_NO)
3469 {
3470 writeEdge(t,fll,flowList[j+1],2);
3471 continue;
3472 }
3473 else if (kind & (CASE_NO | FOR_NO | WHILE_NO))
3474 {
3475 if (kind & CASE_NO)
3476 {
3477 writeEdge(t,fll,flowList[j+1],2);
3478 continue;
3479 }
3480 else
3481 {
3482 writeEdge(t,fll,flowList[j+1],0);
3483 }
3484
3485 kind=END_LOOP;
3486 size_t z=findNode(j+1,fll.stamp,kind);
3487 z=getNextNode(z,flowList[z].stamp);
3488
3489 // assert(z>-1);
3490 writeEdge(t,fll,flowList[z],1);
3491 continue;
3492 }
3493 else if (kind & (TEXT_NO | VARIABLE_NO))
3494 {
3495 size_t z=getNextNode(j,stamp);
3496 writeEdge(t,fll,flowList[z],2);
3497 }
3498 else if (kind & WHEN_NO)
3499 {
3500 // default value
3501 if (qstricmp(fll.text.simplifyWhiteSpace(),"others")==0)
3502 {
3503 writeEdge(t,fll,flowList[j+1],2);
3504 continue;
3505 }
3506
3507
3508 writeEdge(t,fll,flowList[j+1],0);
3509 size_t u=findNode(j,stamp,WHEN_NO);
3510 size_t v=findNode(j,stamp-1,END_CASE);
3511
3512 if (u>0 && u<v)
3513 {
3514 writeEdge(t,fll,flowList[u],1);
3515 }
3516 else
3517 {
3518 writeEdge(t,fll,flowList[v],1);
3519 }
3520 }
3521 else if (kind & END_CASE)
3522 {
3523 size_t z=FlowChart::getNextNode(j,fll.stamp);
3524 writeEdge(t,fll,flowList[z],2);
3525 }
3526 else if (kind & END_LOOP)
3527 {
3528 size_t z=findPrevLoop(j,fll.stamp,true);
3529 writeEdge(t,fll,flowList[z],2);
3530 }
3531 else if (kind & RETURN_NO)
3532 {
3533 writeEdge(t,fll,flowList[size-1],2);
3534 }
3535 else if (kind & (EXIT_NO | NEXT_NO))
3536 {
3537 size_t z = 0;
3538 bool b = kind==NEXT_NO;
3539 if (!fll.exp.isEmpty())
3540 {
3541 writeEdge(t,fll,flowList[j+1],1);
3542 }
3543 if (!fll.label.isEmpty())
3544 {
3545 z=findLabel(j,fll.label);
3546 if (b)
3547 {
3548 writeEdge(t,fll,flowList[z],0);
3549 }
3550 else
3551 {
3553 z=getNextNode(z,flowList[z].stamp);
3554 writeEdge(t,fll,flowList[z],0);
3555 }
3556 continue;
3557 }
3558 else
3559 {
3560 if (b)
3561 {
3562 z=findPrevLoop(j,fll.stamp);
3563 writeEdge(t,fll,flowList[z],0);
3564 continue;
3565 }
3566 else
3567 {
3568 z =findNextLoop(j,fll.stamp-1);
3569 }
3570 z=getNextNode(z,flowList[z].stamp);
3571 }
3572 writeEdge(t,fll,flowList[z],0);
3573 }
3574 } //for
3575} //writeFlowLinks
static size_t findPrevLoop(size_t j, int stamp, bool endif=FALSE)
static size_t findLabel(size_t j, const QCString &)
static size_t findNextLoop(size_t j, int stamp)
static size_t getNextIfLink(const FlowChart &, size_t)
QCString simplifyWhiteSpace() const
return a copy of this string with leading and trailing whitespace removed and multiple whitespace cha...
Definition qcstring.cpp:185
#define EEND

References CASE_NO, EEND, END_CASE, END_LOOP, EXIT_NO, exp, findLabel(), findNextLoop(), findNode(), findPrevLoop(), FlowChart(), flowList, FOR_NO, getNextIfLink(), getNextNode(), IFF, QCString::isEmpty(), label, LOOP_NO, NEXT_NO, qstricmp(), RETURN_NO, QCString::simplifyWhiteSpace(), stamp, text, TEXT_NO, type, VARIABLE_NO, WHEN_NO, WHILE_NO, and writeEdge().

Referenced by writeFlowChart().

◆ writeShape()

void FlowChart::writeShape ( TextStream & t,
const FlowChart & fl )
static

Definition at line 3131 of file vhdldocgen.cpp.

3132{
3133 if (fl.type & EEND) return;
3134 QCString var;
3135 if (fl.type & LOOP)
3136 {
3137 var=" loop";
3138 }
3139 else if (fl.type & IFF)
3140 {
3141 var=" then";
3142 }
3143 else
3144 {
3145 var="";
3146 }
3147
3148 t << getNodeName(fl.id);
3149
3150#ifdef DEBUGFLOW
3151 QCString qq(getNodeName(fl.id));
3152 g_keyMap.emplace(qq.str(),fl.id);
3153#endif
3154
3155 bool dec=(fl.type & DECLN);
3156 bool exit=(fl.type & EXITNEXT);
3157 if (exit && !fl.exp.isEmpty())
3158 {
3159 dec=TRUE;
3160 }
3161 if (dec)
3162 {
3163 QCString exp=fl.exp;
3164 alignText(exp);
3165
3166 t << " [shape=diamond,style=filled,color=\"";
3167 t << flowCol.decisionNode;
3168 t << "\",label=\" ";
3169 QCString kl;
3170 if (exit) kl=fl.text+" ";
3171
3172 if (!fl.label.isEmpty())
3173 {
3174 kl+=fl.label+":"+exp+var;
3175 }
3176 else
3177 {
3178 kl+=exp+var;
3179 }
3180
3182 t << "\"]\n";
3183 }
3184 else if (fl.type & ENDCL)
3185 {
3186 QCString val=fl.text;
3187 t << " [shape=ellipse ,label=\""+val+"\"]\n";
3188 }
3189 else if (fl.type & STARTFIN)
3190 {
3191 QCString val=fl.text;
3192 t << "[shape=box , style=rounded label=<\n";
3193 t << "<TABLE BORDER=\"0\" CELLBORDER=\"0\" CELLSPACING=\"0\" CELLPADDING=\"0\" >\n ";
3194 t << "<TR><TD BGCOLOR=\"";
3195 t<< flowCol.startEndNode;
3196 t<< "\"> ";
3198 t << " </TD></TR></TABLE>>];";
3199 }
3200 else
3201 {
3202 if (fl.text.isEmpty()) return;
3203 bool isVar=(fl.type & FlowChart::VARIABLE_NO);
3204 QCString q=fl.text;
3205
3206 if (exit)
3207 {
3208 q+=" "+fl.label;
3209 }
3210
3211 int z=q.findRev("\n");
3212
3213 if (z==static_cast<int>(q.length())-1)
3214 {
3215 q=q.remove(z,2);
3216 }
3217 t << "[shape=none margin=0.1, label=<\n";
3218 t << "<TABLE BORDER=\"0\" CELLBORDER=\"1\" CELLSPACING=\"0\" CELLPADDING=\"2\" >\n ";
3219 if (isVar)
3220 {
3221 t << "<TR><TD BGCOLOR=\"" << flowCol.varNode << "\" > ";
3222 }
3223 else
3224 {
3225 t << "<TR><TD BGCOLOR=\"" << flowCol.textNode << "\" > ";
3226 }
3228 t << " </TD></TR></TABLE>>];";
3229 }
3230}
QCString & remove(size_t index, size_t len)
Definition qcstring.h:427
int findRev(char c, int index=-1, bool cs=TRUE) const
Definition qcstring.cpp:91
#define ENDCL
#define DECLN
void alignText(QCString &q)
#define STARTFIN
#define EXITNEXT

References alignCommentNode(), alignText(), DECLN, EEND, ENDCL, EXITNEXT, exp, QCString::findRev(), FlowChart(), flowCol, getNodeName(), id, IFF, QCString::isEmpty(), label, QCString::length(), LOOP, QCString::remove(), STARTFIN, QCString::str(), text, TRUE, type, and VARIABLE_NO.

Referenced by writeFlowChart().

Member Data Documentation

◆ exp

QCString FlowChart::exp
private

◆ id

int FlowChart::id = 0
private

Definition at line 305 of file vhdldocgen.h.

Referenced by buildCommentNodes(), printNode(), writeEdge(), and writeShape().

◆ label

◆ line

int FlowChart::line = 0
private

Definition at line 309 of file vhdldocgen.h.

Referenced by buildCommentNodes().

◆ stamp

int FlowChart::stamp = 0
private

◆ text

QCString FlowChart::text
private

◆ type


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