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 2862 of file vhdldocgen.cpp.

2863{
2865
2866 if (typ & STARTL)
2867 {
2868 ifcounter++;
2869 }
2870
2871 text=t;
2872 exp=ex;
2873 type=typ;
2874 label=lab;
2875
2876 if (typ & (ELSE_NO | ELSIF_NO))
2877 {
2878 stamp--;
2879 }
2880
2881 if (typ & (START_NO | END_NO | VARIABLE_NO))
2882 {
2883 stamp=0;
2884 }
2885
2886 id=nodeCounter++;
2887}
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 2889 of file vhdldocgen.cpp.

2890{
2891 if (!VhdlDocGen::getFlowMember()) return;
2892
2893 QCString typeString(text);
2894 QCString expression(exp);
2895
2896
2897 if (!text.isEmpty())
2898 {
2899 typeString=substitute(typeString,";","\n");
2900 }
2901
2902 if (!exp.isEmpty())
2903 {
2904 expression=substitute(expression,"\"","\\\"");
2905 }
2906
2907 if (type & VARIABLE_NO)
2908 {
2909 // Ignore the empty section of the VHDL variable definition.
2910 // This is section between `process` and `begin` keywords, where any source text is missing, probably a bug in the VHDL source parser.
2911 if(text.isEmpty()) return;
2912
2913 flowList.insert(flowList.begin(),FlowChart(type,typeString,expression,label));
2914 flowList.front().line=1; // TODO: use getLine(); of the parser
2915 }
2916 else if (type & START_NO)
2917 {
2918 flowList.insert(flowList.begin(),FlowChart(type,typeString,expression,label));
2919 flowList.front().line=1; // TODO: use getLine(); of the parser
2920 }
2921 else
2922 {
2923 flowList.emplace_back(type,typeString,expression,label);
2924 flowList.back().line=1; // TODO: use getLine(); of the parser
2925 }
2926}
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 2719 of file vhdldocgen.cpp.

2720{
2721 size_t max=0;
2722 QCString s;
2723 StringVector ql=split(com.str(),"\n");
2724 for (size_t j=0;j<ql.size();j++)
2725 {
2726 s=ql[j];
2727 if (max<s.length()) max=s.length();
2728 }
2729
2730 s=ql.back();
2731 int diff=static_cast<int>(max-s.length());
2732
2733 QCString n;
2734 if (diff>0)
2735 {
2736 n.fill(' ',2*diff);
2737 n.append(".");
2738 s+=n;
2739 ql.pop_back();
2740 ql.push_back(s.str());
2741 }
2742
2743 for (size_t j=0;j<ql.size();j++)
2744 {
2745 s=ql[j];
2746 if (j<ql.size()-1)
2747 {
2748 s+="\n";
2749 }
2750 FlowChart::codify(t,s);
2751 }
2752}
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:537
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:7042

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 3277 of file vhdldocgen.cpp.

3278{
3279 size_t index=al.size();
3280 if (index==0) return;
3281
3282 size_t len=q.length()+VhdlDocGen::getFlowMember()->name().length();
3283 QCString prev,temp;
3284 prev.fill(' ',static_cast<int>(len)+1);
3285
3286 q+="\n";
3287 for (const Argument &arg : al)
3288 {
3289 QCString attl=arg.defval+" ";
3290 attl+=arg.name+" ";
3291
3292 if (!isFunc)
3293 {
3294 attl+=arg.attrib+" ";
3295 }
3296 else
3297 {
3298 attl+=" in ";
3299 }
3300 attl+=arg.type;
3301 if (--index) attl+=",\n"; else attl+="\n";
3302
3303 attl.prepend(prev);
3304 temp+=attl;
3305 }
3306
3307 q+=temp;
3308}
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 2755 of file vhdldocgen.cpp.

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

