2828
2929static std::mutex g_PlantUmlMutex;
3030
31- std::vector<QCString> PlantumlManager::writePlantUMLSource (const QCString &outDirArg,const QCString &fileName,
31+ StringVector PlantumlManager::writePlantUMLSource (const QCString &outDirArg,const QCString &fileName,
3232 const QCString &content,OutputFormat format, const QCString &engine,
3333 const QCString &srcFile,int srcLine,bool inlineCode)
3434{
35- std::vector<QCString> baseNameVector;
35+ StringVector baseNameVector;
3636 QCString baseName;
3737 QCString puName;
3838 QCString imgName;
@@ -83,60 +83,37 @@ std::vector<QCString> PlantumlManager::writePlantUMLSource(const QCString &outDi
8383 locEngine += c;
8484 text+=c;
8585 }
86- QCString line;
87- // get everything till end or endOfLine
88- if (c && (c!=' \n ' ))
89- {
90- line += c;
91- while ((c=*p++) && (c!=' \n ' )) line+=c;
92- line = line.stripWhiteSpace ();
93- }
9486 QCString inpName;
9587 QCString rest;
96- // REGEXP (<fn>)(<ext>?)(<rest>)
97- static const reg::Ex re_new0 (R"( (([A-Za-z0-9_][A-Za-z0-9_-]*)))" );
98- static const reg::Ex re_new1 (R"( (([A-Za-z0-9_][A-Za-z0-9_-]*)(\.[A-Za-z0-9_][A-Za-z0-9_-]*)))" );
99- static const reg::Ex re_new2 (R"( (([A-Za-z0-9_][A-Za-z0-9_-]*)(\.[A-Za-z0-9_][A-Za-z0-9_-]*)(.*)))" );
100- static const reg::Ex re_new3 (R"( ([A-Za-z0-9_][A-Za-z0-9_-]*)(.*))" );
101- // std::string_view txtStr = line.view();
102- if (!line.isEmpty ())
88+
89+ // skip leading whitespace
90+ if (*p && (c==' ' || c==' \t ' ))
10391 {
104- reg::Match match0;
105- reg::Match match1;
106- reg::Match match2;
107- reg::Match match3;
108- bool matchSet = false ;
109- if (matchSet = reg::match (line.str (),match0,re_new0))
110- {
111- inpName = match0[1 ].str ();
112- }
113- else if (matchSet = reg::match (line.str (),match1,re_new1))
114- {
115- inpName = match1[1 ].str ();
116- }
117- else if (matchSet = reg::match (line.str (),match2,re_new2))
118- {
119- inpName = match2[1 ].str ();
120- rest = match2[3 ].str ();
121- }
122- else if (matchSet = reg::match (line.str (),match3,re_new3))
123- {
124- inpName = match3[1 ].str ();
125- rest = match3[2 ].str ();
126- }
127- if (matchSet)
128- {
129- generatePlantUmlFileNames (inpName,format,outDir,baseName,puName,imgName);
130- }
131- else
132- {
133- generatePlantUmlFileNames (QCString (),format,outDir,baseName,puName,imgName);
134- }
92+ while ((c=*p++) && (c==' ' || c==' \t ' )) {}
13593 }
136- else
94+ // get everything till end or endOfLine, and split into inpName (without extension) and rest
95+ enum State { InName, InExt, InRest };
96+ State state = InName;
97+ while (*p && c!=' \n ' )
13798 {
138- generatePlantUmlFileNames (QCString (),format,outDir,baseName,puName,imgName);
99+ switch (state)
100+ {
101+ case InName: // looking for the name part
102+ if (isId (c) || c==' -' ) inpName+=c;
103+ else if (c==' .' ) state=InExt;
104+ else rest+=c, state=InRest;
105+ break ;
106+ case InExt: // skipping over extension part
107+ if (!isId (c) && c!=' -' ) rest+=c, state=InRest;
108+ break ;
109+ case InRest: // gather rest until new line
110+ rest+=c;
111+ break ;
112+ }
113+ c = *p++;
139114 }
115+ // printf("inpName='%s' rest='%s'\n",qPrint(inpName),qPrint(rest));
116+ generatePlantUmlFileNames (inpName,format,outDir,baseName,puName,imgName);
140117
141118 // insert the image name
142119 text+=' ' ;
@@ -161,7 +138,7 @@ std::vector<QCString> PlantumlManager::writePlantUMLSource(const QCString &outDi
161138 Debug::print (Debug::Plantuml,0 ," *** writePlantUMLSource generateType: {}\n " ,generateType);
162139 PlantumlManager::instance ().insert (generateType.str (),puName.str (),outDir,format,text,srcFile,srcLine);
163140 Debug::print (Debug::Plantuml,0 ," *** writePlantUMLSource generateType: {}\n " ,generateType);
164- baseNameVector.emplace_back (baseName);
141+ baseNameVector.push_back (baseName. str () );
165142 text.clear ();
166143 }
167144 }
@@ -182,7 +159,7 @@ std::vector<QCString> PlantumlManager::writePlantUMLSource(const QCString &outDi
182159 Debug::print (Debug::Plantuml,0 ," *** writePlantUMLSource generateType: {}\n " ,generateType);
183160 PlantumlManager::instance ().insert (generateType.str (),puName.str (),outDir,format,text,srcFile,srcLine);
184161 Debug::print (Debug::Plantuml,0 ," *** writePlantUMLSource generateType: {}\n " ,generateType);
185- baseNameVector.emplace_back (baseName);
162+ baseNameVector.push_back (baseName. str () );
186163 }
187164
188165 return baseNameVector;
0 commit comments