17
17
18
18
#include < cstdio>
19
19
#include < algorithm>
20
+ #include < regex>
20
21
21
22
#include < qfile.h>
22
23
#include < qfileinfo.h>
23
- #include < qregexp.h>
24
24
#include " classdef.h"
25
25
#include " classlist.h"
26
26
#include " entry.h"
@@ -1630,18 +1630,22 @@ void ClassDefImpl::writeInheritanceGraph(OutputList &ol) const
1630
1630
ol.startParagraph ();
1631
1631
// parseText(ol,theTranslator->trInherits()+" ");
1632
1632
1633
- QCString inheritLine = theTranslator->trInheritsList ((int )m_impl->inherits .size ());
1634
- QRegExp marker (" @[0-9]+" );
1635
- int index=0 ,newIndex,matchLen;
1633
+ std::string inheritLine = theTranslator->trInheritsList ((int )m_impl->inherits .size ()).str ();
1634
+ static std::regex marker (" @[[:digit:]]+" );
1635
+ std::sregex_iterator it (inheritLine.begin (),inheritLine.end (),marker);
1636
+ std::sregex_iterator end;
1637
+ size_t index=0 ;
1636
1638
// now replace all markers in inheritLine with links to the classes
1637
- while ((newIndex=marker. match (inheritLine,index,&matchLen))!=- 1 )
1639
+ for ( ; it!=end ; ++it )
1638
1640
{
1639
- ol.parseText (inheritLine.mid (index,newIndex-index));
1640
- bool ok;
1641
- uint entryIndex = inheritLine.mid (newIndex+1 ,matchLen-1 ).toUInt (&ok);
1642
- BaseClassDef &bcd=m_impl->inherits .at (entryIndex);
1643
- if (ok)
1641
+ const auto &match = *it;
1642
+ size_t newIndex = match.position ();
1643
+ size_t matchLen = match.length ();
1644
+ ol.parseText (inheritLine.substr (index,newIndex-index));
1645
+ unsigned long entryIndex = std::stoul (match.str ().substr (1 ));
1646
+ if (entryIndex<(unsigned long )m_impl->inherits .size ())
1644
1647
{
1648
+ BaseClassDef &bcd=m_impl->inherits [entryIndex];
1645
1649
ClassDef *cd=bcd.classDef ;
1646
1650
1647
1651
// use the class name but with the template arguments as given
@@ -1663,30 +1667,34 @@ void ClassDefImpl::writeInheritanceGraph(OutputList &ol) const
1663
1667
}
1664
1668
else
1665
1669
{
1666
- err (" invalid marker %d in inherits list!\n " ,entryIndex);
1670
+ err (" invalid marker %zu in inherits list!\n " ,entryIndex);
1667
1671
}
1668
1672
index=newIndex+matchLen;
1669
1673
}
1670
- ol.parseText (inheritLine.right (inheritLine. length ()-(uint) index));
1674
+ ol.parseText (inheritLine.substr ( index));
1671
1675
ol.endParagraph ();
1672
1676
}
1673
1677
1674
1678
// write subclasses
1675
1679
if (!m_impl->inheritedBy .empty ())
1676
1680
{
1677
1681
ol.startParagraph ();
1678
- QCString inheritLine = theTranslator->trInheritedByList ((int )m_impl->inheritedBy .size ());
1679
- QRegExp marker (" @[0-9]+" );
1680
- int index=0 ,newIndex,matchLen;
1682
+ std::string inheritLine = theTranslator->trInheritedByList ((int )m_impl->inheritedBy .size ()).str ();
1683
+ static std::regex marker (" @[[:digit:]]+" );
1684
+ std::sregex_iterator it (inheritLine.begin (),inheritLine.end (),marker);
1685
+ std::sregex_iterator end;
1686
+ size_t index=0 ;
1681
1687
// now replace all markers in inheritLine with links to the classes
1682
- while ((newIndex=marker. match (inheritLine,index,&matchLen))!=- 1 )
1688
+ for ( ; it!=end ; ++it )
1683
1689
{
1684
- ol.parseText (inheritLine.mid (index,newIndex-index));
1685
- bool ok;
1686
- uint entryIndex = inheritLine.mid (newIndex+1 ,matchLen-1 ).toUInt (&ok);
1687
- BaseClassDef &bcd=m_impl->inheritedBy .at (entryIndex);
1688
- if (ok)
1690
+ const auto &match = *it;
1691
+ size_t newIndex = match.position ();
1692
+ size_t matchLen = match.length ();
1693
+ ol.parseText (inheritLine.substr (index,newIndex-index));
1694
+ unsigned long entryIndex = std::stoul (match.str ().substr (1 ));
1695
+ if (entryIndex<(unsigned long )m_impl->inherits .size ())
1689
1696
{
1697
+ BaseClassDef &bcd=m_impl->inheritedBy [entryIndex];
1690
1698
ClassDef *cd=bcd.classDef ;
1691
1699
if (cd->isLinkable ())
1692
1700
{
@@ -1698,9 +1706,13 @@ void ClassDefImpl::writeInheritanceGraph(OutputList &ol) const
1698
1706
}
1699
1707
writeInheritanceSpecifier (ol,bcd);
1700
1708
}
1709
+ else
1710
+ {
1711
+ err (" invalid marker %zu in inheritedBy list!\n " ,entryIndex);
1712
+ }
1701
1713
index=newIndex+matchLen;
1702
1714
}
1703
- ol.parseText (inheritLine.right (inheritLine. length ()-(uint) index));
1715
+ ol.parseText (inheritLine.substr ( index));
1704
1716
ol.endParagraph ();
1705
1717
}
1706
1718
0 commit comments