2841{
2842 if (!str.isEmpty())
2843 {
2844 const char *p=str.data();
2845 while (*p)
2846 {
2847 char c=*p++;
2848 switch(c)
2849 {
2850 case '<': t << "&lt;"; break;
2851 case '>': t << "&gt;"; break;
2852 case '&': t << "&amp;"; break;
2853 case '\'': t << "&#39;"; break;
2854 case '"': t << "&quot;"; break;
2855 case '\n': t <<"<BR ALIGN=\"LEFT\"/>"; break;
2856 default: t << c; break;
2857 }
2858 }
2859 }
2860}//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 2655 of file vhdldocgen.cpp.

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

3015{
3016 return VhdlDocGen::getFlowMember()->name();
3017}

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

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

◆ createSVG()

void FlowChart::createSVG ( )
static

Definition at line 3048 of file vhdldocgen.cpp.

3049{
3050 QCString qcs("/");
3051 QCString ov = Config_getString(HTML_OUTPUT);
3052
3054
3055 //const MemberDef *m=VhdlDocGen::getFlowMember();
3056 //if (m)
3057 // fprintf(stderr,"\n creating flowchart : %s %s in file %s \n",theTranslator->trVhdlType(m->getMemberSpecifiers(),TRUE),qPrint(m->name()),qPrint(m->getFileDef()->name()));
3058
3059 QCString dir=" -o \""+ov+qcs+"\"";
3060 ov+="/flow_design.dot";
3061
3062 QCString vlargs="-Tsvg \""+ov+"\" "+dir ;
3063
3065 {
3066 err("could not create dot file\n");
3067 }
3068}
static QCString verifiedDotPath
Definition doxygen.h:139
static QCString convertNameToFileName()
#define Config_getString(name)
Definition config.h:32
#define err(fmt,...)
Definition message.h:127
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 2712 of file vhdldocgen.cpp.

2713{
2714 ifcounter=0;
2715 nodeCounter=0;
2716 flowList.clear();
2717}

References flowList, ifcounter, and nodeCounter.

Referenced by writeFlowChart().

◆ endDot()

void FlowChart::endDot ( TextStream & t)
static

Definition at line 3078 of file vhdldocgen.cpp.

3079{
3080 t << " } \n";
3081}

Referenced by writeFlowChart().

◆ findLabel()

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

Definition at line 3350 of file vhdldocgen.cpp.

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

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

Referenced by writeFlowLinks().

◆ findNextLoop()

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

Definition at line 3310 of file vhdldocgen.cpp.

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

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

Referenced by writeFlowLinks().

◆ findNode() [1/2]

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

Definition at line 3364 of file vhdldocgen.cpp.

3365{
3366 for (size_t j=index+1; j<flowList.size(); j++)
3367 {
3368 const FlowChart &flo = flowList[j];
3369 if (flo.type==type && flo.stamp==stamp)
3370 {
3371 return j;
3372 }
3373 }
3374 return 0;
3375}// 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, FALSE, label, stamp, text, and type.

◆ findPrevLoop()

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

Definition at line 3327 of file vhdldocgen.cpp.

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

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 3418 of file vhdldocgen.cpp.

3419{
3420 int stamp=fl.stamp;
3421 size_t start = index+1;
3422 size_t endifNode = findNode(start,stamp,ENDIF_NO);
3423 size_t elseifNode = findNode(start,stamp,ELSIF_NO);
3424 size_t elseNode = findNode(start,stamp,ELSE_NO);
3425
3426 if (elseifNode>0 && elseifNode<endifNode)
3427 {
3428 return elseifNode;
3429 }
3430
3431 if (elseNode>0 && elseNode<endifNode)
3432 {
3433 return elseNode+1;
3434 }
3435
3436 stamp=flowList[endifNode].stamp;
3437 return getNextNode(endifNode,stamp);
3438}
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 3377 of file vhdldocgen.cpp.

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

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 2705 of file vhdldocgen.cpp.

2706{
2707 QCString node;
2708 node.setNum(n);
2709 return node.prepend("node");
2710}
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 3019 of file vhdldocgen.cpp.

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

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 2928 of file vhdldocgen.cpp.

