19
19
#include < iterator>
20
20
#include < unordered_map>
21
21
#include < string>
22
+ #include < regex>
22
23
23
24
#include < ctype.h>
24
- #include < qregexp.h>
25
25
#include " md5.h"
26
26
#include < stdio.h>
27
27
#include < stdlib.h>
@@ -164,7 +164,7 @@ static bool matchExcludedSymbols(const char *name)
164
164
{
165
165
const StringVector &exclSyms = Config_getList (EXCLUDE_SYMBOLS);
166
166
if (exclSyms.empty ()) return FALSE ; // nothing specified
167
- QCString symName = name;
167
+ std::string symName = name;
168
168
for (const auto &pat : exclSyms)
169
169
{
170
170
QCString pattern = pat.c_str ();
@@ -176,15 +176,15 @@ static bool matchExcludedSymbols(const char *name)
176
176
pattern=pattern.left (pattern.length ()-1 ),forceEnd=TRUE ;
177
177
if (pattern.find (' *' )!=-1 ) // wildcard mode
178
178
{
179
- QRegExp re (substitute (pattern," *" ," .*" ),TRUE );
180
- int pl;
181
- int i = re.match (symName,0 ,&pl);
182
- // printf(" %d = re.match(%s) pattern=%s pl=%d len=%d\n",i,symName.data(),pattern.data(),pl,symName.length());
183
- if (i!=-1 ) // wildcard match
179
+ std::regex re (substitute (pattern," *" ," .*" ).str ());
180
+ std::sregex_iterator it (symName.begin (),symName.end (),re);
181
+ std::sregex_iterator end;
182
+ if (it!=end) // wildcard match
184
183
{
185
- uint ui=(uint )i;
186
- uint sl=symName.length ();
187
- // check if it is a whole word match
184
+ const auto &match = *it;
185
+ size_t ui = match.position ();
186
+ size_t pl = match.length ();
187
+ size_t sl = symName.length ();
188
188
if ((ui==0 || pattern.at (0 )==' *' || (!isId (symName.at (ui-1 )) && !forceStart)) &&
189
189
(ui+pl==sl || pattern.at (pattern.length ()-1 )==' *' || (!isId (symName.at (ui+pl)) && !forceEnd))
190
190
)
@@ -196,12 +196,12 @@ static bool matchExcludedSymbols(const char *name)
196
196
}
197
197
else if (!pattern.isEmpty ()) // match words
198
198
{
199
- int i = symName.find (pattern);
200
- if (i!=- 1 ) // we have a match!
199
+ size_t i = symName.find (pattern);
200
+ if (i!=std::string::npos ) // we have a match!
201
201
{
202
- uint ui=( uint ) i;
203
- uint pl=pattern.length ();
204
- uint sl=symName.length ();
202
+ size_t ui=i;
203
+ size_t pl=pattern.length ();
204
+ size_t sl=symName.length ();
205
205
// check if it is a whole word match
206
206
if ((ui==0 || (!isId (symName.at (ui-1 )) && !forceStart)) &&
207
207
(ui+pl==sl || (!isId (symName.at (ui+pl)) && !forceEnd))
@@ -1212,137 +1212,141 @@ void DefinitionImpl::_writeSourceRefList(OutputList &ol,const char *scopeName,
1212
1212
ol.parseText (text);
1213
1213
ol.docify (" " );
1214
1214
1215
- QCString ldefLine=theTranslator->trWriteList ((int )members.size ());
1216
-
1217
- QRegExp marker (" @[0-9]+" );
1218
- uint index =0 ;
1219
- int matchLen;
1220
- int newIndex;
1221
- // now replace all markers in inheritLine with links to the classes
1222
- while ((newIndex=marker.match (ldefLine,index ,&matchLen))!=-1 )
1215
+ std::string ldefLine=theTranslator->trWriteList ((int )members.size ()).str ();
1216
+ static std::regex marker (" @[[:digit:]]+" );
1217
+ std::sregex_iterator it (ldefLine.begin (),ldefLine.end (),marker);
1218
+ std::sregex_iterator end;
1219
+ size_t index =0 ;
1220
+ // now replace all markers in ldefLine with links to the members
1221
+ for ( ; it!=end ; ++it)
1223
1222
{
1224
- bool ok;
1225
- ol.parseText (ldefLine.mid (index ,(uint )newIndex-index ));
1226
- uint entryIndex = ldefLine.mid (newIndex+1 ,matchLen-1 ).toUInt (&ok);
1227
- const MemberDef *md=members.at (entryIndex);
1228
- if (ok && md)
1223
+ const auto &match = *it;
1224
+ size_t newIndex = match.position ();
1225
+ size_t matchLen = match.length ();
1226
+ ol.parseText (ldefLine.substr (index ,newIndex-index ));
1227
+ unsigned long entryIndex = std::stoul (match.str ().substr (1 ));
1228
+ if (entryIndex<(unsigned long )members.size ())
1229
1229
{
1230
- QCString scope=md->getScopeString ();
1231
- QCString name=md->name ();
1232
- // printf("class=%p scope=%s scopeName=%s\n",md->getClassDef(),scope.data(),scopeName);
1233
- if (!scope.isEmpty () && scope!=scopeName)
1234
- {
1235
- name.prepend (scope+getLanguageSpecificSeparator (m_impl->lang ));
1236
- }
1237
- if (!md->isObjCMethod () &&
1238
- (md->isFunction () || md->isSlot () ||
1239
- md->isPrototype () || md->isSignal ()
1240
- )
1241
- )
1242
- {
1243
- name+=" ()" ;
1244
- }
1245
- // DefinitionImpl *d = md->getOutputFileBase();
1246
- // if (d==Doxygen::globalScope) d=md->getBodyDef();
1247
- if (sourceBrowser &&
1248
- !(md->isLinkable () && !refLinkSource) &&
1249
- md->getStartBodyLine ()!=-1 &&
1250
- md->getBodyDef ()
1251
- )
1230
+ const MemberDef *md=members[entryIndex];
1231
+ if (md)
1252
1232
{
1253
- // printf("md->getBodyDef()=%p global=%p\n",md->getBodyDef(),Doxygen::globalScope);
1254
- // for HTML write a real link
1255
- ol.pushGeneratorState ();
1256
- // ol.disableAllBut(OutputGenerator::Html);
1257
-
1258
- ol.disable (OutputGenerator::Man);
1259
- if (!latexSourceCode)
1260
- {
1261
- ol.disable (OutputGenerator::Latex);
1262
- }
1263
- if (!docbookSourceCode)
1233
+ QCString scope=md->getScopeString ();
1234
+ QCString name=md->name ();
1235
+ // printf("class=%p scope=%s scopeName=%s\n",md->getClassDef(),scope.data(),scopeName);
1236
+ if (!scope.isEmpty () && scope!=scopeName)
1264
1237
{
1265
- ol. disable (OutputGenerator::Docbook );
1238
+ name. prepend (scope+ getLanguageSpecificSeparator (m_impl-> lang ) );
1266
1239
}
1267
- if (!rtfSourceCode)
1240
+ if (!md->isObjCMethod () &&
1241
+ (md->isFunction () || md->isSlot () ||
1242
+ md->isPrototype () || md->isSignal ()
1243
+ )
1244
+ )
1268
1245
{
1269
- ol. disable (OutputGenerator::RTF) ;
1246
+ name+= " () " ;
1270
1247
}
1271
- const int maxLineNrStr = 10 ;
1272
- char anchorStr[maxLineNrStr];
1273
- qsnprintf (anchorStr,maxLineNrStr," l%05d" ,md->getStartBodyLine ());
1274
- // printf("Write object link to %s\n",md->getBodyDef()->getSourceFileBase().data());
1275
- ol.writeObjectLink (0 ,md->getBodyDef ()->getSourceFileBase (),anchorStr,name);
1276
- ol.popGeneratorState ();
1277
-
1278
- // for the other output formats just mention the name
1279
- ol.pushGeneratorState ();
1280
- ol.disable (OutputGenerator::Html);
1281
- if (latexSourceCode)
1248
+ // DefinitionImpl *d = md->getOutputFileBase();
1249
+ // if (d==Doxygen::globalScope) d=md->getBodyDef();
1250
+ if (sourceBrowser &&
1251
+ !(md->isLinkable () && !refLinkSource) &&
1252
+ md->getStartBodyLine ()!=-1 &&
1253
+ md->getBodyDef ()
1254
+ )
1282
1255
{
1283
- ol.disable (OutputGenerator::Latex);
1284
- }
1285
- if (docbookSourceCode)
1286
- {
1287
- ol.disable (OutputGenerator::Docbook);
1288
- }
1289
- if (rtfSourceCode)
1290
- {
1291
- ol.disable (OutputGenerator::RTF);
1292
- }
1293
- ol.docify (name);
1294
- ol.popGeneratorState ();
1295
- }
1296
- else if (md->isLinkable () /* && d && d->isLinkable()*/ )
1297
- {
1298
- // for HTML write a real link
1299
- ol.pushGeneratorState ();
1300
- // ol.disableAllBut(OutputGenerator::Html);
1301
- ol.disable (OutputGenerator::Man);
1302
- if (!latexSourceCode)
1303
- {
1304
- ol.disable (OutputGenerator::Latex);
1305
- }
1306
- if (!docbookSourceCode)
1307
- {
1308
- ol.disable (OutputGenerator::Docbook);
1256
+ // printf("md->getBodyDef()=%p global=%p\n",md->getBodyDef(),Doxygen::globalScope);
1257
+ // for HTML write a real link
1258
+ ol.pushGeneratorState ();
1259
+ // ol.disableAllBut(OutputGenerator::Html);
1260
+
1261
+ ol.disable (OutputGenerator::Man);
1262
+ if (!latexSourceCode)
1263
+ {
1264
+ ol.disable (OutputGenerator::Latex);
1265
+ }
1266
+ if (!docbookSourceCode)
1267
+ {
1268
+ ol.disable (OutputGenerator::Docbook);
1269
+ }
1270
+ if (!rtfSourceCode)
1271
+ {
1272
+ ol.disable (OutputGenerator::RTF);
1273
+ }
1274
+ const int maxLineNrStr = 10 ;
1275
+ char anchorStr[maxLineNrStr];
1276
+ qsnprintf (anchorStr,maxLineNrStr," l%05d" ,md->getStartBodyLine ());
1277
+ // printf("Write object link to %s\n",md->getBodyDef()->getSourceFileBase().data());
1278
+ ol.writeObjectLink (0 ,md->getBodyDef ()->getSourceFileBase (),anchorStr,name);
1279
+ ol.popGeneratorState ();
1280
+
1281
+ // for the other output formats just mention the name
1282
+ ol.pushGeneratorState ();
1283
+ ol.disable (OutputGenerator::Html);
1284
+ if (latexSourceCode)
1285
+ {
1286
+ ol.disable (OutputGenerator::Latex);
1287
+ }
1288
+ if (docbookSourceCode)
1289
+ {
1290
+ ol.disable (OutputGenerator::Docbook);
1291
+ }
1292
+ if (rtfSourceCode)
1293
+ {
1294
+ ol.disable (OutputGenerator::RTF);
1295
+ }
1296
+ ol.docify (name);
1297
+ ol.popGeneratorState ();
1309
1298
}
1310
- if (!rtfSourceCode )
1299
+ else if (md-> isLinkable () /* && d && d->isLinkable() */ )
1311
1300
{
1312
- ol.disable (OutputGenerator::RTF);
1313
- }
1301
+ // for HTML write a real link
1302
+ ol.pushGeneratorState ();
1303
+ // ol.disableAllBut(OutputGenerator::Html);
1304
+ ol.disable (OutputGenerator::Man);
1305
+ if (!latexSourceCode)
1306
+ {
1307
+ ol.disable (OutputGenerator::Latex);
1308
+ }
1309
+ if (!docbookSourceCode)
1310
+ {
1311
+ ol.disable (OutputGenerator::Docbook);
1312
+ }
1313
+ if (!rtfSourceCode)
1314
+ {
1315
+ ol.disable (OutputGenerator::RTF);
1316
+ }
1314
1317
1315
- ol.writeObjectLink (md->getReference (),
1316
- md->getOutputFileBase (),
1317
- md->anchor (),name);
1318
- ol.popGeneratorState ();
1318
+ ol.writeObjectLink (md->getReference (),
1319
+ md->getOutputFileBase (),
1320
+ md->anchor (),name);
1321
+ ol.popGeneratorState ();
1319
1322
1320
- // for the other output formats just mention the name
1321
- ol.pushGeneratorState ();
1322
- ol.disable (OutputGenerator::Html);
1323
- if (latexSourceCode)
1324
- {
1325
- ol.disable (OutputGenerator::Latex);
1326
- }
1327
- if (docbookSourceCode)
1328
- {
1329
- ol.disable (OutputGenerator::Docbook);
1323
+ // for the other output formats just mention the name
1324
+ ol.pushGeneratorState ();
1325
+ ol.disable (OutputGenerator::Html);
1326
+ if (latexSourceCode)
1327
+ {
1328
+ ol.disable (OutputGenerator::Latex);
1329
+ }
1330
+ if (docbookSourceCode)
1331
+ {
1332
+ ol.disable (OutputGenerator::Docbook);
1333
+ }
1334
+ if (rtfSourceCode)
1335
+ {
1336
+ ol.disable (OutputGenerator::RTF);
1337
+ }
1338
+ ol.docify (name);
1339
+ ol.popGeneratorState ();
1330
1340
}
1331
- if (rtfSourceCode)
1341
+ else
1332
1342
{
1333
- ol.disable (OutputGenerator::RTF );
1343
+ ol.docify (name );
1334
1344
}
1335
- ol.docify (name);
1336
- ol.popGeneratorState ();
1337
- }
1338
- else
1339
- {
1340
- ol.docify (name);
1341
1345
}
1342
1346
}
1343
- index =( uint ) newIndex+matchLen;
1347
+ index =newIndex+matchLen;
1344
1348
}
1345
- ol.parseText (ldefLine.right (ldefLine. length ()- index ));
1349
+ ol.parseText (ldefLine.substr ( index ));
1346
1350
ol.writeString (" ." );
1347
1351
ol.endParagraph ();
1348
1352
}
@@ -1850,8 +1854,7 @@ QCString abbreviate(const char *s,const char *name)
1850
1854
const StringVector &briefDescAbbrev = Config_getList (ABBREVIATE_BRIEF);
1851
1855
for (const auto &p : briefDescAbbrev)
1852
1856
{
1853
- QCString str = p.c_str ();
1854
- str.replace (QRegExp (" \\ $name" ), scopelessName); // replace $name with entity name
1857
+ QCString str = substitute (p.c_str ()," $name" ,scopelessName); // replace $name with entity name
1855
1858
str += " " ;
1856
1859
stripWord (result,str);
1857
1860
}
0 commit comments