2929{
2930 if (!VhdlDocGen::getFlowMember()) return;
2931 ifcounter--;
2932}

References VhdlDocGen::getFlowMember(), and ifcounter.

◆ printFlowTree()

void FlowChart::printFlowTree ( )
static

Definition at line 2647 of file vhdldocgen.cpp.

2648{
2649 for (const auto &flowChart : flowList)
2650 {
2651 printNode(flowChart);
2652 }
2653}
static void printNode(const FlowChart &n)

References flowList, and printNode().

Referenced by writeFlowChart().

◆ printNode()

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

Definition at line 2587 of file vhdldocgen.cpp.

2588{
2589 QCString ui="-";
2590 std::string q;
2591 std::string t;
2592
2593 ui.fill('-',255);
2594
2595 if (flo.type & STARTL)
2596 {
2597 if (flo.stamp>0)
2598 {
2599 q=ui.left(2*flo.stamp).str();
2600 }
2601 else
2602 {
2603 q=" ";
2604 }
2605 QCString nn=flo.exp.stripWhiteSpace();
2606 printf("\nYES: %s%s[%d,%d]",qPrint(q),qPrint(nn),flo.stamp,flo.id);
2607 }
2608 else
2609 {
2610 if (flo.type & COMMENT_NO)
2611 {
2612 t=flo.label.str();
2613 }
2614 else
2615 {
2616 t=flo.text.str();
2617 }
2618 static const reg::Ex ep(R"(\s)");
2619 t = reg::replace(t,ep,std::string());
2620 if (t.empty())
2621 {
2622 t=" ";
2623 }
2624 if (flo.stamp>0)
2625 {
2626 q=ui.left(2*flo.stamp).str();
2627 }
2628 else
2629 {
2630 q=" ";
2631 }
2632 if (flo.type & EMPTNODE)
2633 {
2634 printf("\n NO: %s%s[%d,%d]",q.c_str(),FlowChart::getNodeType(flo.type),flo.stamp,flo.id);
2635 }
2636 else if (flo.type & COMMENT_NO)
2637 {
2638 printf("\n NO: %s%s[%d,%d]",t.c_str(),FlowChart::getNodeType(flo.type),flo.stamp,flo.id);
2639 }
2640 else
2641 {
2642 printf("\n NO: %s[%d,%d]",t.c_str(),flo.stamp,flo.id);
2643 }
2644 }
2645}
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
const char * qPrint(const char *s)
Definition qcstring.h:672
#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 2934 of file vhdldocgen.cpp.

2935{
2936 QCString t;
2937 QCString exp=flo.exp.stripWhiteSpace();
2938 QCString text=flo.text.stripWhiteSpace();
2939 switch (flo.type)
2940 {
2941 case START_NO: t=":"+text+"|"; break;
2942 case IF_NO : t="\nif ("+exp+") then (yes)"; break;
2943 case ELSIF_NO: t="\nelseif ("+exp+") then (yes)"; break;
2944 case ELSE_NO: t="\nelse"; break;
2945 case CASE_NO: t="\n:"+exp+";"; break;
2946 case WHEN_NO: t="\n";
2947 if (!ca) t+="else";
2948 t+="if ("+exp+") then (yes)";
2949 break;
2950 case EXIT_NO: break;
2951 case END_NO: if (text.contains(" function")==0) t="\n:"+text+";";
2952 break;
2953 case TEXT_NO: t="\n:"+text+"]"; break;
2954 case ENDIF_NO: t="\nendif"; break;
2955 case FOR_NO: t="\nwhile ("+exp+") is (yes)"; break;
2956 case WHILE_NO: t="\nwhile ("+exp+") is (yes)"; break;
2957 case END_LOOP: t="\nendwhile"; break;
2958 case END_CASE: t="\nendif\n:end case;"; break;
2959 case VARIABLE_NO:t="\n:"+text+";"; break;
2960 case RETURN_NO: t="\n:"+text+";";
2961 if (!endL) t+="\nstop";
2962 break;
2963 case LOOP_NO: t="\nwhile (infinite loop)"; break;
2964 case NEXT_NO: break;
2965 case EMPTY_NO: break;
2966 case COMMENT_NO: t="\n note left \n "+flo.label+"\nend note \n"; break;
2967 case BEGIN_NO: t="\n:begin;"; break;
2968 default: assert(false); break;
2969 }
2970 return t;
2971}
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 2973 of file vhdldocgen.cpp.

2974{
2975 int caseCounter = 0;
2976 int whenCounter = 0;
2977
2978 QCString qcs;
2979 size_t size=flowList.size();
2980 for (size_t j=0;j<size;j++)
2981 {
2982 bool endList = j==FLOWLEN;
2983 const FlowChart &flo = flowList[j];
2984 if (flo.type==CASE_NO)
2985 {
2986 caseCounter++;
2987 whenCounter=0;
2988 }
2989
2990 if (flo.type==END_CASE)
2991 {
2992 caseCounter--;
2993 }
2994
2995 bool ca = (caseCounter>0 && whenCounter==0);
2996
2997 qcs+=printPlantUmlNode(flo,ca,endList);
2998
2999 if (flo.type==WHEN_NO)
3000 {
3001 whenCounter++;
3002 }
3003
3004 }
3005 qcs+="\n";
3006
3007 QCString htmlOutDir = Config_getString(HTML_OUTPUT);
3008
3009 QCString n=convertNameToFileName();
3010 n=PlantumlManager::instance().writePlantUMLSource(htmlOutDir,n,qcs,PlantumlManager::PUML_SVG,"uml",n,1,true);
3012}
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, type, WHEN_NO, and PlantumlManager::writePlantUMLSource().

Referenced by writeFlowChart().

◆ startDot()

void FlowChart::startDot ( TextStream & t)
static

Definition at line 3070 of file vhdldocgen.cpp.

3071{
3072 t << " digraph G { \n";
3073 t << "rankdir=TB \n";
3074 t << "concentrate=true\n";
3075 t << "stylesheet=\"doxygen.css\"\n";
3076}

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 3230 of file vhdldocgen.cpp.

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

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 3248 of file vhdldocgen.cpp.

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

References flowCol, getNodeName(), and label.

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

◆ writeFlowChart()

void FlowChart::writeFlowChart ( )
static

Definition at line 3083 of file vhdldocgen.cpp.

3084{
3085 // assert(VhdlDocGen::flowMember);
3086
3087 QCString ov = Config_getString(HTML_OUTPUT);
3088 QCString fileName = ov+"/flow_design.dot";
3089 std::ofstream f = Portable::openOutputStream(fileName);
3090 if (!f.is_open())
3091 {
3092 err("Cannot open file {} for writing\n",fileName);
3093 return;
3094 }
3095 TextStream t(&f);
3096
3097 colTextNodes();
3098 // buildCommentNodes(t);
3099
3100#ifdef DEBUGFLOW
3101 printFlowTree();
3102#endif
3103
3104 if (!Config_getString(PLANTUML_JAR_PATH).isEmpty())
3105 {
3106 printUmlTree();
3107 delFlowList();
3108 t.flush();
3109 f.close();
3110 return;
3111 }
3112
3113 startDot(t);
3115 for (const auto &fll : flowList)
3116 {
3117 writeShape(t,fll);
3118 }
3119 writeFlowLinks(t);
3120
3122 delFlowList();
3123 t.flush();
3124 f.close();
3126}// 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(), startDot(), writeFlowLinks(), and writeShape().

Referenced by VHDLOutlineParser::createFlow().

◆ writeFlowLinks()

void FlowChart::writeFlowLinks ( TextStream & t)
static

Definition at line 3440 of file vhdldocgen.cpp.

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

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